@empathyco/x-components 9.3.0 → 9.3.1

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 (187) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/core/index.js +2 -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.editablenumberrangefilter.md +4 -2
  35. package/docs/API-reference/api/x-components.facets.md +3 -0
  36. package/docs/API-reference/api/x-components.filterssearch.md +3 -0
  37. package/docs/API-reference/api/x-components.historyqueriesswitch.md +3 -0
  38. package/docs/API-reference/api/x-components.historyquery.md +3 -0
  39. package/docs/API-reference/api/x-components.md +20 -0
  40. package/docs/API-reference/api/x-components.pageloaderbutton.md +3 -0
  41. package/docs/API-reference/api/x-components.pageselector.md +6 -0
  42. package/docs/API-reference/api/x-components.removehistoryquery.md +3 -0
  43. package/docs/API-reference/api/x-components.scrolltotop.md +3 -0
  44. package/docs/API-reference/api/x-components.searchinput.md +3 -0
  45. package/docs/API-reference/api/x-components.sliderfilter.md +4 -0
  46. package/docs/API-reference/api/x-components.sortdropdown.md +3 -0
  47. package/docs/API-reference/components/common/x-components.base-dropdown.md +0 -1
  48. package/js/components/base-dropdown.vue.js +1 -1
  49. package/js/components/base-dropdown.vue.js.map +1 -1
  50. package/js/components/base-dropdown.vue2.js +4 -3
  51. package/js/components/base-dropdown.vue2.js.map +1 -1
  52. package/js/components/column-picker/base-column-picker-dropdown.vue.js +2 -2
  53. package/js/components/column-picker/base-column-picker-dropdown.vue.js.map +1 -1
  54. package/js/components/column-picker/base-column-picker-dropdown.vue2.js +4 -1
  55. package/js/components/column-picker/base-column-picker-dropdown.vue2.js.map +1 -1
  56. package/js/components/column-picker/base-column-picker-list.vue.js +1 -1
  57. package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
  58. package/js/components/column-picker/base-column-picker-list.vue2.js +4 -2
  59. package/js/components/column-picker/base-column-picker-list.vue2.js.map +1 -1
  60. package/js/components/modals/base-events-modal-close.vue.js +2 -2
  61. package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
  62. package/js/components/modals/base-events-modal-close.vue2.js +4 -1
  63. package/js/components/modals/base-events-modal-close.vue2.js.map +1 -1
  64. package/js/components/modals/base-events-modal-open.vue.js +2 -2
  65. package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
  66. package/js/components/modals/base-events-modal-open.vue2.js +4 -1
  67. package/js/components/modals/base-events-modal-open.vue2.js.map +1 -1
  68. package/js/components/modals/base-modal.vue.js +11 -16
  69. package/js/components/modals/base-modal.vue.js.map +1 -1
  70. package/js/components/modals/base-modal.vue2.js +4 -1
  71. package/js/components/modals/base-modal.vue2.js.map +1 -1
  72. package/js/components/page-loader-button.vue.js +2 -2
  73. package/js/components/page-loader-button.vue.js.map +1 -1
  74. package/js/components/page-loader-button.vue2.js +4 -1
  75. package/js/components/page-loader-button.vue2.js.map +1 -1
  76. package/js/components/page-selector.vue.js +12 -12
  77. package/js/components/page-selector.vue.js.map +1 -1
  78. package/js/components/page-selector.vue2.js +4 -1
  79. package/js/components/page-selector.vue2.js.map +1 -1
  80. package/js/components/sort/sort-dropdown.vue.js +2 -2
  81. package/js/components/sort/sort-dropdown.vue.js.map +1 -1
  82. package/js/components/sort/sort-dropdown.vue2.js +4 -1
  83. package/js/components/sort/sort-dropdown.vue2.js.map +1 -1
  84. package/js/index.js +2 -0
  85. package/js/index.js.map +1 -1
  86. package/js/types/accessibility.js +4 -0
  87. package/js/types/accessibility.js.map +1 -0
  88. package/js/utils/accessibility.js +55 -0
  89. package/js/utils/accessibility.js.map +1 -0
  90. package/js/x-installer/x-installer.js +4 -0
  91. package/js/x-installer/x-installer.js.map +1 -1
  92. package/js/x-modules/ai/components/ai-carousel.vue.js +1 -1
  93. package/js/x-modules/ai/components/ai-carousel.vue.js.map +1 -1
  94. package/js/x-modules/ai/components/ai-carousel.vue2.js +4 -1
  95. package/js/x-modules/ai/components/ai-carousel.vue2.js.map +1 -1
  96. package/js/x-modules/facets/components/facets/facets.vue.js +57 -51
  97. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  98. package/js/x-modules/facets/components/facets/facets.vue2.js +4 -1
  99. package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
  100. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js +2 -2
  101. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js.map +1 -1
  102. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js +4 -5
  103. package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js.map +1 -1
  104. package/js/x-modules/facets/components/filters/slider-filter.vue.js +4 -4
  105. package/js/x-modules/facets/components/filters/slider-filter.vue.js.map +1 -1
  106. package/js/x-modules/facets/components/filters/slider-filter.vue2.js +4 -1
  107. package/js/x-modules/facets/components/filters/slider-filter.vue2.js.map +1 -1
  108. package/js/x-modules/facets/components/lists/filters-search.vue.js +2 -2
  109. package/js/x-modules/facets/components/lists/filters-search.vue.js.map +1 -1
  110. package/js/x-modules/facets/components/lists/filters-search.vue2.js +4 -1
  111. package/js/x-modules/facets/components/lists/filters-search.vue2.js.map +1 -1
  112. package/js/x-modules/history-queries/components/clear-history-queries.vue.js +2 -2
  113. package/js/x-modules/history-queries/components/clear-history-queries.vue.js.map +1 -1
  114. package/js/x-modules/history-queries/components/clear-history-queries.vue2.js +4 -1
  115. package/js/x-modules/history-queries/components/clear-history-queries.vue2.js.map +1 -1
  116. package/js/x-modules/history-queries/components/history-queries-switch.vue.js +2 -2
  117. package/js/x-modules/history-queries/components/history-queries-switch.vue.js.map +1 -1
  118. package/js/x-modules/history-queries/components/history-queries-switch.vue2.js +4 -1
  119. package/js/x-modules/history-queries/components/history-queries-switch.vue2.js.map +1 -1
  120. package/js/x-modules/history-queries/components/history-query.vue.js +2 -1
  121. package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
  122. package/js/x-modules/history-queries/components/history-query.vue2.js +4 -1
  123. package/js/x-modules/history-queries/components/history-query.vue2.js.map +1 -1
  124. package/js/x-modules/history-queries/components/remove-history-query.vue.js +2 -2
  125. package/js/x-modules/history-queries/components/remove-history-query.vue.js.map +1 -1
  126. package/js/x-modules/history-queries/components/remove-history-query.vue2.js +4 -1
  127. package/js/x-modules/history-queries/components/remove-history-query.vue2.js.map +1 -1
  128. package/js/x-modules/scroll/components/scroll-to-top.vue.js +2 -2
  129. package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
  130. package/js/x-modules/scroll/components/scroll-to-top.vue2.js +4 -1
  131. package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
  132. package/js/x-modules/search-box/components/search-input.vue.js +2 -2
  133. package/js/x-modules/search-box/components/search-input.vue.js.map +1 -1
  134. package/js/x-modules/search-box/components/search-input.vue2.js +4 -1
  135. package/js/x-modules/search-box/components/search-input.vue2.js.map +1 -1
  136. package/package.json +2 -2
  137. package/report/x-components.api.json +618 -41
  138. package/report/x-components.api.md +173 -11
  139. package/types/src/components/base-dropdown.vue.d.ts +3 -4
  140. package/types/src/components/base-dropdown.vue.d.ts.map +1 -1
  141. package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts +3 -0
  142. package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts.map +1 -1
  143. package/types/src/components/column-picker/base-column-picker-list.vue.d.ts +3 -0
  144. package/types/src/components/column-picker/base-column-picker-list.vue.d.ts.map +1 -1
  145. package/types/src/components/modals/base-events-modal-close.vue.d.ts +3 -0
  146. package/types/src/components/modals/base-events-modal-close.vue.d.ts.map +1 -1
  147. package/types/src/components/modals/base-events-modal-open.vue.d.ts +3 -0
  148. package/types/src/components/modals/base-events-modal-open.vue.d.ts.map +1 -1
  149. package/types/src/components/modals/base-modal.vue.d.ts +3 -0
  150. package/types/src/components/modals/base-modal.vue.d.ts.map +1 -1
  151. package/types/src/components/page-loader-button.vue.d.ts +3 -0
  152. package/types/src/components/page-loader-button.vue.d.ts.map +1 -1
  153. package/types/src/components/page-selector.vue.d.ts +6 -0
  154. package/types/src/components/page-selector.vue.d.ts.map +1 -1
  155. package/types/src/components/sort/sort-dropdown.vue.d.ts +3 -0
  156. package/types/src/components/sort/sort-dropdown.vue.d.ts.map +1 -1
  157. package/types/src/types/accessibility.d.ts +79 -0
  158. package/types/src/types/accessibility.d.ts.map +1 -0
  159. package/types/src/types/index.d.ts +1 -0
  160. package/types/src/types/index.d.ts.map +1 -1
  161. package/types/src/utils/accessibility.d.ts +20 -0
  162. package/types/src/utils/accessibility.d.ts.map +1 -0
  163. package/types/src/utils/index.d.ts +1 -0
  164. package/types/src/utils/index.d.ts.map +1 -1
  165. package/types/src/x-installer/x-installer.d.ts.map +1 -1
  166. package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts +4 -0
  167. package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts.map +1 -1
  168. package/types/src/x-modules/facets/components/facets/facets.vue.d.ts +3 -0
  169. package/types/src/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
  170. package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts +4 -2
  171. package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts.map +1 -1
  172. package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts +4 -0
  173. package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts.map +1 -1
  174. package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts +3 -0
  175. package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts.map +1 -1
  176. package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts +3 -0
  177. package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts.map +1 -1
  178. package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts +3 -0
  179. package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts.map +1 -1
  180. package/types/src/x-modules/history-queries/components/history-query.vue.d.ts +3 -0
  181. package/types/src/x-modules/history-queries/components/history-query.vue.d.ts.map +1 -1
  182. package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts +3 -0
  183. package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts.map +1 -1
  184. package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts +3 -0
  185. package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts.map +1 -1
  186. package/types/src/x-modules/search-box/components/search-input.vue.d.ts +3 -0
  187. package/types/src/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
