@empathyco/x-components 9.3.1 → 9.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/core/index.js +3 -1
- package/core/index.js.map +1 -1
- package/docs/API-reference/api/x-components.aicarousel.md +2 -2
- package/docs/API-reference/api/x-components.basecolumnpickerdropdown.md +2 -2
- package/docs/API-reference/api/x-components.basecolumnpickerlist.md +2 -2
- package/docs/API-reference/api/x-components.basedropdown.md +2 -2
- package/docs/API-reference/api/x-components.baseeventsmodalclose.md +2 -2
- package/docs/API-reference/api/x-components.baseeventsmodalopen.md +2 -2
- package/docs/API-reference/api/x-components.basemodal.md +2 -2
- package/docs/API-reference/api/x-components.clearhistoryqueries.md +2 -2
- package/docs/API-reference/api/x-components.deepmergewithdefaults.md +85 -0
- package/docs/API-reference/api/x-components.editablenumberrangefilter.md +2 -2
- package/docs/API-reference/api/x-components.facets.md +2 -2
- package/docs/API-reference/api/x-components.filterssearch.md +2 -2
- package/docs/API-reference/api/x-components.historyqueriesswitch.md +2 -2
- package/docs/API-reference/api/x-components.historyquery.md +2 -2
- package/docs/API-reference/api/x-components.md +30 -0
- package/docs/API-reference/api/x-components.pageloaderbutton.md +2 -2
- package/docs/API-reference/api/x-components.pageselector.md +2 -2
- package/docs/API-reference/api/x-components.removehistoryquery.md +2 -2
- package/docs/API-reference/api/x-components.scrolltotop.md +2 -2
- package/docs/API-reference/api/x-components.searchinput.md +2 -2
- package/docs/API-reference/api/x-components.sliderfilter.md +2 -2
- package/docs/API-reference/api/x-components.sortdropdown.md +2 -2
- package/docs/API-reference/api/x-components.useaccessibilitylabels.md +72 -0
- package/js/components/base-dropdown.vue.js.map +1 -1
- package/js/components/base-dropdown.vue2.js +11 -4
- package/js/components/base-dropdown.vue2.js.map +1 -1
- package/js/components/base-keyboard-navigation.vue2.js +1 -0
- package/js/components/base-keyboard-navigation.vue2.js.map +1 -1
- package/js/components/column-picker/base-column-picker-dropdown.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-dropdown.vue2.js +10 -3
- package/js/components/column-picker/base-column-picker-dropdown.vue2.js.map +1 -1
- package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
- package/js/components/column-picker/base-column-picker-list.vue2.js +10 -3
- package/js/components/column-picker/base-column-picker-list.vue2.js.map +1 -1
- package/js/components/display-click-provider.vue.js +2 -1
- package/js/components/display-click-provider.vue.js.map +1 -1
- package/js/components/highlight.vue2.js +1 -0
- package/js/components/highlight.vue2.js.map +1 -1
- package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-close.vue2.js +10 -3
- package/js/components/modals/base-events-modal-close.vue2.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue2.js +10 -3
- package/js/components/modals/base-events-modal-open.vue2.js.map +1 -1
- package/js/components/modals/base-id-modal-close.vue2.js +2 -1
- package/js/components/modals/base-id-modal-close.vue2.js.map +1 -1
- package/js/components/modals/base-id-modal-open.vue2.js +2 -1
- package/js/components/modals/base-id-modal-open.vue2.js.map +1 -1
- package/js/components/modals/base-id-modal.vue2.js +2 -1
- package/js/components/modals/base-id-modal.vue2.js.map +1 -1
- package/js/components/modals/base-modal.vue.js.map +1 -1
- package/js/components/modals/base-modal.vue2.js +3 -3
- package/js/components/modals/base-modal.vue2.js.map +1 -1
- package/js/components/page-loader-button.vue.js.map +1 -1
- package/js/components/page-loader-button.vue2.js +3 -3
- package/js/components/page-loader-button.vue2.js.map +1 -1
- package/js/components/page-selector.vue.js.map +1 -1
- package/js/components/page-selector.vue2.js +3 -3
- package/js/components/page-selector.vue2.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel-button.vue2.js +1 -0
- package/js/components/panels/base-id-toggle-panel-button.vue2.js.map +1 -1
- package/js/components/panels/base-id-toggle-panel.vue2.js +2 -1
- package/js/components/panels/base-id-toggle-panel.vue2.js.map +1 -1
- package/js/components/result/base-result-link.vue2.js +2 -1
- package/js/components/result/base-result-link.vue2.js.map +1 -1
- package/js/components/result/base-result-rating.vue2.js +2 -1
- package/js/components/result/base-result-rating.vue2.js.map +1 -1
- package/js/components/sort/sort-dropdown.vue.js.map +1 -1
- package/js/components/sort/sort-dropdown.vue2.js +10 -3
- package/js/components/sort/sort-dropdown.vue2.js.map +1 -1
- package/js/components/suggestions/base-suggestion.vue2.js +1 -0
- package/js/components/suggestions/base-suggestion.vue2.js.map +1 -1
- package/js/composables/use-accessibility-labels.js +40 -0
- package/js/composables/use-accessibility-labels.js.map +1 -0
- package/js/index.js +3 -1
- package/js/index.js.map +1 -1
- package/js/utils/accessibility.js +1 -19
- package/js/utils/accessibility.js.map +1 -1
- package/js/utils/deep-merge-with-defaults.js +47 -0
- package/js/utils/deep-merge-with-defaults.js.map +1 -0
- package/js/x-installer/x-installer.js +0 -4
- package/js/x-installer/x-installer.js.map +1 -1
- package/js/x-modules/ai/components/ai-carousel.vue.js.map +1 -1
- package/js/x-modules/ai/components/ai-carousel.vue2.js +3 -3
- package/js/x-modules/ai/components/ai-carousel.vue2.js.map +1 -1
- package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js +1 -0
- package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue2.js +2 -2
- package/js/x-modules/facets/components/facets/facets-provider.vue2.js +1 -0
- package/js/x-modules/facets/components/facets/facets-provider.vue2.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue2.js +9 -3
- package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js +3 -3
- package/js/x-modules/facets/components/filters/editable-number-range-filter.vue2.js.map +1 -1
- package/js/x-modules/facets/components/filters/slider-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/slider-filter.vue2.js +3 -3
- package/js/x-modules/facets/components/filters/slider-filter.vue2.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-search.vue.js.map +1 -1
- package/js/x-modules/facets/components/lists/filters-search.vue2.js +10 -3
- package/js/x-modules/facets/components/lists/filters-search.vue2.js.map +1 -1
- package/js/x-modules/facets/components/lists/sorted-filters.vue.js +1 -0
- package/js/x-modules/facets/components/lists/sorted-filters.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/clear-history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/clear-history-queries.vue2.js +10 -3
- package/js/x-modules/history-queries/components/clear-history-queries.vue2.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries-switch.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries-switch.vue2.js +10 -3
- package/js/x-modules/history-queries/components/history-queries-switch.vue2.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue2.js +10 -3
- package/js/x-modules/history-queries/components/history-query.vue2.js.map +1 -1
- package/js/x-modules/history-queries/components/remove-history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/remove-history-query.vue2.js +10 -3
- package/js/x-modules/history-queries/components/remove-history-query.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-list.vue2.js +1 -0
- package/js/x-modules/queries-preview/components/query-preview-list.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue2.js +2 -2
- package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js +1 -0
- package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js +1 -0
- package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js.map +1 -1
- package/js/x-modules/recommendations/components/recommendations.vue2.js +1 -0
- package/js/x-modules/recommendations/components/recommendations.vue2.js.map +1 -1
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +2 -1
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js +3 -3
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
- package/js/x-modules/search/wiring.js +1 -0
- package/js/x-modules/search/wiring.js.map +1 -1
- package/js/x-modules/search-box/components/search-input.vue.js.map +1 -1
- package/js/x-modules/search-box/components/search-input.vue2.js +11 -4
- package/js/x-modules/search-box/components/search-input.vue2.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-queries.vue2.js +1 -0
- package/js/x-modules/semantic-queries/components/semantic-queries.vue2.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +401 -40
- package/report/x-components.api.md +46 -43
- package/types/src/components/base-dropdown.vue.d.ts +2 -2
- package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts +2 -2
- package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts.map +1 -1
- package/types/src/components/column-picker/base-column-picker-list.vue.d.ts +2 -2
- package/types/src/components/column-picker/base-column-picker-list.vue.d.ts.map +1 -1
- package/types/src/components/modals/base-events-modal-close.vue.d.ts +2 -2
- package/types/src/components/modals/base-events-modal-close.vue.d.ts.map +1 -1
- package/types/src/components/modals/base-events-modal-open.vue.d.ts +2 -2
- package/types/src/components/modals/base-events-modal-open.vue.d.ts.map +1 -1
- package/types/src/components/modals/base-modal.vue.d.ts +2 -2
- package/types/src/components/modals/base-modal.vue.d.ts.map +1 -1
- package/types/src/components/page-loader-button.vue.d.ts +2 -2
- package/types/src/components/page-loader-button.vue.d.ts.map +1 -1
- package/types/src/components/page-selector.vue.d.ts +2 -2
- package/types/src/components/page-selector.vue.d.ts.map +1 -1
- package/types/src/components/sort/sort-dropdown.vue.d.ts +2 -2
- package/types/src/components/sort/sort-dropdown.vue.d.ts.map +1 -1
- package/types/src/composables/index.d.ts +1 -0
- package/types/src/composables/index.d.ts.map +1 -1
- package/types/src/composables/use-accessibility-labels.d.ts +31 -0
- package/types/src/composables/use-accessibility-labels.d.ts.map +1 -0
- package/types/src/utils/accessibility.d.ts +0 -10
- package/types/src/utils/accessibility.d.ts.map +1 -1
- package/types/src/utils/deep-merge-with-defaults.d.ts +28 -0
- package/types/src/utils/deep-merge-with-defaults.d.ts.map +1 -0
- package/types/src/utils/index.d.ts +1 -0
- package/types/src/utils/index.d.ts.map +1 -1
- package/types/src/x-installer/x-installer.d.ts.map +1 -1
- package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts +2 -2
- package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts.map +1 -1
- package/types/src/x-modules/facets/components/facets/facets.vue.d.ts +2 -2
- package/types/src/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
- package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts +2 -2
- package/types/src/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts.map +1 -1
- package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts +2 -2
- package/types/src/x-modules/facets/components/filters/slider-filter.vue.d.ts.map +1 -1
- package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts +2 -2
- package/types/src/x-modules/facets/components/lists/filters-search.vue.d.ts.map +1 -1
- package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts +2 -2
- package/types/src/x-modules/history-queries/components/clear-history-queries.vue.d.ts.map +1 -1
- package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts +2 -2
- package/types/src/x-modules/history-queries/components/history-queries-switch.vue.d.ts.map +1 -1
- package/types/src/x-modules/history-queries/components/history-query.vue.d.ts +2 -2
- package/types/src/x-modules/history-queries/components/history-query.vue.d.ts.map +1 -1
- package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts +2 -2
- package/types/src/x-modules/history-queries/components/remove-history-query.vue.d.ts.map +1 -1
- package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts +2 -2
- package/types/src/x-modules/scroll/components/scroll-to-top.vue.d.ts.map +1 -1
- package/types/src/x-modules/search-box/components/search-input.vue.d.ts +2 -2
- package/types/src/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-selector.vue.js","sources":["../../../src/components/page-selector.vue"],"sourcesContent":["<template>\n <nav v-if=\"visiblePages?.length > 1\" class=\"x-page-selector\" :aria-label=\"ariaLabels?.pagination\">\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === 1\"\n data-test=\"previous-page-button\"\n :aria-label=\"ariaLabels?.prevPage\"\n :aria-disabled=\"currentPage === 1\"\n @click=\"selectPage(currentPage - 1)\"\n >\n <slot name=\"previous-page-button\">Prev</slot>\n </button>\n\n <button\n v-for=\"page in visiblePages\"\n :key=\"page.value\"\n class=\"x-page-selector__page xds:button\"\n :class=\"[\n itemClasses(page.isSelected),\n {\n 'x-page-selector__page--current': page.isSelected,\n 'x-page-selector__page--hidden': page.value === hiddenPage,\n },\n ]\"\n :data-test=\"`page-button-${page.value}`\"\n :aria-label=\"ariaLabels?.numberPage!(page.value)\"\n :aria-current=\"page.isSelected ? 'page' : undefined\"\n @click=\"selectPage(page.value)\"\n >\n <slot name=\"page-button\" :page=\"page.value\" :is-selected=\"page.isSelected\">\n {{ page.value }}\n </slot>\n </button>\n\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === totalPages\"\n data-test=\"next-page-button\"\n :aria-label=\"ariaLabels?.nextPage\"\n :aria-disabled=\"currentPage === totalPages\"\n @click=\"selectPage(currentPage + 1)\"\n >\n <slot name=\"next-page-button\">Next</slot>\n </button>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { useXBus } from '../composables'\nimport { ACCESSIBILITY_KEY } from '../types'\n\ninterface PageItem {\n value: number | string\n isSelected: boolean\n}\n\n/**\n * Component that renders a pagination control with buttons for navigating\n * between pages. It displays the current page, allows selecting other pages,\n * and emits events when a page is selected.\n *\n * @public\n */\nexport default defineComponent({\n name: 'PageSelector',\n props: {\n /**\n * CSS classes to customize the prev/next buttons.\n */\n buttonClasses: {\n type: Array as PropType<(string | Dictionary<boolean>)[]>,\n default: () => [],\n },\n /**\n * The current page number.\n */\n currentPage: {\n type: Number,\n required: true,\n },\n /**\n * The string content of the hidden pages.\n */\n hiddenPage: {\n type: String,\n default: '...',\n },\n /**\n * CSS classes to customize the page items.\n */\n itemClasses: {\n type: Function as PropType<\n (isSelected: boolean) => string | Dictionary<boolean> | (string | Dictionary<boolean>)[]\n >,\n default: () => [],\n },\n /**\n * The number of pages to show before and after the current page.\n */\n range: {\n type: Number,\n default: 2,\n },\n /**\n * The class of the scroll container to scroll to top when a page is selected.\n */\n scrollTarget: {\n type: String,\n default: 'main-scroll',\n },\n /**\n * The total number of pages.\n */\n totalPages: {\n type: Number,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n const { pageSelector: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const visiblePages = computed(() => {\n const start = Math.max(props.currentPage - props.range, 1)\n const end = Math.min(props.currentPage + props.range, props.totalPages)\n const pages: PageItem[] = Array.from({ length: end - start + 1 }, (_, i) => {\n const pageValue: string | number = start + i\n return { value: pageValue, isSelected: pageValue === props.currentPage }\n })\n\n // Ensure first and last pages are always visible when needed\n if (start > 1) {\n pages.unshift({ value: 1, isSelected: props.currentPage === 1 })\n if (start > 2) {\n pages.splice(1, 0, { value: props.hiddenPage, isSelected: false })\n }\n }\n if (end < props.totalPages) {\n if (end < props.totalPages - 1) {\n pages.push({ value: props.hiddenPage, isSelected: false })\n }\n pages.push({\n value: props.totalPages,\n isSelected: props.totalPages === props.currentPage,\n })\n }\n\n return pages\n })\n\n /**\n * Handles the selection of a page.\n *\n * @param page - The page to select. Can be a number representing the page number or a string '...' indicating an ellipsis.\n */\n const selectPage = (page: number | string): void => {\n if (page === '...') {\n return\n }\n if (typeof page === 'number' && page > 0 && page <= props.totalPages) {\n bus.emit('UserSelectedAPage', page)\n /**\n * Emits scroll to top to prevent keeping the position if there is more content\n * after results, as for example Next Queries Preview.\n */\n bus.emit('UserClickedScrollToTop', props.scrollTarget)\n }\n }\n\n return {\n ariaLabels,\n visiblePages,\n selectPage,\n }\n },\n})\n</script>\n\n<style scoped>\n.x-page-selector {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n}\n\n.x-page-selector__page--current,\n.x-page-selector__page--hidden {\n cursor: default;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the \"UserSelectedAPage\" and the UserClickedScrollToTop events by default.\n\n## See it in action\n\nBasic example of how the component is rendered.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 0,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the slots\n\nThis component allows to customise its content using slots.\n\n```vue live\n<template>\n <PageSelector\n :total-pages=\"totalPages\"\n :currentPage=\"page\"\n :item-classes=\"\n (isSelected: boolean) =>\n isSelected\n ? 'x-button-lead x-text-neutral-10'\n : 'x-text-neutral-90 x-button-outlined'\n \"\n :buttonClasses=\"['x-rounded-md']\"\n >\n <template #previous-page-button>\n <span>Back</span>\n </template>\n <template #page-button=\"{ page, isSelected }\">\n <h2 :class=\"{ 'x-text1': !isSelected }\">\n {{ page }}\n </h2>\n </template>\n <template #next-page-button>\n <span>Forward</span>\n </template>\n </PageSelector>\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 2,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the number of pages to show before and after the current page by changing the range default value.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" :range=\"range\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 6,\n totalPages: 100,\n range: 4,\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":["_createElementBlock","_createElementVNode","_normalizeClass","_renderSlot","_createTextVNode","_openBlock","_Fragment","_renderList","_toDisplayString"],"mappings":";;;;;;;;;;SACa,IAAA,CAAA,YAAA,EAAc,MAAA,GAAM,kBAA/BA,kBAAA,CA6CM,KAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;IA7C+B,KAAA,EAAM,iBAAA;AAAA,IAAmB,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;IACpFC,kBAAA,CAUS,QAAA,EAAA;AAAA,MATP,KAAA,EAAKC,cAAA,CAAA,CAAC,YAAA,EACE,IAAA,CAAA,aAAa,CAAA,CAAA;AAAA,MACpB,UAAU,IAAA,CAAA,WAAA,KAAW,CAAA;AAAA,MACtB,WAAA,EAAU,sBAAA;AAAA,MACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,MACxB,iBAAe,IAAA,CAAA,WAAA,KAAW,CAAA;AAAA,MAC1B,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,UAAA,CAAW,IAAA,CAAA,WAAA,GAAW,CAAA,CAAA;AAAA,KAAA,EAAA;AAE9B,MAAAC,UAAA,CAA6C,yCAA7C,MAA6C;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAX,UAAA,MAAA;AAAA,UAAI;AAAA;AAAA,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AAAA,MAC3B,WAAA,EAAU,kBAAA;AAAA,MACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,MACxB,iBAAe,IAAA,CAAA,WAAA,KAAgB,IAAA,CAAA,UAAA;AAAA,MAC/B,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,UAAA,CAAW,IAAA,CAAA,WAAA,GAAW,CAAA,CAAA;AAAA,KAAA,EAAA;AAE9B,MAAAC,UAAA,CAAyC,qCAAzC,MAAyC;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAX,UAAA,MAAA;AAAA,UAAI;AAAA;AAAA,SAAA;AAAA,OAAA,EAAA,IAAA;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"page-selector.vue.js","sources":["../../../src/components/page-selector.vue"],"sourcesContent":["<template>\n <nav v-if=\"visiblePages?.length > 1\" class=\"x-page-selector\" :aria-label=\"ariaLabels?.pagination\">\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === 1\"\n data-test=\"previous-page-button\"\n :aria-label=\"ariaLabels?.prevPage\"\n :aria-disabled=\"currentPage === 1\"\n @click=\"selectPage(currentPage - 1)\"\n >\n <slot name=\"previous-page-button\">Prev</slot>\n </button>\n\n <button\n v-for=\"page in visiblePages\"\n :key=\"page.value\"\n class=\"x-page-selector__page xds:button\"\n :class=\"[\n itemClasses(page.isSelected),\n {\n 'x-page-selector__page--current': page.isSelected,\n 'x-page-selector__page--hidden': page.value === hiddenPage,\n },\n ]\"\n :data-test=\"`page-button-${page.value}`\"\n :aria-label=\"ariaLabels?.numberPage!(page.value)\"\n :aria-current=\"page.isSelected ? 'page' : undefined\"\n @click=\"selectPage(page.value)\"\n >\n <slot name=\"page-button\" :page=\"page.value\" :is-selected=\"page.isSelected\">\n {{ page.value }}\n </slot>\n </button>\n\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === totalPages\"\n data-test=\"next-page-button\"\n :aria-label=\"ariaLabels?.nextPage\"\n :aria-disabled=\"currentPage === totalPages\"\n @click=\"selectPage(currentPage + 1)\"\n >\n <slot name=\"next-page-button\">Next</slot>\n </button>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useAccessibilityLabels, useXBus } from '../composables'\n\ninterface PageItem {\n value: number | string\n isSelected: boolean\n}\n\n/**\n * Component that renders a pagination control with buttons for navigating\n * between pages. It displays the current page, allows selecting other pages,\n * and emits events when a page is selected.\n *\n * @public\n */\nexport default defineComponent({\n name: 'PageSelector',\n props: {\n /**\n * CSS classes to customize the prev/next buttons.\n */\n buttonClasses: {\n type: Array as PropType<(string | Dictionary<boolean>)[]>,\n default: () => [],\n },\n /**\n * The current page number.\n */\n currentPage: {\n type: Number,\n required: true,\n },\n /**\n * The string content of the hidden pages.\n */\n hiddenPage: {\n type: String,\n default: '...',\n },\n /**\n * CSS classes to customize the page items.\n */\n itemClasses: {\n type: Function as PropType<\n (isSelected: boolean) => string | Dictionary<boolean> | (string | Dictionary<boolean>)[]\n >,\n default: () => [],\n },\n /**\n * The number of pages to show before and after the current page.\n */\n range: {\n type: Number,\n default: 2,\n },\n /**\n * The class of the scroll container to scroll to top when a page is selected.\n */\n scrollTarget: {\n type: String,\n default: 'main-scroll',\n },\n /**\n * The total number of pages.\n */\n totalPages: {\n type: Number,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n const ariaLabels = useAccessibilityLabels('pageSelector')\n\n const visiblePages = computed(() => {\n const start = Math.max(props.currentPage - props.range, 1)\n const end = Math.min(props.currentPage + props.range, props.totalPages)\n const pages: PageItem[] = Array.from({ length: end - start + 1 }, (_, i) => {\n const pageValue: string | number = start + i\n return { value: pageValue, isSelected: pageValue === props.currentPage }\n })\n\n // Ensure first and last pages are always visible when needed\n if (start > 1) {\n pages.unshift({ value: 1, isSelected: props.currentPage === 1 })\n if (start > 2) {\n pages.splice(1, 0, { value: props.hiddenPage, isSelected: false })\n }\n }\n if (end < props.totalPages) {\n if (end < props.totalPages - 1) {\n pages.push({ value: props.hiddenPage, isSelected: false })\n }\n pages.push({\n value: props.totalPages,\n isSelected: props.totalPages === props.currentPage,\n })\n }\n\n return pages\n })\n\n /**\n * Handles the selection of a page.\n *\n * @param page - The page to select. Can be a number representing the page number or a string '...' indicating an ellipsis.\n */\n const selectPage = (page: number | string): void => {\n if (page === '...') {\n return\n }\n if (typeof page === 'number' && page > 0 && page <= props.totalPages) {\n bus.emit('UserSelectedAPage', page)\n /**\n * Emits scroll to top to prevent keeping the position if there is more content\n * after results, as for example Next Queries Preview.\n */\n bus.emit('UserClickedScrollToTop', props.scrollTarget)\n }\n }\n\n return {\n ariaLabels,\n visiblePages,\n selectPage,\n }\n },\n})\n</script>\n\n<style scoped>\n.x-page-selector {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n}\n\n.x-page-selector__page--current,\n.x-page-selector__page--hidden {\n cursor: default;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the \"UserSelectedAPage\" and the UserClickedScrollToTop events by default.\n\n## See it in action\n\nBasic example of how the component is rendered.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 0,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the slots\n\nThis component allows to customise its content using slots.\n\n```vue live\n<template>\n <PageSelector\n :total-pages=\"totalPages\"\n :currentPage=\"page\"\n :item-classes=\"\n (isSelected: boolean) =>\n isSelected\n ? 'x-button-lead x-text-neutral-10'\n : 'x-text-neutral-90 x-button-outlined'\n \"\n :buttonClasses=\"['x-rounded-md']\"\n >\n <template #previous-page-button>\n <span>Back</span>\n </template>\n <template #page-button=\"{ page, isSelected }\">\n <h2 :class=\"{ 'x-text1': !isSelected }\">\n {{ page }}\n </h2>\n </template>\n <template #next-page-button>\n <span>Forward</span>\n </template>\n </PageSelector>\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 2,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the number of pages to show before and after the current page by changing the range default value.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" :range=\"range\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 6,\n totalPages: 100,\n range: 4,\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":["_createElementBlock","_createElementVNode","_normalizeClass","_renderSlot","_createTextVNode","_openBlock","_Fragment","_renderList","_toDisplayString"],"mappings":";;;;;;;;;;SACa,IAAA,CAAA,YAAA,EAAc,MAAA,GAAM,kBAA/BA,kBAAA,CA6CM,KAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;IA7C+B,KAAA,EAAM,iBAAA;AAAA,IAAmB,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;IACpFC,kBAAA,CAUS,QAAA,EAAA;AAAA,MATP,KAAA,EAAKC,cAAA,CAAA,CAAC,YAAA,EACE,IAAA,CAAA,aAAa,CAAA,CAAA;AAAA,MACpB,UAAU,IAAA,CAAA,WAAA,KAAW,CAAA;AAAA,MACtB,WAAA,EAAU,sBAAA;AAAA,MACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,MACxB,iBAAe,IAAA,CAAA,WAAA,KAAW,CAAA;AAAA,MAC1B,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,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AA,YAAAC,eAAA;AADF,cAAAI,eAAA,CAAA,IAAA,CAAK,KAAK,CAAA;AAAA,cAAA;AAAA;AAAA;AAAA,WAAA,EAAA,IAAA;;;;;;IAIjBP,kBAAA,CAUS,QAAA,EAAA;AAAA,MATP,KAAA,EAAKC,cAAA,CAAA,CAAC,YAAA,EACE,IAAA,CAAA,aAAa,CAAA,CAAA;AAAA,MACpB,UAAU,IAAA,CAAA,WAAA,KAAgB,IAAA,CAAA,UAAA;AAAA,MAC3B,WAAA,EAAU,kBAAA;AAAA,MACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,MACxB,iBAAe,IAAA,CAAA,WAAA,KAAgB,IAAA,CAAA,UAAA;AAAA,MAC/B,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,UAAA,CAAW,IAAA,CAAA,WAAA,GAAW,CAAA,CAAA;AAAA,KAAA,EAAA;AAE9B,MAAAC,UAAA,CAAyC,qCAAzC,MAAyC;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAX,UAAA,MAAA;AAAA,UAAI;AAAA;AAAA,SAAA;AAAA,OAAA,EAAA,IAAA;;;;;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, computed } from 'vue';
|
|
2
2
|
import '../composables/create-use-device.js';
|
|
3
3
|
import 'vuex';
|
|
4
4
|
import '../plugins/x-bus.js';
|
|
5
5
|
import '@empathyco/x-utils';
|
|
6
6
|
import '../plugins/x-plugin.js';
|
|
7
7
|
import { useXBus } from '../composables/use-x-bus.js';
|
|
8
|
+
import { useAccessibilityLabels } from '../composables/use-accessibility-labels.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
|
-
import { ACCESSIBILITY_KEY } from '../types/accessibility.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Component that renders a pagination control with buttons for navigating
|
|
@@ -70,7 +70,7 @@ var _sfc_main = defineComponent({
|
|
|
70
70
|
},
|
|
71
71
|
setup(props) {
|
|
72
72
|
const bus = useXBus();
|
|
73
|
-
const
|
|
73
|
+
const ariaLabels = useAccessibilityLabels('pageSelector');
|
|
74
74
|
const visiblePages = computed(() => {
|
|
75
75
|
const start = Math.max(props.currentPage - props.range, 1);
|
|
76
76
|
const end = Math.min(props.currentPage + props.range, props.totalPages);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-selector.vue2.js","sources":["../../../src/components/page-selector.vue"],"sourcesContent":["<template>\n <nav v-if=\"visiblePages?.length > 1\" class=\"x-page-selector\" :aria-label=\"ariaLabels?.pagination\">\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === 1\"\n data-test=\"previous-page-button\"\n :aria-label=\"ariaLabels?.prevPage\"\n :aria-disabled=\"currentPage === 1\"\n @click=\"selectPage(currentPage - 1)\"\n >\n <slot name=\"previous-page-button\">Prev</slot>\n </button>\n\n <button\n v-for=\"page in visiblePages\"\n :key=\"page.value\"\n class=\"x-page-selector__page xds:button\"\n :class=\"[\n itemClasses(page.isSelected),\n {\n 'x-page-selector__page--current': page.isSelected,\n 'x-page-selector__page--hidden': page.value === hiddenPage,\n },\n ]\"\n :data-test=\"`page-button-${page.value}`\"\n :aria-label=\"ariaLabels?.numberPage!(page.value)\"\n :aria-current=\"page.isSelected ? 'page' : undefined\"\n @click=\"selectPage(page.value)\"\n >\n <slot name=\"page-button\" :page=\"page.value\" :is-selected=\"page.isSelected\">\n {{ page.value }}\n </slot>\n </button>\n\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === totalPages\"\n data-test=\"next-page-button\"\n :aria-label=\"ariaLabels?.nextPage\"\n :aria-disabled=\"currentPage === totalPages\"\n @click=\"selectPage(currentPage + 1)\"\n >\n <slot name=\"next-page-button\">Next</slot>\n </button>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport type { AriaLabels } from '../types'\nimport { computed, defineComponent, inject } from 'vue'\nimport { useXBus } from '../composables'\nimport { ACCESSIBILITY_KEY } from '../types'\n\ninterface PageItem {\n value: number | string\n isSelected: boolean\n}\n\n/**\n * Component that renders a pagination control with buttons for navigating\n * between pages. It displays the current page, allows selecting other pages,\n * and emits events when a page is selected.\n *\n * @public\n */\nexport default defineComponent({\n name: 'PageSelector',\n props: {\n /**\n * CSS classes to customize the prev/next buttons.\n */\n buttonClasses: {\n type: Array as PropType<(string | Dictionary<boolean>)[]>,\n default: () => [],\n },\n /**\n * The current page number.\n */\n currentPage: {\n type: Number,\n required: true,\n },\n /**\n * The string content of the hidden pages.\n */\n hiddenPage: {\n type: String,\n default: '...',\n },\n /**\n * CSS classes to customize the page items.\n */\n itemClasses: {\n type: Function as PropType<\n (isSelected: boolean) => string | Dictionary<boolean> | (string | Dictionary<boolean>)[]\n >,\n default: () => [],\n },\n /**\n * The number of pages to show before and after the current page.\n */\n range: {\n type: Number,\n default: 2,\n },\n /**\n * The class of the scroll container to scroll to top when a page is selected.\n */\n scrollTarget: {\n type: String,\n default: 'main-scroll',\n },\n /**\n * The total number of pages.\n */\n totalPages: {\n type: Number,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n const { pageSelector: ariaLabels } = inject(ACCESSIBILITY_KEY) as AriaLabels\n\n const visiblePages = computed(() => {\n const start = Math.max(props.currentPage - props.range, 1)\n const end = Math.min(props.currentPage + props.range, props.totalPages)\n const pages: PageItem[] = Array.from({ length: end - start + 1 }, (_, i) => {\n const pageValue: string | number = start + i\n return { value: pageValue, isSelected: pageValue === props.currentPage }\n })\n\n // Ensure first and last pages are always visible when needed\n if (start > 1) {\n pages.unshift({ value: 1, isSelected: props.currentPage === 1 })\n if (start > 2) {\n pages.splice(1, 0, { value: props.hiddenPage, isSelected: false })\n }\n }\n if (end < props.totalPages) {\n if (end < props.totalPages - 1) {\n pages.push({ value: props.hiddenPage, isSelected: false })\n }\n pages.push({\n value: props.totalPages,\n isSelected: props.totalPages === props.currentPage,\n })\n }\n\n return pages\n })\n\n /**\n * Handles the selection of a page.\n *\n * @param page - The page to select. Can be a number representing the page number or a string '...' indicating an ellipsis.\n */\n const selectPage = (page: number | string): void => {\n if (page === '...') {\n return\n }\n if (typeof page === 'number' && page > 0 && page <= props.totalPages) {\n bus.emit('UserSelectedAPage', page)\n /**\n * Emits scroll to top to prevent keeping the position if there is more content\n * after results, as for example Next Queries Preview.\n */\n bus.emit('UserClickedScrollToTop', props.scrollTarget)\n }\n }\n\n return {\n ariaLabels,\n visiblePages,\n selectPage,\n }\n },\n})\n</script>\n\n<style scoped>\n.x-page-selector {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n}\n\n.x-page-selector__page--current,\n.x-page-selector__page--hidden {\n cursor: default;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the \"UserSelectedAPage\" and the UserClickedScrollToTop events by default.\n\n## See it in action\n\nBasic example of how the component is rendered.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 0,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the slots\n\nThis component allows to customise its content using slots.\n\n```vue live\n<template>\n <PageSelector\n :total-pages=\"totalPages\"\n :currentPage=\"page\"\n :item-classes=\"\n (isSelected: boolean) =>\n isSelected\n ? 'x-button-lead x-text-neutral-10'\n : 'x-text-neutral-90 x-button-outlined'\n \"\n :buttonClasses=\"['x-rounded-md']\"\n >\n <template #previous-page-button>\n <span>Back</span>\n </template>\n <template #page-button=\"{ page, isSelected }\">\n <h2 :class=\"{ 'x-text1': !isSelected }\">\n {{ page }}\n </h2>\n </template>\n <template #next-page-button>\n <span>Forward</span>\n </template>\n </PageSelector>\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 2,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the number of pages to show before and after the current page by changing the range default value.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" :range=\"range\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 6,\n totalPages: 100,\n range: 4,\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;AA8DA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;AACL;;AAEE;AACF,QAAA,aAAa,EAAE;AACb,YAAA,IAAI,EAAE,KAAmD;AACzD,YAAA,OAAO,EAAE,MAAM,EAAE;AAClB,SAAA;AACD;;AAEE;AACF,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;AAEE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;AACD;;AAEE;AACF,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,QAEL;AACD,YAAA,OAAO,EAAE,MAAM,EAAE;AAClB,SAAA;AACD;;AAEE;AACF,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACD;;AAEE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,aAAa;AACvB,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AAA,IAAI,MAAM,KAAK,CAAC,UAAU,EAAE;gBAC1B,IAAI,GAAE,GAAI,KAAK,CAAC,UAAS,GAAI,CAAC,EAAE;AAC9B,oBAAA,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAI,EAAG,CAAA;gBAC3D;gBACA,KAAK,CAAC,IAAI,CAAC;oBACT,KAAK,EAAE,KAAK,CAAC,UAAU;AACvB,oBAAA,UAAU,EAAE,KAAK,CAAC,eAAe,KAAK,CAAC,WAAW;AACnD,iBAAA,CAAA;YACH;AAEA,YAAA,OAAO,KAAI;AACb,QAAA,CAAC,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,UAAS,GAAI,CAAC,IAAqB,KAAS;AAChD,YAAA,IAAI,IAAG,KAAM,KAAK,EAAE;gBAClB;YACF;AACA,YAAA,IAAI,OAAO,IAAG,KAAM,QAAO,IAAK,IAAG,GAAI,CAAA,IAAK,IAAG,IAAK,KAAK,CAAC,UAAU,EAAE;AACpE,gBAAA,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAA;AAClC;;;AAGE;gBACF,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,YAAY,CAAA;YACvD;AACF,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,YAAY;YACZ,UAAU;SACZ;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"page-selector.vue2.js","sources":["../../../src/components/page-selector.vue"],"sourcesContent":["<template>\n <nav v-if=\"visiblePages?.length > 1\" class=\"x-page-selector\" :aria-label=\"ariaLabels?.pagination\">\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === 1\"\n data-test=\"previous-page-button\"\n :aria-label=\"ariaLabels?.prevPage\"\n :aria-disabled=\"currentPage === 1\"\n @click=\"selectPage(currentPage - 1)\"\n >\n <slot name=\"previous-page-button\">Prev</slot>\n </button>\n\n <button\n v-for=\"page in visiblePages\"\n :key=\"page.value\"\n class=\"x-page-selector__page xds:button\"\n :class=\"[\n itemClasses(page.isSelected),\n {\n 'x-page-selector__page--current': page.isSelected,\n 'x-page-selector__page--hidden': page.value === hiddenPage,\n },\n ]\"\n :data-test=\"`page-button-${page.value}`\"\n :aria-label=\"ariaLabels?.numberPage!(page.value)\"\n :aria-current=\"page.isSelected ? 'page' : undefined\"\n @click=\"selectPage(page.value)\"\n >\n <slot name=\"page-button\" :page=\"page.value\" :is-selected=\"page.isSelected\">\n {{ page.value }}\n </slot>\n </button>\n\n <button\n class=\"xds:button\"\n :class=\"buttonClasses\"\n :disabled=\"currentPage === totalPages\"\n data-test=\"next-page-button\"\n :aria-label=\"ariaLabels?.nextPage\"\n :aria-disabled=\"currentPage === totalPages\"\n @click=\"selectPage(currentPage + 1)\"\n >\n <slot name=\"next-page-button\">Next</slot>\n </button>\n </nav>\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useAccessibilityLabels, useXBus } from '../composables'\n\ninterface PageItem {\n value: number | string\n isSelected: boolean\n}\n\n/**\n * Component that renders a pagination control with buttons for navigating\n * between pages. It displays the current page, allows selecting other pages,\n * and emits events when a page is selected.\n *\n * @public\n */\nexport default defineComponent({\n name: 'PageSelector',\n props: {\n /**\n * CSS classes to customize the prev/next buttons.\n */\n buttonClasses: {\n type: Array as PropType<(string | Dictionary<boolean>)[]>,\n default: () => [],\n },\n /**\n * The current page number.\n */\n currentPage: {\n type: Number,\n required: true,\n },\n /**\n * The string content of the hidden pages.\n */\n hiddenPage: {\n type: String,\n default: '...',\n },\n /**\n * CSS classes to customize the page items.\n */\n itemClasses: {\n type: Function as PropType<\n (isSelected: boolean) => string | Dictionary<boolean> | (string | Dictionary<boolean>)[]\n >,\n default: () => [],\n },\n /**\n * The number of pages to show before and after the current page.\n */\n range: {\n type: Number,\n default: 2,\n },\n /**\n * The class of the scroll container to scroll to top when a page is selected.\n */\n scrollTarget: {\n type: String,\n default: 'main-scroll',\n },\n /**\n * The total number of pages.\n */\n totalPages: {\n type: Number,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n const ariaLabels = useAccessibilityLabels('pageSelector')\n\n const visiblePages = computed(() => {\n const start = Math.max(props.currentPage - props.range, 1)\n const end = Math.min(props.currentPage + props.range, props.totalPages)\n const pages: PageItem[] = Array.from({ length: end - start + 1 }, (_, i) => {\n const pageValue: string | number = start + i\n return { value: pageValue, isSelected: pageValue === props.currentPage }\n })\n\n // Ensure first and last pages are always visible when needed\n if (start > 1) {\n pages.unshift({ value: 1, isSelected: props.currentPage === 1 })\n if (start > 2) {\n pages.splice(1, 0, { value: props.hiddenPage, isSelected: false })\n }\n }\n if (end < props.totalPages) {\n if (end < props.totalPages - 1) {\n pages.push({ value: props.hiddenPage, isSelected: false })\n }\n pages.push({\n value: props.totalPages,\n isSelected: props.totalPages === props.currentPage,\n })\n }\n\n return pages\n })\n\n /**\n * Handles the selection of a page.\n *\n * @param page - The page to select. Can be a number representing the page number or a string '...' indicating an ellipsis.\n */\n const selectPage = (page: number | string): void => {\n if (page === '...') {\n return\n }\n if (typeof page === 'number' && page > 0 && page <= props.totalPages) {\n bus.emit('UserSelectedAPage', page)\n /**\n * Emits scroll to top to prevent keeping the position if there is more content\n * after results, as for example Next Queries Preview.\n */\n bus.emit('UserClickedScrollToTop', props.scrollTarget)\n }\n }\n\n return {\n ariaLabels,\n visiblePages,\n selectPage,\n }\n },\n})\n</script>\n\n<style scoped>\n.x-page-selector {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n}\n\n.x-page-selector__page--current,\n.x-page-selector__page--hidden {\n cursor: default;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the \"UserSelectedAPage\" and the UserClickedScrollToTop events by default.\n\n## See it in action\n\nBasic example of how the component is rendered.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 0,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the slots\n\nThis component allows to customise its content using slots.\n\n```vue live\n<template>\n <PageSelector\n :total-pages=\"totalPages\"\n :currentPage=\"page\"\n :item-classes=\"\n (isSelected: boolean) =>\n isSelected\n ? 'x-button-lead x-text-neutral-10'\n : 'x-text-neutral-90 x-button-outlined'\n \"\n :buttonClasses=\"['x-rounded-md']\"\n >\n <template #previous-page-button>\n <span>Back</span>\n </template>\n <template #page-button=\"{ page, isSelected }\">\n <h2 :class=\"{ 'x-text1': !isSelected }\">\n {{ page }}\n </h2>\n </template>\n <template #next-page-button>\n <span>Forward</span>\n </template>\n </PageSelector>\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 2,\n totalPages: 10,\n }\n },\n}\n</script>\n```\n\n### Customize the number of pages to show before and after the current page by changing the range default value.\n\n```vue live\n<template>\n <PageSelector :current-page=\"page\" :total-pages=\"totalPages\" :range=\"range\" />\n</template>\n\n<script>\nimport { PageSelector } from '@empathyco/x-components'\n\nexport default {\n name: 'PageSelectorDemo',\n components: {\n PageSelector,\n },\n data() {\n return {\n page: 6,\n totalPages: 100,\n range: 4,\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;AA4DA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;AACL;;AAEE;AACF,QAAA,aAAa,EAAE;AACb,YAAA,IAAI,EAAE,KAAmD;AACzD,YAAA,OAAO,EAAE,MAAM,EAAE;AAClB,SAAA;AACD;;AAEE;AACF,QAAA,WAAW,EA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AAwB,EAAE,KAAK,CAAC,YAAY,CAAA;YACvD;AACF,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,YAAY;YACZ,UAAU;SACZ;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -5,6 +5,7 @@ import '../../plugins/x-bus.js';
|
|
|
5
5
|
import '@empathyco/x-utils';
|
|
6
6
|
import '../../plugins/x-plugin.js';
|
|
7
7
|
import { useXBus } from '../../composables/use-x-bus.js';
|
|
8
|
+
import '../../utils/storage.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
10
|
import BaseEventButton from '../base-event-button.vue.js';
|
|
10
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-id-toggle-panel-button.vue2.js","sources":["../../../../src/components/panels/base-id-toggle-panel-button.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-base-id-toggle-panel-button xds:button\"\n data-test=\"base-id-toggle-button\"\n :aria-pressed=\"isPanelOpen.toString()\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot :is-panel-open=\"isPanelOpen\" />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/wiring.types'\nimport { computed, defineComponent, ref } from 'vue'\nimport { useXBus } from '../../composables'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component containing an event button that emits\n * {@link XEventsTypes.UserClickedPanelToggleButton} when clicked with\n * the panelId as payload.\n *\n * It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseIdTogglePanelButton',\n components: { BaseEventButton },\n props: {\n /**\n * The panelId to use for the toggle event listeners.\n */\n panelId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n /**\n * The panel state to pass through the slot.\n */\n const isPanelOpen = ref(false)\n\n /**\n * List of events to emit by the BaseEventButton.\n *\n * @returns An object with the event and payload.\n *\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserClickedPanelToggleButton: props.panelId }),\n )\n\n /**\n * The subscription to the {@link XEventsTypes.TogglePanelStateChanged} event\n * to update the `isPanelOpen` property.\n *\n * @param newState - The new isOpen state of the panel.\n * @param id - The `panelId`.\n * @param id.id - The ID of the `panelId`.\n */\n const updatePanelState = (newState: boolean, { id }: WireMetadata) => {\n if (props.panelId === id) {\n isPanelOpen.value = newState\n }\n }\n\n bus\n .on('TogglePanelStateChanged', false)\n .subscribe(newState => updatePanelState(newState, { id: props.panelId, moduleName: null }))\n\n return {\n isPanelOpen,\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- [`UserClickedPanelToggleButton`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the panelId\n that is going to be toggled.\n\n## Examples\n\n### Basic example\n\nThe component renders content passed to the default slot and toggles the panel with panelId\n`myToggle`.\n\n```vue\n<template>\n <div>\n <BaseIdTogglePanelButton panelId=\"myToggle\" v-slot=\"{ isPanelOpen }\">\n <template v-if=\"isPanelOpen\">\n <img src=\"./close-button-icon.svg\" alt=\"Close aside\" />\n <span>Close aside</span>\n </template>\n <template v-else>\n <img src=\"./open-button-icon.svg\" alt=\"Open aside\" />\n <span>Open aside</span>\n </template>\n </BaseIdTogglePanelButton>\n <BaseIdTogglePanel :startOpen=\"true\" :animation=\"animation\" panelId=\"myToggle\">\n <div class=\"x-text1\">My toggle</div>\n </BaseIdTogglePanel>\n </div>\n</template>\n\n<script setup>\nimport { BaseIdTogglePanel, BaseIdTogglePanelButton } from '@empathyco/x-components'\nimport { CollapseFromTop } from '@empathyco/x-components/animations'\nconst animation = CollapseFromTop\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-id-toggle-panel-button.vue2.js","sources":["../../../../src/components/panels/base-id-toggle-panel-button.vue"],"sourcesContent":["<template>\n <BaseEventButton\n :events=\"events\"\n class=\"x-base-id-toggle-panel-button xds:button\"\n data-test=\"base-id-toggle-button\"\n :aria-pressed=\"isPanelOpen.toString()\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot :is-panel-open=\"isPanelOpen\" />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport type { WireMetadata } from '../../wiring/wiring.types'\nimport { computed, defineComponent, ref } from 'vue'\nimport { useXBus } from '../../composables'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Component containing an event button that emits\n * {@link XEventsTypes.UserClickedPanelToggleButton} when clicked with\n * the panelId as payload.\n *\n * It has a default slot to customize its contents.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseIdTogglePanelButton',\n components: { BaseEventButton },\n props: {\n /**\n * The panelId to use for the toggle event listeners.\n */\n panelId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const bus = useXBus()\n\n /**\n * The panel state to pass through the slot.\n */\n const isPanelOpen = ref(false)\n\n /**\n * List of events to emit by the BaseEventButton.\n *\n * @returns An object with the event and payload.\n *\n * @internal\n */\n const events = computed(\n (): Partial<XEventsTypes> => ({ UserClickedPanelToggleButton: props.panelId }),\n )\n\n /**\n * The subscription to the {@link XEventsTypes.TogglePanelStateChanged} event\n * to update the `isPanelOpen` property.\n *\n * @param newState - The new isOpen state of the panel.\n * @param id - The `panelId`.\n * @param id.id - The ID of the `panelId`.\n */\n const updatePanelState = (newState: boolean, { id }: WireMetadata) => {\n if (props.panelId === id) {\n isPanelOpen.value = newState\n }\n }\n\n bus\n .on('TogglePanelStateChanged', false)\n .subscribe(newState => updatePanelState(newState, { id: props.panelId, moduleName: null }))\n\n return {\n isPanelOpen,\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- [`UserClickedPanelToggleButton`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the panelId\n that is going to be toggled.\n\n## Examples\n\n### Basic example\n\nThe component renders content passed to the default slot and toggles the panel with panelId\n`myToggle`.\n\n```vue\n<template>\n <div>\n <BaseIdTogglePanelButton panelId=\"myToggle\" v-slot=\"{ isPanelOpen }\">\n <template v-if=\"isPanelOpen\">\n <img src=\"./close-button-icon.svg\" alt=\"Close aside\" />\n <span>Close aside</span>\n </template>\n <template v-else>\n <img src=\"./open-button-icon.svg\" alt=\"Open aside\" />\n <span>Open aside</span>\n </template>\n </BaseIdTogglePanelButton>\n <BaseIdTogglePanel :startOpen=\"true\" :animation=\"animation\" panelId=\"myToggle\">\n <div class=\"x-text1\">My toggle</div>\n </BaseIdTogglePanel>\n </div>\n</template>\n\n<script setup>\nimport { BaseIdTogglePanel, BaseIdTogglePanelButton } from '@empathyco/x-components'\nimport { CollapseFromTop } from '@empathyco/x-components/animations'\nconst animation = CollapseFromTop\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,yBAAyB;IAC/B,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;AACL;;AAEE;AACF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,GAAE,GAAI,OAAO,EAAC;AAEpB;;AAEE;AACF,QAAA,MAAM,WAAU,GAAI,GAAG,CAAC,KAAK,CAAA;AAE7B;;;;;;AAME;AACF,QAAA,MAAM,MAAK,GAAI,QAAQ,CACrB,OAA8B,EAAE,4BAA4B,EAAE,KAAK,CAAC,OAAM,EAAG,CAAC,CAChF;AAEA;;;;;;;AAOE;QACF,MAAM,gBAAe,GAAI,CAAC,QAAiB,EAAE,EAAE,EAAC,EAAiB,KAAG;AAClE,YAAA,IAAI,KAAK,CAAC,OAAM,KAAM,EAAE,EAAE;AACxB,gBAAA,WAAW,CAAC,KAAI,GAAI,QAAO;YAC7B;AACF,QAAA,CAAA;QAEA;AACG,aAAA,EAAE,CAAC,yBAAyB,EAAE,KAAK;aACnC,SAAS,CAAC,QAAO,IAAK,gBAAgB,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,OAAwB,CAAG,CAAC,CAAA;QAE5F,OAAO;YACL,WAAW;YACX,MAAM;SACR;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineComponent, ref, watch } from 'vue';
|
|
2
2
|
import '../../composables/create-use-device.js';
|
|
3
3
|
import { use$x } from '../../composables/use-_x.js';
|
|
4
|
+
import '@empathyco/x-utils';
|
|
5
|
+
import '../../utils/storage.js';
|
|
4
6
|
import 'vuex';
|
|
5
7
|
import '../../plugins/x-bus.js';
|
|
6
|
-
import '@empathyco/x-utils';
|
|
7
8
|
import '../../plugins/x-plugin.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
10
|
import 'rxjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-id-toggle-panel.vue2.js","sources":["../../../../src/components/panels/base-id-toggle-panel.vue"],"sourcesContent":["<template>\n <BaseTogglePanel :open=\"isOpen\" :animation=\"animation\">\n <!-- @slot (Required) Default content -->\n <slot />\n </BaseTogglePanel>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { NoAnimation } from '../animations'\nimport BaseTogglePanel from './base-toggle-panel.vue'\n\n/**\n * Simple panel that could receives its initial open state via prop, if not the default is opens\n * and a required prop, named `panelId`, which are responsible of rendering default slot\n * inside a configurable transition.\n *\n * It reacts to `UserClickedPanelToggleButton` event, when their payload matches the component's\n * 'panelId' prop, to handle its open/close state.\n *\n * The default slot offers the possibility to customise the modal content.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseIdTogglePanel',\n components: { BaseTogglePanel },\n props: {\n /** Shows the panel open at the beginning or not, depending on its state. */\n startOpen: {\n type: Boolean,\n default: true,\n },\n /** Animation component that will be used to animate the panel content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * The id to link with the BaseIdTogglePanelButton.\n * Both components must use the same Id to make them interact.\n */\n panelId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const $x = use$x()\n\n /** Whether the toggle panel is open or not. */\n const isOpen = ref(props.startOpen)\n\n /**\n * Method to subscribe to the {@link XEventsTypes.UserClickedPanelToggleButton} event.\n *\n * @param panelId - The payload of the {@link XEventsTypes.UserClickedPanelToggleButton} event.\n *\n * @public\n */\n const togglePanel = (panelId: string) => {\n if (props.panelId === panelId) {\n isOpen.value = !isOpen.value\n }\n }\n\n $x.on('UserClickedPanelToggleButton', false).subscribe(togglePanel)\n\n /**\n * Emits the {@link XEventsTypes.TogglePanelStateChanged} event, when the internal state\n * changes.\n *\n * @remarks This event is necessary to link the state with the {@link BaseIdTogglePanelButton}\n * component.\n * @public\n */\n watch(\n () => isOpen.value,\n () => {\n $x.emit('TogglePanelStateChanged', isOpen.value, {\n id: props.panelId,\n target: document.getElementById(props.panelId) as HTMLElement,\n })\n },\n { immediate: true },\n )\n\n return { isOpen }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will watch and emit:\n\n- [`UserClickedPanelToggleButton`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n watched to toggle the panel when the payload matches the `panelId` prop.\n- [`TogglePanelStateChanged`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n emitted when the internal open state changes, with the new state and panel id.\n\n## Examples\n\n### Basic usage\n\n```vue\n<template>\n <div>\n <BaseIdTogglePanelButton panelId=\"myToggle\">\n <img src=\"./open-button-icon.svg\" alt=\"Toggle Aside\" />\n <span>Toggle Aside</span>\n </BaseIdTogglePanelButton>\n <BaseIdTogglePanel :startOpen=\"true\" :animation=\"animation\" panelId=\"myToggle\">\n <div class=\"x-text1\">My toggle</div>\n </BaseIdTogglePanel>\n </div>\n</template>\n\n<script setup>\nimport { BaseIdTogglePanel, BaseIdTogglePanelButton } from '@empathyco/x-components'\nimport { CollapseFromTop } from '@empathyco/x-components/animations'\nconst animation = CollapseFromTop\n</script>\n```\n\n### Listening to state changes\n\nYou can listen to the `TogglePanelStateChanged` event to react to panel open/close state changes:\n\n```vue\n<template>\n <div>\n <span>Panel is {{ isPanelOpen ? 'open' : 'closed' }}</span>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { use$x } from '@empathyco/x-components'\n\nconst x = use$x()\nconst isPanelOpen = ref(false)\nconst panelId = 'myToggle'\n\nx.on('TogglePanelStateChanged').subscribe((isOpen, { id }) => {\n if (id === panelId) {\n isPanelOpen.value = isOpen\n }\n})\n</script>\n```\n</docs>\n"],"names":["NoAnimation"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-id-toggle-panel.vue2.js","sources":["../../../../src/components/panels/base-id-toggle-panel.vue"],"sourcesContent":["<template>\n <BaseTogglePanel :open=\"isOpen\" :animation=\"animation\">\n <!-- @slot (Required) Default content -->\n <slot />\n </BaseTogglePanel>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { NoAnimation } from '../animations'\nimport BaseTogglePanel from './base-toggle-panel.vue'\n\n/**\n * Simple panel that could receives its initial open state via prop, if not the default is opens\n * and a required prop, named `panelId`, which are responsible of rendering default slot\n * inside a configurable transition.\n *\n * It reacts to `UserClickedPanelToggleButton` event, when their payload matches the component's\n * 'panelId' prop, to handle its open/close state.\n *\n * The default slot offers the possibility to customise the modal content.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseIdTogglePanel',\n components: { BaseTogglePanel },\n props: {\n /** Shows the panel open at the beginning or not, depending on its state. */\n startOpen: {\n type: Boolean,\n default: true,\n },\n /** Animation component that will be used to animate the panel content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * The id to link with the BaseIdTogglePanelButton.\n * Both components must use the same Id to make them interact.\n */\n panelId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const $x = use$x()\n\n /** Whether the toggle panel is open or not. */\n const isOpen = ref(props.startOpen)\n\n /**\n * Method to subscribe to the {@link XEventsTypes.UserClickedPanelToggleButton} event.\n *\n * @param panelId - The payload of the {@link XEventsTypes.UserClickedPanelToggleButton} event.\n *\n * @public\n */\n const togglePanel = (panelId: string) => {\n if (props.panelId === panelId) {\n isOpen.value = !isOpen.value\n }\n }\n\n $x.on('UserClickedPanelToggleButton', false).subscribe(togglePanel)\n\n /**\n * Emits the {@link XEventsTypes.TogglePanelStateChanged} event, when the internal state\n * changes.\n *\n * @remarks This event is necessary to link the state with the {@link BaseIdTogglePanelButton}\n * component.\n * @public\n */\n watch(\n () => isOpen.value,\n () => {\n $x.emit('TogglePanelStateChanged', isOpen.value, {\n id: props.panelId,\n target: document.getElementById(props.panelId) as HTMLElement,\n })\n },\n { immediate: true },\n )\n\n return { isOpen }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will watch and emit:\n\n- [`UserClickedPanelToggleButton`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n watched to toggle the panel when the payload matches the `panelId` prop.\n- [`TogglePanelStateChanged`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n emitted when the internal open state changes, with the new state and panel id.\n\n## Examples\n\n### Basic usage\n\n```vue\n<template>\n <div>\n <BaseIdTogglePanelButton panelId=\"myToggle\">\n <img src=\"./open-button-icon.svg\" alt=\"Toggle Aside\" />\n <span>Toggle Aside</span>\n </BaseIdTogglePanelButton>\n <BaseIdTogglePanel :startOpen=\"true\" :animation=\"animation\" panelId=\"myToggle\">\n <div class=\"x-text1\">My toggle</div>\n </BaseIdTogglePanel>\n </div>\n</template>\n\n<script setup>\nimport { BaseIdTogglePanel, BaseIdTogglePanelButton } from '@empathyco/x-components'\nimport { CollapseFromTop } from '@empathyco/x-components/animations'\nconst animation = CollapseFromTop\n</script>\n```\n\n### Listening to state changes\n\nYou can listen to the `TogglePanelStateChanged` event to react to panel open/close state changes:\n\n```vue\n<template>\n <div>\n <span>Panel is {{ isPanelOpen ? 'open' : 'closed' }}</span>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { use$x } from '@empathyco/x-components'\n\nconst x = use$x()\nconst isPanelOpen = ref(false)\nconst panelId = 'myToggle'\n\nx.on('TogglePanelStateChanged').subscribe((isOpen, { id }) => {\n if (id === panelId) {\n isPanelOpen.value = isOpen\n }\n})\n</script>\n```\n</docs>\n"],"names":["NoAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;AAWE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,mBAAmB;IACzB,UAAU,EAAE,EAAE,eAAc,EAAG;AAC/B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,MAAMA,WAAW;AAC3B,SAAA;AACD;;;AAGE;AACF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;;QAGjB,MAAM,MAAK,GAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAA;AAElC;;;;;;AAME;AACF,QAAA,MAAM,WAAU,GAAI,CAAC,OAAe,KAAG;AACrC,YAAA,IAAI,KAAK,CAAC,OAAM,KAAM,OAAO,EAAE;AAC7B,gBAAA,MAAM,CAAC,KAAI,GAAI,CAAC,MAAM,CAAC,KAAI;YAC7B;AACF,QAAA,CAAA;AAEA,QAAA,EAAE,CAAC,EAAE,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,WAAW,CAAA;AAElE;;;;;;;AAOE;QACF,KAAK,CACH,MAAM,MAAM,CAAC,KAAK,EAClB,MAAI;YACF,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,KAAK,EAAE;gBAC/C,EAAE,EAAE,KAAK,CAAC,OAAO;gBACjB,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAgB;AAC9D,aAAA,CAAA;AACH,QAAA,CAAC,EACD,EAAE,SAAS,EAAE,MAAM,CACrB;QAEA,OAAO,EAAE,MAAK,EAAE;IAClB,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineComponent, ref, inject } from 'vue';
|
|
2
2
|
import '../../composables/create-use-device.js';
|
|
3
3
|
import { use$x } from '../../composables/use-_x.js';
|
|
4
|
+
import '@empathyco/x-utils';
|
|
5
|
+
import '../../utils/storage.js';
|
|
4
6
|
import 'vuex';
|
|
5
7
|
import '../../plugins/x-bus.js';
|
|
6
|
-
import '@empathyco/x-utils';
|
|
7
8
|
import '../../plugins/x-plugin.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
10
|
import 'rxjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-link.vue2.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n :ref=\"el\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n @click=\"onClick\"\n @contextmenu=\"onClick\"\n @auxclick=\"({ button }) => button === 1 && onClick()\"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { WireMetadata, XEvent } from '../../wiring'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { defineComponent, inject, ref } from 'vue'\nimport { use$x } from '../../composables/index'\n\n/**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\nexport default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n clickEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedAResult',\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref()\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {})\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const onClick = (): void => {\n $x.emit(props.clickEvent, props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent.UserClickedAResult,\n })\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] })\n })\n }\n\n return {\n el,\n onClick,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-link {\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## Examples\n\nThis component is a wrapper for the result contents (images, name, price...). It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide these events.\n\nThe result prop is required. It will render an anchor element with the href to the result URL:\n\n```vue\n<template>\n <BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\" alt=\"Result image\" />\n <span>{{ result.name }}</span>\n </template>\n </BaseResultLink>\n</template>\n\n<script setup>\nimport { BaseResultLink } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n url: 'https://shop.com/jacket',\n images: ['https://shop.com/jacket.jpg'],\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-result-link.vue2.js","sources":["../../../../src/components/result/base-result-link.vue"],"sourcesContent":["<template>\n <a\n :ref=\"el\"\n :href=\"result.url\"\n class=\"x-result-link\"\n data-test=\"result-link\"\n @click=\"onClick\"\n @contextmenu=\"onClick\"\n @auxclick=\"({ button }) => button === 1 && onClick()\"\n >\n <!--\n @slot (Required) Link content with a text, an image, another component or both\n @binding {Result} result - Result data\n -->\n <slot :result=\"result\" />\n </a>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { PropsWithType } from '../../utils/types'\nimport type { WireMetadata, XEvent } from '../../wiring'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { defineComponent, inject, ref } from 'vue'\nimport { use$x } from '../../composables/index'\n\n/**\n * Component to be reused that renders an `<a>` wrapping the result contents.\n *\n * @remarks\n * It has the logic to emit {@link XEventsTypes.UserClickedAResult} to the bus on click mouse\n * events. Additionally, this component may be injected other events to be emitted on click\n * event, so, depending on where it's used its father component may provide this events.\n *\n * @public\n */\nexport default defineComponent({\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n clickEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedAResult',\n },\n },\n setup(props) {\n const $x = use$x()\n\n /**\n * The rendered DOM element.\n *\n * @internal\n */\n const el = ref()\n\n /**\n * The list of additional events to be emitted by the component when user clicks the link.\n *\n * @internal\n */\n const resultClickExtraEvents = inject<PropsWithType<XEventsTypes, Result>[]>(\n 'resultClickExtraEvents',\n [],\n )\n\n /**\n * The metadata to be injected in the events emitted by the component. This component can emit\n * have extra events so this record pairs each event to its metadata.\n */\n const resultLinkMetadataPerEvent = inject<\n // TODO: Refactor this inject key to the constants when doing EMP-909\n Partial<\n Record<\n PropsWithType<XEventsTypes, Result>,\n Omit<WireMetadata, 'moduleName' | 'origin' | 'location'>\n >\n >\n >('resultLinkMetadataPerEvent', {})\n\n /**\n * Emits the {@link XEventsTypes.UserClickedAResult} when user clicks on the result, and also\n * additional events if have been injected in the component.\n *\n * @internal\n */\n const onClick = (): void => {\n $x.emit(props.clickEvent, props.result, {\n target: el.value!,\n ...resultLinkMetadataPerEvent.UserClickedAResult,\n })\n resultClickExtraEvents.forEach(event => {\n $x.emit(event, props.result, { target: el.value!, ...resultLinkMetadataPerEvent[event] })\n })\n }\n\n return {\n el,\n onClick,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-link {\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following event:\n\n- [`UserClickedAResult`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\nThe component can emit more events on click using the `resultClickExtraEvents` prop.\n\n## Examples\n\nThis component is a wrapper for the result contents (images, name, price...). It may be part of the\nsearch result page, recommendations or other section which needs to include results.\n\nAdditionally, this component may be injected other events to be emitted on click event, so,\ndepending where it's used its father component may provide these events.\n\nThe result prop is required. It will render an anchor element with the href to the result URL:\n\n```vue\n<template>\n <BaseResultLink :result=\"result\">\n <template #default=\"{ result }\">\n <img :src=\"result.images[0]\" alt=\"Result image\" />\n <span>{{ result.name }}</span>\n </template>\n </BaseResultLink>\n</template>\n\n<script setup>\nimport { BaseResultLink } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n url: 'https://shop.com/jacket',\n images: ['https://shop.com/jacket.jpg'],\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA;;;;;;;;;AASE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,oBAAoB;AAC9B,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;AAIE;AACF,QAAA,MAAM,KAAK,GAAG,EAAC;AAEf;;;;AAIE;QACF,MAAM,sBAAqB,GAAI,MAAM,CACnC,wBAAwB,EACxB,EAAE,CACJ;AAEA;;;AAGE;QACF,MAAM,0BAAyB,GAAI,MAAM,CAQvC,4BAA4B,EAAE,EAAE,CAAA;AAElC;;;;;AAKE;QACF,MAAM,UAAU,MAAU;YACxB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE;gBACtC,MAAM,EAAE,EAAE,CAAC,KAAM;gBACjB,GAAG,0BAA0B,CAAC,kBAAkB;AACjD,aAAA,CAAA;AACD,YAAA,sBAAsB,CAAC,OAAO,CAAC,KAAI,IAAG;gBACpC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,KAAM,EAAE,GAAG,0BAA0B,CAAC,KAAK,GAAG,CAAA;AAC1F,YAAA,CAAC,CAAA;AACH,QAAA,CAAA;QAEA,OAAO;YACL,EAAE;YACF,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineComponent, ref } from 'vue';
|
|
2
2
|
import '../../composables/create-use-device.js';
|
|
3
3
|
import { use$x } from '../../composables/use-_x.js';
|
|
4
|
+
import '@empathyco/x-utils';
|
|
5
|
+
import '../../utils/storage.js';
|
|
4
6
|
import 'vuex';
|
|
5
7
|
import '../../plugins/x-bus.js';
|
|
6
|
-
import '@empathyco/x-utils';
|
|
7
8
|
import '../../plugins/x-plugin.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
10
|
import 'rxjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-result-rating.vue2.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n :ref=\"el\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n @click=\"emitClickedEvent\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport BaseRating from '../base-rating.vue'\n\n/**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseRating,\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String,\n },\n },\n setup(props) {\n const $x = use$x()\n\n const el = ref<HTMLElement | null>()\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!,\n })\n }\n\n return {\n el,\n emitClickedEvent,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-rating {\n color: inherit;\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## Examples\n\n### Basic example\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Play with props\n\n#### Custom max value\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n#### With link\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\nfunction logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result)\n}\n</script>\n```\n\n## Extending the component\n\n### Custom icons with slots\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Override all content\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\" :key=\"star\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Reuse BaseRating\n\nIt is also possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating, BaseRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-result-rating.vue2.js","sources":["../../../../src/components/result/base-result-rating.vue"],"sourcesContent":["<template>\n <component\n :is=\"link ? 'a' : 'div'\"\n v-if=\"result.rating && result.rating.value\"\n :ref=\"el\"\n :href=\"link\"\n class=\"x-result-rating\"\n data-test=\"result-rating\"\n @click=\"emitClickedEvent\"\n >\n <!--\n @slot To override the whole content\n -->\n <slot :rating=\"result.rating.value\" :result=\"result\">\n <BaseRating :value=\"result.rating.value\" v-bind=\"$attrs\">\n <template #empty-icon>\n <!--\n @slot The content to render as empty icon\n -->\n <slot name=\"empty-icon\" />\n </template>\n\n <template #filled-icon>\n <!--\n @slot The content to render as filled icon\n -->\n <slot name=\"filled-icon\" />\n </template>\n </BaseRating>\n </slot>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport BaseRating from '../base-rating.vue'\n\n/**\n * This component renders a {@link BaseRating} for a result passed as prop.\n *\n * @public\n */\nexport default defineComponent({\n components: {\n BaseRating,\n },\n inheritAttrs: false,\n props: {\n /**\n * The {@link @empathyco/x-types#Result} to render its rating.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n\n /**\n * A link to redirect when rating is clicked.\n *\n * @public\n */\n link: {\n type: String,\n },\n },\n setup(props) {\n const $x = use$x()\n\n const el = ref<HTMLElement | null>()\n\n /**\n * Emits the `UserClickedAResultRating` event when user clicks this component, with the\n * {@link @empathyco/x-types#Result} as payload.\n *\n * @internal\n */\n const emitClickedEvent = (): void => {\n $x.emit('UserClickedAResultRating', props.result, {\n target: el.value!,\n })\n }\n\n return {\n el,\n emitClickedEvent,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-rating {\n color: inherit;\n text-decoration: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserClickedAResultRating`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## Examples\n\n### Basic example\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Play with props\n\n#### Custom max value\n\nIn this example, the result rating has been configured to 6 as maximum value using the prop `max`.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" :max=\"6\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n#### With link\n\nIn this example, the result rating has been configured with a link to redirect when is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" link=\"https://empathy.co/\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Play with events\n\nIn this example, a message has been added to be shown when the result rating is clicked.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" @UserClickedAResultRating=\"logUserClickedRating\" />\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\nfunction logUserClickedRating(result) {\n console.log('User clickedRating of this result:', result)\n}\n</script>\n```\n\n## Extending the component\n\n### Custom icons with slots\n\nThe rendered icons for rating can be configured through slots. Keep in mind that the icons for both\nstates (filled and empty), must have the same size make component work properly.\n\n```vue\n<template>\n <BaseResultRating :result=\"result\">\n <template #filled-icon>❤️</template>\n <template #empty-icon>🤍</template>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Override all content\n\nIt is possible to override all the content of the component to show your own rating but keeping the\nlink and event behaviour:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <span v-for=\"star in rating\" :key=\"star\">⭐️</span>\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n\n### Reuse BaseRating\n\nIt is also possible to reuse our rating component:\n\n```vue\n<template>\n <BaseResultRating :result=\"result\" #default=\"{ rating, result }\">\n <BaseRating :value=\"rating\" />\n <span>{{ result.name }}</span>\n </BaseResultRating>\n</template>\n\n<script setup>\nimport { BaseResultRating, BaseRating } from '@empathyco/x-components'\nconst result = {\n id: 1,\n name: 'Result with rating',\n rating: { value: 3 },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AAwCA;;;;AAIE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,UAAU,EAAE;QACV,UAAU;AACX,KAAA;AACD,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;AACF,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,MAAM;AACb,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB,QAAA,MAAM,EAAC,GAAI,GAAG,EAAqB;AAEnC;;;;;AAKE;QACF,MAAM,gBAAe,GAAI,MAAU;YACjC,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,CAAC,MAAM,EAAE;gBAChD,MAAM,EAAE,EAAE,CAAC,KAAM;AAClB,aAAA,CAAA;AACH,QAAA,CAAA;QAEA,OAAO;YACL,EAAE;YACF,gBAAgB;SAClB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-dropdown.vue.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type {
|
|
1
|
+
{"version":3,"file":"sort-dropdown.vue.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../../composables'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n const ariaLabels = useAccessibilityLabels('sortDropdown')\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n ariaLabels,\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":["_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CA6Be,uBAAA,EAAA;AAAA,IA5Bb,GAAA,EAAI,SAAA;AAAA,IACH,KAAA,EAAO,IAAA,CAAA,KAAA;AAAA,IACP,aAAA,EAAa,IAAA,CAAA,YAAA;AAAA,IACb,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACZ,KAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EAAU,eAAA;AAAA,IACT,cAAY,IAAA,CAAA,UAAA,EAAY,QAAA;AAAA,IACxB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA;AAEV,IAAA,MAAA,EAAMC,OAAA,CAOf,CAA+D,EAP5C,MAAA,EAAQ,IAAA,EAAI,KAAA;AAAA,MAO/BC,UAAA,CAA+D,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAA/C,MAAA,EAAQ,IAAA,MAAxB,MAA+D;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;AAE5C,IAAA,IAAA,EAAIJ,OAAA,CAQb,CAAgF,EAR/D,IAAA,EAAM,eAAe,UAAA,EAAU,KAAA;AAAA,MAQhDC,WAAgF,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAhE,IAAA,EAAM,aAAA,EAAe,UAAA,MAArC,MAAgF;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;;;;;;;;;"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { defineComponent, ref,
|
|
1
|
+
import { defineComponent, ref, watch } from 'vue';
|
|
2
|
+
import '../../composables/create-use-device.js';
|
|
2
3
|
import { use$x } from '../../composables/use-_x.js';
|
|
3
|
-
import {
|
|
4
|
+
import { useAccessibilityLabels } from '../../composables/use-accessibility-labels.js';
|
|
5
|
+
import 'vuex';
|
|
6
|
+
import '../../plugins/x-bus.js';
|
|
7
|
+
import '@empathyco/x-utils';
|
|
8
|
+
import '../../plugins/x-plugin.js';
|
|
9
|
+
import '@vueuse/core';
|
|
10
|
+
import 'rxjs';
|
|
4
11
|
import BaseDropdown from '../base-dropdown.vue.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
@@ -35,7 +42,7 @@ var _sfc_main = defineComponent({
|
|
|
35
42
|
setup(props, { emit }) {
|
|
36
43
|
const $x = use$x();
|
|
37
44
|
const rootRef = ref();
|
|
38
|
-
const
|
|
45
|
+
const ariaLabels = useAccessibilityLabels('sortDropdown');
|
|
39
46
|
watch(() => props.selectedSort, value => $x.emit(props.selectedSortProvidedEvent, value), {
|
|
40
47
|
immediate: true,
|
|
41
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-dropdown.vue2.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type {
|
|
1
|
+
{"version":3,"file":"sort-dropdown.vue2.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n :aria-label=\"ariaLabels?.dropdown\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../../composables'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n const ariaLabels = useAccessibilityLabels('sortDropdown')\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n ariaLabels,\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AA0CA;;;AAGE;AACF,gBAAe,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,OAAO;YACL,UAAU;YACV,oBAAoB;YACpB,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -2,6 +2,7 @@ import { forEach } from '@empathyco/x-utils';
|
|
|
2
2
|
import { defineComponent, ref, computed } from 'vue';
|
|
3
3
|
import '../../composables/create-use-device.js';
|
|
4
4
|
import { use$x } from '../../composables/use-_x.js';
|
|
5
|
+
import '../../utils/storage.js';
|
|
5
6
|
import 'vuex';
|
|
6
7
|
import '../../plugins/x-bus.js';
|
|
7
8
|
import '../../plugins/x-plugin.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-suggestion.vue2.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" :class=\"dynamicCSSClasses\" @click=\"emitEvents\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\nimport type { BooleanFilter, Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { QueryFeature } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { forEach } from '@empathyco/x-utils'\nimport { computed, defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport Highlight from '../highlight.vue'\n\n/**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\nexport default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: '',\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>,\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true,\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean,\n },\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null)\n\n const $x = use$x()\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter,\n )\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {}\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent,\n }\n })\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature,\n })\n })\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated,\n )\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value,\n }))\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## Examples\n\n### Basic usage\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facets: [\n {\n modelName: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10,\n },\n ],\n },\n ],\n}\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\">\n <template #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </template>\n </BaseSuggestion>\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\n</script>\n```\n\n### Emitting custom events with suggestionSelectedEvents\n\nYou can emit additional custom events when a suggestion is selected by passing them in the `suggestionSelectedEvents` prop. For example, to emit a custom event called `CustomSuggestionEvent` with a payload:\n\n```vue live\n<template>\n <BaseSuggestion\n :query=\"query\"\n :suggestion=\"suggestion\"\n :suggestionSelectedEvents=\"suggestionSelectedEvents\"\n />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\nconst suggestionSelectedEvents = {\n CustomSuggestionEvent: { custom: 'payload' },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;AA0BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,WAAW;AACzB,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,EAAE;AACZ,SAAA;AAED;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;;AAEF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AAED;;;;AAIE;AACF,QAAA,wBAAwB,EAAE;AACxB,YAAA,IAAI,EAAE,MAAyC;AAC/C,YAAA,QAAQ,EAAE,IAAI;A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F,QAAA,MAAM,iBAAgB,GAAI,QAAQ,CAAgB,OAAO;YACvD,0BAA0B,EAAE,sBAAsB,CAAC,KAAK;AACzD,SAAA,CAAC,CAAA;QAEF,OAAO;YACL,EAAE;YACF,MAAM;YACN,UAAU;YACV,iBAAiB;SACnB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"base-suggestion.vue2.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" :class=\"dynamicCSSClasses\" @click=\"emitEvents\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\nimport type { BooleanFilter, Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { QueryFeature } from '../../types'\nimport type { VueCSSClasses } from '../../utils/types'\nimport type { XEventsTypes } from '../../wiring/events.types'\nimport { forEach } from '@empathyco/x-utils'\nimport { computed, defineComponent, ref } from 'vue'\nimport { use$x } from '../../composables/index'\nimport Highlight from '../highlight.vue'\n\n/**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\nexport default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: '',\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>,\n },\n\n /**\n * The {@link XEvent} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true,\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean,\n },\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null)\n\n const $x = use$x()\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter,\n )\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {}\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent,\n }\n })\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature,\n })\n })\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated,\n )\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value,\n }))\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserAcceptedAQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion query\n data.\n- [`UserSelectedASuggestion`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the suggestion data.\n- [`UserClickedAFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button if the suggestion includes a filter. The\n event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## Examples\n\n### Basic usage\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facets: [\n {\n modelName: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10,\n },\n ],\n },\n ],\n}\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion :query=\"query\" :suggestion=\"suggestion\">\n <template #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </template>\n </BaseSuggestion>\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\n</script>\n```\n\n### Emitting custom events with suggestionSelectedEvents\n\nYou can emit additional custom events when a suggestion is selected by passing them in the `suggestionSelectedEvents` prop. For example, to emit a custom event called `CustomSuggestionEvent` with a payload:\n\n```vue live\n<template>\n <BaseSuggestion\n :query=\"query\"\n :suggestion=\"suggestion\"\n :suggestionSelectedEvents=\"suggestionSelectedEvents\"\n />\n</template>\n\n<script setup>\nimport { BaseSuggestion } from '@empathyco/x-components'\nconst query = 'st'\nconst suggestion = {\n modelName: 'QuerySuggestion',\n query: 'steak',\n}\nconst suggestionSelectedEvents = {\n CustomSuggestionEvent: { custom: 'payload' },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AA0BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,EAAE,WAAW;AACzB,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,EAAE;AACZ,SAAA;AAED;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;;AAEF,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AAED;;;;AAIE;AACF,QAAA,wBAAwB,EAAE;AACxB,YAAA,IAAI,EAAE,MAAyC;AAC/C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,OAAO;AACd,SAAA;AACF,KAAA;AAED,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAC,G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ACV,iBAAiB;SACnB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { inject, computed } from 'vue';
|
|
2
|
+
import { ACCESSIBILITY_KEY } from '../types/accessibility.js';
|
|
3
|
+
import { DEFAULT_ARIA_LABELS } from '../utils/accessibility.js';
|
|
4
|
+
import { deepMergeWithDefaults } from '../utils/deep-merge-with-defaults.js';
|
|
5
|
+
import '../utils/storage.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the aria labels for a given {@link AriaLabels} namespace, merging any labels provided
|
|
9
|
+
* by the consumer under {@link ACCESSIBILITY_KEY} on top of the library defaults.
|
|
10
|
+
*
|
|
11
|
+
* The consumer only needs to `app.provide` a **partial** configuration (e.g. the labels
|
|
12
|
+
* translated to its language): every entry that is not provided falls back to the library
|
|
13
|
+
* default. Providing nothing is a regular use case (the components resolve the defaults), and
|
|
14
|
+
* the `inject` fallback keeps Vue from logging an "injection not found" warning in that case.
|
|
15
|
+
*
|
|
16
|
+
* The resolved labels are reactive: if the consumer provides a reactive object (or re-provides
|
|
17
|
+
* translated labels when the locale changes), the components pick the new values up.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```vue
|
|
21
|
+
* <script setup>
|
|
22
|
+
* const ariaLabels = useAccessibilityLabels('pageSelector')
|
|
23
|
+
* </script>
|
|
24
|
+
* <template>
|
|
25
|
+
* <nav :aria-label="ariaLabels.pagination">...</nav>
|
|
26
|
+
* </template>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param namespace - The {@link AriaLabels} namespace to resolve (the PascalCase component name).
|
|
30
|
+
* @returns A reactive object with the resolved aria labels for the given namespace.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
function useAccessibilityLabels(namespace) {
|
|
35
|
+
const injected = inject(ACCESSIBILITY_KEY, {});
|
|
36
|
+
return computed(() => deepMergeWithDefaults(DEFAULT_ARIA_LABELS, injected)[namespace]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { useAccessibilityLabels };
|
|
40
|
+
//# sourceMappingURL=use-accessibility-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-accessibility-labels.js","sources":["../../../src/composables/use-accessibility-labels.ts"],"sourcesContent":["import type { ComputedRef } from 'vue'\nimport type { AriaLabels } from '../types/accessibility'\nimport { computed, inject } from 'vue'\nimport { ACCESSIBILITY_KEY } from '../types/accessibility'\nimport { deepMergeWithDefaults, DEFAULT_ARIA_LABELS } from '../utils'\n\n/**\n * Resolves the aria labels for a given {@link AriaLabels} namespace, merging any labels provided\n * by the consumer under {@link ACCESSIBILITY_KEY} on top of the library defaults.\n *\n * The consumer only needs to `app.provide` a **partial** configuration (e.g. the labels\n * translated to its language): every entry that is not provided falls back to the library\n * default. Providing nothing is a regular use case (the components resolve the defaults), and\n * the `inject` fallback keeps Vue from logging an \"injection not found\" warning in that case.\n *\n * The resolved labels are reactive: if the consumer provides a reactive object (or re-provides\n * translated labels when the locale changes), the components pick the new values up.\n *\n * @example\n * ```vue\n * <script setup>\n * const ariaLabels = useAccessibilityLabels('pageSelector')\n * </script>\n * <template>\n * <nav :aria-label=\"ariaLabels.pagination\">...</nav>\n * </template>\n * ```\n *\n * @param namespace - The {@link AriaLabels} namespace to resolve (the PascalCase component name).\n * @returns A reactive object with the resolved aria labels for the given namespace.\n *\n * @public\n */\nexport function useAccessibilityLabels<N extends keyof AriaLabels>(\n namespace: N,\n): ComputedRef<NonNullable<AriaLabels[N]>> {\n const injected = inject(ACCESSIBILITY_KEY, {})\n return computed(\n () =>\n deepMergeWithDefaults(DEFAULT_ARIA_LABELS, injected)[namespace] as NonNullable<AriaLabels[N]>,\n )\n}\n"],"names":[],"mappings":";;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,sBAAsB,CACpC,SAAY,EAAA;IAEZ,MAAM,QAAQ,GAAG,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC;AAC9C,IAAA,OAAO,QAAQ,CACb,MACE,qBAAqB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS,CAA+B,CAChG;AACH;;;;"}
|
package/js/index.js
CHANGED
|
@@ -153,6 +153,7 @@ export { default as BaseSuggestions } from './components/suggestions/base-sugges
|
|
|
153
153
|
export { getRootXComponent, getXComponentXModuleName, isXComponent } from './components/x-component.utils.js';
|
|
154
154
|
export { createUseDevice } from './composables/create-use-device.js';
|
|
155
155
|
export { use$x } from './composables/use-_x.js';
|
|
156
|
+
export { useAccessibilityLabels } from './composables/use-accessibility-labels.js';
|
|
156
157
|
export { useAliasApi } from './composables/use-alias-api.js';
|
|
157
158
|
export { useDebounce } from './composables/use-debounce.js';
|
|
158
159
|
export { useGetter } from './composables/use-getter.js';
|
|
@@ -175,11 +176,12 @@ export { createStoreEmitters } from './store/utils/store-emitters.utils.js';
|
|
|
175
176
|
export { RootXStoreModule } from './store/x.module.js';
|
|
176
177
|
export { ACCESSIBILITY_KEY } from './types/accessibility.js';
|
|
177
178
|
export { AnimationProp } from './types/animation-prop.js';
|
|
178
|
-
export { DEFAULT_ARIA_LABELS
|
|
179
|
+
export { DEFAULT_ARIA_LABELS } from './utils/accessibility.js';
|
|
179
180
|
export { arrayToObject, createEmitterArrayFilter, deepFilter, deepFlat, groupItemsBy, isArrayEmpty } from './utils/array.js';
|
|
180
181
|
export { CancelSymbol, cancellablePromise } from './utils/cancellable-promise.js';
|
|
181
182
|
export { clone } from './utils/clone.js';
|
|
182
183
|
export { debounce as debounceFunction } from './utils/debounce.js';
|
|
184
|
+
export { deepMergeWithDefaults } from './utils/deep-merge-with-defaults.js';
|
|
183
185
|
export { areFiltersDifferent, createRawFilters } from './utils/filters.js';
|
|
184
186
|
export { FOCUSABLE_SELECTORS } from './utils/focus.js';
|
|
185
187
|
export { noOp } from './utils/function.js';
|
package/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|