@studiometa/ui 0.2.13 → 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 +45 -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,122 +1,52 @@
1
- /**
2
- * @typedef {import('@studiometa/js-toolkit/Base').BaseOptions} BaseOptions
3
- * @typedef {import('./AccordionCore.js').AccordionInterface} AccordionInterface
4
- */
5
- /**
6
- * @typedef {Object} AccordionItemRefs
7
- * @property {HTMLElement} btn
8
- * @property {HTMLElement} content
9
- * @property {HTMLElement} container
10
- */
11
- /**
12
- * @typedef {Object} StylesOption
13
- * @property {String|Partial<CSSStyleDeclaration>} open
14
- * @property {String|Partial<CSSStyleDeclaration>} active
15
- * @property {String|Partial<CSSStyleDeclaration>} closed
16
- */
17
- /**
18
- * @typedef {Partial<Record<'open'|'active'|'closed', string|Partial<CSSStyleDeclaration>>>} AccordionItemStates
19
- * @typedef {Partial<Record<keyof AccordionItemRefs, AccordionItemStates>>} AccordionItemStylesOption
20
- */
21
- /**
22
- * @typedef {Object} AccordionItemOptions
23
- * @property {Boolean} isOpen
24
- * @property {AccordionItemStylesOption} styles
25
- */
26
- /**
27
- * @typedef {Object} AccordionItemPrivateInterface
28
- * @property {AccordionItemOptions} $options
29
- * @property {AccordionItemRefs} $refs
30
- * @property {Accordion & AccordionInterface} $parent
31
- */
32
- /**
33
- * @typedef {AccordionItem & AccordionItemPrivateInterface} AccordionItemInterface
34
- */
1
+ import { Base, BaseConfig } from '@studiometa/js-toolkit';
2
+ import type { BaseProps } from '@studiometa/js-toolkit';
3
+ declare type AccordionItemStates = Partial<Record<'open' | 'active' | 'closed', string | Partial<CSSStyleDeclaration>>>;
4
+ export interface AccordionItemProps extends BaseProps {
5
+ $refs: {
6
+ btn: HTMLElement;
7
+ content: HTMLElement;
8
+ container: HTMLElement;
9
+ };
10
+ $options: {
11
+ isOpen: boolean;
12
+ styles: Partial<Record<keyof AccordionItemProps['$refs'], AccordionItemStates>>;
13
+ };
14
+ }
35
15
  /**
36
16
  * AccordionItem class.
37
17
  */