@@ -1,5 +1,6 @@
1
1
  import { isBooleanFilter } from '@empathyco/x-types';
2
- import { defineComponent, ref, computed, watch, provide } from 'vue';
2
+ import { defineComponent, inject, ref, computed, watch, provide } from 'vue';
3
+ import { ACCESSIBILITY_KEY } from '../../../../types/accessibility.js';
3
4
  import { debounce } from '../../../../utils/debounce.js';
4
5
  import { normalizeString } from '../../../../utils/normalize.js';
5
6
  import { useFiltersInjection } from '../../composables/use-filters-injection.js';
@@ -38,6 +39,7 @@ var _sfc_main = defineComponent({
38
39
  },
39
40
  setup(props) {
40
41
  const renderedFilters = useFiltersInjection(props);
42
+ const { filtersSearch: ariaLabels } = inject(ACCESSIBILITY_KEY);
41
43
  const query = ref('');
42
44
  let setQueryDebounced;
43
45
  const debounceInMs = computed(() => props.debounceInMs);
@@ -90,6 +92,7 @@ var _sfc_main = defineComponent({
90
92
  query.value = '';
91
93
  };
92
94
  return {
95
+ ariaLabels,
93
96
  clearQuery,
94
97
  setQuery,
95
98
  cssClasses,
@@ -1 +1 @@
1
- {"version":3,"file":"filters-search.vue2.js","sources":["../../../../../../src/x-modules/facets/components/lists/filters-search.vue"],"sourcesContent":["<template>\n <div class=\"x-filters-search\" :class=\"cssClasses\" data-test=\"filters-search\">\n <!--\n @slot Search content. It is the content which triggers the filters sifting.\n @binding {string} query - The query to search in filters.\n @binding {Function} setQuery - The function to set the query. The query is passed as\n parameter.\n @binding {Function} clearQuery - The function to clear the query.\n -->\n <slot name=\"search\" v-bind=\"{ query, setQuery, clearQuery }\">\n <input\n :value=\"query\"\n type=\"search\"\n class=\"x-filters-search__input xds:input\"\n data-test=\"filters-search-input\"\n aria-label=\"search into the filter values\"\n @input=\"setQuery(($event?.target as HTMLInputElement)?.value)\"\n />\n </slot>\n <!--\n @slot (Required) Sifted filters content.\n @binding {Filter[]} siftedFilters - Sifted filters data.\n -->\n <slot :sifted-filters=\"siftedFilters\"></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { DebouncedFunction, VueCSSClasses } from '../../../../utils/types'\nimport { isBooleanFilter } from '@empathyco/x-types'\nimport { computed, defineComponent, provide, ref, watch } from 'vue'\nimport { debounce } from '../../../../utils/debounce'\nimport { normalizeString } from '../../../../utils/normalize'\nimport { useFiltersInjection } from '../../composables/use-filters-injection'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Renders the filters sifted with the input query.\n *\n * @public\n */\nexport default defineComponent({\n name: 'FiltersSearch',\n xModule: facetsXModule.name,\n props: {\n /**\n * The list of filters to be rendered as slots.\n *\n * @public\n */\n filters: Array as PropType<Filter[]>,\n\n /**\n * This prop is used in the `HierarchicalFilter` component and only in that case. It is necessary\n * to make the `renderedFilters` to return only the filters of each level of the hierarchy.\n *\n * @public\n */\n parentId: {\n type: String as PropType<Filter['id']>,\n required: false,\n },\n\n /** The debounce time for applying the filter sifting. */\n debounceInMs: {\n type: Number,\n default: 200,\n },\n },\n setup(props) {\n const renderedFilters = useFiltersInjection(props)\n\n const query = ref('')\n let setQueryDebounced: DebouncedFunction<[string]>\n\n const debounceInMs = computed(() => props.debounceInMs)\n\n /**\n * Set the debounce function for setting the query debounced.\n *\n * @internal\n */\n const updateSetQueryDebounced = () => {\n setQueryDebounced = debounce(queryDebounced => {\n query.value = queryDebounced\n }, props.debounceInMs)\n }\n watch(debounceInMs, updateSetQueryDebounced, { immediate: true })\n\n /**\n * Sift the array of filters which matches with the query.\n *\n * @returns Array of sifted filters.\n * @internal\n */\n const siftedFilters = computed((): Filter[] => {\n const normalizedQuery = normalizeString(query.value)\n return renderedFilters.value.filter(\n filter =>\n isBooleanFilter(filter) && normalizeString(filter.label).includes(normalizedQuery),\n )\n })\n provide('filters', siftedFilters)\n\n /**\n * Adds the dynamic css classes to the component.\n *\n * @returns The class to be added to the component.\n * @internal\n */\n const cssClasses = computed((): VueCSSClasses => {\n return { 'x-filters-search--is-sifted': !!query.value }\n })\n\n /**\n * Set the query through the debounced function.\n *\n * @param query - The query to sift filters.\n * @internal\n */\n const setQuery = (query: string): void => {\n setQueryDebounced(query)\n }\n\n /**\n * Clear the query.\n *\n * @internal\n */\n const clearQuery = (): void => {\n query.value = ''\n }\n\n return {\n clearQuery,\n setQuery,\n cssClasses,\n siftedFilters,\n query,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-filters-search {\n display: flex;\n flex-flow: column nowrap;\n}\n\n.x-filters-search__input::-ms-clear {\n display: none;\n width: 0;\n height: 0;\n}\n\n.x-filters-search__input::-ms-reveal {\n display: none;\n width: 0;\n height: 0;\n}\n\n.x-filters-search__input::-webkit-search-decoration,\n.x-filters-search__input::-webkit-search-cancel-button,\n.x-filters-search__input::-webkit-search-results-button,\n.x-filters-search__input::-webkit-search-results-decoration {\n display: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nIt renders an input and a list of filters passed as prop or being injected. The list of filters can\nbe sifted with the query typed in the input. This component has also a debounce prop to set the time\nin milliseconds to apply the filters search. Moreover, it has two scoped slots. The first one for\ncustomize the search triggering with three slot props; the query, a function to set the query by\nsifting and a third one for cleaning the query. The second scoped slot is required and it is for\ndisplaying the list of filters sifted. It has a slot prop with these filters sifted.\n\n### Important\n\nThe component has two ways of receive the filters list, it can be injected by another component or\nbe send it as a prop. If the component doesnt have a parent component that receive and exposed a\nfilters list to their children, it is mandatory to send it as prop.\n\n### Basic usage\n\nUsing default and required slot:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\" v-slot=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\nSetting debounce time:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\" :debounceInMs=\"500\" v-slot=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\nReplacing search triggering:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\">\n <template #search=\"{ query, setQuery, clearQuery }\">\n <input\n @input=\"setQuery($event.target.value)\"\n :value=\"query\"\n class=\"x-input x-filters-search__input\"\n :aria-label=\"filtersSearchInputMessage\"\n />\n <button @click=\"clearQuery\">X</button>\n </template>\n <template #default=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </template>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\n> **Using injection**: It can receive the filters list by injection. It only works if it has a\n> parent component that receives and exposes the filters list. Using the injection, It is not\n> necessary to send the prop to the child components, it has to be send it in the parent component,\n> the rest of components will inject this list.\n\n```vue\n<template>\n <Facets v-slot=\"{ facet }\">\n <SlicedFilters :filters=\"facet.filters\" :max=\"8\">\n <FiltersSearch>\n <Filters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" data-test=\"brand-filter\" />\n </Filters>\n </FiltersSearch>\n </SlicedFilters>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\nimport { SlicedFilters, FiltersSearch, Filters, SimpleFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst facet = ref({\n filters: [\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n ],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;AAsCA;;;;AAIE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,OAAO,EAAE,KAA2B;AAEpC;;;;;AAKE;AACF,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,MAAgC;AACtC,YAAA,QAAQ,EAAE,KAAK;AAChB,SAAA;;AAGD,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,GAAG;AACb,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,eAAc,GAAI,mBAAmB,CAAC,KAAK,CAAA;AAEjD,QAAA,MAAM,KAAI,GAAI,GAAG,CAAC,EAAE,CAAA;AACpB,QAAA,IAAI,iBAA6C;QAEjD,MAAM,YAAW,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,YAAY,CAAA;AAEtD;;;;AAIE;QACF,MAAM,uBAAsB,GAAI,MAAI;AAClC,YAAA,iBAAgB,GAAI,QAAQ,CAAC,cAAa,IAAG;AAC3C,gBAAA,KAAK,CAAC,KAAI,GAAI,cAAa;AAC7B,YAAA,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;AACvB,QAAA,CAAA;QACA,KAAK,CAAC,YAAY,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAG,EAAG,CAAA;AAEhE;;;;;AAKE;AACF,QAAA,MAAM,gBAAgB,QAAQ,CAAC,MAAc;YAC3C,MAAM,eAAc,GAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAA;YACnD,OAAO,eAAe,CAAC,KAAK,CAAC,MAAM,CACjC,UACE,eAAe,CAAC,MAAM,CAAA,IAAK,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CACtF;AACF,QAAA,CAAC,CAAA;AACD,QAAA,OAAO,CAAC,SAAS,EAAE,aAAa,CAAA;AAEhC;;;;;AAKE;AACF,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,MAAmB;YAC7C,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC,KAAK,CAAC,KAAI,EAAE;AACxD,QAAA,CAAC,CAAA;AAED;;;;;AAKE;AACF,QAAA,MAAM,QAAO,GAAI,CAAC,KAAa,KAAS;YACtC,iBAAiB,CAAC,KAAK,CAAA;AACzB,QAAA,CAAA;AAEA;;;;AAIE;QACF,MAAM,UAAS,GAAI,MAAU;AAC3B,YAAA,KAAK,CAAC,KAAI,GAAI,EAAC;AACjB,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,QAAQ;YACR,UAAU;YACV,aAAa;YACb,KAAK;SACP;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"filters-search.vue2.js","sources":["../../../../../../src/x-modules/facets/components/lists/filters-search.vue"],"sourcesContent":["<template>\n <div class=\"x-filters-search\" :class=\"cssClasses\" data-test=\"filters-search\">\n <!--\n @slot Search content. It is the content which triggers the filters sifting.\n @binding {string} query - The query to search in filters.\n @binding {Function} setQuery - The function to set the query. The query is passed as\n parameter.\n @binding {Function} clearQuery - The function to clear the query.\n -->\n <slot name=\"search\" v-bind=\"{ query, setQuery, clearQuery }\">\n <input\n :value=\"query\"\n type=\"search\"\n class=\"x-filters-search__input xds:input\"\n data-test=\"filters-search-input\"\n :aria-label=\"ariaLabels?.input\"\n @input=\"setQuery(($event?.target as HTMLInputElement)?.value)\"\n />\n </slot>\n <!--\n @slot (Required) Sifted filters content.\n @binding {Filter[]} siftedFilters - Sifted filters data.\n -->\n <slot :sifted-filters=\"siftedFilters\"></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Filter } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../../../types'\nimport type { DebouncedFunction, VueCSSClasses } from '../../../../utils/types'\nimport { isBooleanFilter } from '@empathyco/x-types'\nimport { computed, defineComponent, inject, provide, ref, watch } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../../../../types'\nimport { debounce } from '../../../../utils/debounce'\nimport { normalizeString } from '../../../../utils/normalize'\nimport { useFiltersInjection } from '../../composables/use-filters-injection'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Renders the filters sifted with the input query.\n *\n * @public\n */\nexport default defineComponent({\n name: 'FiltersSearch',\n xModule: facetsXModule.name,\n props: {\n /**\n * The list of filters to be rendered as slots.\n *\n * @public\n */\n filters: Array as PropType<Filter[]>,\n\n /**\n * This prop is used in the `HierarchicalFilter` component and only in that case. It is necessary\n * to make the `renderedFilters` to return only the filters of each level of the hierarchy.\n *\n * @public\n */\n parentId: {\n type: String as PropType<Filter['id']>,\n required: false,\n },\n\n /** The debounce time for applying the filter sifting. */\n debounceInMs: {\n type: Number,\n default: 200,\n },\n },\n setup(props) {\n const renderedFilters = useFiltersInjection(props)\n\n const { filtersSearch: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const query = ref('')\n let setQueryDebounced: DebouncedFunction<[string]>\n\n const debounceInMs = computed(() => props.debounceInMs)\n\n /**\n * Set the debounce function for setting the query debounced.\n *\n * @internal\n */\n const updateSetQueryDebounced = () => {\n setQueryDebounced = debounce(queryDebounced => {\n query.value = queryDebounced\n }, props.debounceInMs)\n }\n watch(debounceInMs, updateSetQueryDebounced, { immediate: true })\n\n /**\n * Sift the array of filters which matches with the query.\n *\n * @returns Array of sifted filters.\n * @internal\n */\n const siftedFilters = computed((): Filter[] => {\n const normalizedQuery = normalizeString(query.value)\n return renderedFilters.value.filter(\n filter =>\n isBooleanFilter(filter) && normalizeString(filter.label).includes(normalizedQuery),\n )\n })\n provide('filters', siftedFilters)\n\n /**\n * Adds the dynamic css classes to the component.\n *\n * @returns The class to be added to the component.\n * @internal\n */\n const cssClasses = computed((): VueCSSClasses => {\n return { 'x-filters-search--is-sifted': !!query.value }\n })\n\n /**\n * Set the query through the debounced function.\n *\n * @param query - The query to sift filters.\n * @internal\n */\n const setQuery = (query: string): void => {\n setQueryDebounced(query)\n }\n\n /**\n * Clear the query.\n *\n * @internal\n */\n const clearQuery = (): void => {\n query.value = ''\n }\n\n return {\n ariaLabels,\n clearQuery,\n setQuery,\n cssClasses,\n siftedFilters,\n query,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-filters-search {\n display: flex;\n flex-flow: column nowrap;\n}\n\n.x-filters-search__input::-ms-clear {\n display: none;\n width: 0;\n height: 0;\n}\n\n.x-filters-search__input::-ms-reveal {\n display: none;\n width: 0;\n height: 0;\n}\n\n.x-filters-search__input::-webkit-search-decoration,\n.x-filters-search__input::-webkit-search-cancel-button,\n.x-filters-search__input::-webkit-search-results-button,\n.x-filters-search__input::-webkit-search-results-decoration {\n display: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nIt renders an input and a list of filters passed as prop or being injected. The list of filters can\nbe sifted with the query typed in the input. This component has also a debounce prop to set the time\nin milliseconds to apply the filters search. Moreover, it has two scoped slots. The first one for\ncustomize the search triggering with three slot props; the query, a function to set the query by\nsifting and a third one for cleaning the query. The second scoped slot is required and it is for\ndisplaying the list of filters sifted. It has a slot prop with these filters sifted.\n\n### Important\n\nThe component has two ways of receive the filters list, it can be injected by another component or\nbe send it as a prop. If the component doesnt have a parent component that receive and exposed a\nfilters list to their children, it is mandatory to send it as prop.\n\n### Basic usage\n\nUsing default and required slot:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\" v-slot=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\nSetting debounce time:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\" :debounceInMs=\"500\" v-slot=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\nReplacing search triggering:\n\n```vue\n<template>\n <FiltersSearch :filters=\"filters\">\n <template #search=\"{ query, setQuery, clearQuery }\">\n <input\n @input=\"setQuery($event.target.value)\"\n :value=\"query\"\n class=\"x-input x-filters-search__input\"\n :aria-label=\"filtersSearchInputMessage\"\n />\n <button @click=\"clearQuery\">X</button>\n </template>\n <template #default=\"{ siftedFilters }\">\n <ul v-for=\"filter in siftedFilters\">\n <li :key=\"filter.id\">{{ filter.label }}</li>\n </ul>\n </template>\n </FiltersSearch>\n</template>\n\n<script setup>\nimport { FiltersSearch } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst filters = ref([\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n])\n</script>\n```\n\n> **Using injection**: It can receive the filters list by injection. It only works if it has a\n> parent component that receives and exposes the filters list. Using the injection, It is not\n> necessary to send the prop to the child components, it has to be send it in the parent component,\n> the rest of components will inject this list.\n\n```vue\n<template>\n <Facets v-slot=\"{ facet }\">\n <SlicedFilters :filters=\"facet.filters\" :max=\"8\">\n <FiltersSearch>\n <Filters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" data-test=\"brand-filter\" />\n </Filters>\n </FiltersSearch>\n </SlicedFilters>\n </Facets>\n</template>\n\n<script setup>\nimport { Facets } from '@empathyco/x-components/facets'\nimport { SlicedFilters, FiltersSearch, Filters, SimpleFilter } from '@empathyco/x-components/facets'\nimport { ref } from 'vue'\n\nconst facet = ref({\n filters: [\n { id: '1', label: 'Filter 1', modelName: 'SimpleFilter', selected: false },\n { id: '2', label: 'Filter 2', modelName: 'SimpleFilter', selected: false },\n ],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AAwCA;;;;AAIE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,OAAO,EAAE,KAA2B;AAEpC;;;;;AAKE;AACF,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,MAAgC;AACtC,YAAA,QAAQ,EAAE,KAAK;AAChB,SAAA;;AAGD,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,GAAG;AACb,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,eAAc,GAAI,mBAAmB,CAAC,KAAK,CAAA;QAEjD,MAAM,EAAE,aAAa,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAE5E,QAAA,MAAM,KAAI,GAAI,GAAG,CAAC,EAAE,CAAA;AACpB,QAAA,IAAI,iBAA6C;QAEjD,MAAM,YAAW,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,YAAY,CAAA;AAEtD;;;;AAIE;QACF,MAAM,uBAAsB,GAAI,MAAI;AAClC,YAAA,iBAAgB,GAAI,QAAQ,CAAC,cAAa,IAAG;AAC3C,gBAAA,KAAK,CAAC,KAAI,GAAI,cAAa;AAC7B,YAAA,CAAC,EAAE,KAAK,CAAC,YAAY,CAAA;AACvB,QAAA,CAAA;QACA,KAAK,CAAC,YAAY,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAG,EAAG,CAAA;AAEhE;;;;;AAKE;AACF,QAAA,MAAM,gBAAgB,QAAQ,CAAC,MAAc;YAC3C,MAAM,eAAc,GAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAA;YACnD,OAAO,eAAe,CAAC,KAAK,CAAC,MAAM,CACjC,UACE,eAAe,CAAC,MAAM,CAAA,IAAK,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CACtF;AACF,QAAA,CAAC,CAAA;AACD,QAAA,OAAO,CAAC,SAAS,EAAE,aAAa,CAAA;AAEhC;;;;;AAKE;AACF,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,MAAmB;YAC7C,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC,KAAK,CAAC,KAAI,EAAE;AACxD,QAAA,CAAC,CAAA;AAED;;;;;AAKE;AACF,QAAA,MAAM,QAAO,GAAI,CAAC,KAAa,KAAS;YACtC,iBAAiB,CAAC,KAAK,CAAA;AACzB,QAAA,CAAA;AAEA;;;;AAIE;QACF,MAAM,UAAS,GAAI,MAAU;AAC3B,YAAA,KAAK,CAAC,KAAI,GAAI,EAAC;AACjB,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,UAAU;YACV,QAAQ;YACR,UAAU;YACV,aAAa;YACb,KAAK;SACP;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -9,7 +9,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9
9
  disabled: _ctx.isHistoryQueriesEmpty,
10
10
  events: _ctx.clearHistoryQueriesEvents,
11
11
  "data-test": "clear-history-queries",
12
- "aria-label": "Clear all"
12
+ "aria-label": _ctx.ariaLabels?.button
13
13
  }, {
14
14
  default: withCtx(() => [
15
15
  renderSlot(_ctx.$slots, "default", {}, () => [
@@ -22,7 +22,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
22
22
  ]),
23
23
  _: 3
24
24
  /* FORWARDED */
25
- }, 8, ["class", "disabled", "events"]);
25
+ }, 8, ["class", "disabled", "events", "aria-label"]);
26
26
  }
27
27
  var clearHistoryQueries = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
28
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"clear-history-queries.vue.js","sources":["../../../../../src/x-modules/history-queries/components/clear-history-queries.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-clear-history-queries xds:button\"\n :class=\"dynamicClasses\"\n :disabled=\"isHistoryQueriesEmpty\"\n :events=\"clearHistoryQueriesEvents\"\n data-test=\"clear-history-queries\"\n aria-label=\"Clear all\"\n >\n <!-- @slot (Required) Button content with a message, an icon or both -->\n <slot>✕</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { VueCSSClasses } from '../../../utils/types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useState } from '../../../composables/use-state'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * A button that when is pressed, emits the\n * {@link HistoryQueriesXEvents.UserPressedClearHistoryQueries} event, expressing the user\n * intention to clear the whole history of queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ClearHistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n setup() {\n /**\n * The whole history queries.\n *\n * @internal\n */\n const { historyQueries } = useState('historyQueries')\n\n /**\n * Returns if the array of history queries is empty.\n *\n * @returns `true` if the {@link historyQueries} array is empty, `false` otherwise.\n * @internal\n */\n const isHistoryQueriesEmpty = computed(() => historyQueries.value.length === 0)\n\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add, and the boolean value\n * tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed(\n (): VueCSSClasses => ({\n 'x-clear-history-queries--is-empty': isHistoryQueriesEmpty.value,\n }),\n )\n\n /**\n * The list of events that are going to be emitted when the button is pressed.\n *\n * @internal\n */\n const clearHistoryQueriesEvents: Partial<XEventsTypes> = {\n UserPressedClearHistoryQueries: undefined,\n }\n\n return {\n dynamicClasses,\n clearHistoryQueriesEvents,\n isHistoryQueriesEmpty,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedClearHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button.\n\n## Examples\n\n### Basic example\n\nThe component exposes a single default slot, where you can add icons or text.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ClearHistoryQueries>Clear history queries</ClearHistoryQueries>\n <HistoryQueries :animation=\"animation\" :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script setup>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, ClearHistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\nconst animation = FadeAndSlide\n</script>\n```\n</docs>\n"],"names":["_createBlock","_normalizeClass","_renderSlot","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CAUkB,0BAAA,EAAA;AAAA,IAThB,KAAA,EAAKC,cAAA,CAAA,CAAC,oCAAA,EACE,IAAA,CAAA,cAAc,CAAA,CAAA;AAAA,IACrB,QAAA,EAAU,IAAA,CAAA,qBAAA;AAAA,IACV,MAAA,EAAQ,IAAA,CAAA,yBAAA;AAAA,IACT,WAAA,EAAU,uBAAA;AAAA,IACV,YAAA,EAAW;AAAA,GAAA,EAAA;qBAGX,MAAc;AAAA,MAAdC,UAAA,CAAc,4BAAd,MAAc;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAR,UAAA,GAAA;AAAA,UAAC;AAAA;AAAA,SAAA;AAAA,OAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"clear-history-queries.vue.js","sources":["../../../../../src/x-modules/history-queries/components/clear-history-queries.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-clear-history-queries xds:button\"\n :class=\"dynamicClasses\"\n :disabled=\"isHistoryQueriesEmpty\"\n :events=\"clearHistoryQueriesEvents\"\n data-test=\"clear-history-queries\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a message, an icon or both -->\n <slot>✕</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { AriaLabels } from '../../../types'\nimport type { VueCSSClasses } from '../../../utils/types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useState } from '../../../composables/use-state'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * A button that when is pressed, emits the\n * {@link HistoryQueriesXEvents.UserPressedClearHistoryQueries} event, expressing the user\n * intention to clear the whole history of queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ClearHistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n setup() {\n const { clearHistoryQueries: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The whole history queries.\n *\n * @internal\n */\n const { historyQueries } = useState('historyQueries')\n\n /**\n * Returns if the array of history queries is empty.\n *\n * @returns `true` if the {@link historyQueries} array is empty, `false` otherwise.\n * @internal\n */\n const isHistoryQueriesEmpty = computed(() => historyQueries.value.length === 0)\n\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add, and the boolean value\n * tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed(\n (): VueCSSClasses => ({\n 'x-clear-history-queries--is-empty': isHistoryQueriesEmpty.value,\n }),\n )\n\n /**\n * The list of events that are going to be emitted when the button is pressed.\n *\n * @internal\n */\n const clearHistoryQueriesEvents: Partial<XEventsTypes> = {\n UserPressedClearHistoryQueries: undefined,\n }\n\n return {\n ariaLabels,\n dynamicClasses,\n clearHistoryQueriesEvents,\n isHistoryQueriesEmpty,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedClearHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button.\n\n## Examples\n\n### Basic example\n\nThe component exposes a single default slot, where you can add icons or text.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ClearHistoryQueries>Clear history queries</ClearHistoryQueries>\n <HistoryQueries :animation=\"animation\" :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script setup>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, ClearHistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\nconst animation = FadeAndSlide\n</script>\n```\n</docs>\n"],"names":["_createBlock","_normalizeClass","_renderSlot","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CAUkB,0BAAA,EAAA;AAAA,IAThB,KAAA,EAAKC,cAAA,CAAA,CAAC,oCAAA,EACE,IAAA,CAAA,cAAc,CAAA,CAAA;AAAA,IACrB,QAAA,EAAU,IAAA,CAAA,qBAAA;AAAA,IACV,MAAA,EAAQ,IAAA,CAAA,yBAAA;AAAA,IACT,WAAA,EAAU,uBAAA;AAAA,IACT,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;qBAGzB,MAAc;AAAA,MAAdC,UAAA,CAAc,4BAAd,MAAc;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAR,UAAA,GAAA;AAAA,UAAC;AAAA;AAAA,SAAA;AAAA,OAAA;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, inject, computed } from 'vue';
2
2
  import BaseEventButton from '../../../components/base-event-button.vue.js';
3
3
  import { useState } from '../../../composables/use-state.js';
4
+ import { ACCESSIBILITY_KEY } from '../../../types/accessibility.js';
4
5
  import { historyQueriesXModule } from '../x-module.js';
5
6
 
6
7
  /**
@@ -17,6 +18,7 @@ var _sfc_main = defineComponent({
17
18
  BaseEventButton,
18
19
  },
19
20
  setup() {
21
+ const { clearHistoryQueries: ariaLabels } = inject(ACCESSIBILITY_KEY);
20
22
  /**
21
23
  * The whole history queries.
22
24
  *
@@ -49,6 +51,7 @@ var _sfc_main = defineComponent({
49
51
  UserPressedClearHistoryQueries: undefined,
50
52
  };
51
53
  return {
54
+ ariaLabels,
52
55
  dynamicClasses,
53
56
  clearHistoryQueriesEvents,
54
57
  isHistoryQueriesEmpty,
@@ -1 +1 @@
1
- {"version":3,"file":"clear-history-queries.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/clear-history-queries.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-clear-history-queries xds:button\"\n :class=\"dynamicClasses\"\n :disabled=\"isHistoryQueriesEmpty\"\n :events=\"clearHistoryQueriesEvents\"\n data-test=\"clear-history-queries\"\n aria-label=\"Clear all\"\n >\n <!-- @slot (Required) Button content with a message, an icon or both -->\n <slot>✕</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { VueCSSClasses } from '../../../utils/types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useState } from '../../../composables/use-state'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * A button that when is pressed, emits the\n * {@link HistoryQueriesXEvents.UserPressedClearHistoryQueries} event, expressing the user\n * intention to clear the whole history of queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ClearHistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n setup() {\n /**\n * The whole history queries.\n *\n * @internal\n */\n const { historyQueries } = useState('historyQueries')\n\n /**\n * Returns if the array of history queries is empty.\n *\n * @returns `true` if the {@link historyQueries} array is empty, `false` otherwise.\n * @internal\n */\n const isHistoryQueriesEmpty = computed(() => historyQueries.value.length === 0)\n\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add, and the boolean value\n * tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed(\n (): VueCSSClasses => ({\n 'x-clear-history-queries--is-empty': isHistoryQueriesEmpty.value,\n }),\n )\n\n /**\n * The list of events that are going to be emitted when the button is pressed.\n *\n * @internal\n */\n const clearHistoryQueriesEvents: Partial<XEventsTypes> = {\n UserPressedClearHistoryQueries: undefined,\n }\n\n return {\n dynamicClasses,\n clearHistoryQueriesEvents,\n isHistoryQueriesEmpty,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedClearHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button.\n\n## Examples\n\n### Basic example\n\nThe component exposes a single default slot, where you can add icons or text.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ClearHistoryQueries>Clear history queries</ClearHistoryQueries>\n <HistoryQueries :animation=\"animation\" :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script setup>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, ClearHistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\nconst animation = FadeAndSlide\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAsBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;IACD,KAAK,GAAA;AACH;;;;AAIE;QACF,MAAM,EAAE,cAAa,KAAM,QAAQ,CAAC,gBAAgB,CAAA;AAEpD;;;;;AAKE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,MAAK,KAAM,CAAC,CAAA;AAE9E;;;;;;AAME;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAC7B,OAAsB;YACpB,mCAAmC,EAAE,qBAAqB,CAAC,KAAK;AACjE,SAAA,CAAC,CACJ;AAEA;;;;AAIE;AACF,QAAA,MAAM,yBAAyB,GAA0B;AACvD,YAAA,8BAA8B,EAAE,SAAS;SAC3C;QAEA,OAAO;YACL,cAAc;YACd,yBAAyB;YACzB,qBAAqB;SACvB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"clear-history-queries.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/clear-history-queries.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-clear-history-queries xds:button\"\n :class=\"dynamicClasses\"\n :disabled=\"isHistoryQueriesEmpty\"\n :events=\"clearHistoryQueriesEvents\"\n data-test=\"clear-history-queries\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a message, an icon or both -->\n <slot>✕</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { AriaLabels } from '../../../types'\nimport type { VueCSSClasses } from '../../../utils/types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useState } from '../../../composables/use-state'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * A button that when is pressed, emits the\n * {@link HistoryQueriesXEvents.UserPressedClearHistoryQueries} event, expressing the user\n * intention to clear the whole history of queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ClearHistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n setup() {\n const { clearHistoryQueries: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The whole history queries.\n *\n * @internal\n */\n const { historyQueries } = useState('historyQueries')\n\n /**\n * Returns if the array of history queries is empty.\n *\n * @returns `true` if the {@link historyQueries} array is empty, `false` otherwise.\n * @internal\n */\n const isHistoryQueriesEmpty = computed(() => historyQueries.value.length === 0)\n\n /**\n * Dynamic CSS classes to add to the root element of this component.\n *\n * @returns A booleans dictionary where each key is the class name to add, and the boolean value\n * tells if it should be added or not.\n * @internal\n */\n const dynamicClasses = computed(\n (): VueCSSClasses => ({\n 'x-clear-history-queries--is-empty': isHistoryQueriesEmpty.value,\n }),\n )\n\n /**\n * The list of events that are going to be emitted when the button is pressed.\n *\n * @internal\n */\n const clearHistoryQueriesEvents: Partial<XEventsTypes> = {\n UserPressedClearHistoryQueries: undefined,\n }\n\n return {\n ariaLabels,\n dynamicClasses,\n clearHistoryQueriesEvents,\n isHistoryQueriesEmpty,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedClearHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button.\n\n## Examples\n\n### Basic example\n\nThe component exposes a single default slot, where you can add icons or text.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ClearHistoryQueries>Clear history queries</ClearHistoryQueries>\n <HistoryQueries :animation=\"animation\" :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script setup>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, ClearHistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\nconst animation = FadeAndSlide\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAwBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;IACD,KAAK,GAAA;QACH,MAAM,EAAE,mBAAmB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAElF;;;;AAIE;QACF,MAAM,EAAE,cAAa,KAAM,QAAQ,CAAC,gBAAgB,CAAA;AAEpD;;;;;AAKE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,MAAK,KAAM,CAAC,CAAA;AAE9E;;;;;;AAME;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAC7B,OAAsB;YACpB,mCAAmC,EAAE,qBAAqB,CAAC,KAAK;AACjE,SAAA,CAAC,CACJ;AAEA;;;;AAIE;AACF,QAAA,MAAM,yBAAyB,GAA0B;AACvD,YAAA,8BAA8B,EAAE,SAAS;SAC3C;QAEA,OAAO;YACL,UAAU;YACV,cAAc;YACd,yBAAyB;YACzB,qBAAqB;SACvB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -6,9 +6,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
6
6
  const _component_BaseSwitch = resolveComponent("BaseSwitch");
7
7
  return openBlock(), createBlock(_component_BaseSwitch, {
8
8
  "model-value": _ctx.isEnabled,
9
- "aria-label": "Queries' history",
9
+ "aria-label": _ctx.ariaLabels?.root,
10
10
  "onUpdate:modelValue": _ctx.toggle
11
- }, null, 8, ["model-value", "onUpdate:modelValue"]);
11
+ }, null, 8, ["model-value", "aria-label", "onUpdate:modelValue"]);
12
12
  }
13
13
  var historyQueriesSwitch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
14
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"history-queries-switch.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch :model-value=\"isEnabled\" aria-label=\"Queries' history\" @update:model-value=\"toggle\" />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAAkG,qBAAA,EAAA;AAAA,IAArF,aAAA,EAAa,IAAA,CAAA,SAAA;AAAA,IAAW,YAAA,EAAW,kBAAA;AAAA,IAAoB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,aAAA,EAAA,qBAAA,CAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"history-queries-switch.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch\n :model-value=\"isEnabled\"\n :aria-label=\"ariaLabels?.root\"\n @update:model-value=\"toggle\"\n />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { AriaLabels } from '../../../types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const { historyQueriesSwitch: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n ariaLabels,\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAIE,qBAAA,EAAA;AAAA,IAHC,aAAA,EAAa,IAAA,CAAA,SAAA;AAAA,IACb,cAAY,IAAA,CAAA,UAAA,EAAY,IAAA;AAAA,IACxB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,aAAA,EAAA,YAAA,EAAA,qBAAA,CAAA,CAAA;;;;;;"}
@@ -1,7 +1,8 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, inject, computed } from 'vue';
2
2
  import BaseSwitch from '../../../components/base-switch.vue.js';
