@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
@@ -1 +1 @@
1
- {"version":3,"file":"ai-grouped-carousel.vue2.js","sources":["../../../../../src/x-modules/ai/components/ai-grouped-carousel.vue"],"sourcesContent":["<template>\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 <DisplayClickProvider\n v-for=\"suggestion in suggestionsSearch\"\n :key=\"suggestion.query\"\n :tooling-display-tagging=\"tagging?.searchQueries[suggestion.query].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"tagging?.searchQueries[suggestion.query].toolingDisplayAdd2Cart\"\n result-feature=\"ai_carousel\"\n >\n <li\n v-for=\"result in suggestion.results\"\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 </DisplayClickProvider>\n </ul>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport { DisplayClickProvider, SlidingPanel } from '../../../components'\nimport { useState } from '../../../composables'\n\nexport default defineComponent({\n components: {\n DisplayClickProvider,\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 },\n setup() {\n const { suggestionsSearch, tagging } = useState('ai')\n\n return {\n suggestionsSearch,\n tagging,\n }\n },\n})\n</script>\n"],"names":["DisplayClickProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;8BACVA,WAAoB;QACpB,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;AACnC,KAAA;IACD,KAAK,GAAA;QACH,MAAM,EAAE,iBAAiB,EAAE,OAAM,EAAE,GAAI,QAAQ,CAAC,IAAI,CAAA;QAEpD,OAAO;YACL,iBAAiB;YACjB,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"ai-grouped-carousel.vue2.js","sources":["../../../../../src/x-modules/ai/components/ai-grouped-carousel.vue"],"sourcesContent":["<template>\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 <DisplayClickProvider\n v-for=\"suggestion in suggestionsSearch\"\n :key=\"suggestion.query\"\n :tooling-display-tagging=\"tagging?.searchQueries[suggestion.query].toolingDisplayClick\"\n :tooling-add2-cart-tagging=\"tagging?.searchQueries[suggestion.query].toolingDisplayAdd2Cart\"\n result-feature=\"ai_carousel\"\n >\n <li\n v-for=\"result in suggestion.results\"\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 </DisplayClickProvider>\n </ul>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport { DisplayClickProvider, SlidingPanel } from '../../../components'\nimport { useState } from '../../../composables'\n\nexport default defineComponent({\n components: {\n DisplayClickProvider,\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 },\n setup() {\n const { suggestionsSearch, tagging } = useState('ai')\n\n return {\n suggestionsSearch,\n tagging,\n }\n },\n})\n</script>\n"],"names":["DisplayClickProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;8BACVA,WAAoB;QACpB,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;AACnC,KAAA;IACD,KAAK,GAAA;QACH,MAAM,EAAE,iBAAiB,EAAE,OAAM,EAAE,GAAI,QAAQ,CAAC,IAAI,CAAA;QAEpD,OAAO;YACL,iBAAiB;YACjB,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -95,14 +95,14 @@ 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 { getActiveElement } from '../../../utils/html.js';
99
+ import '../../../utils/storage.js';
98
100
  import 'vuex';
99
101
  import '../../../plugins/x-bus.js';
100
102
  import '../../../plugins/x-plugin.js';
101
103
  import { useDebounce } from '../../../composables/use-debounce.js';
102
104
  import '@vueuse/core';
103
105
  import 'rxjs';
104
- import { getActiveElement } from '../../../utils/html.js';
105
- import '../../../utils/storage.js';
106
106
  import { empathizeXModule } from '../x-module.js';
107
107
 
108
108
  /**
@@ -2,6 +2,7 @@ import { isHierarchicalFacet } from '@empathyco/x-types';
2
2
  import { defineComponent, ref, computed, watch } from 'vue';
3
3
  import { use$x } from '../../../../composables/use-_x.js';
4
4
  import { clone } from '../../../../utils/clone.js';
5
+ import '@empathyco/x-utils';
5
6
  import { areFiltersDifferent } from '../../../../utils/filters.js';
6
7
  import '../../../../utils/storage.js';
7
8
  import { flatHierarchicalFilters } from '../../utils.js';
@@ -1 +1 @@
1
- {"version":3,"file":"facets-provider.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Facet, Filter } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { GroupId } from '../../store/types'\nimport { isHierarchicalFacet } from '@empathyco/x-types'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../../../composables/use-$x'\nimport { clone } from '../../../../utils'\nimport { areFiltersDifferent } from '../../../../utils/filters'\nimport { flatHierarchicalFilters } from '../../utils'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\nexport default defineComponent({\n name: 'FacetsProvider',\n xModule: facetsXModule.name,\n props: {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n groupId: {\n type: String as PropType<GroupId>,\n default: 'provided-facets',\n },\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter}.\n *\n * @internal\n */\n facets: {\n type: Array as PropType<Facet[]>,\n required: true,\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n const selectedFilters: Ref<Filter[] | null> = ref(null)\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n const facetsGroup = computed(() => ({ id: props.groupId, facets: props.facets }))\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n $x.on('SelectedFiltersChanged', false).subscribe((selectedFiltersParams: Filter[]) => {\n if (\n selectedFilters.value === null ||\n areFiltersDifferent(selectedFilters.value, selectedFiltersParams)\n ) {\n $x.emit('UserChangedSelectedFilters', selectedFiltersParams)\n }\n selectedFilters.value = null\n })\n\n /**\n * Extracts the selected filters from the facets and stores them in the\n * {@link FacetsProvider.selectedFilters} property.\n *\n * @param facets - The facets from whom extract the selected filters.\n * @internal\n */\n const extractSelectedFilters = (facets: Facet[]) => {\n selectedFilters.value = facets\n .flatMap(facet =>\n isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters,\n )\n .filter(filter => filter.selected)\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n watch(\n () => facetsGroup.value,\n () => {\n if (facetsGroup.value.facets) {\n const facetsGroupClone = clone(facetsGroup.value)\n $x.emit('FacetsGroupProvided', facetsGroupClone)\n extractSelectedFilters(props.facets)\n }\n },\n { immediate: true },\n )\n\n return () => ''\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserChangedSelectedFilters`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user performed an action that changed the selected filters. The\n payload is the new list of selected filters.\n- [`FacetsGroupProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after updating the facets prop with a new list of facets. The payload\n contains a Facets Group with the facets and the group id.\n\n## Example\n\nThis component allows to provide facets by prop, to add them to the state of the `Facets X-Module`.\nThese facets will be added to the `Facets X-Module` state together with the facets emitted by the\n`Search X-Module` through the `SearchXEvents.FacetsChanged` event.\n\n```vue\n<template>\n <FacetsProvider :facets=\"myFacets\" />\n</template>\n\n<script setup>\nimport { FacetsProvider } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst myFacets = ref([\n {\n modelName: 'SimpleFacet',\n id: 'color-facet',\n label: 'Color',\n filters: [\n {\n modelName: 'SimpleFilter',\n id: 'color:red',\n facetId: 'color-facet',\n label: 'Red',\n selected: false,\n value: 'color:red',\n totalResults: 10,\n },\n {\n modelName: 'SimpleFilter',\n id: 'color:blue',\n facetId: 'color-facet',\n label: 'Blue',\n selected: false,\n value: 'color:blue',\n totalResults: 10,\n },\n ],\n },\n])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;AAYA;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;AACL;;;;;AAKE;AACF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAA2B;AACjC,YAAA,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C5B,MAAM,gBAAe,GAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAA;AAChD,gBAAA,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAA;AAC/C,gBAAA,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAA;YACrC;AACF,QAAA,CAAC,EACD,EAAE,SAAS,EAAE,MAAM,CACrB;AAEA,QAAA,OAAO,MAAM,EAAC;IAChB,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"facets-provider.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Facet, Filter } from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport type { GroupId } from '../../store/types'\nimport { isHierarchicalFacet } from '@empathyco/x-types'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../../../composables/use-$x'\nimport { clone } from '../../../../utils'\nimport { areFiltersDifferent } from '../../../../utils/filters'\nimport { flatHierarchicalFilters } from '../../utils'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\nexport default defineComponent({\n name: 'FacetsProvider',\n xModule: facetsXModule.name,\n props: {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n groupId: {\n type: String as PropType<GroupId>,\n default: 'provided-facets',\n },\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter}.\n *\n * @internal\n */\n facets: {\n type: Array as PropType<Facet[]>,\n required: true,\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n const selectedFilters: Ref<Filter[] | null> = ref(null)\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n const facetsGroup = computed(() => ({ id: props.groupId, facets: props.facets }))\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n $x.on('SelectedFiltersChanged', false).subscribe((selectedFiltersParams: Filter[]) => {\n if (\n selectedFilters.value === null ||\n areFiltersDifferent(selectedFilters.value, selectedFiltersParams)\n ) {\n $x.emit('UserChangedSelectedFilters', selectedFiltersParams)\n }\n selectedFilters.value = null\n })\n\n /**\n * Extracts the selected filters from the facets and stores them in the\n * {@link FacetsProvider.selectedFilters} property.\n *\n * @param facets - The facets from whom extract the selected filters.\n * @internal\n */\n const extractSelectedFilters = (facets: Facet[]) => {\n selectedFilters.value = facets\n .flatMap(facet =>\n isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters,\n )\n .filter(filter => filter.selected)\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n watch(\n () => facetsGroup.value,\n () => {\n if (facetsGroup.value.facets) {\n const facetsGroupClone = clone(facetsGroup.value)\n $x.emit('FacetsGroupProvided', facetsGroupClone)\n extractSelectedFilters(props.facets)\n }\n },\n { immediate: true },\n )\n\n return () => ''\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserChangedSelectedFilters`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user performed an action that changed the selected filters. The\n payload is the new list of selected filters.\n- [`FacetsGroupProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after updating the facets prop with a new list of facets. The payload\n contains a Facets Group with the facets and the group id.\n\n## Example\n\nThis component allows to provide facets by prop, to add them to the state of the `Facets X-Module`.\nThese facets will be added to the `Facets X-Module` state together with the facets emitted by the\n`Search X-Module` through the `SearchXEvents.FacetsChanged` event.\n\n```vue\n<template>\n <FacetsProvider :facets=\"myFacets\" />\n</template>\n\n<script setup>\nimport { FacetsProvider } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst myFacets = ref([\n {\n modelName: 'SimpleFacet',\n id: 'color-facet',\n label: 'Color',\n filters: [\n {\n modelName: 'SimpleFilter',\n id: 'color:red',\n facetId: 'color-facet',\n label: 'Red',\n selected: false,\n value: 'color:red',\n totalResults: 10,\n },\n {\n modelName: 'SimpleFilter',\n id: 'color:blue',\n facetId: 'color-facet',\n label: 'Blue',\n selected: false,\n value: 'color:blue',\n totalResults: 10,\n },\n ],\n },\n])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;AAYA;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;AACL;;;;;AAKE;AACF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAA2B;AACjC,YAAA,OAAO,EAAE,iBAAiB;AAC3B,SAAA;AACD;;;;;AAKE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,KAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;;AAKE;AACF,QAAA,MAAM,eAAe,GAAyB,GAAG,CAAC,IAAI,CAAA;AAEtD;;;;;;AAME;QACF,MAAM,WAAU,GAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,EAA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ponent, withCtx, createElementBlock, Fragment, renderList, renderSlot, mergeProps, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
2
+ import { openBlock, createElementBlock, createBlock, resolveDynamicComponent, withCtx, Fragment, renderList, renderSlot, mergeProps, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
3
3
  import './facets.vue3.js';
4
4
  import _export_sfc from '../../../../_virtual/_plugin-vue_export-helper.js';
5
5
 
6
+ const _hoisted_1 = ["aria-label"];
6
7
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
7
- return _ctx.hasFacets ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), {
8
- key: 0,
9
- class: "x-facets-list",
10
- "data-test": "facets",
11
- tag: "ul"
12
- }, {
13
- default: withCtx(() => [
14
- (openBlock(true), createElementBlock(
15
- Fragment,
16
- null,
17
- renderList(_ctx.mappedFacets, ({ facet, slotNameById, slotNameByModelName }, facetId) => {
18
- return openBlock(), createElementBlock("li", {
19
- key: facetId,
20
- class: "x-facets-list__item",
21
- "data-test": "facets-facet"
22
- }, [
23
- _ctx.hasSlot(slotNameById) ? renderSlot(_ctx.$slots, slotNameById, mergeProps({
24
- key: 0,
25
- ref_for: true
26
- }, {
27
- facet,
28
- selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
29
- }), void 0, true) : _ctx.hasSlot(slotNameByModelName) ? renderSlot(_ctx.$slots, slotNameByModelName, mergeProps({
30
- key: 1,
31
- ref_for: true
32
- }, {
33
- facet,
34
- selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
35
- }), void 0, true) : renderSlot(_ctx.$slots, "default", mergeProps({
36
- key: 2,
37
- ref_for: true
38
- }, {
39
- facet,
40
- selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
41
- }), () => [
42
- createTextVNode(
43
- " This is the " + toDisplayString(facet.label) + " facet. Pass something into its slot to display content. ",
44
- 1
45
- /* TEXT */
46
- )
47
- ], true)
48
- ]);
49
- }),
50
- 128
51
- /* KEYED_FRAGMENT */
52
- ))
53
- ]),
54
- _: 3
55
- /* FORWARDED */
56
- })) : createCommentVNode("v-if", true);
8
+ return openBlock(), createElementBlock("nav", {
9
+ id: "facet-nav",
10
+ "aria-label": _ctx.ariaLabels?.root
11
+ }, [
12
+ _ctx.hasFacets ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), {
13
+ key: 0,
14
+ class: "x-facets-list",
15
+ "data-test": "facets",
16
+ tag: "ul"
17
+ }, {
18
+ default: withCtx(() => [
19
+ (openBlock(true), createElementBlock(
20
+ Fragment,
21
+ null,
22
+ renderList(_ctx.mappedFacets, ({ facet, slotNameById, slotNameByModelName }, facetId) => {
23
+ return openBlock(), createElementBlock("li", {
24
+ key: facetId,
25
+ class: "x-facets-list__item",
26
+ "data-test": "facets-facet"
27
+ }, [
28
+ _ctx.hasSlot(slotNameById) ? renderSlot(_ctx.$slots, slotNameById, mergeProps({
29
+ key: 0,
30
+ ref_for: true
31
+ }, {
32
+ facet,
33
+ selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
34
+ }), void 0, true) : _ctx.hasSlot(slotNameByModelName) ? renderSlot(_ctx.$slots, slotNameByModelName, mergeProps({
35
+ key: 1,
36
+ ref_for: true
37
+ }, {
38
+ facet,
39
+ selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
40
+ }), void 0, true) : renderSlot(_ctx.$slots, "default", mergeProps({
41
+ key: 2,
42
+ ref_for: true
43
+ }, {
44
+ facet,
45
+ selectedFilters: _ctx.selectedFiltersByFacet[facetId] || []
46
+ }), () => [
47
+ createTextVNode(
48
+ " This is the " + toDisplayString(facet.label) + " facet. Pass something into its slot to display content. ",
49
+ 1
50
+ /* TEXT */
51
+ )
52
+ ], true)
53
+ ]);
54
+ }),
55
+ 128
56
+ /* KEYED_FRAGMENT */
57
+ ))
58
+ ]),
59
+ _: 3
60
+ /* FORWARDED */
61
+ })) : createCommentVNode("v-if", true)
62
+ ], 8, _hoisted_1);
57
63
  }
