@empathyco/x-components 3.0.0-alpha.173 → 3.0.0-alpha.175

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 (60) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/core/index.js +1 -0
  3. package/core/index.js.map +1 -1
  4. package/design-system/base.css +17 -17
  5. package/design-system/default-theme.css +10 -10
  6. package/design-system/full-theme.css +10 -10
  7. package/docs/API-reference/api/x-components.facetsmutations.md +1 -0
  8. package/docs/API-reference/api/x-components.facetsmutations.setquery.md +24 -0
  9. package/docs/API-reference/api/x-components.facetsservice.md +1 -0
  10. package/docs/API-reference/api/x-components.facetsservice.setquery.md +24 -0
  11. package/docs/API-reference/api/x-components.facetsstate.md +1 -0
  12. package/docs/API-reference/api/x-components.facetsstate.query.md +13 -0
  13. package/docs/API-reference/api/x-components.facetsxevents.facetsquerychanged.md +13 -0
  14. package/docs/API-reference/api/x-components.facetsxevents.md +1 -0
  15. package/docs/API-reference/api/x-components.md +1 -0
  16. package/docs/API-reference/api/x-components.split_words_regex.md +13 -0
  17. package/docs/API-reference/api/x-components.xcomponentaliasqueryapi.facets.md +13 -0
  18. package/docs/API-reference/api/x-components.xcomponentaliasqueryapi.md +1 -0
  19. package/facets/index.js +1 -1
  20. package/js/index.js +2 -1
  21. package/js/index.js.map +1 -1
  22. package/js/plugins/x-plugin.alias.js +1 -0
  23. package/js/plugins/x-plugin.alias.js.map +1 -1
  24. package/js/utils/is-new-query.js +48 -0
  25. package/js/utils/is-new-query.js.map +1 -0
  26. package/js/x-modules/facets/service/facets.service.js +9 -0
  27. package/js/x-modules/facets/service/facets.service.js.map +1 -1
  28. package/js/x-modules/facets/store/emitters.js +5 -0
  29. package/js/x-modules/facets/store/emitters.js.map +1 -1
  30. package/js/x-modules/facets/store/module.js +4 -0
  31. package/js/x-modules/facets/store/module.js.map +1 -1
  32. package/js/x-modules/facets/utils.js +1 -40
  33. package/js/x-modules/facets/utils.js.map +1 -1
  34. package/js/x-modules/facets/wiring.js +21 -2
  35. package/js/x-modules/facets/wiring.js.map +1 -1
  36. package/package.json +3 -3
  37. package/report/x-components.api.json +188 -0
  38. package/report/x-components.api.md +21 -0
  39. package/types/plugins/x-plugin.alias.d.ts.map +1 -1
  40. package/types/plugins/x-plugin.types.d.ts +2 -0
  41. package/types/plugins/x-plugin.types.d.ts.map +1 -1
  42. package/types/utils/index.d.ts +1 -0
  43. package/types/utils/index.d.ts.map +1 -1
  44. package/types/utils/is-new-query.d.ts +36 -0
  45. package/types/utils/is-new-query.d.ts.map +1 -0
  46. package/types/x-modules/facets/events.types.d.ts +5 -0
  47. package/types/x-modules/facets/events.types.d.ts.map +1 -1
  48. package/types/x-modules/facets/service/facets.service.d.ts +7 -0
  49. package/types/x-modules/facets/service/facets.service.d.ts.map +1 -1
  50. package/types/x-modules/facets/service/types.d.ts +6 -0
  51. package/types/x-modules/facets/service/types.d.ts.map +1 -1
  52. package/types/x-modules/facets/store/emitters.d.ts +5 -0
  53. package/types/x-modules/facets/store/emitters.d.ts.map +1 -1
  54. package/types/x-modules/facets/store/module.d.ts.map +1 -1
  55. package/types/x-modules/facets/store/types.d.ts +8 -0
  56. package/types/x-modules/facets/store/types.d.ts.map +1 -1
  57. package/types/x-modules/facets/utils.d.ts +0 -29
  58. package/types/x-modules/facets/utils.d.ts.map +1 -1
  59. package/types/x-modules/facets/wiring.d.ts +7 -0
  60. package/types/x-modules/facets/wiring.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
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.175](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.174...@empathyco/x-components@3.0.0-alpha.175) (2022-09-20)
7
+
8
+ ### Features
9
+
10
+ - **facets:** remove filters on new query (#717)
11
+ ([e452ece](https://github.com/empathyco/x/commit/e452ecebb194b2fa248402405e26ed1044c1d849)),
12
+ closes [EX-6196](https://searchbroker.atlassian.net/browse/EX-6196)
13
+
14
+ # Change Log
15
+
16
+ All notable changes to this project will be documented in this file. See
17
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
18
+
19
+ ## [3.0.0-alpha.174](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.173...@empathyco/x-components@3.0.0-alpha.174) (2022-09-19)
20
+
21
+ ### Features
22
+
23
+ - **design-system:** generate old design system tokens with tailwind values (#675)
24
+ ([7aa42e4](https://github.com/empathyco/x/commit/7aa42e4e26ec34fea942bbf7f0c7f10a97a94237)),
25
+ closes [EX-6790](https://searchbroker.atlassian.net/browse/EX-6790)
26
+
27
+ # Change Log
28
+
29
+ All notable changes to this project will be documented in this file. See
30
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
31
+
6
32
  ## [3.0.0-alpha.173](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.172...@empathyco/x-components@3.0.0-alpha.173) (2022-09-16)
7
33
 
8
34
  **Note:** Version bump only for package @empathyco/x-components
package/core/index.js CHANGED
@@ -145,6 +145,7 @@ export { areFiltersDifferent, createRawFilters } from '../js/utils/filters.js';
145
145
  export { noOp } from '../js/utils/function.js';
146
146
  export { getURLParameter } from '../js/utils/get-url-parameters.js';
147
147
  export { isElementEqualOrContained } from '../js/utils/html.js';
148
+ export { SPLIT_WORDS_REGEX, isNewQuery } from '../js/utils/is-new-query.js';
148
149
  export { normalizeString } from '../js/utils/normalize.js';
149
150
  export { isInRange } from '../js/utils/number.js';
150
151
  export { createOrigin } from '../js/utils/origin.js';
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,12 +1,19 @@
1
1
  :root {
2
- --x-color-base-lead: #36515b;
3
- --x-color-base-auxiliary: #667981;
2
+ --x-size-border-radius-base-none: 0;
3
+ --x-size-border-radius-base-s: var(--x-size-base-02);
4
+ --x-size-border-radius-base-m: var(--x-size-base-06);
5
+ --x-size-border-radius-base-pill: 99999px;
6
+ --x-size-border-width-base: 1px;
7
+ }
8
+ :root {
9
+ --x-color-base-lead: #243d48;
10
+ --x-color-base-auxiliary: #BFE1EC;
4
11
  --x-color-base-neutral-10: #1a1a1a;
5
12
  --x-color-base-neutral-35: #595959;
6
13
  --x-color-base-neutral-70: #b3b3b3;
7
14
  --x-color-base-neutral-95: #f2f2f2;
8
15
  --x-color-base-neutral-100: #ffffff;
9
- --x-color-base-accent: #b90276;
16
+ --x-color-base-accent: #0086B2;
10
17
  --x-color-base-enable: #00705c;
11
18
  --x-color-base-disable: #e11f26;
12
19
  --x-color-base-transparent: transparent;
@@ -23,15 +30,15 @@
23
30
  --x-size-base-09: 48px;
24
31
  --x-size-base-10: 56px;
25
32
  --x-size-base-11: 64px;
26
- --x-size-base-12: 72px;
33
+ --x-size-base-12: 80px;
27
34
  --x-size-base-13: 80px;
28
35
  --x-size-base-14: 96px;
29
- --x-size-base-15: 112px;
30
- --x-size-base-16: 144px;
31
- --x-size-base-17: 176px;
32
- --x-size-base-18: 208px;
33
- --x-size-base-19: 240px;
34
- --x-size-base-20: 272px;
36
+ --x-size-base-15: 128px;
37
+ --x-size-base-16: 152px;
38
+ --x-size-base-17: 184px;
39
+ --x-size-base-18: 216px;
40
+ --x-size-base-19: 280px;
41
+ --x-size-base-20: 344px;
35
42
  }
36
43
  :root {
37
44
  --x-font-family-base: "Montserrat", sans-serif;
@@ -46,11 +53,4 @@
46
53
  --x-size-line-height-base-s: 16px;
47
54
  --x-size-line-height-base-m: 24px;
48
55
  --x-size-line-height-base-l: 32px;
49
- }
50
- :root {
51
- --x-size-border-radius-base-none: 0;
52
- --x-size-border-radius-base-s: var(--x-size-base-02);
53
- --x-size-border-radius-base-m: var(--x-size-base-06);
54
- --x-size-border-radius-base-pill: 99999px;
55
- --x-size-border-width-base: 1px;
56
56
  }
@@ -2855,14 +2855,14 @@
2855
2855
  --x-size-border-width-base: 1px;
2856
2856
  }
2857
2857
  :root {
2858
- --x-color-base-lead: #36515b;
2859
- --x-color-base-auxiliary: #667981;
2858
+ --x-color-base-lead: #243d48;
2859
+ --x-color-base-auxiliary: #BFE1EC;
2860
2860
  --x-color-base-neutral-10: #1a1a1a;
2861
2861
  --x-color-base-neutral-35: #595959;
2862
2862
  --x-color-base-neutral-70: #b3b3b3;
2863
2863
  --x-color-base-neutral-95: #f2f2f2;
2864
2864
  --x-color-base-neutral-100: #ffffff;
2865
- --x-color-base-accent: #b90276;
2865
+ --x-color-base-accent: #0086B2;
2866
2866
  --x-color-base-enable: #00705c;
2867
2867
  --x-color-base-disable: #e11f26;
2868
2868
  --x-color-base-transparent: transparent;
@@ -2879,15 +2879,15 @@
2879
2879
  --x-size-base-09: 48px;
2880
2880
  --x-size-base-10: 56px;
2881
2881
  --x-size-base-11: 64px;
2882
- --x-size-base-12: 72px;
2882
+ --x-size-base-12: 80px;
2883
2883
  --x-size-base-13: 80px;
2884
2884
  --x-size-base-14: 96px;
2885
- --x-size-base-15: 112px;
2886
- --x-size-base-16: 144px;
2887
- --x-size-base-17: 176px;
2888
- --x-size-base-18: 208px;
2889
- --x-size-base-19: 240px;
2890
- --x-size-base-20: 272px;
2885
+ --x-size-base-15: 128px;
2886
+ --x-size-base-16: 152px;
2887
+ --x-size-base-17: 184px;
2888
+ --x-size-base-18: 216px;
2889
+ --x-size-base-19: 280px;
2890
+ --x-size-base-20: 344px;
2891
2891
  }
2892
2892
  :root {
2893
2893
  --x-font-family-base: "Montserrat", sans-serif;
@@ -6,14 +6,14 @@
6
6
  --x-size-border-width-base: 1px;
7
7
  }
8
8
  :root {
9
- --x-color-base-lead: #36515b;
10
- --x-color-base-auxiliary: #667981;
9
+ --x-color-base-lead: #243d48;
10
+ --x-color-base-auxiliary: #BFE1EC;
11
11
  --x-color-base-neutral-10: #1a1a1a;
12
12
  --x-color-base-neutral-35: #595959;
13
13
  --x-color-base-neutral-70: #b3b3b3;
14
14
  --x-color-base-neutral-95: #f2f2f2;
15
15
  --x-color-base-neutral-100: #ffffff;
16
- --x-color-base-accent: #b90276;
16
+ --x-color-base-accent: #0086B2;
17
17
  --x-color-base-enable: #00705c;
18
18
  --x-color-base-disable: #e11f26;
19
19
  --x-color-base-transparent: transparent;
@@ -30,15 +30,15 @@
30
30
  --x-size-base-09: 48px;
31
31
  --x-size-base-10: 56px;
32
32
  --x-size-base-11: 64px;
33
- --x-size-base-12: 72px;
33
+ --x-size-base-12: 80px;
34
34
  --x-size-base-13: 80px;
35
35
  --x-size-base-14: 96px;
36
- --x-size-base-15: 112px;
37
- --x-size-base-16: 144px;
38
- --x-size-base-17: 176px;
39
- --x-size-base-18: 208px;
40
- --x-size-base-19: 240px;
41
- --x-size-base-20: 272px;
36
+ --x-size-base-15: 128px;
37
+ --x-size-base-16: 152px;
38
+ --x-size-base-17: 184px;
39
+ --x-size-base-18: 216px;
40
+ --x-size-base-19: 280px;
41
+ --x-size-base-20: 344px;
42
42
  }
43
43
  :root {
44
44
  --x-font-family-base: "Montserrat", sans-serif;
@@ -24,4 +24,5 @@ export interface FacetsMutations
24
24
  | [setFacetGroup(facetGroupEntry)](./x-components.facetsmutations.setfacetgroup.md) | Sets the group id of the facet. |
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
+ | [setQuery(query)](./x-components.facetsmutations.setquery.md) | Sets the [FacetsState.query](./x-components.facetsstate.query.md) property. |
27
28
 
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [FacetsMutations](./x-components.facetsmutations.md) &gt; [setQuery](./x-components.facetsmutations.setquery.md)
4
+
5
+ ## FacetsMutations.setQuery() method
6
+
7
+ Sets the [FacetsState.query](./x-components.facetsstate.query.md) property.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ setQuery(query: string): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | query | string | The new [FacetsState.query](./x-components.facetsstate.query.md)<!-- -->. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ void
24
+
@@ -21,6 +21,7 @@ export interface FacetsService
21
21
  | [select(filter)](./x-components.facetsservice.select.md) | Selects filter/filters, adding it/them to the store if it/they was not present. |
22
22
  | [selectPreselectedFilters()](./x-components.facetsservice.selectpreselectedfilters.md) | Selects preselected filter/filters, adding it/them to the store if it/they was not present. |
23
23
  | [setFacets(facetsGroup)](./x-components.facetsservice.setfacets.md) | Sets the facets of the group. This method just replaces the facets, and keeps the given facet's filters selected state as it is. |
24
+ | [setQuery(query)](./x-components.facetsservice.setquery.md) | Sets the query. |
24
25
  | [toggle(filter)](./x-components.facetsservice.toggle.md) | Selects a deselected filter, and deselects a selected filter, adding them to the store in both cases. |
25
26
  | [updateFacets(facetsGroup)](./x-components.facetsservice.updatefacets.md) | Replaces the facets of the group with the new ones. It ignores the provided filters selected state, replacing it with the previous selected filter. |
26
27
  | [updatePreselectedFilters(filters)](./x-components.facetsservice.updatepreselectedfilters.md) | Replaces the preselected filters with the new ones. |
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [FacetsService](./x-components.facetsservice.md) &gt; [setQuery](./x-components.facetsservice.setquery.md)
4
+
5
+ ## FacetsService.setQuery() method
6
+
7
+ Sets the query.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ setQuery(query: string): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | query | string | The query searched. |
20
+
21
+ <b>Returns:</b>
22
+
23
+ void
24
+
@@ -20,4 +20,5 @@ export interface FacetsState
20
20
  | [filters](./x-components.facetsstate.filters.md) | Record&lt;Filter\['id'\], Filter&gt; | Record of all available filters indexed by its id. |
21
21
  | [groups](./x-components.facetsstate.groups.md) | Record&lt;Facet\['id'\], [GroupId](./x-components.groupid.md)<!-- -->&gt; | Record specifying the group each facet belongs to. |
22
22
  | [preselectedFilters](./x-components.facetsstate.preselectedfilters.md) | RawFilter\[\] | Record of preselected filters indexed by its id. |
23
+ | [query](./x-components.facetsstate.query.md) | string | The current query [FacetsState.query](./x-components.facetsstate.query.md)<!-- -->. |
23
24
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [FacetsState](./x-components.facetsstate.md) &gt; [query](./x-components.facetsstate.query.md)
4
+
5
+ ## FacetsState.query property
6
+
7
+ The current query [FacetsState.query](./x-components.facetsstate.query.md)<!-- -->.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ query: string;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [FacetsXEvents](./x-components.facetsxevents.md) &gt; [FacetsQueryChanged](./x-components.facetsxevents.facetsquerychanged.md)
4
+
5
+ ## FacetsXEvents.FacetsQueryChanged property
6
+
7
+ The query used in the module has changed. Payload: The facets query.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ FacetsQueryChanged: string;
13
+ ```
@@ -18,6 +18,7 @@ export interface FacetsXEvents
18
18
  | --- | --- | --- |
19
19
  | [FacetsGroupChanged](./x-components.facetsxevents.facetsgroupchanged.md) | [FacetsGroup](./x-components.facetsgroup.md) | The facets from a group have changed Payload: The group id and the new list of facets for it. |
20
20
  | [FacetsGroupProvided](./x-components.facetsxevents.facetsgroupprovided.md) | [FacetsGroup](./x-components.facetsgroup.md) | A new set of facets for the group has been provided. Payload: The group id and the new list of facets for it. |
21
+ | [FacetsQueryChanged](./x-components.facetsxevents.facetsquerychanged.md) | string | The query used in the module has changed. Payload: The facets query. |
21
22
  | [PreselectedFiltersProvided](./x-components.facetsxevents.preselectedfiltersprovided.md) | RawFilter\[\] | The selected filters provided in the [SnippetConfig](./x-components.snippetconfig.md)<!-- -->. Payload: the raw filters. |
22
23
  | [SelectedFiltersChanged](./x-components.facetsxevents.selectedfilterschanged.md) | Filter\[\] | The selected filters have changed. Payload: the new list of selected filters. |
23
24
  | [UserChangedSelectedFilters](./x-components.facetsxevents.userchangedselectedfilters.md) | Filter\[\] | A user action has changed the selected filters. Payload: The new list of selected filters. |
@@ -574,6 +574,7 @@ X-Components is a library usable everywhere not only for search experiences.
574
574
  | [setUrlScroll](./x-components.seturlscroll.md) | Sets the scroll of the url module. |
575
575
  | [setUrlSort](./x-components.seturlsort.md) | Sets the sort of the url module. |
576
576
  | [ShowIcon](./x-components.showicon.md) | |
577
+ | [SPLIT\_WORDS\_REGEX](./x-components.split_words_regex.md) | Regex for splitting a query into its words. |
577
578
  | [StarIcon](./x-components.staricon.md) | |
578
579
  | [storageKey](./x-components.storagekey.md) | Default implementation for the [HistoryQueriesGetters.storageKey](./x-components.historyqueriesgetters.storagekey.md) getter. |
579
580
  | [taggingXModule](./x-components.taggingxmodule.md) | Tagging [XModule](./x-components.xmodule.md) implementation. This module is auto-registered as soon as you import any component from the <code>empathize</code> entry point. |
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [SPLIT\_WORDS\_REGEX](./x-components.split_words_regex.md)
4
+
5
+ ## SPLIT\_WORDS\_REGEX variable
6
+
7
+ Regex for splitting a query into its words.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ SPLIT_WORDS_REGEX: RegExp
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [XComponentAliasQueryAPI](./x-components.xcomponentaliasqueryapi.md) &gt; [facets](./x-components.xcomponentaliasqueryapi.facets.md)
4
+
5
+ ## XComponentAliasQueryAPI.facets property
6
+
7
+ The [FacetsXModule](./x-components.facetsxmodule.md) query.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ readonly facets: string;
13
+ ```
@@ -16,6 +16,7 @@ export interface XComponentAliasQueryAPI
16
16
 
17
17
  | Property | Type | Description |
18
18
  | --- | --- | --- |
19
+ | [facets](./x-components.xcomponentaliasqueryapi.facets.md) | string | The [FacetsXModule](./x-components.facetsxmodule.md) query. |
19
20
  | [nextQueries](./x-components.xcomponentaliasqueryapi.nextqueries.md) | string | The [NextQueriesXModule](./x-components.nextqueriesxmodule.md) query. |
20
21
  | [querySuggestions](./x-components.xcomponentaliasqueryapi.querysuggestions.md) | string | The [QuerySuggestionsXModule](./x-components.querysuggestionsxmodule.md) query. |
21
22
  | [relatedTags](./x-components.xcomponentaliasqueryapi.relatedtags.md) | string | The [RelatedTagsXModule](./x-components.relatedtagsxmodule.md) query. |
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 { flatHierarchicalFilters, isNewQuery } from '../js/x-modules/facets/utils.js';
35
+ export { flatHierarchicalFilters } 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
@@ -145,6 +145,7 @@ export { areFiltersDifferent, createRawFilters } from './utils/filters.js';
145
145
  export { noOp } from './utils/function.js';
146
146
  export { getURLParameter } from './utils/get-url-parameters.js';
147
147
  export { isElementEqualOrContained } from './utils/html.js';
148
+ export { SPLIT_WORDS_REGEX, isNewQuery } from './utils/is-new-query.js';
148
149
  export { normalizeString } from './utils/normalize.js';
149
150
  export { isInRange } from './utils/number.js';
150
151
  export { createOrigin } from './utils/origin.js';
@@ -210,7 +211,7 @@ export { default as SelectedFiltersList } from './x-modules/facets/components/li
210
211
  export { default as SlicedFilters } from './x-modules/facets/components/lists/sliced-filters.vue.js';
211
212
  export { default as SortedFilters } from './x-modules/facets/components/lists/sorted-filters.vue.js';
212
213
  export { default as ClearFilters } from './x-modules/facets/components/clear-filters.vue.js';
213
- export { flatHierarchicalFilters, isNewQuery } from './x-modules/facets/utils.js';
214
+ export { flatHierarchicalFilters } from './x-modules/facets/utils.js';
214
215
  export { default as FacetsMixin } from './x-modules/facets/components/facets.mixin.js';
215
216
  export { default as ClearHistoryQueries } from './x-modules/history-queries/components/clear-history-queries.vue.js';
216
217
  export { default as HistoryQueries } from './x-modules/history-queries/components/history-queries.vue.js';
package/js/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -10,6 +10,7 @@ import { getGetterPath } from './x-plugin.utils.js';
10
10
  */
11
11
  function getAliasAPI(component) {
12
12
  const queryModules = [
13
+ 'facets',
13
14
  'searchBox',
14
15
  'nextQueries',
15
16
  'querySuggestions',
@@ -1 +1 @@
1
- {"version":3,"file":"x-plugin.alias.js","sources":["../../../src/plugins/x-plugin.alias.ts"],"sourcesContent":["import Vue from 'vue';\nimport { RequestStatus } from '../store/utils/status-store.utils';\nimport {\n XComponentAliasAPI,\n XComponentAliasQueryAPI,\n XComponentAliasStatusAPI\n} from './x-plugin.types';\nimport { getGetterPath } from './x-plugin.utils';\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @param component - The component with the store from which retrieve the data.\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function getAliasAPI(component: Vue): XComponentAliasAPI {\n const queryModules = [\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search'\n ] as const;\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search'\n ] as const;\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return component.$store.state.x[moduleName]?.query ?? '';\n },\n enumerable: true\n });\n }, {} as XComponentAliasQueryAPI);\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return component.$store.state.x[moduleName]?.status;\n },\n enumerable: true\n });\n }, {} as XComponentAliasStatusAPI);\n\n return {\n query,\n status,\n get device() {\n return component.$store.state.x.device?.name ?? null;\n },\n get facets() {\n return component.$store.getters[getGetterPath('facets', 'facets')] ?? {};\n },\n get historyQueries() {\n return component.$store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? [];\n },\n get fullHistoryQueries() {\n return component.$store.state.x.historyQueries?.historyQueries ?? [];\n },\n get identifierResults() {\n return component.$store.state.x.identifierResults?.identifierResults ?? [];\n },\n get isEmpathizeOpen() {\n return component.$store.state.x.empathize?.isOpen ?? false;\n },\n get nextQueries() {\n return component.$store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? [];\n },\n get noResults() {\n return !this.totalResults && !!this.query.search && this.status.search === 'success';\n },\n get partialResults() {\n return component.$store.state.x.search?.partialResults ?? [];\n },\n get popularSearches() {\n return component.$store.state.x.popularSearches?.popularSearches ?? [];\n },\n get querySuggestions() {\n return component.$store.state.x.querySuggestions?.suggestions ?? [];\n },\n get recommendations() {\n return component.$store.state.x.recommendations?.recommendations ?? [];\n },\n get redirections() {\n return component.$store.state.x.search?.redirections ?? [];\n },\n get relatedTags() {\n return component.$store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? [];\n },\n get results() {\n return component.$store.state.x.search?.results ?? [];\n },\n get scroll() {\n return component.$store.state.x.scroll?.data ?? {};\n },\n get selectedFilters() {\n return component.$store.getters[getGetterPath('facets', 'selectedFilters')] ?? [];\n },\n get selectedRelatedTags() {\n return component.$store.state.x.relatedTags?.selectedRelatedTags ?? [];\n },\n get spellcheckedQuery() {\n return component.$store.state.x.search?.spellcheckedQuery ?? null;\n },\n get totalResults() {\n return component.$store.state.x.search?.totalResults ?? 0;\n },\n get selectedSort() {\n return component.$store.state.x.search?.sort ?? '';\n }\n };\n}\n"],"names":[],"mappings":";;AASA;;;;;;;;SAQgB,WAAW,CAAC,SAAc;IACxC,MAAM,YAAY,GAAG;QACnB,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,QAAQ;KACA,CAAC;IACX,MAAM,aAAa,GAAG;QACpB,mBAAmB;Q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,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;SACpF;QACD,IAAI,OAAO;YACT,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;SACvD;QACD,IAAI,MAAM;YACR,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;SACpD;QACD,IAAI,eAAe;YACjB,OAAO,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC;SACnF;QACD,IAAI,mBAAmB;YACrB,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,mBAAmB,IAAI,EAAE,CAAC;SACxE;QACD,IAAI,iBAAiB;YACnB,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,iBAAiB,IAAI,IAAI,CAAC;SACnE;QACD,IAAI,YAAY;YACd,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC,CAAC;SAC3D;QACD,IAAI,YAAY;YACd,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;SACpD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"x-plugin.alias.js","sources":["../../../src/plugins/x-plugin.alias.ts"],"sourcesContent":["import Vue from 'vue';\nimport { RequestStatus } from '../store/utils/status-store.utils';\nimport {\n XComponentAliasAPI,\n XComponentAliasQueryAPI,\n XComponentAliasStatusAPI\n} from './x-plugin.types';\nimport { getGetterPath } from './x-plugin.utils';\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @param component - The component with the store from which retrieve the data.\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function getAliasAPI(component: Vue): XComponentAliasAPI {\n const queryModules = [\n 'facets',\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search'\n ] as const;\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search'\n ] as const;\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return component.$store.state.x[moduleName]?.query ?? '';\n },\n enumerable: true\n });\n }, {} as XComponentAliasQueryAPI);\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return component.$store.state.x[moduleName]?.status;\n },\n enumerable: true\n });\n }, {} as XComponentAliasStatusAPI);\n\n return {\n query,\n status,\n get device() {\n return component.$store.state.x.device?.name ?? null;\n },\n get facets() {\n return component.$store.getters[getGetterPath('facets', 'facets')] ?? {};\n },\n get historyQueries() {\n return component.$store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? [];\n },\n get fullHistoryQueries() {\n return component.$store.state.x.historyQueries?.historyQueries ?? [];\n },\n get identifierResults() {\n return component.$store.state.x.identifierResults?.identifierResults ?? [];\n },\n get isEmpathizeOpen() {\n return component.$store.state.x.empathize?.isOpen ?? false;\n },\n get nextQueries() {\n return component.$store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? [];\n },\n get noResults() {\n return !this.totalResults && !!this.query.search && this.status.search === 'success';\n },\n get partialResults() {\n return component.$store.state.x.search?.partialResults ?? [];\n },\n get popularSearches() {\n return component.$store.state.x.popularSearches?.popularSearches ?? [];\n },\n get querySuggestions() {\n return component.$store.state.x.querySuggestions?.suggestions ?? [];\n },\n get recommendations() {\n return component.$store.state.x.recommendations?.recommendations ?? [];\n },\n get redirections() {\n return component.$store.state.x.search?.redirections ?? [];\n },\n get relatedTags() {\n return component.$store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? [];\n },\n get results() {\n return component.$store.state.x.search?.results ?? [];\n },\n get scroll() {\n return component.$store.state.x.scroll?.data ?? {};\n },\n get selectedFilters() {\n return component.$store.getters[getGetterPath('facets', 'selectedFilters')] ?? [];\n },\n get selectedRelatedTags() {\n return component.$store.state.x.relatedTags?.selectedRelatedTags ?? [];\n },\n get spellcheckedQuery() {\n return component.$store.state.x.search?.spellcheckedQuery ?? null;\n },\n get totalResults() {\n return component.$store.state.x.search?.totalResults ?? 0;\n },\n get selectedSort() {\n return component.$store.state.x.search?.sort ?? '';\n }\n };\n}\n"],"names":[],"mappings":";;AASA;;;;;;;;SAQgB,WAAW,CAAC,SAAc;IACxC,MAAM,YAAY,GAAG;QACnB,QAAQ;QACR,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,QAAQ;KACA,CAAC;IACX,MAAM,aAAa,GAAG;QACpB,mBAAmB;QACnB,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,QAAQ;KACA,CAAC;IAEX,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU;QAChD,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG;gBACD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;aAC1D;YACD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;KACJ,EAAE,EAA6B,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU;QAClD,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG;gBACD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,C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,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,iBAAiB,IAAI,IAAI,CAAC;SACnE;QACD,IAAI,YAAY;YACd,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC,CAAC;SAC3D;QACD,IAAI,YAAY;YACd,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;SACpD;KACF,CAAC;AACJ;;;;"}
@@ -0,0 +1,48 @@
1
+ import { isStringEmpty } from './string.js';
2
+
3
+ /**
4
+ * Regex for splitting a query into its words.
5
+ *
6
+ * @public
7
+ */
8
+ const SPLIT_WORDS_REGEX = /[\s-]/;
9
+ /**
10
+ * Compares two queries to know if the new one is a refined query from the previous one or a new
11
+ * one.
12
+ *
13
+ * A refined query is a query which has the previous query or part of it.
14
+ * Example:
15
+ * - previousQuery = 'lego star'.
16
+ * - newQuery = 'lego star wars'.
17
+ *
18
+ * Example:
19
+ * - previousQuery = 'lego star wars'.
20
+ * - newQuery = 'lego star'.
21
+ *
22
+ * A new query is a query which has not the previous query.
23
+ * Example:
24
+ * - previousQuery = 'lego star'.
25
+ * - newQuery = 'lego wars'.
26
+ *
27
+ * In this case, it is changing the word set, because a word is changed by another one, so
28
+ * this is changing the search intention.
29
+ *
30
+ * @param newQuery - The new query.
31
+ * @param previousQuery - The previous query.
32
+ *
33
+ * @returns A boolean which flags if the query is refined or not.
34
+ *
35
+ * @public
36
+ */
37
+ function isNewQuery(newQuery, previousQuery) {
38
+ const isNewQueryEmpty = isStringEmpty(newQuery);
39
+ const isPreviousQueryEmpty = isStringEmpty(previousQuery);
40
+ const previousQueryWords = previousQuery.split(SPLIT_WORDS_REGEX);
41
+ const newQueryWords = newQuery.split(SPLIT_WORDS_REGEX);
42
+ return (!previousQueryWords.every(previousQueryWord => newQueryWords.some(newQueryWord => newQueryWord.includes(previousQueryWord) || previousQueryWord.includes(newQueryWord))) ||
43
+ (isNewQueryEmpty && !isPreviousQueryEmpty) ||
44
+ (!isNewQueryEmpty && isPreviousQueryEmpty));
45
+ }
46
+
47
+ export { SPLIT_WORDS_REGEX, isNewQuery };
48
+ //# sourceMappingURL=is-new-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-new-query.js","sources":["../../../src/utils/is-new-query.ts"],"sourcesContent":["import { isStringEmpty } from './string';\n\n/**\n * Regex for splitting a query into its words.\n *\n * @public\n */\nexport const SPLIT_WORDS_REGEX = /[\\s-]/;\n\n/**\n * Compares two queries to know if the new one is a refined query from the previous one or a new\n * one.\n *\n * A refined query is a query which has the previous query or part of it.\n * Example:\n * - previousQuery = 'lego star'.\n * - newQuery = 'lego star wars'.\n *\n * Example:\n * - previousQuery = 'lego star wars'.\n * - newQuery = 'lego star'.\n *\n * A new query is a query which has not the previous query.\n * Example:\n * - previousQuery = 'lego star'.\n * - newQuery = 'lego wars'.\n *\n * In this case, it is changing the word set, because a word is changed by another one, so\n * this is changing the search intention.\n *\n * @param newQuery - The new query.\n * @param previousQuery - The previous query.\n *\n * @returns A boolean which flags if the query is refined or not.\n *\n * @public\n */\nexport function isNewQuery(newQuery: string, previousQuery: string): boolean {\n const isNewQueryEmpty = isStringEmpty(newQuery);\n const isPreviousQueryEmpty = isStringEmpty(previousQuery);\n const previousQueryWords = previousQuery.split(SPLIT_WORDS_REGEX);\n const newQueryWords = newQuery.split(SPLIT_WORDS_REGEX);\n return (\n !previousQueryWords.every(previousQueryWord =>\n newQueryWords.some(\n newQueryWord =>\n newQueryWord.includes(previousQueryWord) || previousQueryWord.includes(newQueryWord)\n )\n ) ||\n (isNewQueryEmpty && !isPreviousQueryEmpty) ||\n (!isNewQueryEmpty && isPreviousQueryEmpty)\n );\n}\n"],"names":[],"mappings":";;AAEA;;;;;MAKa,iBAAiB,GAAG,QAAQ;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA4BgB,UAAU,CAAC,QAAgB,EAAE,aAAqB;IAChE,MAAM,eAAe,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACxD,QACE,CAAC,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,IACzC,aAAa,CAAC,IAAI,CAChB,YAAY,IACV,YAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,CACvF,CACF;SACA,eAAe,IAAI,CAAC,oBAAoB,CAAC;SACzC,CAAC,eAAe,IAAI,oBAAoB,CAAC,EAC1C;AACJ;;;;"}
@@ -61,6 +61,15 @@ class DefaultFacetsService {
61
61
  this.select(filter);
62
62
  }
63
63
  }
