@empathyco/x-components 9.2.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 +14 -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 +8 -3
  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
@@ -8,7 +8,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
8
8
  "model-value": _ctx.selectedColumns,
9
9
  items: _ctx.columns,
10
10
  animation: _ctx.animation,
11
- "aria-label": "Select number of columns",
11
+ "aria-label": _ctx.ariaLabels?.dropdown,
12
12
  "onUpdate:modelValue": _ctx.emitEvents
13
13
  }, createSlots({
14
14
  item: withCtx(({ item, isSelected, isHighlighted }) => [
@@ -24,7 +24,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
24
24
  ]),
25
25
  key: "0"
26
26
  } : void 0
27
- ]), 1032, ["model-value", "items", "animation", "onUpdate:modelValue"]);
27
+ ]), 1032, ["model-value", "items", "animation", "aria-label", "onUpdate:modelValue"]);
28
28
  }
29
29
  var baseColumnPickerDropdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
30
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-column-picker-dropdown.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n :model-value=\"selectedColumns\"\n :items=\"columns\"\n :animation=\"animation\"\n aria-label=\"Select number of columns\"\n @update:model-value=\"emitEvents\"\n >\n <template v-if=\"hasToggleSlot\" #toggle=\"{ item, isOpen }\">\n <!--\n @slot From `BaseDropdown` component: Used to render the contents of the dropdown toggle\n button. If not provided, it uses the `item` slot as fallback.\n @binding {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is\n closed.\n -->\n <slot name=\"toggle\" v-bind=\"{ item, isOpen }\" />\n </template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <!--\n @slot (required) From `BaseDropdown` component: Used to render each one of the items\n content, and as fallback for the toggle button content slot if it is not provided.\n @binding {string|number|Identifiable} item - Item to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot name=\"item\" v-bind=\"{ item, isSelected, isHighlighted }\" />\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Component, PropType } from 'vue'\nimport { computed, defineComponent, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * Column picker dropdown component renders {@link BaseDropdown} component which\n * options are the different columns you can set for a grid.\n *\n * It emits {@link XEventsTypes.UserClickedColumnPicker} on dropdown\n * input.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerDropdown',\n components: { BaseDropdown },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const $x = use$x()\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Emits a {@link XEventsTypes.UserClickedColumnPicker} and\n * {@link XEventsTypes.ColumnsNumberProvided} events.\n *\n * @param column - Column number payload.\n */\n function emitEvents(column: number) {\n $x.emit('UserClickedColumnPicker', column)\n $x.emit('ColumnsNumberProvided', column)\n }\n\n return {\n emitEvents,\n hasToggleSlot: !!slots.toggle,\n selectedColumns,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nAn event that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item in the dropdown. The event payload is the\n number of columns that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount, and whenever the value changes. The event payload is the\n current `selectedColumns` value.\n\n## Examples\n\nColumn picker dropdown component renders a dropdown component which options are the different\ncolumns you can set for a grid.\n\n### Usage\n\nNotice that the slots provided match with the `BaseDropdown` component. The `item` slot is required\nunlike the `toggle`, which renders the same `item` slot defined by default.\n\n#### Default usage\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Customizing toggle button\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Using it without v-model / value\n\nThe component emits an X Event, `UserClickedColumnPicker`, on column change and it also listens to\nthat event from outside, so you don't need to store the current column value to keep it synchronized\nwith other column pickers.\n\n```vue live\n<template>\n <BaseColumnPickerDropdown :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_createSlots","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps"],"mappings":";;;;;;sBACEA,WAAA,CA2Be,uBAAA,EAAA;AAAA,IA1BZ,aAAA,EAAa,IAAA,CAAA,eAAA;AAAA,IACb,KAAA,EAAO,IAAA,CAAA,OAAA;AAAA,IACP,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACZ,YAAA,EAAW,0BAAA;AAAA,IACV,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAAC,WAAA,CAAA;AAYV,IAAA,IAAA,EAAIC,OAAA,CAQb,CAAiE,EARhD,IAAA,EAAM,YAAY,aAAA,EAAa,KAAA;AAAA,MAQhDC,UAAA,CAAiE,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAArC,IAAA,EAAM,UAAA,EAAY,aAAA,EAAa,CAAA,CAAA;AAAA,KAAA,CAAA;;;;AAlB7C,IAAA,IAAA,CAAA,aAAA,GAAA;AAAgB,MAAA,IAAA,EAAA,QAAA;AAAA,MAAA,EAAA,EAAAH,OAAA,CAQ9B,CAAgD,EARR,IAAA,EAAM,MAAA,EAAM,KAAA;AAAA,QAQpDC,UAAA,CAAgD,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAlB,IAAA,EAAM,MAAA,EAAM,CAAA,CAAA;AAAA,OAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"base-column-picker-dropdown.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n :model-value=\"selectedColumns\"\n :items=\"columns\"\n :animation=\"animation\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitEvents\"\n >\n <template v-if=\"hasToggleSlot\" #toggle=\"{ item, isOpen }\">\n <!--\n @slot From `BaseDropdown` component: Used to render the contents of the dropdown toggle\n button. If not provided, it uses the `item` slot as fallback.\n @binding {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is\n closed.\n -->\n <slot name=\"toggle\" v-bind=\"{ item, isOpen }\" />\n </template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <!--\n @slot (required) From `BaseDropdown` component: Used to render each one of the items\n content, and as fallback for the toggle button content slot if it is not provided.\n @binding {string|number|Identifiable} item - Item to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot name=\"item\" v-bind=\"{ item, isSelected, isHighlighted }\" />\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Component, PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport { computed, defineComponent, inject, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * Column picker dropdown component renders {@link BaseDropdown} component which\n * options are the different columns you can set for a grid.\n *\n * It emits {@link XEventsTypes.UserClickedColumnPicker} on dropdown\n * input.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerDropdown',\n components: { BaseDropdown },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const $x = use$x()\n\n const { baseColumnPickerDropdown: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Emits a {@link XEventsTypes.UserClickedColumnPicker} and\n * {@link XEventsTypes.ColumnsNumberProvided} events.\n *\n * @param column - Column number payload.\n */\n function emitEvents(column: number) {\n $x.emit('UserClickedColumnPicker', column)\n $x.emit('ColumnsNumberProvided', column)\n }\n\n return {\n ariaLabels,\n emitEvents,\n hasToggleSlot: !!slots.toggle,\n selectedColumns,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nAn event that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item in the dropdown. The event payload is the\n number of columns that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount, and whenever the value changes. The event payload is the\n current `selectedColumns` value.\n\n## Examples\n\nColumn picker dropdown component renders a dropdown component which options are the different\ncolumns you can set for a grid.\n\n### Usage\n\nNotice that the slots provided match with the `BaseDropdown` component. The `item` slot is required\nunlike the `toggle`, which renders the same `item` slot defined by default.\n\n#### Default usage\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Customizing toggle button\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Using it without v-model / value\n\nThe component emits an X Event, `UserClickedColumnPicker`, on column change and it also listens to\nthat event from outside, so you don't need to store the current column value to keep it synchronized\nwith other column pickers.\n\n```vue live\n<template>\n <BaseColumnPickerDropdown :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_createSlots","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps"],"mappings":";;;;;;sBACEA,WAAA,CA2Be,uBAAA,EAAA;AAAA,IA1BZ,aAAA,EAAa,IAAA,CAAA,eAAA;AAAA,IACb,KAAA,EAAO,IAAA,CAAA,OAAA;AAAA,IACP,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACX,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,IACxB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAAC,WAAA,CAAA;AAYV,IAAA,IAAA,EAAIC,OAAA,CAQb,CAAiE,EARhD,IAAA,EAAM,YAAY,aAAA,EAAa,KAAA;AAAA,MAQhDC,UAAA,CAAiE,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAArC,IAAA,EAAM,UAAA,EAAY,aAAA,EAAa,CAAA,CAAA;AAAA,KAAA,CAAA;;;;AAlB7C,IAAA,IAAA,CAAA,aAAA,GAAA;AAAgB,MAAA,IAAA,EAAA,QAAA;AAAA,MAAA,EAAA,EAAAH,OAAA,CAQ9B,CAAgD,EARR,IAAA,EAAM,MAAA,EAAM,KAAA;AAAA,QAQpDC,UAAA,CAAgD,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAlB,IAAA,EAAM,MAAA,EAAM,CAAA,CAAA;AAAA,OAAA,CAAA;;;;;;;;;"}
@@ -1,5 +1,6 @@
1
- import { defineComponent, computed, ref, watch, onBeforeMount } from 'vue';
1
+ import { defineComponent, inject, computed, ref, watch, onBeforeMount } from 'vue';
2
2
  import { use$x } from '../../composables/use-_x.js';