3
3
  import { use$x } from '../../../composables/use-_x.js';
4
4
  import { useState } from '../../../composables/use-state.js';
5
+ import { ACCESSIBILITY_KEY } from '../../../types/accessibility.js';
5
6
  import { isArrayEmpty } from '../../../utils/array.js';
6
7
  import { historyQueriesXModule } from '../x-module.js';
7
8
 
@@ -18,6 +19,7 @@ var _sfc_main = defineComponent({
18
19
  BaseSwitch,
19
20
  },
20
21
  setup() {
22
+ const { historyQueriesSwitch: ariaLabels } = inject(ACCESSIBILITY_KEY);
21
23
  const $x = use$x();
22
24
  /**
23
25
  * An object with the isEnabled value and the history queries coming from the store state.
@@ -43,6 +45,7 @@ var _sfc_main = defineComponent({
43
45
  $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries');
44
46
  };
45
47
  return {
48
+ ariaLabels,
46
49
  toggle,
47
50
  isEnabled,
48
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"history-queries-switch.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch :model-value=\"isEnabled\" aria-label=\"Queries' history\" @update:model-value=\"toggle\" />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;AAaA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,UAAU;AACX,KAAA;IACD,KAAK,GAAA;AACH,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;AAIE;QACF,MAAM,EAAE,SAAS,EAAE,cAAa,EAAE,GAAI,QAAQ,CAAC,gBAAgB,CAAA;AAE/D;;;;AAIE;AACF,QAAA,MAAM,iBAAgB,GAAI,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,KAAuB,CAAC,CAAA;QAE9F,MAAM,YAAW,GAAI,QAAQ,CAAC,MAC5B,iBAAiB,CAAC;AAChB,cAAE;cACA,yCAAyC,CAC/C;AAEA;;;;AAIE;QACF,MAAM,SAAS,MAAU;AACvB,YAAA,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAI,GAAI,YAAY,CAAC,KAAI,GAAI,iCAAiC,CAAA;AAClF,QAAA,CAAA;QAEA,OAAO;YACL,MAAM;YACN,SAAS;SACX;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"history-queries-switch.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch\n :model-value=\"isEnabled\"\n :aria-label=\"ariaLabels?.root\"\n @update:model-value=\"toggle\"\n />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { AriaLabels } from '../../../types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const { historyQueriesSwitch: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n ariaLabels,\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AAmBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,UAAU;AACX,KAAA;IACD,KAAK,GAAA;QACH,MAAM,EAAE,oBAAoB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAEnF,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;AAIE;QACF,MAAM,EAAE,SAAS,EAAE,cAAa,EAAE,GAAI,QAAQ,CAAC,gBAAgB,CAAA;AAE/D;;;;AAIE;AACF,QAAA,MAAM,iBAAgB,GAAI,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,KAAuB,CAAC,CAAA;QAE9F,MAAM,YAAW,GAAI,QAAQ,CAAC,MAC5B,iBAAiB,CAAC;AAChB,cAAE;cACA,yCAAyC,CAC/C;AAEA;;;;AAIE;QACF,MAAM,SAAS,MAAU;AACvB,YAAA,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAI,GAAI,YAAY,CAAC,KAAI,GAAI,iCAAiC,CAAA;AAClF,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,MAAM;YACN,SAAS;SACX;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -23,6 +23,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
23
23
  createVNode(_component_RemoveHistoryQuery, {
24
24
  class: normalizeClass(["x-history-query__remove xds:suggestion-group-button", _ctx.removeButtonClass]),
25
25
  "history-query": _ctx.suggestion,
26
+ "aria-label": _ctx.ariaLabels?.removeButton,
26
27
  "data-test": "remove-history-query"
27
28
  }, {
28
29
  default: withCtx(() => [
@@ -36,7 +37,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
36
37
  ]),
37
38
  _: 3
38
39
  /* FORWARDED */
39
- }, 8, ["class", "history-query"])
40
+ }, 8, ["class", "history-query", "aria-label"])
40
41
  ]);
