@empathyco/x-components 9.3.0 → 9.3.2

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 (240) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/core/index.js +4 -0
  3. package/core/index.js.map +1 -1
  4. package/docs/API-reference/api/x-components.accessibility_key.md +11 -0
  5. package/docs/API-reference/api/x-components.aicarousel.md +4 -0
  6. package/docs/API-reference/api/x-components.arialabels.aicarousel.md +14 -0
  7. package/docs/API-reference/api/x-components.arialabels.basecolumnpickerdropdown.md +13 -0
  8. package/docs/API-reference/api/x-components.arialabels.basecolumnpickerlist.md +13 -0
  9. package/docs/API-reference/api/x-components.arialabels.basedropdown.md +13 -0
  10. package/docs/API-reference/api/x-components.arialabels.baseeventsmodalclose.md +13 -0
  11. package/docs/API-reference/api/x-components.arialabels.baseeventsmodalopen.md +13 -0
  12. package/docs/API-reference/api/x-components.arialabels.basemodal.md +13 -0
  13. package/docs/API-reference/api/x-components.arialabels.clearhistoryqueries.md +13 -0
  14. package/docs/API-reference/api/x-components.arialabels.editablenumberrangefilter.md +14 -0
  15. package/docs/API-reference/api/x-components.arialabels.facets.md +13 -0
  16. package/docs/API-reference/api/x-components.arialabels.filterssearch.md +13 -0
  17. package/docs/API-reference/api/x-components.arialabels.historyqueriesswitch.md +13 -0
  18. package/docs/API-reference/api/x-components.arialabels.historyquery.md +13 -0
  19. package/docs/API-reference/api/x-components.arialabels.md +419 -0
  20. package/docs/API-reference/api/x-components.arialabels.pageloaderbutton.md +13 -0
  21. package/docs/API-reference/api/x-components.arialabels.pageselector.md +16 -0
  22. package/docs/API-reference/api/x-components.arialabels.removehistoryquery.md +13 -0
  23. package/docs/API-reference/api/x-components.arialabels.scrolltotop.md +13 -0
  24. package/docs/API-reference/api/x-components.arialabels.searchinput.md +13 -0
  25. package/docs/API-reference/api/x-components.arialabels.sliderfilter.md +14 -0
  26. package/docs/API-reference/api/x-components.arialabels.sortdropdown.md +13 -0
  27. package/docs/API-reference/api/x-components.basecolumnpickerdropdown.md +3 -0
  28. package/docs/API-reference/api/x-components.basecolumnpickerlist.md +3 -0
  29. package/docs/API-reference/api/x-components.basedropdown.md +3 -2
  30. package/docs/API-reference/api/x-components.baseeventsmodalclose.md +3 -0
  31. package/docs/API-reference/api/x-components.baseeventsmodalopen.md +3 -0
  32. package/docs/API-reference/api/x-components.basemodal.md +3 -0
  33. package/docs/API-reference/api/x-components.clearhistoryqueries.md +3 -0
  34. package/docs/API-reference/api/x-components.deepmergewithdefaults.md +85 -0
  35. package/docs/API-reference/api/x-components.editablenumberrangefilter.md +4 -2
  36. package/docs/API-reference/api/x-components.facets.md +3 -0
  37. package/docs/API-reference/api/x-components.filterssearch.md +3 -0
  38. package/docs/API-reference/api/x-components.historyqueriesswitch.md +3 -0
  39. package/docs/API-reference/api/x-components.historyquery.md +3 -0
  40. package/docs/API-reference/api/x-components.md +50 -0
  41. package/docs/API-reference/api/x-components.pageloaderbutton.md +3 -0
  42. package/docs/API-reference/api/x-components.pageselector.md +6 -0
  43. package/docs/API-reference/api/x-components.removehistoryquery.md +3 -0
  44. package/docs/API-reference/api/x-components.scrolltotop.md +3 -0
  45. package/docs/API-reference/api/x-components.searchinput.md +3 -0
  46. package/docs/API-reference/api/x-components.sliderfilter.md +4 -0
  47. package/docs/API-reference/api/x-components.sortdropdown.md +3 -0
  48. package/docs/API-reference/api/x-components.useaccessibilitylabels.md +72 -0
  49. package/docs/API-reference/components/common/x-components.base-dropdown.md +0 -1
  50. package/js/components/base-dropdown.vue.js +1 -1
  51. package/js/components/base-dropdown.vue.js.map +1 -1
  52. package/js/components/base-dropdown.vue2.js +11 -3
  53. package/js/components/base-dropdown.vue2.js.map +1 -1
  54. package/js/components/base-keyboard-navigation.vue2.js +1 -0
  55. package/js/components/base-keyboard-navigation.vue2.js.map +1 -1
  56. package/js/components/column-picker/base-column-picker-dropdown.vue.js +2 -2
  57. package/js/components/column-picker/base-column-picker-dropdown.vue.js.map +1 -1
  58. package/js/components/column-picker/base-column-picker-dropdown.vue2.js +10 -0
  59. package/js/components/column-picker/base-column-picker-dropdown.vue2.js.map +1 -1
  60. package/js/components/column-picker/base-column-picker-list.vue.js +1 -1
  61. package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
  62. package/js/components/column-picker/base-column-picker-list.vue2.js +10 -1
  63. package/js/components/column-picker/base-column-picker-list.vue2.js.map +1 -1
  64. package/js/components/display-click-provider.vue.js +2 -1
  65. package/js/components/display-click-provider.vue.js.map +1 -1
  66. package/js/components/highlight.vue2.js +1 -0
  67. package/js/components/highlight.vue2.js.map +1 -1
  68. package/js/components/modals/base-events-modal-close.vue.js +2 -2
  69. package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
  70. package/js/components/modals/base-events-modal-close.vue2.js +10 -0
  71. package/js/components/modals/base-events-modal-close.vue2.js.map +1 -1
  72. package/js/components/modals/base-events-modal-open.vue.js +2 -2
  73. package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
  74. package/js/components/modals/base-events-modal-open.vue2.js +10 -0
  75. package/js/components/modals/base-events-modal-open.vue2.js.map +1 -1
  76. package/js/components/modals/base-id-modal-close.vue2.js +2 -1
  77. package/js/components/modals/base-id-modal-close.vue2.js.map +1 -1
  78. package/js/components/modals/base-id-modal-open.vue2.js +2 -1
  79. package/js/components/modals/base-id-modal-open.vue2.js.map +1 -1
  80. package/js/components/modals/base-id-modal.vue2.js +2 -1
  81. package/js/components/modals/base-id-modal.vue2.js.map +1 -1
  82. package/js/components/modals/base-modal.vue.js +11 -16
  83. package/js/components/modals/base-modal.vue.js.map +1 -1
  84. package/js/components/modals/base-modal.vue2.js +3 -0
  85. package/js/components/modals/base-modal.vue2.js.map +1 -1
  86. package/js/components/page-loader-button.vue.js +2 -2
  87. package/js/components/page-loader-button.vue.js.map +1 -1
  88. package/js/components/page-loader-button.vue2.js +3 -0
  89. package/js/components/page-loader-button.vue2.js.map +1 -1
  90. package/js/components/page-selector.vue.js +12 -12
  91. package/js/components/page-selector.vue.js.map +1 -1
  92. package/js/components/page-selector.vue2.js +3 -0
  93. package/js/components/page-selector.vue2.js.map +1 -1
  94. package/js/components/panels/base-id-toggle-panel-button.vue2.js +1 -0
  95. package/js/components/panels/base-id-toggle-panel-button.vue2.js.map +1 -1
  96. package/js/components/panels/base-id-toggle-panel.vue2.js +2 -1
  97. package/js/components/panels/base-id-toggle-panel.vue2.js.map +1 -1
  98. package/js/components/result/base-result-link.vue2.js +2 -1
  99. package/js/components/result/base-result-link.vue2.js.map +1 -1
  100. package/js/components/result/base-result-rating.vue2.js +2 -1
  101. package/js/components/result/base-result-rating.vue2.js.map +1 -1
  102. package/js/components/sort/sort-dropdown.vue.js +2 -2
  103. package/js/components/sort/sort-dropdown.vue.js.map +1 -1
  104. package/js/components/sort/sort-dropdown.vue2.js +10 -0
  105. package/js/components/sort/sort-dropdown.vue2.js.map +1 -1
  106. package/js/components/suggestions/base-suggestion.vue2.js +1 -0
  107. package/js/components/suggestions/base-suggestion.vue2.js.map +1 -1
  108. package/js/composables/use-accessibility-labels.js +40 -0
  109. package/js/composables/use-accessibility-labels.js.map +1 -0
  110. package/js/index.js +4 -0
  111. package/js/index.js.map +1 -1
  112. package/js/types/accessibility.js +4 -0
  113. package/js/types/accessibility.js.map +1 -0
  114. package/js/utils/accessibility.js +37 -0
  115. package/js/utils/accessibility.js.map +1 -0
  116. package/js/utils/deep-merge-with-defaults.js +47 -0
  117. package/js/utils/deep-merge-with-defaults.js.map +1 -0
  118. package/js/x-modules/ai/components/ai-carousel.vue.js +1 -1
  119. package/js/x-modules/ai/components/ai-carousel.vue.js.map +1 -1
  120. package/js/x-modules/ai/components/ai-carousel.vue2.js +3 -0
  121. package/js/x-modules/ai/components/ai-carousel.vue2.js.map +1 -1
  122. package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js +1 -0
  123. package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js.map +1 -1
  124. package/js/x-modules/empathize/components/empathize.vue2.js +2 -2
  125. package/js/x-modules/facets/components/facets/facets-provider.vue2.js +1 -0
  126. package/js/x-modules/facets/components/facets/facets-provider.vue2.js.map +1 -1
  127. package/js/x-modules/facets/components/facets/facets.vue.js +57 -51
  128. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  129. package/js/x-modules/facets/components/facets/facets.vue2.js +9 -0
  130. package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
  131. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js +2 -2
  132. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js.map +1 -1
  133. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js +3 -4
  134. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js.map +1 -1
  135. package/js/x-modules/facets/components/filters/slider-filter.vue.js +4 -4
  136. package/js/x-modules/facets/components/filters/slider-filter.vue.js.map +1 -1
  137. package/js/x-modules/facets/components/filters/slider-filter.vue2.js +3 -0
  138. package/js/x-modules/facets/components/filters/slider-filter.vue2.js.map +1 -1
  139. package/js/x-modules/facets/components/lists/filters-search.vue.js +2 -2
  140. package/js/x-modules/facets/components/lists/filters-search.vue.js.map +1 -1
  141. package/js/x-modules/facets/components/lists/filters-search.vue2.js +10 -0
  142. package/js/x-modules/facets/components/lists/filters-search.vue2.js.map +1 -1
  143. package/js/x-modules/facets/components/lists/sorted-filters.vue.js +1 -0
  144. package/js/x-modules/facets/components/lists/sorted-filters.vue.js.map +1 -1
  145. package/js/x-modules/history-queries/components/clear-history-queries.vue.js +2 -2
  146. package/js/x-modules/history-queries/components/clear-history-queries.vue.js.map +1 -1
  147. package/js/x-modules/history-queries/components/clear-history-queries.vue2.js +10 -0
  148. package/js/x-modules/history-queries/components/clear-history-queries.vue2.js.map +1 -1
  149. package/js/x-modules/history-queries/components/history-queries-switch.vue.js +2 -2
  150. package/js/x-modules/history-queries/components/history-queries-switch.vue.js.map +1 -1
  151. package/js/x-modules/history-queries/components/history-queries-switch.vue2.js +10 -0
  152. package/js/x-modules/history-queries/components/history-queries-switch.vue2.js.map +1 -1
  153. package/js/x-modules/history-queries/components/history-query.vue.js +2 -1
  154. package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
  155. package/js/x-modules/history-queries/components/history-query.vue2.js +10 -0
  156. package/js/x-modules/history-queries/components/history-query.vue2.js.map +1 -1
  157. package/js/x-modules/history-queries/components/remove-history-query.vue.js +2 -2
  158. package/js/x-modules/history-queries/components/remove-history-query.vue.js.map +1 -1
  159. package/js/x-modules/history-queries/components/remove-history-query.vue2.js +10 -0
  160. package/js/x-modules/history-queries/components/remove-history-query.vue2.js.map +1 -1
  161. package/js/x-modules/queries-preview/components/query-preview-list.vue2.js +1 -0
  162. package/js/x-modules/queries-preview/components/query-preview-list.vue2.js.map +1 -1
  163. package/js/x-modules/queries-preview/components/query-preview.vue2.js +2 -2
  164. package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js +1 -0
  165. package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js.map +1 -1
  166. package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js +1 -0
  167. package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js.map +1 -1
  168. package/js/x-modules/recommendations/components/recommendations.vue2.js +1 -0
  169. package/js/x-modules/recommendations/components/recommendations.vue2.js.map +1 -1
  170. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +2 -1
  171. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -1
  172. package/js/x-modules/scroll/components/scroll-to-top.vue.js +2 -2
  173. package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
  174. package/js/x-modules/scroll/components/scroll-to-top.vue2.js +3 -0
  175. package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
  176. package/js/x-modules/search/wiring.js +1 -0
  177. package/js/x-modules/search/wiring.js.map +1 -1
  178. package/js/x-modules/search-box/components/search-input.vue.js +2 -2
  179. package/js/x-modules/search-box/components/search-input.vue.js.map +1 -1
  180. package/js/x-modules/search-box/components/search-input.vue2.js +11 -1
  181. package/js/x-modules/search-box/components/search-input.vue2.js.map +1 -1
  182. package/js/x-modules/semantic-queries/components/semantic-queries.vue2.js +1 -0
  183. package/js/x-modules/semantic-queries/components/semantic-queries.vue2.js.map +1 -1
  184. package/package.json +2 -2
  185. package/report/x-components.api.json +1148 -210
  186. package/report/x-components.api.md +176 -11
  187. package/types/src/components/base-dropdown.vue.d.ts +3 -4
  188. package/types/src/components/base-dropdown.vue.d.ts.map +1 -1
  189. package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts +3 -0
  190. package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts.map +1 -1
  191. package/types/src/components/column-picker/base-column-picker-list.vue.d.ts +3 -0
  192. package/types/src/components/column-picker/base-column-picker-list.vue.d.ts.map +1 -1
  193. package/types/src/components/modals/base-events-modal-close.vue.d.ts +3 -0
  194. package/types/src/components/modals/base-events-modal-close.vue.d.ts.map +1 -1
  195. package/types/src/components/modals/base-events-modal-open.vue.d.ts +3 -0
  196. package/types/src/components/modals/base-events-modal-open.vue.d.ts.map +1 -1
  197. package/types/src/components/modals/base-modal.vue.d.ts +3 -0
  198. package/types/src/components/modals/base-modal.vue.d.ts.map +1 -1
  199. package/types/src/components/page-loader-button.vue.d.ts +3 -0
  200. package/types/src/components/page-loader-button.vue.d.ts.map +1 -1
  201. package/types/src/components/page-selector.vue.d.ts +6 -0
  202. package/types/src/components/page-selector.vue.d.ts.map +1 -1
  203. package/types/src/components/sort/sort-dropdown.vue.d.ts +3 -0
  204. package/types/src/components/sort/sort-dropdown.vue.d.ts.map +1 -1
  205. package/types/src/composables/index.d.ts +1 -0
  206. package/types/src/composables/index.d.ts.map +1 -1
  207. package/types/src/composables/use-accessibility-labels.d.ts +31 -0
  208. package/types/src/composables/use-accessibility-labels.d.ts.map +1 -0
  209. package/types/src/types/accessibility.d.ts +79 -0
  210. package/types/src/types/accessibility.d.ts.map +1 -0
  211. package/types/src/types/index.d.ts +1 -0
  212. package/types/src/types/index.d.ts.map +1 -1
  213. package/types/src/utils/accessibility.d.ts +10 -0
  214. package/types/src/utils/accessibility.d.ts.map +1 -0
  215. package/types/src/utils/deep-merge-with-defaults.d.ts +28 -0
  216. package/types/src/utils/deep-merge-with-defaults.d.ts.map +1 -0
  217. package/types/src/utils/index.d.ts +2 -0
  218. package/types/src/utils/index.d.ts.map +1 -1
  219. package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts +4 -0
  220. package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts.map +1 -1
  221. package/types/src/x-modules/facets/components/facets/facets.vue.d.ts +3 -0
  222. package/types/src/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
  223. package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts +4 -2
  224. package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts.map +1 -1
  225. package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts +4 -0
  226. package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts.map +1 -1
  227. package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts +3 -0
  228. package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts.map +1 -1
  229. package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts +3 -0
  230. package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts.map +1 -1
  231. package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts +3 -0
  232. package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts.map +1 -1
  233. package/types/src/x-modules/history-queries/components/history-query.vue.d.ts +3 -0
  234. package/types/src/x-modules/history-queries/components/history-query.vue.d.ts.map +1 -1
  235. package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts +3 -0
  236. package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts.map +1 -1
  237. package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts +3 -0
  238. package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts.map +1 -1
  239. package/types/src/x-modules/search-box/components/search-input.vue.d.ts +3 -0
  240. package/types/src/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
