@coveo/atomic 3.34.0-pre.8b1d289c8b → 3.34.0-pre.9353d3e7c7

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 (195) hide show
  1. package/dist/atomic/_atomic.esm.js +1 -1
  2. package/dist/atomic/atomic.esm.js.map +1 -1
  3. package/dist/atomic/components/_index.d.ts +2 -2
  4. package/dist/atomic/components/_index.js +1 -1
  5. package/dist/atomic/components/analytics-config.js +1 -1
  6. package/dist/atomic/components/atomic-category-facet.js +1 -1
  7. package/dist/atomic/components/atomic-facet.js +1 -1
  8. package/dist/atomic/components/atomic-format-currency.js +1 -1
  9. package/dist/atomic/components/atomic-format-number.js +1 -1
  10. package/dist/atomic/components/atomic-format-unit.js +1 -1
  11. package/dist/atomic/components/atomic-insight-search-box.js +2 -29
  12. package/dist/atomic/components/atomic-insight-search-box.js.map +1 -1
  13. package/dist/atomic/components/atomic-numeric-facet.js +1 -1
  14. package/dist/atomic/components/atomic-quickview-modal2.js +23 -23
  15. package/dist/atomic/components/atomic-quickview-modal2.js.map +1 -1
  16. package/dist/atomic/components/atomic-quickview.js +1 -1
  17. package/dist/atomic/components/atomic-result-children.js +1 -1
  18. package/dist/atomic/components/atomic-result-fields-list.js +1 -1
  19. package/dist/atomic/components/atomic-result-link.js +1 -1
  20. package/dist/atomic/components/atomic-result-list.js +1 -1
  21. package/dist/atomic/components/atomic-result-table-placeholder2.js +1 -1
  22. package/dist/atomic/components/atomic-search-box-query-suggestions.d.ts +11 -0
  23. package/dist/atomic/components/atomic-search-box-query-suggestions.js +8 -0
  24. package/dist/atomic/components/atomic-search-box-query-suggestions.js.map +1 -0
  25. package/dist/atomic/components/atomic-search-box-query-suggestions2.js +89 -0
  26. package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +1 -0
  27. package/dist/atomic/components/atomic-search-box-recent-queries2.js +1 -1
  28. package/dist/atomic/components/atomic-search-box.js +10 -4
  29. package/dist/atomic/components/atomic-search-box.js.map +1 -1
  30. package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
  31. package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
  32. package/dist/atomic/components/atomic-sort-expression.js +1 -1
  33. package/dist/atomic/components/atomic-tab-manager.js +1 -1
  34. package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +17 -32
  35. package/dist/atomic/components/components/commerce/atomic-product/atomic-product.js +26 -58
  36. package/dist/atomic/components/components/common/layout/custom-render-controller.js +50 -0
  37. package/dist/atomic/components/components/common/layout/item-layout-controller.js +103 -0
  38. package/dist/atomic/components/components/common/validate-props-controller/validate-props-controller.js +50 -0
  39. package/dist/atomic/components/components/search/atomic-relevance-inspector/atomic-relevance-inspector.js +100 -0
  40. package/dist/atomic/components/components/search/atomic-search-interface/atomic-search-interface.js +17 -24
  41. package/dist/atomic/components/components/search/index.js +1 -1
  42. package/dist/atomic/components/components/search/lazy-index.js +1 -1
  43. package/dist/atomic/components/global/environment.js +1 -1
  44. package/dist/atomic/components/stencil-query-suggestions.js +33 -0
  45. package/dist/atomic/components/stencil-query-suggestions.js.map +1 -0
  46. package/dist/atomic/components/utils/compare-utils.js +49 -0
  47. package/dist/atomic/{p-475124d2.entry.js → p-01511388.entry.js} +2 -2
  48. package/dist/atomic/{p-10a0603e.js → p-03615066.js} +2 -2
  49. package/dist/atomic/{p-60800b2f.entry.js → p-0ed76e65.entry.js} +2 -2
  50. package/dist/atomic/{p-0297958a.entry.js → p-2c938403.entry.js} +2 -2
  51. package/dist/atomic/{p-16f6c1f3.entry.js → p-2fb49fe8.entry.js} +2 -2
  52. package/dist/atomic/{p-13391e75.entry.js → p-3549a469.entry.js} +2 -2
  53. package/dist/atomic/{p-7c3c5f07.entry.js → p-4f4c9a03.entry.js} +2 -2
  54. package/dist/atomic/p-4f4c9a03.entry.js.map +1 -0
  55. package/dist/atomic/{p-7ec6dd3e.entry.js → p-65dd9017.entry.js} +2 -2
  56. package/dist/atomic/{p-86bde026.entry.js → p-736f4d7e.entry.js} +2 -2
  57. package/dist/atomic/{p-3cbab25b.entry.js → p-7e971d15.entry.js} +2 -2
  58. package/dist/atomic/{p-4601eb93.entry.js → p-83d3857f.entry.js} +2 -2
  59. package/dist/atomic/{p-dbcef3a9.entry.js → p-87f69e53.entry.js} +2 -2
  60. package/dist/atomic/{p-5a710350.entry.js → p-8bf425b0.entry.js} +2 -2
  61. package/dist/atomic/p-a1522fe5.entry.js +2 -0
  62. package/dist/atomic/p-a1522fe5.entry.js.map +1 -0
  63. package/dist/atomic/p-af93b44c.js +2 -0
  64. package/dist/atomic/p-af93b44c.js.map +1 -0
  65. package/dist/atomic/{p-e398835b.entry.js → p-b2b9e83f.entry.js} +2 -2
  66. package/dist/atomic/{p-8fdef8a3.entry.js → p-b313058c.entry.js} +2 -2
  67. package/dist/atomic/{p-0bdd730f.entry.js → p-b6ae0244.entry.js} +2 -2
  68. package/dist/atomic/{p-3a7a1a00.entry.js → p-bbfe727a.entry.js} +2 -2
  69. package/dist/atomic/{p-97ce3384.entry.js → p-be2a43f4.entry.js} +2 -2
  70. package/dist/atomic/{p-a5714bc4.entry.js → p-d211a422.entry.js} +2 -2
  71. package/dist/atomic/{p-ca3dc59b.entry.js → p-d82b85ab.entry.js} +2 -2
  72. package/dist/atomic/{p-b4359552.entry.js → p-e72b8d70.entry.js} +2 -2
  73. package/dist/atomic/p-ea1b81fa.entry.js +2 -0
  74. package/dist/atomic/p-ea1b81fa.entry.js.map +1 -0
  75. package/dist/cjs/_loader.cjs.js +1 -1
  76. package/dist/cjs/{analytics-config-47c35b47.js → analytics-config-e1eb424e.js} +2 -2
  77. package/dist/cjs/{analytics-config-47c35b47.js.map → analytics-config-e1eb424e.js.map} +1 -1
  78. package/dist/cjs/atomic-category-facet.cjs.entry.js +1 -1
  79. package/dist/cjs/atomic-facet.cjs.entry.js +1 -1
  80. package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
  81. package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
  82. package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
  83. package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
  84. package/dist/cjs/atomic-insight-search-box.cjs.entry.js +4 -30
  85. package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +1 -1
  86. package/dist/cjs/atomic-numeric-facet.cjs.entry.js +1 -1
  87. package/dist/cjs/atomic-quickview-modal.cjs.entry.js +23 -23
  88. package/dist/cjs/atomic-quickview-modal.cjs.entry.js.map +1 -1
  89. package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
  90. package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
  91. package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
  92. package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
  93. package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
  94. package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
  95. package/dist/cjs/atomic-result-placeholder_8.cjs.entry.js +1 -1
  96. package/dist/cjs/{atomic-search-box-recent-queries.cjs.entry.js → atomic-search-box-query-suggestions_2.cjs.entry.js} +68 -5
  97. package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js.map +1 -0
  98. package/dist/cjs/atomic-search-box.cjs.entry.js +3 -3
  99. package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
  100. package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
  101. package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
  102. package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
  103. package/dist/cjs/atomic.cjs.js +1 -1
  104. package/dist/cjs/index-757bc886.js +2 -6
  105. package/dist/cjs/stencil-query-suggestions-03268ecc.js +38 -0
  106. package/dist/cjs/stencil-query-suggestions-03268ecc.js.map +1 -0
  107. package/dist/cjs/version.cjs.js +1 -1
  108. package/dist/esm/_loader.js +1 -1
  109. package/dist/esm/{analytics-config-52ed9753.js → analytics-config-9ca0b7a9.js} +2 -2
  110. package/dist/esm/{analytics-config-52ed9753.js.map → analytics-config-9ca0b7a9.js.map} +1 -1
  111. package/dist/esm/atomic-category-facet.entry.js +1 -1
  112. package/dist/esm/atomic-facet.entry.js +1 -1
  113. package/dist/esm/atomic-format-currency.entry.js +1 -1
  114. package/dist/esm/atomic-format-number.entry.js +1 -1
  115. package/dist/esm/atomic-format-unit.entry.js +1 -1
  116. package/dist/esm/atomic-insight-interface.entry.js +1 -1
  117. package/dist/esm/atomic-insight-search-box.entry.js +3 -29
  118. package/dist/esm/atomic-insight-search-box.entry.js.map +1 -1
  119. package/dist/esm/atomic-numeric-facet.entry.js +1 -1
  120. package/dist/esm/atomic-quickview-modal.entry.js +23 -23
  121. package/dist/esm/atomic-quickview-modal.entry.js.map +1 -1
  122. package/dist/esm/atomic-quickview.entry.js +1 -1
  123. package/dist/esm/atomic-recs-interface.entry.js +1 -1
  124. package/dist/esm/atomic-result-children.entry.js +1 -1
  125. package/dist/esm/atomic-result-fields-list.entry.js +1 -1
  126. package/dist/esm/atomic-result-link.entry.js +1 -1
  127. package/dist/esm/atomic-result-list.entry.js +1 -1
  128. package/dist/esm/atomic-result-placeholder_8.entry.js +1 -1
  129. package/dist/esm/{atomic-search-box-recent-queries.entry.js → atomic-search-box-query-suggestions_2.entry.js} +70 -8
  130. package/dist/esm/atomic-search-box-query-suggestions_2.entry.js.map +1 -0
  131. package/dist/esm/atomic-search-box.entry.js +3 -3
  132. package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
  133. package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
  134. package/dist/esm/atomic-sort-expression.entry.js +1 -1
  135. package/dist/esm/atomic-tab-manager.entry.js +1 -1
  136. package/dist/esm/atomic.js +1 -1
  137. package/dist/esm/index-3f35faca.js +2 -6
  138. package/dist/esm/stencil-query-suggestions-5d6a46d7.js +33 -0
  139. package/dist/esm/stencil-query-suggestions-5d6a46d7.js.map +1 -0
  140. package/dist/esm/version.js +1 -1
  141. package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +2 -3
  142. package/dist/types/components/commerce/atomic-product/atomic-product.d.ts +5 -16
  143. package/dist/types/components/common/facets/facet-search/facet-search-input-guard.d.ts +1 -1
  144. package/dist/types/components/common/layout/custom-render-controller.d.ts +30 -0
  145. package/dist/types/components/common/layout/item-layout-controller.d.ts +47 -0
  146. package/dist/types/components/common/no-items/guard.d.ts +1 -1
  147. package/dist/types/components/common/refine-modal/guard.d.ts +1 -1
  148. package/dist/types/components/common/sort/sort-guard.d.ts +1 -1
  149. package/dist/types/components/common/validate-props-controller/validate-props-controller.d.ts +32 -0
  150. package/dist/types/components/search/atomic-relevance-inspector/atomic-relevance-inspector.d.ts +18 -8
  151. package/dist/types/components/search/atomic-search-interface/atomic-search-interface.d.ts +6 -3
  152. package/dist/types/components/search/index.d.ts +1 -1
  153. package/dist/types/components/search/{atomic-search-box-query-suggestions → search-box-suggestions/atomic-search-box-query-suggestions}/atomic-search-box-query-suggestions.d.ts +7 -16
  154. package/dist/types/components.d.ts +49 -53
  155. package/dist/types/directives/hierarchical-path.d.ts +1 -1
  156. package/dist/types/utils/compare-utils.d.ts +9 -0
  157. package/docs/atomic-docs.json +102 -90
  158. package/package.json +1 -1
  159. package/dist/atomic/components/atomic-relevance-inspector.d.ts +0 -11
  160. package/dist/atomic/components/atomic-relevance-inspector.js +0 -53
  161. package/dist/atomic/components/atomic-relevance-inspector.js.map +0 -1
  162. package/dist/atomic/components/components/search/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js +0 -107
  163. package/dist/atomic/p-5d71a211.entry.js +0 -2
  164. package/dist/atomic/p-5d71a211.entry.js.map +0 -1
  165. package/dist/atomic/p-7c3c5f07.entry.js.map +0 -1
  166. package/dist/atomic/p-de687bed.entry.js +0 -2
  167. package/dist/atomic/p-de687bed.entry.js.map +0 -1
  168. package/dist/atomic/p-f2bab68d.entry.js +0 -2
  169. package/dist/atomic/p-f2bab68d.entry.js.map +0 -1
  170. package/dist/cjs/atomic-relevance-inspector.cjs.entry.js +0 -38
  171. package/dist/cjs/atomic-relevance-inspector.cjs.entry.js.map +0 -1
  172. package/dist/cjs/atomic-search-box-recent-queries.cjs.entry.js.map +0 -1
  173. package/dist/esm/atomic-relevance-inspector.entry.js +0 -34
  174. package/dist/esm/atomic-relevance-inspector.entry.js.map +0 -1
  175. package/dist/esm/atomic-search-box-recent-queries.entry.js.map +0 -1
  176. /package/dist/atomic/{p-475124d2.entry.js.map → p-01511388.entry.js.map} +0 -0
  177. /package/dist/atomic/{p-10a0603e.js.map → p-03615066.js.map} +0 -0
  178. /package/dist/atomic/{p-60800b2f.entry.js.map → p-0ed76e65.entry.js.map} +0 -0
  179. /package/dist/atomic/{p-0297958a.entry.js.map → p-2c938403.entry.js.map} +0 -0
  180. /package/dist/atomic/{p-16f6c1f3.entry.js.map → p-2fb49fe8.entry.js.map} +0 -0
  181. /package/dist/atomic/{p-13391e75.entry.js.map → p-3549a469.entry.js.map} +0 -0
  182. /package/dist/atomic/{p-7ec6dd3e.entry.js.map → p-65dd9017.entry.js.map} +0 -0
  183. /package/dist/atomic/{p-86bde026.entry.js.map → p-736f4d7e.entry.js.map} +0 -0
  184. /package/dist/atomic/{p-3cbab25b.entry.js.map → p-7e971d15.entry.js.map} +0 -0
  185. /package/dist/atomic/{p-4601eb93.entry.js.map → p-83d3857f.entry.js.map} +0 -0
  186. /package/dist/atomic/{p-dbcef3a9.entry.js.map → p-87f69e53.entry.js.map} +0 -0
  187. /package/dist/atomic/{p-5a710350.entry.js.map → p-8bf425b0.entry.js.map} +0 -0
  188. /package/dist/atomic/{p-e398835b.entry.js.map → p-b2b9e83f.entry.js.map} +0 -0
  189. /package/dist/atomic/{p-8fdef8a3.entry.js.map → p-b313058c.entry.js.map} +0 -0
  190. /package/dist/atomic/{p-0bdd730f.entry.js.map → p-b6ae0244.entry.js.map} +0 -0
  191. /package/dist/atomic/{p-3a7a1a00.entry.js.map → p-bbfe727a.entry.js.map} +0 -0
  192. /package/dist/atomic/{p-97ce3384.entry.js.map → p-be2a43f4.entry.js.map} +0 -0
  193. /package/dist/atomic/{p-a5714bc4.entry.js.map → p-d211a422.entry.js.map} +0 -0
  194. /package/dist/atomic/{p-ca3dc59b.entry.js.map → p-d82b85ab.entry.js.map} +0 -0
  195. /package/dist/atomic/{p-b4359552.entry.js.map → p-e72b8d70.entry.js.map} +0 -0
