@studiometa/ui 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +3 -3
  2. package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +8 -15
  3. package/atoms/AnchorScrollTo/AnchorScrollTo.js +26 -1
  4. package/atoms/AnchorScrollTo/index.cjs +20 -0
  5. package/atoms/AnchorScrollTo/index.d.ts +1 -0
  6. package/atoms/AnchorScrollTo/index.js +1 -0
  7. package/atoms/Cursor/Cursor.cjs +16 -9
  8. package/atoms/Cursor/Cursor.d.ts +19 -117
  9. package/atoms/Cursor/Cursor.js +111 -1
  10. package/atoms/Cursor/index.cjs +20 -0
  11. package/atoms/Cursor/index.d.ts +1 -0
  12. package/atoms/Cursor/index.js +1 -0
  13. package/atoms/Figure/Figure.cjs +15 -9
  14. package/atoms/Figure/Figure.d.ts +18 -53
  15. package/atoms/Figure/Figure.js +56 -1
  16. package/atoms/Figure/FigureTwicPics.cjs +10 -10
  17. package/atoms/Figure/FigureTwicPics.d.ts +16 -37
  18. package/atoms/Figure/FigureTwicPics.js +51 -1
  19. package/atoms/Figure/index.cjs +4 -14
  20. package/atoms/Figure/index.d.ts +2 -2
  21. package/atoms/Figure/index.js +2 -1
  22. package/atoms/LargeText/LargeText.cjs +17 -10
  23. package/atoms/LargeText/LargeText.d.ts +19 -40
  24. package/atoms/LargeText/LargeText.js +68 -1
  25. package/atoms/LargeText/index.cjs +20 -0
  26. package/atoms/LargeText/index.d.ts +1 -0
  27. package/atoms/LargeText/index.js +1 -0
  28. package/atoms/LazyInclude/LazyInclude.cjs +2 -2
  29. package/atoms/LazyInclude/LazyInclude.d.ts +17 -36
  30. package/atoms/LazyInclude/LazyInclude.js +46 -1
  31. package/atoms/LazyInclude/index.cjs +20 -0
  32. package/atoms/LazyInclude/index.d.ts +1 -0
  33. package/atoms/LazyInclude/index.js +1 -0
  34. package/atoms/Prefetch/AbstractPrefetch.cjs +6 -6
  35. package/atoms/Prefetch/AbstractPrefetch.d.ts +12 -35
  36. package/atoms/Prefetch/AbstractPrefetch.js +58 -1
  37. package/atoms/Prefetch/PrefetchWhenOver.cjs +5 -8
  38. package/atoms/Prefetch/PrefetchWhenOver.d.ts +8 -14
  39. package/atoms/Prefetch/PrefetchWhenOver.js +19 -1
  40. package/atoms/Prefetch/PrefetchWhenVisible.cjs +5 -8
  41. package/atoms/Prefetch/PrefetchWhenVisible.d.ts +10 -14
  42. package/atoms/Prefetch/PrefetchWhenVisible.js +20 -1
  43. package/atoms/Prefetch/index.cjs +5 -16
  44. package/atoms/Prefetch/index.d.ts +3 -3
  45. package/atoms/Prefetch/index.js +3 -1
  46. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +17 -14
  47. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +19 -89
  48. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +67 -1
  49. package/atoms/ScrollAnimation/ScrollAnimation.cjs +5 -14
  50. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +13 -51
  51. package/atoms/ScrollAnimation/ScrollAnimation.js +21 -1
  52. package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +37 -14
  53. package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +19 -6
  54. package/atoms/ScrollAnimation/ScrollAnimationChild.js +53 -1
  55. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +6 -9
  56. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +8 -2
  57. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +17 -1
  58. package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +8 -8
  59. package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +14 -26
  60. package/atoms/ScrollAnimation/ScrollAnimationParent.js +27 -1
  61. package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +6 -9
  62. package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +15 -2
  63. package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +17 -1
  64. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +24 -16
  65. package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +10 -8
  66. package/atoms/ScrollAnimation/animationScrollWithEase.js +36 -1
  67. package/atoms/ScrollAnimation/index.cjs +9 -24
  68. package/atoms/ScrollAnimation/index.d.ts +7 -7
  69. package/atoms/ScrollAnimation/index.js +7 -1
  70. package/atoms/ScrollReveal/ScrollReveal.cjs +7 -4
  71. package/atoms/ScrollReveal/ScrollReveal.d.ts +16 -59
  72. package/atoms/ScrollReveal/ScrollReveal.js +54 -1
  73. package/atoms/ScrollReveal/index.cjs +3 -12
  74. package/atoms/ScrollReveal/index.d.ts +1 -1
  75. package/atoms/ScrollReveal/index.js +1 -1
  76. package/atoms/index.cjs +5 -18
  77. package/atoms/index.d.ts +8 -8
  78. package/atoms/index.js +8 -1
  79. package/decorators/index.cjs +3 -12
  80. package/decorators/index.d.ts +1 -1
  81. package/decorators/index.js +1 -1
  82. package/decorators/withTransition.cjs +44 -29
  83. package/decorators/withTransition.d.ts +21 -33
  84. package/decorators/withTransition.js +60 -1
  85. package/index.cjs +1 -1
  86. package/index.d.ts +5 -5
  87. package/index.js +5 -1
  88. package/molecules/Accordion/Accordion.cjs +7 -10
  89. package/molecules/Accordion/Accordion.d.ts +5 -23
  90. package/molecules/Accordion/Accordion.js +19 -1
  91. package/molecules/Accordion/AccordionCore.cjs +6 -8
  92. package/molecules/Accordion/AccordionCore.d.ts +22 -70
  93. package/molecules/Accordion/AccordionCore.js +32 -1
  94. package/molecules/Accordion/AccordionItem.cjs +39 -23
  95. package/molecules/Accordion/AccordionItem.d.ts +24 -94
  96. package/molecules/Accordion/AccordionItem.js +153 -1
  97. package/molecules/Accordion/index.cjs +21 -0
  98. package/molecules/Accordion/index.d.ts +2 -0
  99. package/molecules/Accordion/index.js +2 -0
  100. package/molecules/Menu/Menu.cjs +6 -10
  101. package/molecules/Menu/Menu.d.ts +24 -84
  102. package/molecules/Menu/Menu.js +114 -1
  103. package/molecules/Menu/MenuBtn.cjs +7 -5
  104. package/molecules/Menu/MenuBtn.d.ts +7 -9
  105. package/molecules/Menu/MenuBtn.js +30 -1
  106. package/molecules/Menu/MenuList.cjs +13 -11
  107. package/molecules/Menu/MenuList.d.ts +16 -53
  108. package/molecules/Menu/MenuList.js +113 -1
  109. package/molecules/Menu/index.cjs +5 -16
  110. package/molecules/Menu/index.d.ts +3 -3
  111. package/molecules/Menu/index.js +3 -1
  112. package/molecules/Modal/Modal.cjs +42 -13
  113. package/molecules/Modal/Modal.d.ts +69 -140
  114. package/molecules/Modal/Modal.js +163 -1
  115. package/molecules/Modal/ModalWithTransition.cjs +4 -7
  116. package/molecules/Modal/ModalWithTransition.d.ts +6 -22
  117. package/molecules/Modal/ModalWithTransition.js +46 -1
  118. package/molecules/Modal/index.cjs +21 -0
  119. package/molecules/Modal/index.d.ts +2 -0
  120. package/molecules/Modal/index.js +2 -0
  121. package/molecules/Panel/Panel.cjs +41 -26
  122. package/molecules/Panel/Panel.d.ts +22 -21
  123. package/molecules/Panel/Panel.js +108 -1
  124. package/molecules/Panel/index.cjs +20 -0
  125. package/molecules/Panel/index.d.ts +1 -0
  126. package/molecules/Panel/index.js +1 -0
  127. package/molecules/Slider/AbstractSliderChild.cjs +7 -9
  128. package/molecules/Slider/AbstractSliderChild.d.ts +11 -30
  129. package/molecules/Slider/AbstractSliderChild.js +48 -1
  130. package/molecules/Slider/Slider.cjs +46 -30
  131. package/molecules/Slider/Slider.d.ts +40 -157
  132. package/molecules/Slider/Slider.js +279 -1
  133. package/molecules/Slider/SliderBtn.cjs +4 -7
  134. package/molecules/Slider/SliderBtn.d.ts +12 -23
  135. package/molecules/Slider/SliderBtn.js +34 -1
  136. package/molecules/Slider/SliderCount.cjs +4 -7
  137. package/molecules/Slider/SliderCount.d.ts +10 -16
  138. package/molecules/Slider/SliderCount.js +19 -1
  139. package/molecules/Slider/SliderDots.cjs +8 -8
  140. package/molecules/Slider/SliderDots.d.ts +11 -31
  141. package/molecules/Slider/SliderDots.js +32 -1
  142. package/molecules/Slider/SliderDrag.cjs +2 -2
  143. package/molecules/Slider/SliderDrag.d.ts +12 -30
  144. package/molecules/Slider/SliderDrag.js +34 -1
  145. package/molecules/Slider/SliderItem.cjs +12 -6
  146. package/molecules/Slider/SliderItem.d.ts +21 -33
  147. package/molecules/Slider/SliderItem.js +93 -1
  148. package/molecules/Slider/SliderProgress.cjs +4 -7
  149. package/molecules/Slider/SliderProgress.d.ts +10 -25
  150. package/molecules/Slider/SliderProgress.js +26 -1
  151. package/molecules/Slider/index.cjs +10 -26
  152. package/molecules/Slider/index.d.ts +8 -8
  153. package/molecules/Slider/index.js +8 -1
  154. package/molecules/Sticky/Sticky.cjs +16 -10
  155. package/molecules/Sticky/Sticky.d.ts +30 -68
  156. package/molecules/Sticky/Sticky.js +110 -1
  157. package/molecules/Sticky/index.cjs +20 -0
  158. package/molecules/Sticky/index.d.ts +1 -0
  159. package/molecules/Sticky/index.js +1 -0
  160. package/molecules/TableOfContent/TableOfContent.cjs +5 -8
  161. package/molecules/TableOfContent/TableOfContent.d.ts +19 -41
  162. package/molecules/TableOfContent/TableOfContent.js +42 -1
  163. package/molecules/TableOfContent/TableOfContentAnchor.cjs +9 -5
  164. package/molecules/TableOfContent/TableOfContentAnchor.d.ts +14 -17
  165. package/molecules/TableOfContent/TableOfContentAnchor.js +43 -1
  166. package/molecules/TableOfContent/index.cjs +4 -14
  167. package/molecules/TableOfContent/index.d.ts +2 -2
  168. package/molecules/TableOfContent/index.js +2 -1
  169. package/molecules/Tabs/Tabs.cjs +42 -22
  170. package/molecules/Tabs/Tabs.d.ts +28 -90
  171. package/molecules/Tabs/Tabs.js +123 -1
  172. package/molecules/Tabs/index.cjs +20 -0
  173. package/molecules/Tabs/index.d.ts +1 -0
  174. package/molecules/Tabs/index.js +1 -0
  175. package/molecules/index.cjs +7 -24
  176. package/molecules/index.d.ts +9 -10
  177. package/molecules/index.js +9 -1
  178. package/organisms/Frame/Frame.cjs +20 -43
  179. package/organisms/Frame/Frame.d.ts +21 -98
  180. package/organisms/Frame/Frame.js +161 -1
  181. package/organisms/Frame/FrameAnchor.cjs +2 -2
  182. package/organisms/Frame/FrameAnchor.d.ts +7 -16
  183. package/organisms/Frame/FrameAnchor.js +18 -1
  184. package/organisms/Frame/FrameForm.cjs +2 -2
  185. package/organisms/Frame/FrameForm.d.ts +10 -16
  186. package/organisms/Frame/FrameForm.js +18 -1
  187. package/organisms/Frame/FrameTarget.cjs +15 -7
  188. package/organisms/Frame/FrameTarget.d.ts +17 -26
  189. package/organisms/Frame/FrameTarget.js +79 -1
  190. package/organisms/Frame/index.cjs +6 -18
  191. package/organisms/Frame/index.d.ts +4 -4
  192. package/organisms/Frame/index.js +4 -1
  193. package/organisms/index.cjs +1 -1
  194. package/organisms/index.d.ts +1 -1
  195. package/organisms/index.js +1 -1
  196. package/package.json +2 -2
  197. package/primitives/Draggable/Draggable.cjs +9 -6
  198. package/primitives/Draggable/Draggable.d.ts +10 -11
  199. package/primitives/Draggable/Draggable.js +33 -1
  200. package/primitives/Draggable/index.cjs +20 -0
  201. package/primitives/Draggable/index.d.ts +1 -0
  202. package/primitives/Draggable/index.js +1 -0
  203. package/primitives/Sentinel/Sentinel.cjs +2 -2
  204. package/primitives/Sentinel/Sentinel.d.ts +6 -5
  205. package/primitives/Sentinel/Sentinel.js +15 -1
  206. package/primitives/Sentinel/index.cjs +20 -0
  207. package/primitives/Sentinel/index.d.ts +1 -0
  208. package/primitives/Sentinel/index.js +1 -0
  209. package/primitives/Transition/Transition.cjs +12 -3
  210. package/primitives/Transition/Transition.d.ts +13 -7
  211. package/primitives/Transition/Transition.js +16 -1
  212. package/primitives/Transition/index.cjs +20 -0
  213. package/primitives/Transition/index.d.ts +1 -0
  214. package/primitives/Transition/index.js +1 -0
  215. package/primitives/index.cjs +5 -16
  216. package/primitives/index.d.ts +3 -3
  217. package/primitives/index.js +3 -1
