@empathyco/x-components 10.3.0 → 10.5.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/docs/API-reference/api/x-components.arraytoobject.md +1 -1
  3. package/docs/API-reference/api/x-components.baseresultimage.md +39 -5
  4. package/docs/API-reference/api/x-components.createusedevice.md +1 -1
  5. package/docs/API-reference/api/x-components.deepmergewithdefaults.md +1 -1
  6. package/docs/API-reference/api/x-components.md +3 -1
  7. package/docs/API-reference/api/x-components.searchconfig.md +19 -0
  8. package/docs/API-reference/api/x-components.searchconfig.pricesortfield.md +13 -0
  9. package/docs/API-reference/api/x-components.xinstaller.md +4 -4
  10. package/docs/API-reference/api/x-components.xplugin.md +1 -1
  11. package/docs/API-reference/components/common/result/x-components.base-result-image.md +161 -6
  12. package/js/components/base-dropdown.vue.js +2 -6
  13. package/js/components/base-dropdown.vue.js.map +1 -1
  14. package/js/components/base-grid.vue.js +2 -8
  15. package/js/components/base-grid.vue.js.map +1 -1
  16. package/js/components/column-picker/base-column-picker-list.vue.js +1 -1
  17. package/js/components/column-picker/base-column-picker-list.vue.js.map +1 -1
  18. package/js/components/result/base-result-image.vue.js +18 -15
  19. package/js/components/result/base-result-image.vue.js.map +1 -1
  20. package/js/components/result/base-result-image.vue2.js +125 -9
  21. package/js/components/result/base-result-image.vue2.js.map +1 -1
  22. package/js/x-modules/facets/components/facets/facets.vue.js +4 -13
  23. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  24. package/js/x-modules/facets/components/lists/selected-filters-list.vue.js +3 -9
  25. package/js/x-modules/facets/components/lists/selected-filters-list.vue.js.map +1 -1
  26. package/js/x-modules/search/store/getters/request.getter.js +1 -1
  27. package/js/x-modules/search/store/getters/request.getter.js.map +1 -1
  28. package/js/x-modules/search/store/module.js +1 -0
  29. package/js/x-modules/search/store/module.js.map +1 -1
  30. package/package.json +24 -24
  31. package/report/tsdoc-metadata.json +1 -1
  32. package/report/x-adapter-platform.api.json +5 -5
  33. package/report/x-components.api.json +830 -659
  34. package/report/x-components.api.md +40 -5
  35. package/report/x-types.api.json +30 -30
  36. package/types/src/components/result/base-result-image.vue.d.ts +105 -6
  37. package/types/src/components/result/base-result-image.vue.d.ts.map +1 -1
  38. package/types/src/x-modules/search/config.types.d.ts +5 -0
  39. package/types/src/x-modules/search/config.types.d.ts.map +1 -1
  40. package/types/src/x-modules/search/store/module.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
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
+ ## [10.5.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.5.0) (2026-11-05)
7
+
8
+ ### Features
9
+
10
+ * **search:** add priceFacetId to SearchConfig and update request accordingly (#2194)
11
+ * **x-components:** add responsive image props and loading events to BaseResultImage (#2195)
12
+
13
+
14
+ ## [10.4.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.4.0) (2026-11-03)
15
+
16
+ ### Features
17
+
18
+ * **search:** add priceFacetId to SearchConfig and update request accordingly (#2194)
19
+
20
+
6
21
  ## [10.3.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.2.0...@empathyco/x-components@10.3.0) (2026-10-30)
7
22
 
8
23
  ### Features
@@ -56,5 +56,5 @@ New object which properties object\[key\] contains object of each iteration in t
56
56
 
57
57
  ## Example
58
58
 
59
- Converting an array to an object: arrayToObject(\['a', 'b', 'c'\]) === {<!-- -->a: 'a', b: 'b', c: 'c'<!-- -->}
59
+ Converting an array to an object: arrayToObject(\['a', 'b', 'c'\]) === {<!-- -->a: 'a', b: 'b', c: 'c'<!-- -->}
60
60
 
@@ -6,6 +6,8 @@
6
6
 
7
7
  Component to be reused that renders an `<img>`<!-- -->.
8
8
 
9
+ Additional `<img>` attributes passed to the component (e.g. `decoding`<!-- -->, `crossorigin`<!-- -->, `referrerpolicy`<!-- -->, `fetchpriority`<!-- -->, `width` and `height`<!-- -->) are forwarded to the rendered images, while `class`<!-- -->, `style` and event listeners keep falling through to the root element, as before. Use the `imageLoaded` and `imageError` events to observe the image loading state.
10
+
9
11
  **Signature:**
10
12
 
11
13
  ```typescript
@@ -25,18 +27,36 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
25
27
  type: BooleanConstructor;
26
28
  default: boolean;
27
29
  };
30
+ srcset: {
31
+ type: PropType<string | (string | undefined)[]>;
32
+ };
33
+ sizes: {
34
+ type: StringConstructor;
35
+ };
36
+ loading: {
37
+ type: PropType<"lazy" | "eager">;
38
+ default: string;
39
+ };
28
40
  }>, {
29
- pendingImages: Ref<string[], string[]>;
30
- loadedImages: Ref<string[], string[]>;
41
+ imageAttrs: import("vue").ComputedRef<{
42
+ [k: string]: unknown;
43
+ }>;
44
+ rootAttrs: import("vue").ComputedRef<{
45
+ class: import("vue").ClassValue;
46
+ style: StyleValue;
47
+ }>;
48
+ pendingImages: Ref<ImageEntry[], ImageEntry[]>;
49
+ loadedImages: Ref<ImageEntry[], ImageEntry[]>;
31
50
  isHovering: Ref<boolean, boolean>;
32
51
  userHasHoveredImage: Ref<boolean, boolean>;
33
52
  loaderStyles: import("vue").CSSProperties;
34
53
  animation: import("vue").ComputedRef<string | Function | Record<string, any>>;
35
54
  imageSrc: import("vue").ComputedRef<string>;
55
+ imageSrcset: import("vue").ComputedRef<string | undefined>;
36
56
  shouldLoadNextImage: import("vue").ComputedRef<boolean>;
37
57
  flagImageAsFailed: () => void;
38
- flagImageLoaded: () => void;
39
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
58
+ flagImageLoaded: (event: Event) => void;
59
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("imageLoaded" | "imageError")[], "imageLoaded" | "imageError", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
40
60
  result: {
41
61
  type: PropType<Result>;
42
62
  required: true;
@@ -52,8 +72,22 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
52
72
  type: BooleanConstructor;
53
73
  default: boolean;
54
74
  };
55
- }>> & Readonly<{}>, {
75
+ srcset: {
76
+ type: PropType<string | (string | undefined)[]>;
77
+ };
78
+ sizes: {
79
+ type: StringConstructor;
80
+ };
81
+ loading: {
82
+ type: PropType<"lazy" | "eager">;
83
+ default: string;
84
+ };
85
+ }>> & Readonly<{
86
+ onImageLoaded?: ((...args: any[]) => any) | undefined;
87
+ onImageError?: ((...args: any[]) => any) | undefined;
88
+ }>, {
56
89
  loadAnimation: string | Function | Record<string, any>;
57
90
  showNextImageOnHover: boolean;
91
+ loading: "lazy" | "eager";
58
92
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
59
93
  ```
@@ -60,5 +60,5 @@ The `orientation` only works for orientation-sensor devices (mobile, tablet, etc
60
60
 
61
61
  ## Example
62
62
 
63
- ´´´typescript const useDevice = createUseDevice(<!-- -->{ mobile: 0, tablet: 744, desktop: 1024 }<!-- -->); const { isMobile, isMobileOrLess, isMobileOrGreater, isTablet, isTabletOrLess, isTabletOrGreater, isDesktop, isDesktopOrLess, isDesktopOrGreater, deviceName, orientation, istTouchable } = useDevice();
63
+ ´´´typescript const useDevice = createUseDevice(<!-- -->{ mobile: 0, tablet: 744, desktop: 1024 }<!-- -->); const { isMobile, isMobileOrLess, isMobileOrGreater, isTablet, isTabletOrLess, isTabletOrGreater, isDesktop, isDesktopOrLess, isDesktopOrGreater, deviceName, orientation, istTouchable } = useDevice();
64
64
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  Deeply merges `overrides` onto `defaults` at any depth, so nested objects can be overridden partially without losing the rest of the default configuration:
8
8
 
9
- - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults` are ignored. - An `undefined` entry in `overrides` keeps the default value. - When both the default and the override are plain objects, they are merged recursively. - Any other value (string, function, array, `null`<!-- -->...) in `overrides` replaces the default.
9
+ - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults` are ignored. - An `undefined` entry in `overrides` keeps the default value. - When both the default and the override are plain objects, they are merged recursively. - Any other value (string, function, array, `null`<!-- -->...) in `overrides` replaces the default.
10
10
 
11
11
  Neither input is mutated.
12
12
 
@@ -577,7 +577,7 @@ Flat an `Item[]` deeply using the given `childrenKey` to access to his children.
577
577
 
578
578
  Deeply merges `overrides` onto `defaults` at any depth, so nested objects can be overridden partially without losing the rest of the default configuration:
579
579
 
580
- - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults` are ignored. - An `undefined` entry in `overrides` keeps the default value. - When both the default and the override are plain objects, they are merged recursively. - Any other value (string, function, array, `null`<!-- -->...) in `overrides` replaces the default.
580
+ - The keys of `defaults` define the shape of the result: keys that do not exist in `defaults` are ignored. - An `undefined` entry in `overrides` keeps the default value. - When both the default and the override are plain objects, they are merged recursively. - Any other value (string, function, array, `null`<!-- -->...) in `overrides` replaces the default.
581
581
 
582
582
  Neither input is mutated.
583
583
 
@@ -4227,6 +4227,8 @@ Component that renders the [Result](./x-types.result.md) current price that may
4227
4227
 
4228
4228
  Component to be reused that renders an `<img>`<!-- -->.
4229
4229
 
4230
+ Additional `<img>` attributes passed to the component (e.g. `decoding`<!-- -->, `crossorigin`<!-- -->, `referrerpolicy`<!-- -->, `fetchpriority`<!-- -->, `width` and `height`<!-- -->) are forwarded to the rendered images, while `class`<!-- -->, `style` and event listeners keep falling through to the root element, as before. Use the `imageLoaded` and `imageError` events to observe the image loading state.
4231
+
4230
4232
 
4231
4233
  </td></tr>
4232
4234
  <tr><td>
@@ -89,6 +89,25 @@ number
89
89
  Maximum number of results to request.
90
90
 
91
91
 
92
+ </td></tr>
93
+ <tr><td>
94
+
95
+ [priceSortField?](./x-components.searchconfig.pricesortfield.md)
96
+
97
+
98
+ </td><td>
99
+
100
+
101
+ </td><td>
102
+
103
+ string
104
+
105
+
106
+ </td><td>
107
+
108
+ _(Optional)_ The id of the price facet that is used to sort the results by price. If not provided, the sort is sent as-is, i.e. still using `price`<!-- -->.
109
+
110
+
92
111
  </td></tr>
93
112
  </tbody></table>
94
113
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [SearchConfig](./x-components.searchconfig.md) &gt; [priceSortField](./x-components.searchconfig.pricesortfield.md)
4
+
5
+ ## SearchConfig.priceSortField property
6
+
7
+ The id of the price facet that is used to sort the results by price. If not provided, the sort is sent as-is, i.e. still using `price`<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ priceSortField?: string;
13
+ ```
@@ -18,24 +18,24 @@ export declare class XInstaller
18
18
 
19
19
  ## Example
20
20
 
21
- The way to use this class is the next: 1. Create the installer passing in the [InstallXOptions](./x-components.installxoptions.md)<!-- -->. This only save the options:
21
+ The way to use this class is the next: 1. Create the installer passing in the [InstallXOptions](./x-components.installxoptions.md)<!-- -->. This only save the options:
22
22
 
23
23
  ```
24
24
  const installer = new XInstaller(installXOptions)
25
25
  ```
26
- 2. Initialize passing the [SnippetConfig](./x-components.snippetconfig.md)<!-- -->. This installs the plugin and creates the App. There are 3 different ways to do this:
26
+ 2. Initialize passing the [SnippetConfig](./x-components.snippetconfig.md)<!-- -->. This installs the plugin and creates the App. There are 3 different ways to do this:
27
27
 
28
28
  2.1 Using the created installer:
29
29
 
30
30
  ```
31
31
  installer.init(snippetConfig)
32
32
  ```
33
- 2.2 If the API option is enabled (`createAPI` is `true` in [InstallXOptions](./x-components.installxoptions.md)<!-- -->, or is not present as the default value is `true`<!-- -->) then this init step can be done with the Public API:
33
+ 2.2 If the API option is enabled (`createAPI` is `true` in [InstallXOptions](./x-components.installxoptions.md)<!-- -->, or is not present as the default value is `true`<!-- -->) then this init step can be done with the Public API:
34
34
 
35
35
  ```
36
36
  window.InterfaceX.init(snippetConfig)
37
37
  ```
38
- 2.3 When the script of the project build is loaded it searches for a global `initX` variable that the customer must have in their website. This variable can be a function that returns the [SnippetConfig](./x-components.snippetconfig.md) or an object that contains the [SnippetConfig](./x-components.snippetconfig.md) itself:
38
+ 2.3 When the script of the project build is loaded it searches for a global `initX` variable that the customer must have in their website. This variable can be a function that returns the [SnippetConfig](./x-components.snippetconfig.md) or an object that contains the [SnippetConfig](./x-components.snippetconfig.md) itself:
39
39
 
40
40
  ```
41
41
  window.initX = function() {
@@ -23,7 +23,7 @@ Minimal installation example. An API adapter is needed to connect the X Componen
23
23
 
24
24
  ## Example 2
25
25
 
26
- If you are using [Vuex](https://vuex.vuejs.org/) in your project you must install its plugin, and instantiate a store before installing the XPlugin:
26
+ If you are using [Vuex](https://vuex.vuejs.org/) in your project you must install its plugin, and instantiate a store before installing the XPlugin:
27
27
 
28
28
  ```typescript
29
29
  Vue.use(Vuex);
@@ -8,14 +8,30 @@ title: BaseResultImage
8
8
 
9
9
  Component to be reused that renders an `<img>`.
10
10
 
11
+ Additional `<img>` attributes passed to the component (e.g. `decoding`, `crossorigin`,
12
+ `referrerpolicy`, `fetchpriority`, `width` and `height`) are forwarded to the rendered
13
+ images, while `class`, `style` and event listeners keep falling through to the root
14
+ element, as before. Use the `imageLoaded` and `imageError` events to observe the image
15
+ loading state.
16
+
11
17
  ## Props
12
18
 
13
- | Name | Description | Type | Default |
14
- | --------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------ |
15
- | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
16
- | <code>loadAnimation</code> | Animation to use when switching between the placeholder, the loaded image, or the failed<br />image fallback. | <code>AnimationProp</code> | <code>() => NoAnimation</code> |
17
- | <code>hoverAnimation</code> | Animation to use when switching between the loaded image and the hover image. | <code>AnimationProp</code> | <code></code> |
18
- | <code>showNextImageOnHover</code> | Indicates if the next valid image should be displayed on hover. | <code>boolean</code> | <code>false</code> |
19
+ | Name | Description | Type | Default |
20
+ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------ |
21
+ | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> |
22
+ | <code>loadAnimation</code> | Animation to use when switching between the placeholder, the loaded image, or the failed<br />image fallback. | <code>AnimationProp</code> | <code>() => NoAnimation</code> |
23
+ | <code>hoverAnimation</code> | Animation to use when switching between the loaded image and the hover image. | <code>AnimationProp</code> | <code></code> |
24
+ | <code>showNextImageOnHover</code> | Indicates if the next valid image should be displayed on hover. | <code>boolean</code> | <code>false</code> |
25
+ | <code>srcset</code> | Responsive image candidates (`srcset`).<br /><br />- A single string is applied to every image of the result (e.g.<br /> `"image-480.jpg 480w, image-1024.jpg 1024w"`).<br />- An array is parallel to `result.images`, so each image can have its own candidates.<br /><br />When provided, the `src` is kept as a fallback for browsers without `srcset` support. | <code>string \| (string \| undefined)[]</code> | <code></code> |
26
+ | <code>sizes</code> | The sizes of the image for different page layouts (`sizes`).<br /><br />It is shared by all the images of the result, since it depends on the layout and not on<br />the image. Pass it together with `srcset`, since it is ignored otherwise. | <code>string</code> | <code></code> |
27
+ | <code>loading</code> | Image loading mode. | <code>string</code> | <code>'lazy'</code> |
28
+
29
+ ## Events
30
+
31
+ | Event name | Properties | Description |
32
+ | ----------- | ---------- | ----------- |
33
+ | imageLoaded | |
34
+ | imageError | |
19
35
 
20
36
  ## Slots
21
37
 
@@ -47,6 +63,34 @@ const result = {
47
63
  </script>
48
64
  ```
49
65
 
66
+ ### Responsive images with `srcset` and `sizes`
67
+
68
+ The `srcset` and `sizes` props are used to deliver the right image candidate according to the
69
+ device and the layout (like the native `<img>` attributes).
70
+
71
+ `srcset` can be a single string, applied to all the images of the result, or an array parallel to
72
+ `result.images`, so each image can have its own candidates.
73
+
74
+ ```vue
75
+ <template>
76
+ <BaseResultImage
77
+ :result="result"
78
+ srcset="image1-480.jpg?width=400 480w, image1-1024.jpg?width=1024 1024w"
79
+ sizes="(min-width: 600px) 33vw, 100vw"
80
+ />
81
+ </template>
82
+
83
+ <script setup>
84
+ import { BaseResultImage } from "@empathyco/x-components";
85
+ const result = {
86
+ name: "Jacket",
87
+ images: ["https://some-image-url.com/image1.jpg"],
88
+ };
89
+ </script>
90
+ ```
91
+
92
+ The `src` of the image is always kept, so it works as a fallback when `srcset` is not supported.
93
+
50
94
  ### Showing the next image on hover
51
95
 
52
96
  If a result has multiple images, it can show the next one on hover.
@@ -133,3 +177,114 @@ const result = {
133
177
  };
134
178
  </script>
135
179
  ```
180
+
181
+ ### Optimizing the first result for LCP
182
+
183
+ By default, images are loaded lazily. For the first (above-the-fold) result of the search results
184
+ page, the image is usually the **Largest Contentful Paint (LCP)** element: eager-loading it with
185
+ a high fetch priority avoids waiting for the lazy-load viewport check and lets the browser start
186
+ the request immediately.
187
+
188
+ Combine it with `width` and `height` so the browser can prioritize and reserve the space of the
189
+ LCP element from the start:
190
+
191
+ ```vue
192
+ <template>
193
+ <!-- First, above-the-fold result -->
194
+ <BaseResultImage
195
+ :result="firstResult"
196
+ loading="eager"
197
+ fetchPriority="high"
198
+ :width="256"
199
+ :height="371"
200
+ />
201
+ <!-- All the remaining results keep the default lazy loading -->
202
+ <BaseResultImage
203
+ v-for="result in otherResults"
204
+ :key="result.id"
205
+ :result="result"
206
+ />
207
+ </template>
208
+
209
+ <script setup>
210
+ import { BaseResultImage } from "@empathyco/x-components";
211
+ </script>
212
+ ```
213
+
214
+ Only the above-the-fold results should use `loading="eager"`; keep the rest lazy to avoid
215
+ requesting more images than needed.
216
+
217
+ ### Avoiding layout shift (CLS)
218
+
219
+ Passing `width` and `height` (the intrinsic dimensions of the image) helps the browser reserve
220
+ the right space before the image is loaded, preventing the layout shift caused by the image
221
+ replacing the placeholder.
222
+
223
+ ```vue
224
+ <template>
225
+ <BaseResultImage :result="result" :width="256" :height="371" />
226
+ </template>
227
+
228
+ <script setup>
229
+ import { BaseResultImage } from "@empathyco/x-components";
230
+ </script>
231
+ ```
232
+
233
+ ### Passing additional image attributes
234
+
235
+ Any additional `<img>` attribute passed to the component is forwarded to the rendered images
236
+ (the hidden preload image and the visible one), so there is no need for a specific prop per
237
+ attribute:
238
+
239
+ ```vue
240
+ <template>
241
+ <BaseResultImage
242
+ :result="result"
243
+ decoding="async"
244
+ crossorigin="anonymous"
245
+ fetchpriority="high"
246
+ referrerpolicy="no-referrer"
247
+ :width="256"
248
+ :height="371"
249
+ />
250
+ </template>
251
+
252
+ <script setup>
253
+ import { BaseResultImage } from "@empathyco/x-components";
254
+ </script>
255
+ ```
256
+
257
+ `class`, `style` and event listeners keep being applied to the root element, so the wrapper
258
+ can still be styled and listened to. Any other additional attribute is only applied to the
259
+ rendered images, never to the wrapper div. Observe the image loading state with the
260
+ `imageLoaded` and `imageError` events instead.
261
+
262
+ ### Image loading events
263
+
264
+ The component emits `imageLoaded` when an image finishes loading, and `imageError` when an image
265
+ fails to load (the next one of the queue will be tried).
266
+
267
+ ```vue
268
+ <template>
269
+ <BaseResultImage
270
+ :result="result"
271
+ @imageLoaded="imageLoaded"
272
+ @imageError="imageError"
273
+ />
274
+ </template>
275
+
276
+ <script setup>
277
+ import { BaseResultImage } from "@empathyco/x-components";
278
+ const result = {
279
+ name: "Jacket",
280
+ images: ["https://some-image-url.com/image1.jpg"],
281
+ };
282
+ const imageLoaded = ({ index, src, currentSrc }) => {
283
+ // For example, track the candidate actually downloaded by the browser
284
+ console.log(`Image ${index} loaded: ${src} (downloaded ${currentSrc})`);
285
+ };
286
+ const imageError = ({ index, src }) => {
287
+ console.log(`Image ${index} failed: ${src}`);
288
+ };
289
+ </script>
290
+ ```
@@ -33,7 +33,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
33
33
  onKeydown: _cache[1] || (_cache[1] = withKeys(withModifiers((...args) => _ctx.open && _ctx.open(...args), ["prevent", "stop"]), ["up", "down"]))
34
34
  }, [
35
35
  _ctx.hasToggleSlot ? renderSlot(_ctx.$slots, "toggle", {
36
- key: 0,
37
36
  isOpen: _ctx.isOpen,
38
37
  item: _ctx.modelValue
39
38
  }, () => [
@@ -42,16 +41,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
42
41
  1
43
42
  /* TEXT */
44
43
  )
45
- ], true) : renderSlot(_ctx.$slots, "item", {
46
- key: 1,
47
- item: _ctx.modelValue
48
- }, () => [
44
+ ], true, 0) : renderSlot(_ctx.$slots, "item", { item: _ctx.modelValue }, () => [
49
45
  createTextVNode(
50
46
  toDisplayString(_ctx.modelValue),
51
47
  1
52
48
  /* TEXT */
53
49
  )
54
- ], true)
50
+ ], true, 1)
55
51
  ], 40, _hoisted_1),
