@coveo/atomic 3.33.8-pre.f82c4ba7d3 → 3.33.8-pre.fb042f4f0e
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/atomic.esm.js.map +1 -1
- package/dist/atomic/components/_index.d.ts +2 -0
- package/dist/atomic/components/_index.js +1 -0
- 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-history-toggle.js +2 -2
- package/dist/atomic/components/atomic-insight-history-toggle.js.map +1 -1
- package/dist/atomic/components/atomic-insight-user-actions-toggle.js +2 -2
- package/dist/atomic/components/atomic-insight-user-actions-toggle.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-query-suggestions2.js +1 -1
- package/dist/atomic/components/atomic-search-box-recent-queries.d.ts +11 -0
- package/dist/atomic/components/atomic-search-box-recent-queries.js +8 -0
- package/dist/atomic/components/atomic-search-box-recent-queries.js.map +1 -0
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +183 -0
- package/dist/atomic/components/atomic-search-box-recent-queries2.js.map +1 -0
- package/dist/atomic/components/atomic-search-box.js +23 -6
- 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-tab-manager.js +1 -1
- package/dist/atomic/components/clock.js +2 -2
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +49 -7
- package/dist/atomic/components/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.js +2 -2
- 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 +12 -5
- package/dist/atomic/components/components/common/atomic-modal/atomic-modal.js +2 -0
- package/dist/atomic/components/components/search/index.js +0 -1
- package/dist/atomic/components/components/search/lazy-index.js +0 -1
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/{p-75e00690.entry.js → p-089be992.entry.js} +2 -2
- package/dist/atomic/{p-4b3d253b.entry.js → p-09a3a067.entry.js} +2 -2
- package/dist/atomic/{p-7b899b57.entry.js → p-1d1f54a5.entry.js} +2 -2
- package/dist/atomic/{p-ae98c582.entry.js → p-2ce8220a.entry.js} +2 -2
- package/dist/atomic/{p-877d35b1.entry.js → p-3b023e83.entry.js} +2 -2
- package/dist/atomic/{p-52ba404c.entry.js → p-49c38b27.entry.js} +2 -2
- package/dist/atomic/p-4c2f230f.entry.js +2 -0
- package/dist/atomic/p-4c2f230f.entry.js.map +1 -0
- package/dist/atomic/{p-299555fb.entry.js → p-4c41abd0.entry.js} +2 -2
- package/dist/atomic/{p-88d5e178.entry.js → p-51a4606d.entry.js} +2 -2
- package/dist/atomic/{p-0ce38b0d.entry.js → p-5528d006.entry.js} +2 -2
- package/dist/atomic/{p-d00a12e9.entry.js → p-5f1fa581.entry.js} +2 -2
- package/dist/atomic/{p-ba4bf29f.entry.js → p-6329ff94.entry.js} +2 -2
- package/dist/atomic/{p-7383fd32.entry.js → p-6e6d686e.entry.js} +2 -2
- package/dist/atomic/p-744da781.entry.js +2 -0
- package/dist/atomic/{p-c88a3d2d.entry.js.map → p-744da781.entry.js.map} +1 -1
- package/dist/atomic/{p-a760d9f9.entry.js → p-7e2109e9.entry.js} +2 -2
- package/dist/atomic/{p-b28011e6.entry.js → p-89085429.entry.js} +2 -2
- package/dist/atomic/{p-39e63678.entry.js → p-89ab44de.entry.js} +2 -2
- package/dist/atomic/{p-330e6e7c.entry.js → p-9c9b1965.entry.js} +2 -2
- package/dist/atomic/{p-78b70622.entry.js → p-a8882a2a.entry.js} +2 -2
- package/dist/atomic/{p-f22bcb8c.entry.js → p-b6963bae.entry.js} +2 -2
- package/dist/atomic/{p-3c8d109e.entry.js → p-b7063a0d.entry.js} +2 -2
- package/dist/atomic/{p-e1cc5150.js → p-c280cd05.js} +1 -1
- package/dist/atomic/{p-5bc31a30.js → p-dd761b10.js} +2 -2
- package/dist/atomic/{p-7b0b9e9b.entry.js → p-f289269f.entry.js} +2 -2
- package/dist/atomic/{p-c49cfa0c.entry.js → p-fda26113.entry.js} +2 -2
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/{analytics-config-68dbae8e.js → analytics-config-fa9c8790.js} +2 -2
- package/dist/cjs/{analytics-config-68dbae8e.js.map → analytics-config-fa9c8790.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-history-toggle.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-history-toggle.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-user-actions-toggle.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-user-actions-toggle.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-query-suggestions_2.cjs.entry.js +234 -0
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js.map +1 -0
- package/dist/cjs/atomic-search-box.cjs.entry.js +15 -4
- 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-tab-manager.cjs.entry.js +1 -1
- package/dist/cjs/atomic.cjs.js +1 -1
- package/dist/cjs/clock-f03ff827.js +7 -0
- package/dist/cjs/clock-f03ff827.js.map +1 -0
- package/dist/cjs/index-757bc886.js +2 -2
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_loader.js +1 -1
- package/dist/esm/{analytics-config-18d42f83.js → analytics-config-c51d0bc9.js} +2 -2
- package/dist/esm/{analytics-config-18d42f83.js.map → analytics-config-c51d0bc9.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-history-toggle.entry.js +2 -2
- package/dist/esm/atomic-insight-history-toggle.entry.js.map +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-insight-user-actions-toggle.entry.js +2 -2
- package/dist/esm/atomic-insight-user-actions-toggle.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-query-suggestions_2.entry.js +229 -0
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js.map +1 -0
- package/dist/esm/atomic-search-box.entry.js +15 -4
- 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-tab-manager.entry.js +1 -1
- package/dist/esm/atomic.js +1 -1
- package/dist/esm/clock-add3e9a5.js +5 -0
- package/dist/esm/clock-add3e9a5.js.map +1 -0
- package/dist/esm/index-3f35faca.js +2 -2
- 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 +1 -0
- package/dist/types/components/search/atomic-search-box/atomic-search-box.d.ts +1 -0
- package/dist/types/components/search/index.d.ts +0 -1
- package/dist/types/components/search/{atomic-search-box-recent-queries → search-box-suggestions/atomic-search-box-recent-queries}/atomic-search-box-recent-queries.d.ts +7 -15
- package/dist/types/components.d.ts +49 -0
- package/docs/atomic-docs.json +98 -1
- package/package.json +3 -3
- package/dist/atomic/components/components/search/atomic-search-box-recent-queries/atomic-search-box-recent-queries.js +0 -137
- package/dist/atomic/p-2e9db4ca.entry.js +0 -2
- package/dist/atomic/p-2e9db4ca.entry.js.map +0 -1
- package/dist/atomic/p-c88a3d2d.entry.js +0 -2
- package/dist/cjs/atomic-search-box-query-suggestions.cjs.entry.js +0 -76
- package/dist/cjs/atomic-search-box-query-suggestions.cjs.entry.js.map +0 -1
- package/dist/cjs/clock-7aeb19d0.js +0 -7
- package/dist/cjs/clock-7aeb19d0.js.map +0 -1
- package/dist/esm/atomic-search-box-query-suggestions.entry.js +0 -72
- package/dist/esm/atomic-search-box-query-suggestions.entry.js.map +0 -1
- package/dist/esm/clock-b1f5d7f7.js +0 -5
- package/dist/esm/clock-b1f5d7f7.js.map +0 -1
- /package/dist/atomic/{p-75e00690.entry.js.map → p-089be992.entry.js.map} +0 -0
- /package/dist/atomic/{p-4b3d253b.entry.js.map → p-09a3a067.entry.js.map} +0 -0
- /package/dist/atomic/{p-7b899b57.entry.js.map → p-1d1f54a5.entry.js.map} +0 -0
- /package/dist/atomic/{p-ae98c582.entry.js.map → p-2ce8220a.entry.js.map} +0 -0
- /package/dist/atomic/{p-877d35b1.entry.js.map → p-3b023e83.entry.js.map} +0 -0
- /package/dist/atomic/{p-52ba404c.entry.js.map → p-49c38b27.entry.js.map} +0 -0
- /package/dist/atomic/{p-299555fb.entry.js.map → p-4c41abd0.entry.js.map} +0 -0
- /package/dist/atomic/{p-88d5e178.entry.js.map → p-51a4606d.entry.js.map} +0 -0
- /package/dist/atomic/{p-0ce38b0d.entry.js.map → p-5528d006.entry.js.map} +0 -0
- /package/dist/atomic/{p-d00a12e9.entry.js.map → p-5f1fa581.entry.js.map} +0 -0
- /package/dist/atomic/{p-ba4bf29f.entry.js.map → p-6329ff94.entry.js.map} +0 -0
- /package/dist/atomic/{p-7383fd32.entry.js.map → p-6e6d686e.entry.js.map} +0 -0
- /package/dist/atomic/{p-a760d9f9.entry.js.map → p-7e2109e9.entry.js.map} +0 -0
- /package/dist/atomic/{p-b28011e6.entry.js.map → p-89085429.entry.js.map} +0 -0
- /package/dist/atomic/{p-39e63678.entry.js.map → p-89ab44de.entry.js.map} +0 -0
- /package/dist/atomic/{p-330e6e7c.entry.js.map → p-9c9b1965.entry.js.map} +0 -0
- /package/dist/atomic/{p-78b70622.entry.js.map → p-a8882a2a.entry.js.map} +0 -0
- /package/dist/atomic/{p-f22bcb8c.entry.js.map → p-b6963bae.entry.js.map} +0 -0
- /package/dist/atomic/{p-3c8d109e.entry.js.map → p-b7063a0d.entry.js.map} +0 -0
- /package/dist/atomic/{p-e1cc5150.js.map → p-c280cd05.js.map} +0 -0
- /package/dist/atomic/{p-5bc31a30.js.map → p-dd761b10.js.map} +0 -0
- /package/dist/atomic/{p-7b0b9e9b.entry.js.map → p-f289269f.entry.js.map} +0 -0
- /package/dist/atomic/{p-c49cfa0c.entry.js.map → p-fda26113.entry.js.map} +0 -0
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,6 +137,7 @@ export declare class AtomicCommerceSearchBox extends LitElement implements Initi
|
|
137
137
|
private renderSuggestions;
|
138
138
|
private renderPanel;
|
139
139
|
private renderSuggestion;
|
140
|
+
private renderSlotContent;
|
140
141
|
render(): import("lit-html").TemplateResult<1>;
|
141
142
|
}
|
142
143
|
declare global {
|
@@ -161,5 +161,6 @@ export declare class AtomicSearchBox implements InitializableComponent<Bindings>
|
|
161
161
|
private getSearchInputLabel;
|
162
162
|
private announceNewActiveSuggestionToScreenReader;
|
163
163
|
private announceNewSuggestionsToScreenReader;
|
164
|
+
private renderSlotContent;
|
164
165
|
render(): any;
|
165
166
|
}
|
@@ -1,4 +1,3 @@
|
|
1
1
|
export { AtomicQuerySummary } from './atomic-query-summary/atomic-query-summary.js';
|
2
2
|
export { AtomicResultsPerPage } from './atomic-results-per-page/atomic-results-per-page.js';
|
3
|
-
export { AtomicSearchBoxRecentQueries } from './atomic-search-box-recent-queries/atomic-search-box-recent-queries.js';
|
4
3
|
export { AtomicSearchLayout } from './atomic-search-layout/atomic-search-layout.js';
|
@@ -1,15 +1,11 @@
|
|
1
|
-
import { type SearchBox } from '@coveo/headless';
|
2
|
-
import { LitElement } from 'lit';
|
3
|
-
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
4
|
-
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../common/suggestions/suggestions-types';
|
5
|
-
import type { Bindings } from '../atomic-search-interface/interfaces';
|
6
1
|
/**
|
7
2
|
* 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.
|
8
3
|
*/
|
9
|
-
export declare class AtomicSearchBoxRecentQueries
|
10
|
-
bindings
|
4
|
+
export declare class AtomicSearchBoxRecentQueries {
|
5
|
+
private bindings;
|
11
6
|
private recentQueriesList;
|
12
7
|
private storage;
|
8
|
+
private host;
|
13
9
|
error: Error;
|
14
10
|
/**
|
15
11
|
* The SVG icon to display.
|
@@ -27,8 +23,9 @@ export declare class AtomicSearchBoxRecentQueries extends LitElement implements
|
|
27
23
|
* The maximum number of suggestions that will be displayed initially when the input field is empty.
|
28
24
|
*/
|
29
25
|
maxWithoutQuery?: number;
|
30
|
-
|
31
|
-
|
26
|
+
componentWillLoad(): void;
|
27
|
+
private renderIcon;
|
28
|
+
private initialize;
|
32
29
|
private retrieveLocalStorage;
|
33
30
|
private updateLocalStorage;
|
34
31
|
private warnUser;
|
@@ -36,10 +33,5 @@ export declare class AtomicSearchBoxRecentQueries extends LitElement implements
|
|
36
33
|
private renderItems;
|
37
34
|
private renderClear;
|
38
35
|
private renderItem;
|
39
|
-
render():
|
40
|
-
}
|
41
|
-
declare global {
|
42
|
-
interface HTMLElementTagNameMap {
|
43
|
-
'atomic-search-box-recent-queries': AtomicSearchBoxRecentQueries;
|
44
|
-
}
|
36
|
+
render(): any;
|
45
37
|
}
|
@@ -2432,6 +2432,23 @@ export namespace Components {
|
|
2432
2432
|
*/
|
2433
2433
|
"maxWithoutQuery"?: number;
|
2434
2434
|
}
|
2435
|
+
/**
|
2436
|
+
* 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.
|
2437
|
+
*/
|
2438
|
+
interface AtomicSearchBoxRecentQueries {
|
2439
|
+
/**
|
2440
|
+
* The SVG icon to display. - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location. - Use a value that starts with `assets://`, to display an icon from the Atomic package. - Use a stringified SVG to display it directly.
|
2441
|
+
*/
|
2442
|
+
"icon"?: string;
|
2443
|
+
/**
|
2444
|
+
* The maximum number of suggestions that will be displayed if the user has typed something into the input field.
|
2445
|
+
*/
|
2446
|
+
"maxWithQuery": number;
|
2447
|
+
/**
|
2448
|
+
* The maximum number of suggestions that will be displayed initially when the input field is empty.
|
2449
|
+
*/
|
2450
|
+
"maxWithoutQuery"?: number;
|
2451
|
+
}
|
2435
2452
|
/**
|
2436
2453
|
* The `atomic-search-interface` component is the parent to all other atomic components in a search page. It handles the headless search engine and localization configurations.
|
2437
2454
|
*/
|
@@ -4186,6 +4203,15 @@ declare global {
|
|
4186
4203
|
prototype: HTMLAtomicSearchBoxQuerySuggestionsElement;
|
4187
4204
|
new (): HTMLAtomicSearchBoxQuerySuggestionsElement;
|
4188
4205
|
};
|
4206
|
+
/**
|
4207
|
+
* 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.
|
4208
|
+
*/
|
4209
|
+
interface HTMLAtomicSearchBoxRecentQueriesElement extends Components.AtomicSearchBoxRecentQueries, HTMLStencilElement {
|
4210
|
+
}
|
4211
|
+
var HTMLAtomicSearchBoxRecentQueriesElement: {
|
4212
|
+
prototype: HTMLAtomicSearchBoxRecentQueriesElement;
|
4213
|
+
new (): HTMLAtomicSearchBoxRecentQueriesElement;
|
4214
|
+
};
|
4189
4215
|
/**
|
4190
4216
|
* The `atomic-search-interface` component is the parent to all other atomic components in a search page. It handles the headless search engine and localization configurations.
|
4191
4217
|
*/
|
@@ -4590,6 +4616,7 @@ declare global {
|
|
4590
4616
|
"atomic-search-box": HTMLAtomicSearchBoxElement;
|
4591
4617
|
"atomic-search-box-instant-results": HTMLAtomicSearchBoxInstantResultsElement;
|
4592
4618
|
"atomic-search-box-query-suggestions": HTMLAtomicSearchBoxQuerySuggestionsElement;
|
4619
|
+
"atomic-search-box-recent-queries": HTMLAtomicSearchBoxRecentQueriesElement;
|
4593
4620
|
"atomic-search-interface": HTMLAtomicSearchInterfaceElement;
|
4594
4621
|
"atomic-segmented-facet": HTMLAtomicSegmentedFacetElement;
|
4595
4622
|
"atomic-segmented-facet-scrollable": HTMLAtomicSegmentedFacetScrollableElement;
|
@@ -6872,6 +6899,23 @@ declare namespace LocalJSX {
|
|
6872
6899
|
*/
|
6873
6900
|
"maxWithoutQuery"?: number;
|
6874
6901
|
}
|
6902
|
+
/**
|
6903
|
+
* 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.
|
6904
|
+
*/
|
6905
|
+
interface AtomicSearchBoxRecentQueries {
|
6906
|
+
/**
|
6907
|
+
* The SVG icon to display. - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location. - Use a value that starts with `assets://`, to display an icon from the Atomic package. - Use a stringified SVG to display it directly.
|
6908
|
+
*/
|
6909
|
+
"icon"?: string;
|
6910
|
+
/**
|
6911
|
+
* The maximum number of suggestions that will be displayed if the user has typed something into the input field.
|
6912
|
+
*/
|
6913
|
+
"maxWithQuery"?: number;
|
6914
|
+
/**
|
6915
|
+
* The maximum number of suggestions that will be displayed initially when the input field is empty.
|
6916
|
+
*/
|
6917
|
+
"maxWithoutQuery"?: number;
|
6918
|
+
}
|
6875
6919
|
/**
|
6876
6920
|
* The `atomic-search-interface` component is the parent to all other atomic components in a search page. It handles the headless search engine and localization configurations.
|
6877
6921
|
*/
|
@@ -7444,6 +7488,7 @@ declare namespace LocalJSX {
|
|
7444
7488
|
"atomic-search-box": AtomicSearchBox;
|
7445
7489
|
"atomic-search-box-instant-results": AtomicSearchBoxInstantResults;
|
7446
7490
|
"atomic-search-box-query-suggestions": AtomicSearchBoxQuerySuggestions;
|
7491
|
+
"atomic-search-box-recent-queries": AtomicSearchBoxRecentQueries;
|
7447
7492
|
"atomic-search-interface": AtomicSearchInterface;
|
7448
7493
|
"atomic-segmented-facet": AtomicSegmentedFacet;
|
7449
7494
|
"atomic-segmented-facet-scrollable": AtomicSegmentedFacetScrollable;
|
@@ -7960,6 +8005,10 @@ declare module "@stencil/core" {
|
|
7960
8005
|
* 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.
|
7961
8006
|
*/
|
7962
8007
|
"atomic-search-box-query-suggestions": LocalJSX.AtomicSearchBoxQuerySuggestions & JSXBase.HTMLAttributes<HTMLAtomicSearchBoxQuerySuggestionsElement>;
|
8008
|
+
/**
|
8009
|
+
* 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.
|
8010
|
+
*/
|
8011
|
+
"atomic-search-box-recent-queries": LocalJSX.AtomicSearchBoxRecentQueries & JSXBase.HTMLAttributes<HTMLAtomicSearchBoxRecentQueriesElement>;
|
7963
8012
|
/**
|
7964
8013
|
* The `atomic-search-interface` component is the parent to all other atomic components in a search page. It handles the headless search engine and localization configurations.
|
7965
8014
|
*/
|
package/docs/atomic-docs.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "2025-09-
|
2
|
+
"timestamp": "2025-09-30T16:46:54",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
5
|
"version": "4.20.0",
|
@@ -12480,11 +12480,13 @@
|
|
12480
12480
|
"dependents": [],
|
12481
12481
|
"dependencies": [
|
12482
12482
|
"atomic-suggestion-renderer",
|
12483
|
+
"atomic-search-box-recent-queries",
|
12483
12484
|
"atomic-search-box-query-suggestions"
|
12484
12485
|
],
|
12485
12486
|
"dependencyGraph": {
|
12486
12487
|
"atomic-search-box": [
|
12487
12488
|
"atomic-suggestion-renderer",
|
12489
|
+
"atomic-search-box-recent-queries",
|
12488
12490
|
"atomic-search-box-query-suggestions"
|
12489
12491
|
]
|
12490
12492
|
}
|
@@ -12803,6 +12805,101 @@
|
|
12803
12805
|
]
|
12804
12806
|
}
|
12805
12807
|
},
|
12808
|
+
{
|
12809
|
+
"filePath": "src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.tsx",
|
12810
|
+
"encapsulation": "shadow",
|
12811
|
+
"tag": "atomic-search-box-recent-queries",
|
12812
|
+
"docs": "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.",
|
12813
|
+
"docsTags": [],
|
12814
|
+
"usage": {},
|
12815
|
+
"props": [
|
12816
|
+
{
|
12817
|
+
"name": "icon",
|
12818
|
+
"type": "string | undefined",
|
12819
|
+
"complexType": {
|
12820
|
+
"original": "string",
|
12821
|
+
"resolved": "string | undefined",
|
12822
|
+
"references": {}
|
12823
|
+
},
|
12824
|
+
"mutable": false,
|
12825
|
+
"attr": "icon",
|
12826
|
+
"reflectToAttr": false,
|
12827
|
+
"docs": "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.",
|
12828
|
+
"docsTags": [],
|
12829
|
+
"values": [
|
12830
|
+
{
|
12831
|
+
"type": "string"
|
12832
|
+
},
|
12833
|
+
{
|
12834
|
+
"type": "undefined"
|
12835
|
+
}
|
12836
|
+
],
|
12837
|
+
"optional": true,
|
12838
|
+
"required": false
|
12839
|
+
},
|
12840
|
+
{
|
12841
|
+
"name": "maxWithQuery",
|
12842
|
+
"type": "number",
|
12843
|
+
"complexType": {
|
12844
|
+
"original": "number",
|
12845
|
+
"resolved": "number",
|
12846
|
+
"references": {}
|
12847
|
+
},
|
12848
|
+
"mutable": false,
|
12849
|
+
"attr": "max-with-query",
|
12850
|
+
"reflectToAttr": true,
|
12851
|
+
"docs": "The maximum number of suggestions that will be displayed if the user has typed something into the input field.",
|
12852
|
+
"docsTags": [],
|
12853
|
+
"default": "3",
|
12854
|
+
"values": [
|
12855
|
+
{
|
12856
|
+
"type": "number"
|
12857
|
+
}
|
12858
|
+
],
|
12859
|
+
"optional": false,
|
12860
|
+
"required": false
|
12861
|
+
},
|
12862
|
+
{
|
12863
|
+
"name": "maxWithoutQuery",
|
12864
|
+
"type": "number | undefined",
|
12865
|
+
"complexType": {
|
12866
|
+
"original": "number",
|
12867
|
+
"resolved": "number | undefined",
|
12868
|
+
"references": {}
|
12869
|
+
},
|
12870
|
+
"mutable": false,
|
12871
|
+
"attr": "max-without-query",
|
12872
|
+
"reflectToAttr": true,
|
12873
|
+
"docs": "The maximum number of suggestions that will be displayed initially when the input field is empty.",
|
12874
|
+
"docsTags": [],
|
12875
|
+
"values": [
|
12876
|
+
{
|
12877
|
+
"type": "number"
|
12878
|
+
},
|
12879
|
+
{
|
12880
|
+
"type": "undefined"
|
12881
|
+
}
|
12882
|
+
],
|
12883
|
+
"optional": true,
|
12884
|
+
"required": false
|
12885
|
+
}
|
12886
|
+
],
|
12887
|
+
"methods": [],
|
12888
|
+
"events": [],
|
12889
|
+
"listeners": [],
|
12890
|
+
"styles": [],
|
12891
|
+
"slots": [],
|
12892
|
+
"parts": [],
|
12893
|
+
"dependents": [
|
12894
|
+
"atomic-search-box"
|
12895
|
+
],
|
12896
|
+
"dependencies": [],
|
12897
|
+
"dependencyGraph": {
|
12898
|
+
"atomic-search-box": [
|
12899
|
+
"atomic-search-box-recent-queries"
|
12900
|
+
]
|
12901
|
+
}
|
12902
|
+
},
|
12806
12903
|
{
|
12807
12904
|
"filePath": "src/components/search/atomic-search-interface/atomic-search-interface.tsx",
|
12808
12905
|
"encapsulation": "shadow",
|
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.fb042f4f0e",
|
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.1-pre.
|
84
|
+
"@coveo/headless": "3.31.1-pre.fb042f4f0e",
|
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.1-pre.
|
156
|
+
"@coveo/headless": "3.31.1-pre.fb042f4f0e",
|
157
157
|
"typescript": ">=5.0.0"
|
158
158
|
},
|
159
159
|
"peerDependenciesMeta": {
|
@@ -1,137 +0,0 @@
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
-
};
|
7
|
-
import { buildRecentQueriesList, } from '@coveo/headless';
|
8
|
-
import { html, LitElement, nothing } from 'lit';
|
9
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
10
|
-
import { errorGuard } from "../../../decorators/error-guard";
|
11
|
-
import { SafeStorage, StorageItems } from "../../../utils/local-storage-utils";
|
12
|
-
import { once } from "../../../utils/utils";
|
13
|
-
const Clock = "<svg fill=\"none\" stroke=\"currentColor\" stroke-linejoin=\"round\" stroke-linecap=\"round\" viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"8\" cy=\"8\" r=\"7.5\"/><path d=\"m8.5 4.5v4\"/><path d=\"m10.3066 10.1387-1.80932-1.5768\"/></svg>";
|
14
|
-
import { getPartialRecentQueryClearElement, getPartialRecentQueryElement, renderRecentQuery, renderRecentQueryClear, } from '../../common/suggestions/recent-queries';
|
15
|
-
import { dispatchSearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-events';
|
16
|
-
/**
|
17
|
-
* 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.
|
18
|
-
*/
|
19
|
-
let AtomicSearchBoxRecentQueries = class AtomicSearchBoxRecentQueries extends LitElement {
|
20
|
-
constructor() {
|
21
|
-
super(...arguments);
|
22
|
-
/**
|
23
|
-
* The maximum number of suggestions that will be displayed if the user has typed something into the input field.
|
24
|
-
*/
|
25
|
-
this.maxWithQuery = 3;
|
26
|
-
this.warnUser = once(() => this.bindings.engine.logger.warn('Because analytics are disabled, the recent queries feature is deactivated.'));
|
27
|
-
}
|
28
|
-
connectedCallback() {
|
29
|
-
super.connectedCallback();
|
30
|
-
try {
|
31
|
-
dispatchSearchBoxSuggestionsEvent((bindings) => {
|
32
|
-
this.bindings = bindings;
|
33
|
-
return this.initialize();
|
34
|
-
}, this, ['atomic-search-box']);
|
35
|
-
}
|
36
|
-
catch (error) {
|
37
|
-
this.error = error;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
initialize() {
|
41
|
-
this.storage = new SafeStorage();
|
42
|
-
this.recentQueriesList = buildRecentQueriesList(this.bindings.engine, {
|
43
|
-
initialState: { queries: this.retrieveLocalStorage() },
|
44
|
-
options: {
|
45
|
-
maxLength: 1000,
|
46
|
-
clearFilters: this.bindings.clearFilters,
|
47
|
-
},
|
48
|
-
});
|
49
|
-
this.recentQueriesList.subscribe(() => this.updateLocalStorage());
|
50
|
-
return {
|
51
|
-
position: Array.from(this.parentNode.children).indexOf(this),
|
52
|
-
renderItems: () => this.renderItems(),
|
53
|
-
};
|
54
|
-
}
|
55
|
-
retrieveLocalStorage() {
|
56
|
-
return this.storage.getParsedJSON(StorageItems.RECENT_QUERIES, []);
|
57
|
-
}
|
58
|
-
updateLocalStorage() {
|
59
|
-
if (!this.recentQueriesList.state.analyticsEnabled) {
|
60
|
-
return this.disableFeature();
|
61
|
-
}
|
62
|
-
return this.storage.setJSON(StorageItems.RECENT_QUERIES, this.recentQueriesList.state.queries);
|
63
|
-
}
|
64
|
-
disableFeature() {
|
65
|
-
this.warnUser();
|
66
|
-
this.storage.removeItem(StorageItems.RECENT_QUERIES);
|
67
|
-
}
|
68
|
-
renderItems() {
|
69
|
-
if (!this.recentQueriesList.state.analyticsEnabled) {
|
70
|
-
return [];
|
71
|
-
}
|
72
|
-
const query = this.bindings.searchBoxController.state.value;
|
73
|
-
const hasQuery = query !== '';
|
74
|
-
const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;
|
75
|
-
const filteredQueries = this.recentQueriesList.state.queries
|
76
|
-
.filter((recentQuery) => recentQuery.toLowerCase().startsWith(query.toLowerCase()))
|
77
|
-
.slice(0, max);
|
78
|
-
const suggestionElements = filteredQueries.map((value) => this.renderItem(value));
|
79
|
-
if (suggestionElements.length) {
|
80
|
-
suggestionElements.unshift(this.renderClear());
|
81
|
-
}
|
82
|
-
return suggestionElements;
|
83
|
-
}
|
84
|
-
renderClear() {
|
85
|
-
const partialItem = getPartialRecentQueryClearElement(this.bindings.i18n);
|
86
|
-
return {
|
87
|
-
...partialItem,
|
88
|
-
content: renderRecentQueryClear({ i18n: this.bindings.i18n }),
|
89
|
-
onSelect: () => {
|
90
|
-
this.recentQueriesList.clear();
|
91
|
-
this.bindings.triggerSuggestions();
|
92
|
-
},
|
93
|
-
};
|
94
|
-
}
|
95
|
-
renderItem(value) {
|
96
|
-
const query = this.bindings.searchBoxController.state.value;
|
97
|
-
const partialItem = getPartialRecentQueryElement(value, this.bindings.i18n);
|
98
|
-
return {
|
99
|
-
...partialItem,
|
100
|
-
content: renderRecentQuery({
|
101
|
-
icon: this.icon || Clock,
|
102
|
-
query,
|
103
|
-
value,
|
104
|
-
}),
|
105
|
-
onSelect: () => {
|
106
|
-
if (this.bindings.isStandalone) {
|
107
|
-
this.bindings.searchBoxController.updateText(value);
|
108
|
-
this.bindings.searchBoxController.submit();
|
109
|
-
return;
|
110
|
-
}
|
111
|
-
this.recentQueriesList.executeRecentQuery(this.recentQueriesList.state.queries.indexOf(value));
|
112
|
-
},
|
113
|
-
};
|
114
|
-
}
|
115
|
-
render() {
|
116
|
-
return html `${nothing}`;
|
117
|
-
}
|
118
|
-
};
|
119
|
-
__decorate([
|
120
|
-
state()
|
121
|
-
], AtomicSearchBoxRecentQueries.prototype, "error", void 0);
|
122
|
-
__decorate([
|
123
|
-
property()
|
124
|
-
], AtomicSearchBoxRecentQueries.prototype, "icon", void 0);
|
125
|
-
__decorate([
|
126
|
-
property({ type: Number, attribute: 'max-with-query' })
|
127
|
-
], AtomicSearchBoxRecentQueries.prototype, "maxWithQuery", void 0);
|
128
|
-
__decorate([
|
129
|
-
property({ type: Number, attribute: 'max-without-query' })
|
130
|
-
], AtomicSearchBoxRecentQueries.prototype, "maxWithoutQuery", void 0);
|
131
|
-
__decorate([
|
132
|
-
errorGuard()
|
133
|
-
], AtomicSearchBoxRecentQueries.prototype, "render", null);
|
134
|
-
AtomicSearchBoxRecentQueries = __decorate([
|
135
|
-
customElement('atomic-search-box-recent-queries')
|
136
|
-
], AtomicSearchBoxRecentQueries);
|
137
|
-
export { AtomicSearchBoxRecentQueries };
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{r as t,h as s,g as e}from"./p-dc3df5ce.js";import{loadQuerySuggestActions as i}from"@coveo/headless";import{S as r}from"./p-cfb3c589.js";import{g as o,Q as n,a as h,b as c}from"./p-af93b44c.js";import{d as a}from"./p-4b7a19db.js";import"./p-8f5830b4.js";import"./p-c9074946.js";import"./p-1580513b.js";const d=class{constructor(s){t(this,s);this.error=undefined;this.icon=undefined;this.maxWithQuery=undefined;this.maxWithoutQuery=undefined}componentWillLoad(){try{a((t=>{this.bindings=t;return this.initialize()}),this.host,["atomic-search-box"])}catch(t){this.error=t}}initialize(){const t=this.bindings.engine;const{registerQuerySuggest:s,fetchQuerySuggestions:e}=i(t);t.dispatch(s({id:this.bindings.id,count:this.bindings.numberOfQueries}));return{position:Array.from(this.host.parentNode.children).indexOf(this.host),onInput:()=>t.dispatch(e({id:this.bindings.id})),renderItems:()=>this.renderItems()}}renderItems(){const t=this.bindings.searchBoxController.state.value!=="";const s=t?this.maxWithQuery:this.maxWithoutQuery;return this.bindings.searchBoxController.state.suggestions.slice(0,s).map((t=>this.renderItem(t)))}renderItem(t){const e=this.bindings.searchBoxController.state.value!=="";const i=o(t,this.bindings.i18n);return{...i,content:s(c,null,s(h,{icon:this.icon||r,hasSuggestion:this.bindings.getSuggestions().length>1}),s(n,{suggestion:t,hasQuery:e})),onSelect:()=>{this.bindings.searchBoxController.selectSuggestion(t.rawValue)}}}render(){if(this.error){return s("atomic-component-error",{key:"818ed7b1734a6f2cbf721b1eb3fd03d020791e9e",element:this.host,error:this.error})}}get host(){return e(this)}};export{d as atomic_search_box_query_suggestions};
|
2
|
-
//# sourceMappingURL=p-2e9db4ca.entry.js.map
|
@@ -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"],"sources":["src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.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} from '../../../common/suggestions/suggestions-events';\nimport type {\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n} from '../../../common/suggestions/suggestions-types';\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"],"mappings":"2TA8BaA,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","ignoreList":[]}
|