@studiometa/ui 0.1.1 → 0.2.2
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.
- package/README.md +37 -1
- package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +52 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +31 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +26 -0
- package/atoms/Cursor/Cursor.cjs +129 -0
- package/{Cursor.d.ts → atoms/Cursor/Cursor.d.ts} +0 -0
- package/atoms/Cursor/Cursor.js +103 -0
- package/atoms/Figure/Figure.cjs +53 -0
- package/atoms/Figure/Figure.d.ts +31 -0
- package/atoms/Figure/Figure.js +27 -0
- package/atoms/LargeText/LargeText.cjs +74 -0
- package/atoms/LargeText/LargeText.d.ts +71 -0
- package/atoms/LargeText/LargeText.js +48 -0
- package/atoms/LazyInclude/LazyInclude.cjs +72 -0
- package/atoms/LazyInclude/LazyInclude.d.ts +64 -0
- package/atoms/LazyInclude/LazyInclude.js +46 -0
- package/atoms/Prefetch/AbstractPrefetch.cjs +84 -0
- package/atoms/Prefetch/AbstractPrefetch.d.ts +52 -0
- package/atoms/Prefetch/AbstractPrefetch.js +58 -0
- package/atoms/Prefetch/PrefetchWhenOver.cjs +65 -0
- package/atoms/Prefetch/PrefetchWhenOver.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenOver.js +35 -0
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +66 -0
- package/atoms/Prefetch/PrefetchWhenVisible.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenVisible.js +36 -0
- package/atoms/Prefetch/index.cjs +40 -0
- package/atoms/Prefetch/index.d.ts +3 -0
- package/atoms/Prefetch/index.js +8 -0
- package/atoms/index.cjs +45 -0
- package/atoms/index.d.ts +6 -0
- package/atoms/index.js +13 -0
- package/index.cjs +26 -0
- package/index.d.ts +3 -6
- package/index.js +3 -6
- package/molecules/Accordion/Accordion.cjs +65 -0
- package/{Accordion/index.d.ts → molecules/Accordion/Accordion.d.ts} +5 -6
- package/molecules/Accordion/Accordion.js +35 -0
- package/molecules/Accordion/AccordionCore.cjs +60 -0
- package/{Accordion/Accordion.d.ts → molecules/Accordion/AccordionCore.d.ts} +0 -0
- package/molecules/Accordion/AccordionCore.js +34 -0
- package/molecules/Accordion/AccordionItem.cjs +208 -0
- package/{Accordion → molecules/Accordion}/AccordionItem.d.ts +11 -13
- package/molecules/Accordion/AccordionItem.js +178 -0
- package/molecules/Modal/Modal.cjs +176 -0
- package/{Modal.d.ts → molecules/Modal/Modal.d.ts} +9 -9
- package/molecules/Modal/Modal.js +150 -0
- package/molecules/Modal/ModalWithTransition.cjs +100 -0
- package/molecules/Modal/ModalWithTransition.d.ts +29 -0
- package/molecules/Modal/ModalWithTransition.js +69 -0
- package/molecules/Panel/Panel.cjs +148 -0
- package/molecules/Panel/Panel.d.ts +42 -0
- package/molecules/Panel/Panel.js +117 -0
- package/molecules/Slider/AbstractSliderChild.cjs +74 -0
- package/molecules/Slider/AbstractSliderChild.d.ts +55 -0
- package/molecules/Slider/AbstractSliderChild.js +43 -0
- package/molecules/Slider/Slider.cjs +240 -0
- package/molecules/Slider/Slider.d.ts +245 -0
- package/molecules/Slider/Slider.js +209 -0
- package/molecules/Slider/SliderBtn.cjs +65 -0
- package/molecules/Slider/SliderBtn.d.ts +31 -0
- package/molecules/Slider/SliderBtn.js +34 -0
- package/molecules/Slider/SliderCount.cjs +50 -0
- package/molecules/Slider/SliderCount.d.ts +21 -0
- package/molecules/Slider/SliderCount.js +19 -0
- package/molecules/Slider/SliderDots.cjs +55 -0
- package/molecules/Slider/SliderDots.d.ts +33 -0
- package/molecules/Slider/SliderDots.js +24 -0
- package/molecules/Slider/SliderDrag.cjs +45 -0
- package/molecules/Slider/SliderDrag.d.ts +16 -0
- package/molecules/Slider/SliderDrag.js +19 -0
- package/molecules/Slider/SliderItem.cjs +130 -0
- package/molecules/Slider/SliderItem.d.ts +106 -0
- package/molecules/Slider/SliderItem.js +105 -0
- package/molecules/Slider/SliderProgress.cjs +54 -0
- package/molecules/Slider/SliderProgress.d.ts +27 -0
- package/molecules/Slider/SliderProgress.js +23 -0
- package/molecules/Slider/index.cjs +50 -0
- package/molecules/Slider/index.d.ts +8 -0
- package/molecules/Slider/index.js +18 -0
- package/molecules/Sticky/Sticky.cjs +133 -0
- package/molecules/Sticky/Sticky.d.ts +141 -0
- package/molecules/Sticky/Sticky.js +107 -0
- package/molecules/TableOfContent/TableOfContent.cjs +73 -0
- package/molecules/TableOfContent/TableOfContent.d.ts +59 -0
- package/molecules/TableOfContent/TableOfContent.js +42 -0
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +65 -0
- package/molecules/TableOfContent/TableOfContentAnchor.d.ts +36 -0
- package/molecules/TableOfContent/TableOfContentAnchor.js +39 -0
- package/molecules/TableOfContent/index.cjs +38 -0
- package/molecules/TableOfContent/index.d.ts +2 -0
- package/molecules/TableOfContent/index.js +6 -0
- package/molecules/Tabs/Tabs.cjs +152 -0
- package/{Tabs.d.ts → molecules/Tabs/Tabs.d.ts} +2 -4
- package/molecules/Tabs/Tabs.js +126 -0
- package/molecules/index.cjs +50 -0
- package/molecules/index.d.ts +9 -0
- package/molecules/index.js +18 -0
- package/organisms/Frame/Frame.cjs +202 -0
- package/organisms/Frame/Frame.d.ts +119 -0
- package/organisms/Frame/Frame.js +171 -0
- package/organisms/Frame/FrameAnchor.cjs +48 -0
- package/organisms/Frame/FrameAnchor.d.ts +35 -0
- package/organisms/Frame/FrameAnchor.js +22 -0
- package/organisms/Frame/FrameForm.cjs +48 -0
- package/organisms/Frame/FrameForm.d.ts +32 -0
- package/organisms/Frame/FrameForm.js +22 -0
- package/organisms/Frame/FrameTarget.cjs +134 -0
- package/organisms/Frame/FrameTarget.d.ts +47 -0
- package/organisms/Frame/FrameTarget.js +109 -0
- package/organisms/Frame/index.cjs +42 -0
- package/organisms/Frame/index.d.ts +4 -0
- package/organisms/Frame/index.js +10 -0
- package/organisms/index.cjs +24 -0
- package/organisms/index.d.ts +1 -0
- package/organisms/index.js +1 -0
- package/package.json +2 -2
- package/primitives/Draggable/Draggable.cjs +64 -0
- package/{Draggable.d.ts → primitives/Draggable/Draggable.d.ts} +0 -0
- package/primitives/Draggable/Draggable.js +38 -0
- package/primitives/Sentinel/Sentinel.cjs +41 -0
- package/primitives/Sentinel/Sentinel.d.ts +12 -0
- package/primitives/Sentinel/Sentinel.js +15 -0
- package/primitives/Transition/Transition.cjs +71 -0
- package/primitives/Transition/Transition.d.ts +69 -0
- package/primitives/Transition/Transition.js +45 -0
- package/primitives/index.cjs +40 -0
- package/primitives/index.d.ts +3 -0
- package/primitives/index.js +8 -0
- package/Accordion/Accordion.js +0 -29
- package/Accordion/AccordionItem.js +0 -197
- package/Accordion/index.js +0 -12
- package/Cursor.js +0 -121
- package/Draggable.js +0 -31
- package/Modal.js +0 -167
- package/Tabs.js +0 -106
|
@@ -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,176 @@
|
|
|
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
|
+
}
|
|
79
|
+
get $refs() {
|
|
80
|
+
const $refs = super.$refs;
|
|
81
|
+
if (this.$options.move && this.__refsBackup) {
|
|
82
|
+
Object.entries(this.__refsBackup).forEach(([key, ref]) => {
|
|
83
|
+
if (!$refs[key]) {
|
|
84
|
+
$refs[key] = ref;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return $refs;
|
|
89
|
+
}
|
|
90
|
+
destroyed() {
|
|
91
|
+
this.close();
|
|
92
|
+
if (this.$options.move && this.__refModalParentBackup) {
|
|
93
|
+
this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
|
|
94
|
+
this.__refModalPlaceholder.remove();
|
|
95
|
+
delete this.__refModalPlaceholder;
|
|
96
|
+
delete this.__refModalParentBackup;
|
|
97
|
+
}
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
keyed({ event, isUp, isDown, ESC }) {
|
|
101
|
+
if (!this.isOpen) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (isDown) {
|
|
105
|
+
trap(this.$refs.modal, event);
|
|
106
|
+
}
|
|
107
|
+
if (ESC && isUp) {
|
|
108
|
+
this.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
open() {
|
|
112
|
+
return __async(this, null, function* () {
|
|
113
|
+
if (this.isOpen) {
|
|
114
|
+
return Promise.resolve();
|
|
115
|
+
}
|
|
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
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
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
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
__publicField(Modal, "config", {
|
|
155
|
+
name: "Modal",
|
|
156
|
+
refs: ["close", "container", "content", "modal", "open", "overlay"],
|
|
157
|
+
emits: ["open", "close"],
|
|
158
|
+
options: {
|
|
159
|
+
move: String,
|
|
160
|
+
autofocus: { type: String, default: "[autofocus]" },
|
|
161
|
+
styles: {
|
|
162
|
+
type: Object,
|
|
163
|
+
default: () => ({
|
|
164
|
+
modal: {
|
|
165
|
+
closed: {
|
|
166
|
+
opacity: "0",
|
|
167
|
+
pointerEvents: "none",
|
|
168
|
+
visibility: "hidden"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
module.exports = __toCommonJS(Modal_exports);
|
|
176
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* @property {HTMLElement} overlay
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* @typedef {
|
|
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():
|
|
82
|
+
mounted(): void;
|
|
83
83
|
isOpen: boolean;
|
|
84
84
|
__refsBackup: import("@studiometa/js-toolkit/Base/managers/RefsManager").default & ModalRefs;
|
|
85
85
|
__refModalPlaceholder: Comment;
|
|
@@ -111,16 +111,16 @@ export default class Modal extends Base {
|
|
|
111
111
|
* Open the modal.
|
|
112
112
|
*
|
|
113
113
|
* @this {ModalInterface}
|
|
114
|
-
* @return {Promise<
|
|
114
|
+
* @return {Promise<void>} The Modal instance.
|
|
115
115
|
*/
|
|
116
|
-
open(): Promise<
|
|
116
|
+
open(): Promise<void>;
|
|
117
117
|
/**
|
|
118
118
|
* Close the modal.
|
|
119
119
|
*
|
|
120
120
|
* @this {ModalInterface}
|
|
121
|
-
* @return {Promise<
|
|
121
|
+
* @return {Promise<void>} The Modal instance.
|
|
122
122
|
*/
|
|
123
|
-
close(): Promise<
|
|
123
|
+
close(): 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
|
|
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";
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (module2, isNodeMode) => {
|
|
22
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
25
|
+
return (module2, temp) => {
|
|
26
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
27
|
+
};
|
|
28
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
29
|
+
var __publicField = (obj, key, value) => {
|
|
30
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// packages/ui/molecules/Modal/ModalWithTransition.js
|
|
55
|
+
var ModalWithTransition_exports = {};
|
|
56
|
+
__export(ModalWithTransition_exports, {
|
|
57
|
+
default: () => ModalWithTransition
|
|
58
|
+
});
|
|
59
|
+
var import_Modal = __toESM(require("./Modal.cjs"), 1);
|
|
60
|
+
var ModalWithTransition = class extends import_Modal.default {
|
|
61
|
+
open() {
|
|
62
|
+
this.$refs.modal.style.visibility = "";
|
|
63
|
+
return super.open();
|
|
64
|
+
}
|
|
65
|
+
close() {
|
|
66
|
+
var __superGet = (key) => super[key];
|
|
67
|
+
return __async(this, null, function* () {
|
|
68
|
+
yield __superGet("close").call(this);
|
|
69
|
+
this.$refs.modal.style.visibility = "hidden";
|
|
70
|
+
return Promise.resolve();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
__publicField(ModalWithTransition, "config", {
|
|
75
|
+
name: "ModalWithTransition",
|
|
76
|
+
options: {
|
|
77
|
+
styles: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => ({
|
|
80
|
+
modal: {
|
|
81
|
+
closed: {
|
|
82
|
+
opacity: "0",
|
|
83
|
+
pointerEvents: "none"
|
|
84
|
+
},
|
|
85
|
+
active: "transition duration-500 ease-out-expo"
|
|
86
|
+
},
|
|
87
|
+
overlay: {
|
|
88
|
+
closed: "opacity-0",
|
|
89
|
+
active: "transition duration-500 ease-out-expo"
|
|
90
|
+
},
|
|
91
|
+
container: {
|
|
92
|
+
closed: "transform scale-95 opacity-0",
|
|
93
|
+
active: "transition duration-500 ease-out-expo"
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(ModalWithTransition_exports);
|
|
100
|
+
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";
|