@empathyco/x-components 6.0.0-alpha.74 → 6.0.0-alpha.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/design-system/deprecated-full-theme.css +1053 -1053
- package/docs/API-reference/api/x-components.allfilter.md +3 -3
- package/docs/API-reference/api/x-components.facets.md +3 -3
- package/docs/API-reference/api/x-components.historyqueries.md +1 -1
- package/docs/API-reference/api/x-components.historyquery.md +1 -1
- package/docs/API-reference/api/x-components.identifierresult.md +2 -2
- package/docs/API-reference/api/x-components.md +1 -1
- package/docs/API-reference/api/x-components.nextqueries.md +1 -1
- package/docs/API-reference/api/x-components.popularsearches.md +1 -1
- package/docs/API-reference/api/x-components.querysuggestion.md +1 -1
- package/docs/API-reference/api/x-components.querysuggestions.md +1 -1
- package/docs/API-reference/api/x-components.semanticquery.md +1 -1
- package/docs/API-reference/api/x-components.usegetter.md +3 -17
- package/js/components/base-teleport.vue.js.map +1 -1
- package/js/components/base-teleport.vue2.js +1 -1
- package/js/components/base-teleport.vue2.js.map +1 -1
- package/js/composables/use-getter.js +11 -11
- package/js/composables/use-getter.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue2.js +1 -1
- package/js/x-modules/facets/components/facets/facets.vue2.js.map +1 -1
- package/js/x-modules/facets/components/filters/all-filter.vue.js.map +1 -1
- package/js/x-modules/facets/components/filters/all-filter.vue2.js +1 -1
- package/js/x-modules/facets/components/filters/all-filter.vue2.js.map +1 -1
- package/js/x-modules/facets/composables/use-facets.js +1 -4
- package/js/x-modules/facets/composables/use-facets.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue2.js +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue2.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-query.vue2.js +1 -1
- package/js/x-modules/history-queries/components/history-query.vue2.js.map +1 -1
- package/js/x-modules/identifier-results/components/identifier-result.vue.js.map +1 -1
- package/js/x-modules/identifier-results/components/identifier-result.vue2.js +1 -3
- package/js/x-modules/identifier-results/components/identifier-result.vue2.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries-list.vue.js +1 -3
- package/js/x-modules/next-queries/components/next-queries-list.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue2.js +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue2.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue2.js +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue2.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestion.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestion.vue2.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue2.js.map +1 -1
- package/js/x-modules/related-tags/components/related-tags.vue.js.map +1 -1
- package/js/x-modules/related-tags/components/related-tags.vue2.js +1 -3
- package/js/x-modules/related-tags/components/related-tags.vue2.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-query.vue.js.map +1 -1
- package/js/x-modules/semantic-queries/components/semantic-query.vue2.js +2 -2
- package/js/x-modules/semantic-queries/components/semantic-query.vue2.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +67 -132
- package/report/x-components.api.md +11 -9
- package/types/composables/use-getter.d.ts +13 -3
- package/types/composables/use-getter.d.ts.map +1 -1
- package/types/x-modules/facets/components/facets/facets.vue.d.ts +4 -4
- package/types/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
- package/types/x-modules/facets/components/filters/all-filter.vue.d.ts +4 -4
- package/types/x-modules/facets/components/filters/all-filter.vue.d.ts.map +1 -1
- package/types/x-modules/history-queries/components/history-queries.vue.d.ts +1 -1
- package/types/x-modules/history-queries/components/history-query.vue.d.ts +1 -1
- package/types/x-modules/identifier-results/components/identifier-result.vue.d.ts +3 -3
- package/types/x-modules/identifier-results/components/identifier-result.vue.d.ts.map +1 -1
- package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts.map +1 -1
- package/types/x-modules/next-queries/components/next-queries.vue.d.ts +1 -1
- package/types/x-modules/popular-searches/components/popular-searches.vue.d.ts +1 -1
- package/types/x-modules/query-suggestions/components/query-suggestion.vue.d.ts +1 -1
- package/types/x-modules/query-suggestions/components/query-suggestions.vue.d.ts +1 -1
- package/types/x-modules/related-tags/components/related-tags.vue.d.ts.map +1 -1
- package/types/x-modules/semantic-queries/components/semantic-query.vue.d.ts +1 -1
|
@@ -15,11 +15,11 @@ _default: import("vue").DefineComponent<{
|
|
|
15
15
|
required: true;
|
|
16
16
|
};
|
|
17
17
|
}, {
|
|
18
|
-
clickEvent: ComputedRef<Partial<XEventsTypes>>;
|
|
19
|
-
cssClasses: ComputedRef<{
|
|
18
|
+
clickEvent: import("vue").ComputedRef<Partial<XEventsTypes>>;
|
|
19
|
+
cssClasses: import("vue").ComputedRef<{
|
|
20
20
|
'x-selected x-all-filter--is-selected': boolean;
|
|
21
21
|
}>;
|
|
22
|
-
isSelected: ComputedRef<boolean>;
|
|
22
|
+
isSelected: import("vue").ComputedRef<boolean>;
|
|
23
23
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
24
|
facet: {
|
|
25
25
|
type: PropType<Facet>;
|
|
@@ -18,9 +18,9 @@ _default: import("vue").DefineComponent<{
|
|
|
18
18
|
};
|
|
19
19
|
renderableFacets: StringConstructor;
|
|
20
20
|
}, {
|
|
21
|
-
selectedFiltersByFacet: ComputedRef<import("../..").FiltersByFacet>;
|
|
22
|
-
hasFacets: ComputedRef<boolean>;
|
|
23
|
-
mappedFacets: ComputedRef<Dictionary<RenderFacet>>;
|
|
21
|
+
selectedFiltersByFacet: import("vue").ComputedRef<import("../..").FiltersByFacet>;
|
|
22
|
+
hasFacets: import("vue").ComputedRef<boolean>;
|
|
23
|
+
mappedFacets: import("vue").ComputedRef<Dictionary<RenderFacet>>;
|
|
24
24
|
hasSlot: (name: string) => boolean;
|
|
25
25
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
26
26
|
facetsIds: PropType<(string | number)[]>;
|
|
@@ -10,6 +10,6 @@ This component renders a list of suggestions coming from the user queries histor
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<{}, {
|
|
13
|
-
historyQueriesWithResults: import("vue").ComputedRef<
|
|
13
|
+
historyQueriesWithResults: import("vue").ComputedRef<import("@empathyco/x-types").HistoryQuery[]>;
|
|
14
14
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>
|
|
15
15
|
```
|
|
@@ -17,7 +17,7 @@ _default: import("vue").DefineComponent<{
|
|
|
17
17
|
removeButtonClass: StringConstructor;
|
|
18
18
|
suggestionClass: StringConstructor;
|
|
19
19
|
}, {
|
|
20
|
-
query: import("vue").ComputedRef<
|
|
20
|
+
query: import("vue").ComputedRef<string>;
|
|
21
21
|
suggestionSelectedEvents: import("vue").ComputedRef<Partial<XEventsTypes>>;
|
|
22
22
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
23
23
|
suggestion: {
|
|
@@ -15,8 +15,8 @@ _default: import("vue").DefineComponent<{
|
|
|
15
15
|
required: true;
|
|
16
16
|
};
|
|
17
17
|
}, {
|
|
18
|
-
query: ComputedRef<string>;
|
|
19
|
-
highlightedQueryHTML: ComputedRef<string>;
|
|
18
|
+
query: import("vue").ComputedRef<string>;
|
|
19
|
+
highlightedQueryHTML: import("vue").ComputedRef<string>;
|
|
20
20
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
21
|
result: {
|
|
22
22
|
type: PropType<Result>;
|
|
@@ -87,7 +87,6 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
87
87
|
| [useEmitDisplayEvent({ element, taggingRequest, eventMetadata, })](./x-components.useemitdisplayevent.md) | Composable that emits a <code>TrackableElementDisplayed</code> event whenever the provided element appears in the viewport for the first time. |
|
|
88
88
|
| [useFacets(props)](./x-components.usefacets.md) | Composable to share Facets logic. |
|
|
89
89
|
| [useFiltersInjection(props)](./x-components.usefiltersinjection.md) | Composable to share filters injection logic. |
|
|
90
|
-
| [useGetter(module, getters)](./x-components.usegetter.md) | Function which returns the requested getters as a dictionary of getters. |
|
|
91
90
|
| [useOnDisplay({ element, callback, triggerOnce, })](./x-components.useondisplay.md) | Composable that triggers a callback whenever the provided element appears in the viewport. It can trigger the first time only or every time the element appears in the viewport. |
|
|
92
91
|
| [useScroll(props, { emit }, scrollEl)](./x-components.usescroll.md) | Composable to share Scroll logic. |
|
|
93
92
|
| [useState(module)](./x-components.usestate.md) | Function which returns the requested state's properties as a dictionary. |
|
|
@@ -661,6 +660,7 @@ X-Components is a library usable everywhere not only for search experiences.
|
|
|
661
660
|
| [updateHistoryQueriesWithSearchResponse](./x-components.updatehistoryquerieswithsearchresponse.md) | Updates the history queries with the relevant info included in a search response. |
|
|
662
661
|
| [UrlHandler](./x-components.urlhandler.md) | This component manages the browser URL parameters to preserve them through reloads and browser history navigation. It allow to configure the default url parameter names using its attributes. This component doesn't render elements to the DOM. |
|
|
663
662
|
| [urlXModule](./x-components.urlxmodule.md) | URL [XModule](./x-components.xmodule.md) implementation. This module is auto-registered as soon as you import any component from the <code>url</code> entry point. |
|
|
663
|
+
| [useGetter](./x-components.usegetter.md) | Function which returns the requested getter's properties as a dictionary. |
|
|
664
664
|
| [useQueriesPreview](./x-components.usequeriespreview.md) | Composable helpers for the QueriesPreview module. |
|
|
665
665
|
| [xPlugin](./x-components.xplugin.md) | Vue plugin that modifies each component instance, extending them with the [X Component API](./x-components.xcomponentapi.md)<!-- -->. |
|
|
666
666
|
|
|
@@ -16,7 +16,7 @@ _default: import("vue").DefineComponent<{
|
|
|
16
16
|
};
|
|
17
17
|
suggestions: PropType<NextQueryModel[]>;
|
|
18
18
|
}, {
|
|
19
|
-
renderedNextQueries: import("vue").ComputedRef<
|
|
19
|
+
renderedNextQueries: import("vue").ComputedRef<NextQueryModel[]>;
|
|
20
20
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
21
|
highlightCurated: {
|
|
22
22
|
type: BooleanConstructor;
|
|
@@ -10,6 +10,6 @@ Simple popular-searches component that renders a list of suggestions, allowing t
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<{}, {
|
|
13
|
-
popularSearches: import("vue").ComputedRef<
|
|
13
|
+
popularSearches: import("vue").ComputedRef<import("@empathyco/x-types").Suggestion[]>;
|
|
14
14
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>
|
|
15
15
|
```
|
|
@@ -10,6 +10,6 @@ This component renders a list of possible search queries to select from as a que
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<{}, {
|
|
13
|
-
suggestions: import("vue").ComputedRef<
|
|
13
|
+
suggestions: import("vue").ComputedRef<import("@empathyco/x-types").Suggestion[]>;
|
|
14
14
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>
|
|
15
15
|
```
|
|
@@ -2,26 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [useGetter](./x-components.usegetter.md)
|
|
4
4
|
|
|
5
|
-
## useGetter
|
|
5
|
+
## useGetter variable
|
|
6
6
|
|
|
7
|
-
Function which returns the requested
|
|
7
|
+
Function which returns the requested getter's properties as a dictionary.
|
|
8
8
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
|
|
12
|
+
useGetter: UseGetter
|
|
13
13
|
```
|
|
14
|
-
|
|
15
|
-
## Parameters
|
|
16
|
-
|
|
17
|
-
| Parameter | Type | Description |
|
|
18
|
-
| --- | --- | --- |
|
|
19
|
-
| module | Module | The [XModuleName](./x-components.xmodulename.md) of the getter. |
|
|
20
|
-
| getters | GetterName\[\] | List of getters names. |
|
|
21
|
-
|
|
22
|
-
**Returns:**
|
|
23
|
-
|
|
24
|
-
Dictionary<ComputedRef>
|
|
25
|
-
|
|
26
|
-
The requested getters from the module.
|
|
27
|
-
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-teleport.vue.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport :to=\"teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { defineComponent, watchEffect } from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String,
|
|
1
|
+
{"version":3,"file":"base-teleport.vue.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport :to=\"teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { defineComponent, watchEffect } from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n const teleportHost = document.createElement('div')\n\n watchEffect(() => {\n if (props.disabled) {\n teleportHost.remove()\n return\n }\n teleportHost.className = `x-base-teleport x-base-teleport--${props.position}`\n const targetElement =\n typeof props.target === 'string' ? document.querySelector(props.target) : props.target\n if (!targetElement) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.insertAdjacentElement(position, teleportHost)\n })\n\n return { teleportHost }\n },\n})\n</script>\n\n<style lang=\"css\">\n:has(> .x-base-teleport--onlychild) > *:not(.x-base-teleport) {\n display: none;\n}\n</style>\n"],"names":["teleportHost","_openBlock","_createBlock","_Teleport"],"mappings":";;;;;SACiBA,WAAY,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAAA,QAAA,EAAA;AAAG,EAAA,OAAAC,SAAA,EAAQ,EAAAC,WAAA,CAAAC,QAAA,EAAA;AAAA,IAAA,EAAA,EAAA,IAAA,CAAA,YAAA;IACpC,QAAa,EAAA,IAAA,CAAA,QAAA;AAAA,GAAA,EAAA;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-teleport.vue2.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport :to=\"teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { defineComponent, watchEffect } from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String,
|
|
1
|
+
{"version":3,"file":"base-teleport.vue2.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport :to=\"teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { defineComponent, watchEffect } from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n const teleportHost = document.createElement('div')\n\n watchEffect(() => {\n if (props.disabled) {\n teleportHost.remove()\n return\n }\n teleportHost.className = `x-base-teleport x-base-teleport--${props.position}`\n const targetElement =\n typeof props.target === 'string' ? document.querySelector(props.target) : props.target\n if (!targetElement) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.insertAdjacentElement(position, teleportHost)\n })\n\n return { teleportHost }\n },\n})\n</script>\n\n<style lang=\"css\">\n:has(> .x-base-teleport--onlychild) > *:not(.x-base-teleport) {\n display: none;\n}\n</style>\n"],"names":[],"mappings":";;AAUA,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;;AAEL,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA+B;AACpD,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;;;;AAOE;AACF,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,MAEL;AACD,YAAA,OAAO,EAAE,WAAW;AACrB,SAAA;;AAED,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;QACT,MAAM,YAAW,GAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAA,CAAA;QAEjD,WAAW,CAAC,MAAM;YAChB,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAClB,YAAY,CAAC,MAAM,EAAC,CAAA;gBACpB,OAAK;AACP,aAAA;YACA,YAAY,CAAC,SAAU,GAAE,CAAA,iCAAA,EAAoC,KAAK,CAAC,QAAQ,EAAC,CAAA;YAC5E,MAAM,aAAc,GAClB,OAAO,KAAK,CAAC,MAAO,KAAI,QAAO,GAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAA,GAAI,KAAK,CAAC,MAAK,CAAA;YACvF,IAAI,CAAC,aAAa,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAA,8BAAA,EAAiC,KAAK,CAAC,MAAM,CAAc,YAAA,CAAA,CAAA,CAAA;gBACxE,OAAK;AACP,aAAA;AACA,YAAA,MAAM,QAAO,GAAI,KAAK,CAAC,QAAS,KAAI,WAAU,GAAI,WAAY,GAAE,KAAK,CAAC,QAAO,CAAA;AAC7E,YAAA,aAAa,CAAC,qBAAqB,CAAC,QAAQ,EAAE,YAAY,CAAA,CAAA;AAC5D,SAAC,CAAA,CAAA;QAED,OAAO,EAAE,YAAa,EAAA,CAAA;KACvB;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
|
+
import { useStore } from 'vuex';
|
|
2
3
|
import '@vue/devtools-api';
|
|
3
4
|
import '../plugins/devtools/timeline.devtools.js';
|
|
4
5
|
import '@empathyco/x-utils';
|
|
@@ -8,25 +9,24 @@ import '../plugins/devtools/colors.utils.js';
|
|
|
8
9
|
import '../plugins/x-bus.js';
|
|
9
10
|
import '../plugins/x-plugin.js';
|
|
10
11
|
import { getGetterPath } from '../plugins/x-plugin.utils.js';
|
|
11
|
-
import { useStore } from 'vuex';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Function which returns the requested
|
|
14
|
+
* Function which returns the requested getter's properties as a dictionary.
|
|
15
15
|
*
|
|
16
16
|
* @param module - The {@link XModuleName} of the getter.
|
|
17
|
-
* @param getters - List of getters names.
|
|
18
17
|
* @returns The requested getters from the module.
|
|
19
18
|
* @public
|
|
20
19
|
*/
|
|
21
|
-
function useGetter(module
|
|
20
|
+
const useGetter = function useGetter(module) {
|
|
22
21
|
const store = useStore();
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
return new Proxy({}, {
|
|
23
|
+
get(_obj, getterName) {
|
|
24
|
+
const path = getGetterPath(module, getterName);
|
|
25
|
+
// eslint-disable-next-line ts/no-unsafe-member-access,ts/no-unsafe-return
|
|
26
|
+
return computed(() => store.getters[path]);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
export { useGetter };
|
|
32
32
|
//# sourceMappingURL=use-getter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-getter.js","sources":["../../../src/composables/use-getter.ts"],"sourcesContent":["import type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef } from 'vue'\nimport type { ExtractGetters, XModuleName } from '../x-modules/x-modules.types'\nimport { computed } from 'vue'\nimport { getGetterPath } from '../plugins/index'\
|
|
1
|
+
{"version":3,"file":"use-getter.js","sources":["../../../src/composables/use-getter.ts"],"sourcesContent":["import type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef } from 'vue'\nimport type { RootXStoreState } from '../store/index'\nimport type { ExtractGetters, XModuleName } from '../x-modules/x-modules.types'\nimport { computed } from 'vue'\nimport { useStore } from 'vuex'\nimport { getGetterPath } from '../plugins/index'\n\ninterface UseGetter {\n /** @deprecated Use the single-argument overload instead. */\n <Module extends XModuleName, Getters = keyof ExtractGetters<Module> & string[]>(\n module: Module,\n getters: Getters,\n ): Dictionary<ComputedRef>\n\n /**\n * Preferred. Use this signature for better type inference and future compatibility.\n */\n <Module extends XModuleName, Getters = ExtractGetters<Module>>(\n module: Module,\n ): { [P in keyof Getters]: ComputedRef<Getters[P]> }\n}\n\n/**\n * Function which returns the requested getter's properties as a dictionary.\n *\n * @param module - The {@link XModuleName} of the getter.\n * @returns The requested getters from the module.\n * @public\n */\nexport const useGetter: UseGetter = function useGetter<\n Module extends XModuleName,\n Getters = ExtractGetters<Module>,\n>(module: Module): { [P in keyof Getters]: ComputedRef<Getters[P]> } {\n const store = useStore<RootXStoreState>()\n return new Proxy({} as { [P in keyof Getters]: ComputedRef<Getters[P]> }, {\n get(_obj, getterName) {\n const path = getGetterPath(module, getterName as keyof ExtractGetters<Module>)\n // eslint-disable-next-line ts/no-unsafe-member-access,ts/no-unsafe-return\n return computed(() => store.getters[path as typeof getterName])\n },\n })\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAuBA;;;;;;AAMG;AACU,MAAA,SAAS,GAAc,SAAS,SAAS,CAGpD,MAAc,EAAA;AACd,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAmB,CAAA;AACzC,IAAA,OAAO,IAAI,KAAK,CAAC,EAAuD,EAAE;QACxE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAA;YAClB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,UAA0C,CAAC,CAAA;;AAE9E,YAAA,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAyB,CAAC,CAAC,CAAA;SAChE;AACF,KAAA,CAAC,CAAA;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef, PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n\n const { facets } = useGetter('facets', ['facets']) as {\n /** Dictionary of facets in the state. */\n facets: ComputedRef<Record<Facet['id'], Facet>>\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":["animation","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_renderSlot","_mergeProps","hasSlot","_createCommentVNode"],"mappings":";;;;;AACE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EADF,MACkBA,EAAAA,MAAAA,EAAAA,KAAAA,EAAAA,QAAAA,EAAAA;AADlB,EAAA,OAAA,IAAA,CAAA,SAAA,IAAAC,SAAA,EACmE,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAC,GAAA,EAAA,CAAA;AAAA,IAAmB,KAAI,EAAA,eAAA;AAAA,IAAA,WAAA,EAAA,QAAA;AAD3F,IAAA,GAAA,EAAA,IAAA;AAAA,GAAA,EAAA;;iBAIY,IAAO,CAAA,EAAAC,kBAAA;AAAA,QAAAC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,YAAA,EAAA,CAAA,EAAA,KAAA,EAAA,YAAA,EAAA,mBAAA,EAAA,EAAA,OAAA,KAAA;AACR,UAAA,OAAAL,SAAA,EAAsB,EAAAG,kBAAA,CAAA,IAAA,EAAA;AAAA,YAC3B,GAAA,EAAA,OAAA;AAAA,YAAA,KAAA,EAAA,qBAAA;AASe,YAAA,WAAA,EAAA,cAAA;AAAA,WAAA,EAAA;AAfrB,YAAA,IAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAAG,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,YAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AAgBiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;AAadC,cAAAA,eAAAA,EAAAA,IAAAA,CAAQ,sBAAmB,CAAA,OAAA,CAAA,IAAA,EAAA;AAAA,aAAA,CAAA,EAAA,KAAA,CAAA,EADxC,IA5BN,CAAA,GAAA,IAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAAF,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,mBAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AA8BiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;AAY3B,cAAA,eAAA,EAAA,IAAA,CAQO,8BARP,CAQO,IAAA,EAAA;AAAA,aAlDb,CAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA,GAAAD,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AA4CiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;+BA5CjC,IAiDoB,CAAA,sBAAA,CAAA,OAAA,CAAA,IAAA,EAAA;AAAA,aAAA,CAAA,EAAA,MAAA;;;;;;;;AAjDpB,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,CAAA,IAAAE,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":["animation","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_renderSlot","_mergeProps","hasSlot","_createCommentVNode"],"mappings":";;;;;AACE,SAAA,WAAA,CAAA,IAAA,EAAA,MAAA,EADF,MACkBA,EAAAA,MAAAA,EAAAA,KAAAA,EAAAA,QAAAA,EAAAA;AADlB,EAAA,OAAA,IAAA,CAAA,SAAA,IAAAC,SAAA,EACmE,EAAAC,WAAA,CAAAC,uBAAA,CAAA,IAAA,CAAA,SAAA,CAAA,EAAA;AAAA,IAAC,GAAA,EAAA,CAAA;AAAA,IAAmB,KAAI,EAAA,eAAA;AAAA,IAAA,WAAA,EAAA,QAAA;AAD3F,IAAA,GAAA,EAAA,IAAA;AAAA,GAAA,EAAA;;iBAIY,IAAO,CAAA,EAAAC,kBAAA;AAAA,QAAAC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAAA,IAAA,CAAA,YAAA,EAAA,CAAA,EAAA,KAAA,EAAA,YAAA,EAAA,mBAAA,EAAA,EAAA,OAAA,KAAA;AACR,UAAA,OAAAL,SAAA,EAAsB,EAAAG,kBAAA,CAAA,IAAA,EAAA;AAAA,YAC3B,GAAA,EAAA,OAAA;AAAA,YAAA,KAAA,EAAA,qBAAA;AASe,YAAA,WAAA,EAAA,cAAA;AAAA,WAAA,EAAA;AAfrB,YAAA,IAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAAG,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,YAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AAgBiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;AAadC,cAAAA,eAAAA,EAAAA,IAAAA,CAAQ,sBAAmB,CAAA,OAAA,CAAA,IAAA,EAAA;AAAA,aAAA,CAAA,EAAA,KAAA,CAAA,EADxC,IA5BN,CAAA,GAAA,IAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAAF,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,mBAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AA8BiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;AAY3B,cAAA,eAAA,EAAA,IAAA,CAQO,8BARP,CAQO,IAAA,EAAA;AAAA,aAlDb,CAAA,EAAA,KAAA,CAAA,EAAA,IAAA,CAAA,GAAAD,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,EAAAC,UAAA,CAAA;AAAA,cAAA,GAAA,EAAA,CAAA;AA4CiC,cAAA,OAAA,EAAA,IAAA;AAAA,aAAA,EAAA;;+BA5CjC,IAiDoB,CAAA,sBAAA,CAAA,OAAA,CAAA,IAAA,EAAA;AAAA,aAAA,CAAA,EAAA,MAAA;;;;;;;;AAjDpB,SAAA,CAAA;AAAA,QAAA,GAAA;AAAA;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,IAAA,CAAA,EAAA,CAAA;AAAA;AAAA,GAAA,CAAA,IAAAE,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -51,7 +51,7 @@ var _sfc_main = defineComponent({
|
|
|
51
51
|
},
|
|
52
52
|
setup(props, { slots }) {
|
|
53
53
|
const { selectedFiltersByFacet } = useFacets(props);
|
|
54
|
-
const { facets } = useGetter('facets'
|
|
54
|
+
const { facets } = useGetter('facets');
|
|
55
55
|
/**
|
|
56
56
|
* The facets to be rendered after filtering {@link Facets.facets} by
|
|
57
57
|
* {@link Facets.renderableFacets} content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { ComputedRef, PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n\n const { facets } = useGetter('facets', ['facets']) as {\n /** Dictionary of facets in the state. */\n facets: ComputedRef<Record<Facet['id'], Facet>>\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;;;AA8EA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,KAAqC;;AAEhD,QAAA,aAAa,EAAE,OAAO;;AAEtB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;;;;;;;;;;;;;;;AAkBE;AACF,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,KAAI,EAAG,EAAA;QACpB,MAAM,EAAE,sBAAqB,KAAM,SAAS,CAAC,KAAK,CAAA,CAAA;AAElD,QAAA,MAAM,EAAE,QAAS,GAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAGjD,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,cAAa,GAAI,QAAQ,CAAoB,MAAM;AACvD,YAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC3B,OAAO,MAAM,CAAC,KAAI,CAAA;AAClB,aAAA;AAAK,iBAAA;gBACL,MAAM,cAAe,GAAE,IAAG,CAAA;gBAC1B,MAAM,QAAQ,GAAa,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAM,IAAK,OAAO,CAAC,IAAI,EAAE,CAAA,CAAA;gBAC1F,MAAM,QAAQ,GAAa,EAAC,CAAA;gBAC5B,MAAM,QAAQ,GAAa,EAAC,CAAA;AAC5B,gBAAA,QAAQ,CAAC,OAAO,CAAC,OAAQ,IAAG;AAC1B,oBAAA,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;AAChC,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA,CAAA;AACjD,qBAAA;AAAK,yBAAA;AACL,wBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAA,CAAA;AACvB,qBAAA;AACF,iBAAC,CAAA,CAAA;AAED,gBAAA,OAAO,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAA,CAAA;AAChD,aAAA;AACF,SAAC,CAAA,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,YAAa,GAAE,QAAQ,CAA0B,MAAM;AAC3D,YAAA,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,MAAM;AACpD,gBAAA,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC;AAClC,gBAAA,mBAAmB,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjD,KAAK;AACN,aAAA,CAAC,CAAA,CAAA;AACJ,SAAC,CAAA,CAAA;AAED;;;;AAIE;QACF,MAAM,SAAQ,GAAI,QAAQ,CAAU,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA,CAAA;AAEpF;;;;;;;AAOE;AACF,QAAA,SAAS,oBAAoB,CAAC,QAAkB,EAAE,QAAkB,EAAA;AAClE,YAAA,MAAM,mBAAoB,GAAE,QAAQ,CAAC,SAAS,CAAA,CAAA;YAC9C,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,QAAO,IAAK;gBAC5C,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAA;gBACrD,MAAM,UAAS,GAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAA;AAErD,gBAAA,OAAO,mBAAoB,GAAE,UAAW,IAAG,CAAC,UAAS,GAAI,CAAC,UAAS,CAAA;AACrE,aAAC,CAAA,CAAA;SACH;AAEA;;;;;;AAME;QACF,SAAS,OAAO,CAAC,IAAY,EAAA;AAC3B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA,CAAA;SACrB;QAEA,OAAO;YACL,sBAAsB;YACtB,SAAS;YACT,YAAY;YACZ,OAAO;SACT,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"facets.vue2.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" v-if=\"hasFacets\" class=\"x-facets-list\" data-test=\"facets\" tag=\"ul\">\n <li\n v-for=\"({ facet, slotNameById, slotNameByModelName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-if=\"hasSlot(slotNameById)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameById\"\n />\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's modelName will result\n in the facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else-if=\"hasSlot(slotNameByModelName)\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n :name=\"slotNameByModelName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n @binding {Filter[]} selectedFilters - List of selected filters of the given facet\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || [],\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { PropType } from 'vue'\nimport { map, objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent } from 'vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { AnimationProp } from '../../../../types'\nimport { toKebabCase } from '../../../../utils/string'\nimport { useFacets } from '../../composables/use-facets'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotNameById: string\n slotNameByModelName: string\n facet: Facet\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @public\n */\nexport default defineComponent({\n name: 'Facets',\n xModule: facetsXModule.name,\n props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds: Array as PropType<Array<Facet['id']>>,\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible: Boolean,\n /** Animation component that will be used to animate the facets. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n */\n renderableFacets: String,\n },\n setup(props, { slots }) {\n const { selectedFiltersByFacet } = useFacets(props)\n const { facets } = useGetter('facets')\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n */\n const facetsToRender = computed<Dictionary<Facet>>(() => {\n if (!props.renderableFacets) {\n return facets.value\n } else {\n const excludedRegExp = /^!/\n const facetIds: string[] = props.renderableFacets.split(',').map(facetId => facetId.trim())\n const included: string[] = []\n const excluded: string[] = []\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''))\n } else {\n included.push(facetId)\n }\n })\n\n return filterFacetsToRender(included, excluded)\n }\n })\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n */\n const mappedFacets = computed<Dictionary<RenderFacet>>(() => {\n return map(facetsToRender.value, (facetId, facet) => ({\n slotNameById: toKebabCase(facetId),\n slotNameByModelName: toKebabCase(facet.modelName),\n facet,\n }))\n })\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n */\n const hasFacets = computed<boolean>(() => !!Object.keys(facetsToRender.value).length)\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n */\n function filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0\n return objectFilter(facets.value, facetKey => {\n const isIncluded = included.includes(String(facetKey))\n const isExcluded = excluded.includes(String(facetKey))\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded\n })\n }\n\n /**\n * Whether the slot is present in the template or not.\n *\n * @param name - The slot name.\n *\n * @returns True is the slot is present in the template. False otherwise.\n */\n function hasSlot(name: string): boolean {\n return !!slots[name]\n }\n\n return {\n selectedFiltersByFacet,\n hasFacets,\n mappedFacets,\n hasSlot,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-facets-list {\n display: flex;\n flex-flow: column nowrap;\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\nIt is also possible to customize the Facet content by the facet \"model name\". For example, to\nconfigure different content for \"Hierarchical Facets\" the \"hierarchical-facet\" slot will apply that\ncustomization. This can be combined with the facets by facet id. If some hierarchical facet needs\nsome different customization from the rest of the hierarchical, it can be achieve using the slot\nwith the facet id.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #hierarchical-facet=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n <ul v-for=\"childFilter in filter.children\" :key=\"filter.id\">\n <li v-if=\"!childFilter.selected\">\n {{ childFilter.label }}\n </li>\n </ul>\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\nimport { Facets } from '@empathyco/x-components/facets'\n\nexport default {\n components: {\n Facets,\n },\n}\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\nimport {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter,\n} from '@empathyco/x-components/facets'\n\nimport { BasePriceFilterLabel } from '@empathyco/x-components'\n\nexport default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel,\n },\n}\n</script>\n```\n</docs>\n"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type {
|
|
1
|
+
{"version":3,"file":"all-filter.vue.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../../components/base-event-button.vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet } = useGetter('facets')\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":["_resolveComponent","_openBlock","_createBlock","_normalizeClass","_withCtx","facet","_renderSlot","isSelected"],"mappings":";;;;;AAcoB,EAAA,MAAA,0BAAA,GAAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AAXhB,EAAA,OAAAC,SAAA,EAAsB,EAAAC,WAAA,CAAA,0BAAA,EAAA;AAAA,IACtB,OAAKC,cAAU,CAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,UAAA,CAAA,CAAA;AAAA,IACd,WAAA,EAAA,YAAA;AAAA,IACA,IAAM,EAAA,UAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,UAAA,CAAA,QAAA,EAAA;AANX,IAAA,MAAA,EAAA,IAAA,CAAA,UAAA;AAAA,GAAA,EAAA;AAagB,IAAA,OAAA,EAAAC,OAAA,CAAEC,MAAK;AAAA,MAAAC,UAAA,CAAc,KAAEC,MAAU,EAAA,SAAA,EAAA;AAAA,QAAY,KAAA,EAAA,IAAA,CAAA,KAAA;AAAA,QAb7D,UAamD,EAAA,IAAA,CAAA,UAAA;AAAA,OAAA,EAAA,MAAA;;AAbnD,OAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -28,7 +28,7 @@ var _sfc_main = defineComponent({
|
|
|
28
28
|
},
|
|
29
29
|
setup(props) {
|
|
30
30
|
/** The getter of the selectedFiltersByFacet. */
|
|
31
|
-
const { selectedFiltersByFacet } = useGetter('facets'
|
|
31
|
+
const { selectedFiltersByFacet } = useGetter('facets');
|
|
32
32
|
/**
|
|
33
33
|
* The event that will be emitted when the all filter button is clicked.
|
|
34
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-filter.vue2.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type {
|
|
1
|
+
{"version":3,"file":"all-filter.vue2.js","sources":["../../../../../../src/x-modules/facets/components/filters/all-filter.vue"],"sourcesContent":["<template>\n <BaseEventButton\n class=\"x-facet-filter x-all-filter\"\n data-test=\"all-filter\"\n role=\"checkbox\"\n :aria-checked=\"isSelected.toString()\"\n :events=\"clickEvent\"\n :class=\"cssClasses\"\n >\n <!--\n @slot The content to render inside the button\n @binding {Facet} Facet - The facet data\n -->\n <slot :facet=\"facet\" :is-selected=\"isSelected\">all</slot>\n </BaseEventButton>\n</template>\n\n<script lang=\"ts\">\nimport type { Facet } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport type { XEventsTypes } from '../../../../wiring/events.types'\nimport { computed, defineComponent } from 'vue'\nimport BaseEventButton from '../../../../components/base-event-button.vue'\nimport { useGetter } from '../../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../../utils/array'\nimport { facetsXModule } from '../../x-module'\n\n/**\n * This component receives a required `facet` with\n * {@link @empathyco/x-types#BooleanFilter} as prop and renders a button, which\n * on clicked emits the {@link FacetsXEvents.UserClickedAllFilter} event. By default\n * the rendered button displays a message with the facet label but this content is customizable\n * through the default slot.\n *\n * @public\n */\nexport default defineComponent({\n name: 'AllFilter',\n components: {\n BaseEventButton,\n },\n xModule: facetsXModule.name,\n props: {\n /** The facet data. */\n facet: {\n type: Object as PropType<Facet>,\n required: true,\n },\n },\n setup(props) {\n /** The getter of the selectedFiltersByFacet. */\n const { selectedFiltersByFacet } = useGetter('facets')\n\n /**\n * The event that will be emitted when the all filter button is clicked.\n *\n * @returns The event to emit on click.\n * @internal\n */\n const clickEvent = computed((): Partial<XEventsTypes> => {\n return { UserClickedAllFilter: [props.facet.id] }\n })\n\n /**\n * Computed to retrieve the selected state of this component.\n *\n * @returns True if is selected false otherwise.\n */\n const isSelected = computed(() => {\n return isArrayEmpty(selectedFiltersByFacet.value?.[props.facet.id])\n })\n\n /**\n * Dynamic CSS classes to apply to the component.\n *\n * @remarks This is only valid considering that in the case of HierarchicalFilters, ancestors\n * of nested selected filters are also selected.\n *\n * @returns The dynamic CSS classes to apply to the component.\n * @internal\n */\n const cssClasses = computed(() => {\n return {\n 'x-selected x-all-filter--is-selected': isSelected.value,\n }\n })\n\n return {\n clickEvent,\n cssClasses,\n isSelected,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nA list of events that the component will emit:\n\n- [`UserClickedAllFilter`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n the event is emitted after the user clicks the button. The event payload is the id of the facet\n that this `AllFilter` component corresponds to.\n\n## Examples\n\nThis component receives a required `facet` as prop and renders a button, which on clicked emits the\nUserClickedAllFilter event. By default the rendered button displays a message with the facet label\nbut this content is customizable through the default slot.\n\n### Basic usage\n\n```vue\n<AllFilter :facet=\"facet\" />\n```\n\n### Customizing its content\n\n```vue\n<AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n</AllFilter>\n```\n\n### Basic example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter :facet=\"facet\" />\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n\n### Custom example within facets\n\n```vue\n<Facets>\n <template #default=\"{ facet }\">\n <AllFilter v-slot=\"{ facet }\" :facet=\"facet\">\n Select all {{ facet.label }}\n </AllFilter>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <SimpleFilter :filter=\"filter\" />\n </Filters>\n </template>\n</Facets>\n```\n</docs>\n"],"names":[],"mappings":";;;;;;AA2BA;;;;;;;;AAQE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU,EAAE;QACV,eAAe;AAChB,KAAA;IACD,OAAO,EAAE,aAAa,CAAC,IAAI;AAC3B,IAAA,KAAK,EAAE;;AAEL,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAyB;AAC/B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACF,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;;QAET,MAAM,EAAE,wBAAyB,GAAE,SAAS,CAAC,QAAQ,CAAA,CAAA;AAErD;;;;;AAKE;AACF,QAAA,MAAM,UAAS,GAAI,QAAQ,CAAC,MAA6B;YACvD,OAAO,EAAE,oBAAoB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,EAAA,CAAA;AAClD,SAAC,CAAA,CAAA;AAED;;;;AAIE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;AAChC,YAAA,OAAO,YAAY,CAAC,sBAAsB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA,CAAA;AACpE,SAAC,CAAA,CAAA;AAED;;;;;;;;AAQE;AACF,QAAA,MAAM,UAAW,GAAE,QAAQ,CAAC,MAAM;YAChC,OAAO;gBACL,sCAAsC,EAAE,UAAU,CAAC,KAAK;aAC1D,CAAA;AACF,SAAC,CAAA,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;YACV,UAAU;SACZ,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
|
|
@@ -10,10 +10,7 @@ import { isArrayEmpty } from '../../../utils/array.js';
|
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
function useFacets(props) {
|
|
13
|
-
const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets'
|
|
14
|
-
'selectedFiltersByFacet',
|
|
15
|
-
'selectedFilters',
|
|
16
|
-
]);
|
|
13
|
+
const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets');
|
|
17
14
|
/**
|
|
18
15
|
* Get selected filters.
|
|
19
16
|
* If there are facets ids, get selected filters whose facet id match with some of facets ids.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-facets.js","sources":["../../../../../src/x-modules/facets/composables/use-facets.ts"],"sourcesContent":["import type { Facet, Filter } from '@empathyco/x-types'\nimport type { ComputedRef } from 'vue'\nimport type { FiltersByFacet } from '../store/types'\nimport { computed } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../utils/array'\n\n/**\n * Composable to share Facets logic.\n *\n * @param props - Composable props.\n * @returns Composable.\n * @public\n */\nexport function useFacets(props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds?: Array<Facet['id']>\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible?: boolean\n}) {\n const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets', [\n 'selectedFiltersByFacet',\n 'selectedFilters',\n ]) as {\n /** Dictionary of filters {@link FiltersByFacet} filtered by facet id. */\n selectedFiltersByFacet: ComputedRef<FiltersByFacet>\n /** Get the selected filters from store. */\n selectedFilters: ComputedRef<Filter[]>\n }\n\n /**\n * Get selected filters.\n * If there are facets ids, get selected filters whose facet id match with some of facets ids.\n * If there aren't facets ids, get selected filters.\n *\n * @returns Array of selected filters depends on there are facets ids or not.\n */\n const selectedFilters = computed<Filter[]>(() => {\n if (props.facetsIds) {\n return (props.facetsIds as string[]).reduce(\n (selectedFilters, facetId) => [\n ...selectedFilters,\n ...(Array.isArray(selectedFiltersByFacet.value[facetId])\n ? selectedFiltersByFacet.value[facetId]\n : []),\n ],\n [] as Filter[],\n )\n }\n\n return selectedFiltersGetter.value\n })\n\n /**\n * Check if there are selected filters.\n *\n * @returns True or false depends on if there are selected filters.\n */\n const hasSelectedFilters = computed<boolean>(() => !isArrayEmpty(selectedFilters.value))\n\n /**\n * Flag representing if the component should be visible/rendered or not.\n *\n * @returns True whenever alwaysVisible is true or has selected filters. False\n * otherwise.\n */\n const isVisible = computed<boolean>(() => !!props.alwaysVisible || hasSelectedFilters.value)\n\n return {\n selectedFiltersByFacet,\n selectedFilters,\n hasSelectedFilters,\n isVisible,\n }\n}\n"],"names":[],"mappings":";;;;AAOA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,KAKzB,EAAA;IACC,MAAM,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"use-facets.js","sources":["../../../../../src/x-modules/facets/composables/use-facets.ts"],"sourcesContent":["import type { Facet, Filter } from '@empathyco/x-types'\nimport type { ComputedRef } from 'vue'\nimport type { FiltersByFacet } from '../store/types'\nimport { computed } from 'vue'\nimport { useGetter } from '../../../composables/use-getter'\nimport { isArrayEmpty } from '../../../utils/array'\n\n/**\n * Composable to share Facets logic.\n *\n * @param props - Composable props.\n * @returns Composable.\n * @public\n */\nexport function useFacets(props: {\n /** Array of facets ids used to get the selected filters for those facets. */\n facetsIds?: Array<Facet['id']>\n /** Flag to render the component even if there are no filters selected. */\n alwaysVisible?: boolean\n}) {\n const { selectedFiltersByFacet, selectedFilters: selectedFiltersGetter } = useGetter('facets', [\n 'selectedFiltersByFacet',\n 'selectedFilters',\n ]) as {\n /** Dictionary of filters {@link FiltersByFacet} filtered by facet id. */\n selectedFiltersByFacet: ComputedRef<FiltersByFacet>\n /** Get the selected filters from store. */\n selectedFilters: ComputedRef<Filter[]>\n }\n\n /**\n * Get selected filters.\n * If there are facets ids, get selected filters whose facet id match with some of facets ids.\n * If there aren't facets ids, get selected filters.\n *\n * @returns Array of selected filters depends on there are facets ids or not.\n */\n const selectedFilters = computed<Filter[]>(() => {\n if (props.facetsIds) {\n return (props.facetsIds as string[]).reduce(\n (selectedFilters, facetId) => [\n ...selectedFilters,\n ...(Array.isArray(selectedFiltersByFacet.value[facetId])\n ? selectedFiltersByFacet.value[facetId]\n : []),\n ],\n [] as Filter[],\n )\n }\n\n return selectedFiltersGetter.value\n })\n\n /**\n * Check if there are selected filters.\n *\n * @returns True or false depends on if there are selected filters.\n */\n const hasSelectedFilters = computed<boolean>(() => !isArrayEmpty(selectedFilters.value))\n\n /**\n * Flag representing if the component should be visible/rendered or not.\n *\n * @returns True whenever alwaysVisible is true or has selected filters. False\n * otherwise.\n */\n const isVisible = computed<boolean>(() => !!props.alwaysVisible || hasSelectedFilters.value)\n\n return {\n selectedFiltersByFacet,\n selectedFilters,\n hasSelectedFilters,\n isVisible,\n }\n}\n"],"names":[],"mappings":";;;;AAOA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,KAKzB,EAAA;IACC,MAAM,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC,QAGpF,CAKA,CAAA;AAED;;;;;;AAMG;AACH,IAAA,MAAM,eAAe,GAAG,QAAQ,CAAW,MAAK;QAC9C,IAAI,KAAK,CAAC,SAAS,EAAE;AACnB,YAAA,OAAQ,KAAK,CAAC,SAAsB,CAAC,MAAM,CACzC,CAAC,eAAe,EAAE,OAAO,KAAK;AAC5B,gBAAA,GAAG,eAAe;gBAClB,IAAI,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACtD,sBAAE,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC;sBACrC,EAAE;aACP,EACD,EAAc,CACf,CAAA;AACF,SAAA;QAED,OAAO,qBAAqB,CAAC,KAAK,CAAA;AACpC,KAAC,CAAC,CAAA;AAEF;;;;AAIG;AACH,IAAA,MAAM,kBAAkB,GAAG,QAAQ,CAAU,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AAExF;;;;;AAKG;AACH,IAAA,MAAM,SAAS,GAAG,QAAQ,CAAU,MAAM,CAAC,CAAC,KAAK,CAAC,aAAa,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAE5F,OAAO;QACL,sBAAsB;QACtB,eAAe;QACf,kBAAkB;QAClB,SAAS;KACV,CAAA;AACH;;;;"}
|