@empathyco/x-components 3.0.0-alpha.59 → 3.0.0-alpha.61

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 (67) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/core/index.js +1 -1
  3. package/core/index.js.map +1 -1
  4. package/docs/API-reference/api/x-components.clearfilters.md +4 -7
  5. package/docs/API-reference/api/x-components.every.md +27 -0
  6. package/docs/API-reference/api/x-components.facetsmixin.alwaysvisible.md +13 -0
  7. package/docs/API-reference/api/x-components.facetsmixin.facetsids.md +13 -0
  8. package/docs/API-reference/api/x-components.facetsmixin.md +22 -0
  9. package/docs/API-reference/api/x-components.md +3 -1
  10. package/docs/API-reference/api/x-components.selectedfilterslist.md +7 -5
  11. package/docs/API-reference/components/facets/x-components.clear-filters.md +4 -4
  12. package/docs/API-reference/components/facets/x-components.facets/facets.md +6 -4
  13. package/docs/API-reference/components/facets/x-components.lists/selected-filters-list.md +12 -11
  14. package/docs/API-reference/components/facets/x-components.lists/selected-filters.md +7 -7
  15. package/facets/index.js +2 -1
  16. package/js/index.js +2 -1
  17. package/js/index.js.map +1 -1
  18. package/js/utils/object.js +15 -1
  19. package/js/utils/object.js.map +1 -1
  20. package/js/x-modules/facets/components/clear-filters.vue.js +4 -6
  21. package/js/x-modules/facets/components/clear-filters.vue.js.map +1 -1
  22. package/js/x-modules/facets/components/clear-filters.vue_rollup-plugin-vue_script.vue.js +8 -56
  23. package/js/x-modules/facets/components/clear-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  24. package/js/x-modules/facets/components/facets/facets.vue.js +2 -2
  25. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  26. package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js +5 -5
  27. package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  28. package/js/x-modules/facets/components/facets.mixin.js +181 -0
  29. package/js/x-modules/facets/components/facets.mixin.js.map +1 -0
  30. package/js/x-modules/facets/components/lists/selected-filters-list.vue.js +1 -1
  31. package/js/x-modules/facets/components/lists/selected-filters-list.vue.js.map +1 -1
  32. package/js/x-modules/facets/components/lists/selected-filters-list.vue_rollup-plugin-vue_script.vue.js +6 -9
  33. package/js/x-modules/facets/components/lists/selected-filters-list.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  34. package/js/x-modules/facets/components/lists/selected-filters.vue.js +1 -1
  35. package/js/x-modules/facets/components/lists/selected-filters.vue.js.map +1 -1
  36. package/js/x-modules/facets/components/lists/selected-filters.vue_rollup-plugin-vue_script.vue.js +5 -43
  37. package/js/x-modules/facets/components/lists/selected-filters.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  38. package/js/x-modules/facets/store/getters/selected-filters-by-facet.getter.js.map +1 -1
  39. package/package.json +2 -2
  40. package/report/x-components.api.json +200 -262
  41. package/report/x-components.api.md +23 -26
  42. package/types/adapter/mocked-adapter.d.ts.map +1 -1
  43. package/types/router.d.ts.map +1 -1
  44. package/types/utils/object.d.ts +10 -0
  45. package/types/utils/object.d.ts.map +1 -1
  46. package/types/views/base-config.d.ts.map +1 -1
  47. package/types/x-modules/facets/components/clear-filters.vue.d.ts +4 -51
  48. package/types/x-modules/facets/components/clear-filters.vue.d.ts.map +1 -1
  49. package/types/x-modules/facets/components/facets/facets.vue.d.ts +4 -8
  50. package/types/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
  51. package/types/x-modules/facets/components/facets.mixin.d.ts +60 -0
  52. package/types/x-modules/facets/components/facets.mixin.d.ts.map +1 -0
  53. package/types/x-modules/facets/components/lists/selected-filters-list.vue.d.ts +6 -20
  54. package/types/x-modules/facets/components/lists/selected-filters-list.vue.d.ts.map +1 -1
  55. package/types/x-modules/facets/components/lists/selected-filters.vue.d.ts +4 -52
  56. package/types/x-modules/facets/components/lists/selected-filters.vue.d.ts.map +1 -1
  57. package/types/x-modules/facets/index.d.ts +1 -0
  58. package/types/x-modules/facets/index.d.ts.map +1 -1
  59. package/types/x-modules/facets/store/getters/selected-filters-by-facet.getter.d.ts.map +1 -1
  60. package/docs/API-reference/api/x-components.clearfilters.alwaysvisible.md +0 -13
  61. package/docs/API-reference/api/x-components.clearfilters.facetsids.md +0 -13
  62. package/docs/API-reference/api/x-components.selectedfilters.alwaysvisible.md +0 -13
  63. package/docs/API-reference/api/x-components.selectedfilters.facetid.md +0 -13
  64. package/docs/API-reference/api/x-components.selectedfilters.selectedfiltersbyfacet.md +0 -13
  65. package/docs/API-reference/api/x-components.selectedfilters.selectedfiltersgetter.md +0 -13
  66. package/docs/API-reference/api/x-components.selectedfilterslist.alwaysvisible.md +0 -15
  67. package/docs/API-reference/api/x-components.selectedfilterslist.facetid.md +0 -13