41
42
  }
42
43
  var HistoryQuery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
@@ -1 +1 @@
1
- {"version":3,"file":"history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeClass","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;AACO,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,sCAAA,EAAsC;;;;AAAjD,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAoCM,OApCN,UAAA,EAoCM;AAAA,IA7BJC,WAAA,CAgBiB,2BAhBjBC,UAAA,CAgBiB;AAAA,MAdf,KAAA,EAAK,CAAC,6BAAA,EACE,IAAA,CAAA,eAAe;AAAA,KAAA,EAAA,EAAA,UAAA,EACb,IAAA,CAAA,UAAA,EAAU,wBAAA,EAAE,IAAA,CAAA,wBAAA,EAAwB,KAAA,EAAE,IAAA,CAAA,KAAA,EAAK,EAAA;AAAA,MACrD,WAAA,EAAU,eAAA;AAAA,MACV,OAAA,EAAQ,eAAA;AAAA,MACP,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,KAAA,CAAK,OAAA,EAAU,iBAAY,MAAM,CAAA;AAAA,KAAA,CAAA,EAAA;AAQzC,MAAA,OAAA,EAAAC,OAAA,CAAA,CAAkC,SAAA,KAdjB;AAAA,QAcjBC,UAAA,CAAkC,+DAAf,SAAA,EAAS,CAAA,CAAA;AAAA,OAAA,CAAA;;;;IAE9BH,WAAA,CAWqB,6BAAA,EAAA;AAAA,MAVnB,KAAA,EAAKI,cAAA,CAAA,CAAC,qDAAA,EACE,IAAA,CAAA,iBAAiB,CAAA,CAAA;AAAA,MACxB,eAAA,EAAe,IAAA,CAAA,UAAA;AAAA,MAChB,WAAA,EAAU;AAAA,KAAA,EAAA;uBAMV,MAAmE;AAAA,QAAnED,UAAA,CAAmE,IAAA,CAAA,MAAA,EAAA,uBAAA,EAAAE,cAAA,CAAAC,kBAAA,CAAA,EAAA,UAAA,EAAtB,IAAA,CAAA,UAAA,EAAU,CAAA,CAAA,EAAvD,MAAmE;AAAA,UAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAR,YAAA,GAAA;AAAA,YAAC;AAAA;AAAA,WAAA;AAAA,SAAA;;;;;;;;;;;"}
1
+ {"version":3,"file":"history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n :aria-label=\"ariaLabels?.removeButton\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../../types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n const { historyQuery: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n ariaLabels,\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeClass","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;AACO,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,sCAAA,EAAsC;;;;AAAjD,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAqCM,OArCN,UAAA,EAqCM;AAAA,IA9BJC,WAAA,CAgBiB,2BAhBjBC,UAAA,CAgBiB;AAAA,MAdf,KAAA,EAAK,CAAC,6BAAA,EACE,IAAA,CAAA,eAAe;AAAA,KAAA,EAAA,EAAA,UAAA,EACb,IAAA,CAAA,UAAA,EAAU,wBAAA,EAAE,IAAA,CAAA,wBAAA,EAAwB,KAAA,EAAE,IAAA,CAAA,KAAA,EAAK,EAAA;AAAA,MACrD,WAAA,EAAU,eAAA;AAAA,MACV,OAAA,EAAQ,eAAA;AAAA,MACP,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,KAAA,CAAK,OAAA,EAAU,iBAAY,MAAM,CAAA;AAAA,KAAA,CAAA,EAAA;AAQzC,MAAA,OAAA,EAAAC,OAAA,CAAA,CAAkC,SAAA,KAdjB;AAAA,QAcjBC,UAAA,CAAkC,+DAAf,SAAA,EAAS,CAAA,CAAA;AAAA,OAAA,CAAA;;;;IAE9BH,WAAA,CAYqB,6BAAA,EAAA;AAAA,MAXnB,KAAA,EAAKI,cAAA,CAAA,CAAC,qDAAA,EACE,IAAA,CAAA,iBAAiB,CAAA,CAAA;AAAA,MACxB,eAAA,EAAe,IAAA,CAAA,UAAA;AAAA,MACf,cAAY,IAAA,CAAA,UAAA,EAAY,YAAA;AAAA,MACzB,WAAA,EAAU;AAAA,KAAA,EAAA;uBAMV,MAAmE;AAAA,QAAnED,UAAA,CAAmE,IAAA,CAAA,MAAA,EAAA,uBAAA,EAAAE,cAAA,CAAAC,kBAAA,CAAA,EAAA,UAAA,EAAtB,IAAA,CAAA,UAAA,EAAU,CAAA,CAAA,EAAvD,MAAmE;AAAA,UAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAR,YAAA,GAAA;AAAA,YAAC;AAAA;AAAA,WAAA;AAAA,SAAA;;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, inject, computed } from 'vue';
2
2
  import BaseSuggestion from '../../../components/suggestions/base-suggestion.vue.js';
3
3
  import { useGetter } from '../../../composables/use-getter.js';
4
+ import { ACCESSIBILITY_KEY } from '../../../types/accessibility.js';
4
5
  import { historyQueriesXModule } from '../x-module.js';
5
6
  import RemoveHistoryQuery from './remove-history-query.vue.js';
6
7
 
@@ -32,6 +33,7 @@ var _sfc_main = defineComponent({
32
33
  },
33
34
  emits: ['click'],
34
35
  setup(props) {
36
+ const { historyQuery: ariaLabels } = inject(ACCESSIBILITY_KEY);
35
37
  /**
36
38
  * The normalized query of the history-queries module.
37
39
  *
@@ -48,6 +50,7 @@ var _sfc_main = defineComponent({
48
50
  UserSelectedAHistoryQuery: props.suggestion,
49
51
  }));
50
52
  return {
53
+ ariaLabels,
51
54
  query,
52
55
  suggestionSelectedEvents,
53
56
  };
@@ -1 +1 @@
1
- {"version":3,"file":"history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAkDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,EAAE,kBAAkB,EAAE,gBAAgB;AAClD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,eAAe,EAAE,MAAM;AACxB,KAAA;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;AAChB,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,KAAI,GAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,eAAc;AAExD;;;;;AAKE;AACF,QAAA,MAAM,wBAAuB,GAAI,QAAQ,CACvC,OAA8B;YAC5B,yBAAyB,EAAE,KAAK,CAAC,UAAU;AAC5C,SAAA,CAAC,CACJ;QAEA,OAAO;YACL,KAAK;YACL,wBAAwB;SAC1B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n :aria-label=\"ariaLabels?.removeButton\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../../types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n const { historyQuery: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n ariaLabels,\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;AAqDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,EAAE,kBAAkB,EAAE,gBAAgB;AAClD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,eAAe,EAAE,MAAM;AACxB,KAAA;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;AAChB,IAAA,KAAK,CAAC,KAAK,EAAA;QACT,MAAM,EAAE,YAAY,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAE3E;;;;AAIE;QACF,MAAM,KAAI,GAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,eAAc;AAExD;;;;;AAKE;AACF,QAAA,MAAM,wBAAuB,GAAI,QAAQ,CACvC,OAA8B;YAC5B,yBAAyB,EAAE,KAAK,CAAC,UAAU;AAC5C,SAAA,CAAC,CACJ;QAEA,OAAO;YACL,UAAU;YACV,KAAK;YACL,wBAAwB;SAC1B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -7,14 +7,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
7
7
  return openBlock(), createBlock(_component_BaseEventButton, {
8
8
  class: "x-remove-history-query",
9
9
  events: _ctx.removeHistoryQueryEvent,
10
- "aria-label": "remove"
10
+ "aria-label": _ctx.ariaLabels?.button
11
11
  }, {
12
12
  default: withCtx(() => [
13
13
  renderSlot(_ctx.$slots, "default")
14
14
  ]),
15
15
  _: 3
16
16
  /* FORWARDED */
17
- }, 8, ["events"]);
17
+ }, 8, ["events", "aria-label"]);
18
18
  }
