@coveo/atomic 3.33.8-pre.d75d8e5578 → 3.33.8-pre.de35a78164

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.
Files changed (150) hide show
  1. package/dist/atomic/_atomic.esm.js +1 -1
  2. package/dist/atomic/components/_index.js +2 -1
  3. package/dist/atomic/components/analytics-config.js +1 -1
  4. package/dist/atomic/components/atomic-insight-search-box.js +3 -4
  5. package/dist/atomic/components/atomic-insight-search-box.js.map +1 -1
  6. package/dist/atomic/components/atomic-search-box-instant-results.js +2 -2
  7. package/dist/atomic/components/atomic-search-box-instant-results.js.map +1 -1
  8. package/dist/atomic/components/atomic-search-box-query-suggestions2.js +2 -2
  9. package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +1 -1
  10. package/dist/atomic/components/atomic-search-box-recent-queries2.js +2 -2
  11. package/dist/atomic/components/atomic-search-box-recent-queries2.js.map +1 -1
  12. package/dist/atomic/components/atomic-search-box.js +5 -6
  13. package/dist/atomic/components/atomic-search-box.js.map +1 -1
  14. package/dist/atomic/components/atomic-suggestion-renderer2.js +1 -1
  15. package/dist/atomic/components/atomic-suggestion-renderer2.js.map +1 -1
  16. package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +1 -4
  17. package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +50 -8
  18. package/dist/atomic/components/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.js +2 -2
  19. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +25 -10
  20. package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +1 -1
  21. package/dist/atomic/components/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.js +1 -1
  22. package/dist/atomic/components/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.js +1 -1
  23. package/dist/atomic/components/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.js +1 -1
  24. package/dist/atomic/components/components/common/atomic-modal/atomic-modal.js +2 -0
  25. package/dist/atomic/components/components/common/layout/layout-styles-controller.js +1 -1
  26. package/dist/atomic/components/components/common/suggestions/suggestion-manager.js +1 -1
  27. package/dist/atomic/components/components/common/suggestions/{suggestions-common.js → suggestions-events.js} +16 -18
  28. package/dist/atomic/components/components/common/suggestions/suggestions-types.js +1 -0
  29. package/dist/atomic/components/components/common/suggestions/suggestions-utils.js +18 -0
  30. package/dist/atomic/components/global/environment.js +1 -1
  31. package/dist/atomic/components/index.js.map +1 -1
  32. package/dist/atomic/components/stencil-query-suggestions.js.map +1 -1
  33. package/dist/atomic/components/stencil-suggestion-manager.js +20 -2
  34. package/dist/atomic/components/stencil-suggestion-manager.js.map +1 -1
  35. package/dist/atomic/components/{suggestions-common.js → suggestions-events.js} +18 -20
  36. package/dist/atomic/components/suggestions-events.js.map +1 -0
  37. package/dist/atomic/index.esm.js +1 -1
  38. package/dist/atomic/index.esm.js.map +1 -1
  39. package/dist/atomic/p-0a051b8d.js +2 -0
  40. package/dist/atomic/p-0a051b8d.js.map +1 -0
  41. package/dist/atomic/p-16f4ce98.js +2 -0
  42. package/dist/atomic/p-16f4ce98.js.map +1 -0
  43. package/dist/atomic/{p-8867af82.entry.js → p-26a51a77.entry.js} +2 -2
  44. package/dist/atomic/p-26a51a77.entry.js.map +1 -0
  45. package/dist/atomic/{p-c1bf43cf.entry.js → p-31f1e44e.entry.js} +2 -2
  46. package/dist/atomic/p-31f1e44e.entry.js.map +1 -0
  47. package/dist/atomic/p-4b7a19db.js +2 -0
  48. package/dist/atomic/p-4b7a19db.js.map +1 -0
  49. package/dist/atomic/{p-0bfa74d3.entry.js → p-4ca61a15.entry.js} +2 -2
  50. package/dist/atomic/{p-828d74f8.entry.js → p-9f172e51.entry.js} +2 -2
  51. package/dist/atomic/p-af93b44c.js.map +1 -1
  52. package/dist/atomic/{p-caa647d5.js → p-b6d8adf1.js} +2 -2
  53. package/dist/atomic/{p-3d847e45.entry.js → p-c88a3d2d.entry.js} +2 -2
  54. package/dist/atomic/p-c88a3d2d.entry.js.map +1 -0
  55. package/dist/atomic/{p-36e71b99.entry.js → p-d0f47b33.entry.js} +2 -2
  56. package/dist/atomic/p-d0f47b33.entry.js.map +1 -0
  57. package/dist/atomic/{p-8b9b8089.entry.js → p-ec43f802.entry.js} +2 -2
  58. package/dist/atomic/{p-aa4224ea.entry.js → p-fbfe913d.entry.js} +2 -2
  59. package/dist/atomic/p-fbfe913d.entry.js.map +1 -0
  60. package/dist/cjs/_index.cjs.js +5 -2
  61. package/dist/cjs/{analytics-config-75507a47.js → analytics-config-bc4ee794.js} +2 -2
  62. package/dist/cjs/{analytics-config-75507a47.js.map → analytics-config-bc4ee794.js.map} +1 -1
  63. package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
  64. package/dist/cjs/atomic-insight-search-box.cjs.entry.js +5 -5
  65. package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +1 -1
  66. package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
  67. package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js +3 -3
  68. package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js.map +1 -1
  69. package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +5 -5
  70. package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js.map +1 -1
  71. package/dist/cjs/atomic-search-box.cjs.entry.js +7 -7
  72. package/dist/cjs/atomic-search-box.cjs.entry.js.map +1 -1
  73. package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
  74. package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js +1 -1
  75. package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js.map +1 -1
  76. package/dist/cjs/index.cjs.js.map +1 -1
  77. package/dist/cjs/stencil-query-suggestions-03268ecc.js.map +1 -1
  78. package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js → stencil-suggestion-manager-2cba6d69.js} +4 -4
  79. package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js.map → stencil-suggestion-manager-2cba6d69.js.map} +1 -1
  80. package/dist/cjs/{suggestions-common-5097a362.js → suggestions-events-63dd0640.js} +17 -21
  81. package/dist/cjs/suggestions-events-63dd0640.js.map +1 -0
  82. package/dist/cjs/suggestions-utils-61000808.js +25 -0
  83. package/dist/cjs/suggestions-utils-61000808.js.map +1 -0
  84. package/dist/cjs/version.cjs.js +2 -2
  85. package/dist/esm/_index.js +2 -1
  86. package/dist/esm/{analytics-config-54cbe2b9.js → analytics-config-37553b6a.js} +2 -2
  87. package/dist/esm/{analytics-config-54cbe2b9.js.map → analytics-config-37553b6a.js.map} +1 -1
  88. package/dist/esm/atomic-insight-interface.entry.js +1 -1
  89. package/dist/esm/atomic-insight-search-box.entry.js +4 -4
  90. package/dist/esm/atomic-insight-search-box.entry.js.map +1 -1
  91. package/dist/esm/atomic-recs-interface.entry.js +1 -1
  92. package/dist/esm/atomic-search-box-instant-results.entry.js +2 -2
  93. package/dist/esm/atomic-search-box-instant-results.entry.js.map +1 -1
  94. package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +3 -3
  95. package/dist/esm/atomic-search-box-query-suggestions_2.entry.js.map +1 -1
  96. package/dist/esm/atomic-search-box.entry.js +6 -6
  97. package/dist/esm/atomic-search-box.entry.js.map +1 -1
  98. package/dist/esm/atomic-search-interface.entry.js +1 -1
  99. package/dist/esm/atomic-suggestion-renderer.entry.js +1 -1
  100. package/dist/esm/atomic-suggestion-renderer.entry.js.map +1 -1
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/esm/stencil-query-suggestions-5d6a46d7.js.map +1 -1
  103. package/dist/esm/{stencil-suggestion-manager-486094dd.js → stencil-suggestion-manager-376f83e8.js} +2 -2
  104. package/dist/esm/{stencil-suggestion-manager-486094dd.js.map → stencil-suggestion-manager-376f83e8.js.map} +1 -1
  105. package/dist/esm/{suggestions-common-2b20db26.js → suggestions-events-b7a6f007.js} +18 -20
  106. package/dist/esm/suggestions-events-b7a6f007.js.map +1 -0
  107. package/dist/esm/suggestions-utils-591559a0.js +22 -0
  108. package/dist/esm/suggestions-utils-591559a0.js.map +1 -0
  109. package/dist/esm/version.js +2 -2
  110. package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +1 -2
  111. package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +29 -2
  112. package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +1 -0
  113. package/dist/types/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.d.ts +1 -1
  114. package/dist/types/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.d.ts +1 -1
  115. package/dist/types/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.d.ts +1 -1
  116. package/dist/types/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.d.ts +1 -1
  117. package/dist/types/components/common/suggestions/instant-item.d.ts +1 -1
  118. package/dist/types/components/common/suggestions/query-suggestions.d.ts +1 -1
  119. package/dist/types/components/common/suggestions/recent-queries.d.ts +1 -1
  120. package/dist/types/components/common/suggestions/stencil-instant-item.d.ts +1 -1
  121. package/dist/types/components/common/suggestions/stencil-query-suggestions.d.ts +1 -1
  122. package/dist/types/components/common/suggestions/stencil-recent-queries.d.ts +1 -1
  123. package/dist/types/components/common/suggestions/stencil-suggestion-manager.d.ts +1 -1
  124. package/dist/types/components/common/suggestions/suggestion-manager.d.ts +1 -1
  125. package/dist/types/components/common/suggestions/suggestions-events.d.ts +14 -0
  126. package/dist/types/components/common/suggestions/{suggestions-common.d.ts → suggestions-types.d.ts} +6 -16
  127. package/dist/types/components/common/suggestions/suggestions-utils.d.ts +15 -0
  128. package/dist/types/components/search/atomic-search-box/atomic-search-box.d.ts +1 -1
  129. package/dist/types/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.d.ts +1 -1
  130. package/dist/types/components.d.ts +2 -2
  131. package/dist/types/decorators/types.d.ts +1 -1
  132. package/dist/types/index.d.ts +3 -1
  133. package/docs/atomic-docs.json +3 -3
  134. package/package.json +3 -3
  135. package/dist/atomic/components/suggestions-common.js.map +0 -1
  136. package/dist/atomic/p-29fd6768.js +0 -2
  137. package/dist/atomic/p-29fd6768.js.map +0 -1
  138. package/dist/atomic/p-36e71b99.entry.js.map +0 -1
  139. package/dist/atomic/p-3d847e45.entry.js.map +0 -1
  140. package/dist/atomic/p-7601c3de.js +0 -2
  141. package/dist/atomic/p-7601c3de.js.map +0 -1
  142. package/dist/atomic/p-8867af82.entry.js.map +0 -1
  143. package/dist/atomic/p-aa4224ea.entry.js.map +0 -1
  144. package/dist/atomic/p-c1bf43cf.entry.js.map +0 -1
  145. package/dist/cjs/suggestions-common-5097a362.js.map +0 -1
  146. package/dist/esm/suggestions-common-2b20db26.js.map +0 -1
  147. /package/dist/atomic/{p-0bfa74d3.entry.js.map → p-4ca61a15.entry.js.map} +0 -0
  148. /package/dist/atomic/{p-828d74f8.entry.js.map → p-9f172e51.entry.js.map} +0 -0
  149. /package/dist/atomic/{p-caa647d5.js.map → p-b6d8adf1.js.map} +0 -0
  150. /package/dist/atomic/{p-8b9b8089.entry.js.map → p-ec43f802.entry.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';
@@ -86,7 +86,7 @@ let AtomicCommerceInterface = class AtomicCommerceInterface extends ChildrenUpda
86
86
  this.urlManager.synchronize(this.fragment);
87
87
  };
