@empathyco/x-components 7.5.0 → 8.1.0
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 +18 -0
- package/browse/index.js +0 -1
- package/core/index.js +3 -0
- package/core/index.js.map +1 -1
- package/docs/API-reference/api/x-components.aiconfig.md +0 -45
- package/docs/API-reference/api/x-components.md +0 -11
- package/docs/API-reference/api/x-components.sortdropdown.md +30 -4
- package/docs/API-reference/api/x-components.sortlist.md +32 -7
- package/docs/API-reference/api/x-components.sortpickerlist.md +32 -7
- package/docs/API-reference/api/x-components.usealiasapi.browseselectedsort.md +13 -0
- package/docs/API-reference/api/x-components.usealiasapi.md +21 -0
- package/docs/API-reference/components/{search → common/sort}/x-components.sort-dropdown.md +7 -4
- package/docs/API-reference/components/{search → common/sort}/x-components.sort-list.md +7 -4
- package/docs/API-reference/components/{search → common/sort}/x-components.sort-picker-list.md +8 -5
- package/js/{x-modules/search/components → components/sort}/sort-dropdown.vue.js +1 -1
- package/js/components/sort/sort-dropdown.vue.js.map +1 -0
- package/js/{x-modules/search/components → components/sort}/sort-dropdown.vue2.js +19 -12
- package/js/components/sort/sort-dropdown.vue2.js.map +1 -0
- package/js/{x-modules/search/components → components/sort}/sort-list.vue.js +2 -2
- package/js/components/sort/sort-list.vue.js.map +1 -0
- package/js/{x-modules/search/components → components/sort}/sort-list.vue2.js +22 -15
- package/js/components/sort/sort-list.vue2.js.map +1 -0
- package/js/components/sort/sort-list.vue3.js +7 -0
- package/js/{x-modules/search/components → components/sort}/sort-picker-list.vue.js +1 -1
- package/js/components/sort/sort-picker-list.vue.js.map +1 -0
- package/js/{x-modules/search/components → components/sort}/sort-picker-list.vue2.js +21 -14
- package/js/components/sort/sort-picker-list.vue2.js.map +1 -0
- package/js/composables/use-alias-api.js +3 -0
- package/js/composables/use-alias-api.js.map +1 -1
- package/js/index.js +3 -4
- package/js/index.js.map +1 -1
- package/js/x-modules/ai/components/ai-carousel.vue2.js +4 -0
- package/js/x-modules/ai/components/ai-carousel.vue2.js.map +1 -1
- package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js +4 -0
- package/js/x-modules/ai/components/ai-grouped-carousel.vue2.js.map +1 -1
- package/js/x-modules/ai/store/getters/suggestions-request.getter.js +2 -2
- package/js/x-modules/ai/store/getters/suggestions-request.getter.js.map +1 -1
- package/js/x-modules/ai/store/module.js +1 -3
- package/js/x-modules/ai/store/module.js.map +1 -1
- package/js/x-modules/browse/store/actions/set-url-params.action.js +1 -1
- package/js/x-modules/browse/store/actions/set-url-params.action.js.map +1 -1
- package/js/x-modules/browse/wiring.js +6 -1
- package/js/x-modules/browse/wiring.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue2.js +4 -0
- package/js/x-modules/empathize/components/empathize.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview-button.vue2.js +4 -0
- package/js/x-modules/queries-preview/components/query-preview-button.vue2.js.map +1 -1
- package/js/x-modules/queries-preview/components/query-preview.vue2.js +4 -0
- package/js/x-modules/queries-preview/components/query-preview.vue2.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js +4 -0
- package/js/x-modules/scroll/components/scroll-to-top.vue2.js.map +1 -1
- package/js/x-modules/search/store/actions/set-url-params.action.js +1 -1
- package/js/x-modules/search/store/actions/set-url-params.action.js.map +1 -1
- package/js/x-modules/search/wiring.js +3 -0
- package/js/x-modules/search/wiring.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +516 -333
- package/report/x-components.api.md +106 -57
- package/search/index.js +0 -3
- package/types/src/components/index.d.ts +1 -0
- package/types/src/components/index.d.ts.map +1 -1
- package/types/src/components/sort/index.d.ts +4 -0
- package/types/src/components/sort/index.d.ts.map +1 -0
- package/types/src/{x-modules/search/components → components/sort}/sort-dropdown.vue.d.ts +33 -6
- package/types/src/components/sort/sort-dropdown.vue.d.ts.map +1 -0
- package/types/src/{x-modules/search/components → components/sort}/sort-list.vue.d.ts +35 -10
- package/types/src/components/sort/sort-list.vue.d.ts.map +1 -0
- package/types/src/{x-modules/search/components → components/sort}/sort-picker-list.vue.d.ts +45 -10
- package/types/src/components/sort/sort-picker-list.vue.d.ts.map +1 -0
- package/types/src/composables/use-alias-api.d.ts +2 -0
- package/types/src/composables/use-alias-api.d.ts.map +1 -1
- package/types/src/x-modules/ai/config.types.d.ts +0 -4
- package/types/src/x-modules/ai/config.types.d.ts.map +1 -1
- package/types/src/x-modules/ai/store/getters/suggestions-request.getter.d.ts.map +1 -1
- package/types/src/x-modules/ai/store/module.d.ts.map +1 -1
- package/types/src/x-modules/browse/components/index.d.ts +0 -1
- package/types/src/x-modules/browse/components/index.d.ts.map +1 -1
- package/types/src/x-modules/browse/wiring.d.ts +6 -1
- package/types/src/x-modules/browse/wiring.d.ts.map +1 -1
- package/types/src/x-modules/search/components/index.d.ts +0 -3
- package/types/src/x-modules/search/components/index.d.ts.map +1 -1
- package/types/src/x-modules/search/wiring.d.ts +3 -0
- package/types/src/x-modules/search/wiring.d.ts.map +1 -1
- package/docs/API-reference/api/x-components.aiconfig.lowresultsthreshold.md +0 -13
- package/docs/API-reference/api/x-components.browsesortpickerlist.md +0 -45
- package/docs/API-reference/components/browse/x-components.browse-sort-picker-list.md +0 -24
- package/js/x-modules/browse/components/browse-sort-picker-list.vue.js +0 -73
- package/js/x-modules/browse/components/browse-sort-picker-list.vue.js.map +0 -1
- package/js/x-modules/browse/components/browse-sort-picker-list.vue2.js +0 -6
- package/js/x-modules/browse/components/browse-sort-picker-list.vue2.js.map +0 -1
- package/js/x-modules/search/components/sort-dropdown.vue.js.map +0 -1
- package/js/x-modules/search/components/sort-dropdown.vue2.js.map +0 -1
- package/js/x-modules/search/components/sort-list.vue.js.map +0 -1
- package/js/x-modules/search/components/sort-list.vue2.js.map +0 -1
- package/js/x-modules/search/components/sort-list.vue3.js +0 -7
- package/js/x-modules/search/components/sort-picker-list.vue.js.map +0 -1
- package/js/x-modules/search/components/sort-picker-list.vue2.js.map +0 -1
- package/types/src/x-modules/browse/components/browse-sort-picker-list.vue.d.ts +0 -50
- package/types/src/x-modules/browse/components/browse-sort-picker-list.vue.d.ts.map +0 -1
- package/types/src/x-modules/search/components/sort-dropdown.vue.d.ts.map +0 -1
- package/types/src/x-modules/search/components/sort-list.vue.d.ts.map +0 -1
- package/types/src/x-modules/search/components/sort-picker-list.types.d.ts +0 -12
- package/types/src/x-modules/search/components/sort-picker-list.types.d.ts.map +0 -1
- package/types/src/x-modules/search/components/sort-picker-list.vue.d.ts.map +0 -1
- /package/js/{x-modules/search/components → components/sort}/sort-list.vue3.js.map +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.1.0](https://github.com/empathyco/x/compare/@empathyco/x-components@8.0.0...@empathyco/x-components@8.1.0) (2026-07-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* trigger ai suggestions only in no results scenario (#2137)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [8.0.0](https://github.com/empathyco/x/compare/@empathyco/x-components@7.5.0...@empathyco/x-components@8.0.0) (2026-07-13)
|
|
14
|
+
|
|
15
|
+
### ⚠ BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* Sorting components moved to x-components/src/components/sort. Now, sorting components can be used by the search and browse module by managing them through props.
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* create sort components that could be shared between search and … (#2134)
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [7.5.0](https://github.com/empathyco/x/compare/@empathyco/x-components@7.4.1...@empathyco/x-components@7.5.0) (2026-07-13)
|
|
7
25
|
|
|
8
26
|
### Features
|
package/browse/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as BrowseResultsList } from '../js/x-modules/browse/components/browse-results-list.vue.js';
|
|
2
|
-
export { default as BrowseSortPickerList } from '../js/x-modules/browse/components/browse-sort-picker-list.vue.js';
|
|
3
2
|
export { cancelFetchAndSaveBrowseResponse, fetchAndSaveBrowseResponse } from '../js/x-modules/browse/store/actions/fetch-and-save-browse-response.action.js';
|
|
4
3
|
export { fetchAndSaveResultsEnrichment as fetchAndSaveBrowseResultsEnrichment } from '../js/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.js';
|
|
5
4
|
export { fetchBrowseResponse } from '../js/x-modules/browse/store/actions/fetch-browse-response.action.js';
|
package/core/index.js
CHANGED
|
@@ -145,6 +145,9 @@ export { default as BaseScroll } from '../js/components/scroll/base-scroll.vue.j
|
|
|
145
145
|
export { useScroll } from '../js/components/scroll/use-scroll.js';
|
|
146
146
|
export { default as SlidingPanel } from '../js/components/sliding-panel.vue.js';
|
|
147
147
|
export { default as SnippetCallbacks } from '../js/components/snippet-callbacks.vue.js';
|
|
148
|
+
export { default as SortDropdown } from '../js/components/sort/sort-dropdown.vue.js';
|
|
149
|
+
export { default as SortList } from '../js/components/sort/sort-list.vue.js';
|
|
150
|
+
export { default as SortPickerList } from '../js/components/sort/sort-picker-list.vue.js';
|
|
148
151
|
export { default as BaseSuggestion } from '../js/components/suggestions/base-suggestion.vue.js';
|
|
149
152
|
export { default as BaseSuggestions } from '../js/components/suggestions/base-suggestions.vue.js';
|
|
150
153
|
export { getRootXComponent, getXComponentXModuleName, isXComponent } from '../js/components/x-component.utils.js';
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -11,48 +11,3 @@ Configuration options for the [AiXModule](./x-components.aixmodule.md)<!-- -->.
|
|
|
11
11
|
```typescript
|
|
12
12
|
export interface AiConfig
|
|
13
13
|
```
|
|
14
|
-
|
|
15
|
-
## Properties
|
|
16
|
-
|
|
17
|
-
<table><thead><tr><th>
|
|
18
|
-
|
|
19
|
-
Property
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</th><th>
|
|
23
|
-
|
|
24
|
-
Modifiers
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</th><th>
|
|
28
|
-
|
|
29
|
-
Type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</th><th>
|
|
33
|
-
|
|
34
|
-
Description
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</th></tr></thead>
|
|
38
|
-
<tbody><tr><td>
|
|
39
|
-
|
|
40
|
-
[lowResultsThreshold](./x-components.aiconfig.lowresultsthreshold.md)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</td><td>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</td><td>
|
|
47
|
-
|
|
48
|
-
number
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</td><td>
|
|
52
|
-
|
|
53
|
-
Maximum number of results in the SearchResponse to display ai elements.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</td></tr>
|
|
57
|
-
</tbody></table>
|
|
58
|
-
|
|
@@ -4329,17 +4329,6 @@ The component provides a default slot which wraps the whole component with the `
|
|
|
4329
4329
|
It also provides the slot result to customize the item, which is within the default slot, with the result bound.
|
|
4330
4330
|
|
|
4331
4331
|
|
|
4332
|
-
</td></tr>
|
|
4333
|
-
<tr><td>
|
|
4334
|
-
|
|
4335
|
-
[BrowseSortPickerList](./x-components.browsesortpickerlist.md)
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
</td><td>
|
|
4339
|
-
|
|
4340
|
-
The `SortPickerList` component allows user to select the browse results order. This component also allows to change the selected sort programmatically.
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
4332
|
</td></tr>
|
|
4344
4333
|
<tr><td>
|
|
4345
4334
|
|
|
@@ -10,24 +10,50 @@ The `SortDropdown` component allows user to select the search results order. Thi
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
13
|
+
animation: PropType<string | Component>;
|
|
13
14
|
items: {
|
|
14
15
|
type: PropType<Sort[]>;
|
|
15
16
|
required: true;
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
+
selectedSort: {
|
|
19
|
+
type: PropType<Sort>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
selectedSortProvidedEvent: {
|
|
23
|
+
type: PropType<XEvent>;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
clickedSortEvent: {
|
|
27
|
+
type: PropType<XEvent>;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
18
30
|
}>, {
|
|
19
31
|
emitUserClickedASort: (sort: Sort) => void;
|
|
20
32
|
rootRef: import("vue").Ref<import("vue").DefineComponent<{}, {}, any> | undefined, import("vue").DefineComponent<{}, {}, any> | undefined>;
|
|
21
|
-
selectedSort: import("vue").ComputedRef<string>;
|
|
22
33
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
animation: PropType<string | Component>;
|
|
23
35
|
items: {
|
|
24
36
|
type: PropType<Sort[]>;
|
|
25
37
|
required: true;
|
|
26
38
|
};
|
|
27
|
-
|
|
39
|
+
selectedSort: {
|
|
40
|
+
type: PropType<Sort>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
selectedSortProvidedEvent: {
|
|
44
|
+
type: PropType<XEvent>;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
clickedSortEvent: {
|
|
48
|
+
type: PropType<XEvent>;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
28
51
|
}>> & Readonly<{
|
|
29
52
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
30
|
-
}>, {
|
|
53
|
+
}>, {
|
|
54
|
+
selectedSortProvidedEvent: keyof import("../../wiring/events.types").XEventsTypes;
|
|
55
|
+
clickedSortEvent: keyof import("../../wiring/events.types").XEventsTypes;
|
|
56
|
+
}, {}, {
|
|
31
57
|
BaseDropdown: import("vue").DefineComponent<{}, {}, any>;
|
|
32
58
|
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
|
|
33
59
|
```
|
|
@@ -10,28 +10,53 @@ The `SortList` component allows user to select the search results order. This co
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
13
|
+
animation: {
|
|
14
|
+
type: PropType<string | Component>;
|
|
15
|
+
default: () => string;
|
|
16
|
+
};
|
|
13
17
|
items: {
|
|
14
18
|
type: PropType<Sort[]>;
|
|
15
19
|
required: true;
|
|
16
20
|
};
|
|
17
|
-
|
|
18
|
-
type: PropType<
|
|
19
|
-
|
|
21
|
+
selectedSort: {
|
|
22
|
+
type: PropType<Sort>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
selectedSortProvidedEvent: {
|
|
26
|
+
type: PropType<XEvent>;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
clickedSortEvent: {
|
|
30
|
+
type: PropType<XEvent>;
|
|
31
|
+
default: string;
|
|
20
32
|
};
|
|
21
33
|
}>, {
|
|
22
34
|
listItems: import("vue").ComputedRef<SortListItem[]>;
|
|
23
|
-
selectedSort: import("vue").ComputedRef<string>;
|
|
24
35
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
|
+
animation: {
|
|
37
|
+
type: PropType<string | Component>;
|
|
38
|
+
default: () => string;
|
|
39
|
+
};
|
|
25
40
|
items: {
|
|
26
41
|
type: PropType<Sort[]>;
|
|
27
42
|
required: true;
|
|
28
43
|
};
|
|
29
|
-
|
|
30
|
-
type: PropType<
|
|
31
|
-
|
|
44
|
+
selectedSort: {
|
|
45
|
+
type: PropType<Sort>;
|
|
46
|
+
required: true;
|
|
47
|
+
};
|
|
48
|
+
selectedSortProvidedEvent: {
|
|
49
|
+
type: PropType<XEvent>;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
clickedSortEvent: {
|
|
53
|
+
type: PropType<XEvent>;
|
|
54
|
+
default: string;
|
|
32
55
|
};
|
|
33
56
|
}>> & Readonly<{}>, {
|
|
34
57
|
animation: string | Component;
|
|
58
|
+
selectedSortProvidedEvent: keyof XEventsTypes;
|
|
59
|
+
clickedSortEvent: keyof XEventsTypes;
|
|
35
60
|
}, {}, {
|
|
36
61
|
BaseEventButton: import("vue").DefineComponent<{}, {}, any>;
|
|
37
62
|
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
|
|
@@ -10,30 +10,55 @@ The `SortPickerList` component allows user to select the search results order. T
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
_default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
13
|
+
animation: {
|
|
14
|
+
type: PropType<string | Component>;
|
|
15
|
+
default: () => string;
|
|
16
|
+
};
|
|
13
17
|
items: {
|
|
14
18
|
type: PropType<Sort[]>;
|
|
15
19
|
required: true;
|
|
16
20
|
};
|
|
17
|
-
|
|
18
|
-
type: PropType<
|
|
19
|
-
|
|
21
|
+
selectedSort: {
|
|
22
|
+
type: PropType<Sort>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
selectedSortProvidedEvent: {
|
|
26
|
+
type: PropType<XEvent>;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
clickedSortEvent: {
|
|
30
|
+
type: PropType<XEvent>;
|
|
31
|
+
default: string;
|
|
20
32
|
};
|
|
21
33
|
buttonClass: StringConstructor;
|
|
22
34
|
}>, {
|
|
23
35
|
listItems: import("vue").ComputedRef<SortPickerItem[]>;
|
|
24
|
-
selectedSort: import("vue").ComputedRef<string>;
|
|
25
36
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
+
animation: {
|
|
38
|
+
type: PropType<string | Component>;
|
|
39
|
+
default: () => string;
|
|
40
|
+
};
|
|
26
41
|
items: {
|
|
27
42
|
type: PropType<Sort[]>;
|
|
28
43
|
required: true;
|
|
29
44
|
};
|
|
30
|
-
|
|
31
|
-
type: PropType<
|
|
32
|
-
|
|
45
|
+
selectedSort: {
|
|
46
|
+
type: PropType<Sort>;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
selectedSortProvidedEvent: {
|
|
50
|
+
type: PropType<XEvent>;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
clickedSortEvent: {
|
|
54
|
+
type: PropType<XEvent>;
|
|
55
|
+
default: string;
|
|
33
56
|
};
|
|
34
57
|
buttonClass: StringConstructor;
|
|
35
58
|
}>> & Readonly<{}>, {
|
|
36
59
|
animation: string | Component;
|
|
60
|
+
selectedSortProvidedEvent: keyof XEventsTypes;
|
|
61
|
+
clickedSortEvent: keyof XEventsTypes;
|
|
37
62
|
}, {}, {
|
|
38
63
|
BaseEventButton: import("vue").DefineComponent<{}, {}, any>;
|
|
39
64
|
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [UseAliasAPI](./x-components.usealiasapi.md) > [browseSelectedSort](./x-components.usealiasapi.browseselectedsort.md)
|
|
4
|
+
|
|
5
|
+
## UseAliasAPI.browseSelectedSort property
|
|
6
|
+
|
|
7
|
+
The [BrowseXModule](./x-components.browsexmodule.md) selected sort.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
readonly browseSelectedSort: string;
|
|
13
|
+
```
|
|
@@ -37,6 +37,27 @@ Description
|
|
|
37
37
|
</th></tr></thead>
|
|
38
38
|
<tbody><tr><td>
|
|
39
39
|
|
|
40
|
+
[browseSelectedSort](./x-components.usealiasapi.browseselectedsort.md)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
`readonly`
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</td><td>
|
|
49
|
+
|
|
50
|
+
string
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</td><td>
|
|
54
|
+
|
|
55
|
+
The [BrowseXModule](./x-components.browsexmodule.md) selected sort.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
</td></tr>
|
|
59
|
+
<tr><td>
|
|
60
|
+
|
|
40
61
|
[browseTotalResults](./x-components.usealiasapi.browsetotalresults.md)
|
|
41
62
|
|
|
42
63
|
|
|
@@ -11,10 +11,13 @@ also allows to change the selected sort programmatically.
|
|
|
11
11
|
|
|
12
12
|
## Props
|
|
13
13
|
|
|
14
|
-
| Name
|
|
15
|
-
|
|
|
16
|
-
| <code>
|
|
17
|
-
| <code>
|
|
14
|
+
| Name | Description | Type | Default |
|
|
15
|
+
| -------------------------------------- | ----------------------------------------------------------- | ------------------- | ----------------------------------- |
|
|
16
|
+
| <code>animation</code> | The transition to use for opening and closing the dropdown. | <code></code> | <code></code> |
|
|
17
|
+
| <code>items</code> | The list of possible sort values. | <code>Sort[]</code> | <code></code> |
|
|
18
|
+
| <code>selectedSort</code> | | <code>Sort</code> | <code></code> |
|
|
19
|
+
| <code>selectedSortProvidedEvent</code> | | <code>XEvent</code> | <code>'SelectedSortProvided'</code> |
|
|
20
|
+
| <code>clickedSortEvent</code> | | <code>XEvent</code> | <code>'UserClickedASort'</code> |
|
|
18
21
|
|
|
19
22
|
## Events
|
|
20
23
|
|
|
@@ -11,10 +11,13 @@ also allows to change the selected sort programmatically.
|
|
|
11
11
|
|
|
12
12
|
## Props
|
|
13
13
|
|
|
14
|
-
| Name
|
|
15
|
-
|
|
|
16
|
-
| <code>
|
|
17
|
-
| <code>
|
|
14
|
+
| Name | Description | Type | Default |
|
|
15
|
+
| -------------------------------------- | --------------------------------------------- | -------------------------------- | ----------------------------------- |
|
|
16
|
+
| <code>animation</code> | The transition to use for rendering the list. | <code>string \| Component</code> | <code>() => 'ul'</code> |
|
|
17
|
+
| <code>items</code> | The list of possible sort values. | <code>Sort[]</code> | <code></code> |
|
|
18
|
+
| <code>selectedSort</code> | | <code>Sort</code> | <code></code> |
|
|
19
|
+
| <code>selectedSortProvidedEvent</code> | | <code>XEvent</code> | <code>'SelectedSortProvided'</code> |
|
|
20
|
+
| <code>clickedSortEvent</code> | | <code>XEvent</code> | <code>'UserClickedASort'</code> |
|
|
18
21
|
|
|
19
22
|
## Slots
|
|
20
23
|
|
package/docs/API-reference/components/{search → common/sort}/x-components.sort-picker-list.md
RENAMED
|
@@ -11,11 +11,14 @@ also allows to change the selected sort programmatically.
|
|
|
11
11
|
|
|
12
12
|
## Props
|
|
13
13
|
|
|
14
|
-
| Name
|
|
15
|
-
|
|
|
16
|
-
| <code>
|
|
17
|
-
| <code>
|
|
18
|
-
| <code>
|
|
14
|
+
| Name | Description | Type | Default |
|
|
15
|
+
| -------------------------------------- | --------------------------------------------- | -------------------------------- | ----------------------------------- |
|
|
16
|
+
| <code>animation</code> | The transition to use for rendering the list. | <code>string \| Component</code> | <code>() => 'div'</code> |
|
|
17
|
+
| <code>items</code> | The list of possible sort values. | <code>Sort[]</code> | <code></code> |
|
|
18
|
+
| <code>selectedSort</code> | | <code>Sort</code> | <code></code> |
|
|
19
|
+
| <code>selectedSortProvidedEvent</code> | | <code>XEvent</code> | <code>'SelectedSortProvided'</code> |
|
|
20
|
+
| <code>clickedSortEvent</code> | | <code>XEvent</code> | <code>'UserClickedASort'</code> |
|
|
21
|
+
| <code>buttonClass</code> | Class inherited by each sort button. | <code>string</code> | <code></code> |
|
|
19
22
|
|
|
20
23
|
## Slots
|
|
21
24
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _sfc_main from './sort-dropdown.vue2.js';
|
|
2
2
|
import { resolveComponent, openBlock, createBlock, withCtx, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString } from 'vue';
|
|
3
|
-
import _export_sfc from '
|
|
3
|
+
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
4
4
|
|
|
5
5
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
6
6
|
const _component_BaseDropdown = resolveComponent("BaseDropdown");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-dropdown.vue.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n aria-label=\"Select sorting\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":["_createBlock","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode"],"mappings":";;;;;;sBACEA,WAAA,CA6Be,uBAAA,EAAA;AAAA,IA5Bb,GAAA,EAAI,SAAA;AAAA,IACH,KAAA,EAAO,IAAA,CAAA,KAAA;AAAA,IACP,aAAA,EAAa,IAAA,CAAA,YAAA;AAAA,IACb,SAAA,EAAW,IAAA,CAAA,SAAA;AAAA,IACZ,KAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EAAU,eAAA;AAAA,IACV,YAAA,EAAW,gBAAA;AAAA,IACV,qBAAA,EAAoB,IAAA,CAAA;AAAA,GAAA,EAAA;AAEV,IAAA,MAAA,EAAMC,OAAA,CAOf,CAA+D,EAP5C,MAAA,EAAQ,IAAA,EAAI,KAAA;AAAA,MAO/BC,UAAA,CAA+D,IAAA,CAAA,MAAA,EAAA,QAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAA/C,MAAA,EAAQ,IAAA,MAAxB,MAA+D;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;AAE5C,IAAA,IAAA,EAAIJ,OAAA,CAQb,CAAgF,EAR/D,IAAA,EAAM,eAAe,UAAA,EAAU,KAAA;AAAA,MAQhDC,WAAgF,IAAA,CAAA,MAAA,EAAA,MAAA,EAAAC,cAAA,CAAAC,kBAAA,CAAA,EAAhE,IAAA,EAAM,aAAA,EAAe,UAAA,MAArC,MAAgF;AAAA,QAAAC,eAAA;0BAAd,IAAI,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA,OAAA;;;;;;;;;;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, watch } from 'vue';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useState } from '../../../composables/use-state.js';
|
|
5
|
-
import { searchXModule } from '../x-module.js';
|
|
2
|
+
import { use$x } from '../../composables/use-_x.js';
|
|
3
|
+
import BaseDropdown from '../base-dropdown.vue.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* The `SortDropdown` component allows user to select the search results order. This component
|
|
@@ -10,23 +8,33 @@ import { searchXModule } from '../x-module.js';
|
|
|
10
8
|
*/
|
|
11
9
|
var _sfc_main = defineComponent({
|
|
12
10
|
name: 'SortDropdown',
|
|
13
|
-
xModule: searchXModule.name,
|
|
14
11
|
components: { BaseDropdown },
|
|
15
12
|
props: {
|
|
13
|
+
/** The transition to use for opening and closing the dropdown. */
|
|
14
|
+
animation: [String, Object],
|
|
16
15
|
/** The list of possible sort values. */
|
|
17
16
|
items: {
|
|
18
17
|
type: Array,
|
|
19
18
|
required: true,
|
|
20
19
|
},
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
selectedSort: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
selectedSortProvidedEvent: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'SelectedSortProvided',
|
|
27
|
+
},
|
|
28
|
+
clickedSortEvent: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'UserClickedASort',
|
|
31
|
+
},
|
|
23
32
|
},
|
|
24
33
|
emits: ['change'],
|
|
25
|
-
setup(
|
|
34
|
+
setup(props, { emit }) {
|
|
26
35
|
const $x = use$x();
|
|
27
|
-
const { sort: selectedSort } = useState('search');
|
|
28
36
|
const rootRef = ref();
|
|
29
|
-
watch(selectedSort,
|
|
37
|
+
watch(() => props.selectedSort, value => $x.emit(props.selectedSortProvidedEvent, value), {
|
|
30
38
|
immediate: true,
|
|
31
39
|
});
|
|
32
40
|
/**
|
|
@@ -38,13 +46,12 @@ var _sfc_main = defineComponent({
|
|
|
38
46
|
* @param sort - The selected sort.
|
|
39
47
|
*/
|
|
40
48
|
function emitUserClickedASort(sort) {
|
|
41
|
-
$x.emit(
|
|
49
|
+
$x.emit(props.clickedSortEvent, sort, { target: rootRef.value?.$el });
|
|
42
50
|
emit('change', sort);
|
|
43
51
|
}
|
|
44
52
|
return {
|
|
45
53
|
emitUserClickedASort,
|
|
46
54
|
rootRef,
|
|
47
|
-
selectedSort,
|
|
48
55
|
};
|
|
49
56
|
},
|
|
50
57
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-dropdown.vue2.js","sources":["../../../../src/components/sort/sort-dropdown.vue"],"sourcesContent":["<template>\n <BaseDropdown\n ref=\"rootRef\"\n :items=\"items\"\n :model-value=\"selectedSort\"\n :animation=\"animation\"\n class=\"x-sort-dropdown\"\n data-test=\"sort-dropdown\"\n aria-label=\"Select sorting\"\n @update:model-value=\"emitUserClickedASort\"\n >\n <template #toggle=\"{ isOpen, item }\">\n <!--\n @slot Used to render the contents of the dropdown toggle button. If not provided, it uses\n the item slot as fallback.\n @binding {Sort} item - The sort data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-bind=\"{ isOpen, item }\" name=\"toggle\">{{ item }}</slot>\n </template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <!--\n @slot (required) Used to render each one of the items content, and as fallback\n for the toggle button content slot if it is not provided.\n @binding {Sort} item - Sort to render\n @binding {boolean} isHighlighted - True when the item has the focus.\n @binding {boolean} isSelected - True when the item is selected.\n -->\n <slot v-bind=\"{ item, isHighlighted, isSelected }\" name=\"item\">{{ item }}</slot>\n </template>\n </BaseDropdown>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { XEvent } from '../../wiring/index'\nimport { defineComponent, ref, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseDropdown from '../base-dropdown.vue'\n\n/**\n * The `SortDropdown` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortDropdown',\n components: { BaseDropdown },\n props: {\n /** The transition to use for opening and closing the dropdown. */\n animation: [String, Object] as PropType<string | Component>,\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n emits: ['change'],\n setup(props, { emit }) {\n const $x = use$x()\n const rootRef = ref<typeof BaseDropdown>()\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Emits the events related to the selection of a sort value.\n *\n * @remarks `(rootRef.value as any)?.$el` because rollup-plugin-vue understands\n * `ref<typeof BaseDropdown>` as VueConstructor which doesn't contain $el.\n *\n * @param sort - The selected sort.\n */\n function emitUserClickedASort(sort: Sort) {\n $x.emit(props.clickedSortEvent, sort, { target: (rootRef.value as any)?.$el })\n emit('change', sort)\n }\n\n return {\n emitUserClickedASort,\n rootRef,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Sort Dropdown\n\nThe `SortDropdown` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can be received then in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing both the toggle button and each one of the possible sort\nvalues. This can be done with the `toggle` and `item` slots.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortDropdown :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortDropdown v-model=\"selectedSort\" :items=\"sortValues\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}</template>\n <template #item=\"{ item, isHighlighted, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n <span v-if=\"isHighlighted\">🟢</span>\n {{ item }}\n </template>\n </SortDropdown>\n</template>\n\n<script setup>\nimport { SortDropdown } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAyCA;;;AAGE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,EAAE,YAAW,EAAG;AAC5B,IAAA,KAAK,EAAE;;AAEL,QAAA,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAiC;;AAE3D,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,KAAyB;AAC/B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAwB;AAC9B,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD,QAAA,yBAAyB,EAAE;AACzB,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,sBAAsB;AAChC,SAAA;AACD,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,MAA0B;AAChC,YAAA,OAAO,EAAE,kBAAkB;AAC5B,SAAA;AACF,KAAA;IACD,KAAK,EAAE,CAAC,QAAQ,CAAC;AACjB,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAG,EAAG,EAAA;AACnB,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC;AACjB,QAAA,MAAM,OAAM,GAAI,GAAG,EAAsB;QAEzC,KAAK,CACH,MAAM,KAAK,CAAC,YAAY,EACxB,KAAI,IAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,EACxD;AACE,YAAA,SAAS,EAAE,IAAI;AAChB,SAAA,CACH;AAEA;;;;;;;AAOE;QACF,SAAS,oBAAoB,CAAC,IAAU,EAAA;AACtC,YAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,MAAM,EAAG,OAAO,CAAC,KAAa,EAAE,KAAK,CAAA;AAC7E,YAAA,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAA;QACrB;QAEA,OAAO;YACL,oBAAoB;YACpB,OAAO;SACT;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from './sort-list.vue2.js';
|
|
2
2
|
import { resolveComponent, openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createVNode, renderSlot, mergeProps, createTextVNode, toDisplayString } from 'vue';
|
|
3
3
|
import './sort-list.vue3.js';
|
|
4
|
-
import _export_sfc from '
|
|
4
|
+
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
|
|
5
5
|
|
|
6
6
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
7
7
|
const _component_BaseEventButton = resolveComponent("BaseEventButton");
|
|
@@ -52,7 +52,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
52
52
|
/* FORWARDED */
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
var sortList = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-
|
|
55
|
+
var sortList = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-52bd793c"]]);
|
|
56
56
|
|
|
57
57
|
export { sortList as default };
|
|
58
58
|
//# sourceMappingURL=sort-list.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-list.vue.js","sources":["../../../../src/components/sort/sort-list.vue"],"sourcesContent":["<template>\n <component :is=\"animation\" tag=\"ul\" class=\"x-option-list x-sort-list\" data-test=\"sort-list\">\n <li\n v-for=\"{ item, cssClasses, event } in listItems\"\n :key=\"item\"\n :class=\"cssClasses\"\n class=\"x-option-list__item x-sort-list__item\"\n >\n <BaseEventButton\n class=\"x-sort-list__button xds:button\"\n data-test=\"x-sort-button\"\n :events=\"event\"\n >\n <slot v-bind=\"{ item, isSelected: item === selectedSort }\">\n {{ item }}\n </slot>\n </BaseEventButton>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { Sort } from '@empathyco/x-types'\nimport type { Component, PropType } from 'vue'\nimport type { VueCSSClasses } from '../../utils/index'\nimport type { XEvent, XEventsTypes } from '../../wiring/index'\nimport { computed, defineComponent, watch } from 'vue'\nimport { use$x } from '../../composables/use-$x'\nimport BaseEventButton from '../base-event-button.vue'\n\n/**\n * Sort list item options.\n */\ninterface SortListItem {\n item: Sort\n cssClasses: VueCSSClasses\n event: Partial<XEventsTypes>\n}\n\n/**\n * The `SortList` component allows user to select the search results order. This component\n * also allows to change the selected sort programmatically.\n */\nexport default defineComponent({\n name: 'SortList',\n components: { BaseEventButton },\n props: {\n /** The transition to use for rendering the list. */\n animation: {\n type: [String, Object] as PropType<string | Component>,\n default: () => 'ul',\n },\n /** The list of possible sort values. */\n items: {\n type: Array as PropType<Sort[]>,\n required: true,\n },\n selectedSort: {\n type: String as PropType<Sort>,\n required: true,\n },\n selectedSortProvidedEvent: {\n type: String as PropType<XEvent>,\n default: 'SelectedSortProvided',\n },\n clickedSortEvent: {\n type: String as PropType<XEvent>,\n default: 'UserClickedASort',\n },\n },\n setup(props) {\n const $x = use$x()\n\n watch(\n () => props.selectedSort,\n value => $x.emit(props.selectedSortProvidedEvent, value),\n {\n immediate: true,\n },\n )\n\n /**\n * Sort list items.\n *\n * @returns A list of items with their css class and the event associate to it.\n */\n const listItems = computed<SortListItem[]>(() =>\n props.items.map(item => ({\n item,\n cssClasses: {\n 'x-sort-list__item--is-selected': item === props.selectedSort,\n 'x-option-list__item--is-selected': item === props.selectedSort,\n },\n event: { [props.clickedSortEvent]: item },\n })),\n )\n\n return {\n listItems,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-sort-list {\n list-style-type: none;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Sort List\n\nThe `SortList` component can be used to change the way the search results are ordered.\n\nTo do so, the list of valid sort values has to be provided using the `items` prop. These are the\nvalues that can then be received in the `SearchAdapter`.\n\nThe component also optionally accepts the selected sort, which can be set using the `v-model` prop.\nThis prop allows changing programmatically the selected sort, as it will be synced with the store\nimmediately. If this prop is not provided, the first item from the `items` prop will be the one\nselected by default.\n\nThis component also allows customizing each one of the possible sort values. This can be done with\nthe default slot.\n\n## Events\n\nThis component emits 2 different events:\n\n- [`SelectedSortProvided`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n To sync the selected sort with the store state value. This event is emitted as soon as the list of\n items is received, whenever this list changes if there is no provided value, and when the provided\n value changes.\n- [`UserClickedASort`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts):\n As its name suggests, the event is emitted after the user clicks one of the sort options. This does\n not mean that the sort has changed, only that the user has clicked it.\n\n## Examples\n\n### Only providing the list of items\n\n```vue\n<template>\n <SortList :items=\"sortValues\">\n <template #default=\"{ item, isSelected }\">Item: {{ item }}</template>\n </SortList>\n</template>\n\n<script setup>\nimport { SortList } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n\n### Providing also the selected value\n\n```vue\n<template>\n <SortList v-model=\"selectedSort\" :items=\"sortValues\">\n <template #default=\"{ item, isSelected }\">\n <span v-if=\"isSelected\">✅</span>\n {{ item }}\n </template>\n </SortList>\n</template>\n\n<script setup>\nimport { SortList } from '@empathyco/x-components/search'\nimport { ref } from 'vue'\n\nconst selectedSort = ref('Price asc')\nconst sortValues = ref(['Relevance', 'Price asc', 'Price desc'])\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_Fragment","_renderList","_normalizeClass","_createVNode","_renderSlot","_mergeProps","_createTextVNode"],"mappings":";;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,WAAA,CAiBYC,wBAjBI,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,IAAE,GAAA,EAAI,IAAA;AAAA,IAAK,KAAA,EAAM,2BAAA;AAAA,IAA4B,WAAA,EAAU;AAAA,GAAA,EAAA;qBAE5E,MAAgD;AAAA,OAAAF,SAAA,CAAA,IAAA,CAAA,EADlDG,kBAAA;AAAA,QAeKC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAdmC,IAAA,CAAA,SAAA,EAAS,CAAA,EAAtC,IAAA,EAAM,UAAA,EAAY,KAAA,EAAK,KAAA;AADlC,UAAA,OAAAL,SAAA,EAAA,EAAAG,kBAAA;AAAA,YAeK,IAAA;AAAA,YAAA;AAAA,cAbF,GAAA,EAAK,IAAA;AAAA,cACL,KAAA,EAAKG,cAAA,CAAA,CAAE,UAAA,EACF,uCAAuC,CAAA;AAAA,aAAA;;cAE7CC,WAAA,CAQkB,0BAAA,EAAA;AAAA,gBAPhB,KAAA,EAAM,gCAAA;AAAA,gBACN,WAAA,EAAU,eAAA;AAAA,gBACT,MAAA,EAAQ;AAAA,eAAA,EAAA;iCAET,MAEO;AAAA,kBAFPC,UAAA,CAEO,wBAFPC,UAAA,CAEO,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,EAFS,MAAI,UAAA,EAAc,IAAA,KAAS,IAAA,CAAA,YAAA,EAAY,CAAA,EAAvD,MAEO;AAAA,oBAAAC,eAAA;sCADF,IAAI,CAAA;AAAA,sBAAA;AAAA;AAAA;AAAA,mBAAA,EAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { defineComponent, watch, computed } from 'vue';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useState } from '../../../composables/use-state.js';
|
|
5
|
-
import { searchXModule } from '../x-module.js';
|
|
2
|
+
import { use$x } from '../../composables/use-_x.js';
|
|
3
|
+
import BaseEventButton from '../base-event-button.vue.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* The `SortList` component allows user to select the search results order. This component
|
|
@@ -10,24 +8,34 @@ import { searchXModule } from '../x-module.js';
|
|
|
10
8
|
*/
|
|
11
9
|
var _sfc_main = defineComponent({
|
|
12
10
|
name: 'SortList',
|
|
13
|
-
xModule: searchXModule.name,
|
|
14
11
|
components: { BaseEventButton },
|
|
15
12
|
props: {
|
|
13
|
+
/** The transition to use for rendering the list. */
|
|
14
|
+
animation: {
|
|
15
|
+
type: [String, Object],
|
|
16
|
+
default: () => 'ul',
|
|
17
|
+
},
|
|
16
18
|
/** The list of possible sort values. */
|
|
17
19
|
items: {
|
|
18
20
|
type: Array,
|
|
19
21
|
required: true,
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
selectedSort: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
selectedSortProvidedEvent: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'SelectedSortProvided',
|
|
30
|
+
},
|
|
31
|
+
clickedSortEvent: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'UserClickedASort',
|
|
25
34
|
},
|
|
26
35
|
},
|
|
27
36
|
setup(props) {
|
|
28
37
|
const $x = use$x();
|
|
29
|
-
|
|
30
|
-
watch(selectedSort, (value) => $x.emit('SelectedSortProvided', value), {
|
|
38
|
+
watch(() => props.selectedSort, value => $x.emit(props.selectedSortProvidedEvent, value), {
|
|
31
39
|
immediate: true,
|
|
32
40
|
});
|
|
33
41
|
/**
|
|
@@ -38,14 +46,13 @@ var _sfc_main = defineComponent({
|
|
|
38
46
|
const listItems = computed(() => props.items.map(item => ({
|
|
39
47
|
item,
|
|
40
48
|
cssClasses: {
|
|
41
|
-
'x-sort-list__item--is-selected': item === selectedSort
|
|
42
|
-
'x-option-list__item--is-selected': item === selectedSort
|
|
49
|
+
'x-sort-list__item--is-selected': item === props.selectedSort,
|
|
50
|
+
'x-option-list__item--is-selected': item === props.selectedSort,
|
|
43
51
|
},
|
|
44
|
-
event: {
|
|
52
|
+
event: { [props.clickedSortEvent]: item },
|
|
45
53
|
})));
|
|
46
54
|
return {
|
|
47
55
|
listItems,
|
|
48
|
-
selectedSort,
|
|
49
56
|
};
|
|
50
57
|
},
|
|
51
58
|
});
|