19
19
  var RemoveHistoryQuery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
20
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"remove-history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n aria-label=\"remove\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAOkB,0BAAA,EAAA;AAAA,IANhB,KAAA,EAAM,wBAAA;AAAA,IACL,MAAA,EAAQ,IAAA,CAAA,uBAAA;AAAA,IACT,YAAA,EAAW;AAAA,GAAA,EAAA;qBAGX,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"remove-history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../../types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n const { removeHistoryQuery: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n ariaLabels,\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAOkB,0BAAA,EAAA;AAAA,IANhB,KAAA,EAAM,wBAAA;AAAA,IACL,MAAA,EAAQ,IAAA,CAAA,uBAAA;AAAA,IACR,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;qBAGzB,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -1,5 +1,6 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, inject, computed } from 'vue';
2
2
  import BaseEventButton from '../../../components/base-event-button.vue.js';
3
+ import { ACCESSIBILITY_KEY } from '../../../types/accessibility.js';
3
4
  import { historyQueriesXModule } from '../x-module.js';
4
5
 
5
6
  /**
@@ -27,6 +28,7 @@ var _sfc_main = defineComponent({
27
28
  },
28
29
  },
29
30
  setup(props) {
31
+ const { removeHistoryQuery: ariaLabels } = inject(ACCESSIBILITY_KEY);
30
32
  /**
31
33
  * The event handler that will be triggered when clicking on the clear history query button.
32
34
  *
@@ -38,6 +40,7 @@ var _sfc_main = defineComponent({
38
40
  */
