@studiometa/ui 0.2.3 → 0.2.6

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 (163) hide show
  1. package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +8 -13
  2. package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -26
  3. package/atoms/Button/Button.twig +68 -0
  4. package/atoms/Button/StyledButton.twig +47 -0
  5. package/atoms/Cursor/Cursor.cjs +14 -22
  6. package/atoms/Cursor/Cursor.d.ts +2 -2
  7. package/atoms/Cursor/Cursor.js +1 -103
  8. package/atoms/Cursor/Cursor.twig +28 -0
  9. package/atoms/Figure/Figure.cjs +20 -16
  10. package/atoms/Figure/Figure.d.ts +19 -1
  11. package/atoms/Figure/Figure.js +1 -27
  12. package/atoms/Figure/Figure.twig +120 -0
  13. package/atoms/Figure/FigureTwicPics.cjs +72 -0
  14. package/atoms/Figure/FigureTwicPics.d.ts +48 -0
  15. package/atoms/Figure/FigureTwicPics.js +1 -0
  16. package/atoms/Figure/index.cjs +31 -0
  17. package/atoms/Figure/index.d.ts +2 -0
  18. package/atoms/Figure/index.js +1 -0
  19. package/atoms/Icon/Icon.twig +13 -0
  20. package/atoms/LargeText/LargeText.cjs +15 -23
  21. package/atoms/LargeText/LargeText.d.ts +3 -3
  22. package/atoms/LargeText/LargeText.js +1 -64
  23. package/atoms/LargeText/LargeText.twig +49 -0
  24. package/atoms/LazyInclude/LazyInclude.cjs +8 -13
  25. package/atoms/LazyInclude/LazyInclude.d.ts +4 -4
  26. package/atoms/LazyInclude/LazyInclude.js +1 -46
  27. package/atoms/Prefetch/AbstractPrefetch.cjs +8 -13
  28. package/atoms/Prefetch/AbstractPrefetch.d.ts +1 -1
  29. package/atoms/Prefetch/AbstractPrefetch.js +1 -58
  30. package/atoms/Prefetch/PrefetchWhenOver.cjs +12 -34
  31. package/atoms/Prefetch/PrefetchWhenOver.d.ts +1 -1
  32. package/atoms/Prefetch/PrefetchWhenOver.js +1 -35
  33. package/atoms/Prefetch/PrefetchWhenVisible.cjs +12 -34
  34. package/atoms/Prefetch/PrefetchWhenVisible.d.ts +1 -1
  35. package/atoms/Prefetch/PrefetchWhenVisible.js +1 -36
  36. package/atoms/Prefetch/index.cjs +9 -16
  37. package/atoms/Prefetch/index.js +1 -8
  38. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +126 -0
  39. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +133 -0
  40. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -0
  41. package/atoms/ScrollAnimation/ScrollAnimation.cjs +51 -0
  42. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +55 -0
  43. package/atoms/ScrollAnimation/ScrollAnimation.js +1 -0
  44. package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +51 -0
  45. package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +13 -0
  46. package/atoms/ScrollAnimation/ScrollAnimationChild.js +1 -0
  47. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +41 -0
  48. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +6 -0
  49. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +1 -0
  50. package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +48 -0
  51. package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +35 -0
  52. package/atoms/ScrollAnimation/ScrollAnimationParent.js +1 -0
  53. package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +41 -0
  54. package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +6 -0
  55. package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +1 -0
  56. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +70 -0
  57. package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +11 -0
  58. package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -0
  59. package/atoms/ScrollAnimation/index.cjs +41 -0
  60. package/atoms/ScrollAnimation/index.d.ts +7 -0
  61. package/atoms/ScrollAnimation/index.js +1 -0
  62. package/atoms/index.cjs +13 -19
  63. package/atoms/index.d.ts +2 -1
  64. package/atoms/index.js +1 -13
  65. package/index.cjs +12 -15
  66. package/index.d.ts +1 -0
  67. package/index.js +1 -3
  68. package/molecules/Accordion/Accordion.cjs +12 -34
  69. package/molecules/Accordion/Accordion.js +1 -35
  70. package/molecules/Accordion/Accordion.twig +54 -0
  71. package/molecules/Accordion/AccordionCore.cjs +8 -13
  72. package/molecules/Accordion/AccordionCore.d.ts +2 -2
  73. package/molecules/Accordion/AccordionCore.js +1 -34
  74. package/molecules/Accordion/AccordionItem.cjs +70 -114
  75. package/molecules/Accordion/AccordionItem.d.ts +7 -6
  76. package/molecules/Accordion/AccordionItem.js +1 -178
  77. package/molecules/Menu/Menu.cjs +148 -0
  78. package/molecules/Menu/Menu.d.ts +140 -0
  79. package/molecules/Menu/Menu.js +1 -0
  80. package/molecules/Menu/MenuBtn.cjs +53 -0
  81. package/molecules/Menu/MenuBtn.d.ts +39 -0
  82. package/molecules/Menu/MenuBtn.js +1 -0
  83. package/molecules/Menu/MenuList.cjs +134 -0
  84. package/molecules/Menu/MenuList.d.ts +101 -0
  85. package/molecules/Menu/MenuList.js +1 -0
  86. package/molecules/Menu/index.cjs +33 -0
  87. package/molecules/Menu/index.d.ts +3 -0
  88. package/molecules/Menu/index.js +1 -0
  89. package/molecules/Modal/Modal.cjs +42 -71
  90. package/molecules/Modal/Modal.d.ts +5 -5
  91. package/molecules/Modal/Modal.js +1 -150
  92. package/molecules/Modal/Modal.twig +108 -0
  93. package/molecules/Modal/ModalWithTransition.cjs +13 -43
  94. package/molecules/Modal/ModalWithTransition.js +1 -69
  95. package/molecules/Modal/StyledModal.twig +39 -0
  96. package/molecules/Panel/Panel.cjs +42 -76
  97. package/molecules/Panel/Panel.js +1 -117
  98. package/molecules/Panel/Panel.twig +73 -0
  99. package/molecules/Panel/StyledPanel.twig +28 -0
  100. package/molecules/Slider/AbstractSliderChild.cjs +10 -20
  101. package/molecules/Slider/AbstractSliderChild.d.ts +6 -2
  102. package/molecules/Slider/AbstractSliderChild.js +1 -43
  103. package/molecules/Slider/Slider.cjs +14 -24
  104. package/molecules/Slider/Slider.d.ts +6 -6
  105. package/molecules/Slider/Slider.js +1 -209
  106. package/molecules/Slider/SliderBtn.cjs +9 -16
  107. package/molecules/Slider/SliderBtn.d.ts +1 -1
  108. package/molecules/Slider/SliderBtn.js +1 -34
  109. package/molecules/Slider/SliderCount.cjs +9 -16
  110. package/molecules/Slider/SliderCount.js +1 -19
  111. package/molecules/Slider/SliderDots.cjs +9 -16
  112. package/molecules/Slider/SliderDots.js +1 -24
  113. package/molecules/Slider/SliderDrag.cjs +8 -13
  114. package/molecules/Slider/SliderDrag.js +1 -19
  115. package/molecules/Slider/SliderItem.cjs +14 -37
  116. package/molecules/Slider/SliderItem.js +1 -105
  117. package/molecules/Slider/SliderProgress.cjs +9 -16
  118. package/molecules/Slider/SliderProgress.js +1 -23
  119. package/molecules/Slider/index.cjs +9 -16
  120. package/molecules/Slider/index.js +1 -18
  121. package/molecules/Sticky/Sticky.cjs +11 -19
  122. package/molecules/Sticky/Sticky.d.ts +8 -8
  123. package/molecules/Sticky/Sticky.js +1 -107
  124. package/molecules/Sticky/Sticky.twig +31 -0
  125. package/molecules/TableOfContent/TableOfContent.cjs +9 -16
  126. package/molecules/TableOfContent/TableOfContent.d.ts +1 -1
  127. package/molecules/TableOfContent/TableOfContent.js +1 -42
  128. package/molecules/TableOfContent/TableOfContentAnchor.cjs +8 -13
  129. package/molecules/TableOfContent/TableOfContentAnchor.js +1 -39
  130. package/molecules/TableOfContent/index.cjs +9 -16
  131. package/molecules/TableOfContent/index.js +1 -6
  132. package/molecules/Tabs/Tabs.cjs +54 -82
  133. package/molecules/Tabs/Tabs.d.ts +5 -4
  134. package/molecules/Tabs/Tabs.js +1 -126
  135. package/molecules/Tabs/Tabs.twig +20 -0
  136. package/molecules/index.cjs +13 -18
  137. package/molecules/index.d.ts +1 -0
  138. package/molecules/index.js +1 -18
  139. package/organisms/Frame/Frame.cjs +107 -99
  140. package/organisms/Frame/Frame.d.ts +37 -4
  141. package/organisms/Frame/Frame.js +1 -171
  142. package/organisms/Frame/FrameAnchor.cjs +8 -13
  143. package/organisms/Frame/FrameAnchor.js +1 -22
  144. package/organisms/Frame/FrameForm.cjs +8 -13
  145. package/organisms/Frame/FrameForm.js +1 -22
  146. package/organisms/Frame/FrameTarget.cjs +31 -73
  147. package/organisms/Frame/FrameTarget.js +1 -109
  148. package/organisms/Frame/index.cjs +9 -16
  149. package/organisms/Frame/index.js +1 -10
  150. package/organisms/ImageGrid/ImageGrid.twig +42 -0
  151. package/organisms/index.cjs +9 -13
  152. package/organisms/index.js +1 -1
  153. package/package.json +3 -4
  154. package/primitives/Draggable/Draggable.cjs +15 -28
  155. package/primitives/Draggable/Draggable.d.ts +0 -5
  156. package/primitives/Draggable/Draggable.js +1 -38
  157. package/primitives/Sentinel/Sentinel.cjs +8 -13
  158. package/primitives/Sentinel/Sentinel.js +1 -15
  159. package/primitives/Transition/Transition.cjs +12 -17
  160. package/primitives/Transition/Transition.d.ts +2 -4
  161. package/primitives/Transition/Transition.js +1 -45
  162. package/primitives/index.cjs +9 -16
  163. package/primitives/index.js +1 -8