58
64
  var facets = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ec0aa26c"]]);
59
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { RenderFacet } from './facets.types'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"childFilter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example of\nthe `Facets` component using the `FiltersSearch`, `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel` components.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_renderSlot","_mergeProps","_createTextVNode","_toDisplayString"],"mappings":";;;;;;SACmC,IAAA,CAAA,SAAA,IAAAA,SAAA,EAAA,EAAjCC,WAAA,CAmDYC,wBAnDI,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;IAAmB,KAAA,EAAM,eAAA;AAAA,IAAgB,WAAA,EAAU,QAAA;AAAA,IAAS,GAAA,EAAI;AAAA,GAAA,EAAA;qBAErF,MAA+E;AAAA,OAAAF,SAAA,CAAA,IAAA,CAAA,EADjFG,kBAAA;AAAA,QAiDKC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAhD+D,mBAAY,CAAA,EAApE,KAAA,EAAO,YAAA,EAAc,mBAAA,IAAuB,OAAA,KAAO;8BAD/DF,kBAAA,CAiDK,IAAA,EAAA;AAAA,YA/CF,GAAA,EAAK,OAAA;AAAA,YACN,KAAA,EAAM,qBAAA;AAAA,YACN,WAAA,EAAU;AAAA,WAAA,EAAA;AASF,YAAA,IAAA,CAAA,OAAA,CAAQ,YAAY,CAAA,GAD5BG,UAAA,CAOE,IAAA,CAAA,MAAA,EADO,cANTC,UAAA,CAOE;AAAA,cAAA,GAAA,EAAA,CAAA;;;AALoB,cAAA,KAAA;AAAA,cAAA,eAAA,EAAkC,4BAAuB,OAAO,CAAA,IAAA;AAAA,aAAA,CAAA,EAAA,MAAA,EAAA,IAAA,CAAA,GAazE,aAAQ,mBAAmB,CAAA,GADxCD,UAAA,CAOE,IAAA,CAAA,MAAA,EADO,qBANTC,UAAA,CAOE;AAAA,cAAA,GAAA,EAAA,CAAA;;;AALoB,cAAA,KAAA;AAAA,cAAA,eAAA,EAAkC,4BAAuB,OAAO,CAAA,IAAA;AAAA,aAAA,CAAA,EAAA,MAAA,EAAA,IAAA,CAAA,GAYtFD,UAAA,CAQO,wBARPC,UAAA,CAQO;AAAA,cAAA,GAAA,EAAA,CAAA;;;AANe,cAAA,KAAA;AAAA,cAAA,eAAA,EAAkC,4BAAuB,OAAO,CAAA,IAAA;AAAA,aAAA,CAAA,EAFtF,MAQO;AAAA,cAAAC,eAAA;gBAFN,eAAA,GACaC,eAAA,CAAG,KAAA,CAAM,KAAK,CAAA,GAAG,2DAAA;AAAA,gBAC/B;AAAA;AAAA;AAAA,aAAA,EAAA,IAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <nav id=\"facet-nav\" :aria-label=\"ariaLabels?.root\">\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { RenderFacet } from './facets.types'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useAccessibilityLabels } from '../../../../composables'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n const ariaLabels = useAccessibilityLabels('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n ariaLabels,\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"childFilter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example of\nthe `Facets` component using the `FiltersSearch`, `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel` components.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_createElementBlock","_openBlock","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AAA,IAAA;AAAA,eAAA,CAAA,EAAA,MAAA,EAAA,IAAA,CAAA,GAY1FD,UAAA,CAQO,wBARPC,UAAA,CAQO;AAAA,gBAAA,GAAA,EAAA,CAAA;;;AANiB,gBAAA,KAAA;AAAA,gBAAA,eAAA,EAAoC,4BAAuB,OAAO,CAAA,IAAA;AAAA,eAAA,CAAA,EAF1F,MAQO;AAAA,gBAAAC,eAAA;kBAFN,eAAA,GACaC,eAAA,CAAG,KAAA,CAAM,KAAK,CAAA,GAAG,2DAAA;AAAA,kBAC/B;AAAA;AAAA;AAAA,eAAA,EAAA,IAAA;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,13 @@
1
1
  import { map, objectFilter } from '@empathyco/x-utils';
