@studiometa/ui 0.2.1 → 0.2.4

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 (136) hide show
  1. package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +47 -0
  2. package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +31 -0
  3. package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -0
  4. package/atoms/Cursor/Cursor.cjs +14 -22
  5. package/atoms/Cursor/Cursor.d.ts +2 -2
  6. package/atoms/Cursor/Cursor.js +1 -103
  7. package/atoms/Figure/Figure.cjs +9 -14
  8. package/atoms/Figure/Figure.d.ts +1 -1
  9. package/atoms/Figure/Figure.js +1 -27
  10. package/atoms/LargeText/LargeText.cjs +82 -0
  11. package/atoms/LargeText/LargeText.d.ts +94 -0
  12. package/atoms/LargeText/LargeText.js +1 -0
  13. package/atoms/LazyInclude/LazyInclude.cjs +67 -0
  14. package/atoms/LazyInclude/LazyInclude.d.ts +64 -0
  15. package/atoms/LazyInclude/LazyInclude.js +1 -0
  16. package/atoms/Prefetch/AbstractPrefetch.cjs +79 -0
  17. package/atoms/Prefetch/AbstractPrefetch.d.ts +52 -0
  18. package/atoms/Prefetch/AbstractPrefetch.js +1 -0
  19. package/atoms/Prefetch/PrefetchWhenOver.cjs +43 -0
  20. package/atoms/Prefetch/PrefetchWhenOver.d.ts +21 -0
  21. package/atoms/Prefetch/PrefetchWhenOver.js +1 -0
  22. package/atoms/Prefetch/PrefetchWhenVisible.cjs +44 -0
  23. package/atoms/Prefetch/PrefetchWhenVisible.d.ts +21 -0
  24. package/atoms/Prefetch/PrefetchWhenVisible.js +1 -0
  25. package/atoms/Prefetch/index.cjs +33 -0
  26. package/atoms/Prefetch/index.d.ts +3 -0
  27. package/atoms/Prefetch/index.js +1 -0
  28. package/atoms/index.cjs +19 -18
  29. package/atoms/index.d.ts +5 -1
  30. package/atoms/index.js +1 -6
  31. package/index.cjs +11 -15
  32. package/index.js +1 -3
  33. package/molecules/Accordion/Accordion.cjs +12 -34
  34. package/molecules/Accordion/Accordion.js +1 -35
  35. package/molecules/Accordion/AccordionCore.cjs +8 -13
  36. package/molecules/Accordion/AccordionCore.d.ts +2 -2
  37. package/molecules/Accordion/AccordionCore.js +1 -34
  38. package/molecules/Accordion/AccordionItem.cjs +70 -114
  39. package/molecules/Accordion/AccordionItem.d.ts +15 -16
  40. package/molecules/Accordion/AccordionItem.js +1 -178
  41. package/molecules/Menu/Menu.cjs +148 -0
  42. package/molecules/Menu/Menu.d.ts +140 -0
  43. package/molecules/Menu/Menu.js +1 -0
  44. package/molecules/Menu/MenuBtn.cjs +53 -0
  45. package/molecules/Menu/MenuBtn.d.ts +39 -0
  46. package/molecules/Menu/MenuBtn.js +1 -0
  47. package/molecules/Menu/MenuList.cjs +134 -0
  48. package/molecules/Menu/MenuList.d.ts +101 -0
  49. package/molecules/Menu/MenuList.js +1 -0
  50. package/molecules/Menu/index.cjs +33 -0
  51. package/molecules/Menu/index.d.ts +3 -0
  52. package/molecules/Menu/index.js +1 -0
  53. package/molecules/Modal/Modal.cjs +42 -72
  54. package/molecules/Modal/Modal.d.ts +11 -11
  55. package/molecules/Modal/Modal.js +1 -151
  56. package/molecules/Modal/ModalWithTransition.cjs +70 -0
  57. package/molecules/Modal/ModalWithTransition.d.ts +29 -0
  58. package/molecules/Modal/ModalWithTransition.js +1 -0
  59. package/molecules/Panel/Panel.cjs +114 -0
  60. package/molecules/Panel/Panel.d.ts +42 -0
  61. package/molecules/Panel/Panel.js +1 -0
  62. package/molecules/Slider/AbstractSliderChild.cjs +64 -0
  63. package/molecules/Slider/AbstractSliderChild.d.ts +59 -0
  64. package/molecules/Slider/AbstractSliderChild.js +1 -0
  65. package/molecules/Slider/Slider.cjs +230 -0
  66. package/molecules/Slider/Slider.d.ts +245 -0
  67. package/molecules/Slider/Slider.js +1 -0
  68. package/molecules/Slider/SliderBtn.cjs +58 -0
  69. package/molecules/Slider/SliderBtn.d.ts +31 -0
  70. package/molecules/Slider/SliderBtn.js +1 -0
  71. package/molecules/Slider/SliderCount.cjs +43 -0
  72. package/molecules/Slider/SliderCount.d.ts +21 -0
  73. package/molecules/Slider/SliderCount.js +1 -0
  74. package/molecules/Slider/SliderDots.cjs +48 -0
  75. package/molecules/Slider/SliderDots.d.ts +33 -0
  76. package/molecules/Slider/SliderDots.js +1 -0
  77. package/molecules/Slider/SliderDrag.cjs +40 -0
  78. package/molecules/Slider/SliderDrag.d.ts +16 -0
  79. package/molecules/Slider/SliderDrag.js +1 -0
  80. package/molecules/Slider/SliderItem.cjs +107 -0
  81. package/molecules/Slider/SliderItem.d.ts +106 -0
  82. package/molecules/Slider/SliderItem.js +1 -0
  83. package/molecules/Slider/SliderProgress.cjs +47 -0
  84. package/molecules/Slider/SliderProgress.d.ts +27 -0
  85. package/molecules/Slider/SliderProgress.js +1 -0
  86. package/molecules/Slider/index.cjs +43 -0
  87. package/molecules/Slider/index.d.ts +8 -0
  88. package/molecules/Slider/index.js +1 -0
  89. package/molecules/Sticky/Sticky.cjs +11 -19
  90. package/molecules/Sticky/Sticky.d.ts +8 -8
  91. package/molecules/Sticky/Sticky.js +1 -107
  92. package/molecules/TableOfContent/TableOfContent.cjs +66 -0
  93. package/molecules/TableOfContent/TableOfContent.d.ts +59 -0
  94. package/molecules/TableOfContent/TableOfContent.js +1 -0
  95. package/molecules/TableOfContent/TableOfContentAnchor.cjs +60 -0
  96. package/molecules/TableOfContent/TableOfContentAnchor.d.ts +36 -0
  97. package/molecules/TableOfContent/TableOfContentAnchor.js +1 -0
  98. package/molecules/TableOfContent/index.cjs +31 -0
  99. package/molecules/TableOfContent/index.d.ts +2 -0
  100. package/molecules/TableOfContent/index.js +1 -0
  101. package/molecules/Tabs/Tabs.cjs +54 -82
  102. package/molecules/Tabs/Tabs.d.ts +7 -8
  103. package/molecules/Tabs/Tabs.js +1 -126
  104. package/molecules/index.cjs +18 -17
  105. package/molecules/index.d.ts +6 -1
  106. package/molecules/index.js +1 -12
  107. package/organisms/Frame/Frame.cjs +171 -0
  108. package/organisms/Frame/Frame.d.ts +119 -0
  109. package/organisms/Frame/Frame.js +1 -0
  110. package/organisms/Frame/FrameAnchor.cjs +43 -0
  111. package/organisms/Frame/FrameAnchor.d.ts +35 -0
  112. package/organisms/Frame/FrameAnchor.js +1 -0
  113. package/organisms/Frame/FrameForm.cjs +43 -0
  114. package/organisms/Frame/FrameForm.d.ts +32 -0
  115. package/organisms/Frame/FrameForm.js +1 -0
  116. package/organisms/Frame/FrameTarget.cjs +92 -0
  117. package/organisms/Frame/FrameTarget.d.ts +47 -0
  118. package/organisms/Frame/FrameTarget.js +1 -0
  119. package/organisms/Frame/index.cjs +35 -0
  120. package/organisms/Frame/index.d.ts +4 -0
  121. package/organisms/Frame/index.js +1 -0
  122. package/organisms/index.cjs +9 -12
  123. package/organisms/index.d.ts +1 -1
  124. package/organisms/index.js +1 -0
  125. package/package.json +3 -4
  126. package/primitives/Draggable/Draggable.cjs +15 -28
  127. package/primitives/Draggable/Draggable.d.ts +0 -5
  128. package/primitives/Draggable/Draggable.js +1 -38
  129. package/primitives/Sentinel/Sentinel.cjs +8 -13
  130. package/primitives/Sentinel/Sentinel.js +1 -15
  131. package/primitives/Transition/Transition.cjs +66 -0
  132. package/primitives/Transition/Transition.d.ts +67 -0
  133. package/primitives/Transition/Transition.js +1 -0
  134. package/primitives/index.cjs +12 -17
  135. package/primitives/index.d.ts +1 -0
  136. package/primitives/index.js +1 -6