3
+ import { ACCESSIBILITY_KEY } from '../../types/accessibility.js';
3
4
  import BaseDropdown from '../base-dropdown.vue.js';
4
5
 
5
6
  /**
@@ -28,6 +29,7 @@ var _sfc_main = defineComponent({
28
29
  emits: ['update:modelValue'],
29
30
  setup(props, { emit, slots }) {
30
31
  const $x = use$x();
32
+ const { baseColumnPickerDropdown: ariaLabels } = inject(ACCESSIBILITY_KEY);
31
33
  const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0]);
32
34
  const selectedColumns = ref(providedSelectedColumns.value);
33
35
  /**
@@ -77,6 +79,7 @@ var _sfc_main = defineComponent({
77
79
  $x.emit('ColumnsNumberProvided', column);
78
80
  }
79
81
  return {
82
+ ariaLabels,
80
83
  emitEvents,
81
84
  hasToggleSlot: !!slots.toggle,
82
85
  selectedColumns,
@@ -1 +1 @@
1
- {"version":3,"file":"base-column-picker-dropdown.vue2.js","sources":["../../../../src/components/column-picker/base-column-picker-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n :model-value=\"selectedColumns\"\n :items=\"columns\"\n :animation=\"animation\"\n aria-label=\"Select number of columns\"\n @update:model-value=\"emitEvents\"\n >\n <template v-if=\"hasToggleSlot\" #toggle=\"{ item, isOpen }\">\n <!--\n @slot From `BaseDropdown` component: Used to render the contents of the dropdown toggle\n button. If not provided, it uses the `item` slot as fallback.\n @binding {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is\n closed.\n -->\n <slot name=\"toggle\" v-bind=\"{ item, isOpen }\" />\n </template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <!--\n @slot (required) From `BaseDropdown` component: Used to render each one of the items\n content, and as fallback for the toggle button content slot if it is not provided.\n @binding {string|number|Identifiable} item - Item to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot name=\"item\" v-bind=\"{ item, isSelected, isHighlighted }\" />\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Component, PropType } from 'vue'\nimport { computed, defineComponent, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * Column picker dropdown component renders {@link BaseDropdown} component which\n * options are the different columns you can set for a grid.\n *\n * It emits {@link XEventsTypes.UserClickedColumnPicker} on dropdown\n * input.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerDropdown',\n components: { BaseDropdown },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const $x = use$x()\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Emits a {@link XEventsTypes.UserClickedColumnPicker} and\n * {@link XEventsTypes.ColumnsNumberProvided} events.\n *\n * @param column - Column number payload.\n */\n function emitEvents(column: number) {\n $x.emit('UserClickedColumnPicker', column)\n $x.emit('ColumnsNumberProvided', column)\n }\n\n return {\n emitEvents,\n hasToggleSlot: !!slots.toggle,\n selectedColumns,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nAn event that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item in the dropdown. The event payload is the\n number of columns that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount, and whenever the value changes. The event payload is the\n current `selectedColumns` value.\n\n## Examples\n\nColumn picker dropdown component renders a dropdown component which options are the different\ncolumns you can set for a grid.\n\n### Usage\n\nNotice that the slots provided match with the `BaseDropdown` component. The `item` slot is required\nunlike the `toggle`, which renders the same `item` slot defined by default.\n\n#### Default usage\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Customizing toggle button\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Using it without v-model / value\n\nThe component emits an X Event, `UserClickedColumnPicker`, on column change and it also listens to\nthat event from outside, so you don't need to store the current column value to keep it synchronized\nwith other column pickers.\n\n```vue live\n<template>\n <BaseColumnPickerDropdown :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAqCA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,0BAA0B;IAChC,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;;AAEL,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,KAA2B;AACjC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,UAAU,EAAE,MAAM;;AAElB,QAAA,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAiC;AAC5D,KAAA;IACD,KAAK,EAAE,CAAC,mBAAmB,CAAC;AAC5B,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAI,EAAG,EAAA;AAC1B,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,UAAS,IAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnF,MAAM,eAAc,GAAI,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAA;AAEzD;;;;AAIE;QACF,SAAS,yBAAyB,CAAC,MAAc,EAAA;AAC/C,YAAA,eAAe,CAAC,KAAI,GAAI,MAAK;AAC7B,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;AAEA;;;;AAIE;QACF,SAAS,oBAAoB,CAAC,MAAc,EAAA;AAC1C,YAAA,IAAI,KAAK,CAAC,UAAS,KAAM,MAAM,EAAE;AAC/B,gBAAA,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAA;YAClC;QACF;AAEA,QAAA,KAAK,CAAC,uBAAuB,EAAE,yBAAyB,CAAA;AACxD,QAAA,KAAK,CAAC,eAAe,EAAE,oBAAoB,CAAA;QAE3C,EAAE,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAK,KAAM,eAAe,CAAC,KAAI,GAAI,MAAM,CAAC,CAAA;AAE1F;;;;;AAKE;QACF,aAAa,CAAC,MAAI;YAChB,IAAI,eAAe,CAAC,KAAI,KAAM,uBAAuB,CAAC,KAAK,EAAE;AAC3D,gBAAA,yBAAyB,CAAC,eAAe,CAAC,KAAK,CAAA;YACjD;iBAAO;AACL,gBAAA,oBAAoB,CAAC,eAAe,CAAC,KAAK,CAAA;YAC5C;AACF,QAAA,CAAC,CAAA;AAED;;;;;AAKE;QACF,SAAS,UAAU,CAAC,MAAc,EAAA;AAChC,YAAA,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAA;AACzC,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;QAEA,OAAO;YACL,UAAU;AACV,YAAA,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM;YAC7B,eAAe;SACjB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-column-picker-dropdown.vue2.js","sources":["../../../../src/components/column-picker/base-column-picker-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n :model-value=\"selectedColumns\"\n :items=\"columns\"\n :animation=\"animation\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitEvents\"\n >\n <template v-if=\"hasToggleSlot\" #toggle=\"{ item, isOpen }\">\n <!--\n @slot From `BaseDropdown` component: Used to render the contents of the dropdown toggle\n button. If not provided, it uses the `item` slot as fallback.\n @binding {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is\n closed.\n -->\n <slot name=\"toggle\" v-bind=\"{ item, isOpen }\" />\n </template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <!--\n @slot (required) From `BaseDropdown` component: Used to render each one of the items\n content, and as fallback for the toggle button content slot if it is not provided.\n @binding {string|number|Identifiable} item - Item to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot name=\"item\" v-bind=\"{ item, isSelected, isHighlighted }\" />\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Component, PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport { computed, defineComponent, inject, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * Column picker dropdown component renders {@link BaseDropdown} component which\n * options are the different columns you can set for a grid.\n *\n * It emits {@link XEventsTypes.UserClickedColumnPicker} on dropdown\n * input.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerDropdown',\n components: { BaseDropdown },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const $x = use$x()\n\n const { baseColumnPickerDropdown: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Emits a {@link XEventsTypes.UserClickedColumnPicker} and\n * {@link XEventsTypes.ColumnsNumberProvided} events.\n *\n * @param column - Column number payload.\n */\n function emitEvents(column: number) {\n $x.emit('UserClickedColumnPicker', column)\n $x.emit('ColumnsNumberProvided', column)\n }\n\n return {\n ariaLabels,\n emitEvents,\n hasToggleSlot: !!slots.toggle,\n selectedColumns,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nAn event that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item in the dropdown. The event payload is the\n number of columns that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount, and whenever the value changes. The event payload is the\n current `selectedColumns` value.\n\n## Examples\n\nColumn picker dropdown component renders a dropdown component which options are the different\ncolumns you can set for a grid.\n\n### Usage\n\nNotice that the slots provided match with the `BaseDropdown` component. The `item` slot is required\nunlike the `toggle`, which renders the same `item` slot defined by default.\n\n#### Default usage\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Customizing toggle button\n\n```vue live\n<template>\n <BaseColumnPickerDropdown v-model=\"selectedColumns\" :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n\nconst selectedColumns = ref(2)\n</script>\n```\n\n#### Using it without v-model / value\n\nThe component emits an X Event, `UserClickedColumnPicker`, on column change and it also listens to\nthat event from outside, so you don't need to store the current column value to keep it synchronized\nwith other column pickers.\n\n```vue live\n<template>\n <BaseColumnPickerDropdown :columns=\"[2, 4, 6]\">\n <template #toggle=\"{ item, isOpen }\">Selected: {{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseColumnPickerDropdown>\n</template>\n\n<script setup>\nimport BaseColumnPickerDropdown from '@empathyco/x-components/js/components/column-picker/base-column-picker-dropdown.vue'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAuCA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,0BAA0B;IAChC,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;;AAEL,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,KAA2B;AACjC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,UAAU,EAAE,MAAM;;AAElB,QAAA,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAiC;AAC5D,KAAA;IACD,KAAK,EAAE,CAAC,mBAAmB,CAAC;AAC5B,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAI,EAAG,EAAA;AAC1B,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;QAEjB,MAAM,EAAE,wBAAwB,EAAE,UAAS,KAAM,MAAM,CAAC,iBAAiB,CAAc;AAEvF,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,UAAS,IAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnF,MAAM,eAAc,GAAI,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAA;AAEzD;;;;AAIE;QACF,SAAS,yBAAyB,CAAC,MAAc,EAAA;AAC/C,YAAA,eAAe,CAAC,KAAI,GAAI,MAAK;AAC7B,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;AAEA;;;;AAIE;QACF,SAAS,oBAAoB,CAAC,MAAc,EAAA;AAC1C,YAAA,IAAI,KAAK,CAAC,UAAS,KAAM,MAAM,EAAE;AAC/B,gBAAA,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAA;YAClC;QACF;AAEA,QAAA,KAAK,CAAC,uBAAuB,EAAE,yBAAyB,CAAA;AACxD,QAAA,KAAK,CAAC,eAAe,EAAE,oBAAoB,CAAA;QAE3C,EAAE,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAK,KAAM,eAAe,CAAC,KAAI,GAAI,MAAM,CAAC,CAAA;AAE1F;;;;;AAKE;QACF,aAAa,CAAC,MAAI;YAChB,IAAI,eAAe,CAAC,KAAI,KAAM,uBAAuB,CAAC,KAAK,EAAE;AAC3D,gBAAA,yBAAyB,CAAC,eAAe,CAAC,KAAK,CAAA;YACjD;iBAAO;AACL,gBAAA,oBAAoB,CAAC,eAAe,CAAC,KAAK,CAAA;YAC5C;AACF,QAAA,CAAC,CAAA;AAED;;;;;AAKE;QACF,SAAS,UAAU,CAAC,MAAc,EAAA;AAChC,YAAA,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAA;AACzC,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;QAEA,OAAO;YACL,UAAU;YACV,UAAU;AACV,YAAA,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM;YAC7B,eAAe;SACjB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -23,7 +23,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
23
23
  "data-test": "column-picker-button",
24
24
  "aria-pressed": isSelected.toString(),
25
25
  events,
26
- "aria-label": `${column} columns`,
26
+ "aria-label": _ctx.ariaLabels?.button(column),
27
27
  role: "listitem"
28
28
  }, {
29
29
  default: withCtx(() => [
@@ -1 +1 @@
1
- {"version":3,"file":"base-column-picker-list.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list xds:button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template\n v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\"\n :key=\"column\"\n >\n <BaseEventButton\n class=\"x-column-picker-list__button xds:button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected.toString()\"\n :events=\"events\"\n :aria-label=\"`${column} columns`\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring'\nimport { computed, defineComponent, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseEventButton from '../base-event-button.vue'\n\nexport interface ColumnPickerItem {\n column: number\n cssClasses: VueCSSClasses\n events: Partial<XEventsTypes>\n isSelected: boolean\n}\n\n/**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerList',\n components: { BaseEventButton },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** Class inherited by each button. */\n buttonClass: String,\n },\n emits: ['update:modelValue'],\n setup(props, { emit }) {\n const $x = use$x()\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n */\n const columnsWithCssClasses = computed<ColumnPickerItem[]>(() =>\n props.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n { 'xds:selected': selectedColumns.value === column },\n ],\n isSelected: selectedColumns.value === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column,\n },\n })),\n )\n\n return { columnsWithCssClasses }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nbutton emits the needed events to sync other instances of column pickers or grids with the\nnumber of columns being selected when clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n### Using v-model\n\nIt is possible to do two-way binding in order to synchronize the value with the parent. It will be\nupdated if the value changes or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\nconst selectedColumns = ref(4)\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\nimport ChevronRightIcon from '@empathyco/x-components/js/components/icons/chevron-right.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"xds:button-circle\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createVNode","_normalizeClass","_renderSlot","_mergeProps","_createTextVNode","_createCommentVNode"],"mappings":";;;;;EACO,KAAA,EAAM,uCAAA;AAAA,EAAwC,WAAA,EAAU,oBAAA;AAAA,EAAqB,IAAA,EAAK;;;;AAAvF,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CA+BM,OA/BN,UAAA,EA+BM;AAAA,KAAAD,SAAA,CAAA,IAAA,CAAA,EA9BJC,kBAAA;AAAA,MA6BWC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CA5BqD,4BAAqB,CAAA,EAAzE,MAAA,EAAQ,YAAY,MAAA,EAAQ,UAAA,IAAc,KAAA,KAAK;;;iBACnD,MAAA,EAAM;AAAA,UAAA;AAAA,YAEZC,WAAA,CAkBkB,0BAAA,EAAA;AAAA,cAjBhB,KAAA,EAAKC,cAAA,CAAA,CAAC,yCAAA,EAAyC,CACtC,kBAAa,UAAU,CAAA,CAAA,CAAA;AAAA,cAChC,WAAA,EAAU,sBAAA;AAAA,cACT,cAAA,EAAc,WAAW,QAAA,EAAQ;AAAA,cACjC,MAAA;AAAA,cACA,YAAA,EAAU,GAAK,MAAM,CAAA,QAAA,CAAA;AAAA,cACtB,IAAA,EAAK;AAAA,aAAA,EAAA;+BAQL,MAEO;AAAA,gBAFPC,WAEO,IAAA,CAAA,MAAA,EAAA,SAAA,EAFPC,UAAA,CAEO,qBAFS,MAAA,EAAQ,UAAA,KAAxB,MAEO;AAAA,kBAAAC,eAAA;oCADF,MAAM,CAAA;AAAA,oBAAA;AAAA;AAAA;AAAA,iBAAA;;;;;YAQD,KAAA,KAAU,IAAA,CAAA,qBAAA,CAAsB,MAAA,GAAM,CAAA,GAAlDF,UAAA,CAA8E,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,GAAA,EAAA,CAAA,EAAA,CAAA,GAAAG,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-column-picker-list.vue.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list xds:button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template\n v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\"\n :key=\"column\"\n >\n <BaseEventButton\n class=\"x-column-picker-list__button xds:button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected.toString()\"\n :events=\"events\"\n :aria-label=\"ariaLabels?.button!(column)\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring'\nimport { computed, defineComponent, inject, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\nexport interface ColumnPickerItem {\n column: number\n cssClasses: VueCSSClasses\n events: Partial<XEventsTypes>\n isSelected: boolean\n}\n\n/**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerList',\n components: { BaseEventButton },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** Class inherited by each button. */\n buttonClass: String,\n },\n emits: ['update:modelValue'],\n setup(props, { emit }) {\n const $x = use$x()\n\n const { baseColumnPickerList: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n */\n const columnsWithCssClasses = computed<ColumnPickerItem[]>(() =>\n props.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n { 'xds:selected': selectedColumns.value === column },\n ],\n isSelected: selectedColumns.value === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column,\n },\n })),\n )\n\n return { ariaLabels, columnsWithCssClasses }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nbutton emits the needed events to sync other instances of column pickers or grids with the\nnumber of columns being selected when clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n### Using v-model\n\nIt is possible to do two-way binding in order to synchronize the value with the parent. It will be\nupdated if the value changes or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\nconst selectedColumns = ref(4)\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\nimport ChevronRightIcon from '@empathyco/x-components/js/components/icons/chevron-right.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"xds:button-circle\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createVNode","_normalizeClass","_renderSlot","_mergeProps","_createTextVNode","_createCommentVNode"],"mappings":";;;;;EACO,KAAA,EAAM,uCAAA;AAAA,EAAwC,WAAA,EAAU,oBAAA;AAAA,EAAqB,IAAA,EAAK;;;;AAAvF,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CA+BM,OA/BN,UAAA,EA+BM;AAAA,KAAAD,SAAA,CAAA,IAAA,CAAA,EA9BJC,kBAAA;AAAA,MA6BWC,QAAA;AAAA,MAAA,IAAA;AAAA,MAAAC,UAAA,CA5BqD,4BAAqB,CAAA,EAAzE,MAAA,EAAQ,YAAY,MAAA,EAAQ,UAAA,IAAc,KAAA,KAAK;;;iBACnD,MAAA,EAAM;AAAA,UAAA;AAAA,YAEZC,WAAA,CAkBkB,0BAAA,EAAA;AAAA,cAjBhB,KAAA,EAAKC,cAAA,CAAA,CAAC,yCAAA,EAAyC,CACtC,kBAAa,UAAU,CAAA,CAAA,CAAA;AAAA,cAChC,WAAA,EAAU,sBAAA;AAAA,cACT,cAAA,EAAc,WAAW,QAAA,EAAQ;AAAA,cACjC,MAAA;AAAA,cACA,YAAA,EAAY,IAAA,CAAA,UAAA,EAAY,MAAA,CAAQ,MAAM,CAAA;AAAA,cACvC,IAAA,EAAK;AAAA,aAAA,EAAA;+BAQL,MAEO;AAAA,gBAFPC,WAEO,IAAA,CAAA,MAAA,EAAA,SAAA,EAFPC,UAAA,CAEO,qBAFS,MAAA,EAAQ,UAAA,KAAxB,MAEO;AAAA,kBAAAC,eAAA;oCADF,MAAM,CAAA;AAAA,oBAAA;AAAA;AAAA;AAAA,iBAAA;;;;;YAQD,KAAA,KAAU,IAAA,CAAA,qBAAA,CAAsB,MAAA,GAAM,CAAA,GAAlDF,UAAA,CAA8E,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,GAAA,EAAA,CAAA,EAAA,CAAA,GAAAG,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;;;;;;;;"}
@@ -1,5 +1,6 @@
1
- import { defineComponent, computed, ref, watch, onBeforeMount } from 'vue';
1
+ import { defineComponent, inject, computed, ref, watch, onBeforeMount } from 'vue';
2
2
  import { use$x } from '../../composables/use-_x.js';
3
+ import { ACCESSIBILITY_KEY } from '../../types/accessibility.js';
3
4
  import BaseEventButton from '../base-event-button.vue.js';
4
5
 
5
6
  /**
@@ -27,6 +28,7 @@ var _sfc_main = defineComponent({
27
28
  emits: ['update:modelValue'],
28
29
  setup(props, { emit }) {
29
30
  const $x = use$x();
31
+ const { baseColumnPickerList: ariaLabels } = inject(ACCESSIBILITY_KEY);
30
32
  const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0]);
31
33
  const selectedColumns = ref(providedSelectedColumns.value);
32
34
  /**
@@ -82,7 +84,7 @@ var _sfc_main = defineComponent({
82
84
  ColumnsNumberProvided: column,
83
85
  },
84
86
  })));
85
- return { columnsWithCssClasses };
87
+ return { ariaLabels, columnsWithCssClasses };
86
88
  },
87
89
  });
88
90
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-column-picker-list.vue2.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list xds:button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template\n v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\"\n :key=\"column\"\n >\n <BaseEventButton\n class=\"x-column-picker-list__button xds:button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected.toString()\"\n :events=\"events\"\n :aria-label=\"`${column} columns`\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring'\nimport { computed, defineComponent, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseEventButton from '../base-event-button.vue'\n\nexport interface ColumnPickerItem {\n column: number\n cssClasses: VueCSSClasses\n events: Partial<XEventsTypes>\n isSelected: boolean\n}\n\n/**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerList',\n components: { BaseEventButton },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** Class inherited by each button. */\n buttonClass: String,\n },\n emits: ['update:modelValue'],\n setup(props, { emit }) {\n const $x = use$x()\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n */\n const columnsWithCssClasses = computed<ColumnPickerItem[]>(() =>\n props.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n { 'xds:selected': selectedColumns.value === column },\n ],\n isSelected: selectedColumns.value === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column,\n },\n })),\n )\n\n return { columnsWithCssClasses }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nbutton emits the needed events to sync other instances of column pickers or grids with the\nnumber of columns being selected when clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n### Using v-model\n\nIt is possible to do two-way binding in order to synchronize the value with the parent. It will be\nupdated if the value changes or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\nconst selectedColumns = ref(4)\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\nimport ChevronRightIcon from '@empathyco/x-components/js/components/icons/chevron-right.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"xds:button-circle\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":[],"mappings":";;;;AAkDA;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,sBAAsB;IAC5B,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;;AAEL,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,KAA2B;AACjC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,UAAU,EAAE,MAAM;;AAElB,QAAA,WAAW,EAAE,MAAM;AACpB,KAAA;IACD,KAAK,EAAE,CAAC,mBAAmB,CAAC;AAC5B,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAG,EAAG,EAAA;AACnB,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,UAAS,IAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnF,MAAM,eAAc,GAAI,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAA;AAEzD;;;;AAIE;QACF,SAAS,yBAAyB,CAAC,MAAc,EAAA;AAC/C,YAAA,eAAe,CAAC,KAAI,GAAI,MAAK;AAC7B,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;AAEA;;;;AAIE;QACF,SAAS,oBAAoB,CAAC,MAAc,EAAA;AAC1C,YAAA,IAAI,KAAK,CAAC,UAAS,KAAM,MAAM,EAAE;AAC/B,gBAAA,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAA;YAClC;QACF;AAEA,QAAA,KAAK,CAAC,uBAAuB,EAAE,yBAAyB,CAAA;AACxD,QAAA,KAAK,CAAC,eAAe,EAAE,oBAAoB,CAAA;QAE3C,EAAE,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAK,KAAM,eAAe,CAAC,KAAI,GAAI,MAAM,CAAC,CAAA;AAE1F;;;;;AAKE;QACF,aAAa,CAAC,MAAI;YAChB,IAAI,eAAe,CAAC,KAAI,KAAM,uBAAuB,CAAC,KAAK,EAAE;AAC3D,gBAAA,yBAAyB,CAAC,eAAe,CAAC,KAAK,CAAA;YACjD;iBAAO;AACL,gBAAA,oBAAoB,CAAC,eAAe,CAAC,KAAK,CAAA;YAC5C;AACF,QAAA,CAAC,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAqB,MACzD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAK,KAAM;YAC3B,MAAM;AACN,YAAA,UAAU,EAAE;AACV,gBAAA,CAAA,8BAAA,EAAiC,MAAM,CAAA,KAAA,CAAO;AAC9C,gBAAA,EAAE,cAAc,EAAE,eAAe,CAAC,KAAI,KAAM,MAAK,EAAG;AACrD,aAAA;AACD,YAAA,UAAU,EAAE,eAAe,CAAC,KAAI,KAAM,MAAM;AAC5C,YAAA,MAAM,EAAE;AACN,gBAAA,uBAAuB,EAAE,MAAM;AAC/B,gBAAA,qBAAqB,EAAE,MAAM;AAC9B,aAAA;SACF,CAAC,CAAC,CACL;QAEA,OAAO,EAAE,qBAAoB,EAAE;IACjC,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-column-picker-list.vue2.js","sources":["../../../../src/components/column-picker/base-column-picker-list.vue"],"sourcesContent":["<template>\n <div class=\"x-column-picker-list xds:button-group\" data-test=\"column-picker-list\" role=\"list\">\n <template\n v-for=\"({ column, cssClasses, events, isSelected }, index) in columnsWithCssClasses\"\n :key=\"column\"\n >\n <BaseEventButton\n class=\"x-column-picker-list__button xds:button\"\n :class=\"[buttonClass, cssClasses]\"\n data-test=\"column-picker-button\"\n :aria-pressed=\"isSelected.toString()\"\n :events=\"events\"\n :aria-label=\"ariaLabels?.button!(column)\"\n role=\"listitem\"\n >\n <!--\n @slot Customized Column Picker Button content. Specifying a slot with the column value\n will result in the column using that slot composition to render.\n @binding {number} column - Columns Number to pick.\n @binding {boolean} isSelected - True if the columns number are the chosen value.\n -->\n <slot v-bind=\"{ column, isSelected }\">\n {{ column }}\n </slot>\n </BaseEventButton>\n\n <!--\n @slot Customized Column Picker divider. Specify an element to act as divider for\n the items in the column picker. Empty by default.\n -->\n <slot v-if=\"index !== columnsWithCssClasses.length - 1\" name=\"divider\"></slot>\n </template>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring'\nimport { computed, defineComponent, inject, onBeforeMount, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\nexport interface ColumnPickerItem {\n column: number\n cssClasses: VueCSSClasses\n events: Partial<XEventsTypes>\n isSelected: boolean\n}\n\n/**\n * Column picker list component renders a list of buttons to choose the columns number.\n *\n * Additionally, this component exposes the following props to modify the classes of the\n * elements: `buttonClass`.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseColumnPickerList',\n components: { BaseEventButton },\n props: {\n /** An array of numbers that represents the number of columns to render. */\n columns: {\n type: Array as PropType<number[]>,\n required: true,\n },\n /** The value of the selected columns number. */\n modelValue: Number,\n /** Class inherited by each button. */\n buttonClass: String,\n },\n emits: ['update:modelValue'],\n setup(props, { emit }) {\n const $x = use$x()\n\n const { baseColumnPickerList: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const providedSelectedColumns = computed(() => props.modelValue ?? props.columns[0])\n const selectedColumns = ref(providedSelectedColumns.value)\n\n /**\n * Assigns `selectedColumns` value and emits `ColumnsNumberProvided`.\n *\n * @param column - Column number provided.\n */\n function emitColumnsNumberProvided(column: number) {\n selectedColumns.value = column\n $x.emit('ColumnsNumberProvided', column)\n }\n\n /**\n * Emits `update:modelValue` with the column selected.\n *\n * @param column - Column number selected.\n */\n function emitUpdateModelValue(column: number) {\n if (props.modelValue !== column) {\n emit('update:modelValue', column)\n }\n }\n\n watch(providedSelectedColumns, emitColumnsNumberProvided)\n watch(selectedColumns, emitUpdateModelValue)\n\n $x.on('ColumnsNumberProvided', false).subscribe(column => (selectedColumns.value = column))\n\n /**\n * Synchronizes the columns number before mounting the component. If the real number of selected\n * columns equals the provided columns, it emits the event to sync it with every other component.\n * If it is not equal it means that the user has already selected a number of columns, so we emit\n * a `update:modelValue` event so developers can sync the provided value.\n */\n onBeforeMount(() => {\n if (selectedColumns.value === providedSelectedColumns.value) {\n emitColumnsNumberProvided(selectedColumns.value)\n } else {\n emitUpdateModelValue(selectedColumns.value)\n }\n })\n\n /**\n * Maps the column to an object containing: the `column` and `CSS classes`.\n *\n * @returns An array of objects containing the column number and CSS classes.\n */\n const columnsWithCssClasses = computed<ColumnPickerItem[]>(() =>\n props.columns.map(column => ({\n column,\n cssClasses: [\n `x-column-picker-list__button--${column}-cols`,\n { 'xds:selected': selectedColumns.value === column },\n ],\n isSelected: selectedColumns.value === column,\n events: {\n UserClickedColumnPicker: column,\n ColumnsNumberProvided: column,\n },\n })),\n )\n\n return { ariaLabels, columnsWithCssClasses }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on the columns prop. Each\nbutton emits the needed events to sync other instances of column pickers or grids with the\nnumber of columns being selected when clicked.\n\n### Default usage\n\nIt is required to send the columns prop.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n### Using v-model\n\nIt is possible to do two-way binding in order to synchronize the value with the parent. It will be\nupdated if the value changes or if the parent changes it.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" v-model=\"selectedColumns\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\nconst selectedColumns = ref(4)\n</script>\n```\n\n### Customized usage\n\n#### Overriding the slots\n\nIt is possible to override the column picker button content.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #default=\"{ column, isSelected }\">\n <span>{{ column }} {{ isSelected ? '🟢' : '' }}</span>\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\nIt is also possible to add a divider element between the column picker buttons by overriding the\n`divider` slot.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\">\n <template #divider>\n <ChevronRightIcon aria-hidden=\"true\" />\n </template>\n </BaseColumnPickerList>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\nimport ChevronRightIcon from '@empathyco/x-components/js/components/icons/chevron-right.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n#### Customizing the buttons with classes\n\nThe `buttonClass` prop can be used to add classes to the buttons.\n\n```vue live\n<template>\n <BaseColumnPickerList :columns=\"columns\" buttonClass=\"xds:button-circle\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport BaseColumnPickerList from '@empathyco/x-components/js/components/column-picker/base-column-picker-list.vue'\n\nconst columns = ref([2, 4, 6])\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedColumnPicker`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks an item. The event payload is the number of columns\n that the clicked item represents.\n- [`ColumnsNumberProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted on component mount. The event payload is the current `selectedColumns` value.\n</docs>\n"],"names":[],"mappings":";;;;;AAoDA;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,sBAAsB;IAC5B,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;;AAEL,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,KAA2B;AACjC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,UAAU,EAAE,MAAM;;AAElB,QAAA,WAAW,EAAE,MAAM;AACpB,KAAA;IACD,KAAK,EAAE,CAAC,mBAAmB,CAAC;AAC5B,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAG,EAAG,EAAA;AACnB,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;QAEjB,MAAM,EAAE,oBAAoB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;AAEnF,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,UAAS,IAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnF,MAAM,eAAc,GAAI,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAA;AAEzD;;;;AAIE;QACF,SAAS,yBAAyB,CAAC,MAAc,EAAA;AAC/C,YAAA,eAAe,CAAC,KAAI,GAAI,MAAK;AAC7B,YAAA,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAA;QACzC;AAEA;;;;AAIE;QACF,SAAS,oBAAoB,CAAC,MAAc,EAAA;AAC1C,YAAA,IAAI,KAAK,CAAC,UAAS,KAAM,MAAM,EAAE;AAC/B,gBAAA,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAA;YAClC;QACF;AAEA,QAAA,KAAK,CAAC,uBAAuB,EAAE,yBAAyB,CAAA;AACxD,QAAA,KAAK,CAAC,eAAe,EAAE,oBAAoB,CAAA;QAE3C,EAAE,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAK,KAAM,eAAe,CAAC,KAAI,GAAI,MAAM,CAAC,CAAA;AAE1F;;;;;AAKE;QACF,aAAa,CAAC,MAAI;YAChB,IAAI,eAAe,CAAC,KAAI,KAAM,uBAAuB,CAAC,KAAK,EAAE;AAC3D,gBAAA,yBAAyB,CAAC,eAAe,CAAC,KAAK,CAAA;YACjD;iBAAO;AACL,gBAAA,oBAAoB,CAAC,eAAe,CAAC,KAAK,CAAA;YAC5C;AACF,QAAA,CAAC,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAqB,MACzD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAK,KAAM;YAC3B,MAAM;AACN,YAAA,UAAU,EAAE;AACV,gBAAA,CAAA,8BAAA,EAAiC,MAAM,CAAA,KAAA,CAAO;AAC9C,gBAAA,EAAE,cAAc,EAAE,eAAe,CAAC,KAAI,KAAM,MAAK,EAAG;AACrD,aAAA;AACD,YAAA,UAAU,EAAE,eAAe,CAAC,KAAI,KAAM,MAAM;AAC5C,YAAA,MAAM,EAAE;AACN,gBAAA,uBAAuB,EAAE,MAAM;AAC/B,gBAAA,qBAAqB,EAAE,MAAM;AAC9B,aAAA;SACF,CAAC,CAAC,CACL;AAEA,QAAA,OAAO,EAAE,UAAU,EAAE,qBAAoB,EAAE;IAC7C,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -8,14 +8,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
8
8
  events: _ctx.events,