2
2
  import { defineComponent, computed } from 'vue';
3
+ import '../../../../composables/create-use-device.js';
4
+ import 'vuex';
5
+ import '../../../../plugins/x-bus.js';
6
+ import '../../../../plugins/x-plugin.js';
7
+ import 'rxjs';
8
+ import { useAccessibilityLabels } from '../../../../composables/use-accessibility-labels.js';
3
9
  import { useGetter } from '../../../../composables/use-getter.js';
10
+ import '@vueuse/core';
4
11
  import { AnimationProp } from '../../../../types/animation-prop.js';
5
12
  import { toKebabCase } from '../../../../utils/string.js';
6
13
  import { useFacets } from '../../composables/use-facets.js';
@@ -52,6 +59,7 @@ var _sfc_main = defineComponent({
52
59
  setup(props, { slots }) {
53
60
  const { selectedFiltersByFacet } = useFacets(props);
54
61
  const { facets } = useGetter('facets');
62
+ const ariaLabels = useAccessibilityLabels('facets');
55
63
  /**
56
64
  * The facets to be rendered after filtering {@link Facets.facets} by
57
65
  * {@link Facets.renderableFacets} content.
@@ -123,6 +131,7 @@ var _sfc_main = defineComponent({
123
131
  return !!slots[name];
124
132
  }
125
133
  return {
134
+ ariaLabels,
126
135
  selectedFiltersByFacet,
127
136
  hasFacets,
128
137
  mappedFacets,
@@ -1 +1 @@
1
- {"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { RenderFacet } from './facets.types'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"childFilter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example of\nthe `Facets` component using the `FiltersSearch`, `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel` components.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AAoEA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;;;;;;;;;;;;;;;AAkBE;AACF,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;QACpB,MAAM,EAAE,sBAAqB,KAAM,SAAS,CAAC,KAAK,CAAA;QAClD,MAAM,EAAE,MAAK,EAAE,GAAI,SAAS,CAAC,QAAQ,CAAA;AAErC;;;;;AAKE;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAAoB,MAAI;AACrD,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC3B,OAAO,MAAM,CAAC,KAAI;YACpB;iBAAO;gBACL,MAAM,cAAa,GAAI,IAAG;gBAC1B,MAAM,QAAQ,GAAa,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAM,IAAK,OAAO,CAAC,IAAI,EAAE,CAAA;gBAC1F,MAAM,QAAQ,GAAa,EA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Q,CAAC,CAAA;AAErD,gBAAA,OAAO,mBAAkB,GAAI,UAAS,IAAK,CAAC,UAAS,GAAI,CAAC,UAAS;AACrE,YAAA,CAAC,CAAA;QACH;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;QACrB;QAEA,OAAO;YACL,sBAAsB;YACtB,SAAS;YACT,YAAY;YACZ,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <nav id=\"facet-nav\" :aria-label=\"ariaLabels?.root\">\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { RenderFacet } from './facets.types'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useAccessibilityLabels } from '../../../../composables'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n const ariaLabels = useAccessibilityLabels('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n ariaLabels,\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"childFilter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example of\nthe `Facets` component using the `FiltersSearch`, `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel` components.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script setup>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuEA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;;;;;;;;;;;;;;;AAkBE;AACF,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAA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WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjD,KAAK;AACN,aAAA,CAAC,CAAA;AACJ,QAAA,CAAC,CAAA;AAED;;;;AAIE;QACF,MAAM,SAAQ,GAAI,QAAQ,CAAU,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA;AAEpF;;;;;;;AAOE;AACF,QAAA,SAAS,oBAAoB,CAAC,QAAkB,EAAE,QAAkB,EAAA;AAClE,YAAA,MAAM,mBAAkB,GAAI,QAAQ,CAAC,SAAS,CAAA;YAC9C,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,QAAO,IAAG;gBAC1C,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;gBACrD,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAErD,gBAAA,OAAO,mBAAkB,GAAI,UAAS,IAAK,CAAC,UAAS,GAAI,CAAC,UAAS;AACrE,YAAA,CAAC,CAAA;QACH;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;QACrB;QAEA,OAAO;YACL,UAAU;YACV,sBAAsB;YACtB,SAAS;YACT,YAAY;YACZ,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -30,7 +30,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
30
30
  class: normalizeClass(["x-editable-number-range-filter__input x-editable-number-range-filter__input--min xds:input", _ctx.inputsClass]),
31
31
  value: !_ctx.isAnyRange ? _ctx.min : null,
32
32
  "data-test": "range-min",
33
- "aria-label": _ctx.rangeFilterMin,
33
+ "aria-label": _ctx.ariaLabels?.min,
34
34
  onChange: _cache[0] || (_cache[0] = ($event) => _ctx.setMin($event?.target?.valueAsNumber))
35
35
  }, null, 42, _hoisted_1),
36
36
  createElementVNode("input", {
@@ -39,7 +39,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
39
39
  class: normalizeClass(["x-editable-number-range-filter__input x-editable-number-range-filter__input--max xds:input", _ctx.inputsClass]),
40
40
  value: _ctx.max,
41
41
  "data-test": "range-max",
42
- "aria-label": _ctx.rangeFilterMax,
42
+ "aria-label": _ctx.ariaLabels?.max,
43
43
  onChange: _cache[1] || (_cache[1] = ($event) => _ctx.setMax($event?.target?.valueAsNumber))
44
44
  }, null, 42, _hoisted_2),
45
45
  !_ctx.isInstant ? (openBlock(), createElementBlock("button", {
@@ -1 +1 @@
1
- {"version":3,"file":"editable-number-range-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/editable-number-range-filter.vue"],"sourcesContent":["<template>\n <div\n class=\"x-editable-number-range-filter\"\n :class=\"cssClasses\"\n data-test=\"editable-number-range-filter\"\n >\n <!--\n @slot Empty slot used to customize the whole component.\n @binding {min} number - Component min value.\n @binding {max} number - Component max value.\n @binding {setMin} function - Component min setter.\n @binding {setMax} function - Component max setter.\n @binding {emitUserModifiedFilter} function - It emits the\n `UserModifiedEditableNumberRangeFilter` X event.\n @binding {clearValues} function - It sets component min and max values to null.\n @binding {hasError} boolean - Returns true when there is an error with component values.\n -->\n <slot\n v-bind=\"{\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n }\"\n >\n <!-- eslint-disable max-len -->\n <input\n name=\"min\"\n type=\"number\"\n class=\"x-editable-number-range-filter__input x-editable-number-range-filter__input--min xds:input\"\n :class=\"inputsClass\"\n :value=\"!isAnyRange ? min : null\"\n data-test=\"range-min\"\n :aria-label=\"rangeFilterMin\"\n @change=\"setMin(($event?.target as HTMLInputElement)?.valueAsNumber)\"\n />\n\n <input\n name=\"max\"\n type=\"number\"\n class=\"x-editable-number-range-filter__input x-editable-number-range-filter__input--max xds:input\"\n :class=\"inputsClass\"\n :value=\"max\"\n data-test=\"range-max\"\n :aria-label=\"rangeFilterMax\"\n @change=\"setMax(($event?.target as HTMLInputElement)?.valueAsNumber)\"\n />\n <!-- eslint-enable max-len -->\n\n <button\n v-if=\"!isInstant\"\n class=\"x-editable-number-range-filter__apply xds:button\"\n :class=\"buttonsClass\"\n :disabled=\"hasError\"\n data-test=\"range-apply\"\n @click=\"emitUserModifiedFilter\"\n >\n <!--\n @slot Slot used to customize the apply button content.\n -->\n <slot name=\"apply-content\">✓</slot>\n </button>\n\n <button\n v-if=\"renderClearButton\"\n class=\"x-editable-number-range-filter__clear xds:button\"\n :class=\"buttonsClass\"\n data-test=\"range-clear\"\n @click=\"clearValues\"\n >\n <!--\n @slot Slot used to customize the clear button content.\n -->\n <slot name=\"clear-content\">𐄂</slot>\n </button>\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type {\n EditableNumberRangeFilter as EditableNumberRangeFilterModel,\n RangeValue,\n} from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../../../composables'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Renders an editable number range filter. It has two input fields to handle min and max values,\n * emitting the needed events when clicked.\n *\n * It provides a default slot, with some utils bind, to customize the whole component; and two\n * named slots `apply-content` and `clear-content` to override each button content.\n *\n * If `instant` prop is true, the needed events are emitted immediately; else, apply button is\n * rendered to confirm to do it. False by default.\n *\n * If `clear` prop is true, clear button, which sets to null component min and max values, is\n * rendered. True by default.\n *\n * @public\n */\nexport default defineComponent({\n name: 'EditableNumberRangeFilter',\n xModule: facetsXModule.name,\n props: {\n /**\n * The filter data to render and edit.\n *\n * @public\n */\n filter: {\n type: Object as PropType<EditableNumberRangeFilterModel>,\n required: true,\n },\n /**\n * If `instant` prop is true, the needed events are emitted immediately; else, apply button is\n * rendered to confirm to do it. False by default.\n *\n * @public\n */\n isInstant: Boolean,\n /**\n * If `clear` prop is true, clear button, which sets to null component min and max values, is\n * rendered. True by default.\n *\n * @public\n */\n hasClearButton: {\n type: Boolean,\n default: true,\n },\n /** Class inherited by content element. */\n inputsClass: String,\n /** Class inherited by content element. */\n buttonsClass: String,\n },\n setup(props) {\n const $x = use$x()\n\n const rangeFilterMin = 'minimum amount'\n const rangeFilterMax = 'maximum amount'\n /**\n * Component min value.\n *\n * @internal\n */\n const min: Ref<RangeValue['min']> = ref(null)\n /**\n * Component max value.\n *\n * @internal\n */\n const max: Ref<RangeValue['max']> = ref(null)\n\n /**\n * Returns {@link @empathyco/x-types#RangeValue} with component min and max\n * values.\n *\n * @returns Range value object with component values.\n *\n * @internal\n */\n const range = computed((): RangeValue => {\n return { min: min.value, max: max.value }\n })\n\n /**\n * It checks if component min and max values are valid.\n *\n * @returns True if there is any error in the component min and max values.\n *\n * @internal\n */\n const hasError = computed(\n () => min.value !== null && max.value !== null && min.value > max.value,\n )\n\n /**\n * It checks if component min and max values are different from the ones within the filter\n * provided as property.\n *\n * @returns True if they are different.\n *\n * @internal\n */\n const areValuesDifferent = computed(\n () => min.value !== props.filter.range.min || max.value !== props.filter.range.max,\n )\n\n /**\n * Dynamic CSS classes.\n *\n * @returns Object which contains dynamic CSS classes.\n *\n * @internal\n */\n const cssClasses = computed(() => {\n return { 'x-editable-number-range-filter--error': hasError.value }\n })\n\n /**\n * Checks if the range of the filter allows any value, which happens when the min is\n * null or 0 and the max is null.\n *\n * @returns True if the range of the filter allows any value.\n *\n * @internal\n */\n const isAnyRange = computed(() => !min.value && max.value === null)\n\n /**\n * It returns true if the property `hasClearButton` is true and there are values to clear.\n *\n * @returns True if the clear button has to be rendered.\n *\n * @internal\n */\n const renderClearButton = computed(() => props.hasClearButton && !isAnyRange.value)\n\n /**\n * It emits {@link FacetsXEvents.UserModifiedEditableNumberRangeFilter} event if there are no\n * errors and component `min` and `max` values are different than `filter.range` ones.\n *\n * @internal\n */\n const emitUserModifiedFilter = () => {\n if (!hasError.value && areValuesDifferent.value) {\n $x.emit('UserModifiedEditableNumberRangeFilter', {\n ...props.filter,\n range: range.value,\n })\n }\n }\n\n /**\n * It returns the number if possible or null otherwise.\n *\n * @param value - Value.\n * @returns The element value as a number if possible or null.\n *\n * @internal\n */\n const parseRangeValue = (value: number) => (Number.isNaN(value) ? null : value)\n\n /**\n * `min` setter.\n *\n * @param value - The component `min` value to be set.\n *\n * @internal\n */\n const setMin = (value: number) => {\n min.value = parseRangeValue(value)\n }\n\n /**\n * `max` setter.\n *\n * @param value - The component `max` value to be set.\n *\n * @internal\n */\n const setMax = (value: number) => {\n max.value = parseRangeValue(value)\n }\n\n /**\n * It sets component `min` and `max` values to null , and it emits the change if component is\n * working in instant mode.\n *\n * @internal\n */\n const clearValues = () => {\n min.value = null\n max.value = null\n }\n\n /**\n * It resets the min/max range values to null if the\n * {@link FacetsXEvents.UserClickedClearAllFilters} event is fired.\n *\n * @public\n */\n $x.on('UserClickedClearAllFilters', false).subscribe(clearValues)\n\n /**\n * It watches the filter range values passed as property and updates component range values if\n * they change.\n *\n * @param newRange - New range value.\n *\n * @internal\n */\n watch(\n () => props.filter.range,\n (newRange: RangeValue) => {\n min.value = newRange.min\n max.value = newRange.max\n },\n { immediate: true, deep: true },\n )\n\n /**\n * It watches range values in order to emit the event with the change if `isInstant`\n * property is true.\n *\n * @internal\n */\n watch(\n range,\n () => {\n if (props.isInstant) {\n emitUserModifiedFilter()\n }\n },\n { deep: true },\n )\n\n return {\n rangeFilterMin,\n rangeFilterMax,\n cssClasses,\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n renderClearButton,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-editable-number-range-filter--error .x-editable-number-range-filter__input {\n border-color: red;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserModifiedEditableNumberRangeFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n this event is emitted instantly after typing the value or clicking the submit button. The event\n payload in both cases is an object containing the filter and the new value for the range.\n\n## Example\n\nRenders an editable number range filter. It has two input fields to handle min and max values,\nemitting the needed events when clicked.\n\nIt provides a default slot, with some utils bind, to customize the whole component; and two named\nslots `apply-content` and `clear-content` to override each button content.\n\nIf `instant` prop is true, the needed events are emitted immediately; else, apply button is rendered\nto confirm to do it. False by default.\n\nIf `clear` prop is true, clear button, which sets to null component min and max values, is rendered.\nTrue by default.\n\n### Basic usage\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\" />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Properties\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\" :isInstant=\"true\" :hasClearButton=\"false\" />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing content slots\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\">\n <template #apply-content>Apply</template>\n <template #clear-content>Clear</template>\n </EditableNumberRangeFilter>\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing default slot\n\n```vue\n<template>\n <EditableNumberRangeFilter\n :filter=\"editableFilter\"\n #default=\"{\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n }\"\n >\n <button @click=\"emitUserModifiedFilter\">✅ Apply!</button>\n <button @click=\"clearValues\">🗑 Clear!</button>\n <input :value=\"!isAnyRange ? min : null\" @change=\"setMin($event.target.valueAsNumber)\" />\n <input :value=\"max\" @change=\"setMax($event.target.valueAsNumber)\" />\n <div class=\"has-error\" v-if=\"hasError\">⚠️ Invalid range values</div>\n </EditableNumberRangeFilter>\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing the items with classes\n\nThe `buttonsClass` and `inputsClass` props can be used to add classes to the inputs and buttons of\nthe component.\n\n```\n<template>\n <EditableNumberRangeFilter\n :filter=\"editableFilter\"\n :inputsClass=\"'my-inputs-class'\"\n :buttonsClass=\"'my-buttons-class'\"\n />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_renderSlot","_normalizeProps","_guardReactiveProps","_createElementVNode","_createTextVNode"],"mappings":";;;;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA+EM,KAAA;AAAA,IAAA;AAAA,MA9EJ,KAAA,EAAKC,cAAA,CAAA,CAAC,gCAAA,EACE,IAAA,CAAA,UAAU,CAAA,CAAA;AAAA,MAClB,WAAA,EAAU;AAAA,KAAA;;MAaVC,UAAA,CA8DO,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA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;AAAA,WAAA;;AAKR,YAAAC,UAAA,CAAoC,kCAApC,MAAoC;AAAA,cAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAI,eAAA;AAAT,gBAAA,IAAA;AAAA,gBAAE;AAAA;AAAA,eAAA;AAAA,aAAA,EAAA,IAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"editable-number-range-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/editable-number-range-filter.vue"],"sourcesContent":["<template>\n <div\n class=\"x-editable-number-range-filter\"\n :class=\"cssClasses\"\n data-test=\"editable-number-range-filter\"\n >\n <!--\n @slot Empty slot used to customize the whole component.\n @binding {min} number - Component min value.\n @binding {max} number - Component max value.\n @binding {setMin} function - Component min setter.\n @binding {setMax} function - Component max setter.\n @binding {emitUserModifiedFilter} function - It emits the\n `UserModifiedEditableNumberRangeFilter` X event.\n @binding {clearValues} function - It sets component min and max values to null.\n @binding {hasError} boolean - Returns true when there is an error with component values.\n -->\n <slot\n v-bind=\"{\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n }\"\n >\n <!-- eslint-disable max-len -->\n <input\n name=\"min\"\n type=\"number\"\n class=\"x-editable-number-range-filter__input x-editable-number-range-filter__input--min xds:input\"\n :class=\"inputsClass\"\n :value=\"!isAnyRange ? min : null\"\n data-test=\"range-min\"\n :aria-label=\"ariaLabels?.min\"\n @change=\"setMin(($event?.target as HTMLInputElement)?.valueAsNumber)\"\n />\n\n <input\n name=\"max\"\n type=\"number\"\n class=\"x-editable-number-range-filter__input x-editable-number-range-filter__input--max xds:input\"\n :class=\"inputsClass\"\n :value=\"max\"\n data-test=\"range-max\"\n :aria-label=\"ariaLabels?.max\"\n @change=\"setMax(($event?.target as HTMLInputElement)?.valueAsNumber)\"\n />\n <!-- eslint-enable max-len -->\n\n <button\n v-if=\"!isInstant\"\n class=\"x-editable-number-range-filter__apply xds:button\"\n :class=\"buttonsClass\"\n :disabled=\"hasError\"\n data-test=\"range-apply\"\n @click=\"emitUserModifiedFilter\"\n >\n <!--\n @slot Slot used to customize the apply button content.\n -->\n <slot name=\"apply-content\">✓</slot>\n </button>\n\n <button\n v-if=\"renderClearButton\"\n class=\"x-editable-number-range-filter__clear xds:button\"\n :class=\"buttonsClass\"\n data-test=\"range-clear\"\n @click=\"clearValues\"\n >\n <!--\n @slot Slot used to customize the clear button content.\n -->\n <slot name=\"clear-content\">𐄂</slot>\n </button>\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type {\n EditableNumberRangeFilter as EditableNumberRangeFilterModel,\n RangeValue,\n} from '@empathyco/x-types'\nimport type { PropType, Ref } from 'vue'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { use$x, useAccessibilityLabels } from '../../../../composables'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Renders an editable number range filter. It has two input fields to handle min and max values,\n * emitting the needed events when clicked.\n *\n * It provides a default slot, with some utils bind, to customize the whole component; and two\n * named slots `apply-content` and `clear-content` to override each button content.\n *\n * If `instant` prop is true, the needed events are emitted immediately; else, apply button is\n * rendered to confirm to do it. False by default.\n *\n * If `clear` prop is true, clear button, which sets to null component min and max values, is\n * rendered. True by default.\n *\n * @public\n */\nexport default defineComponent({\n name: 'EditableNumberRangeFilter',\n xModule: facetsXModule.name,\n props: {\n /**\n * The filter data to render and edit.\n *\n * @public\n */\n filter: {\n type: Object as PropType<EditableNumberRangeFilterModel>,\n required: true,\n },\n /**\n * If `instant` prop is true, the needed events are emitted immediately; else, apply button is\n * rendered to confirm to do it. False by default.\n *\n * @public\n */\n isInstant: Boolean,\n /**\n * If `clear` prop is true, clear button, which sets to null component min and max values, is\n * rendered. True by default.\n *\n * @public\n */\n hasClearButton: {\n type: Boolean,\n default: true,\n },\n /** Class inherited by content element. */\n inputsClass: String,\n /** Class inherited by content element. */\n buttonsClass: String,\n },\n setup(props) {\n const $x = use$x()\n\n const ariaLabels = useAccessibilityLabels('editableNumberRangeFilter')\n\n /**\n * Component min value.\n *\n * @internal\n */\n const min: Ref<RangeValue['min']> = ref(null)\n /**\n * Component max value.\n *\n * @internal\n */\n const max: Ref<RangeValue['max']> = ref(null)\n\n /**\n * Returns {@link @empathyco/x-types#RangeValue} with component min and max\n * values.\n *\n * @returns Range value object with component values.\n *\n * @internal\n */\n const range = computed((): RangeValue => {\n return { min: min.value, max: max.value }\n })\n\n /**\n * It checks if component min and max values are valid.\n *\n * @returns True if there is any error in the component min and max values.\n *\n * @internal\n */\n const hasError = computed(\n () => min.value !== null && max.value !== null && min.value > max.value,\n )\n\n /**\n * It checks if component min and max values are different from the ones within the filter\n * provided as property.\n *\n * @returns True if they are different.\n *\n * @internal\n */\n const areValuesDifferent = computed(\n () => min.value !== props.filter.range.min || max.value !== props.filter.range.max,\n )\n\n /**\n * Dynamic CSS classes.\n *\n * @returns Object which contains dynamic CSS classes.\n *\n * @internal\n */\n const cssClasses = computed(() => {\n return { 'x-editable-number-range-filter--error': hasError.value }\n })\n\n /**\n * Checks if the range of the filter allows any value, which happens when the min is\n * null or 0 and the max is null.\n *\n * @returns True if the range of the filter allows any value.\n *\n * @internal\n */\n const isAnyRange = computed(() => !min.value && max.value === null)\n\n /**\n * It returns true if the property `hasClearButton` is true and there are values to clear.\n *\n * @returns True if the clear button has to be rendered.\n *\n * @internal\n */\n const renderClearButton = computed(() => props.hasClearButton && !isAnyRange.value)\n\n /**\n * It emits {@link FacetsXEvents.UserModifiedEditableNumberRangeFilter} event if there are no\n * errors and component `min` and `max` values are different than `filter.range` ones.\n *\n * @internal\n */\n const emitUserModifiedFilter = () => {\n if (!hasError.value && areValuesDifferent.value) {\n $x.emit('UserModifiedEditableNumberRangeFilter', {\n ...props.filter,\n range: range.value,\n })\n }\n }\n\n /**\n * It returns the number if possible or null otherwise.\n *\n * @param value - Value.\n * @returns The element value as a number if possible or null.\n *\n * @internal\n */\n const parseRangeValue = (value: number) => (Number.isNaN(value) ? null : value)\n\n /**\n * `min` setter.\n *\n * @param value - The component `min` value to be set.\n *\n * @internal\n */\n const setMin = (value: number) => {\n min.value = parseRangeValue(value)\n }\n\n /**\n * `max` setter.\n *\n * @param value - The component `max` value to be set.\n *\n * @internal\n */\n const setMax = (value: number) => {\n max.value = parseRangeValue(value)\n }\n\n /**\n * It sets component `min` and `max` values to null , and it emits the change if component is\n * working in instant mode.\n *\n * @internal\n */\n const clearValues = () => {\n min.value = null\n max.value = null\n }\n\n /**\n * It resets the min/max range values to null if the\n * {@link FacetsXEvents.UserClickedClearAllFilters} event is fired.\n *\n * @public\n */\n $x.on('UserClickedClearAllFilters', false).subscribe(clearValues)\n\n /**\n * It watches the filter range values passed as property and updates component range values if\n * they change.\n *\n * @param newRange - New range value.\n *\n * @internal\n */\n watch(\n () => props.filter.range,\n (newRange: RangeValue) => {\n min.value = newRange.min\n max.value = newRange.max\n },\n { immediate: true, deep: true },\n )\n\n /**\n * It watches range values in order to emit the event with the change if `isInstant`\n * property is true.\n *\n * @internal\n */\n watch(\n range,\n () => {\n if (props.isInstant) {\n emitUserModifiedFilter()\n }\n },\n { deep: true },\n )\n\n return {\n ariaLabels,\n cssClasses,\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n renderClearButton,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-editable-number-range-filter--error .x-editable-number-range-filter__input {\n border-color: red;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserModifiedEditableNumberRangeFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n this event is emitted instantly after typing the value or clicking the submit button. The event\n payload in both cases is an object containing the filter and the new value for the range.\n\n## Example\n\nRenders an editable number range filter. It has two input fields to handle min and max values,\nemitting the needed events when clicked.\n\nIt provides a default slot, with some utils bind, to customize the whole component; and two named\nslots `apply-content` and `clear-content` to override each button content.\n\nIf `instant` prop is true, the needed events are emitted immediately; else, apply button is rendered\nto confirm to do it. False by default.\n\nIf `clear` prop is true, clear button, which sets to null component min and max values, is rendered.\nTrue by default.\n\n### Basic usage\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\" />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Properties\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\" :isInstant=\"true\" :hasClearButton=\"false\" />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing content slots\n\n```vue\n<template>\n <EditableNumberRangeFilter :filter=\"editableFilter\">\n <template #apply-content>Apply</template>\n <template #clear-content>Clear</template>\n </EditableNumberRangeFilter>\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing default slot\n\n```vue\n<template>\n <EditableNumberRangeFilter\n :filter=\"editableFilter\"\n #default=\"{\n min,\n max,\n setMin,\n setMax,\n emitUserModifiedFilter,\n clearValues,\n hasError,\n isAnyRange,\n }\"\n >\n <button @click=\"emitUserModifiedFilter\">✅ Apply!</button>\n <button @click=\"clearValues\">🗑 Clear!</button>\n <input :value=\"!isAnyRange ? min : null\" @change=\"setMin($event.target.valueAsNumber)\" />\n <input :value=\"max\" @change=\"setMax($event.target.valueAsNumber)\" />\n <div class=\"has-error\" v-if=\"hasError\">⚠️ Invalid range values</div>\n </EditableNumberRangeFilter>\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n\n### Customizing the items with classes\n\nThe `buttonsClass` and `inputsClass` props can be used to add classes to the inputs and buttons of\nthe component.\n\n```\n<template>\n <EditableNumberRangeFilter\n :filter=\"editableFilter\"\n :inputsClass=\"'my-inputs-class'\"\n :buttonsClass=\"'my-buttons-class'\"\n />\n</template>\n\n<script setup>\nimport { EditableNumberRangeFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst editableFilter = ref({\n facetId: 'age',\n id: 'age:primary',\n label: 'primary',\n modelName: 'EditableNumberRangeFilter',\n range: {\n min: null,\n max: null,\n },\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_renderSlot","_normalizeProps","_guardReactiveProps","_createElementVNode","_createTextVNode"],"mappings":";;;;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA+EM,KAAA;AAAA,IAAA;AAAA,MA9EJ,KAAA,EAAKC,cAAA,CAAA,CAAC,gCAAA,EACE,IAAA,CAAA,UAAU,CAAA,CAAA;AAAA,MAClB,WAAA,EAAU;AAAA,KAAA;;MAaVC,UAAA,CA8DO,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA;AAAA,QAAA,GAAA,EA7Da,IAAA,CAAA,GAAA;AAAA,QAAA,GAAA,EAAa,IAAA,CAAA,GAAA;AAAA,QAAA,MAAA,EAAa,IAAA,CAAA,MAAA;AAAA,QAAA,MAAA,EAAgB,IAAA,CAAA,MAAA;AAAA,QAAA,sBAAA,EAAgB,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AAA,aAAA,EAAA,IAAA;;;;;;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { defineComponent, ref, computed, watch } from 'vue';
2
2
  import '../../../../composables/create-use-device.js';
3
3
  import { use$x } from '../../../../composables/use-_x.js';
4
+ import { useAccessibilityLabels } from '../../../../composables/use-accessibility-labels.js';
4
5
  import 'vuex';
5
6
  import '../../../../plugins/x-bus.js';
6
7
  import '@empathyco/x-utils';
@@ -61,8 +62,7 @@ var _sfc_main = defineComponent({
61
62
  },
62
63
  setup(props) {
63
64
  const $x = use$x();
64
- const rangeFilterMin = 'minimum amount';
65
- const rangeFilterMax = 'maximum amount';
65
+ const ariaLabels = useAccessibilityLabels('editableNumberRangeFilter');
66
66
  /**
67
67
  * Component min value.
68
68
  *
@@ -214,8 +214,7 @@ var _sfc_main = defineComponent({
214
214
  }
215
215
  }, { deep: true });
216
216
  return {
217
- rangeFilterMin,
218
- rangeFilterMax,
217
+ ariaLabels,
219
218
  cssClasses,
220
219
  min,
221
220
  max,