@@ -1,171 +1,100 @@
1
- /**
2
- * @typedef {Object} ModalRefs
3
- * @property {HTMLElement} close[]
4
- * @property {HTMLElement} container
5
- * @property {HTMLElement} content
6
- * @property {HTMLElement} modal
7
- * @property {HTMLElement} open[]
8
- * @property {HTMLElement} overlay
9
- */
10
- /**
11
- * @typedef {Partial<Record<'open'|'active'|'closed', string|Partial<CSSStyleDeclaration>>>} ModalStates
12
- * @typedef {Partial<Record<keyof ModalRefs, ModalStates>>} ModalStylesOption
13
- */
14
- /**
15
- * @typedef {Object} ModalOptions
16
- * @property {String} move A selector where to move the modal to.
17
- * @property {String} autofocus A selector for the element to set the focus to when the modal opens.
18
- * @property {Boolean} scrollLock Lock or allow scroll in the documentElement.
19
- * @property {ModalStylesOption} styles The styles for the different state of the modal.
20
- */
21
- /**
22
- * @typedef {Object} ModalPrivateInterface
23
- * @property {ModalRefs} $refs
24
- * @property {ModalOptions} $options
25
- * @property {Boolean} isOpen
26
- * @property {Comment} refModalPlaceholder
27
- * @property {HTMLElement} refModalParentBackup
28
- * @property {Function} refModalUnbindGetRefFilter
29
- */
30
- /**
31
- * @typedef {Modal & ModalPrivateInterface} ModalInterface
32
- * @typedef {typeof Modal} ModalConstructor
33
- */
1
+ import { Base, KeyServiceProps } from '@studiometa/js-toolkit';
2
+ import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
3
+ declare type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | Partial<CSSStyleDeclaration>>>;
4
+ declare type ModalStylesOption = Partial<Record<keyof ModalProps['$refs'], ModalStates>>;
5
+ export interface ModalProps extends BaseProps {
6
+ $refs: {
7
+ close: HTMLElement[];
8
+ container: HTMLElement;
9
+ content: HTMLElement;
10
+ modal: HTMLElement;
11
+ open: HTMLElement[];
12
+ overlay: HTMLElement;
13
+ };
14
+ $options: {
15
+ /**
16
+ * A selector where to move the modal to.
17
+ */
18
+ move: string;
19
+ /**
20
+ * A selector for the element to set the focus to when the modal opens.
21
+ */
22
+ autofocus: string;
23
+ /**
24
+ * Lock or allow scroll in the documentElement.
25
+ */
26
+ scrollLock: boolean;
27
+ /**
28
+ * The styles for the different state of the modal.
29
+ */
30
+ styles: ModalStylesOption;
31
+ };
32
+ }
34
33
  /**
35
34
  * Modal class.
36
35
  */