9
9
  class: "x-events-modal-close-button xds:button",
10
10
  "data-test": "close-modal",
11
- "aria-label": "Close"
11
+ "aria-label": _ctx.ariaLabels?.button
12
12
  }, {
13
13
  default: withCtx(() => [
14
14
  renderSlot(_ctx.$slots, "default")
15
15
  ]),
16
16
  _: 3
17
17
  /* FORWARDED */
18
- }, 8, ["events"]);
18
+ }, 8, ["events", "aria-label"]);
19
19
  }
20
20
  var BaseEventsModalClose = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
21
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-events-modal-close.vue.js","sources":["../../../../src/components/modals/base-events-modal-close.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-close-button xds:button\"\n data-test=\"close-modal\"\n aria-label=\"Close\"\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 { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedCloseEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for closing the modal.\n *\n * @public\n */\n closingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedCloseEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.closingEvent]: undefined }))\n return {\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedCloseEventsModal`](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\nThe `BaseEventsModalClose` component can be used to close the `BaseEventsModal` component.\n\n### Basic example\n\nOn click, the component closes the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalClose>\n <img src=\"./close-button-icon.svg\" />\n </BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `closingEvent` that the `BaseEventsModal` is listening to. This event can be changed using the `closingEvent` prop.\n\n```vue\n<template>\n <BaseEventsModalClose closingEvent=\"UserClosedEmpathize\">×</BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACT,KAAA,EAAM,wCAAA;AAAA,IACN,WAAA,EAAU,aAAA;AAAA,IACV,YAAA,EAAW;AAAA,GAAA,EAAA;qBAGX,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"base-events-modal-close.vue.js","sources":["../../../../src/components/modals/base-events-modal-close.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-close-button xds:button\"\n data-test=\"close-modal\"\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 { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedCloseEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for closing the modal.\n *\n * @public\n */\n closingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedCloseEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.closingEvent]: undefined }))\n const { baseEventsModalClose: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n return {\n ariaLabels,\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedCloseEventsModal`](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\nThe `BaseEventsModalClose` component can be used to close the `BaseEventsModal` component.\n\n### Basic example\n\nOn click, the component closes the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalClose>\n <img src=\"./close-button-icon.svg\" />\n </BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `closingEvent` that the `BaseEventsModal` is listening to. This event can be changed using the `closingEvent` prop.\n\n```vue\n<template>\n <BaseEventsModalClose closingEvent=\"UserClosedEmpathize\">×</BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACT,KAAA,EAAM,wCAAA;AAAA,IACN,WAAA,EAAU,aAAA;AAAA,IACT,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;qBAGzB,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, computed, inject } from 'vue';
2
+ import { ACCESSIBILITY_KEY } from '../../types/accessibility.js';
2
3
  import BaseEventButton from '../base-event-button.vue.js';
