@empathyco/x-components 10.7.0 → 10.8.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,20 @@
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.8.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.8.0) (2026-11-12)
7
+
8
+ ### Features
9
+
10
+ * **base-modal:** add scrollLock prop to control page scroll behavior (#2200)
11
+ * **search:** add priceFacetId to SearchConfig and update request accordingly (#2194)
12
+ * **x-components:** add responsive image props and loading events to BaseResultImage (#2195)
13
+
14
+ ### Bug Fixes
15
+
16
+ * change CSS selector for only child teleport (#2197)
17
+ * remove parent selector when BaseTeleport is unmounted (#2198)
18
+
19
+
6
20
  ## [10.7.0](https://github.com/empathyco/x/compare/@empathyco/x-components@10.3.0...@empathyco/x-components@10.7.0) (2026-11-10)
7
21
 
8
22
  ### Features
@@ -27,6 +27,10 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
27
27
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
28
28
  default: () => import("vue").DefineComponent<{}, {}, any>;
29
29
  };
30
+ scrollLock: {
31
+ type: BooleanConstructor;
32
+ default: boolean;
33
+ };
30
34
  contentClass: StringConstructor;
31
35
  overlayClass: StringConstructor;
32
36
  }>, {
@@ -55,6 +59,10 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
55
59
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
56
60
  default: () => import("vue").DefineComponent<{}, {}, any>;
57
61
  };
62
+ scrollLock: {
63
+ type: BooleanConstructor;
64
+ default: boolean;
65
+ };
58
66
  contentClass: StringConstructor;
59
67
  overlayClass: StringConstructor;
60
68
  }>> & Readonly<{
@@ -64,5 +72,6 @@ _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
64
72
  focusOnOpen: boolean;
65
73
  animation: string | Function | Record<string, any>;
66
74
  overlayAnimation: string | Function | Record<string, any>;
75
+ scrollLock: boolean;
67
76
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>
68
77
  ```
@@ -11,15 +11,16 @@ complex modals.
11
11
 
12
12
  ## Props
13
13
 
14
- | Name | Description | Type | Default |
15
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------ |
16
- | <code>open</code> | Determines if the modal is open or not. | <code>boolean</code> | <code></code> |
17
- | <code>focusOnOpen</code> | Determines if the focused element changes to one inside the modal when it opens. Either the<br />first element with a positive tabindex or just the first focusable element. | <code>boolean</code> | <code>true</code> |
18
- | <code>referenceSelector</code> | The reference selector of a DOM element to use as reference to position the modal.<br />This selector can be an ID or a class, if it is a class, it will use the first<br />element that matches. | <code>string</code> | <code></code> |
19
- | <code>animation</code> | Animation to use for opening/closing the modal.This animation only affects the content. | <code>AnimationProp</code> | <code>() => NoAnimation</code> |
20
- | <code>overlayAnimation</code> | Animation to use for the overlay (backdrop) part of the modal. By default, it uses<br />a fade transition. | <code>AnimationProp</code> | <code>() => Fade</code> |
21
- | <code>contentClass</code> | Class inherited by content element. | <code>string</code> | <code></code> |
22
- | <code>overlayClass</code> | Class inherited by overlay element. | <code>string</code> | <code></code> |
14
+ | Name | Description | Type | Default |
15
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------ |
16
+ | <code>open</code> | Determines if the modal is open or not. | <code>boolean</code> | <code></code> |
17
+ | <code>focusOnOpen</code> | Determines if the focused element changes to one inside the modal when it opens. Either the<br />first element with a positive tabindex or just the first focusable element. | <code>boolean</code> | <code>true</code> |
18
+ | <code>referenceSelector</code> | The reference selector of a DOM element to use as reference to position the modal.<br />This selector can be an ID or a class, if it is a class, it will use the first<br />element that matches. | <code>string</code> | <code></code> |
19
+ | <code>animation</code> | Animation to use for opening/closing the modal.This animation only affects the content. | <code>AnimationProp</code> | <code>() => NoAnimation</code> |
20
+ | <code>overlayAnimation</code> | Animation to use for the overlay (backdrop) part of the modal. By default, it uses<br />a fade transition. | <code>AnimationProp</code> | <code>() => Fade</code> |
21
+ | <code>scrollLock</code> | Determines if the scroll of the body and the window is disabled while the modal is open.<br />Set it to `false` for modals that must not lock the page scroll. It can be toggled while the<br />modal is open. | <code>boolean</code> | <code>true</code> |
22
+ | <code>contentClass</code> | Class inherited by content element. | <code>string</code> | <code></code> |
23
+ | <code>overlayClass</code> | Class inherited by overlay element. | <code>string</code> | <code></code> |
23
24
 
24
25
  ## Events
25
26
 
@@ -131,6 +132,18 @@ const fadeAndSlide = FadeAndSlide;
131
132
  </script>
132
133
  ```
133
134
 
135
+ #### Not locking the page scroll
136
+
137
+ By default (`scrollLock` is `true`) the modal sets `overflow: hidden` on the `body` and `html`
138
+ elements while it is open, and restores them when it closes. Set the `scrollLock` prop to `false`
139
+ to keep the page scrollable. The prop can be toggled while the modal is open.
140
+
141
+ ```vue
142
+ <BaseModal :open="open" :scroll-lock="false">
143
+ <p>The page behind can still be scrolled.</p>
144
+ </BaseModal>
145
+ ```
146
+
134
147
  ## Vue Events
135
148
 
136
149
  A list of events that the component will emit:
@@ -1 +1 @@
1
- {"version":3,"file":"base-modal.vue.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n :aria-label=\"ariaLabels?.modal\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useAccessibilityLabels, useDebounce } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n const ariaLabels = useAccessibilityLabels('baseModal')\n\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n ariaLabels,\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["_withDirectives","_openBlock","_createElementBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_renderSlot","_createCommentVNode","_withCtx","_vShow"],"mappings":";;;;;;EAC0C,GAAA,EAAI,UAAA;AAAA,EAAW,KAAA,EAAM,SAAA;AAAA,EAAU,WAAA,EAAU;;;;AAAjF,EAAA,OAAAA,cAAA,EAAAC,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA6BM,KAAA;AAAA,IA7BN,UAAA;AAAA,IA6BM;AAAA,OAAAD,SAAA,EAAA,EA5BJE,WAAA;AAAA,QAiBYC,wBAhBL,IAAA,CAAA,SAAS,CAAA;AAAA,QAAA;AAAA,UACb,aAAA,EAAY,sCAAE,IAAA,CAAA,iBAAA,GAAiB,IAAA,CAAA;AAAA,UAC/B,YAAA,EAAW,sCAAE,IAAA,CAAA,iBAAA,GAAiB,KAAA;AAAA,SAAA;;2BAE/B,MAWM;AAAA,YAVE,0BADRF,kBAAA,CAWM,KAAA,EAAA;AAAA,cAAA,GAAA,EAAA,CAAA;cATJ,GAAA,EAAI,iBAAA;AAAA,cACJ,KAAA,EAAKG,cAAA,CAAA,CAAC,kBAAA,EAGE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,cAFpB,WAAA,EAAU,eAAA;AAAA,cACV,IAAA,EAAK,QAAA;AAAA,cAEJ,cAAY,IAAA,CAAA,UAAA,EAAY;AAAA,aAAA,EAAA;cAGzBC,UAAA,CAAQ,IAAA,CAAA,MAAA,EAAA,SAAA,EAAA,EAAA,EAAA,MAAA,EAAA,IAAA;AAAA,aAAA,EAAA,EAAA,EAAA,UAAA,CAAA,IAAAC,kBAAA,CAAA,MAAA,EAAA,IAAA;;;;;;;;AAGZ,OAAAN,SAAA,EAAA,EAAAE,WAAA,CASYC,wBATI,IAAA,CAAA,gBAAgB,CAAA,EAAA,IAAA,EAAA;AAAA,QAAA,OAAA,EAAAI,OAAA,CAC9B,MAOE;AAAA,UANM,IAAA,CAAA,IAAA,IAAAP,SAAA,EAAA,EADRC,kBAAA;AAAA,YAOE,KAAA;AAAA,YAAA;AAAA,cAAA,GAAA,EAAA,CAAA;cALA,KAAA,EAAKG,cAAA,CAAA,CAAC,oBACE,IAAA,CAAA,YAAY,CAAA,CAAA;AAAA,cACpB,WAAA,EAAU,eAAA;AAAA,cACT,SAAK,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,cACP,WAAO,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;AAAA,aAAA;;;;;;;;;;;;;AA1BH,IAAA,CAAAI,KAAA,EAAA,IAAA,CAAA,iBAAA,IAAqB,IAAA,CAAA,IAAI;AAAA,GAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"base-modal.vue.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n :aria-label=\"ariaLabels?.modal\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useAccessibilityLabels, useDebounce } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /**\n * Determines if the scroll of the body and the window is disabled while the modal is open.\n * Set it to `false` for modals that must not lock the page scroll. It can be toggled while the\n * modal is open.\n */\n scrollLock: {\n type: Boolean,\n default: true,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n const ariaLabels = useAccessibilityLabels('baseModal')\n\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Whether this modal is currently holding the scroll lock, so it only restores what it set. */\n let isScrollDisabled = false\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n if (!props.scrollLock || isScrollDisabled) {\n return\n }\n isScrollDisabled = true\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n if (!isScrollDisabled) {\n return\n }\n isScrollDisabled = false\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n watch(\n () => props.scrollLock,\n shouldLockScroll => {\n if (props.open) {\n shouldLockScroll ? disableScroll() : enableScroll()\n }\n },\n )\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n ariaLabels,\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Not locking the page scroll\n\nBy default (`scrollLock` is `true`) the modal sets `overflow: hidden` on the `body` and `html`\nelements while it is open, and restores them when it closes. Set the `scrollLock` prop to `false`\nto keep the page scrollable. The prop can be toggled while the modal is open.\n\n```vue\n<BaseModal :open=\"open\" :scroll-lock=\"false\">\n <p>The page behind can still be scrolled.</p>\n</BaseModal>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["_withDirectives","_openBlock","_createElementBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_renderSlot","_createCommentVNode","_withCtx","_vShow"],"mappings":";;;;;;EAC0C,GAAA,EAAI,UAAA;AAAA,EAAW,KAAA,EAAM,SAAA;AAAA,EAAU,WAAA,EAAU;;;;AAAjF,EAAA,OAAAA,cAAA,EAAAC,SAAA,EAAA,EAAAC,kBAAA;AAAA,IA6BM,KAAA;AAAA,IA7BN,UAAA;AAAA,IA6BM;AAAA,OAAAD,SAAA,EAAA,EA5BJE,WAAA;AAAA,QAiBYC,wBAhBL,IAAA,CAAA,SAAS,CAAA;AAAA,QAAA;AAAA,UACb,aAAA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AA,CAAA,GAAA,CAAA,GAAA,IAAA,KAAE,IAAA,CAAA,kBAAA,IAAA,IAAA,CAAA,kBAAA,CAAA,GAAA,IAAA,CAAA;AAAA,aAAA;;;;;;;;;;;;;AA1BH,IAAA,CAAAI,KAAA,EAAA,IAAA,CAAA,iBAAA,IAAqB,IAAA,CAAA,IAAI;AAAA,GAAA,CAAA;;;;;;"}
@@ -73,6 +73,15 @@ var _sfc_main = defineComponent({
73
73
  type: AnimationProp,
74
74
  default: () => Fade,
75
75
  },
76
+ /**
77
+ * Determines if the scroll of the body and the window is disabled while the modal is open.
78
+ * Set it to `false` for modals that must not lock the page scroll. It can be toggled while the
79
+ * modal is open.
80
+ */
81
+ scrollLock: {
82
+ type: Boolean,
83
+ default: true,
84
+ },
76
85
  /** Class inherited by content element. */
77
86
  contentClass: String,
78
87
  /** Class inherited by overlay element. */
@@ -93,14 +102,24 @@ var _sfc_main = defineComponent({
93
102
  const isWaitingForLeave = ref(false);
94
103
  /** The reference element to use to find the modal's position. */
95
104
  let referenceElement;
105
+ /** Whether this modal is currently holding the scroll lock, so it only restores what it set. */
106
+ let isScrollDisabled = false;
96
107
  /** Disables the scroll of both the body and the window. */
97
108
  function disableScroll() {
109
+ if (!props.scrollLock || isScrollDisabled) {
110
+ return;
111
+ }
112
+ isScrollDisabled = true;
98
113
  previousBodyOverflow.value = document.body.style.overflow;
99
114
  previousHTMLOverflow.value = document.documentElement.style.overflow;
100
115
  document.body.style.overflow = document.documentElement.style.overflow = 'hidden';
101
116
  }
102
117
  /** Restores the scroll of both the body and the window. */
103
118
  function enableScroll() {
119
+ if (!isScrollDisabled) {
120
+ return;
121
+ }
122
+ isScrollDisabled = false;
104
123
  document.body.style.overflow = previousBodyOverflow.value;
105
124
  document.documentElement.style.overflow = previousHTMLOverflow.value;
106
125
  }
@@ -186,6 +205,11 @@ var _sfc_main = defineComponent({
186
205
  let resizeObserver;
187
206
  onMounted(() => {
188
207
  watch(() => props.open, syncBody);
208
+ watch(() => props.scrollLock, shouldLockScroll => {
209
+ if (props.open) {
210
+ shouldLockScroll ? disableScroll() : enableScroll();
211
+ }
212
+ });
189
213
  if (props.open) {
190
214
  syncBody(true);
191
215
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-modal.vue2.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n :aria-label=\"ariaLabels?.modal\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useAccessibilityLabels, useDebounce } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n const ariaLabels = useAccessibilityLabels('baseModal')\n\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n ariaLabels,\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["NoAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,KAAK,EAAE;;AAEL,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;AAGE;AACF,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;AAIE;AACF,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,E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BAAA,mBAAmB,EAAC;AACpB,gBAAA,YAAY,EAAC;YACf;YACA,cAAc,CAAC,UAAU,EAAC;AAC5B,QAAA,CAAC,CAAA;QAED,OAAO;YACL,UAAU;YACV,kBAAkB;YAClB,iBAAiB;YACjB,eAAe;YACf,QAAQ;SACV;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"base-modal.vue2.js","sources":["../../../../src/components/modals/base-modal.vue"],"sourcesContent":["<template>\n <div v-show=\"isWaitingForLeave || open\" ref=\"modalRef\" class=\"x-modal\" data-test=\"modal\">\n <component\n :is=\"animation\"\n @before-leave=\"isWaitingForLeave = true\"\n @after-leave=\"isWaitingForLeave = false\"\n >\n <div\n v-if=\"open\"\n ref=\"modalContentRef\"\n class=\"x-modal__content\"\n data-test=\"modal-content\"\n role=\"dialog\"\n :class=\"contentClass\"\n :aria-label=\"ariaLabels?.modal\"\n >\n <!-- @slot (Required) Modal container content -->\n <slot />\n </div>\n </component>\n <component :is=\"overlayAnimation\">\n <div\n v-if=\"open\"\n class=\"x-modal__overlay\"\n :class=\"overlayClass\"\n data-test=\"modal-overlay\"\n @click=\"emitOverlayClicked\"\n @keydown=\"emitOverlayClicked\"\n />\n </component>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useAccessibilityLabels, useDebounce } from '../../composables'\nimport { AnimationProp } from '../../types'\nimport { FOCUSABLE_SELECTORS, getTargetElement } from '../../utils'\nimport { Fade, NoAnimation } from '../animations'\n\n/**\n * Base component with no XPlugin dependencies that serves as a utility for constructing more\n * complex modals.\n *\n * @public\n */\nexport default defineComponent({\n name: 'BaseModal',\n props: {\n /** Determines if the modal is open or not. */\n open: {\n type: Boolean,\n required: true,\n },\n /**\n * Determines if the focused element changes to one inside the modal when it opens. Either the\n * first element with a positive tabindex or just the first focusable element.\n */\n focusOnOpen: {\n type: Boolean,\n default: true,\n },\n /**\n * The reference selector of a DOM element to use as reference to position the modal.\n * This selector can be an ID or a class, if it is a class, it will use the first\n * element that matches.\n */\n referenceSelector: String,\n /** Animation to use for opening/closing the modal.This animation only affects the content. */\n animation: {\n type: AnimationProp,\n default: () => NoAnimation,\n },\n /**\n * Animation to use for the overlay (backdrop) part of the modal. By default, it uses\n * a fade transition.\n */\n overlayAnimation: {\n type: AnimationProp,\n default: () => Fade,\n },\n /**\n * Determines if the scroll of the body and the window is disabled while the modal is open.\n * Set it to `false` for modals that must not lock the page scroll. It can be toggled while the\n * modal is open.\n */\n scrollLock: {\n type: Boolean,\n default: true,\n },\n /** Class inherited by content element. */\n contentClass: String,\n /** Class inherited by overlay element. */\n overlayClass: String,\n },\n emits: ['click:overlay', 'focusin:body'],\n setup(props, { emit }) {\n const ariaLabels = useAccessibilityLabels('baseModal')\n\n /** Reference to the modal element in the DOM. */\n const modalRef = ref<HTMLDivElement>()\n /** Reference to the modal content element in the DOM. */\n const modalContentRef = ref<HTMLDivElement>()\n\n /** The previous value of the body overflow style. */\n const previousBodyOverflow = ref('')\n /** The previous value of the HTML element overflow style. */\n const previousHTMLOverflow = ref('')\n /** Boolean to delay the leave animation until it has completed. */\n const isWaitingForLeave = ref(false)\n /** The reference element to use to find the modal's position. */\n let referenceElement: HTMLElement | undefined\n\n /** Whether this modal is currently holding the scroll lock, so it only restores what it set. */\n let isScrollDisabled = false\n\n /** Disables the scroll of both the body and the window. */\n function disableScroll() {\n if (!props.scrollLock || isScrollDisabled) {\n return\n }\n isScrollDisabled = true\n previousBodyOverflow.value = document.body.style.overflow\n previousHTMLOverflow.value = document.documentElement.style.overflow\n document.body.style.overflow = document.documentElement.style.overflow = 'hidden'\n }\n\n /** Restores the scroll of both the body and the window. */\n function enableScroll() {\n if (!isScrollDisabled) {\n return\n }\n isScrollDisabled = false\n document.body.style.overflow = previousBodyOverflow.value\n document.documentElement.style.overflow = previousHTMLOverflow.value\n }\n\n /**\n * Emits the `click:overlay` event if the click has been triggered in the overlay layer.\n *\n * @param event - The click event.\n */\n function emitOverlayClicked(event: Event) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('click:overlay', event)\n }\n\n /**\n * Emits the `focusin:body` event if a focus event has been triggered outside the modal.\n *\n * @param event - The focusin event.\n */\n function emitFocusInBody(event: FocusEvent) {\n if (!modalContentRef.value?.contains(getTargetElement(event))) {\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('focusin:body', event)\n }\n }\n\n /**\n * Adds listeners to the body element ot detect if the modal should be closed.\n *\n * @remarks TODO find a better solution and remove the timeout\n * To avoid emit the focusin on opening X that provokes closing it immediately.\n * This is because this event was emitted after the open of main modal when the user clicks\n * on the customer website search box (focus event). This way we avoid add the listener before\n * the open and the avoid the event that provokes the close.\n */\n function addBodyListeners() {\n setTimeout(() => {\n document.body.addEventListener('focusin', emitFocusInBody)\n })\n }\n\n /** Removes the body listeners. */\n function removeBodyListeners() {\n document.body.removeEventListener('focusin', emitFocusInBody)\n }\n\n /**\n * Sets the focused element to the first element either the first element with a positive\n * tabindex or, if there isn't any, the first focusable element inside the modal.\n */\n function setFocus() {\n const candidates: HTMLElement[] = Array.from(\n modalContentRef.value?.querySelectorAll(FOCUSABLE_SELECTORS) ?? [],\n )\n const element = candidates.find(element => element.tabIndex) ?? candidates[0]\n element?.focus()\n }\n\n /**\n * Syncs the body to the open state of the modal, adding or removing styles and listeners.\n *\n * @remarks nextTick() to wait for `modalContentRef` to be updated to look for focusable\n * candidates inside.\n *\n * @param isOpen - True when the modal is opened.\n */\n async function syncBody(isOpen: boolean) {\n if (isOpen) {\n disableScroll()\n addBodyListeners()\n if (props.focusOnOpen) {\n await nextTick()\n setFocus()\n }\n } else {\n enableScroll()\n removeBodyListeners()\n }\n }\n\n /**\n * Updates the position of the modal setting the top of the element depending\n * on the selector. The modal will be placed under this selector.\n */\n const debouncedUpdatePosition = useDebounce(\n () => {\n const { height, y } = referenceElement?.getBoundingClientRect() ?? { height: 0, y: 0 }\n modalRef.value!.style.top = `${height + y}px`\n modalRef.value!.style.bottom = '0'\n modalRef.value!.style.height = 'auto'\n },\n 100,\n { leading: true },\n )\n\n let resizeObserver: ResizeObserver\n\n onMounted(() => {\n watch(() => props.open, syncBody)\n watch(\n () => props.scrollLock,\n shouldLockScroll => {\n if (props.open) {\n shouldLockScroll ? disableScroll() : enableScroll()\n }\n },\n )\n if (props.open) {\n syncBody(true)\n }\n\n resizeObserver = new ResizeObserver(debouncedUpdatePosition)\n\n watch(\n () => props.referenceSelector,\n () => {\n resizeObserver.disconnect()\n\n if (props.referenceSelector) {\n const element = document.querySelector(props.referenceSelector) as HTMLElement\n if (element) {\n referenceElement = element\n resizeObserver.observe(element)\n }\n } else {\n referenceElement = undefined\n debouncedUpdatePosition()\n }\n },\n { immediate: true },\n )\n })\n\n onBeforeUnmount(() => {\n if (props.open) {\n removeBodyListeners()\n enableScroll()\n }\n resizeObserver.disconnect()\n })\n\n return {\n ariaLabels,\n emitOverlayClicked,\n isWaitingForLeave,\n modalContentRef,\n modalRef,\n }\n },\n})\n</script>\n\n<style lang=\"css\" scoped>\n.x-modal {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n width: 100%;\n height: 100%;\n z-index: 1;\n}\n\n.x-modal__content {\n display: flex;\n flex-flow: column nowrap;\n z-index: 1;\n}\n\n.x-modal__overlay {\n width: 100%;\n height: 100%;\n position: absolute;\n background-color: rgb(0, 0, 0);\n opacity: 0.3;\n}\n</style>\n\n<docs lang=\"mdx\">\n## Examples\n\nThe `BaseModal` is a simple component that serves to create complex modals. Its open state has to be\npassed via prop. There is a prop, `referenceSelector`, used to place the modal under some element\ninstead of set the top of the element directly. It also accepts an animation to use for opening &\nclosing.\n\nIt emits a `click:overlay` event when any part out of the content is clicked, but only if the modal\nis open.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n### Customized usage\n\n#### Customizing the content with classes\n\nThe `contentClass` prop can be used to add classes to the modal content.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n contentClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Customizing the overlay with classes\n\nThe `overlayClass` prop can be used to add classes to the modal overlay.\n\n```vue\n<template>\n <div>\n <button @click=\"open = true\">Open modal</button>\n <BaseModal\n :animation=\"fadeAndSlide\"\n :open=\"open\"\n @click:overlay=\"open = false\"\n referenceSelector=\".header\"\n overlayClass=\"x-bg-neutral-75\"\n >\n <h1>Hello</h1>\n <p>The modal is working</p>\n <button @click=\"open = false\">Close modal</button>\n </BaseModal>\n </div>\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport { BaseModal, FadeAndSlide } from '@empathyco/x-components'\nconst open = ref(false)\nconst fadeAndSlide = FadeAndSlide\n</script>\n```\n\n#### Not locking the page scroll\n\nBy default (`scrollLock` is `true`) the modal sets `overflow: hidden` on the `body` and `html`\nelements while it is open, and restores them when it closes. Set the `scrollLock` prop to `false`\nto keep the page scrollable. The prop can be toggled while the modal is open.\n\n```vue\n<BaseModal :open=\"open\" :scroll-lock=\"false\">\n <p>The page behind can still be scrolled.</p>\n</BaseModal>\n```\n\n## Vue Events\n\nA list of events that the component will emit:\n\n- `click:overlay`: the event is emitted after the user clicks any part out of the content but only\n if the modal is open. The event payload is the mouse event that triggers it.\n- `focusin:body`: the event is emitted after the user focus in any part out of the content but only\n if the modal is open. The event payload is the focus event that triggers it.\n</docs>\n"],"names":["NoAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;;;;;AAKE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,KAAK,EAAE;;AAEL,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AACD;;;AAGE;AACF,QAAA,WAAW,EAAE;AACX,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD;;;;AAIE;AACF,QAAA,iBAAiB,EAAE,MAAM;;AAEzB,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,MAAMA,WAAW;AAC3B,SAAA;AACD;;;AAGE;AACF,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,aAAa;AACnB,YAAA,OAAO,EAAE,MAAM,IAAI;AACpB,SAAA;AACD;;;;AAIE;AACF,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,YAAY,EAAE,MAAM;;AAEpB,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA;AACD,IAAA,KAAK,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC;AACxC,IAAA,KAAK,CAAC,KAAK,EAAE,EAAE,IAAG,EAAG,EAAA;AACnB,QAAA,MAAM,UAAS,GAAI,sBAAsB,CAAC,WAAW,CAAA;;AAGrD,QAAA,MAAM,QAAO,GAAI,GAAG,EAAiB;;AAErC,QAAA,MAAM,eAAc,G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CAAC,CAAA;QAED,OAAO;YACL,UAAU;YACV,kBAAkB;YAClB,iBAAiB;YACjB,eAAe;YACf,QAAQ;SACV;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-components",
3
- "version": "10.7.0",
3
+ "version": "10.8.0",
4
4
  "description": "Empathy X Components",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -67,10 +67,10 @@
67
67
  "vuex": "4.0.2"
68
68
  },
69
69
  "dependencies": {
70
- "@empathyco/x-adapter": "8.2.4",
71
- "@empathyco/x-adapter-platform": "2.0.4",
72
- "@empathyco/x-types": "11.0.4",
73
- "@empathyco/x-utils": "1.1.4",
70
+ "@empathyco/x-adapter": "8.2.5",
71
+ "@empathyco/x-adapter-platform": "2.0.5",
72
+ "@empathyco/x-types": "11.0.5",
73
+ "@empathyco/x-utils": "1.1.5",
74
74
  "@vue/devtools-api": "~6.6.4",
75
75
  "@vueuse/core": "~12.8.2",
76
76
  "js-md5": "~0.9.2",
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "devDependencies": {
84
84
  "@babel/preset-env": "8.0.7",
85
- "@empathyco/x-design-system": "1.2.4",
85
+ "@empathyco/x-design-system": "1.2.5",
86
86
  "@microsoft/api-documenter": "7.30.19",
87
87
  "@microsoft/api-extractor": "7.60.0",
88
88
  "@tailwindcss/vite": "4.3.3",
@@ -117,5 +117,5 @@
117
117
  "access": "public",
118
118
  "directory": "dist"
119
119
  },
120
- "gitHead": "13d8b0c97aa5dbc4f26b27751c538b32e95da1ee"
120
+ "gitHead": "317191ef5637e5f390f558ced832dee6b57df8cc"
121
121
  }
@@ -10054,7 +10054,16 @@
10054
10054
  },
10055
10055
  {
10056
10056
  "kind": "Content",
10057
- "text": "<{}, {}, any>;\n };\n contentClass: "
10057
+ "text": "<{}, {}, any>;\n };\n scrollLock: {\n type: "
10058
+ },
10059
+ {
10060
+ "kind": "Reference",
10061
+ "text": "BooleanConstructor",
10062
+ "canonicalReference": "!BooleanConstructor:interface"
10063
+ },
10064
+ {
10065
+ "kind": "Content",
10066
+ "text": ";\n default: boolean;\n };\n contentClass: "
10058
10067
  },
10059
10068
  {
10060
10069
  "kind": "Reference",
@@ -10297,7 +10306,16 @@
10297
10306
  },
10298
10307
  {
10299
10308
  "kind": "Content",
10300
- "text": "<{}, {}, any>;\n };\n contentClass: "
10309
+ "text": "<{}, {}, any>;\n };\n scrollLock: {\n type: "
10310
+ },
10311
+ {
10312
+ "kind": "Reference",
10313
+ "text": "BooleanConstructor",
10314
+ "canonicalReference": "!BooleanConstructor:interface"
10315
+ },
10316
+ {
10317
+ "kind": "Content",
10318
+ "text": ";\n default: boolean;\n };\n contentClass: "
10301
10319
  },
10302
10320
  {
10303
10321
  "kind": "Reference",
@@ -10360,7 +10378,7 @@
10360
10378
  },
10361
10379
  {
10362
10380
  "kind": "Content",
10363
- "text": "<string, any>;\n}, {}, {}, {}, string, import(\"vue\")."
10381
+ "text": "<string, any>;\n scrollLock: boolean;\n}, {}, {}, {}, string, import(\"vue\")."
10364
10382
  },
10365
10383
  {
10366
10384
  "kind": "Reference",
@@ -10378,7 +10396,7 @@
10378
10396
  "name": "BaseModal",
10379
10397
  "variableTypeTokenRange": {
10380
10398
  "startIndex": 1,
10381
- "endIndex": 98
10399
+ "endIndex": 102
10382
10400
  }
10383
10401
  },
10384
10402
  {
@@ -1230,6 +1230,10 @@ overlayAnimation: {
1230
1230
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
1231
1231
  default: () => DefineComponent< {}, {}, any>;
1232
1232
  };
1233
+ scrollLock: {
1234
+ type: BooleanConstructor;
1235
+ default: boolean;
1236
+ };
1233
1237
  contentClass: StringConstructor;
1234
1238
  overlayClass: StringConstructor;
1235
1239
  }>, {
@@ -1258,6 +1262,10 @@ overlayAnimation: {
1258
1262
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
1259
1263
  default: () => DefineComponent< {}, {}, any>;
1260
1264
  };
1265
+ scrollLock: {
1266
+ type: BooleanConstructor;
1267
+ default: boolean;
1268
+ };
1261
1269
  contentClass: StringConstructor;
1262
1270
  overlayClass: StringConstructor;
1263
1271
  }>> & Readonly<{
@@ -1267,6 +1275,7 @@ overlayClass: StringConstructor;
1267
1275
  focusOnOpen: boolean;
1268
1276
  animation: string | Function | Record<string, any>;
1269
1277
  overlayAnimation: string | Function | Record<string, any>;
1278
+ scrollLock: boolean;
1270
1279
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
1271
1280
 
1272
1281
  export { BasePlaceholderImage }
@@ -37,6 +37,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
37
37
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
38
38
  default: () => import("vue").DefineComponent<{}, {}, any>;
39
39
  };
40
+ /**
41
+ * Determines if the scroll of the body and the window is disabled while the modal is open.
42
+ * Set it to `false` for modals that must not lock the page scroll. It can be toggled while the
43
+ * modal is open.
44
+ */
45
+ scrollLock: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  /** Class inherited by content element. */
41
50
  contentClass: StringConstructor;
42
51
  /** Class inherited by overlay element. */
@@ -82,6 +91,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
82
91
  type: (StringConstructor | ObjectConstructor | FunctionConstructor)[];
83
92
  default: () => import("vue").DefineComponent<{}, {}, any>;
84
93
  };
94
+ /**
95
+ * Determines if the scroll of the body and the window is disabled while the modal is open.
96
+ * Set it to `false` for modals that must not lock the page scroll. It can be toggled while the
97
+ * modal is open.
98
+ */
99
+ scrollLock: {
100
+ type: BooleanConstructor;
101
+ default: boolean;
102
+ };
85
103
  /** Class inherited by content element. */
86
104
  contentClass: StringConstructor;
87
105
  /** Class inherited by overlay element. */
@@ -93,6 +111,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
93
111
  focusOnOpen: boolean;
94
112
  animation: string | Function | Record<string, any>;
95
113
  overlayAnimation: string | Function | Record<string, any>;
114
+ scrollLock: boolean;
96
115
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
97
116
  export default _default;
98
117
  //# sourceMappingURL=base-modal.vue?vue&type=script&lang.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-modal.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/components/modals/base-modal.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;;IAIC,8CAA8C;;;;;IAK9C;;;OAGG;;;;;IAKH;;;;OAIG;;IAEH,8FAA8F;;;;;IAK9F;;;OAGG;;;;;IAKH,0CAA0C;;IAE1C,0CAA0C;;;;;;gCAuCP,KAAK;;;;;IAzExC,8CAA8C;;;;;IAK9C;;;OAGG;;;;;IAKH;;;;OAIG;;IAEH,8FAA8F;;;;;IAK9F;;;OAGG;;;;;IAKH,0CAA0C;;IAE1C,0CAA0C;;;;;;;;;;AArC9C,wBAgNE"}
1
+ {"version":3,"file":"base-modal.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/components/modals/base-modal.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;;IAIC,8CAA8C;;;;;IAK9C;;;OAGG;;;;;IAKH;;;;OAIG;;IAEH,8FAA8F;;;;;IAK9F;;;OAGG;;;;;IAKH;;;;OAIG;;;;;IAKH,0CAA0C;;IAE1C,0CAA0C;;;;;;gCAkDP,KAAK;;;;;IA7FxC,8CAA8C;;;;;IAK9C;;;OAGG;;;;;IAKH;;;;OAIG;;IAEH,8FAA8F;;;;;IAK9F;;;OAGG;;;;;IAKH;;;;OAIG;;;;;IAKH,0CAA0C;;IAE1C,0CAA0C;;;;;;;;;;;AA9C9C,wBA4OE"}