37
- export default class Modal extends Base {
36
+ export declare class Modal<T extends BaseProps = BaseProps> extends Base<T & ModalProps> {
38
37
  /**
39
- * Modal options.
38
+ * Config.
40
39
  */
41
- static config: {
42
- name: string;
43
- refs: string[];
44
- emits: string[];
45
- options: {
46
- move: StringConstructor;
47
- autofocus: {
48
- type: StringConstructor;
49
- default: string;
50
- };
51
- styles: {
52
- type: ObjectConstructor;
53
- /**
54
- * @return {ModalStylesOption}
55
- */
56
- default: () => ModalStylesOption;
57
- };
58
- /**
59
- * @return {ModalScrollLockOption}
60
- */
61
- scrollLock: {
62
- type: BooleanConstructor;
63
- default: boolean;
64
- };
65
- };
66
- };
40
+ static config: BaseConfig;
67
41
  /**
68
- * Open the modal on click on the `open` ref.
69
- *
70
- * @return {Function} The component's `open` method.
42
+ * Wether the modal is open or not.
71
43
  */
72
- get onOpenClick(): Function;
44
+ isOpen: boolean;
73
45
  /**
74
- * Close the modal on click on the `close` ref.
75
- *
76
- * @return {Function} The component's `close` method.
46
+ * @private
77
47
  */
78
- get onCloseClick(): Function;
48
+ __refsBackup: (T & ModalProps)['$refs'];
79
49
  /**
80
- * Close the modal on click on the `overlay` ref.
81
- *
82
- * @return {Function} The component's `close` method.
50
+ * @private
83
51
  */
84
- get onOverlayClick(): Function;
52
+ __refModalPlaceholder: Comment;
85
53
  /**
86
- * Initialize the component's behaviours.
87
- *
88
- * @this {ModalInterface}
54
+ * @private
89
55
  */
90
- mounted(this: ModalInterface): void;
91
- isOpen: boolean;
92
- __refsBackup: import("@studiometa/js-toolkit/Base/managers/RefsManager").default & ModalRefs;
93
- __refModalPlaceholder: Comment;
94
56
  __refModalParentBackup: HTMLElement;
95
57
  /**
96
- * Unbind all events on destroy.
97
- *
98
- * @this {ModalInterface}
99
- * @return {Modal} The Modal instance.
58
+ * @private
100
59
  */
101
- destroyed(this: ModalInterface): Modal;
60
+ __refModalUnbindGetRefFilter: () => void;
102
61
  /**
103
- * Close the modal on `ESC` and trap the tabulation.
104
- *
105
- * @this {ModalInterface}
106
- * @param {Object} options
107
- * @param {KeyboardEvent} options.event The original keyboard event
108
- * @param {Boolean} options.isUp Is it a keyup event?
109
- * @param {Boolean} options.isDown Is it a keydown event?
110
- * @param {Boolean} options.ESC Is it the ESC key?
62
+ * Open the modal on click on the `open` ref.
111
63
  */
112
- keyed(this: ModalInterface, { event, isUp, isDown, ESC }: {
113
- event: KeyboardEvent;
114
- isUp: boolean;
115
- isDown: boolean;
116
- ESC: boolean;
117
- }): void;
64
+ get onOpenClick(): () => Promise<void>;
118
65
  /**
119
- * Open the modal.
120
- *
121
- * @this {ModalInterface}
122
- * @return {Promise<void>} The Modal instance.
66
+ * Close the modal on click on the `close` ref.
123
67
  */
124
- open(this: ModalInterface): Promise<void>;
68
+ get onCloseClick(): () => Promise<void>;
125
69
  /**
126
- * Close the modal.
70
+ * Close the modal on click on the `overlay` ref.
127
71
  *
128
- * @this {ModalInterface}
129
- * @return {Promise<void>} The Modal instance.
72
+ * @returns {Function} The component's `close` method.
130
73
  */
131
- close(this: ModalInterface): Promise<void>;
132
- }
133
- export type ModalRefs = {
134
- close: HTMLElement;
135
- container: HTMLElement;
136
- content: HTMLElement;
137
- modal: HTMLElement;
138
- open: HTMLElement;
139
- overlay: HTMLElement;
140
- };
141
- export type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | Partial<CSSStyleDeclaration>>>;
142
- export type ModalStylesOption = Partial<Record<keyof ModalRefs, ModalStates>>;
143
- export type ModalOptions = {
74
+ get onOverlayClick(): () => Promise<void>;
144
75
  /**
145
- * A selector where to move the modal to.
76
+ * Initialize the component's behaviours.
146
77
  */
147
- move: string;
78
+ mounted(): void;
148
79
  /**
149
- * A selector for the element to set the focus to when the modal opens.
80
+ * Add the moved refs to `this.$refs` when using the `move` options.
150
81
  */
151
- autofocus: string;
82
+ get $refs(): import("@studiometa/js-toolkit/Base/managers/RefsManager").default & (T & ModalProps)["$refs"] & import("@studiometa/js-toolkit/Base").BaseRefs;
152
83
  /**
153
- * Lock or allow scroll in the documentElement.
84
+ * Unbind all events on destroy.
154
85
  */
155
- scrollLock: boolean;
86
+ destroyed(): this;
156
87
  /**
157
- * The styles for the different state of the modal.
88
+ * Close the modal on `ESC` and trap the tabulation.
158
89
  */
159
- styles: ModalStylesOption;
160
- };
161
- export type ModalPrivateInterface = {
162
- $refs: ModalRefs;
163
- $options: ModalOptions;
164
- isOpen: boolean;
165
- refModalPlaceholder: Comment;
166
- refModalParentBackup: HTMLElement;
167
- refModalUnbindGetRefFilter: Function;
168
- };
169
- export type ModalInterface = Modal & ModalPrivateInterface;
170
- export type ModalConstructor = typeof Modal;
171
- import { Base } from "@studiometa/js-toolkit";
90
+ keyed({ event, isUp, isDown, ESC }: KeyServiceProps): void;
91
+ /**
92
+ * Open the modal.
93
+ */
94
+ open(): Promise<void>;
95
+ /**
96
+ * Close the modal.
97
+ */
98
+ close(): Promise<void>;
99
+ }
100
+ export {};
@@ -1 +1,163 @@
1
- import{Base as n}from"@studiometa/js-toolkit";import{transition as r,focusTrap as l}from"@studiometa/js-toolkit/utils";const{trap:a,untrap:c,saveActiveElement:f}=l();class h extends n{static config={name:"Modal",refs:["close[]","container","content","modal","open[]","overlay"],emits:["open","close"],options:{move:String,autofocus:{type:String,default:"[autofocus]"},styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none",visibility:"hidden"}}})},scrollLock:{type:Boolean,default:!0}}};get onOpenClick(){return this.open}get onCloseClick(){return this.close}get onOverlayClick(){return this.close}mounted(){if(this.isOpen=!1,this.close(),this.$options.move){const e=document.querySelector(this.$options.move)||document.body;this.__refsBackup=this.$refs,this.__refModalPlaceholder=document.createComment(""),this.__refModalParentBackup=this.$refs.modal.parentElement||this.$el,this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder,this.$refs.modal),e.appendChild(this.$refs.modal)}}get $refs(){const e=super.$refs;return this.$options.move&&this.__refsBackup&&Object.entries(this.__refsBackup).forEach(([t,s])=>{e[t]||(e[t]=s)}),e}destroyed(){return this.close(),this.$options.move&&this.__refModalParentBackup&&(this.__refModalParentBackup.insertBefore(this.$refs.modal,this.__refModalPlaceholder),this.__refModalPlaceholder.remove(),delete this.__refModalPlaceholder,delete this.__refModalParentBackup),this}keyed({event:e,isUp:t,isDown:s,ESC:o}){!this.isOpen||(s&&a(this.$refs.modal,e),o&&t&&this.close())}async open(){if(this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","false"),this.$options.scrollLock&&(document.documentElement.style.overflow="hidden"),this.isOpen=!0,this.$emit("open");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:i,active:o,to:s},"keep"))).then(()=>(this.$options.autofocus&&this.$refs.modal.querySelector(this.$options.autofocus)&&(f(),this.$refs.modal.querySelector(this.$options.autofocus).focus()),Promise.resolve()))}async close(){if(!this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","true"),this.$options.scrollLock&&(document.documentElement.style.overflow=""),this.isOpen=!1,c(),this.$emit("close");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:s,active:o,to:i},"keep"))).then(()=>Promise.resolve())}}export{h as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { Base } from "@studiometa/js-toolkit";
8
+ import { transition, isArray, focusTrap } from "@studiometa/js-toolkit/utils";
9
+ function delegateTransition(elementOrElements, name, endMode) {
10
+ return isArray(elementOrElements) || elementOrElements instanceof NodeList ? Promise.all(
11
+ Array.from(elementOrElements).map((el) => transition(el, name, endMode))
12
+ ) : transition(elementOrElements, name, endMode);
13
+ }
14
+ const { trap, untrap, saveActiveElement } = focusTrap();
15
+ class Modal extends Base {
16
+ constructor() {
17
+ super(...arguments);
18
+ __publicField(this, "isOpen", false);
19
+ __publicField(this, "__refsBackup");
20
+ __publicField(this, "__refModalPlaceholder");
21
+ __publicField(this, "__refModalParentBackup");
22
+ __publicField(this, "__refModalUnbindGetRefFilter");
23
+ }
24
+ get onOpenClick() {
25
+ return this.open;
26
+ }
27
+ get onCloseClick() {
28
+ return this.close;
29
+ }
30
+ get onOverlayClick() {
31
+ return this.close;
32
+ }
33
+ mounted() {
34
+ this.isOpen = false;
35
+ this.close();
36
+ if (this.$options.move) {
37
+ const target = document.querySelector(this.$options.move) || document.body;
38
+ this.__refsBackup = this.$refs;
39
+ this.__refModalPlaceholder = document.createComment("");
40
+ this.__refModalParentBackup = this.$refs.modal.parentElement || this.$el;
41
+ this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder, this.$refs.modal);
42
+ target.append(this.$refs.modal);
43
+ }
44
+ }
45
+ get $refs() {
46
+ const $refs = super.$refs;
47
+ if (this.$options.move && this.__refsBackup) {
48
+ Object.entries(this.__refsBackup).forEach(([key, ref]) => {
49
+ if (!$refs[key]) {
50
+ $refs[key] = ref;
51
+ }
52
+ });
53
+ }
54
+ return $refs;
55
+ }
56
+ destroyed() {
57
+ this.close();
58
+ if (this.$options.move && this.__refModalParentBackup) {
59
+ this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
60
+ this.__refModalPlaceholder.remove();
61
+ delete this.__refModalPlaceholder;
62
+ delete this.__refModalParentBackup;
63
+ }
64
+ return this;
65
+ }
66
+ keyed({ event, isUp, isDown, ESC }) {
67
+ if (!this.isOpen) {
68
+ return;
69
+ }
70
+ if (isDown) {
71
+ trap(this.$refs.modal, event);
72
+ }
73
+ if (ESC && isUp) {
74
+ this.close();
75
+ }
76
+ }
77
+ async open() {
78
+ if (this.isOpen) {
79
+ return Promise.resolve();
80
+ }
81
+ this.$refs.modal.setAttribute("aria-hidden", "false");
82
+ if (this.$options.scrollLock) {
83
+ document.documentElement.style.overflow = "hidden";
84
+ }
85
+ this.isOpen = true;
86
+ this.$emit("open");
87
+ const refs = this.$refs;
88
+ return Promise.all(
89
+ Object.entries(this.$options.styles).map(
90
+ ([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => delegateTransition(
91
+ refs[refName],
92
+ {
93
+ from: closed,
94
+ active,
95
+ to: open
96
+ },
97
+ "keep"
98
+ )
99
+ )
100
+ ).then(() => {
101
+ if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {
102
+ saveActiveElement();
103
+ const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);
104
+ autofocusElement.focus();
105
+ }
106
+ return Promise.resolve();
107
+ });
108
+ }
109
+ async close() {
110
+ if (!this.isOpen) {
111
+ return Promise.resolve();
112
+ }
113
+ this.$refs.modal.setAttribute("aria-hidden", "true");
114
+ if (this.$options.scrollLock) {
115
+ document.documentElement.style.overflow = "";
116
+ }
117
+ this.isOpen = false;
118
+ untrap();
119
+ this.$emit("close");
120
+ const refs = this.$refs;
121
+ return Promise.all(
122
+ Object.entries(this.$options.styles).map(
123
+ ([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => delegateTransition(
124
+ refs[refName],
125
+ {
126
+ from: open,
127
+ active,
128
+ to: closed
129
+ },
130
+ "keep"
131
+ )
132
+ )
133
+ ).then(() => Promise.resolve());
134
+ }
135
+ }
136
+ __publicField(Modal, "config", {
137
+ name: "Modal",
138
+ refs: ["close[]", "container", "content", "modal", "open[]", "overlay"],
139
+ emits: ["open", "close"],
140
+ options: {
141
+ move: String,
142
+ autofocus: { type: String, default: "[autofocus]" },
143
+ styles: {
144
+ type: Object,
145
+ default: () => ({
146
+ modal: {
147
+ closed: {
148
+ opacity: "0",
149
+ pointerEvents: "none",
150
+ visibility: "hidden"
151
+ }
152
+ }
153
+ })
154
+ },
155
+ scrollLock: {
156
+ type: Boolean,
157
+ default: true
158
+ }
159
+ }
160
+ });
161
+ export {
162
+ Modal
163
+ };
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
6
  var __export = (target, all) => {
@@ -17,21 +15,20 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
19
  var __publicField = (obj, key, value) => {
23
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
21
  return value;
25
22
  };
26
23
 
27
- // packages/ui/molecules/Modal/ModalWithTransition.js
24
+ // packages/ui/molecules/Modal/ModalWithTransition.ts
28
25
  var ModalWithTransition_exports = {};
29
26
  __export(ModalWithTransition_exports, {
30
- default: () => ModalWithTransition
27
+ ModalWithTransition: () => ModalWithTransition
31
28
  });
32
29
  module.exports = __toCommonJS(ModalWithTransition_exports);
33
- var import_Modal = __toESM(require("./Modal.cjs"), 1);
34
- var ModalWithTransition = class extends import_Modal.default {
30
+ var import_Modal = require("./Modal.cjs");
31
+ var ModalWithTransition = class extends import_Modal.Modal {
35
32
  open() {
36
33
  this.$refs.modal.style.visibility = "";
37
34
  return super.open();
@@ -1,29 +1,13 @@
1
- /**
2
- * @typedef {import('./Modal.js').ModalInterface} ModalInterface
3
- * @typedef {import('./Modal.js').ModalStylesOption} ModalStylesOption
4
- * @typedef {ModalInterface & ModalWithTransition} ModalWithTransitionInterface
5
- */
1
+ import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
2
+ import { Modal } from './Modal.js';
6
3
  /**
7
4
  * ModalWithTransition class.
8
5
  */
9
- export default class ModalWithTransition extends Modal {
6
+ export declare class ModalWithTransition<T extends BaseProps = BaseProps> extends Modal<T> {
10
7
  /**
11
8
  * Modal options.
12
9
  */
13
- static config: {
14
- name: string;
15
- options: {
16
- styles: {
17
- type: ObjectConstructor;
18
- /**
19
- * @return {ModalStylesOption}
20
- */
21
- default: () => ModalStylesOption;
22
- };
23
- };
24
- };
10
+ static config: BaseConfig;
11
+ open(): Promise<void>;
12
+ close(): Promise<void>;
25
13
  }
26
- export type ModalInterface = import('./Modal.js').ModalInterface;
27
- export type ModalStylesOption = import('./Modal.js').ModalStylesOption;
28
- export type ModalWithTransitionInterface = ModalInterface & ModalWithTransition;
29
- import Modal from "./Modal.js";
@@ -1 +1,46 @@
1
- import e from"./Modal.js";class t extends e{static config={name:"ModalWithTransition",options:{styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none"},active:"transition duration-500 ease-out-expo"},overlay:{closed:"opacity-0",active:"transition duration-500 ease-out-expo"},container:{closed:"transform scale-95 opacity-0",active:"transition duration-500 ease-out-expo"}})}}};open(){return this.$refs.modal.style.visibility="",super.open()}async close(){return await super.close(),this.$refs.modal.style.visibility="hidden",Promise.resolve()}}export{t as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { Modal } from "./Modal.js";
8
+ class ModalWithTransition extends Modal {
9
+ open() {
10
+ this.$refs.modal.style.visibility = "";
11
+ return super.open();
12
+ }
13
+ async close() {
14
+ await super.close();
15
+ this.$refs.modal.style.visibility = "hidden";
16
+ return Promise.resolve();
17
+ }
18
+ }
19
+ __publicField(ModalWithTransition, "config", {
20
+ name: "ModalWithTransition",
21
+ options: {
22
+ styles: {
23
+ type: Object,
24
+ default: () => ({
25
+ modal: {
26
+ closed: {
27
+ opacity: "0",
28
+ pointerEvents: "none"
29
+ },
30
+ active: "transition duration-500 ease-out-expo"
31
+ },
32
+ overlay: {
33
+ closed: "opacity-0",
34
+ active: "transition duration-500 ease-out-expo"
35
+ },
36
+ container: {
37
+ closed: "transform scale-95 opacity-0",
38
+ active: "transition duration-500 ease-out-expo"
39
+ }
40
+ })
41
+ }
42
+ }
43
+ });
44
+ export {
45
+ ModalWithTransition
46
+ };
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // packages/ui/molecules/Modal/index.ts
17
+ var Modal_exports = {};
18
+ module.exports = __toCommonJS(Modal_exports);
19
+ __reExport(Modal_exports, require("./Modal.cjs"), module.exports);
20
+ __reExport(Modal_exports, require("./ModalWithTransition.cjs"), module.exports);
21
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,2 @@
1
+ export * from './Modal.js';
2
+ export * from './ModalWithTransition.js';
@@ -0,0 +1,2 @@
1
+ export * from "./Modal.js";
2
+ export * from "./ModalWithTransition.js";