@@ -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)();
@@ -75,7 +51,6 @@ var Modal = class extends import_js_toolkit.Base {
75
51
  this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder, this.$refs.modal);
76
52
  target.appendChild(this.$refs.modal);
77
53
  }
78
- return this;
79
54
  }
80
55
  get $refs() {
81
56
  const $refs = super.$refs;
@@ -109,47 +84,43 @@ var Modal = class extends import_js_toolkit.Base {
109
84
  this.close();
110
85
  }
111
86
  }
112
- open() {
113
- return __async(this, null, function* () {
114
- if (this.isOpen) {
115
- return Promise.resolve(this);
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();
116
105
  }
117
- this.$refs.modal.setAttribute("aria-hidden", "false");
118
- document.documentElement.style.overflow = "hidden";
119
- this.isOpen = true;
120
- this.$emit("open");
121
- const refs = this.$refs;
122
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
123
- from: closed,
124
- active,
125
- to: open
126
- }, "keep"))).then(() => {
127
- if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {
128
- saveActiveElement();
129
- const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);
130
- autofocusElement.focus();
131
- }
132
- return Promise.resolve(this);
133
- });
106
+ return Promise.resolve();
134
107
  });
135
108
  }
136
- close() {
137
- return __async(this, null, function* () {
138
- if (!this.isOpen) {
139
- return Promise.resolve(this);
140
- }
141
- this.$refs.modal.setAttribute("aria-hidden", "true");
142
- document.documentElement.style.overflow = "";
143
- this.isOpen = false;
144
- untrap();
145
- this.$emit("close");
146
- const refs = this.$refs;
147
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
148
- from: open,
149
- active,
150
- to: closed
151
- }, "keep"))).then(() => Promise.resolve(this));
152
- });
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());
153
124
  }
