@empathyco/x-components 9.3.0 → 9.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/core/index.js +4 -0
- package/core/index.js.map +1 -1
- package/docs/API-reference/api/x-components.accessibility_key.md +11 -0
- package/docs/API-reference/api/x-components.aicarousel.md +4 -0
- package/docs/API-reference/api/x-components.arialabels.aicarousel.md +14 -0
- package/docs/API-reference/api/x-components.arialabels.basecolumnpickerdropdown.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.basecolumnpickerlist.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.basedropdown.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.baseeventsmodalclose.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.baseeventsmodalopen.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.basemodal.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.clearhistoryqueries.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.editablenumberrangefilter.md +14 -0
- package/docs/API-reference/api/x-components.arialabels.facets.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.filterssearch.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.historyqueriesswitch.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.historyquery.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.md +419 -0
- package/docs/API-reference/api/x-components.arialabels.pageloaderbutton.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.pageselector.md +16 -0
- package/docs/API-reference/api/x-components.arialabels.removehistoryquery.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.scrolltotop.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.searchinput.md +13 -0
- package/docs/API-reference/api/x-components.arialabels.sliderfilter.md +14 -0
- package/docs/API-reference/api/x-components.arialabels.sortdropdown.md +13 -0
- package/docs/API-reference/api/x-components.basecolumnpickerdropdown.md +3 -0
- package/docs/API-reference/api/x-components.basecolumnpickerlist.md +3 -0
- package/docs/API-reference/api/x-components.basedropdown.md +3 -2
- package/docs/API-reference/api/x-components.baseeventsmodalclose.md +3 -0
- package/docs/API-reference/api/x-components.baseeventsmodalopen.md +3 -0
- package/docs/API-reference/api/x-components.basemodal.md +3 -0
- package/docs/API-reference/api/x-components.clearhistoryqueries.md +3 -0
- package/docs/API-reference/api/x-components.deepmergewithdefaults.md +85 -0
- package/docs/API-reference/api/x-components.editablenumberrangefilter.md +4 -2
- package/docs/API-reference/api/x-components.facets.md +3 -0
- package/docs/API-reference/api/x-components.filterssearch.md +3 -0
- package/docs/API-reference/api/x-components.historyqueriesswitch.md +3 -0
- package/docs/API-reference/api/x-components.historyquery.md +3 -0
- package/docs/API-reference/api/x-components.md +50 -0
- package/docs/API-reference/api/x-components.pageloaderbutton.md +3 -0
- package/docs/API-reference/api/x-components.pageselector.md +6 -0
- package/docs/API-reference/api/x-components.removehistoryquery.md +3 -0
- package/docs/API-reference/api/x-components.scrolltotop.md +3 -0
- package/docs/API-reference/api/x-components.searchinput.md +3 -0
- package/docs/API-reference/api/x-components.sliderfilter.md +4 -0
- package/docs/API-reference/api/x-components.sortdropdown.md +3 -0
- package/docs/API-reference/api/x-components.useaccessibilitylabels.md +72 -0
- package/docs/API-reference/components/common/x-components.base-dropdown.md +0 -1
- package/js/components/base-dropdown.vue.js +1 -1
- package/js/components/base-dropdown.vue.js.map +1 -1
- package/js/components/base-dropdown.vue2.js +11 -3
- 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 +2 -2
- 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 -0
- 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 +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 -1
- 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 +2 -2
- package/js/components/modals/base-events-modal-close.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-close.vue2.js +10 -0
- package/js/components/modals/base-events-modal-close.vue2.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue.js +2 -2
- package/js/components/modals/base-events-modal-open.vue.js.map +1 -1
- package/js/components/modals/base-events-modal-open.vue2.js +10 -0
- 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 +11 -16
- package/js/components/modals/base-modal.vue.js.map +1 -1
- package/js/components/modals/base-modal.vue2.js +3 -0
- package/js/components/modals/base-modal.vue2.js.map +1 -1
- package/js/components/page-loader-button.vue.js +2 -2
- package/js/components/page-loader-button.vue.js.map +1 -1
- package/js/components/page-loader-button.vue2.js +3 -0
- package/js/components/page-loader-button.vue2.js.map +1 -1
- package/js/components/page-selector.vue.js +12 -12
- package/js/components/page-selector.vue.js.map +1 -1
- package/js/components/page-selector.vue2.js +3 -0
- 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 +2 -2
- package/js/components/sort/sort-dropdown.vue.js.map +1 -1
- package/js/components/sort/sort-dropdown.vue2.js +10 -0
- 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 +4 -0
- package/js/index.js.map +1 -1
- package/js/types/accessibility.js +4 -0
- package/js/types/accessibility.js.map +1 -0
- package/js/utils/accessibility.js +37 -0
- package/js/utils/accessibility.js.map +1 -0
- package/js/utils/deep-merge-with-defaults.js +47 -0
- package/js/utils/deep-merge-with-defaults.js.map +1 -0
- package/js/x-modules/ai/components/ai-carousel.vue.js +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 -0
- 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 +57 -51
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue2.js +9 -0
- 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 +2 -2
- 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 -4
- 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 +4 -4
- 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 -0
- 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 +2 -2
- 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 -0
- 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 +2 -2
- 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 -0
- 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 +2 -2
- 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 -0
- 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 +2 -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 -0
- 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 +2 -2
- 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 -0
- 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 +2 -2
- 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 -0
- 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 +2 -2
- 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 -1
- 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 +1148 -210
- package/report/x-components.api.md +176 -11
- package/types/src/components/base-dropdown.vue.d.ts +3 -4
- package/types/src/components/base-dropdown.vue.d.ts.map +1 -1
- package/types/src/components/column-picker/base-column-picker-dropdown.vue.d.ts +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- package/types/src/components/modals/base-modal.vue.d.ts.map +1 -1
- package/types/src/components/page-loader-button.vue.d.ts +3 -0
- package/types/src/components/page-loader-button.vue.d.ts.map +1 -1
- package/types/src/components/page-selector.vue.d.ts +6 -0
- package/types/src/components/page-selector.vue.d.ts.map +1 -1
- package/types/src/components/sort/sort-dropdown.vue.d.ts +3 -0
- 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/types/accessibility.d.ts +79 -0
- package/types/src/types/accessibility.d.ts.map +1 -0
- package/types/src/types/index.d.ts +1 -0
- package/types/src/types/index.d.ts.map +1 -1
- package/types/src/utils/accessibility.d.ts +10 -0
- package/types/src/utils/accessibility.d.ts.map +1 -0
- 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 +2 -0
- package/types/src/utils/index.d.ts.map +1 -1
- package/types/src/x-modules/ai/components/ai-carousel.vue.d.ts +4 -0
- 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 +3 -0
- 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 +4 -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 +4 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +3 -0
- package/types/src/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-queries-switch.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch
|
|
1
|
+
{"version":3,"file":"history-queries-switch.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch\n :model-value=\"isEnabled\"\n :aria-label=\"ariaLabels?.root\"\n @update:model-value=\"toggle\"\n />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const ariaLabels = useAccessibilityLabels('historyQueriesSwitch')\n\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n ariaLabels,\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAIE,qBAAA,EAAA;AAAA,IAHC,aAAA,EAAa,IAAA,CAAA,SAAA;AAAA,IACb,cAAY,IAAA,CAAA,UAAA,EAAY,IAAA;AAAA,IACxB,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,aAAA,EAAA,YAAA,EAAA,qBAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { defineComponent, computed } from 'vue';
|
|
2
2
|
import BaseSwitch from '../../../components/base-switch.vue.js';
|
|
3
|
+
import '../../../composables/create-use-device.js';
|
|
3
4
|
import { use$x } from '../../../composables/use-_x.js';
|
|
5
|
+
import { useAccessibilityLabels } from '../../../composables/use-accessibility-labels.js';
|
|
6
|
+
import 'vuex';
|
|
7
|
+
import '../../../plugins/x-bus.js';
|
|
8
|
+
import '@empathyco/x-utils';
|
|
9
|
+
import '../../../plugins/x-plugin.js';
|
|
10
|
+
import '@vueuse/core';
|
|
11
|
+
import 'rxjs';
|
|
4
12
|
import { useState } from '../../../composables/use-state.js';
|
|
5
13
|
import { isArrayEmpty } from '../../../utils/array.js';
|
|
6
14
|
import { historyQueriesXModule } from '../x-module.js';
|
|
@@ -18,6 +26,7 @@ var _sfc_main = defineComponent({
|
|
|
18
26
|
BaseSwitch,
|
|
19
27
|
},
|
|
20
28
|
setup() {
|
|
29
|
+
const ariaLabels = useAccessibilityLabels('historyQueriesSwitch');
|
|
21
30
|
const $x = use$x();
|
|
22
31
|
/**
|
|
23
32
|
* An object with the isEnabled value and the history queries coming from the store state.
|
|
@@ -43,6 +52,7 @@ var _sfc_main = defineComponent({
|
|
|
43
52
|
$x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries');
|
|
44
53
|
};
|
|
45
54
|
return {
|
|
55
|
+
ariaLabels,
|
|
46
56
|
toggle,
|
|
47
57
|
isEnabled,
|
|
48
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-queries-switch.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch
|
|
1
|
+
{"version":3,"file":"history-queries-switch.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries-switch.vue"],"sourcesContent":["<template>\n <BaseSwitch\n :model-value=\"isEnabled\"\n :aria-label=\"ariaLabels?.root\"\n @update:model-value=\"toggle\"\n />\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSwitch from '../../../components/base-switch.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * History Queries Switch is a component to activate or deactivate the history queries.\n * This component emits events depending on the `isEnabled` value.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueriesSwitch',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSwitch,\n },\n setup() {\n const ariaLabels = useAccessibilityLabels('historyQueriesSwitch')\n\n const $x = use$x()\n\n /**\n * An object with the isEnabled value and the history queries coming from the store state.\n *\n * @internal\n */\n const { isEnabled, historyQueries } = useState('historyQueries')\n\n /**\n * Checks if there are history queries.\n *\n * @returns True if there are history queries; false otherwise.\n */\n const hasHistoryQueries = computed(() => !isArrayEmpty(historyQueries.value as HistoryQuery[]))\n\n const disableEvent = computed(() =>\n hasHistoryQueries.value\n ? 'UserClickedDisableHistoryQueries'\n : 'UserClickedConfirmDisableHistoryQueries',\n )\n\n /**\n * Emits an event based on the switch state.\n *\n * @internal\n */\n const toggle = (): void => {\n $x.emit(isEnabled.value ? disableEvent.value : 'UserClickedEnableHistoryQueries')\n }\n\n return {\n ariaLabels,\n toggle,\n isEnabled,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedEnableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch and the history queries are deactivated.\n- [`UserClickedDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is not empty.\n- [`UserClickedConfirmDisableHistoryQueries`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted whenever the user clicks the switch when the history queries are activated\n and the list of history queries is empty.\n\n## See it in action\n\nHere you have a basic example of how the switch is rendered.\n\n_Try clicking it to see how it changes its state_\n\n```vue live\n<template>\n <HistoryQueriesSwitch />\n</template>\n\n<script setup>\nimport { HistoryQueriesSwitch } from '@empathyco/x-components/history-queries'\n</script>\n```\n\nHere you have a more complex example.\n\n```vue live\n<template>\n <div>\n <div>\n <SearchInput :instant=\"false\" />\n <SearchButton>Search</SearchButton>\n </div>\n <label>\n History queries:\n <HistoryQueriesSwitch />\n <HistoryQueries />\n <BaseEventsModal :eventsToOpenModal=\"eventsToOpenModal\">\n <BaseEventButton :events=\"disableEvents\">Disable</BaseEventButton>\n <BaseEventButton :events=\"cancelEvents\">Cancel</BaseEventButton>\n </BaseEventsModal>\n </label>\n </div>\n</template>\n\n<script setup>\nimport { BaseEventButton, BaseEventsModal } from '@empathyco/x-components'\nimport { HistoryQueriesSwitch, HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { SearchInput, SearchButton } from '@empathyco/x-components/search-box'\nimport { ref } from 'vue'\n\nconst eventsToOpenModal = ref(['UserClickedDisableHistoryQueries'])\nconst disableEvents = ref({\n UserClickedConfirmDisableHistoryQueries: undefined,\n UserClickedCloseEventsModal: undefined,\n})\nconst cancelEvents = ref({\n UserClickedCloseEventsModal: undefined,\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,UAAU;AACX,KAAA;IACD,KAAK,GAAA;AACH,QAAA,MAAM,UAAS,GAAI,sBAAsB,CAAC,sBAAsB,CAAA;AAEhE,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AAEjB;;;;AAIE;QACF,MAAM,EAAE,SAAS,EAAE,cAAa,EAAE,GAAI,QAAQ,CAAC,gBAAgB,CAAA;AAE/D;;;;AAIE;AACF,QAAA,MAAM,iBAAgB,GAAI,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,KAAuB,CAAC,CAAA;QAE9F,MAAM,YAAW,GAAI,QAAQ,CAAC,MAC5B,iBAAiB,CAAC;AAChB,cAAE;cACA,yCAAyC,CAC/C;AAEA;;;;AAIE;QACF,MAAM,SAAS,MAAU;AACvB,YAAA,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAI,GAAI,YAAY,CAAC,KAAI,GAAI,iCAAiC,CAAA;AAClF,QAAA,CAAA;QAEA,OAAO;YACL,UAAU;YACV,MAAM;YACN,SAAS;SACX;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -23,6 +23,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
23
|
createVNode(_component_RemoveHistoryQuery, {
|
|
24
24
|
class: normalizeClass(["x-history-query__remove xds:suggestion-group-button", _ctx.removeButtonClass]),
|
|
25
25
|
"history-query": _ctx.suggestion,
|
|
26
|
+
"aria-label": _ctx.ariaLabels?.removeButton,
|
|
26
27
|
"data-test": "remove-history-query"
|
|
27
28
|
}, {
|
|
28
29
|
default: withCtx(() => [
|
|
@@ -36,7 +37,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
36
37
|
]),
|
|
37
38
|
_: 3
|
|
38
39
|
/* FORWARDED */
|
|
39
|
-
}, 8, ["class", "history-query"])
|
|
40
|
+
}, 8, ["class", "history-query", "aria-label"])
|
|
40
41
|
]);
|
|
41
42
|
}
|
|
42
43
|
var HistoryQuery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeClass","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;AACO,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,sCAAA,EAAsC;;;;AAAjD,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,
|
|
1
|
+
{"version":3,"file":"history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n :aria-label=\"ariaLabels?.removeButton\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n const ariaLabels = useAccessibilityLabels('historyQuery')\n\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n ariaLabels,\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeClass","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;AACO,MAAA,UAAA,GAAA,EAAA,KAAA,EAAM,sCAAA,EAAsC;;;;AAAjD,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAqCM,OArCN,UAAA,EAqCM;AAAA,IA9BJC,WAAA,CAgBiB,2BAhBjBC,UAAA,CAgBiB;AAAA,MAdf,KAAA,EAAK,CAAC,6BAAA,EACE,IAAA,CAAA,eAAe;AAAA,KAAA,EAAA,EAAA,UAAA,EACb,IAAA,CAAA,UAAA,EAAU,wBAAA,EAAE,IAAA,CAAA,wBAAA,EAAwB,KAAA,EAAE,IAAA,CAAA,KAAA,EAAK,EAAA;AAAA,MACrD,WAAA,EAAU,eAAA;AAAA,MACV,OAAA,EAAQ,eAAA;AAAA,MACP,OAAA,EAAK,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAE,IAAA,CAAA,KAAA,CAAK,OAAA,EAAU,iBAAY,MAAM,CAAA;AAAA,KAAA,CAAA,EAAA;AAQzC,MAAA,OAAA,EAAAC,OAAA,CAAA,CAAkC,SAAA,KAdjB;AAAA,QAcjBC,UAAA,CAAkC,+DAAf,SAAA,EAAS,CAAA,CAAA;AAAA,OAAA,CAAA;;;;IAE9BH,WAAA,CAYqB,6BAAA,EAAA;AAAA,MAXnB,KAAA,EAAKI,cAAA,CAAA,CAAC,qDAAA,EACE,IAAA,CAAA,iBAAiB,CAAA,CAAA;AAAA,MACxB,eAAA,EAAe,IAAA,CAAA,UAAA;AAAA,MACf,cAAY,IAAA,CAAA,UAAA,EAAY,YAAA;AAAA,MACzB,WAAA,EAAU;AAAA,KAAA,EAAA;uBAMV,MAAmE;AAAA,QAAnED,UAAA,CAAmE,IAAA,CAAA,MAAA,EAAA,uBAAA,EAAAE,cAAA,CAAAC,kBAAA,CAAA,EAAA,UAAA,EAAtB,IAAA,CAAA,UAAA,EAAU,CAAA,CAAA,EAAvD,MAAmE;AAAA,UAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,eAAA;AAAR,YAAA,GAAA;AAAA,YAAC;AAAA;AAAA,WAAA;AAAA,SAAA;;;;;;;;;;;"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { defineComponent, computed } from 'vue';
|
|
2
2
|
import BaseSuggestion from '../../../components/suggestions/base-suggestion.vue.js';
|
|
3
|
+
import '../../../composables/create-use-device.js';
|
|
4
|
+
import 'vuex';
|
|
5
|
+
import '../../../plugins/x-bus.js';
|
|
6
|
+
import '@empathyco/x-utils';
|
|
7
|
+
import '../../../plugins/x-plugin.js';
|
|
8
|
+
import 'rxjs';
|
|
9
|
+
import { useAccessibilityLabels } from '../../../composables/use-accessibility-labels.js';
|
|
3
10
|
import { useGetter } from '../../../composables/use-getter.js';
|
|
11
|
+
import '@vueuse/core';
|
|
4
12
|
import { historyQueriesXModule } from '../x-module.js';
|
|
5
13
|
import RemoveHistoryQuery from './remove-history-query.vue.js';
|
|
6
14
|
|
|
@@ -32,6 +40,7 @@ var _sfc_main = defineComponent({
|
|
|
32
40
|
},
|
|
33
41
|
emits: ['click'],
|
|
34
42
|
setup(props) {
|
|
43
|
+
const ariaLabels = useAccessibilityLabels('historyQuery');
|
|
35
44
|
/**
|
|
36
45
|
* The normalized query of the history-queries module.
|
|
37
46
|
*
|
|
@@ -48,6 +57,7 @@ var _sfc_main = defineComponent({
|
|
|
48
57
|
UserSelectedAHistoryQuery: props.suggestion,
|
|
49
58
|
}));
|
|
50
59
|
return {
|
|
60
|
+
ariaLabels,
|
|
51
61
|
query,
|
|
52
62
|
suggestionSelectedEvents,
|
|
53
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query xds:suggestion-group\">\n <!--\n Click on the History Query suggestion\n @event click\n @property {Suggestion} suggestion - History Query suggestion data\n @property {MouseEvent} event - The original mouse event\n -->\n <BaseSuggestion\n v-slot=\"baseScope\"\n class=\"x-history-query__suggestion\"\n :class=\"suggestionClass\"\n v-bind=\"{ suggestion, suggestionSelectedEvents, query }\"\n data-test=\"history-query\"\n feature=\"history_query\"\n @click=\"$emit('click', suggestion, $event)\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter or undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n <RemoveHistoryQuery\n class=\"x-history-query__remove xds:suggestion-group-button\"\n :class=\"removeButtonClass\"\n :history-query=\"suggestion\"\n :aria-label=\"ariaLabels?.removeButton\"\n data-test=\"remove-history-query\"\n >\n <!--\n @slot History Query remove button content\n @binding {Suggestion} suggestion - History Query suggestion data\n -->\n <slot name=\"remove-button-content\" v-bind=\"{ suggestion }\">✕</slot>\n </RemoveHistoryQuery>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { useGetter } from '../../../composables/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport RemoveHistoryQuery from './remove-history-query.vue'\n\n/**\n * This component renders a history query suggestion combining two buttons: one for selecting this\n * suggestion as the search query, and another one to remove this query suggestion from the\n * history queries.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQuery',\n xModule: historyQueriesXModule.name,\n components: { RemoveHistoryQuery, BaseSuggestion },\n props: {\n /**\n * The history query suggestion to render.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<HistoryQueryModel>,\n required: true,\n },\n /** Class inherited by content element. */\n removeButtonClass: String,\n /** Class inherited by content element. */\n suggestionClass: String,\n },\n emits: ['click'],\n setup(props) {\n const ariaLabels = useAccessibilityLabels('historyQuery')\n\n /**\n * The normalized query of the history-queries module.\n *\n * @internal\n */\n const query = useGetter('historyQueries').normalizedQuery\n\n /**\n * The list of events that are going to be emitted when the suggestion button is pressed.\n *\n * @internal\n * @returns The {@link XEvent} to emit.\n */\n const suggestionSelectedEvents = computed(\n (): Partial<XEventsTypes> => ({\n UserSelectedAHistoryQuery: props.suggestion,\n }),\n )\n\n return {\n ariaLabels,\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserSelectedAHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic usage\n\nThis component only requires a prop called `suggestion`.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing slots content\n\nSuggestion and remove buttons contents can be customized.\n\nThe default slot allows you to replace the content of the suggestion button. It has two properties,\nthe suggestion itself, and a `string` of HTML with the matched query.\n\nThe other slot is called `remove-button-content`, and allows you to set the content of the button\nthat serves to remove this query from the history. This slot only has one property, the suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\">\n <template #default=\"{ suggestion }\">\n <HistoryIcon />\n <Highlight highlight=\"tro\" :text=\"suggestion.query\" />\n </template>\n\n <template #remove-button-content=\"{ suggestion }\">\n <CrossIcon />\n </template>\n </HistoryQuery>\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\n### Customizing the content with classes\n\nThe `suggestionClass` prop can be used to add classes to the history query suggestion.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" suggestionClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n\nThe `removeButtonClass` prop can be used to add classes to the remove history query.\n\n```vue live\n<template>\n <HistoryQuery :suggestion=\"suggestion\" removeButtonClass=\"x-custom-class\" />\n</template>\n\n<script setup>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst suggestion = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAoDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,EAAE,kBAAkB,EAAE,gBAAgB;AAClD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,eAAe,EAAE,MAAM;AACxB,KAAA;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;AAChB,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,UAAS,GAAI,sBAAsB,CAAC,cAAc,CAAA;AAExD;;;;AAIE;QACF,MAAM,KAAI,GAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,eAAc;AAExD;;;;;AAKE;AACF,QAAA,MAAM,wBAAuB,GAAI,QAAQ,CACvC,OAA8B;YAC5B,yBAAyB,EAAE,KAAK,CAAC,UAAU;AAC5C,SAAA,CAAC,CACJ;QAEA,OAAO;YACL,UAAU;YACV,KAAK;YACL,wBAAwB;SAC1B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -7,14 +7,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
7
7
|
return openBlock(), createBlock(_component_BaseEventButton, {
|
|
8
8
|
class: "x-remove-history-query",
|
|
9
9
|
events: _ctx.removeHistoryQueryEvent,
|
|
10
|
-
"aria-label":
|
|
10
|
+
"aria-label": _ctx.ariaLabels?.button
|
|
11
11
|
}, {
|
|
12
12
|
default: withCtx(() => [
|
|
13
13
|
renderSlot(_ctx.$slots, "default")
|
|
14
14
|
]),
|
|
15
15
|
_: 3
|
|
16
16
|
/* FORWARDED */
|
|
17
|
-
}, 8, ["events"]);
|
|
17
|
+
}, 8, ["events", "aria-label"]);
|
|
18
18
|
}
|
|
19
19
|
var RemoveHistoryQuery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
20
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n aria-label=\"
|
|
1
|
+
{"version":3,"file":"remove-history-query.vue.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n const ariaLabels = useAccessibilityLabels('removeHistoryQuery')\n\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n ariaLabels,\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":["_createBlock","_renderSlot"],"mappings":";;;;;;sBACEA,WAAA,CAOkB,0BAAA,EAAA;AAAA,IANhB,KAAA,EAAM,wBAAA;AAAA,IACL,MAAA,EAAQ,IAAA,CAAA,uBAAA;AAAA,IACR,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,GAAA,EAAA;qBAGzB,MAAQ;AAAA,MAARC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { defineComponent, computed } from 'vue';
|
|
2
2
|
import BaseEventButton from '../../../components/base-event-button.vue.js';
|
|
3
|
+
import '../../../composables/create-use-device.js';
|
|
4
|
+
import 'vuex';
|
|
5
|
+
import '../../../plugins/x-bus.js';
|
|
6
|
+
import '@empathyco/x-utils';
|
|
7
|
+
import '../../../plugins/x-plugin.js';
|
|
8
|
+
import 'rxjs';
|
|
9
|
+
import { useAccessibilityLabels } from '../../../composables/use-accessibility-labels.js';
|
|
10
|
+
import '@vueuse/core';
|
|
3
11
|
import { historyQueriesXModule } from '../x-module.js';
|
|
4
12
|
|
|
5
13
|
/**
|
|
@@ -27,6 +35,7 @@ var _sfc_main = defineComponent({
|
|
|
27
35
|
},
|
|
28
36
|
},
|
|
29
37
|
setup(props) {
|
|
38
|
+
const ariaLabels = useAccessibilityLabels('removeHistoryQuery');
|
|
30
39
|
/**
|
|
31
40
|
* The event handler that will be triggered when clicking on the clear history query button.
|
|
32
41
|
*
|
|
@@ -38,6 +47,7 @@ var _sfc_main = defineComponent({
|
|
|
38
47
|
*/
|
|
39
48
|
const removeHistoryQueryEvent = computed(() => ({ UserPressedRemoveHistoryQuery: props.historyQuery }));
|
|
40
49
|
return {
|
|
50
|
+
ariaLabels,
|
|
41
51
|
removeHistoryQueryEvent,
|
|
42
52
|
};
|
|
43
53
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n aria-label=\"
|
|
1
|
+
{"version":3,"file":"remove-history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/remove-history-query.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-remove-history-query\"\n :events=\"removeHistoryQueryEvent\"\n :aria-label=\"ariaLabels?.button\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { HistoryQuery } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../components/base-event-button.vue'\nimport { useAccessibilityLabels } from '../../../composables'\nimport { historyQueriesXModule } from '../x-module'\n\n/**\n * Button that when it is pressed emits the\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery} event, expressing the user\n * intention to remove a query in the history.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RemoveHistoryQuery',\n xModule: historyQueriesXModule.name,\n components: {\n BaseEventButton,\n },\n props: {\n /**\n * The historyQuery that will be removed when clicking the clear button.\n *\n * @public\n */\n historyQuery: {\n type: Object as PropType<HistoryQuery>,\n required: true,\n },\n },\n setup(props) {\n const ariaLabels = useAccessibilityLabels('removeHistoryQuery')\n\n /**\n * The event handler that will be triggered when clicking on the clear history query button.\n *\n * @remarks\n * {@link HistoryQueriesXEvents.UserPressedRemoveHistoryQuery}: historyQuery\n *\n * @returns The {@link XEvent} to emit.\n * @public\n */\n const removeHistoryQueryEvent = computed(\n (): Partial<XEventsTypes> => ({ UserPressedRemoveHistoryQuery: props.historyQuery }),\n )\n\n return {\n ariaLabels,\n removeHistoryQueryEvent,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserPressedRemoveHistoryQuery`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the history query\n data.\n\n## Examples\n\n### Basic Example\n\nYou can customize the content that this component renders. To do so, simply use the default slot.\n\n```vue\n<template>\n <RemoveHistoryQuery :historyQuery=\"historyQuery\">\n <img class=\"x-history-query__icon\" src=\"./my-awesome-clear-icon.svg\" />\n </RemoveHistoryQuery>\n</template>\n\n<script setup>\nimport { RemoveHistoryQuery } from '@empathyco/x-components/history-queries'\nimport { ref } from 'vue'\n\nconst historyQuery = ref({\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n})\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;AAoBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;AACD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACtC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,aAAa,sBAAsB,CAAC,oBAAoB,CAAA;AAE9D;;;;;;;;AAQE;AACF,QAAA,MAAM,uBAAsB,GAAI,QAAQ,CACtC,OAA8B,EAAE,6BAA6B,EAAE,KAAK,CAAC,YAAW,EAAG,CAAC,CACtF;QAEA,OAAO;YACL,UAAU;YACV,uBAAuB;SACzB;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -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 'rxjs';
|
|
8
|
+
import '../../../utils/storage.js';
|
|
8
9
|
import '@vueuse/core';
|
|
9
10
|
import { useState } from '../../../composables/use-state.js';
|
|
10
11
|
import { AnimationProp } from '../../../types/animation-prop.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-preview-list.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n :class=\"{ 'padding-block-1': loadWhenVisible }\"\n :data-query-preview-hash=\"\n getHashFromQueryPreviewInfo(queryPreview, { ...params, ...queryPreview.extraParams })\n \"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n :debounce-time-ms=\"debounceTimeMs\"\n :load-when-visible=\"loadWhenVisible\"\n :max-items-to-render=\"maxItemsToRender\"\n :persist-in-cache=\"persistInCache\"\n :query-feature=\"queryFeature\"\n :query-preview-info=\"queryPreview\"\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n >\n <template v-for=\"(_, slotName) in $slots\" #[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { RequestStatus } from '../../../store'\nimport type { QueryFeature } from '../../../types'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { useState } from '../../../composables/index'\nimport { AnimationProp } from '../../../types'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\nimport QueryPreview from './query-preview.vue'\n\ninterface QueryPreviewStatusRecord {\n [query: string]: RequestStatus\n}\n\n/**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true,\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n *\n * @public\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\n *\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n },\n setup(props) {\n const { params } = useState('queriesPreview')\n\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n const queriesStatus = ref<QueryPreviewStatusRecord>({})\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item =>\n getHashFromQueryPreviewInfo(item, { ...params.value, ...item.extraParams }),\n ),\n )\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item, {\n ...params.value,\n ...item.extraParams,\n })\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n )\n })\n })\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value))\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading'\n }\n }\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key]\n }\n }\n loadNext()\n }\n },\n { immediate: true, deep: true },\n )\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success'\n loadNext()\n }\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error'\n loadNext()\n }\n\n return {\n params,\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded,\n getHashFromQueryPreviewInfo,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.padding-block-1 {\n padding-block: 1px;\n}\n</style>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport SlidingPanel from '@empathyco/x-components/sliding-panel.vue'\nimport Result from '@empathyco/x-components/result.vue'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with vendor results and vendor banners\n\nThe `VendorResultsList` and `VendorBannersList` components can be used inside the default slot of\nthe `QueryPreviewList`, so the vendor results and vendor banners provided for each query are\ninserted within its results. The order of the nested components defines the merge strategy.\n\n```vue\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" #default=\"{ queryPreviewHash }\">\n <VendorResultsList :queryPreviewHash=\"queryPreviewHash\">\n <VendorBannersList :queryPreviewHash=\"queryPreviewHash\">\n <BaseGrid>\n <template #result=\"{ item }\">\n <span>Result: {{ item.id }}</span>\n </template>\n <template #vendor-result=\"{ item }\">\n <span>Vendor result: {{ item.id }}</span>\n </template>\n <template #vendor-banner=\"{ item }\">\n <span>Vendor banner: {{ item.id }}</span>\n </template>\n </BaseGrid>\n </VendorBannersList>\n </VendorResultsList>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { VendorBannersList, VendorResultsList } from '@empathyco/x-components/vendor'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA6CA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,qBAAqB,CAAC,IAAI;IACnC,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,kBAAkB,EAAE;AAClB,YAAA,IAAI,EAAE,KAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AACD;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAAM;AACb,SAAA;AACD;;;;AAIE;AACF,QAAA,eAAe,EAAE;AACf,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;AACD;;;;;;AAME;AACF,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACD;;;;;AAKE;AACF,QAAA,cAAc,EAAE,OAAO;AACvB;;;;AAIE;AACF,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;QACT,MAAM,EAAE,QAAO,GAAI,QAAQ,CAAC,gBAAgB,CAAA;AAE5C;;AAEE;AACF,QAAA,MAAM,aAAY,GAAI,GAAG,CAA2B,EAAE,CAAA;AAEtD;;;;;AAKE;AACF,QAAA,MAAM,OAAM,GAAI,QAAQ,CAAC,MACvB,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAC3B,2BAA2B,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,WAAU,EAAG,CAAC,CAC5E,CACH;AAEA;;;;;AAKE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAC,MAAwB;YAC7D,OAAO,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAG,IAAG;AAC3C,gBAAA,MAAM,mBAAmB,2BAA2B,CAAC,IAAI,EAAE;oBACzD,GAAG,MAAM,CAAC,KAAK;oBACf,GAAG,IAAI,CAAC,WAAW;AACpB,iBAAA,CAAA;gBACD,QACE,aAAa,CAAC,KAAK,CAAC,gBAAgB,CAAA,KAAM,SAAQ;oBAClD,aAAa,CAAC,KAAK,CAAC,gBAAgB,MAAM,SAAQ;AAEtD,YAAA,CAAC,CAAA;AACH,QAAA,CAAC,CAAA;AAED;;;;AAIE;QACF,MAAM,QAAO,GAAI,MAAU;YACzB,MAAM,WAAU,GAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAI,IAAK,EAAE,KAAI,IAAK,aAAa,CAAC,KAAK,CAAC,CAAA;YAC/E,IAAI,WAAW,EAAE;AACf,gBAAA,aAAa,CAAC,KAAK,CAAC,WAAW,CAAA,GAAI,SAAQ;YAC7C;AACF,QAAA,CAAA;AAEA;;;;;;AAME;QACF,KAAK,CACH,OAAO,EACP,CAAC,UAAoB,EAAE,UAAgC,KAAG;YACxD,IAAI,UAAU,CAAC,QAAQ,EAAC,KAAM,UAAU,EAAE,QAAQ,EAAE,EAAE;AACpD,gBAAA,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;oBAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC7B,wBAAA,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAA;oBAChC;gBACF;AACA,gBAAA,QAAQ,EAAC;YACX;QACF,CAAC,EACD,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAG,EAAG,CACjC;AAEA;;;;;AAKE;AACF,QAAA,MAAM,eAAe,CAAC,WAAmB,KAAS;AAChD,YAAA,aAAa,CAAC,KAAK,CAAC,WAAW,CAAA,GAAI,SAAQ;AAC3C,YAAA,QAAQ,EAAC;AACX,QAAA,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,eAAe,CAAC,WAAmB,KAAS;AAChD,YAAA,aAAa,CAAC,KAAK,CAAC,WAAW,IAAI,OAAM;AACzC,YAAA,QAAQ,EAAC;AACX,QAAA,CAAA;QAEA,OAAO;YACL,MAAM;YACN,qBAAqB;YACrB,YAAY;YACZ,YAAY;YACZ,2BAA2B;SAC7B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"query-preview-list.vue2.js","sources":["../../../../../src/x-modules/queries-preview/components/query-preview-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" class=\"x-query-preview-list\" tag=\"ul\">\n <li\n v-for=\"(queryPreview, index) in renderedQueryPreviews\"\n :key=\"index\"\n :class=\"{ 'padding-block-1': loadWhenVisible }\"\n :data-query-preview-hash=\"\n getHashFromQueryPreviewInfo(queryPreview, { ...params, ...queryPreview.extraParams })\n \"\n data-test=\"query-preview-item\"\n >\n <QueryPreview\n :debounce-time-ms=\"debounceTimeMs\"\n :load-when-visible=\"loadWhenVisible\"\n :max-items-to-render=\"maxItemsToRender\"\n :persist-in-cache=\"persistInCache\"\n :query-feature=\"queryFeature\"\n :query-preview-info=\"queryPreview\"\n @load=\"flagAsLoaded\"\n @error=\"flagAsFailed\"\n >\n <template v-for=\"(_, slotName) in $slots\" #[slotName]=\"scope\">\n <slot :name=\"slotName\" v-bind=\"scope\" />\n </template>\n </QueryPreview>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport type { RequestStatus } from '../../../store'\nimport type { QueryFeature } from '../../../types'\nimport type { QueryPreviewInfo } from '../store/types'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { useState } from '../../../composables/index'\nimport { AnimationProp } from '../../../types'\nimport { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview'\nimport { queriesPreviewXModule } from '../x-module'\nimport QueryPreview from './query-preview.vue'\n\ninterface QueryPreviewStatusRecord {\n [query: string]: RequestStatus\n}\n\n/**\n * Renders the results previews of a list of objects with the information about the query preview,\n * and exposes the {@link QueryPreview} slots to modify the content.\n * The requests are made in sequential order.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QueryPreviewList',\n xModule: queriesPreviewXModule.name,\n components: { QueryPreview },\n props: {\n /**\n * The list of queries preview to render.\n *\n * @public\n */\n queriesPreviewInfo: {\n type: Array as PropType<QueryPreviewInfo[]>,\n required: true,\n },\n /**\n * The origin property for the request on each query preview.\n *\n * @public\n */\n queryFeature: {\n type: String as PropType<QueryFeature>,\n },\n /**\n * Number of query preview results to be rendered on each query preview.\n *\n * @public\n */\n maxItemsToRender: {\n type: Number,\n },\n /**\n * Controls whether the query preview requests should be triggered when the component is visible in the viewport.\n *\n * @public\n */\n loadWhenVisible: {\n type: Boolean,\n default: false,\n },\n /**\n * Debounce time in milliseconds for triggering the search requests\n * on each query preview.\n *\n * It will default to 0 to fit the most common use case (pre-search),\n * and it would work properly with a 250 value inside empathize.\n */\n debounceTimeMs: {\n type: Number,\n default: 0,\n },\n /**\n * Controls whether all the QueryPreview should be removed from the state\n * when the component is destroyed.\n *\n * @public\n */\n persistInCache: Boolean,\n /**\n * Animation component that will be used to animate the elements.\n *\n * @public\n */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n },\n setup(props) {\n const { params } = useState('queriesPreview')\n\n /**\n * Contains the status of the preview requests, indexed by query.\n */\n const queriesStatus = ref<QueryPreviewStatusRecord>({})\n\n /**\n * The list of queries to preview.\n *\n * @returns The list of queries in the queriesPreviewInfo list.\n * @internal\n */\n const queries = computed((): string[] =>\n props.queriesPreviewInfo.map(item =>\n getHashFromQueryPreviewInfo(item, { ...params.value, ...item.extraParams }),\n ),\n )\n\n /**\n * Gets all the queries to render, that are those that don't have an `error` status.\n *\n * @returns A list of queries.\n * @internal\n */\n const renderedQueryPreviews = computed((): QueryPreviewInfo[] => {\n return props.queriesPreviewInfo.filter(item => {\n const queryPreviewHash = getHashFromQueryPreviewInfo(item, {\n ...params.value,\n ...item.extraParams,\n })\n return (\n queriesStatus.value[queryPreviewHash] === 'success' ||\n queriesStatus.value[queryPreviewHash] === 'loading'\n )\n })\n })\n\n /**\n * Tries to load the next query.\n *\n * @internal\n */\n const loadNext = (): void => {\n const queryToLoad = queries.value.find(query => !(query in queriesStatus.value))\n if (queryToLoad) {\n queriesStatus.value[queryToLoad] = 'loading'\n }\n }\n\n /**\n * Resets the status of all queries if they change.\n *\n * @param newQueries - The new queries.\n * @param oldQueries - The old queries.\n * @internal\n */\n watch(\n queries,\n (newQueries: string[], oldQueries: string[] | undefined) => {\n if (newQueries.toString() !== oldQueries?.toString()) {\n for (const key of Object.keys(queriesStatus.value)) {\n if (!newQueries.includes(key)) {\n delete queriesStatus.value[key]\n }\n }\n loadNext()\n }\n },\n { immediate: true, deep: true },\n )\n\n /**\n * Sets the status of a given query to `success`.\n *\n * @param loadedQuery - The query to flag as loaded.\n * @internal\n */\n const flagAsLoaded = (loadedQuery: string): void => {\n queriesStatus.value[loadedQuery] = 'success'\n loadNext()\n }\n\n /**\n * Sets the status of a given query to `error`.\n *\n * @param failedQuery - The query to flag as failed.\n * @internal\n */\n const flagAsFailed = (failedQuery: string): void => {\n queriesStatus.value[failedQuery] = 'error'\n loadNext()\n }\n\n return {\n params,\n renderedQueryPreviews,\n flagAsFailed,\n flagAsLoaded,\n getHashFromQueryPreviewInfo,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.padding-block-1 {\n padding-block: 1px;\n}\n</style>\n\n<docs lang=\"mdx\">\n## See it in action\n\nHere you have a basic example of how the QueryPreviewList is rendered. Keep in mind that this\ncomponent is intended to be used overriding its default slot. By default it will only render the\nnames of the results.\n\n```vue live\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" />\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with the default slot\n\nIn this example, the results will be rendered inside a sliding panel.\n\n```vue live\n<template>\n <QueryPreviewList\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #default=\"{ queryPreviewInfo, totalResults, results }\"\n >\n <div class=\"x-flex x-flex-col x-gap-8 x-mb-16\">\n <h1 class=\"x-title2\">{{ queryPreviewInfo.query }} ({{ totalResults }})</h1>\n <SlidingPanel :resetOnContentChange=\"false\">\n <div class=\"x-flex x-gap-8\">\n <Result\n v-for=\"result in results\"\n :key=\"result.id\"\n :result=\"result\"\n style=\"max-width: 180px\"\n />\n </div>\n </SlidingPanel>\n </div>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport SlidingPanel from '@empathyco/x-components/sliding-panel.vue'\nimport Result from '@empathyco/x-components/result.vue'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with the result slot\n\nThe component exposes a slot to override the result content, without modifying the list.\n\nIn this example, the ID of the results will be rendered along with the name.\n\n```vue\n<template>\n <QueryPreviewList\n class=\"x-flex x-gap-8\"\n :queriesPreviewInfo=\"queriesPreviewInfo\"\n #result=\"{ result }\"\n >\n <span class=\"x-font-bold\">{{ result.id }}:</span>\n <span>{{ result.name }}</span>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n\n### Play with vendor results and vendor banners\n\nThe `VendorResultsList` and `VendorBannersList` components can be used inside the default slot of\nthe `QueryPreviewList`, so the vendor results and vendor banners provided for each query are\ninserted within its results. The order of the nested components defines the merge strategy.\n\n```vue\n<template>\n <QueryPreviewList :queriesPreviewInfo=\"queriesPreviewInfo\" #default=\"{ queryPreviewHash }\">\n <VendorResultsList :queryPreviewHash=\"queryPreviewHash\">\n <VendorBannersList :queryPreviewHash=\"queryPreviewHash\">\n <BaseGrid>\n <template #result=\"{ item }\">\n <span>Result: {{ item.id }}</span>\n </template>\n <template #vendor-result=\"{ item }\">\n <span>Vendor result: {{ item.id }}</span>\n </template>\n <template #vendor-banner=\"{ item }\">\n <span>Vendor banner: {{ item.id }}</span>\n </template>\n </BaseGrid>\n </VendorBannersList>\n </VendorResultsList>\n </QueryPreviewList>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nimport { QueryPreviewList } from '@empathyco/x-components/queries-preview'\nimport { VendorBannersList, VendorResultsList } from '@empathyco/x-components/vendor'\nimport { reactive } from 'vue'\nconst queriesPreviewInfo = reactive([\n { query: 'sandals' },\n { query: 'tshirt' },\n { query: 'jacket' },\n])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6CA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,qBAAqB,CAAC,IAAI;IACnC,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,kBAAkB,EAAE;AAClB,YAAA,IAAI,EAAE,KAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;AAIE;AACF,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AACD;;;;AAIE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAAM;AACb,SAAA;AACD;;;;AAIE;AACF,QAAA,eAAe,EAAE;AACf,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;AACD;;;;;;AAME;AACF,QAAA,cAAc,EAAE;AACd,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACD;;;;;AAKE;AACF,QAAA,cAAc,EAAE,OAAO;AACvB;;;;AAIE;AACF,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;QACT,MAAM,EAAE,QAAO,GAAI,QAAQ,CAAC,gBAAgB,CAAA;AAE5C;;AAEE;AACF,QAAA,MAAM,aAAY,GAAI,GAAG,CAA2B,EAAE,CAAA;AAEtD;;;;;AAKE;AACF,QAAA,MAAM,OAAM,GAAI,QAAQ,CAAC,MACvB,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAC3B,2BAA2B,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,WAAU,EAAG,CAAC,CAC5E,CACH;AAEA;;;;;AAKE;AACF,QAAA,MAAM,qBAAoB,GAAI,QAAQ,CAAC,MAAwB;YAC7D,OAAO,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAG,IAAG;AAC3C,gBAAA,MAAM,mBAAmB,2BAA2B,CAAC,IAAI,EAAE;oBACzD,GAAG,MAAM,CAAC,KAAK;oBACf,GAAG,IAAI,CAAC,WAAW;AACpB,iBAAA,CAAA;gBACD,QACE,aAAa,CAAC,KAAK,CAAC,gBAAgB,CAAA,KAAM,SAAQ;oBAClD,aAAa,CAAC,KAAK,CAAC,gBAAgB,MAAM,SAAQ;AAEtD,YAAA,CAAC,CAAA;AACH,QAAA,CAAC,CAAA;AAED;;;;AAIE;QACF,MAAM,QAAO,GAAI,MAAU;YACzB,MAAM,WAAU,GAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAI,IAAK,EAAE,KAAI,IAAK,aAAa,CAAC,KAAK,CAAC,CAAA;YAC/E,IAAI,WAAW,EAAE;AACf,gBAAA,aAAa,CAAC,KAAK,CAAC,WAAW,CAAA,GAAI,SAAQ;YAC7C;AACF,QAAA,CAAA;AAEA;;;;;;AAME;QACF,KAAK,CACH,OAAO,EACP,CAAC,UAAoB,EAAE,UAAgC,KAAG;YACxD,IAAI,UAAU,CAAC,QAAQ,EAAC,KAAM,UAAU,EAAE,QAAQ,EAAE,EAAE;AACpD,gBAAA,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;oBAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC7B,wBAAA,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAA;oBAChC;gBACF;AACA,gBAAA,QAAQ,EAAC;YACX;QACF,CAAC,EACD,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAG,EAAG,CACjC;AAEA;;;;;AAKE;AACF,QAAA,MAAM,eAAe,CAAC,WAAmB,KAAS;AAChD,YAAA,aAAa,CAAC,KAAK,CAAC,WAAW,CAAA,GAAI,SAAQ;AAC3C,YAAA,QAAQ,EAAC;AACX,QAAA,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,eAAe,CAAC,WAAmB,KAAS;AAChD,YAAA,aAAa,CAAC,KAAK,CAAC,WAAW,IAAI,OAAM;AACzC,YAAA,QAAQ,EAAC;AACX,QAAA,CAAA;QAEA,OAAO;YACL,MAAM;YACN,qBAAqB;YACrB,YAAY;YACZ,YAAY;YACZ,2BAA2B;SAC7B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -99,11 +99,11 @@ import '../../../components/suggestions/base-suggestions.vue2.js';
|
|
|
99
99
|
import '../../../components/suggestions/base-suggestions.vue3.js';
|
|
100
100
|
import '../../../composables/create-use-device.js';
|
|
101
101
|
import { debounce } from '../../../utils/debounce.js';
|
|
102
|
-
import { useOnDisplay } from '../../../composables/use-on-display.js';
|
|
103
|
-
import { useState } from '../../../composables/use-state.js';
|
|
104
102
|
import { createRawFilters } from '../../../utils/filters.js';
|
|
105
103
|
import { createOrigin } from '../../../utils/origin.js';
|
|
106
104
|
import '../../../utils/storage.js';
|
|
105
|
+
import { useOnDisplay } from '../../../composables/use-on-display.js';
|
|
106
|
+
import { useState } from '../../../composables/use-state.js';
|
|
107
107
|
import { getHashFromQueryPreviewInfo } from '../utils/get-hash-from-query-preview.js';
|
|
108
108
|
import { queriesPreviewXModule } from '../x-module.js';
|
|
109
109
|
|
|
@@ -6,6 +6,7 @@ import '../../../plugins/x-bus.js';
|
|
|
6
6
|
import '@empathyco/x-utils';
|
|
7
7
|
import '../../../plugins/x-plugin.js';
|
|
8
8
|
import 'rxjs';
|
|
9
|
+
import '../../../utils/storage.js';
|
|
9
10
|
import { useGetter } from '../../../composables/use-getter.js';
|
|
10
11
|
import '@vueuse/core';
|
|
11
12
|
import { querySuggestionsXModule } from '../x-module.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-suggestion.vue2.js","sources":["../../../../../src/x-modules/query-suggestions/components/query-suggestion.vue"],"sourcesContent":["<template>\n <BaseSuggestion\n v-slot=\"baseScope\"\n v-bind=\"{ query, suggestion, suggestionSelectedEvents }\"\n class=\"x-query-suggestion\"\n data-test=\"query-suggestion\"\n feature=\"query_suggestion\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot Query Suggestion content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter \\| undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n</template>\n\n<script lang=\"ts\">\nimport type { Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables'\nimport { querySuggestionsXModule } from '../x-module'\n\n/**\n * This component renders a suggestion for a query. A query suggestion is a recommended query\n * based on previous search queries. It contains the query itself and a set of filters associated.\n * For example, if you're searching for _shirt_, a query suggestion could be _long sleeve shirt_.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QuerySuggestion',\n xModule: querySuggestionsXModule.name,\n components: { BaseSuggestion },\n props: {\n /** The suggestion to render. */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n },\n setup(props) {\n /** The normalized query of the query-suggestions module. */\n const query = useGetter('querySuggestions').normalizedQuery\n\n /**\n * Emits {@link QuerySuggestionsXEvents.UserSelectedAQuerySuggestion} with the suggestion as\n * payload when selecting the query suggestion.\n */\n const suggestionSelectedEvents = {\n UserSelectedAQuerySuggestion: props.suggestion,\n }\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserSelectedAQuerySuggestion`](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 query suggestion\n data.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>Empathize</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you can see how a single query suggestion is rendered using the `suggestion` prop.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\n</script>\n```\n\n### Play with default slot\n\nIn this example, we are adding an emoji next to the suggestion.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" #default=\"{ suggestion }\">\n <span>🔍</span>\n <span>{{ suggestion.query }}</span>\n </QuerySuggestion>\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\n</script>\n```\n\n### Play with events\n\nIn this example, when you click on the query suggestion, a message is displayed to illustrate that\nthe `UserSelectedAQuerySuggestion` event has been triggered.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" @UserSelectedAQuerySuggestion=\"alertSuggestion\" />\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\nfunction alertSuggestion(querySuggestion) {\n alert(`You have clicked the query suggestion: ${querySuggestion.query}`)\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-suggestion.vue2.js","sources":["../../../../../src/x-modules/query-suggestions/components/query-suggestion.vue"],"sourcesContent":["<template>\n <BaseSuggestion\n v-slot=\"baseScope\"\n v-bind=\"{ query, suggestion, suggestionSelectedEvents }\"\n class=\"x-query-suggestion\"\n data-test=\"query-suggestion\"\n feature=\"query_suggestion\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot Query Suggestion content\n @binding {Object} v-bind - `BaseSuggestion` default slot scope: **suggestion** <code>Suggestion</code> - Suggestion data<br /> **query** <code>string</code> - The query that the suggestion belongs to<br /> **filter** <code>Filter \\| undefined</code> - Suggestion's filter\n -->\n <!-- eslint-enable max-len -->\n <slot v-bind=\"{ ...baseScope }\" />\n </BaseSuggestion>\n</template>\n\n<script lang=\"ts\">\nimport type { Suggestion } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { defineComponent } from 'vue'\nimport BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'\nimport { useGetter } from '../../../composables'\nimport { querySuggestionsXModule } from '../x-module'\n\n/**\n * This component renders a suggestion for a query. A query suggestion is a recommended query\n * based on previous search queries. It contains the query itself and a set of filters associated.\n * For example, if you're searching for _shirt_, a query suggestion could be _long sleeve shirt_.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QuerySuggestion',\n xModule: querySuggestionsXModule.name,\n components: { BaseSuggestion },\n props: {\n /** The suggestion to render. */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true,\n },\n },\n setup(props) {\n /** The normalized query of the query-suggestions module. */\n const query = useGetter('querySuggestions').normalizedQuery\n\n /**\n * Emits {@link QuerySuggestionsXEvents.UserSelectedAQuerySuggestion} with the suggestion as\n * payload when selecting the query suggestion.\n */\n const suggestionSelectedEvents = {\n UserSelectedAQuerySuggestion: props.suggestion,\n }\n\n return {\n query,\n suggestionSelectedEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`UserSelectedAQuerySuggestion`](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 query suggestion\n data.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>Empathize</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you can see how a single query suggestion is rendered using the `suggestion` prop.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" />\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\n</script>\n```\n\n### Play with default slot\n\nIn this example, we are adding an emoji next to the suggestion.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" #default=\"{ suggestion }\">\n <span>🔍</span>\n <span>{{ suggestion.query }}</span>\n </QuerySuggestion>\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\n</script>\n```\n\n### Play with events\n\nIn this example, when you click on the query suggestion, a message is displayed to illustrate that\nthe `UserSelectedAQuerySuggestion` event has been triggered.\n\n```vue live\n<template>\n <QuerySuggestion :suggestion=\"suggestion\" @UserSelectedAQuerySuggestion=\"alertSuggestion\" />\n</template>\n\n<script setup>\nimport { QuerySuggestion } from '@empathyco/x-components/query-suggestions'\nimport { ref } from 'vue'\nconst suggestion = ref({\n modelName: 'QuerySuggestion',\n query: 'tshirt',\n facets: [],\n})\nfunction alertSuggestion(querySuggestion) {\n alert(`You have clicked the query suggestion: ${querySuggestion.query}`)\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0BA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,uBAAuB,CAAC,IAAI;IACrC,UAAU,EAAE,EAAE,cAAa,EAAG;AAC9B,IAAA,KAAK,EAAE;;AAEL,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;;QAET,MAAM,KAAI,GAAI,SAAS,CAAC,kBAAkB,CAAC,CAAC,eAAc;AAE1D;;;AAGE;AACF,QAAA,MAAM,wBAAuB,GAAI;YAC/B,4BAA4B,EAAE,KAAK,CAAC,UAAU;SAChD;QAEA,OAAO;YACL,KAAK;YACL,wBAAwB;SAC1B;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -6,6 +6,7 @@ import '../../../plugins/x-bus.js';
|
|
|
6
6
|
import '@empathyco/x-utils';
|
|
7
7
|
import '../../../plugins/x-plugin.js';
|
|
8
8
|
import 'rxjs';
|
|
9
|
+
import '../../../utils/storage.js';
|
|
9
10
|
import { useGetter } from '../../../composables/use-getter.js';
|
|
10
11
|
import '@vueuse/core';
|
|
11
12
|
import { querySuggestionsXModule } from '../x-module.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-suggestions.vue2.js","sources":["../../../../../src/x-modules/query-suggestions/components/query-suggestions.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"suggestions\"\n class=\"x-query-suggestions\"\n data-test=\"query-suggestions\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot Custom component that replaces the `QuerySuggestion` component\n @binding {Object} v-bind - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <QuerySuggestion\n v-slot=\"querySuggestionScope\"\n :suggestion=\"baseScope.suggestion\"\n class=\"x-query-suggestions__suggestion xds:suggestion\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot Custom content that replaces the `QuerySuggestion` default content\n @binding {Object} v-bind - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...querySuggestionScope }\" />\n </QuerySuggestion>\n </slot>\n </template>\n </BaseSuggestions>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport BaseSuggestions from '../../../components/suggestions/base-suggestions.vue'\nimport { useGetter } from '../../../composables'\nimport { querySuggestionsXModule } from '../x-module'\nimport QuerySuggestion from './query-suggestion.vue'\n\n/**\n * This component renders a list of possible search queries to select from as a query is entered\n * in the input field. By default, this is a list of\n * [`QuerySuggestion`](./x-components.query-suggestion.md) components.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QuerySuggestions',\n xModule: querySuggestionsXModule.name,\n components: { BaseSuggestions, QuerySuggestion },\n setup() {\n /** The module's list of suggestions. */\n const { querySuggestions } = useGetter('querySuggestions')\n\n return { suggestions: querySuggestions }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Inherited props\n\nThis component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)\nprops.\n\n| Name | Description | Type | Default |\n| ------------------ | ------------------------------------------- | -------- | ------- |\n| `animation` | Animation component for `QuerySuggestions`. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of query suggestions to be rendered. | `number` | |\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>Empathize</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nIn this example, a list of query suggestions is displayed. See how the suggestions change as you\ntype “sandal”. If you click on a suggestion, the search term in the search input is updated and the\nquery suggestions are changed to reflect the new search term.\n\n_Type “sandal” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions />\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n\n### Play with props\n\nIn this example, an `StaggeredFadeAndSlide` animation component has been passed as prop, so that the\nmatching query suggestions are shuffled with a slight delay as more letters of the term are typed.\n\n_Type “lipstick” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions :animation=\"StaggeredFadeAndSlide\" />\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with suggestion slot\n\nHere, the `suggestion` binding property passes the suggestion data.\n\n_Type “bag” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions #suggestion=\"{ suggestion }\">\n <QuerySuggestion :suggestion=\"suggestion\" #default=\"{ suggestion }\">\n <span>🔍</span>\n <span>{{ suggestion.query }}</span>\n </QuerySuggestion>\n </QuerySuggestions>\n</template>\n\n<script setup>\nimport { QuerySuggestion, QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n\n<!-- prettier-ignore-start -->\n::: danger\nIf you're not using the [`QuerySuggestion`](./query-suggestion.md) component, then\nyou must implement the `UserAcceptedAQuery` and `UserSelectedAQuerySuggestion` events in\n`QuerySuggestions`.\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions #suggestion=\"{ suggestion }\">\n <button @click=\"emitSuggestionClickedEvents($event, suggestion)\">\n {{ suggestion.query }}\n </button>\n </QuerySuggestions>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { use$x } from '../../../composables/use-$x'\n\nconst x = use$x()\nfunction emitSuggestionClickedEvents(event, suggestion) {\n x.emit('UserAcceptedAQuery', suggestion.query, {\n target: event.target\n })\n x.emit('UserSelectedASuggestion', suggestion, {\n target: event.target\n })\n x.emit('UserSelectedAQuerySuggestion', suggestion, {\n target: event.target\n })\n}\n</script>\n```\n\n:::\n<!-- prettier-ignore-end -->\n\n### Play with suggestion-content slot\n\nIn this example, the `suggestion` and `query` properties of the `suggestion-content` slot are used\nto paint a suggestion with an icon.\n\n_Type “trousers” or another toy in the input field to try it out!_\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <QuerySuggestions #suggestion-content=\"{ suggestion, query }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n </QuerySuggestions>\n </div>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { Highlight } from '@empathyco/x-components'\n</script>\n```\n\n## Extending the component\n\nComponents can be combined and communicate with each other. Commonly, the `QuerySuggestions`\ncomponent communicates with the [`SearchInput`](../search-box/x-components.search-input.md),\nupdating the term in the search input.\n\n_Type “pants” or another toy in the input field to try it out!_\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <QuerySuggestions />\n </div>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-suggestions.vue2.js","sources":["../../../../../src/x-modules/query-suggestions/components/query-suggestions.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"suggestions\"\n class=\"x-query-suggestions\"\n data-test=\"query-suggestions\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot Custom component that replaces the `QuerySuggestion` component\n @binding {Object} v-bind - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <QuerySuggestion\n v-slot=\"querySuggestionScope\"\n :suggestion=\"baseScope.suggestion\"\n class=\"x-query-suggestions__suggestion xds:suggestion\"\n >\n <!-- eslint-disable max-len -->\n <!--\n @slot Custom content that replaces the `QuerySuggestion` default content\n @binding {Object} v-bind - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...querySuggestionScope }\" />\n </QuerySuggestion>\n </slot>\n </template>\n </BaseSuggestions>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport BaseSuggestions from '../../../components/suggestions/base-suggestions.vue'\nimport { useGetter } from '../../../composables'\nimport { querySuggestionsXModule } from '../x-module'\nimport QuerySuggestion from './query-suggestion.vue'\n\n/**\n * This component renders a list of possible search queries to select from as a query is entered\n * in the input field. By default, this is a list of\n * [`QuerySuggestion`](./x-components.query-suggestion.md) components.\n *\n * @public\n */\nexport default defineComponent({\n name: 'QuerySuggestions',\n xModule: querySuggestionsXModule.name,\n components: { BaseSuggestions, QuerySuggestion },\n setup() {\n /** The module's list of suggestions. */\n const { querySuggestions } = useGetter('querySuggestions')\n\n return { suggestions: querySuggestions }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Inherited props\n\nThis component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)\nprops.\n\n| Name | Description | Type | Default |\n| ------------------ | ------------------------------------------- | -------- | ------- |\n| `animation` | Animation component for `QuerySuggestions`. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of query suggestions to be rendered. | `number` | |\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>Empathize</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nIn this example, a list of query suggestions is displayed. See how the suggestions change as you\ntype “sandal”. If you click on a suggestion, the search term in the search input is updated and the\nquery suggestions are changed to reflect the new search term.\n\n_Type “sandal” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions />\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n\n### Play with props\n\nIn this example, an `StaggeredFadeAndSlide` animation component has been passed as prop, so that the\nmatching query suggestions are shuffled with a slight delay as more letters of the term are typed.\n\n_Type “lipstick” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions :animation=\"StaggeredFadeAndSlide\" />\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with suggestion slot\n\nHere, the `suggestion` binding property passes the suggestion data.\n\n_Type “bag” or another fashion term in the input field to try it out!_\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions #suggestion=\"{ suggestion }\">\n <QuerySuggestion :suggestion=\"suggestion\" #default=\"{ suggestion }\">\n <span>🔍</span>\n <span>{{ suggestion.query }}</span>\n </QuerySuggestion>\n </QuerySuggestions>\n</template>\n\n<script setup>\nimport { QuerySuggestion, QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n\n<!-- prettier-ignore-start -->\n::: danger\nIf you're not using the [`QuerySuggestion`](./query-suggestion.md) component, then\nyou must implement the `UserAcceptedAQuery` and `UserSelectedAQuerySuggestion` events in\n`QuerySuggestions`.\n\n```vue live\n<template>\n <SearchInput />\n <QuerySuggestions #suggestion=\"{ suggestion }\">\n <button @click=\"emitSuggestionClickedEvents($event, suggestion)\">\n {{ suggestion.query }}\n </button>\n </QuerySuggestions>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { use$x } from '../../../composables/use-$x'\n\nconst x = use$x()\nfunction emitSuggestionClickedEvents(event, suggestion) {\n x.emit('UserAcceptedAQuery', suggestion.query, {\n target: event.target\n })\n x.emit('UserSelectedASuggestion', suggestion, {\n target: event.target\n })\n x.emit('UserSelectedAQuerySuggestion', suggestion, {\n target: event.target\n })\n}\n</script>\n```\n\n:::\n<!-- prettier-ignore-end -->\n\n### Play with suggestion-content slot\n\nIn this example, the `suggestion` and `query` properties of the `suggestion-content` slot are used\nto paint a suggestion with an icon.\n\n_Type “trousers” or another toy in the input field to try it out!_\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <QuerySuggestions #suggestion-content=\"{ suggestion, query }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n </QuerySuggestions>\n </div>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { Highlight } from '@empathyco/x-components'\n</script>\n```\n\n## Extending the component\n\nComponents can be combined and communicate with each other. Commonly, the `QuerySuggestions`\ncomponent communicates with the [`SearchInput`](../search-box/x-components.search-input.md),\nupdating the term in the search input.\n\n_Type “pants” or another toy in the input field to try it out!_\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <QuerySuggestions />\n </div>\n</template>\n\n<script setup>\nimport { QuerySuggestions } from '@empathyco/x-components/query-suggestions'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAuCA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,uBAAuB,CAAC,IAAI;AACrC,IAAA,UAAU,EAAE,EAAE,eAAe,EAAE,iBAAiB;IAChD,KAAK,GAAA;;QAEH,MAAM,EAAE,gBAAe,EAAE,GAAI,SAAS,CAAC,kBAAkB,CAAA;AAEzD,QAAA,OAAO,EAAE,WAAW,EAAE,gBAAe,EAAE;IACzC,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -6,6 +6,7 @@ import '../../../plugins/x-bus.js';
|
|
|
6
6
|
import '@empathyco/x-utils';
|
|
7
7
|
import '../../../plugins/x-plugin.js';
|
|
8
8
|
import 'rxjs';
|
|
9
|
+
import '../../../utils/storage.js';
|
|
9
10
|
import '@vueuse/core';
|
|
10
11
|
import { useState } from '../../../composables/use-state.js';
|
|
11
12
|
import { AnimationProp } from '../../../types/animation-prop.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommendations.vue2.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n provide(LIST_ITEMS_KEY as string, recommendations)\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](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 link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recommendations.vue2.js","sources":["../../../../../src/x-modules/recommendations/components/recommendations.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"recommendations.length\"\n tag=\"ul\"\n data-test=\"recommendations\"\n class=\"x-recommendations\"\n >\n <li\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n class=\"x-recommendations__item\"\n data-test=\"recommendation-item\"\n >\n <!--\n @slot (Required) Recommendation content.\n @binding {recommendation} recommendation - Recommendation data.\n -->\n <slot :recommendation=\"recommendation\" />\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropsWithType } from '../../../utils'\nimport type { XEventsTypes } from '../../../wiring'\nimport { computed, defineComponent, provide } from 'vue'\nimport { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts'\nimport { useState } from '../../../composables'\nimport { AnimationProp } from '../../../types'\nimport { recommendationsXModule } from '../x-module'\n\n/**\n * It renders a list of recommendations from the\n * {@link RecommendationsState.recommendations} state by default.\n * The component provides the slot layout which wraps the whole component with the\n * recommendations bounded. It also provides the default slot to customize the item, which is\n * within the layout slot, with the recommendation bounded. Each recommendation should be\n * represented by a {@link BaseResultLink} component besides any other component.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Recommendations',\n xModule: recommendationsXModule.name,\n props: {\n /** Animation component that will be used to animate the recommendations. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** Number of recommendations to be rendered. */\n maxItemsToRender: Number,\n },\n setup(props, { slots }) {\n /** The module's list of recommendations. */\n const storedRecommendations = useState('recommendations').recommendations\n\n /** The additional events to be emitted by the mandatory {@link BaseResultLink} component. */\n provide<PropsWithType<XEventsTypes, Result>[]>('resultClickExtraEvents', [\n 'UserClickedARecommendation',\n ])\n\n /**\n * Slices the recommendations from the state.\n *\n * @returns - The list of recommendations slice by the number of items to render.\n */\n const recommendations = computed<Result[]>(() =>\n storedRecommendations.value.slice(0, props.maxItemsToRender),\n )\n\n provide(LIST_ITEMS_KEY as string, recommendations)\n\n /**\n * Render function to execute the `layout` slot, binding `slotsProps` and getting only the\n * first `vNode` to avoid Fragments and Text root nodes.\n * If there are no recommendations, nothing is rendered.\n *\n * @remarks `slotProps` must be values without Vue reactivity and located inside the\n * render-function to update the binding data properly.\n *\n * @returns The root `vNode` of the `layout` slot or empty string if there are\n * no recommendations.\n */\n function renderLayoutSlot() {\n const slotProps = {\n animation: props.animation,\n recommendations: recommendations.value,\n }\n return recommendations.value.length ? slots.layout?.(slotProps)[0] : ''\n }\n\n /* Hack to render through a render-function, the `layout` slot or, in its absence,\n the component itself. It is the alternative for the NoElement antipattern. */\n const componentProps = { recommendations }\n return (slots.layout ? renderLayoutSlot : componentProps) as typeof componentProps\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-recommendations {\n display: flex;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events, but it makes components such as `BaseResultLink` emit additional\nevents:\n\n- [`UserClickedARecommendation`](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 link of a recommendation.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend service required\nTo use this component, the Topclicked service must be implemented.\n:::\n<!-- prettier-ignore-end -->\n\nHere you have a basic example on how the recommendations are rendered. You can customize how each\nresult is rendered by using the `default` slot. It is highly recommended to use base components such\nas the `BaseResultLink` or the `BaseResultAddToCart`, as they provide integration with other\nmodules such as the `tagging` one.\n\n```vue live\n<template>\n <Recommendations v-slot=\"{ recommendation }\">\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n\n### Play with props\n\nIn this example, the component will render a maximum of 4 result recommendations, and will use the\n`StaggeredFadeAndSlide` animation for the results, smoothing the entrance.\n\n```vue live\n<template>\n <Recommendations\n v-slot=\"{ recommendation }\"\n :maxItemsToRender=\"4\"\n :animation=\"StaggeredFadeAndSlide\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\nimport StaggeredFadeAndSlide from '@empathyco/x-components/animations/staggered-fade-and-slide.vue'\n</script>\n```\n\n### Play with the layout\n\nIn this example you can build your own layout, and the `Recommendations` component will just act as\na provider of the result recommendations data. Using the component this way, you can render any\nlayout you want using the `layout` slot.\n\n```vue live\n<template>\n <Recommendations v-slot:layout=\"{ recommendations }\">\n <div class=\"x-recommendations\">\n <article\n class=\"x-recommendations-list\"\n v-for=\"recommendation in recommendations\"\n :key=\"recommendation.id\"\n >\n <BaseResultLink :result=\"recommendation\" class=\"x-recommendations__link\">\n <img\n :src=\"recommendation.images[0]\"\n :alt=\"recommendation.name\"\n class=\"x-recommendations__image\"\n />\n <span class=\"x-recommendations__title\">{{ recommendation.name }}</span>\n </BaseResultLink>\n <BaseResultAddToCart :result=\"recommendation\">Add to cart</BaseResultAddToCart>\n </article>\n </div>\n </Recommendations>\n</template>\n\n<script setup>\nimport { Recommendations } from '@empathyco/x-components/recommendations'\nimport { BaseResultLink, BaseResultAddToCart } from '@empathyco/x-components'\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAiCA;;;;;;;;;AASE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,sBAAsB,CAAC,IAAI;AACpC,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;;QAEpB,MAAM,qBAAoB,GAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC,eAAc;;QAGxE,OAAO,CAAwC,wBAAwB,EAAE;YACvE,4BAA4B;AAC7B,SAAA,CAAA;AAED;;;;AAIE;QACF,MAAM,eAAc,GAAI,QAAQ,CAAW,MACzC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAC9D;AAEA,QAAA,OAAO,CAAC,cAAwB,EAAE,eAAe,CAAA;AAEjD;;;;;;;;;;AAUE;AACF,QAAA,SAAS,gBAAgB,GAAA;AACvB,YAAA,MAAM,YAAY;gBAChB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,eAAe,EAAE,eAAe,CAAC,KAAK;aACxC;YACA,OAAO,eAAe,CAAC,KAAK,CAAC,MAAK,GAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA,GAAI,EAAC;QACxE;AAEA;AAC+E;AAC/E,QAAA,MAAM,cAAa,GAAI,EAAE,eAAc,EAAE;AACzC,QAAA,QAAQ,KAAK,CAAC,MAAK,GAAI,gBAAe,GAAI,cAAc;IAC1D,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -3,9 +3,10 @@ import _sfc_main$1 from '../../../components/display-emitter.vue.js';
|
|
|
3
3
|
import SlidingPanel from '../../../components/sliding-panel.vue.js';
|
|
4
4
|
import '../../../composables/create-use-device.js';
|
|
5
5
|
import { use$x } from '../../../composables/use-_x.js';
|
|
6
|
+
import '@empathyco/x-utils';
|
|
7
|
+
import '../../../utils/storage.js';
|
|
6
8
|
import 'vuex';
|
|
7
9
|
import '../../../plugins/x-bus.js';
|
|
8
|
-
import '@empathyco/x-utils';
|
|
9
10
|
import '../../../plugins/x-plugin.js';
|
|
10
11
|
import '@vueuse/core';
|
|
11
12
|
import 'rxjs';
|