@coveo/atomic 3.33.8-pre.a40e031589 → 3.33.8-pre.a42c491ac0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/components/_index.js +2 -1
- package/dist/atomic/components/analytics-config.js +1 -1
- package/dist/atomic/components/atomic-category-facet.js +1 -1
- package/dist/atomic/components/atomic-facet.js +1 -1
- package/dist/atomic/components/atomic-format-currency.js +1 -1
- package/dist/atomic/components/atomic-format-number.js +1 -1
- package/dist/atomic/components/atomic-format-unit.js +1 -1
- package/dist/atomic/components/atomic-insight-search-box.js +3 -4
- package/dist/atomic/components/atomic-insight-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-numeric-facet.js +1 -1
- package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
- package/dist/atomic/components/atomic-quickview.js +1 -1
- package/dist/atomic/components/atomic-result-children.js +1 -1
- package/dist/atomic/components/atomic-result-fields-list.js +1 -1
- package/dist/atomic/components/atomic-result-link.js +1 -1
- package/dist/atomic/components/atomic-result-list.js +1 -1
- package/dist/atomic/components/atomic-search-box-instant-results.js +2 -2
- package/dist/atomic/components/atomic-search-box-instant-results.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +2 -2
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +2 -2
- package/dist/atomic/components/atomic-search-box-recent-queries2.js.map +1 -1
- package/dist/atomic/components/atomic-search-box.js +5 -17
- package/dist/atomic/components/atomic-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
- package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
- package/dist/atomic/components/atomic-sort-expression.js +1 -1
- package/dist/atomic/components/atomic-suggestion-renderer2.js +1 -1
- package/dist/atomic/components/atomic-suggestion-renderer2.js.map +1 -1
- package/dist/atomic/components/atomic-tab-manager.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +49 -7
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +25 -10
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +6 -14
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.js +1 -1
- package/dist/atomic/components/components/common/suggestions/suggestion-manager.js +1 -1
- package/dist/atomic/components/components/common/suggestions/{suggestions-common.js → suggestions-events.js} +16 -18
- package/dist/atomic/components/components/common/suggestions/suggestions-types.js +1 -0
- package/dist/atomic/components/components/common/suggestions/suggestions-utils.js +18 -0
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/components/stencil-query-suggestions.js.map +1 -1
- package/dist/atomic/components/stencil-suggestion-manager.js +20 -2
- package/dist/atomic/components/stencil-suggestion-manager.js.map +1 -1
- package/dist/atomic/components/{suggestions-common.js → suggestions-events.js} +18 -20
- package/dist/atomic/components/suggestions-events.js.map +1 -0
- package/dist/atomic/index.esm.js +1 -1
- package/dist/atomic/index.esm.js.map +1 -1
- package/dist/atomic/p-0a051b8d.js +2 -0
- package/dist/atomic/p-0a051b8d.js.map +1 -0
- package/dist/atomic/p-16f4ce98.js +2 -0
- package/dist/atomic/p-16f4ce98.js.map +1 -0
- package/dist/atomic/{p-8867af82.entry.js → p-26a51a77.entry.js} +2 -2
- package/dist/atomic/p-26a51a77.entry.js.map +1 -0
- package/dist/atomic/{p-1f22292a.entry.js → p-31f1e44e.entry.js} +2 -2
- package/dist/atomic/p-31f1e44e.entry.js.map +1 -0
- package/dist/atomic/{p-9c9b1965.entry.js → p-330e6e7c.entry.js} +2 -2
- package/dist/atomic/{p-8f8da1ef.js → p-3ae7d4d8.js} +2 -2
- package/dist/atomic/{p-b7063a0d.entry.js → p-3c8d109e.entry.js} +2 -2
- package/dist/atomic/{p-09a3a067.entry.js → p-4b3d253b.entry.js} +2 -2
- package/dist/atomic/p-4b7a19db.js +2 -0
- package/dist/atomic/p-4b7a19db.js.map +1 -0
- package/dist/atomic/{p-49c38b27.entry.js → p-52ba404c.entry.js} +2 -2
- package/dist/atomic/{p-089be992.entry.js → p-75e00690.entry.js} +2 -2
- package/dist/atomic/{p-a8882a2a.entry.js → p-78b70622.entry.js} +2 -2
- package/dist/atomic/{p-2ce8220a.entry.js → p-7a625c7e.entry.js} +2 -2
- package/dist/atomic/{p-f289269f.entry.js → p-7b0b9e9b.entry.js} +2 -2
- package/dist/atomic/{p-1d1f54a5.entry.js → p-7b899b57.entry.js} +2 -2
- package/dist/atomic/{p-3b023e83.entry.js → p-877d35b1.entry.js} +2 -2
- package/dist/atomic/{p-4b1fecf5.entry.js → p-9383d0d3.entry.js} +2 -2
- package/dist/atomic/{p-4718485f.entry.js → p-9d6d0631.entry.js} +2 -2
- package/dist/atomic/{p-7e2109e9.entry.js → p-a760d9f9.entry.js} +2 -2
- package/dist/atomic/{p-89ab44de.entry.js → p-aa2a81fd.entry.js} +2 -2
- package/dist/atomic/p-af93b44c.js.map +1 -1
- package/dist/atomic/{p-89085429.entry.js → p-b28011e6.entry.js} +2 -2
- package/dist/atomic/{p-fda26113.entry.js → p-c49cfa0c.entry.js} +2 -2
- package/dist/atomic/{p-11ff1517.entry.js → p-c6eca514.entry.js} +2 -2
- package/dist/atomic/p-c88a3d2d.entry.js +2 -0
- package/dist/atomic/p-c88a3d2d.entry.js.map +1 -0
- package/dist/atomic/{p-5f1fa581.entry.js → p-d00a12e9.entry.js} +2 -2
- package/dist/atomic/{p-36e71b99.entry.js → p-d0f47b33.entry.js} +2 -2
- package/dist/atomic/p-d0f47b33.entry.js.map +1 -0
- package/dist/atomic/{p-b6963bae.entry.js → p-f22bcb8c.entry.js} +2 -2
- package/dist/atomic/{p-aa4224ea.entry.js → p-fbfe913d.entry.js} +2 -2
- package/dist/atomic/p-fbfe913d.entry.js.map +1 -0
- package/dist/cjs/_index.cjs.js +5 -2
- package/dist/cjs/{analytics-config-25d3be01.js → analytics-config-e2beaf7f.js} +2 -2
- package/dist/cjs/{analytics-config-25d3be01.js.map → analytics-config-e2beaf7f.js.map} +1 -1
- package/dist/cjs/atomic-category-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js +5 -5
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-numeric-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js +3 -3
- package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +5 -5
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-box.cjs.entry.js +7 -18
- package/dist/cjs/atomic-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
- package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js +1 -1
- package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/stencil-query-suggestions-03268ecc.js.map +1 -1
- package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js → stencil-suggestion-manager-2cba6d69.js} +4 -4
- package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js.map → stencil-suggestion-manager-2cba6d69.js.map} +1 -1
- package/dist/cjs/{suggestions-common-5097a362.js → suggestions-events-63dd0640.js} +17 -21
- package/dist/cjs/suggestions-events-63dd0640.js.map +1 -0
- package/dist/cjs/suggestions-utils-61000808.js +25 -0
- package/dist/cjs/suggestions-utils-61000808.js.map +1 -0
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_index.js +2 -1
- package/dist/esm/{analytics-config-db964380.js → analytics-config-75896191.js} +2 -2
- package/dist/esm/{analytics-config-db964380.js.map → analytics-config-75896191.js.map} +1 -1
- package/dist/esm/atomic-category-facet.entry.js +1 -1
- package/dist/esm/atomic-facet.entry.js +1 -1
- package/dist/esm/atomic-format-currency.entry.js +1 -1
- package/dist/esm/atomic-format-number.entry.js +1 -1
- package/dist/esm/atomic-format-unit.entry.js +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-insight-search-box.entry.js +4 -4
- package/dist/esm/atomic-insight-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-numeric-facet.entry.js +1 -1
- package/dist/esm/atomic-quickview-modal.entry.js +1 -1
- package/dist/esm/atomic-quickview.entry.js +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/atomic-result-children.entry.js +1 -1
- package/dist/esm/atomic-result-fields-list.entry.js +1 -1
- package/dist/esm/atomic-result-link.entry.js +1 -1
- package/dist/esm/atomic-result-list.entry.js +1 -1
- package/dist/esm/atomic-search-box-instant-results.entry.js +2 -2
- package/dist/esm/atomic-search-box-instant-results.entry.js.map +1 -1
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +3 -3
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js.map +1 -1
- package/dist/esm/atomic-search-box.entry.js +6 -17
- package/dist/esm/atomic-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-search-interface.entry.js +1 -1
- package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
- package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
- package/dist/esm/atomic-sort-expression.entry.js +1 -1
- package/dist/esm/atomic-suggestion-renderer.entry.js +1 -1
- package/dist/esm/atomic-suggestion-renderer.entry.js.map +1 -1
- package/dist/esm/atomic-tab-manager.entry.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stencil-query-suggestions-5d6a46d7.js.map +1 -1
- package/dist/esm/{stencil-suggestion-manager-486094dd.js → stencil-suggestion-manager-376f83e8.js} +2 -2
- package/dist/esm/{stencil-suggestion-manager-486094dd.js.map → stencil-suggestion-manager-376f83e8.js.map} +1 -1
- package/dist/esm/{suggestions-common-2b20db26.js → suggestions-events-b7a6f007.js} +18 -20
- package/dist/esm/suggestions-events-b7a6f007.js.map +1 -0
- package/dist/esm/suggestions-utils-591559a0.js +22 -0
- package/dist/esm/suggestions-utils-591559a0.js.map +1 -0
- package/dist/esm/version.js +2 -2
- package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +29 -1
- package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +1 -0
- package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +0 -1
- package/dist/types/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.d.ts +1 -1
- package/dist/types/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.d.ts +1 -1
- package/dist/types/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.d.ts +1 -1
- package/dist/types/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.d.ts +1 -1
- package/dist/types/components/common/suggestions/instant-item.d.ts +1 -1
- package/dist/types/components/common/suggestions/query-suggestions.d.ts +1 -1
- package/dist/types/components/common/suggestions/recent-queries.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-instant-item.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-query-suggestions.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-recent-queries.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-suggestion-manager.d.ts +1 -1
- package/dist/types/components/common/suggestions/suggestion-manager.d.ts +1 -1
- package/dist/types/components/common/suggestions/suggestions-events.d.ts +14 -0
- package/dist/types/components/common/suggestions/{suggestions-common.d.ts → suggestions-types.d.ts} +6 -16
- package/dist/types/components/common/suggestions/suggestions-utils.d.ts +15 -0
- package/dist/types/components/search/atomic-search-box/atomic-search-box.d.ts +1 -2
- package/dist/types/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.d.ts +1 -1
- package/dist/types/components.d.ts +2 -2
- package/dist/types/decorators/types.d.ts +1 -1
- package/dist/types/index.d.ts +3 -1
- package/docs/atomic-docs.json +3 -3
- package/package.json +3 -3
- package/dist/atomic/components/suggestions-common.js.map +0 -1
- package/dist/atomic/p-1f22292a.entry.js.map +0 -1
- package/dist/atomic/p-29fd6768.js +0 -2
- package/dist/atomic/p-29fd6768.js.map +0 -1
- package/dist/atomic/p-36e71b99.entry.js.map +0 -1
- package/dist/atomic/p-7601c3de.js +0 -2
- package/dist/atomic/p-7601c3de.js.map +0 -1
- package/dist/atomic/p-8867af82.entry.js.map +0 -1
- package/dist/atomic/p-aa4224ea.entry.js.map +0 -1
- package/dist/atomic/p-ae6c5f54.entry.js +0 -2
- package/dist/atomic/p-ae6c5f54.entry.js.map +0 -1
- package/dist/cjs/suggestions-common-5097a362.js.map +0 -1
- package/dist/esm/suggestions-common-2b20db26.js.map +0 -1
- /package/dist/atomic/{p-9c9b1965.entry.js.map → p-330e6e7c.entry.js.map} +0 -0
- /package/dist/atomic/{p-8f8da1ef.js.map → p-3ae7d4d8.js.map} +0 -0
- /package/dist/atomic/{p-b7063a0d.entry.js.map → p-3c8d109e.entry.js.map} +0 -0
- /package/dist/atomic/{p-09a3a067.entry.js.map → p-4b3d253b.entry.js.map} +0 -0
- /package/dist/atomic/{p-49c38b27.entry.js.map → p-52ba404c.entry.js.map} +0 -0
- /package/dist/atomic/{p-089be992.entry.js.map → p-75e00690.entry.js.map} +0 -0
- /package/dist/atomic/{p-a8882a2a.entry.js.map → p-78b70622.entry.js.map} +0 -0
- /package/dist/atomic/{p-2ce8220a.entry.js.map → p-7a625c7e.entry.js.map} +0 -0
- /package/dist/atomic/{p-f289269f.entry.js.map → p-7b0b9e9b.entry.js.map} +0 -0
- /package/dist/atomic/{p-1d1f54a5.entry.js.map → p-7b899b57.entry.js.map} +0 -0
- /package/dist/atomic/{p-3b023e83.entry.js.map → p-877d35b1.entry.js.map} +0 -0
- /package/dist/atomic/{p-4b1fecf5.entry.js.map → p-9383d0d3.entry.js.map} +0 -0
- /package/dist/atomic/{p-4718485f.entry.js.map → p-9d6d0631.entry.js.map} +0 -0
- /package/dist/atomic/{p-7e2109e9.entry.js.map → p-a760d9f9.entry.js.map} +0 -0
- /package/dist/atomic/{p-89ab44de.entry.js.map → p-aa2a81fd.entry.js.map} +0 -0
- /package/dist/atomic/{p-89085429.entry.js.map → p-b28011e6.entry.js.map} +0 -0
- /package/dist/atomic/{p-fda26113.entry.js.map → p-c49cfa0c.entry.js.map} +0 -0
- /package/dist/atomic/{p-11ff1517.entry.js.map → p-c6eca514.entry.js.map} +0 -0
- /package/dist/atomic/{p-5f1fa581.entry.js.map → p-d00a12e9.entry.js.map} +0 -0
- /package/dist/atomic/{p-b6963bae.entry.js.map → p-f22bcb8c.entry.js.map} +0 -0
@@ -1,6 +1,22 @@
|
|
1
1
|
import { c as closest } from './dom-utils-f6086cd3.js';
|
2
2
|
import { b as buildCustomEvent } from './event-utils-8de63ec3.js';
|
3
3
|
|
4
|
+
/**
|
5
|
+
* Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
|
6
|
+
*
|
7
|
+
* @param event Event sent from the registered query suggestions to the parent search box
|
8
|
+
* @param element Element on which to dispatch the event, which must be the child of a configured search box
|
9
|
+
* @param allowedSearchBoxElements Optional array of allowed search box element selectors
|
10
|
+
*
|
11
|
+
* @throws Error if the element is not a child of an allowed search box element
|
12
|
+
*/
|
13
|
+
const dispatchSearchBoxSuggestionsEvent = (event, element, allowedSearchBoxElements = searchBoxElements) => {
|
14
|
+
const interfaceElement = closest(element, searchBoxElements.join(', '));
|
15
|
+
if (!interfaceElement) {
|
16
|
+
throw new Error(`The "${element.nodeName.toLowerCase()}" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(', ')}`);
|
17
|
+
}
|
18
|
+
void dispatchSearchBoxSuggestionsEventEventually(interfaceElement, element, event);
|
19
|
+
};
|
4
20
|
const searchBoxElements = [
|
5
21
|
'atomic-search-box',
|
6
22
|
'atomic-insight-search-box',
|
@@ -18,25 +34,7 @@ const dispatchSearchBoxSuggestionsEventEventually = async (interfaceElement, ele
|
|
18
34
|
}
|
19
35
|
element.dispatchEvent(buildCustomEvent('atomic/searchBoxSuggestion/register', event));
|
20
36
|
};
|
21
|
-
/**
|
22
|
-
* Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
|
23
|
-
* @param event Event sent from the registered query suggestions to the parent search box.
|
24
|
-
* @param element Element on which to dispatch the event, which must be the child of a configured search box.
|
25
|
-
*/
|
26
|
-
const dispatchSearchBoxSuggestionsEvent = (event, element, allowedSearchBoxElements = searchBoxElements) => {
|
27
|
-
const interfaceElement = closest(element, searchBoxElements.join(', '));
|
28
|
-
if (!interfaceElement) {
|
29
|
-
throw new Error(`The "${element.nodeName.toLowerCase()}" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(', ')}`);
|
30
|
-
}
|
31
|
-
void dispatchSearchBoxSuggestionsEventEventually(interfaceElement, element, event);
|
32
|
-
};
|
33
|
-
function elementHasNoQuery(el) {
|
34
|
-
return !el.query || el.query.trim() === '';
|
35
|
-
}
|
36
|
-
function elementHasQuery(el) {
|
37
|
-
return !!el.query && el.query.trim() !== '';
|
38
|
-
}
|
39
37
|
|
40
|
-
export {
|
38
|
+
export { dispatchSearchBoxSuggestionsEvent as d };
|
41
39
|
|
42
|
-
//# sourceMappingURL=suggestions-
|
40
|
+
//# sourceMappingURL=suggestions-events-b7a6f007.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"suggestions-events-b7a6f007.js","mappings":";;;AAOA;;;;;;;;;MASa,iCAAiC,GAAG,CAI/C,KAA+D,EAC/D,OAAoB,EACpB,2BAA0E,iBAAiB;IAE3F,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,QAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,gFAAgF,wBAAwB,CAAC,IAAI,CACjJ,IAAI,CACL,EAAE,CACJ,CAAC;KACH;IACD,KAAK,2CAA2C,CAC9C,gBAAgB,EAChB,OAAO,EACP,KAAK,CACN,CAAC;AACJ,EAAE;AAEF,MAAM,iBAAiB,GAAG;IACxB,mBAAmB;IACnB,2BAA2B;IAC3B,4BAA4B;CACpB,CAAC;AAEX,MAAM,mBAAmB,GAAG,CAAC,SAAkB,KAC7C,gBAAgB,IAAK,SAAwB;IAC5C,SAAwB,CAAC,cAAc,YAAY,OAAO,CAAC;AAE9D,MAAM,2CAA2C,GAAG,OAIlD,gBAAyB,EACzB,OAAoB,EACpB,KAA+D;IAE/D,MAAM,cAAc,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1E,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,EAAE;QACzC,MAAM,gBAAgB,CAAC,cAAc,CAAC;KACvC;SAAM,IAAI,kBAAkB,IAAI,gBAAgB,EAAE;QACjD,MAAO,gBAAuC,CAAC,gBAAgB,EAAE,CAAC;KACnE;IACD,OAAO,CAAC,aAAa,CACnB,gBAAgB,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAC/D,CAAC;AACJ,CAAC;;;;","names":[],"sources":["src/components/common/suggestions/suggestions-events.ts"],"sourcesContent":["import type {HTMLStencilElement} from '@stencil/core/internal';\nimport type {LitElement} from 'lit';\nimport {closest} from '../../../utils/dom-utils';\nimport {buildCustomEvent} from '../../../utils/event-utils';\nimport type {AnyBindings} from '../interface/bindings';\nimport type {SearchBoxSuggestionsEvent} from './suggestions-types';\n\n/**\n * Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.\n *\n * @param event Event sent from the registered query suggestions to the parent search box\n * @param element Element on which to dispatch the event, which must be the child of a configured search box\n * @param allowedSearchBoxElements Optional array of allowed search box element selectors\n *\n * @throws Error if the element is not a child of an allowed search box element\n */\nexport const dispatchSearchBoxSuggestionsEvent = <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>,\n element: HTMLElement,\n allowedSearchBoxElements: readonly (typeof searchBoxElements)[number][] = searchBoxElements\n) => {\n const interfaceElement = closest(element, searchBoxElements.join(', '));\n if (!interfaceElement) {\n throw new Error(\n `The \"${element.nodeName.toLowerCase()}\" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(\n ', '\n )}`\n );\n }\n void dispatchSearchBoxSuggestionsEventEventually(\n interfaceElement,\n element,\n event\n );\n};\n\nconst searchBoxElements = [\n 'atomic-search-box',\n 'atomic-insight-search-box',\n 'atomic-commerce-search-box',\n] as const;\n\nconst isLitElementLoosely = (candidate: unknown): candidate is LitElement =>\n 'updateComplete' in (candidate as LitElement) &&\n (candidate as LitElement).updateComplete instanceof Promise;\n\nconst dispatchSearchBoxSuggestionsEventEventually = async <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n interfaceElement: Element,\n element: HTMLElement,\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>\n) => {\n await customElements.whenDefined(interfaceElement.nodeName.toLowerCase());\n if (isLitElementLoosely(interfaceElement)) {\n await interfaceElement.updateComplete;\n } else if ('componentOnReady' in interfaceElement) {\n await (interfaceElement as HTMLStencilElement).componentOnReady();\n }\n element.dispatchEvent(\n buildCustomEvent('atomic/searchBoxSuggestion/register', event)\n );\n};\n"],"version":3}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Checks if a search box suggestion element has no query.
|
3
|
+
*
|
4
|
+
* @param el - The search box suggestion element to check
|
5
|
+
* @returns True if the element has no query or the query is whitespace-only
|
6
|
+
*/
|
7
|
+
function elementHasNoQuery(el) {
|
8
|
+
return !el.query || el.query.trim() === '';
|
9
|
+
}
|
10
|
+
/**
|
11
|
+
* Checks if a search box suggestion element has a query.
|
12
|
+
*
|
13
|
+
* @param el - The search box suggestion element to check
|
14
|
+
* @returns True if the element has a non-empty, non-whitespace query
|
15
|
+
*/
|
16
|
+
function elementHasQuery(el) {
|
17
|
+
return !!el.query && el.query.trim() !== '';
|
18
|
+
}
|
19
|
+
|
20
|
+
export { elementHasQuery as a, elementHasNoQuery as e };
|
21
|
+
|
22
|
+
//# sourceMappingURL=suggestions-utils-591559a0.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"suggestions-utils-591559a0.js","mappings":"AAEA;;;;;;SAMgB,iBAAiB,CAAC,EAA8B;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,eAAe,CAAC,EAA8B;IAC5D,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC9C;;;;","names":[],"sources":["src/components/common/suggestions/suggestions-utils.ts"],"sourcesContent":["import type {SearchBoxSuggestionElement} from './suggestions-types';\n\n/**\n * Checks if a search box suggestion element has no query.\n *\n * @param el - The search box suggestion element to check\n * @returns True if the element has no query or the query is whitespace-only\n */\nexport function elementHasNoQuery(el: SearchBoxSuggestionElement): boolean {\n return !el.query || el.query.trim() === '';\n}\n\n/**\n * Checks if a search box suggestion element has a query.\n *\n * @param el - The search box suggestion element to check\n * @returns True if the element has a non-empty, non-whitespace query\n */\nexport function elementHasQuery(el: SearchBoxSuggestionElement): boolean {\n return !!el.query && el.query.trim() !== '';\n}\n"],"version":3}
|
package/dist/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const headlessVersion = '3.31.
|
2
|
-
export const atomicVersion = '3.33.8-pre.
|
1
|
+
export const headlessVersion = '3.31.1-pre.a42c491ac0';
|
2
|
+
export const atomicVersion = '3.33.8-pre.a42c491ac0';
|
package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type CommerceEngine, type CommerceEngineConfiguration, type Context, type LogLevel, type ProductListing, type ProductListingSummaryState, type Search, type SearchSummaryState, type Summary, type UrlManager } from '@coveo/headless/commerce';
|
2
|
+
import type { CurrencyCodeISO4217 } from '@coveo/relay-event-types';
|
2
3
|
import { type i18n } from 'i18next';
|
3
4
|
import { type CSSResultGroup, LitElement } from 'lit';
|
4
5
|
import type { CommonBindings } from '../../common/interface/bindings';
|
@@ -49,7 +50,13 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
49
50
|
/**
|
50
51
|
* The commerce interface language.
|
51
52
|
*
|
52
|
-
* Will default to the value set in the Headless engine context if not
|
53
|
+
* Will default to the value set in the Headless engine context if not
|
54
|
+
* provided.
|
55
|
+
*
|
56
|
+
* @deprecated - This property will be removed in the next major version of
|
57
|
+
* Atomic (v4). Rather than using this property, set the initial language
|
58
|
+
* through the engine configuration when calling `initializeWithEngine`, and
|
59
|
+
* update the language as needed using the `updateLocale` method.
|
53
60
|
*/
|
54
61
|
language?: string;
|
55
62
|
/**
|
@@ -100,6 +107,26 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
100
107
|
* Executes the first request after initializing connection to the headless commerce engine.
|
101
108
|
*/
|
102
109
|
executeFirstRequest(): Promise<void>;
|
110
|
+
/**
|
111
|
+
* Updates the locale settings for the commerce interface and headless commerce
|
112
|
+
* engine. Only the provided parameters will be updated.
|
113
|
+
*
|
114
|
+
* Calling this method affects the localization of the interface as well as
|
115
|
+
* the catalog configuration being used by the Commerce API. If the resulting
|
116
|
+
* language-country-currency combination matches no existing catalog
|
117
|
+
* configuration in your Coveo organization, requests made through the
|
118
|
+
* commerce engine will start failing.
|
119
|
+
*
|
120
|
+
* @param language - (Optional) The IETF language code tag (e.g., `en`).
|
121
|
+
* @param country - (Optional) The ISO-3166-1 country tag (e.g., `US`).
|
122
|
+
* @param currency - (Optional) The ISO-4217 currency code (e.g., `USD`).
|
123
|
+
*
|
124
|
+
* @example
|
125
|
+
* ```typescript
|
126
|
+
* interface.updateLocale('fr', 'CA', 'CAD');
|
127
|
+
* ```
|
128
|
+
*/
|
129
|
+
updateLocale(language?: string, country?: string, currency?: CurrencyCodeISO4217): void;
|
103
130
|
toggleAnalytics(): void;
|
104
131
|
updateIconAssetsPath(): void;
|
105
132
|
updateLanguage(): void;
|
@@ -115,6 +142,7 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
115
142
|
private initSummary;
|
116
143
|
private initUrlManager;
|
117
144
|
private internalInitialization;
|
145
|
+
private isNewLocale;
|
118
146
|
private onHashChange;
|
119
147
|
scrollToTop(): void;
|
120
148
|
private updateHash;
|
package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts
CHANGED
@@ -137,7 +137,6 @@ export declare class AtomicCommerceSearchBox extends LitElement implements Initi
|
|
137
137
|
private renderSuggestions;
|
138
138
|
private renderPanel;
|
139
139
|
private renderSuggestion;
|
140
|
-
private renderSlotContent;
|
141
140
|
render(): import("lit-html").TemplateResult<1>;
|
142
141
|
}
|
143
142
|
declare global {
|
@@ -2,7 +2,7 @@ import { type Product, type SearchBox } from '@coveo/headless/commerce';
|
|
2
2
|
import { LitElement } from 'lit';
|
3
3
|
import type { ItemRenderingFunction } from "../../common/item-list/item-list-common";
|
4
4
|
import type { ItemDisplayDensity, ItemDisplayImageSize } from "../../common/layout/display-options";
|
5
|
-
import {
|
5
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from "../../common/suggestions/suggestions-types";
|
6
6
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
7
7
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
8
8
|
export type AriaLabelGenerator = (bindings: CommerceBindings, product: Product) => string | undefined;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type SearchBox } from '@coveo/headless/commerce';
|
2
2
|
import { LitElement } from 'lit';
|
3
|
-
import {
|
3
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from "../../common/suggestions/suggestions-types";
|
4
4
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
5
5
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
6
6
|
/**
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { type SearchBox } from '@coveo/headless/commerce';
|
2
2
|
import { LitElement } from 'lit';
|
3
3
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
4
|
-
import {
|
4
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../common/suggestions/suggestions-types';
|
5
5
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
6
6
|
/**
|
7
7
|
* The `atomic-commerce-search-box-recent-queries` component can be added as a child of an `atomic-commerce-search-box` component, allowing for the configuration of recent query suggestions.
|
package/dist/types/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { i18n } from 'i18next';
|
2
|
-
import { SearchBoxSuggestionElement } from '../suggestions/suggestions-
|
2
|
+
import { SearchBoxSuggestionElement } from '../suggestions/suggestions-types';
|
3
3
|
/**
|
4
4
|
* The `atomic-suggestion-renderer` component is used to render individual suggestions. It was created to isolate
|
5
5
|
* the rendering logic of the 'content' property of the `SearchBoxSuggestionElement` interface. This property can be Stencil
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { i18n } from 'i18next';
|
2
|
-
import type { SearchBoxSuggestionElement } from './suggestions-
|
2
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
3
3
|
export declare const getPartialInstantItemElement: (i18n: i18n, itemTitle: string, itemUniqueId: string) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part">;
|
4
4
|
export declare const getPartialInstantItemShowAllElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "key" | "part" | "ariaLabel">;
|
5
5
|
interface InstantItemShowAllButtonProps {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { i18n } from 'i18next';
|
2
|
-
import type { SearchBoxSuggestionElement } from './suggestions-
|
2
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
3
3
|
export declare const getPartialRecentQueryElement: (value: string, i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "query" | "part">;
|
4
4
|
export declare const getPartialRecentQueryClearElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part" | "hideIfLast">;
|
5
5
|
export interface RecentQueriesContainerProps {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types';
|
4
4
|
export declare const getPartialInstantItemElement: (i18n: i18n, itemTitle: string, itemUniqueId: string) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part">;
|
5
5
|
export declare const getPartialInstantItemShowAllElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "key" | "part" | "ariaLabel">;
|
6
6
|
interface InstantItemShowAllButtonProps {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types.js';
|
4
4
|
interface Suggestion {
|
5
5
|
highlightedValue: string;
|
6
6
|
rawValue: string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types';
|
4
4
|
export declare const getPartialRecentQueryElement: (value: string, i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "query" | "part">;
|
5
5
|
export declare const getPartialRecentQueryClearElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part" | "hideIfLast">;
|
6
6
|
export declare const RecentQueriesContainer: FunctionalComponent;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { SearchBoxSuggestionElement, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent } from './suggestions-types';
|
2
2
|
/**
|
3
3
|
* List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.
|
4
4
|
*/
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { LitElement } from 'lit';
|
2
|
-
import {
|
2
|
+
import type { SearchBoxSuggestionElement, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent } from './suggestions-types';
|
3
3
|
/**
|
4
4
|
* List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.
|
5
5
|
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { AnyBindings } from '../interface/bindings';
|
2
|
+
import type { SearchBoxSuggestionsEvent } from './suggestions-types';
|
3
|
+
/**
|
4
|
+
* Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
|
5
|
+
*
|
6
|
+
* @param event Event sent from the registered query suggestions to the parent search box
|
7
|
+
* @param element Element on which to dispatch the event, which must be the child of a configured search box
|
8
|
+
* @param allowedSearchBoxElements Optional array of allowed search box element selectors
|
9
|
+
*
|
10
|
+
* @throws Error if the element is not a child of an allowed search box element
|
11
|
+
*/
|
12
|
+
export declare const dispatchSearchBoxSuggestionsEvent: <SearchBoxController, Bindings = AnyBindings>(event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>, element: HTMLElement, allowedSearchBoxElements?: readonly (typeof searchBoxElements)[number][]) => void;
|
13
|
+
declare const searchBoxElements: readonly ["atomic-search-box", "atomic-insight-search-box", "atomic-commerce-search-box"];
|
14
|
+
export {};
|
package/dist/types/components/common/suggestions/{suggestions-common.d.ts → suggestions-types.d.ts}
RENAMED
@@ -68,15 +68,6 @@ export interface SearchBoxSuggestions {
|
|
68
68
|
*/
|
69
69
|
onSuggestedQueryChange?(q: string): Promise<unknown>;
|
70
70
|
}
|
71
|
-
/**
|
72
|
-
* Event sent from the registered query suggestions to the parent search box.
|
73
|
-
*/
|
74
|
-
export type SearchBoxSuggestionsEvent<SearchBoxController, Bindings = AnyBindings> = (
|
75
|
-
/**
|
76
|
-
* The bindings passed from the search box to the suggestions.
|
77
|
-
*/
|
78
|
-
bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>) => SearchBoxSuggestions;
|
79
|
-
declare const searchBoxElements: readonly ["atomic-search-box", "atomic-insight-search-box", "atomic-commerce-search-box"];
|
80
71
|
/**
|
81
72
|
* The bindings passed from the search box to the suggestions.
|
82
73
|
*/
|
@@ -124,11 +115,10 @@ export type SearchBoxSuggestionsBindings<SearchBoxController, Bindings = AnyBind
|
|
124
115
|
getSuggestionElements(): SearchBoxSuggestionElement[];
|
125
116
|
};
|
126
117
|
/**
|
127
|
-
*
|
128
|
-
* @param event Event sent from the registered query suggestions to the parent search box.
|
129
|
-
* @param element Element on which to dispatch the event, which must be the child of a configured search box.
|
118
|
+
* Event sent from the registered query suggestions to the parent search box.
|
130
119
|
*/
|
131
|
-
export
|
132
|
-
|
133
|
-
|
134
|
-
|
120
|
+
export type SearchBoxSuggestionsEvent<SearchBoxController, Bindings = AnyBindings> = (
|
121
|
+
/**
|
122
|
+
* The bindings passed from the search box to the suggestions.
|
123
|
+
*/
|
124
|
+
bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>) => SearchBoxSuggestions;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
2
|
+
/**
|
3
|
+
* Checks if a search box suggestion element has no query.
|
4
|
+
*
|
5
|
+
* @param el - The search box suggestion element to check
|
6
|
+
* @returns True if the element has no query or the query is whitespace-only
|
7
|
+
*/
|
8
|
+
export declare function elementHasNoQuery(el: SearchBoxSuggestionElement): boolean;
|
9
|
+
/**
|
10
|
+
* Checks if a search box suggestion element has a query.
|
11
|
+
*
|
12
|
+
* @param el - The search box suggestion element to check
|
13
|
+
* @returns True if the element has a non-empty, non-whitespace query
|
14
|
+
*/
|
15
|
+
export declare function elementHasQuery(el: SearchBoxSuggestionElement): boolean;
|
@@ -2,7 +2,7 @@ import { SearchBox, StandaloneSearchBox } from '@coveo/headless';
|
|
2
2
|
import { EventEmitter } from '../../../stencil-public-runtime';
|
3
3
|
import { InitializableComponent } from '../../../utils/initialization-utils';
|
4
4
|
import { RedirectionPayload } from '../../common/search-box/redirection-payload';
|
5
|
-
import { SearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-
|
5
|
+
import type { SearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-types';
|
6
6
|
import { Bindings } from '../atomic-search-interface/atomic-search-interface';
|
7
7
|
/**
|
8
8
|
* The `atomic-search-box` component creates a search box with built-in support for suggestions.
|
@@ -161,6 +161,5 @@ export declare class AtomicSearchBox implements InitializableComponent<Bindings>
|
|
161
161
|
private getSearchInputLabel;
|
162
162
|
private announceNewActiveSuggestionToScreenReader;
|
163
163
|
private announceNewSuggestionsToScreenReader;
|
164
|
-
private renderSlotContent;
|
165
164
|
render(): any;
|
166
165
|
}
|
@@ -2,7 +2,7 @@ import { Result, SearchBox } from '@coveo/headless';
|
|
2
2
|
import { InitializableComponent } from '../../../../utils/initialization-utils';
|
3
3
|
import { ItemRenderingFunction } from '../../../common/item-list/stencil-item-list-common';
|
4
4
|
import { ItemDisplayDensity, ItemDisplayImageSize } from '../../../common/layout/display-options';
|
5
|
-
import { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../../common/suggestions/suggestions-
|
5
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../../common/suggestions/suggestions-types';
|
6
6
|
import { Bindings } from '../../atomic-search-interface/atomic-search-interface';
|
7
7
|
export type AriaLabelGenerator = (bindings: Bindings, result: Result) => string | undefined;
|
8
8
|
/**
|
@@ -26,7 +26,7 @@ import { RedirectionPayload } from "./components/common/search-box/redirection-p
|
|
26
26
|
import { AriaLabelGenerator } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results";
|
27
27
|
import { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface";
|
28
28
|
import { StandaloneSearchBoxData } from "./utils/local-storage-utils";
|
29
|
-
import { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-
|
29
|
+
import { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-types";
|
30
30
|
export { AutomaticFacet, CategoryFacetSortCriterion, DateFilterRange, DateRangeRequest, FacetResultsMustMatch, FacetSortCriterion, FoldedResult, GeneratedAnswer, GeneratedAnswerCitation, InlineLink, InteractiveCitation, InteractiveResult, LogLevel, NumericFilter, NumericFilterState, RangeFacetRangeAlgorithm, RangeFacetSortCriterion, RelativeDateUnit, Result, ResultTemplate, ResultTemplateCondition, SearchEngine, SearchStatus } from "@coveo/headless";
|
31
31
|
export { AtomicInterface } from "./utils/initialization-utils";
|
32
32
|
export { AnyBindings } from "./components/common/interface/bindings";
|
@@ -48,7 +48,7 @@ export { RedirectionPayload } from "./components/common/search-box/redirection-p
|
|
48
48
|
export { AriaLabelGenerator } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results";
|
49
49
|
export { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface";
|
50
50
|
export { StandaloneSearchBoxData } from "./utils/local-storage-utils";
|
51
|
-
export { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-
|
51
|
+
export { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-types";
|
52
52
|
export namespace Components {
|
53
53
|
/**
|
54
54
|
* An automatic facet is a special type of facet generated by the automatic facets feature.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { LitElement, TemplateResult } from 'lit';
|
2
2
|
import type { TemplateResultType } from 'lit/directive-helpers.js';
|
3
3
|
import type { AnyBindings } from '../components/common/interface/bindings';
|
4
|
-
import type { SearchBoxSuggestions } from '../components/common/suggestions/suggestions-
|
4
|
+
import type { SearchBoxSuggestions } from '../components/common/suggestions/suggestions-types';
|
5
5
|
export type GenericRender<T extends TemplateResultType> = TemplateResult<T>;
|
6
6
|
export type RenderGuardDecorator<Component, T extends TemplateResultType, Descriptor = TypedPropertyDescriptor<() => GenericRender<T>>> = (target: Component, propertyKey: 'render', descriptor: Descriptor) => Descriptor;
|
7
7
|
/**
|
package/dist/types/index.d.ts
CHANGED
@@ -5,7 +5,9 @@ export { SelectChildProductEventArgs } from './components/commerce/atomic-produc
|
|
5
5
|
export { productContext } from './components/commerce/product-template-component-utils/stencil-product-template-decorators';
|
6
6
|
export { PopoverChildFacet } from './components/common/facets/popover/popover-type';
|
7
7
|
export { RedirectionPayload } from './components/common/search-box/redirection-payload';
|
8
|
-
export { dispatchSearchBoxSuggestionsEvent
|
8
|
+
export { dispatchSearchBoxSuggestionsEvent } from './components/common/suggestions/suggestions-events';
|
9
|
+
export type { SearchBoxSuggestionElement, SearchBoxSuggestions, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent, } from './components/common/suggestions/suggestions-types';
|
10
|
+
export { elementHasNoQuery, elementHasQuery, } from './components/common/suggestions/suggestions-utils';
|
9
11
|
export { RecsBindings } from './components/recommendations/atomic-recs-interface/atomic-recs-interface';
|
10
12
|
export { Bindings } from './components/search/atomic-search-interface/atomic-search-interface';
|
11
13
|
export { resultContext } from './components/search/result-template-components/result-template-decorators';
|
package/docs/atomic-docs.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "2025-09-
|
2
|
+
"timestamp": "2025-09-29T18:57:52",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
5
|
"version": "4.20.0",
|
@@ -16089,10 +16089,10 @@
|
|
16089
16089
|
"docstring": "",
|
16090
16090
|
"path": "src/components/common/layout/display-options.ts"
|
16091
16091
|
},
|
16092
|
-
"src/components/common/suggestions/suggestions-
|
16092
|
+
"src/components/common/suggestions/suggestions-types.ts::SearchBoxSuggestionElement": {
|
16093
16093
|
"declaration": "export interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n *\n * @remarks\n * The `VNode` type will be deprecated in v4 as we are detaching from Stencil.\n */\n content: Element | VNode;\n /**\n * Hook called when the selection is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, provide this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Hide the suggestion if it's the last in the list.\n */\n hideIfLast?: boolean;\n}",
|
16094
16094
|
"docstring": "Element which will be rendered in the list of suggestions.",
|
16095
|
-
"path": "src/components/common/suggestions/suggestions-
|
16095
|
+
"path": "src/components/common/suggestions/suggestions-types.ts"
|
16096
16096
|
},
|
16097
16097
|
"../headless/dist/definitions/index.d.ts::RelativeDateUnit": {
|
16098
16098
|
"declaration": "any",
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coveo/atomic",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.33.8-pre.
|
4
|
+
"version": "3.33.8-pre.a42c491ac0",
|
5
5
|
"description": "A web-component library for building modern UIs interfacing with the Coveo platform",
|
6
6
|
"homepage": "https://docs.coveo.com/en/atomic/latest/",
|
7
7
|
"repository": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
},
|
82
82
|
"dependencies": {
|
83
83
|
"@coveo/bueno": "1.1.2",
|
84
|
-
"@coveo/headless": "3.31.
|
84
|
+
"@coveo/headless": "3.31.1-pre.a42c491ac0",
|
85
85
|
"@lit/context": "1.1.6",
|
86
86
|
"@open-wc/lit-helpers": "0.7.0",
|
87
87
|
"@popperjs/core": "2.11.8",
|
@@ -153,7 +153,7 @@
|
|
153
153
|
},
|
154
154
|
"peerDependencies": {
|
155
155
|
"@coveo/bueno": "1.1.2",
|
156
|
-
"@coveo/headless": "3.31.
|
156
|
+
"@coveo/headless": "3.31.1-pre.a42c491ac0",
|
157
157
|
"typescript": ">=5.0.0"
|
158
158
|
},
|
159
159
|
"peerDependenciesMeta": {
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"suggestions-common.js","mappings":";;;AA0FA,MAAM,iBAAiB,GAAG;IACxB,mBAAmB;IACnB,2BAA2B;IAC3B,4BAA4B;CACpB,CAAC;AAoDX,MAAM,mBAAmB,GAAG,CAAC,SAAkB,KAC7C,gBAAgB,IAAK,SAAwB;IAC5C,SAAwB,CAAC,cAAc,YAAY,OAAO,CAAC;AAE9D,MAAM,2CAA2C,GAAG,OAIlD,gBAAyB,EACzB,OAAoB,EACpB,KAA+D;IAE/D,MAAM,cAAc,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1E,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,EAAE;QACzC,MAAM,gBAAgB,CAAC,cAAc,CAAC;KACvC;SAAM,IAAI,kBAAkB,IAAI,gBAAgB,EAAE;QACjD,MAAO,gBAAuC,CAAC,gBAAgB,EAAE,CAAC;KACnE;IACD,OAAO,CAAC,aAAa,CACnB,gBAAgB,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;MAKa,iCAAiC,GAAG,CAI/C,KAA+D,EAC/D,OAAoB,EACpB,2BAA0E,iBAAiB;IAE3F,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,QAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,gFAAgF,wBAAwB,CAAC,IAAI,CACjJ,IAAI,CACL,EAAE,CACJ,CAAC;KACH;IACD,KAAK,2CAA2C,CAC9C,gBAAgB,EAChB,OAAO,EACP,KAAK,CACN,CAAC;AACJ,EAAE;SAEc,iBAAiB,CAAC,EAA8B;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;SAEe,eAAe,CAAC,EAA8B;IAC5D,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC9C;;;;","names":[],"sources":["src/components/common/suggestions/suggestions-common.ts"],"sourcesContent":["import type {VNode} from '@stencil/core';\nimport type {HTMLStencilElement} from '@stencil/core/internal';\nimport type {LitElement} from 'lit';\nimport {closest} from '../../../utils/dom-utils';\nimport {buildCustomEvent} from '../../../utils/event-utils';\nimport type {AnyBindings} from '../interface/bindings';\n\n/**\n * Element which will be rendered in the list of suggestions.\n */\nexport interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n *\n * @remarks\n * The `VNode` type will be deprecated in v4 as we are detaching from Stencil.\n */\n content: Element | VNode;\n /**\n * Hook called when the selection is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, provide this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Hide the suggestion if it's the last in the list.\n */\n hideIfLast?: boolean;\n}\n\n/**\n * List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.\n */\nexport interface SearchBoxSuggestions {\n /**\n * The search box will sort the position of suggestions using this value. The lowest value being first.\n * By default, the DOM position will be used.\n */\n position: number;\n /**\n * Whether the suggestions should be listed in the right or left panel. By default, the suggestions are listed in the right panel.\n */\n panel?: 'left' | 'right';\n /**\n * Method that returns the list of elements which will be rendered in the list of suggestions.\n */\n renderItems(): SearchBoxSuggestionElement[];\n /**\n * Hook called when the user changes the search box's input value. This can lead to all the query suggestions being updated.\n */\n onInput?(): Promise<unknown>;\n /**\n * Hook called when the suggested query changes as a user traverses through the list of suggestions.\n * This is used for instant results, which are rendered based on the current suggested query.\n * @param q The new suggested query.\n */\n onSuggestedQueryChange?(q: string): Promise<unknown>;\n}\n\n/**\n * Event sent from the registered query suggestions to the parent search box.\n */\nexport type SearchBoxSuggestionsEvent<\n SearchBoxController,\n Bindings = AnyBindings,\n> = (\n /**\n * The bindings passed from the search box to the suggestions.\n */\n bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>\n) => SearchBoxSuggestions;\n\nconst searchBoxElements = [\n 'atomic-search-box',\n 'atomic-insight-search-box',\n 'atomic-commerce-search-box',\n] as const;\n\n/**\n * The bindings passed from the search box to the suggestions.\n */\nexport type SearchBoxSuggestionsBindings<\n SearchBoxController,\n Bindings = AnyBindings,\n> = Bindings & {\n /**\n * The unique id of the search box.\n */\n id: string;\n /**\n * Whether the search box is [standalone](https://docs.coveo.com/en/atomic/latest/usage/ssb/).\n */\n isStandalone: boolean;\n /**\n * The search box headless controller.\n */\n searchBoxController: SearchBoxController;\n /**\n * The number of queries to display when the user interacts with the search box.\n */\n numberOfQueries: number;\n /**\n * Whether to clear all active query filters when the end user submits a new query from the search box.\n */\n clearFilters: boolean;\n /**\n * Retrieves the suggested query, meaning the query that would be sent if the search is executed.\n * The suggested query changes as a user traverses through the list of suggestions.\n */\n suggestedQuery(): string;\n /**\n * Removes the current suggestions.\n */\n clearSuggestions(): void;\n /**\n * Triggers update & retrieval of all suggestions.\n */\n triggerSuggestions(): void;\n /**\n * Retrieves the current suggestions.\n */\n getSuggestions(): SearchBoxSuggestions[];\n /**\n * Retrieves the current suggestions elements.\n */\n getSuggestionElements(): SearchBoxSuggestionElement[];\n};\n\nconst isLitElementLoosely = (candidate: unknown): candidate is LitElement =>\n 'updateComplete' in (candidate as LitElement) &&\n (candidate as LitElement).updateComplete instanceof Promise;\n\nconst dispatchSearchBoxSuggestionsEventEventually = async <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n interfaceElement: Element,\n element: HTMLElement,\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>\n) => {\n await customElements.whenDefined(interfaceElement.nodeName.toLowerCase());\n if (isLitElementLoosely(interfaceElement)) {\n await interfaceElement.updateComplete;\n } else if ('componentOnReady' in interfaceElement) {\n await (interfaceElement as HTMLStencilElement).componentOnReady();\n }\n element.dispatchEvent(\n buildCustomEvent('atomic/searchBoxSuggestion/register', event)\n );\n};\n\n/**\n * Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.\n * @param event Event sent from the registered query suggestions to the parent search box.\n * @param element Element on which to dispatch the event, which must be the child of a configured search box.\n */\nexport const dispatchSearchBoxSuggestionsEvent = <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>,\n element: HTMLElement,\n allowedSearchBoxElements: readonly (typeof searchBoxElements)[number][] = searchBoxElements\n) => {\n const interfaceElement = closest(element, searchBoxElements.join(', '));\n if (!interfaceElement) {\n throw new Error(\n `The \"${element.nodeName.toLowerCase()}\" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(\n ', '\n )}`\n );\n }\n void dispatchSearchBoxSuggestionsEventEventually(\n interfaceElement,\n element,\n event\n );\n};\n\nexport function elementHasNoQuery(el: SearchBoxSuggestionElement) {\n return !el.query || el.query.trim() === '';\n}\n\nexport function elementHasQuery(el: SearchBoxSuggestionElement) {\n return !!el.query && el.query.trim() !== '';\n}\n"],"version":3}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["AtomicSearchBoxQuerySuggestions","componentWillLoad","dispatchSearchBoxSuggestionsEvent","bindings","this","initialize","host","error","engine","registerQuerySuggest","fetchQuerySuggestions","loadQuerySuggestActions","dispatch","id","count","numberOfQueries","position","Array","from","parentNode","children","indexOf","onInput","renderItems","hasQuery","searchBoxController","state","value","max","maxWithQuery","maxWithoutQuery","suggestions","slice","map","suggestion","renderItem","partialItem","getPartialSearchBoxSuggestionElement","i18n","content","h","QuerySuggestionContainer","QuerySuggestionIcon","icon","SearchIcon","hasSuggestion","getSuggestions","length","QuerySuggestionText","onSelect","selectSuggestion","rawValue","render","key","element","getPartialRecentQueryElement","part","query","encodeForDomAttribute","ariaLabel","t","interpolation","escapeValue","getPartialRecentQueryClearElement","hideIfLast","RecentQueriesContainer","_","class","RecentQueryIcon","RecentQueryText","innerHTML","HighlightUtils","highlightString","openingDelimiter","closingDelimiter","highlights","offset","RecentQueryClear","AtomicSearchBoxRecentQueries","warnUser","once","logger","warn","renderIcon","Clock","storage","SafeStorage","recentQueriesList","buildRecentQueriesList","initialState","queries","retrieveLocalStorage","options","maxLength","clearFilters","subscribe","updateLocalStorage","getParsedJSON","StorageItems","RECENT_QUERIES","analyticsEnabled","disableFeature","setJSON","removeItem","filteredQueries","filter","recentQuery","toLowerCase","startsWith","suggestionElements","unshift","renderClear","clear","triggerSuggestions","isStandalone","updateText","submit","executeRecentQuery"],"sources":["src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.tsx","src/components/common/suggestions/stencil-recent-queries.tsx","src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.tsx"],"sourcesContent":["import {\n loadQuerySuggestActions,\n SearchBox,\n SearchEngine,\n Suggestion,\n} from '@coveo/headless';\nimport {Component, Element, Prop, State, h} from '@stencil/core';\nimport SearchIcon from '../../../../images/search.svg';\nimport {\n getPartialSearchBoxSuggestionElement,\n QuerySuggestionContainer,\n QuerySuggestionIcon,\n QuerySuggestionText,\n} from '../../../common/suggestions/stencil-query-suggestions';\nimport {\n dispatchSearchBoxSuggestionsEvent,\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n} from '../../../common/suggestions/suggestions-common';\n\n/**\n * The `atomic-search-box-query-suggestions` component can be added as a child of an `atomic-search-box` component, allowing for the configuration of query suggestion behavior.\n */\n@Component({\n tag: 'atomic-search-box-query-suggestions',\n shadow: true,\n})\nexport class AtomicSearchBoxQuerySuggestions {\n private bindings!: SearchBoxSuggestionsBindings<SearchBox>;\n @Element() private host!: HTMLElement;\n\n @State() public error!: Error;\n\n /**\n * The SVG icon to display.\n *\n * - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location.\n * - Use a value that starts with `assets://`, to display an icon from the Atomic package.\n * - Use a stringified SVG to display it directly.\n */\n @Prop() public icon?: string;\n\n /**\n * The maximum number of suggestions that will be displayed if the user has typed something into the input field.\n */\n @Prop({reflect: true}) public maxWithQuery?: number;\n /**\n * The maximum number of suggestions that will be displayed initially when the input field is empty.\n */\n @Prop({reflect: true}) public maxWithoutQuery?: number;\n\n componentWillLoad() {\n try {\n dispatchSearchBoxSuggestionsEvent<SearchBox>(\n (bindings) => {\n this.bindings = bindings;\n return this.initialize();\n },\n this.host,\n ['atomic-search-box']\n );\n } catch (error) {\n this.error = error as Error;\n }\n }\n\n private initialize(): SearchBoxSuggestions {\n const engine = this.bindings.engine as SearchEngine<{\n querySet: string;\n querySuggest: string;\n }>;\n const {registerQuerySuggest, fetchQuerySuggestions} =\n loadQuerySuggestActions(engine);\n\n engine.dispatch(\n registerQuerySuggest({\n id: this.bindings.id,\n count: this.bindings.numberOfQueries,\n })\n );\n\n return {\n position: Array.from(this.host.parentNode!.children).indexOf(this.host),\n onInput: () =>\n engine.dispatch(\n fetchQuerySuggestions({\n id: this.bindings.id,\n })\n ),\n renderItems: () => this.renderItems(),\n };\n }\n\n private renderItems(): SearchBoxSuggestionElement[] {\n const hasQuery = this.bindings.searchBoxController.state.value !== '';\n const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;\n return this.bindings.searchBoxController.state.suggestions\n .slice(0, max)\n .map((suggestion) => this.renderItem(suggestion));\n }\n\n private renderItem(suggestion: Suggestion) {\n const hasQuery = this.bindings.searchBoxController.state.value !== '';\n const partialItem = getPartialSearchBoxSuggestionElement(\n suggestion,\n this.bindings.i18n\n );\n\n return {\n ...partialItem,\n content: (\n <QuerySuggestionContainer>\n <QuerySuggestionIcon\n icon={this.icon || SearchIcon}\n hasSuggestion={this.bindings.getSuggestions().length > 1}\n />\n\n <QuerySuggestionText suggestion={suggestion} hasQuery={hasQuery} />\n </QuerySuggestionContainer>\n ),\n onSelect: () => {\n this.bindings.searchBoxController.selectSuggestion(suggestion.rawValue);\n },\n };\n }\n\n public render() {\n if (this.error) {\n return (\n <atomic-component-error\n element={this.host}\n error={this.error}\n ></atomic-component-error>\n );\n }\n }\n}\n","import {HighlightUtils} from '@coveo/headless';\nimport {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils';\nimport {SearchBoxSuggestionElement} from './suggestions-common';\n\nexport const getPartialRecentQueryElement = (\n value: string,\n i18n: i18n\n): Pick<SearchBoxSuggestionElement, 'ariaLabel' | 'key' | 'query' | 'part'> => {\n return {\n part: 'recent-query-item',\n query: value,\n key: `recent-${encodeForDomAttribute(value)}`,\n ariaLabel: i18n.t('recent-query-suggestion-label', {\n query: value,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const getPartialRecentQueryClearElement = (\n i18n: i18n\n): Pick<\n SearchBoxSuggestionElement,\n 'ariaLabel' | 'key' | 'part' | 'hideIfLast'\n> => {\n return {\n key: 'recent-query-clear',\n ariaLabel: i18n.t('clear-recent-searches', {\n interpolation: {escapeValue: false},\n }),\n part: 'recent-query-title-item suggestion-divider',\n hideIfLast: true,\n };\n};\n\nexport const RecentQueriesContainer: FunctionalComponent = (_, children) => {\n return (\n <div\n part=\"recent-query-content\"\n class=\"flex items-center text-left break-all\"\n >\n {children}\n </div>\n );\n};\n\ninterface RecentQueryIconProps {\n icon: string;\n}\n\nexport const RecentQueryIcon: FunctionalComponent<RecentQueryIconProps> = ({\n icon,\n}) => {\n return (\n <atomic-icon\n part=\"recent-query-icon\"\n icon={icon}\n class=\"mr-2 h-4 w-4 shrink-0\"\n ></atomic-icon>\n );\n};\n\ninterface RecentQueryTextProps {\n query: string;\n value: string;\n}\n\nexport const RecentQueryText: FunctionalComponent<RecentQueryTextProps> = ({\n query,\n value,\n}) => {\n if (query === '') {\n return (\n <span part=\"recent-query-text\" class=\"line-clamp-2 break-all\">\n {value}\n </span>\n );\n }\n return (\n <span\n part=\"recent-query-text\"\n class=\"line-clamp-2 break-all\"\n innerHTML={HighlightUtils.highlightString({\n content: value,\n openingDelimiter:\n '<span part=\"recent-query-text-highlight\" class=\"font-bold\">',\n closingDelimiter: '</span>',\n highlights: [\n {\n offset: query.length,\n length: value.length - query.length,\n },\n ],\n })}\n ></span>\n );\n};\n\ninterface RecentQueryClearProps {\n i18n: i18n;\n}\n\nexport const RecentQueryClear: FunctionalComponent<RecentQueryClearProps> = ({\n i18n,\n}) => {\n return (\n <div part=\"recent-query-title-content\" class=\"flex w-full justify-between\">\n <span class=\"font-bold\" part=\"recent-query-title\">\n {i18n.t('recent-searches')}\n </span>\n <span part=\"recent-query-clear\">{i18n.t('clear')}</span>\n </div>\n );\n};\n","import {\n buildRecentQueriesList,\n RecentQueriesList,\n SearchBox,\n} from '@coveo/headless';\nimport {Component, Element, Prop, State, h} from '@stencil/core';\nimport Clock from '../../../../images/clock.svg';\nimport {SafeStorage, StorageItems} from '../../../../utils/local-storage-utils';\nimport {once} from '../../../../utils/utils';\nimport {\n getPartialRecentQueryClearElement,\n getPartialRecentQueryElement,\n RecentQueriesContainer,\n RecentQueryClear,\n RecentQueryIcon,\n RecentQueryText,\n} from '../../../common/suggestions/stencil-recent-queries';\nimport {\n dispatchSearchBoxSuggestionsEvent,\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n} from '../../../common/suggestions/suggestions-common';\nimport {Bindings} from '../../atomic-search-interface/atomic-search-interface';\n\n/**\n * The `atomic-search-box-recent-queries` component can be added as a child of an `atomic-search-box` component, allowing for the configuration of recent query suggestions.\n */\n@Component({\n tag: 'atomic-search-box-recent-queries',\n shadow: true,\n})\nexport class AtomicSearchBoxRecentQueries {\n private bindings!: SearchBoxSuggestionsBindings<SearchBox, Bindings>;\n private recentQueriesList!: RecentQueriesList;\n private storage!: SafeStorage;\n\n @Element() private host!: HTMLElement;\n\n @State() public error!: Error;\n\n /**\n * The SVG icon to display.\n *\n * - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location.\n * - Use a value that starts with `assets://`, to display an icon from the Atomic package.\n * - Use a stringified SVG to display it directly.\n */\n @Prop() public icon?: string;\n\n /**\n * The maximum number of suggestions that will be displayed if the user has typed something into the input field.\n */\n @Prop({reflect: true}) public maxWithQuery = 3;\n /**\n * The maximum number of suggestions that will be displayed initially when the input field is empty.\n */\n @Prop({reflect: true}) public maxWithoutQuery?: number;\n\n componentWillLoad() {\n try {\n dispatchSearchBoxSuggestionsEvent<SearchBox, Bindings>(\n (bindings) => {\n this.bindings = bindings;\n return this.initialize();\n },\n this.host,\n ['atomic-search-box']\n );\n } catch (error) {\n this.error = error as Error;\n }\n }\n\n private renderIcon() {\n return this.icon || Clock;\n }\n\n private initialize(): SearchBoxSuggestions {\n this.storage = new SafeStorage();\n this.recentQueriesList = buildRecentQueriesList(this.bindings.engine, {\n initialState: {queries: this.retrieveLocalStorage()},\n options: {maxLength: 1000, clearFilters: this.bindings.clearFilters},\n });\n\n this.recentQueriesList.subscribe(() => this.updateLocalStorage());\n\n return {\n position: Array.from(this.host.parentNode!.children).indexOf(this.host),\n renderItems: () => this.renderItems(),\n };\n }\n\n private retrieveLocalStorage() {\n return this.storage.getParsedJSON(StorageItems.RECENT_QUERIES, []);\n }\n\n private updateLocalStorage() {\n if (!this.recentQueriesList.state.analyticsEnabled) {\n return this.disableFeature();\n }\n\n return this.storage.setJSON(\n StorageItems.RECENT_QUERIES,\n this.recentQueriesList.state.queries\n );\n }\n\n private warnUser = once(() =>\n this.bindings.engine.logger.warn(\n 'Because analytics are disabled, the recent queries feature is deactivated.'\n )\n );\n\n private disableFeature() {\n this.warnUser();\n this.storage.removeItem(StorageItems.RECENT_QUERIES);\n }\n\n private renderItems(): SearchBoxSuggestionElement[] {\n if (!this.recentQueriesList.state.analyticsEnabled) {\n return [];\n }\n\n const query = this.bindings.searchBoxController.state.value;\n const hasQuery = query !== '';\n const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;\n const filteredQueries = this.recentQueriesList.state.queries\n .filter((recentQuery) =>\n recentQuery.toLowerCase().startsWith(query.toLowerCase())\n )\n .slice(0, max);\n\n const suggestionElements: SearchBoxSuggestionElement[] =\n filteredQueries.map((value) => this.renderItem(value));\n if (suggestionElements.length) {\n suggestionElements.unshift(this.renderClear());\n }\n\n return suggestionElements;\n }\n\n private renderClear(): SearchBoxSuggestionElement {\n const partialItem = getPartialRecentQueryClearElement(this.bindings.i18n);\n\n return {\n ...partialItem,\n content: <RecentQueryClear i18n={this.bindings.i18n} />,\n onSelect: () => {\n this.recentQueriesList.clear();\n this.bindings.triggerSuggestions();\n },\n };\n }\n\n private renderItem(value: string): SearchBoxSuggestionElement {\n const query = this.bindings.searchBoxController.state.value;\n const partialItem = getPartialRecentQueryElement(value, this.bindings.i18n);\n return {\n ...partialItem,\n content: (\n <RecentQueriesContainer>\n <RecentQueryIcon icon={this.renderIcon()} />\n <RecentQueryText query={query} value={value} />\n </RecentQueriesContainer>\n ),\n\n onSelect: () => {\n if (this.bindings.isStandalone) {\n this.bindings.searchBoxController.updateText(value);\n this.bindings.searchBoxController.submit();\n return;\n }\n\n this.recentQueriesList.executeRecentQuery(\n this.recentQueriesList.state.queries.indexOf(value)\n );\n },\n };\n }\n\n public render() {\n if (this.error) {\n return (\n <atomic-component-error\n element={this.host}\n error={this.error}\n ></atomic-component-error>\n );\n }\n }\n}\n"],"mappings":"0hBA4BaA,EAA+B,M,6HAwB1C,iBAAAC,GACE,IACEC,GACGC,IACCC,KAAKD,SAAWA,EAChB,OAAOC,KAAKC,YAAY,GAE1BD,KAAKE,KACL,CAAC,qB,CAEH,MAAOC,GACPH,KAAKG,MAAQA,C,EAIT,UAAAF,GACN,MAAMG,EAASJ,KAAKD,SAASK,OAI7B,MAAMC,qBAACA,EAAoBC,sBAAEA,GAC3BC,EAAwBH,GAE1BA,EAAOI,SACLH,EAAqB,CACnBI,GAAIT,KAAKD,SAASU,GAClBC,MAAOV,KAAKD,SAASY,mBAIzB,MAAO,CACLC,SAAUC,MAAMC,KAAKd,KAAKE,KAAKa,WAAYC,UAAUC,QAAQjB,KAAKE,MAClEgB,QAAS,IACPd,EAAOI,SACLF,EAAsB,CACpBG,GAAIT,KAAKD,SAASU,MAGxBU,YAAa,IAAMnB,KAAKmB,c,CAIpB,WAAAA,GACN,MAAMC,EAAWpB,KAAKD,SAASsB,oBAAoBC,MAAMC,QAAU,GACnE,MAAMC,EAAMJ,EAAWpB,KAAKyB,aAAezB,KAAK0B,gBAChD,OAAO1B,KAAKD,SAASsB,oBAAoBC,MAAMK,YAC5CC,MAAM,EAAGJ,GACTK,KAAKC,GAAe9B,KAAK+B,WAAWD,I,CAGjC,UAAAC,CAAWD,GACjB,MAAMV,EAAWpB,KAAKD,SAASsB,oBAAoBC,MAAMC,QAAU,GACnE,MAAMS,EAAcC,EAClBH,EACA9B,KAAKD,SAASmC,MAGhB,MAAO,IACFF,EACHG,QACEC,EAACC,EAAwB,KACvBD,EAACE,EAAmB,CAClBC,KAAMvC,KAAKuC,MAAQC,EACnBC,cAAezC,KAAKD,SAAS2C,iBAAiBC,OAAS,IAGzDP,EAACQ,EAAmB,CAACd,WAAYA,EAAYV,SAAUA,KAG3DyB,SAAU,KACR7C,KAAKD,SAASsB,oBAAoByB,iBAAiBhB,EAAWiB,SAAS,E,CAKtE,MAAAC,GACL,GAAIhD,KAAKG,MAAO,CACd,OACEiC,EAAA,0BAAAa,IAAA,2CACEC,QAASlD,KAAKE,KACdC,MAAOH,KAAKG,O,8BC9Hf,MAAMgD,EAA+B,CAC1C5B,EACAW,KAEO,CACLkB,KAAM,oBACNC,MAAO9B,EACP0B,IAAK,UAAUK,EAAsB/B,KACrCgC,UAAWrB,EAAKsB,EAAE,gCAAiC,CACjDH,MAAO9B,EACPkC,cAAe,CAACC,YAAa,WAK5B,MAAMC,EACXzB,IAKO,CACLe,IAAK,qBACLM,UAAWrB,EAAKsB,EAAE,wBAAyB,CACzCC,cAAe,CAACC,YAAa,SAE/BN,KAAM,6CACNQ,WAAY,OAIT,MAAMC,EAA8C,CAACC,EAAG9C,IAE3DoB,EAAA,OACEgB,KAAK,uBACLW,MAAM,yCAEL/C,GASA,MAAMgD,EAA6D,EACxEzB,UAGEH,EAAA,eACEgB,KAAK,oBACLb,KAAMA,EACNwB,MAAM,0BAUL,MAAME,EAA6D,EACxEZ,QACA9B,YAEA,GAAI8B,IAAU,GAAI,CAChB,OACEjB,EAAA,QAAMgB,KAAK,oBAAoBW,MAAM,0BAClCxC,E,CAIP,OACEa,EAAA,QACEgB,KAAK,oBACLW,MAAM,yBACNG,UAAWC,EAAeC,gBAAgB,CACxCjC,QAASZ,EACT8C,iBACE,8DACFC,iBAAkB,UAClBC,WAAY,CACV,CACEC,OAAQnB,EAAMV,OACdA,OAAQpB,EAAMoB,OAASU,EAAMV,YAI7B,EAQL,MAAM8B,EAA+D,EAC1EvC,UAGEE,EAAA,OAAKgB,KAAK,6BAA6BW,MAAM,+BAC3C3B,EAAA,QAAM2B,MAAM,YAAYX,KAAK,sBAC1BlB,EAAKsB,EAAE,oBAEVpB,EAAA,QAAMgB,KAAK,sBAAsBlB,EAAKsB,EAAE,W,MChFjCkB,EAA4B,M,yBAqBT1E,KAAAyB,aAAe,EAuDrCzB,KAAA2E,SAAWC,GAAK,IACtB5E,KAAKD,SAASK,OAAOyE,OAAOC,KAC1B,gF,2DAzDyC,E,+BAM7C,iBAAAjF,GACE,IACEC,GACGC,IACCC,KAAKD,SAAWA,EAChB,OAAOC,KAAKC,YAAY,GAE1BD,KAAKE,KACL,CAAC,qB,CAEH,MAAOC,GACPH,KAAKG,MAAQA,C,EAIT,UAAA4E,GACN,OAAO/E,KAAKuC,MAAQyC,C,CAGd,UAAA/E,GACND,KAAKiF,QAAU,IAAIC,EACnBlF,KAAKmF,kBAAoBC,EAAuBpF,KAAKD,SAASK,OAAQ,CACpEiF,aAAc,CAACC,QAAStF,KAAKuF,wBAC7BC,QAAS,CAACC,UAAW,IAAMC,aAAc1F,KAAKD,SAAS2F,gBAGzD1F,KAAKmF,kBAAkBQ,WAAU,IAAM3F,KAAK4F,uBAE5C,MAAO,CACLhF,SAAUC,MAAMC,KAAKd,KAAKE,KAAKa,WAAYC,UAAUC,QAAQjB,KAAKE,MAClEiB,YAAa,IAAMnB,KAAKmB,c,CAIpB,oBAAAoE,GACN,OAAOvF,KAAKiF,QAAQY,cAAcC,EAAaC,eAAgB,G,CAGzD,kBAAAH,GACN,IAAK5F,KAAKmF,kBAAkB7D,MAAM0E,iBAAkB,CAClD,OAAOhG,KAAKiG,gB,CAGd,OAAOjG,KAAKiF,QAAQiB,QAClBJ,EAAaC,eACb/F,KAAKmF,kBAAkB7D,MAAMgE,Q,CAUzB,cAAAW,GACNjG,KAAK2E,WACL3E,KAAKiF,QAAQkB,WAAWL,EAAaC,e,CAG/B,WAAA5E,GACN,IAAKnB,KAAKmF,kBAAkB7D,MAAM0E,iBAAkB,CAClD,MAAO,E,CAGT,MAAM3C,EAAQrD,KAAKD,SAASsB,oBAAoBC,MAAMC,MACtD,MAAMH,EAAWiC,IAAU,GAC3B,MAAM7B,EAAMJ,EAAWpB,KAAKyB,aAAezB,KAAK0B,gBAChD,MAAM0E,EAAkBpG,KAAKmF,kBAAkB7D,MAAMgE,QAClDe,QAAQC,GACPA,EAAYC,cAAcC,WAAWnD,EAAMkD,iBAE5C3E,MAAM,EAAGJ,GAEZ,MAAMiF,EACJL,EAAgBvE,KAAKN,GAAUvB,KAAK+B,WAAWR,KACjD,GAAIkF,EAAmB9D,OAAQ,CAC7B8D,EAAmBC,QAAQ1G,KAAK2G,c,CAGlC,OAAOF,C,CAGD,WAAAE,GACN,MAAM3E,EAAc2B,EAAkC3D,KAAKD,SAASmC,MAEpE,MAAO,IACFF,EACHG,QAASC,EAACqC,EAAgB,CAACvC,KAAMlC,KAAKD,SAASmC,OAC/CW,SAAU,KACR7C,KAAKmF,kBAAkByB,QACvB5G,KAAKD,SAAS8G,oBAAoB,E,CAKhC,UAAA9E,CAAWR,GACjB,MAAM8B,EAAQrD,KAAKD,SAASsB,oBAAoBC,MAAMC,MACtD,MAAMS,EAAcmB,EAA6B5B,EAAOvB,KAAKD,SAASmC,MACtE,MAAO,IACFF,EACHG,QACEC,EAACyB,EAAsB,KACrBzB,EAAC4B,EAAe,CAACzB,KAAMvC,KAAK+E,eAC5B3C,EAAC6B,EAAe,CAACZ,MAAOA,EAAO9B,MAAOA,KAI1CsB,SAAU,KACR,GAAI7C,KAAKD,SAAS+G,aAAc,CAC9B9G,KAAKD,SAASsB,oBAAoB0F,WAAWxF,GAC7CvB,KAAKD,SAASsB,oBAAoB2F,SAClC,M,CAGFhH,KAAKmF,kBAAkB8B,mBACrBjH,KAAKmF,kBAAkB7D,MAAMgE,QAAQrE,QAAQM,GAC9C,E,CAKA,MAAAyB,GACL,GAAIhD,KAAKG,MAAO,CACd,OACEiC,EAAA,0BAAAa,IAAA,2CACEC,QAASlD,KAAKE,KACdC,MAAOH,KAAKG,O","ignoreList":[]}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{h as t,f as s}from"./p-dc3df5ce.js";import{B as e}from"./p-b93ccff9.js";import{isNullOrUndefined as i}from"@coveo/bueno";import{D as n}from"./p-f284897c.js";import{d as r}from"./p-01c91b69.js";import{e as o,a}from"./p-7601c3de.js";const h=`<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">\n<circle cx="7" cy="7" r="6.5" stroke="currentColor"/>\n<path d="M16 16L12 12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>\n`;const u=(s,e)=>{const i=()=>{const t="flex bg-background w-full border border-neutral rounded-md focus-within:ring-3 absolute top-0 left-0";const e=s.disabled?"focus-within:border-disabled focus-within:ring-neutral":"focus-within:border-primary focus-within:ring-ring-primary";return[t,e].join(" ")};return t("div",{part:"wrapper",class:i(),onFocusout:s.onFocusout},e)};const c=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M15 1.00012L1.00012 14.9999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M0.999878 1L14.9999 15" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>\n`;const l=({inputRef:s,bindings:i,onClick:n,...r})=>t("div",{part:"clear-button-wrapper",class:"ml-2 flex items-center justify-center py-2"},t(e,{style:"text-transparent",part:"clear-button",class:"text-neutral-dark flex h-8 w-8 shrink-0 items-center justify-center",onClick:()=>{n?.();s?.focus()},ariaLabel:i.i18n.t("clear"),...r},t("atomic-icon",{part:"clear-icon",icon:c,class:"h-4 w-4"})));function g(t){return{autocomplete:"off",autocapitalize:"off",autocorrect:"off",...t.activeDescendant&&{"aria-activedescendant":t.activeDescendant},"aria-autocomplete":"both","aria-haspopup":"true","aria-controls":t.id}}function f(t,s){const e=t?.parentNode;if(!e){return}if(t.value==="\n"){return}e.dataset.replicatedValue=s??t.value}function d(t){const s=t?.parentNode;if(s){delete s.dataset.replicatedValue}}function p(t){const s=t?.parentNode;if(s){s.classList.remove("expanded")}}function m(t){const s=t?.parentNode;if(s){s.classList.add("expanded")}}const w=({textAreaRef:s,loading:e,bindings:i,onInput:n,onFocus:r,onBlur:o,onChange:a,onKeyDown:h,onKeyUp:u,value:c,ariaLabel:w,onClear:b,popup:v,...y})=>t("div",{class:"flex grow overflow-hidden"},t("div",{part:"textarea-expander",class:"grid grow overflow-hidden"},t("textarea",{part:"textarea","aria-label":w,placeholder:i.i18n.t("search"),class:"placeholder-neutral-dark",rows:1,onInput:t=>{n?.(t);f(s)},onKeyDown:t=>{f(s);if(t.key==="Enter"){if(t.shiftKey){return}t.preventDefault()}h?.(t)},onKeyUp:t=>{u?.(t);if(t.key==="Enter"){t.preventDefault();return}f(s)},onBlur:t=>{o?.(t);p(s);f(s)},onChange:t=>{a?.(t);f(s)},onFocus:t=>{r?.(t);const e=t.target;f(s??e);m(s??e)},autocomplete:"off",...v&&g(v),...y,value:c})),e&&t("div",{class:"searchbox-button-wrapper ml-2 flex items-center justify-center"},t("span",{part:"loading",class:"loading mr-2 grid h-5 w-5 animate-spin place-items-center rounded-full bg-linear-to-r"})),!e&&c&&t(l,{inputRef:s,bindings:i,onClick:()=>{b();d(s)}}));function b(t,s){let e;const i=new Promise(((t,i)=>{e=setTimeout((()=>{i(new Error("Promise timed out."))}),s)}));return Promise.race([t,i]).then((()=>{clearTimeout(e)}))}class v{constructor(t){this.ownerSearchBoxProps=t;this.suggestions=[];this.leftSuggestionElements=[];this.rightSuggestionElements=[];this.leftPanel=undefined;this.rightPanel=undefined;this.activeDescendant="";this.suggestedQuery="";this.keyboardActiveDescendant="";this.queryDataAttribute="data-query";this.suggestionEvents=[];this.previousActiveDescendantElement=null;this.leftSuggestions=[];this.rightSuggestions=[];this.triggerSuggestions=r((()=>this.executeQuerySuggestion()),this.ownerSearchBoxProps.getSuggestionDelay())}get partialSuggestionBindings(){return{suggestedQuery:()=>this.suggestedQuery,clearSuggestions:()=>this.clearSuggestions(),triggerSuggestions:()=>this.triggerSuggestions(),getSuggestions:()=>this.suggestions,getSuggestionElements:()=>this.allSuggestionElements}}get activeDescendantElement(){if(!this.hasActiveDescendant){return null}return this.leftPanel?.querySelector(`#${this.activeDescendant}`)||this.rightPanel?.querySelector(`#${this.activeDescendant}`)||null}onSubmit(){this.clickOnActiveElement();this.clearSuggestions()}updateActiveDescendant(t=""){this.activeDescendant=t;s(this.ownerSearchBoxProps.getHost())}updateKeyboardActiveDescendant(t=""){this.keyboardActiveDescendant=t}clickOnActiveElement(){this.activeDescendantElement?.click();this.updateActiveDescendant()}isRightPanelInFocus(){if(i(this.panelInFocus)||i(this.rightPanel)){return false}return this.panelInFocus===this.rightPanel}initializeSuggestions(t){this.suggestions=this.suggestionEvents.map((s=>s(t)))}registerSuggestionsFromEvent(t,s){t.preventDefault();t.stopPropagation();this.suggestionEvents.push(t.detail);this.suggestions.push(t.detail(s))}registerSuggestions(t){this.suggestions.push(t)}get isDoubleList(){return Boolean(this.leftSuggestionElements.length&&this.rightSuggestionElements.length)}focusPanel(t){const s=t==="left"?this.leftPanel:this.rightPanel;if(this.panelInFocus===s){return}if(s?.firstElementChild){const t=this.previousActiveDescendantElement&&s.contains(this.previousActiveDescendantElement);const e=t?this.previousActiveDescendantElement:s.firstElementChild;this.updateDescendants(e.id)}}clearSuggestions(){this.clearSuggestionElements();this.updateActiveDescendant()}async focusNextValue(){if(!this.hasSuggestions||!this.nextOrFirstValue){return}await this.focusValue(this.nextOrFirstValue)}async focusValue(t){this.updateKeyboardActiveDescendant(t.id);this.updateActiveDescendant(t.id);this.scrollActiveDescendantIntoView();await this.updateQueryFromSuggestion()}async onSuggestionMouseOver(t,s,e){const i=s==="left"?this.leftPanel:this.rightPanel;this.updateKeyboardActiveDescendant();if(this.panelInFocus===i){this.updateActiveDescendant(e)}else{this.updateDescendants(e)}if(t.query){await this.updateSuggestedQuery(t.query)}}async onSuggestionClick(t,s){if(t.query){this.clearSuggestions();await this.updateOwnerSearchboxQuery(t.query)}t.onSelect?.(s)}get hasSuggestions(){return!!this.allSuggestionElements.length}get allSuggestionElements(){return[...this.leftSuggestionElements,...this.rightSuggestionElements]}async focusPreviousValue(){if(this.firstValue===this.activeDescendantElement){this.updateKeyboardActiveDescendant();this.updateActiveDescendant();return}if(!this.hasSuggestions||!this.previousOrLastValue){return}await this.focusValue(this.previousOrLastValue)}get hasActiveDescendant(){return this.activeDescendant!==""}async executeQuerySuggestion(){this.updateActiveDescendant();const t=await Promise.allSettled(this.suggestions.map((t=>b(t.onInput?t.onInput():Promise.resolve(),this.ownerSearchBoxProps.getSuggestionTimeout()))));const s=[];t.forEach(((t,e)=>{if(t.status==="fulfilled"){s.push(this.suggestions[e])}else{this.ownerSearchBoxProps.getLogger().warn("Some query suggestions are not being shown because the promise timed out.")}}));const e=(t,e=false)=>s.filter((s=>s.panel===t||!s.panel&&e)).sort(this.sortSuggestions);this.leftSuggestions=e("left",true);this.leftSuggestionElements=this.getAndFilterLeftSuggestionElements();this.rightSuggestions=e("right");this.rightSuggestionElements=this.getSuggestionElements(this.rightSuggestions);const i=this.allSuggestionElements.find(o)?.query||"";await this.updateSuggestedQuery(i)}get lastValue(){return this.panelInFocus?.lastElementChild}get previousOrLastValue(){if(!this.hasActiveDescendant){return this.lastValue?.firstChild}const t=this.activeDescendantElement?.parentElement;return t?.previousElementSibling?.firstChild||this.firstValue?.firstChild}sortSuggestions(t,s){return t.position-s.position}get nextOrFirstValue(){if(!this.hasActiveDescendant){return this.firstValue?.firstChild}const t=this.activeDescendantElement?.parentElement;return t?.nextElementSibling?.firstChild||this.firstValue?.firstChild}get firstValue(){return this.panelInFocus?.firstElementChild}get panelInFocus(){if(this.leftPanel?.contains(this.activeDescendantElement)){return this.leftPanel}if(this.rightPanel?.contains(this.activeDescendantElement)){return this.rightPanel}return this.leftPanel||this.rightPanel}scrollActiveDescendantIntoView(){this.activeDescendantElement?.scrollIntoView({block:"nearest"})}async updateQueryFromSuggestion(){const t=this.activeDescendantElement?.getAttribute(this.queryDataAttribute);await this.updateOwnerSearchboxQuery(t||"")}async updateOwnerSearchboxQuery(t){if(t&&this.ownerSearchBoxProps.getSearchBoxValue()!==t){this.ownerSearchBoxProps.updateQuery(t);await this.updateSuggestedQuery(t)}}async updateSuggestedQuery(t){await Promise.allSettled(this.suggestions.map((s=>b(s.onSuggestedQueryChange?s.onSuggestedQueryChange(t):Promise.resolve(),this.ownerSearchBoxProps.getSuggestionTimeout()))));this.suggestedQuery=t;this.updateSuggestionElements(t);s(this.ownerSearchBoxProps.getHost())}updateSuggestionElements(t){if(!this.isPanelInFocus(this.leftPanel,t)){this.leftSuggestionElements=this.getAndFilterLeftSuggestionElements()}if(!this.isPanelInFocus(this.rightPanel,t)){this.rightSuggestionElements=this.getSuggestionElements(this.rightSuggestions)}}forceUpdate(){this.updateSuggestionElements(this.suggestedQuery);s(this.ownerSearchBoxProps.getHost())}isPanelInFocus(t,s){if(!this.activeDescendantElement){return false}if(s){const e=n.sanitize(s);return!!t?.querySelector(`[${this.queryDataAttribute}="${CSS.escape(e)}"]`)}return this.activeDescendantElement?.closest("ul")===t}getAndFilterLeftSuggestionElements(){const t=this.getSuggestionElements(this.leftSuggestions);const s=new Set;const e=t.filter((t=>{if(i(t.query)){return true}if(s.has(t.query)){return false}else{s.add(t.query);return true}}));return e}getSuggestionElements(t){const s=t.flatMap((t=>t.renderItems()));const e=this.ownerSearchBoxProps.getNumberOfSuggestionsToDisplay()+s.filter(a).length;return s.slice(0,e)}updateDescendants(t=""){const s=this.activeDescendantElement;this.previousActiveDescendantElement=s;this.updateActiveDescendant(t)}clearSuggestionElements(){this.leftSuggestionElements=[];this.rightSuggestionElements=[]}}export{v as S,h as a,w as b,u as c};
|
2
|
-
//# sourceMappingURL=p-29fd6768.js.map
|