@empathyco/x-components 3.0.0-alpha.146 → 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.
- package/CHANGELOG.md +19 -0
- package/design-system/default-theme.css +73 -73
- package/design-system/full-theme.css +4 -5
- package/docs/API-reference/api/x-adapter-platform.md +0 -1
- package/docs/API-reference/api/x-adapter-platform.searchresponsemapper.md +1 -11
- package/docs/API-reference/api/x-components.facetsmutations.md +1 -1
- package/docs/API-reference/api/x-components.facetsmutations.mutatefilter.md +24 -0
- package/docs/API-reference/api/x-components.flathierarchicalfilters.md +26 -0
- package/docs/API-reference/api/x-components.md +2 -0
- package/docs/API-reference/api/x-components.mutatefilterpayload.filter.md +13 -0
- package/docs/API-reference/api/x-components.mutatefilterpayload.md +21 -0
- package/docs/API-reference/api/x-components.mutatefilterpayload.newfilterstate.md +13 -0
- package/docs/API-reference/api/x-types.hierarchicalfilter.children.md +2 -2
- package/docs/API-reference/api/x-types.hierarchicalfilter.md +2 -2
- package/docs/API-reference/api/x-types.hierarchicalfilter.parentid.md +1 -1
- package/facets/index.js +1 -1
- package/js/index.js +1 -1
- package/js/x-modules/facets/components/facets/facets-provider.vue.js +2 -2
- package/js/x-modules/facets/components/facets/facets-provider.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js +7 -2
- package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue_rollup-plugin-vue_script.vue.js +2 -130
- package/js/x-modules/facets/components/filters/hierarchical-filter.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/facets/entities/editable-number-range-filter.entity.js +11 -10
- package/js/x-modules/facets/entities/editable-number-range-filter.entity.js.map +1 -1
- package/js/x-modules/facets/entities/hierarchical-filter.entity.js +9 -11
- package/js/x-modules/facets/entities/hierarchical-filter.entity.js.map +1 -1
- package/js/x-modules/facets/entities/number-range-filter.entity.js +2 -2
- package/js/x-modules/facets/entities/number-range-filter.entity.js.map +1 -1
- package/js/x-modules/facets/entities/raw-filter.entity.js +1 -1
- package/js/x-modules/facets/entities/raw-filter.entity.js.map +1 -1
- package/js/x-modules/facets/entities/simple-filter.entity.js +2 -2
- package/js/x-modules/facets/entities/simple-filter.entity.js.map +1 -1
- package/js/x-modules/facets/entities/single-select.modifier.js +1 -1
- package/js/x-modules/facets/entities/single-select.modifier.js.map +1 -1
- package/js/x-modules/facets/service/facets.service.js +18 -2
- package/js/x-modules/facets/service/facets.service.js.map +1 -1
- package/js/x-modules/facets/store/module.js +4 -3
- package/js/x-modules/facets/store/module.js.map +1 -1
- package/js/x-modules/facets/utils.js +16 -1
- package/js/x-modules/facets/utils.js.map +1 -1
- package/js/x-modules/search-box/components/search-input.vue.js +54 -45
- package/js/x-modules/search-box/components/search-input.vue.js.map +1 -1
- package/js/x-modules/search-box/components/search-input.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/package.json +4 -4
- package/report/x-adapter-platform.api.json +5 -133
- package/report/x-components.api.json +181 -45
- package/report/x-components.api.md +14 -5
- package/report/x-types.api.json +5 -5
- package/types/x-modules/facets/components/facets/facets-provider.vue.d.ts.map +1 -1
- package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +0 -6
- package/types/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
- package/types/x-modules/facets/entities/editable-number-range-filter.entity.d.ts +1 -1
- package/types/x-modules/facets/entities/editable-number-range-filter.entity.d.ts.map +1 -1
- package/types/x-modules/facets/entities/hierarchical-filter.entity.d.ts +2 -1
- package/types/x-modules/facets/entities/hierarchical-filter.entity.d.ts.map +1 -1
- package/types/x-modules/facets/entities/single-select.modifier.d.ts.map +1 -1
- package/types/x-modules/facets/service/facets.service.d.ts +13 -0
- package/types/x-modules/facets/service/facets.service.d.ts.map +1 -1
- package/types/x-modules/facets/store/module.d.ts.map +1 -1
- package/types/x-modules/facets/store/types.d.ts +22 -6
- package/types/x-modules/facets/store/types.d.ts.map +1 -1
- package/types/x-modules/facets/utils.d.ts +11 -0
- package/types/x-modules/facets/utils.d.ts.map +1 -1
- package/types/x-modules/search-box/components/search-input.vue.d.ts.map +1 -1
- package/docs/API-reference/api/x-adapter-platform.searchresponsefacetsmapper.md +0 -27
- package/docs/API-reference/api/x-components.facetsmutations.setfilter.md +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.0-alpha.147](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.146...@empathyco/x-components@3.0.0-alpha.147) (2022-08-03)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- **facets:** Removed the `setFilter`mutation from `facets` X-Module. Use `mutateFilter` instead.
|
|
11
|
+
- **facets:** Modified the `HierarchicalFilter.children` Model type. Now it is an
|
|
12
|
+
`Array<HierarchicalFilter>` instead of an array of ids.
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **facets:** Move filters flattening from `x-adapter-platform` to `x-components`. (#626)
|
|
17
|
+
([2bebaeb](https://github.com/empathyco/x/commit/2bebaeb2863fe794f1b3bea924904651b9302ef6)),
|
|
18
|
+
closes [EX-6484](https://searchbroker.atlassian.net/browse/EX-6484)
|
|
19
|
+
|
|
20
|
+
# Change Log
|
|
21
|
+
|
|
22
|
+
All notable changes to this project will be documented in this file. See
|
|
23
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
24
|
+
|
|
6
25
|
## [3.0.0-alpha.146](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.145...@empathyco/x-components@3.0.0-alpha.146) (2022-08-03)
|
|
7
26
|
|
|
8
27
|
### Documentation
|
|
@@ -407,6 +407,79 @@
|
|
|
407
407
|
[dir="rtl"] .x-dropdown--right .x-dropdown__items-list {
|
|
408
408
|
left: 0;
|
|
409
409
|
}
|
|
410
|
+
:root {
|
|
411
|
+
--x-size-border-radius-dropdown-default: var(--x-size-border-radius-base-none);
|
|
412
|
+
--x-size-border-radius-top-left-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
413
|
+
--x-size-border-radius-top-right-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
414
|
+
--x-size-border-radius-bottom-right-dropdown-default: var(
|
|
415
|
+
--x-size-border-radius-dropdown-default
|
|
416
|
+
);
|
|
417
|
+
--x-size-border-radius-bottom-left-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
418
|
+
--x-size-border-width-dropdown-toggle-default: var(--x-size-border-width-base);
|
|
419
|
+
--x-size-border-width-top-dropdown-toggle-default: var(
|
|
420
|
+
--x-size-border-width-dropdown-toggle-default
|
|
421
|
+
);
|
|
422
|
+
--x-size-border-width-right-dropdown-toggle-default: var(
|
|
423
|
+
--x-size-border-width-dropdown-toggle-default
|
|
424
|
+
);
|
|
425
|
+
--x-size-border-width-bottom-dropdown-toggle-default: var(
|
|
426
|
+
--x-size-border-width-dropdown-toggle-default
|
|
427
|
+
);
|
|
428
|
+
--x-size-border-width-left-dropdown-toggle-default: var(
|
|
429
|
+
--x-size-border-width-dropdown-toggle-default
|
|
430
|
+
);
|
|
431
|
+
--x-size-border-width-dropdown-list-default: var(--x-size-border-width-base);
|
|
432
|
+
--x-size-border-width-top-dropdown-list-default: 0;
|
|
433
|
+
--x-size-border-width-right-dropdown-list-default: var(
|
|
434
|
+
--x-size-border-width-dropdown-list-default
|
|
435
|
+
);
|
|
436
|
+
--x-size-border-width-bottom-dropdown-list-default: var(
|
|
437
|
+
--x-size-border-width-dropdown-list-default
|
|
438
|
+
);
|
|
439
|
+
--x-size-border-width-left-dropdown-list-default: var(
|
|
440
|
+
--x-size-border-width-dropdown-list-default
|
|
441
|
+
);
|
|
442
|
+
--x-color-border-dropdown-toggle-default: var(--x-color-base-neutral-95);
|
|
443
|
+
--x-color-border-dropdown-list-default: var(--x-color-border-dropdown-toggle-default);
|
|
444
|
+
--x-color-background-dropdown-default: var(--x-color-base-neutral-100);
|
|
445
|
+
--x-color-background-dropdown-toggle-default: var(--x-color-base-neutral-100);
|
|
446
|
+
--x-color-background-dropdown-toggle-open-default: var(
|
|
447
|
+
--x-color-background-dropdown-toggle-default
|
|
448
|
+
);
|
|
449
|
+
--x-color-background-dropdown-item-default-selected: var(--x-color-base-neutral-95);
|
|
450
|
+
--x-color-background-dropdown-item-default-hover: var(--x-color-base-neutral-95);
|
|
451
|
+
--x-color-text-dropdown-default: var(--x-color-text-default);
|
|
452
|
+
--x-color-text-dropdown-toggle-default: var(--x-color-text-dropdown-default);
|
|
453
|
+
--x-color-text-dropdown-toggle-default-selected: var(--x-color-base-neutral-35);
|
|
454
|
+
--x-color-text-dropdown-item-default-hover: var(--x-color-base-neutral-35);
|
|
455
|
+
--x-color-text-dropdown-item-default-selected: var(--x-color-text-default);
|
|
456
|
+
--x-font-family-dropdown-default: var(--x-font-family-text);
|
|
457
|
+
--x-size-font-dropdown-default: var(--x-size-font-text);
|
|
458
|
+
--x-size-line-height-dropdown-default: var(--x-size-line-height-text);
|
|
459
|
+
--x-number-font-weight-dropdown-default: var(--x-number-font-weight-base-regular);
|
|
460
|
+
--x-number-font-weight-dropdown-item-default-hover: var(--x-number-font-weight-base-bold);
|
|
461
|
+
--x-number-font-weight-dropdown-item-default-selected: var(--x-number-font-weight-base-regular);
|
|
462
|
+
--x-font-decoration-dropdown-item-default-hover: none;
|
|
463
|
+
--x-font-decoration-dropdown-item-default-selected: none;
|
|
464
|
+
--x-size-width-dropdown-toggle-default: 100%;
|
|
465
|
+
--x-size-min-width-dropdown-list-default: 100%;
|
|
466
|
+
--x-size-gap-dropdown-default: 0;
|
|
467
|
+
--x-size-padding-top-dropdown-toggle-default: var(--x-size-padding-top-dropdown-item-default);
|
|
468
|
+
--x-size-padding-right-dropdown-toggle-default: var(--x-size-padding-right-dropdown-item-default);
|
|
469
|
+
--x-size-padding-bottom-dropdown-toggle-default: var(
|
|
470
|
+
--x-size-padding-bottom-dropdown-item-default
|
|
471
|
+
);
|
|
472
|
+
--x-size-padding-left-dropdown-toggle-default: var(--x-size-padding-left-dropdown-item-default);
|
|
473
|
+
--x-size-padding-vertical-dropdown-list-default: 0;
|
|
474
|
+
--x-size-padding-top-dropdown-item-default: var(--x-size-base-04);
|
|
475
|
+
--x-size-padding-right-dropdown-item-default: var(--x-size-base-05);
|
|
476
|
+
--x-size-padding-bottom-dropdown-item-default: var(--x-size-base-04);
|
|
477
|
+
--x-size-padding-left-dropdown-item-default: var(--x-size-base-05);
|
|
478
|
+
--x-size-gap-dropdown-item-default: var(--x-size-base-03);
|
|
479
|
+
--x-string-box-shadow-dropdown-default: none;
|
|
480
|
+
--x-string-overflow-dropdown-toggle-default: hidden;
|
|
481
|
+
--x-string-overflow-dropdown-list-default: hidden;
|
|
482
|
+
}
|
|
410
483
|
:root {
|
|
411
484
|
--x-color-background-facet-default: transparent;
|
|
412
485
|
--x-color-border-facet-default: var(--x-color-background-facet-default);
|
|
@@ -2833,77 +2906,4 @@
|
|
|
2833
2906
|
--x-size-line-height-base-s: 16px;
|
|
2834
2907
|
--x-size-line-height-base-m: 24px;
|
|
2835
2908
|
--x-size-line-height-base-l: 32px;
|
|
2836
|
-
}
|
|
2837
|
-
:root {
|
|
2838
|
-
--x-size-border-radius-dropdown-default: var(--x-size-border-radius-base-none);
|
|
2839
|
-
--x-size-border-radius-top-left-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
2840
|
-
--x-size-border-radius-top-right-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
2841
|
-
--x-size-border-radius-bottom-right-dropdown-default: var(
|
|
2842
|
-
--x-size-border-radius-dropdown-default
|
|
2843
|
-
);
|
|
2844
|
-
--x-size-border-radius-bottom-left-dropdown-default: var(--x-size-border-radius-dropdown-default);
|
|
2845
|
-
--x-size-border-width-dropdown-toggle-default: var(--x-size-border-width-base);
|
|
2846
|
-
--x-size-border-width-top-dropdown-toggle-default: var(
|
|
2847
|
-
--x-size-border-width-dropdown-toggle-default
|
|
2848
|
-
);
|
|
2849
|
-
--x-size-border-width-right-dropdown-toggle-default: var(
|
|
2850
|
-
--x-size-border-width-dropdown-toggle-default
|
|
2851
|
-
);
|
|
2852
|
-
--x-size-border-width-bottom-dropdown-toggle-default: var(
|
|
2853
|
-
--x-size-border-width-dropdown-toggle-default
|
|
2854
|
-
);
|
|
2855
|
-
--x-size-border-width-left-dropdown-toggle-default: var(
|
|
2856
|
-
--x-size-border-width-dropdown-toggle-default
|
|
2857
|
-
);
|
|
2858
|
-
--x-size-border-width-dropdown-list-default: var(--x-size-border-width-base);
|
|
2859
|
-
--x-size-border-width-top-dropdown-list-default: 0;
|
|
2860
|
-
--x-size-border-width-right-dropdown-list-default: var(
|
|
2861
|
-
--x-size-border-width-dropdown-list-default
|
|
2862
|
-
);
|
|
2863
|
-
--x-size-border-width-bottom-dropdown-list-default: var(
|
|
2864
|
-
--x-size-border-width-dropdown-list-default
|
|
2865
|
-
);
|
|
2866
|
-
--x-size-border-width-left-dropdown-list-default: var(
|
|
2867
|
-
--x-size-border-width-dropdown-list-default
|
|
2868
|
-
);
|
|
2869
|
-
--x-color-border-dropdown-toggle-default: var(--x-color-base-neutral-95);
|
|
2870
|
-
--x-color-border-dropdown-list-default: var(--x-color-border-dropdown-toggle-default);
|
|
2871
|
-
--x-color-background-dropdown-default: var(--x-color-base-neutral-100);
|
|
2872
|
-
--x-color-background-dropdown-toggle-default: var(--x-color-base-neutral-100);
|
|
2873
|
-
--x-color-background-dropdown-toggle-open-default: var(
|
|
2874
|
-
--x-color-background-dropdown-toggle-default
|
|
2875
|
-
);
|
|
2876
|
-
--x-color-background-dropdown-item-default-selected: var(--x-color-base-neutral-95);
|
|
2877
|
-
--x-color-background-dropdown-item-default-hover: var(--x-color-base-neutral-95);
|
|
2878
|
-
--x-color-text-dropdown-default: var(--x-color-text-default);
|
|
2879
|
-
--x-color-text-dropdown-toggle-default: var(--x-color-text-dropdown-default);
|
|
2880
|
-
--x-color-text-dropdown-toggle-default-selected: var(--x-color-base-neutral-35);
|
|
2881
|
-
--x-color-text-dropdown-item-default-hover: var(--x-color-base-neutral-35);
|
|
2882
|
-
--x-color-text-dropdown-item-default-selected: var(--x-color-text-default);
|
|
2883
|
-
--x-font-family-dropdown-default: var(--x-font-family-text);
|
|
2884
|
-
--x-size-font-dropdown-default: var(--x-size-font-text);
|
|
2885
|
-
--x-size-line-height-dropdown-default: var(--x-size-line-height-text);
|
|
2886
|
-
--x-number-font-weight-dropdown-default: var(--x-number-font-weight-base-regular);
|
|
2887
|
-
--x-number-font-weight-dropdown-item-default-hover: var(--x-number-font-weight-base-bold);
|
|
2888
|
-
--x-number-font-weight-dropdown-item-default-selected: var(--x-number-font-weight-base-regular);
|
|
2889
|
-
--x-font-decoration-dropdown-item-default-hover: none;
|
|
2890
|
-
--x-font-decoration-dropdown-item-default-selected: none;
|
|
2891
|
-
--x-size-width-dropdown-toggle-default: 100%;
|
|
2892
|
-
--x-size-min-width-dropdown-list-default: 100%;
|
|
2893
|
-
--x-size-gap-dropdown-default: 0;
|
|
2894
|
-
--x-size-padding-top-dropdown-toggle-default: var(--x-size-padding-top-dropdown-item-default);
|
|
2895
|
-
--x-size-padding-right-dropdown-toggle-default: var(--x-size-padding-right-dropdown-item-default);
|
|
2896
|
-
--x-size-padding-bottom-dropdown-toggle-default: var(
|
|
2897
|
-
--x-size-padding-bottom-dropdown-item-default
|
|
2898
|
-
);
|
|
2899
|
-
--x-size-padding-left-dropdown-toggle-default: var(--x-size-padding-left-dropdown-item-default);
|
|
2900
|
-
--x-size-padding-vertical-dropdown-list-default: 0;
|
|
2901
|
-
--x-size-padding-top-dropdown-item-default: var(--x-size-base-04);
|
|
2902
|
-
--x-size-padding-right-dropdown-item-default: var(--x-size-base-05);
|
|
2903
|
-
--x-size-padding-bottom-dropdown-item-default: var(--x-size-base-04);
|
|
2904
|
-
--x-size-padding-left-dropdown-item-default: var(--x-size-base-05);
|
|
2905
|
-
--x-size-gap-dropdown-item-default: var(--x-size-base-03);
|
|
2906
|
-
--x-string-box-shadow-dropdown-default: none;
|
|
2907
|
-
--x-string-overflow-dropdown-toggle-default: hidden;
|
|
2908
|
-
--x-string-overflow-dropdown-list-default: hidden;
|
|
2909
2909
|
}
|
|
@@ -1144,6 +1144,10 @@
|
|
|
1144
1144
|
--x-size-width-icon-default: var(--x-size-width-icon-xl);
|
|
1145
1145
|
--x-size-height-icon-default: var(--x-size-height-icon-xl);
|
|
1146
1146
|
}
|
|
1147
|
+
:root {
|
|
1148
|
+
--x-size-width-icon-xl: var(--x-size-base-07);
|
|
1149
|
+
--x-size-height-icon-xl: var(--x-size-base-07);
|
|
1150
|
+
}
|
|
1147
1151
|
.x-input-group--card.x-input-group,
|
|
1148
1152
|
.x-input-group--card .x-input-group {
|
|
1149
1153
|
--x-size-border-radius-input-group-default: var(--x-size-border-radius-input-group-card);
|
|
@@ -7589,8 +7593,3 @@
|
|
|
7589
7593
|
.x-normal-case {
|
|
7590
7594
|
text-transform: none;
|
|
7591
7595
|
}
|
|
7592
|
-
|
|
7593
|
-
:root {
|
|
7594
|
-
--x-size-width-icon-xl: var(--x-size-base-07);
|
|
7595
|
-
--x-size-height-icon-xl: var(--x-size-base-07);
|
|
7596
|
-
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
| [extractUrlParameters(url)](./x-adapter-platform.extracturlparameters.md) | Returns the base url path and an object with the query parameters. |
|
|
12
12
|
| [getFacetConfig(facet)](./x-adapter-platform.getfacetconfig.md) | Returns the facet's config. |
|
|
13
13
|
| [getTaggingInfoFromUrl(taggingUrl)](./x-adapter-platform.gettagginginfofromurl.md) | Extracts the tagging info from a URL. |
|
|
14
|
-
| [searchResponseFacetsMapper(from, { mappedValue })](./x-adapter-platform.searchresponsefacetsmapper.md) | Mapper to flatten hierarchical facet filters. |
|
|
15
14
|
|
|
16
15
|
## Interfaces
|
|
17
16
|
|
|
@@ -7,15 +7,5 @@
|
|
|
7
7
|
<b>Signature:</b>
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
searchResponseMapper: import("@empathyco/x-adapter").Mapper<PlatformSearchResponse,
|
|
11
|
-
banners: import("@empathyco/x-types").Banner[];
|
|
12
|
-
facets: import("@empathyco/x-types").Facet[];
|
|
13
|
-
partialResults: import("@empathyco/x-types").PartialResult[];
|
|
14
|
-
promoteds: import("@empathyco/x-types").Promoted[];
|
|
15
|
-
queryTagging: import("@empathyco/x-types").TaggingRequest;
|
|
16
|
-
redirections: import("@empathyco/x-types").Redirection[];
|
|
17
|
-
results: import("@empathyco/x-types").Result[];
|
|
18
|
-
spellcheck: string;
|
|
19
|
-
totalResults: number;
|
|
20
|
-
}>
|
|
10
|
+
searchResponseMapper: import("@empathyco/x-adapter").Mapper<PlatformSearchResponse, SearchResponse>
|
|
21
11
|
```
|
|
@@ -16,12 +16,12 @@ export interface FacetsMutations
|
|
|
16
16
|
|
|
17
17
|
| Method | Description |
|
|
18
18
|
| --- | --- |
|
|
19
|
+
| [mutateFilter(payload)](./x-components.facetsmutations.mutatefilter.md) | Updates the state of a filter. |
|
|
19
20
|
| [removeFacet(facet)](./x-components.facetsmutations.removefacet.md) | Removes the facet from the [facets](./x-components.facetsstate.facets.md) record. |
|
|
20
21
|
| [removeFilter(filter)](./x-components.facetsmutations.removefilter.md) | Removes the filter from the [filters](./x-components.facetsstate.filters.md) record. |
|
|
21
22
|
| [removeFilters(filters)](./x-components.facetsmutations.removefilters.md) | Removes a list of filters from the [filters](./x-components.facetsstate.filters.md) record. |
|
|
22
23
|
| [setFacet(facet)](./x-components.facetsmutations.setfacet.md) | Adds the facet to the [facets](./x-components.facetsstate.facets.md) record. |
|
|
23
24
|
| [setFacetGroup(facetGroupEntry)](./x-components.facetsmutations.setfacetgroup.md) | Sets the group id of the facet. |
|
|
24
|
-
| [setFilter(filter)](./x-components.facetsmutations.setfilter.md) | Adds the filter to the [filters](./x-components.facetsstate.filters.md) record. |
|
|
25
25
|
| [setFilters(filters)](./x-components.facetsmutations.setfilters.md) | Adds a list of filters to the [filters](./x-components.facetsstate.filters.md) record. |
|
|
26
26
|
| [setPreselectedFilters(filters)](./x-components.facetsmutations.setpreselectedfilters.md) | Adds a list of filters to the [preselectedFilters](./x-components.facetsstate.preselectedfilters.md) record. |
|
|
27
27
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [FacetsMutations](./x-components.facetsmutations.md) > [mutateFilter](./x-components.facetsmutations.mutatefilter.md)
|
|
4
|
+
|
|
5
|
+
## FacetsMutations.mutateFilter() method
|
|
6
|
+
|
|
7
|
+
Updates the state of a filter.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
mutateFilter(payload: MutateFilterPayload): void;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| payload | [MutateFilterPayload](./x-components.mutatefilterpayload.md) | An object containing the filter to update, and the properties to modify. |
|
|
20
|
+
|
|
21
|
+
<b>Returns:</b>
|
|
22
|
+
|
|
23
|
+
void
|
|
24
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [flatHierarchicalFilters](./x-components.flathierarchicalfilters.md)
|
|
4
|
+
|
|
5
|
+
## flatHierarchicalFilters() function
|
|
6
|
+
|
|
7
|
+
This function flattens the Hierarchical Filters, returning an array with all filters including the children.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function flatHierarchicalFilters(hierarchicalFilters: HierarchicalFilter[]): HierarchicalFilter[];
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| hierarchicalFilters | HierarchicalFilter\[\] | The list of Hierarchical Filters to flatten. |
|
|
20
|
+
|
|
21
|
+
<b>Returns:</b>
|
|
22
|
+
|
|
23
|
+
HierarchicalFilter\[\]
|
|
24
|
+
|
|
25
|
+
An array with all the Hierarchical filters.
|
|
26
|
+
|
|
@@ -166,6 +166,7 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
166
166
|
| [filterFalsyPayload(wire)](./x-components.filterfalsypayload.md) | Creates a [Wire](./x-components.wire.md) that is only executed when the payload is truthy. A truthy value is whatever is not a [falsy value](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)<!-- -->. |
|
|
167
167
|
| [filterTruthyPayload(wire)](./x-components.filtertruthypayload.md) | Creates a [Wire](./x-components.wire.md) that is only executed when the payload is a [falsy value](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)<!-- -->. |
|
|
168
168
|
| [filterWhitelistedModules(wire, whitelist)](./x-components.filterwhitelistedmodules.md) | Creates a [Wire](./x-components.wire.md) that is only executed if the event is emitted from a [XModule](./x-components.xmodule.md) that is included in the <code>whitelist</code> array passed as parameter. |
|
|
169
|
+
| [flatHierarchicalFilters(hierarchicalFilters)](./x-components.flathierarchicalfilters.md) | This function flattens the Hierarchical Filters, returning an array with all filters including the children. |
|
|
169
170
|
| [getRootXComponent(component)](./x-components.getrootxcomponent.md) | Given a component, finds the root XComponent in the ancestors hierarchy. |
|
|
170
171
|
| [getStateAndGettersFromModule(state, getters, moduleName)](./x-components.getstateandgettersfrommodule.md) | Returns an object with the getters and state of a module of store defined by the moduleName parameter. |
|
|
171
172
|
| [Getter(module, getter)](./x-components.getter.md) | Generates a computed property which returns the selected getter value.<!-- -->The decorated property needs to be public for type inference to work. |
|
|
@@ -253,6 +254,7 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
253
254
|
| [InitWrapper](./x-components.initwrapper.md) | Interface for the returned type of the [XInstaller.init()](./x-components.xinstaller.init.md) function. |
|
|
254
255
|
| [InstallXOptions](./x-components.installxoptions.md) | Interface for the parameter of the constructor of [XInstaller](./x-components.xinstaller.md) function. It is an extended version of [XPluginOptions](./x-components.xpluginoptions.md)<!-- -->. |
|
|
255
256
|
| [InternalSearchRequest](./x-components.internalsearchrequest.md) | An internal search request containing the page used to calculate the start and rows properties of a [SearchRequest](./x-types.searchrequest.md)<!-- -->. |
|
|
257
|
+
| [MutateFilterPayload](./x-components.mutatefilterpayload.md) | Payload to use in the <code>mutateFilter</code> mutation. |
|
|
256
258
|
| [NamespacedWireCommit](./x-components.namespacedwirecommit.md) | Namespaced type for the [wireCommit()](./x-components.wirecommit.md) which creates a wire with its payload associated. Possible ways for creating a wire that commits a mutation. If a payload is passed, then the observable payload can be ignored, so the wire is applicable to any event. If no payload is passed, then the wire is only applicable to events with the same payload type than the mutation. |
|
|
257
259
|
| [NamespacedWireDispatch](./x-components.namespacedwiredispatch.md) | Namespaced type for the [wireDispatch()](./x-components.wiredispatch.md) which creates a wire with its payload associated. Possible ways for creating a wire that dispatches an action. If a payload is passed, then the observable payload can be ignored, so the wire is applicable to any event. If no payload is passed, then the wire is only applicable to events with the same payload type than the action. |
|
|
258
260
|
| [NextQueriesActions](./x-components.nextqueriesactions.md) | Next queries module actions. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [MutateFilterPayload](./x-components.mutatefilterpayload.md) > [filter](./x-components.mutatefilterpayload.filter.md)
|
|
4
|
+
|
|
5
|
+
## MutateFilterPayload.filter property
|
|
6
|
+
|
|
7
|
+
The filter to modify. If it does not belong to the store it will be added.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
filter: Filter;
|
|
13
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [MutateFilterPayload](./x-components.mutatefilterpayload.md)
|
|
4
|
+
|
|
5
|
+
## MutateFilterPayload interface
|
|
6
|
+
|
|
7
|
+
Payload to use in the `mutateFilter` mutation.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export interface MutateFilterPayload
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
| Property | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| [filter](./x-components.mutatefilterpayload.filter.md) | Filter | The filter to modify. If it does not belong to the store it will be added. |
|
|
20
|
+
| [newFilterState](./x-components.mutatefilterpayload.newfilterstate.md) | Partial<Filter> | The new fields values to modify in the filter. |
|
|
21
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [MutateFilterPayload](./x-components.mutatefilterpayload.md) > [newFilterState](./x-components.mutatefilterpayload.newfilterstate.md)
|
|
4
|
+
|
|
5
|
+
## MutateFilterPayload.newFilterState property
|
|
6
|
+
|
|
7
|
+
The new fields values to modify in the filter.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
newFilterState: Partial<Filter>;
|
|
13
|
+
```
|
|
@@ -17,7 +17,7 @@ export interface HierarchicalFilter extends BooleanFilter
|
|
|
17
17
|
|
|
18
18
|
| Property | Type | Description |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
-
| [children?](./x-types.hierarchicalfilter.children.md) | [
|
|
20
|
+
| [children?](./x-types.hierarchicalfilter.children.md) | [HierarchicalFilter](./x-types.hierarchicalfilter.md)<!-- -->\[\] | <i>(Optional)</i> Descendants filters. |
|
|
21
21
|
| [modelName](./x-types.hierarchicalfilter.modelname.md) | 'HierarchicalFilter' | Model name to indicate the filter type. |
|
|
22
|
-
| [parentId](./x-types.hierarchicalfilter.parentid.md) | [Filter](./x-types.filter.md)<!-- -->\['id'\] \| null |
|
|
22
|
+
| [parentId](./x-types.hierarchicalfilter.parentid.md) | [Filter](./x-types.filter.md)<!-- -->\['id'\] \| null | A unique id used to reference the parent filter or null if it hasn't. |
|
|
23
23
|
|
package/facets/index.js
CHANGED
|
@@ -32,5 +32,5 @@ export { default as SelectedFiltersList } from '../js/x-modules/facets/component
|
|
|
32
32
|
export { default as SlicedFilters } from '../js/x-modules/facets/components/lists/sliced-filters.vue.js';
|
|
33
33
|
export { default as SortedFilters } from '../js/x-modules/facets/components/lists/sorted-filters.vue.js';
|
|
34
34
|
export { default as ClearFilters } from '../js/x-modules/facets/components/clear-filters.vue.js';
|
|
35
|
-
export { isNewQuery } from '../js/x-modules/facets/utils.js';
|
|
35
|
+
export { flatHierarchicalFilters, isNewQuery } from '../js/x-modules/facets/utils.js';
|
|
36
36
|
export { default as FacetsMixin } from '../js/x-modules/facets/components/facets.mixin.js';
|
package/js/index.js
CHANGED
|
@@ -207,7 +207,7 @@ export { default as SelectedFiltersList } from './x-modules/facets/components/li
|
|
|
207
207
|
export { default as SlicedFilters } from './x-modules/facets/components/lists/sliced-filters.vue.js';
|
|
208
208
|
export { default as SortedFilters } from './x-modules/facets/components/lists/sorted-filters.vue.js';
|
|
209
209
|
export { default as ClearFilters } from './x-modules/facets/components/clear-filters.vue.js';
|
|
210
|
-
export { isNewQuery } from './x-modules/facets/utils.js';
|
|
210
|
+
export { flatHierarchicalFilters, isNewQuery } from './x-modules/facets/utils.js';
|
|
211
211
|
export { default as FacetsMixin } from './x-modules/facets/components/facets.mixin.js';
|
|
212
212
|
export { default as ClearHistoryQueries } from './x-modules/history-queries/components/clear-history-queries.vue.js';
|
|
213
213
|
export { default as HistoryQueries } from './x-modules/history-queries/components/history-queries.vue.js';
|
|
@@ -10,11 +10,11 @@ const __vue_script__ = script;
|
|
|
10
10
|
/* style */
|
|
11
11
|
const __vue_inject_styles__ = function (inject) {
|
|
12
12
|
if (!inject) return
|
|
13
|
-
inject("data-v-
|
|
13
|
+
inject("data-v-7e46f769_0", { source: ".x-facets-list[data-v-7e46f769] {\n list-style-type: none;\n}", map: undefined, media: undefined });
|
|
14
14
|
|
|
15
15
|
};
|
|
16
16
|
/* scoped */
|
|
17
|
-
const __vue_scope_id__ = "data-v-
|
|
17
|
+
const __vue_scope_id__ = "data-v-7e46f769";
|
|
18
18
|
/* module identifier */
|
|
19
19
|
const __vue_module_identifier__ = undefined;
|
|
20
20
|
/* functional template */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets-provider.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue"],"sourcesContent":["<script lang=\"ts\">\n import { Facet, Filter } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop, Watch } from 'vue-property-decorator';\n import { XOn } from '../../../../components';\n import { xComponentMixin } from '../../../../components/x-component.mixin';\n import { areFiltersDifferent } from '../../../../utils/filters';\n import { FacetsGroup } from '../../service/types';\n import { GroupId } from '../../store/types';\n import { facetsXModule } from '../../x-module';\n\n /**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class FacetsProvider extends Vue {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n @Prop({ default: 'provided-facets' })\n public groupId!: GroupId;\n\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter | filters}.\n *\n * @internal\n */\n @Prop({ required: true })\n public facets!: Facet[];\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n protected selectedFilters: Filter[] | null = null;\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n protected get facetsGroup(): FacetsGroup {\n return { id: this.groupId, facets: this.facets };\n }\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n @XOn('SelectedFiltersChanged')\n emitSelectedFiltersChanged(selectedFilters: Filter[]): void {\n if (\n this.selectedFilters === null ||\n areFiltersDifferent(this.selectedFilters, selectedFilters)\n ) {\n this.$x.emit('UserChangedSelectedFilters', selectedFilters);\n }\n this.selectedFilters = null;\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n @Watch('facetsGroup', { immediate: true })\n provideFacets(): void {\n if (this.facetsGroup.facets) {\n this.$x.emit('FacetsGroupProvided',
|
|
1
|
+
{"version":3,"file":"facets-provider.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue"],"sourcesContent":["<script lang=\"ts\">\n import { Facet, Filter, isHierarchicalFacet } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop, Watch } from 'vue-property-decorator';\n import { XOn } from '../../../../components';\n import { xComponentMixin } from '../../../../components/x-component.mixin';\n import { clone } from '../../../../utils';\n import { areFiltersDifferent } from '../../../../utils/filters';\n import { FacetsGroup } from '../../service/types';\n import { GroupId } from '../../store/types';\n import { flatHierarchicalFilters } from '../../utils';\n import { facetsXModule } from '../../x-module';\n\n /**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class FacetsProvider extends Vue {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n @Prop({ default: 'provided-facets' })\n public groupId!: GroupId;\n\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter | filters}.\n *\n * @internal\n */\n @Prop({ required: true })\n public facets!: Facet[];\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n protected selectedFilters: Filter[] | null = null;\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n protected get facetsGroup(): FacetsGroup {\n return { id: this.groupId, facets: this.facets };\n }\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n @XOn('SelectedFiltersChanged')\n emitSelectedFiltersChanged(selectedFilters: Filter[]): void {\n if (\n this.selectedFilters === null ||\n areFiltersDifferent(this.selectedFilters, selectedFilters)\n ) {\n this.$x.emit('UserChangedSelectedFilters', selectedFilters);\n }\n this.selectedFilters = null;\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n @Watch('facetsGroup', { immediate: true })\n provideFacets(): void {\n if (this.facetsGroup.facets) {\n const facetsGroupClone = clone(this.facetsGroup);\n this.$x.emit('FacetsGroupProvided', facetsGroupClone);\n this.extractSelectedFilters(this.facets);\n }\n }\n\n /**\n * Extracts the selected filters from the facets and stores them in the\n * {@link FacetsProvider.selectedFilters} property.\n *\n * @param facets - The facets from whom extract the selected filters.\n * @internal\n */\n protected extractSelectedFilters(facets: Facet[]): void {\n this.selectedFilters = facets\n .flatMap(facet =>\n isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters\n )\n .filter(filter => filter.selected);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n }\n</script>\n\n<style lang=\"scss\" scoped>\n .x-facets-list {\n list-style-type: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component allows to provide facets by prop, to add them to the state of the `Facets X-Module`.\nThese facets will be added to the `Facets X-Module` state together with the facets emitted by the\n`Search X-Module` through the {@link SearchXEvents.FacetsChanged} event.\n\n```vue\n<template>\n <FacetsProvider :facets=\"myFacets\" />\n</template>\n\n<script>\n import { FacetsProvider } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n FacetsProvider\n },\n data() {\n return {\n myFacets: [\n {\n modelName: 'SimpleFacet',\n id: 'color-facet',\n label: 'Color',\n filters: [\n {\n modelName: 'SimpleFilter',\n id: 'color:red',\n facetId: 'color-facet',\n label: 'Red',\n selected: false,\n value: 'color:red',\n totalResults: 10\n },\n {\n modelName: 'SimpleFilter',\n id: 'color:blue',\n facetId: 'color-facet',\n label: 'Blue',\n selected: false,\n value: 'color:blue',\n totalResults: 10\n }\n ]\n }\n ]\n };\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserChangedSelectedFilters`: the event is emitted after the user performed an action that changed\n the selected filters. The payload is the new list of selected filters.\n- `FacetsGroupProvided`: the event is emitted after updating the facets prop with a new list of\n facets. The payload contains a Facets Group with the facets and the group id.\n</docs>\n"],"names":[],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/js/x-modules/facets/components/facets/facets-provider.vue_rollup-plugin-vue_script.vue.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
+
import { isHierarchicalFacet } from '@empathyco/x-types';
|
|
2
3
|
import Vue from 'vue';
|
|
3
4
|
import { Prop, Watch, Component } from 'vue-property-decorator';
|
|
4
5
|
import '../../../../components/animations/animate-width.vue.js';
|
|
@@ -123,7 +124,10 @@ import { XOn } from '../../../../components/decorators/bus.decorators.js';
|
|
|
123
124
|
import 'vue-class-component';
|
|
124
125
|
import '../../../../components/items-list-injection.mixin.js';
|
|
125
126
|
import { xComponentMixin } from '../../../../components/x-component.mixin.js';
|
|
127
|
+
import { clone } from '../../../../utils/clone.js';
|
|
126
128
|
import { areFiltersDifferent } from '../../../../utils/filters.js';
|
|
129
|
+
import '../../../../utils/storage.js';
|
|
130
|
+
import { flatHierarchicalFilters } from '../../utils.js';
|
|
127
131
|
import { facetsXModule } from '../../x-module.js';
|
|
128
132
|
|
|
129
133
|
/**
|
|
@@ -176,7 +180,8 @@ let FacetsProvider = class FacetsProvider extends Vue {
|
|
|
176
180
|
*/
|
|
177
181
|
provideFacets() {
|
|
178
182
|
if (this.facetsGroup.facets) {
|
|
179
|
-
|
|
183
|
+
const facetsGroupClone = clone(this.facetsGroup);
|
|
184
|
+
this.$x.emit('FacetsGroupProvided', facetsGroupClone);
|
|
180
185
|
this.extractSelectedFilters(this.facets);
|
|
181
186
|
}
|
|
182
187
|
}
|
|
@@ -189,7 +194,7 @@ let FacetsProvider = class FacetsProvider extends Vue {
|
|
|
189
194
|
*/
|
|
190
195
|
extractSelectedFilters(facets) {
|
|
191
196
|
this.selectedFilters = facets
|
|
192
|
-
.flatMap(facet => facet.filters)
|
|
197
|
+
.flatMap(facet => isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters)
|
|
193
198
|
.filter(filter => filter.selected);
|
|
194
199
|
}
|
|
195
200
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets-provider.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\nimport { Facet, Filter } from '@empathyco/x-types';\nimport Vue from 'vue';\nimport { Component, Prop, Watch } from 'vue-property-decorator';\nimport { XOn } from '../../../../components';\nimport { xComponentMixin } from '../../../../components/x-component.mixin';\nimport { areFiltersDifferent } from '../../../../utils/filters';\nimport { FacetsGroup } from '../../service/types';\nimport { GroupId } from '../../store/types';\nimport { facetsXModule } from '../../x-module';\n\n/**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class FacetsProvider extends Vue {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n @Prop({ default: 'provided-facets' })\n public groupId!: GroupId;\n\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter | filters}.\n *\n * @internal\n */\n @Prop({ required: true })\n public facets!: Facet[];\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n protected selectedFilters: Filter[] | null = null;\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n protected get facetsGroup(): FacetsGroup {\n return { id: this.groupId, facets: this.facets };\n }\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n @XOn('SelectedFiltersChanged')\n emitSelectedFiltersChanged(selectedFilters: Filter[]): void {\n if (\n this.selectedFilters === null ||\n areFiltersDifferent(this.selectedFilters, selectedFilters)\n ) {\n this.$x.emit('UserChangedSelectedFilters', selectedFilters);\n }\n this.selectedFilters = null;\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n @Watch('facetsGroup', { immediate: true })\n provideFacets(): void {\n if (this.facetsGroup.facets) {\n this.$x.emit('FacetsGroupProvided',
|
|
1
|
+
{"version":3,"file":"facets-provider.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets-provider.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\nimport { Facet, Filter, isHierarchicalFacet } from '@empathyco/x-types';\nimport Vue from 'vue';\nimport { Component, Prop, Watch } from 'vue-property-decorator';\nimport { XOn } from '../../../../components';\nimport { xComponentMixin } from '../../../../components/x-component.mixin';\nimport { clone } from '../../../../utils';\nimport { areFiltersDifferent } from '../../../../utils/filters';\nimport { FacetsGroup } from '../../service/types';\nimport { GroupId } from '../../store/types';\nimport { flatHierarchicalFilters } from '../../utils';\nimport { facetsXModule } from '../../x-module';\n\n/**\n * This component allows to provide facets by prop, to add them to the state of the\n * `Facets X-Module`. These facets will be added to the `Facets X-Module` state together with\n * the facets emitted by the `Search X-Module` through the {@link SearchXEvents.FacetsChanged}\n * event.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class FacetsProvider extends Vue {\n /**\n * An facet group identifier to distinguish the provided facets from other facets like the\n * `Search X-Module` facets.\n *\n * @public\n */\n @Prop({ default: 'provided-facets' })\n public groupId!: GroupId;\n\n /**\n * The facets to provide to the `Facets X-Module` state. They have to include the\n * {@link @empathyco/x-types#Filter | filters}.\n *\n * @internal\n */\n @Prop({ required: true })\n public facets!: Facet[];\n\n /**\n * Temporarily stores the selected filters from the {@link FacetsProvider.facets} prop.\n * This is necessary to handle the {@link FacetsXEvents.UserChangedSelectedFilters} event.\n *\n * @internal\n */\n protected selectedFilters: Filter[] | null = null;\n\n /**\n * A computed property to group the facets and the groupId. This is used by the watcher.\n *\n * @returns The FacetGroup with the facets and the group id.\n *\n * @internal\n */\n protected get facetsGroup(): FacetsGroup {\n return { id: this.groupId, facets: this.facets };\n }\n\n /**\n * Emits the {@link FacetsXEvents.UserChangedSelectedFilters} event when the user changes\n * the selected filters.\n *\n * @param selectedFilters - The new list of selected filters.\n * @internal\n */\n @XOn('SelectedFiltersChanged')\n emitSelectedFiltersChanged(selectedFilters: Filter[]): void {\n if (\n this.selectedFilters === null ||\n areFiltersDifferent(this.selectedFilters, selectedFilters)\n ) {\n this.$x.emit('UserChangedSelectedFilters', selectedFilters);\n }\n this.selectedFilters = null;\n }\n\n /**\n * Emits the {@link FacetsXEvents.FacetsGroupProvided} event with the\n * {@link FacetsProvider.facetsGroup} as payload. It also extracts and saves the selected\n * filters.\n */\n @Watch('facetsGroup', { immediate: true })\n provideFacets(): void {\n if (this.facetsGroup.facets) {\n const facetsGroupClone = clone(this.facetsGroup);\n this.$x.emit('FacetsGroupProvided', facetsGroupClone);\n this.extractSelectedFilters(this.facets);\n }\n }\n\n /**\n * Extracts the selected filters from the facets and stores them in the\n * {@link FacetsProvider.selectedFilters} property.\n *\n * @param facets - The facets from whom extract the selected filters.\n * @internal\n */\n protected extractSelectedFilters(facets: Facet[]): void {\n this.selectedFilters = facets\n .flatMap(facet =>\n isHierarchicalFacet(facet) ? flatHierarchicalFilters(facet.filters) : facet.filters\n )\n .filter(filter => filter.selected);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;;;AAWA,IAAqB,cAAc,GAAnC,MAAqB,cAAe,SAAQ,GAAG;IAA/C;;;;;;;;QAyBY,oBAAe,GAAoB,IAAI,CAAC;KA8DnD;;;;;;;;IArDC,IAAc,WAAW;QACvB,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;KAClD;;;;;;;;IAUD,0BAA0B,CAAC,eAAyB;QAClD,IACE,IAAI,CAAC,eAAe,KAAK,IAAI;YAC7B,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,EAC1D;YACA,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;SAC7D;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;KAC7B;;;;;;IAQD,aAAa;QACX,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;YAC3B,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACjD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;YACtD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC1C;KACF;;;;;;;;IASS,sBAAsB,CAAC,MAAe;QAC9C,IAAI,CAAC,eAAe,GAAG,MAAM;aAC1B,OAAO,CAAC,KAAK,IACZ,mBAAmB,CAAC,KAAK,CAAC,GAAG,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CACpF;aACA,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;KACtC;;IAGD,MAAM,MAAW;CAClB,CAAA;AA/EC;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;+CACZ;AASzB;IADC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8CACD;AA6BxB;IADC,GAAG,CAAC,wBAAwB,CAAC;gEAS7B;AAQD;IADC,KAAK,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;mDAOzC;AApEkB,cAAc;IAHlC,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;GACmB,cAAc,CAuFlC;aAvFoB,cAAc;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchical-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/hierarchical-filter.vue"],"sourcesContent":["<template>\n <div class=\"x-hierarchical-filter-container\" data-test=\"hierarchical-filter-container\">\n <RenderlessFilter\n v-slot=\"{ filter, clickFilter, cssClasses, isDisabled }\"\n :class=\"cssClasses\"\n :clickEvents=\"_clickEvents\"\n :filter=\"filter\"\n class=\"x-hierarchical-filter\"\n >\n <!--\n @slot The content to render inside the button.\n @binding {Filter} filter - The filter data.\n @binding {Function} clickFilter - The handler to invoke when clicking the filter.\n @binding {VueCssClasses} cssClasses - The CSS classes.\n @binding {boolean} isDisabled - Flag determining the disabled state.\n -->\n <slot v-bind=\"{ filter, clickFilter, cssClasses, isDisabled }\">\n <button\n @click=\"clickFilter\"\n :aria-checked=\"filter.selected.toString()\"\n :class=\"cssClasses\"\n :disabled=\"isDisabled\"\n data-test=\"filter\"\n role=\"checkbox\"\n >\n <!--\n @slot The content to render inside the button.\n @binding {Filter} filter - The filter data.\n -->\n <slot name=\"label\" :filter=\"filter\">{{ filter.label }}</slot>\n </button>\n </slot>\n </RenderlessFilter>\n <FiltersList\n v-slot=\"{ filter: childFilter }\"\n :animation=\"childrenAnimation\"\n :filters=\"renderedChildrenFilters\"\n :parent-id=\"filter.id\"\n class=\"x-hierarchical-filter__children\"\n data-test=\"children-filters\"\n >\n <HierarchicalFilter\n :childrenAnimation=\"childrenAnimation\"\n :filter=\"childFilter\"\n :clickEvents=\"getChildFilterClickEvents(childFilter)\"\n >\n <template #default=\"{ filter, clickFilter, cssClasses, isDisabled }\">\n <slot v-bind=\"{ filter, clickFilter, cssClasses, isDisabled }\" />\n </template>\n <template #label=\"{ filter }\">\n <slot name=\"label\" :filter=\"filter\" />\n </template>\n </HierarchicalFilter>\n </FiltersList>\n </div>\n</template>\n\n<script lang=\"ts\">\n import {\n Filter,\n HierarchicalFilter as HierarchicalFilterModel,\n isHierarchicalFilter\n } from '@empathyco/x-types';\n import { isObject } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { State, xComponentMixin } from '../../../../components';\n import { VueCSSClasses } from '../../../../utils/types';\n import { XEventsTypes } from '../../../../wiring/events.types';\n import { facetsXModule } from '../../x-module';\n import FiltersList from '../lists/filters-list.vue';\n import 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 })\n export 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</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAFilter`](x-components.xeventstypes.userclickedafilter.md): the event is emitted\n after the user clicks the button, using the `filter` prop as its payload.\n- [`UserClickedAHierarchicalFilter`](x-components.xeventstypes.userclickedahierarchicalfilter.md):\n the event is emitted after the user clicks the button, using the `filter` prop as its payload.\n filter.\n\n## See it in action\n\nThis component renders a button, which on clicked emits the `UserClickedAFilter` and\n`UserClickedAHierarchicalFilter` events. By default it renders the filter label as the button text.\nIf the provided filter has children filters, this component will render them recursively. Changing\nthe slot content will change it for all of the children.\n\nThe `filter` prop is required. The `clickEvents` prop is optional and allows configuring the events\nto emit on click.\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\" />\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Playing with props\n\nConfiguring the events to emit when the filter is clicked.\n\n```vue\n<template>\n <HierarchicalFilter :clickEvents=\"{ UserClickedAHierarchicalFilter: filter }\" :filter=\"filter\" />\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Customizing the default slot content\n\nIn this example, the child filters will also include the label and checkbox.\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\" v-slot=\"{ filter, clickFilter, slotCSSClasses, isDisabled }\">\n <label :class=\"slotCSSClasses\">\n <input @change=\"clickFilter\" :disabled=\"isDisabled\" />\n {{ filter.label }}\n </label>\n </HierarchicalFilter>\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Customizing the label slot content\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\">\n <template #label :filter=\"filter\">\n <span class=\"custom-class\">{{ filter.label }}</span>\n </template>\n </HierarchicalFilter>\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"hierarchical-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/hierarchical-filter.vue"],"sourcesContent":["<template>\n <div class=\"x-hierarchical-filter-container\" data-test=\"hierarchical-filter-container\">\n <RenderlessFilter\n v-slot=\"{ filter, clickFilter, cssClasses, isDisabled }\"\n :class=\"cssClasses\"\n :clickEvents=\"_clickEvents\"\n :filter=\"filter\"\n class=\"x-hierarchical-filter\"\n >\n <!--\n @slot The content to render inside the button.\n @binding {Filter} filter - The filter data.\n @binding {Function} clickFilter - The handler to invoke when clicking the filter.\n @binding {VueCssClasses} cssClasses - The CSS classes.\n @binding {boolean} isDisabled - Flag determining the disabled state.\n -->\n <slot v-bind=\"{ filter, clickFilter, cssClasses, isDisabled }\">\n <button\n @click=\"clickFilter\"\n :aria-checked=\"filter.selected.toString()\"\n :class=\"cssClasses\"\n :disabled=\"isDisabled\"\n data-test=\"filter\"\n role=\"checkbox\"\n >\n <!--\n @slot The content to render inside the button.\n @binding {Filter} filter - The filter data.\n -->\n <slot name=\"label\" :filter=\"filter\">{{ filter.label }}</slot>\n </button>\n </slot>\n </RenderlessFilter>\n <FiltersList\n v-slot=\"{ filter: childFilter }\"\n :animation=\"childrenAnimation\"\n :filters=\"renderedChildrenFilters\"\n :parent-id=\"filter.id\"\n class=\"x-hierarchical-filter__children\"\n data-test=\"children-filters\"\n >\n <HierarchicalFilter\n :childrenAnimation=\"childrenAnimation\"\n :filter=\"childFilter\"\n :clickEvents=\"getChildFilterClickEvents(childFilter)\"\n >\n <template #default=\"{ filter, clickFilter, cssClasses, isDisabled }\">\n <slot v-bind=\"{ filter, clickFilter, cssClasses, isDisabled }\" />\n </template>\n <template #label=\"{ filter }\">\n <slot name=\"label\" :filter=\"filter\" />\n </template>\n </HierarchicalFilter>\n </FiltersList>\n </div>\n</template>\n\n<script lang=\"ts\">\n import {\n Filter,\n HierarchicalFilter as HierarchicalFilterModel,\n isHierarchicalFilter\n } from '@empathyco/x-types';\n import { isObject } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { xComponentMixin } from '../../../../components/x-component.mixin';\n import { VueCSSClasses } from '../../../../utils/types';\n import { XEventsTypes } from '../../../../wiring/events.types';\n import { facetsXModule } from '../../x-module';\n import FiltersList from '../lists/filters-list.vue';\n import 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 })\n export 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</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAFilter`](x-components.xeventstypes.userclickedafilter.md): the event is emitted\n after the user clicks the button, using the `filter` prop as its payload.\n- [`UserClickedAHierarchicalFilter`](x-components.xeventstypes.userclickedahierarchicalfilter.md):\n the event is emitted after the user clicks the button, using the `filter` prop as its payload.\n filter.\n\n## See it in action\n\nThis component renders a button, which on clicked emits the `UserClickedAFilter` and\n`UserClickedAHierarchicalFilter` events. By default it renders the filter label as the button text.\nIf the provided filter has children filters, this component will render them recursively. Changing\nthe slot content will change it for all of the children.\n\nThe `filter` prop is required. The `clickEvents` prop is optional and allows configuring the events\nto emit on click.\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\" />\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Playing with props\n\nConfiguring the events to emit when the filter is clicked.\n\n```vue\n<template>\n <HierarchicalFilter :clickEvents=\"{ UserClickedAHierarchicalFilter: filter }\" :filter=\"filter\" />\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Customizing the default slot content\n\nIn this example, the child filters will also include the label and checkbox.\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\" v-slot=\"{ filter, clickFilter, slotCSSClasses, isDisabled }\">\n <label :class=\"slotCSSClasses\">\n <input @change=\"clickFilter\" :disabled=\"isDisabled\" />\n {{ filter.label }}\n </label>\n </HierarchicalFilter>\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n\n### Customizing the label slot content\n\n```vue\n<template>\n <HierarchicalFilter :filter=\"filter\">\n <template #label :filter=\"filter\">\n <span class=\"custom-class\">{{ filter.label }}</span>\n </template>\n </HierarchicalFilter>\n</template>\n\n<script>\n import { HierarchicalFilter } from '@empathyco/x-components/facets';\n\n export default {\n name: 'HierarchicalFilterTest',\n components: {\n HierarchicalFilter\n },\n date() {\n return {\n filter: {\n id: `categories:men`,\n modelName: 'HierarchicalFilter',\n label: `men`,\n facetId: 'categories',\n parentId: null,\n totalResults: 10,\n children: [],\n selected: false\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|