56
52
  (openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), null, {
57
53
  default: withCtx(() => [
@@ -1 +1 @@
1
- {"version":3,"file":"base-dropdown.vue.js","sources":["../../../src/components/base-dropdown.vue"],"sourcesContent":["<template>\n <div\n ref=\"rootRef\"\n :class=\"dropdownCSSClasses\"\n class=\"x-dropdown\"\n @keydown=\"updateSearchBuffer\"\n @keydown.down.prevent=\"highlightNextItem\"\n @keydown.up.prevent=\"highlightPreviousItem\"\n >\n <button\n ref=\"toggleButtonRef\"\n class=\"x-dropdown__toggle\"\n data-test=\"dropdown-toggle\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listId\"\n :aria-label=\"ariaLabels?.toggleButton\"\n aria-autocomplete=\"none\"\n @click=\"toggle\"\n @keydown.up.down.prevent.stop=\"open\"\n >\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 {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-if=\"hasToggleSlot\" :is-open=\"isOpen\" :item=\"modelValue\" name=\"toggle\">\n {{ modelValue }}\n </slot>\n <slot v-else :item=\"modelValue\" name=\"item\">{{ modelValue }}</slot>\n </button>\n\n <component :is=\"animation\">\n <ul\n v-show=\"isOpen\"\n :id=\"listId\"\n class=\"x-dropdown__items-list\"\n data-test=\"dropdown-list\"\n role=\"listbox\"\n tabindex=\"-1\"\n @keydown.end=\"highlightLastItem\"\n @keydown.esc=\"closeAndFocusToggleButton\"\n @keydown.home=\"highlightFirstItem\"\n >\n <li\n v-for=\"(item, index) in items\"\n :key=\"(item as Identifiable).id ?? item\"\n class=\"x-dropdown__list-item\"\n >\n <button\n :ref=\"el => (itemsButtonRefs[index] = el as HTMLButtonElement | null)\"\n :aria-selected=\"item === modelValue\"\n :class=\"itemsCSSClasses[index]\"\n class=\"x-dropdown__item\"\n data-test=\"dropdown-item\"\n role=\"option\"\n @click=\"emitSelectedItemChanged(item)\"\n >\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 {string|number|Identifiable} item - Item 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\n :is-highlighted=\"index === highlightedItemIndex\"\n :is-selected=\"item === modelValue\"\n :item=\"item\"\n name=\"item\"\n >\n {{ item }}\n </slot>\n </button>\n </li>\n </ul>\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Identifiable } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../composables'\nimport { AnimationProp } from '../types'\nimport { debounceFunction, getTargetElement, normalizeString } from '../utils'\nimport { NoAnimation } from './animations'\n\ntype DropdownItem = string | number | Identifiable\nlet dropdownCount = 0\n\n/**\n * Dropdown component that mimics a Select element behavior, but with the option\n * to customize the toggle button and each item contents.\n */\nexport default defineComponent({\n name: 'BaseDropdown',\n props: {\n /** List of items to display.*/\n items: {\n type: Array as PropType<DropdownItem[]>,\n required: true,\n },\n /** The selected item. */\n modelValue: {\n type: null as unknown as PropType<DropdownItem | null>,\n validator: (v: any) =>\n typeof v === 'string' || typeof v === 'number' || typeof v === 'object' || v === null,\n required: true,\n },\n /**\n * Animation component to use for expanding the dropdown. This is a single element animation,\n * so only `<transition>` components are allowed.\n */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /** Time to wait without receiving any keystroke before resetting the items search query. */\n searchTimeoutMs: {\n type: Number,\n default: 1000,\n },\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const rootRef = ref<HTMLElement>()\n /** The button that opens and closes the list of options. */\n const toggleButtonRef = ref<HTMLButtonElement>()\n /** Array containing the dropdown list buttons HTMLElements. */\n const itemsButtonRefs = ref<(HTMLButtonElement | null)[]>([])\n\n /** Property to check whether the dropdown is expanded or closed. */\n const isOpen = ref(false)\n /** Index of the element that has the focus in the list. -1 means no element has focus. */\n const highlightedItemIndex = ref(-1)\n /** String to search for the first element that starts with it. */\n const searchBuffer = ref('')\n\n /** Resets the search buffer after a certain time has passed. */\n let restartResetSearchTimeout: () => void\n /* Unique ID to identify the dropdown. */\n const listId = `x-dropdown-${dropdownCount++}`\n\n const ariaLabels = useAccessibilityLabels('baseDropdown')\n\n /**\n * Dynamic CSS classes to add to the dropdown root element.\n *\n * @returns An object containing the CSS classes to add to the dropdown root element.\n */\n const dropdownCSSClasses = computed(() => ({ 'x-dropdown--is-open': isOpen }))\n\n /**\n * Dynamic CSS classes to add to each one of the items.\n *\n * @returns An object containing the CSS classes to add to each item.\n */\n const itemsCSSClasses = computed(() =>\n props.items.map((item, index) => ({\n 'x-dropdown__item--is-selected': props.modelValue === item,\n 'x-dropdown__item--is-highlighted': highlightedItemIndex.value === index,\n })),\n )\n\n /* Opens the dropdown. */\n const open = () => (isOpen.value = true)\n /* Closes the dropdown. */\n const close = () => (isOpen.value = false)\n /* Toggles the dropdown. */\n const toggle = () => (isOpen.value = !isOpen.value)\n\n /**\n * Closes the modal and focuses the toggle button.\n */\n function closeAndFocusToggleButton() {\n close()\n toggleButtonRef.value?.focus()\n }\n\n /**\n * Emits the event that the selected item has changed.\n *\n * @param item - The new selected item.\n */\n function emitSelectedItemChanged(item: DropdownItem) {\n emit('update:modelValue', item)\n closeAndFocusToggleButton()\n }\n\n /**\n * Highlights the item after the one that is currently highlighted.\n */\n function highlightNextItem() {\n open()\n highlightedItemIndex.value = (highlightedItemIndex.value + 1) % props.items.length\n }\n\n /**\n * Highlights the item before the one that is currently highlighted.\n */\n function highlightPreviousItem() {\n const currentIndex = highlightedItemIndex.value\n open()\n highlightedItemIndex.value = currentIndex > 0 ? currentIndex - 1 : props.items.length - 1\n }\n\n /**\n * Highlights the first of the provided items.\n */\n function highlightFirstItem() {\n highlightedItemIndex.value = 0\n }\n\n /**\n * Highlights the last of the provided items.\n */\n function highlightLastItem() {\n highlightedItemIndex.value = props.items.length - 1\n }\n\n /**\n * Updates the variable that is used to search in the filters.\n *\n * @param event - The event coming from the user typing.\n */\n function updateSearchBuffer(event: KeyboardEvent) {\n if (/^\\w$/.test(event.key)) {\n const key = event.key\n searchBuffer.value += key\n restartResetSearchTimeout()\n }\n }\n\n /**\n * Resets the search buffer.\n */\n function resetSearchBuffer() {\n searchBuffer.value = ''\n }\n\n /**\n * Closes the dropdown if the passed event has happened on an element out of the dropdown.\n *\n * @param event - The event to check if it has happened out of the dropdown component.\n */\n function closeIfEventIsOutOfDropdown(event: MouseEvent | TouchEvent | FocusEvent) {\n if (!rootRef.value?.contains(getTargetElement(event))) {\n close()\n }\n }\n\n /**\n * Adds listeners to the document element to detect if the focus has moved out from the\n * dropdown.\n */\n function addDocumentCloseListeners() {\n document.addEventListener('mousedown', closeIfEventIsOutOfDropdown)\n document.addEventListener('touchstart', closeIfEventIsOutOfDropdown)\n document.addEventListener('focusin', closeIfEventIsOutOfDropdown)\n }\n\n /**\n * Removes the listeners of the document element to detect if the focus has moved out from the\n * dropdown.\n */\n function removeDocumentCloseListeners() {\n document.removeEventListener('mousedown', closeIfEventIsOutOfDropdown)\n document.removeEventListener('touchstart', closeIfEventIsOutOfDropdown)\n document.removeEventListener('focusin', closeIfEventIsOutOfDropdown)\n }\n\n /**\n * Highlights the item that matches the search buffer. To do so it checks the list buttons\n * text content. It highlights items following this priority:\n * - If an element is already highlighted, it starts searching from that element.\n * - If no element is found starting from the previously highlighted, it returns the first one.\n * - If no element is found matching the search query it highlights the first element.\n *\n * @param search - The search string to find in the HTML.\n */\n watch(searchBuffer, search => {\n if (search) {\n const normalizedSearch = normalizeString(search)\n const matchingIndices = itemsButtonRefs?.value?.reduce<number[]>(\n (matchingIndices, button, index) => {\n if (button) {\n const safeButtonWordCharacters = button.textContent!.replace(/\\W/g, '')\n const normalizedButtonText = normalizeString(safeButtonWordCharacters)\n if (normalizedButtonText.startsWith(normalizedSearch)) {\n matchingIndices.push(index)\n }\n }\n return matchingIndices\n },\n [],\n )\n highlightedItemIndex.value =\n // First matching item starting to search from the current highlighted element\n matchingIndices?.find(index => index >= highlightedItemIndex.value) ??\n // First matching item\n matchingIndices?.[0] ??\n // First item\n 0\n }\n })\n\n /**\n * Updates the debounced function to reset the search.\n *\n * @param searchTimeoutMs - The new milliseconds that have to pass without typing before\n * resetting the search.\n */\n watch(\n () => props.searchTimeoutMs,\n searchTimeoutMs => {\n restartResetSearchTimeout = debounceFunction(resetSearchBuffer, searchTimeoutMs)\n },\n { immediate: true },\n )\n\n /**\n * Focuses the DOM element which matches the `highlightedItemIndex`.\n *\n * @param highlightedItemIndex - The index of the HTML element to focus.\n */\n watch(\n highlightedItemIndex,\n highlightedItemIndex => {\n nextTick(() => itemsButtonRefs.value[highlightedItemIndex]?.focus())\n },\n { immediate: true },\n )\n\n /**\n * When the dropdown is open it sets the focused element to the one that is selected.\n *\n * @param isOpen - True if the dropdown is open, false otherwise.\n */\n watch(isOpen, isOpen => {\n highlightedItemIndex.value = isOpen\n ? props.modelValue === null\n ? 0\n : props.items.indexOf(props.modelValue)\n : -1\n })\n\n /**\n * Adds and removes listeners to close the dropdown when it loses the focus.\n *\n * @param isOpen - True if the dropdown is open, false otherwise.\n */\n watch(isOpen, isOpen => {\n /*\n * Because there is an issue with Firefox in macOS and Safari that doesn't focus the target\n * element of the `mousedown` events, the `focusout` event `relatedTarget` property can't be\n * used to detect whether the user has blurred the dropdown. The hack here is to use\n * document listeners that have the side effect of losing the focus.\n */\n if (isOpen) {\n addDocumentCloseListeners()\n } else {\n removeDocumentCloseListeners()\n }\n })\n\n /**\n * If the dropdown is destroyed before removing the document listeners, it ensures that they\n * are removed too.\n */\n onBeforeUnmount(() => {\n removeDocumentCloseListeners()\n })\n\n return {\n ariaLabels,\n hasToggleSlot: !!slots.toggle,\n closeAndFocusToggleButton,\n dropdownCSSClasses,\n emitSelectedItemChanged,\n highlightFirstItem,\n highlightLastItem,\n highlightNextItem,\n highlightPreviousItem,\n highlightedItemIndex,\n isOpen,\n itemsButtonRefs,\n itemsCSSClasses,\n listId,\n open,\n rootRef,\n toggle,\n toggleButtonRef,\n updateSearchBuffer,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-dropdown {\n position: relative;\n}\n\n.x-dropdown__items-list {\n z-index: 1;\n list-style: none;\n position: absolute;\n padding: 0;\n margin: 0;\n top: calc(100% + var(--x-size-gap-dropdown-default, 0));\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThe `Dropdown` component is a simple yet customizable select component. The component needs to work\nwith the list of items available to select, which are passed using the `items` prop, and the selected\nitem, which is passed in using the `value` prop.\n\nThe supported items must be an array that can contain unique strings, unique numbers, or objects\nwith a unique `id` property.\n\nThe content of each item can be customized using the `item` slot, which apart from the data of the\nitem, it also receives via prop if the element is selected or highlighted.\n\nThe `toggle` slot can be used to customize the button that opens the dropdown. If this is not\nprovided, the `item` slot will be used for that.\n\n```vue\n<template>\n <BaseDropdown v-model=\"value\" :items=\"items\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseDropdown>\n</template>\n\n<script setup>\nimport { BaseDropdown } from '@empathyco/x-components'\nimport { ref } from 'vue'\nconst items = ['a', 2, { id: '3' }]\nconst value = ref('a')\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_withKeys","_withModifiers","_createElementVNode","_renderSlot","_createTextVNode","_createBlock","_resolveDynamicComponent","_withCtx","_withDirectives","_Fragment","_renderList"],"mappings":";;;;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA8EM,KAAA;AAAA,IAAA;AAAA,MA7EJ,GAAA,EAAI,SAAA;AAAA,MACH,KAAA,EAAKC,cAAA,CAAA,CAAE,IAAA,CAAA,kBAAA,EACF,YAAY,CAAA,CAAA;AAAA,MACjB,SAAA,EAAO;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAC,QAAA,CAAAC,aAAA,CAAA,CAAA,GAAA,IAAA,KACa,IAAA,CAAA,iBAAA,IAAA,IAAA,CAAA,iBAAA,CAAA,GAAA,IAAA,CAAA,EAAiB,CAAA,SAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAAD,QAAA,CAAAC,aAAA,CAAA,CAAA,GAAA,IAAA,KACnB,IAAA,CAAA,qBAAA,IAAA,IAAA,CAAA,qBAAA,CAAA,GAAA,IAAA,CAAA,EAAqB,CA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AA,cAAAC,UAAA,CA7BqB,IAAA,CAAA,KAAA,EAAK,CAArB,IAAA,EAAM,KAAA,KAAK;oCADrBZ,kBAAA,CA8BK,IAAA,EAAA;AAAA,kBA5BF,GAAA,EAAM,KAAsB,EAAA,IAAM,IAAA;AAAA,kBACnC,KAAA,EAAM;AAAA,iBAAA,EAAA;kBAENI,kBAAA,CAwBS,QAAA,EAAA;AAAA,oBAAA,OAAA,EAAA,IAAA;oBAvBN,GAAA,EAAK,CAAA,EAAA,KAAO,IAAA,CAAA,eAAA,CAAgB,KAAK,CAAA,GAAI,EAAA;AAAA,oBACrC,iBAAe,IAAA,KAAS,IAAA,CAAA,UAAA;AAAA,oBACxB,KAAA,EAAKH,cAAA,CAAA,CAAE,IAAA,CAAA,eAAA,CAAgB,KAAK,GACvB,kBAAkB,CAAA,CAAA;AAAA,oBACxB,WAAA,EAAU,eAAA;AAAA,oBACV,IAAA,EAAK,QAAA;AAAA,oBACJ,OAAA,EAAK,CAAA,MAAA,KAAE,IAAA,CAAA,uBAAA,CAAwB,IAAI;AAAA,mBAAA,EAAA;oBASpCI,UAAA,CAOO,IAAA,CAAA,MAAA,EAAA,MAAA,EAAA;AAAA,sBANJ,eAAgB,KAAA,KAAU,IAAA,CAAA,oBAAA;AAAA,sBAC1B,YAAa,IAAA,KAAS,IAAA,CAAA,UAAA;AAAA,sBACtB;AAAA,qBAAA,EAHH,MAOO;AAAA,sBAAAC,eAAA;wCADF,IAAI,CAAA;AAAA,wBAAA;AAAA;AAAA;AAAA,qBAAA,EAAA,IAAA;;;;;;;;oBArCL,IAAA,CAAA,MAAM;AAAA,WAAA;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-dropdown.vue.js","sources":["../../../src/components/base-dropdown.vue"],"sourcesContent":["<template>\n <div\n ref=\"rootRef\"\n :class=\"dropdownCSSClasses\"\n class=\"x-dropdown\"\n @keydown=\"updateSearchBuffer\"\n @keydown.down.prevent=\"highlightNextItem\"\n @keydown.up.prevent=\"highlightPreviousItem\"\n >\n <button\n ref=\"toggleButtonRef\"\n class=\"x-dropdown__toggle\"\n data-test=\"dropdown-toggle\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listId\"\n :aria-label=\"ariaLabels?.toggleButton\"\n aria-autocomplete=\"none\"\n @click=\"toggle\"\n @keydown.up.down.prevent.stop=\"open\"\n >\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 {string|number|Identifiable} item - The item data to render.\n @binding {boolean} isOpen - True if the dropdown is opened, and false if it is closed.\n -->\n <slot v-if=\"hasToggleSlot\" :is-open=\"isOpen\" :item=\"modelValue\" name=\"toggle\">\n {{ modelValue }}\n </slot>\n <slot v-else :item=\"modelValue\" name=\"item\">{{ modelValue }}</slot>\n </button>\n\n <component :is=\"animation\">\n <ul\n v-show=\"isOpen\"\n :id=\"listId\"\n class=\"x-dropdown__items-list\"\n data-test=\"dropdown-list\"\n role=\"listbox\"\n tabindex=\"-1\"\n @keydown.end=\"highlightLastItem\"\n @keydown.esc=\"closeAndFocusToggleButton\"\n @keydown.home=\"highlightFirstItem\"\n >\n <li\n v-for=\"(item, index) in items\"\n :key=\"(item as Identifiable).id ?? item\"\n class=\"x-dropdown__list-item\"\n >\n <button\n :ref=\"el => (itemsButtonRefs[index] = el as HTMLButtonElement | null)\"\n :aria-selected=\"item === modelValue\"\n :class=\"itemsCSSClasses[index]\"\n class=\"x-dropdown__item\"\n data-test=\"dropdown-item\"\n role=\"option\"\n @click=\"emitSelectedItemChanged(item)\"\n >\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 {string|number|Identifiable} item - Item 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\n :is-highlighted=\"index === highlightedItemIndex\"\n :is-selected=\"item === modelValue\"\n :item=\"item\"\n name=\"item\"\n >\n {{ item }}\n </slot>\n </button>\n </li>\n </ul>\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Identifiable } from '@empathyco/x-types'\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport { useAccessibilityLabels } from '../composables'\nimport { AnimationProp } from '../types'\nimport { debounceFunction, getTargetElement, normalizeString } from '../utils'\nimport { NoAnimation } from './animations'\n\ntype DropdownItem = string | number | Identifiable\nlet dropdownCount = 0\n\n/**\n * Dropdown component that mimics a Select element behavior, but with the option\n * to customize the toggle button and each item contents.\n */\nexport default defineComponent({\n name: 'BaseDropdown',\n props: {\n /** List of items to display.*/\n items: {\n type: Array as PropType<DropdownItem[]>,\n required: true,\n },\n /** The selected item. */\n modelValue: {\n type: null as unknown as PropType<DropdownItem | null>,\n validator: (v: any) =>\n typeof v === 'string' || typeof v === 'number' || typeof v === 'object' || v === null,\n required: true,\n },\n /**\n * Animation component to use for expanding the dropdown. This is a single element animation,\n * so only `<transition>` components are allowed.\n */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /** Time to wait without receiving any keystroke before resetting the items search query. */\n searchTimeoutMs: {\n type: Number,\n default: 1000,\n },\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const rootRef = ref<HTMLElement>()\n /** The button that opens and closes the list of options. */\n const toggleButtonRef = ref<HTMLButtonElement>()\n /** Array containing the dropdown list buttons HTMLElements. */\n const itemsButtonRefs = ref<(HTMLButtonElement | null)[]>([])\n\n /** Property to check whether the dropdown is expanded or closed. */\n const isOpen = ref(false)\n /** Index of the element that has the focus in the list. -1 means no element has focus. */\n const highlightedItemIndex = ref(-1)\n /** String to search for the first element that starts with it. */\n const searchBuffer = ref('')\n\n /** Resets the search buffer after a certain time has passed. */\n let restartResetSearchTimeout: () => void\n /* Unique ID to identify the dropdown. */\n const listId = `x-dropdown-${dropdownCount++}`\n\n const ariaLabels = useAccessibilityLabels('baseDropdown')\n\n /**\n * Dynamic CSS classes to add to the dropdown root element.\n *\n * @returns An object containing the CSS classes to add to the dropdown root element.\n */\n const dropdownCSSClasses = computed(() => ({ 'x-dropdown--is-open': isOpen }))\n\n /**\n * Dynamic CSS classes to add to each one of the items.\n *\n * @returns An object containing the CSS classes to add to each item.\n */\n const itemsCSSClasses = computed(() =>\n props.items.map((item, index) => ({\n 'x-dropdown__item--is-selected': props.modelValue === item,\n 'x-dropdown__item--is-highlighted': highlightedItemIndex.value === index,\n })),\n )\n\n /* Opens the dropdown. */\n const open = () => (isOpen.value = true)\n /* Closes the dropdown. */\n const close = () => (isOpen.value = false)\n /* Toggles the dropdown. */\n const toggle = () => (isOpen.value = !isOpen.value)\n\n /**\n * Closes the modal and focuses the toggle button.\n */\n function closeAndFocusToggleButton() {\n close()\n toggleButtonRef.value?.focus()\n }\n\n /**\n * Emits the event that the selected item has changed.\n *\n * @param item - The new selected item.\n */\n function emitSelectedItemChanged(item: DropdownItem) {\n emit('update:modelValue', item)\n closeAndFocusToggleButton()\n }\n\n /**\n * Highlights the item after the one that is currently highlighted.\n */\n function highlightNextItem() {\n open()\n highlightedItemIndex.value = (highlightedItemIndex.value + 1) % props.items.length\n }\n\n /**\n * Highlights the item before the one that is currently highlighted.\n */\n function highlightPreviousItem() {\n const currentIndex = highlightedItemIndex.value\n open()\n highlightedItemIndex.value = currentIndex > 0 ? currentIndex - 1 : props.items.length - 1\n }\n\n /**\n * Highlights the first of the provided items.\n */\n function highlightFirstItem() {\n highlightedItemIndex.value = 0\n }\n\n /**\n * Highlights the last of the provided items.\n */\n function highlightLastItem() {\n highlightedItemIndex.value = props.items.length - 1\n }\n\n /**\n * Updates the variable that is used to search in the filters.\n *\n * @param event - The event coming from the user typing.\n */\n function updateSearchBuffer(event: KeyboardEvent) {\n if (/^\\w$/.test(event.key)) {\n const key = event.key\n searchBuffer.value += key\n restartResetSearchTimeout()\n }\n }\n\n /**\n * Resets the search buffer.\n */\n function resetSearchBuffer() {\n searchBuffer.value = ''\n }\n\n /**\n * Closes the dropdown if the passed event has happened on an element out of the dropdown.\n *\n * @param event - The event to check if it has happened out of the dropdown component.\n */\n function closeIfEventIsOutOfDropdown(event: MouseEvent | TouchEvent | FocusEvent) {\n if (!rootRef.value?.contains(getTargetElement(event))) {\n close()\n }\n }\n\n /**\n * Adds listeners to the document element to detect if the focus has moved out from the\n * dropdown.\n */\n function addDocumentCloseListeners() {\n document.addEventListener('mousedown', closeIfEventIsOutOfDropdown)\n document.addEventListener('touchstart', closeIfEventIsOutOfDropdown)\n document.addEventListener('focusin', closeIfEventIsOutOfDropdown)\n }\n\n /**\n * Removes the listeners of the document element to detect if the focus has moved out from the\n * dropdown.\n */\n function removeDocumentCloseListeners() {\n document.removeEventListener('mousedown', closeIfEventIsOutOfDropdown)\n document.removeEventListener('touchstart', closeIfEventIsOutOfDropdown)\n document.removeEventListener('focusin', closeIfEventIsOutOfDropdown)\n }\n\n /**\n * Highlights the item that matches the search buffer. To do so it checks the list buttons\n * text content. It highlights items following this priority:\n * - If an element is already highlighted, it starts searching from that element.\n * - If no element is found starting from the previously highlighted, it returns the first one.\n * - If no element is found matching the search query it highlights the first element.\n *\n * @param search - The search string to find in the HTML.\n */\n watch(searchBuffer, search => {\n if (search) {\n const normalizedSearch = normalizeString(search)\n const matchingIndices = itemsButtonRefs?.value?.reduce<number[]>(\n (matchingIndices, button, index) => {\n if (button) {\n const safeButtonWordCharacters = button.textContent!.replace(/\\W/g, '')\n const normalizedButtonText = normalizeString(safeButtonWordCharacters)\n if (normalizedButtonText.startsWith(normalizedSearch)) {\n matchingIndices.push(index)\n }\n }\n return matchingIndices\n },\n [],\n )\n highlightedItemIndex.value =\n // First matching item starting to search from the current highlighted element\n matchingIndices?.find(index => index >= highlightedItemIndex.value) ??\n // First matching item\n matchingIndices?.[0] ??\n // First item\n 0\n }\n })\n\n /**\n * Updates the debounced function to reset the search.\n *\n * @param searchTimeoutMs - The new milliseconds that have to pass without typing before\n * resetting the search.\n */\n watch(\n () => props.searchTimeoutMs,\n searchTimeoutMs => {\n restartResetSearchTimeout = debounceFunction(resetSearchBuffer, searchTimeoutMs)\n },\n { immediate: true },\n )\n\n /**\n * Focuses the DOM element which matches the `highlightedItemIndex`.\n *\n * @param highlightedItemIndex - The index of the HTML element to focus.\n */\n watch(\n highlightedItemIndex,\n highlightedItemIndex => {\n nextTick(() => itemsButtonRefs.value[highlightedItemIndex]?.focus())\n },\n { immediate: true },\n )\n\n /**\n * When the dropdown is open it sets the focused element to the one that is selected.\n *\n * @param isOpen - True if the dropdown is open, false otherwise.\n */\n watch(isOpen, isOpen => {\n highlightedItemIndex.value = isOpen\n ? props.modelValue === null\n ? 0\n : props.items.indexOf(props.modelValue)\n : -1\n })\n\n /**\n * Adds and removes listeners to close the dropdown when it loses the focus.\n *\n * @param isOpen - True if the dropdown is open, false otherwise.\n */\n watch(isOpen, isOpen => {\n /*\n * Because there is an issue with Firefox in macOS and Safari that doesn't focus the target\n * element of the `mousedown` events, the `focusout` event `relatedTarget` property can't be\n * used to detect whether the user has blurred the dropdown. The hack here is to use\n * document listeners that have the side effect of losing the focus.\n */\n if (isOpen) {\n addDocumentCloseListeners()\n } else {\n removeDocumentCloseListeners()\n }\n })\n\n /**\n * If the dropdown is destroyed before removing the document listeners, it ensures that they\n * are removed too.\n */\n onBeforeUnmount(() => {\n removeDocumentCloseListeners()\n })\n\n return {\n ariaLabels,\n hasToggleSlot: !!slots.toggle,\n closeAndFocusToggleButton,\n dropdownCSSClasses,\n emitSelectedItemChanged,\n highlightFirstItem,\n highlightLastItem,\n highlightNextItem,\n highlightPreviousItem,\n highlightedItemIndex,\n isOpen,\n itemsButtonRefs,\n itemsCSSClasses,\n listId,\n open,\n rootRef,\n toggle,\n toggleButtonRef,\n updateSearchBuffer,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-dropdown {\n position: relative;\n}\n\n.x-dropdown__items-list {\n z-index: 1;\n list-style: none;\n position: absolute;\n padding: 0;\n margin: 0;\n top: calc(100% + var(--x-size-gap-dropdown-default, 0));\n}\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThe `Dropdown` component is a simple yet customizable select component. The component needs to work\nwith the list of items available to select, which are passed using the `items` prop, and the selected\nitem, which is passed in using the `value` prop.\n\nThe supported items must be an array that can contain unique strings, unique numbers, or objects\nwith a unique `id` property.\n\nThe content of each item can be customized using the `item` slot, which apart from the data of the\nitem, it also receives via prop if the element is selected or highlighted.\n\nThe `toggle` slot can be used to customize the button that opens the dropdown. If this is not\nprovided, the `item` slot will be used for that.\n\n```vue\n<template>\n <BaseDropdown v-model=\"value\" :items=\"items\">\n <template #toggle=\"{ item, isOpen }\">{{ item }} {{ isOpen ? '🔼' : '🔽' }}️</template>\n <template #item=\"{ item, isSelected, isHighlighted }\">\n <span v-if=\"isHighlighted\">🟢</span>\n <span v-if=\"isSelected\">✅</span>\n <span>{{ item }}</span>\n </template>\n </BaseDropdown>\n</template>\n\n<script setup>\nimport { BaseDropdown } from '@empathyco/x-components'\nimport { ref } from 'vue'\nconst items = ['a', 2, { id: '3' }]\nconst value = ref('a')\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeClass","_withKeys","_withModifiers","_createElementVNode","_renderSlot","_createTextVNode","_createBlock","_resolveDynamicComponent","_withCtx","_withDirectives","_Fragment","_renderList"],"mappings":";;;;;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA8EM,KAAA;AAAA,IAAA;AAAA,MA7EJ,GAAA,EAAI,SAAA;AAAA,MACH,KAAA,EAAKC,cAAA,CAAA,CAAE,IAAA,CAAA,kBAAA,EACF,YAAY,CAAA,CAAA;AAAA,MACjB,SAAA,EAAO;AAAA,QAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA,QAAA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CAAA,UAAA;AAAA,sBACtB;AAAA,qBAAA,EAHH,MAOO;AAAA,sBAAAC,eAAA;wCADF,IAAI,CAAA;AAAA,wBAAA;AAAA;AAAA;AAAA,qBAAA,EAAA,IAAA;;;;;;;;oBArCL,IAAA,CAAA,MAAM;AAAA,WAAA;;;;;;;;;;;;;;"}
@@ -23,19 +23,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
23
23
  class: normalizeClass([cssClass, "x-base-grid__item"])
24
24
  },
25
25
  [
26
- _ctx.slots[slotName] ? renderSlot(_ctx.$slots, slotName, {
27
- key: 0,
28
- item
29
- }, void 0, true) : renderSlot(_ctx.$slots, "default", {
30
- key: 1,
31
- item
32
- }, () => [
26
+ _ctx.slots[slotName] ? renderSlot(_ctx.$slots, slotName, { item }, void 0, true, 0) : renderSlot(_ctx.$slots, "default", { item }, () => [
33
27
  createTextVNode(
34
28
  toDisplayString(item.name || item.modelName || item.id || item),
35
29
  1
36
30
  /* TEXT */
37
31
  )
38
- ], true)
32
+ ], true, 1)
39
33
  ],
40
34
  2
41
35
  /* CLASS */
@@ -1 +1 @@
1
- {"version":3,"file":"base-grid.vue.js","sources":["../../../src/components/base-grid.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n ref=\"gridEl\"\n :style=\"style\"\n class=\"x-base-grid\"\n :class=\"cssClasses\"\n tag=\"ul\"\n data-test=\"grid\"\n >\n <li\n v-for=\"{ item, cssClass, slotName } in gridItems\"\n :key=\"item.id\"\n :class=\"cssClass\"\n class=\"x-base-grid__item\"\n >\n <!--\n @slot Customized item rendering. Specifying a slot with the item's modelName will result in\n the item using that slot composition to render.\n @binding {item} item - Item to render\n -->\n <slot v-if=\"slots[slotName]\" :name=\"slotName\" :item=\"item\" />\n <!--\n @slot (required) Default item rendering. This slot will be used by default for rendering\n the item without an specific slot implementation.\n @binding {item} item - Item to render\n -->\n <slot v-else :item=\"item\">{{ (item as any).name || item.modelName || item.id || item }}</slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { MaybeComputedElementRef, UseResizeObserverReturn } from '@vueuse/core'\nimport type { PropType, Ref } from 'vue'\nimport type { ListItem } from '../utils/types'\nimport type { GridItem } from './base-grid.types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useXBus } from '../composables/use-x-bus'\nimport { AnimationProp } from '../types/animation-prop'\nimport { toKebabCase } from '../utils/string'\nimport { LIST_ITEMS_KEY } from './decorators/injection.consts'\n\n/**\n * Grid component that is able to render different items based on their modelName value. In order\n * to achieve this, it exposes a scopedSlot for each different modelName. In case the items used\n * do not have modelName property, the default slot is used instead. It has a required property:\n * the `items` to render; and an optional one: the number `columns` the grid is divided in. If the\n * number of columns is not specified, the grid automatically fills the rows with as many columns\n * as it can fit.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseGrid',\n props: {\n /** Animation component that will be used to animate the base grid. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Number of columns the grid is divided into. By default, its value is 0, setting the grid\n * columns mode to auto-fill.\n */\n columns: {\n type: Number,\n default: 0,\n },\n /**\n * The list of items to be rendered.\n *\n * @remarks The items must have an ID property.\n */\n items: {\n type: Array as PropType<ListItem[]>,\n },\n },\n setup(props, { slots }) {\n // eslint-disable-next-line ts/consistent-type-definitions\n type ElementRef = {\n $el: HTMLElement\n }\n\n const xBus = useXBus()\n\n /** It injects {@link ListItem} provided by an ancestor. */\n const injectedListItems = inject<Ref<ListItem[]>>(LIST_ITEMS_KEY as string)\n const gridEl = ref<ElementRef | HTMLElement>()\n const renderedColumnsNumber = ref(0)\n\n /**\n * Emits the {@link XEventsTypes.RenderedColumnsNumberChanged}\n * event whenever the number of columns rendered inside the grid changes.\n */\n watch(\n renderedColumnsNumber,\n () => xBus.emit('RenderedColumnsNumberChanged', renderedColumnsNumber.value),\n { immediate: false },\n )\n\n /**\n * It returns the items passed as props or the injected ones.\n *\n * @returns List of grid items.\n */\n const computedItems = computed<ListItem[] | void>(() => {\n return (\n props.items ??\n injectedListItems?.value ??\n console.warn('It is necessary to pass a prop or inject the list of filters')\n )\n })\n\n /**\n * CSS class based on the column property value so items inside the grid can fill different\n * amount of columns or rows based on how many columns the grid is divided into.\n *\n * @returns CSS class with the column property value.\n */\n const cssClasses = computed(() => `x-base-grid--cols-${props.columns || 'auto'}`)\n\n /**\n * CSSStyleDeclaration object specifying the number of columns the grid is divided into based on\n * the column property value.\n *\n * @returns A CSSStyleDeclaration to use as the style attribute.\n */\n const style = computed<Partial<CSSStyleDeclaration>>(() => ({\n gridTemplateColumns: props.columns\n ? `repeat(${props.columns}, minmax(0, 1fr))`\n : 'repeat(auto-fill, minmax(var(--x-size-min-width-grid-item, 150px), 1fr))',\n }))\n\n /**\n * Maps the item to an object containing: the `item`, its `CSS class` and its slot name.\n *\n * @returns An array of objects containing the item and its CSS class.\n */\n const gridItems = computed<GridItem[]>(() =>\n (computedItems.value as ListItem[]).map(item => {\n const slotName = toKebabCase(item.modelName)\n let cssClass = `x-base-grid__${slotName}`\n if (item.modelName === 'VendorBanner' && (item as any).position === undefined) {\n cssClass += ` x-base-grid__${slotName}--row`\n }\n return {\n slotName,\n item,\n cssClass,\n }\n }),\n )\n\n /**\n * Checks if a given value is an `ElementRef` object.\n *\n * @param value - The value to check.\n * @returns `true` if the value is an `ElementRef` object, `false` otherwise.\n */\n const isElementRef = (value: any): value is ElementRef => {\n return value && value.$el instanceof HTMLElement\n }\n\n /** Updates the number of columns rendered inside the grid. */\n function updateRenderedColumnsNumber() {\n const { gridTemplateColumns } = getComputedStyle(\n isElementRef(gridEl.value) ? gridEl.value.$el : (gridEl.value as Element),\n )\n renderedColumnsNumber.value = gridTemplateColumns.split(' ').length\n }\n\n /** Initialises the rendered columns number and sets a ResizeObserver to keep it updated. */\n let resizeObserver: UseResizeObserverReturn\n onMounted(() => {\n resizeObserver = useResizeObserver(\n gridEl as MaybeComputedElementRef,\n updateRenderedColumnsNumber,\n )\n })\n onBeforeUnmount(() => resizeObserver?.stop())\n\n return {\n gridItems,\n cssClasses,\n style,\n gridEl,\n slots,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-base-grid {\n display: grid;\n grid-auto-flow: dense;\n list-style: none;\n align-items: stretch;\n}\n\n.x-base-grid__banner,\n.x-base-grid__vendor-banner--row,\n.x-base-grid__next-queries-group,\n.x-base-grid__related-prompts-group {\n grid-column-start: 1;\n grid-column-end: -1;\n}\n\n.x-base-grid__related-prompts-group.x-staggered-fade-and-slide-leave-active,\n.x-base-grid__related-prompts-group.x-staggered-fade-and-slide-enter-active {\n transition: none;\n position: relative;\n}\n\n.x-base-grid__item {\n display: flex;\n flex-flow: column nowrap;\n}\n\n.x-base-grid__item > * {\n flex-grow: 1;\n}\n\n.x-base-grid--cols-auto .x-base-grid__item {\n min-width: var(--x-size-min-width-grid-item);\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on their modelName. In order\nto achieve this, it exposes a scopedSlot for each different modelName. In case the items used do not\nhave modelName property, the default slot is used instead. It has a required property, the `items`\nto render, and an optional one, the number of `columns` the grid is divided in. If the number of\ncolumns is not specified, the grid automatically fills the rows with as many columns as it can fit.\n\n### Basic example\n\nIt renders a list of items using the default slot:\n\n```vue\n<template>\n <BaseGrid :items=\"items\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n\n### Configuring the number of columns\n\nIt renders a grid with 12 columns instead of 6, which is the default value:\n\n```vue\n<template>\n <BaseGrid :items=\"items\" :columns=\"12\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n\n### Rendering usage\n\nConfiguring the number of columns.\n\nIt renders a list of items using the different scopedSlots created by the item's modelName. For\nexample, if you want to use this component as the search grid, you pass the search results (results,\nbanners, promoted, next queries...etc) as items. Each of these results have a different modelName\nand are rendered in different slots.\n\n```vue\n<template>\n <BaseGrid :animation=\"animation\" :items=\"items\">\n <template #banner=\"{ item }\">\n <span class=\"banner\">\n {{ `${item.title} banner` }}\n </span>\n </template>\n <template #next-queries=\"{ item }\">\n <span>\n {{ `${item.totalResults} next queries` }}\n </span>\n </template>\n <template #promoted=\"{ item }\">\n <span class=\"promoted\">\n {{ `${item.title} promoted` }}\n </span>\n </template>\n <template #result=\"{ item }\">\n <BaseResultLink :result=\"item\">\n {{ item.name }}\n </BaseResultLink>\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nimport BaseResultLink from './BaseResultLink.vue'\nconst animation = 'ul'\nconst items = [\n { id: 1, modelName: 'banner', title: 'Banner 1' },\n { id: 2, modelName: 'next-queries', totalResults: 5 },\n { id: 3, modelName: 'promoted', title: 'Promo 1' },\n { id: 4, modelName: 'result', name: 'Result 1' },\n]\n</script>\n```\n\n### Customizing the items width\n\nThe `--x-size-min-width-grid-item` variable can be used to customize the min width of the grid\nitems.\n\n```vue\n<template>\n <BaseGrid :items=\"items\" style=\"--x-size-min-width-grid-item: 150px\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeStyle","_normalizeClass","_createElementBlock","_Fragment","_ren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AA;AAAA,kBAAA;AAAA;AAAA;AAAA,eAAA,EAAA,IAAA;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-grid.vue.js","sources":["../../../src/components/base-grid.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n ref=\"gridEl\"\n :style=\"style\"\n class=\"x-base-grid\"\n :class=\"cssClasses\"\n tag=\"ul\"\n data-test=\"grid\"\n >\n <li\n v-for=\"{ item, cssClass, slotName } in gridItems\"\n :key=\"item.id\"\n :class=\"cssClass\"\n class=\"x-base-grid__item\"\n >\n <!--\n @slot Customized item rendering. Specifying a slot with the item's modelName will result in\n the item using that slot composition to render.\n @binding {item} item - Item to render\n -->\n <slot v-if=\"slots[slotName]\" :name=\"slotName\" :item=\"item\" />\n <!--\n @slot (required) Default item rendering. This slot will be used by default for rendering\n the item without an specific slot implementation.\n @binding {item} item - Item to render\n -->\n <slot v-else :item=\"item\">{{ (item as any).name || item.modelName || item.id || item }}</slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\nimport type { MaybeComputedElementRef, UseResizeObserverReturn } from '@vueuse/core'\nimport type { PropType, Ref } from 'vue'\nimport type { ListItem } from '../utils/types'\nimport type { GridItem } from './base-grid.types'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, defineComponent, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useXBus } from '../composables/use-x-bus'\nimport { AnimationProp } from '../types/animation-prop'\nimport { toKebabCase } from '../utils/string'\nimport { LIST_ITEMS_KEY } from './decorators/injection.consts'\n\n/**\n * Grid component that is able to render different items based on their modelName value. In order\n * to achieve this, it exposes a scopedSlot for each different modelName. In case the items used\n * do not have modelName property, the default slot is used instead. It has a required property:\n * the `items` to render; and an optional one: the number `columns` the grid is divided in. If the\n * number of columns is not specified, the grid automatically fills the rows with as many columns\n * as it can fit.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseGrid',\n props: {\n /** Animation component that will be used to animate the base grid. */\n animation: {\n type: AnimationProp,\n default: 'ul',\n },\n /**\n * Number of columns the grid is divided into. By default, its value is 0, setting the grid\n * columns mode to auto-fill.\n */\n columns: {\n type: Number,\n default: 0,\n },\n /**\n * The list of items to be rendered.\n *\n * @remarks The items must have an ID property.\n */\n items: {\n type: Array as PropType<ListItem[]>,\n },\n },\n setup(props, { slots }) {\n // eslint-disable-next-line ts/consistent-type-definitions\n type ElementRef = {\n $el: HTMLElement\n }\n\n const xBus = useXBus()\n\n /** It injects {@link ListItem} provided by an ancestor. */\n const injectedListItems = inject<Ref<ListItem[]>>(LIST_ITEMS_KEY as string)\n const gridEl = ref<ElementRef | HTMLElement>()\n const renderedColumnsNumber = ref(0)\n\n /**\n * Emits the {@link XEventsTypes.RenderedColumnsNumberChanged}\n * event whenever the number of columns rendered inside the grid changes.\n */\n watch(\n renderedColumnsNumber,\n () => xBus.emit('RenderedColumnsNumberChanged', renderedColumnsNumber.value),\n { immediate: false },\n )\n\n /**\n * It returns the items passed as props or the injected ones.\n *\n * @returns List of grid items.\n */\n const computedItems = computed<ListItem[] | void>(() => {\n return (\n props.items ??\n injectedListItems?.value ??\n console.warn('It is necessary to pass a prop or inject the list of filters')\n )\n })\n\n /**\n * CSS class based on the column property value so items inside the grid can fill different\n * amount of columns or rows based on how many columns the grid is divided into.\n *\n * @returns CSS class with the column property value.\n */\n const cssClasses = computed(() => `x-base-grid--cols-${props.columns || 'auto'}`)\n\n /**\n * CSSStyleDeclaration object specifying the number of columns the grid is divided into based on\n * the column property value.\n *\n * @returns A CSSStyleDeclaration to use as the style attribute.\n */\n const style = computed<Partial<CSSStyleDeclaration>>(() => ({\n gridTemplateColumns: props.columns\n ? `repeat(${props.columns}, minmax(0, 1fr))`\n : 'repeat(auto-fill, minmax(var(--x-size-min-width-grid-item, 150px), 1fr))',\n }))\n\n /**\n * Maps the item to an object containing: the `item`, its `CSS class` and its slot name.\n *\n * @returns An array of objects containing the item and its CSS class.\n */\n const gridItems = computed<GridItem[]>(() =>\n (computedItems.value as ListItem[]).map(item => {\n const slotName = toKebabCase(item.modelName)\n let cssClass = `x-base-grid__${slotName}`\n if (item.modelName === 'VendorBanner' && (item as any).position === undefined) {\n cssClass += ` x-base-grid__${slotName}--row`\n }\n return {\n slotName,\n item,\n cssClass,\n }\n }),\n )\n\n /**\n * Checks if a given value is an `ElementRef` object.\n *\n * @param value - The value to check.\n * @returns `true` if the value is an `ElementRef` object, `false` otherwise.\n */\n const isElementRef = (value: any): value is ElementRef => {\n return value && value.$el instanceof HTMLElement\n }\n\n /** Updates the number of columns rendered inside the grid. */\n function updateRenderedColumnsNumber() {\n const { gridTemplateColumns } = getComputedStyle(\n isElementRef(gridEl.value) ? gridEl.value.$el : (gridEl.value as Element),\n )\n renderedColumnsNumber.value = gridTemplateColumns.split(' ').length\n }\n\n /** Initialises the rendered columns number and sets a ResizeObserver to keep it updated. */\n let resizeObserver: UseResizeObserverReturn\n onMounted(() => {\n resizeObserver = useResizeObserver(\n gridEl as MaybeComputedElementRef,\n updateRenderedColumnsNumber,\n )\n })\n onBeforeUnmount(() => resizeObserver?.stop())\n\n return {\n gridItems,\n cssClasses,\n style,\n gridEl,\n slots,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-base-grid {\n display: grid;\n grid-auto-flow: dense;\n list-style: none;\n align-items: stretch;\n}\n\n.x-base-grid__banner,\n.x-base-grid__vendor-banner--row,\n.x-base-grid__next-queries-group,\n.x-base-grid__related-prompts-group {\n grid-column-start: 1;\n grid-column-end: -1;\n}\n\n.x-base-grid__related-prompts-group.x-staggered-fade-and-slide-leave-active,\n.x-base-grid__related-prompts-group.x-staggered-fade-and-slide-enter-active {\n transition: none;\n position: relative;\n}\n\n.x-base-grid__item {\n display: flex;\n flex-flow: column nowrap;\n}\n\n.x-base-grid__item > * {\n flex-grow: 1;\n}\n\n.x-base-grid--cols-auto .x-base-grid__item {\n min-width: var(--x-size-min-width-grid-item);\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThis component renders a list of elements in different slots depending on their modelName. In order\nto achieve this, it exposes a scopedSlot for each different modelName. In case the items used do not\nhave modelName property, the default slot is used instead. It has a required property, the `items`\nto render, and an optional one, the number of `columns` the grid is divided in. If the number of\ncolumns is not specified, the grid automatically fills the rows with as many columns as it can fit.\n\n### Basic example\n\nIt renders a list of items using the default slot:\n\n```vue\n<template>\n <BaseGrid :items=\"items\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n\n### Configuring the number of columns\n\nIt renders a grid with 12 columns instead of 6, which is the default value:\n\n```vue\n<template>\n <BaseGrid :items=\"items\" :columns=\"12\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n\n### Rendering usage\n\nConfiguring the number of columns.\n\nIt renders a list of items using the different scopedSlots created by the item's modelName. For\nexample, if you want to use this component as the search grid, you pass the search results (results,\nbanners, promoted, next queries...etc) as items. Each of these results have a different modelName\nand are rendered in different slots.\n\n```vue\n<template>\n <BaseGrid :animation=\"animation\" :items=\"items\">\n <template #banner=\"{ item }\">\n <span class=\"banner\">\n {{ `${item.title} banner` }}\n </span>\n </template>\n <template #next-queries=\"{ item }\">\n <span>\n {{ `${item.totalResults} next queries` }}\n </span>\n </template>\n <template #promoted=\"{ item }\">\n <span class=\"promoted\">\n {{ `${item.title} promoted` }}\n </span>\n </template>\n <template #result=\"{ item }\">\n <BaseResultLink :result=\"item\">\n {{ item.name }}\n </BaseResultLink>\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nimport BaseResultLink from './BaseResultLink.vue'\nconst animation = 'ul'\nconst items = [\n { id: 1, modelName: 'banner', title: 'Banner 1' },\n { id: 2, modelName: 'next-queries', totalResults: 5 },\n { id: 3, modelName: 'promoted', title: 'Promo 1' },\n { id: 4, modelName: 'result', name: 'Result 1' },\n]\n</script>\n```\n\n### Customizing the items width\n\nThe `--x-size-min-width-grid-item` variable can be used to customize the min width of the grid\nitems.\n\n```vue\n<template>\n <BaseGrid :items=\"items\" style=\"--x-size-min-width-grid-item: 150px\">\n <template #default=\"{ item }\">\n {{ `Default slot content: ${item.id}` }}\n </template>\n </BaseGrid>\n</template>\n\n<script setup>\nimport { BaseGrid } from '@empathyco/x-components'\nconst items = [\n { id: 1, name: 'Item 1' },\n { id: 2, name: 'Item 2' },\n { id: 3, name: 'Item 3' },\n]\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeStyle","_normalizeClass","_createElementBlock","_Fragment","_renderList","_renderSlot","_createTextVNode","_toDisplayString"],"mappings":";;;;;;AACE,EAAA,OAAAA,SAAA,EAAA,EAAAC,WAAA,CA4BYC,wBA3BL,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,IACd,GAAA,EAAI,QAAA;AAAA,IACH,KAAA,EAAKC,eAAE,IAAA,CAAA,KAAK,CAAA;AAAA,IACb,KAAA,EAAKC,cAAA,CAAA,CAAC,aAAA,EACE,IAAA,CAAA,UAAU,CAAA,CAAA;AAAA,IAClB,GAAA,EAAI,IAAA;AAAA,IACJ,WAAA,EAAU;AAAA,GAAA,EAAA;qBAGR,MAAiD;AAAA,OAAAJ,SAAA,CAAA,IAAA,CAAA,EADnDK,kBAAA;AAAA,QAkBKC,QAAA;AAAA,QAAA,IAAA;AAAA,QAAAC,UAAA,CAjBoC,IAAA,CAAA,SAAA,EAAS,CAAA,EAAvC,IAAA,EAAM,QAAA,EAAU,QAAA,EAAQ,KAAA;AADnC,UAAA,OAAAP,SAAA,E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