@@ -11,7 +11,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
11
11
  animation: _ctx.animation,
12
12
  class: "x-sort-dropdown",
13
13
  "data-test": "sort-dropdown",
14
- "aria-label": "Select sorting",
14
+ "aria-label": _ctx.ariaLabels?.dropdown,
15
15
  "onUpdate:modelValue": _ctx.emitUserClickedASort
16
16
  }, {
17
17
  toggle: withCtx(({ isOpen, item }) => [
@@ -34,7 +34,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
34
34
  ]),
35
35
  _: 3
36
36
  /* FORWARDED */
37
- }, 8, ["items", "model-value", "animation", "onUpdate:modelValue"]);
37
+ }, 8, ["items", "model-value", "animation", "aria-label", "onUpdate:modelValue"]);
38
38
  }
39
39
  var sortDropdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
40
40
 
@@ -1 +1 @@
1
- {"version":3,"file":"sort-dropdown.vue.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n aria-label=\"Select sorting\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":["_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CA6Be,uBAAA,EAAA;AAAA,IA5Bb,GAAA,EAAI,SAAA;AAAA,IACH,KAAA,EAAO,IAAA,CAAA,KAAA;AAAA,IACP,aAAA,EAAa,IAAA,CAAA,YAAA;AAAA,IACb,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACZ,KAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EAAU,eAAA;AAAA,IACV,YAAA,EAAW,gBAAA;AAAA,IACV,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA;AAEV,IAAA,MAAA,EAAMC,OAAA,CAOf,CAA+D,EAP5C,MAAA,EAAQ,IAAA,EAAI,KAAA;AAAA,MAO/BC,UAAA,CAA+D,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAA/C,MAAA,EAAQ,IAAA,MAAxB,MAA+D;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;AAE5C,IAAA,IAAA,EAAIJ,OAAA,CAQb,CAAgF,EAR/D,IAAA,EAAM,eAAe,UAAA,EAAU,KAAA;AAAA,MAQhDC,WAAgF,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAhE,IAAA,EAAM,aAAA,EAAe,UAAA,MAArC,MAAgF;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"sort-dropdown.vue.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../../composables'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n const ariaLabels = useAccessibilityLabels('sortDropdown')\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n ariaLabels,\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":["_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CA6Be,uBAAA,EAAA;AAAA,IA5Bb,GAAA,EAAI,SAAA;AAAA,IACH,KAAA,EAAO,IAAA,CAAA,KAAA;AAAA,IACP,aAAA,EAAa,IAAA,CAAA,YAAA;AAAA,IACb,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACZ,KAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EAAU,eAAA;AAAA,IACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,IACxB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA;AAEV,IAAA,MAAA,EAAMC,OAAA,CAOf,CAA+D,EAP5C,MAAA,EAAQ,IAAA,EAAI,KAAA;AAAA,MAO/BC,UAAA,CAA+D,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAA/C,MAAA,EAAQ,IAAA,MAAxB,MAA+D;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;AAE5C,IAAA,IAAA,EAAIJ,OAAA,CAQb,CAAgF,EAR/D,IAAA,EAAM,eAAe,UAAA,EAAU,KAAA;AAAA,MAQhDC,WAAgF,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAhE,IAAA,EAAM,aAAA,EAAe,UAAA,MAArC,MAAgF;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;;;;;;;;;"}
@@ -1,5 +1,13 @@
1
1
  import { defineComponent, ref, watch } from 'vue';
2
+ import '../../composables/create-use-device.js';
2
3
  import { use$x } from '../../composables/use-_x.js';
4
+ import { useAccessibilityLabels } from '../../composables/use-accessibility-labels.js';
5
+ import 'vuex';
6
+ import '../../plugins/x-bus.js';
7
+ import '@empathyco/x-utils';
8
+ import '../../plugins/x-plugin.js';
9
+ import '@vueuse/core';
10
+ import 'rxjs';
3
11
  import BaseDropdown from '../base-dropdown.vue.js';
4
12
 
5
13
  /**
@@ -34,6 +42,7 @@ var _sfc_main = defineComponent({
34
42
  setup(props, { emit }) {
35
43
  const $x = use$x();
36
44
  const rootRef = ref();
45
+ const ariaLabels = useAccessibilityLabels('sortDropdown');
37
46
  watch(() => props.selectedSort, value => $x.emit(props.selectedSortProvidedEvent, value), {
38
47
  immediate: true,
39
48
  });
@@ -50,6 +59,7 @@ var _sfc_main = defineComponent({
50
59
  emit('change', sort);
51
60
  }
52
61
  return {
62
+ ariaLabels,
53
63
  emitUserClickedASort,
54
64
  rootRef,
55
65
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sort-dropdown.vue2.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n aria-label=\"Select sorting\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAyCA;;;AAGE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAiC;;AAE3D,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,KAAyB;AAC/B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAwB;AAC9B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,yBAAyB,EAAE;AACzB,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,sBAAsB;AAChC,SAAA;AACD,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,kBAAkB;AAC5B,SAAA;AACF,KAAA;IACD,KAAK,EAAE,CAAC,QAAQ,CAAC;AACjB,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAG,EAAG,EAAA;AACnB,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AACjB,QAAA,MAAM,OAAM,GAAI,GAAG,EAAsB;QAEzC,KAAK,CACH,MAAM,KAAK,CAAC,YAAY,EACxB,KAAI,IAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,EACxD;AACE,YAAA,SAAS,EAAE,IAAI;AAChB,SAAA,CACH;AAEA;;;;;;;AAOE;QACF,SAAS,oBAAoB,CAAC,IAAU,EAAA;AACtC,YAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,MAAM,EAAG,OAAO,CAAC,KAAa,EAAE,KAAK,CAAA;AAC7E,YAAA,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAA;QACrB;QAEA,OAAO;YACL,oBAAoB;YACpB,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"sort-dropdown.vue2.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../../composables'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n const ariaLabels = useAccessibilityLabels('sortDropdown')\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n ariaLabels,\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AA0CA;;;AAGE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,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
  import { defineComponent, ref, computed } from 'vue';
3
3
  import '../../composables/create-use-device.js';
4
4
  import { use$x } from '../../composables/use-_x.js';
5
+ import '../../utils/storage.js';
5
6
  import 'vuex';
6
7
  import '../../plugins/x-bus.js';
7
8
  import '../../plugins/x-plugin.js';
@@ -1 +1 @@
1
- {"version":3,"file":"base-suggestion.vue2.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" :class=\"dynamicCSSClasses\" @click=\"emitEvents\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\nimport type { BooleanFilter, Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { QueryFeature } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { forEach } from '@empathyco/x-utils'\nimport { computed, defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport Highlight from '../highlight.vue'\n\n/**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\nexport default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: '',\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>,\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true,\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean,\n },\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null)\n\n const $x = use$x()\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter,\n )\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {}\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent,\n }\n })\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature,\n })\n })\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated,\n )\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value,\n }))\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## Examples\n\n### Basic usage\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facets: [\n {\n modelName: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10,\n },\n ],\n },\n ],\n}\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\">\n <template #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </template>\n </BaseSuggestion>\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\n</script>\n```\n\n### Emitting custom events with suggestionSelectedEvents\n\nYou can emit additional custom events when a suggestion is selected by passing them in the `suggestionSelectedEvents` prop. For example, to emit a custom event called `CustomSuggestionEvent` with a payload:\n\n```vue live\n<template>\n <BaseSuggestion\n :query=\"query\"\n :suggestion=\"suggestion\"\n :suggestionSelectedEvents=\"suggestionSelectedEvents\"\n />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\nconst suggestionSelectedEvents = {\n CustomSuggestionEvent: { custom: 'payload' },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;AA0BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,WAAW;AACzB,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,EAAE;AACZ,SAAA;AAED;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;;AAEF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AAED;;;;AAIE;AACF,QAAA,wBAAwB,EAAE;AACxB,YAAA,IAAI,EAAE,MAAyC;AAC/C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,OAAO;AACd,SAAA;AACF,KAAA;AAED,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,GAAG,CAAqB,IAAI,CAAA;AAEvC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AA,CAAA;;;;"}
1
+ {"version":3,"file":"base-suggestion.vue2.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" :class=\"dynamicCSSClasses\" @click=\"emitEvents\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\nimport type { BooleanFilter, Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { QueryFeature } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { forEach } from '@empathyco/x-utils'\nimport { computed, defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport Highlight from '../highlight.vue'\n\n/**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\nexport default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: '',\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>,\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true,\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean,\n },\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null)\n\n const $x = use$x()\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter,\n )\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {}\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent,\n }\n })\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature,\n })\n })\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated,\n )\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value,\n }))\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## Examples\n\n### Basic usage\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facets: [\n {\n modelName: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10,\n },\n ],\n },\n ],\n}\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\">\n <template #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </template>\n </BaseSuggestion>\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\n</script>\n```\n\n### Emitting custom events with suggestionSelectedEvents\n\nYou can emit additional custom events when a suggestion is selected by passing them in the `suggestionSelectedEvents` prop. For example, to emit a custom event called `CustomSuggestionEvent` with a payload:\n\n```vue live\n<template>\n <BaseSuggestion\n :query=\"query\"\n :suggestion=\"suggestion\"\n :suggestionSelectedEvents=\"suggestionSelectedEvents\"\n />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\nconst suggestionSelectedEvents = {\n CustomSuggestionEvent: { custom: 'payload' },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AA0BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,WAAW;AACzB,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,EAAE;AACZ,SAAA;AAED;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;;AAEF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AAED;;;;AAIE;AACF,QAAA,wBAAwB,EAAE;AACxB,YAAA,IAAI,EAAE,MAAyC;AAC/C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,OAAO;AACd,SAAA;AACF,KAAA;AAED,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,GAAG,CAAqB,IAAI,CAAA;AAEvC,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;;;;;AAQE;QACF,MAAM,SAAS,QAAQ,CACrB,MAAM,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAkB,CACjE;AAEA;;;;;;;;;;;AAWE;AACF,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAwB,MAAI;AACjD,YAAA,MAAM,WAAW,GAA0B,MAAM,CAAC;AAChD,kBAAE,EAAE,kBAAkB,EAAE,MAAM,CAAC,KAAI;kBACjC,EAAC;YACL,OAAO;AACL,gBAAA,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK;gBAC1C,uBAAuB,EAAE,KAAK,CAAC,UAAU;gBACzC,GAAG,KAAK,CAAC,wBAAwB;AACjC,gBAAA,GAAG,WAAW;aAChB;AACF,QAAA,CAAC,CAAA;AAED;;;;AAIE;QACF,MAAM,UAAS,GAAI,MAAU;YAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAS;AAC5C,gBAAA,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE;oBACtB,MAAM,EAAE,EAAE,CAAC,KAAM;oBACjB,OAAO,EAAE,KAAK,CAAC,OAAO;AACvB,iBAAA,CAAA;AACH,YAAA,CAAC,CAAA;AACH,QAAA,CAAA;AAEA;;;;;;AAME;AACF,QAAA,MAAM,sBAAqB,GAAI,QAAQ,CACrC,MAAM,KAAK,CAAC,gBAAe,IAAK,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAC9D;AAEA;;;;;;;;AAQE;AACF,QAAA,MAAM,iBAAgB,GAAI,QAAQ,CAAgB,OAAO;YACvD,0BAA0B,EAAE,sBAAsB,CAAC,KAAK;AACzD,SAAA,CAAC,CAAA;QAEF,OAAO;YACL,EAAE;YACF,MAAM;YACN,UAAU;YACV,iBAAiB;SACnB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -0,0 +1,40 @@
1
+ import { inject, computed } from 'vue';
2
+ import { ACCESSIBILITY_KEY } from '../types/accessibility.js';
3
+ import { DEFAULT_ARIA_LABELS } from '../utils/accessibility.js';
4
+ import { deepMergeWithDefaults } from '../utils/deep-merge-with-defaults.js';
5
+ import '../utils/storage.js';
6
+
7
+ /**
8
+ * Resolves the aria labels for a given {@link AriaLabels} namespace, merging any labels provided
9
+ * by the consumer under {@link ACCESSIBILITY_KEY} on top of the library defaults.
10
+ *
11
+ * The consumer only needs to `app.provide` a **partial** configuration (e.g. the labels
12
+ * translated to its language): every entry that is not provided falls back to the library
13
+ * default. Providing nothing is a regular use case (the components resolve the defaults), and
14
+ * the `inject` fallback keeps Vue from logging an "injection not found" warning in that case.
15
+ *
16
+ * The resolved labels are reactive: if the consumer provides a reactive object (or re-provides
17
+ * translated labels when the locale changes), the components pick the new values up.
18
+ *
19
+ * @example
20
+ * ```vue
21
+ * <script setup>
22
+ * const ariaLabels = useAccessibilityLabels('pageSelector')
23
+ * </script>
24
+ * <template>
25
+ * <nav :aria-label="ariaLabels.pagination">...</nav>
26
+ * </template>
27
+ * ```
28
+ *
29
+ * @param namespace - The {@link AriaLabels} namespace to resolve (the PascalCase component name).
30
+ * @returns A reactive object with the resolved aria labels for the given namespace.
31
+ *
32
+ * @public
33
+ */
34
+ function useAccessibilityLabels(namespace) {
35
+ const injected = inject(ACCESSIBILITY_KEY, {});
36
+ return computed(() => deepMergeWithDefaults(DEFAULT_ARIA_LABELS, injected)[namespace]);
37
+ }
38
+
39
+ export { useAccessibilityLabels };
40
+ //# sourceMappingURL=use-accessibility-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-accessibility-labels.js","sources":["../../../src/composables/use-accessibility-labels.ts"],"sourcesContent":["import type { ComputedRef } from 'vue'\nimport type { AriaLabels } from '../types/accessibility'\nimport { computed, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../types/accessibility'\nimport { deepMergeWithDefaults, DEFAULT_ARIA_LABELS } from '../utils'\n\n/**\n * Resolves the aria labels for a given {@link AriaLabels} namespace, merging any labels provided\n * by the consumer under {@link ACCESSIBILITY_KEY} on top of the library defaults.\n *\n * The consumer only needs to `app.provide` a **partial** configuration (e.g. the labels\n * translated to its language): every entry that is not provided falls back to the library\n * default. Providing nothing is a regular use case (the components resolve the defaults), and\n * the `inject` fallback keeps Vue from logging an \"injection not found\" warning in that case.\n *\n * The resolved labels are reactive: if the consumer provides a reactive object (or re-provides\n * translated labels when the locale changes), the components pick the new values up.\n *\n * @example\n * ```vue\n * <script setup>\n * const ariaLabels = useAccessibilityLabels('pageSelector')\n * </script>\n * <template>\n * <nav :aria-label=\"ariaLabels.pagination\">...</nav>\n * </template>\n * ```\n *\n * @param namespace - The {@link AriaLabels} namespace to resolve (the PascalCase component name).\n * @returns A reactive object with the resolved aria labels for the given namespace.\n *\n * @public\n */\nexport function useAccessibilityLabels<N extends keyof AriaLabels>(\n namespace: N,\n): ComputedRef<NonNullable<AriaLabels[N]>> {\n const injected = inject(ACCESSIBILITY_KEY, {})\n return computed(\n () =>\n deepMergeWithDefaults(DEFAULT_ARIA_LABELS, injected)[namespace] as NonNullable<AriaLabels[N]>,\n )\n}\n"],"names":[],"mappings":";;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,sBAAsB,CACpC,SAAY,EAAA;IAEZ,MAAM,QAAQ,GAAG,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC;AAC9C,IAAA,OAAO,QAAQ,CACb,MACE,qBAAqB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS,CAA+B,CAChG;AACH;;;;"}
package/js/index.js CHANGED
@@ -153,6 +153,7 @@ export { default as BaseSuggestions } from './components/suggestions/base-sugges
153
153
  export { getRootXComponent, getXComponentXModuleName, isXComponent } from './components/x-component.utils.js';
154
154
  export { createUseDevice } from './composables/create-use-device.js';
155
155
  export { use$x } from './composables/use-_x.js';
156
+ export { useAccessibilityLabels } from './composables/use-accessibility-labels.js';
156
157
  export { useAliasApi } from './composables/use-alias-api.js';
157
158
  export { useDebounce } from './composables/use-debounce.js';
158
159
  export { useGetter } from './composables/use-getter.js';
@@ -173,11 +174,14 @@ export { createRelatedTagsQueryGetter, setQuery } from './store/utils/query.util
173
174
  export { setStatus } from './store/utils/status-store.utils.js';
174
175
  export { createStoreEmitters } from './store/utils/store-emitters.utils.js';
175
176
  export { RootXStoreModule } from './store/x.module.js';
177
+ export { ACCESSIBILITY_KEY } from './types/accessibility.js';
176
178
  export { AnimationProp } from './types/animation-prop.js';
179
+ export { DEFAULT_ARIA_LABELS } from './utils/accessibility.js';
177
180
  export { arrayToObject, createEmitterArrayFilter, deepFilter, deepFlat, groupItemsBy, isArrayEmpty } from './utils/array.js';
178
181
  export { CancelSymbol, cancellablePromise } from './utils/cancellable-promise.js';
179
182
  export { clone } from './utils/clone.js';
180
183
  export { debounce as debounceFunction } from './utils/debounce.js';
184
+ export { deepMergeWithDefaults } from './utils/deep-merge-with-defaults.js';
181
185
  export { areFiltersDifferent, createRawFilters } from './utils/filters.js';
182
186
  export { FOCUSABLE_SELECTORS } from './utils/focus.js';
183
187
  export { noOp } from './utils/function.js';
package/js/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,4 @@
1
+ const ACCESSIBILITY_KEY = Symbol('accessibility');
2
+
3
+ export { ACCESSIBILITY_KEY };
4
+ //# sourceMappingURL=accessibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibility.js","sources":["../../../src/types/accessibility.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\n\n/**\n * Configuration of the global aria labels for the components. Namespaces are the PascalCase\n * component names and every entry is optional, so the map can be set partially. The entries\n * `PageSelector.numberPage` and `BaseColumnPickerList.ariaLabel` are template strings: their\n * `page` and `column` tokens are substituted per item at resolution.\n *\n * @public\n */\nexport interface AriaLabels {\n pageSelector?: {\n pagination?: string\n prevPage?: string\n nextPage?: string\n numberPage?: (page: number | string) => string\n }\n aiCarousel?: { expand?: string; collapse?: string }\n baseColumnPickerDropdown?: { dropdown?: string }\n baseColumnPickerList?: { button?: (page: number) => string }\n pageLoaderButton?: { button?: string }\n baseModal?: { modal?: string }\n baseEventsModalOpen?: { button?: string }\n baseEventsModalClose?: { button?: string }\n sortDropdown?: { dropdown?: string }\n facets?: { root?: string }\n filtersSearch?: { input?: string }\n sliderFilter?: { min?: string; max?: string }\n editableNumberRangeFilter?: { min?: string; max?: string }\n searchInput?: { input?: string }\n clearHistoryQueries?: { button?: string }\n historyQueriesSwitch?: { root?: string }\n historyQuery?: { removeButton?: string }\n removeHistoryQuery?: { button?: string }\n scrollToTop?: { button?: string }\n baseDropdown?: { toggleButton?: string }\n}\n\nexport const ACCESSIBILITY_KEY: InjectionKey<AriaLabels> = Symbol('accessibility')\n"],"names":[],"mappings":"MAsCa,iBAAiB,GAA6B,MAAM,CAAC,eAAe;;;;"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Single source of truth for default labels (moved verbatim from the SFC `DEFAULTS`
3
+ * constants). Every namespace has an explicit entry (even when empty) so the merge
4
+ * iterates all keys uniformly and a consumer override is never dropped.
5
+ *
6
+ * @internal
7
+ */
8
+ const DEFAULT_ARIA_LABELS = {
9
+ pageSelector: {
10
+ pagination: 'Pagination',
11
+ prevPage: 'Previous page',
12
+ nextPage: 'Next page',
13
+ numberPage: (page) => `Page ${page}`,
14
+ },
15
+ aiCarousel: { expand: 'Expand', collapse: 'Collapse' },
16
+ baseColumnPickerDropdown: { dropdown: 'Select number of columns' },
17
+ baseColumnPickerList: { button: (column) => `${column} columns` },
18
+ pageLoaderButton: { button: 'Load' },
19
+ baseModal: { modal: 'Base modal content' },
20
+ baseEventsModalOpen: { button: 'Open' },
21
+ baseEventsModalClose: { button: 'Close' },
22
+ sortDropdown: { dropdown: 'Select sorting' },
23
+ facets: { root: 'Facets' },
24
+ filtersSearch: { input: 'search into the filter values' },
25
+ sliderFilter: { min: 'minimum amount', max: 'maximum amount' },
26
+ editableNumberRangeFilter: { min: 'minimum amount', max: 'maximum amount' },
27
+ searchInput: { input: 'type your query here' },
28
+ clearHistoryQueries: { button: 'Clear all' },
29
+ historyQueriesSwitch: { root: "Queries' history" },
30
+ historyQuery: { removeButton: 'Remove' },
31
+ removeHistoryQuery: { button: 'remove' },
32
+ scrollToTop: { button: 'Scroll to top' },
33
+ baseDropdown: { toggleButton: '' },
34
+ };
35
+
36
+ export { DEFAULT_ARIA_LABELS };
37
+ //# sourceMappingURL=accessibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibility.js","sources":["../../../src/utils/accessibility.ts"],"sourcesContent":["import type { AriaLabels } from '../types/accessibility'\n\n/**\n * Single source of truth for default labels (moved verbatim from the SFC `DEFAULTS`\n * constants). Every namespace has an explicit entry (even when empty) so the merge\n * iterates all keys uniformly and a consumer override is never dropped.\n *\n * @internal\n */\nexport const DEFAULT_ARIA_LABELS: AriaLabels = {\n pageSelector: {\n pagination: 'Pagination',\n prevPage: 'Previous page',\n nextPage: 'Next page',\n numberPage: (page: number | string) => `Page ${page}`,\n },\n aiCarousel: { expand: 'Expand', collapse: 'Collapse' },\n baseColumnPickerDropdown: { dropdown: 'Select number of columns' },\n baseColumnPickerList: { button: (column: number) => `${column} columns` },\n pageLoaderButton: { button: 'Load' },\n baseModal: { modal: 'Base modal content' },\n baseEventsModalOpen: { button: 'Open' },\n baseEventsModalClose: { button: 'Close' },\n sortDropdown: { dropdown: 'Select sorting' },\n facets: { root: 'Facets' },\n filtersSearch: { input: 'search into the filter values' },\n sliderFilter: { min: 'minimum amount', max: 'maximum amount' },\n editableNumberRangeFilter: { min: 'minimum amount', max: 'maximum amount' },\n searchInput: { input: 'type your query here' },\n clearHistoryQueries: { button: 'Clear all' },\n historyQueriesSwitch: { root: \"Queries' history\" },\n historyQuery: { removeButton: 'Remove' },\n removeHistoryQuery: { button: 'remove' },\n scrollToTop: { button: 'Scroll to top' },\n baseDropdown: { toggleButton: '' },\n}\n"],"names":[],"mappings":"AAEA;;;;;;AAMG;AACI,MAAM,mBAAmB,GAAe;AAC7C,IAAA,YAAY,EAAE;AACZ,QAAA,UAAU,EAAE,YAAY;AACxB,QAAA,QAAQ,EAAE,eAAe;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MAAM,EAAE,eAAe,EAAE;AACxC,IAAA,YAAY,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;;;;;"}
@@ -0,0 +1,47 @@
1
+ import { isObject } from '@empathyco/x-utils';
2
+
3
+ /**
4
+ * Deeply merges `overrides` onto `defaults` at any depth, so nested objects can be overridden
5
+ * partially without losing the rest of the default configuration:
6
+ *
7
+ * - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults`
8
+ * are ignored.
9
+ * - An `undefined` entry in `overrides` keeps the default value.
10
+ * - When both the default and the override are plain objects, they are merged recursively.
11
+ * - Any other value (string, function, array, `null`...) in `overrides` replaces the default.
12
+ *
13
+ * Neither input is mutated.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const defaults = { a: { b: { c: 1, d: 2 }, e: 'keep' }, f: () => 'x' }
18
+ * deepMergeWithDefaults(defaults, { a: { b: { c: 10 } } })
19
+ * // → { a: { b: { c: 10, d: 2 }, e: 'keep' }, f: () => 'x' }
20
+ * ```
21
+ *
22
+ * @param defaults - The base object. It provides the result shape and the fallback values.
23
+ * @param overrides - The values that win over the defaults at each leaf.
24
+ * @returns A new object with the same shape as `defaults`.
25
+ *
26
+ * @public
27
+ */
28
+ function deepMergeWithDefaults(defaults, overrides) {
29
+ const result = {};
30
+ const overrideEntries = overrides;
31
+ for (const [key, defaultValue] of Object.entries(defaults)) {
32
+ const overrideValue = overrideEntries?.[key];
33
+ if (overrideValue === undefined) {
34
+ result[key] = defaultValue;
35
+ }
36
+ else if (isObject(defaultValue) && isObject(overrideValue)) {
37
+ result[key] = deepMergeWithDefaults(defaultValue, overrideValue);
38
+ }
39
+ else {
40
+ result[key] = overrideValue;
41
+ }
42
+ }
43
+ return result;
44
+ }
45
+
46
+ export { deepMergeWithDefaults };
47
+ //# sourceMappingURL=deep-merge-with-defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-merge-with-defaults.js","sources":["../../../src/utils/deep-merge-with-defaults.ts"],"sourcesContent":["import type { DeepPartial } from '@empathyco/x-utils'\nimport { isObject } from '@empathyco/x-utils'\n\n/**\n * Deeply merges `overrides` onto `defaults` at any depth, so nested objects can be overridden\n * partially without losing the rest of the default configuration:\n *\n * - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults`\n * are ignored.\n * - An `undefined` entry in `overrides` keeps the default value.\n * - When both the default and the override are plain objects, they are merged recursively.\n * - Any other value (string, function, array, `null`...) in `overrides` replaces the default.\n *\n * Neither input is mutated.\n *\n * @example\n * ```ts\n * const defaults = { a: { b: { c: 1, d: 2 }, e: 'keep' }, f: () => 'x' }\n * deepMergeWithDefaults(defaults, { a: { b: { c: 10 } } })\n * // → { a: { b: { c: 10, d: 2 }, e: 'keep' }, f: () => 'x' }\n * ```\n *\n * @param defaults - The base object. It provides the result shape and the fallback values.\n * @param overrides - The values that win over the defaults at each leaf.\n * @returns A new object with the same shape as `defaults`.\n *\n * @public\n */\nexport function deepMergeWithDefaults<T extends object>(\n defaults: T,\n overrides?: DeepPartial<T>,\n): T {\n const result: Record<string, unknown> = {}\n const overrideEntries = overrides as Record<string, unknown> | undefined\n for (const [key, defaultValue] of Object.entries(defaults)) {\n const overrideValue = overrideEntries?.[key]\n if (overrideValue === undefined) {\n result[key] = defaultValue\n } else if (isObject(defaultValue) && isObject(overrideValue)) {\n result[key] = deepMergeWithDefaults(defaultValue, overrideValue)\n } else {\n result[key] = overrideValue\n }\n }\n return result as T\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACG,SAAU,qBAAqB,CACnC,QAAW,EACX,SAA0B,EAAA;IAE1B,MAAM,MAAM,GAA4B,EAAE;IAC1C,MAAM,eAAe,GAAG,SAAgD;AACxE,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC1D,QAAA,MAAM,aAAa,GAAG,eAAe,GAAG,GAAG,CAAC;AAC5C,QAAA,IAAI,aAAa,KAAK,SAAS,EAAE;AAC/B,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY;QAC5B;aAAO,IAAI,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,aAAa,CAAC,EAAE;YAC5D,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC;QAClE;aAAO;AACL,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa;QAC7B;IACF;AACA,IAAA,OAAO,MAAW;AACpB;;;;"}
@@ -71,7 +71,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
71
71
  key: 0,
72
72
  class: "x-ai-carousel-title-button",
73
73
  "data-test": "ai-carousel-title-button",
74
- "aria-label": _ctx.titleExpanded ? "Collapse" : "Expand"
74
+ "aria-label": _ctx.titleExpanded ? _ctx.ariaLabels?.collapse : _ctx.ariaLabels?.expand
75
75
  }, [
76
76
  createVNode(_component_ChevronDownIcon, {
77
77
  class: normalizeClass(["x-ai-carousel-title-button-icon", { "x-ai-carousel-title-button-icon--expanded": _ctx.titleExpanded }])
@@ -1 +1 @@
1
- {"version":3,"file":"ai-carousel.vue.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? 'Collapse' : 'Expand'\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n\n <AiGroupedCarousel\n v-if=\"group\"\n :sliding-panel-classes=\"slidingPanelClasses\"\n :sliding-panel-container-classes=\"slidingPanelContainerClasses\"\n :sliding-panel-buttons-classes=\"slidingPanelButtonsClasses\"\n >\n <template #sliding-panels-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panels-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panels-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <template #result=\"{ result }\">\n <slot name=\"result\" :result=\"result\" />\n </template>\n </AiGroupedCarousel>\n\n <div v-else class=\"x-ai-carousel-suggestions\" data-test=\"ai-carousel-suggestions-container\">\n <DisplayEmitter\n v-for=\"{ query: suggestionQuery, results: queriesResults } in suggestionsSearch\"\n :key=\"suggestionQuery\"\n :payload=\"tagging?.searchQueries[suggestionQuery].toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-query-display-emitter\"\n >\n <div class=\"x-ai-carousel-suggestion\" data-test=\"ai-carousel-suggestion\">\n <BaseEventButton\n class=\"x-ai-carousel-suggestion-query-btn\"\n :events=\"{ UserAcceptedAQuery: suggestionQuery }\"\n >\n {{ suggestionQuery }}\n <ArrowRightIcon class=\"x-ai-carousel-suggestion-query-btn-icon\" />\n </BaseEventButton>\n\n <DisplayClickProvider\n :tooling-display-tagging=\"tagging?.searchQueries[suggestionQuery].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestionQuery].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <slot name=\"sliding-panel\" :results=\"queriesResults\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <ul class=\"x-ai-carousel-suggestion-results\">\n <li\n v-for=\"result in queriesResults\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </ul>\n </SlidingPanel>\n </slot>\n </DisplayClickProvider>\n </div>\n </DisplayEmitter>\n <slot name=\"suggestions-extra-content\" />\n </div>\n\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, onMounted, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n} from '../../../components'\nimport { use$x, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\nimport AiGroupedCarousel from './ai-grouped-carousel.vue'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n AIStarIcon,\n AiGroupedCarousel,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: String,\n /* The classes added to the sliding panel. */\n slidingPanelClasses: String,\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: String,\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: String,\n /* Controls whether the carousel should group results or display N carousels per N queries. */\n group: {\n type: Boolean,\n default: true,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n onMounted(() => {\n $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' })\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n emptyTaggingRequest,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n\n.x-ai-carousel-suggestions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n padding-bottom: 1rem;\n}\n\n.x-ai-carousel-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.x-ai-carousel-suggestion-query-btn {\n border-color: transparent;\n background-color: transparent;\n margin-left: 1rem;\n margin-right: 1rem;\n font-weight: 700;\n width: fit-content;\n display: flex;\n align-items: center;\n gap: 1rem;\n cursor: pointer;\n}\n\n.x-ai-carousel-suggestion-query-btn-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n}\n\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["_createBlock","_withCtx","_openBlock","_createElementBlock","_createVNode","_createElementVNode","_normalizeClass","_renderSlot","_Fragment","_renderList","_createTextVNode","_toDisplayString","_createCommentVNode"],"mappings":";;;;;;;EAEyC,KAAA,EAAM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AA,CAAA,EARHC,kBAAA;AAAA,kCAOKK,QAAA;AAAA,kCAAA,IAAA;AAAA,kCAAAC,UAAA,CANc,cAAA,EAAc,CAAxB,MAAA,KAAM;wDADfN,kBAAA,CAOK,IAAA,EAAA;AAAA,sCALF,KAAK,MAAA,CAAO,EAAA;AAAA,sCACb,WAAA,EAAU;AAAA,qCAAA,EAAA;AAGV,sCAAAI,UAAA,CAAuC,yBAAlB,MAAA,EAAc;AAAA,qCAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;UAQjDA,UAAA,CAAyC,IAAA,CAAA,MAAA,EAAA,2BAAA;AAAA,SAAA,CAAA,CAAA;QAG3CA,UAAA,CAA6B,IAAA,CAAA,MAAA,EAAA,eAAA,CAAA;AAAA,QAC7BA,UAAA,CAA0B,IAAA,CAAA,MAAA,EAAA,YAAA;AAAA,OAAA,CAAA,IAAAK,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"ai-carousel.vue.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? ariaLabels?.collapse : ariaLabels?.expand\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n\n <AiGroupedCarousel\n v-if=\"group\"\n :sliding-panel-classes=\"slidingPanelClasses\"\n :sliding-panel-container-classes=\"slidingPanelContainerClasses\"\n :sliding-panel-buttons-classes=\"slidingPanelButtonsClasses\"\n >\n <template #sliding-panels-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panels-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panels-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <template #result=\"{ result }\">\n <slot name=\"result\" :result=\"result\" />\n </template>\n </AiGroupedCarousel>\n\n <div v-else class=\"x-ai-carousel-suggestions\" data-test=\"ai-carousel-suggestions-container\">\n <DisplayEmitter\n v-for=\"{ query: suggestionQuery, results: queriesResults } in suggestionsSearch\"\n :key=\"suggestionQuery\"\n :payload=\"tagging?.searchQueries[suggestionQuery].toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-query-display-emitter\"\n >\n <div class=\"x-ai-carousel-suggestion\" data-test=\"ai-carousel-suggestion\">\n <BaseEventButton\n class=\"x-ai-carousel-suggestion-query-btn\"\n :events=\"{ UserAcceptedAQuery: suggestionQuery }\"\n >\n {{ suggestionQuery }}\n <ArrowRightIcon class=\"x-ai-carousel-suggestion-query-btn-icon\" />\n </BaseEventButton>\n\n <DisplayClickProvider\n :tooling-display-tagging=\"tagging?.searchQueries[suggestionQuery].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestionQuery].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <slot name=\"sliding-panel\" :results=\"queriesResults\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <ul class=\"x-ai-carousel-suggestion-results\">\n <li\n v-for=\"result in queriesResults\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </ul>\n </SlidingPanel>\n </slot>\n </DisplayClickProvider>\n </div>\n </DisplayEmitter>\n <slot name=\"suggestions-extra-content\" />\n </div>\n\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, onMounted, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n} from '../../../components'\nimport { use$x, useAccessibilityLabels, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\nimport AiGroupedCarousel from './ai-grouped-carousel.vue'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n AIStarIcon,\n AiGroupedCarousel,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: String,\n /* The classes added to the sliding panel. */\n slidingPanelClasses: String,\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: String,\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: String,\n /* Controls whether the carousel should group results or display N carousels per N queries. */\n group: {\n type: Boolean,\n default: true,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const ariaLabels = useAccessibilityLabels('aiCarousel')\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n onMounted(() => {\n $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' })\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n ariaLabels,\n emptyTaggingRequest,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n\n.x-ai-carousel-suggestions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n padding-bottom: 1rem;\n}\n\n.x-ai-carousel-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.x-ai-carousel-suggestion-query-btn {\n border-color: transparent;\n background-color: transparent;\n margin-left: 1rem;\n margin-right: 1rem;\n font-weight: 700;\n width: fit-content;\n display: flex;\n align-items: center;\n gap: 1rem;\n cursor: pointer;\n}\n\n.x-ai-carousel-suggestion-query-btn-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n}\n\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["_createBlock","_withCtx","_openBlock","_createElementBlock","_createVNode","_createElementVNode","_normalizeClass","_renderSlot","_Fragment","_renderList","_createTextVNode","_toDisplayString","_createCommentVNode"],"mappings":";;;;;;;EAEyC,KAAA,EAAM;;;;;EA4D7B,KAAA,EAAM,2BAAA;AAAA,EAA4B,W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AAA,IAAA,CAAA,EARHC,kBAAA;AAAA,kCAOKK,QAAA;AAAA,kCAAA,IAAA;AAAA,kCAAAC,UAAA,CANc,cAAA,EAAc,CAAxB,MAAA,KAAM;wDADfN,kBAAA,CAOK,IAAA,EAAA;AAAA,sCALF,KAAK,MAAA,CAAO,EAAA;AAAA,sCACb,WAAA,EAAU;AAAA,qCAAA,EAAA;AAGV,sCAAAI,UAAA,CAAuC,yBAAlB,MAAA,EAAc;AAAA,qCAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;UAQjDA,UAAA,CAAyC,IAAA,CAAA,MAAA,EAAA,2BAAA;AAAA,SAAA,CAAA,CAAA;QAG3CA,UAAA,CAA6B,IAAA,CAAA,MAAA,EAAA,eAAA,CAAA;AAAA,QAC7BA,UAAA,CAA0B,IAAA,CAAA,MAAA,EAAA,YAAA;AAAA,OAAA,CAAA,IAAAK,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;"}
@@ -95,6 +95,7 @@ import '../../../components/suggestions/base-suggestion.vue2.js';
95
95
  import '../../../components/suggestions/base-suggestions.vue2.js';
96
96
  import '../../../components/suggestions/base-suggestions.vue3.js';
97
97
  import '../../../composables/create-use-device.js';
98
+ import { useAccessibilityLabels } from '../../../composables/use-accessibility-labels.js';
98
99
  import 'vuex';
99
100
  import '../../../plugins/x-bus.js';
100
101
  import '../../../plugins/x-plugin.js';
@@ -136,6 +137,7 @@ var _sfc_main = defineComponent({
136
137
  const $x = use$x();
137
138
  const { query, suggestionsSearch, queries, tagging } = useState('ai');
138
139
  const emptyTaggingRequest = { url: '', params: {} };
140
+ const ariaLabels = useAccessibilityLabels('aiCarousel');
139
141
  const titleRef = ref(null);
140
142
  const titleExpanded = ref(false);
141
143
  const isTitleOverflowing = ref(false);
@@ -178,6 +180,7 @@ var _sfc_main = defineComponent({
178
180
  });
179
181
  useResizeObserver(titleRef, updateTitleOverflow);
180
182
  return {
183
+ ariaLabels,
181
184
  emptyTaggingRequest,
182
185
  isTitleOverflowing,
183
186
  queries,
@@ -1 +1 @@
1
- {"version":3,"file":"ai-carousel.vue2.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? 'Collapse' : 'Expand'\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n\n <AiGroupedCarousel\n v-if=\"group\"\n :sliding-panel-classes=\"slidingPanelClasses\"\n :sliding-panel-container-classes=\"slidingPanelContainerClasses\"\n :sliding-panel-buttons-classes=\"slidingPanelButtonsClasses\"\n >\n <template #sliding-panels-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panels-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panels-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <template #result=\"{ result }\">\n <slot name=\"result\" :result=\"result\" />\n </template>\n </AiGroupedCarousel>\n\n <div v-else class=\"x-ai-carousel-suggestions\" data-test=\"ai-carousel-suggestions-container\">\n <DisplayEmitter\n v-for=\"{ query: suggestionQuery, results: queriesResults } in suggestionsSearch\"\n :key=\"suggestionQuery\"\n :payload=\"tagging?.searchQueries[suggestionQuery].toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-query-display-emitter\"\n >\n <div class=\"x-ai-carousel-suggestion\" data-test=\"ai-carousel-suggestion\">\n <BaseEventButton\n class=\"x-ai-carousel-suggestion-query-btn\"\n :events=\"{ UserAcceptedAQuery: suggestionQuery }\"\n >\n {{ suggestionQuery }}\n <ArrowRightIcon class=\"x-ai-carousel-suggestion-query-btn-icon\" />\n </BaseEventButton>\n\n <DisplayClickProvider\n :tooling-display-tagging=\"tagging?.searchQueries[suggestionQuery].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestionQuery].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <slot name=\"sliding-panel\" :results=\"queriesResults\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <ul class=\"x-ai-carousel-suggestion-results\">\n <li\n v-for=\"result in queriesResults\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </ul>\n </SlidingPanel>\n </slot>\n </DisplayClickProvider>\n </div>\n </DisplayEmitter>\n <slot name=\"suggestions-extra-content\" />\n </div>\n\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, onMounted, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n} from '../../../components'\nimport { use$x, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\nimport AiGroupedCarousel from './ai-grouped-carousel.vue'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n AIStarIcon,\n AiGroupedCarousel,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: String,\n /* The classes added to the sliding panel. */\n slidingPanelClasses: String,\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: String,\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: String,\n /* Controls whether the carousel should group results or display N carousels per N queries. */\n group: {\n type: Boolean,\n default: true,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n onMounted(() => {\n $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' })\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n emptyTaggingRequest,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n\n.x-ai-carousel-suggestions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n padding-bottom: 1rem;\n}\n\n.x-ai-carousel-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.x-ai-carousel-suggestion-query-btn {\n border-color: transparent;\n background-color: transparent;\n margin-left: 1rem;\n margin-right: 1rem;\n font-weight: 700;\n width: fit-content;\n display: flex;\n align-items: center;\n gap: 1rem;\n cursor: pointer;\n}\n\n.x-ai-carousel-suggestion-query-btn-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n}\n\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["DisplayClickProvider","DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,gBAAe,eAAe,CAAC;IAC7B,OAAO,EAAE,SAAS,CAAC,IAAI;AACvB,IAAA,UAAU,EAAE;QACV,UAAU;QACV,iBAAiB;QACjB,cAAc;QACd,eAAe;QACf,YAAY;QACZ,eAAe;QACf,cAAc;8BACdA,WAAoB;wBACpBC,WAAc;QACd,YAAY;AACb,KAAA;AACD,IAAA,KAAK,EAAE;;AAEL,QAAA,KAAK,EAAE,MAAM;;AAEb,QAAA,mBAAmB,EAAE,MAAM;;AAE3B,QAAA,4BAA4B,EAAE,MAAM;;AAEpC,QAAA,0BAA0B,EAAE,MAAM;;AAElC,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AACjB,QAAA,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAM,EAAE,GAAI,QAAQ,CAAC,IAAI,C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BAAA,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAA;YAC7C;AACF,QAAA,CAAC,CAAA;QAED,SAAS,CAAC,MAAI;AACZ,YAAA,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,aAAY,EAAG,CAAA;AACrE,QAAA,CAAC,CAAA;AAED,QAAA,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,CAAA;QAE/C,OAAO;YACL,mBAAmB;YACnB,kBAAkB;YAClB,OAAO;YACP,KAAK;YACL,iBAAiB;YACjB,OAAO;YACP,KAAK;YACL,aAAa;YACb,QAAQ;YACR,oBAAoB;SACtB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"ai-carousel.vue2.js","sources":["../../../../../src/x-modules/ai/components/ai-carousel.vue"],"sourcesContent":["<template>\n <CollapseHeight>\n <div v-if=\"suggestionsSearch.length\" class=\"x-ai-carousel\">\n <DisplayEmitter\n :payload=\"tagging?.toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-display-emitter\"\n >\n <span\n class=\"x-ai-carousel-title\"\n :class=\"{ 'x-ai-carousel-title--expanded': titleExpanded }\"\n data-test=\"ai-carousel-title\"\n @click=\"toggleTitleExpansion\"\n >\n <AIStarIcon class=\"x-ai-carousel-title-icon\" />\n <ChangeHeight>\n <span\n ref=\"titleRef\"\n class=\"x-ai-carousel-title-text\"\n :class=\"{ 'x-ai-carousel-title-text--expanded': titleExpanded }\"\n >\n {{ title }}\n </span>\n </ChangeHeight>\n <button\n v-if=\"isTitleOverflowing\"\n class=\"x-ai-carousel-title-button\"\n data-test=\"ai-carousel-title-button\"\n :aria-label=\"titleExpanded ? ariaLabels?.collapse : ariaLabels?.expand\"\n >\n <ChevronDownIcon\n class=\"x-ai-carousel-title-button-icon\"\n :class=\"{ 'x-ai-carousel-title-button-icon--expanded': titleExpanded }\"\n />\n </button>\n </span>\n </DisplayEmitter>\n\n <AiGroupedCarousel\n v-if=\"group\"\n :sliding-panel-classes=\"slidingPanelClasses\"\n :sliding-panel-container-classes=\"slidingPanelContainerClasses\"\n :sliding-panel-buttons-classes=\"slidingPanelButtonsClasses\"\n >\n <template #sliding-panels-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panels-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panels-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <template #result=\"{ result }\">\n <slot name=\"result\" :result=\"result\" />\n </template>\n </AiGroupedCarousel>\n\n <div v-else class=\"x-ai-carousel-suggestions\" data-test=\"ai-carousel-suggestions-container\">\n <DisplayEmitter\n v-for=\"{ query: suggestionQuery, results: queriesResults } in suggestionsSearch\"\n :key=\"suggestionQuery\"\n :payload=\"tagging?.searchQueries[suggestionQuery].toolingDisplay ?? emptyTaggingRequest\"\n :event-metadata=\"{\n feature: 'ai_carousel',\n displayOriginalQuery: query || 'ai-carousel-without-query',\n replaceable: false,\n }\"\n data-test=\"ai-carousel-query-display-emitter\"\n >\n <div class=\"x-ai-carousel-suggestion\" data-test=\"ai-carousel-suggestion\">\n <BaseEventButton\n class=\"x-ai-carousel-suggestion-query-btn\"\n :events=\"{ UserAcceptedAQuery: suggestionQuery }\"\n >\n {{ suggestionQuery }}\n <ArrowRightIcon class=\"x-ai-carousel-suggestion-query-btn-icon\" />\n </BaseEventButton>\n\n <DisplayClickProvider\n :tooling-display-tagging=\"tagging?.searchQueries[suggestionQuery].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"\n tagging?.searchQueries[suggestionQuery].toolingDisplayAdd2Cart\n \"\n result-feature=\"ai_carousel\"\n >\n <slot name=\"sliding-panel\" :results=\"queriesResults\">\n <SlidingPanel\n :class=\"slidingPanelClasses\"\n :scroll-container-class=\"slidingPanelContainerClasses\"\n :button-class=\"slidingPanelButtonsClasses\"\n :reset-on-content-change=\"false\"\n >\n <template #sliding-panel-addons=\"{ arrivedState }\">\n <slot name=\"sliding-panels-addons\" :arrived-state=\"arrivedState\" />\n </template>\n <template #sliding-panel-left-button>\n <slot name=\"sliding-panels-left-button\" />\n </template>\n <template #sliding-panel-right-button>\n <slot name=\"sliding-panels-right-button\" />\n </template>\n <ul class=\"x-ai-carousel-suggestion-results\">\n <li\n v-for=\"result in queriesResults\"\n :key=\"result.id\"\n data-test=\"ai-carousel-suggestion-result\"\n >\n <!-- @slot (required) result card -->\n <slot name=\"result\" :result=\"result\" />\n </li>\n </ul>\n </SlidingPanel>\n </slot>\n </DisplayClickProvider>\n </div>\n </DisplayEmitter>\n <slot name=\"suggestions-extra-content\" />\n </div>\n\n <slot name=\"extra-content\" />\n <slot name=\"cta-button\" />\n </div>\n </CollapseHeight>\n</template>\n\n<script lang=\"ts\">\nimport type { TaggingRequest } from '@empathyco/x-types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, onMounted, ref, watch } from 'vue'\nimport {\n AIStarIcon,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n} from '../../../components'\nimport { use$x, useAccessibilityLabels, useState } from '../../../composables'\nimport { aiXModule } from '../x-module'\nimport AiGroupedCarousel from './ai-grouped-carousel.vue'\n\nexport default defineComponent({\n xModule: aiXModule.name,\n components: {\n AIStarIcon,\n AiGroupedCarousel,\n ArrowRightIcon,\n BaseEventButton,\n ChangeHeight,\n ChevronDownIcon,\n CollapseHeight,\n DisplayClickProvider,\n DisplayEmitter,\n SlidingPanel,\n },\n props: {\n /* The title text displayed */\n title: String,\n /* The classes added to the sliding panel. */\n slidingPanelClasses: String,\n /* The classes added to the sliding panel container. */\n slidingPanelContainerClasses: String,\n /* The classes added to the sliding panel buttons. */\n slidingPanelButtonsClasses: String,\n /* Controls whether the carousel should group results or display N carousels per N queries. */\n group: {\n type: Boolean,\n default: true,\n },\n },\n setup(props) {\n const $x = use$x()\n const { query, suggestionsSearch, queries, tagging } = useState('ai')\n const emptyTaggingRequest: TaggingRequest = { url: '', params: {} }\n\n const ariaLabels = useAccessibilityLabels('aiCarousel')\n\n const titleRef = ref<HTMLElement | null>(null)\n const titleExpanded = ref(false)\n const isTitleOverflowing = ref(false)\n\n /**\n * Checks if the title is overflowing and updates the state.\n */\n function updateTitleOverflow() {\n if (titleExpanded.value) {\n return\n }\n if (titleRef.value) {\n isTitleOverflowing.value = titleRef.value.scrollWidth > titleRef.value.clientWidth\n }\n }\n\n /**\n * Toggles the title expanded state if it is overflowing.\n */\n function toggleTitleExpansion() {\n if (isTitleOverflowing.value) {\n titleExpanded.value = !titleExpanded.value\n }\n }\n\n const title = computed(() => {\n if (!props.title) {\n const queriesList = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n }).format(queries.value.map(({ query }) => query))\n return `Searching for ${queriesList}`\n }\n return props.title\n })\n\n watch(queries, () => {\n if (queries.value.length > 0) {\n $x.emit('AiSuggestionsSearchRequestUpdated')\n }\n })\n\n onMounted(() => {\n $x.emit('AiComponentMounted', undefined, { feature: 'ai_carousel' })\n })\n\n useResizeObserver(titleRef, updateTitleOverflow)\n\n return {\n ariaLabels,\n emptyTaggingRequest,\n isTitleOverflowing,\n queries,\n query,\n suggestionsSearch,\n tagging,\n title,\n titleExpanded,\n titleRef,\n toggleTitleExpansion,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-ai-carousel {\n --color: var(--x-ai-carousel-color, #bbc9cf);\n --color-lighter: var(--x-ai-carousel-color-lighter, color-mix(in srgb, var(--color) 25%, white));\n\n padding: 8px 0;\n position: relative;\n border-radius: 1.5rem;\n background-color: var(--color-lighter);\n}\n\n.x-ai-carousel-title {\n display: flex;\n font-size: 12px;\n gap: 8px;\n align-items: flex-start;\n margin: 0 14px 8px;\n cursor: pointer;\n}\n.x-ai-carousel-title-text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.x-ai-carousel-title-text--expanded {\n white-space: normal;\n}\n.x-ai-carousel-title-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n color: var(--color);\n flex-shrink: 0;\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button {\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--color);\n margin-bottom: auto;\n}\n.x-ai-carousel-title-button-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n transition: transform 0.3s ease;\n}\n.x-ai-carousel-title-button-icon--expanded {\n transform: rotate(180deg);\n}\n\n.x-ai-carousel-suggestions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n padding-bottom: 1rem;\n}\n\n.x-ai-carousel-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.x-ai-carousel-suggestion-query-btn {\n border-color: transparent;\n background-color: transparent;\n margin-left: 1rem;\n margin-right: 1rem;\n font-weight: 700;\n width: fit-content;\n display: flex;\n align-items: center;\n gap: 1rem;\n cursor: pointer;\n}\n\n.x-ai-carousel-suggestion-query-btn-icon {\n height: 1rem;\n aspect-ratio: 1 / 1;\n}\n\n.x-ai-carousel-suggestion-results {\n display: flex;\n gap: 1rem;\n padding-left: 1rem;\n padding-right: 1rem;\n}\n</style>\n"],"names":["DisplayClickProvider","DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,gBAAe,eAAe,CAAC;IAC7B,OAAO,EAAE,SAAS,CAAC,IAAI;AACvB,IAAA,UAAU,EAAE;QACV,UAAU;QACV,iBAAiB;QACjB,cAAc;QACd,eAAe;QACf,YAAY;QACZ,eAAe;QACf,cAAc;8BAC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KAAI,GAAI,QAAQ,CAAC,MAAI;AACzB,YAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;gBAChB,MAAM,WAAU,GAAI,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;AAC5C,oBAAA,KAAK,EAAE,MAAM;AACb,oBAAA,IAAI,EAAE,aAAa;AACpB,iBAAA,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,KAAK,KAAK,CAAC,CAAA;gBACjD,OAAO,CAAA,cAAA,EAAiB,WAAW,CAAA,CAAC;YACtC;YACA,OAAO,KAAK,CAAC,KAAI;AACnB,QAAA,CAAC,CAAA;AAED,QAAA,KAAK,CAAC,OAAO,EAAE,MAAI;YACjB,IAAI,OAAO,CAAC,KAAK,CAAC,MAAK,GAAI,CAAC,EAAE;AAC5B,gBAAA,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAA;YAC7C;AACF,QAAA,CAAC,CAAA;QAED,SAAS,CAAC,MAAI;AACZ,YAAA,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,aAAY,EAAG,CAAA;AACrE,QAAA,CAAC,CAAA;AAED,QAAA,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,CAAA;QAE/C,OAAO;YACL,UAAU;YACV,mBAAmB;YACnB,kBAAkB;YAClB,OAAO;YACP,KAAK;YACL,iBAAiB;YACjB,OAAO;YACP,KAAK;YACL,aAAa;YACb,QAAQ;YACR,oBAAoB;SACtB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -96,6 +96,7 @@ import '../../../components/suggestions/base-suggestion.vue2.js';
96
96
  import '../../../components/suggestions/base-suggestions.vue2.js';
97
97
  import '../../../components/suggestions/base-suggestions.vue3.js';
98
98
  import '../../../composables/create-use-device.js';
99
+ import '../../../utils/storage.js';
99
100
  import '@vueuse/core';
100
101
  import { useState } from '../../../composables/use-state.js';
101
102