package/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
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.61](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.60...@empathyco/x-components@3.0.0-alpha.61) (2022-02-24)
7
+
8
+ ### Testing
9
+
10
+ - **e2e:** add `extra-params` scenarios
11
+ ([4275c28](https://github.com/empathyco/x/commit/4275c2811ea7b0eaaf588fa4d96a7ae3cf4c43c7)),
12
+ closes [EX-5377](https://searchbroker.atlassian.net/browse/EX-5377)
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.60](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.59...@empathyco/x-components@3.0.0-alpha.60) (2022-02-24)
20
+
21
+ ### Features
22
+
23
+ - **facets:** add facets mixin to share logic between components
24
+ ([c8a9046](https://github.com/empathyco/x/commit/c8a904612213cd12040dd6fa1348f6c9a7726eda)),
25
+ closes [EX-2899](https://searchbroker.atlassian.net/browse/EX-2899)
26
+
27
+ ### Testing
28
+
29
+ - **e2e:** fix `tagging` using the `mockedAdapter` and replacing `fetch` for `sendBeacon`
30
+ ([cf06d2f](https://github.com/empathyco/x/commit/cf06d2f7e9aff3987bc14fa46cd65eace402e612)),
31
+ closes [EX-5374](https://searchbroker.atlassian.net/browse/EX-5374)
32
+
33
+ # Change Log
34
+
35
+ All notable changes to this project will be documented in this file. See
36
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
37
+
6
38
  ## [3.0.0-alpha.59](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.58...@empathyco/x-components@3.0.0-alpha.59) (2022-02-17)
7
39
 
8
40
  ### Features
package/core/index.js CHANGED
@@ -136,7 +136,7 @@ export { getURLParameter } from '../js/utils/get-url-parameters.js';
136
136
  export { isElementEqualOrContained } from '../js/utils/html.js';
137
137
  export { normalizeString } from '../js/utils/normalize.js';
138
138
  export { isInRange } from '../js/utils/number.js';
139
- export { cleanUndefined, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce } from '../js/utils/object.js';
139
+ export { cleanUndefined, every, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce } from '../js/utils/object.js';
140
140
  export { createOrigin } from '../js/utils/origin.js';
141
141
  export { sanitize } from '../js/utils/sanitize.js';
142
142
  export { localStorageService } from '../js/utils/storage.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,14 +9,11 @@ Renders a simple button, emitting the needed events when clicked.
9
9
  <b>Signature:</b>
10
10
 
11
11
  ```typescript
12
- export default class ClearFilters extends Vue
12
+ export default class ClearFilters extends FacetsMixin
13
13
  ```
14
- <b>Extends:</b> Vue
14
+ <b>Extends:</b> FacetsMixin
15
15
 
16
- ## Properties
16
+ ## Remarks
17
17
 
18
- | Property | Modifiers | Type | Description |
19
- | --- | --- | --- | --- |
20
- | [alwaysVisible](./x-components.clearfilters.alwaysvisible.md) | | boolean | It handles if the ClearFilters button is always visible no matter if there are not filters selected. If false, the ClearFilters button is not visible whether there are no filters selected. |
21
- | [facetsIds?](./x-components.clearfilters.facetsids.md) | | Array&lt;Facet\['id'\]&gt; | <i>(Optional)</i> Array of facets ids that will be passed to event like payload. |
18
+ It extends [FacetsMixin](./x-components.facetsmixin.md)<!-- -->.
22
19
 
@@ -0,0 +1,27 @@
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; [every](./x-components.every.md)
4
+
5
+ ## every() function
6
+
7
+ Ensures that the given condition is met in all the non-undefined entries of the object.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ export declare function every<ObjectType extends Dictionary>(object: ObjectType, condition: (key: keyof ObjectType, value: Exclude<ObjectType[keyof ObjectType], undefined>, index: number) => boolean): boolean;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | object | ObjectType | The object to check if every item meets the given condition. |
20
+ | condition | (key: keyof ObjectType, value: Exclude&lt;ObjectType\[keyof ObjectType\], undefined&gt;, index: number) =&gt; boolean | The condition to check in each one of the entries of the object. |
21
+
22
+ <b>Returns:</b>
23
+
24
+ boolean
25
+
26
+ True when all the entries pass the condition. False otherwise.
27
+
@@ -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; [FacetsMixin](./x-components.facetsmixin.md) &gt; [alwaysVisible](./x-components.facetsmixin.alwaysvisible.md)
4
+
5
+ ## FacetsMixin.alwaysVisible property
6
+
7
+ Flag to render the component even if there are no filters selected.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ alwaysVisible: boolean;
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; [FacetsMixin](./x-components.facetsmixin.md) &gt; [facetsIds](./x-components.facetsmixin.facetsids.md)
4
+
5
+ ## FacetsMixin.facetsIds property
6
+
7
+ Array of facets ids used to get the selected filters for those facets.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ facetsIds?: Array<Facet['id']>;
13
+ ```
@@ -0,0 +1,22 @@
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; [FacetsMixin](./x-components.facetsmixin.md)
4
+
5
+ ## FacetsMixin class
6
+
7
+ Mixin to share Facets logic.
8
+
9
+ <b>Signature:</b>
10
+
11
+ ```typescript
12
+ export default class FacetsMixin extends Vue
13
+ ```
14
+ <b>Extends:</b> Vue
15
+
16
+ ## Properties
17
+
18
+ | Property | Modifiers | Type | Description |
19
+ | --- | --- | --- | --- |
20
+ | [alwaysVisible](./x-components.facetsmixin.alwaysvisible.md) | | boolean | Flag to render the component even if there are no filters selected. |
21
+ | [facetsIds?](./x-components.facetsmixin.facetsids.md) | | Array&lt;Facet\['id'\]&gt; | <i>(Optional)</i> Array of facets ids used to get the selected filters for those facets. |
22
+
@@ -66,6 +66,7 @@ X-Components is a library usable everywhere not only for search experiences.
66
66
  | [ExcludeFiltersWithNoResults](./x-components.excludefilterswithnoresults.md) | The <code>ExcludeFiltersWithNoResults</code> component filters the provided list of filters, excluding those which have the <code>totalResults</code> property exactly equal to <code>0</code>. It won't remove filters with no <code>totalResults</code> property.<!-- -->The new list of filters is bound to the default scoped slot. As this component does not render no root element, this default slot must contain a single root node. |
67
67
  | [ExtraParams](./x-components.extraparams.md) | It emits a [ExtraParamsXEvents.ExtraParamsProvided](./x-components.extraparamsxevents.extraparamsprovided.md) with the values received as a prop. |
68
68
  | [Facets](./x-components.facets.md) | This component renders the list of facets stored in the Facets module. Facets can be rendered differently based on their purpose and this can be achieved using the exposed slots: - A default and required slot. - A custom slot for each facet with the facetId as its name. This allows each facet to be rendered differently based on its needs. |
69
+ | [FacetsMixin](./x-components.facetsmixin.md) | Mixin to share Facets logic. |
69
70
  | [FacetsProvider](./x-components.facetsprovider.md) | This component allows to provide facets by prop, to add them to the state of the <code>Facets X-Module</code>. These facets will be added to the <code>Facets X-Module</code> state together with the facets emitted by the <code>Search X-Module</code> through the [SearchXEvents.FacetsChanged](./x-components.searchxevents.facetschanged.md) event. |
70
71
  | [FadeAndSlide](./x-components.fadeandslide.md) | Renders a transition group wrapping the elements passed in the default slot and animating them with a fade and slide animation. |
71
72
  | [FiltersInjectionMixin](./x-components.filtersinjectionmixin.md) | Mixin to share filters injection logic. |
@@ -112,7 +113,7 @@ X-Components is a library usable everywhere not only for search experiences.
112
113
  | [SearchButton](./x-components.searchbutton.md) | This component renders a button to submit the query. |
113
114
  | [SearchInput](./x-components.searchinput.md) | This component renders an input field that allows the user to type a query. It also reacts to query changes through event listening. |
114
115
  | [SelectedFilters](./x-components.selectedfilters.md) | Provides a scoped slot with the selected filters from every facet, or from the facet which facet id is passed as property.<!-- -->The default slot renders the length of the selected filters array. The property "alwaysVisible" handles if the component is rendered if no filters are selected. |
115
- | [SelectedFiltersList](./x-components.selectedfilterslist.md) | This component renders a list of selected filters from every facet, or from the facet which facet id is passed as property. It uses the SelectedFilters component (state).<!-- -->It provides two slots: a scoped one which name is the filter facet id; and a default one. Both exposes the filter and renders the filter label by default.<!-- -->The property "alwaysVisible" handles if the component is rendered if no filters are selected. |
116
+ | [SelectedFiltersList](./x-components.selectedfilterslist.md) | This component renders a list of selected filters from every facet, or from the facet ids passed as property. It uses the SelectedFilters component (state).<!-- -->It provides two slots: a scoped one which name is the filter facet id; and a default one. Both exposes the filter and renders the filter label by default.<!-- -->The property "alwaysVisible" handles if the component is rendered if no filters are selected. |
116
117
  | [SimpleFilter](./x-components.simplefilter.md) | Renders a simple filter, emitting the needed events when clicked. |
117
118
  | [SingleColumnLayout](./x-components.singlecolumnlayout.md) | Component for use as Layout to be filled with the rest of the Components. |
118
119
  | [SlicedFilters](./x-components.slicedfilters.md) | Component that slices a list of filters and returns them using the default scoped slot, allowing the user to show the full list of them or slicing them again using the show more/less buttons. |
@@ -155,6 +156,7 @@ X-Components is a library usable everywhere not only for search experiences.
155
156
  | [Debounce(debounceTimeInMs, debounceOptions)](./x-components.debounce.md) | Adds debounce to the method that the decorator is applied to. |
156
157
  | [deepFilter(array, filter, childrenKey)](./x-components.deepfilter.md) | Filters an array with all elements that pass the test implemented by the provided filter function. It also does it recursively if the property accessed, whose name is the parameter childrenKey, to the current iteration in an array. |
157
158
  | [deepFlat(array, childrenKey)](./x-components.deepflat.md) | Flat an ArrayType\[\] recursively using the childrenKey passed as parameter to access to his nested child which is also ArrayType\[\]. |
159
+ | [every(object, condition)](./x-components.every.md) | Ensures that the given condition is met in all the non-undefined entries of the object. |
158
160
  | [filter(wire, filterFn)](./x-components.filter.md) | Creates a [Wire](./x-components.wire.md) that is only executed whenever the condition in the filterFn is true. |
159
161
  | [filterBlacklistedModules(wire, blacklist)](./x-components.filterblacklistedmodules.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 NOT included in the <code>blacklist</code> array passed as parameter. |
160
162
  | [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)<!-- -->. |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## SelectedFiltersList class
6
6
 
7
- This component renders a list of selected filters from every facet, or from the facet which facet id is passed as property. It uses the SelectedFilters component (state).
7
+ This component renders a list of selected filters from every facet, or from the facet ids passed as property. It uses the SelectedFilters component (state).
8
8
 
9
9
  It provides two slots: a scoped one which name is the filter facet id; and a default one. Both exposes the filter and renders the filter label by default.
10
10
 
@@ -13,15 +13,17 @@ The property "alwaysVisible" handles if the component is rendered if no filters
13
13
  <b>Signature:</b>
14
14
 
15
15
  ```typescript
16
- export default class SelectedFiltersList extends Vue
16
+ export default class SelectedFiltersList extends FacetsMixin
17
17
  ```
18
- <b>Extends:</b> Vue
18
+ <b>Extends:</b> FacetsMixin
19
+
20
+ ## Remarks
21
+
22
+ It extends [FacetsMixin](./x-components.facetsmixin.md)<!-- -->.
19
23
 
20
24
  ## Properties
21
25
 
22
26
  | Property | Modifiers | Type | Description |
23
27
  | --- | --- | --- | --- |
24
- | [alwaysVisible](./x-components.selectedfilterslist.alwaysvisible.md) | | boolean | It is directly passed to the selected filters component. It handles if the SelectedFilters component is always rendered no matter if no filters are selected.<!-- -->If true, the SelectedFilters component is always rendered. If false, the SelectedFilters component is not rendered whether no filters are selected. |
25
28
  | [animation](./x-components.selectedfilterslist.animation.md) | | Vue \| string | Animation component that will be used to animate the selected filters list. |
26
- | [facetId](./x-components.selectedfilterslist.facetid.md) | | Facet\['id'\] \| undefined | It is directly passed to the selected filters component. If a facet id is passed as prop, the component filters the selected filters for that facet. |
27
29
 
@@ -10,10 +10,10 @@ Renders a simple button, emitting the needed events when clicked.
10
10
 
11
11
  ## Props
12
12
 
13
- | Name | Description | Type | Default |
14
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | ------------------ |
15
- | <code>alwaysVisible</code> | It handles if the ClearFilters button is always visible no matter if there are not<br />filters selected. If false, the ClearFilters button is not visible whether<br />there are no filters selected. | <code>boolean</code> | <code>false</code> |
16
- | <code>facetsIds</code> | Array of facets ids that will be passed to event like payload. | <code>Array</code> | <code></code> |
13
+ | Name | Description | Type | Default |
14
+ | -------------------------- | ---------------------------------------------------------------------- | -------------------- | ------------------ |
15
+ | <code>facetsIds</code> | Array of facets ids used to get the selected filters for those facets. | <code>Array</code> | <code></code> |
16
+ | <code>alwaysVisible</code> | Flag to render the component even if there are no filters selected. | <code>boolean</code> | <code>false</code> |
17
17
 
18
18
  ## Slots
19
19
 
@@ -15,10 +15,12 @@ differently based on their purpose and this can be achieved using the exposed sl
15
15
 
16
16
  ## Props
17
17
 
18
- | Name | Description | Type | Default |
19
- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----------------- |
20
- | <code>animation</code> | Animation component that will be used to animate the facets. | <code>union</code> | <code>'ul'</code> |
21
- | <code>renderableFacets</code> | Discriminates the facets rendered by this component. It expects a string containing facets<br />ids, comma separated. This property will include or exclude facets based on its value.<br />The default value is an empty string and the component will render all existing facets.<br /><br />To behave as a `include`, simply set the facets ids, comma separated:<br />`existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`<br />`renderableFacets="brand, category"`<br /><br />The component will render brand and category facets.<br /><br />On the other hand, to simulate an `exclude` behaviour and exclude a facet from being<br />rendered, append a '!' before its id:<br />`existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`<br />`renderableFacets="!brand,!price"`<br /><br />The component will render category and color facets. | <code>union</code> | <code></code> |
18
+ | Name | Description | Type | Default |
19
+ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------ |
20
+ | <code>facetsIds</code> | Array of facets ids used to get the selected filters for those facets. | <code>Array</code> | <code></code> |
21
+ | <code>alwaysVisible</code> | Flag to render the component even if there are no filters selected. | <code>boolean</code> | <code>false</code> |
22
+ | <code>animation</code> | Animation component that will be used to animate the facets. | <code>union</code> | <code>'ul'</code> |
23
+ | <code>renderableFacets</code> | Discriminates the facets rendered by this component. It expects a string containing facets<br />ids, comma separated. This property will include or exclude facets based on its value.<br />The default value is an empty string and the component will render all existing facets.<br /><br />To behave as a `include`, simply set the facets ids, comma separated:<br />`existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`<br />`renderableFacets="brand, category"`<br /><br />The component will render brand and category facets.<br /><br />On the other hand, to simulate an `exclude` behaviour and exclude a facet from being<br />rendered, append a '!' before its id:<br />`existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`<br />`renderableFacets="!brand,!price"`<br /><br />The component will render category and color facets. | <code>union</code> | <code></code> |
22
24
 
23
25
  ## Slots
24
26
 
@@ -7,7 +7,7 @@ title: SelectedFiltersList
7
7
  # SelectedFiltersList
8
8
 
9
9
  This component renders a list of selected filters from every facet, or from the facet
10
- which facet id is passed as property. It uses the SelectedFilters component (state).
10
+ ids passed as property. It uses the SelectedFilters component (state).
11
11
 
12
12
  It provides two slots: a scoped one which name is the filter facet id; and a default one.
13
13
  Both exposes the filter and renders the filter label by default.
@@ -16,11 +16,11 @@ The property "alwaysVisible" handles if the component is rendered if no filters
16
16
 
17
17
  ## Props
18
18
 
19
- | Name | Description | Type | Default |
20
- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------ |
21
- | <code>facetId</code> | It is directly passed to the selected filters component. If a facet id is passed as prop,<br />the component filters the selected filters for that facet. | <code>union</code> | <code></code> |
22
- | <code>alwaysVisible</code> | It is directly passed to the selected filters component. It handles if the SelectedFilters<br />component is always rendered no matter if no filters are selected.<br /><br />If true, the SelectedFilters component is always rendered.<br />If false, the SelectedFilters component is not rendered whether no filters are selected. | <code>boolean</code> | <code>false</code> |
23
- | <code>animation</code> | Animation component that will be used to animate the selected filters list. | <code>union</code> | <code>'ul'</code> |
19
+ | Name | Description | Type | Default |
20
+ | -------------------------- | --------------------------------------------------------------------------- | -------------------- | ------------------ |
21
+ | <code>facetsIds</code> | Array of facets ids used to get the selected filters for those facets. | <code>Array</code> | <code></code> |
22
+ | <code>alwaysVisible</code> | Flag to render the component even if there are no filters selected. | <code>boolean</code> | <code>false</code> |
23
+ | <code>animation</code> | Animation component that will be used to animate the selected filters list. | <code>union</code> | <code>'ul'</code> |
24
24
 
25
25
  ## Slots
26
26
 
@@ -30,8 +30,8 @@ The property "alwaysVisible" handles if the component is rendered if no filters
30
30
 
31
31
  ## Example
32
32
 
33
- This component renders a list of selected filters from every facet, or from the facet which facet id
34
- is passed as property. It uses the SelectedFilters component (state).
33
+ This component renders a list of selected filters from every facet, or from the facets which facets
34
+ ids are passed as property. It uses the SelectedFilters component (state).
35
35
 
36
36
  It provides two slots: a scoped one which name is the filter facet id; and a default one. Both
37
37
  exposes the filter and renders the filter label by default.
@@ -114,10 +114,11 @@ Output:
114
114
  </div>
115
115
  ```
116
116
 
117
- #### Providing a facet id
117
+ #### Providing an array of facet ids
118
118
 
119
- In this example, the selected filters computed are the ones that match the facet passed as property.
119
+ In this example, the selected filters computed are the ones that match the facet ids passed as
120
+ properties.
120
121
 
121
122
  ```vue
122
- <SelectedFilters facetId="brand_facet" />
123
+ <SelectedFilters :facetsIds="['brand_facet', 'gender_facet']" />
123
124
  ```
@@ -14,10 +14,10 @@ The property "alwaysVisible" handles if the component is rendered if no filters
14
14
 
15
15
  ## Props
16
16
 
17
- | Name | Description | Type | Default |
18
- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------ |
19
- | <code>facetId</code> | If a facet id is passed as prop, the component filters the selected filters for that facet. | <code>union</code> | <code></code> |
20
- | <code>alwaysVisible</code> | It handles if the SelectedFilters component is always rendered no matter if no filters are<br />selected.<br />If true, the SelectedFilters component is always rendered.<br />If false, the SelectedFilters component is not rendered whether no filters are selected. | <code>boolean</code> | <code>false</code> |
17
+ | Name | Description | Type | Default |
18
+ | -------------------------- | ---------------------------------------------------------------------- | -------------------- | ------------------ |
19
+ | <code>facetsIds</code> | Array of facets ids used to get the selected filters for those facets. | <code>Array</code> | <code></code> |
20
+ | <code>alwaysVisible</code> | Flag to render the component even if there are no filters selected. | <code>boolean</code> | <code>false</code> |
21
21
 
22
22
  ## Slots
23
23
 
@@ -71,14 +71,14 @@ Output:
71
71
  <div class="x-selected-filters">Selected filters: 1</div>
72
72
  ```
73
73
 
74
- In this example, the selected filters computed are the ones that match the facet passed as property.
74
+ In this example, the selected filters are filtered by the facetsIds property.
75
75
 
76
76
  ```vue
77
- <SelectedFilters facetId="brand_facet" />
77
+ <SelectedFilters :facetsIds="['brand_facet']" />
78
78
  ```
79
79
 
80
80
  ```vue
81
- <SelectedFilters facetId="brand_facet">
81
+ <SelectedFilters :facetsIds="['brand_facet', 'gender_facet']">
82
82
  <template #default="{ selectedFilters }">
83
83
  Selected filters: {{ selectedFilters.length }}
84
84
  </template>
package/facets/index.js CHANGED
@@ -31,4 +31,5 @@ export { default as SelectedFiltersList } from '../js/x-modules/facets/component
31
31
  export { default as SlicedFilters } from '../js/x-modules/facets/components/lists/sliced-filters.vue.js';
32
32
  export { default as SortedFilters } from '../js/x-modules/facets/components/lists/sorted-filters.vue.js';
33
33
  export { default as ClearFilters } from '../js/x-modules/facets/components/clear-filters.vue.js';
34
- export { isNewQuery } from '../js/x-modules/facets/utils.js';
34
+ export { isNewQuery } from '../js/x-modules/facets/utils.js';
35
+ export { default as FacetsMixin } from '../js/x-modules/facets/components/facets.mixin.js';
package/js/index.js CHANGED
@@ -136,7 +136,7 @@ export { getURLParameter } from './utils/get-url-parameters.js';
136
136
  export { isElementEqualOrContained } from './utils/html.js';
137
137
  export { normalizeString } from './utils/normalize.js';
138
138
  export { isInRange } from './utils/number.js';
139
- export { cleanUndefined, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce } from './utils/object.js';
139
+ export { cleanUndefined, every, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce } from './utils/object.js';
140
140
  export { createOrigin } from './utils/origin.js';
141
141
  export { sanitize } from './utils/sanitize.js';
142
142
  export { localStorageService } from './utils/storage.js';
@@ -200,6 +200,7 @@ export { default as SlicedFilters } from './x-modules/facets/components/lists/sl
200
200
  export { default as SortedFilters } from './x-modules/facets/components/lists/sorted-filters.vue.js';
201
201
  export { default as ClearFilters } from './x-modules/facets/components/clear-filters.vue.js';
202
202
  export { isNewQuery } from './x-modules/facets/utils.js';
203
+ export { default as FacetsMixin } from './x-modules/facets/components/facets.mixin.js';
203
204
  export { default as ClearHistoryQueries } from './x-modules/history-queries/components/clear-history-queries.vue.js';
204
205
  export { default as HistoryQueries } from './x-modules/history-queries/components/history-queries.vue.js';
205
206
  export { default as HistoryQuery } from './x-modules/history-queries/components/history-query.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -95,7 +95,21 @@ function getNewAndUpdatedKeys(newValue, oldValue) {
95
95
  return [];
96
96
  }
97
97
  return Object.keys(newValue).filter(key => !(key in oldValue) || newValue[key] !== oldValue[key]);
98
+ }
99
+ /**
100
+ * Ensures that the given condition is met in all the non-undefined entries of the object.
101
+ *
102
+ * @param object - The object to check if every item meets the given condition.
103
+ * @param condition - The condition to check in each one of the entries of the object.
104
+ *
105
+ * @returns True when all the entries pass the condition. False otherwise.
106
+ * @public
107
+ */
108
+ function every(object, condition) {
109
+ return Object.entries(object)
110
+ .filter(([, value]) => value !== undefined)
111
+ .every(([key, value], index) => condition(key, value, index));
98
112
  }
99
113
 
100
- export { cleanUndefined, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce };
114
+ export { cleanUndefined, every, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce };
101
115
  //# sourceMappingURL=object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sources":["../../../src/utils/object.ts"],"sourcesContent":["import { Dictionary } from './types';\n\n/**\n * Iterates over every non-undefined property of the object calling the callback passed as\n * parameter.\n *\n * @param obj - The object to iterate through each property.\n * @param callbackFn - The callback function to call for each property.\n * @public\n */\nexport function forEach<T extends Dictionary>(\n obj: T | undefined | null,\n callbackFn: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => void\n): void {\n if (obj == null) {\n return;\n }\n\n let index = 0;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined) {\n callbackFn(key, obj[key], index++);\n }\n }\n}\n\n/**\n * Iterates through the obj properties calling the reducer function.\n *\n * @param obj - The object to iterate through each property.\n * @param reducer - A function that will be called for each property, modifying the initialValue\n * object.\n * @param initialValue - The initial value of the accumulator property of the reducer function.\n * @returns Result of the reducer function.\n * @public\n */\nexport function reduce<T extends Dictionary, V>(\n obj: T | undefined | null,\n reducer: (\n accumulator: V,\n key: keyof T,\n value: Exclude<T[keyof T], undefined>,\n index: number\n ) => V,\n initialValue: V\n): V {\n let accumulator = initialValue;\n forEach(obj, (key, value, index) => {\n accumulator = reducer(accumulator, key, value, index);\n });\n return accumulator;\n}\n\n/**\n * Creates an object from another object transforming each property value.\n *\n * @param obj - The object to transform each property value.\n * @param mapper - The mapper function which will transform each value.\n * @returns A record with the result of the mapper.\n * @public\n */\nexport function map<T extends Dictionary, W>(\n obj: T | undefined | null,\n mapper: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => W\n): Record<keyof T, W> {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n accumulator[key] = mapper(key, value, index);\n return accumulator;\n },\n {} as Record<keyof T, W>\n );\n}\n\n/**\n * Creates an object picking only the not undefined properties.\n *\n * @param obj - The object from whom pick the values.\n * @returns A new object with the not undefined properties of the source object.\n * @public\n */\nexport function cleanUndefined<T>(obj: T): T {\n return typeof obj !== 'object' || obj === null || Array.isArray(obj)\n ? obj\n : reduce(\n obj,\n (pickedObject, key, value) => {\n pickedObject[key] = cleanUndefined(value);\n return pickedObject;\n },\n {} as T\n );\n}\n\n/**\n * Creates an object picking only the ones that pass the test implemented by the\n * provided function isIncluded.\n *\n * @param obj - T object to be filtered.\n * @param isIncluded - Test function that every obj item must pass.\n * @returns A filtered object.\n * @public\n */\nexport function objectFilter<T extends Dictionary>(\n obj: T | undefined | null,\n isIncluded: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => boolean\n): T {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n if (isIncluded(key, value, index)) {\n accumulator[key] = value;\n }\n return accumulator;\n },\n {} as T\n );\n}\n\n/**\n * Compares two objects of the same type, checking the values of their keys and retrieving\n * those that were not present in the old value and/or those whose value has changed.\n *\n * @param newValue - The new object value.\n * @param oldValue - The old object value.\n *\n * @returns An array of keys.\n * @public\n */\nexport function getNewAndUpdatedKeys<ObjectType extends Dictionary>(\n newValue: ObjectType | undefined,\n oldValue: ObjectType | undefined\n): (keyof ObjectType)[] {\n if (newValue === oldValue || !newValue || !oldValue) {\n return [];\n }\n\n return Object.keys(newValue).filter(key => !(key in oldValue) || newValue[key] !== oldValue[key]);\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;SAQgB,OAAO,CACrB,GAAyB,EACzB,UAAwF;IAExF,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO;KACR;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YAC5E,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC;AAED;;;;;;;;;;SAUgB,MAAM,CACpB,GAAyB,EACzB,OAKM,EACN,YAAe;IAEf,IAAI,WAAW,GAAG,YAAY,CAAC;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACvD,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;SAQgB,GAAG,CACjB,GAAyB,EACzB,MAAiF;IAEjF,OAAO,MAAM,CACX,GAAG,EACH,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,WAAW,CAAC;KACpB,EACD,EAAwB,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;SAOgB,cAAc,CAAI,GAAM;IACtC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;UAChE,GAAG;UACH,MAAM,CACJ,GAAG,EACH,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK;YACvB,YAAY,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC;SACrB,EACD,EAAO,CACR,CAAC;AACR,CAAC;AAED;;;;;;;;;SASgB,YAAY,CAC1B,GAAyB,EACzB,UAA2F;IAE3F,OAAO,MAAM,CACX,GAAG,EACH,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,IAAI,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE;YACjC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAC1B;QACD,OAAO,WAAW,CAAC;KACpB,EACD,EAAO,CACR,CAAC;AACJ,CAAC;AAED;;;;;;;;;;SAUgB,oBAAoB,CAClC,QAAgC,EAChC,QAAgC;IAEhC,IAAI,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;QACnD,OAAO,EAAE,CAAC;KACX;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACpG;;;;"}
1
+ {"version":3,"file":"object.js","sources":["../../../src/utils/object.ts"],"sourcesContent":["import { Dictionary } from './types';\n\n/**\n * Iterates over every non-undefined property of the object calling the callback passed as\n * parameter.\n *\n * @param obj - The object to iterate through each property.\n * @param callbackFn - The callback function to call for each property.\n * @public\n */\nexport function forEach<T extends Dictionary>(\n obj: T | undefined | null,\n callbackFn: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => void\n): void {\n if (obj == null) {\n return;\n }\n\n let index = 0;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined) {\n callbackFn(key, obj[key], index++);\n }\n }\n}\n\n/**\n * Iterates through the obj properties calling the reducer function.\n *\n * @param obj - The object to iterate through each property.\n * @param reducer - A function that will be called for each property, modifying the initialValue\n * object.\n * @param initialValue - The initial value of the accumulator property of the reducer function.\n * @returns Result of the reducer function.\n * @public\n */\nexport function reduce<T extends Dictionary, V>(\n obj: T | undefined | null,\n reducer: (\n accumulator: V,\n key: keyof T,\n value: Exclude<T[keyof T], undefined>,\n index: number\n ) => V,\n initialValue: V\n): V {\n let accumulator = initialValue;\n forEach(obj, (key, value, index) => {\n accumulator = reducer(accumulator, key, value, index);\n });\n return accumulator;\n}\n\n/**\n * Creates an object from another object transforming each property value.\n *\n * @param obj - The object to transform each property value.\n * @param mapper - The mapper function which will transform each value.\n * @returns A record with the result of the mapper.\n * @public\n */\nexport function map<T extends Dictionary, W>(\n obj: T | undefined | null,\n mapper: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => W\n): Record<keyof T, W> {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n accumulator[key] = mapper(key, value, index);\n return accumulator;\n },\n {} as Record<keyof T, W>\n );\n}\n\n/**\n * Creates an object picking only the not undefined properties.\n *\n * @param obj - The object from whom pick the values.\n * @returns A new object with the not undefined properties of the source object.\n * @public\n */\nexport function cleanUndefined<T>(obj: T): T {\n return typeof obj !== 'object' || obj === null || Array.isArray(obj)\n ? obj\n : reduce(\n obj,\n (pickedObject, key, value) => {\n pickedObject[key] = cleanUndefined(value);\n return pickedObject;\n },\n {} as T\n );\n}\n\n/**\n * Creates an object picking only the ones that pass the test implemented by the\n * provided function isIncluded.\n *\n * @param obj - T object to be filtered.\n * @param isIncluded - Test function that every obj item must pass.\n * @returns A filtered object.\n * @public\n */\nexport function objectFilter<T extends Dictionary>(\n obj: T | undefined | null,\n isIncluded: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => boolean\n): T {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n if (isIncluded(key, value, index)) {\n accumulator[key] = value;\n }\n return accumulator;\n },\n {} as T\n );\n}\n\n/**\n * Compares two objects of the same type, checking the values of their keys and retrieving\n * those that were not present in the old value and/or those whose value has changed.\n *\n * @param newValue - The new object value.\n * @param oldValue - The old object value.\n *\n * @returns An array of keys.\n * @public\n */\nexport function getNewAndUpdatedKeys<ObjectType extends Dictionary>(\n newValue: ObjectType | undefined,\n oldValue: ObjectType | undefined\n): (keyof ObjectType)[] {\n if (newValue === oldValue || !newValue || !oldValue) {\n return [];\n }\n\n return Object.keys(newValue).filter(key => !(key in oldValue) || newValue[key] !== oldValue[key]);\n}\n\n/**\n * Ensures that the given condition is met in all the non-undefined entries of the object.\n *\n * @param object - The object to check if every item meets the given condition.\n * @param condition - The condition to check in each one of the entries of the object.\n *\n * @returns True when all the entries pass the condition. False otherwise.\n * @public\n */\nexport function every<ObjectType extends Dictionary>(\n object: ObjectType,\n condition: (\n key: keyof ObjectType,\n value: Exclude<ObjectType[keyof ObjectType], undefined>,\n index: number\n ) => boolean\n): boolean {\n return Object.entries(object)\n .filter(([, value]) => value !== undefined)\n .every(([key, value], index) => condition(key, value, index));\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;SAQgB,OAAO,CACrB,GAAyB,EACzB,UAAwF;IAExF,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO;KACR;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YAC5E,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC;AAED;;;;;;;;;;SAUgB,MAAM,CACpB,GAAyB,EACzB,OAKM,EACN,YAAe;IAEf,IAAI,WAAW,GAAG,YAAY,CAAC;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACvD,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;SAQgB,GAAG,CACjB,GAAyB,EACzB,MAAiF;IAEjF,OAAO,MAAM,CACX,GAAG,EACH,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,WAAW,CAAC;KACpB,EACD,EAAwB,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;SAOgB,cAAc,CAAI,GAAM;IACtC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;UAChE,GAAG;UACH,MAAM,CACJ,GAAG,EACH,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK;YACvB,YAAY,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC;SACrB,EACD,EAAO,CACR,CAAC;AACR,CAAC;AAED;;;;;;;;;SASgB,YAAY,CAC1B,GAAyB,EACzB,UAA2F;IAE3F,OAAO,MAAM,CACX,GAAG,EACH,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,IAAI,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE;YACjC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAC1B;QACD,OAAO,WAAW,CAAC;KACpB,EACD,EAAO,CACR,CAAC;AACJ,CAAC;AAED;;;;;;;;;;SAUgB,oBAAoB,CAClC,QAAgC,EAChC,QAAgC;IAEhC,IAAI,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;QACnD,OAAO,EAAE,CAAC;KACX;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACpG,CAAC;AAED;;;;;;;;;SASgB,KAAK,CACnB,MAAkB,EAClB,SAIY;IAEZ,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,SAAS,CAAC;SAC1C,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAClE;;;;"}
@@ -9,7 +9,7 @@ var __vue_render__ = function () {
9
9
  var _vm = this;
10
10
  var _h = _vm.$createElement;
11
11
  var _c = _vm._self._c || _h;
12
- return _vm.show
12
+ return _vm.isVisible
13
13
  ? _c(
14
14
  "BaseEventButton",
15
15
  {
@@ -17,7 +17,7 @@ var __vue_render__ = function () {
17
17
  class: _vm.cssClasses,
18
18
  attrs: {
19
19
  "data-test": "clear-filters",
20
- disabled: !_vm.areThereSelectedFilters,
20
+ disabled: !_vm.hasSelectedFilters,
21
21
  events: _vm.events,
22
22
  },
23
23
  },
@@ -27,13 +27,11 @@ var __vue_render__ = function () {
27
27
  function () {
28
28
  return [
29
29
  _vm._v(
30
- "\n Clear Filters (" +
31
- _vm._s(_vm.facetsSelectedFilters.length) +
32
- ")\n "
30
+ "Clear Filters (" + _vm._s(_vm.selectedFilters.length) + ")"
33
31
  ),
34
32
  ]
35
33
  },
36
- { selectedFilters: _vm.facetsSelectedFilters }
34
+ { selectedFilters: _vm.selectedFilters }
37
35
  ),
38
36
  ],
39
37
  2
@@ -1 +1 @@
1
- {"version":3,"file":"clear-filters.vue.js","sources":["../../../../../src/x-modules/facets/components/clear-filters.vue"],"sourcesContent":["<template>\n <BaseEventButton\n v-if=\"show\"\n class=\"x-button x-clear-filters\"\n data-test=\"clear-filters\"\n :disabled=\"!areThereSelectedFilters\"\n :events=\"events\"\n :class=\"cssClasses\"\n >\n <slot :selectedFilters=\"facetsSelectedFilters\">\n Clear Filters ({{ facetsSelectedFilters.length }})\n </slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\n import { Facet, Filter, isFacetFilter } from '@empathyco/x-types';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { Getter, xComponentMixin } from '../../../components';\n import BaseEventButton from '../../../components/base-event-button.vue';\n import { VueCSSClasses } from '../../../utils';\n import { XEventsTypes } from '../../../wiring';\n import { facetsXModule } from '../x-module';\n\n /**\n * Renders a simple button, emitting the needed events when clicked.\n *\n * @public\n */\n @Component({\n components: { BaseEventButton },\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class ClearFilters extends Vue {\n /**\n * It handles if the ClearFilters button is always visible no matter if there are not\n * filters selected. If false, the ClearFilters button is not visible whether\n * there are no filters selected.\n *\n * @public\n */\n @Prop({ default: false })\n public alwaysVisible!: boolean;\n\n /**\n * Array of facets ids that will be passed to event like payload.\n *\n * @public\n */\n @Prop()\n public facetsIds?: Array<Facet['id']>;\n\n /**\n * Get the selected filters from store.\n *\n * @internal\n */\n @Getter('facets', 'selectedFilters')\n public allSelectedFilters!: Filter[];\n\n /**\n * If alwaysVisible prop is true, ClearAllFilters button is always shown, but disabled\n * if there are no filters selected.\n * If alwaysVisible prop is false, ClearAllFilters button is shown whether there\n * are some filter selected.\n *\n * @returns True if alwaysVisible is true or in the opposite case true or false depends\n * on if there are selected filters or not.\n *\n * @internal\n */\n protected get show(): boolean {\n return this.alwaysVisible || this.areThereSelectedFilters;\n }\n\n /**\n * Get selected filters.\n * If there are facets ids, get selected filters whose facet id match with some of facets ids.\n * If there aren't facets ids, get selected filters.\n *\n * @returns Array of selected filters depends on there are facets ids or not.\n * @internal\n */\n protected get facetsSelectedFilters(): Filter[] {\n if (this.facetsIds) {\n return this.allSelectedFilters.filter(\n filter => isFacetFilter(filter) && this.facetsIds!.includes(filter.facetId)\n );\n } else {\n return this.allSelectedFilters;\n }\n }\n\n /**\n * Check if there are selected filters.\n *\n * @returns True or false depends on if there are facets ids and if there are selected filters.\n * @internal\n */\n protected get areThereSelectedFilters(): boolean {\n return !!this.facetsSelectedFilters.length;\n }\n\n /**\n * The events that will be emitted when the button clear filters is clicked.\n *\n * @returns The events to be emitted when the button clear filters is clicked.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return this.facetsIds\n ? {\n UserClickedClearAllFilters: this.facetsIds\n }\n : {\n UserClickedClearAllFilters: undefined\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-clear-filters--has-not-selected-filters': !this.areThereSelectedFilters,\n 'x-clear-filters--has-selected-filters': this.areThereSelectedFilters\n };\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a button, which on clicked emits the `UserClickedClearAllFilters` or\n`UserClickedClearAllFilters` event.\n\n### Basic usage\n\n```vue\n<ClearFilters />\n```\n\n### Customizing its contents\n\nIn this example, show the custom message in button.\n\n```vue\n<ClearFilters v-slot=\"{ selectedFilters }\">\n Delete {{ selectedFilters.length }} selected\n</ClearFilters>\n```\n\nIn this example, show the custom message in button with always visible a true and list of facets\nids.\n\n```vue\n<ClearFilters v-slot=\"{ selectedFilters }\" :alwaysVisible=\"true\" :facetsIds=\"facetsIds\">\n Delete {{ selectedFilters.length }} selected\n</ClearFilters>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserClickedClearAllFilters`: the event is emitted after the user clicks the button to clear a\n certain facets filter. The event payload is the id of the facets that are going to be cleared.\n- `UserClickedClearAllFilters`: the event is emitted after the user clicks the button. The event\n payload is undefined.\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"clear-filters.vue.js","sources":["../../../../../src/x-modules/facets/components/clear-filters.vue"],"sourcesContent":["<template>\n <BaseEventButton\n v-if=\"isVisible\"\n class=\"x-button x-clear-filters\"\n data-test=\"clear-filters\"\n :disabled=\"!hasSelectedFilters\"\n :events=\"events\"\n :class=\"cssClasses\"\n >\n <slot :selectedFilters=\"selectedFilters\">Clear Filters ({{ selectedFilters.length }})</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\n import Component from 'vue-class-component';\n import { xComponentMixin } from '../../../components';\n import BaseEventButton from '../../../components/base-event-button.vue';\n import { VueCSSClasses } from '../../../utils';\n import { XEventsTypes } from '../../../wiring';\n import { facetsXModule } from '../x-module';\n import FacetsMixin from './facets.mixin';\n\n /**\n * Renders a simple button, emitting the needed events when clicked.\n *\n * @remarks It extends {@link FacetsMixin}.\n *\n * @public\n */\n @Component({\n components: { BaseEventButton },\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class ClearFilters extends FacetsMixin {\n /**\n * The events that will be emitted when the button clear filters is clicked.\n *\n * @returns The events to be emitted when the button clear filters is clicked.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return this.facetsIds\n ? {\n UserClickedClearAllFilters: this.facetsIds\n }\n : {\n UserClickedClearAllFilters: undefined\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-clear-filters--has-not-selected-filters': !this.hasSelectedFilters,\n 'x-clear-filters--has-selected-filters': this.hasSelectedFilters\n };\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a button, which on clicked emits the `UserClickedClearAllFilters` or\n`UserClickedClearAllFilters` event.\n\n### Basic usage\n\n```vue\n<ClearFilters />\n```\n\n### Customizing its contents\n\nIn this example, show the custom message in button.\n\n```vue\n<ClearFilters v-slot=\"{ selectedFilters }\">\n Delete {{ selectedFilters.length }} selected\n</ClearFilters>\n```\n\nIn this example, show the custom message in button with always visible a true and list of facets\nids.\n\n```vue\n<ClearFilters v-slot=\"{ selectedFilters }\" :alwaysVisible=\"true\" :facetsIds=\"facetsIds\">\n Delete {{ selectedFilters.length }} selected\n</ClearFilters>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserClickedClearAllFilters`: the event is emitted after the user clicks the button to clear a\n certain facets filter. The event payload is the id of the facets that are going to be cleared.\n- `UserClickedClearAllFilters`: the event is emitted after the user clicks the button. The event\n payload is undefined.\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}