3
4
 
4
5
  /**
@@ -24,7 +25,9 @@ var _sfc_main = defineComponent({
24
25
  },
25
26
  setup(props) {
26
27
  const events = computed(() => ({ [props.closingEvent]: undefined }));
28
+ const { baseEventsModalClose: ariaLabels } = inject(ACCESSIBILITY_KEY);
27
29
  return {
30
+ ariaLabels,
28
31
  events,
29
32
  };
30
33
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base-events-modal-close.vue2.js","sources":["../../../../src/components/modals/base-events-modal-close.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-close-button xds:button\"\n data-test=\"close-modal\"\n aria-label=\"Close\"\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 { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedCloseEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for closing the modal.\n *\n * @public\n */\n closingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedCloseEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.closingEvent]: undefined }))\n return {\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedCloseEventsModal`](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\nThe `BaseEventsModalClose` component can be used to close the `BaseEventsModal` component.\n\n### Basic example\n\nOn click, the component closes the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalClose>\n <img src=\"./close-button-icon.svg\" />\n </BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `closingEvent` that the `BaseEventsModal` is listening to. This event can be changed using the `closingEvent` prop.\n\n```vue\n<template>\n <BaseEventsModalClose closingEvent=\"UserClosedEmpathize\">×</BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;AAmBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAqD;AAC3D,YAAA,OAAO,EAAE,6BAA6B;AACvC,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAwB,OAAO,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,SAAQ,EAAG,CAAC,CAAA;QAC1F,OAAO;YACL,MAAM;SACR;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-events-modal-close.vue2.js","sources":["../../../../src/components/modals/base-events-modal-close.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-close-button xds:button\"\n data-test=\"close-modal\"\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 { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedCloseEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for closing the modal.\n *\n * @public\n */\n closingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedCloseEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.closingEvent]: undefined }))\n const { baseEventsModalClose: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n return {\n ariaLabels,\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedCloseEventsModal`](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\nThe `BaseEventsModalClose` component can be used to close the `BaseEventsModal` component.\n\n### Basic example\n\nOn click, the component closes the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalClose>\n <img src=\"./close-button-icon.svg\" />\n </BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `closingEvent` that the `BaseEventsModal` is listening to. This event can be changed using the `closingEvent` prop.\n\n```vue\n<template>\n <BaseEventsModalClose closingEvent=\"UserClosedEmpathize\">×</BaseEventsModalClose>\n</template>\n\n<script setup>\nimport { BaseEventsModalClose } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAqBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAqD;AAC3D,YAAA,OAAO,EAAE,6BAA6B;AACvC,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAwB,OAAO,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,SAAQ,EAAG,CAAC,CAAA;QAC1F,MAAM,EAAE,oBAAoB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;QAEnF,OAAO;YACL,UAAU;YACV,MAAM;SACR;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -8,14 +8,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
8
8
  events: _ctx.events,
9
9
  class: "x-events-modal-open-button xds:button",
10
10
  "data-test": "open-modal",
11
- "aria-label": "Open"
11
+ "aria-label": _ctx.ariaLabels?.button
12
12
  }, {
13
13
  default: withCtx(() => [
14
14
  renderSlot(_ctx.$slots, "default")
15
15
  ]),
16
16
  _: 3
17
17
  /* FORWARDED */
18
- }, 8, ["events"]);
18
+ }, 8, ["events", "aria-label"]);
19
19
  }
