@empathyco/x-components 6.0.0-alpha.75 → 6.0.0-alpha.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/design-system/deprecated-full-theme.css +1624 -1624
  3. package/docs/API-reference/api/x-components.allfilter.md +3 -3
  4. package/docs/API-reference/api/x-components.baseeventsmodalclose.md +3 -3
  5. package/docs/API-reference/api/x-components.baseeventsmodalopen.md +3 -3
  6. package/docs/API-reference/api/x-components.facets.md +3 -3
  7. package/docs/API-reference/api/x-components.globalxbus.md +4 -0
  8. package/docs/API-reference/api/x-components.hierarchicalfilter.md +2 -0
  9. package/docs/API-reference/api/x-components.historyqueries.md +1 -1
  10. package/docs/API-reference/api/x-components.historyquery.md +1 -1
  11. package/docs/API-reference/api/x-components.identifierresult.md +2 -2
  12. package/docs/API-reference/api/x-components.md +5 -3
  13. package/docs/API-reference/api/x-components.nextqueries.md +1 -1
  14. package/docs/API-reference/api/x-components.popularsearches.md +1 -1
  15. package/docs/API-reference/api/x-components.querysuggestion.md +1 -1
  16. package/docs/API-reference/api/x-components.querysuggestions.md +1 -1
  17. package/docs/API-reference/api/x-components.relatedpromptsxevents.md +2 -0
  18. package/docs/API-reference/api/x-components.relatedpromptsxevents.relatedpromptsresponsechanged.md +13 -0
  19. package/docs/API-reference/api/x-components.relatedpromptsxevents.relatedpromptsunmounted.md +13 -0
  20. package/docs/API-reference/api/x-components.semanticquery.md +1 -1
  21. package/docs/API-reference/api/x-components.simplefilter.md +2 -0
  22. package/docs/API-reference/api/x-components.snippetcallbacks.md +2 -0
  23. package/docs/API-reference/api/x-components.tracknoresultsquerywithfallbackwire.md +13 -0
  24. package/docs/API-reference/api/x-components.tracknoresultsquerywithfallbackwiredebounced.md +13 -0
  25. package/docs/API-reference/api/x-components.tracknoresultsquerywithsemanticswire.md +6 -1
  26. package/docs/API-reference/api/x-components.tracknoresultsquerywithsemanticswiredebounced.md +6 -1
  27. package/docs/API-reference/api/x-components.usegetter.md +3 -17
  28. package/js/composables/use-getter.js +11 -11
  29. package/js/composables/use-getter.js.map +1 -1
  30. package/js/index.js +1 -1
  31. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  32. package/js/x-modules/facets/components/facets/facets.vue2.js +1 -1
  33. package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
  34. package/js/x-modules/facets/components/filters/all-filter.vue.js.map +1 -1
  35. package/js/x-modules/facets/components/filters/all-filter.vue2.js +1 -1
  36. package/js/x-modules/facets/components/filters/all-filter.vue2.js.map +1 -1
  37. package/js/x-modules/facets/composables/use-facets.js +1 -4
  38. package/js/x-modules/facets/composables/use-facets.js.map +1 -1
  39. package/js/x-modules/history-queries/components/history-queries.vue.js.map +1 -1
  40. package/js/x-modules/history-queries/components/history-queries.vue2.js +1 -1
  41. package/js/x-modules/history-queries/components/history-queries.vue2.js.map +1 -1
  42. package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
  43. package/js/x-modules/history-queries/components/history-query.vue2.js +1 -1
  44. package/js/x-modules/history-queries/components/history-query.vue2.js.map +1 -1
  45. package/js/x-modules/identifier-results/components/identifier-result.vue.js.map +1 -1
  46. package/js/x-modules/identifier-results/components/identifier-result.vue2.js +1 -3
  47. package/js/x-modules/identifier-results/components/identifier-result.vue2.js.map +1 -1
  48. package/js/x-modules/next-queries/components/next-queries-list.vue.js +1 -3
  49. package/js/x-modules/next-queries/components/next-queries-list.vue.js.map +1 -1
  50. package/js/x-modules/next-queries/components/next-queries.vue.js.map +1 -1
  51. package/js/x-modules/next-queries/components/next-queries.vue2.js +1 -1
  52. package/js/x-modules/next-queries/components/next-queries.vue2.js.map +1 -1
  53. package/js/x-modules/popular-searches/components/popular-searches.vue.js.map +1 -1
  54. package/js/x-modules/popular-searches/components/popular-searches.vue2.js +1 -1
  55. package/js/x-modules/popular-searches/components/popular-searches.vue2.js.map +1 -1
  56. package/js/x-modules/query-suggestions/components/query-suggestion.vue.js.map +1 -1
  57. package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js +1 -1
  58. package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js.map +1 -1
  59. package/js/x-modules/query-suggestions/components/query-suggestions.vue.js.map +1 -1
  60. package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js +1 -1
  61. package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js.map +1 -1
  62. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue.js.map +1 -1
  63. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +4 -1
  64. package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -1
  65. package/js/x-modules/related-prompts/store/emitters.js +1 -0
  66. package/js/x-modules/related-prompts/store/emitters.js.map +1 -1
  67. package/js/x-modules/related-tags/components/related-tags.vue.js.map +1 -1
  68. package/js/x-modules/related-tags/components/related-tags.vue2.js +1 -3
  69. package/js/x-modules/related-tags/components/related-tags.vue2.js.map +1 -1
  70. package/js/x-modules/semantic-queries/components/semantic-query.vue.js.map +1 -1
  71. package/js/x-modules/semantic-queries/components/semantic-query.vue2.js +2 -2
  72. package/js/x-modules/semantic-queries/components/semantic-query.vue2.js.map +1 -1
  73. package/js/x-modules/tagging/wiring.js +27 -8
  74. package/js/x-modules/tagging/wiring.js.map +1 -1
  75. package/package.json +2 -2
  76. package/report/x-components.api.json +293 -144
  77. package/report/x-components.api.md +42 -18
  78. package/tagging/index.js +1 -1
  79. package/types/components/global-x-bus.vue.d.ts +4 -0
  80. package/types/components/global-x-bus.vue.d.ts.map +1 -1
  81. package/types/components/modals/base-events-modal-close.vue.d.ts +3 -3
  82. package/types/components/modals/base-events-modal-open.vue.d.ts +3 -3
  83. package/types/components/snippet-callbacks.vue.d.ts +2 -0
  84. package/types/components/snippet-callbacks.vue.d.ts.map +1 -1
  85. package/types/composables/use-getter.d.ts +13 -3
  86. package/types/composables/use-getter.d.ts.map +1 -1
  87. package/types/x-modules/facets/components/facets/facets.vue.d.ts +4 -4
  88. package/types/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
  89. package/types/x-modules/facets/components/filters/all-filter.vue.d.ts +4 -4
  90. package/types/x-modules/facets/components/filters/all-filter.vue.d.ts.map +1 -1
  91. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +2 -0
  92. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
  93. package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts +2 -0
  94. package/types/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
  95. package/types/x-modules/history-queries/components/history-queries.vue.d.ts +1 -1
  96. package/types/x-modules/history-queries/components/history-query.vue.d.ts +1 -1
  97. package/types/x-modules/identifier-results/components/identifier-result.vue.d.ts +3 -3
  98. package/types/x-modules/identifier-results/components/identifier-result.vue.d.ts.map +1 -1
  99. package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts.map +1 -1
  100. package/types/x-modules/next-queries/components/next-queries.vue.d.ts +1 -1
  101. package/types/x-modules/popular-searches/components/popular-searches.vue.d.ts +1 -1
  102. package/types/x-modules/query-suggestions/components/query-suggestion.vue.d.ts +1 -1
  103. package/types/x-modules/query-suggestions/components/query-suggestions.vue.d.ts +1 -1
  104. package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts.map +1 -1
  105. package/types/x-modules/related-prompts/events.types.d.ts +10 -1
  106. package/types/x-modules/related-prompts/events.types.d.ts.map +1 -1
  107. package/types/x-modules/related-prompts/store/emitters.d.ts +1 -0
  108. package/types/x-modules/related-prompts/store/emitters.d.ts.map +1 -1
  109. package/types/x-modules/related-tags/components/related-tags.vue.d.ts.map +1 -1
  110. package/types/x-modules/semantic-queries/components/semantic-query.vue.d.ts +1 -1
  111. package/types/x-modules/tagging/wiring.d.ts +23 -4
  112. package/types/x-modules/tagging/wiring.d.ts.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef, PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n\n const { facets } = useGetter('facets', ['facets']) as {\n /** Dictionary of facets in the state. */\n facets: ComputedRef<Record<Facet['id'], Facet>>\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AA8EA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;;;;;;;;;;;;;;;AAkBE;AACF,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;QACpB,MAAM,EAAE,sBAAqB,KAAM,SAAS,CAAC,KAAK,CAAA,CAAA;AAElD,QAAA,MAAM,EAAE,QAAS,GAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAGjD,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAAoB,MAAM;AACvD,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC3B,OAAO,MAAM,CAAC,KAAI,CAAA;AAClB,aAAA;AAAK,iBAAA;gBACL,MAAM,cAAe,GAAE,IAAG,CAAA;gBAC1B,MAAM,QAAQ,GAAa,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAM,IAAK,OAAO,CAAC,IAAI,EAAE,CAAA,CAAA;gBAC1F,MAAM,QAAQ,GAAa,EAAC,CAAA;gBAC5B,MAAM,QAAQ,GAAa,EAAC,CAAA;AAC5B,gBAAA,QAAQ,CAAC,OAAO,CAAC,OAAQ,IAAG;AAC1B,oBAAA,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;AAChC,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA,CAAA;AACjD,qBAAA;AAAK,yBAAA;AACL,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAA,CAAA;AACvB,qBAAA;AACF,iBAAC,CAAA,CAAA;AAED,gBAAA,OAAO,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAA,CAAA;AAChD,aAAA;AACF,SAAC,CAAA,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,YAAa,GAAE,QAAQ,CAA0B,MAAM;AAC3D,YAAA,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,MAAM;AACpD,gBAAA,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC;AAClC,gBAAA,mBAAmB,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjD,KAAK;AACN,aAAA,CAAC,CAAA,CAAA;AACJ,SAAC,CAAA,CAAA;AAED;;;;AAIE;QACF,MAAM,SAAQ,GAAI,QAAQ,CAAU,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA,CAAA;AAEpF;;;;;;;AAOE;AACF,QAAA,SAAS,oBAAoB,CAAC,QAAkB,EAAE,QAAkB,EAAA;AAClE,YAAA,MAAM,mBAAoB,GAAE,QAAQ,CAAC,SAAS,CAAA,CAAA;YAC9C,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,QAAO,IAAK;gBAC5C,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAA;gBACrD,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAA;AAErD,gBAAA,OAAO,mBAAoB,GAAE,UAAW,IAAG,CAAC,UAAS,GAAI,CAAC,UAAS,CAAA;AACrE,aAAC,CAAA,CAAA;SACH;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA,CAAA;SACrB;QAEA,OAAO;YACL,sBAAsB;YACtB,SAAS;YACT,YAAY;YACZ,OAAO;SACT,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"all-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef, PropType } from 'vue'\nimport type { XEventsTypes } from '../../../../wiring/events.types'\nimport type { FiltersByFacet } from '../../store'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../../components/base-event-button.vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet }: Dictionary<ComputedRef<FiltersByFacet>> = useGetter(\n 'facets',\n ['selectedFiltersByFacet'],\n )\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_normalizeClass","_withCtx","facet","_renderSlot","isSelected"],"mappings":";;;;;AAcoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAXhB,EAAA,OAAAC,SAAA,EAAsB,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACtB,OAAKC,cAAU,CAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,UAAA,CAAA,CAAA;AAAA,IACd,WAAA,EAAA,YAAA;AAAA,IACA,IAAM,EAAA,UAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,UAAA,CAAA,QAAA,EAAA;AANX,IAAA,MAAA,EAAA,IAAA,CAAA,UAAA;AAAA,GAAA,EAAA;AAagB,IAAA,OAAA,EAAAC,OAAA,CAAEC,MAAK;AAAA,MAAAC,UAAA,CAAc,KAAEC,MAAU,EAAA,SAAA,EAAA;AAAA,QAAY,KAAA,EAAA,IAAA,CAAA,KAAA;AAAA,QAb7D,UAamD,EAAA,IAAA,CAAA,UAAA;AAAA,OAAA,EAAA,MAAA;;AAbnD,OAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"all-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } 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 { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet } = useGetter('facets')\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_normalizeClass","_withCtx","facet","_renderSlot","isSelected"],"mappings":";;;;;AAcoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAXhB,EAAA,OAAAC,SAAA,EAAsB,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACtB,OAAKC,cAAU,CAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,UAAA,CAAA,CAAA;AAAA,IACd,WAAA,EAAA,YAAA;AAAA,IACA,IAAM,EAAA,UAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,UAAA,CAAA,QAAA,EAAA;AANX,IAAA,MAAA,EAAA,IAAA,CAAA,UAAA;AAAA,GAAA,EAAA;AAagB,IAAA,OAAA,EAAAC,OAAA,CAAEC,MAAK;AAAA,MAAAC,UAAA,CAAc,KAAEC,MAAU,EAAA,SAAA,EAAA;AAAA,QAAY,KAAA,EAAA,IAAA,CAAA,KAAA;AAAA,QAb7D,UAamD,EAAA,IAAA,CAAA,UAAA;AAAA,OAAA,EAAA,MAAA;;AAbnD,OAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -28,7 +28,7 @@ var _sfc_main = defineComponent({
28
28
  },
29
29
  setup(props) {
30
30
  /** The getter of the selectedFiltersByFacet. */
31
- const { selectedFiltersByFacet } = useGetter('facets', ['selectedFiltersByFacet']);
31
+ const { selectedFiltersByFacet } = useGetter('facets');
32
32
  /**
33
33
  * The event that will be emitted when the all filter button is clicked.
34
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"all-filter.vue2.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef, PropType } from 'vue'\nimport type { XEventsTypes } from '../../../../wiring/events.types'\nimport type { FiltersByFacet } from '../../store'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../../components/base-event-button.vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet }: Dictionary<ComputedRef<FiltersByFacet>> = useGetter(\n 'facets',\n ['selectedFiltersByFacet'],\n )\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AA6BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;IACD,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAyB;AAC/B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;;AAET,QAAA,MAAM,EAAE,sBAAuB,EAAC,GAA4C,SAAS,CACnF,QAAQ,EACR,CAAC,wBAAwB,CAAC,CAC5B,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,MAA6B;YACvD,OAAO,EAAE,oBAAoB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,EAAA,CAAA;AAClD,SAAC,CAAA,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;AAChC,YAAA,OAAO,YAAY,CAAC,sBAAsB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA,CAAA;AACpE,SAAC,CAAA,CAAA;AAED;;;;;;;;AAQE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;YAChC,OAAO;gBACL,sCAAsC,EAAE,UAAU,CAAC,KAAK;aAC1D,CAAA;AACF,SAAC,CAAA,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;YACV,UAAU;SACZ,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"all-filter.vue2.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } 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 { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet } = useGetter('facets')\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AA2BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;IACD,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAyB;AAC/B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;;QAET,MAAM,EAAE,wBAAyB,GAAE,SAAS,CAAC,QAAQ,CAAA,CAAA;AAErD;;;;;AAKE;AACF,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,MAA6B;YACvD,OAAO,EAAE,oBAAoB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,EAAA,CAAA;AAClD,SAAC,CAAA,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;AAChC,YAAA,OAAO,YAAY,CAAC,sBAAsB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA,CAAA;AACpE,SAAC,CAAA,CAAA;AAED;;;;;;;;AAQE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;YAChC,OAAO;gBACL,sCAAsC,EAAE,UAAU,CAAC,KAAK;aAC1D,CAAA;AACF,SAAC,CAAA,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;YACV,UAAU;SACZ,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
@@ -10,10 +10,7 @@ import { isArrayEmpty } from '../../../utils/array.js';
10
10
  * @public
11
11
  */
12
12
  function useFacets(props) {
13
- const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets', [
14
- 'selectedFiltersByFacet',
15
- 'selectedFilters',
16
- ]);
13
+ const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets');
17
14
  /**
18
15
  * Get selected filters.
19
16
  * If there are facets ids, get selected filters whose facet id match with some of facets ids.
@@ -1 +1 @@
1
- {"version":3,"file":"use-facets.js","sources":["../../../../../src/x-modules/facets/composables/use-facets.ts"],"sourcesContent":["import type { Facet, Filter } from '@empathyco/x-types'\nimport type { ComputedRef } from 'vue'\nimport type { FiltersByFacet } from '../store/types'\nimport { computed } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../utils/array'\n\n/**\n * Composable to share Facets logic.\n *\n * @param props - Composable props.\n * @returns Composable.\n * @public\n */\nexport function useFacets(props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds?: Array<Facet['id']>\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible?: boolean\n}) {\n const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets', [\n 'selectedFiltersByFacet',\n 'selectedFilters',\n ]) as {\n /** Dictionary of filters {@link FiltersByFacet} filtered by facet id. */\n selectedFiltersByFacet: ComputedRef<FiltersByFacet>\n /** Get the selected filters from store. */\n selectedFilters: ComputedRef<Filter[]>\n }\n\n /**\n * Get selected filters.\n * If there are facets ids, get selected filters whose facet id match with some of facets ids.\n * If there aren't facets ids, get selected filters.\n *\n * @returns Array of selected filters depends on there are facets ids or not.\n */\n const selectedFilters = computed<Filter[]>(() => {\n if (props.facetsIds) {\n return (props.facetsIds as string[]).reduce(\n (selectedFilters, facetId) => [\n ...selectedFilters,\n ...(Array.isArray(selectedFiltersByFacet.value[facetId])\n ? selectedFiltersByFacet.value[facetId]\n : []),\n ],\n [] as Filter[],\n )\n }\n\n return selectedFiltersGetter.value\n })\n\n /**\n * Check if there are selected filters.\n *\n * @returns True or false depends on if there are selected filters.\n */\n const hasSelectedFilters = computed<boolean>(() => !isArrayEmpty(selectedFilters.value))\n\n /**\n * Flag representing if the component should be visible/rendered or not.\n *\n * @returns True whenever alwaysVisible is true or has selected filters. False\n * otherwise.\n */\n const isVisible = computed<boolean>(() => !!props.alwaysVisible || hasSelectedFilters.value)\n\n return {\n selectedFiltersByFacet,\n selectedFilters,\n hasSelectedFilters,\n isVisible,\n }\n}\n"],"names":[],"mappings":";;;;AAOA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,KAKzB,EAAA;IACC,MAAM,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE;QAC7F,wBAAwB;QACxB,iBAAiB;AAClB,KAAA,CAKA,CAAA;AAED;;;;;;AAMG;AACH,IAAA,MAAM,eAAe,GAAG,QAAQ,CAAW,MAAK;QAC9C,IAAI,KAAK,CAAC,SAAS,EAAE;AACnB,YAAA,OAAQ,KAAK,CAAC,SAAsB,CAAC,MAAM,CACzC,CAAC,eAAe,EAAE,OAAO,KAAK;AAC5B,gBAAA,GAAG,eAAe;gBAClB,IAAI,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACtD,sBAAE,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC;sBACrC,EAAE;aACP,EACD,EAAc,CACf,CAAA;AACF,SAAA;QAED,OAAO,qBAAqB,CAAC,KAAK,CAAA;AACpC,KAAC,CAAC,CAAA;AAEF;;;;AAIG;AACH,IAAA,MAAM,kBAAkB,GAAG,QAAQ,CAAU,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AAExF;;;;;AAKG;AACH,IAAA,MAAM,SAAS,GAAG,QAAQ,CAAU,MAAM,CAAC,CAAC,KAAK,CAAC,aAAa,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAE5F,OAAO;QACL,sBAAsB;QACtB,eAAe;QACf,kBAAkB;QAClB,SAAS;KACV,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"use-facets.js","sources":["../../../../../src/x-modules/facets/composables/use-facets.ts"],"sourcesContent":["import type { Facet, Filter } from '@empathyco/x-types'\nimport type { ComputedRef } from 'vue'\nimport type { FiltersByFacet } from '../store/types'\nimport { computed } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../utils/array'\n\n/**\n * Composable to share Facets logic.\n *\n * @param props - Composable props.\n * @returns Composable.\n * @public\n */\nexport function useFacets(props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds?: Array<Facet['id']>\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible?: boolean\n}) {\n const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets', [\n 'selectedFiltersByFacet',\n 'selectedFilters',\n ]) as {\n /** Dictionary of filters {@link FiltersByFacet} filtered by facet id. */\n selectedFiltersByFacet: ComputedRef<FiltersByFacet>\n /** Get the selected filters from store. */\n selectedFilters: ComputedRef<Filter[]>\n }\n\n /**\n * Get selected filters.\n * If there are facets ids, get selected filters whose facet id match with some of facets ids.\n * If there aren't facets ids, get selected filters.\n *\n * @returns Array of selected filters depends on there are facets ids or not.\n */\n const selectedFilters = computed<Filter[]>(() => {\n if (props.facetsIds) {\n return (props.facetsIds as string[]).reduce(\n (selectedFilters, facetId) => [\n ...selectedFilters,\n ...(Array.isArray(selectedFiltersByFacet.value[facetId])\n ? selectedFiltersByFacet.value[facetId]\n : []),\n ],\n [] as Filter[],\n )\n }\n\n return selectedFiltersGetter.value\n })\n\n /**\n * Check if there are selected filters.\n *\n * @returns True or false depends on if there are selected filters.\n */\n const hasSelectedFilters = computed<boolean>(() => !isArrayEmpty(selectedFilters.value))\n\n /**\n * Flag representing if the component should be visible/rendered or not.\n *\n * @returns True whenever alwaysVisible is true or has selected filters. False\n * otherwise.\n */\n const isVisible = computed<boolean>(() => !!props.alwaysVisible || hasSelectedFilters.value)\n\n return {\n selectedFiltersByFacet,\n selectedFilters,\n hasSelectedFilters,\n isVisible,\n }\n}\n"],"names":[],"mappings":";;;;AAOA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,KAKzB,EAAA;IACC,MAAM,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC,QAGpF,CAKA,CAAA;AAED;;;;;;AAMG;AACH,IAAA,MAAM,eAAe,GAAG,QAAQ,CAAW,MAAK;QAC9C,IAAI,KAAK,CAAC,SAAS,EAAE;AACnB,YAAA,OAAQ,KAAK,CAAC,SAAsB,CAAC,MAAM,CACzC,CAAC,eAAe,EAAE,OAAO,KAAK;AAC5B,gBAAA,GAAG,eAAe;gBAClB,IAAI,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACtD,sBAAE,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC;sBACrC,EAAE;aACP,EACD,EAAc,CACf,CAAA;AACF,SAAA;QAED,OAAO,qBAAqB,CAAC,KAAK,CAAA;AACpC,KAAC,CAAC,CAAA;AAEF;;;;AAIG;AACH,IAAA,MAAM,kBAAkB,GAAG,QAAQ,CAAU,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AAExF;;;;;AAKG;AACH,IAAA,MAAM,SAAS,GAAG,QAAQ,CAAU,MAAM,CAAC,CAAC,KAAK,CAAC,aAAa,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAE5F,OAAO;QACL,sBAAsB;QACtB,eAAe;QACf,kBAAkB;QAClB,SAAS;KACV,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"history-queries.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"historyQueriesWithResults\"\n class=\"x-history-queries\"\n data-test=\"history-queries\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query item\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <HistoryQuery\n :suggestion=\"baseScope.suggestion\"\n data-test=\"history-query-item\"\n class=\"x-history-queries__item\"\n suggestion-class=\"x-suggestion\"\n >\n <template #default=\"historyQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...historyQueryScope }\" />\n </template>\n <template #remove-button-content=\"removeHistoryQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query remove button content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot\n name=\"suggestion-remove-content\"\n v-bind=\"{ ...baseScope, ...removeHistoryQueryScope }\"\n />\n </template>\n </HistoryQuery>\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/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport HistoryQuery from './history-query.vue'\n\n/**\n * This component renders a list of suggestions coming from the user queries history.\n * Allows the user to select one of them, emitting the needed events. A history query is just\n * another type of suggestion that contains a query that the user has made in the past.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSuggestions,\n HistoryQuery,\n },\n setup() {\n /**\n * The filtered list of history queries.\n *\n * @internal\n */\n const { historyQueriesWithResults } = useGetter('historyQueries', ['historyQueriesWithResults'])\n\n return {\n historyQueriesWithResults,\n }\n },\n})\n</script>\n\n<!--eslint-disable max-len -->\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 that will be used to animate the suggestions. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |\n\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the HistoryQueries is rendered.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with props\n\nIn this example, the history queries have been limited to render a maximum of 10 queries (by default\nit is 5).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with the animation\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :animation=\"'FadeAndSlide'\" />\n </div>\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\n// Registering the animation as a global component\nVue.component('FadeAndSlide', FadeAndSlide)\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion slot\n\nIn this example, the [`HistoryQuery`](./x-components.history-query.md) component is passed in the\n`suggestion` slot (although any other component could potentially be passed).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion=\"{ suggestion }\">\n <HistoryQuery :suggestion=\"suggestion\" />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, HistoryQuery } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n HistoryQuery,\n },\n}\n</script>\n```\n\n### Play with suggestion-content slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, an HTML span tag for the text are also\npassed.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-content=\"{ suggestion }\">\n <span>{{ suggestion.query }}</span>\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion-content-remove slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, a cross icon is also passed to change the\nicon to remove the history query.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-remove-content=\"{ suggestion }\">\n <CrossIcon />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { CrossIcon } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n CrossIcon,\n },\n}\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createVNode"],"mappings":";;;;;;AA4CoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAzCX,EAAA,OAAAC,SAAA,EAAoB,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACzB,WAAU,EAAA,IAAA,CAAA,yBAAA;AAAA,IAAA,KAAA,EAAA,mBAAA;IAEC,WAAO,EAAA,iBAAA;AAAA,GAAA,EAAA;aAQdC,OA2Be,CAAA,CAAA,SAAA,KAAA;AAAA,MA1BZC,UAAA,CAAA,IAAA,CAAY,QAAS,YAAW,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,CAAA,CAAA,EAAA,MAAA;AAAA,QAAAC,WAAA,CACxB,uBAAqB,EAAA;AAAA,UAC9B,UAAM,EAAA,SAAA,CAAA,UAAA;AAAA,UACN,WAAA,EAAA,oBAAA;AAAA,UAAA,KAAA,EAAA,yBAAA;UAEW,kBAAS,EAAA,cAAA;AAAA,SAAA,EAAA;;AAST,YAAAH,UAAA,CAAA,IAAA,CAAA,MAAA,EAAqB,sBAAEC,cAAuB,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,GAAA,iBAAA,EAAA,CAAA,CAAA,CAAA;AAAA,WAAA,CAAA;;AA7BnE,YAAAF,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,GAAA,uBAAA,EAAA,CAAA,CAAA,CAAA;AAAA,WAAA,CAAA;;;;AAAA,OAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"history-queries.vue.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"historyQueriesWithResults\"\n class=\"x-history-queries\"\n data-test=\"history-queries\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query item\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <HistoryQuery\n :suggestion=\"baseScope.suggestion\"\n data-test=\"history-query-item\"\n class=\"x-history-queries__item\"\n suggestion-class=\"x-suggestion\"\n >\n <template #default=\"historyQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...historyQueryScope }\" />\n </template>\n <template #remove-button-content=\"removeHistoryQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query remove button content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot\n name=\"suggestion-remove-content\"\n v-bind=\"{ ...baseScope, ...removeHistoryQueryScope }\"\n />\n </template>\n </HistoryQuery>\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/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport HistoryQuery from './history-query.vue'\n\n/**\n * This component renders a list of suggestions coming from the user queries history.\n * Allows the user to select one of them, emitting the needed events. A history query is just\n * another type of suggestion that contains a query that the user has made in the past.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSuggestions,\n HistoryQuery,\n },\n setup() {\n /**\n * The filtered list of history queries.\n *\n * @internal\n */\n const { historyQueriesWithResults } = useGetter('historyQueries')\n\n return {\n historyQueriesWithResults,\n }\n },\n})\n</script>\n\n<!--eslint-disable max-len -->\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 that will be used to animate the suggestions. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |\n\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the HistoryQueries is rendered.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with props\n\nIn this example, the history queries have been limited to render a maximum of 10 queries (by default\nit is 5).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with the animation\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :animation=\"'FadeAndSlide'\" />\n </div>\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\n// Registering the animation as a global component\nVue.component('FadeAndSlide', FadeAndSlide)\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion slot\n\nIn this example, the [`HistoryQuery`](./x-components.history-query.md) component is passed in the\n`suggestion` slot (although any other component could potentially be passed).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion=\"{ suggestion }\">\n <HistoryQuery :suggestion=\"suggestion\" />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, HistoryQuery } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n HistoryQuery,\n },\n}\n</script>\n```\n\n### Play with suggestion-content slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, an HTML span tag for the text are also\npassed.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-content=\"{ suggestion }\">\n <span>{{ suggestion.query }}</span>\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion-content-remove slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, a cross icon is also passed to change the\nicon to remove the history query.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-remove-content=\"{ suggestion }\">\n <CrossIcon />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { CrossIcon } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n CrossIcon,\n },\n}\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createVNode"],"mappings":";;;;;;AA4CoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAzCX,EAAA,OAAAC,SAAA,EAAoB,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACzB,WAAU,EAAA,IAAA,CAAA,yBAAA;AAAA,IAAA,KAAA,EAAA,mBAAA;IAEC,WAAO,EAAA,iBAAA;AAAA,GAAA,EAAA;aAQdC,OA2Be,CAAA,CAAA,SAAA,KAAA;AAAA,MA1BZC,UAAA,CAAA,IAAA,CAAY,QAAS,YAAW,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,CAAA,CAAA,EAAA,MAAA;AAAA,QAAAC,WAAA,CACxB,uBAAqB,EAAA;AAAA,UAC9B,UAAM,EAAA,SAAA,CAAA,UAAA;AAAA,UACN,WAAA,EAAA,oBAAA;AAAA,UAAA,KAAA,EAAA,yBAAA;UAEW,kBAAS,EAAA,cAAA;AAAA,SAAA,EAAA;;AAST,YAAAH,UAAA,CAAA,IAAA,CAAA,MAAA,EAAqB,sBAAEC,cAAuB,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,GAAA,iBAAA,EAAA,CAAA,CAAA,CAAA;AAAA,WAAA,CAAA;;AA7BnE,YAAAF,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,GAAA,uBAAA,EAAA,CAAA,CAAA,CAAA;AAAA,WAAA,CAAA;;;;AAAA,OAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
@@ -24,7 +24,7 @@ var _sfc_main = defineComponent({
24
24
  *
25
25
  * @internal
26
26
  */
27
- const { historyQueriesWithResults } = useGetter('historyQueries', ['historyQueriesWithResults']);
27
+ const { historyQueriesWithResults } = useGetter('historyQueries');
28
28
  return {
29
29
  historyQueriesWithResults,
30
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"history-queries.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"historyQueriesWithResults\"\n class=\"x-history-queries\"\n data-test=\"history-queries\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query item\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <HistoryQuery\n :suggestion=\"baseScope.suggestion\"\n data-test=\"history-query-item\"\n class=\"x-history-queries__item\"\n suggestion-class=\"x-suggestion\"\n >\n <template #default=\"historyQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...historyQueryScope }\" />\n </template>\n <template #remove-button-content=\"removeHistoryQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query remove button content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot\n name=\"suggestion-remove-content\"\n v-bind=\"{ ...baseScope, ...removeHistoryQueryScope }\"\n />\n </template>\n </HistoryQuery>\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/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport HistoryQuery from './history-query.vue'\n\n/**\n * This component renders a list of suggestions coming from the user queries history.\n * Allows the user to select one of them, emitting the needed events. A history query is just\n * another type of suggestion that contains a query that the user has made in the past.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSuggestions,\n HistoryQuery,\n },\n setup() {\n /**\n * The filtered list of history queries.\n *\n * @internal\n */\n const { historyQueriesWithResults } = useGetter('historyQueries', ['historyQueriesWithResults'])\n\n return {\n historyQueriesWithResults,\n }\n },\n})\n</script>\n\n<!--eslint-disable max-len -->\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 that will be used to animate the suggestions. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |\n\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the HistoryQueries is rendered.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with props\n\nIn this example, the history queries have been limited to render a maximum of 10 queries (by default\nit is 5).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with the animation\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :animation=\"'FadeAndSlide'\" />\n </div>\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\n// Registering the animation as a global component\nVue.component('FadeAndSlide', FadeAndSlide)\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion slot\n\nIn this example, the [`HistoryQuery`](./x-components.history-query.md) component is passed in the\n`suggestion` slot (although any other component could potentially be passed).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion=\"{ suggestion }\">\n <HistoryQuery :suggestion=\"suggestion\" />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, HistoryQuery } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n HistoryQuery,\n },\n}\n</script>\n```\n\n### Play with suggestion-content slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, an HTML span tag for the text are also\npassed.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-content=\"{ suggestion }\">\n <span>{{ suggestion.query }}</span>\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion-content-remove slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, a cross icon is also passed to change the\nicon to remove the history query.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-remove-content=\"{ suggestion }\">\n <CrossIcon />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { CrossIcon } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n CrossIcon,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAsDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;QACf,YAAY;AACb,KAAA;IACD,KAAK,GAAA;AACH;;;;AAIE;AACF,QAAA,MAAM,EAAE,yBAA0B,EAAA,GAAI,SAAS,CAAC,gBAAgB,EAAE,CAAC,2BAA2B,CAAC,CAAA,CAAA;QAE/F,OAAO;YACL,yBAAyB;SAC3B,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"history-queries.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-queries.vue"],"sourcesContent":["<template>\n <BaseSuggestions\n :suggestions=\"historyQueriesWithResults\"\n class=\"x-history-queries\"\n data-test=\"history-queries\"\n >\n <template #default=\"baseScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query item\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion\" v-bind=\"{ ...baseScope }\">\n <HistoryQuery\n :suggestion=\"baseScope.suggestion\"\n data-test=\"history-query-item\"\n class=\"x-history-queries__item\"\n suggestion-class=\"x-suggestion\"\n >\n <template #default=\"historyQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot name=\"suggestion-content\" v-bind=\"{ ...baseScope, ...historyQueryScope }\" />\n </template>\n <template #remove-button-content=\"removeHistoryQueryScope\">\n <!-- eslint-disable max-len -->\n <!--\n @slot History Query remove button content\n @binding {Object} v-bind - History Query suggestion attributes:<br />&nbsp;&nbsp;- **suggestion** <code>Suggestion</code> - History Query suggestion data<br />&nbsp;&nbsp;- **index** <code>number</code> - History Query suggestion index\n -->\n <!-- eslint-enable max-len -->\n <slot\n name=\"suggestion-remove-content\"\n v-bind=\"{ ...baseScope, ...removeHistoryQueryScope }\"\n />\n </template>\n </HistoryQuery>\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/use-getter'\nimport { historyQueriesXModule } from '../x-module'\nimport HistoryQuery from './history-query.vue'\n\n/**\n * This component renders a list of suggestions coming from the user queries history.\n * Allows the user to select one of them, emitting the needed events. A history query is just\n * another type of suggestion that contains a query that the user has made in the past.\n *\n * @public\n */\nexport default defineComponent({\n name: 'HistoryQueries',\n xModule: historyQueriesXModule.name,\n components: {\n BaseSuggestions,\n HistoryQuery,\n },\n setup() {\n /**\n * The filtered list of history queries.\n *\n * @internal\n */\n const { historyQueriesWithResults } = useGetter('historyQueries')\n\n return {\n historyQueriesWithResults,\n }\n },\n})\n</script>\n\n<!--eslint-disable max-len -->\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 that will be used to animate the suggestions. | `Vue` | `\"ul\"` |\n| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |\n\n## Events\n\nThis component doesn't emit events.\n\n## See it in action\n\nHere you have a basic example of how the HistoryQueries is rendered.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with props\n\nIn this example, the history queries have been limited to render a maximum of 10 queries (by default\nit is 5).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :maxItemsToRender=\"10\" />\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with the animation\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries :animation=\"'FadeAndSlide'\" />\n </div>\n</template>\n\n<script>\nimport Vue from 'vue'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { FadeAndSlide } from '@empathyco/x-components'\n\n// Registering the animation as a global component\nVue.component('FadeAndSlide', FadeAndSlide)\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion slot\n\nIn this example, the [`HistoryQuery`](./x-components.history-query.md) component is passed in the\n`suggestion` slot (although any other component could potentially be passed).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion=\"{ suggestion }\">\n <HistoryQuery :suggestion=\"suggestion\" />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries, HistoryQuery } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n HistoryQuery,\n },\n}\n</script>\n```\n\n### Play with suggestion-content slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, an HTML span tag for the text are also\npassed.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-content=\"{ suggestion }\">\n <span>{{ suggestion.query }}</span>\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n },\n}\n</script>\n```\n\n### Play with suggestion-content-remove slot\n\nTo continue the previous example, the [`HistoryQuery`](./x-components.history-query.md) component is\npassed in the `suggestion-content` slot, but in addition, a cross icon is also passed to change the\nicon to remove the history query.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <HistoryQueries #suggestion-remove-content=\"{ suggestion }\">\n <CrossIcon />\n </HistoryQueries>\n </div>\n</template>\n\n<script>\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { HistoryQueries } from '@empathyco/x-components/history-queries'\nimport { CrossIcon } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueriesDemo',\n components: {\n SearchInput,\n HistoryQueries,\n CrossIcon,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAsDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE;QACV,eAAe;QACf,YAAY;AACb,KAAA;IACD,KAAK,GAAA;AACH;;;;AAIE;QACF,MAAM,EAAE,yBAA0B,EAAA,GAAI,SAAS,CAAC,gBAAgB,CAAA,CAAA;QAEhE,OAAO;YACL,yBAAyB;SAC3B,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
@@ -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 x-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 x-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']).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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n HistoryIcon,\n CrossIcon,\n Highlight,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","suggestionClass","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps"],"mappings":";;;;;;;wCACEA,gBAoCM,CAAA,oBAAA,CAAA,CAAA;AA3BF,EAAA,OAAAC,SAAA,uBAAmC,KAC3BC,EAAAA,UAAAA,EAAAA;AAAAA,IACYC,WAAA,CAAA,yBAAA,EAAAC,UAAA,CAAA;AAAA,MACpB,KAAyB,EAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,eAAA,CAAA;AAAA,KAAA,EACzB,cAAQ,IAAe,CAAA,UAAA,EAAA,wBAAA,EAAA,IAAA,CAAA,wBAAA,EAAA,KAAA,EAAA,IAAA,CAAA,KAAA,EAAA,EAAA;AAAA,MACtB,WAAK,EAAA,eAAA;AAAA,MAAA,OAAA,EAAA,eAAA;AAfZ,MAAA,OAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KASc,MAAS,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,KAAA,CAAA,OAAA,EAAA,IAAA,CAAA,UAAA,EAAA,MAAA,CAAA,CAAA;AAAA,KAcjB,CAAA,EAAA;AAAA,MAAA,OAAA,EAAAC,OAAA,CAAA,CAAA,SAAA,KAAA;AAvBN,QAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,CAAA,CAAA,CAAA;AAAA,OAAA,CAAA;AAyBI,MAAA,CAAA,EAAA,CAAA;AAAA;AAAA,KAAA,EACE,IA1BN,CA0BY,OAAA,CAAA,CAAA;AAAA,IAAAL,WAAA,CAEL,6BAAyB,EAAA;AAAA,MAC1B,sBAAU,CAAsB,mDAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,CAAA;AAAA,MAAA,eAAA,EAAA,IAAA,CAAA,UAAA;AA7BtC,MAAA,WAAA,EAAA,sBAAA;AAAA,KAAA,EAAA;eAAAE,OAmCkE,CAAA,MAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,uBAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,UAAA,EAAA,IAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA,MAAA;;AAnClE,SAAA,CAAA;AAAA,OAAA,CAAA;;;;;;;;;;"}
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 x-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 x-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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n HistoryIcon,\n CrossIcon,\n Highlight,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","suggestionClass","_createVNode","_mergeProps","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps"],"mappings":";;;;;;;wCACEA,gBAoCM,CAAA,oBAAA,CAAA,CAAA;AA3BF,EAAA,OAAAC,SAAA,uBAAmC,KAC3BC,EAAAA,UAAAA,EAAAA;AAAAA,IACYC,WAAA,CAAA,yBAAA,EAAAC,UAAA,CAAA;AAAA,MACpB,KAAyB,EAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,eAAA,CAAA;AAAA,KAAA,EACzB,cAAQ,IAAe,CAAA,UAAA,EAAA,wBAAA,EAAA,IAAA,CAAA,wBAAA,EAAA,KAAA,EAAA,IAAA,CAAA,KAAA,EAAA,EAAA;AAAA,MACtB,WAAK,EAAA,eAAA;AAAA,MAAA,OAAA,EAAA,eAAA;AAfZ,MAAA,OAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KASc,MAAS,CAAA,CAAA,CAAA,GAAA,CAAA,MAAA,KAAA,IAAA,CAAA,KAAA,CAAA,OAAA,EAAA,IAAA,CAAA,UAAA,EAAA,MAAA,CAAA,CAAA;AAAA,KAcjB,CAAA,EAAA;AAAA,MAAA,OAAA,EAAAC,OAAA,CAAA,CAAA,SAAA,KAAA;AAvBN,QAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,GAAA,SAAA,EAAA,CAAA,CAAA,CAAA;AAAA,OAAA,CAAA;AAyBI,MAAA,CAAA,EAAA,CAAA;AAAA;AAAA,KAAA,EACE,IA1BN,CA0BY,OAAA,CAAA,CAAA;AAAA,IAAAL,WAAA,CAEL,6BAAyB,EAAA;AAAA,MAC1B,sBAAU,CAAsB,mDAAA,EAAA,IAAA,CAAA,iBAAA,CAAA,CAAA;AAAA,MAAA,eAAA,EAAA,IAAA,CAAA,UAAA;AA7BtC,MAAA,WAAA,EAAA,sBAAA;AAAA,KAAA,EAAA;eAAAE,OAmCkE,CAAA,MAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,uBAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAA,UAAA,EAAA,IAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA,MAAA;;AAnClE,SAAA,CAAA;AAAA,OAAA,CAAA;;;;;;;;;;"}
@@ -37,7 +37,7 @@ var _sfc_main = defineComponent({
37
37
  *
38
38
  * @internal
39
39
  */
40
- const query = useGetter('historyQueries', ['normalizedQuery']).normalizedQuery;
40
+ const query = useGetter('historyQueries').normalizedQuery;
41
41
  /**
42
42
  * The list of events that are going to be emitted when the suggestion button is pressed.
43
43
  *
@@ -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 x-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 x-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']).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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n HistoryIcon,\n CrossIcon,\n Highlight,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAkDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,EAAE,kBAAkB,EAAE,gBAAgB;AAClD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,eAAe,EAAE,MAAM;AACxB,KAAA;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;AAChB,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;AACF,QAAA,MAAM,KAAI,GAAI,SAAS,CAAC,gBAAgB,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,eAAc,CAAA;AAE7E;;;;;AAKE;AACF,QAAA,MAAM,wBAAuB,GAAI,QAAQ,CACvC,OAA8B;YAC5B,yBAAyB,EAAE,KAAK,CAAC,UAAU;AAC5C,SAAA,CAAC,CACJ,CAAA;QAEA,OAAO;YACL,KAAK;YACL,wBAAwB;SAC1B,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"history-query.vue2.js","sources":["../../../../../src/x-modules/history-queries/components/history-query.vue"],"sourcesContent":["<template>\n <div class=\"x-history-query x-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 x-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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nimport { HistoryIcon, CrossIcon, Highlight } from '@empathyco/x-components'\n\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n HistoryIcon,\n CrossIcon,\n Highlight,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\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>\nimport { HistoryQuery } from '@empathyco/x-components/history-queries'\nexport default {\n name: 'HistoryQueryDemo',\n components: {\n HistoryQuery,\n },\n data() {\n return {\n suggestion: {\n modelName: 'HistoryQuery',\n query: 'trousers',\n facets: [],\n },\n }\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AAkDA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,EAAE,kBAAkB,EAAE,gBAAgB;AAClD,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAAqC;AAC3C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,eAAe,EAAE,MAAM;AACxB,KAAA;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;AAChB,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,KAAI,GAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,eAAc,CAAA;AAExD;;;;;AAKE;AACF,QAAA,MAAM,wBAAuB,GAAI,QAAQ,CACvC,OAA8B;YAC5B,yBAAyB,EAAE,KAAK,CAAC,UAAU;AAC5C,SAAA,CAAC,CACJ,CAAA;QAEA,OAAO;YACL,KAAK;YACL,wBAAwB;SAC1B,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"identifier-result.vue.js","sources":["../../../../../src/x-modules/identifier-results/components/identifier-result.vue"],"sourcesContent":["<template>\n <span\n v-if=\"query\"\n class=\"x-identifier-result\"\n data-test=\"identifier-result\"\n v-html=\"highlightedQueryHTML\"\n ></span>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { ComputedRef, PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { identifierResultsXModule } from '../x-module'\n\n/**\n * This component renders an identifier result value and highlights its matching part with the\n * query from the state. Receives as prop the {@link @empathyco/x-types#Result} data.\n *\n * @public\n */\nexport default defineComponent({\n name: 'IdentifierResult',\n xModule: identifierResultsXModule.name,\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * Query from the module state.\n *\n * @public\n */\n const { query } = useState('identifierResults')\n\n /**\n * The RegExp with the current query from the state adding the separatorChars after each\n * matching character.\n *\n * @public\n */\n const identifierHighlightRegexp: ComputedRef<RegExp> = useGetter('identifierResults', [\n 'identifierHighlightRegexp',\n ]).identifierHighlightRegexp\n\n /**\n * Highlights the matching part of the identifier result with the query from the state.\n *\n * @returns String - The identifier result s query with the matching part inside a `<span>` tag.\n * @public\n */\n const highlightedQueryHTML = computed(() => {\n const identifierValue = props.result.identifier?.value ?? ''\n if (identifierValue && identifierHighlightRegexp.value) {\n return identifierValue.replace(\n identifierHighlightRegexp.value,\n '<span class=\"x-identifier-result__matching-part\">$1</span>',\n )\n }\n return identifierValue\n })\n\n return {\n query,\n highlightedQueryHTML,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders an identifier result value and highlights its matching part with the query\nfrom the state. Receives as prop the result data\n\n### Basic usage:\n\n```vue\n<IdentifierResult v-bind=\"{ result }\" />\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createCommentVNode"],"mappings":";;;;;qBACE,IAKQ,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AANV,EAAA,OAAA,IAAA,CAAA,KAAA,IAAAA,SAAA,EAG+B,EAAAC,kBAAA,CAAA,MAAA,EAAA;AAAA,IAC3B,GAAA,EAAA,CAAA;AAAA,IACA,KAAA,EAAA,qBAAA;AAAA,IAAA,WAAA,EAAA,mBAAA;AALJ,IAAA,SAAA,EAAA,IAAA,CAAA,oBAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,UAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"identifier-result.vue.js","sources":["../../../../../src/x-modules/identifier-results/components/identifier-result.vue"],"sourcesContent":["<template>\n <span\n v-if=\"query\"\n class=\"x-identifier-result\"\n data-test=\"identifier-result\"\n v-html=\"highlightedQueryHTML\"\n ></span>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { identifierResultsXModule } from '../x-module'\n\n/**\n * This component renders an identifier result value and highlights its matching part with the\n * query from the state. Receives as prop the {@link @empathyco/x-types#Result} data.\n *\n * @public\n */\nexport default defineComponent({\n name: 'IdentifierResult',\n xModule: identifierResultsXModule.name,\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * Query from the module state.\n *\n * @public\n */\n const { query } = useState('identifierResults')\n\n /**\n * The RegExp with the current query from the state adding the separatorChars after each\n * matching character.\n *\n * @public\n */\n const identifierHighlightRegexp = useGetter('identifierResults').identifierHighlightRegexp\n\n /**\n * Highlights the matching part of the identifier result with the query from the state.\n *\n * @returns String - The identifier result s query with the matching part inside a `<span>` tag.\n * @public\n */\n const highlightedQueryHTML = computed(() => {\n const identifierValue = props.result.identifier?.value ?? ''\n if (identifierValue && identifierHighlightRegexp.value) {\n return identifierValue.replace(\n identifierHighlightRegexp.value,\n '<span class=\"x-identifier-result__matching-part\">$1</span>',\n )\n }\n return identifierValue\n })\n\n return {\n query,\n highlightedQueryHTML,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders an identifier result value and highlights its matching part with the query\nfrom the state. Receives as prop the result data\n\n### Basic usage:\n\n```vue\n<IdentifierResult v-bind=\"{ result }\" />\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_createCommentVNode"],"mappings":";;;;;qBACE,IAKQ,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AANV,EAAA,OAAA,IAAA,CAAA,KAAA,IAAAA,SAAA,EAG+B,EAAAC,kBAAA,CAAA,MAAA,EAAA;AAAA,IAC3B,GAAA,EAAA,CAAA;AAAA,IACA,KAAA,EAAA,qBAAA;AAAA,IAAA,WAAA,EAAA,mBAAA;AALJ,IAAA,SAAA,EAAA,IAAA,CAAA,oBAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,UAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
@@ -36,9 +36,7 @@ var _sfc_main = defineComponent({
36
36
  *
37
37
  * @public
38
38
  */
39
- const identifierHighlightRegexp = useGetter('identifierResults', [
40
- 'identifierHighlightRegexp',
41
- ]).identifierHighlightRegexp;
39
+ const identifierHighlightRegexp = useGetter('identifierResults').identifierHighlightRegexp;
42
40
  /**
43
41
  * Highlights the matching part of the identifier result with the query from the state.
44
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"identifier-result.vue2.js","sources":["../../../../../src/x-modules/identifier-results/components/identifier-result.vue"],"sourcesContent":["<template>\n <span\n v-if=\"query\"\n class=\"x-identifier-result\"\n data-test=\"identifier-result\"\n v-html=\"highlightedQueryHTML\"\n ></span>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { ComputedRef, PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { identifierResultsXModule } from '../x-module'\n\n/**\n * This component renders an identifier result value and highlights its matching part with the\n * query from the state. Receives as prop the {@link @empathyco/x-types#Result} data.\n *\n * @public\n */\nexport default defineComponent({\n name: 'IdentifierResult',\n xModule: identifierResultsXModule.name,\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * Query from the module state.\n *\n * @public\n */\n const { query } = useState('identifierResults')\n\n /**\n * The RegExp with the current query from the state adding the separatorChars after each\n * matching character.\n *\n * @public\n */\n const identifierHighlightRegexp: ComputedRef<RegExp> = useGetter('identifierResults', [\n 'identifierHighlightRegexp',\n ]).identifierHighlightRegexp\n\n /**\n * Highlights the matching part of the identifier result with the query from the state.\n *\n * @returns String - The identifier result s query with the matching part inside a `<span>` tag.\n * @public\n */\n const highlightedQueryHTML = computed(() => {\n const identifierValue = props.result.identifier?.value ?? ''\n if (identifierValue && identifierHighlightRegexp.value) {\n return identifierValue.replace(\n identifierHighlightRegexp.value,\n '<span class=\"x-identifier-result__matching-part\">$1</span>',\n )\n }\n return identifierValue\n })\n\n return {\n query,\n highlightedQueryHTML,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders an identifier result value and highlights its matching part with the query\nfrom the state. Receives as prop the result data\n\n### Basic usage:\n\n```vue\n<IdentifierResult v-bind=\"{ result }\" />\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAiBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,wBAAwB,CAAC,IAAI;AACtC,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,EAAE,KAAI,KAAM,QAAQ,CAAC,mBAAmB,CAAA,CAAA;AAE9C;;;;;AAKE;AACF,QAAA,MAAM,yBAAyB,GAAwB,SAAS,CAAC,mBAAmB,EAAE;YACpF,2BAA2B;SAC5B,CAAC,CAAC,yBAAwB,CAAA;AAE3B;;;;;AAKE;AACF,QAAA,MAAM,oBAAqB,GAAE,QAAQ,CAAC,MAAM;YAC1C,MAAM,eAAc,GAAI,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,KAAI,IAAK,EAAC,CAAA;AAC3D,YAAA,IAAI,eAAgB,IAAG,yBAAyB,CAAC,KAAK,EAAE;gBACtD,OAAO,eAAe,CAAC,OAAO,CAC5B,yBAAyB,CAAC,KAAK,EAC/B,4DAA4D,CAC9D,CAAA;AACF,aAAA;AACA,YAAA,OAAO,eAAc,CAAA;AACvB,SAAC,CAAA,CAAA;QAED,OAAO;YACL,KAAK;YACL,oBAAoB;SACtB,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"identifier-result.vue2.js","sources":["../../../../../src/x-modules/identifier-results/components/identifier-result.vue"],"sourcesContent":["<template>\n <span\n v-if=\"query\"\n class=\"x-identifier-result\"\n data-test=\"identifier-result\"\n v-html=\"highlightedQueryHTML\"\n ></span>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { identifierResultsXModule } from '../x-module'\n\n/**\n * This component renders an identifier result value and highlights its matching part with the\n * query from the state. Receives as prop the {@link @empathyco/x-types#Result} data.\n *\n * @public\n */\nexport default defineComponent({\n name: 'IdentifierResult',\n xModule: identifierResultsXModule.name,\n props: {\n /**\n * (Required) The {@link @empathyco/x-types#Result} information.\n *\n * @public\n */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n },\n setup(props) {\n /**\n * Query from the module state.\n *\n * @public\n */\n const { query } = useState('identifierResults')\n\n /**\n * The RegExp with the current query from the state adding the separatorChars after each\n * matching character.\n *\n * @public\n */\n const identifierHighlightRegexp = useGetter('identifierResults').identifierHighlightRegexp\n\n /**\n * Highlights the matching part of the identifier result with the query from the state.\n *\n * @returns String - The identifier result s query with the matching part inside a `<span>` tag.\n * @public\n */\n const highlightedQueryHTML = computed(() => {\n const identifierValue = props.result.identifier?.value ?? ''\n if (identifierValue && identifierHighlightRegexp.value) {\n return identifierValue.replace(\n identifierHighlightRegexp.value,\n '<span class=\"x-identifier-result__matching-part\">$1</span>',\n )\n }\n return identifierValue\n })\n\n return {\n query,\n highlightedQueryHTML,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders an identifier result value and highlights its matching part with the query\nfrom the state. Receives as prop the result data\n\n### Basic usage:\n\n```vue\n<IdentifierResult v-bind=\"{ result }\" />\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAiBA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,wBAAwB,CAAC,IAAI;AACtC,IAAA,KAAK,EAAE;AACL;;;;AAIE;AACF,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT;;;;AAIE;QACF,MAAM,EAAE,KAAI,KAAM,QAAQ,CAAC,mBAAmB,CAAA,CAAA;AAE9C;;;;;AAKE;QACF,MAAM,4BAA4B,SAAS,CAAC,mBAAmB,CAAC,CAAC,yBAAwB,CAAA;AAEzF;;;;;AAKE;AACF,QAAA,MAAM,oBAAqB,GAAE,QAAQ,CAAC,MAAM;YAC1C,MAAM,eAAc,GAAI,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,KAAI,IAAK,EAAC,CAAA;AAC3D,YAAA,IAAI,eAAgB,IAAG,yBAAyB,CAAC,KAAK,EAAE;gBACtD,OAAO,eAAe,CAAC,OAAO,CAC5B,yBAAyB,CAAC,KAAK,EAC/B,4DAA4D,CAC9D,CAAA;AACF,aAAA;AACA,YAAA,OAAO,eAAc,CAAA;AACvB,SAAC,CAAA,CAAA;QAED,OAAO;YACL,KAAK;YACL,oBAAoB;SACtB,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
@@ -51,9 +51,7 @@ var _sfc_main = defineComponent({
51
51
  setup(props, { slots }) {
52
52
  const { query, status } = useState('nextQueries');
53
53
  /** The state next queries. */
54
- const nextQueries = useGetter('nextQueries', [
55
- 'nextQueries',
56
- ]).nextQueries;
54
+ const nextQueries = useGetter('nextQueries').nextQueries;
57
55
  /** Injected query, updated when the related request(s) have succeeded. */
58
56
  const injectedQuery = inject(QUERY_KEY);
59
57
  /** Indicates if there are more available results than the injected. */
@@ -1 +1 @@
1
- {"version":3,"file":"next-queries-list.vue.js","sources":["../../../../../src/x-modules/next-queries/components/next-queries-list.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { NextQuery } from '@empathyco/x-types'\nimport type { ComputedRef, Ref } from 'vue'\nimport type { ListItem } from '../../../utils/types'\nimport type { NextQueriesGroup } from '../types'\nimport { computed, defineComponent, h, inject, provide } from 'vue'\nimport {\n HAS_MORE_ITEMS_KEY,\n LIST_ITEMS_KEY,\n QUERY_KEY,\n} from '../../../components/decorators/injection.consts'\nimport ItemsList from '../../../components/items-list.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { AnimationProp } from '../../../types/animation-prop'\nimport { groupItemsBy } from '../../../utils/array'\nimport { nextQueriesXModule } from '../x-module'\n\n/**\n * Component that inserts groups of next queries in different positions of the injected search\n * items list, based on the provided configuration.\n *\n * @public\n */\nexport default defineComponent({\n name: 'NextQueriesList',\n xModule: nextQueriesXModule.name,\n props: {\n /** Animation component that will be used to animate the next queries groups. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** The first index to insert a group of next queries at. */\n offset: {\n type: Number,\n default: 24,\n },\n /** The items cycle size to keep inserting next queries groups at. */\n frequency: {\n type: Number,\n default: 24,\n },\n /** The maximum amount of next queries to add in a single group. */\n maxNextQueriesPerGroup: {\n type: Number,\n default: 4,\n },\n /** The maximum number of groups to insert into the injected list items list. */\n maxGroups: Number,\n /**\n * Determines if a group is added to the injected items list in case the number\n * of items is smaller than the offset.\n */\n showOnlyAfterOffset: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const { query, status } = useState('nextQueries')\n\n /** The state next queries. */\n const nextQueries: ComputedRef<NextQuery[]> = useGetter('nextQueries', [\n 'nextQueries',\n ]).nextQueries\n\n /** Injected query, updated when the related request(s) have succeeded. */\n const injectedQuery = inject<Ref<string>>(QUERY_KEY as string)\n\n /** Indicates if there are more available results than the injected. */\n const hasMoreItems = inject<Ref<boolean>>(HAS_MORE_ITEMS_KEY as string)\n\n /**\n * The grouped next queries based on the given config.\n *\n * @returns A list of next queries groups.\n */\n const nextQueriesGroups = computed<NextQueriesGroup[]>(() =>\n Object.values(\n groupItemsBy(nextQueries?.value, (_, index) =>\n Math.floor(index / props.maxNextQueriesPerGroup),\n ),\n )\n .slice(0, props.maxGroups)\n .map(nextQueries => ({\n modelName: 'NextQueriesGroup' as const,\n id: nextQueries.map(nextQuery => nextQuery.query).join(','),\n nextQueries,\n })),\n )\n\n /** It injects {@link ListItem} provided by an ancestor as injectedListItems. */\n const injectedListItems = inject<Ref<ListItem[]>>(LIST_ITEMS_KEY as string)\n\n /**\n * Checks if the next queries are outdated taking into account the injected query.\n *\n * @returns True if the next queries are outdated, false if not.\n */\n const nextQueriesAreOutdated = computed(\n () =>\n !!injectedQuery?.value &&\n (query.value !== injectedQuery.value || status.value !== 'success'),\n )\n\n /**\n * Checks if the number of items is smaller than the offset so a group\n * should be added to the injected items list.\n *\n * @returns True if a group should be added, false if not.\n */\n const hasNotEnoughListItems = computed(\n () =>\n !props.showOnlyAfterOffset &&\n !hasMoreItems?.value &&\n injectedListItems !== undefined &&\n injectedListItems.value.length > 0 &&\n props.offset > injectedListItems.value.length,\n )\n\n /**\n * New list of {@link ListItem}s to render.\n *\n * @returns The new list of {@link ListItem}s with the next queries groups inserted.\n */\n const items = computed(() => {\n if (!injectedListItems?.value) {\n return nextQueriesGroups.value\n }\n if (nextQueriesAreOutdated.value) {\n return injectedListItems.value\n }\n if (hasNotEnoughListItems.value) {\n return injectedListItems.value.concat(nextQueriesGroups.value[0] ?? [])\n }\n return nextQueriesGroups?.value.reduce(\n (items, nextQueriesGroup, index) => {\n const targetIndex = props.offset + props.frequency * index\n if (targetIndex <= items.length) {\n items.splice(targetIndex, 0, nextQueriesGroup)\n }\n return items\n },\n [...injectedListItems.value],\n )\n })\n\n /**\n * The computed list items of the entity that uses the mixin.\n *\n * @remarks It should be overridden in the component that uses the mixin and it's intended to be\n * filled with items from the state. Vue doesn't allow mixins as abstract classes.\n * @returns An empty array as fallback in case it is not overridden.\n */\n provide(LIST_ITEMS_KEY as string, items)\n\n return () => {\n const innerProps = { items: items.value, animation: props.animation }\n // https://vue-land.github.io/faq/forwarding-slots#passing-all-slots\n return slots.default?.(innerProps)[0] ?? h(ItemsList, innerProps, slots)\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>QuerySignals</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nUsually, this component is going to be used together with the `ResultsList` one. Next queries groups\nwill be inserted between the results, guiding users to discover new searches directly from the\nresults list.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Play with the index that next queries groups are inserted at\n\nThe component allows to customise where are the next queries groups inserted. In the following\nexample, the first group of next queries will be inserted at the index `48` (`offset`), and then a\nsecond group will be inserted at index `120` because of the `frequency` prop configured to `72`.\nFinally, a third group will be inserted at index `192`. Because `maxGroups` is configured to `3`, no\nmore groups will be inserted. Each one of this groups will have up to `6` next queries\n(`maxNextQueriesPerGroup`).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList :offset=\"48\" :frequency=\"72\" :maxNextQueriesPerGroup=\"6\" :maxGroups=\"3\" />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Showing/hiding first next queries group when no more items\n\nBy default, the first next query group will be inserted when the total number of results is smaller\nthan the offset, but this behavior can be deactivated by setting the `showOnlyAfterOffset` to\n`true`.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList\n :offset=\"48\"\n :frequency=\"72\"\n :maxNextQueriesPerGroup=\"1\"\n :showOnlyAfterOffset=\"true\"\n />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Customise the layout of the component\n\nThis component will render by default the `id` of each search item, both the injected, and for the\ngroups of next queries generated, but the common case is to integrate it with another layout\ncomponent, for example the `BaseGrid`. To do so, you can use the `default` slot\n\n```vue\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList\n :offset=\"48\"\n :frequency=\"72\"\n :maxNextQueriesPerGroup=\"6\"\n :maxGroups=\"3\"\n #default=\"{ items }\"\n >\n <BaseGrid :items=\"items\" :animation=\"animation\">\n <template #next-queries-group=\"{ item }\">\n <span>NextQueriesGroup: {{ item.queries.join(', ') }}</span>\n </template>\n <template #result=\"{ item }\">\n <span>Result: {{ item.name }}</span>\n </template>\n <template #default=\"{ item }\">\n <span>Default: {{ item }}</span>\n </template>\n </BaseGrid>\n </NextQueriesList>\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { BaseGrid } from '@empathyco/x-components'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n BaseGrid,\n SearchInput,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"next-queries-list.vue.js","sources":["../../../../../src/x-modules/next-queries/components/next-queries-list.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Ref } from 'vue'\nimport type { ListItem } from '../../../utils/types'\nimport type { NextQueriesGroup } from '../types'\nimport { computed, defineComponent, h, inject, provide } from 'vue'\nimport {\n HAS_MORE_ITEMS_KEY,\n LIST_ITEMS_KEY,\n QUERY_KEY,\n} from '../../../components/decorators/injection.consts'\nimport ItemsList from '../../../components/items-list.vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { useState } from '../../../composables/use-state'\nimport { AnimationProp } from '../../../types/animation-prop'\nimport { groupItemsBy } from '../../../utils/array'\nimport { nextQueriesXModule } from '../x-module'\n\n/**\n * Component that inserts groups of next queries in different positions of the injected search\n * items list, based on the provided configuration.\n *\n * @public\n */\nexport default defineComponent({\n name: 'NextQueriesList',\n xModule: nextQueriesXModule.name,\n props: {\n /** Animation component that will be used to animate the next queries groups. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /** The first index to insert a group of next queries at. */\n offset: {\n type: Number,\n default: 24,\n },\n /** The items cycle size to keep inserting next queries groups at. */\n frequency: {\n type: Number,\n default: 24,\n },\n /** The maximum amount of next queries to add in a single group. */\n maxNextQueriesPerGroup: {\n type: Number,\n default: 4,\n },\n /** The maximum number of groups to insert into the injected list items list. */\n maxGroups: Number,\n /**\n * Determines if a group is added to the injected items list in case the number\n * of items is smaller than the offset.\n */\n showOnlyAfterOffset: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const { query, status } = useState('nextQueries')\n\n /** The state next queries. */\n const nextQueries = useGetter('nextQueries').nextQueries\n\n /** Injected query, updated when the related request(s) have succeeded. */\n const injectedQuery = inject<Ref<string>>(QUERY_KEY as string)\n\n /** Indicates if there are more available results than the injected. */\n const hasMoreItems = inject<Ref<boolean>>(HAS_MORE_ITEMS_KEY as string)\n\n /**\n * The grouped next queries based on the given config.\n *\n * @returns A list of next queries groups.\n */\n const nextQueriesGroups = computed<NextQueriesGroup[]>(() =>\n Object.values(\n groupItemsBy(nextQueries?.value, (_, index) =>\n Math.floor(index / props.maxNextQueriesPerGroup),\n ),\n )\n .slice(0, props.maxGroups)\n .map(nextQueries => ({\n modelName: 'NextQueriesGroup' as const,\n id: nextQueries.map(nextQuery => nextQuery.query).join(','),\n nextQueries,\n })),\n )\n\n /** It injects {@link ListItem} provided by an ancestor as injectedListItems. */\n const injectedListItems = inject<Ref<ListItem[]>>(LIST_ITEMS_KEY as string)\n\n /**\n * Checks if the next queries are outdated taking into account the injected query.\n *\n * @returns True if the next queries are outdated, false if not.\n */\n const nextQueriesAreOutdated = computed(\n () =>\n !!injectedQuery?.value &&\n (query.value !== injectedQuery.value || status.value !== 'success'),\n )\n\n /**\n * Checks if the number of items is smaller than the offset so a group\n * should be added to the injected items list.\n *\n * @returns True if a group should be added, false if not.\n */\n const hasNotEnoughListItems = computed(\n () =>\n !props.showOnlyAfterOffset &&\n !hasMoreItems?.value &&\n injectedListItems !== undefined &&\n injectedListItems.value.length > 0 &&\n props.offset > injectedListItems.value.length,\n )\n\n /**\n * New list of {@link ListItem}s to render.\n *\n * @returns The new list of {@link ListItem}s with the next queries groups inserted.\n */\n const items = computed(() => {\n if (!injectedListItems?.value) {\n return nextQueriesGroups.value\n }\n if (nextQueriesAreOutdated.value) {\n return injectedListItems.value\n }\n if (hasNotEnoughListItems.value) {\n return injectedListItems.value.concat(nextQueriesGroups.value[0] ?? [])\n }\n return nextQueriesGroups?.value.reduce(\n (items, nextQueriesGroup, index) => {\n const targetIndex = props.offset + props.frequency * index\n if (targetIndex <= items.length) {\n items.splice(targetIndex, 0, nextQueriesGroup)\n }\n return items\n },\n [...injectedListItems.value],\n )\n })\n\n /**\n * The computed list items of the entity that uses the mixin.\n *\n * @remarks It should be overridden in the component that uses the mixin and it's intended to be\n * filled with items from the state. Vue doesn't allow mixins as abstract classes.\n * @returns An empty array as fallback in case it is not overridden.\n */\n provide(LIST_ITEMS_KEY as string, items)\n\n return () => {\n const innerProps = { items: items.value, animation: props.animation }\n // https://vue-land.github.io/faq/forwarding-slots#passing-all-slots\n return slots.default?.(innerProps)[0] ?? h(ItemsList, innerProps, slots)\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\n<!-- prettier-ignore-start -->\n:::warning Backend microservice required\nTo use this component, the <b>QuerySignals</b> microservice must be\nimplemented.\n:::\n<!-- prettier-ignore-end -->\n\nUsually, this component is going to be used together with the `ResultsList` one. Next queries groups\nwill be inserted between the results, guiding users to discover new searches directly from the\nresults list.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Play with the index that next queries groups are inserted at\n\nThe component allows to customise where are the next queries groups inserted. In the following\nexample, the first group of next queries will be inserted at the index `48` (`offset`), and then a\nsecond group will be inserted at index `120` because of the `frequency` prop configured to `72`.\nFinally, a third group will be inserted at index `192`. Because `maxGroups` is configured to `3`, no\nmore groups will be inserted. Each one of this groups will have up to `6` next queries\n(`maxNextQueriesPerGroup`).\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList :offset=\"48\" :frequency=\"72\" :maxNextQueriesPerGroup=\"6\" :maxGroups=\"3\" />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Showing/hiding first next queries group when no more items\n\nBy default, the first next query group will be inserted when the total number of results is smaller\nthan the offset, but this behavior can be deactivated by setting the `showOnlyAfterOffset` to\n`true`.\n\n```vue live\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList\n :offset=\"48\"\n :frequency=\"72\"\n :maxNextQueriesPerGroup=\"1\"\n :showOnlyAfterOffset=\"true\"\n />\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n SearchInput,\n },\n}\n</script>\n```\n\n### Customise the layout of the component\n\nThis component will render by default the `id` of each search item, both the injected, and for the\ngroups of next queries generated, but the common case is to integrate it with another layout\ncomponent, for example the `BaseGrid`. To do so, you can use the `default` slot\n\n```vue\n<template>\n <div>\n <SearchInput />\n <ResultsList>\n <NextQueriesList\n :offset=\"48\"\n :frequency=\"72\"\n :maxNextQueriesPerGroup=\"6\"\n :maxGroups=\"3\"\n #default=\"{ items }\"\n >\n <BaseGrid :items=\"items\" :animation=\"animation\">\n <template #next-queries-group=\"{ item }\">\n <span>NextQueriesGroup: {{ item.queries.join(', ') }}</span>\n </template>\n <template #result=\"{ item }\">\n <span>Result: {{ item.name }}</span>\n </template>\n <template #default=\"{ item }\">\n <span>Default: {{ item }}</span>\n </template>\n </BaseGrid>\n </NextQueriesList>\n </ResultsList>\n </div>\n</template>\n\n<script>\nimport { NextQueriesList } from '@empathyco/x-components/next-queries'\nimport { ResultsList } from '@empathyco/x-components/search'\nimport { SearchInput } from '@empathyco/x-components/search-box'\nimport { BaseGrid } from '@empathyco/x-components'\n\nexport default {\n name: 'NextQueriesListDemo',\n components: {\n NextQueriesList,\n ResultsList,\n BaseGrid,\n SearchInput,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}