Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 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 @@ -60,6 +60,7 @@ AtomicProductSectionVisual,
AtomicProductTemplate,
AtomicProductText,
AtomicQuerySummary,
AtomicResultTemplate,
AtomicResultsPerPage,
AtomicSearchBoxInstantResults,
AtomicSearchBoxQuerySuggestions,
Expand Down Expand Up @@ -129,7 +130,6 @@ AtomicResultSectionExcerpt,
AtomicResultSectionTitle,
AtomicResultSectionTitleMetadata,
AtomicResultSectionVisual,
AtomicResultTemplate,
AtomicResultText,
AtomicResultTimespan,
AtomicSearchBox,
Expand Down Expand Up @@ -205,6 +205,7 @@ AtomicProductSectionVisual,
AtomicProductTemplate,
AtomicProductText,
AtomicQuerySummary,
AtomicResultTemplate,
AtomicResultsPerPage,
AtomicSearchBoxInstantResults,
AtomicSearchBoxQuerySuggestions,
Expand Down Expand Up @@ -274,7 +275,6 @@ AtomicResultSectionExcerpt,
AtomicResultSectionTitle,
AtomicResultSectionTitleMetadata,
AtomicResultSectionVisual,
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 @@ -2193,37 +2193,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 @@ -3848,17 +3817,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 @@ -4283,7 +4241,6 @@ declare global {
"atomic-result-section-title-metadata": HTMLAtomicResultSectionTitleMetadataElement;
"atomic-result-section-visual": HTMLAtomicResultSectionVisualElement;
"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 @@ -6395,33 +6352,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 @@ -6994,7 +6924,6 @@ declare namespace LocalJSX {
"atomic-result-section-title-metadata": AtomicResultSectionTitleMetadata;
"atomic-result-section-visual": AtomicResultSectionVisual;
"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 @@ -7476,12 +7405,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
@@ -0,0 +1,117 @@
import { Meta } from '@storybook/addon-docs/blocks';
import * as AtomicResultTemplateStories from './atomic-result-template.new.stories';
import { AtomicDocTemplate } from '../../../../storybook-utils/documentation/atomic-doc-template';


<Meta of={AtomicResultTemplateStories} />

<AtomicDocTemplate
stories={AtomicResultTemplateStories}
defaultStory="Default"
githubPath="search/atomic-result-template/atomic-result-template.ts"
tagName="atomic-result-template"
className="AtomicResultTemplate"
>

This component defines the UI display of your search results.
It can be used inside `atomic-result-list`, `atomic-folded-result-list`, or `atomic-search-box-instant-results`, and it must have a `<template>` as its child.

Example using the `atomic-result-list`:
```html
<atomic-result-list>
<atomic-result-template>
<template>
<atomic-result-section-visual>
<atomic-result-image field="ytthumbnailurl" fallback="https://picsum.photos/350"></atomic-result-image>
</atomic-result-section-visual>

<atomic-result-section-badges>
<atomic-field-condition must-match-sourcetype="YouTube">
<atomic-result-badge
label="YouTube"
class="youtube-badge"
></atomic-result-badge>
</atomic-field-condition>

<atomic-result-badge
icon="https://raw.githubusercontent.com/Rush/Font-Awesome-SVG-PNG/master/black/svg/language.svg"
>
<atomic-result-multi-value-text
field="language"
></atomic-result-multi-value-text>
</atomic-result-badge>
</atomic-result-section-badges>

<atomic-result-section-title>
<atomic-result-link></atomic-result-link>
</atomic-result-section-title>

<atomic-result-section-excerpt>
<atomic-result-text field="excerpt"></atomic-result-text>
</atomic-result-section-excerpt>

<atomic-result-section-bottom-metadata>
<atomic-result-fields-list>
<atomic-field-condition class="field" if-defined="source">
<span class="field-label">
<atomic-text value="source"></atomic-text>:
</span>
<atomic-result-text field="source"></atomic-result-text>
</atomic-field-condition>

<atomic-field-condition class="field" if-defined="author">
<span class="field-label">
<atomic-text value="author"></atomic-text>:
</span>
<atomic-result-text field="author"></atomic-result-text>
</atomic-field-condition>

<atomic-field-condition class="field" if-defined="date">
<span class="field-label">
<atomic-text value="date"></atomic-text>:
</span>
<atomic-result-date></atomic-result-date>
</atomic-field-condition>
</atomic-result-fields-list>
</atomic-result-section-bottom-metadata>
</template>
</atomic-result-template>
</atomic-result-list>
```

## Template Conditions

You can use conditions to display different templates based on result properties:

```html
<atomic-result-list>
<!-- Template for YouTube videos -->
<atomic-result-template must-match-sourcetype="YouTube">
<template>
<atomic-result-section-visual>
<atomic-result-image field="ytthumbnailurl"></atomic-result-image>
</atomic-result-section-visual>
<atomic-result-section-title>
<atomic-result-link></atomic-result-link>
</atomic-result-section-title>
<atomic-result-section-excerpt>
<atomic-result-text field="excerpt"></atomic-result-text>
</atomic-result-section-excerpt>
</template>
</atomic-result-template>

<!-- Default template for all other results -->
<atomic-result-template>
<template>
<atomic-result-section-title>
<atomic-result-link></atomic-result-link>
</atomic-result-section-title>
<atomic-result-section-excerpt>
<atomic-result-text field="excerpt"></atomic-result-text>
</atomic-result-section-excerpt>
</template>
</atomic-result-template>
</atomic-result-list>
```

</AtomicDocTemplate>
Loading
Loading