20
20
  var BaseEventsModalOpen = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
21
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-events-modal-open.vue.js","sources":["../../../../src/components/modals/base-events-modal-open.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-open-button xds:button\"\n data-test=\"open-modal\"\n aria-label=\"Open\"\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 { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedOpenEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for opening the modal.\n *\n * @public\n */\n openingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedOpenEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.openingEvent]: undefined }))\n\n return {\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedOpenEventsModal`](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\nThis component serves to open the `BaseEventsModal`.\n\n### Basic example\n\nOn click, the component opens the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalOpen>\n <img src=\"./open-button-icon.svg\" />\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `openingEvent` that the `BaseEventsModal` is listening to by default.\nThis event can be changed using the `openingEvent` prop, but remember to change it in the target `BaseEventsModal` too.\n\n```vue\n<template>\n <BaseEventsModalOpen openingEvent=\"UserOpenedEmpathize\">\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACT,KAAA,EAAM,uCAAA;AAAA,IACN,WAAA,EAAU,YAAA;AAAA,IACV,YAAA,EAAW;AAAA,GAAA,EAAA;qBAGX,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"base-events-modal-open.vue.js","sources":["../../../../src/components/modals/base-events-modal-open.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-open-button xds:button\"\n data-test=\"open-modal\"\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 { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedOpenEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for opening the modal.\n *\n * @public\n */\n openingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedOpenEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.openingEvent]: undefined }))\n const { baseEventsModalOpen: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n return {\n ariaLabels,\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedOpenEventsModal`](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\nThis component serves to open the `BaseEventsModal`.\n\n### Basic example\n\nOn click, the component opens the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalOpen>\n <img src=\"./open-button-icon.svg\" />\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `openingEvent` that the `BaseEventsModal` is listening to by default.\nThis event can be changed using the `openingEvent` prop, but remember to change it in the target `BaseEventsModal` too.\n\n```vue\n<template>\n <BaseEventsModalOpen openingEvent=\"UserOpenedEmpathize\">\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAQkB,0BAAA,EAAA;AAAA,IAPf,MAAA,EAAQ,IAAA,CAAA,MAAA;AAAA,IACT,KAAA,EAAM,uCAAA;AAAA,IACN,WAAA,EAAU,YAAA;AAAA,IACT,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;qBAGzB,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
- import { defineComponent, computed } from 'vue';
1
+ import { defineComponent, computed, inject } from 'vue';
2
+ import { ACCESSIBILITY_KEY } from '../../types/accessibility.js';
2
3
  import BaseEventButton from '../base-event-button.vue.js';
