@studiometa/ui 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +37 -1
  2. package/atoms/Cursor/Cursor.cjs +129 -0
  3. package/{Cursor.d.ts → atoms/Cursor/Cursor.d.ts} +0 -0
  4. package/atoms/Cursor/Cursor.js +103 -0
  5. package/atoms/Figure/Figure.cjs +53 -0
  6. package/atoms/Figure/Figure.d.ts +31 -0
  7. package/atoms/Figure/Figure.js +27 -0
  8. package/atoms/index.cjs +38 -0
  9. package/atoms/index.d.ts +2 -0
  10. package/atoms/index.js +6 -0
  11. package/index.cjs +26 -0
  12. package/index.d.ts +3 -6
  13. package/index.js +3 -6
  14. package/molecules/Accordion/Accordion.cjs +65 -0
  15. package/{Accordion/index.d.ts → molecules/Accordion/Accordion.d.ts} +5 -6
  16. package/molecules/Accordion/Accordion.js +35 -0
  17. package/molecules/Accordion/AccordionCore.cjs +60 -0
  18. package/{Accordion/Accordion.d.ts → molecules/Accordion/AccordionCore.d.ts} +0 -0
  19. package/molecules/Accordion/AccordionCore.js +34 -0
  20. package/molecules/Accordion/AccordionItem.cjs +208 -0
  21. package/{Accordion → molecules/Accordion}/AccordionItem.d.ts +3 -3
  22. package/molecules/Accordion/AccordionItem.js +178 -0
  23. package/molecules/Modal/Modal.cjs +177 -0
  24. package/{Modal.d.ts → molecules/Modal/Modal.d.ts} +0 -0
  25. package/molecules/Modal/Modal.js +151 -0
  26. package/molecules/Sticky/Sticky.cjs +133 -0
  27. package/molecules/Sticky/Sticky.d.ts +141 -0
  28. package/molecules/Sticky/Sticky.js +107 -0
  29. package/molecules/Tabs/Tabs.cjs +152 -0
  30. package/{Tabs.d.ts → molecules/Tabs/Tabs.d.ts} +0 -0
  31. package/molecules/Tabs/Tabs.js +126 -0
  32. package/molecules/index.cjs +44 -0
  33. package/molecules/index.d.ts +5 -0
  34. package/molecules/index.js +12 -0
  35. package/organisms/index.cjs +23 -0
  36. package/organisms/index.d.ts +1 -0
  37. package/organisms/index.js +0 -0
  38. package/package.json +2 -2
  39. package/primitives/Draggable/Draggable.cjs +64 -0
  40. package/{Draggable.d.ts → primitives/Draggable/Draggable.d.ts} +0 -0
  41. package/primitives/Draggable/Draggable.js +38 -0
  42. package/primitives/Sentinel/Sentinel.cjs +41 -0
  43. package/primitives/Sentinel/Sentinel.d.ts +12 -0
  44. package/primitives/Sentinel/Sentinel.js +15 -0
  45. package/primitives/index.cjs +38 -0
  46. package/primitives/index.d.ts +2 -0
  47. package/primitives/index.js +6 -0
  48. package/Accordion/Accordion.js +0 -29
  49. package/Accordion/AccordionItem.js +0 -197
  50. package/Accordion/index.js +0 -12
  51. package/Cursor.js +0 -121
  52. package/Draggable.js +0 -31
  53. package/Modal.js +0 -167
  54. package/Tabs.js +0 -106
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
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 });
16
+ }
17
+ return target;
18
+ };
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);
24
+ var __publicField = (obj, key, value) => {
25
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ return value;
27
+ };
28
+
29
+ // packages/ui/molecules/Accordion/AccordionCore.js
30
+ var AccordionCore_exports = {};
31
+ __export(AccordionCore_exports, {
32
+ default: () => Accordion
33
+ });
34
+ var import_js_toolkit = require("@studiometa/js-toolkit");
35
+ var Accordion = class extends import_js_toolkit.Base {
36
+ onAccordionItemOpen(index) {
37
+ const accordionItem = this.$children.AccordionItem[index];
38
+ this.$emit("open", accordionItem, index);
39
+ if (this.$options.autoclose) {
40
+ this.$children.AccordionItem.filter((el, i) => index !== i).forEach((item) => item.close());
41
+ }
42
+ }
43
+ onAccordionItemClose(index) {
44
+ const accordionItem = this.$children.AccordionItem[index];
45
+ this.$emit("close", accordionItem, index);
46
+ }
47
+ };
48
+ __publicField(Accordion, "config", {
49
+ name: "Accordion",
50
+ emits: ["open", "close"],
51
+ options: {
52
+ autoclose: Boolean,
53
+ item: {
54
+ type: Object,
55
+ default: () => ({})
56
+ }
57
+ }
58
+ });
59
+ module.exports = __toCommonJS(AccordionCore_exports);
60
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { Base } from "@studiometa/js-toolkit";
8
+ class Accordion extends Base {
9
+ onAccordionItemOpen(index) {
10
+ const accordionItem = this.$children.AccordionItem[index];
11
+ this.$emit("open", accordionItem, index);
12
+ if (this.$options.autoclose) {
13
+ this.$children.AccordionItem.filter((el, i) => index !== i).forEach((item) => item.close());
14
+ }
15
+ }
16
+ onAccordionItemClose(index) {
17
+ const accordionItem = this.$children.AccordionItem[index];
18
+ this.$emit("close", accordionItem, index);
19
+ }
20
+ }
21
+ __publicField(Accordion, "config", {
22
+ name: "Accordion",
23
+ emits: ["open", "close"],
24
+ options: {
25
+ autoclose: Boolean,
26
+ item: {
27
+ type: Object,
28
+ default: () => ({})
29
+ }
30
+ }
31
+ });
32
+ export {
33
+ Accordion as default
34
+ };
@@ -0,0 +1,208 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
11
+ var __objRest = (source, exclude) => {
12
+ var target = {};
13
+ for (var prop in source)
14
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
15
+ target[prop] = source[prop];
16
+ if (source != null && __getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(source)) {
18
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
19
+ target[prop] = source[prop];
20
+ }
21
+ return target;
22
+ };
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __reExport = (target, module2, copyDefault, desc) => {
28
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
29
+ for (let key of __getOwnPropNames(module2))
30
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
31
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
32
+ }
33
+ return target;
34
+ };
35
+ var __toESM = (module2, isNodeMode) => {
36
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
37
+ };
38
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
39
+ return (module2, temp) => {
40
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
41
+ };
42
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
43
+ var __publicField = (obj, key, value) => {
44
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
45
+ return value;
46
+ };
47
+ var __async = (__this, __arguments, generator) => {
48
+ return new Promise((resolve, reject) => {
49
+ var fulfilled = (value) => {
50
+ try {
51
+ step(generator.next(value));
52
+ } catch (e) {
53
+ reject(e);
54
+ }
55
+ };
56
+ var rejected = (value) => {
57
+ try {
58
+ step(generator.throw(value));
59
+ } catch (e) {
60
+ reject(e);
61
+ }
62
+ };
63
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
+ step((generator = generator.apply(__this, __arguments)).next());
65
+ });
66
+ };
67
+
68
+ // packages/ui/molecules/Accordion/AccordionItem.js
69
+ var AccordionItem_exports = {};
70
+ __export(AccordionItem_exports, {
71
+ default: () => AccordionItem
72
+ });
73
+ var import_deepmerge = __toESM(require("deepmerge"), 1);
74
+ var import_js_toolkit = require("@studiometa/js-toolkit");
75
+ var import_utils = require("@studiometa/js-toolkit/utils");
76
+ var import_AccordionCore = __toESM(require("./AccordionCore.cjs"), 1);
77
+ var _AccordionItem = class extends import_js_toolkit.Base {
78
+ mounted() {
79
+ if (this.$parent && this.$parent instanceof import_AccordionCore.default && this.$parent.$options.item) {
80
+ Object.entries(this.$parent.$options.item).forEach(([key, value]) => {
81
+ if (key in this.$options) {
82
+ const type = _AccordionItem.config.options[key].type || _AccordionItem.config.options[key];
83
+ if (type === Array || type === Object) {
84
+ this.$options[key] = (0, import_deepmerge.default)(this.$options[key], value);
85
+ } else {
86
+ this.$options[key] = value;
87
+ }
88
+ }
89
+ });
90
+ }
91
+ this.$refs.btn.setAttribute("id", this.$id);
92
+ this.$refs.btn.setAttribute("aria-controls", this.contentId);
93
+ this.$refs.content.setAttribute("aria-labelledby", this.$id);
94
+ this.$refs.content.setAttribute("id", this.contentId);
95
+ const { isOpen } = this.$options;
96
+ this.updateAttributes(isOpen);
97
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
98
+ const refs = this.$refs;
99
+ Object.entries(otherStyles).filter(([refName]) => refs[refName]).forEach(([refName, { open, closed } = { open: "", closed: "" }]) => {
100
+ (0, import_utils.transition)(refs[refName], { to: isOpen ? open : closed }, "keep");
101
+ });
102
+ }
103
+ destroyed() {
104
+ this.$refs.container.style.visibility = "";
105
+ this.$refs.container.style.height = "";
106
+ }
107
+ onBtnClick() {
108
+ if (this.$options.isOpen) {
109
+ this.close();
110
+ } else {
111
+ this.open();
112
+ }
113
+ }
114
+ get contentId() {
115
+ return `content-${this.$id}`;
116
+ }
117
+ updateAttributes(isOpen) {
118
+ this.$refs.container.style.visibility = isOpen ? "" : "invisible";
119
+ this.$refs.container.style.height = isOpen ? "" : "0";
120
+ this.$refs.content.setAttribute("aria-hidden", isOpen ? "false" : "true");
121
+ this.$refs.btn.setAttribute("aria-expanded", isOpen ? "true" : "false");
122
+ }
123
+ open() {
124
+ return __async(this, null, function* () {
125
+ if (this.$options.isOpen) {
126
+ return;
127
+ }
128
+ this.$log("open");
129
+ this.$emit("open");
130
+ this.$options.isOpen = true;
131
+ this.updateAttributes(this.$options.isOpen);
132
+ this.$refs.container.style.visibility = "";
133
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
134
+ const refs = this.$refs;
135
+ yield Promise.all([
136
+ (0, import_utils.transition)(refs.container, {
137
+ from: { height: 0 },
138
+ active: container.active,
139
+ to: { height: `${refs.content.offsetHeight}px` }
140
+ }).then(() => {
141
+ if (this.$options.isOpen) {
142
+ refs.content.style.position = "";
143
+ }
144
+ return Promise.resolve();
145
+ }),
146
+ ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
147
+ from: closed,
148
+ active,
149
+ to: open
150
+ }, "keep"))
151
+ ]);
152
+ });
153
+ }
154
+ close() {
155
+ return __async(this, null, function* () {
156
+ if (!this.$options.isOpen) {
157
+ return;
158
+ }
159
+ this.$log("close");
160
+ this.$emit("close");
161
+ this.$options.isOpen = false;
162
+ const height = this.$refs.container.offsetHeight;
163
+ this.$refs.content.style.position = "absolute";
164
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
165
+ const refs = this.$refs;
166
+ yield Promise.all([
167
+ (0, import_utils.transition)(refs.container, {
168
+ from: { height: `${height}px` },
169
+ active: container.active,
170
+ to: { height: "0" }
171
+ }).then(() => {
172
+ if (!this.$options.isOpen) {
173
+ refs.container.style.height = "0";
174
+ refs.container.style.visibility = "invisible";
175
+ this.updateAttributes(this.$options.isOpen);
176
+ }
177
+ return Promise.resolve();
178
+ }),
179
+ ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => (0, import_utils.transition)(refs[refName], {
180
+ from: open,
181
+ active,
182
+ to: closed
183
+ }, "keep"))
184
+ ]);
185
+ });
186
+ }
187
+ };
188
+ var AccordionItem = _AccordionItem;
189
+ __publicField(AccordionItem, "config", {
190
+ name: "AccordionItem",
191
+ refs: ["btn", "content", "container"],
192
+ emits: ["open", "close"],
193
+ options: {
194
+ isOpen: Boolean,
195
+ styles: {
196
+ type: Object,
197
+ default: () => ({
198
+ container: {
199
+ open: "",
200
+ active: "",
201
+ closed: ""
202
+ }
203
+ })
204
+ }
205
+ }
206
+ });
207
+ module.exports = __toCommonJS(AccordionItem_exports);
208
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @typedef {import('@studiometa/js-toolkit/Base').BaseOptions} BaseOptions
3
- * @typedef {import('./Accordion.js').AccordionInterface} AccordionInterface
3
+ * @typedef {import('./AccordionCore.js').AccordionInterface} AccordionInterface
4
4
  */
