@empathyco/x-components 3.0.0-alpha.144 → 3.0.0-alpha.147

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 (86) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/design-system/default-theme.css +28 -28
  3. package/design-system/full-theme.css +53 -54
  4. package/docs/API-reference/api/x-adapter-platform.md +0 -1
  5. package/docs/API-reference/api/x-adapter-platform.searchresponsemapper.md +1 -11
  6. package/docs/API-reference/api/x-components.facetsmutations.md +1 -1
  7. package/docs/API-reference/api/x-components.facetsmutations.mutatefilter.md +24 -0
  8. package/docs/API-reference/api/x-components.flathierarchicalfilters.md +26 -0
  9. package/docs/API-reference/api/x-components.md +2 -0
  10. package/docs/API-reference/api/x-components.mutatefilterpayload.filter.md +13 -0
  11. package/docs/API-reference/api/x-components.mutatefilterpayload.md +21 -0
  12. package/docs/API-reference/api/x-components.mutatefilterpayload.newfilterstate.md +13 -0
  13. package/docs/API-reference/api/x-types.hierarchicalfilter.children.md +2 -2
  14. package/docs/API-reference/api/x-types.hierarchicalfilter.md +2 -2
  15. package/docs/API-reference/api/x-types.hierarchicalfilter.parentid.md +1 -1
  16. package/docs/build-search-ui/web-archetype-development-guide.md +10 -7
  17. package/docs/build-search-ui/web-archetype-integration-guide.md +15 -14
  18. package/docs/build-search-ui/web-x-components-development-guide.md +5 -4
  19. package/docs/experience-search-&-discovery/README.md +119 -0
  20. package/docs/experience-search-&-discovery/empathize.md +102 -0
  21. package/docs/experience-search-&-discovery/facets-and-filters.md +138 -0
  22. package/docs/experience-search-&-discovery/history-queries.md +56 -0
  23. package/docs/experience-search-&-discovery/id-results.md +40 -0
  24. package/docs/experience-search-&-discovery/next-queries.md +52 -0
  25. package/docs/experience-search-&-discovery/popular-searches.md +32 -0
  26. package/docs/experience-search-&-discovery/product-results-ui.md +68 -0
  27. package/docs/experience-search-&-discovery/query-suggestions.md +32 -0
  28. package/docs/experience-search-&-discovery/recommendations.md +32 -0
  29. package/docs/experience-search-&-discovery/related-tags.md +41 -0
  30. package/docs/experience-search-&-discovery/search-box.md +81 -0
  31. package/docs/experience-search-&-discovery/serp-ui.md +109 -0
  32. package/docs/experience-search-&-discovery/web-local-storage.md +25 -0
  33. package/facets/index.js +1 -1
  34. package/js/index.js +1 -1
  35. package/js/x-modules/facets/components/facets/facets-provider.vue.js +2 -2
  36. package/js/x-modules/facets/components/facets/facets-provider.vue.js.map +1 -1
  37. package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js +7 -2
  38. package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  39. package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js.map +1 -1
  40. package/js/x-modules/facets/components/filters/hierarchical-filter.vue_rollup-plugin-vue_script.vue.js +2 -130
  41. package/js/x-modules/facets/components/filters/hierarchical-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  42. package/js/x-modules/facets/entities/editable-number-range-filter.entity.js +11 -10
  43. package/js/x-modules/facets/entities/editable-number-range-filter.entity.js.map +1 -1
  44. package/js/x-modules/facets/entities/hierarchical-filter.entity.js +9 -11
  45. package/js/x-modules/facets/entities/hierarchical-filter.entity.js.map +1 -1
  46. package/js/x-modules/facets/entities/number-range-filter.entity.js +2 -2
  47. package/js/x-modules/facets/entities/number-range-filter.entity.js.map +1 -1
  48. package/js/x-modules/facets/entities/raw-filter.entity.js +1 -1
  49. package/js/x-modules/facets/entities/raw-filter.entity.js.map +1 -1
  50. package/js/x-modules/facets/entities/simple-filter.entity.js +2 -2
  51. package/js/x-modules/facets/entities/simple-filter.entity.js.map +1 -1
  52. package/js/x-modules/facets/entities/single-select.modifier.js +1 -1
  53. package/js/x-modules/facets/entities/single-select.modifier.js.map +1 -1
  54. package/js/x-modules/facets/service/facets.service.js +18 -2
  55. package/js/x-modules/facets/service/facets.service.js.map +1 -1
  56. package/js/x-modules/facets/store/module.js +4 -3
  57. package/js/x-modules/facets/store/module.js.map +1 -1
  58. package/js/x-modules/facets/utils.js +16 -1
  59. package/js/x-modules/facets/utils.js.map +1 -1
  60. package/js/x-modules/search-box/components/search-input.vue.js +54 -45
  61. package/js/x-modules/search-box/components/search-input.vue.js.map +1 -1
  62. package/js/x-modules/search-box/components/search-input.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  63. package/package.json +4 -4
  64. package/report/x-adapter-platform.api.json +5 -133
  65. package/report/x-components.api.json +181 -45
  66. package/report/x-components.api.md +14 -5
  67. package/report/x-types.api.json +5 -5
  68. package/types/x-modules/facets/components/facets/facets-provider.vue.d.ts.map +1 -1
  69. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +0 -6
  70. package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
  71. package/types/x-modules/facets/entities/editable-number-range-filter.entity.d.ts +1 -1
  72. package/types/x-modules/facets/entities/editable-number-range-filter.entity.d.ts.map +1 -1
  73. package/types/x-modules/facets/entities/hierarchical-filter.entity.d.ts +2 -1
  74. package/types/x-modules/facets/entities/hierarchical-filter.entity.d.ts.map +1 -1
  75. package/types/x-modules/facets/entities/single-select.modifier.d.ts.map +1 -1
  76. package/types/x-modules/facets/service/facets.service.d.ts +13 -0
  77. package/types/x-modules/facets/service/facets.service.d.ts.map +1 -1
  78. package/types/x-modules/facets/store/module.d.ts.map +1 -1
  79. package/types/x-modules/facets/store/types.d.ts +22 -6
  80. package/types/x-modules/facets/store/types.d.ts.map +1 -1
  81. package/types/x-modules/facets/utils.d.ts +11 -0
  82. package/types/x-modules/facets/utils.d.ts.map +1 -1
  83. package/types/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
  84. package/docs/API-reference/api/x-adapter-platform.searchresponsefacetsmapper.md +0 -27
  85. package/docs/API-reference/api/x-components.facetsmutations.setfilter.md +0 -24
  86. package/docs/functional-doc/web-local-storage.md +0 -22
@@ -3,129 +3,6 @@ import { isHierarchicalFilter } from '@empathyco/x-types';
3
3
  import { isObject } from '@empathyco/x-utils';
4
4
  import Vue from 'vue';
5
5
  import { Prop, Component } from 'vue-property-decorator';
