@coveo/atomic 3.33.8-pre.9cacc0cb9c → 3.33.8-pre.9f7e197648
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 -2
- package/dist/atomic/components/_index.js +1 -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-history-toggle.js +2 -2
- package/dist/atomic/components/atomic-insight-history-toggle.js.map +1 -1
- package/dist/atomic/components/atomic-insight-search-box.js +29 -2
- package/dist/atomic/components/atomic-insight-search-box.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-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 +18 -7
- 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/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js +107 -0
- package/dist/atomic/components/components/search/index.js +1 -1
- package/dist/atomic/components/components/search/lazy-index.js +1 -1
- package/dist/atomic/components/global/environment.js +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-ae98c582.entry.js → p-11a2e38a.entry.js} +2 -2
- package/dist/atomic/{p-7b899b57.entry.js → p-1d1f54a5.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-3ac0a150.entry.js → p-5152e964.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-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-b0287ff8.entry.js +2 -0
- package/dist/atomic/p-b0287ff8.entry.js.map +1 -0
- 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-39e63678.entry.js → p-cd62de88.entry.js} +2 -2
- package/dist/atomic/p-d2b14ff1.entry.js +2 -0
- package/dist/atomic/p-d2b14ff1.entry.js.map +1 -0
- package/dist/atomic/{p-7b0b9e9b.entry.js → p-f289269f.entry.js} +2 -2
- package/dist/atomic/{p-01336eda.entry.js → p-f5e2c49f.entry.js} +2 -2
- package/dist/atomic/{p-992b3f11.entry.js → p-f8d3f353.entry.js} +2 -2
- package/dist/atomic/{p-c49cfa0c.entry.js → p-fda26113.entry.js} +2 -2
- package/dist/atomic/{p-1ef117be.js → p-fecf67fa.js} +2 -2
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/{analytics-config-32b7c6ab.js → analytics-config-ad34bbcc.js} +2 -2
- package/dist/cjs/{analytics-config-32b7c6ab.js.map → analytics-config-ad34bbcc.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-search-box.cjs.entry.js +30 -4
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +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-recent-queries.cjs.entry.js +171 -0
- package/dist/cjs/atomic-search-box-recent-queries.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-709e0114.js → analytics-config-015e3a98.js} +2 -2
- package/dist/esm/{analytics-config-709e0114.js.map → analytics-config-015e3a98.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-search-box.entry.js +29 -3
- package/dist/esm/atomic-insight-search-box.entry.js.map +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-recent-queries.entry.js +167 -0
- package/dist/esm/atomic-search-box-recent-queries.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/{atomic-search-box-recent-queries/atomic-search-box-recent-queries.d.ts → atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.d.ts} +5 -12
- package/dist/types/components/search/index.d.ts +1 -1
- package/dist/types/components/search/search-box-suggestions/{atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.d.ts → atomic-search-box-recent-queries/atomic-search-box-recent-queries.d.ts} +11 -3
- package/dist/types/components.d.ts +14 -14
- package/docs/atomic-docs.json +11 -13
- package/package.json +3 -3
- package/dist/atomic/components/atomic-search-box-query-suggestions.d.ts +0 -11
- package/dist/atomic/components/atomic-search-box-query-suggestions.js +0 -8
- package/dist/atomic/components/atomic-search-box-query-suggestions.js.map +0 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +0 -89
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +0 -1
- package/dist/atomic/components/components/search/atomic-search-box-recent-queries/atomic-search-box-recent-queries.js +0 -139
- package/dist/atomic/components/stencil-query-suggestions.js +0 -33
- package/dist/atomic/components/stencil-query-suggestions.js.map +0 -1
- package/dist/atomic/p-26a51a77.entry.js +0 -2
- package/dist/atomic/p-26a51a77.entry.js.map +0 -1
- package/dist/atomic/p-2e9db4ca.entry.js +0 -2
- package/dist/atomic/p-2e9db4ca.entry.js.map +0 -1
- package/dist/atomic/p-af93b44c.js +0 -2
- package/dist/atomic/p-af93b44c.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/cjs/stencil-query-suggestions-03268ecc.js +0 -38
- package/dist/cjs/stencil-query-suggestions-03268ecc.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/esm/stencil-query-suggestions-5d6a46d7.js +0 -33
- package/dist/esm/stencil-query-suggestions-5d6a46d7.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-ae98c582.entry.js.map → p-11a2e38a.entry.js.map} +0 -0
- /package/dist/atomic/{p-7b899b57.entry.js.map → p-1d1f54a5.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-3ac0a150.entry.js.map → p-5152e964.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-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-39e63678.entry.js.map → p-cd62de88.entry.js.map} +0 -0
- /package/dist/atomic/{p-7b0b9e9b.entry.js.map → p-f289269f.entry.js.map} +0 -0
- /package/dist/atomic/{p-01336eda.entry.js.map → p-f5e2c49f.entry.js.map} +0 -0
- /package/dist/atomic/{p-992b3f11.entry.js.map → p-f8d3f353.entry.js.map} +0 -0
- /package/dist/atomic/{p-c49cfa0c.entry.js.map → p-fda26113.entry.js.map} +0 -0
- /package/dist/atomic/{p-1ef117be.js.map → p-fecf67fa.js.map} +0 -0
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { buildCommerceEngine, buildContext, buildProductListing, buildSearch, VERSION as HEADLESS_VERSION, loadConfigurationActions, loadQueryActions, } from '@coveo/headless/commerce';
|
|
7
|
+
import { buildCommerceEngine, buildContext, buildProductListing, buildSearch, VERSION as HEADLESS_VERSION, loadConfigurationActions, loadContextActions, loadQueryActions, } from '@coveo/headless/commerce';
|
|
8
8
|
import { provide } from '@lit/context';
|
|
9
9
|
import i18next from 'i18next';
|
|
10
10
|
import { css, html, LitElement } from 'lit';
|
|
@@ -144,6 +144,41 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
144
144
|
this.searchOrListing.executeFirstRequest();
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Updates the locale settings for the commerce interface and headless commerce
|
|
149
|
+
* engine. Only the provided parameters will be updated.
|
|
150
|
+
*
|
|
151
|
+
* Calling this method affects the localization of the interface as well as
|
|
152
|
+
* the catalog configuration being used by the Commerce API. If the resulting
|
|
153
|
+
* language-country-currency combination matches no existing catalog
|
|
154
|
+
* configuration in your Coveo organization, requests made through the
|
|
155
|
+
* commerce engine will start failing.
|
|
156
|
+
*
|
|
157
|
+
* @param language - (Optional) The IETF language code tag (e.g., `en`).
|
|
158
|
+
* @param country - (Optional) The ISO-3166-1 country tag (e.g., `US`).
|
|
159
|
+
* @param currency - (Optional) The ISO-4217 currency code (e.g., `USD`).
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* interface.updateLocale('fr', 'CA', 'CAD');
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
updateLocale(language, country, currency) {
|
|
167
|
+
if (!this.interfaceController.engineIsCreated(this.engine) ||
|
|
168
|
+
!this.context) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
language && this.interfaceController.onLanguageChange(language);
|
|
172
|
+
if (this.isNewLocale(language, country, currency)) {
|
|
173
|
+
const { setContext } = loadContextActions(this.engine);
|
|
174
|
+
this.engine.dispatch(setContext({
|
|
175
|
+
...this.context.state,
|
|
176
|
+
...(language && { language }),
|
|
177
|
+
...(country && { country }),
|
|
178
|
+
...(currency && { currency }),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
147
182
|
toggleAnalytics() {
|
|
148
183
|
this.interfaceController.onAnalyticsChange();
|
|
149
184
|
}
|
|
@@ -157,11 +192,10 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
157
192
|
!this.context) {
|
|
158
193
|
return;
|
|
159
194
|
}
|
|
160
|
-
|
|
195
|
+
this.engine.logger.warn('The `language` property will be removed in the next major version of Atomic (v4). Rather than using this property, set the initial language through the engine configuration when calling `initialize` or `initializeWithEngine`, and update the language as needed using the `updateLocale` method.');
|
|
161
196
|
this.context.setLanguage(this.language);
|
|
162
197
|
return this.interfaceController.onLanguageChange();
|
|
163
198
|
}
|
|
164
|
-
// TODO - KIT-4993: Add updateLocale public method.
|
|
165
199
|
disconnectedCallback() {
|
|
166
200
|
super.disconnectedCallback();
|
|
167
201
|
if (typeof this.unsubscribeUrlManager === 'function') {
|
|
@@ -211,11 +245,11 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
211
245
|
throw error;
|
|
212
246
|
}
|
|
213
247
|
}
|
|
214
|
-
// TODO - KIT-4993: Adjust.
|
|
215
248
|
initLanguage() {
|
|
216
|
-
if (!this.language) {
|
|
217
|
-
|
|
249
|
+
if (!this.context || this.language) {
|
|
250
|
+
return;
|
|
218
251
|
}
|
|
252
|
+
this.interfaceController.onLanguageChange(this.context.state.language);
|
|
219
253
|
}
|
|
220
254
|
initRequestStatus() {
|
|
221
255
|
this.searchOrListing =
|
|
@@ -257,7 +291,7 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
257
291
|
this.i18Initialized,
|
|
258
292
|
]);
|
|
259
293
|
this.initContext();
|
|
260
|
-
this.updateLanguage();
|
|
294
|
+
this.updateLanguage(); // TODO - (v4) KIT-4365: Remove.
|
|
261
295
|
this.bindings = this.getBindings();
|
|
262
296
|
markParentAsReady(this);
|
|
263
297
|
this.initRequestStatus();
|
|
@@ -267,6 +301,14 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
|
|
|
267
301
|
this.initUrlManager();
|
|
268
302
|
this.initialized = true;
|
|
269
303
|
}
|
|
304
|
+
isNewLocale(language, country, currency) {
|
|
305
|
+
if (!this.context) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return ((language && language !== this.context.state.language) ||
|
|
309
|
+
(country && country !== this.context.state.country) ||
|
|
310
|
+
(currency && currency !== this.context.state.currency));
|
|
311
|
+
}
|
|
270
312
|
// TODO - (v4) KIT-4991: Make private.
|
|
271
313
|
scrollToTop() {
|
|
272
314
|
const scrollContainerElement = document.querySelector(this.scrollContainer);
|
|
@@ -37,7 +37,7 @@ let AtomicCommerceQuerySummary = class AtomicCommerceQuerySummary extends LitEle
|
|
|
37
37
|
this.listingOrSearchSummary = controller.summary();
|
|
38
38
|
}
|
|
39
39
|
render() {
|
|
40
|
-
const { firstProduct, firstRequestExecuted, lastProduct, totalNumberOfProducts, hasProducts, hasError, } = this.listingOrSearchSummaryState;
|
|
40
|
+
const { firstProduct, firstRequestExecuted, lastProduct, totalNumberOfProducts, hasProducts, hasError, isLoading, } = this.listingOrSearchSummaryState;
|
|
41
41
|
const { i18nKey, highlights, ariaLiveMessage } = getProductQuerySummaryI18nParameters({
|
|
42
42
|
first: firstProduct,
|
|
43
43
|
last: lastProduct,
|
|
@@ -46,7 +46,7 @@ let AtomicCommerceQuerySummary = class AtomicCommerceQuerySummary extends LitEle
|
|
|
46
46
|
: '',
|
|
47
47
|
total: totalNumberOfProducts,
|
|
48
48
|
i18n: this.bindings.i18n,
|
|
49
|
-
isLoading
|
|
49
|
+
isLoading,
|
|
50
50
|
});
|
|
51
51
|
this.ariaMessage.message = ariaLiveMessage;
|
|
52
52
|
return html `${renderQuerySummaryGuard({
|
|
@@ -50,6 +50,9 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
50
50
|
*
|
|
51
51
|
*/
|
|
52
52
|
this.iconAssetsPath = './assets';
|
|
53
|
+
// TODO - KIT-4994: Add disableAnalytics property that defaults to false.
|
|
54
|
+
// TODO - KIT-4994: Deprecate in favor of disableAnalytics property.
|
|
55
|
+
// TODO - (v4) KIT-4990: Remove.
|
|
53
56
|
/**
|
|
54
57
|
* Whether to enable analytics.
|
|
55
58
|
*/
|
|
@@ -104,13 +107,15 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
104
107
|
return;
|
|
105
108
|
}
|
|
106
109
|
language && this.interfaceController.onLanguageChange(language);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
if (this.isNewLocale(language, country, currency)) {
|
|
111
|
+
const { setContext } = loadContextActions(this.engine);
|
|
112
|
+
this.engine.dispatch(setContext({
|
|
113
|
+
...this.context.state,
|
|
114
|
+
...(language && { language }),
|
|
115
|
+
...(country && { country }),
|
|
116
|
+
...(currency && { currency }),
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
114
119
|
}
|
|
115
120
|
toggleAnalytics() {
|
|
116
121
|
this.interfaceController.onAnalyticsChange();
|
|
@@ -118,6 +123,7 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
118
123
|
updateIconAssetsPath() {
|
|
119
124
|
this.store.state.iconAssetsPath = this.iconAssetsPath;
|
|
120
125
|
}
|
|
126
|
+
// TODO - (v4) KIT-4365: Remove.
|
|
121
127
|
async updateLanguage() {
|
|
122
128
|
if (!this.interfaceController.engineIsCreated(this.engine) ||
|
|
123
129
|
!this.language ||
|
|
@@ -150,7 +156,7 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
150
156
|
this.i18Initialized,
|
|
151
157
|
]);
|
|
152
158
|
this.initContext();
|
|
153
|
-
this.
|
|
159
|
+
this.updateLanguage();
|
|
154
160
|
this.bindings = this.getBindings();
|
|
155
161
|
markParentAsReady(this);
|
|
156
162
|
this.initLanguage();
|
|
@@ -167,9 +173,18 @@ let AtomicCommerceRecommendationInterface = class AtomicCommerceRecommendationIn
|
|
|
167
173
|
};
|
|
168
174
|
}
|
|
169
175
|
initLanguage() {
|
|
170
|
-
if (!this.language) {
|
|
171
|
-
|
|
176
|
+
if (!this.context || this.language) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.interfaceController.onLanguageChange(this.context.state.language);
|
|
180
|
+
}
|
|
181
|
+
isNewLocale(language, country, currency) {
|
|
182
|
+
if (!this.context) {
|
|
183
|
+
return false;
|
|
172
184
|
}
|
|
185
|
+
return ((language && language !== this.context.state.language) ||
|
|
186
|
+
(country && country !== this.context.state.country) ||
|
|
187
|
+
(currency && currency !== this.context.state.currency));
|
|
173
188
|
}
|
|
174
189
|
};
|
|
175
190
|
AtomicCommerceRecommendationInterface.styles = [
|
|
@@ -20,6 +20,7 @@ import { AriaLiveRegionController } from "../../../utils/accessibility-utils";
|
|
|
20
20
|
import { hasKeyboard, isMacOS } from "../../../utils/device-utils";
|
|
21
21
|
import { SafeStorage, StorageItems, } from "../../../utils/local-storage-utils";
|
|
22
22
|
import { updateBreakpoints } from "../../../utils/replace-breakpoint-utils";
|
|
23
|
+
import { getDefaultSlotFromHost } from "../../../utils/slot-utils";
|
|
23
24
|
import { isFocusingOut, once, randomID, spreadProperties, } from '../../../utils/utils';
|
|
24
25
|
import { renderSearchBoxWrapper } from '../../common/search-box/search-box-wrapper';
|
|
25
26
|
import { renderSearchBoxTextArea } from '../../common/search-box/search-text-area';
|
|
@@ -123,9 +124,6 @@ let AtomicCommerceSearchBox = class AtomicCommerceSearchBox extends LitElement {
|
|
|
123
124
|
}
|
|
124
125
|
connectedCallback() {
|
|
125
126
|
super.connectedCallback();
|
|
126
|
-
if (this.children.length === 0) {
|
|
127
|
-
this.replaceChildren(document.createElement('atomic-commerce-search-box-recent-queries'), document.createElement('atomic-commerce-search-box-query-suggestions'));
|
|
128
|
-
}
|
|
129
127
|
this.addEventListener('atomic/searchBoxSuggestion/register', (event) => {
|
|
130
128
|
const customEvent = event;
|
|
131
129
|
this.searchBoxSuggestionEventsQueue.push(customEvent);
|
|
@@ -492,6 +490,14 @@ let AtomicCommerceSearchBox = class AtomicCommerceSearchBox extends LitElement {
|
|
|
492
490
|
></atomic-suggestion-renderer>
|
|
493
491
|
`;
|
|
494
492
|
}
|
|
493
|
+
renderSlotContent() {
|
|
494
|
+
const hasDefaultSlot = !!getDefaultSlotFromHost(this);
|
|
495
|
+
if (hasDefaultSlot) {
|
|
496
|
+
return html `<slot></slot>`;
|
|
497
|
+
}
|
|
498
|
+
return html `<atomic-commerce-search-box-recent-queries></atomic-commerce-search-box-recent-queries>
|
|
499
|
+
<atomic-commerce-search-box-query-suggestions></atomic-commerce-search-box-query-suggestions>`;
|
|
500
|
+
}
|
|
495
501
|
render() {
|
|
496
502
|
this.updateBreakpoints();
|
|
497
503
|
if (!this.suggestionManager.suggestions.length) {
|
|
@@ -511,7 +517,7 @@ let AtomicCommerceSearchBox = class AtomicCommerceSearchBox extends LitElement {
|
|
|
511
517
|
},
|
|
512
518
|
},
|
|
513
519
|
})(html `${this.renderTextBox()}
|
|
514
|
-
|
|
520
|
+
${renderSubmitButton({
|
|
515
521
|
props: {
|
|
516
522
|
i18n: this.bindings.i18n,
|
|
517
523
|
disabled: this.isSearchDisabledForEndUser,
|
|
@@ -521,7 +527,8 @@ let AtomicCommerceSearchBox = class AtomicCommerceSearchBox extends LitElement {
|
|
|
521
527
|
},
|
|
522
528
|
},
|
|
523
529
|
})}
|
|
524
|
-
|
|
530
|
+
${this.renderSuggestions()}`)}
|
|
531
|
+
${this.renderSlotContent()}
|
|
525
532
|
`;
|
|
526
533
|
}
|
|
527
534
|
};
|
|
@@ -9,6 +9,7 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
|
9
9
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
10
10
|
import { when } from 'lit/directives/when.js';
|
|
11
11
|
import { booleanConverter } from "../../../converters/boolean-converter.js";
|
|
12
|
+
import { bindings } from "../../../decorators/bindings.js";
|
|
12
13
|
import { errorGuard } from "../../../decorators/error-guard";
|
|
13
14
|
import { watch } from "../../../decorators/watch.js";
|
|
14
15
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
|
@@ -296,6 +297,7 @@ __decorate([
|
|
|
296
297
|
], AtomicModal.prototype, "watchToggleOpen", null);
|
|
297
298
|
AtomicModal = __decorate([
|
|
298
299
|
customElement('atomic-modal'),
|
|
300
|
+
bindings(),
|
|
299
301
|
withTailwindStyles
|
|
300
302
|
], AtomicModal);
|
|
301
303
|
export { AtomicModal };
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { loadQuerySuggestActions, } from '@coveo/headless';
|
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { getPartialSearchBoxSuggestionElement, renderQuerySuggestion, } from "../../common/suggestions/query-suggestions";
|
|
11
|
+
import { dispatchSearchBoxSuggestionsEvent } from "../../common/suggestions/suggestions-events";
|
|
12
|
+
import { errorGuard } from "../../../decorators/error-guard";
|
|
13
|
+
const SearchIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m6.4 0c3.5 0 6.4 2.9 6.4 6.4 0 1.4-.4 2.7-1.2 3.7l4 4c.4.4.4 1 .1 1.5l-.1.1c-.2.2-.5.3-.8.3s-.6-.1-.8-.3l-4-4c-1 .7-2.3 1.2-3.7 1.2-3.4-.1-6.3-3-6.3-6.5s2.9-6.4 6.4-6.4zm0 2.1c-2.3 0-4.3 1.9-4.3 4.3s1.9 4.3 4.3 4.3 4.3-1.9 4.3-4.3-1.9-4.3-4.3-4.3z\"/></svg>";
|
|
14
|
+
/**
|
|
15
|
+
* 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.
|
|
16
|
+
*/
|
|
17
|
+
let AtomicSearchBoxQuerySuggestions = class AtomicSearchBoxQuerySuggestions extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
/**
|
|
21
|
+
* The maximum number of suggestions that will be displayed if the user has typed something into the input field.
|
|
22
|
+
*/
|
|
23
|
+
this.maxWithQuery = 3;
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
try {
|
|
28
|
+
dispatchSearchBoxSuggestionsEvent((bindings) => {
|
|
29
|
+
this.bindings = bindings;
|
|
30
|
+
return this.initialize();
|
|
31
|
+
}, this, ['atomic-search-box']);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
this.error = error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
initialize() {
|
|
38
|
+
const engine = this.bindings.engine;
|
|
39
|
+
const { registerQuerySuggest, fetchQuerySuggestions } = loadQuerySuggestActions(engine);
|
|
40
|
+
const numberOfQueries = this.bindings.numberOfQueries;
|
|
41
|
+
const maxWithQuery = this.maxWithQuery;
|
|
42
|
+
if (numberOfQueries < maxWithQuery) {
|
|
43
|
+
const logger = this.bindings.engine.logger;
|
|
44
|
+
logger.warn(`Query suggestions configuration mismatch: atomic-search-box has number-of-queries="${numberOfQueries}" but atomic-search-box-query-suggestions has max-with-query="${maxWithQuery}". ` +
|
|
45
|
+
`This may cause inconsistent behavior where the search box requests ${numberOfQueries} suggestions but the component tries to display up to ${maxWithQuery}. ` +
|
|
46
|
+
`Consider updating max-with-query to ${numberOfQueries} or increasing number-of-queries to ${maxWithQuery}.`);
|
|
47
|
+
}
|
|
48
|
+
engine.dispatch(registerQuerySuggest({
|
|
49
|
+
id: this.bindings.id,
|
|
50
|
+
count: this.bindings.numberOfQueries,
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
position: Array.from(this.parentNode.children).indexOf(this),
|
|
54
|
+
onInput: () => engine.dispatch(fetchQuerySuggestions({
|
|
55
|
+
id: this.bindings.id,
|
|
56
|
+
})),
|
|
57
|
+
renderItems: () => this.renderItems(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
renderItems() {
|
|
61
|
+
const hasQuery = this.bindings.searchBoxController.state.value !== '';
|
|
62
|
+
const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;
|
|
63
|
+
return this.bindings.searchBoxController.state.suggestions
|
|
64
|
+
.slice(0, max)
|
|
65
|
+
.map((suggestion) => this.renderItem(suggestion));
|
|
66
|
+
}
|
|
67
|
+
renderItem(suggestion) {
|
|
68
|
+
const partialItem = getPartialSearchBoxSuggestionElement(suggestion, this.bindings.i18n);
|
|
69
|
+
const icon = this.icon ? this.icon : SearchIcon;
|
|
70
|
+
const hasQuery = this.bindings.searchBoxController.state.value !== '';
|
|
71
|
+
const hasMultipleKindOfSuggestions = this.bindings.getSuggestions().length > 1;
|
|
72
|
+
return {
|
|
73
|
+
...partialItem,
|
|
74
|
+
content: renderQuerySuggestion({
|
|
75
|
+
icon,
|
|
76
|
+
hasQuery,
|
|
77
|
+
suggestion,
|
|
78
|
+
hasMultipleKindOfSuggestions,
|
|
79
|
+
}),
|
|
80
|
+
onSelect: () => {
|
|
81
|
+
this.bindings.searchBoxController.selectSuggestion(suggestion.rawValue);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
render() {
|
|
86
|
+
return html `${nothing}`;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
__decorate([
|
|
90
|
+
state()
|
|
91
|
+
], AtomicSearchBoxQuerySuggestions.prototype, "error", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
property()
|
|
94
|
+
], AtomicSearchBoxQuerySuggestions.prototype, "icon", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: Number, attribute: 'max-with-query', reflect: true })
|
|
97
|
+
], AtomicSearchBoxQuerySuggestions.prototype, "maxWithQuery", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: Number, attribute: 'max-without-query', reflect: true })
|
|
100
|
+
], AtomicSearchBoxQuerySuggestions.prototype, "maxWithoutQuery", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
errorGuard()
|
|
103
|
+
], AtomicSearchBoxQuerySuggestions.prototype, "render", null);
|
|
104
|
+
AtomicSearchBoxQuerySuggestions = __decorate([
|
|
105
|
+
customElement('atomic-search-box-query-suggestions')
|
|
106
|
+
], AtomicSearchBoxQuerySuggestions);
|
|
107
|
+
export { AtomicSearchBoxQuerySuggestions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Auto-generated file
|
|
2
2
|
export { AtomicQuerySummary } from './atomic-query-summary/atomic-query-summary.js';
|
|
3
3
|
export { AtomicResultsPerPage } from './atomic-results-per-page/atomic-results-per-page.js';
|
|
4
|
-
export {
|
|
4
|
+
export { AtomicSearchBoxQuerySuggestions } from './atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js';
|
|
5
5
|
export { AtomicSearchLayout } from './atomic-search-layout/atomic-search-layout.js';
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
export default {
|
|
3
3
|
'atomic-query-summary': async () => await import('./atomic-query-summary/atomic-query-summary.js'),
|
|
4
4
|
'atomic-results-per-page': async () => await import('./atomic-results-per-page/atomic-results-per-page.js'),
|
|
5
|
-
'atomic-search-box-
|
|
5
|
+
'atomic-search-box-query-suggestions': async () => await import('./atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js'),
|
|
6
6
|
'atomic-search-layout': async () => await import('./atomic-search-layout/atomic-search-layout.js'),
|
|
7
7
|
};
|