@@ -8,7 +8,8 @@ import { html, LitElement } from 'lit';
8
8
  import { customElement, property } from 'lit/decorators.js';
9
9
  import { ref } from 'lit/directives/ref.js';
10
10
  import { resultComponentClass, } from "../../common/item-list/item-list-common";
11
- import { ItemLayout, } from "../../common/layout/display-options";
11
+ import { CustomRenderController } from "../../common/layout/custom-render-controller";
12
+ import { ItemLayoutController } from "../../common/layout/item-layout-controller";
12
13
  import { booleanConverter } from "../../../converters/boolean-converter";
13
14
  import { withTailwindStyles } from "../../../decorators/with-tailwind-styles";
14
15
  import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
@@ -20,7 +21,6 @@ import styles from './atomic-product.tw.css';
20
21
  let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitElement) {
21
22
  constructor() {
22
23
  super(...arguments);
23
- this.executedRenderingFunctionOnce = false;
24
24
  /**
25
25
  * The product link to use when the product is clicked in a grid layout.
26
26
  *
@@ -84,11 +84,26 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
84
84
  }
85
85
  async connectedCallback() {
86
86
  super.connectedCallback();
87
- if (!this.content) {
88
- console.warn('AtomicProduct: content property is undefined. Cannot create layout.', this);
89
- return;
90
- }
91
- this.layout = new ItemLayout(this.content.children, this.display, this.density, this.imageSize);
87
+ this.customRenderController = new CustomRenderController(this, {
88
+ renderingFunction: () => this.renderingFunction,
89
+ itemData: () => this.product,
90
+ rootElementRef: () => this.productRootRef,
91
+ linkContainerRef: () => this.linkContainerRef,
92
+ onRenderComplete: (element, output) => {
93
+ this.itemLayoutController.applyLayoutClassesToElement(element, output);
94
+ },
95
+ });
96
+ this.itemLayoutController = new ItemLayoutController(this, {
97
+ elementPrefix: 'atomic-product',
98
+ renderingFunction: () => this.renderingFunction,
99
+ content: () => this.content,
100
+ layoutConfig: () => ({
101
+ display: this.display,
102
+ density: this.density,
103
+ imageSize: this.imageSize,
104
+ }),
105
+ itemClasses: () => this.classes,
106
+ });
92
107
  this.addEventListener('atomic/resolveResult', this.resolveProduct);
93
108
  this.addEventListener('atomic/resolveInteractiveResult', this.resolveInteractiveProduct);
94
109
  this.addEventListener('atomic/resolveStopPropagation', this.resolveStopPropagation);
@@ -105,12 +120,9 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
105
120
  this.removeEventListener('atomic/resolveResultDisplayConfig', this.resolveProductDisplayConfig);
106
121
  this.removeEventListener('click', this.handleClick);
107
122
  }
108
- get isCustomRenderFunctionMode() {
109
- return this.renderingFunction !== undefined;
110
- }
111
123
  getContentHTML() {
112
124
  if (!this.content) {
113
- console.warn('AtomicProduct: content property is undefined. Cannot get content HTML.', this);
125
+ console.warn('atomic-product: content property is undefined. Cannot get content HTML.', this);
114
126
  return '';
115
127
  }
116
128
  return parentNodeToString(this.content);
@@ -118,13 +130,8 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
118
130
  getLinkHTML() {
119
131
  return parentNodeToString(this.linkContent ?? new HTMLElement());
120
132
  }
121
- shouldExecuteRenderFunction() {
122
- return (this.isCustomRenderFunctionMode &&
123
- this.productRootRef &&
124
- !this.executedRenderingFunctionOnce);
125
- }
126
133
  render() {
127
- if (this.isCustomRenderFunctionMode) {
134
+ if (this.customRenderController.hasCustomRenderFunction) {
128
135
  return html `
129
136
  <div class=${resultComponentClass}>
130
137
  <div
@@ -143,16 +150,13 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
143
150
  `;
144
151
  }
145
152
  // Handle case where content is undefined and layout was not created
146
- if (!this.layout) {
153
+ if (!this.itemLayoutController.getLayout()) {
147
154
  return html `<div class=${resultComponentClass}></div>`;
148
155
  }
149
156
  return html `
150
157
  <div class=${resultComponentClass}>
151
158
  <div
152
- class="result-root ${this.layout
153
- .getClasses()
154
- .concat(this.classes)
155
- .join(' ')}"
159
+ class="result-root ${this.itemLayoutController.getCombinedClasses().join(' ')}"
156
160
  .innerHTML=${this.getContentHTML()}
157
161
  ></div>
158
162
  <div class="link-container" .innerHTML=${this.getLinkHTML()}></div>
@@ -164,42 +168,6 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
164
168
  this.store.unsetLoadingFlag(this.loadingFlag);
165
169
  }
166
170
  }
167
- getCombinedClasses(additionalContent) {
168
- const layoutClasses = this.layout
169
- ? this.layout.getClasses(additionalContent)
170
- : [];
171
- const extraClasses = this.classes.split(/\s+/).filter((c) => c);
172
- return [...layoutClasses, ...extraClasses];
173
- }
174
- applyClassesToChildren() {
175
- if (!this.layout) {
176
- return;
177
- }
178
- const classes = this.getCombinedClasses();
179
- const root = this.shadowRoot?.querySelector('.result-root');
180
- if (!root) {
181
- return;
182
- }
183
- root.querySelectorAll('*').forEach((el) => {
184
- const tag = el.tagName.toLowerCase();
185
- if (tag.startsWith('atomic-product-')) {
186
- el.classList.add(...classes);
187
- }
188
- });
189
- }
190
- updated(_changedProperties) {
191
- if (this.shouldExecuteRenderFunction()) {
192
- const customRenderOutputAsString = this.renderingFunction(this.product, this.productRootRef, this.linkContainerRef);
193
- if (this.layout) {
194
- const classes = this.getCombinedClasses(customRenderOutputAsString);
195
- this.productRootRef.classList.add(...classes);
196
- }
197
- this.executedRenderingFunctionOnce = true;
198
- }
199
- if (!this.isCustomRenderFunctionMode) {
200
- this.applyClassesToChildren();
201
- }
202
- }
203
171
  };
204
172
  AtomicProduct.styles = styles;
205
173
  __decorate([
@@ -0,0 +1,50 @@
1
+ /**
2
+ * A reactive controller that manages custom rendering function execution for item components.
3
+ */
4
+ export class CustomRenderController {
5
+ constructor(host, options) {
6
+ this.hasExecutedRenderFunction = false;
7
+ this.options = {
8
+ linkContainerRef: () => undefined,
9
+ onRenderComplete: () => { },
10
+ ...options,
11
+ };
12
+ host.addController(this);
13
+ }
14
+ hostConnected() {
15
+ this.resetRenderState();
16
+ }
17
+ hostUpdated() {
18
+ this.executeRenderFunction();
19
+ }
20
+ /**
21
+ * Indicates whether a custom rendering function is provided.
22
+ */
23
+ get hasCustomRenderFunction() {
24
+ return this.options.renderingFunction() !== undefined;
25
+ }
26
+ resetRenderState() {
27
+ this.hasExecutedRenderFunction = false;
28
+ }
29
+ shouldExecuteRenderFunction() {
30
+ const rootElementRef = this.options.rootElementRef();
31
+ return !!(this.hasCustomRenderFunction &&
32
+ rootElementRef &&
33
+ !this.hasExecutedRenderFunction);
34
+ }
35
+ executeRenderFunction() {
36
+ if (!this.shouldExecuteRenderFunction()) {
37
+ return;
38
+ }
39
+ const renderingFunction = this.options.renderingFunction();
40
+ const itemData = this.options.itemData();
41
+ const rootElementRef = this.options.rootElementRef();
42
+ const linkContainerRef = this.options.linkContainerRef();
43
+ if (!renderingFunction || !itemData || !rootElementRef) {
44
+ return;
45
+ }
46
+ const customRenderOutput = renderingFunction(itemData, rootElementRef, linkContainerRef);
47
+ this.options.onRenderComplete(rootElementRef, customRenderOutput);
48
+ this.hasExecutedRenderFunction = true;
49
+ }
50
+ }
@@ -0,0 +1,103 @@
1
+ import { ItemLayout, } from './display-options';
2
+ /**
3
+ * A reactive controller that manages layout creation and class application for item components.
4
+ */
5
+ export class ItemLayoutController {
6
+ constructor(host, options) {
7
+ this.layoutInstance = null;
8
+ this.host = host;
9
+ this.options = {
10
+ ...options,
11
+ };
12
+ host.addController(this);
13
+ }
14
+ hostConnected() {
15
+ this.createLayout();
16
+ }
17
+ hostUpdated() {
18
+ this.applyLayoutClasses();
19
+ }
20
+ /**
21
+ * Gets the current layout instance
22
+ */
23
+ getLayout() {
24
+ return this.layoutInstance;
25
+ }
26
+ /**
27
+ * Gets combined layout and extra classes
28
+ */
29
+ getCombinedClasses(additionalContent) {
30
+ const layout = this.getLayout();
31
+ const layoutClasses = layout ? layout.getClasses(additionalContent) : [];
32
+ const itemClasses = this.options
33
+ .itemClasses()
34
+ .split(/\s+/)
35
+ .filter((c) => c);
36
+ return [...layoutClasses, ...itemClasses];
37
+ }
38
+ /**
39
+ * Applies layout classes to a specific element (useful for custom rendering)
40
+ */
41
+ applyLayoutClassesToElement(element, additionalContent) {
42
+ const layout = this.getLayout();
43
+ if (!layout) {
44
+ return;
45
+ }
46
+ const classes = this.getCombinedClasses(additionalContent);
47
+ if (classes.length > 0) {
48
+ element.classList.add(...classes);
49
+ }
50
+ }
51
+ applyLayoutClasses() {
52
+ const layout = this.getLayout();
53
+ if (!layout) {
54
+ return;
55
+ }
56
+ const classes = this.getCombinedClasses();
57
+ const root = this.host.shadowRoot?.querySelector('.result-root');
58
+ if (!root || classes.length === 0) {
59
+ return;
60
+ }
61
+ if (this.hasCustomRenderFunction()) {
62
+ this.observeAndApplyClasses(root, classes);
63
+ }
64
+ else {
65
+ this.addClassesToElements(root, classes);
66
+ }
67
+ }
68
+ createLayout() {
69
+ const content = this.options.content();
70
+ if (!content) {
71
+ console.warn(`${this.options.elementPrefix}: content property is undefined. Cannot create layout.`, this.host);
72
+ this.layoutInstance = null;
73
+ return;
74
+ }
75
+ const config = this.options.layoutConfig();
76
+ this.layoutInstance = new ItemLayout(content.children, config.display, config.density, config.imageSize);
77
+ }
78
+ hasCustomRenderFunction() {
79
+ return this.options.renderingFunction() !== undefined;
80
+ }
81
+ addClassesToElements(root, classes) {
82
+ if (classes.length === 0) {
83
+ return;
84
+ }
85
+ const elements = root.querySelectorAll('*');
86
+ elements.forEach((element) => {
87
+ const tagName = element.tagName.toLowerCase();
88
+ if (tagName.startsWith(`${this.options.elementPrefix}-`)) {
89
+ element.classList.add(...classes);
90
+ }
91
+ });
92
+ }
93
+ observeAndApplyClasses(root, classes) {
94
+ const observer = new MutationObserver((mutations) => {
95
+ const hasNewElements = mutations.some((mutation) => mutation.type === 'childList' && mutation.addedNodes.length > 0);
96
+ if (hasNewElements) {
97
+ this.addClassesToElements(root, classes);
98
+ observer.disconnect();
99
+ }
100
+ });
101
+ observer.observe(root, { childList: true, subtree: true });
102
+ }
103
+ }
@@ -0,0 +1,50 @@
1
+ import { deepEqual } from "../../../utils/compare-utils";
2
+ /**
3
+ * A reactive controller that validates the props of a Lit component against a
4
+ * provided Bueno schema.
5
+ *
6
+ * It validates the props when the host is connected to the DOM and whenever
7
+ * the host updates, revalidating only if the props have changed since the last
8
+ * validation.
9
+ *
10
+ * If validation fails, the controller sets the `error` property on the host.
11
+ */
12
+ export class ValidatePropsController {
13
+ /**
14
+ * Creates a `ValidatePropsController`.
15
+ *
16
+ * @param host The host element.
17
+ * @param getProps A function that returns the current props to validate.
18
+ * @param schema The Bueno schema to validate the props against.
19
+ */
20
+ constructor(host, getProps, schema) {
21
+ this.host = host;
22
+ this.getProps = getProps;
23
+ this.schema = schema;
24
+ host.addController(this);
25
+ }
26
+ hostConnected() {
27
+ this.currentProps = this.getProps();
28
+ this._validateProps();
29
+ }
30
+ hostUpdate() {
31
+ this.currentProps = this.getProps();
32
+ if (deepEqual(this.currentProps, this.previousProps)) {
33
+ return;
34
+ }
35
+ // @ts-expect-error: we need to clear the error.
36
+ this.host.error = undefined;
37
+ this._validateProps();
38
+ }
39
+ _validateProps() {
40
+ try {
41
+ this.schema.validate(this.currentProps);
42
+ }
43
+ catch (error) {
44
+ this.host.error = error;
45
+ }
46
+ finally {
47
+ this.previousProps = this.currentProps;
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,100 @@
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 { getOrganizationEndpoint } from '@coveo/headless';
8
+ import { html, LitElement, nothing } from 'lit';
9
+ import { customElement, state } from 'lit/decorators.js';
10
+ import { renderButton } from "../../common/button";
11
+ import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
12
+ import "../../common/atomic-modal/atomic-modal";
13
+ import { bindingGuard } from "../../../decorators/binding-guard";
14
+ import { bindings } from "../../../decorators/bindings";
15
+ import { errorGuard } from "../../../decorators/error-guard";
16
+ /**
17
+ * The `atomic-relevance-inspector` component is used internally to offer insight on search page relevance, as well as information to help troubleshoot issues during development.
18
+ *
19
+ * @internal
20
+ */
21
+ let AtomicRelevanceInspector = class AtomicRelevanceInspector extends LitElement {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.open = false;
25
+ this.initialize = () => {
26
+ this.bindings.interfaceElement.addEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
27
+ };
28
+ this.handleRelevanceInspectorDoubleClick = (e) => {
29
+ if (e.altKey) {
30
+ this.open = !this.open;
31
+ }
32
+ };
33
+ }
34
+ disconnectedCallback() {
35
+ this.bindings.interfaceElement.removeEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
36
+ }
37
+ render() {
38
+ return html `
39
+ <atomic-modal
40
+ .isOpen=${this.open}
41
+ @close=${() => this.handleCloseRelevanceInspector()}
42
+ exportparts="footer"
43
+ >
44
+ <p slot="header">Open the relevance inspector</p>
45
+ <p slot="body">
46
+ The Relevance Inspector will open in the Coveo Administration Console.
47
+ </p>
48
+ <div slot="footer" class="flex w-full items-center justify-end">
49
+ ${renderButton({
50
+ props: {
51
+ style: 'outline-primary',
52
+ class: 'mr-2 p-2',
53
+ onClick: () => this.handleCloseRelevanceInspector(),
54
+ text: 'Ignore',
55
+ },
56
+ })(nothing)}
57
+ ${renderButton({
58
+ props: {
59
+ style: 'primary',
60
+ class: 'p-2',
61
+ onClick: () => {
62
+ window.open(this.adminHref, '_blank');
63
+ this.handleCloseRelevanceInspector();
64
+ },
65
+ text: 'Open',
66
+ },
67
+ })(nothing)}
68
+ </div>
69
+ </atomic-modal>
70
+ `;
71
+ }
72
+ handleCloseRelevanceInspector() {
73
+ this.open = false;
74
+ }
75
+ get adminHref() {
76
+ const { organizationId, environment } = this.bindings.engine.state.configuration;
77
+ const admin = getOrganizationEndpoint(organizationId, environment, 'admin');
78
+ const { searchResponseId } = this.bindings.engine.state.search;
79
+ return `${admin}/admin/#/${organizationId}/search/relevanceInspector/${searchResponseId}`;
80
+ }
81
+ };
82
+ __decorate([
83
+ state()
84
+ ], AtomicRelevanceInspector.prototype, "bindings", void 0);
85
+ __decorate([
86
+ state()
87
+ ], AtomicRelevanceInspector.prototype, "error", void 0);
88
+ __decorate([
89
+ state()
90
+ ], AtomicRelevanceInspector.prototype, "open", void 0);
91
+ __decorate([
92
+ bindingGuard(),
93
+ errorGuard()
94
+ ], AtomicRelevanceInspector.prototype, "render", null);
95
+ AtomicRelevanceInspector = __decorate([
96
+ customElement('atomic-relevance-inspector'),
97
+ bindings(),
98
+ withTailwindStyles
99
+ ], AtomicRelevanceInspector);
100
+ export { AtomicRelevanceInspector };
@@ -8,7 +8,7 @@ import { buildSearchEngine, buildSearchStatus, buildUrlManager, EcommerceDefault
8
8
  import { provide } from '@lit/context';
9
9
  import i18next from 'i18next';
10
10
  import { css, html, LitElement } from 'lit';
11
- import { customElement, property, state } from 'lit/decorators.js';
11
+ import { customElement, property, query, state } from 'lit/decorators.js';
12
12
  import { when } from 'lit/directives/when.js';
13
13
  import { InterfaceController, } from "../../common/interface/interface-controller";
14
14
  import { MobileBreakpointController } from "../../common/layout/mobile-breakpoint-controller";
@@ -21,6 +21,7 @@ import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js"
21
21
  import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
22
22
  import { markParentAsReady } from "../../../utils/init-queue";
23
23
  import { SafeStorage, StorageItems, } from "../../../utils/local-storage-utils";
24
+ import "../atomic-relevance-inspector/atomic-relevance-inspector";
24
25
  import { getAnalyticsConfig } from './analytics-config';
25
26
  import { createSearchStore } from './store';
26
27
  // TODO - Remove once all components that use atomic-modal have been migrated.
@@ -35,7 +36,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
35
36
  constructor() {
36
37
  super();
37
38
  this.bindings = {};
38
- this.relevanceInspectorIsOpen = false;
39
39
  this.unsubscribeUrlManager = () => { };
40
40
  this.unsubscribeSearchStatus = () => { };
41
41
  this.initialized = false;
@@ -105,11 +105,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
105
105
  this.handleInitialization = (event) => {
106
106
  this.interfaceController.onComponentInitializing(event);
107
107
  };
108
- this.handleRelevanceInspectorDoubleClick = (e) => {
109
- if (e.altKey) {
110
- this.relevanceInspectorIsOpen = !this.relevanceInspectorIsOpen;
111
- }
112
- };
113
108
  this.onHashChange = () => {
114
109
  this.urlManager.synchronize(this.fragment);
115
110
  };
@@ -122,15 +117,13 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
122
117
  connectedCallback() {
123
118
  super.connectedCallback();
124
119
  this.store.setLoadingFlag(FirstSearchExecutedFlag);
125
- this.initRelevanceInspector();
126
120
  this.addEventListener('atomic/initializeComponent', this.handleInitialization);
127
121
  this.addEventListener('atomic/scrollToTop', this.scrollToTop);
128
- this.addEventListener('atomic/relevanceInspector/close', this.closeRelevanceInspector);
129
122
  }
130
123
  willUpdate(changedProperties) {
131
124
  super.willUpdate(changedProperties);
132
125
  if (changedProperties.has('fieldsToInclude')) {
133
- this.initFieldsToInclude();
126
+ this.updateFieldsToInclude();
134
127
  }
135
128
  }
136
129
  disconnectedCallback() {
@@ -144,8 +137,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
144
137
  window.removeEventListener('hashchange', this.onHashChange);
145
138
  this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
146
139
  this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
147
- this.removeEventListener('atomic/relevanceInspector/close', this.closeRelevanceInspector);
148
- this.removeEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
149
140
  }
150
141
  // TODO - (v4) KIT-4991: Make private.
151
142
  scrollToTop() {
@@ -156,8 +147,13 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
156
147
  }
157
148
  scrollContainerElement.scrollIntoView({ behavior: 'smooth' });
158
149
  }
150
+ /**
151
+ * @deprecated provided for backward compatibility. set the 'open' property directly on the relevance inspector instead.
152
+ */
159
153
  closeRelevanceInspector() {
160
- this.relevanceInspectorIsOpen = false;
154
+ if (this.relevanceInspector) {
155
+ this.relevanceInspector.open = false;
156
+ }
161
157
  }
162
158
  /**
163
159
  * Initializes the connection with the headless search engine using options for `accessToken` (required), `organizationId` (required), `environment` (defaults to `prod`), and `renewAccessToken`.
@@ -260,6 +256,11 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
260
256
  const fields = EcommerceDefaultFieldsToInclude.concat(this.fieldsToInclude);
261
257
  this.store.addFieldsToInclude(fields);
262
258
  }
259
+ updateFieldsToInclude() {
260
+ this.store.state.fieldsToInclude = [];
261
+ this.initFieldsToInclude();
262
+ this.registerFieldsToInclude();
263
+ }
263
264
  registerFieldsToInclude() {
264
265
  this.engine?.dispatch(loadFieldActions(this.engine).registerFieldsToInclude(this.store.state.fieldsToInclude));
265
266
  }
@@ -314,11 +315,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
314
315
  this.unsubscribeUrlManager = this.urlManager.subscribe(() => this.updateHash());
315
316
  window.addEventListener('hashchange', this.onHashChange);
316
317
  }
317
- initRelevanceInspector() {
318
- if (this.enableRelevanceInspector && !this.disableRelevanceInspector) {
319
- this.addEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
320
- }
321
- }
322
318
  initSearchStatus() {
323
319
  this.searchStatus = buildSearchStatus(this.engine);
324
320
  this.unsubscribeSearchStatus = this.searchStatus.subscribe(() => {
@@ -363,10 +359,7 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
363
359
  return html `
364
360
  ${when(this.bindings?.engine &&
365
361
  this.enableRelevanceInspector &&
366
- !this.disableRelevanceInspector, () => html `<atomic-relevance-inspector
367
- ?open=${this.relevanceInspectorIsOpen}
368
- .bindings=${this.bindings}
369
- ></atomic-relevance-inspector>`)}
362
+ !this.disableRelevanceInspector, () => html `<atomic-relevance-inspector></atomic-relevance-inspector>`)}
370
363
  <slot></slot>
371
364
  `;
372
365
  }
@@ -382,8 +375,8 @@ __decorate([
382
375
  state()
383
376
  ], AtomicSearchInterface.prototype, "error", void 0);
384
377
  __decorate([
385
- state()
386
- ], AtomicSearchInterface.prototype, "relevanceInspectorIsOpen", void 0);
378
+ query('atomic-relevance-inspector')
379
+ ], AtomicSearchInterface.prototype, "relevanceInspector", void 0);
387
380
  __decorate([
388
381
  property({
389
382
  type: Array,
@@ -1,7 +1,7 @@
1
1
  // Auto-generated file
2
2
  export { AtomicPager } from './atomic-pager/atomic-pager.js';
3
3
  export { AtomicQuerySummary } from './atomic-query-summary/atomic-query-summary.js';
4
+ export { AtomicRelevanceInspector } from './atomic-relevance-inspector/atomic-relevance-inspector.js';
4
5
  export { AtomicResultsPerPage } from './atomic-results-per-page/atomic-results-per-page.js';
5
- export { AtomicSearchBoxQuerySuggestions } from './atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js';
6
6
  export { AtomicSearchInterface } from './atomic-search-interface/atomic-search-interface.js';
7
7
  export { AtomicSearchLayout } from './atomic-search-layout/atomic-search-layout.js';
@@ -2,8 +2,8 @@
2
2
  export default {
3
3
  'atomic-pager': async () => await import('./atomic-pager/atomic-pager.js'),
4
4
  'atomic-query-summary': async () => await import('./atomic-query-summary/atomic-query-summary.js'),
5
+ 'atomic-relevance-inspector': async () => await import('./atomic-relevance-inspector/atomic-relevance-inspector.js'),
5
6
  'atomic-results-per-page': async () => await import('./atomic-results-per-page/atomic-results-per-page.js'),
6
- 'atomic-search-box-query-suggestions': async () => await import('./atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js'),
7
7
  'atomic-search-interface': async () => await import('./atomic-search-interface/atomic-search-interface.js'),
8
8
  'atomic-search-layout': async () => await import('./atomic-search-layout/atomic-search-layout.js'),
9
9
  };
@@ -3,7 +3,7 @@ function getWindow() {
3
3
  }
4
4
  export function getAtomicEnvironment(headlessVersion) {
5
5
  return {
6
- version: "3.34.0-pre.8b1d289c8b",
6
+ version: "3.34.0-pre.9353d3e7c7",
7
7
  headlessVersion,
8
8
  };
9
9
  }
@@ -0,0 +1,33 @@
1
+ import { h } from '@stencil/core/internal/client';
2
+ import { e as encodeForDomAttribute } from './string-utils.js';
3
+
4
+ const getPartialSearchBoxSuggestionElement = (suggestion, i18n) => {
5
+ return {
6
+ part: 'query-suggestion-item',
7
+ key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,
8
+ query: suggestion.rawValue,
9
+ ariaLabel: i18n.t('query-suggestion-label', {
10
+ query: suggestion.rawValue,
11
+ interpolation: { escapeValue: false },
12
+ }),
13
+ };
14
+ };
15
+ const QuerySuggestionContainer = (_, children) => {
16
+ return (h("div", { part: "query-suggestion-content", class: "flex items-center" }, children));
17
+ };
18
+ const QuerySuggestionIcon = ({ icon, hasSuggestion }) => {
19
+ if (!hasSuggestion) {
20
+ return;
21
+ }
22
+ return (h("atomic-icon", { part: "query-suggestion-icon", icon: icon, class: "mr-2 h-4 w-4 shrink-0" }));
23
+ };
24
+ const QuerySuggestionText = ({ suggestion, hasQuery }) => {
25
+ if (hasQuery) {
26
+ return (h("span", { part: "query-suggestion-text", class: "line-clamp-2 break-all", innerHTML: suggestion.highlightedValue }));
27
+ }
28
+ return (h("span", { part: "query-suggestion-text", class: "line-clamp-2 break-all" }, suggestion.rawValue));
29
+ };
30
+
31
+ export { QuerySuggestionContainer as Q, QuerySuggestionIcon as a, QuerySuggestionText as b, getPartialSearchBoxSuggestionElement as g };
32
+
33
+ //# sourceMappingURL=stencil-query-suggestions.js.map
@@ -0,0 +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-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}