@@ -0,0 +1,134 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __publicField = (obj, key, value) => {
23
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
+ return value;
25
+ };
26
+
27
+ // packages/ui/molecules/Menu/MenuList.js
28
+ var MenuList_exports = {};
29
+ __export(MenuList_exports, {
30
+ default: () => MenuList
31
+ });
32
+ module.exports = __toCommonJS(MenuList_exports);
33
+ var import_Transition = __toESM(require("../../primitives/Transition/Transition.cjs"), 1);
34
+ var FOCUSABLE_ELEMENTS = [
35
+ "a[href]:not([inert])",
36
+ "area[href]:not([inert])",
37
+ "input:not([disabled]):not([inert])",
38
+ "select:not([disabled]):not([inert])",
39
+ "textarea:not([disabled]):not([inert])",
40
+ "button:not([disabled]):not([inert])",
41
+ "iframe:not([inert])",
42
+ "audio:not([inert])",
43
+ "video:not([inert])",
44
+ "[contenteditable]:not([inert])",
45
+ "[tabindex]:not([inert])"
46
+ ].join(",");
47
+ var _MenuList = class extends import_Transition.default {
48
+ isOpen = false;
49
+ isHover = false;
50
+ get $options() {
51
+ const options = super.$options;
52
+ options.leaveKeep = true;
53
+ options.enterKeep = true;
54
+ return options;
55
+ }
56
+ mounted() {
57
+ this.__updateTabIndexes("close");
58
+ }
59
+ onMouseenter() {
60
+ this.isHover = true;
61
+ }
62
+ onMouseleave(event) {
63
+ this.isHover = false;
64
+ this.$emit("items-mouseleave", event);
65
+ }
66
+ open() {
67
+ if (this.isOpen) {
68
+ return;
69
+ }
70
+ const clickOutsideHandler = (event) => {
71
+ if (!this.$el.contains(event.target)) {
72
+ document.removeEventListener("click", clickOutsideHandler);
73
+ this.close();
74
+ }
75
+ };
76
+ document.addEventListener("click", clickOutsideHandler);
77
+ this.__updateTabIndexes("open");
78
+ this.$el.setAttribute("aria-hidden", "false");
79
+ this.isOpen = true;
80
+ this.enter();
81
+ this.$emit("items-open");
82
+ }
83
+ close() {
84
+ if (!this.isOpen) {
85
+ return;
86
+ }
87
+ this.$children.MenuList.forEach((menuItem) => {
88
+ menuItem.close();
89
+ });
90
+ if (document.activeElement instanceof HTMLElement && this.$el.contains(document.activeElement)) {
91
+ document.activeElement.blur();
92
+ }
93
+ this.$el.setAttribute("aria-hidden", "true");
94
+ this.__updateTabIndexes("close");
95
+ this.isOpen = false;
96
+ this.leave();
97
+ this.$emit("items-close");
98
+ }
99
+ toggle() {
100
+ console.log(this.$id, "toggle", this.isOpen);
101
+ if (this.isOpen) {
102
+ this.close();
103
+ } else {
104
+ this.open();
105
+ }
106
+ }
107
+ __updateTabIndexes(mode = "open") {
108
+ const focusableItems = Array.from(this.$el.querySelectorAll(FOCUSABLE_ELEMENTS)).filter((item) => this.__filterFocusableItems(item));
109
+ focusableItems.forEach((item) => {
110
+ if (mode === "close") {
111
+ item.setAttribute("tabindex", "-1");
112
+ } else {
113
+ item.removeAttribute("tabindex");
114
+ }
115
+ });
116
+ }
117
+ __filterFocusableItems(item) {
118
+ let ancestor = item.parentElement;
119
+ while (ancestor && (!ancestor.__base__ || !ancestor.__base__.has(this.constructor))) {
120
+ ancestor = ancestor.parentElement;
121
+ }
122
+ return ancestor === null || ancestor === this.$el;
123
+ }
124
+ };
125
+ var MenuList = _MenuList;
126
+ __publicField(MenuList, "config", {
127
+ ...import_Transition.default.config,
128
+ name: "MenuList",
129
+ emits: ["items-open", "items-close", "items-mouseleave"],
130
+ components: {
131
+ MenuList: _MenuList
132
+ }
133
+ });
134
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @typedef {MenuList & {
3
+ * $children: {
4
+ * MenuList: MenuList[]
5
+ * }
6
+ * }} MenuListInterface
7
+ */
8
+ /**
9
+ * MenuList class.
10
+ */
11
+ export default class MenuList extends Transition {
12
+ /**
13
+ * Config.
14
+ */
15
+ static config: {
16
+ name: string;
17
+ emits: string[];
18
+ components: {
19
+ MenuList: typeof MenuList;
20
+ };
21
+ options: {
22
+ enterFrom: StringConstructor;
23
+ enterActive: StringConstructor;
24
+ enterTo: StringConstructor;
25
+ enterKeep: BooleanConstructor;
26
+ leaveFrom: StringConstructor;
27
+ leaveActive: StringConstructor;
28
+ leaveTo: StringConstructor;
29
+ leaveKeep: BooleanConstructor;
30
+ };
31
+ };
32
+ /**
33
+ * Are the menu items visible?
34
+ * @type {boolean}
35
+ */
36
+ isOpen: boolean;
37
+ /**
38
+ * Wether the component is hovered.
39
+ * @type {boolean}
40
+ */
41
+ isHover: boolean;
42
+ /**
43
+ * Update tab indexes on mount.
44
+ *
45
+ * @returns {void}
46
+ */
47
+ mounted(): void;
48
+ /**
49
+ * Set hover state.
50
+ *
51
+ * @returns {void}
52
+ */
53
+ onMouseenter(): void;
54
+ /**
55
+ * Unset hover state.
56
+ *
57
+ * @param {MouseEvent} event
58
+ * @returns {void}
59
+ */
60
+ onMouseleave(event: MouseEvent): void;
61
+ /**
62
+ * Display the menu items.
63
+ *
64
+ * @returns {void}
65
+ */
66
+ open(): void;
67
+ /**
68
+ * Hide the menu items.
69
+ *
70
+ * @this {MenuListInterface}
71
+ * @returns {void}
72
+ */
73
+ close(this: MenuListInterface): void;
74
+ /**
75
+ * Toggle the menu items.
76
+ * @returns {void}
77
+ */
78
+ toggle(): void;
79
+ /**
80
+ * Update `tabindex` attribute of child focusable elements.
81
+ *
82
+ * @private
83
+ * @param {'open'|'close'} mode
84
+ * @returns {void}
85
+ */
86
+ private __updateTabIndexes;
87
+ /**
88
+ * Filter out items which are inside a child `MenuList` instance.
89
+ *
90
+ * @private
91
+ * @param {HTMLElement} item
92
+ * @returns {boolean}
93
+ */
94
+ private __filterFocusableItems;
95
+ }
96
+ export type MenuListInterface = MenuList & {
97
+ $children: {
98
+ MenuList: MenuList[];
99
+ };
100
+ };
101
+ import Transition from "../../primitives/Transition/Transition.js";
@@ -0,0 +1 @@
1
+ import n from"../../primitives/Transition/Transition.js";const o=["a[href]:not([inert])","area[href]:not([inert])","input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])","iframe:not([inert])","audio:not([inert])","video:not([inert])","[contenteditable]:not([inert])","[tabindex]:not([inert])"].join(",");class s extends n{static config={...n.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:s}};isOpen=!1;isHover=!1;get $options(){const e=super.$options;return e.leaveKeep=!0,e.enterKeep=!0,e}mounted(){this.__updateTabIndexes("close")}onMouseenter(){this.isHover=!0}onMouseleave(e){this.isHover=!1,this.$emit("items-mouseleave",e)}open(){if(this.isOpen)return;const e=t=>{this.$el.contains(t.target)||(document.removeEventListener("click",e),this.close())};document.addEventListener("click",e),this.__updateTabIndexes("open"),this.$el.setAttribute("aria-hidden","false"),this.isOpen=!0,this.enter(),this.$emit("items-open")}close(){!this.isOpen||(this.$children.MenuList.forEach(e=>{e.close()}),document.activeElement instanceof HTMLElement&&this.$el.contains(document.activeElement)&&document.activeElement.blur(),this.$el.setAttribute("aria-hidden","true"),this.__updateTabIndexes("close"),this.isOpen=!1,this.leave(),this.$emit("items-close"))}toggle(){console.log(this.$id,"toggle",this.isOpen),this.isOpen?this.close():this.open()}__updateTabIndexes(e="open"){Array.from(this.$el.querySelectorAll(o)).filter(i=>this.__filterFocusableItems(i)).forEach(i=>{e==="close"?i.setAttribute("tabindex","-1"):i.removeAttribute("tabindex")})}__filterFocusableItems(e){let t=e.parentElement;for(;t&&(!t.__base__||!t.__base__.has(this.constructor));)t=t.parentElement;return t===null||t===this.$el}}export{s as default};
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ 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));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // packages/ui/molecules/Menu/index.js
23
+ var Menu_exports = {};
24
+ __export(Menu_exports, {
25
+ Menu: () => import_Menu.default,
26
+ MenuBtn: () => import_MenuBtn.default,
27
+ MenuList: () => import_MenuList.default
28
+ });
29
+ module.exports = __toCommonJS(Menu_exports);
30
+ var import_Menu = __toESM(require("./Menu.cjs"), 1);
31
+ var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
32
+ var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
33
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,3 @@
1
+ export { default as Menu } from "./Menu.js";
2
+ export { default as MenuBtn } from "./MenuBtn.js";
3
+ export { default as MenuList } from "./MenuList.js";
@@ -0,0 +1 @@
1
+ import{default as a}from"./Menu.js";import{default as o}from"./MenuBtn.js";import{default as u}from"./MenuList.js";export{a as Menu,o as MenuBtn,u as MenuList};
@@ -3,54 +3,30 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
10
9
  };
