@mekari/pixel3-modal 0.0.1
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/dist/body.d.mts +6 -0
- package/dist/body.d.ts +6 -0
- package/dist/body.js +63 -0
- package/dist/body.mjs +8 -0
- package/dist/chunk-2WYPEVZV.mjs +62 -0
- package/dist/chunk-7LGGLG42.mjs +77 -0
- package/dist/chunk-ASQKAMBD.mjs +37 -0
- package/dist/chunk-D4KITWKW.mjs +34 -0
- package/dist/chunk-DKUTSUEJ.mjs +8 -0
- package/dist/chunk-FU2Y3XYA.mjs +70 -0
- package/dist/chunk-FXPPG3HJ.mjs +24 -0
- package/dist/chunk-MO6AFEOO.mjs +285 -0
- package/dist/chunk-NCQFKFXL.mjs +69 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-THCDEEFK.mjs +24 -0
- package/dist/close-button.d.mts +6 -0
- package/dist/close-button.d.ts +6 -0
- package/dist/close-button.js +60 -0
- package/dist/close-button.mjs +8 -0
- package/dist/content.d.mts +28 -0
- package/dist/content.d.ts +28 -0
- package/dist/content.js +359 -0
- package/dist/content.mjs +10 -0
- package/dist/footer.d.mts +6 -0
- package/dist/footer.d.ts +6 -0
- package/dist/footer.js +48 -0
- package/dist/footer.mjs +7 -0
- package/dist/header.d.mts +6 -0
- package/dist/header.d.ts +6 -0
- package/dist/header.js +48 -0
- package/dist/header.mjs +7 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +668 -0
- package/dist/index.mjs +34 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modal.d.mts +103 -0
- package/dist/modal.d.ts +103 -0
- package/dist/modal.js +191 -0
- package/dist/modal.mjs +10 -0
- package/dist/modules/modal.context.d.mts +11 -0
- package/dist/modules/modal.context.d.ts +11 -0
- package/dist/modules/modal.context.js +33 -0
- package/dist/modules/modal.context.mjs +9 -0
- package/dist/modules/modal.props.d.mts +64 -0
- package/dist/modules/modal.props.d.ts +64 -0
- package/dist/modules/modal.props.js +88 -0
- package/dist/modules/modal.props.mjs +11 -0
- package/dist/modules/useModal.d.mts +28 -0
- package/dist/modules/useModal.d.ts +28 -0
- package/dist/modules/useModal.js +321 -0
- package/dist/modules/useModal.mjs +12 -0
- package/dist/overlay.d.mts +6 -0
- package/dist/overlay.d.ts +6 -0
- package/dist/overlay.js +104 -0
- package/dist/overlay.mjs +8 -0
- package/package.json +47 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
MpModal: () => MpModal,
|
|
35
|
+
MpModalBody: () => MpModalBody,
|
|
36
|
+
MpModalCloseButton: () => MpModalCloseButton,
|
|
37
|
+
MpModalContent: () => MpModalContent,
|
|
38
|
+
MpModalFooter: () => MpModalFooter,
|
|
39
|
+
MpModalHeader: () => MpModalHeader,
|
|
40
|
+
MpModalOverlay: () => MpModalOverlay
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
|
|
44
|
+
// src/modal.tsx
|
|
45
|
+
var import_vue2 = require("vue");
|
|
46
|
+
var import_vue3 = require("vue");
|
|
47
|
+
|
|
48
|
+
// src/modules/modal.context.ts
|
|
49
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
50
|
+
var [ModalProvider, useModalContext] = (0, import_pixel3_utils.usePixelCreateContext)("ModalContext");
|
|
51
|
+
|
|
52
|
+
// src/modules/modal.props.ts
|
|
53
|
+
var modalProps = {
|
|
54
|
+
id: {
|
|
55
|
+
type: String
|
|
56
|
+
},
|
|
57
|
+
isOpen: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
isBlockScrollOnMount: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
isCloseOnEsc: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
isCloseOnOverlayClick: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: true
|
|
72
|
+
},
|
|
73
|
+
isKeepAlive: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
isCentered: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
81
|
+
scrollBehavior: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: "outside"
|
|
84
|
+
},
|
|
85
|
+
size: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "md"
|
|
88
|
+
},
|
|
89
|
+
isDisablePortal: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var modalContentProps = {
|
|
95
|
+
type: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "modal"
|
|
98
|
+
},
|
|
99
|
+
placement: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: "right"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var modalEmits = {
|
|
105
|
+
"open": (value) => value,
|
|
106
|
+
"close": (value) => value
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/modules/useModal.ts
|
|
110
|
+
var import_vue = require("vue");
|
|
111
|
+
var import_pixel3_utils2 = require("@mekari/pixel3-utils");
|
|
112
|
+
var import_body_scroll_lock = require("body-scroll-lock");
|
|
113
|
+
var import_animejs = __toESM(require("animejs"));
|
|
114
|
+
var import_pixel3_utils3 = require("@mekari/pixel3-utils");
|
|
115
|
+
var baseSizes = {
|
|
116
|
+
sm: "330px",
|
|
117
|
+
md: "448px",
|
|
118
|
+
lg: "684px",
|
|
119
|
+
xl: "920px",
|
|
120
|
+
"2xl": "1152px",
|
|
121
|
+
full: "100%"
|
|
122
|
+
};
|
|
123
|
+
function useModal(props, emit) {
|
|
124
|
+
const isModalOpen = (0, import_vue.ref)(props.isOpen);
|
|
125
|
+
const modalEl = (0, import_vue.ref)();
|
|
126
|
+
const getId = (0, import_vue.computed)(() => props.id || (0, import_pixel3_utils2.useId)(4));
|
|
127
|
+
function onOpen() {
|
|
128
|
+
isModalOpen.value = true;
|
|
129
|
+
if (props.isBlockScrollOnMount) {
|
|
130
|
+
(0, import_vue.nextTick)(() => {
|
|
131
|
+
(0, import_body_scroll_lock.disableBodyScroll)(modalEl.value);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
emit("open", true);
|
|
135
|
+
}
|
|
136
|
+
__name(onOpen, "onOpen");
|
|
137
|
+
function onClose() {
|
|
138
|
+
if (props.isBlockScrollOnMount) {
|
|
139
|
+
(0, import_body_scroll_lock.enableBodyScroll)(modalEl.value);
|
|
140
|
+
}
|
|
141
|
+
emit("close", true);
|
|
142
|
+
}
|
|
143
|
+
__name(onClose, "onClose");
|
|
144
|
+
return {
|
|
145
|
+
isModalOpen,
|
|
146
|
+
modalEl,
|
|
147
|
+
getId,
|
|
148
|
+
onOpen,
|
|
149
|
+
onClose
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
__name(useModal, "useModal");
|
|
153
|
+
function useModalContent(props) {
|
|
154
|
+
const {
|
|
155
|
+
props: modalProps2,
|
|
156
|
+
onClose,
|
|
157
|
+
isModalOpen
|
|
158
|
+
} = useModalContext();
|
|
159
|
+
const {
|
|
160
|
+
isCloseOnOverlayClick,
|
|
161
|
+
isOpen,
|
|
162
|
+
isCloseOnEsc,
|
|
163
|
+
isKeepAlive,
|
|
164
|
+
size,
|
|
165
|
+
isCentered,
|
|
166
|
+
scrollBehavior
|
|
167
|
+
} = modalProps2;
|
|
168
|
+
const wrapperEl = (0, import_vue.ref)();
|
|
169
|
+
const inlineStyle = (0, import_vue.computed)(() => {
|
|
170
|
+
let wrapperStyle = {};
|
|
171
|
+
let contentStyle = {};
|
|
172
|
+
if (isCentered == null ? void 0 : isCentered.value) {
|
|
173
|
+
wrapperStyle = {
|
|
174
|
+
display: "flex",
|
|
175
|
+
alignItems: "center",
|
|
176
|
+
justifyContent: "center"
|
|
177
|
+
};
|
|
178
|
+
} else {
|
|
179
|
+
contentStyle = {
|
|
180
|
+
top: "3.75rem",
|
|
181
|
+
mx: "auto"
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (scrollBehavior.value === "inside") {
|
|
185
|
+
wrapperStyle = {
|
|
186
|
+
...wrapperStyle,
|
|
187
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
188
|
+
overflow: "hidden",
|
|
189
|
+
top: "3.75rem"
|
|
190
|
+
};
|
|
191
|
+
contentStyle = {
|
|
192
|
+
...contentStyle,
|
|
193
|
+
height: "100%",
|
|
194
|
+
top: 0
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (scrollBehavior.value === "outside") {
|
|
198
|
+
wrapperStyle = {
|
|
199
|
+
...wrapperStyle,
|
|
200
|
+
overflowY: "auto",
|
|
201
|
+
overflowX: "hidden"
|
|
202
|
+
};
|
|
203
|
+
contentStyle = {
|
|
204
|
+
...contentStyle,
|
|
205
|
+
my: "3.75rem",
|
|
206
|
+
top: 0
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (scrollBehavior.value === "auto") {
|
|
210
|
+
wrapperStyle = {
|
|
211
|
+
...wrapperStyle,
|
|
212
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
213
|
+
overflow: "hidden",
|
|
214
|
+
top: "3.75rem"
|
|
215
|
+
};
|
|
216
|
+
contentStyle = {
|
|
217
|
+
...contentStyle,
|
|
218
|
+
height: "auto",
|
|
219
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
220
|
+
top: 0
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (size.value === "full" || props.type === "drawer") {
|
|
224
|
+
wrapperStyle = {};
|
|
225
|
+
contentStyle = {};
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
wrapperStyle,
|
|
229
|
+
contentStyle
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
const {
|
|
233
|
+
activate: activeFocusTrap,
|
|
234
|
+
deactivate: deactivateFocusTrap
|
|
235
|
+
} = (0, import_pixel3_utils3.useFocusTrap)(wrapperEl);
|
|
236
|
+
function onOverlayClick(e) {
|
|
237
|
+
if (isOpen.value && isCloseOnOverlayClick.value && e.target === wrapperEl.value) {
|
|
238
|
+
onClose();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
__name(onOverlayClick, "onOverlayClick");
|
|
242
|
+
const onKeydown = /* @__PURE__ */ __name((event) => {
|
|
243
|
+
if (event.key === "Escape" && isCloseOnEsc.value) {
|
|
244
|
+
onClose();
|
|
245
|
+
}
|
|
246
|
+
}, "onKeydown");
|
|
247
|
+
const getTransition = (0, import_vue.computed)(() => {
|
|
248
|
+
const duration = size.value === "full" ? 400 : 300;
|
|
249
|
+
let enter = {};
|
|
250
|
+
let leave = {};
|
|
251
|
+
if (props.type === "modal") {
|
|
252
|
+
enter = {
|
|
253
|
+
opacity: [0, 1],
|
|
254
|
+
scale: [0.95, 1],
|
|
255
|
+
translateY: ["16px", "0px"],
|
|
256
|
+
easing: "easeOutSine",
|
|
257
|
+
duration
|
|
258
|
+
};
|
|
259
|
+
leave = {
|
|
260
|
+
opacity: [1, 0],
|
|
261
|
+
scale: [1, 0.95],
|
|
262
|
+
translateY: ["0px", "16px"],
|
|
263
|
+
easing: "easeInSine",
|
|
264
|
+
duration: 300
|
|
265
|
+
};
|
|
266
|
+
return {
|
|
267
|
+
enter,
|
|
268
|
+
leave
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
if (props.type === "drawer") {
|
|
272
|
+
if (props.placement === "right") {
|
|
273
|
+
enter = {
|
|
274
|
+
translateX(el) {
|
|
275
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
276
|
+
return [translateWidth, "0px"];
|
|
277
|
+
},
|
|
278
|
+
easing: "easeInOutSine",
|
|
279
|
+
duration: 500
|
|
280
|
+
};
|
|
281
|
+
leave = {
|
|
282
|
+
translateX: ["0px", "100%"],
|
|
283
|
+
easing: "easeInOutSine",
|
|
284
|
+
duration: 500
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
if (props.placement === "left") {
|
|
288
|
+
enter = {
|
|
289
|
+
translateX(el) {
|
|
290
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
291
|
+
return [`-${translateWidth}`, "0px"];
|
|
292
|
+
},
|
|
293
|
+
easing: "easeInOutSine",
|
|
294
|
+
duration: 500
|
|
295
|
+
};
|
|
296
|
+
leave = {
|
|
297
|
+
translateX: ["0px", "-100%"],
|
|
298
|
+
easing: "easeInOutSine",
|
|
299
|
+
duration: 500
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if (props.placement === "top") {
|
|
303
|
+
enter = {
|
|
304
|
+
translateY(el) {
|
|
305
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
306
|
+
return [`-${translateWidth}`, "0px"];
|
|
307
|
+
},
|
|
308
|
+
easing: "easeInOutSine",
|
|
309
|
+
duration: 500
|
|
310
|
+
};
|
|
311
|
+
leave = {
|
|
312
|
+
translateY: ["0px", "-100%"],
|
|
313
|
+
easing: "easeInOutSine",
|
|
314
|
+
duration: 500
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (props.placement === "bottom") {
|
|
318
|
+
enter = {
|
|
319
|
+
translateY(el) {
|
|
320
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
321
|
+
return [`${translateWidth}`, "0px"];
|
|
322
|
+
},
|
|
323
|
+
easing: "easeInOutSine",
|
|
324
|
+
duration: 500
|
|
325
|
+
};
|
|
326
|
+
leave = {
|
|
327
|
+
translateY: ["0px", "100%"],
|
|
328
|
+
easing: "easeInOutSine",
|
|
329
|
+
duration: 500
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
enter,
|
|
335
|
+
leave
|
|
336
|
+
};
|
|
337
|
+
});
|
|
338
|
+
const beforeEnterAnimation = /* @__PURE__ */ __name((el) => {
|
|
339
|
+
el && el.style.setProperty("will-change", "opacity, transform", "scale");
|
|
340
|
+
}, "beforeEnterAnimation");
|
|
341
|
+
const enterAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
342
|
+
(0, import_animejs.default)({
|
|
343
|
+
targets: el,
|
|
344
|
+
...getTransition.value.enter,
|
|
345
|
+
complete: () => {
|
|
346
|
+
if (isOpen.value) {
|
|
347
|
+
complete();
|
|
348
|
+
document.addEventListener("keydown", onKeydown);
|
|
349
|
+
activeFocusTrap();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}, "enterAnimation");
|
|
354
|
+
const leaveAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
355
|
+
deactivateFocusTrap();
|
|
356
|
+
(0, import_animejs.default)({
|
|
357
|
+
targets: el,
|
|
358
|
+
...getTransition.value.leave,
|
|
359
|
+
complete: () => {
|
|
360
|
+
complete();
|
|
361
|
+
isModalOpen.value = false;
|
|
362
|
+
document.removeEventListener("keydown", onKeydown);
|
|
363
|
+
onClose();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}, "leaveAnimation");
|
|
367
|
+
return {
|
|
368
|
+
wrapperEl,
|
|
369
|
+
isOpen,
|
|
370
|
+
isKeepAlive,
|
|
371
|
+
size,
|
|
372
|
+
inlineStyle,
|
|
373
|
+
onOverlayClick,
|
|
374
|
+
// Animation
|
|
375
|
+
beforeEnterAnimation,
|
|
376
|
+
enterAnimation,
|
|
377
|
+
leaveAnimation
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
__name(useModalContent, "useModalContent");
|
|
381
|
+
|
|
382
|
+
// src/modal.tsx
|
|
383
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
384
|
+
var MpModal = (0, import_vue3.defineComponent)({
|
|
385
|
+
name: "MpModal",
|
|
386
|
+
props: modalProps,
|
|
387
|
+
inheritAttrs: false,
|
|
388
|
+
emits: modalEmits,
|
|
389
|
+
setup(props, {
|
|
390
|
+
slots,
|
|
391
|
+
emit,
|
|
392
|
+
attrs
|
|
393
|
+
}) {
|
|
394
|
+
const {
|
|
395
|
+
modalEl,
|
|
396
|
+
getId,
|
|
397
|
+
onClose,
|
|
398
|
+
onOpen,
|
|
399
|
+
isModalOpen
|
|
400
|
+
} = useModal(props, emit);
|
|
401
|
+
ModalProvider({
|
|
402
|
+
props: (0, import_vue3.toRefs)(props),
|
|
403
|
+
modalEl,
|
|
404
|
+
getId,
|
|
405
|
+
onClose,
|
|
406
|
+
onOpen,
|
|
407
|
+
isModalOpen
|
|
408
|
+
});
|
|
409
|
+
(0, import_vue3.watch)(() => props.isOpen, () => {
|
|
410
|
+
if (props.isOpen) {
|
|
411
|
+
onOpen();
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
immediate: true
|
|
416
|
+
});
|
|
417
|
+
return () => {
|
|
418
|
+
const {
|
|
419
|
+
root,
|
|
420
|
+
rootChild
|
|
421
|
+
} = (0, import_recipes.modalSlotRecipe)({
|
|
422
|
+
full: props.size === "full" ? true : false
|
|
423
|
+
});
|
|
424
|
+
const modalNode = (0, import_vue2.withDirectives)((0, import_vue2.createVNode)("div", (0, import_vue2.mergeProps)({
|
|
425
|
+
"ref": modalEl,
|
|
426
|
+
"data-pixel-component": "MpModal",
|
|
427
|
+
"class": root,
|
|
428
|
+
"id": `modal-${getId.value}`
|
|
429
|
+
}, attrs), [(0, import_vue2.createVNode)("div", {
|
|
430
|
+
"class": rootChild
|
|
431
|
+
}, [(0, import_vue2.createTextVNode)(" "), slots.default && slots.default(), (0, import_vue2.createTextVNode)(" ")])]), [[import_vue2.vShow, isModalOpen.value]]);
|
|
432
|
+
const renderModalNode = !props.isDisablePortal ? (0, import_vue2.createVNode)(import_vue3.Teleport, {
|
|
433
|
+
"to": "body"
|
|
434
|
+
}, {
|
|
435
|
+
default: () => [(0, import_vue2.createTextVNode)(" "), modalNode, (0, import_vue2.createTextVNode)(" ")]
|
|
436
|
+
}) : modalNode;
|
|
437
|
+
const conditionalRenderNode = isModalOpen.value ? renderModalNode : null;
|
|
438
|
+
return (0, import_vue2.createVNode)(import_vue2.Fragment, null, [props.isKeepAlive ? renderModalNode : conditionalRenderNode]);
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
// src/overlay.tsx
|
|
444
|
+
var import_vue4 = require("vue");
|
|
445
|
+
var import_vue5 = require("vue");
|
|
446
|
+
var import_animejs2 = __toESM(require("animejs"));
|
|
447
|
+
var import_recipes2 = require("@mekari/pixel3-styled-system/recipes");
|
|
448
|
+
var MpModalOverlay = (0, import_vue5.defineComponent)({
|
|
449
|
+
name: "MpModalOverlay",
|
|
450
|
+
setup(_props, {
|
|
451
|
+
slots
|
|
452
|
+
}) {
|
|
453
|
+
const {
|
|
454
|
+
overlay
|
|
455
|
+
} = (0, import_recipes2.modalSlotRecipe)();
|
|
456
|
+
const {
|
|
457
|
+
props: modalProps2
|
|
458
|
+
} = useModalContext();
|
|
459
|
+
const {
|
|
460
|
+
isOpen,
|
|
461
|
+
isKeepAlive
|
|
462
|
+
} = modalProps2;
|
|
463
|
+
const handleBeforeEnter = /* @__PURE__ */ __name((el) => {
|
|
464
|
+
el && el.style.setProperty("will-change", "opacity, transform", "scale");
|
|
465
|
+
}, "handleBeforeEnter");
|
|
466
|
+
const enterAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
467
|
+
(0, import_animejs2.default)({
|
|
468
|
+
targets: el,
|
|
469
|
+
opacity: [0, 1],
|
|
470
|
+
easing: "easeOutSine",
|
|
471
|
+
duration: 300,
|
|
472
|
+
complete
|
|
473
|
+
});
|
|
474
|
+
}, "enterAnimation");
|
|
475
|
+
const leaveAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
476
|
+
(0, import_animejs2.default)({
|
|
477
|
+
targets: el,
|
|
478
|
+
opacity: [1, 0],
|
|
479
|
+
easing: "easeInSine",
|
|
480
|
+
duration: 300,
|
|
481
|
+
complete
|
|
482
|
+
});
|
|
483
|
+
}, "leaveAnimation");
|
|
484
|
+
return () => {
|
|
485
|
+
const overlayNode = (0, import_vue4.withDirectives)((0, import_vue4.createVNode)("div", {
|
|
486
|
+
"data-pixel-component": "MpModalOverlay",
|
|
487
|
+
"class": overlay
|
|
488
|
+
}, [slots.default && slots.default()]), [[import_vue4.vShow, isOpen.value]]);
|
|
489
|
+
const withConditionalRender = isOpen.value ? overlayNode : null;
|
|
490
|
+
return (0, import_vue4.createVNode)(import_vue5.Transition, {
|
|
491
|
+
"css": false,
|
|
492
|
+
"appear": true,
|
|
493
|
+
"onBeforeEnter": (el) => handleBeforeEnter(el),
|
|
494
|
+
"onEnter": (el, complete) => enterAnimation(el, complete),
|
|
495
|
+
"onLeave": (el, complete) => leaveAnimation(el, complete)
|
|
496
|
+
}, {
|
|
497
|
+
default: () => [isKeepAlive.value ? overlayNode : withConditionalRender]
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// src/content.tsx
|
|
504
|
+
var import_vue6 = require("vue");
|
|
505
|
+
var import_vue7 = require("vue");
|
|
506
|
+
var import_recipes3 = require("@mekari/pixel3-styled-system/recipes");
|
|
507
|
+
var MpModalContent = (0, import_vue7.defineComponent)({
|
|
508
|
+
name: "MpModalContent",
|
|
509
|
+
props: modalContentProps,
|
|
510
|
+
inheritAttrs: false,
|
|
511
|
+
setup(props, {
|
|
512
|
+
slots,
|
|
513
|
+
attrs
|
|
514
|
+
}) {
|
|
515
|
+
const {
|
|
516
|
+
wrapperEl,
|
|
517
|
+
isOpen,
|
|
518
|
+
isKeepAlive,
|
|
519
|
+
size,
|
|
520
|
+
inlineStyle,
|
|
521
|
+
onOverlayClick,
|
|
522
|
+
beforeEnterAnimation,
|
|
523
|
+
enterAnimation,
|
|
524
|
+
leaveAnimation
|
|
525
|
+
} = useModalContent(props);
|
|
526
|
+
return () => {
|
|
527
|
+
const {
|
|
528
|
+
contentRoot,
|
|
529
|
+
contentChild
|
|
530
|
+
} = (0, import_recipes3.modalSlotRecipe)({
|
|
531
|
+
full: size.value === "full" ? true : false
|
|
532
|
+
});
|
|
533
|
+
const contentNode = (0, import_vue6.withDirectives)((0, import_vue6.createVNode)("div", (0, import_vue6.mergeProps)({
|
|
534
|
+
"data-pixel-component": "MpModalContent",
|
|
535
|
+
"class": contentChild,
|
|
536
|
+
"style": {
|
|
537
|
+
maxWidth: baseSizes[size.value],
|
|
538
|
+
...inlineStyle.value.contentStyle
|
|
539
|
+
},
|
|
540
|
+
"tabindex": "-1"
|
|
541
|
+
}, attrs), [slots.default && slots.default()]), [[import_vue6.vShow, isOpen.value]]);
|
|
542
|
+
const conditionalRender = isOpen.value ? contentNode : null;
|
|
543
|
+
return (0, import_vue6.createVNode)("div", {
|
|
544
|
+
"ref": wrapperEl,
|
|
545
|
+
"class": contentRoot,
|
|
546
|
+
"style": inlineStyle.value.wrapperStyle,
|
|
547
|
+
"onClick": onOverlayClick
|
|
548
|
+
}, [(0, import_vue6.createVNode)(import_vue7.Transition, {
|
|
549
|
+
"css": false,
|
|
550
|
+
"appear": true,
|
|
551
|
+
"onBeforeEnter": (el) => beforeEnterAnimation(el),
|
|
552
|
+
"onEnter": (el, complete) => enterAnimation(el, complete),
|
|
553
|
+
"onLeave": (el, complete) => leaveAnimation(el, complete)
|
|
554
|
+
}, {
|
|
555
|
+
default: () => [isKeepAlive ? contentNode : conditionalRender]
|
|
556
|
+
})]);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// src/body.tsx
|
|
562
|
+
var import_vue8 = require("vue");
|
|
563
|
+
var import_vue9 = require("vue");
|
|
564
|
+
var import_recipes4 = require("@mekari/pixel3-styled-system/recipes");
|
|
565
|
+
var MpModalBody = (0, import_vue9.defineComponent)({
|
|
566
|
+
name: "MpModalBody",
|
|
567
|
+
setup(_props, {
|
|
568
|
+
slots
|
|
569
|
+
}) {
|
|
570
|
+
const {
|
|
571
|
+
body
|
|
572
|
+
} = (0, import_recipes4.modalSlotRecipe)();
|
|
573
|
+
const {
|
|
574
|
+
props: modalProps2
|
|
575
|
+
} = useModalContext();
|
|
576
|
+
const {
|
|
577
|
+
scrollBehavior
|
|
578
|
+
} = modalProps2;
|
|
579
|
+
return () => {
|
|
580
|
+
return (0, import_vue8.createVNode)("div", {
|
|
581
|
+
"data-pixel-component": "MpModalBody",
|
|
582
|
+
"class": body,
|
|
583
|
+
"style": {
|
|
584
|
+
overflowY: scrollBehavior.value === "inside" || scrollBehavior.value === "auto" ? "auto" : "inherit"
|
|
585
|
+
}
|
|
586
|
+
}, [slots.default && slots.default()]);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
// src/header.tsx
|
|
592
|
+
var import_vue10 = require("vue");
|
|
593
|
+
var import_vue11 = require("vue");
|
|
594
|
+
var import_recipes5 = require("@mekari/pixel3-styled-system/recipes");
|
|
595
|
+
var MpModalHeader = (0, import_vue11.defineComponent)({
|
|
596
|
+
name: "MpModalHeader",
|
|
597
|
+
setup(_props, {
|
|
598
|
+
slots
|
|
599
|
+
}) {
|
|
600
|
+
const {
|
|
601
|
+
header
|
|
602
|
+
} = (0, import_recipes5.modalSlotRecipe)();
|
|
603
|
+
return () => {
|
|
604
|
+
return (0, import_vue10.createVNode)("header", {
|
|
605
|
+
"data-pixel-component": "MpModalHeader",
|
|
606
|
+
"class": header
|
|
607
|
+
}, [slots.default && slots.default()]);
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// src/footer.tsx
|
|
613
|
+
var import_vue12 = require("vue");
|
|
614
|
+
var import_vue13 = require("vue");
|
|
615
|
+
var import_recipes6 = require("@mekari/pixel3-styled-system/recipes");
|
|
616
|
+
var MpModalFooter = (0, import_vue13.defineComponent)({
|
|
617
|
+
name: "MpModalFooter",
|
|
618
|
+
setup(_props, {
|
|
619
|
+
slots
|
|
620
|
+
}) {
|
|
621
|
+
const {
|
|
622
|
+
footer
|
|
623
|
+
} = (0, import_recipes6.modalSlotRecipe)();
|
|
624
|
+
return () => {
|
|
625
|
+
return (0, import_vue12.createVNode)("footer", {
|
|
626
|
+
"data-pixel-component": "MpModalFooter",
|
|
627
|
+
"class": footer
|
|
628
|
+
}, [slots.default && slots.default()]);
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
// src/close-button.tsx
|
|
634
|
+
var import_vue14 = require("vue");
|
|
635
|
+
var import_vue15 = require("vue");
|
|
636
|
+
var import_pixel3_button = require("@mekari/pixel3-button");
|
|
637
|
+
var import_recipes7 = require("@mekari/pixel3-styled-system/recipes");
|
|
638
|
+
var MpModalCloseButton = (0, import_vue15.defineComponent)({
|
|
639
|
+
name: "MpModalCloseButton",
|
|
640
|
+
setup() {
|
|
641
|
+
const {
|
|
642
|
+
closeButton
|
|
643
|
+
} = (0, import_recipes7.modalSlotRecipe)();
|
|
644
|
+
const {
|
|
645
|
+
onClose
|
|
646
|
+
} = useModalContext();
|
|
647
|
+
return () => {
|
|
648
|
+
return (0, import_vue14.createVNode)(import_pixel3_button.MpButton, {
|
|
649
|
+
"data-pixel-component": "MpModalCloseButton",
|
|
650
|
+
"class": closeButton,
|
|
651
|
+
"leftIcon": "close",
|
|
652
|
+
"size": "sm",
|
|
653
|
+
"variant": "ghost",
|
|
654
|
+
"onClick": onClose
|
|
655
|
+
}, null);
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
660
|
+
0 && (module.exports = {
|
|
661
|
+
MpModal,
|
|
662
|
+
MpModalBody,
|
|
663
|
+
MpModalCloseButton,
|
|
664
|
+
MpModalContent,
|
|
665
|
+
MpModalFooter,
|
|
666
|
+
MpModalHeader,
|
|
667
|
+
MpModalOverlay
|
|
668
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MpModalBody
|
|
3
|
+
} from "./chunk-ASQKAMBD.mjs";
|
|
4
|
+
import {
|
|
5
|
+
MpModalCloseButton
|
|
6
|
+
} from "./chunk-D4KITWKW.mjs";
|
|
7
|
+
import {
|
|
8
|
+
MpModalContent
|
|
9
|
+
} from "./chunk-NCQFKFXL.mjs";
|
|
10
|
+
import {
|
|
11
|
+
MpModalFooter
|
|
12
|
+
} from "./chunk-THCDEEFK.mjs";
|
|
13
|
+
import {
|
|
14
|
+
MpModalHeader
|
|
15
|
+
} from "./chunk-FXPPG3HJ.mjs";
|
|
16
|
+
import {
|
|
17
|
+
MpModal
|
|
18
|
+
} from "./chunk-7LGGLG42.mjs";
|
|
19
|
+
import "./chunk-2WYPEVZV.mjs";
|
|
20
|
+
import "./chunk-MO6AFEOO.mjs";
|
|
21
|
+
import {
|
|
22
|
+
MpModalOverlay
|
|
23
|
+
} from "./chunk-FU2Y3XYA.mjs";
|
|
24
|
+
import "./chunk-DKUTSUEJ.mjs";
|
|
25
|
+
import "./chunk-QZ7VFGWC.mjs";
|
|
26
|
+
export {
|
|
27
|
+
MpModal,
|
|
28
|
+
MpModalBody,
|
|
29
|
+
MpModalCloseButton,
|
|
30
|
+
MpModalContent,
|
|
31
|
+
MpModalFooter,
|
|
32
|
+
MpModalHeader,
|
|
33
|
+
MpModalOverlay
|
|
34
|
+
};
|