6
- import '../../../../components/animations/animate-width.vue.js';
7
- import '../../../../components/animations/collapse-height.vue.js';
8
- import '../../../../components/animations/collapse-width.vue.js';
9
- import '../../../../components/animations/cross-fade.vue.js';
10
- import '../../../../components/animations/fade.vue.js';
11
- import '../../../../components/animations/fade-and-slide.vue.js';
12
- import '../../../../components/animations/staggered-fade-and-slide.vue.js';
13
- import '../../../../components/animations/staggering-transition-group.vue_rollup-plugin-vue_script.vue.js';
14
- import 'vue-runtime-helpers/dist/normalize-component.mjs';
15
- import 'vue-runtime-helpers/dist/inject-style/browser.mjs';
16
- import '../../../../components/animations/animate-clip-path/animate-clip-path.style.scss.js';
17
- import '../../../../components/animations/animate-scale/animate-scale.style.scss.js';
18
- import '../../../../components/animations/animate-translate/animate-translate.style.scss.js';
19
- import '../../../../components/column-picker/base-column-picker-dropdown.vue.js';
20
- import '../../../../components/column-picker/base-column-picker-list.vue.js';
21
- import '../../../../components/column-picker/column-picker.mixin.js';
22
- import '../../../../components/currency/base-currency.vue.js';
23
- import '../../../../components/filters/labels/base-price-filter-label.vue_rollup-plugin-vue_script.vue.js';
24
- import '../../../../components/filters/labels/base-rating-filter-label.vue.js';
25
- import '../../../../components/icons/arrow-down.vue.js';
26
- import '../../../../components/icons/arrow-left.vue.js';
27
- import '../../../../components/icons/arrow-right.vue.js';
28
- import '../../../../components/icons/arrow-up.vue.js';
29
- import '../../../../components/icons/bag.vue.js';
30
- import '../../../../components/icons/bar-code.vue.js';
31
- import '../../../../components/icons/barcode-tiny.vue.js';
32
- import '../../../../components/icons/cart.vue.js';
33
- import '../../../../components/icons/check-tiny.vue.js';
34
- import '../../../../components/icons/check.vue.js';
35
- import '../../../../components/icons/checkbox-card-selected.vue.js';
36
- import '../../../../components/icons/checkbox-card-unselected.vue.js';
37
- import '../../../../components/icons/checkbox-selected.vue.js';
38
- import '../../../../components/icons/checkbox-unselected.vue.js';
39
- import '../../../../components/icons/chevron-down.vue.js';
40
- import '../../../../components/icons/chevron-left.vue.js';
41
- import '../../../../components/icons/chevron-right.vue.js';
42
- import '../../../../components/icons/chevron-tiny-down.vue.js';
43
- import '../../../../components/icons/chevron-tiny-left.vue.js';
44
- import '../../../../components/icons/chevron-tiny-right.vue.js';
45
- import '../../../../components/icons/chevron-tiny-up.vue.js';
46
- import '../../../../components/icons/chevron-up.vue.js';
47
- import '../../../../components/icons/cross-tiny.vue.js';
48
- import '../../../../components/icons/cross.vue.js';
49
- import '../../../../components/icons/curated-check.vue.js';
50
- import '../../../../components/icons/filters.vue.js';
51
- import '../../../../components/icons/grid-1-col.vue.js';
52
- import '../../../../components/icons/grid-2-col.vue.js';
53
- import '../../../../components/icons/grid-4-col.vue.js';
54
- import '../../../../components/icons/grid-2-rows.vue.js';
55
- import '../../../../components/icons/hide.vue.js';
56
- import '../../../../components/icons/history-tiny.vue.js';
57
- import '../../../../components/icons/history.vue.js';
58
- import '../../../../components/icons/light-bulb-off.vue.js';
59
- import '../../../../components/icons/light-bulb-on.vue.js';
60
- import '../../../../components/icons/menu.vue.js';
61
- import '../../../../components/icons/minus-tiny.vue.js';
62
- import '../../../../components/icons/minus.vue.js';
63
- import '../../../../components/icons/nq-1.vue.js';
64
- import '../../../../components/icons/nq-2.vue.js';
65
- import '../../../../components/icons/nq-3.vue.js';
66
- import '../../../../components/icons/nq-4.vue.js';
67
- import '../../../../components/icons/plus.vue.js';
68
- import '../../../../components/icons/radiobutton-selected.vue.js';
69
- import '../../../../components/icons/radiobutton-unselected.vue.js';
70
- import '../../../../components/icons/search.vue.js';
71
- import '../../../../components/icons/settings.vue.js';
72
- import '../../../../components/icons/show.vue.js';
73
- import '../../../../components/icons/star.vue.js';
74
- import '../../../../components/icons/search-tiny.vue.js';
75
- import '../../../../components/icons/tag.vue.js';
76
- import '../../../../components/icons/trash-open.vue.js';
77
- import '../../../../components/icons/trash.vue.js';
78
- import '../../../../components/icons/trending-tiny.vue.js';
79
- import '../../../../components/icons/trending.vue.js';
80
- import '../../../../components/icons/user.vue.js';
81
- import '../../../../components/layouts/fixed-header-and-asides-layout.vue.js';
82
- import '../../../../components/layouts/multi-column-max-width-layout.vue.js';
83
- import '../../../../components/layouts/single-column-layout.vue.js';
84
- import '../../../../components/modals/base-events-modal-close.vue.js';
85
- import '../../../../components/modals/base-events-modal.vue.js';
86
- import '../../../../components/modals/base-events-modal-open.vue.js';
87
- import '../../../../components/modals/base-modal.vue.js';
88
- import '../../../../components/modals/base-id-modal.vue.js';
89
- import '../../../../components/modals/base-id-modal-close.vue.js';
90
- import '../../../../components/modals/base-id-modal-open.vue.js';
91
- import '../../../../components/modals/close-main-modal.vue.js';
92
- import '../../../../components/modals/main-modal.vue.js';
93
- import '../../../../components/modals/open-main-modal.vue.js';
94
- import '../../../../components/panels/base-header-toggle-panel.vue.js';
95
- import '../../../../components/panels/base-toggle-panel.vue.js';
96
- import '../../../../components/panels/base-id-toggle-panel.vue.js';
97
- import '../../../../components/panels/base-id-toggle-panel-button.vue.js';
98
- import '../../../../components/result/base-result-add-to-cart.vue.js';
99
- import '../../../../components/result/base-result-current-price.vue.js';
100
- import '../../../../components/result/base-result-image.vue.js';
101
- import '../../../../components/result/base-result-link.vue.js';
102
- import '../../../../components/result/base-result-previous-price.vue.js';
103
- import '../../../../components/result/base-result-fallback-image.vue.js';
104
- import '../../../../components/result/base-result-placeholder-image.vue.js';
105
- import '../../../../components/result/base-result-rating.vue.js';
106
- import '../../../../components/scroll/base-scroll.vue.js';
107
- import '../../../../components/scroll/scroll.mixin.js';
108
- import '../../../../components/suggestions/base-suggestion.vue.js';
109
- import '../../../../components/suggestions/base-suggestions.vue.js';
110
- import '../../../../components/auto-progress-bar.vue.js';
111
- import '../../../../components/base-dropdown.vue.js';
112
- import '../../../../components/base-event-button.vue.js';
113
- import '../../../../components/base-grid.vue.js';
114
- import '../../../../components/base-keyboard-navigation.vue.js';
115
- import '../../../../components/base-rating.vue.js';
116
- import '../../../../components/base-switch.vue.js';
117
- import '../../../../components/base-variable-column-grid.vue.js';
118
- import '../../../../components/global-x-bus.vue_rollup-plugin-vue_script.vue.js';
119
- import '../../../../components/items-list.vue.js';
120
- import '../../../../components/location-provider.vue_rollup-plugin-vue_script.vue.js';
121
- import '../../../../components/no-element.js';
122
- import '../../../../components/sliding-panel.vue.js';
123
- import '../../../../components/snippet-callbacks.vue.js';
124
- import 'rxjs';
125
- import 'rxjs/operators';
126
- import 'vue-class-component';
127
- import { State } from '../../../../components/decorators/store.decorators.js';
128
- import '../../../../components/items-list-injection.mixin.js';
129
6
  import { xComponentMixin } from '../../../../components/x-component.mixin.js';
130
7
  import { facetsXModule } from '../../x-module.js';
131
8
  import __vue_component__ from '../lists/filters-list.vue.js';