11
- var __reExport = (target, module2, copyDefault, desc) => {
12
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
- for (let key of __getOwnPropNames(module2))
14
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
15
  }
17
- return target;
16
+ return to;
18
17
  };
19
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
- return (module2, temp) => {
21
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
- };
23
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
19
  var __publicField = (obj, key, value) => {
25
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
21
  return value;
27
22
  };
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
23
 
49
24
  // packages/ui/molecules/Modal/Modal.js
50
25
  var Modal_exports = {};
51
26
  __export(Modal_exports, {
52
27
  default: () => Modal
53
28
  });
29
+ module.exports = __toCommonJS(Modal_exports);
54
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
55
31
  var import_utils = require("@studiometa/js-toolkit/utils");
56
32
  var { trap, untrap, saveActiveElement } = (0, import_utils.focusTrap)();
@@ -108,47 +84,43 @@ var Modal = class extends import_js_toolkit.Base {
108
84
  this.close();
109
85
  }
110
86
  }
111
- open() {
112
- return __async(this, null, function* () {
113
- if (this.isOpen) {
114
- return Promise.resolve();
87
+ async open() {
88
+ if (this.isOpen) {
89
+ return Promise.resolve();
90
+ }
91
+ this.$refs.modal.setAttribute("aria-hidden", "false");
92
+ document.documentElement.style.overflow = "hidden";
93
+ this.isOpen = true;
94
+ this.$emit("open");
95
+ const refs = this.$refs;
96
+ return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
97
+ from: closed,
98
+ active,
99
+ to: open
100
+ }, "keep"))).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();
115
105
  }