154
125
  };
155
126
  __publicField(Modal, "config", {
@@ -173,5 +144,4 @@ __publicField(Modal, "config", {
173
144
  }
174
145
  }
175
146
  });
176
- module.exports = __toCommonJS(Modal_exports);
177
147
  if (module.exports.default) module.exports = module.exports.default;
@@ -8,8 +8,7 @@
8
8
  * @property {HTMLElement} overlay
9
9
  */
10
10
  /**
11
- * @typedef {import('@studiometa/js-toolkit/utils/css/styles.js').CssStyleObject} CssStyleObject
12
- * @typedef {Partial<Record<'open'|'active'|'closed', string|CssStyleObject>>} ModalStates
11
+ * @typedef {Partial<Record<'open'|'active'|'closed', string|Partial<CSSStyleDeclaration>>>} ModalStates
13
12
  * @typedef {Partial<Record<keyof ModalRefs, ModalStates>>} ModalStylesOption
14
13
  */
15
14
  /**
@@ -29,6 +28,7 @@
29
28
  */
30
29
  /**
31
30
  * @typedef {Modal & ModalPrivateInterface} ModalInterface
31
+ * @typedef {typeof Modal} ModalConstructor
32
32
  */
33
33
  /**
34
34
  * Modal class.
@@ -79,7 +79,7 @@ export default class Modal extends Base {
79
79
  *
80
80
  * @this {ModalInterface}
81
81
  */