38
- export default class AccordionItem extends Base {
18
+ export declare class AccordionItem<T extends BaseProps = BaseProps> extends Base<T & AccordionItemProps> {
39
19
  /**
40
- * AccordionItem config
41
- * @return {Object}
20
+ * Config.
42
21
  */
43
- static config: {
44
- name: string;
45
- refs: string[];
46
- emits: string[];
47
- options: {
48
- isOpen: BooleanConstructor;
49
- styles: {
50
- type: ObjectConstructor;
51
- /**
52
- * @return {AccordionItemStylesOption}
53
- */
54
- default: () => AccordionItemStylesOption;
55
- merge: boolean;
56
- };
57
- };
58
- };
22
+ static config: BaseConfig;
59
23
  /**
60
24
  * Add aria-attributes on mounted.
61
- * @this {AccordionItemInterface}
62
25
  */
63
- mounted(this: AccordionItemInterface): void;
26
+ mounted(): void;
64
27
  /**
65
28
  * Remove styles on destroy.
66
- * @this {AccordionItemInterface}
67
29
  */
68
- destroyed(this: AccordionItemInterface): void;
30
+ destroyed(): void;
69
31
  /**
70
32
  * Handler for the click event on the `btn` ref.
71
- * @this {AccordionItemInterface}
72
33
  */
73
- onBtnClick(this: AccordionItemInterface): void;
34
+ onBtnClick(): void;
74
35
  /**
75
36
  * Get the content ID.
76
- * @return {String}
77
37
  */
78
38
  get contentId(): string;
79
39
  /**
80
40
  * Update the refs' attributes according to the given type.
81
- *
82
- * @this {AccordionItemInterface}
83
- * @param {Boolean} isOpen The state of the item.
84
41
  */
85
- updateAttributes(this: AccordionItemInterface, isOpen: boolean): void;
42
+ updateAttributes(isOpen: boolean): void;
86
43
  /**
87
44
  * Open an item.
88
- * @this {AccordionItemInterface}
89
45
  */
90
- open(this: AccordionItemInterface): Promise<void>;
46
+ open(): Promise<void>;
91
47
  /**
92
48
  * Close an item.
93
- * @this {AccordionItemInterface}
94
49
  */
95
- close(this: AccordionItemInterface): Promise<void>;
50
+ close(): Promise<void>;
96
51
  }
97
- export type BaseOptions = import('@studiometa/js-toolkit/Base').BaseOptions;
98
- export type AccordionInterface = import('./AccordionCore.js').AccordionInterface;
99
- export type AccordionItemRefs = {
100
- btn: HTMLElement;
101
- content: HTMLElement;
102
- container: HTMLElement;
103
- };
104
- export type StylesOption = {
105
- open: string | Partial<CSSStyleDeclaration>;
106
- active: string | Partial<CSSStyleDeclaration>;
107
- closed: string | Partial<CSSStyleDeclaration>;
108
- };
109
- export type AccordionItemStates = Partial<Record<'open' | 'active' | 'closed', string | Partial<CSSStyleDeclaration>>>;
110
- export type AccordionItemStylesOption = Partial<Record<keyof AccordionItemRefs, AccordionItemStates>>;
111
- export type AccordionItemOptions = {
112
- isOpen: boolean;
113
- styles: AccordionItemStylesOption;
114
- };
115
- export type AccordionItemPrivateInterface = {
116
- $options: AccordionItemOptions;
117
- $refs: AccordionItemRefs;
118
- $parent: Accordion & AccordionInterface;
119
- };
120
- export type AccordionItemInterface = AccordionItem & AccordionItemPrivateInterface;
121
- import { Base } from "@studiometa/js-toolkit";
122
- import Accordion from "./AccordionCore.js";
52
+ export {};
@@ -1 +1,153 @@
1
- import a from"deepmerge";import{Base as l}from"@studiometa/js-toolkit";import{transition as r}from"@studiometa/js-toolkit/utils";import f from"./AccordionCore.js";class c extends l{static config={name:"AccordionItem",refs:["btn","content","container"],emits:["open","close"],options:{isOpen:Boolean,styles:{type:Object,default:()=>({container:{open:"",active:"",closed:""}}),merge:!0}}};mounted(){this.$parent&&this.$parent instanceof f&&this.$parent.$options.item&&Object.entries(this.$parent.$options.item).forEach(([t,o])=>{if(t in this.$options){const n=c.config.options[t].type||c.config.options[t];n===Array||n===Object?this.$options[t]=a(this.$options[t],o):this.$options[t]=o}}),this.$refs.btn.setAttribute("id",this.$id),this.$refs.btn.setAttribute("aria-controls",this.contentId),this.$refs.content.setAttribute("aria-labelledby",this.$id),this.$refs.content.setAttribute("id",this.contentId);const{isOpen:i}=this.$options;this.updateAttributes(i);const{container:h,...s}=this.$options.styles,e=this.$refs;Object.entries(s).filter(([t])=>e[t]).forEach(([t,{open:o,closed:n}={open:"",closed:""}])=>{r(e[t],{to:i?o:n},"keep")})}destroyed(){this.$refs.container.style.visibility="",this.$refs.container.style.height=""}onBtnClick(){this.$options.isOpen?this.close():this.open()}get contentId(){return`content-${this.$id}`}updateAttributes(i){this.$refs.container.style.visibility=i?"":"invisible",this.$refs.container.style.height=i?"":"0",this.$refs.content.setAttribute("aria-hidden",i?"false":"true"),this.$refs.btn.setAttribute("aria-expanded",i?"true":"false")}async open(){if(this.$options.isOpen)return;this.$log("open"),this.$emit("open"),this.$options.isOpen=!0,this.updateAttributes(this.$options.isOpen),this.$refs.container.style.visibility="";const{container:i,...h}=this.$options.styles,s=this.$refs;await Promise.all([r(s.container,{from:{height:"0"},active:i.active,to:{height:`${s.content.offsetHeight}px`}}).then(()=>(this.$options.isOpen&&(s.content.style.position=""),Promise.resolve())),...Object.entries(h).filter(([e])=>s[e]).map(([e,{open:t,active:o,closed:n}={open:"",active:"",closed:""}])=>r(s[e],{from:n,active:o,to:t},"keep"))])}async close(){if(!this.$options.isOpen)return;this.$log("close"),this.$emit("close"),this.$options.isOpen=!1;const i=this.$refs.container.offsetHeight;this.$refs.content.style.position="absolute";const{container:h,...s}=this.$options.styles,e=this.$refs;await Promise.all([r(e.container,{from:{height:`${i}px`},active:h.active,to:{height:"0"}}).then(()=>(this.$options.isOpen||(e.container.style.height="0",e.container.style.visibility="invisible",this.updateAttributes(this.$options.isOpen)),Promise.resolve())),...Object.entries(s).filter(([t])=>e[t]).map(([t,{open:o,active:n,closed:p}={open:"",active:"",closed:""}])=>r(e[t],{from:o,active:n,to:p},"keep"))])}}export{c 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 deepmerge from "deepmerge";
8
+ import { Base } from "@studiometa/js-toolkit";
9
+ import { transition } from "@studiometa/js-toolkit/utils";
10
+ import { AccordionCore as Accordion } from "./AccordionCore.js";
11
+ const _AccordionItem = class extends Base {
12
+ mounted() {
13
+ if (this.$parent && this.$parent instanceof Accordion && this.$parent.$options.item) {
14
+ Object.entries(this.$parent.$options.item).forEach(([key, value]) => {
15
+ var _a;
16
+ if (key in this.$options) {
17
+ const type = (_a = _AccordionItem.config.options[key].type) != null ? _a : _AccordionItem.config.options[key];
18
+ if (type === Array || type === Object) {
19
+ this.$options[key] = deepmerge(this.$options[key], value);
20
+ } else {
21
+ this.$options[key] = value;
22
+ }
23
+ }
24
+ });
25
+ }
26
+ this.$refs.btn.setAttribute("id", this.$id);
27
+ this.$refs.btn.setAttribute("aria-controls", this.contentId);
28
+ this.$refs.content.setAttribute("aria-labelledby", this.$id);
29
+ this.$refs.content.setAttribute("id", this.contentId);
30
+ const { isOpen } = this.$options;
31
+ this.updateAttributes(isOpen);
32
+ const { container, ...otherStyles } = this.$options.styles;
33
+ const { $refs } = this;
34
+ Object.entries(otherStyles).filter(([refName]) => $refs[refName]).forEach(([refName, { open, closed } = { open: "", closed: "" }]) => {
35
+ transition($refs[refName], { to: isOpen ? open : closed }, "keep");
36
+ });
37
+ }
38
+ destroyed() {
39
+ this.$refs.container.style.visibility = "";
40
+ this.$refs.container.style.height = "";
41
+ }
42
+ onBtnClick() {
43
+ if (this.$options.isOpen) {
44
+ this.close();
45
+ } else {
46
+ this.open();
47
+ }
48
+ }
49
+ get contentId() {
50
+ return `content-${this.$id}`;
51
+ }
52
+ updateAttributes(isOpen) {
53
+ this.$refs.container.style.visibility = isOpen ? "" : "invisible";
54
+ this.$refs.container.style.height = isOpen ? "" : "0";
55
+ this.$refs.content.setAttribute("aria-hidden", isOpen ? "false" : "true");
56
+ this.$refs.btn.setAttribute("aria-expanded", isOpen ? "true" : "false");
57
+ }
58
+ async open() {
59
+ if (this.$options.isOpen) {
60
+ return;
61
+ }
62
+ this.$log("open");
63
+ this.$emit("open");
64
+ this.$options.isOpen = true;
65
+ this.updateAttributes(this.$options.isOpen);
66
+ this.$refs.container.style.visibility = "";
67
+ const { container, ...otherStyles } = this.$options.styles;
68
+ const { $refs } = this;
69
+ await Promise.all([
70
+ transition($refs.container, {
71
+ from: { height: "0" },
72
+ active: container.active,
73
+ to: { height: `${$refs.content.offsetHeight}px` }
74
+ }).then(() => {
75
+ if (this.$options.isOpen) {
76
+ $refs.content.style.position = "";
77
+ }
78
+ return Promise.resolve();
79
+ }),
80
+ ...Object.entries(otherStyles).filter(([refName]) => $refs[refName]).map(
81
+ ([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(
82
+ $refs[refName],
83
+ {
84
+ from: closed,
85
+ active,
86
+ to: open
87
+ },
88
+ "keep"
89
+ )
90
+ )
91
+ ]);
92
+ }
93
+ async close() {
94
+ if (!this.$options.isOpen) {
95
+ return;
96
+ }
97
+ this.$log("close");
98
+ this.$emit("close");
99
+ this.$options.isOpen = false;
100
+ const height = this.$refs.container.offsetHeight;
101
+ this.$refs.content.style.position = "absolute";
102
+ const { container, ...otherStyles } = this.$options.styles;
103
+ const refs = this.$refs;
104
+ await Promise.all([
105
+ transition(refs.container, {
106
+ from: { height: `${height}px` },
107
+ active: container.active,
108
+ to: { height: "0" }
109
+ }).then(() => {
110
+ if (!this.$options.isOpen) {
111
+ refs.container.style.height = "0";
112
+ refs.container.style.visibility = "invisible";
113
+ this.updateAttributes(this.$options.isOpen);
114
+ }
115
+ return Promise.resolve();
116
+ }),
117
+ ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(
118
+ ([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(
119
+ refs[refName],
120
+ {
121
+ from: open,
122
+ active,
123
+ to: closed
124
+ },
125
+ "keep"
126
+ )
127
+ )
128
+ ]);
129
+ }
130
+ };
131
+ let AccordionItem = _AccordionItem;
132
+ __publicField(AccordionItem, "config", {
133
+ name: "AccordionItem",
134
+ refs: ["btn", "content", "container"],
135
+ emits: ["open", "close"],
136
+ options: {
137
+ isOpen: Boolean,
138
+ styles: {
139
+ type: Object,
140
+ default: () => ({
141
+ container: {
142
+ open: "",
143
+ active: "",
144
+ closed: ""
145
+ }
146
+ }),
147
+ merge: true
148
+ }
149
+ }
150
+ });
151
+ export {
152
+ AccordionItem
153
+ };
@@ -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/Accordion/index.ts
17
+ var Accordion_exports = {};
18
+ module.exports = __toCommonJS(Accordion_exports);
19
+ __reExport(Accordion_exports, require("./Accordion.cjs"), module.exports);
20
+ __reExport(Accordion_exports, require("./AccordionItem.cjs"), module.exports);
21
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,2 @@
1
+ export * from './Accordion.js';
2
+ export * from './AccordionItem.js';
@@ -0,0 +1,2 @@
1
+ export * from "./Accordion.js";
2
+ export * from "./AccordionItem.js";
@@ -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,23 +15,22 @@ 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/Menu/Menu.js
24
+ // packages/ui/molecules/Menu/Menu.ts
28
25
  var Menu_exports = {};
29
26
  __export(Menu_exports, {
30
- default: () => Menu
27
+ Menu: () => Menu
31
28
  });
32
29
  module.exports = __toCommonJS(Menu_exports);
33
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
34
31
  var import_utils = require("@studiometa/js-toolkit/utils");
35
- var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
36
- var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
32
+ var import_MenuBtn = require("./MenuBtn.cjs");
33
+ var import_MenuList = require("./MenuList.cjs");
37
34
  var _Menu = class extends import_js_toolkit.Base {
38
35
  get menuList() {
39
36
  return (0, import_js_toolkit.getDirectChildren)(this, "Menu", "MenuList")[0];
@@ -123,10 +120,9 @@ var _Menu = class extends import_js_toolkit.Base {
123
120
  var Menu = _Menu;
124
121
  __publicField(Menu, "config", {
125
122
  name: "Menu",
126
- debug: true,
127
123
  components: {
128
- MenuBtn: import_MenuBtn.default,
129
- MenuList: import_MenuList.default,
124
+ MenuBtn: import_MenuBtn.MenuBtn,
125
+ MenuList: import_MenuList.MenuList,
130
126
  Menu: _Menu
131
127
  },
132
128
  options: {
@@ -1,140 +1,80 @@
1
- /**
2
- * @typedef {Menu & {
3
- * $children: {
4
- * Menu: Menu[],
5
- * MenuBtn: MenuBtn[],
6
- * MenuList: MenuList[],
7
- * },
8
- * $options: {
9
- * mode: 'click'|'hover'
10
- * }
11
- * }} MenuInterface
12
- */
1
+ import { Base } from '@studiometa/js-toolkit';
2
+ import type { BaseConfig, BaseProps, KeyServiceProps } from '@studiometa/js-toolkit';
3
+ import { MenuBtn } from './MenuBtn.js';
4
+ import { MenuList } from './MenuList.js';
5
+ export interface MenuProps extends BaseProps {
6
+ $children: {
7
+ Menu: Menu[];
8
+ MenutBtn: MenuBtn[];
9
+ MenuList: MenuList[];
10
+ };
11
+ $options: {
12
+ mode: 'click' | 'hover';
13
+ };
14
+ }
13
15
  /**
14
16
  * Menu class.
15
17
  */
16
- export default class Menu extends Base {
18
+ export declare class Menu<T extends BaseProps = BaseProps> extends Base<T & MenuProps> {
17
19
  /**
18
20
  * Config.
19
21
  */
20
- static config: {
21
- name: string;
22
- debug: boolean;
23
- components: {
24
- MenuBtn: typeof MenuBtn;
25
- MenuList: typeof MenuList;
26
- Menu: typeof Menu;
27
- };
28
- options: {
29
- mode: {
30
- type: StringConstructor;
31
- default: string;
32
- };
33
- };
34
- };
22
+ static config: BaseConfig;
35
23
  /**
36
24
  * Get the first `MenuList` instance.
37
- *
38
- * @this {MenuInterface}
39
- * @returns {MenuList}
40
25
  */
41
26
  get menuList(): MenuList;
42
27
  /**
43
28
  * Get the first `MenuBtn` instance.
44
- *
45
- * @this {MenuInterface}
46
- * @returns {MenuBtn}
47
29
  */
48
30
  get menuBtn(): MenuBtn;
49
31
  /**
50
- * @todo test breakpoint to switch between click and hover.
32
+ * Test which mode to use.
51
33
  */
52
34
  get shouldReactOnClick(): boolean;
53
35
  /**
54
36
  * Wether the button or the items are hovered.
55
- *
56
- * @returns {boolean}
57
37
  */
58
38
  get isHover(): boolean;
59
39
  /**
60
40
  * Set attributes on mounted, destroy the component if it is missing required
61
41
  * child components.
62
- *
63
- * @returns {void}
64
42
  */
65
43
  mounted(): void;
66
44
  /**
67
45
  * Keyboard management.
68
- *
69
- * @param {import('@studiometa/js-toolkit/services/key').KeyServiceProps} options
70
- * @returns {void}
71
46
  */
72
- keyed({ ENTER, ESC, isUp }: import('@studiometa/js-toolkit/services/key').KeyServiceProps): void;
47
+ keyed({ ENTER, ESC, isUp }: KeyServiceProps): void;
73
48
  /**
74
- * Toggle menu items on button click;
75
- *
76
- * @this {MenuInterface}
77
- * @param {number} index
78
- * @param {MouseEvent} event
79
- * @returns {void}
49
+ * Toggle menu items on button click.
80
50
  */
81
- onMenuBtnClick(this: MenuInterface, index: number, event: MouseEvent): void;
51
+ onMenuBtnClick(index: number, event: MouseEvent): void;
82
52
  /**
83
53
  * Open menu items on button mouse enter.
84
- *
85
- * @this {MenuInterface}
86
- * @param {number} index
87
- * @returns {void}
88
54
  */
89
- onMenuBtnMouseenter(this: MenuInterface, index: number): void;
55
+ onMenuBtnMouseenter(index: number): void;
90
56
  /**
91
57
  * Close menu items on button mouse leave.
92
- *
93
- * @this {MenuInterface}
94
- * @returns {void}
95
58
  */
96
- onMenuBtnMouseleave(this: MenuInterface): void;
59
+ onMenuBtnMouseleave(): void;
97
60
  /**
98
61
  * Close menu items on button mouse leave.
99
- *
100
- * @this {MenuInterface}
101
- * @returns {void}
102
62
  */
103
- onMenuListMouseleave(this: MenuInterface): void;
63
+ onMenuListMouseleave(): void;
104
64
  /**
105
65
  * Close other non-parent menu items on menu items open.
106
- *
107
- * @this {MenuInterface}
108
- * @param {number} index
109
- * @returns {void}
110
66
  */
111
- onMenuListItemsOpen(this: MenuInterface, index: number): void;
67
+ onMenuListItemsOpen(index: number): void;
112
68
  /**
113
69
  * Close the menu.
114
- * @returns {void}
115
70
  */
116
71
  close(): void;
117
72
  /**
118
73
  * Open the menu.
119
- * @returns {void}
120
74
  */
121
75
  open(): void;
122
76
  /**
123
77
  * Toggle the menu.
124
- * @returns {void}
125
78
  */
126
79
  toggle(): void;
127
80
  }
128
- export type MenuInterface = Menu & {
129
- $children: {
130
- Menu: Menu[];
131
- MenuBtn: MenuBtn[];
132
- MenuList: MenuList[];
133
- };
134
- $options: {
135
- mode: 'click' | 'hover';
136
- };
137
- };
138
- import { Base } from "@studiometa/js-toolkit";
139
- import MenuList from "./MenuList.js";
140
- import MenuBtn from "./MenuBtn.js";
@@ -1 +1,114 @@
1
- import{Base as h,isDirectChild as r,getDirectChildren as s}from"@studiometa/js-toolkit";import{nextTick as o}from"@studiometa/js-toolkit/utils";import l from"./MenuBtn.js";import c from"./MenuList.js";class n extends h{static config={name:"Menu",debug:!0,components:{MenuBtn:l,MenuList:c,Menu:n},options:{mode:{type:String,default:"click"}}};get menuList(){return s(this,"Menu","MenuList")[0]}get menuBtn(){return s(this,"Menu","MenuBtn")[0]}get shouldReactOnClick(){return this.$options.mode==="click"}get isHover(){return this.menuBtn.isHover||this.menuList.isHover}mounted(){if(!this.menuBtn||!this.menuList){this.$destroy();return}this.menuBtn.$el.setAttribute("aria-controls",this.$id),this.menuList.$el.setAttribute("id",this.$id),this.menuList.close()}keyed({ENTER:t,ESC:e,isUp:i}){if(!!i){if(e){this.close();return}if(!this.shouldReactOnClick){const u=document.activeElement===this.menuBtn.$el;t&&u&&this.toggle()}}}onMenuBtnClick(t,e){r(this,"Menu","MenuBtn",this.$children.MenuBtn[t])&&this.shouldReactOnClick&&(e.preventDefault(),this.toggle())}onMenuBtnMouseenter(t){this.$children.MenuBtn[t]===this.menuBtn&&!this.shouldReactOnClick&&this.open()}onMenuBtnMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListItemsOpen(t){const e=this.$children.MenuList[t];this.$children.MenuList.forEach(i=>{i.$el.contains(e.$el)||i.close()})}close(){this.menuList.close()}open(){this.menuList.open()}toggle(){this.menuList.toggle()}}export{n 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, isDirectChild, getDirectChildren } from "@studiometa/js-toolkit";
8
+ import { nextTick } from "@studiometa/js-toolkit/utils";
9
+ import { MenuBtn } from "./MenuBtn.js";
10
+ import { MenuList } from "./MenuList.js";
11
+ const _Menu = class extends Base {
12
+ get menuList() {
13
+ return getDirectChildren(this, "Menu", "MenuList")[0];
14
+ }
15
+ get menuBtn() {
16
+ return getDirectChildren(this, "Menu", "MenuBtn")[0];
17
+ }
18
+ get shouldReactOnClick() {
19
+ return this.$options.mode === "click";
20
+ }
21
+ get isHover() {
22
+ return this.menuBtn.isHover || this.menuList.isHover;
23
+ }
24
+ mounted() {
25
+ if (!this.menuBtn || !this.menuList) {
26
+ this.$destroy();
27
+ return;
28
+ }
29
+ this.menuBtn.$el.setAttribute("aria-controls", this.$id);
30
+ this.menuList.$el.setAttribute("id", this.$id);
31
+ this.menuList.close();
32
+ }
33
+ keyed({ ENTER, ESC, isUp }) {
34
+ if (!isUp) {
35
+ return;
36
+ }
37
+ if (ESC) {
38
+ this.close();
39
+ return;
40
+ }
41
+ if (!this.shouldReactOnClick) {
42
+ const hasFocusElementWithin = document.activeElement === this.menuBtn.$el;
43
+ if (ENTER && hasFocusElementWithin) {
44
+ this.toggle();
45
+ }
46
+ }
47
+ }
48
+ onMenuBtnClick(index, event) {
49
+ if (isDirectChild(this, "Menu", "MenuBtn", this.$children.MenuBtn[index]) && this.shouldReactOnClick) {
50
+ event.preventDefault();
51
+ this.toggle();
52
+ }
53
+ }
54
+ onMenuBtnMouseenter(index) {
55
+ if (this.$children.MenuBtn[index] === this.menuBtn && !this.shouldReactOnClick) {
56
+ this.open();
57
+ }
58
+ }
59
+ onMenuBtnMouseleave() {
60
+ if (this.shouldReactOnClick) {
61
+ return;
62
+ }
63
+ nextTick(() => {
64
+ if (!this.isHover) {
65
+ this.close();
66
+ }
67
+ });
68
+ }
69
+ onMenuListMouseleave() {
70
+ if (this.shouldReactOnClick) {
71
+ return;
72
+ }
73
+ nextTick(() => {
74
+ if (!this.isHover) {
75
+ this.close();
76
+ }
77
+ });
78
+ }
79
+ onMenuListItemsOpen(index) {
80
+ const targetMenu = this.$children.MenuList[index];
81
+ this.$children.MenuList.forEach((menuItem) => {
82
+ if (!menuItem.$el.contains(targetMenu.$el)) {
83
+ menuItem.close();
84
+ }
85
+ });
86
+ }
87
+ close() {
88
+ this.menuList.close();
89
+ }
90
+ open() {
91
+ this.menuList.open();
92
+ }
93
+ toggle() {
94
+ this.menuList.toggle();
95
+ }
96
+ };
97
+ let Menu = _Menu;
98
+ __publicField(Menu, "config", {
99
+ name: "Menu",
100
+ components: {
101
+ MenuBtn,
102
+ MenuList,
103
+ Menu: _Menu
104
+ },
105
+ options: {
106
+ mode: {
107
+ type: String,
108
+ default: "click"
109
+ }
110
+ }
111
+ });
112
+ export {
113
+ Menu
114
+ };