39
41
  const removeHistoryQueryEvent = computed(() => ({ UserPressedRemoveHistoryQuery: props.historyQuery }));
40
42
  return {
43
+ ariaLabels,
41
44
  removeHistoryQueryEvent,
42
45
  };
43
46
  },
@@ -1 +1 @@
1
- {"version":3,"file":"remove-history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n aria-label=\"remove\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAmBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACtC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;;;;;AAQE;AACF,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CACtC,OAA8B,EAAE,6BAA6B,EAAE,KAAK,CAAC,YAAW,EAAG,CAAC,CACtF;QAEA,OAAO;YACL,uBAAuB;SACzB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"remove-history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../../types'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { ACCESSIBILITY_KEY } from '../../../types'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n const { removeHistoryQuery: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n ariaLabels,\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAqBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACtC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;QACT,MAAM,EAAE,kBAAkB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAEjF;;;;;;;;AAQE;AACF,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CACtC,OAA8B,EAAE,6BAA6B,EAAE,KAAK,CAAC,YAAW,EAAG,CAAC,CACtF;QAEA,OAAO;YACL,UAAU;YACV,uBAAuB;SACzB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -10,7 +10,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
10
10
  key: 0,
11
11
  class: "x-scroll-to-top xds:button",
12
12
  "data-test": "scroll-to-top",
13
- "aria-label": "Scroll to top",
13
+ "aria-label": _ctx.ariaLabels?.button,
14
14
  events: _ctx.events
15
15
  }, {
16
16
  default: withCtx(() => [
@@ -18,7 +18,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
18
18
  ]),
19
19
  _: 3
20
20
  /* FORWARDED */
21
- }, 8, ["events"])) : createCommentVNode("v-if", true)
21
+ }, 8, ["aria-label", "events"])) : createCommentVNode("v-if", true)
22
22
  ]),
