Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7ef605d
changed file name
jmazzah-coveo Sep 30, 2025
397b0c5
migrated result template to Reactive controller
jmazzah-coveo Sep 30, 2025
6faf0f1
unit tests for result templace common and controller
jmazzah-coveo Sep 30, 2025
7547a67
naming
jmazzah-coveo Oct 1, 2025
c119e3b
Merge branch 'main' into KIT-4962
jmazzah-coveo Oct 1, 2025
d3113c3
moved table element utils to common package
jmazzah-coveo Oct 7, 2025
0bd8252
parent template controller for result and product templates
jmazzah-coveo Oct 7, 2025
56e23a1
product template inheriting from base template
jmazzah-coveo Oct 7, 2025
f0ccc24
result template inheriting from base template
jmazzah-coveo Oct 7, 2025
5006a54
removed utils from result and product template since they now use com…
jmazzah-coveo Oct 7, 2025
230ec88
template utils
jmazzah-coveo Oct 7, 2025
109fe7e
Merge branch 'main' into KIT-4962
jmazzah-coveo Oct 7, 2025
4a0ebd0
import errors
jmazzah-coveo Oct 7, 2025
0a89224
unnecessary snapshot file
jmazzah-coveo Oct 7, 2025
e649e42
import fix
jmazzah-coveo Oct 7, 2025
fb6feb1
atomic-product-template test fix to have right parameters for the new…
jmazzah-coveo Oct 7, 2025
795ee59
import fix
jmazzah-coveo Oct 7, 2025
09f4ba8
useless mock
jmazzah-coveo Oct 7, 2025
90fb011
migrated atomic-result-template to lit
jmazzah-coveo Oct 7, 2025
e3b0593
atomic-result-template unit tests
jmazzah-coveo Oct 9, 2025
d288ce6
Documentation
jmazzah-coveo Oct 10, 2025
f3c2d89
moved to search package
jmazzah-coveo Oct 14, 2025
8eec648
atomic result template documentation
jmazzah-coveo Oct 14, 2025
8294b84
tests fix
jmazzah-coveo Oct 14, 2025
bada99a
removed tsx file
jmazzah-coveo Oct 14, 2025
e28a96a
Merge branch 'main' into KIT-4963
jmazzah-coveo Oct 14, 2025
6fcffa7
Add generated files
developer-experience-bot[bot] Oct 14, 2025
196b4e0
e2e tests
jmazzah-coveo Oct 14, 2025
ba9c2f9
Merge branch 'KIT-4963' of https://github.com/coveo/ui-kit into KIT-4963
jmazzah-coveo Oct 14, 2025
350ce30
Merge branch 'main' into KIT-4963
jmazzah-coveo Oct 14, 2025
5eaa9c1
compilation error fix
jmazzah-coveo Oct 14, 2025
8839a48
test pr fix
jmazzah-coveo Oct 16, 2025
e2bf5b9
doc pr fix
jmazzah-coveo Oct 16, 2025
9259f9e
Doc fix
jmazzah-coveo Oct 17, 2025
29519a3
pr test fix
jmazzah-coveo Oct 17, 2025
aa78089
doc harmonizing
jmazzah-coveo Oct 20, 2025
c5d0b46
conditions documentation
jmazzah-coveo Oct 20, 2025
a304b57
Merge branch 'main' into KIT-4963
jmazzah-coveo Oct 21, 2025
8732abc
Merge branch 'main' into KIT-4963
jmazzah-coveo Oct 21, 2025
fa0625d
search interface wrapper fix
jmazzah-coveo Oct 21, 2025
b7873e6
Add generated files
developer-experience-bot[bot] Oct 21, 2025
739134f
Merge branch 'main' into KIT-4963
jmazzah-coveo Oct 21, 2025
5df9a4b
doc update
jmazzah-coveo Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ AtomicResultSectionExcerpt,
AtomicResultSectionTitle,
AtomicResultSectionTitleMetadata,
AtomicResultSectionVisual,
AtomicResultTemplate,
AtomicResultsPerPage,
AtomicSearchBoxInstantResults,
AtomicSearchBoxQuerySuggestions,
Expand Down Expand Up @@ -129,7 +130,6 @@ AtomicResultMultiValueText,
AtomicResultNumber,
AtomicResultPrintableUri,
AtomicResultRating,
AtomicResultTemplate,
AtomicResultText,
AtomicResultTimespan,
AtomicSearchBox,
Expand Down Expand Up @@ -214,6 +214,7 @@ AtomicResultSectionExcerpt,
AtomicResultSectionTitle,
AtomicResultSectionTitleMetadata,
AtomicResultSectionVisual,
AtomicResultTemplate,
AtomicResultsPerPage,
AtomicSearchBoxInstantResults,
AtomicSearchBoxQuerySuggestions,
Expand Down Expand Up @@ -274,7 +275,6 @@ AtomicResultMultiValueText,
AtomicResultNumber,
AtomicResultPrintableUri,
AtomicResultRating,
AtomicResultTemplate,
AtomicResultText,
AtomicResultTimespan,
AtomicSearchBox,
Expand Down