116
- this.$refs.modal.setAttribute("aria-hidden", "false");
117
- document.documentElement.style.overflow = "hidden";
118
- this.isOpen = true;
119
- this.$emit("open");
120
- const refs = this.$refs;
121
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
122
- from: closed,
123
- active,
124
- to: open
125
- }, "keep"))).then(() => {
126
- if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {
127
- saveActiveElement();
128
- const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);
129
- autofocusElement.focus();
130
- }
131
- return Promise.resolve();
132
- });
106
+ return Promise.resolve();
133
107
  });
134
108
  }
135
- close() {
136
- return __async(this, null, function* () {
137
- if (!this.isOpen) {
138
- return Promise.resolve();
139
- }
140
- this.$refs.modal.setAttribute("aria-hidden", "true");
141
- document.documentElement.style.overflow = "";
142
- this.isOpen = false;
143
- untrap();
144
- this.$emit("close");
145
- const refs = this.$refs;
146
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
147
- from: open,
148
- active,
149
- to: closed
150
- }, "keep"))).then(() => Promise.resolve());
151
- });
109
+ async close() {
110
+ if (!this.isOpen) {
111
+ return Promise.resolve();
112
+ }
113
+ this.$refs.modal.setAttribute("aria-hidden", "true");
114
+ document.documentElement.style.overflow = "";
115
+ this.isOpen = false;
116
+ untrap();
117
+ this.$emit("close");
118
+ const refs = this.$refs;
119
+ return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
120
+ from: open,
121
+ active,
122
+ to: closed
123
+ }, "keep"))).then(() => Promise.resolve());
152
124
  }