@@ -200,12 +77,10 @@ let HierarchicalFilter = class HierarchicalFilter extends Vue {
200
77
  * @internal
201
78
  */
202
79
  get renderedChildrenFilters() {
203
- return this.filter.children?.map(filterId => this.filters[filterId]) ?? [];
80
+ return this.filter.children ?? [];
204
81
  }
205
82
  isFilterPartiallySelected(filter) {
206
- const selectedChildren = filter.children
207
- ?.map(filterId => this.filters[filterId])
208
- ?.filter(filter => filter?.selected);
83
+ const selectedChildren = filter.children?.filter(filter => filter.selected);
209
84
  const filterChildrenLength = filter.children?.length ?? 0;
210
85
  return (!!selectedChildren &&
211
86
  ((selectedChildren.length > 0 && selectedChildren.length < filterChildrenLength) ||
@@ -219,9 +94,6 @@ __decorate([
219
94
  __decorate([
220
95
  Prop()
221
96
  ], HierarchicalFilter.prototype, "childrenAnimation", void 0);
222
- __decorate([
223
- State('facets', 'filters')
224
- ], HierarchicalFilter.prototype, "filters", void 0);
225
97
  __decorate([
226
98
  Prop()
227
99
  ], HierarchicalFilter.prototype, "clickEvents", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"hierarchical-filter.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/hierarchical-filter.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport {\n Filter,\n HierarchicalFilter as HierarchicalFilterModel,\n isHierarchicalFilter\n} from '@empathyco/x-types';\nimport { isObject } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { State, xComponentMixin } from '../../../../components';\nimport { VueCSSClasses } from '../../../../utils/types';\nimport { XEventsTypes } from '../../../../wiring/events.types';\nimport { facetsXModule } from '../../x-module';\nimport FiltersList from '../lists/filters-list.vue';\nimport RenderlessFilter from './renderless-filter.vue';\n\n/**\n * Renders a hierarchical filter recursively, emitting the needed events when clicked.\n *\n * @public\n */\n@Component({\n name: 'HierarchicalFilter',\n components: { FiltersList, RenderlessFilter },\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class HierarchicalFilter extends Vue {\n /** The filter data to render. */\n @Prop({ required: true })\n public filter!: HierarchicalFilterModel;\n\n /** The animation component to use for the children filters. */\n @Prop()\n public childrenAnimation?: Vue | string;\n /**\n * The state filters.\n *\n * @internal\n */\n @State('facets', 'filters')\n public filters!: Record<Filter['id'], Filter>;\n\n /**\n * Additional events, with their payload, to emit when the filter is clicked.\n *\n * @public\n */\n @Prop()\n public clickEvents!: Partial<XEventsTypes>;\n\n /**\n * The {@link XEventsTypes | events} to emit.\n *\n * @returns The events to emit when clicked.\n * @internal\n */\n protected get _clickEvents(): Partial<XEventsTypes> {\n return {\n UserClickedAHierarchicalFilter: this.filter,\n ...this.clickEvents\n };\n }\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n protected get cssClasses(): VueCSSClasses {\n return {\n 'x-hierarchical-filter--is-partially-selected': this.isPartiallySelected,\n 'x-hierarchical-filter--is-selected': this.filter.selected,\n 'x-filter--is-partially-selected': this.isPartiallySelected\n };\n }\n\n /**\n * Gets the child filter click events, converting the payload of the events that have a\n * {@link @empathyco/x-types#HierarchicalFilter} as payload to the corresponding child filter.\n *\n * @param childFilter - The child filter.\n * @returns The events to emit when clicking a child.\n * @internal\n */\n protected getChildFilterClickEvents(\n childFilter: HierarchicalFilterModel\n ): Partial<XEventsTypes> {\n return Object.entries(this._clickEvents).reduce((clickEvents, [event, payload]) => {\n return {\n ...clickEvents,\n [event]:\n isObject(payload) &&\n isHierarchicalFilter(payload as unknown as Filter) &&\n childFilter !== (payload as unknown as HierarchicalFilterModel)\n ? childFilter\n : payload\n };\n }, {} as Partial<XEventsTypes>);\n }\n\n /**\n * Returns if the filter is partially selected, which means having more than one child filter\n * selected, but not every of them, or having at least one child filter partially selected.\n *\n * @returns True if the filter is partially selected. False otherwise.\n * @internal\n */\n protected get isPartiallySelected(): boolean {\n return this.isFilterPartiallySelected(this.filter);\n }\n\n /**\n * List of filters to render, in case that the children's array\n * is empty it will return an empty array instead of inject the ones from the parent.\n *\n * @returns A list of filters.\n * @internal\n */\n protected get renderedChildrenFilters(): Filter[] {\n return this.filter.children?.map(filterId => this.filters[filterId]) ?? [];\n }\n\n protected isFilterPartiallySelected(filter: HierarchicalFilterModel): boolean {\n const selectedChildren = filter.children\n ?.map(filterId => this.filters[filterId])\n ?.filter(filter => filter?.selected) as HierarchicalFilterModel[] | undefined;\n const filterChildrenLength = filter.children?.length ?? 0;\n return (\n !!selectedChildren &&\n ((selectedChildren.length > 0 && selectedChildren.length < filterChildrenLength) ||\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectedChildren.some(this.isFilterPartiallySelected))\n );\n }\n}\n"],"names":["FiltersList","RenderlessFilter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,QAAQ,CAA0C,CAAC;QAChF,MAAM,oBAAoB,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;QAC1D,QACE,CAAC,CAAC,gBAAgB;aACjB,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,gBAAgB,CAAC,MAAM,GAAG,oBAAoB;;gBAE7E,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,EACxD;KACH;CACF,CAAA;AA1GC;IADC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACe;AAIxC;IADC,IAAI,EAAE;6DACiC;AAOxC;IADC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;mDACmB;AAQ9C;IADC,IAAI,EAAE;uDACoC;AAtBxB,kBAAkB;IALtC,SAAS,CAAC;QACT,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE,eAAEA,iBAAW,oBAAEC,mBAAgB,EAAE;QAC7C,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;GACmB,kBAAkB,CA6GtC;aA7GoB,kBAAkB;;;;"}
1
+ {"version":3,"file":"hierarchical-filter.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/hierarchical-filter.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport {\n Filter,\n HierarchicalFilter as HierarchicalFilterModel,\n isHierarchicalFilter\n} from '@empathyco/x-types';\nimport { isObject } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { xComponentMixin } from '../../../../components/x-component.mixin';\nimport { VueCSSClasses } from '../../../../utils/types';\nimport { XEventsTypes } from '../../../../wiring/events.types';\nimport { facetsXModule } from '../../x-module';\nimport FiltersList from '../lists/filters-list.vue';\nimport RenderlessFilter from './renderless-filter.vue';\n\n/**\n * Renders a hierarchical filter recursively, emitting the needed events when clicked.\n *\n * @public\n */\n@Component({\n name: 'HierarchicalFilter',\n components: { FiltersList, RenderlessFilter },\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class HierarchicalFilter extends Vue {\n /** The filter data to render. */\n @Prop({ required: true })\n public filter!: HierarchicalFilterModel;\n\n /** The animation component to use for the children filters. */\n @Prop()\n public childrenAnimation?: Vue | string;\n\n /**\n * Additional events, with their payload, to emit when the filter is clicked.\n *\n * @public\n */\n @Prop()\n public clickEvents!: Partial<XEventsTypes>;\n\n /**\n * The {@link XEventsTypes | events} to emit.\n *\n * @returns The events to emit when clicked.\n * @internal\n */\n protected get _clickEvents(): Partial<XEventsTypes> {\n return {\n UserClickedAHierarchicalFilter: this.filter,\n ...this.clickEvents\n };\n }\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n protected get cssClasses(): VueCSSClasses {\n return {\n 'x-hierarchical-filter--is-partially-selected': this.isPartiallySelected,\n 'x-hierarchical-filter--is-selected': this.filter.selected,\n 'x-filter--is-partially-selected': this.isPartiallySelected\n };\n }\n\n /**\n * Gets the child filter click events, converting the payload of the events that have a\n * {@link @empathyco/x-types#HierarchicalFilter} as payload to the corresponding child filter.\n *\n * @param childFilter - The child filter.\n * @returns The events to emit when clicking a child.\n * @internal\n */\n protected getChildFilterClickEvents(\n childFilter: HierarchicalFilterModel\n ): Partial<XEventsTypes> {\n return Object.entries(this._clickEvents).reduce((clickEvents, [event, payload]) => {\n return {\n ...clickEvents,\n [event]:\n isObject(payload) &&\n isHierarchicalFilter(payload as unknown as Filter) &&\n childFilter !== (payload as unknown as HierarchicalFilterModel)\n ? childFilter\n : payload\n };\n }, {} as Partial<XEventsTypes>);\n }\n\n /**\n * Returns if the filter is partially selected, which means having more than one child filter\n * selected, but not every of them, or having at least one child filter partially selected.\n *\n * @returns True if the filter is partially selected. False otherwise.\n * @internal\n */\n protected get isPartiallySelected(): boolean {\n return this.isFilterPartiallySelected(this.filter);\n }\n\n /**\n * List of filters to render, in case that the children's array\n * is empty it will return an empty array instead of inject the ones from the parent.\n *\n * @returns A list of filters.\n * @internal\n */\n protected get renderedChildrenFilters(): Filter[] {\n return this.filter.children ?? [];\n }\n\n protected isFilterPartiallySelected(filter: HierarchicalFilterModel): boolean {\n const selectedChildren = filter.children?.filter(filter => filter.selected);\n const filterChildrenLength = filter.children?.length ?? 0;\n return (\n !!selectedChildren &&\n ((selectedChildren.length > 0 && selectedChildren.length < filterChildrenLength) ||\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectedChildren.some(this.isFilterPartiallySelected))\n );\n }\n}\n"],"names":["FiltersList","RenderlessFilter"],"mappings":";;;;;;;;;;AAyEA;;;;;AAUA,IAAqB,kBAAkB,GAAvC,MAAqB,kBAAmB,SAAQ,GAAG;;;;;;;IAuBjD,IAAc,YAAY;QACxB,OAAO;YACL,8BAA8B,EAAE,IAAI,CAAC,MAAM;YAC3C,GAAG,IAAI,CAAC,WAAW;SACpB,CAAC;KACH;;;;;;;IAQD,IAAc,UAAU;QACtB,OAAO;YACL,8CAA8C,EAAE,IAAI,CAAC,mBAAmB;YACxE,oCAAoC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC1D,iCAAiC,EAAE,IAAI,CAAC,mBAAmB;SAC5D,CAAC;KACH;;;;;;;;;IAUS,yBAAyB,CACjC,WAAoC;QAEpC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;YAC5E,OAAO;gBACL,GAAG,WAAW;gBACd,CAAC,KAAK,GACJ,QAAQ,CAAC,OAAO,CAAC;oBACjB,oBAAoB,CAAC,OAA4B,CAAC;oBAClD,WAAW,KAAM,OAA8C;sBAC3D,WAAW;sBACX,OAAO;aACd,CAAC;SACH,EAAE,EAA2B,CAAC,CAAC;KACjC;;;;;;;;IASD,IAAc,mBAAmB;QAC/B,OAAO,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACpD;;;;;;;;IASD,IAAc,uBAAuB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;KACnC;IAES,yBAAyB,CAAC,MAA+B;QACjE,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5E,MAAM,oBAAoB,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;QAC1D,QACE,CAAC,CAAC,gBAAgB;aACjB,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,gBAAgB,CAAC,MAAM,GAAG,oBAAoB;;gBAE7E,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,EACxD;KACH;CACF,CAAA;AAjGC;IADC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACe;AAIxC;IADC,IAAI,EAAE;6DACiC;AAQxC;IADC,IAAI,EAAE;uDACoC;AAfxB,kBAAkB;IALtC,SAAS,CAAC;QACT,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE,eAAEA,iBAAW,oBAAEC,mBAAgB,EAAE;QAC7C,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;GACmB,kBAAkB,CAoGtC;aApGoB,kBAAkB;;;;"}
@@ -22,14 +22,16 @@ class EditableNumberRangeFilterEntity {
22
22
  * @param filter - The filter to deselect.
23
23
  */
24
24
  deselect(filter) {
25
- const newFilter = {
26
- ...filter,
27
- selected: false,
28
- range: { min: null, max: null }
25
+ const newFilterState = {
26
+ facetId: filter.facetId,
27
+ range: { min: null, max: null },
28
+ selected: false
29
29
  };
30
- newFilter.id = this.getNewFilterId(newFilter);
31
30
  this.removePreviousFilter(filter.facetId);
32
- this.store.commit('x/facets/setFilter', newFilter);
31
+ this.store.commit('x/facets/mutateFilter', {
32
+ filter,
33
+ newFilterState: Object.assign(newFilterState, { id: this.getNewFilterId(newFilterState) })
34
+ });
33
35
  addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');
34
36
  }
35
37
  /**
@@ -43,10 +45,9 @@ class EditableNumberRangeFilterEntity {
43
45
  select(filter) {
44
46
  const newFilterId = this.getNewFilterId(filter);
45
47
  this.removePreviousFilter(filter.facetId);
46
- this.store.commit('x/facets/setFilter', {
47
- ...filter,
48
- id: newFilterId,
49
- selected: this.isSelected(filter)
48
+ this.store.commit('x/facets/mutateFilter', {
49
+ filter,
50
+ newFilterState: { id: newFilterId, selected: this.isSelected(filter) }
50
51
  });
51
52
  addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');
52
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"editable-number-range-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/editable-number-range-filter.entity.ts"],"sourcesContent":["import {\n EditableNumberRangeFilter,\n Facet,\n Filter,\n isEditableNumberRangeFilter\n} from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter}.\n *\n * @internal\n */\nexport class EditableNumberRangeFilterEntity implements FilterEntity {\n public constructor(protected store: Store<RootXStoreState>) {}\n\n static accepts(filter: Filter): boolean {\n return isEditableNumberRangeFilter(filter);\n }\n\n /**\n * It sets {@link @empathyco/x-types#EditableNumberRangeFilter | EditableNumberRangeFilter} to\n * false and reset the {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter} values to null.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: EditableNumberRangeFilter): void {\n const newFilter: EditableNumberRangeFilter = {\n ...filter,\n selected: false,\n range: { min: null, max: null }\n };\n newFilter.id = this.getNewFilterId(newFilter);\n this.removePreviousFilter(filter.facetId);\n this.store.commit('x/facets/setFilter', newFilter);\n addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');\n }\n\n /**\n * It selects the {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter}.\n *\n * @param filter - The filter to select.\n * @remarks If the filter has no selected range, then filter is deselected when this\n * method is called.\n */\n select(filter: EditableNumberRangeFilter): void {\n const newFilterId = this.getNewFilterId(filter);\n this.removePreviousFilter(filter.facetId);\n this.store.commit('x/facets/setFilter', {\n ...filter,\n id: newFilterId,\n selected: this.isSelected(filter)\n });\n addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');\n }\n\n /**\n * Generates a new filter id using the range values.\n *\n * @param filter - The filter to generate its new id.\n * @returns The new filter id.\n * @internal\n */\n protected getNewFilterId(filter: EditableNumberRangeFilter): string {\n return `${filter.facetId}:${String(filter.range.min)}_${String(filter.range.max)}`;\n }\n\n /**\n * It returns if the filter range min or the filter range max is not null.\n *\n * @param filter - The filter to determine if it is selected or not.\n * @returns True if filter range min or filter range max is not null.\n * @internal\n */\n protected isSelected(filter: EditableNumberRangeFilter): boolean {\n return filter.range.min !== null || filter.range.max !== null;\n }\n\n /**\n * Removes the previous filter of this facet from the store, only if it exists.\n *\n * @param facetId - The facet to remove its only filter.\n * @internal\n */\n protected removePreviousFilter(facetId: Facet['id']): void {\n const previousFilter = this.getFilterByFacet(facetId);\n if (previousFilter) {\n this.store.commit('x/facets/removeFilter', previousFilter);\n }\n }\n\n /**\n * Retrieves the filter of the given facet id from the store.\n *\n * @param facetId - The facet id to retrieve its filter.\n * @returns The filter of the facet if it exists.\n * @internal\n */\n protected getFilterByFacet(facetId: Facet['id']): EditableNumberRangeFilter | undefined {\n return this.store.getters['x/facets/facets'][facetId]?.filters?.[0];\n }\n}\n"],"names":[],"mappings":";;;AAWA;;;;;;MAMa,+BAA+B;IAC1C,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;IAE9D,OAAO,OAAO,CAAC,MAAc;QAC3B,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;KAC5C;;;;;;;;IASD,QAAQ,CAAC,MAAiC;QACxC,MAAM,SAAS,GAA8B;YAC3C,GAAG,MAAM;YACT,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE;SAChC,CAAC;QACF,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;QACnD,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;KAC9E;;;;;;;;;IAUD,MAAM,CAAC,MAAiC;QACtC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE;YACtC,GAAG,MAAM;YACT,EAAE,EAAE,WAAW;YACf,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SAClC,CAAC,CAAC;QACH,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;KAC9E;;;;;;;;IASS,cAAc,CAAC,MAAiC;QACxD,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;KACpF;;;;;;;;IASS,UAAU,CAAC,MAAiC;QACpD,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC;KAC/D;;;;;;;IAQS,oBAAoB,CAAC,OAAoB;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;SAC5D;KACF;;;;;;;;IASS,gBAAgB,CAAC,OAAoB;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;KACrE;;;;;"}
1
+ {"version":3,"file":"editable-number-range-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/editable-number-range-filter.entity.ts"],"sourcesContent":["import {\n EditableNumberRangeFilter,\n Facet,\n Filter,\n isEditableNumberRangeFilter\n} from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter}.\n *\n * @internal\n */\nexport class EditableNumberRangeFilterEntity implements FilterEntity {\n public constructor(protected store: Store<RootXStoreState>) {}\n\n static accepts(filter: Filter): boolean {\n return isEditableNumberRangeFilter(filter);\n }\n\n /**\n * It sets {@link @empathyco/x-types#EditableNumberRangeFilter | EditableNumberRangeFilter} to\n * false and reset the {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter} values to null.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: EditableNumberRangeFilter): void {\n const newFilterState: Pick<EditableNumberRangeFilter, 'range' | 'facetId' | 'selected'> = {\n facetId: filter.facetId,\n range: { min: null, max: null },\n selected: false\n };\n this.removePreviousFilter(filter.facetId);\n this.store.commit('x/facets/mutateFilter', {\n filter,\n newFilterState: Object.assign(newFilterState, { id: this.getNewFilterId(newFilterState) })\n });\n addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');\n }\n\n /**\n * It selects the {@link @empathyco/x-types#EditableNumberRangeFilter\n * | EditableNumberRangeFilter}.\n *\n * @param filter - The filter to select.\n * @remarks If the filter has no selected range, then filter is deselected when this\n * method is called.\n */\n select(filter: EditableNumberRangeFilter): void {\n const newFilterId = this.getNewFilterId(filter);\n this.removePreviousFilter(filter.facetId);\n this.store.commit('x/facets/mutateFilter', {\n filter,\n newFilterState: { id: newFilterId, selected: this.isSelected(filter) }\n });\n addFacetIfNotPresent(this.store, filter.facetId, 'EditableNumberRangeFacet');\n }\n\n /**\n * Generates a new filter id using the range values.\n *\n * @param filter - The filter to generate its new id.\n * @returns The new filter id.\n * @internal\n */\n protected getNewFilterId(filter: Pick<EditableNumberRangeFilter, 'range' | 'facetId'>): string {\n return `${filter.facetId}:${String(filter.range.min)}_${String(filter.range.max)}`;\n }\n\n /**\n * It returns if the filter range min or the filter range max is not null.\n *\n * @param filter - The filter to determine if it is selected or not.\n * @returns True if filter range min or filter range max is not null.\n * @internal\n */\n protected isSelected(filter: EditableNumberRangeFilter): boolean {\n return filter.range.min !== null || filter.range.max !== null;\n }\n\n /**\n * Removes the previous filter of this facet from the store, only if it exists.\n *\n * @param facetId - The facet to remove its only filter.\n * @internal\n */\n protected removePreviousFilter(facetId: Facet['id']): void {\n const previousFilter = this.getFilterByFacet(facetId);\n if (previousFilter) {\n this.store.commit('x/facets/removeFilter', previousFilter);\n }\n }\n\n /**\n * Retrieves the filter of the given facet id from the store.\n *\n * @param facetId - The facet id to retrieve its filter.\n * @returns The filter of the facet if it exists.\n * @internal\n */\n protected getFilterByFacet(facetId: Facet['id']): EditableNumberRangeFilter | undefined {\n return this.store.getters['x/facets/facets'][facetId]?.filters?.[0];\n }\n}\n"],"names":[],"mappings":";;;AAWA;;;;;;MAMa,+BAA+B;IAC1C,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;IAE9D,OAAO,OAAO,CAAC,MAAc;QAC3B,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;KAC5C;;;;;;;;IASD,QAAQ,CAAC,MAAiC;QACxC,MAAM,cAAc,GAAsE;YACxF,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE;YAC/B,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE;YACzC,MAAM;YACN,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC;SAC3F,CAAC,CAAC;QACH,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;KAC9E;;;;;;;;;IAUD,MAAM,CAAC,MAAiC;QACtC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE;YACzC,MAAM;YACN,cAAc,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;SACvE,CAAC,CAAC;QACH,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;KAC9E;;;;;;;;IASS,cAAc,CAAC,MAA4D;QACnF,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;KACpF;;;;;;;;IASS,UAAU,CAAC,MAAiC;QACpD,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC;KAC/D;;;;;;;IAQS,oBAAoB,CAAC,OAAoB;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;SAC5D;KACF;;;;;;;;IASS,gBAAgB,CAAC,OAAoB;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;KACrE;;;;;"}
@@ -17,7 +17,7 @@ class HierarchicalFilterEntity {
17
17
  * @param filter - The filter to deselect.
18
18
  */
19
19
  deselect(filter) {
20
- this.saveFilter({ ...filter, selected: false });
20
+ this.saveFilter(filter, { selected: false });
21
21
  this.deselectDescendants(filter);
22
22
  addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');
23
23
  }
@@ -27,7 +27,7 @@ class HierarchicalFilterEntity {
27
27
  * @param filter - The filter to select.
28
28
  */
29
29
  select(filter) {
30
- this.saveFilter({ ...filter, selected: true });
30
+ this.saveFilter(filter, { selected: true });
31
31
  this.selectAncestors(filter);
32
32
  addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');
33
33
  }
@@ -40,12 +40,9 @@ class HierarchicalFilterEntity {
40
40
  */
41
41
  deselectDescendants(filter) {
42
42
  if (filter.children) {
43
- filter.children.forEach(childId => {
44
- const child = this.getFilterById(childId);
45
- if (child) {
46
- this.saveFilter({ ...child, selected: false });
47
- this.deselectDescendants(child);
48
- }
43
+ filter.children.forEach(child => {
44
+ this.saveFilter(child, { selected: false });
45
+ this.deselectDescendants(child);
49
46
  });
50
47
  }
51
48
  }
@@ -60,7 +57,7 @@ class HierarchicalFilterEntity {
60
57
  if (filter.parentId) {
61
58
  const parent = this.getFilterById(filter.parentId);
62
59
  if (parent) {
63
- this.saveFilter({ ...parent, selected: true });
60
+ this.saveFilter(parent, { selected: true });
64
61
  this.selectAncestors(parent);
65
62
  }
66
63
  }
@@ -79,10 +76,11 @@ class HierarchicalFilterEntity {
79
76
  * Saves the given filter to the store.
80
77
  *
81
78
  * @param filter - The filter to save to the store.
79
+ * @param newFilterState - The new partial state of the filter.
82
80
  * @internal
83
81
  */
84
- saveFilter(filter) {
85
- this.store.commit('x/facets/setFilter', filter);
82
+ saveFilter(filter, newFilterState = {}) {
83
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState });
86
84
  }
87
85
  }
88
86
  HierarchicalFilterEntity.accepts = isHierarchicalFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"hierarchical-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/hierarchical-filter.entity.ts"],"sourcesContent":["import { HierarchicalFilter, isHierarchicalFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#HierarchicalFilter\n * | HierarchicalFilter}.\n *\n * @internal\n */\nexport class HierarchicalFilterEntity implements FilterEntity {\n public static accepts = isHierarchicalFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects the hierarchical filter and all of its descendants.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: HierarchicalFilter): void {\n this.saveFilter({ ...filter, selected: false });\n this.deselectDescendants(filter);\n addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');\n }\n\n /**\n * Selects the hierarchical filter and its ancestors.\n *\n * @param filter - The filter to select.\n */\n select(filter: HierarchicalFilter): void {\n this.saveFilter({ ...filter, selected: true });\n this.selectAncestors(filter);\n addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');\n }\n\n /**\n * Deselects all the descendants of the given filter, saving them to the store.\n *\n * @remarks The descendants hierarchy is retrieved from the store.\n * @param filter - The filter to deselect its descendants.\n * @internal\n */\n protected deselectDescendants(filter: HierarchicalFilter): void {\n if (filter.children) {\n filter.children.forEach(childId => {\n const child = this.getFilterById(childId);\n if (child) {\n this.saveFilter({ ...child, selected: false });\n this.deselectDescendants(child);\n }\n });\n }\n }\n\n /**\n * Selects all the ancestors of the given filter, saving them to the store.\n *\n * @remarks The ancestors hierarchy is retrieved from the store.\n * @param filter - The filter to select its ancestors.\n * @internal\n */\n protected selectAncestors(filter: HierarchicalFilter): void {\n if (filter.parentId) {\n const parent = this.getFilterById(filter.parentId);\n if (parent) {\n this.saveFilter({ ...parent, selected: true });\n this.selectAncestors(parent);\n }\n }\n }\n\n /**\n * Retrieves a hierarchical filter from the store by its id.\n *\n * @param id - The id of the filter to retrieve.\n * @returns The hierarchical filter retrieved from the store.\n * @internal\n */\n protected getFilterById(id: HierarchicalFilter['id']): HierarchicalFilter {\n return this.store.state.x.facets.filters[id] as HierarchicalFilter;\n }\n\n /**\n * Saves the given filter to the store.\n *\n * @param filter - The filter to save to the store.\n * @internal\n */\n protected saveFilter(filter: HierarchicalFilter): void {\n this.store.commit('x/facets/setFilter', filter);\n }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CAAC,UAAU,CAAC,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC/C,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;aAC9B;SACF;KACF;;;;;;;;IASS,aAAa,CAAC,EAA4B;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAuB,CAAC;KACpE;;;;;;;IAQS,UAAU,CAAC,MAA0B;QAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;KACjD;;AAjFa,gCAAO,GAAG,oBAAoB;;;;"}
1
+ {"version":3,"file":"hierarchical-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/hierarchical-filter.entity.ts"],"sourcesContent":["import { HierarchicalFilter, isHierarchicalFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#HierarchicalFilter\n * | HierarchicalFilter}.\n *\n * @internal\n */\nexport class HierarchicalFilterEntity implements FilterEntity {\n public static accepts = isHierarchicalFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects the hierarchical filter and all of its descendants.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: HierarchicalFilter): void {\n this.saveFilter(filter, { selected: false });\n this.deselectDescendants(filter);\n addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');\n }\n\n /**\n * Selects the hierarchical filter and its ancestors.\n *\n * @param filter - The filter to select.\n */\n select(filter: HierarchicalFilter): void {\n this.saveFilter(filter, { selected: true });\n this.selectAncestors(filter);\n addFacetIfNotPresent(this.store, filter.facetId, 'HierarchicalFacet');\n }\n\n /**\n * Deselects all the descendants of the given filter, saving them to the store.\n *\n * @remarks The descendants hierarchy is retrieved from the store.\n * @param filter - The filter to deselect its descendants.\n * @internal\n */\n protected deselectDescendants(filter: HierarchicalFilter): void {\n if (filter.children) {\n filter.children.forEach(child => {\n this.saveFilter(child, { selected: false });\n this.deselectDescendants(child);\n });\n }\n }\n\n /**\n * Selects all the ancestors of the given filter, saving them to the store.\n *\n * @remarks The ancestors hierarchy is retrieved from the store.\n * @param filter - The filter to select its ancestors.\n * @internal\n */\n protected selectAncestors(filter: HierarchicalFilter): void {\n if (filter.parentId) {\n const parent = this.getFilterById(filter.parentId);\n if (parent) {\n this.saveFilter(parent, { selected: true });\n this.selectAncestors(parent);\n }\n }\n }\n\n /**\n * Retrieves a hierarchical filter from the store by its id.\n *\n * @param id - The id of the filter to retrieve.\n * @returns The hierarchical filter retrieved from the store.\n * @internal\n */\n protected getFilterById(id: HierarchicalFilter['id']): HierarchicalFilter {\n return this.store.state.x.facets.filters[id] as HierarchicalFilter;\n }\n\n /**\n * Saves the given filter to the store.\n *\n * @param filter - The filter to save to the store.\n * @param newFilterState - The new partial state of the filter.\n * @internal\n */\n protected saveFilter(\n filter: HierarchicalFilter,\n newFilterState: Partial<HierarchicalFilter> = {}\n ): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState });\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;;;MAMa,wBAAwB;IAGnC,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;;;;;;IAO9D,QAAQ,CAAC,MAA0B;QACjC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACjC,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;KACvE;;;;;;IAOD,MAAM,CAAC,MAA0B;QAC/B,IAAI,CAAC,UAAU,CAAC,MAAM,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filter) {
19
- this.store.commit('x/facets/setFilter', { ...filter, selected: false });
19
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: false } });
20
20
  addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');
21
21
  }
22
22
  /**
@@ -25,7 +25,7 @@ class NumberRangeFilterEntity {
25
25
  * @param filter - The filter to select.
26
26
  */
27
27
  select(filter) {
28
- this.store.commit('x/facets/setFilter', { ...filter, selected: true });
28
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });
29
29
  addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"number-range-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/number-range-filter.entity.ts"],"sourcesContent":["import { Store } from 'vuex';\nimport { isNumberRangeFilter, NumberRangeFilter } from '@empathyco/x-types';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link NumberRangeFilter}.\n *\n * @internal\n */\nexport class NumberRangeFilterEntity implements FilterEntity {\n public static accepts = isNumberRangeFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects and saves to the store the given filter.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: NumberRangeFilter): void {\n this.store.commit('x/facets/setFilter', { ...filter, selected: false });\n addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');\n }\n\n /**\n * Selects and saves to the store the given filter.\n *\n * @param filter - The filter to select.\n */\n select(filter: NumberRangeFilter): void {\n this.store.commit('x/facets/setFilter', { ...filter, selected: true });\n addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;;MAKa,uBAAuB;IAGlC,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;;;;;;IAO9D,QAAQ,CAAC,MAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;KACtE;;;;;;IAOD,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;KACtE;;AAtBa,+BAAO,GAAG,mBAAmB;;;;"}
1
+ {"version":3,"file":"number-range-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/number-range-filter.entity.ts"],"sourcesContent":["import { Store } from 'vuex';\nimport { isNumberRangeFilter, NumberRangeFilter } from '@empathyco/x-types';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link NumberRangeFilter}.\n *\n * @internal\n */\nexport class NumberRangeFilterEntity implements FilterEntity {\n public static accepts = isNumberRangeFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects and saves to the store the given filter.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: NumberRangeFilter): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: false } });\n addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');\n }\n\n /**\n * Selects and saves to the store the given filter.\n *\n * @param filter - The filter to select.\n */\n select(filter: NumberRangeFilter): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });\n addFacetIfNotPresent(this.store, filter.facetId, 'NumberRangeFacet');\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;;MAKa,uBAAuB;IAGlC,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;;;;;;IAO9D,QAAQ,CAAC,MAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5F,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;KACtE;;;;;;IAOD,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3F,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;KACtE;;AAtBa,+BAAO,GAAG,mBAAmB;;;;"}
@@ -27,7 +27,7 @@ class RawFilterEntity {
27
27
  * there is no need to set this property.
28
28
  */
29
29
  select(filter) {
30
- this.store.commit('x/facets/setFilter', filter);
30
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });
31
31
  }
32
32
  }
33
33
  RawFilterEntity.accepts = isRawFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"raw-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/raw-filter.entity.ts"],"sourcesContent":["import { isRawFilter, RawFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @internal\n */\nexport class RawFilterEntity implements FilterEntity {\n public static accepts = isRawFilter;\n\n public constructor(protected store: Store<unknown>) {}\n\n /**\n * It deselects the {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @param filter - The filter to deselect.\n * @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,\n * the deselection just removes the filter from the store.\n */\n deselect(filter: RawFilter): void {\n this.store.commit('x/facets/removeFilter', filter);\n }\n\n /**\n * It selects the {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @param filter - The filter to select.\n * @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,\n * there is no need to set this property.\n */\n select(filter: RawFilter): void {\n this.store.commit('x/facets/setFilter', filter);\n }\n}\n"],"names":[],"mappings":";;AAIA;;;;;MAKa,eAAe;IAG1B,YAA6B,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;KAAI;;;;;;;;IAStD,QAAQ,CAAC,MAAiB;QACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;KACpD;;;;;;;;IASD,MAAM,CAAC,MAAiB;QACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;KACjD;;AAxBa,uBAAO,GAAG,WAAW;;;;"}
1
+ {"version":3,"file":"raw-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/raw-filter.entity.ts"],"sourcesContent":["import { isRawFilter, RawFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @internal\n */\nexport class RawFilterEntity implements FilterEntity {\n public static accepts = isRawFilter;\n\n public constructor(protected store: Store<unknown>) {}\n\n /**\n * It deselects the {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @param filter - The filter to deselect.\n * @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,\n * the deselection just removes the filter from the store.\n */\n deselect(filter: RawFilter): void {\n this.store.commit('x/facets/removeFilter', filter);\n }\n\n /**\n * It selects the {@link @empathyco/x-types#RawFilter | RawFilter}.\n *\n * @param filter - The filter to select.\n * @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,\n * there is no need to set this property.\n */\n select(filter: RawFilter): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });\n }\n}\n"],"names":[],"mappings":";;AAIA;;;;;MAKa,eAAe;IAG1B,YAA6B,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;KAAI;;;;;;;;IAStD,QAAQ,CAAC,MAAiB;QACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;KACpD;;;;;;;;IASD,MAAM,CAAC,MAAiB;QACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;KAC5F;;AAxBa,uBAAO,GAAG,WAAW;;;;"}
@@ -16,7 +16,7 @@ class SimpleFilterEntity {
16
16
  * @param filter - The filter to deselect.
17
17
  */
18
18
  deselect(filter) {
19
- this.store.commit('x/facets/setFilter', { ...filter, selected: false });
19
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: false } });
20
20
  addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');
21
21
  }