Large diffs are not rendered by default.

77 changes: 0 additions & 77 deletions packages/atomic/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2099,37 +2099,6 @@ export namespace Components {
"imageSize": ItemDisplayImageSize;
"rows": number;
}
/**
* A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template.
* @MapProp name: mustMatch;attr: must-match;docs: The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is `lithiummessage` or `YouTubePlaylist`: `must-match-filetype="lithiummessage,YouTubePlaylist"`;type: Record<string, string[]> ;default: {}
* @MapProp name: mustNotMatch;attr: must-not-match;docs: The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is not `lithiummessage`: `must-not-match-filetype="lithiummessage";type: Record<string, string[]> ;default: {}
*/
interface AtomicResultTemplate {
/**
* A function that must return true on results for the result template to apply. Set programmatically before initialization, not via attribute. For example, the following targets a template and sets a condition to make it apply only to results whose `title` contains `singapore`: `document.querySelector('#target-template').conditions = [(result) => /singapore/i.test(result.title)];`
*/
"conditions": ResultTemplateCondition[];
/**
* Gets the appropriate result template based on conditions applied.
*/
"getTemplate": () => Promise<ResultTemplate<DocumentFragment> | null>;
/**
* Verifies whether the specified fields match the specified values.
* @type {Record<string, string[]>}
*/
"mustMatch": Record<
string,
string[]
>;
/**
* Verifies whether the specified fields do not match the specified values.
* @type {Record<string, string[]>}
*/
"mustNotMatch": Record<
string,
string[]
>;
}
/**
* The `atomic-result-text` component renders the value of a string result field.
*/
Expand Down Expand Up @@ -3628,17 +3597,6 @@ declare global {
prototype: HTMLAtomicResultTablePlaceholderElement;
new (): HTMLAtomicResultTablePlaceholderElement;
};
/**
* A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template.
* @MapProp name: mustMatch;attr: must-match;docs: The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is `lithiummessage` or `YouTubePlaylist`: `must-match-filetype="lithiummessage,YouTubePlaylist"`;type: Record<string, string[]> ;default: {}
* @MapProp name: mustNotMatch;attr: must-not-match;docs: The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is not `lithiummessage`: `must-not-match-filetype="lithiummessage";type: Record<string, string[]> ;default: {}
*/
interface HTMLAtomicResultTemplateElement extends Components.AtomicResultTemplate, HTMLStencilElement {
}
var HTMLAtomicResultTemplateElement: {
prototype: HTMLAtomicResultTemplateElement;
new (): HTMLAtomicResultTemplateElement;
};
/**
* The `atomic-result-text` component renders the value of a string result field.
*/
Expand Down Expand Up @@ -4054,7 +4012,6 @@ declare global {
"atomic-result-printable-uri": HTMLAtomicResultPrintableUriElement;
"atomic-result-rating": HTMLAtomicResultRatingElement;
"atomic-result-table-placeholder": HTMLAtomicResultTablePlaceholderElement;
"atomic-result-template": HTMLAtomicResultTemplateElement;
"atomic-result-text": HTMLAtomicResultTextElement;
"atomic-result-timespan": HTMLAtomicResultTimespanElement;
"atomic-search-box": HTMLAtomicSearchBoxElement;
Expand Down Expand Up @@ -6072,33 +6029,6 @@ declare namespace LocalJSX {
"imageSize": ItemDisplayImageSize;
"rows": number;
}
/**
* A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template.
* @MapProp name: mustMatch;attr: must-match;docs: The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is `lithiummessage` or `YouTubePlaylist`: `must-match-filetype="lithiummessage,YouTubePlaylist"`;type: Record<string, string[]> ;default: {}
* @MapProp name: mustNotMatch;attr: must-not-match;docs: The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is not `lithiummessage`: `must-not-match-filetype="lithiummessage";type: Record<string, string[]> ;default: {}
*/
interface AtomicResultTemplate {
/**
* A function that must return true on results for the result template to apply. Set programmatically before initialization, not via attribute. For example, the following targets a template and sets a condition to make it apply only to results whose `title` contains `singapore`: `document.querySelector('#target-template').conditions = [(result) => /singapore/i.test(result.title)];`
*/
"conditions"?: ResultTemplateCondition[];
/**
* Verifies whether the specified fields match the specified values.
* @type {Record<string, string[]>}
*/
"mustMatch"?: Record<
string,
string[]
>;
/**
* Verifies whether the specified fields do not match the specified values.
* @type {Record<string, string[]>}
*/
"mustNotMatch"?: Record<
string,
string[]
>;
}
/**
* The `atomic-result-text` component renders the value of a string result field.
*/
Expand Down Expand Up @@ -6662,7 +6592,6 @@ declare namespace LocalJSX {
"atomic-result-printable-uri": AtomicResultPrintableUri;
"atomic-result-rating": AtomicResultRating;
"atomic-result-table-placeholder": AtomicResultTablePlaceholder;
"atomic-result-template": AtomicResultTemplate;
"atomic-result-text": AtomicResultText;
"atomic-result-timespan": AtomicResultTimespan;
"atomic-search-box": AtomicSearchBox;
Expand Down Expand Up @@ -7063,12 +6992,6 @@ declare module "@stencil/core" {
* The `atomic-result-table-placeholder` component provides an intermediate visual state that is rendered before the first results are available.
*/
"atomic-result-table-placeholder": LocalJSX.AtomicResultTablePlaceholder & JSXBase.HTMLAttributes<HTMLAtomicResultTablePlaceholderElement>;
/**
* A [result template](https://docs.coveo.com/en/atomic/latest/usage/displaying-results#defining-a-result-template) determines the format of the query results, depending on the conditions that are defined for each template.
* @MapProp name: mustMatch;attr: must-match;docs: The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is `lithiummessage` or `YouTubePlaylist`: `must-match-filetype="lithiummessage,YouTubePlaylist"`;type: Record<string, string[]> ;default: {}
* @MapProp name: mustNotMatch;attr: must-not-match;docs: The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose `filetype` is not `lithiummessage`: `must-not-match-filetype="lithiummessage";type: Record<string, string[]> ;default: {}
*/
"atomic-result-template": LocalJSX.AtomicResultTemplate & JSXBase.HTMLAttributes<HTMLAtomicResultTemplateElement>;
/**
* The `atomic-result-text` component renders the value of a string result field.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { AtomicDocTemplate } from '../../../../storybook-utils/documentation/ato
>

This component defines the UI display of your products.
It can be used inside `atomic-commerce-product-list`, `atomic-commerce-recommendation-list`, or `atomic-search-box-instant-products`, and it must have a `<template>` as its child.
A `template` element must be the child of an `atomic-product-template`. Furthermore, an `atomic-commerce-product-list`, `atomic-commerce-recommendation-list`, or `atomic-commerce-search-box-instant-products` must be the parent of each `atomic-product-template`.
* **Note:** Any `<script>` tags that are defined inside a `<template>` element will not be executed when the products are being rendered.

Example using the `atomic-commerce-product-list`:
```html
Expand Down Expand Up @@ -53,5 +54,110 @@ Example using the `atomic-commerce-product-list`:
</atomic-commerce-product-list>
```

## Template Conditions

You can use conditions to display different templates based on product properties. You can specify as many `must-match-*` and `must-not-match-*` attributes as you want on a template, each targeting a different field. Each attribute can accept multiple comma-separated values.

**Comma represents OR:** Within a single attribute, comma-separated values represent a logical OR. For example, `must-match-ec_brand="Nike,Adidas"` means the brand must be Nike OR Adidas.

**Multiple attributes represent AND:** All conditions from different attributes must be met (logical AND) for the template to apply to a product.

If you set both `must-match-*` and `must-not-match-*` for the same field and there is any overlap in values, the template will be ignored (it will never match any product).

**Order of declaration matters:** The first template whose conditions are met will be applied. If a default template (without conditions) is declared first, it will apply to all products, even if other templates with conditions are declared later.

**Examples:**

```html
<!-- Template applies if brand is Nike or Adidas, and product is in stock -->
<atomic-product-template
must-match-ec_brand="Nike,Adidas"
must-match-ec_in_stock="true"
>
<template>
<!-- ... -->
</template>
</atomic-product-template>

<!-- This template will never apply, because the same value is required and forbidden -->
<atomic-product-template
must-match-ec_brand="Nike"
must-not-match-ec_brand="Nike"
>
<template>
<!-- ... -->
</template>
</atomic-product-template>
```

```html
<atomic-commerce-product-list>
<!-- Template for luxury brands -->
<atomic-product-template must-match-ec_brand="Gucci,Prada,Louis Vuitton">
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold text-gold"></atomic-product-link>
</atomic-product-section-name>

<atomic-product-section-metadata>
<atomic-product-text field="ec_brand" class="block text-luxury-gold"></atomic-product-text>
<span class="luxury-badge">✨ Luxury</span>
</atomic-product-section-metadata>

<atomic-product-section-emphasized>
<atomic-product-price currency="USD" class="text-gold"></atomic-product-price>
</atomic-product-section-emphasized>
</template>
</atomic-product-template>

<!-- Template for out-of-stock products -->
<atomic-product-template must-match-ec_in_stock="false">
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold opacity-60"></atomic-product-link>
</atomic-product-section-name>

<atomic-product-section-metadata>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
</atomic-product-field-condition>
<span class="out-of-stock-badge text-red-600">Out of Stock</span>
</atomic-product-section-metadata>

<atomic-product-section-emphasized>
<atomic-product-price currency="USD" class="opacity-60"></atomic-product-price>
</atomic-product-section-emphasized>
</template>
</atomic-product-template>

<!-- Default template for all other products -->
<atomic-product-template>
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold"></atomic-product-link>
</atomic-product-section-name>

<atomic-product-section-metadata>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
</atomic-product-field-condition>

<atomic-product-field-condition if-defined="ec_rating">
<atomic-product-rating field="ec_rating"></atomic-product-rating>
</atomic-product-field-condition>
</atomic-product-section-metadata>

<atomic-product-section-description>
<atomic-product-text field="excerpt" class="block text-neutral-dark"></atomic-product-text>
</atomic-product-section-description>

<atomic-product-section-emphasized>
<atomic-product-price currency="USD"></atomic-product-price>
</atomic-product-section-emphasized>
</template>
</atomic-product-template>
</atomic-commerce-product-list>
```

</AtomicDocTemplate>

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import '../atomic-product/atomic-product';
import {arrayConverter} from '@/src/converters/array-converter';

/**
* * A product template determines the format of the products, depending on the conditions that are defined for each template.
* A product template determines the format of the products, depending on the conditions that are defined for each template.
*
* A `template` element must be the child of an `atomic-product-template`. Furthermore, an `atomic-commerce-product-list`, `atomic-commerce-recommendation-list`, or `atomic-commerce-search-box-instant-products` must be the parent of each `atomic-product-template`.
*
* **Note:** Any `<script>` tags that are defined inside a `<template>` element will not be executed when the products are being rendered.
* @MapProp name: mustMatch;attr: must-match;docs: The field and values that must be matched by a product item for the template to apply. For example, a template with the following attribute only applies to product items whose `filetype` is `lithiummessage` or `YouTubePlaylist`: `must-match-filetype="lithiummessage,YouTubePlaylist"`;type: Record<string, string[]> ;default: {}
* @MapProp name: mustNotMatch;attr: must-not-match;docs: The field and values that must not be matched by a product item for the template to apply. For example, a template with the following attribute only applies to product items whose `filetype` is not `lithiummessage`: `must-not-match-filetype="lithiummessage";type: Record<string, string[]> ;default: {}
* @slot default - The default slot where to insert the template element.
Expand Down
Loading