153
125
  };
154
126
  __publicField(Modal, "config", {
@@ -172,5 +144,4 @@ __publicField(Modal, "config", {
172
144
  }
173
145
  }
174
146
  });
175
- module.exports = __toCommonJS(Modal_exports);
176
147
  if (module.exports.default) module.exports = module.exports.default;
@@ -79,7 +79,7 @@ export default class Modal extends Base {
79
79
  *
80
80
  * @this {ModalInterface}
81
81
  */
82
- mounted(): void;
82
+ mounted(this: ModalInterface): void;
83
83
  isOpen: boolean;
84
84
  __refsBackup: import("@studiometa/js-toolkit/Base/managers/RefsManager").default & ModalRefs;
85
85
  __refModalPlaceholder: Comment;
@@ -90,7 +90,7 @@ export default class Modal extends Base {
90
90
  * @this {ModalInterface}
91
91
  * @return {Modal} The Modal instance.
92
92
  */
93
- destroyed(): Modal;
93
+ destroyed(this: ModalInterface): Modal;
94
94
  /**
95
95
  * Close the modal on `ESC` and trap the tabulation.
96
96
  *
@@ -101,7 +101,7 @@ export default class Modal extends Base {
101
101
  * @param {Boolean} options.isDown Is it a keydown event?
102
102
  * @param {Boolean} options.ESC Is it the ESC key?
103
103
  */
104
- keyed({ event, isUp, isDown, ESC }: {
104
+ keyed(this: ModalInterface, { event, isUp, isDown, ESC }: {
105
105
  event: KeyboardEvent;
106
106
  isUp: boolean;
107
107
  isDown: boolean;
@@ -113,14 +113,14 @@ export default class Modal extends Base {
113
113
  * @this {ModalInterface}
114
114
  * @return {Promise<void>} The Modal instance.
115
115
  */
116
- open(): Promise<void>;
116
+ open(this: ModalInterface): Promise<void>;
117
117
  /**
118
118
  * Close the modal.
119
119
  *
120
120
  * @this {ModalInterface}
121
121
  * @return {Promise<void>} The Modal instance.
122
122
  */
123
- close(): Promise<void>;
123
+ close(this: ModalInterface): Promise<void>;
124
124
  }
125
125
  export type ModalRefs = {
126
126
  close: HTMLElement;
@@ -1,150 +1 @@
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
- var __async = (__this, __arguments, generator) => {
8
- return new Promise((resolve, reject) => {
9
- var fulfilled = (value) => {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- };
16
- var rejected = (value) => {
17
- try {
18
- step(generator.throw(value));
19
- } catch (e) {
20
- reject(e);
21
- }
22
- };
23
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
24
- step((generator = generator.apply(__this, __arguments)).next());
25
- });
26
- };
27
- import { Base } from "@studiometa/js-toolkit";
28
- import { transition, focusTrap } from "@studiometa/js-toolkit/utils";
29
- const { trap, untrap, saveActiveElement } = focusTrap();
30
- class Modal extends Base {
31
- get onOpenClick() {
32
- return this.open;
33
- }
34
- get onCloseClick() {
35
- return this.close;
36
- }
37
- get onOverlayClick() {
38
- return this.close;
39
- }
40
- mounted() {
41
- this.isOpen = false;
42
- this.close();
43
- if (this.$options.move) {
44
- const target = document.querySelector(this.$options.move) || document.body;
45
- this.__refsBackup = this.$refs;
46
- this.__refModalPlaceholder = document.createComment("");
47
- this.__refModalParentBackup = this.$refs.modal.parentElement || this.$el;
48
- this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder, this.$refs.modal);
49
- target.appendChild(this.$refs.modal);
50
- }
51
- }
52
- get $refs() {
53
- const $refs = super.$refs;
54
- if (this.$options.move && this.__refsBackup) {
55
- Object.entries(this.__refsBackup).forEach(([key, ref]) => {
56
- if (!$refs[key]) {
57
- $refs[key] = ref;
58
- }
59
- });
60
- }
61
- return $refs;
62
- }
63
- destroyed() {
64
- this.close();
65
- if (this.$options.move && this.__refModalParentBackup) {
66
- this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
67
- this.__refModalPlaceholder.remove();
68
- delete this.__refModalPlaceholder;
69
- delete this.__refModalParentBackup;
70
- }
71
- return this;
72
- }
73
- keyed({ event, isUp, isDown, ESC }) {
74
- if (!this.isOpen) {
75
- return;
76
- }
77
- if (isDown) {
78
- trap(this.$refs.modal, event);
79
- }
80
- if (ESC && isUp) {
81
- this.close();
82
- }
83
- }
84
- open() {
85
- return __async(this, null, function* () {
86
- if (this.isOpen) {
87
- return Promise.resolve();
88
- }
89
- this.$refs.modal.setAttribute("aria-hidden", "false");
90
- document.documentElement.style.overflow = "hidden";
91
- this.isOpen = true;
92
- this.$emit("open");
93
- const refs = this.$refs;
94
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
95
- from: closed,
96
- active,
97
- to: open
98
- }, "keep"))).then(() => {
99
- if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {
100
- saveActiveElement();
101
- const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);
102
- autofocusElement.focus();
103
- }
104
- return Promise.resolve();
105
- });
106
- });
107
- }
108
- close() {
109
- return __async(this, null, function* () {
110
- if (!this.isOpen) {
111
- return Promise.resolve();
112
- }
113
- this.$refs.modal.setAttribute("aria-hidden", "true");
114
- document.documentElement.style.overflow = "";
115
- this.isOpen = false;
116
- untrap();
117
- this.$emit("close");
118
- const refs = this.$refs;
119
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
120
- from: open,
121
- active,
122
- to: closed
123
- }, "keep"))).then(() => Promise.resolve());
124
- });
125
- }
126
- }
127
- __publicField(Modal, "config", {
128
- name: "Modal",
129
- refs: ["close", "container", "content", "modal", "open", "overlay"],
130
- emits: ["open", "close"],
131
- options: {
132
- move: String,
133
- autofocus: { type: String, default: "[autofocus]" },
134
- styles: {
135
- type: Object,
136
- default: () => ({
137
- modal: {
138
- closed: {
139
- opacity: "0",
140
- pointerEvents: "none",
141
- visibility: "hidden"
142
- }
143
- }
144
- })
145
- }
146
- }
147
- });
148
- export {
149
- Modal as default
150
- };
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"}}})}}};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"),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"),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};