64
+ /**
65
+ * Sets the query.
66
+ *
67
+ * @param query - The query searched.
68
+ * @internal
69
+ */
70
+ setQuery(query) {
71
+ this.store.commit('x/facets/setQuery', query);
72
+ }
64
73
  /**
65
74
  * Creates an entity from a filter DTO.
66
75
  *
@@ -1 +1 @@
1
- {"version":3,"file":"facets.service.js","sources":["../../../../../src/x-modules/facets/service/facets.service.ts"],"sourcesContent":["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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MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3E,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,CAChE,CAAC;QACF,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,OAAO,cAAc,CAAC;KACvB;;;;;;;IAQS,aAAa,CAAC,UAA2B;QACjD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;KACzD;;;;;;;;IASS,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAS;QACjD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;KACnD;;;;;;;IAQS,WAAW,CAAC,KAA6B;QACjD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;KAClD;;;;;;;IAQS,UAAU,CAAC,OAAiB;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;KACnD;;;;;;;IAQS,oBAAoB,CAAC,OAAiB;QAC9C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,gCAAgC,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;;;;"}
1
+ {"version":3,"file":"facets.service.js","sources":["../../../../../src/x-modules/facets/service/facets.service.ts"],"sourcesContent":["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 * Sets the query.\n *\n * @param query - The query searched.\n * @internal\n */\n setQuery(query: string): void {\n this.store.commit('x/facets/setQuery', query);\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;aACtB,M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AAE,OAAO,CAAC,CAAC;KACnD;;;;;;;IAQS,oBAAoB,CAAC,OAAiB;QAC9C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;KAC9D;;;;;;;IAQS,aAAa,CAAC,OAAiB;QACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;KACtD;;AAvPD;;;AAGc,6BAAQ,GAAkB,IAAI,oBAAoB,EAAE;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { createStoreEmitters } from '../../../store/utils/store-emitters.utils.js';
2
2
  import { areFiltersDifferent } from '../../../utils/filters.js';
3
+ import { isNewQuery } from '../../../utils/is-new-query.js';
3
4
  import { facetsXStoreModule } from './module.js';
4
5
 
5
6
  /**
@@ -11,6 +12,10 @@ const facetsEmitters = createStoreEmitters(facetsXStoreModule, {
11
12
  SelectedFiltersChanged: {
12
13
  selector: (_, getters) => getters.selectedFilters,
13
14
  filter: areFiltersDifferent
15
+ },
16
+ FacetsQueryChanged: {
17
+ selector: state => state.query,
18
+ filter: isNewQuery
14
19
  }
15
20
  });
16
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"emitters.js","sources":["../../../../../src/x-modules/facets/store/emitters.ts"],"sourcesContent":["import { createStoreEmitters } from '../../../store/utils/store-emitters.utils';\nimport { areFiltersDifferent } from '../../../utils/filters';\nimport { facetsXStoreModule } from './module';\n\n/**\n * {@link StoreEmitters} For the facets module.\n *\n * @internal\n */\nexport const facetsEmitters = createStoreEmitters(facetsXStoreModule, {\n SelectedFiltersChanged: {\n selector: (_, getters) => getters.selectedFilters,\n filter: areFiltersDifferent\n }\n});\n"],"names":[],"mappings":";;;;AAIA;;;;;MAKa,cAAc,GAAG,mBAAmB,CAAC,kBAAkB,EAAE;IACpE,sBAAsB,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,eAAe;QACjD,MAAM,EAAE,mBAAmB;KAC5B;CACF;;;;"}
1
+ {"version":3,"file":"emitters.js","sources":["../../../../../src/x-modules/facets/store/emitters.ts"],"sourcesContent":["import { createStoreEmitters } from '../../../store/utils/store-emitters.utils';\nimport { areFiltersDifferent } from '../../../utils/filters';\nimport { isNewQuery } from '../../../utils/is-new-query';\nimport { facetsXStoreModule } from './module';\n\n/**\n * {@link StoreEmitters} For the facets module.\n *\n * @internal\n */\nexport const facetsEmitters = createStoreEmitters(facetsXStoreModule, {\n SelectedFiltersChanged: {\n selector: (_, getters) => getters.selectedFilters,\n filter: areFiltersDifferent\n },\n FacetsQueryChanged: {\n selector: state => state.query,\n filter: isNewQuery\n }\n});\n"],"names":[],"mappings":";;;;;AAKA;;;;;MAKa,cAAc,GAAG,mBAAmB,CAAC,kBAAkB,EAAE;IACpE,sBAAsB,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,eAAe;QACjD,MAAM,EAAE,mBAAmB;KAC5B;IACD,kBAAkB,EAAE;QAClB,QAAQ,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK;QAC9B,MAAM,EAAE,UAAU;KACnB;CACF;;;;"}
@@ -10,6 +10,7 @@ import { selectedFilters } from './getters/selected-filters.getter.js';
10
10
  */
11
11
  const facetsXStoreModule = {
12
12
  state: () => ({
13
+ query: '',
13
14
  filters: {},
14
15
  groups: {},
15
16
  facets: {},
@@ -45,6 +46,9 @@ const facetsXStoreModule = {
45
46
  },
46
47
  setFacet(state, facet) {
47
48
  Vue.set(state.facets, facet.id, facet);
49
+ },
50
+ setQuery(state, query) {
51
+ state.query = query;
48
52
  }
49
53
  },
50
54
  actions: {}