@empathyco/x-components 10.4.0 → 10.6.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 CHANGED
@@ -3,6 +3,26 @@
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.6.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.6.0) (2026-11-09)
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
+ ### Bug Fixes
14
+
15
+ * change CSS selector for only child teleport (#2197)
16
+
17
+
18
+ ## [10.5.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.5.0) (2026-11-05)
19
+
20
+ ### Features
21
+
22
+ * **search:** add priceFacetId to SearchConfig and update request accordingly (#2194)
23
+ * **x-components:** add responsive image props and loading events to BaseResultImage (#2195)
24
+
25
+
6
26
  ## [10.4.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.4.0) (2026-11-03)
7
27
 
8
28
  ### Features
@@ -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
  ```
@@ -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>
@@ -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
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"base-teleport.vue.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"teleportHost\" :to=\"teleportHost.shadowRoot ?? teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport {\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUnmounted,\n ref,\n watch,\n watchEffect,\n} from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n /** Styles for the teleport (content container) */\n hostStyle: Object as PropType<string | CSSStyleDeclaration>,\n },\n setup(props) {\n if (typeof document === 'undefined') {\n return { teleportHost: ref<HTMLElement>() }\n }\n\n const instance = getCurrentInstance()\n /** Hook where the slot content will be teleported to. */\n const teleportHost = ref<HTMLElement>()\n /** The page element where the teleport host will be inserted. */\n const targetElement = ref<HTMLElement>()\n let isIsolated = false\n\n // Before doing app.mount it is unknown if it will be mounted in a shadow so we need to wait.\n if (instance?.appContext.app._container) {\n createHost()\n } else {\n afterAppMount(createHost)\n }\n\n const targetAddedObserver = new MutationObserver(targetAdded)\n const targetRemovedObserver = new MutationObserver(targetRemoved)\n\n onUnmounted(() => {\n if (isIsolated && teleportHost.value) {\n ;(window as any).xCSSInjector.removeHost(teleportHost.value.shadowRoot)\n }\n })\n\n onBeforeUnmount(() => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n teleportHost.value?.remove()\n })\n\n // Handles target prop changes and init the observers accordingly.\n watch(\n () => props.target,\n newTarget => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n const target = typeof newTarget === 'string' ? document.querySelector(newTarget) : newTarget\n if (target?.isConnected) {\n targetAdded()\n } else {\n targetRemoved()\n }\n },\n { immediate: true },\n )\n\n // Updates the teleport host when props change.\n watchEffect(() => {\n if (!teleportHost.value) {\n return\n }\n if (props.disabled) {\n teleportHost.value.remove()\n return\n }\n teleportHost.value.className = `x-base-teleport x-base-teleport--${props.position}`\n\n if (!targetElement.value) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.value.insertAdjacentElement(position, teleportHost.value)\n })\n\n /* Update the host inline styles when it changes */\n watchEffect(() => {\n if (teleportHost.value && props.hostStyle) {\n if (typeof props.hostStyle === 'string') {\n teleportHost.value.style.cssText = props.hostStyle\n } else {\n Object.assign(teleportHost.value.style, props.hostStyle)\n }\n }\n })\n\n /** Checks if the target element exists in the DOM and updates the observers */\n function targetAdded() {\n let element: string | Element | null = props.target\n if (typeof element === 'string') {\n element = document.querySelector(element)\n }\n if (element instanceof HTMLElement && element.isConnected) {\n targetAddedObserver.disconnect()\n targetElement.value = element\n while (element.parentElement) {\n element = element.parentElement\n targetRemovedObserver.observe(element, { childList: true })\n }\n }\n }\n\n /** Checks if the target was disconnected from the DOM and updates the observers */\n function targetRemoved() {\n if (targetElement.value && !targetElement.value.isConnected) {\n targetRemovedObserver.disconnect()\n targetAddedObserver.observe(document.body, { childList: true, subtree: true })\n targetElement.value = undefined\n }\n }\n\n /** Creates and sets the teleport host element */\n function createHost() {\n teleportHost.value = document.createElement('div')\n isIsolated = instance?.appContext.app._container instanceof ShadowRoot\n if (isIsolated) {\n teleportHost.value.attachShadow({ mode: 'open' })\n ;(window as any).xCSSInjector.addHost(teleportHost.value.shadowRoot)\n }\n }\n\n function afterAppMount(fn: () => void) {\n onMounted(() => setTimeout(fn, 0))\n }\n\n return { teleportHost }\n },\n})\n\n/** Teleport host styles should be injected outside our shadowRoots */\nif (typeof document !== 'undefined') {\n const css = document.createElement('style')\n css.textContent =\n ':has(> .x-base-teleport--onlychild) > *:not(.x-base-teleport) { display: none; }'\n document.head?.appendChild(css) ||\n document.addEventListener('DOMContentLoaded', () => document.head.appendChild(css))\n}\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThe BaseTeleport component allows you to teleport its slot content to a specified target element in\nthe DOM. It provides flexibility in positioning the content relative to the target element and\nsupports shadow DOM integration.\n\n### Basic example\n\nTeleport content to a specific element in the DOM:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\">\n <div>This content will be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Positioning options\n\nTeleport content inside the target element, before its first child:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" position=\"afterbegin\">\n <div>Teleported content at the beginning.</div>\n </BaseTeleport>\n</template>\n```\n\n### Disabled Teleport\n\nPrevent teleporting the content:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" :disabled=\"true\">\n <div>This content will not be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Notes\n\n- When using the `onlychild` position, all other children of the target element will be hidden.\n- The component supports shadow DOM integration, automatically handling style injection. Anyway, Empathy's custom CSS\n injector is required. Teleport depends on it to add the styles.\n</docs>\n"],"names":["_openBlock","_createBlock","_Teleport","_renderSlot","_createCommentVNode"],"mappings":";;;;;AACkB,EAAA,OAAA,IAAA,CAAA,YAAA,IAAAA,SAAA,EAAA,EAAhBC,WAAA,CAEWC,QAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;AAFoB,IAAA,EAAA,EAAI,kBAAa,UAAA,IAAc,IAAA,CAAA,YAAA;AAAA,IAAe,QAAA,EAAA,IAAA,CAAA;AAAA,GAAA,EAAA;IAC3EC,UAAA,CAAa,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,GAAA,EAAA,CAAA,EAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"base-teleport.vue.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"teleportHost\" :to=\"teleportHost.shadowRoot ?? teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport {\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUnmounted,\n ref,\n watch,\n watchEffect,\n} from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n /** Styles for the teleport (content container) */\n hostStyle: Object as PropType<string | CSSStyleDeclaration>,\n },\n setup(props) {\n if (typeof document === 'undefined') {\n return { teleportHost: ref<HTMLElement>() }\n }\n\n const instance = getCurrentInstance()\n /** Hook where the slot content will be teleported to. */\n const teleportHost = ref<HTMLElement>()\n /** The page element where the teleport host will be inserted. */\n const targetElement = ref<HTMLElement>()\n let isIsolated = false\n\n // Before doing app.mount it is unknown if it will be mounted in a shadow so we need to wait.\n if (instance?.appContext.app._container) {\n createHost()\n } else {\n afterAppMount(createHost)\n }\n\n const targetAddedObserver = new MutationObserver(targetAdded)\n const targetRemovedObserver = new MutationObserver(targetRemoved)\n\n onUnmounted(() => {\n if (isIsolated && teleportHost.value) {\n ;(window as any).xCSSInjector.removeHost(teleportHost.value.shadowRoot)\n }\n })\n\n onBeforeUnmount(() => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n teleportHost.value?.remove()\n })\n\n // Handles target prop changes and init the observers accordingly.\n watch(\n () => props.target,\n newTarget => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n const target = typeof newTarget === 'string' ? document.querySelector(newTarget) : newTarget\n if (target?.isConnected) {\n targetAdded()\n } else {\n targetRemoved()\n }\n },\n { immediate: true },\n )\n\n // Updates the teleport host when props change.\n watchEffect(() => {\n if (!teleportHost.value) {\n return\n }\n if (props.disabled) {\n teleportHost.value.remove()\n return\n }\n teleportHost.value.className = `x-base-teleport x-base-teleport--${props.position}`\n\n if (!targetElement.value) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.value.insertAdjacentElement(position, teleportHost.value)\n\n if (props.position === 'onlychild') {\n targetElement.value.className += ' x-base-teleport-parent--onlychild'\n }\n })\n\n /* Update the host inline styles when it changes */\n watchEffect(() => {\n if (teleportHost.value && props.hostStyle) {\n if (typeof props.hostStyle === 'string') {\n teleportHost.value.style.cssText = props.hostStyle\n } else {\n Object.assign(teleportHost.value.style, props.hostStyle)\n }\n }\n })\n\n /** Checks if the target element exists in the DOM and updates the observers */\n function targetAdded() {\n let element: string | Element | null = props.target\n if (typeof element === 'string') {\n element = document.querySelector(element)\n }\n if (element instanceof HTMLElement && element.isConnected) {\n targetAddedObserver.disconnect()\n targetElement.value = element\n while (element.parentElement) {\n element = element.parentElement\n targetRemovedObserver.observe(element, { childList: true })\n }\n }\n }\n\n /** Checks if the target was disconnected from the DOM and updates the observers */\n function targetRemoved() {\n if (targetElement.value && !targetElement.value.isConnected) {\n targetRemovedObserver.disconnect()\n targetAddedObserver.observe(document.body, { childList: true, subtree: true })\n targetElement.value = undefined\n }\n }\n\n /** Creates and sets the teleport host element */\n function createHost() {\n teleportHost.value = document.createElement('div')\n isIsolated = instance?.appContext.app._container instanceof ShadowRoot\n if (isIsolated) {\n teleportHost.value.attachShadow({ mode: 'open' })\n ;(window as any).xCSSInjector.addHost(teleportHost.value.shadowRoot)\n }\n }\n\n function afterAppMount(fn: () => void) {\n onMounted(() => setTimeout(fn, 0))\n }\n\n return { teleportHost }\n },\n})\n\n/** Teleport host styles should be injected outside our shadowRoots */\nif (typeof document !== 'undefined') {\n const css = document.createElement('style')\n css.textContent = `.x-base-teleport-parent--onlychild > *:not(.x-base-teleport) { display: none; }`\n document.head?.appendChild(css) ||\n document.addEventListener('DOMContentLoaded', () => document.head.appendChild(css))\n}\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThe BaseTeleport component allows you to teleport its slot content to a specified target element in\nthe DOM. It provides flexibility in positioning the content relative to the target element and\nsupports shadow DOM integration.\n\n### Basic example\n\nTeleport content to a specific element in the DOM:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\">\n <div>This content will be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Positioning options\n\nTeleport content inside the target element, before its first child:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" position=\"afterbegin\">\n <div>Teleported content at the beginning.</div>\n </BaseTeleport>\n</template>\n```\n\n### Disabled Teleport\n\nPrevent teleporting the content:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" :disabled=\"true\">\n <div>This content will not be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Notes\n\n- When using the `onlychild` position, all other children of the target element will be hidden.\n- The component supports shadow DOM integration, automatically handling style injection. Anyway, Empathy's custom CSS\n injector is required. Teleport depends on it to add the styles.\n</docs>\n"],"names":["_openBlock","_createBlock","_Teleport","_renderSlot","_createCommentVNode"],"mappings":";;;;;AACkB,EAAA,OAAA,IAAA,CAAA,YAAA,IAAAA,SAAA,EAAA,EAAhBC,WAAA,CAEWC,QAAA,EAAA;AAAA,IAAA,GAAA,EAAA,CAAA;AAFoB,IAAA,EAAA,EAAI,kBAAa,UAAA,IAAc,IAAA,CAAA,YAAA;AAAA,IAAe,QAAA,EAAA,IAAA,CAAA;AAAA,GAAA,EAAA;IAC3EC,UAAA,CAAa,IAAA,CAAA,MAAA,EAAA,SAAA;AAAA,GAAA,EAAA,CAAA,EAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;;;;;;"}
@@ -85,6 +85,9 @@ var _sfc_main = defineComponent({
85
85
  }
86
86
  const position = props.position === 'onlychild' ? 'beforeend' : props.position;
87
87
  targetElement.value.insertAdjacentElement(position, teleportHost.value);
88
+ if (props.position === 'onlychild') {
89
+ targetElement.value.className += ' x-base-teleport-parent--onlychild';
90
+ }
88
91
  });
89
92
  /* Update the host inline styles when it changes */
90
93
  watchEffect(() => {
@@ -138,8 +141,7 @@ var _sfc_main = defineComponent({
138
141
  /** Teleport host styles should be injected outside our shadowRoots */
139
142
  if (typeof document !== 'undefined') {
140
143
  const css = document.createElement('style');
141
- css.textContent =
142
- ':has(> .x-base-teleport--onlychild) > *:not(.x-base-teleport) { display: none; }';
144
+ css.textContent = `.x-base-teleport-parent--onlychild > *:not(.x-base-teleport) { display: none; }`;
143
145
  document.head?.appendChild(css) ||
144
146
  document.addEventListener('DOMContentLoaded', () => document.head.appendChild(css));
145
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-teleport.vue2.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"teleportHost\" :to=\"teleportHost.shadowRoot ?? teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport {\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUnmounted,\n ref,\n watch,\n watchEffect,\n} from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n /** Styles for the teleport (content container) */\n hostStyle: Object as PropType<string | CSSStyleDeclaration>,\n },\n setup(props) {\n if (typeof document === 'undefined') {\n return { teleportHost: ref<HTMLElement>() }\n }\n\n const instance = getCurrentInstance()\n /** Hook where the slot content will be teleported to. */\n const teleportHost = ref<HTMLElement>()\n /** The page element where the teleport host will be inserted. */\n const targetElement = ref<HTMLElement>()\n let isIsolated = false\n\n // Before doing app.mount it is unknown if it will be mounted in a shadow so we need to wait.\n if (instance?.appContext.app._container) {\n createHost()\n } else {\n afterAppMount(createHost)\n }\n\n const targetAddedObserver = new MutationObserver(targetAdded)\n const targetRemovedObserver = new MutationObserver(targetRemoved)\n\n onUnmounted(() => {\n if (isIsolated && teleportHost.value) {\n ;(window as any).xCSSInjector.removeHost(teleportHost.value.shadowRoot)\n }\n })\n\n onBeforeUnmount(() => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n teleportHost.value?.remove()\n })\n\n // Handles target prop changes and init the observers accordingly.\n watch(\n () => props.target,\n newTarget => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n const target = typeof newTarget === 'string' ? document.querySelector(newTarget) : newTarget\n if (target?.isConnected) {\n targetAdded()\n } else {\n targetRemoved()\n }\n },\n { immediate: true },\n )\n\n // Updates the teleport host when props change.\n watchEffect(() => {\n if (!teleportHost.value) {\n return\n }\n if (props.disabled) {\n teleportHost.value.remove()\n return\n }\n teleportHost.value.className = `x-base-teleport x-base-teleport--${props.position}`\n\n if (!targetElement.value) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.value.insertAdjacentElement(position, teleportHost.value)\n })\n\n /* Update the host inline styles when it changes */\n watchEffect(() => {\n if (teleportHost.value && props.hostStyle) {\n if (typeof props.hostStyle === 'string') {\n teleportHost.value.style.cssText = props.hostStyle\n } else {\n Object.assign(teleportHost.value.style, props.hostStyle)\n }\n }\n })\n\n /** Checks if the target element exists in the DOM and updates the observers */\n function targetAdded() {\n let element: string | Element | null = props.target\n if (typeof element === 'string') {\n element = document.querySelector(element)\n }\n if (element instanceof HTMLElement && element.isConnected) {\n targetAddedObserver.disconnect()\n targetElement.value = element\n while (element.parentElement) {\n element = element.parentElement\n targetRemovedObserver.observe(element, { childList: true })\n }\n }\n }\n\n /** Checks if the target was disconnected from the DOM and updates the observers */\n function targetRemoved() {\n if (targetElement.value && !targetElement.value.isConnected) {\n targetRemovedObserver.disconnect()\n targetAddedObserver.observe(document.body, { childList: true, subtree: true })\n targetElement.value = undefined\n }\n }\n\n /** Creates and sets the teleport host element */\n function createHost() {\n teleportHost.value = document.createElement('div')\n isIsolated = instance?.appContext.app._container instanceof ShadowRoot\n if (isIsolated) {\n teleportHost.value.attachShadow({ mode: 'open' })\n ;(window as any).xCSSInjector.addHost(teleportHost.value.shadowRoot)\n }\n }\n\n function afterAppMount(fn: () => void) {\n onMounted(() => setTimeout(fn, 0))\n }\n\n return { teleportHost }\n },\n})\n\n/** Teleport host styles should be injected outside our shadowRoots */\nif (typeof document !== 'undefined') {\n const css = document.createElement('style')\n css.textContent =\n ':has(> .x-base-teleport--onlychild) > *:not(.x-base-teleport) { display: none; }'\n document.head?.appendChild(css) ||\n document.addEventListener('DOMContentLoaded', () => document.head.appendChild(css))\n}\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThe BaseTeleport component allows you to teleport its slot content to a specified target element in\nthe DOM. It provides flexibility in positioning the content relative to the target element and\nsupports shadow DOM integration.\n\n### Basic example\n\nTeleport content to a specific element in the DOM:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\">\n <div>This content will be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Positioning options\n\nTeleport content inside the target element, before its first child:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" position=\"afterbegin\">\n <div>Teleported content at the beginning.</div>\n </BaseTeleport>\n</template>\n```\n\n### Disabled Teleport\n\nPrevent teleporting the content:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" :disabled=\"true\">\n <div>This content will not be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Notes\n\n- When using the `onlychild` position, all other children of the target element will be hidden.\n- The component supports shadow DOM integration, automatically handling style injection. Anyway, Empathy's custom CSS\n injector is required. Teleport depends on it to add the styles.\n</docs>\n"],"names":[],"mappings":";;AAmBA,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;;AAEL,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA+B;AACpD,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;;;;AAOE;AACF,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,MAEL;AACD,YAAA,OAAO,EAAE,WAAW;AACrB,SAAA;;AAED,QAAA,QAAQ,EAAE;AACR,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;;AAED,QAAA,SAAS,EAAE,MAAgD;AAC5D,KAAA;AACD,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,IAAI,OAAO,QAAO,KAAM,WAAW,EAAE;AACnC,YAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAc,EAAE;QAC5C;AAEA,QAAA,MAAM,QAAO,GAAI,kBAAkB,EAAC;;AAEpC,QAAA,MAAM,YAAW,GAAI,GAAG,EAAc;;AAEtC,QAAA,MAAM,aAAY,GAAI,GAAG,EAAc;QACvC,IAAI,UAAS,G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C,CAAA;AACtF;;;;"}
1
+ {"version":3,"file":"base-teleport.vue2.js","sources":["../../../src/components/base-teleport.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"teleportHost\" :to=\"teleportHost.shadowRoot ?? teleportHost\" :disabled>\n <slot></slot>\n </Teleport>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport {\n defineComponent,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUnmounted,\n ref,\n watch,\n watchEffect,\n} from 'vue'\n\nexport default defineComponent({\n name: 'BaseTeleport',\n props: {\n /** The element or css selector to which the component will be teleported. */\n target: {\n type: [String, Object] as PropType<string | Element>,\n required: true,\n },\n /**\n * The position relative to the target\n * - `beforebegin`: Before the target element.\n * - `afterbegin`: Inside the target element, before its first child.\n * - `beforeend`: Inside the target element, after its last child.\n * - `afterend`: After the target element.\n * - `onlychild`: Adds it as child and hides all other children of the target element.\n */\n position: {\n type: String as PropType<\n 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'onlychild'\n >,\n default: 'onlychild',\n },\n /** If disabled, the slot content will not be teleported */\n disabled: {\n type: Boolean,\n default: false,\n },\n /** Styles for the teleport (content container) */\n hostStyle: Object as PropType<string | CSSStyleDeclaration>,\n },\n setup(props) {\n if (typeof document === 'undefined') {\n return { teleportHost: ref<HTMLElement>() }\n }\n\n const instance = getCurrentInstance()\n /** Hook where the slot content will be teleported to. */\n const teleportHost = ref<HTMLElement>()\n /** The page element where the teleport host will be inserted. */\n const targetElement = ref<HTMLElement>()\n let isIsolated = false\n\n // Before doing app.mount it is unknown if it will be mounted in a shadow so we need to wait.\n if (instance?.appContext.app._container) {\n createHost()\n } else {\n afterAppMount(createHost)\n }\n\n const targetAddedObserver = new MutationObserver(targetAdded)\n const targetRemovedObserver = new MutationObserver(targetRemoved)\n\n onUnmounted(() => {\n if (isIsolated && teleportHost.value) {\n ;(window as any).xCSSInjector.removeHost(teleportHost.value.shadowRoot)\n }\n })\n\n onBeforeUnmount(() => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n teleportHost.value?.remove()\n })\n\n // Handles target prop changes and init the observers accordingly.\n watch(\n () => props.target,\n newTarget => {\n targetAddedObserver.disconnect()\n targetRemovedObserver.disconnect()\n const target = typeof newTarget === 'string' ? document.querySelector(newTarget) : newTarget\n if (target?.isConnected) {\n targetAdded()\n } else {\n targetRemoved()\n }\n },\n { immediate: true },\n )\n\n // Updates the teleport host when props change.\n watchEffect(() => {\n if (!teleportHost.value) {\n return\n }\n if (props.disabled) {\n teleportHost.value.remove()\n return\n }\n teleportHost.value.className = `x-base-teleport x-base-teleport--${props.position}`\n\n if (!targetElement.value) {\n console.warn(`BaseTeleport: Target element \"${props.target}\" not found.`)\n return\n }\n const position = props.position === 'onlychild' ? 'beforeend' : props.position\n targetElement.value.insertAdjacentElement(position, teleportHost.value)\n\n if (props.position === 'onlychild') {\n targetElement.value.className += ' x-base-teleport-parent--onlychild'\n }\n })\n\n /* Update the host inline styles when it changes */\n watchEffect(() => {\n if (teleportHost.value && props.hostStyle) {\n if (typeof props.hostStyle === 'string') {\n teleportHost.value.style.cssText = props.hostStyle\n } else {\n Object.assign(teleportHost.value.style, props.hostStyle)\n }\n }\n })\n\n /** Checks if the target element exists in the DOM and updates the observers */\n function targetAdded() {\n let element: string | Element | null = props.target\n if (typeof element === 'string') {\n element = document.querySelector(element)\n }\n if (element instanceof HTMLElement && element.isConnected) {\n targetAddedObserver.disconnect()\n targetElement.value = element\n while (element.parentElement) {\n element = element.parentElement\n targetRemovedObserver.observe(element, { childList: true })\n }\n }\n }\n\n /** Checks if the target was disconnected from the DOM and updates the observers */\n function targetRemoved() {\n if (targetElement.value && !targetElement.value.isConnected) {\n targetRemovedObserver.disconnect()\n targetAddedObserver.observe(document.body, { childList: true, subtree: true })\n targetElement.value = undefined\n }\n }\n\n /** Creates and sets the teleport host element */\n function createHost() {\n teleportHost.value = document.createElement('div')\n isIsolated = instance?.appContext.app._container instanceof ShadowRoot\n if (isIsolated) {\n teleportHost.value.attachShadow({ mode: 'open' })\n ;(window as any).xCSSInjector.addHost(teleportHost.value.shadowRoot)\n }\n }\n\n function afterAppMount(fn: () => void) {\n onMounted(() => setTimeout(fn, 0))\n }\n\n return { teleportHost }\n },\n})\n\n/** Teleport host styles should be injected outside our shadowRoots */\nif (typeof document !== 'undefined') {\n const css = document.createElement('style')\n css.textContent = `.x-base-teleport-parent--onlychild > *:not(.x-base-teleport) { display: none; }`\n document.head?.appendChild(css) ||\n document.addEventListener('DOMContentLoaded', () => document.head.appendChild(css))\n}\n</script>\n\n<docs lang=\"mdx\">\n## Example\n\nThe BaseTeleport component allows you to teleport its slot content to a specified target element in\nthe DOM. It provides flexibility in positioning the content relative to the target element and\nsupports shadow DOM integration.\n\n### Basic example\n\nTeleport content to a specific element in the DOM:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\">\n <div>This content will be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Positioning options\n\nTeleport content inside the target element, before its first child:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" position=\"afterbegin\">\n <div>Teleported content at the beginning.</div>\n </BaseTeleport>\n</template>\n```\n\n### Disabled Teleport\n\nPrevent teleporting the content:\n\n```vue\n<template>\n <BaseTeleport target=\"#my-target\" :disabled=\"true\">\n <div>This content will not be teleported.</div>\n </BaseTeleport>\n</template>\n```\n\n### Notes\n\n- When using the `onlychild` position, all other children of the target element will be hidden.\n- The component supports shadow DOM integration, automatically handling style injection. Anyway, Empathy's custom CSS\n injector is required. Teleport depends on it to add the styles.\n</docs>\n"],"names":[],"mappings":";;AAmBA,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,KAAK,EAAE;;AAEL,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA+B;AACpD,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;;;;;AAOE;AACF,QAAA,QAA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K,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAA;gBAC9C,MAAc,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAA;YACrE;QACF;QAEA,SAAS,aAAa,CAAC,EAAc,EAAA;YACnC,SAAS,CAAC,MAAM,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACnC;QAEA,OAAO,EAAE,YAAW,EAAE;IACxB,CAAC;AACF,CAAA,CAAA;AAED;AACA,IAAI,OAAO,QAAO,KAAM,WAAW,EAAE;IACnC,MAAM,GAAE,GAAI,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAA;AAC1C,IAAA,GAAG,CAAC,WAAU,GAAI,CAAA,+EAAA,CAAgF;AAClG,IAAA,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG;AAC5B,QAAA,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;AACtF;;;;"}
@@ -1,52 +1,55 @@
1
1
  import _sfc_main from './base-result-image.vue2.js';
2
- import { openBlock, createElementBlock, normalizeStyle, createCommentVNode, createBlock, resolveDynamicComponent, withCtx, renderSlot } from 'vue';
2
+ import { openBlock, createElementBlock, mergeProps, createCommentVNode, createBlock, resolveDynamicComponent, withCtx, renderSlot } from 'vue';
3
3
  import './base-result-image.vue3.js';
4
4
  import _export_sfc from '../../_virtual/_plugin-vue_export-helper.js';
5
5
 
6
- const _hoisted_1 = ["src"];
7
- const _hoisted_2 = ["alt", "src"];
6
+ const _hoisted_1 = ["loading", "src", "srcset", "sizes"];
7
+ const _hoisted_2 = ["alt", "src", "srcset", "sizes"];
8
8
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9
9
  return openBlock(), createElementBlock(
10
10
  "div",
11
- {
11
+ mergeProps(_ctx.rootAttrs, {
12
12
  class: "x-result-picture xds:picture",
13
13
  "data-test": "result-picture",
14
14
  onMouseenterOnce: _cache[2] || (_cache[2] = ($event) => _ctx.userHasHoveredImage = true),
15
15
  onMouseenter: _cache[3] || (_cache[3] = ($event) => _ctx.isHovering = true),
16
16
  onMouseleave: _cache[4] || (_cache[4] = ($event) => _ctx.isHovering = false)
17
- },
17
+ }),
18
18
  [
19
- _ctx.shouldLoadNextImage ? (openBlock(), createElementBlock("img", {
20
- key: 0,
21
- loading: "lazy",
22
- src: _ctx.pendingImages[0],
23
- style: normalizeStyle(_ctx.loaderStyles),
19
+ _ctx.shouldLoadNextImage ? (openBlock(), createElementBlock("img", mergeProps({ key: 0 }, _ctx.imageAttrs, {
20
+ loading: _ctx.loading,
21
+ src: _ctx.pendingImages[0].src,
22
+ srcset: _ctx.pendingImages[0].srcset,
23
+ sizes: _ctx.sizes,
24
+ style: _ctx.loaderStyles,
24
25
  class: "xds:picture-image",
25
26
  "data-test": "result-picture-loader",
26
27
  alt: "",
27
28
  role: "presentation",
28
29
  onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.flagImageLoaded && _ctx.flagImageLoaded(...args)),
29
30
  onError: _cache[1] || (_cache[1] = (...args) => _ctx.flagImageAsFailed && _ctx.flagImageAsFailed(...args))
30
- }, null, 44, _hoisted_1)) : createCommentVNode("v-if", true),
31
+ }), null, 16, _hoisted_1)) : createCommentVNode("v-if", true),
31
32
  (openBlock(), createBlock(resolveDynamicComponent(_ctx.animation), {
32
33
  class: "xds:picture-image",
33
34
  appear: false
34
35
  }, {
35
36
  default: withCtx(() => [
36
- !_ctx.loadedImages.length && !_ctx.pendingImages.length ? renderSlot(_ctx.$slots, "fallback", {}, void 0, true, 0) : !_ctx.loadedImages.length ? renderSlot(_ctx.$slots, "placeholder", {}, void 0, true, 1) : (openBlock(), createElementBlock("img", {
37
+ !_ctx.loadedImages.length && !_ctx.pendingImages.length ? renderSlot(_ctx.$slots, "fallback", {}, void 0, true, 0) : !_ctx.loadedImages.length ? renderSlot(_ctx.$slots, "placeholder", {}, void 0, true, 1) : (openBlock(), createElementBlock("img", mergeProps({ key: 2 }, _ctx.imageAttrs, {
37
38
  key: _ctx.imageSrc,
38
39
  alt: _ctx.result.name,
39
40
  src: _ctx.imageSrc,
41
+ srcset: _ctx.imageSrcset,
42
+ sizes: _ctx.sizes,
40
43
  class: "x-result-picture-image",
41
44
  "data-test": "result-picture-image"
42
- }, null, 8, _hoisted_2))
45
+ }), null, 16, _hoisted_2))
43
46
  ]),
44
47
  _: 3
45
48
  /* FORWARDED */
46
49
  }))
47
50
  ],
48
- 32
49
- /* NEED_HYDRATION */
51
+ 16
52
+ /* FULL_PROPS */
50
53
  );
51
54
  }
52
55
  var baseResultImage = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-17531567"]]);
@@ -1 +1 @@
1
- {"version":3,"file":"base-result-image.vue.js","sources":["../../../../src/components/result/base-result-image.vue"],"sourcesContent":["<template>\n <!-- This is a div because using a picture causes the onload event of the image to fire twice. -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events -->\n <div\n class=\"x-result-picture xds:picture\"\n data-test=\"result-picture\"\n @mouseenter.once=\"userHasHoveredImage = true\"\n @mouseenter=\"isHovering = true\"\n @mouseleave=\"isHovering = false\"\n >\n <img\n v-if=\"shouldLoadNextImage\"\n loading=\"lazy\"\n :src=\"pendingImages[0]\"\n :style=\"loaderStyles\"\n class=\"xds:picture-image\"\n data-test=\"result-picture-loader\"\n alt=\"\"\n role=\"presentation\"\n @load=\"flagImageLoaded\"\n @error=\"flagImageAsFailed\"\n />\n <component :is=\"animation\" class=\"xds:picture-image\" :appear=\"false\">\n <!-- @slot Fallback image content. It will be rendered when all the images failed -->\n <slot v-if=\"!loadedImages.length && !pendingImages.length\" name=\"fallback\" />\n\n <!-- @slot Loading image content. It will be rendered while the real image is not loaded -->\n <slot v-else-if=\"!loadedImages.length\" name=\"placeholder\" />\n\n <img\n v-else\n :key=\"imageSrc\"\n :alt=\"result.name\"\n :src=\"imageSrc\"\n class=\"x-result-picture-image\"\n data-test=\"result-picture-image\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType, Ref, StyleValue } from 'vue'\nimport { computed, defineComponent, ref, watch } from 'vue'\nimport { AnimationProp } from '../../types'\nimport { NoAnimation } from '../animations'\n\n/**\n * Component to be reused that renders an `<img>`.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseResultImage',\n props: {\n /** (Required) The {@link @empathyco/x-types#Result} information. */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n */\n loadAnimation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /** Animation to use when switching between the loaded image and the hover image. */\n hoverAnimation: {\n type: AnimationProp,\n },\n /**\n * Indicates if the next valid image should be displayed on hover.\n *\n * @public\n */\n showNextImageOnHover: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n /**\n * Copy of the images of the result.\n *\n * It is used as a queue of images to load, once an image loads/fails to load, it is removed\n * from this array.\n *\n * @internal\n */\n const pendingImages: Ref<string[]> = ref([])\n\n /**\n * Contains the images that have been loaded successfully.\n *\n * @internal\n */\n const loadedImages: Ref<string[]> = ref([])\n\n /**\n * Indicates if the user is hovering the image.\n *\n * @internal\n */\n const isHovering = ref(false)\n\n /**\n * Indicates if the user has hovered the image.\n *\n * @internal\n */\n const userHasHoveredImage = ref(false)\n\n /**\n * Styles to use inline in the image loader, to prevent override from CSS\n *\n * @internal\n */\n const loaderStyles: StyleValue = {\n // csstype issue: https://github.com/frenic/csstype/issues/160\n position: 'absolute !important' as 'absolute',\n top: '0 !important' as '0',\n left: '0 !important' as '0',\n width: '100% !important' as '100%',\n height: '100% !important' as '100%',\n pointerEvents: 'none !important' as 'none',\n visibility: 'hidden !important' as 'hidden',\n }\n\n /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n () => props.result.images,\n () => {\n pendingImages.value = [...(props.result.images ?? [])]\n loadedImages.value = pendingImages.value.filter(image => loadedImages.value.includes(image))\n },\n { immediate: true },\n )\n\n /**\n * Animation to be used.\n *\n * @returns The animation to be used, taking into account if the user has hovered the image.\n *\n * @internal\n */\n const animation = computed(() => {\n return userHasHoveredImage.value\n ? (props.hoverAnimation ?? props.loadAnimation)\n : props.loadAnimation\n })\n\n /**\n * Gets the src from the result image.\n *\n * @returns The result image src.\n *\n * @internal\n */\n const imageSrc = computed(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering.value ? 0 : loadedImages.value.length - 1\n ]\n })\n\n /**\n * Indicates if the loader should try to load the next image.\n *\n * @returns True if it should try to load the next image.\n *\n * @internal\n */\n const shouldLoadNextImage = computed(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage.value ? 2 : 1\n return !!pendingImages.value.length && loadedImages.value.length < numImagesToLoad\n })\n\n /**\n * Sets an image as failed.\n *\n * @internal\n */\n const flagImageAsFailed = () => {\n pendingImages.value.shift()\n }\n\n /**\n * Sets an image as loaded.\n *\n * @internal\n */\n const flagImageLoaded = () => {\n const image = pendingImages.value.shift()\n if (image) {\n loadedImages.value.push(image)\n }\n }\n\n return {\n pendingImages,\n loadedImages,\n isHovering,\n userHasHoveredImage,\n loaderStyles,\n animation,\n imageSrc,\n shouldLoadNextImage,\n flagImageAsFailed,\n flagImageLoaded,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-picture {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n}\n\n.x-result-picture-image {\n max-width: 100%;\n max-height: 100%;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component is for the result image. It may be part of the search result page, recommendations or\nother section which needs to include results.\n\nThe result prop is required. It will render a `<img/>` with the result image:\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\n</script>\n```\n\n### Showing the next image on hover\n\nIf a result has multiple images, it can show the next one on hover.\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" showNextImageOnHover />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg', 'https://some-image-url.com/image2.jpg'],\n}\n</script>\n```\n\n### Customizing slots content\n\nFallback and placeholder contents can be customized.\n\nThe fallback slot allows you to replace the content of the fallback image.\n\nThe other slot is called `placeholder`, and allows you to set the image that its going to be\ndisplayed while the real one is loaded.\n\n```vue\n<template>\n <BaseResultImage :result=\"result\">\n <template #placeholder>\n <img alt=\"Placeholder image\" src=\"./placeholder-image.svg\" />\n </template>\n <template #fallback>\n <img alt=\"Fallback image\" src=\"./fallback-image.svg\" />\n </template>\n </BaseResultImage>\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\n</script>\n```\n\n### Customizing the animations\n\nTwo animations can be used in this component.\n\nThe `loadAnimation` is used to transition between the placeholder, the fallback and the image.\n\nThe `hoverAnimation` is used to transition between the image and the hover image, if the\n`showNextImageOnHover` prop is `true`.\n\n`hoverAnimation` will default to `loadAnimation` if it is not provided.\n\n```vue\n<template>\n <BaseResultImage\n :result=\"result\"\n :loadAnimation=\"loadAnimation\"\n :hoverAnimation=\"hoverAnimation\"\n showNextImageOnHover\n />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nimport { CrossFade, CollapseHeight } from '@empathyco/x-components/animations'\nconst loadAnimation = CrossFade\nconst hoverAnimation = CollapseHeight\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg', 'https://some-image-url.com/image2.jpg'],\n}\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_normalizeStyle","_createCommentVNode","_createBl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AAC,kBAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AAEV,OAAAH,SAAA,EAAA,EAAAI,WAAA,CAeYC,wBAfI,IAAA,CAAA,SAAS,CAAA,EAAA;AAAA,QAAE,KAAA,EAAM,mBAAA;AAAA,QAAqB,MAAA,EAAQ;AAAA,OAAA,EAAA;yBAE5D,MAA6E;AAAA,UAAA,CAAhE,IAAA,CAAA,YAAA,CAAa,MAAA,IAAM,CAAK,IAAA,CAAA,aAAA,CAAc,MAAA,GAAnDC,UAAA,CAA6E,IAAA,CAAA,MAAA,EAAA,UAAA,EAAA,EAAA,EAAA,MAAA,EAAA,IAAA,EAAA,CAAA,CAAA,GAAA,CAG3D,IAAA,CAAA,YAAA,CAAa,MAAA,GAA/BA,UAAA,CAA4D,IAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,EAAA,MAAA,EAAA,IAAA,EAAA,CAAA,CAAA,IAAAN,SAAA,EAAA,EAE5DC,kBAAA,CAOE,KAAA,EAAA;AAAA,YALC,GAAA,EAAK,IAAA,CAAA,QAAA;AAAA,YACL,KAAK,IAAA,CAAA,MAAA,CAAO,IAAA;AAAA,YACZ,GAAA,EAAK,IAAA,CAAA,QAAA;AAAA,YACN,KAAA,EAAM,wBAAA;AAAA,YACN,WAAA,EAAU;AAAA,WAAA,EAAA,IAAA,EAAA,CAAA,EAAA,UAAA,CAAA;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-result-image.vue.js","sources":["../../../../src/components/result/base-result-image.vue"],"sourcesContent":["<template>\n <!-- This is a div because using a picture causes the onload event of the image to fire twice. -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events -->\n <div\n v-bind=\"rootAttrs\"\n class=\"x-result-picture xds:picture\"\n data-test=\"result-picture\"\n @mouseenter.once=\"userHasHoveredImage = true\"\n @mouseenter=\"isHovering = true\"\n @mouseleave=\"isHovering = false\"\n >\n <img\n v-if=\"shouldLoadNextImage\"\n v-bind=\"imageAttrs\"\n :loading=\"loading\"\n :src=\"pendingImages[0].src\"\n :srcset=\"pendingImages[0].srcset\"\n :sizes=\"sizes\"\n :style=\"loaderStyles\"\n class=\"xds:picture-image\"\n data-test=\"result-picture-loader\"\n alt=\"\"\n role=\"presentation\"\n @load=\"flagImageLoaded\"\n @error=\"flagImageAsFailed\"\n />\n <component :is=\"animation\" class=\"xds:picture-image\" :appear=\"false\">\n <!-- @slot Fallback image content. It will be rendered when all the images failed -->\n <slot v-if=\"!loadedImages.length && !pendingImages.length\" name=\"fallback\" />\n\n <!-- @slot Loading image content. It will be rendered while the real image is not loaded -->\n <slot v-else-if=\"!loadedImages.length\" name=\"placeholder\" />\n\n <img\n v-else\n v-bind=\"imageAttrs\"\n :key=\"imageSrc\"\n :alt=\"result.name\"\n :src=\"imageSrc\"\n :srcset=\"imageSrcset\"\n :sizes=\"sizes\"\n class=\"x-result-picture-image\"\n data-test=\"result-picture-image\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport type { Result } from '@empathyco/x-types'\nimport type { PropType, Ref, StyleValue } from 'vue'\nimport { computed, defineComponent, ref, useAttrs, watch } from 'vue'\n\nimport { AnimationProp } from '../../types'\nimport { NoAnimation } from '../animations'\n\n/**\n * An entry of the images queue: the image `src` and its optional `srcset`.\n *\n * @internal\n */\ninterface ImageEntry {\n /** Index of the image inside `result.images`. */\n index: number\n /** The image URL. */\n src: string\n /** Responsive candidates for the image, if provided. */\n srcset?: string\n}\n\n/**\n * Component to be reused that renders an `<img>`.\n *\n * Additional `<img>` attributes passed to the component (e.g. `decoding`, `crossorigin`,\n * `referrerpolicy`, `fetchpriority`, `width` and `height`) are forwarded to the rendered\n * images, while `class`, `style` and event listeners keep falling through to the root\n * element, as before. Use the `imageLoaded` and `imageError` events to observe the image\n * loading state.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseResultImage',\n inheritAttrs: false,\n props: {\n /** (Required) The {@link @empathyco/x-types#Result} information. */\n result: {\n type: Object as PropType<Result>,\n required: true,\n },\n /**\n * Animation to use when switching between the placeholder, the loaded image, or the failed\n * image fallback.\n */\n loadAnimation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /** Animation to use when switching between the loaded image and the hover image. */\n hoverAnimation: {\n type: AnimationProp,\n },\n /**\n * Indicates if the next valid image should be displayed on hover.\n *\n * @public\n */\n showNextImageOnHover: {\n type: Boolean,\n default: false,\n },\n /**\n * Responsive image candidates (`srcset`).\n *\n * - A single string is applied to every image of the result (e.g.\n * `\"image-480.jpg 480w, image-1024.jpg 1024w\"`).\n * - An array is parallel to `result.images`, so each image can have its own candidates.\n *\n * When provided, the `src` is kept as a fallback for browsers without `srcset` support.\n *\n * @public\n */\n srcset: {\n type: [String, Array] as PropType<string | (string | undefined)[]>,\n },\n /**\n * The sizes of the image for different page layouts (`sizes`).\n *\n * It is shared by all the images of the result, since it depends on the layout and not on\n * the image. Pass it together with `srcset`, since it is ignored otherwise.\n *\n * @public\n */\n sizes: {\n type: String,\n },\n /**\n * Image loading mode.\n *\n * @public\n */\n loading: {\n type: String as PropType<'lazy' | 'eager'>,\n default: 'lazy',\n },\n },\n emits: ['imageLoaded', 'imageError'],\n setup(props, { emit }) {\n const attrs = useAttrs()\n\n /**\n * Additional `<img>` attributes passed to the component (e.g. `decoding`,\n * `crossorigin`, `fetchpriority`, `width`, `height`), forwarded to the rendered images.\n *\n * Event listeners are excluded so they don't reach the hidden loader: they keep\n * falling through to the root element, and the image loading state is exposed through\n * the `imageLoaded` and `imageError` events.\n *\n * @internal\n */\n const imageAttrs = computed(() =>\n Object.fromEntries(Object.entries(attrs).filter(([key]) => !key.startsWith('on'))),\n )\n\n /**\n * The consumer's `class`, `style` and event listeners, applied to the root element.\n *\n * The component uses `inheritAttrs: false` so the remaining attributes (e.g.\n * `decoding`, `crossorigin`, `fetchpriority`, `width`, `height`) only reach the\n * rendered images through `imageAttrs` and don't leak to the wrapper div.\n *\n * @internal\n */\n const rootAttrs = computed(() => ({\n class: attrs.class,\n style: attrs.style,\n ...Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith('on'))),\n }))\n\n /**\n * Copy of the images of the result.\n *\n * It is used as a queue of images to load, once an image loads/fails to load, it is removed\n * from this array.\n *\n * @internal\n */\n const pendingImages: Ref<ImageEntry[]> = ref([])\n\n /**\n * Contains the images that have been loaded successfully.\n *\n * @internal\n */\n const loadedImages: Ref<ImageEntry[]> = ref([])\n\n /**\n * Indicates if the user is hovering the image.\n *\n * @internal\n */\n const isHovering = ref(false)\n\n /**\n * Indicates if the user has hovered the image.\n *\n * @internal\n */\n const userHasHoveredImage = ref(false)\n\n /**\n * Styles to use inline in the image loader, to prevent override from CSS\n *\n * @internal\n */\n const loaderStyles: StyleValue = {\n // csstype issue: https://github.com/frenic/csstype/issues/160\n position: 'absolute !important' as 'absolute',\n top: '0 !important' as '0',\n left: '0 !important' as '0',\n width: '100% !important' as '100%',\n height: '100% !important' as '100%',\n pointerEvents: 'none !important' as 'none',\n visibility: 'hidden !important' as 'hidden',\n }\n\n /**\n * Resolves the `srcset` to use for the image at the given index.\n *\n * @param index - Index of the image inside `result.images`.\n *\n * @returns The `srcset` for that image, if any.\n *\n * @internal\n */\n const resolveSrcset = (index: number): string | undefined =>\n Array.isArray(props.srcset) ? props.srcset[index] : props.srcset\n\n /**\n * Initializes images state and resets when the result's images change.\n *\n * @internal\n */\n watch(\n () => props.result.images,\n () => {\n pendingImages.value = (props.result.images ?? []).map((src, index) => ({\n index,\n src,\n srcset: resolveSrcset(index),\n }))\n loadedImages.value = pendingImages.value.filter(image =>\n loadedImages.value.some(loadedImage => loadedImage.src === image.src),\n )\n },\n { immediate: true },\n )\n\n /**\n * Animation to be used.\n *\n * @returns The animation to be used, taking into account if the user has hovered the image.\n *\n * @internal\n */\n const animation = computed(() => {\n return userHasHoveredImage.value\n ? (props.hoverAnimation ?? props.loadAnimation)\n : props.loadAnimation\n })\n\n /**\n * Gets the currently loaded image.\n *\n * @returns The currently loaded image entry, or undefined if none has been loaded.\n *\n * @internal\n */\n const currentImage = computed(() => {\n return loadedImages.value[\n !props.showNextImageOnHover || !isHovering.value ? 0 : loadedImages.value.length - 1\n ]\n })\n\n /**\n * Gets the src of the currently loaded image.\n *\n * @returns The current image src.\n *\n * @internal\n */\n const imageSrc = computed(() => currentImage.value?.src)\n\n /**\n * Gets the srcset of the currently loaded image.\n *\n * @returns The current image srcset, if any.\n *\n * @internal\n */\n const imageSrcset = computed(() => currentImage.value?.srcset)\n\n /**\n * Indicates if the loader should try to load the next image.\n *\n * @returns True if it should try to load the next image.\n *\n * @internal\n */\n const shouldLoadNextImage = computed(() => {\n const numImagesToLoad = props.showNextImageOnHover && userHasHoveredImage.value ? 2 : 1\n return !!pendingImages.value.length && loadedImages.value.length < numImagesToLoad\n })\n\n /**\n * Sets an image as failed.\n *\n * @param event - The error event of the loader image.\n *\n * @internal\n */\n const flagImageAsFailed = () => {\n const image = pendingImages.value.shift()\n if (image) {\n emit('imageError', { index: image.index, src: image.src, srcset: image.srcset })\n }\n }\n\n /**\n * Sets an image as loaded.\n *\n * @param event - The load event of the loader image.\n *\n * @internal\n */\n const flagImageLoaded = (event: Event) => {\n const image = pendingImages.value.shift()\n if (image) {\n loadedImages.value.push(image)\n const element = event.target as HTMLImageElement\n emit('imageLoaded', {\n index: image.index,\n src: image.src,\n srcset: image.srcset,\n currentSrc: element.currentSrc || image.src,\n element,\n })\n }\n }\n\n return {\n imageAttrs,\n rootAttrs,\n pendingImages,\n loadedImages,\n isHovering,\n userHasHoveredImage,\n loaderStyles,\n animation,\n imageSrc,\n imageSrcset,\n shouldLoadNextImage,\n flagImageAsFailed,\n flagImageLoaded,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-result-picture {\n position: relative;\n min-width: 1px;\n min-height: 1px;\n}\n\n.x-result-picture-image {\n max-width: 100%;\n max-height: 100%;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThis component is for the result image. It may be part of the search result page, recommendations or\nother section which needs to include results.\n\nThe result prop is required. It will render a `<img/>` with the result image:\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\n</script>\n```\n\n### Responsive images with `srcset` and `sizes`\n\nThe `srcset` and `sizes` props are used to deliver the right image candidate according to the\ndevice and the layout (like the native `<img>` attributes).\n\n`srcset` can be a single string, applied to all the images of the result, or an array parallel to\n`result.images`, so each image can have its own candidates.\n\n```vue\n<template>\n <BaseResultImage\n :result=\"result\"\n srcset=\"image1-480.jpg?width=400 480w, image1-1024.jpg?width=1024 1024w\"\n sizes=\"(min-width: 600px) 33vw, 100vw\"\n />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\n</script>\n```\n\nThe `src` of the image is always kept, so it works as a fallback when `srcset` is not supported.\n\n### Showing the next image on hover\n\nIf a result has multiple images, it can show the next one on hover.\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" showNextImageOnHover />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg', 'https://some-image-url.com/image2.jpg'],\n}\n</script>\n```\n\n### Customizing slots content\n\nFallback and placeholder contents can be customized.\n\nThe fallback slot allows you to replace the content of the fallback image.\n\nThe other slot is called `placeholder`, and allows you to set the image that its going to be\ndisplayed while the real one is loaded.\n\n```vue\n<template>\n <BaseResultImage :result=\"result\">\n <template #placeholder>\n <img alt=\"Placeholder image\" src=\"./placeholder-image.svg\" />\n </template>\n <template #fallback>\n <img alt=\"Fallback image\" src=\"./fallback-image.svg\" />\n </template>\n </BaseResultImage>\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\n</script>\n```\n\n### Customizing the animations\n\nTwo animations can be used in this component.\n\nThe `loadAnimation` is used to transition between the placeholder, the fallback and the image.\n\nThe `hoverAnimation` is used to transition between the image and the hover image, if the\n`showNextImageOnHover` prop is `true`.\n\n`hoverAnimation` will default to `loadAnimation` if it is not provided.\n\n```vue\n<template>\n <BaseResultImage\n :result=\"result\"\n :loadAnimation=\"loadAnimation\"\n :hoverAnimation=\"hoverAnimation\"\n showNextImageOnHover\n />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nimport { CrossFade, CollapseHeight } from '@empathyco/x-components/animations'\nconst loadAnimation = CrossFade\nconst hoverAnimation = CollapseHeight\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg', 'https://some-image-url.com/image2.jpg'],\n}\n</script>\n```\n\n### Optimizing the first result for LCP\n\nBy default, images are loaded lazily. For the first (above-the-fold) result of the search results\npage, the image is usually the **Largest Contentful Paint (LCP)** element: eager-loading it with\na high fetch priority avoids waiting for the lazy-load viewport check and lets the browser start\nthe request immediately.\n\nCombine it with `width` and `height` so the browser can prioritize and reserve the space of the\nLCP element from the start:\n\n```vue\n<template>\n <!-- First, above-the-fold result -->\n <BaseResultImage\n :result=\"firstResult\"\n loading=\"eager\"\n fetchPriority=\"high\"\n :width=\"256\"\n :height=\"371\"\n />\n <!-- All the remaining results keep the default lazy loading -->\n <BaseResultImage v-for=\"result in otherResults\" :key=\"result.id\" :result=\"result\" />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\n</script>\n```\n\nOnly the above-the-fold results should use `loading=\"eager\"`; keep the rest lazy to avoid\nrequesting more images than needed.\n\n### Avoiding layout shift (CLS)\n\nPassing `width` and `height` (the intrinsic dimensions of the image) helps the browser reserve\nthe right space before the image is loaded, preventing the layout shift caused by the image\nreplacing the placeholder.\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" :width=\"256\" :height=\"371\" />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\n</script>\n```\n\n### Passing additional image attributes\n\nAny additional `<img>` attribute passed to the component is forwarded to the rendered images\n(the hidden preload image and the visible one), so there is no need for a specific prop per\nattribute:\n\n```vue\n<template>\n <BaseResultImage\n :result=\"result\"\n decoding=\"async\"\n crossorigin=\"anonymous\"\n fetchpriority=\"high\"\n referrerpolicy=\"no-referrer\"\n :width=\"256\"\n :height=\"371\"\n />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\n</script>\n```\n\n`class`, `style` and event listeners keep being applied to the root element, so the wrapper\ncan still be styled and listened to. Any other additional attribute is only applied to the\nrendered images, never to the wrapper div. Observe the image loading state with the\n`imageLoaded` and `imageError` events instead.\n\n### Image loading events\n\nThe component emits `imageLoaded` when an image finishes loading, and `imageError` when an image\nfails to load (the next one of the queue will be tried).\n\n```vue\n<template>\n <BaseResultImage :result=\"result\" @imageLoaded=\"imageLoaded\" @imageError=\"imageError\" />\n</template>\n\n<script setup>\nimport { BaseResultImage } from '@empathyco/x-components'\nconst result = {\n name: 'Jacket',\n images: ['https://some-image-url.com/image1.jpg'],\n}\nconst imageLoaded = ({ index, src, currentSrc }) => {\n // For example, track the candidate actually downloaded by the browser\n console.log(`Image ${index} loaded: ${src} (downloaded ${currentSrc})`)\n}\nconst imageError = ({ index, src }) => {\n console.log(`Image ${index} failed: ${src}`)\n}\n</script>\n```\n</docs>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_createCommentVNode","_createBlock","_resolveDynamicComponent","_renderSlot"],"mappings":";;;;;;;;AAGE,EAAA,OAAAA,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA0CM,KAAA;AAAA,IA1CNC,UAAA,CA0CM,KAzCI,SAAA,EAAS;AAAA,MACjB,KAAA,EAAM,8BAAA;AAAA,MACN,WAAA,EAAU,gBAAA;AAAA,MAAA,gBAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAA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