3
4
 
4
5
  /**
@@ -24,7 +25,9 @@ var _sfc_main = defineComponent({
24
25
  },
25
26
  setup(props) {
26
27
  const events = computed(() => ({ [props.openingEvent]: undefined }));
28
+ const { baseEventsModalOpen: ariaLabels } = inject(ACCESSIBILITY_KEY);
27
29
  return {
30
+ ariaLabels,
28
31
  events,
29
32
  };
30
33
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base-events-modal-open.vue2.js","sources":["../../../../src/components/modals/base-events-modal-open.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-open-button xds:button\"\n data-test=\"open-modal\"\n aria-label=\"Open\"\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 { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedOpenEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for opening the modal.\n *\n * @public\n */\n openingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedOpenEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.openingEvent]: undefined }))\n\n return {\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedOpenEventsModal`](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\nThis component serves to open the `BaseEventsModal`.\n\n### Basic example\n\nOn click, the component opens the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalOpen>\n <img src=\"./open-button-icon.svg\" />\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `openingEvent` that the `BaseEventsModal` is listening to by default.\nThis event can be changed using the `openingEvent` prop, but remember to change it in the target `BaseEventsModal` too.\n\n```vue\n<template>\n <BaseEventsModalOpen openingEvent=\"UserOpenedEmpathize\">\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;AAmBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAqD;AAC3D,YAAA,OAAO,EAAE,4BAA4B;AACtC,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAwB,OAAO,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,SAAQ,EAAG,CAAC,CAAA;QAE1F,OAAO;YACL,MAAM;SACR;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-events-modal-open.vue2.js","sources":["../../../../src/components/modals/base-events-modal-open.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-events-modal-open-button xds:button\"\n data-test=\"open-modal\"\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 { PropType } from 'vue'\nimport type { AriaLabels } from '../../types'\nimport type { PropsWithType } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../../types'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component contains an event button that emits {@link XEventsTypes.UserClickedOpenEventsModal}\n * when clicked. It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * Event name to use for opening the modal.\n *\n * @public\n */\n openingEvent: {\n type: String as PropType<PropsWithType<XEventsTypes, void>>,\n default: 'UserClickedOpenEventsModal',\n },\n },\n setup(props) {\n const events = computed<Partial<XEventsTypes>>(() => ({ [props.openingEvent]: undefined }))\n const { baseEventsModalOpen: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n return {\n ariaLabels,\n events,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedOpenEventsModal`](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\nThis component serves to open the `BaseEventsModal`.\n\n### Basic example\n\nOn click, the component opens the `BaseEventsModal`. The only required part is the content that\nthe button should render, which can be anything: text, image, icon, or a combination.\n\n```vue\n<template>\n <BaseEventsModalOpen>\n <img src=\"./open-button-icon.svg\" />\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n\n### Defining another event to emit when clicking the button\n\nBy default, it uses the same `openingEvent` that the `BaseEventsModal` is listening to by default.\nThis event can be changed using the `openingEvent` prop, but remember to change it in the target `BaseEventsModal` too.\n\n```vue\n<template>\n <BaseEventsModalOpen openingEvent=\"UserOpenedEmpathize\">\n <span>Open</span>\n </BaseEventsModalOpen>\n</template>\n\n<script setup>\nimport { BaseEventsModalOpen } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAqBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAqD;AAC3D,YAAA,OAAO,EAAE,4BAA4B;AACtC,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,MAAK,GAAI,QAAQ,CAAwB,OAAO,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,SAAQ,EAAG,CAAC,CAAA;QAC1F,MAAM,EAAE,mBAAmB,EAAE,UAAS,EAAE,GAAI,MAAM,CAAC,iBAAiB,CAAc;QAElF,OAAO;YACL,UAAU;YACV,MAAM;SACR;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
@@ -8,6 +8,7 @@ const _hoisted_1 = {
8
8
  class: "x-modal",
9
9
  "data-test": "modal"
10
10
  };
11
+ const _hoisted_2 = ["aria-label"];
11
12
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
12
13
  return withDirectives((openBlock(), createElementBlock(
13
14
  "div",
@@ -21,22 +22,16 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
21
22
  },
22
23
  {
23
24
  default: withCtx(() => [
24
- _ctx.open ? (openBlock(), createElementBlock(
25
- "div",
26
- {
27
- key: 0,
28
- ref: "modalContentRef",
29
- class: normalizeClass(["x-modal__content", _ctx.contentClass]),
30
- "data-test": "modal-content",
31
- role: "dialog",
32
- "aria-label": "Base modal content"
33
- },
34
- [
35
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
36
- ],
37
- 2
38
- /* CLASS */
39
- )) : createCommentVNode("v-if", true)
25
+ _ctx.open ? (openBlock(), createElementBlock("div", {
26
+ key: 0,
27
+ ref: "modalContentRef",
28
+ class: normalizeClass(["x-modal__content", _ctx.contentClass]),
29
+ "data-test": "modal-content",
30
+ role: "dialog",
31
+ "aria-label": _ctx.ariaLabels?.modal
32
+ }, [
33
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
34
+ ], 10, _hoisted_2)) : createCommentVNode("v-if", true)
40
35
  ]),
41
36
  _: 3
42
37
  /* FORWARDED */
@@ -1 +1 @@
1
- {"version":3,"file":"base-modal.vue.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n aria-label=\"Base modal content\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useDebounce } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["_withDirectives","_openBlock","_createElementBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_renderSlot","_withCtx","_vShow"],"mappings":";;;;;;EAC0C,GAAA,EAAI,UAAA;AAAA,EAAW,KAAA,EAAM,SAAA;AAAA,EAAU,WAAA,EAAU;;;AAAjF,EAAA,OAAAA,cAAA,EAAAC,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA6BM,KAAA;AAAA,IA7BN,UAAA;AAAA,IA6BM;AAAA,OAAAD,SAAA,EAAA,EA5BJE,WAAA;AAAA,QAiBYC,wBAhBL,IAAA,CAAA,SAAS,CAAA;AAAA,QAAA;AAAA,UACb,aAAA,EAAY,sCAAE,IAAA,CAAA,iBAAA,GAAiB,IAAA,CAAA;AAAA,UAC/B,YAAA,EAAW,sCAAE,IAAA,CAAA,iBAAA,GAAiB,KAAA;AAAA,SAAA;;2BAE/B,MAWM;AAAA,YAVE,IAAA,CAAA,IAAA,IAAAH,SAAA,EAAA,EADRC,kBAAA;AAAA,cAWM,KAAA;AAAA,cAAA;AAAA,gBAAA,GAAA,EAAA,CAAA;gBATJ,GAAA,EAAI,iBAAA;AAAA,gBACJ,KAAA,EAAKG,cAAA,CAAA,CAAC,kBAAA,EAGE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,gBAFpB,WAAA,EAAU,eAAA;AAAA,gBACV,IAAA,EAAK,QAAA;AAAA,gBAEL,YAAA,EAAW;AAAA,eAAA;;gBAGXC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,EAAA,MAAA,EAAA,IAAA;AAAA,eAAA;;;;;;;;;;;AAGZ,OAAAL,SAAA,EAAA,EAAAE,WAAA,CASYC,wBATI,IAAA,CAAA,gBAAgB,CAAA,EAAA,IAAA,EAAA;AAAA,QAAA,OAAA,EAAAG,OAAA,CAC9B,MAOE;AAAA,UANM,IAAA,CAAA,IAAA,IAAAN,SAAA,EAAA,EADRC,kBAAA;AAAA,YAOE,KAAA;AAAA,YAAA;AAAA,cAAA,GAAA,EAAA,CAAA;cALA,KAAA,EAAKG,cAAA,CAAA,CAAC,oBACE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,cACpB,WAAA,EAAU,eAAA;AAAA,cACT,SAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,cACP,WAAO,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA;AAAA,aAAA;;;;;;;;;;;;;AA1BH,IAAA,CAAAG,KAAA,EAAA,IAAA,CAAA,iBAAA,IAAqB,IAAA,CAAA,IAAI;AAAA,GAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"base-modal.vue.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n :aria-label=\"ariaLabels?.modal\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { AriaLabels } from '../../types'\nimport { defineComponent, inject, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useDebounce } from '../../composables'\nimport { ACCESSIBILITY_KEY, AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n const { baseModal: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n ariaLabels,\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["_withDirectives","_openBlock","_createElementBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_renderSlot","_createCommentVNode","_withCtx","_vShow"],"mappings":";;;;;;EAC0C,GAAA,EAAI,UAAA;AAAA,EAAW,KAAA,EAAM,SAAA;AAAA,EAAU,WAAA,EAAU;;;;AAAjF,EAAA,OAAAA,cAAA,EAAAC,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA6BM,KAAA;AAAA,IA7BN,UAAA;AAAA,IA6BM;AAAA,OAAAD,SAAA,EAAA,EA5BJE,WAAA;AAAA,QAiBYC,wBAhBL,IAAA,CAAA,SAAS,CAAA;AAAA,QAAA;AAAA,UACb,aAAA,EAAY,sCAAE,IAAA,CAAA,iBAAA,GAAiB,IAAA,CAAA;AAAA,UAC/B,YAAA,EAAW,sCAAE,IAAA,CAAA,iBAAA,GAAiB,KAAA;AAAA,SAAA;;2BAE/B,MAWM;AAAA,YAVE,0BADRF,kBAAA,CAWM,KAAA,EAAA;AAAA,cAAA,GAAA,EAAA,CAAA;cATJ,GAAA,EAAI,iBAAA;AAAA,cACJ,KAAA,EAAKG,cAAA,CAAA,CAAC,kBAAA,EAGE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,cAFpB,WAAA,EAAU,eAAA;AAAA,cACV,IAAA,EAAK,QAAA;AAAA,cAEJ,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,aAAA,EAAA;cAGzBC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,EAAA,MAAA,EAAA,IAAA;AAAA,aAAA,EAAA,EAAA,EAAA,UAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;AAGZ,OAAAN,SAAA,EAAA,EAAAE,WAAA,CASYC,wBATI,IAAA,CAAA,gBAAgB,CAAA,EAAA,IAAA,EAAA;AAAA,QAAA,OAAA,EAAAI,OAAA,CAC9B,MAOE;AAAA,UANM,IAAA,CAAA,IAAA,IAAAP,SAAA,EAAA,EADRC,kBAAA;AAAA,YAOE,KAAA;AAAA,YAAA;AAAA,cAAA,GAAA,EAAA,CAAA;cALA,KAAA,EAAKG,cAAA,CAAA,CAAC,oBACE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,cACpB,WAAA,EAAU,eAAA;AAAA,cACT,SAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,cACP,WAAO,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA;AAAA,aAAA;;;;;;;;;;;;;AA1BH,IAAA,CAAAI,KAAA,EAAA,IAAA,CAAA,iBAAA,IAAqB,IAAA,CAAA,IAAI;AAAA,GAAA,CAAA;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, onMounted, watch, onBeforeUnmount, nextTick } from 'vue';
1
+ import { defineComponent, inject, ref, onMounted, watch, onBeforeUnmount, nextTick } from 'vue';
2
2
  import '../../composables/create-use-device.js';
3
3
  import 'vuex';
4
4
  import '../../plugins/x-bus.js';
@@ -7,6 +7,7 @@ import '../../plugins/x-plugin.js';
7
7
  import 'rxjs';
8
8
  import { useDebounce } from '../../composables/use-debounce.js';
9
9
  import '@vueuse/core';
10
+ import { ACCESSIBILITY_KEY } from '../../types/accessibility.js';
10
11
  import { AnimationProp } from '../../types/animation-prop.js';
11
12
  import { FOCUSABLE_SELECTORS } from '../../utils/focus.js';
12
13
  import { getTargetElement } from '../../utils/html.js';
@@ -79,6 +80,7 @@ var _sfc_main = defineComponent({
79
80
  },
80
81
  emits: ['click:overlay', 'focusin:body'],
81
82
  setup(props, { emit }) {
83
+ const { baseModal: ariaLabels } = inject(ACCESSIBILITY_KEY);
82
84
  /** Reference to the modal element in the DOM. */
83
85
  const modalRef = ref();
84
86
  /** Reference to the modal content element in the DOM. */
@@ -211,6 +213,7 @@ var _sfc_main = defineComponent({
211
213
  resizeObserver.disconnect();
212
214
  });
213
215
  return {
216
+ ariaLabels,
214
217
  emitOverlayClicked,
215
218
  isWaitingForLeave,
216
219
  modalContentRef,