5
5
  /**
6
6
  * @typedef {Object} AccordionItemRefs
@@ -95,7 +95,7 @@ export default class AccordionItem extends Base {
95
95
  close(): Promise<void>;
96
96
  }
97
97
  export type BaseOptions = import('@studiometa/js-toolkit/Base').BaseOptions;
98
- export type AccordionInterface = import('./Accordion.js').AccordionInterface;
98
+ export type AccordionInterface = import('./AccordionCore.js').AccordionInterface;
99
99
  export type AccordionItemRefs = {
100
100
  btn: HTMLElement;
101
101
  content: HTMLElement;
@@ -120,4 +120,4 @@ export type AccordionItemPrivateInterface = {
120
120
  };
121
121
  export type AccordionItemInterface = AccordionItem & AccordionItemPrivateInterface;
122
122
  import { Base } from "@studiometa/js-toolkit";
123
- import Accordion from "./Accordion.js";
123
+ import Accordion from "./AccordionCore.js";
@@ -0,0 +1,178 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __objRest = (source, exclude) => {
7
+ var target = {};
8
+ for (var prop in source)
9
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
10
+ target[prop] = source[prop];
11
+ if (source != null && __getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(source)) {
13
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
14
+ target[prop] = source[prop];
15
+ }
16
+ return target;
17
+ };
18
+ var __publicField = (obj, key, value) => {
19
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
+ return value;
21
+ };
22
+ var __async = (__this, __arguments, generator) => {
23
+ return new Promise((resolve, reject) => {
24
+ var fulfilled = (value) => {
25
+ try {
26
+ step(generator.next(value));
27
+ } catch (e) {
28
+ reject(e);
29
+ }
30
+ };
31
+ var rejected = (value) => {
32
+ try {
33
+ step(generator.throw(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
39
+ step((generator = generator.apply(__this, __arguments)).next());
40
+ });
41
+ };
42
+ import deepmerge from "deepmerge";
43
+ import { Base } from "@studiometa/js-toolkit";
44
+ import { transition } from "@studiometa/js-toolkit/utils";
45
+ import Accordion from "./AccordionCore.js";
46
+ const _AccordionItem = class extends Base {
47
+ mounted() {
48
+ if (this.$parent && this.$parent instanceof Accordion && this.$parent.$options.item) {
49
+ Object.entries(this.$parent.$options.item).forEach(([key, value]) => {
50
+ if (key in this.$options) {
51
+ const type = _AccordionItem.config.options[key].type || _AccordionItem.config.options[key];
52
+ if (type === Array || type === Object) {
53
+ this.$options[key] = deepmerge(this.$options[key], value);
54
+ } else {
55
+ this.$options[key] = value;
56
+ }
57
+ }
58
+ });
59
+ }
60
+ this.$refs.btn.setAttribute("id", this.$id);
61
+ this.$refs.btn.setAttribute("aria-controls", this.contentId);
62
+ this.$refs.content.setAttribute("aria-labelledby", this.$id);
63
+ this.$refs.content.setAttribute("id", this.contentId);
64
+ const { isOpen } = this.$options;
65
+ this.updateAttributes(isOpen);
66
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
67
+ const refs = this.$refs;
68
+ Object.entries(otherStyles).filter(([refName]) => refs[refName]).forEach(([refName, { open, closed } = { open: "", closed: "" }]) => {
69
+ transition(refs[refName], { to: isOpen ? open : closed }, "keep");
70
+ });
71
+ }
72
+ destroyed() {
73
+ this.$refs.container.style.visibility = "";
74
+ this.$refs.container.style.height = "";
75
+ }
76
+ onBtnClick() {
77
+ if (this.$options.isOpen) {
78
+ this.close();
79
+ } else {
80
+ this.open();
81
+ }
82
+ }
83
+ get contentId() {
84
+ return `content-${this.$id}`;
85
+ }
86
+ updateAttributes(isOpen) {
87
+ this.$refs.container.style.visibility = isOpen ? "" : "invisible";
88
+ this.$refs.container.style.height = isOpen ? "" : "0";
89
+ this.$refs.content.setAttribute("aria-hidden", isOpen ? "false" : "true");
90
+ this.$refs.btn.setAttribute("aria-expanded", isOpen ? "true" : "false");
91
+ }
92
+ open() {
93
+ return __async(this, null, function* () {
94
+ if (this.$options.isOpen) {
95
+ return;
96
+ }
97
+ this.$log("open");
98
+ this.$emit("open");
99
+ this.$options.isOpen = true;
100
+ this.updateAttributes(this.$options.isOpen);
101
+ this.$refs.container.style.visibility = "";
102
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
103
+ const refs = this.$refs;
104
+ yield Promise.all([
105
+ transition(refs.container, {
106
+ from: { height: 0 },
107
+ active: container.active,
108
+ to: { height: `${refs.content.offsetHeight}px` }
109
+ }).then(() => {
110
+ if (this.$options.isOpen) {
111
+ refs.content.style.position = "";
112
+ }
113
+ return Promise.resolve();
114
+ }),
115
+ ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
116
+ from: closed,
117
+ active,
118
+ to: open
119
+ }, "keep"))
120
+ ]);
121
+ });
122
+ }
123
+ close() {
124
+ return __async(this, null, function* () {
125
+ if (!this.$options.isOpen) {
126
+ return;
127
+ }
128
+ this.$log("close");
129
+ this.$emit("close");
130
+ this.$options.isOpen = false;
131
+ const height = this.$refs.container.offsetHeight;
132
+ this.$refs.content.style.position = "absolute";
133
+ const _a = this.$options.styles, { container } = _a, otherStyles = __objRest(_a, ["container"]);
134
+ const refs = this.$refs;
135
+ yield Promise.all([
136
+ transition(refs.container, {
137
+ from: { height: `${height}px` },
138
+ active: container.active,
139
+ to: { height: "0" }
140
+ }).then(() => {
141
+ if (!this.$options.isOpen) {
142
+ refs.container.style.height = "0";
143
+ refs.container.style.visibility = "invisible";
144
+ this.updateAttributes(this.$options.isOpen);
145
+ }
146
+ return Promise.resolve();
147
+ }),
148
+ ...Object.entries(otherStyles).filter(([refName]) => refs[refName]).map(([refName, { open, active, closed } = { open: "", active: "", closed: "" }]) => transition(refs[refName], {
149
+ from: open,
150
+ active,
151
+ to: closed
152
+ }, "keep"))
153
+ ]);
154
+ });
155
+ }
156
+ };
157
+ let AccordionItem = _AccordionItem;
158
+ __publicField(AccordionItem, "config", {
159
+ name: "AccordionItem",
160
+ refs: ["btn", "content", "container"],
161
+ emits: ["open", "close"],
162
+ options: {
163
+ isOpen: Boolean,
164
+ styles: {
165
+ type: Object,
166
+ default: () => ({
167
+ container: {
168
+ open: "",
169
+ active: "",
170
+ closed: ""
171
+ }
172
+ })
173
+ }
174
+ }
175
+ });
176
+ export {
177
+ AccordionItem as default
178
+ };
@@ -0,0 +1,177 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
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 });
16
+ }
17
+ return target;
18
+ };
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);
24
+ var __publicField = (obj, key, value) => {
25
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ return value;
27
+ };
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
+
49
+ // packages/ui/molecules/Modal/Modal.js
50
+ var Modal_exports = {};
51
+ __export(Modal_exports, {
52
+ default: () => Modal
53
+ });
54
+ var import_js_toolkit = require("@studiometa/js-toolkit");
55
+ var import_utils = require("@studiometa/js-toolkit/utils");
56
+ var { trap, untrap, saveActiveElement } = (0, import_utils.focusTrap)();
57
+ var Modal = class extends import_js_toolkit.Base {
58
+ get onOpenClick() {
59
+ return this.open;
60
+ }
61
+ get onCloseClick() {
62
+ return this.close;
63
+ }
64
+ get onOverlayClick() {
65
+ return this.close;
66
+ }
67
+ mounted() {
68
+ this.isOpen = false;
69
+ this.close();
70
+ if (this.$options.move) {
71
+ const target = document.querySelector(this.$options.move) || document.body;
72
+ this.__refsBackup = this.$refs;
73
+ this.__refModalPlaceholder = document.createComment("");
74
+ this.__refModalParentBackup = this.$refs.modal.parentElement || this.$el;
75
+ this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder, this.$refs.modal);
76
+ target.appendChild(this.$refs.modal);
77
+ }
78
+ return this;
79
+ }
80
+ get $refs() {
81
+ const $refs = super.$refs;
82
+ if (this.$options.move && this.__refsBackup) {
83
+ Object.entries(this.__refsBackup).forEach(([key, ref]) => {
84
+ if (!$refs[key]) {
85
+ $refs[key] = ref;
86
+ }
87
+ });
88
+ }
89
+ return $refs;
90
+ }
91
+ destroyed() {
92
+ this.close();
93
+ if (this.$options.move && this.__refModalParentBackup) {
94
+ this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
95
+ this.__refModalPlaceholder.remove();
96
+ delete this.__refModalPlaceholder;
97
+ delete this.__refModalParentBackup;
98
+ }
99
+ return this;
100
+ }
101
+ keyed({ event, isUp, isDown, ESC }) {
102
+ if (!this.isOpen) {
103
+ return;
104
+ }
105
+ if (isDown) {
106
+ trap(this.$refs.modal, event);
107
+ }
108
+ if (ESC && isUp) {
109
+ this.close();
110
+ }
111
+ }
112
+ open() {
113
+ return __async(this, null, function* () {
114
+ if (this.isOpen) {
115
+ return Promise.resolve(this);
116
+ }
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
+ });
134
+ });
135
+ }
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
+ });
153
+ }
154
+ };
155
+ __publicField(Modal, "config", {
156
+ name: "Modal",
157
+ refs: ["close", "container", "content", "modal", "open", "overlay"],
158
+ emits: ["open", "close"],
159
+ options: {
160
+ move: String,
161
+ autofocus: { type: String, default: "[autofocus]" },
162
+ styles: {
163
+ type: Object,
164
+ default: () => ({
165
+ modal: {
166
+ closed: {
167
+ opacity: "0",
168
+ pointerEvents: "none",
169
+ visibility: "hidden"
170
+ }
171
+ }
172
+ })
173
+ }
174
+ }
175
+ });
176
+ module.exports = __toCommonJS(Modal_exports);
177
+ if (module.exports.default) module.exports = module.exports.default;
File without changes