22
22
  /**
@@ -25,7 +25,7 @@ class SimpleFilterEntity {
25
25
  * @param filter - The filter to select.
26
26
  */
27
27
  select(filter) {
28
- this.store.commit('x/facets/setFilter', { ...filter, selected: true });
28
+ this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });
29
29
  addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"simple-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/simple-filter.entity.ts"],"sourcesContent":["import { SimpleFilter, isSimpleFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link SimpleFilter}.\n *\n * @internal\n */\nexport class SimpleFilterEntity implements FilterEntity {\n public static accepts = isSimpleFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects and saves to the store the given filter.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: SimpleFilter): void {\n this.store.commit('x/facets/setFilter', { ...filter, selected: false });\n addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');\n }\n\n /**\n * Selects and saves to the store the given filter.\n *\n * @param filter - The filter to select.\n */\n select(filter: SimpleFilter): void {\n this.store.commit('x/facets/setFilter', { ...filter, selected: true });\n addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;;MAKa,kBAAkB;IAG7B,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;;;;;;IAO9D,QAAQ,CAAC,MAAoB;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KACjE;;;;;;IAOD,MAAM,CAAC,MAAoB;QACzB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KACjE;;AAtBa,0BAAO,GAAG,cAAc;;;;"}
1
+ {"version":3,"file":"simple-filter.entity.js","sources":["../../../../../src/x-modules/facets/entities/simple-filter.entity.ts"],"sourcesContent":["import { SimpleFilter, isSimpleFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { RootXStoreState } from '../../../store/store.types';\nimport { addFacetIfNotPresent } from './add-facet-if-not-present';\nimport { FilterEntity } from './types';\n\n/**\n * Allows selecting and deselecting a filter of {@link SimpleFilter}.\n *\n * @internal\n */\nexport class SimpleFilterEntity implements FilterEntity {\n public static accepts = isSimpleFilter;\n\n public constructor(protected store: Store<RootXStoreState>) {}\n\n /**\n * Deselects and saves to the store the given filter.\n *\n * @param filter - The filter to deselect.\n */\n deselect(filter: SimpleFilter): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: false } });\n addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');\n }\n\n /**\n * Selects and saves to the store the given filter.\n *\n * @param filter - The filter to select.\n */\n select(filter: SimpleFilter): void {\n this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });\n addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;;MAKa,kBAAkB;IAG7B,YAA6B,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;KAAI;;;;;;IAO9D,QAAQ,CAAC,MAAoB;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5F,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KACjE;;;;;;IAOD,MAAM,CAAC,MAAoB;QACzB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3F,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KACjE;;AAtBa,0BAAO,GAAG,cAAc;;;;"}
@@ -68,7 +68,7 @@ class SingleSelectModifier extends BaseFilterEntityModifier {
68
68
  */
69
69
  getDescendantsIds(filter, ids = [filter.id]) {
70
70
  return filter?.children
71
- ? filter?.children.flatMap(descendantId => this.getAncestorsIds(this.store.state.x.facets.filters[descendantId], [descendantId, ...ids]))
71
+ ? filter?.children.flatMap(descendant => this.getDescendantsIds(descendant, [descendant.id, ...ids]))
72
72
  : ids;
73
73
  }
74
74
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"single-select.modifier.js","sources":["../../../../../src/x-modules/facets/entities/single-select.modifier.ts"],"sourcesContent":["import {\n isFacetFilter,\n isHierarchicalFilter,\n FacetFilter,\n Facet,\n Filter,\n HierarchicalFilter\n} from '@empathyco/x-types';\nimport { BaseFilterEntityModifier } from './types';\n\n/**\n * Allows only to select only one filter from the same facet at the same time.\n *\n * @internal\n */\nexport class SingleSelectModifier extends BaseFilterEntityModifier {\n /**\n * Selects the passed filter, and then deselects any other filter of the same facet.\n *\n * @param filter - The filter to select.\n */\n select(filter: FacetFilter): void {\n this.getOtherFilters(filter).forEach(this.deselect.bind(this));\n this.entity.select(filter);\n }\n\n /**\n * Retrieves the rest of selected filters of the same facet than the one given.\n *\n * @param filter - The filter to find its relatives.\n * @returns A list of selected filters that belong to the same facet than the filter passed.\n * @remarks It takes into account if the passed filter is an\n * {@link @empathyco/x-types#HierarchicalFilter | HierarchicalFilter} to exclude the ancestors and\n * descendants.\n *\n * @internal\n */\n protected getOtherFilters(filter: FacetFilter): FacetFilter[] {\n /* This check seems dumb, but when you instantiate this modifier using the factory, the types\n `FacetFilter` parameter type is lost, so we should check it to avoid unexpected crashes\n due to a wrong configuration. */\n if (isHierarchicalFilter(filter)) {\n const ancestorsIds = this.getAncestorsIds(filter);\n const descendantsIds = this.getDescendantsIds(filter);\n return this.getFacetFilters(filter.facetId).filter(\n storeFilter =>\n !ancestorsIds.includes(storeFilter.id) && !descendantsIds.includes(storeFilter.id)\n );\n } else if (isFacetFilter(filter)) {\n return this.getFacetFilters(filter.facetId).filter(\n storeFilter => storeFilter.id !== filter.id && storeFilter.selected\n );\n } else {\n // TODO Add a warning in case a non facet filter is passed here.\n return [];\n }\n }\n\n /**\n * Returns the ancestors Filters Ids of the passed filter.\n *\n * @param filter - The {@link @empathyco/x-types#Filter | Filter} which obtain the ancestors from.\n * @param ids - (Optional) an Array with the Ids used to execute the method recursively.\n * @returns An Array with the ancestors ids.\n * @internal\n */\n protected getAncestorsIds(\n filter: HierarchicalFilter,\n ids: Array<Filter['id']> = [filter.id]\n ): Array<Filter['id']> {\n return filter?.parentId\n ? this.getAncestorsIds(\n this.store.state.x.facets.filters[filter.parentId] as HierarchicalFilter,\n [filter.parentId, ...ids]\n )\n : ids;\n }\n\n /**\n * Returns the descendants Filters Ids of the passed filter.\n *\n * @param filter - The {@link @empathyco/x-types#Filter | Filter} which obtain the descendants\n * from.\n * @param ids - (Optional) an Array with the Ids used to execute the method recursively.\n * @returns An Array with the descendants ids.\n * @internal\n */\n protected getDescendantsIds(\n filter: HierarchicalFilter,\n ids: Array<Filter['id']> = [filter.id]\n ): Array<Filter['id']> {\n return filter?.children\n ? filter?.children.flatMap(descendantId =>\n this.getAncestorsIds(\n this.store.state.x.facets.filters[descendantId] as HierarchicalFilter,\n [descendantId, ...ids]\n )\n )\n : ids;\n }\n\n /**\n * Retrieves All the filters from the given facet.\n *\n * @param facetId - The facet id to retrieve its filters.\n * @returns The filters from the given facet.\n * @internal\n */\n protected getFacetFilters(facetId: Facet['id']): FacetFilter[] {\n return (\n ((this.store.getters['x/facets/facets'] as Record<Facet['id'], Facet>)[facetId]\n ?.filters as FacetFilter[]) ?? []\n );\n }\n}\n"],"names":[],"mappings":";;;AAUA;;;;;MAKa,oBAAqB,SAAQ,wBAAwB;;;;;;IAMhE,MAAM,CAAC,MAAmB;QACxB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC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EtC,OAAO,MAAM,EAAE,QAAQ;cACnB,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IACnC,IAAI,CAAC,eAAe,CAClB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAuB,EACrE,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,CACvB,CACF;cACD,GAAG,CAAC;KACT;;;;;;;;IASS,eAAe,CAAC,OAAoB;QAC5C,QACI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAgC,CAAC,OAAO,CAAC;cAC3E,OAAyB,IAAI,EAAE,EACnC;KACH;;;;;"}
1
+ {"version":3,"file":"single-select.modifier.js","sources":["../../../../../src/x-modules/facets/entities/single-select.modifier.ts"],"sourcesContent":["import {\n isFacetFilter,\n isHierarchicalFilter,\n FacetFilter,\n Facet,\n Filter,\n HierarchicalFilter\n} from '@empathyco/x-types';\nimport { BaseFilterEntityModifier } from './types';\n\n/**\n * Allows only to select only one filter from the same facet at the same time.\n *\n * @internal\n */\nexport class SingleSelectModifier extends BaseFilterEntityModifier {\n /**\n * Selects the passed filter, and then deselects any other filter of the same facet.\n *\n * @param filter - The filter to select.\n */\n select(filter: FacetFilter): void {\n this.getOtherFilters(filter).forEach(this.deselect.bind(this));\n this.entity.select(filter);\n }\n\n /**\n * Retrieves the rest of selected filters of the same facet than the one given.\n *\n * @param filter - The filter to find its relatives.\n * @returns A list of selected filters that belong to the same facet than the filter passed.\n * @remarks It takes into account if the passed filter is an\n * {@link @empathyco/x-types#HierarchicalFilter | HierarchicalFilter} to exclude the ancestors and\n * descendants.\n *\n * @internal\n */\n protected getOtherFilters(filter: FacetFilter): FacetFilter[] {\n /* This check seems dumb, but when you instantiate this modifier using the factory, the types\n `FacetFilter` parameter type is lost, so we should check it to avoid unexpected crashes\n due to a wrong configuration. */\n if (isHierarchicalFilter(filter)) {\n const ancestorsIds = this.getAncestorsIds(filter);\n const descendantsIds = this.getDescendantsIds(filter);\n return this.getFacetFilters(filter.facetId).filter(\n storeFilter =>\n !ancestorsIds.includes(storeFilter.id) && !descendantsIds.includes(storeFilter.id)\n );\n } else if (isFacetFilter(filter)) {\n return this.getFacetFilters(filter.facetId).filter(\n storeFilter => storeFilter.id !== filter.id && storeFilter.selected\n );\n } else {\n // TODO Add a warning in case a non facet filter is passed here.\n return [];\n }\n }\n\n /**\n * Returns the ancestors Filters Ids of the passed filter.\n *\n * @param filter - The {@link @empathyco/x-types#Filter | Filter} which obtain the ancestors from.\n * @param ids - (Optional) an Array with the Ids used to execute the method recursively.\n * @returns An Array with the ancestors ids.\n * @internal\n */\n protected getAncestorsIds(\n filter: HierarchicalFilter,\n ids: Array<Filter['id']> = [filter.id]\n ): Array<Filter['id']> {\n return filter?.parentId\n ? this.getAncestorsIds(\n this.store.state.x.facets.filters[filter.parentId] as HierarchicalFilter,\n [filter.parentId, ...ids]\n )\n : ids;\n }\n\n /**\n * Returns the descendants Filters Ids of the passed filter.\n *\n * @param filter - The {@link @empathyco/x-types#Filter | Filter} which obtain the descendants\n * from.\n * @param ids - (Optional) an Array with the Ids used to execute the method recursively.\n * @returns An Array with the descendants ids.\n * @internal\n */\n protected getDescendantsIds(\n filter: HierarchicalFilter,\n ids: Array<Filter['id']> = [filter.id]\n ): Array<Filter['id']> {\n return filter?.children\n ? filter?.children.flatMap(descendant =>\n this.getDescendantsIds(descendant, [descendant.id, ...ids])\n )\n : ids;\n }\n\n /**\n * Retrieves All the filters from the given facet.\n *\n * @param facetId - The facet id to retrieve its filters.\n * @returns The filters from the given facet.\n * @internal\n */\n protected getFacetFilters(facetId: Facet['id']): FacetFilter[] {\n return (\n ((this.store.getters['x/facets/facets'] as Record<Facet['id'], Facet>)[facetId]\n ?.filters as FacetFilter[]) ?? []\n );\n }\n}\n"],"names":[],"mappings":";;;AAUA;;;;;MAKa,oBAAqB,SAAQ,wBAAwB;;;;;;IAMhE,MAAM,CAAC,MAAmB;QACxB,I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iB,CACzB,MAA0B,EAC1B,MAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;QAEtC,OAAO,MAAM,EAAE,QAAQ;cACnB,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,IACjC,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,CAC5D;cACD,GAAG,CAAC;KACT;;;;;;;;IASS,eAAe,CAAC,OAAoB;QAC5C,QACI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAgC,CAAC,OAAO,CAAC;cAC3E,OAAyB,IAAI,EAAE,EACnC;KACH;;;;;"}
@@ -1,9 +1,10 @@
1
- import { isFacetFilter } from '@empathyco/x-types';
1
+ import { isFacetFilter, isHierarchicalFacet } from '@empathyco/x-types';
2
2
  import '../../../plugins/x-bus.js';
3
3
  import { XPlugin } from '../../../plugins/x-plugin.js';
4
4
  import { isArrayEmpty, arrayToObject, groupItemsBy } from '../../../utils/array.js';
5
5
  import '../../../utils/storage.js';
6
6
  import { FilterEntityFactory } from '../entities/filter-entity.factory.js';
7
+ import { flatHierarchicalFilters } from '../utils.js';
7
8
 
8
9
  /**
9
10
  * Default implementation for the {@link FacetsService}.
@@ -85,10 +86,25 @@ class DefaultFacetsService {
85
86
  this.setFacetGroup({ facetId: facet.id, groupId: facetsGroup.id });
86
87
  this.setFacet(facet);
87
88
  });
88
- const newFilters = facetsGroup.facets.flatMap(facet => facet.filters);
89
+ const newFilters = this.flatFilters(facetsGroup);
89
90
  this.setFilters(newFilters);
90
91
  return newFilters;
91
92
  }
93
+ /**
94
+ * This function returns the filters of the facets group flattened in an array. It keeps the
95
+ * relations between the filters (parent--children).
96
+ *
97
+ * @privateRemarks If it is necessary to deal with more cases than the hierarchical, we need to
98
+ * refactor this logic and maybe move it to the entities, to not make this service dependant of
99
+ * the facet type. At the moment it is only one `if`, and is ok as long as no more `if`s are
100
+ * needed.
101
+ * @param facetsGroup - The facets group from where extract the filters to flat.
102
+ * @returns An array with the filters flattened.
103
+ * @internal
104
+ */
105
+ flatFilters(facetsGroup) {
106
+ return facetsGroup.facets.flatMap(facet => isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters);
107
+ }
92
108
  /**
93
109
  * Retrieves the selected filters from the store.
94
110
  *
@@ -1 +1 @@
1
- {"version":3,"file":"facets.service.js","sources":["../../../../../src/x-modules/facets/service/facets.service.ts"],"sourcesContent":["import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { XPlugin } from '../../../plugins/index';\nimport { RootXStoreState } from '../../../store/index';\nimport { arrayToObject, groupItemsBy, isArrayEmpty } from '../../../utils/index';\nimport { FilterEntityFactory } from '../entities/filter-entity.factory';\nimport { FilterEntity } from '../entities/types';\nimport { FacetGroupEntry, FacetsGetters } from '../store/types';\nimport { FacetsGroup, FacetsService } from './types';\n\n/**\n * Default implementation for the {@link FacetsService}.\n *\n * @public\n */\nexport class DefaultFacetsService implements FacetsService {\n /**\n * Global instance of the {@link FacetsService}.\n */\n public static instance: FacetsService = new DefaultFacetsService();\n\n public constructor(\n protected filterEntityFactory: FilterEntityFactory = FilterEntityFactory.instance\n ) {}\n\n /**\n * The {@link https://vuex.vuejs.org/ | Vuex} store to use in the service.\n *\n * @returns The store.\n * @internal\n */\n protected get store(): Store<RootXStoreState> {\n return XPlugin.store;\n }\n\n setFacets(facetsGroup: FacetsGroup): void {\n const newFilters = this.updateStore(facetsGroup);\n /* Ensures that filters are selected with valid values. For example, you can't set a single\n select facet with 2 or more selected filters */\n this.updateFiltersSelectedState(newFilters);\n }\n\n updateFacets(facetsGroup: FacetsGroup): void {\n const selectedFilters = this.getSelectedFilters();\n const newFilters = this.updateStore(facetsGroup);\n this.updateFiltersSelectedState(newFilters, selectedFilters);\n }\n\n updatePreselectedFilters(filters: Filter[]): void {\n this.setPreselectedFilter(filters);\n }\n\n selectPreselectedFilters(): void {\n this.select(this.store.state.x.facets.preselectedFilters);\n }\n\n clearFilters(facetIds?: Array<Facet['id']>): void {\n this.getSelectedFilters()\n .filter(filter => !facetIds || (isFacetFilter(filter) && facetIds.includes(filter.facetId)))\n .forEach(this.deselect.bind(this));\n }\n\n deselect(filter: Filter): void {\n this.getFilterEntity(filter).deselect(filter);\n }\n\n select(filterOrFilters: Filter | Filter[]): void {\n const filters = Array.isArray(filterOrFilters) ? filterOrFilters : [filterOrFilters];\n filters.forEach(filter => this.getFilterEntity(filter).select(filter));\n }\n\n toggle(filter: Filter): void {\n if (filter.selected) {\n this.deselect(filter);\n } else {\n this.select(filter);\n }\n }\n\n /**\n * Creates an entity from a filter DTO.\n *\n * @param filter - The filter to create an entity from.\n * @returns The filter entity.\n * @internal\n */\n protected getFilterEntity(filter: Filter): FilterEntity {\n return this.filterEntityFactory.getFilterEntity(this.store, filter);\n }\n\n /**\n * Sets in the store the Facets, the Filters and the FacetsGroup, without applying any logic\n * to the selected state.\n *\n * @param facetsGroup - The {@link FacetsGroup} to set into the store state.\n * @returns An array with the new filters.\n * @internal\n */\n protected updateStore(facetsGroup: FacetsGroup): Filter[] {\n this.removeGroupFacets(facetsGroup.id);\n this.removeGroupFilters(facetsGroup.id);\n facetsGroup.facets.forEach(facet => {\n this.setFacetGroup({ facetId: facet.id, groupId: facetsGroup.id });\n this.setFacet(facet);\n });\n const newFilters = facetsGroup.facets.flatMap(facet => facet.filters);\n this.setFilters(newFilters);\n return newFilters;\n }\n\n /**\n * Retrieves the selected filters from the store.\n *\n * @returns The list of selected filters of the store.\n * @internal\n */\n protected getSelectedFilters(): FacetsGetters['selectedFilters'] {\n return this.store.getters['x/facets/selectedFilters'];\n }\n\n /**\n * Changes the filters selection state to match the store.\n *\n * @param newFilters - The list of filters to save.\n * @param previousFilters - (Optional) The list of old filters, used to set the `newFilters`\n * selected state.\n */\n protected updateFiltersSelectedState(newFilters: Filter[], previousFilters?: Filter[]): void {\n if (!isArrayEmpty(newFilters)) {\n const newStateFiltersMap = arrayToObject(previousFilters ?? newFilters, 'id');\n newFilters.forEach(filter => {\n const filterEntity = this.getFilterEntity(filter);\n if (newStateFiltersMap[filter.id]?.selected) {\n filterEntity.select(filter);\n } else {\n filterEntity.deselect(filter);\n }\n });\n }\n }\n\n /**\n * Removes the filters that belong to the given group.\n *\n * @param groupId - The id of the group from whom remove the filters that are in the store.\n *\n * @returns The removed filters.\n *\n * @internal\n */\n protected removeGroupFilters(groupId: FacetsGroup['id']): Filter[] {\n const filtersToRemove =\n groupItemsBy(Object.values(this.store.state.x.facets.filters), filter =>\n isFacetFilter(filter)\n ? this.store.state.x.facets.groups[filter.facetId]\n : '__unknown-group__'\n )[groupId] ?? [];\n this.removeFilters(filtersToRemove);\n return filtersToRemove;\n }\n /**\n * Removes the facets that belong to the given group.\n *\n * @param groupId - The id of the group from whom remove the facets that are in the store.\n * @returns The removed facets.\n * @internal\n */\n protected removeGroupFacets(groupId: FacetsGroup['id']): Omit<Facet, 'filters'>[] {\n const facetsToRemove = Object.values(this.store.state.x.facets.facets).filter(\n facet => this.store.state.x.facets.groups[facet.id] === groupId\n );\n facetsToRemove.forEach(this.removeFacet.bind(this));\n return facetsToRemove;\n }\n\n /**\n * Sets the group that a facet belongs to.\n *\n * @param facetGroup - The id of the facet, and the group it belongs to.\n * @internal\n */\n protected setFacetGroup(facetGroup: FacetGroupEntry): void {\n this.store.commit('x/facets/setFacetGroup', facetGroup);\n }\n\n /**\n * Sets the Facet to the store facets record.\n *\n * @param facet - The facet to store.\n *\n * @internal\n */\n protected setFacet({ filters, ...restFacet }: Facet): void {\n this.store.commit('x/facets/setFacet', restFacet);\n }\n\n /**\n * Removes a facet from the store.\n *\n * @param facet - The facet to remove.\n * @internal\n */\n protected removeFacet(facet: Omit<Facet, 'filters'>): void {\n this.store.commit('x/facets/removeFacet', facet);\n }\n\n /**\n * Saves a list of filters to the store without any state change logic applied.\n *\n * @param filters - The filters to save.\n * @internal\n */\n protected setFilters(filters: Filter[]): void {\n this.store.commit('x/facets/setFilters', filters);\n }\n\n /**\n * Saves a list of preselected filters to the store without any state change logic applied.\n *\n * @param filters - The filters to save.\n * @internal\n */\n protected setPreselectedFilter(filters: Filter[]): void {\n this.store.commit('x/facets/setPreselectedFilters', filters);\n }\n\n /**\n * Removes a list of filters from the store.\n *\n * @param filters - The filters to remove.\n * @internal\n */\n protected removeFilters(filters: Filter[]): void {\n this.store.commit('x/facets/removeFilters', filters);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAUA;;;;;MAKa,oBAAoB;IAM/B,YACY,sBAA2C,mBAAmB,CAAC,QAAQ;QAAvE,wBAAmB,GAAnB,mBAAmB,CAAoD;KAC/E;;;;;;;IAQJ,IAAc,KAAK;QACjB,OAAO,OAAO,CAAC,KAAK,CAAC;KACtB;IAED,SAAS,CAAC,WAAwB;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;;;QAGjD,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;KAC7C;IAED,YAAY,CAAC,WAAwB;QACnC,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;KAC9D;IAED,wBAAwB,CAAC,OAAiB;QACxC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;KACpC;IAED,wBAAwB;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;KAC3D;IAED,YAAY,CAAC,QAA6B;QACxC,IAAI,CAAC,kBAAkB,EAAE;aACtB,MAAM,CAAC,MAAM,IAAI,CAAC,QAAQ,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC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Content":["import { Facet, Filter, isFacetFilter, isHierarchicalFacet } from '@empathyco/x-types';\nimport { Store } from 'vuex';\nimport { XPlugin } from '../../../plugins/index';\nimport { RootXStoreState } from '../../../store/index';\nimport { arrayToObject, groupItemsBy, isArrayEmpty } from '../../../utils/index';\nimport { FilterEntityFactory } from '../entities/filter-entity.factory';\nimport { FilterEntity } from '../entities/types';\nimport { FacetGroupEntry, FacetsGetters } from '../store/types';\nimport { flatHierarchicalFilters } from '../utils';\nimport { FacetsGroup, FacetsService } from './types';\n\n/**\n * Default implementation for the {@link FacetsService}.\n *\n * @public\n */\nexport class DefaultFacetsService implements FacetsService {\n /**\n * Global instance of the {@link FacetsService}.\n */\n public static instance: FacetsService = new DefaultFacetsService();\n\n public constructor(\n protected filterEntityFactory: FilterEntityFactory = FilterEntityFactory.instance\n ) {}\n\n /**\n * The {@link https://vuex.vuejs.org/ | Vuex} store to use in the service.\n *\n * @returns The store.\n * @internal\n */\n protected get store(): Store<RootXStoreState> {\n return XPlugin.store;\n }\n\n setFacets(facetsGroup: FacetsGroup): void {\n const newFilters = this.updateStore(facetsGroup);\n /* Ensures that filters are selected with valid values. For example, you can't set a single\n select facet with 2 or more selected filters */\n this.updateFiltersSelectedState(newFilters);\n }\n\n updateFacets(facetsGroup: FacetsGroup): void {\n const selectedFilters = this.getSelectedFilters();\n const newFilters = this.updateStore(facetsGroup);\n this.updateFiltersSelectedState(newFilters, selectedFilters);\n }\n\n updatePreselectedFilters(filters: Filter[]): void {\n this.setPreselectedFilter(filters);\n }\n\n selectPreselectedFilters(): void {\n this.select(this.store.state.x.facets.preselectedFilters);\n }\n\n clearFilters(facetIds?: Array<Facet['id']>): void {\n this.getSelectedFilters()\n .filter(filter => !facetIds || (isFacetFilter(filter) && facetIds.includes(filter.facetId)))\n .forEach(this.deselect.bind(this));\n }\n\n deselect(filter: Filter): void {\n this.getFilterEntity(filter).deselect(filter);\n }\n\n select(filterOrFilters: Filter | Filter[]): void {\n const filters = Array.isArray(filterOrFilters) ? filterOrFilters : [filterOrFilters];\n filters.forEach(filter => this.getFilterEntity(filter).select(filter));\n }\n\n toggle(filter: Filter): void {\n if (filter.selected) {\n this.deselect(filter);\n } else {\n this.select(filter);\n }\n }\n\n /**\n * Creates an entity from a filter DTO.\n *\n * @param filter - The filter to create an entity from.\n * @returns The filter entity.\n * @internal\n */\n protected getFilterEntity(filter: Filter): FilterEntity {\n return this.filterEntityFactory.getFilterEntity(this.store, filter);\n }\n\n /**\n * Sets in the store the Facets, the Filters and the FacetsGroup, without applying any logic\n * to the selected state.\n *\n * @param facetsGroup - The {@link FacetsGroup} to set into the store state.\n * @returns An array with the new filters.\n * @internal\n */\n protected updateStore(facetsGroup: FacetsGroup): Filter[] {\n this.removeGroupFacets(facetsGroup.id);\n this.removeGroupFilters(facetsGroup.id);\n facetsGroup.facets.forEach(facet => {\n this.setFacetGroup({ facetId: facet.id, groupId: facetsGroup.id });\n this.setFacet(facet);\n });\n const newFilters = this.flatFilters(facetsGroup);\n this.setFilters(newFilters);\n return newFilters;\n }\n\n /**\n * This function returns the filters of the facets group flattened in an array. It keeps the\n * relations between the filters (parent--children).\n *\n * @privateRemarks If it is necessary to deal with more cases than the hierarchical, we need to\n * refactor this logic and maybe move it to the entities, to not make this service dependant of\n * the facet type. At the moment it is only one `if`, and is ok as long as no more `if`s are\n * needed.\n * @param facetsGroup - The facets group from where extract the filters to flat.\n * @returns An array with the filters flattened.\n * @internal\n */\n protected flatFilters(facetsGroup: FacetsGroup): Filter[] {\n return facetsGroup.facets.flatMap(facet =>\n isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters\n );\n }\n\n /**\n * Retrieves the selected filters from the store.\n *\n * @returns The list of selected filters of the store.\n * @internal\n */\n protected getSelectedFilters(): FacetsGetters['selectedFilters'] {\n return this.store.getters['x/facets/selectedFilters'];\n }\n\n /**\n * Changes the filters selection state to match the store.\n *\n * @param newFilters - The list of filters to save.\n * @param previousFilters - (Optional) The list of old filters, used to set the `newFilters`\n * selected state.\n */\n protected updateFiltersSelectedState(newFilters: Filter[], previousFilters?: Filter[]): void {\n if (!isArrayEmpty(newFilters)) {\n const newStateFiltersMap = arrayToObject(previousFilters ?? newFilters, 'id');\n newFilters.forEach(filter => {\n const filterEntity = this.getFilterEntity(filter);\n if (newStateFiltersMap[filter.id]?.selected) {\n filterEntity.select(filter);\n } else {\n filterEntity.deselect(filter);\n }\n });\n }\n }\n\n /**\n * Removes the filters that belong to the given group.\n *\n * @param groupId - The id of the group from whom remove the filters that are in the store.\n *\n * @returns The removed filters.\n *\n * @internal\n */\n protected removeGroupFilters(groupId: FacetsGroup['id']): Filter[] {\n const filtersToRemove =\n groupItemsBy(Object.values(this.store.state.x.facets.filters), filter =>\n isFacetFilter(filter)\n ? this.store.state.x.facets.groups[filter.facetId]\n : '__unknown-group__'\n )[groupId] ?? [];\n this.removeFilters(filtersToRemove);\n return filtersToRemove;\n }\n\n /**\n * Removes the facets that belong to the given group.\n *\n * @param groupId - The id of the group from whom remove the facets that are in the store.\n * @returns The removed facets.\n * @internal\n */\n protected removeGroupFacets(groupId: FacetsGroup['id']): Omit<Facet, 'filters'>[] {\n const facetsToRemove = Object.values(this.store.state.x.facets.facets).filter(\n facet => this.store.state.x.facets.groups[facet.id] === groupId\n );\n facetsToRemove.forEach(this.removeFacet.bind(this));\n return facetsToRemove;\n }\n\n /**\n * Sets the group that a facet belongs to.\n *\n * @param facetGroup - The id of the facet, and the group it belongs to.\n * @internal\n */\n protected setFacetGroup(facetGroup: FacetGroupEntry): void {\n this.store.commit('x/facets/setFacetGroup', facetGroup);\n }\n\n /**\n * Sets the Facet to the store facets record.\n *\n * @param facet - The facet to store.\n *\n * @internal\n */\n protected setFacet({ filters, ...restFacet }: Facet): void {\n this.store.commit('x/facets/setFacet', restFacet);\n }\n\n /**\n * Removes a facet from the store.\n *\n * @param facet - The facet to remove.\n * @internal\n */\n protected removeFacet(facet: Omit<Facet, 'filters'>): void {\n this.store.commit('x/facets/removeFacet', facet);\n }\n\n /**\n * Saves a list of filters to the store without any state change logic applied.\n *\n * @param filters - The filters to save.\n * @internal\n */\n protected setFilters(filters: Filter[]): void {\n this.store.commit('x/facets/setFilters', filters);\n }\n\n /**\n * Saves a list of preselected filters to the store without any state change logic applied.\n *\n * @param filters - The filters to save.\n * @internal\n */\n protected setPreselectedFilter(filters: Filter[]): void {\n this.store.commit('x/facets/setPreselectedFilters', filters);\n }\n\n /**\n * Removes a list of filters from the store.\n *\n * @param filters - The filters to remove.\n * @internal\n */\n protected removeFilters(filters: Filter[]): void {\n this.store.commit('x/facets/removeFilters', filters);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAWA;;;;;MAKa,oBAAoB;IAM/B,YACY,sBAA2C,mBAAmB,CAAC,QAAQ;QAAvE,wBAAmB,GAAnB,mBAAmB,CAAoD;KAC/E;;;;;;;IAQJ,IAAc,KAAK;QACjB,OAAO,OAAO,CAAC,KAAK,CAAC;KACtB;IAED,SAAS,CAAC,WAAwB;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;;;QAGjD,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;KAC7C;IAED,YAAY,CAAC,WAAwB;QACnC,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;KAC9D;IAED,wBAAwB,CAAC,OAAiB;QACxC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;KACpC;IAED,wBAAwB;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;KAC3D;IAED,YAAY,CAAC,QAA6B;QACxC,IAAI,CAAC,kBAAkB,EAAE;aAC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AAgC,EAAE,OAAO,CAAC,CAAC;KAC9D;;;;;;;IAQS,aAAa,CAAC,OAAiB;QACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;KACtD;;AA7OD;;;AAGc,6BAAQ,GAAkB,IAAI,oBAAoB,EAAE;;;;"}
@@ -21,11 +21,12 @@ const facetsXStoreModule = {
21
21
  facets
22
22
  },
23
23
  mutations: {
24
- setFilter(state, filter) {
25
- Vue.set(state.filters, filter.id, Object.freeze(filter));
24
+ mutateFilter(state, { filter, newFilterState }) {
25
+ const newFilter = Object.assign(filter, newFilterState);
26
+ Vue.set(state.filters, newFilter.id, newFilter);
26
27
  },
27
28
  setFilters(state, filters) {
28
- filters.forEach(filter => Vue.set(state.filters, filter.id, Object.freeze(filter)));
29
+ filters.forEach(filter => Vue.set(state.filters, filter.id, filter));
29
30
  },
30
31
  setPreselectedFilters(state, filters) {
31
32
  state.preselectedFilters = filters;