23
23
  _: 3
24
24
  /* FORWARDED */
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-top.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <BaseEventButton\n v-if=\"isVisible\"\n class=\"x-scroll-to-top xds:button\"\n data-test=\"scroll-to-top\"\n aria-label=\"Scroll to top\"\n :events=\"events\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent } from 'vue'\nimport { BaseEventButton, NoAnimation } from '../../../components'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { scrollXModule } from '../x-module'\nimport { MainScrollId } from './scroll.const'\n\n/**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ScrollToTop',\n xModule: scrollXModule.name,\n components: { BaseEventButton },\n props: {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n thresholdPx: Number,\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n scrollId: {\n type: String,\n default: MainScrollId,\n },\n },\n setup(props) {\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n const { data } = useState('scroll')\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n const scrollData = computed(() => {\n return props.scrollId && data.value[props.scrollId]\n ? data.value[props.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false,\n }\n })\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserClickedScrollToTop: props.scrollId }),\n )\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n const useThresholdStrategy = computed(() => typeof props.thresholdPx === 'number')\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n const isThresholdReached = computed(\n () => useThresholdStrategy.value && scrollData.value.position > props.thresholdPx!,\n )\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n const hasAlmostReachedScrollEnd = computed(\n () => scrollData.value.hasAlmostReachedEnd && scrollData.value.direction === 'DOWN',\n )\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n const isVisible = computed(() =>\n useThresholdStrategy.value ? isThresholdReached.value : hasAlmostReachedScrollEnd.value,\n )\n\n return {\n events,\n isVisible,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedScrollToTop`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the scroll\n that is going to be scrolled.\n\n## Examples\n\n### Basic example\n\nThe component renders whatever is passed to it in the default slot and scrolls to top the scroll\nwith an id `scrollId`.\n\nIt also receives an optional threshold in pixels. When the threshold is reached from the top, the\ncomponent will be shown once the user scrolls `UP`.\n\nIf this parameter is not provided the button will be visible when the user almost reaches the end of\nthe scroll.\n\n```vue\n<template>\n <div>\n <ScrollToTop scroll-id=\"scrollId\" :threshold-px=\"1000\">\n <span>Scroll to top</span>\n </ScrollToTop>\n </div>\n</template>\n\n<script setup>\nimport { ScrollToTop } from '@empathyco/x-components/scroll'\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_renderSlot"],"mappings":";;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,WAAA,CAWYC,wBAXI,IAAA,CAAA,SAAS,CAAA,EAAA,IAAA,EAAA;AAAA,IAAA,OAAA,EAAAC,OAAA,CACvB,MASkB;AAAA,MARV,+BADRF,WAAA,CASkB,0BAAA,EAAA;AAAA,QAAA,GAAA,EAAA,CAAA;QAPhB,KAAA,EAAM,4BAAA;AAAA,QACN,WAAA,EAAU,eAAA;AAAA,QACV,YAAA,EAAW,eAAA;AAAA,QACV,MAAA,EAAQ,IAAA,CAAA;AAAA,OAAA,EAAA;yBAGT,MAAQ;AAAA,UAARG,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,SAAA,CAAA;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"scroll-to-top.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <BaseEventButton\n v-if=\"isVisible\"\n class=\"x-scroll-to-top xds:button\"\n data-test=\"scroll-to-top\"\n :aria-label=\"ariaLabels?.button\"\n :events=\"events\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { AriaLabels } from '../../../types'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, inject } from 'vue'\nimport { BaseEventButton, NoAnimation } from '../../../components'\nimport { useState } from '../../../composables'\nimport { ACCESSIBILITY_KEY, AnimationProp } from '../../../types'\nimport { scrollXModule } from '../x-module'\nimport { MainScrollId } from './scroll.const'\n\n/**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\nexport default defineComponent({\n name: 'ScrollToTop',\n xModule: scrollXModule.name,\n components: { BaseEventButton },\n props: {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n thresholdPx: Number,\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n scrollId: {\n type: String,\n default: MainScrollId,\n },\n },\n setup(props) {\n const { scrollToTop: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n const { data } = useState('scroll')\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n const scrollData = computed(() => {\n return props.scrollId && data.value[props.scrollId]\n ? data.value[props.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false,\n }\n })\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserClickedScrollToTop: props.scrollId }),\n )\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n const useThresholdStrategy = computed(() => typeof props.thresholdPx === 'number')\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n const isThresholdReached = computed(\n () => useThresholdStrategy.value && scrollData.value.position > props.thresholdPx!,\n )\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n const hasAlmostReachedScrollEnd = computed(\n () => scrollData.value.hasAlmostReachedEnd && scrollData.value.direction === 'DOWN',\n )\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n const isVisible = computed(() =>\n useThresholdStrategy.value ? isThresholdReached.value : hasAlmostReachedScrollEnd.value,\n )\n\n return {\n ariaLabels,\n events,\n isVisible,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedScrollToTop`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the scroll\n that is going to be scrolled.\n\n## Examples\n\n### Basic example\n\nThe component renders whatever is passed to it in the default slot and scrolls to top the scroll\nwith an id `scrollId`.\n\nIt also receives an optional threshold in pixels. When the threshold is reached from the top, the\ncomponent will be shown once the user scrolls `UP`.\n\nIf this parameter is not provided the button will be visible when the user almost reaches the end of\nthe scroll.\n\n```vue\n<template>\n <div>\n <ScrollToTop scroll-id=\"scrollId\" :threshold-px=\"1000\">\n <span>Scroll to top</span>\n </ScrollToTop>\n </div>\n</template>\n\n<script setup>\nimport { ScrollToTop } from '@empathyco/x-components/scroll'\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_renderSlot"],"mappings":";;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,WAAA,CAWYC,wBAXI,IAAA,CAAA,SAAS,CAAA,EAAA,IAAA,EAAA;AAAA,IAAA,OAAA,EAAAC,OAAA,CACvB,MASkB;AAAA,MARV,+BADRF,WAAA,CASkB,0BAAA,EAAA;AAAA,QAAA,GAAA,EAAA,CAAA;QAPhB,KAAA,EAAM,4BAAA;AAAA,QACN,WAAA,EAAU,eAAA;AAAA,QACT,cAAY,IAAA,CAAA,UAAA,EAAY,MAAA;AAAA,QACxB,MAAA,EAAQ,IAAA,CAAA;AAAA,OAAA,EAAA;yBAGT,MAAQ;AAAA,UAARG,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,SAAA,CAAA;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, inject, computed } from 'vue';
2
2
  import '../../../components/animations/animate-clip-path.vue2.js';