82
- mounted(): ModalInterface;
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;
@@ -111,16 +111,16 @@ export default class Modal extends Base {
111
111
  * Open the modal.
112
112
  *
113
113
  * @this {ModalInterface}
114
- * @return {Promise<ModalInterface>} The Modal instance.
114
+ * @return {Promise<void>} The Modal instance.
115
115
  */
116
- open(): Promise<ModalInterface>;
116
+ open(this: ModalInterface): Promise<void>;
117
117
  /**
118
118
  * Close the modal.
119
119
  *
120
120
  * @this {ModalInterface}
121
- * @return {Promise<ModalInterface>} The Modal instance.
121
+ * @return {Promise<void>} The Modal instance.
122
122
  */
123
- close(): Promise<ModalInterface>;
123
+ close(this: ModalInterface): Promise<void>;
124
124
  }
125
125
  export type ModalRefs = {
126
126
  close: HTMLElement;
@@ -130,8 +130,7 @@ export type ModalRefs = {
130
130
  open: HTMLElement;
131
131
  overlay: HTMLElement;
132
132
  };
133
- export type CssStyleObject = import('@studiometa/js-toolkit/utils/css/styles.js').CssStyleObject;
134
- export type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | CssStyleObject>>;
133
+ export type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | Partial<CSSStyleDeclaration>>>;
135
134
  export type ModalStylesOption = Partial<Record<keyof ModalRefs, ModalStates>>;
136
135
  export type ModalOptions = {
137
136
  /**
@@ -156,4 +155,5 @@ export type ModalPrivateInterface = {
156
155
  refModalUnbindGetRefFilter: Function;
157
156
  };
158
157
  export type ModalInterface = Modal & ModalPrivateInterface;
158
+ export type ModalConstructor = typeof Modal;
159
159
  import { Base } from "@studiometa/js-toolkit";
@@ -1,151 +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
- return this;
52
- }
53
- get $refs() {
54
- const $refs = super.$refs;
55
- if (this.$options.move && this.__refsBackup) {
56
- Object.entries(this.__refsBackup).forEach(([key, ref]) => {
57
- if (!$refs[key]) {
58
- $refs[key] = ref;
59
- }
60
- });
61
- }
62
- return $refs;
63
- }
64
- destroyed() {
65
- this.close();
66
- if (this.$options.move && this.__refModalParentBackup) {
67
- this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
68
- this.__refModalPlaceholder.remove();
69
- delete this.__refModalPlaceholder;
70
- delete this.__refModalParentBackup;
71
- }
72
- return this;
73
- }
74
- keyed({ event, isUp, isDown, ESC }) {
75
- if (!this.isOpen) {
76
- return;
77
- }
78
- if (isDown) {
79
- trap(this.$refs.modal, event);
80
- }
81
- if (ESC && isUp) {
82
- this.close();
83
- }
84
- }
85
- open() {
86
- return __async(this, null, function* () {
87
- if (this.isOpen) {
88
- return Promise.resolve(this);
89
- }
90
- this.$refs.modal.setAttribute("aria-hidden", "false");
91
- document.documentElement.style.overflow = "hidden";
92
- this.isOpen = true;
93
- this.$emit("open");
94
- const refs = this.$refs;
95
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
96
- from: closed,
97
- active,
98
- to: open
99
- }, "keep"))).then(() => {
100
- if (this.$options.autofocus && this.$refs.modal.querySelector(this.$options.autofocus)) {
101
- saveActiveElement();
102
- const autofocusElement = this.$refs.modal.querySelector(this.$options.autofocus);
103
- autofocusElement.focus();
104
- }
105
- return Promise.resolve(this);
106
- });
107
- });
108
- }
109
- close() {
110
- return __async(this, null, function* () {
111
- if (!this.isOpen) {
112
- return Promise.resolve(this);
113
- }
114
- this.$refs.modal.setAttribute("aria-hidden", "true");
115
- document.documentElement.style.overflow = "";
116
- this.isOpen = false;
117
- untrap();
118
- this.$emit("close");
119
- const refs = this.$refs;
120
- return Promise.all(Object.entries(this.$options.styles).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
121
- from: open,
122
- active,
123
- to: closed
124
- }, "keep"))).then(() => Promise.resolve(this));
125
- });
126
- }
127
- }
128
- __publicField(Modal, "config", {
129
- name: "Modal",
130
- refs: ["close", "container", "content", "modal", "open", "overlay"],
131
- emits: ["open", "close"],
132
- options: {
133
- move: String,
134
- autofocus: { type: String, default: "[autofocus]" },
135
- styles: {
136
- type: Object,
137
- default: () => ({
138
- modal: {
139
- closed: {
140
- opacity: "0",
141
- pointerEvents: "none",
142
- visibility: "hidden"
143
- }
144
- }
145
- })
146
- }
147
- }
148
- });
149
- export {
150
- Modal as default
151
- };
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};
@@ -0,0 +1,70 @@
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/Modal/ModalWithTransition.js
28
+ var ModalWithTransition_exports = {};
29
+ __export(ModalWithTransition_exports, {
30
+ default: () => ModalWithTransition
31
+ });
32
+ module.exports = __toCommonJS(ModalWithTransition_exports);
33
+ var import_Modal = __toESM(require("./Modal.cjs"), 1);
34
+ var ModalWithTransition = class extends import_Modal.default {
35
+ open() {
36
+ this.$refs.modal.style.visibility = "";
37
+ return super.open();
38
+ }
39
+ async close() {
40
+ await super.close();
41
+ this.$refs.modal.style.visibility = "hidden";
42
+ return Promise.resolve();
43
+ }
44
+ };
45
+ __publicField(ModalWithTransition, "config", {
46
+ name: "ModalWithTransition",
47
+ options: {
48
+ styles: {
49
+ type: Object,
50
+ default: () => ({
51
+ modal: {
52
+ closed: {
53
+ opacity: "0",
54
+ pointerEvents: "none"
55
+ },
56
+ active: "transition duration-500 ease-out-expo"
57
+ },
58
+ overlay: {
59
+ closed: "opacity-0",
60
+ active: "transition duration-500 ease-out-expo"
61
+ },
62
+ container: {
63
+ closed: "transform scale-95 opacity-0",
64
+ active: "transition duration-500 ease-out-expo"
65
+ }
66
+ })
67
+ }
68
+ }
69
+ });
70
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {import('./Modal.js').ModalInterface} ModalInterface
3
+ * @typedef {import('./Modal.js').ModalStylesOption} ModalStylesOption
4
+ * @typedef {ModalInterface & ModalWithTransition} ModalWithTransitionInterface
5
+ */
6
+ /**
7
+ * ModalWithTransition class.
8
+ */
9
+ export default class ModalWithTransition extends Modal {
10
+ /**
11
+ * Modal options.
12
+ */
13
+ static config: {
14
+ name: string;
15
+ options: {
16
+ styles: {
17
+ type: ObjectConstructor;
18
+ /**
19
+ * @return {ModalStylesOption}
20
+ */
21
+ default: () => ModalStylesOption;
22
+ };
23
+ };
24
+ };
25
+ }
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";
@@ -0,0 +1 @@
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};
@@ -0,0 +1,114 @@
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/Panel/Panel.js
28
+ var Panel_exports = {};
29
+ __export(Panel_exports, {
30
+ default: () => Panel
31
+ });
32
+ module.exports = __toCommonJS(Panel_exports);
33
+ var import_utils = require("@studiometa/js-toolkit/utils");
34
+ var import_Modal = __toESM(require("../Modal/Modal.cjs"), 1);
35
+ var _Panel = class extends import_Modal.default {
36
+ get translateClass() {
37
+ return _Panel.translateClasses[this.$options.position] ?? _Panel.translateClasses[_Panel.config.options.position.default];
38
+ }
39
+ get containerOffset() {
40
+ const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = this.$refs.container;
41
+ const store = {
42
+ top: {
43
+ translateY: (offsetTop + offsetHeight) * -1
44
+ },
45
+ right: {
46
+ translateX: window.innerWidth - offsetLeft + offsetWidth * 2
47
+ },
48
+ bottom: {
49
+ translateY: window.innerHeight - offsetTop + offsetHeight * 2
50
+ },
51
+ left: {
52
+ translateX: (offsetLeft + offsetWidth) * -1
53
+ }
54
+ };
55
+ return (0, import_utils.matrix)(store[this.$options.position]);
56
+ }
57
+ async open() {
58
+ if (this.isOpen) {
59
+ return Promise.resolve();
60
+ }
61
+ this.$refs.modal.classList.remove("pointer-events-none");
62
+ (0, import_utils.transition)(this.$refs.container, {
63
+ from: {
64
+ transform: this.containerOffset
65
+ },
66
+ to: {
67
+ transform: "none"
68
+ }
69
+ }, "keep");
70
+ (0, import_utils.transition)(this.$refs.overlay, {
71
+ from: "opacity-0"
72
+ });
73
+ return super.open();
74
+ }
75
+ async close() {
76
+ if (!this.isOpen || this.isClosing) {
77
+ return Promise.resolve();
78
+ }
79
+ this.isClosing = true;
80
+ this.$refs.modal.classList.add("pointer-events-none");
81
+ await Promise.all([
82
+ (0, import_utils.transition)(this.$refs.container, {
83
+ from: {
84
+ transform: "none"
85
+ },
86
+ to: {
87
+ transform: this.containerOffset
88
+ }
89
+ }, "keep"),
90
+ (0, import_utils.transition)(this.$refs.overlay, {
91
+ to: "opacity-0"
92
+ }, "keep")
93
+ ]);
94
+ this.isClosing = false;
95
+ return super.close();
96
+ }
97
+ };
98
+ var Panel = _Panel;
99
+ __publicField(Panel, "config", {
100
+ name: "Panel",
101
+ options: {
102
+ position: {
103
+ type: String,
104
+ default: "left"
105
+ }
106
+ }
107
+ });
108
+ __publicField(Panel, "translateClasses", {
109
+ top: "-translate-y-full",
110
+ right: "translate-x-full",
111
+ bottom: "translate-y-full",
112
+ left: "-translate-x-full"
113
+ });
114
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @typedef {import('../Modal/Modal.js').ModalInterface} ModalInterface
3
+ * @typedef {Panel & ModalInterface} PanelInterface
4
+ * @typedef {typeof Modal} ModalConstructor
5
+ */
6
+ /**
7
+ * Panel class.
8
+ */
9
+ export default class Panel extends Modal {
10
+ /**
11
+ * Config.
12
+ */
13
+ static config: {
14
+ name: string;
15
+ options: {
16
+ position: {
17
+ type: StringConstructor;
18
+ default: string;
19
+ };
20
+ };
21
+ };
22
+ static translateClasses: {
23
+ top: string;
24
+ right: string;
25
+ bottom: string;
26
+ left: string;
27
+ };
28
+ /**
29
+ * Get the translation class.
30
+ * @returns {string}
31
+ */
32
+ get translateClass(): string;
33
+ /**
34
+ * @this {PanelInterface}
35
+ */
36
+ get containerOffset(): string;
37
+ isClosing: boolean;
38
+ }
39
+ export type ModalInterface = import('../Modal/Modal.js').ModalInterface;
40
+ export type PanelInterface = Panel & ModalInterface;
41
+ export type ModalConstructor = typeof Modal;
42
+ import Modal from "../Modal/Modal.js";
@@ -0,0 +1 @@
1
+ import{transition as s,matrix as a}from"@studiometa/js-toolkit/utils";import l from"../Modal/Modal.js";class t extends l{static config={name:"Panel",options:{position:{type:String,default:"left"}}};static translateClasses={top:"-translate-y-full",right:"translate-x-full",bottom:"translate-y-full",left:"-translate-x-full"};get translateClass(){return t.translateClasses[this.$options.position]??t.translateClasses[t.config.options.position.default]}get containerOffset(){const{offsetTop:e,offsetLeft:o,offsetWidth:n,offsetHeight:i}=this.$refs.container,r={top:{translateY:(e+i)*-1},right:{translateX:window.innerWidth-o+n*2},bottom:{translateY:window.innerHeight-e+i*2},left:{translateX:(o+n)*-1}};return a(r[this.$options.position])}async open(){return this.isOpen?Promise.resolve():(this.$refs.modal.classList.remove("pointer-events-none"),s(this.$refs.container,{from:{transform:this.containerOffset},to:{transform:"none"}},"keep"),s(this.$refs.overlay,{from:"opacity-0"}),super.open())}async close(){return!this.isOpen||this.isClosing?Promise.resolve():(this.isClosing=!0,this.$refs.modal.classList.add("pointer-events-none"),await Promise.all([s(this.$refs.container,{from:{transform:"none"},to:{transform:this.containerOffset}},"keep"),s(this.$refs.overlay,{to:"opacity-0"},"keep")]),this.isClosing=!1,super.close())}}export{t as default};