88
88
  this.store = createCommerceStore(this.type);
89
- this._mobileBreakpointController = new MobileBreakpointController(this, this.store);
89
+ new MobileBreakpointController(this, this.store);
90
90
  const { promise, resolve } = Promise.withResolvers();
91
91
  this.i18Initialized = promise;
92
92
  this.i18n = i18next.createInstance(undefined, resolve);
@@ -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
- // TODO - KIT-4993: Add temporary deprecation warning.
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
- this.language = this.context.state.language;
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: false,
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
- const { setContext } = loadContextActions(this.engine);
108
- this.engine.dispatch(setContext({
109
- ...this.context.state,
110
- ...(language && { language }),
111
- ...(country && { country }),
112
- ...(currency && { currency }),
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.language && this.updateLanguage();
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
- this.interfaceController.onLanguageChange(this.context.state.language);
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 = [
@@ -25,7 +25,7 @@ import { renderSearchBoxWrapper } from '../../common/search-box/search-box-wrapp
25
25
  import { renderSearchBoxTextArea } from '../../common/search-box/search-text-area';
26
26
  import { renderSubmitButton } from '../../common/search-box/submit-button';
27
27
  import { SuggestionManager } from '../../common/suggestions/suggestion-manager';
28
- import { elementHasQuery, } from '../../common/suggestions/suggestions-common';
28
+ import { elementHasQuery } from '../../common/suggestions/suggestions-utils';
29
29
  import '../atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products';
30
30
  import '../atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions';
31
31
  import '../atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries';
@@ -9,7 +9,7 @@ import { html, LitElement, nothing, render } from 'lit';
9
9
  import { customElement, property, state } from 'lit/decorators.js';
10
10
  import { keyed } from 'lit/directives/keyed.js';
11
11
  import { getPartialInstantItemElement, getPartialInstantItemShowAllElement, renderInstantItemShowAllButton, } from "../../common/suggestions/instant-item";
12
- import { dispatchSearchBoxSuggestionsEvent, } from "../../common/suggestions/suggestions-common";
12
+ import { dispatchSearchBoxSuggestionsEvent } from "../../common/suggestions/suggestions-events";
13
13
  import { errorGuard } from "../../../decorators/error-guard";
14
14
  import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
15
15
  import { encodeForDomAttribute } from "../../../utils/string-utils";
@@ -8,7 +8,7 @@ import { loadQuerySuggestActions, } from '@coveo/headless/commerce';
8
8
  import { html, LitElement, nothing } from 'lit';
9
9
  import { customElement, property, state } from 'lit/decorators.js';
10
10
  import { getPartialSearchBoxSuggestionElement, renderQuerySuggestion, } from "../../common/suggestions/query-suggestions";
11
- import { dispatchSearchBoxSuggestionsEvent, } from "../../common/suggestions/suggestions-common";
11
+ import { dispatchSearchBoxSuggestionsEvent } from "../../common/suggestions/suggestions-events";
12
12
  import { errorGuard } from "../../../decorators/error-guard";
13
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
14
  /**
@@ -12,7 +12,7 @@ import { SafeStorage, StorageItems } from "../../../utils/local-storage-utils";
12
12
  import { once } from "../../../utils/utils";
13
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
14
  import { getPartialRecentQueryClearElement, getPartialRecentQueryElement, renderRecentQuery, renderRecentQueryClear, } from '../../common/suggestions/recent-queries';
15
- import { dispatchSearchBoxSuggestionsEvent, } from '../../common/suggestions/suggestions-common';
15
+ import { dispatchSearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-events';
16
16
  /**
17
17
  * 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.
18
18
  */
@@ -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 };
@@ -14,7 +14,7 @@ export class LayoutStylesController {
14
14
  if (!this.host.id) {
15
15
  this.host.id = randomID(this.componentPrefix);
16
16
  }
17
- this.updateStyles();
17
+ this.host.updateComplete.then(() => this.updateStyles());
18
18
  }
19
19
  /**
20
20
  * Updates the dynamic styles based on the current mobile breakpoint
@@ -2,7 +2,7 @@ import { isNullOrUndefined } from '@coveo/bueno';
2
2
  import DOMPurify from 'dompurify';
3
3
  import { debounce } from '../../../utils/debounce-utils';
4
4
  import { promiseTimeout } from '../../../utils/promise-utils';
5
- import { elementHasNoQuery, elementHasQuery, } from './suggestions-common';
5
+ import { elementHasNoQuery, elementHasQuery } from './suggestions-utils';
6
6
  export class SuggestionManager {
7
7
  constructor(ownerSearchBoxProps) {
8
8
  this.ownerSearchBoxProps = ownerSearchBoxProps;
@@ -1,5 +1,21 @@
1
1
  import { closest } from '../../../utils/dom-utils';
2
2
  import { buildCustomEvent } from '../../../utils/event-utils';
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 const dispatchSearchBoxSuggestionsEvent = (event, element, allowedSearchBoxElements = searchBoxElements) => {
13
+ const interfaceElement = closest(element, searchBoxElements.join(', '));
14
+ if (!interfaceElement) {
15
+ throw new Error(`The "${element.nodeName.toLowerCase()}" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(', ')}`);
16
+ }
17
+ void dispatchSearchBoxSuggestionsEventEventually(interfaceElement, element, event);
18
+ };
3
19
  const searchBoxElements = [
4
20
  'atomic-search-box',
5
21
  'atomic-insight-search-box',
@@ -17,21 +33,3 @@ const dispatchSearchBoxSuggestionsEventEventually = async (interfaceElement, ele
17
33
  }
18
34
  element.dispatchEvent(buildCustomEvent('atomic/searchBoxSuggestion/register', event));
19
35
  };
20
- /**
21
- * Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
22
- * @param event Event sent from the registered query suggestions to the parent search box.
23
- * @param element Element on which to dispatch the event, which must be the child of a configured search box.
24
- */
25
- export const dispatchSearchBoxSuggestionsEvent = (event, element, allowedSearchBoxElements = searchBoxElements) => {
26
- const interfaceElement = closest(element, searchBoxElements.join(', '));
27
- if (!interfaceElement) {
28
- throw new Error(`The "${element.nodeName.toLowerCase()}" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(', ')}`);
29
- }
30
- void dispatchSearchBoxSuggestionsEventEventually(interfaceElement, element, event);
31
- };
32
- export function elementHasNoQuery(el) {
33
- return !el.query || el.query.trim() === '';
34
- }
35
- export function elementHasQuery(el) {
36
- return !!el.query && el.query.trim() !== '';
37
- }
@@ -0,0 +1,18 @@
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
+ export 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
+ export function elementHasQuery(el) {
17
+ return !!el.query && el.query.trim() !== '';
18
+ }
@@ -3,7 +3,7 @@ function getWindow() {
3
3
  }
4
4
  export function getAtomicEnvironment(headlessVersion) {
5
5
  return {
6
- version: "3.33.8-pre.d75d8e5578",
6
+ version: "3.33.8-pre.de35a78164",
7
7
  headlessVersion,
8
8
  };
9
9
  }
@@ -1 +1 @@
1
- {"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;SAYgB,cAAc,CAAoB,OAAgB;IAChE,OAAO,WAAW,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACnD;;MCHa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,WAAmB,EAAE,UAAkB;QACjD,KAAK,CACH,QAAQ,WAAW,sCAAsC,UAAU,YAAY,CAChF,CAAC;KACH;;;ACfH,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;SAIpC,gBAAgB,CAAI,OAAgB,EAAE,UAAkB;IACtE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM;QACpC,MAAM,KAAK,GAAG,gBAAgB,CAC5B,oBAAoB,EACpB,CAAC,IAAO;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB,CACF,CAAC;QACF,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE;YACjC,MAAM,CACJ,IAAI,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CACnE,CAAC;SACH;KACF,CAAC,CAAC;AACL;;ACoDA;;;;;;;;;;SAUgB,mBAAmB,CAAoB,OAAgB;IACrE,OAAO,gBAAgB,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACxD;;;;","names":[],"sources":["src/components/commerce/product-template-component-utils/stencil-product-template-decorators.tsx","src/components/common/item-list/context/item-context-controller.ts","src/components/common/item-list/fetch-item-context.ts","src/decorators/commerce/product-template-decorators.ts"],"sourcesContent":["import {Product} from '@coveo/headless/commerce';\nimport {itemContext} from '../../common/item-list/stencil-item-decorators';\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This method is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the method in the [connectedCallback lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered \"atomic-product\".\n * @returns A promise that resolves on initialization of the parent \"atomic-product\" element, or rejects when there is no parent \"atomic-product\" element.\n *\n * @deprecated should only be used for Stencil components. For Lit components, use `fetchProductContext` from \\@/src/decorators/commerce/product-template-decorators.ts\n */\nexport function productContext<T extends Product>(element: Element) {\n return itemContext<T>(element, 'atomic-product');\n}\n","import type {LitElement, ReactiveController, ReactiveControllerHost} from 'lit';\nimport type {InitializableComponent} from '@/src/decorators/types.js';\nimport {buildCustomEvent} from '@/src/utils/event-utils';\n\ntype LitElementWithError = Omit<\n Pick<InitializableComponent, 'error'>,\n 'error'\n> &\n LitElement & {\n error: Error | null;\n };\n\nconst itemContextEventName = 'atomic/resolveResult';\n\nexport class MissingParentError extends Error {\n constructor(elementName: string, parentName: string) {\n super(\n `The \"${elementName}\" element must be the child of an \"${parentName}\" element.`\n );\n }\n}\n\nfunction extractFolded<T = Record<string, unknown>>(\n item: Record<string, unknown>,\n returnFolded: boolean\n): T {\n if (returnFolded) {\n if ('children' in item) {\n return item as T;\n } else {\n return {children: [], result: item} as T;\n }\n }\n\n if ('children' in item && 'result' in item) {\n return item.result as T;\n }\n return item as T;\n}\n\n/**\n * A reactive controller that manages item context data from parent components.\n * Handles fetching item data via custom events and manages error states.\n */\nexport class ItemContextController<T = Record<string, unknown>>\n implements ReactiveController\n{\n private host: ReactiveControllerHost & LitElementWithError;\n private parentName: string;\n private folded: boolean;\n private _item: T | null = null;\n private _error: MissingParentError | null = null;\n\n constructor(\n host: ReactiveControllerHost & LitElementWithError,\n options: {parentName?: string; folded?: boolean} = {}\n ) {\n this.host = host;\n this.parentName = options.parentName ?? 'atomic-result';\n this.folded = options.folded ?? false;\n host.addController(this);\n }\n\n get item(): T | null {\n return this._error ? null : this._item;\n }\n\n get error(): MissingParentError | null {\n return this._error;\n }\n\n get hasError(): boolean {\n return this._error !== null;\n }\n\n hostConnected(): void {\n this._resolveItemContext();\n }\n\n private _resolveItemContext(): void {\n const event = buildCustomEvent(\n itemContextEventName,\n (item: Record<string, unknown>) => {\n this._item = extractFolded<T>(item, this.folded);\n this._error = null;\n this.host.error = null;\n this.host.requestUpdate();\n }\n );\n\n const canceled = this.host.dispatchEvent(event);\n if (canceled) {\n const elementName = (this.host as Element).nodeName.toLowerCase();\n this._error = new MissingParentError(elementName, this.parentName);\n this._item = null;\n this.host.error = this._error;\n this.host.requestUpdate();\n }\n }\n}\n\ntype ItemContextEventHandler<T> = (item: T) => void;\nexport type ItemContextEvent<T> = CustomEvent<ItemContextEventHandler<T>>;\n","import {closest} from '../../../utils/dom-utils.js';\nimport {buildCustomEvent} from '../../../utils/event-utils.js';\nimport {MissingParentError} from './context/item-context-controller.js';\n\nconst itemContextEventName = 'atomic/resolveResult';\n\ntype ItemContextEventHandler<T> = (item: T) => void;\n\nexport function fetchItemContext<T>(element: Element, parentName: string) {\n return new Promise<T>((resolve, reject) => {\n const event = buildCustomEvent<ItemContextEventHandler<T>>(\n itemContextEventName,\n (item: T) => {\n return resolve(item);\n }\n );\n element.dispatchEvent(event);\n\n if (!closest(element, parentName)) {\n reject(\n new MissingParentError(element.nodeName.toLowerCase(), parentName)\n );\n }\n });\n}\n","import type {InteractiveProduct, Product} from '@coveo/headless/commerce';\nimport type {LitElement} from 'lit';\nimport {\n InteractiveItemContextController,\n type InteractiveItemContextEvent,\n} from '@/src/components/common/item-list/context/interactive-item-context-controller';\nimport {\n ItemContextController,\n type ItemContextEvent,\n} from '@/src/components/common/item-list/context/item-context-controller';\nimport {fetchItemContext} from '@/src/components/common/item-list/fetch-item-context';\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing product context in product template components.\n *\n * @param host - The Lit component instance\n * @param options - Configuration options\n * @returns ItemContextController instance configured for atomic-product\n *\n * @example\n * ```typescript\n * @customElement('my-product-component')\n * export class MyProductComponent extends LitElement {\n * private productController = createProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.productController.item;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createProductContextController(\n host: LitElement & {error: Error | null},\n options: {folded?: boolean} = {}\n): ItemContextController<Product> {\n return new ItemContextController<Product>(host, {\n parentName: 'atomic-product',\n folded: options.folded ?? false,\n });\n}\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing interactive product context in product template components.\n *\n * @param host - The Lit component instance\n * @returns InteractiveItemContextController instance\n *\n * @example\n * ```typescript\n * @customElement('my-interactive-product-component')\n * export class MyInteractiveProductComponent extends LitElement {\n * private interactiveProductController = createInteractiveProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.interactiveProductController.interactiveItem;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createInteractiveProductContextController(\n host: LitElement & {error: Error}\n): InteractiveItemContextController<InteractiveProduct> {\n return new InteractiveItemContextController<InteractiveProduct>(host);\n}\n\nexport type ProductContextEvent<T = Product> = ItemContextEvent<T>;\nexport type InteractiveProductContextEvent<\n T extends InteractiveProduct = InteractiveProduct,\n> = InteractiveItemContextEvent<T>;\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This utility function is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the utility function in the [`connectedCallback` lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered `atomic-product`.\n * @returns A promise that resolves on initialization of the parent `atomic-product` element, or rejects when there is no parent `atomic-product` element.\n */\nexport function fetchProductContext<T extends Product>(element: Element) {\n return fetchItemContext<T>(element, 'atomic-product');\n}\n"],"version":3}
1
+ {"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;SAYgB,cAAc,CAAoB,OAAgB;IAChE,OAAO,WAAW,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACnD;;MCHa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,WAAmB,EAAE,UAAkB;QACjD,KAAK,CACH,QAAQ,WAAW,sCAAsC,UAAU,YAAY,CAChF,CAAC;KACH;;;ACfH,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;SAIpC,gBAAgB,CAAI,OAAgB,EAAE,UAAkB;IACtE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM;QACpC,MAAM,KAAK,GAAG,gBAAgB,CAC5B,oBAAoB,EACpB,CAAC,IAAO;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB,CACF,CAAC;QACF,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE;YACjC,MAAM,CACJ,IAAI,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CACnE,CAAC;SACH;KACF,CAAC,CAAC;AACL;;ACoDA;;;;;;;;;;SAUgB,mBAAmB,CAAoB,OAAgB;IACrE,OAAO,gBAAgB,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACxD;;;;","names":[],"sources":["src/components/commerce/product-template-component-utils/stencil-product-template-decorators.tsx","src/components/common/item-list/context/item-context-controller.ts","src/components/common/item-list/fetch-item-context.ts","src/decorators/commerce/product-template-decorators.ts"],"sourcesContent":["import {Product} from '@coveo/headless/commerce';\nimport {itemContext} from '../../common/item-list/stencil-item-decorators';\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This method is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the method in the [connectedCallback lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered \"atomic-product\".\n * @returns A promise that resolves on initialization of the parent \"atomic-product\" element, or rejects when there is no parent \"atomic-product\" element.\n *\n * @deprecated should only be used for Stencil components. For Lit components, use `fetchProductContext` from \\@/src/decorators/commerce/product-template-decorators.ts\n */\nexport function productContext<T extends Product>(element: Element) {\n return itemContext<T>(element, 'atomic-product');\n}\n","import type {LitElement, ReactiveController, ReactiveControllerHost} from 'lit';\nimport type {InitializableComponent} from '@/src/decorators/types.js';\nimport {buildCustomEvent} from '@/src/utils/event-utils';\n\ntype LitElementWithError = Omit<\n Pick<InitializableComponent, 'error'>,\n 'error'\n> &\n LitElement & {\n error: Error | null;\n };\n\nconst itemContextEventName = 'atomic/resolveResult';\n\nexport class MissingParentError extends Error {\n constructor(elementName: string, parentName: string) {\n super(\n `The \"${elementName}\" element must be the child of an \"${parentName}\" element.`\n );\n }\n}\n\nfunction extractFolded<T = Record<string, unknown>>(\n item: Record<string, unknown>,\n returnFolded: boolean\n): T {\n if (returnFolded) {\n if ('children' in item) {\n return item as T;\n } else {\n return {children: [], result: item} as T;\n }\n }\n\n if ('children' in item && 'result' in item) {\n return item.result as T;\n }\n return item as T;\n}\n\n/**\n * A reactive controller that manages item context data from parent components.\n * Handles fetching item data via custom events and manages error states.\n */\nexport class ItemContextController<T = Record<string, unknown>>\n implements ReactiveController\n{\n private host: ReactiveControllerHost & LitElementWithError;\n private parentName: string;\n private folded: boolean;\n private _item: T | null = null;\n private _error: MissingParentError | null = null;\n\n constructor(\n host: ReactiveControllerHost & LitElementWithError,\n options: {parentName?: string; folded?: boolean} = {}\n ) {\n this.host = host;\n this.parentName = options.parentName ?? 'atomic-result';\n this.folded = options.folded ?? false;\n host.addController(this);\n }\n\n get item(): T | null {\n return this._error ? null : this._item;\n }\n\n get error(): MissingParentError | null {\n return this._error;\n }\n\n get hasError(): boolean {\n return this._error !== null;\n }\n\n hostConnected(): void {\n this._resolveItemContext();\n }\n\n private _resolveItemContext(): void {\n const event = buildCustomEvent(\n itemContextEventName,\n (item: Record<string, unknown>) => {\n this._item = extractFolded<T>(item, this.folded);\n this._error = null;\n this.host.error = null;\n this.host.requestUpdate();\n }\n );\n\n const canceled = this.host.dispatchEvent(event);\n if (canceled) {\n const elementName = (this.host as Element).nodeName.toLowerCase();\n this._error = new MissingParentError(elementName, this.parentName);\n this._item = null;\n this.host.error = this._error;\n this.host.requestUpdate();\n }\n }\n}\n\ntype ItemContextEventHandler<T> = (item: T) => void;\nexport type ItemContextEvent<T> = CustomEvent<ItemContextEventHandler<T>>;\n","import {closest} from '../../../utils/dom-utils.js';\nimport {buildCustomEvent} from '../../../utils/event-utils.js';\nimport {MissingParentError} from './context/item-context-controller.js';\n\nconst itemContextEventName = 'atomic/resolveResult';\n\ntype ItemContextEventHandler<T> = (item: T) => void;\n\nexport function fetchItemContext<T>(element: Element, parentName: string) {\n return new Promise<T>((resolve, reject) => {\n const event = buildCustomEvent<ItemContextEventHandler<T>>(\n itemContextEventName,\n (item: T) => {\n return resolve(item);\n }\n );\n element.dispatchEvent(event);\n\n if (!closest(element, parentName)) {\n reject(\n new MissingParentError(element.nodeName.toLowerCase(), parentName)\n );\n }\n });\n}\n","import type {InteractiveProduct, Product} from '@coveo/headless/commerce';\nimport type {LitElement} from 'lit';\nimport {\n InteractiveItemContextController,\n type InteractiveItemContextEvent,\n} from '@/src/components/common/item-list/context/interactive-item-context-controller';\nimport {\n ItemContextController,\n type ItemContextEvent,\n} from '@/src/components/common/item-list/context/item-context-controller';\nimport {fetchItemContext} from '@/src/components/common/item-list/fetch-item-context';\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing product context in product template components.\n *\n * @param host - The Lit component instance\n * @param options - Configuration options\n * @returns ItemContextController instance configured for atomic-product\n *\n * @example\n * ```typescript\n * @customElement('my-product-component')\n * export class MyProductComponent extends LitElement {\n * private productController = createProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.productController.item;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createProductContextController(\n host: LitElement & {error: Error | null},\n options: {folded?: boolean} = {}\n): ItemContextController<Product> {\n return new ItemContextController<Product>(host, {\n parentName: 'atomic-product',\n folded: options.folded ?? false,\n });\n}\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing interactive product context in product template components.\n *\n * @param host - The Lit component instance\n * @returns InteractiveItemContextController instance\n *\n * @example\n * ```typescript\n * @customElement('my-interactive-product-component')\n * export class MyInteractiveProductComponent extends LitElement {\n * private interactiveProductController = createInteractiveProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.interactiveProductController.interactiveItem;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createInteractiveProductContextController(\n host: LitElement & {error: Error}\n): InteractiveItemContextController<InteractiveProduct> {\n return new InteractiveItemContextController<InteractiveProduct>(host);\n}\n\nexport type ProductContextEvent<T = Product> = ItemContextEvent<T>;\nexport type InteractiveProductContextEvent<\n T extends InteractiveProduct = InteractiveProduct,\n> = InteractiveItemContextEvent<T>;\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This utility function is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the utility function in the [`connectedCallback` lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered `atomic-product`.\n * @returns A promise that resolves on initialization of the parent `atomic-product` element, or rejects when there is no parent `atomic-product` element.\n */\nexport function fetchProductContext<T extends Product>(element: Element) {\n return fetchItemContext<T>(element, 'atomic-product');\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"file":"stencil-query-suggestions.js","mappings":";;;MAUa,oCAAoC,GAAG,CAClD,UAAsB,EACtB,IAAU;IAEV,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,GAAG,EAAE,MAAM,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACvD,KAAK,EAAE,UAAU,CAAC,QAAQ;QAC1B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB,EAAE;YAC1C,KAAK,EAAE,UAAU,CAAC,QAAQ;YAC1B,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;SACpC,CAAC;KACH,CAAC;AACJ,EAAE;MAEW,wBAAwB,GAAwB,CAAC,CAAC,EAAE,QAAQ;IACvE,QACE,WAAK,IAAI,EAAC,0BAA0B,EAAC,KAAK,EAAC,mBAAmB,IAC3D,QAAQ,CACL,EACN;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC;IACxB,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KACR;IAED,QACE,mBACE,IAAI,EAAC,uBAAuB,EAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,uBAAuB,GAChB,EACf;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,UAAU,EAAE,QAAQ,EAAC;IACzB,IAAI,QAAQ,EAAE;QACZ,QACE,YACE,IAAI,EAAC,uBAAuB,EAC5B,KAAK,EAAC,wBAAwB,EAC9B,SAAS,EAAE,UAAU,CAAC,gBAAgB,GAChC,EACR;KACH;IAED,QACE,YAAM,IAAI,EAAC,uBAAuB,EAAC,KAAK,EAAC,wBAAwB,IAC9D,UAAU,CAAC,QAAQ,CACf,EACP;AACJ;;;;","names":[],"sources":["src/components/common/suggestions/stencil-query-suggestions.tsx"],"sourcesContent":["import {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils.js';\nimport {SearchBoxSuggestionElement} from './suggestions-common.js';\n\ninterface Suggestion {\n highlightedValue: string;\n rawValue: string;\n}\n\nexport const getPartialSearchBoxSuggestionElement = (\n suggestion: Suggestion,\n i18n: i18n\n): Pick<SearchBoxSuggestionElement, 'ariaLabel' | 'key' | 'query' | 'part'> => {\n return {\n part: 'query-suggestion-item',\n key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,\n query: suggestion.rawValue,\n ariaLabel: i18n.t('query-suggestion-label', {\n query: suggestion.rawValue,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const QuerySuggestionContainer: FunctionalComponent = (_, children) => {\n return (\n <div part=\"query-suggestion-content\" class=\"flex items-center\">\n {children}\n </div>\n );\n};\n\ninterface QuerySuggestionIconProps {\n icon: string;\n hasSuggestion: boolean;\n}\n\nexport const QuerySuggestionIcon: FunctionalComponent<\n QuerySuggestionIconProps\n> = ({icon, hasSuggestion}) => {\n if (!hasSuggestion) {\n return;\n }\n\n return (\n <atomic-icon\n part=\"query-suggestion-icon\"\n icon={icon}\n class=\"mr-2 h-4 w-4 shrink-0\"\n ></atomic-icon>\n );\n};\n\ninterface QuerySuggestionTextProps {\n suggestion: Suggestion;\n hasQuery: boolean;\n}\n\nexport const QuerySuggestionText: FunctionalComponent<\n QuerySuggestionTextProps\n> = ({suggestion, hasQuery}) => {\n if (hasQuery) {\n return (\n <span\n part=\"query-suggestion-text\"\n class=\"line-clamp-2 break-all\"\n innerHTML={suggestion.highlightedValue}\n ></span>\n );\n }\n\n return (\n <span part=\"query-suggestion-text\" class=\"line-clamp-2 break-all\">\n {suggestion.rawValue}\n </span>\n );\n};\n"],"version":3}
1
+ {"file":"stencil-query-suggestions.js","mappings":";;;MAUa,oCAAoC,GAAG,CAClD,UAAsB,EACtB,IAAU;IAEV,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,GAAG,EAAE,MAAM,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACvD,KAAK,EAAE,UAAU,CAAC,QAAQ;QAC1B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB,EAAE;YAC1C,KAAK,EAAE,UAAU,CAAC,QAAQ;YAC1B,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;SACpC,CAAC;KACH,CAAC;AACJ,EAAE;MAEW,wBAAwB,GAAwB,CAAC,CAAC,EAAE,QAAQ;IACvE,QACE,WAAK,IAAI,EAAC,0BAA0B,EAAC,KAAK,EAAC,mBAAmB,IAC3D,QAAQ,CACL,EACN;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC;IACxB,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KACR;IAED,QACE,mBACE,IAAI,EAAC,uBAAuB,EAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,uBAAuB,GAChB,EACf;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,UAAU,EAAE,QAAQ,EAAC;IACzB,IAAI,QAAQ,EAAE;QACZ,QACE,YACE,IAAI,EAAC,uBAAuB,EAC5B,KAAK,EAAC,wBAAwB,EAC9B,SAAS,EAAE,UAAU,CAAC,gBAAgB,GAChC,EACR;KACH;IAED,QACE,YAAM,IAAI,EAAC,uBAAuB,EAAC,KAAK,EAAC,wBAAwB,IAC9D,UAAU,CAAC,QAAQ,CACf,EACP;AACJ;;;;","names":[],"sources":["src/components/common/suggestions/stencil-query-suggestions.tsx"],"sourcesContent":["import {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils.js';\nimport {SearchBoxSuggestionElement} from './suggestions-types.js';\n\ninterface Suggestion {\n highlightedValue: string;\n rawValue: string;\n}\n\nexport const getPartialSearchBoxSuggestionElement = (\n suggestion: Suggestion,\n i18n: i18n\n): Pick<SearchBoxSuggestionElement, 'ariaLabel' | 'key' | 'query' | 'part'> => {\n return {\n part: 'query-suggestion-item',\n key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,\n query: suggestion.rawValue,\n ariaLabel: i18n.t('query-suggestion-label', {\n query: suggestion.rawValue,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const QuerySuggestionContainer: FunctionalComponent = (_, children) => {\n return (\n <div part=\"query-suggestion-content\" class=\"flex items-center\">\n {children}\n </div>\n );\n};\n\ninterface QuerySuggestionIconProps {\n icon: string;\n hasSuggestion: boolean;\n}\n\nexport const QuerySuggestionIcon: FunctionalComponent<\n QuerySuggestionIconProps\n> = ({icon, hasSuggestion}) => {\n if (!hasSuggestion) {\n return;\n }\n\n return (\n <atomic-icon\n part=\"query-suggestion-icon\"\n icon={icon}\n class=\"mr-2 h-4 w-4 shrink-0\"\n ></atomic-icon>\n );\n};\n\ninterface QuerySuggestionTextProps {\n suggestion: Suggestion;\n hasQuery: boolean;\n}\n\nexport const QuerySuggestionText: FunctionalComponent<\n QuerySuggestionTextProps\n> = ({suggestion, hasQuery}) => {\n if (hasQuery) {\n return (\n <span\n part=\"query-suggestion-text\"\n class=\"line-clamp-2 break-all\"\n innerHTML={suggestion.highlightedValue}\n ></span>\n );\n }\n\n return (\n <span part=\"query-suggestion-text\" class=\"line-clamp-2 break-all\">\n {suggestion.rawValue}\n </span>\n );\n};\n"],"version":3}
@@ -3,7 +3,25 @@ import { B as Button } from './stencil-button.js';
3
3
  import { isNullOrUndefined } from '@coveo/bueno';
4
4
  import { D as DOMPurify } from './purify.js';
5
5
  import { d as debounce } from './debounce-utils.js';
6
- import { e as elementHasQuery, a as elementHasNoQuery } from './suggestions-common.js';
6
+
7
+ /**
8
+ * Checks if a search box suggestion element has no query.
9
+ *
10
+ * @param el - The search box suggestion element to check
11
+ * @returns True if the element has no query or the query is whitespace-only
12
+ */
13
+ function elementHasNoQuery(el) {
14
+ return !el.query || el.query.trim() === '';
15
+ }
16
+ /**
17
+ * Checks if a search box suggestion element has a query.
18
+ *
19
+ * @param el - The search box suggestion element to check
20
+ * @returns True if the element has a non-empty, non-whitespace query
21
+ */
22
+ function elementHasQuery(el) {
23
+ return !!el.query && el.query.trim() !== '';
24
+ }
7
25
 
8
26
  const SearchSlimIcon = `<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
9
27
  <circle cx="7" cy="7" r="6.5" stroke="currentColor"/>
@@ -409,6 +427,6 @@ class SuggestionManager {
409
427
  }
410
428
  }
411
429
 
412
- export { SuggestionManager as S, SearchSlimIcon as a, SearchBoxWrapper as b, SearchTextArea as c };
430
+ export { SuggestionManager as S, elementHasQuery as a, SearchSlimIcon as b, SearchBoxWrapper as c, SearchTextArea as d, elementHasNoQuery as e };
413
431
 
414
432
  //# sourceMappingURL=stencil-suggestion-manager.js.map