3
3
  import '../../../components/animations/animate-scale.vue2.js';
4
4
  import '../../../components/animations/animate-translate.vue2.js';
@@ -100,6 +100,7 @@ import '../../../components/suggestions/base-suggestions.vue3.js';
100
100
  import '../../../composables/create-use-device.js';
101
101
  import '@vueuse/core';
102
102
  import { useState } from '../../../composables/use-state.js';
103
+ import { ACCESSIBILITY_KEY } from '../../../types/accessibility.js';
103
104
  import { scrollXModule } from '../x-module.js';
104
105
  import { MainScrollId } from './scroll.const.js';
105
106
 
@@ -140,6 +141,7 @@ var _sfc_main = defineComponent({
140
141
  },
141
142
  },
142
143
  setup(props) {
144
+ const { scrollToTop: ariaLabels } = inject(ACCESSIBILITY_KEY);
143
145
  /**
144
146
  * State of all the scroll components in this module.
145
147
  *
@@ -201,6 +203,7 @@ var _sfc_main = defineComponent({
201
203
  */
202
204
  const isVisible = computed(() => useThresholdStrategy.value ? isThresholdReached.value : hasAlmostReachedScrollEnd.value);
203
205
  return {
206
+ ariaLabels,
204
207
  events,
205
208
  isVisible,
206
209
  };