@gopowerteam/modal-render 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components → cjs/components}/modal-container.vue.d.ts +32 -30
- package/dist/{components → cjs/components}/modal-provider.vue.d.ts +3 -3
- package/dist/cjs/hooks/on-submit.d.ts +2 -0
- package/dist/{hooks → cjs/hooks}/use-modal.d.ts +0 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +2 -1
- package/dist/{interfaces.d.ts → cjs/interfaces.d.ts} +5 -3
- package/dist/{utils → cjs/utils}/find-container.d.ts +1 -1
- package/dist/es/components/modal-container.vue.d.ts +89 -0
- package/dist/es/components/modal-provider.vue.d.ts +59 -0
- package/dist/es/constants.d.ts +3 -0
- package/dist/es/hooks/on-submit.d.ts +2 -0
- package/dist/es/hooks/use-modal.d.ts +7 -0
- package/dist/es/index.d.ts +7 -0
- package/dist/es/index.mjs +401 -0
- package/dist/es/interfaces.d.ts +37 -0
- package/dist/es/utils/find-container.d.ts +2 -0
- package/dist/style.css +1 -1
- package/package.json +20 -10
- package/dist/hooks/on-submit.d.ts +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.js +0 -404
- /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { unref as J, isRef as Q, toRefs as Z, customRef as j, getCurrentScope as ee, onScopeDispose as te, ref as B, computed as x, watch as oe, defineComponent as I, inject as W, shallowRef as P, onMounted as X, onUnmounted as ne, openBlock as g, createElementBlock as w, normalizeStyle as A, withModifiers as re, createElementVNode as b, normalizeClass as ie, toDisplayString as se, createCommentVNode as $, createBlock as R, resolveDynamicComponent as le, normalizeProps as ae, guardReactiveProps as ue, triggerRef as M, provide as de, Fragment as F, renderSlot as ce, Teleport as fe, createVNode as pe, TransitionGroup as me, withCtx as ve, renderList as ye, mergeProps as he, defineAsyncComponent as ge, getCurrentInstance as Y } from "vue";
|
|
2
|
+
const z = Symbol("__MODAL__");
|
|
3
|
+
function _e(o) {
|
|
4
|
+
return ee() ? (te(o), !0) : !1;
|
|
5
|
+
}
|
|
6
|
+
function h(o) {
|
|
7
|
+
return typeof o == "function" ? o() : J(o);
|
|
8
|
+
}
|
|
9
|
+
const K = typeof window < "u" && typeof document < "u", we = Object.prototype.toString, be = (o) => we.call(o) === "[object Object]", xe = () => {
|
|
10
|
+
};
|
|
11
|
+
function Ce(o, i = {}) {
|
|
12
|
+
if (!Q(o))
|
|
13
|
+
return Z(o);
|
|
14
|
+
const e = Array.isArray(o.value) ? Array.from({ length: o.value.length }) : {};
|
|
15
|
+
for (const r in o.value)
|
|
16
|
+
e[r] = j(() => ({
|
|
17
|
+
get() {
|
|
18
|
+
return o.value[r];
|
|
19
|
+
},
|
|
20
|
+
set(n) {
|
|
21
|
+
var u;
|
|
22
|
+
if ((u = h(i.replaceRef)) != null ? u : !0)
|
|
23
|
+
if (Array.isArray(o.value)) {
|
|
24
|
+
const p = [...o.value];
|
|
25
|
+
p[r] = n, o.value = p;
|
|
26
|
+
} else {
|
|
27
|
+
const p = { ...o.value, [r]: n };
|
|
28
|
+
Object.setPrototypeOf(p, Object.getPrototypeOf(o.value)), o.value = p;
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
o.value[r] = n;
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
return e;
|
|
35
|
+
}
|
|
36
|
+
function Se(o) {
|
|
37
|
+
var i;
|
|
38
|
+
const e = h(o);
|
|
39
|
+
return (i = e == null ? void 0 : e.$el) != null ? i : e;
|
|
40
|
+
}
|
|
41
|
+
const q = K ? window : void 0;
|
|
42
|
+
function H(...o) {
|
|
43
|
+
let i, e, r, n;
|
|
44
|
+
if (typeof o[0] == "string" || Array.isArray(o[0]) ? ([e, r, n] = o, i = q) : [i, e, r, n] = o, !i)
|
|
45
|
+
return xe;
|
|
46
|
+
Array.isArray(e) || (e = [e]), Array.isArray(r) || (r = [r]);
|
|
47
|
+
const u = [], v = () => {
|
|
48
|
+
u.forEach((a) => a()), u.length = 0;
|
|
49
|
+
}, p = (a, l, d, f) => (a.addEventListener(l, d, f), () => a.removeEventListener(l, d, f)), m = oe(
|
|
50
|
+
() => [Se(i), h(n)],
|
|
51
|
+
([a, l]) => {
|
|
52
|
+
if (v(), !a)
|
|
53
|
+
return;
|
|
54
|
+
const d = be(l) ? { ...l } : l;
|
|
55
|
+
u.push(
|
|
56
|
+
...e.flatMap((f) => r.map((C) => p(a, f, C, d)))
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
{ immediate: !0, flush: "post" }
|
|
60
|
+
), s = () => {
|
|
61
|
+
m(), v();
|
|
62
|
+
};
|
|
63
|
+
return _e(s), s;
|
|
64
|
+
}
|
|
65
|
+
function Ee(o, i = {}) {
|
|
66
|
+
var e, r;
|
|
67
|
+
const {
|
|
68
|
+
pointerTypes: n,
|
|
69
|
+
preventDefault: u,
|
|
70
|
+
stopPropagation: v,
|
|
71
|
+
exact: p,
|
|
72
|
+
onMove: m,
|
|
73
|
+
onEnd: s,
|
|
74
|
+
onStart: a,
|
|
75
|
+
initialValue: l,
|
|
76
|
+
axis: d = "both",
|
|
77
|
+
draggingElement: f = q,
|
|
78
|
+
containerElement: C,
|
|
79
|
+
handle: L = o
|
|
80
|
+
} = i, y = B(
|
|
81
|
+
(e = h(l)) != null ? e : { x: 0, y: 0 }
|
|
82
|
+
), _ = B(), S = (t) => n ? n.includes(t.pointerType) : !0, E = (t) => {
|
|
83
|
+
h(u) && t.preventDefault(), h(v) && t.stopPropagation();
|
|
84
|
+
}, D = (t) => {
|
|
85
|
+
var c;
|
|
86
|
+
if (!S(t) || h(p) && t.target !== h(o))
|
|
87
|
+
return;
|
|
88
|
+
const N = ((c = h(C)) != null ? c : h(o)).getBoundingClientRect(), V = {
|
|
89
|
+
x: t.clientX - N.left,
|
|
90
|
+
y: t.clientY - N.top
|
|
91
|
+
};
|
|
92
|
+
(a == null ? void 0 : a(V, t)) !== !1 && (_.value = V, E(t));
|
|
93
|
+
}, O = (t) => {
|
|
94
|
+
if (!S(t) || !_.value)
|
|
95
|
+
return;
|
|
96
|
+
let { x: c, y: k } = y.value;
|
|
97
|
+
(d === "x" || d === "both") && (c = t.clientX - _.value.x), (d === "y" || d === "both") && (k = t.clientY - _.value.y), y.value = {
|
|
98
|
+
x: c,
|
|
99
|
+
y: k
|
|
100
|
+
}, m == null || m(y.value, t), E(t);
|
|
101
|
+
}, T = (t) => {
|
|
102
|
+
S(t) && _.value && (_.value = void 0, s == null || s(y.value, t), E(t));
|
|
103
|
+
};
|
|
104
|
+
if (K) {
|
|
105
|
+
const t = { capture: (r = i.capture) != null ? r : !0 };
|
|
106
|
+
H(L, "pointerdown", D, t), H(f, "pointermove", O, t), H(f, "pointerup", T, t);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...Ce(y),
|
|
110
|
+
position: y,
|
|
111
|
+
isDragging: x(() => !!_.value),
|
|
112
|
+
style: x(
|
|
113
|
+
() => `left:${y.value.x}px;top:${y.value.y}px;`
|
|
114
|
+
)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const Me = { class: "title font-bold" }, ke = { class: "action" }, Ae = {
|
|
118
|
+
key: 1,
|
|
119
|
+
class: "modal-footer space-x-2"
|
|
120
|
+
}, Pe = ["form"], $e = {
|
|
121
|
+
name: "ModalContainer",
|
|
122
|
+
inheritAttrs: !0
|
|
123
|
+
}, Be = /* @__PURE__ */ I({
|
|
124
|
+
...$e,
|
|
125
|
+
props: {
|
|
126
|
+
id: {},
|
|
127
|
+
form: {},
|
|
128
|
+
component: {},
|
|
129
|
+
componentProps: {},
|
|
130
|
+
width: {},
|
|
131
|
+
maxWidth: {},
|
|
132
|
+
maxHeight: {},
|
|
133
|
+
sizes: {},
|
|
134
|
+
size: { default: "middle" },
|
|
135
|
+
fullscreen: { type: Boolean },
|
|
136
|
+
title: {},
|
|
137
|
+
header: { type: Boolean, default: !0 },
|
|
138
|
+
footer: { type: Boolean, default: !1 },
|
|
139
|
+
closeable: { type: Boolean, default: !0 },
|
|
140
|
+
esc: { type: Boolean, default: !1 },
|
|
141
|
+
maskClosable: { type: Boolean, default: !1 },
|
|
142
|
+
draggable: { type: Boolean, default: !1 },
|
|
143
|
+
mode: { default: "dialog" }
|
|
144
|
+
},
|
|
145
|
+
emits: ["submit"],
|
|
146
|
+
setup(o, { emit: i }) {
|
|
147
|
+
const e = o, r = i, n = W(z);
|
|
148
|
+
let u = 0, v = 0;
|
|
149
|
+
const p = P(), m = P(), s = P(), { x: a, y: l } = Ee(s, {
|
|
150
|
+
initialValue: { x: 0, y: 0 }
|
|
151
|
+
});
|
|
152
|
+
function d() {
|
|
153
|
+
n == null || n.close(e.id);
|
|
154
|
+
}
|
|
155
|
+
function f(t) {
|
|
156
|
+
if (typeof t == "number")
|
|
157
|
+
return `${t}px`;
|
|
158
|
+
if (typeof t == "string")
|
|
159
|
+
return t;
|
|
160
|
+
}
|
|
161
|
+
const C = x(() => {
|
|
162
|
+
const t = {};
|
|
163
|
+
return e.mode === "dialog" && (t.justifyContent = "center"), e.mode === "drawer" && (t.justifyContent = "flex-end"), t;
|
|
164
|
+
}), L = x(() => {
|
|
165
|
+
const t = {};
|
|
166
|
+
return e.size && (t.width = f(e.sizes[e.size])), e.width && (t.width = f(e.width)), e.maxWidth && (t.maxWidth = f(e.maxWidth)), e.fullscreen && (t.maxWidth = "unset", t.width = "100%", t.position = "fixed", t.top = 0, t.left = 0, t.bottom = 0, t.right = 0, t.borderRadius = 0), e.draggable && !e.fullscreen && e.mode === "dialog" && (t.transform = `translate3d(${a.value - u}px, ${l.value - v}px, 0px)`), e.mode === "drawer" && (t.borderRadius = 0), t;
|
|
167
|
+
}), y = x(() => {
|
|
168
|
+
const t = {};
|
|
169
|
+
return e.draggable && !e.fullscreen && e.mode === "dialog" && (t.cursor = "move"), t;
|
|
170
|
+
}), _ = x(() => {
|
|
171
|
+
var c;
|
|
172
|
+
const t = {};
|
|
173
|
+
return e.maxHeight && (t.maxHeight = `calc(${(c = f(e.maxHeight)) == null ? void 0 : c.replace("%", "vh")} - 50px)`), e.mode === "drawer" && (t.maxHeight = "unset", t.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.fullscreen && (t.maxHeight = "unset", t.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), t;
|
|
174
|
+
});
|
|
175
|
+
function S() {
|
|
176
|
+
const t = m.value;
|
|
177
|
+
if (e.form && t) {
|
|
178
|
+
const c = t.querySelector(`form[name="${e.form}"]`);
|
|
179
|
+
c && c.dispatchEvent(new Event("submit"));
|
|
180
|
+
}
|
|
181
|
+
r("submit", {
|
|
182
|
+
open: n == null ? void 0 : n.open,
|
|
183
|
+
close: (c) => n == null ? void 0 : n.close(e.id, c)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function E() {
|
|
187
|
+
n == null || n.close(e.id);
|
|
188
|
+
}
|
|
189
|
+
function D() {
|
|
190
|
+
window && window.addEventListener("resize", () => {
|
|
191
|
+
M(p), M(m), u = m.value.offsetLeft, v = m.value.offsetTop;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function O() {
|
|
195
|
+
if (e.closeable && e.esc) {
|
|
196
|
+
const t = ({ key: c }) => {
|
|
197
|
+
c === "Escape" && (n == null || n.close(e.id), window.removeEventListener("keydown", t));
|
|
198
|
+
};
|
|
199
|
+
window.addEventListener("keydown", t);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function T() {
|
|
203
|
+
u = m.value.offsetLeft, v = m.value.offsetTop;
|
|
204
|
+
}
|
|
205
|
+
return X(() => {
|
|
206
|
+
O(), D();
|
|
207
|
+
}), ne(() => {
|
|
208
|
+
}), (t, c) => (g(), w("div", {
|
|
209
|
+
ref_key: "wrapperRef",
|
|
210
|
+
ref: p,
|
|
211
|
+
class: "modal-wrapper",
|
|
212
|
+
style: A(C.value),
|
|
213
|
+
onClick: c[0] || (c[0] = re((k) => t.maskClosable && d(), ["self"]))
|
|
214
|
+
}, [
|
|
215
|
+
b("div", {
|
|
216
|
+
ref_key: "contentRef",
|
|
217
|
+
ref: m,
|
|
218
|
+
class: ie(["modal-content", { [`${t.mode}-mode`]: !0 }]),
|
|
219
|
+
style: A(L.value)
|
|
220
|
+
}, [
|
|
221
|
+
t.header ? (g(), w("div", {
|
|
222
|
+
key: 0,
|
|
223
|
+
ref_key: "headerRef",
|
|
224
|
+
ref: s,
|
|
225
|
+
class: "modal-header",
|
|
226
|
+
style: A(y.value),
|
|
227
|
+
onMousedown: T
|
|
228
|
+
}, [
|
|
229
|
+
b("div", Me, se(t.title), 1),
|
|
230
|
+
b("div", ke, [
|
|
231
|
+
t.closeable ? (g(), w("div", {
|
|
232
|
+
key: 0,
|
|
233
|
+
class: "i-icon-park-outline:close block cursor-pointer",
|
|
234
|
+
onClick: d
|
|
235
|
+
})) : $("", !0)
|
|
236
|
+
])
|
|
237
|
+
], 36)) : $("", !0),
|
|
238
|
+
b("div", {
|
|
239
|
+
class: "modal-body",
|
|
240
|
+
style: A(_.value)
|
|
241
|
+
}, [
|
|
242
|
+
(g(), R(le(t.component), ae(ue(t.componentProps)), null, 16))
|
|
243
|
+
], 4),
|
|
244
|
+
t.footer ? (g(), w("div", Ae, [
|
|
245
|
+
b("button", {
|
|
246
|
+
class: "submit-button",
|
|
247
|
+
form: t.form,
|
|
248
|
+
type: "submit",
|
|
249
|
+
onClick: S
|
|
250
|
+
}, " 确定 ", 8, Pe),
|
|
251
|
+
b("button", {
|
|
252
|
+
class: "cancel-button",
|
|
253
|
+
type: "button",
|
|
254
|
+
onClick: E
|
|
255
|
+
}, " 取消 ")
|
|
256
|
+
])) : $("", !0)
|
|
257
|
+
], 6)
|
|
258
|
+
], 4));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const G = (o, i) => {
|
|
262
|
+
const e = o.__vccOpts || o;
|
|
263
|
+
for (const [r, n] of i)
|
|
264
|
+
e[r] = n;
|
|
265
|
+
return e;
|
|
266
|
+
}, ze = /* @__PURE__ */ G(Be, [["__scopeId", "data-v-5a470d86"]]), Le = {
|
|
267
|
+
key: 0,
|
|
268
|
+
class: "modal-teleport"
|
|
269
|
+
}, De = {
|
|
270
|
+
name: "ModalProvider",
|
|
271
|
+
inheritAttrs: !0
|
|
272
|
+
}, Oe = /* @__PURE__ */ I({
|
|
273
|
+
...De,
|
|
274
|
+
props: {
|
|
275
|
+
appendToBody: { type: [Boolean, String], default: !1 },
|
|
276
|
+
sizes: { default: () => ({
|
|
277
|
+
small: 520,
|
|
278
|
+
middle: 860,
|
|
279
|
+
large: 1190
|
|
280
|
+
}) },
|
|
281
|
+
maxWidth: { default: "80%" },
|
|
282
|
+
maxHeight: { default: "80%" }
|
|
283
|
+
},
|
|
284
|
+
setup(o, { expose: i }) {
|
|
285
|
+
const e = P([]), r = B(!1);
|
|
286
|
+
async function n(s, a, l) {
|
|
287
|
+
const d = ge(
|
|
288
|
+
() => Promise.resolve(s)
|
|
289
|
+
);
|
|
290
|
+
return new Promise((f) => {
|
|
291
|
+
e.value.push({
|
|
292
|
+
id: Math.random().toString(32).slice(2),
|
|
293
|
+
component: d,
|
|
294
|
+
props: a,
|
|
295
|
+
options: l,
|
|
296
|
+
resolve: f,
|
|
297
|
+
onSubmit: B(null)
|
|
298
|
+
}), M(e);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function u(s, a) {
|
|
302
|
+
const l = e.value.findIndex((f) => f.id === s);
|
|
303
|
+
if (l < 0)
|
|
304
|
+
return;
|
|
305
|
+
const d = e.value[l];
|
|
306
|
+
d == null || d.resolve(a), e.value.splice(l, 1), M(e);
|
|
307
|
+
}
|
|
308
|
+
function v() {
|
|
309
|
+
e.value.forEach((s) => {
|
|
310
|
+
s.resolve();
|
|
311
|
+
}), e.value = [], M(e);
|
|
312
|
+
}
|
|
313
|
+
function p(s) {
|
|
314
|
+
return e.value.find((a) => a.id === s);
|
|
315
|
+
}
|
|
316
|
+
function m(s, a) {
|
|
317
|
+
const l = e.value.find((d) => d.id === s);
|
|
318
|
+
console.log(a, 111), l && (l.onSubmit.value = a);
|
|
319
|
+
}
|
|
320
|
+
return de(z, {
|
|
321
|
+
open: n,
|
|
322
|
+
close: u,
|
|
323
|
+
closeAll: v,
|
|
324
|
+
getElement: p,
|
|
325
|
+
addSubmitListener: m
|
|
326
|
+
}), i({
|
|
327
|
+
elements: e
|
|
328
|
+
}), X(() => {
|
|
329
|
+
r.value = !0;
|
|
330
|
+
}), (s, a) => (g(), w(F, null, [
|
|
331
|
+
ce(s.$slots, "default", {}, void 0, !0),
|
|
332
|
+
r.value ? (g(), w("div", Le, [
|
|
333
|
+
(g(), R(fe, {
|
|
334
|
+
disabled: !s.appendToBody,
|
|
335
|
+
to: typeof s.appendToBody == "string" ? s.appendToBody : "body"
|
|
336
|
+
}, [
|
|
337
|
+
pe(me, { name: "modal-fade" }, {
|
|
338
|
+
default: ve(() => [
|
|
339
|
+
(g(!0), w(F, null, ye(e.value, (l) => (g(), R(ze, he({
|
|
340
|
+
id: l.id,
|
|
341
|
+
key: l.id,
|
|
342
|
+
component: l.component,
|
|
343
|
+
"component-props": l.props,
|
|
344
|
+
"max-height": s.maxHeight,
|
|
345
|
+
"max-width": s.maxWidth,
|
|
346
|
+
sizes: s.sizes
|
|
347
|
+
}, l.options, {
|
|
348
|
+
onSubmit: l.onSubmit.value
|
|
349
|
+
}), null, 16, ["id", "component", "component-props", "max-height", "max-width", "sizes", "onSubmit"]))), 128))
|
|
350
|
+
]),
|
|
351
|
+
_: 1
|
|
352
|
+
})
|
|
353
|
+
], 8, ["disabled", "to"]))
|
|
354
|
+
])) : $("", !0)
|
|
355
|
+
], 64));
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
const He = /* @__PURE__ */ G(Oe, [["__scopeId", "data-v-cec9e05a"]]);
|
|
359
|
+
function U(o, i) {
|
|
360
|
+
var r, n;
|
|
361
|
+
let e = o == null ? void 0 : o.parent;
|
|
362
|
+
for (; e && ((r = e == null ? void 0 : e.type) == null ? void 0 : r.name) !== i; )
|
|
363
|
+
e = e.parent;
|
|
364
|
+
return ((n = e == null ? void 0 : e.type) == null ? void 0 : n.name) === i ? e : null;
|
|
365
|
+
}
|
|
366
|
+
function Re() {
|
|
367
|
+
const o = W(z), i = Y();
|
|
368
|
+
return {
|
|
369
|
+
open(e, r, n) {
|
|
370
|
+
if (!o)
|
|
371
|
+
throw new Error("Not Found Modal Provider Component");
|
|
372
|
+
return o.open(e, r || {}, n || {});
|
|
373
|
+
},
|
|
374
|
+
close(e) {
|
|
375
|
+
var u;
|
|
376
|
+
if (!o)
|
|
377
|
+
throw new Error("Not Found Modal Provider Component");
|
|
378
|
+
const r = U(i, "ModalContainer"), n = (u = r == null ? void 0 : r.props) == null ? void 0 : u.id;
|
|
379
|
+
if (!n)
|
|
380
|
+
throw new Error("Not Found Current Modal Container");
|
|
381
|
+
o.close(n, e);
|
|
382
|
+
},
|
|
383
|
+
closeAll() {
|
|
384
|
+
if (!o)
|
|
385
|
+
throw new Error("Not Found Modal Provider Component");
|
|
386
|
+
o.closeAll();
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function We(o) {
|
|
391
|
+
var u;
|
|
392
|
+
const i = W(z), e = Y(), r = U(e, "ModalContainer"), n = (u = r == null ? void 0 : r.props) == null ? void 0 : u.id;
|
|
393
|
+
i && n && i.addSubmitListener(n, o);
|
|
394
|
+
}
|
|
395
|
+
export {
|
|
396
|
+
ze as ModalContainer,
|
|
397
|
+
z as ModalKey,
|
|
398
|
+
He as ModalProvider,
|
|
399
|
+
We as onSubmit,
|
|
400
|
+
Re as useModal
|
|
401
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Component, Ref } from 'vue';
|
|
2
|
+
import type { useModal } from './hooks/use-modal';
|
|
3
|
+
export interface SizeOptions {
|
|
4
|
+
small: number;
|
|
5
|
+
middle: number;
|
|
6
|
+
large: number;
|
|
7
|
+
}
|
|
8
|
+
export interface OpenModalOptions {
|
|
9
|
+
closeable?: boolean;
|
|
10
|
+
esc?: boolean;
|
|
11
|
+
mask?: boolean;
|
|
12
|
+
maskClosable?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
header?: boolean;
|
|
15
|
+
footer?: boolean;
|
|
16
|
+
width?: number | string;
|
|
17
|
+
size?: 'large' | 'middle' | 'small';
|
|
18
|
+
fullscreen?: boolean;
|
|
19
|
+
draggable?: boolean;
|
|
20
|
+
form?: string;
|
|
21
|
+
mode?: 'dialog' | 'drawer';
|
|
22
|
+
}
|
|
23
|
+
export interface ModalElement extends OpenModalOptions {
|
|
24
|
+
id: string;
|
|
25
|
+
resolve: (data?: any) => void;
|
|
26
|
+
component: Component;
|
|
27
|
+
props: Record<string, any>;
|
|
28
|
+
options: OpenModalOptions;
|
|
29
|
+
onSubmit: Ref<((actions: ReturnType<typeof useModal>) => void) | null>;
|
|
30
|
+
}
|
|
31
|
+
export interface ModalActions {
|
|
32
|
+
open: (component: Component, props: Record<string, any>, options: OpenModalOptions) => Promise<any | void>;
|
|
33
|
+
close: (id: string, data?: any) => void;
|
|
34
|
+
closeAll: () => void;
|
|
35
|
+
getElement: (id: string) => ModalElement | undefined;
|
|
36
|
+
addSubmitListener: (id: string, fun: (modal: ReturnType<typeof useModal>) => void) => void;
|
|
37
|
+
}
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.fixed{position:fixed}.
|
|
1
|
+
*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.fixed{position:fixed}.block{display:block}.flex{display:flex}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.resize{resize:both}.space-x-2>:not([hidden])~:not([hidden]){--un-space-x-reverse:0;margin-left:calc(.5rem * calc(1 - var(--un-space-x-reverse)));margin-right:calc(.5rem * var(--un-space-x-reverse))}.px{padding-left:1rem;padding-right:1rem}.font-bold{font-weight:700}.outline{outline-style:solid}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.ease{transition-timing-function:cubic-bezier(.4,0,.2,1)}.modal-wrapper[data-v-5a470d86]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-5a470d86]{background:#ffffff;border-radius:5px}.modal-header[data-v-5a470d86]{box-sizing:border-box;padding:10px;height:50px;display:flex;justify-content:space-between;align-items:center;border-bottom:solid 1px var(--color-border-1, #e8e8e8)}.modal-body[data-v-5a470d86]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-5a470d86]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:end;padding:10px}.modal-footer button[data-v-5a470d86]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.modal-footer button.submit-button[data-v-5a470d86]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-5a470d86]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-5a470d86]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-5a470d86]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-fade-enter-active[data-v-cec9e05a],.modal-fade-leave-active[data-v-cec9e05a]{transition:opacity .5s ease}.modal-fade-enter-active[data-v-cec9e05a] .modal-content.drawer-mode,.modal-fade-leave-active[data-v-cec9e05a] .modal-content.drawer-mode{transition:transform .5s ease}.modal-fade-enter-from[data-v-cec9e05a],.modal-fade-leave-to[data-v-cec9e05a]{opacity:0}.modal-fade-enter-from[data-v-cec9e05a] .modal-content.drawer-mode,.modal-fade-leave-to[data-v-cec9e05a] .modal-content.drawer-mode{transform:translate3d(100%,0,0)}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopowerteam/modal-render",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "zhuchentong",
|
|
7
7
|
"email": "2037630@gmail.com"
|
|
@@ -15,19 +15,29 @@
|
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/gopowerteam/x-render/issues"
|
|
17
17
|
},
|
|
18
|
+
"main": "./dist/cjs/index.cjs",
|
|
19
|
+
"module": "./dist/es/index.mjs",
|
|
20
|
+
"types": "./dist/es/index.d.ts",
|
|
18
21
|
"exports": {
|
|
19
22
|
".": {
|
|
20
|
-
"
|
|
21
|
-
"import":
|
|
22
|
-
|
|
23
|
-
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
23
|
+
"types": "./dist/es/index.d.ts",
|
|
24
|
+
"import": "./dist/es/index.mjs",
|
|
25
|
+
"require": "./dist/cjs/index.cjs"
|
|
25
26
|
},
|
|
26
|
-
"./
|
|
27
|
+
"./es": {
|
|
28
|
+
"types": "./dist/es/index.d.ts",
|
|
29
|
+
"import": "./dist/es/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./cjs": {
|
|
32
|
+
"types": "./dist/cjs/index.d.ts",
|
|
33
|
+
"require": "./dist/cjs/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./dist/style.css": {
|
|
36
|
+
"require": "./dist/style.css",
|
|
37
|
+
"import": "./dist/style.css"
|
|
38
|
+
},
|
|
39
|
+
"./*": "./*"
|
|
27
40
|
},
|
|
28
|
-
"main": "./dist/index.cjs",
|
|
29
|
-
"module": "./dist/index.js",
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
41
|
"files": [
|
|
32
42
|
"dist",
|
|
33
43
|
"README.md"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function onSubmit(callback: () => void): void;
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const E=Symbol("__MODAL__");function O(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}function g(n){return typeof n=="function"?n():e.unref(n)}const V=typeof window<"u"&&typeof document<"u",D=Object.prototype.toString,H=n=>D.call(n)==="[object Object]",T=()=>{};function W(n,i={}){if(!e.isRef(n))return e.toRefs(n);const t=Array.isArray(n.value)?Array.from({length:n.value.length}):{};for(const r in n.value)t[r]=e.customRef(()=>({get(){return n.value[r]},set(l){var u;if((u=g(i.replaceRef))!=null?u:!0)if(Array.isArray(n.value)){const m=[...n.value];m[r]=l,n.value=m}else{const m={...n.value,[r]:l};Object.setPrototypeOf(m,Object.getPrototypeOf(n.value)),n.value=m}else n.value[r]=l}}));return t}function F(n){var i;const t=g(n);return(i=t==null?void 0:t.$el)!=null?i:t}const $=V?window:void 0;function z(...n){let i,t,r,l;if(typeof n[0]=="string"||Array.isArray(n[0])?([t,r,l]=n,i=$):[i,t,r,l]=n,!i)return T;Array.isArray(t)||(t=[t]),Array.isArray(r)||(r=[r]);const u=[],y=()=>{u.forEach(c=>c()),u.length=0},m=(c,s,d,f)=>(c.addEventListener(s,d,f),()=>c.removeEventListener(s,d,f)),v=e.watch(()=>[F(i),g(l)],([c,s])=>{if(y(),!c)return;const d=H(s)?{...s}:s;u.push(...t.flatMap(f=>r.map(w=>m(c,f,w,d))))},{immediate:!0,flush:"post"}),a=()=>{v(),y()};return O(a),a}function I(n,i={}){var t,r;const{pointerTypes:l,preventDefault:u,stopPropagation:y,exact:m,onMove:v,onEnd:a,onStart:c,initialValue:s,axis:d="both",draggingElement:f=$,containerElement:w,handle:x=n}=i,h=e.ref((t=g(s))!=null?t:{x:0,y:0}),_=e.ref(),b=o=>l?l.includes(o.pointerType):!0,k=o=>{g(u)&&o.preventDefault(),g(y)&&o.stopPropagation()},S=o=>{var p;if(!b(o)||g(m)&&o.target!==g(n))return;const P=((p=g(w))!=null?p:g(n)).getBoundingClientRect(),N={x:o.clientX-P.left,y:o.clientY-P.top};(c==null?void 0:c(N,o))!==!1&&(_.value=N,k(o))},M=o=>{if(!b(o)||!_.value)return;let{x:p,y:C}=h.value;(d==="x"||d==="both")&&(p=o.clientX-_.value.x),(d==="y"||d==="both")&&(C=o.clientY-_.value.y),h.value={x:p,y:C},v==null||v(h.value,o),k(o)},B=o=>{b(o)&&_.value&&(_.value=void 0,a==null||a(h.value,o),k(o))};if(V){const o={capture:(r=i.capture)!=null?r:!0};z(x,"pointerdown",S,o),z(f,"pointermove",M,o),z(f,"pointerup",B,o)}return{...W(h),position:h,isDragging:e.computed(()=>!!_.value),style:e.computed(()=>`left:${h.value.x}px;top:${h.value.y}px;`)}}const X={class:"modal-container fixed inset-0"},Y={class:"title font-bold"},q={class:"action"},K={key:1,class:"modal-footer space-x-2"},j=["form"],G={name:"ModalContainer",inheritAttrs:!0},U=e.defineComponent({...G,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},sizes:{},size:{default:"middle"},title:{},header:{type:Boolean,default:!0},footer:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},esc:{type:Boolean,default:!1},maskClosable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},mode:{default:"dialog"}},emits:["submit"],setup(n,{emit:i}){const t=n,r=i,l=e.inject(E);let u=0,y=0;const m=e.shallowRef(),v=e.shallowRef(),a=e.shallowRef(),{x:c,y:s}=I(a,{initialValue:{x:0,y:0}});function d(){l==null||l.close(t.id)}function f(o){if(typeof o=="number")return`${o}px`;if(typeof o=="string")return o}const w=e.computed(()=>{const o={};return t.mode==="dialog"&&(o.justifyContent="center"),t.mode==="drawer"&&(o.justifyContent="flex-end"),o}),x=e.computed(()=>{const o={};return t.size&&(o.width=f(t.sizes[t.size])),t.width&&(o.width=f(t.width)),t.maxWidth&&(o.maxWidth=f(t.maxWidth)),t.size==="fullscreen"&&(o.maxWidth="unset",o.position="fixed",o.top=0,o.left=0,o.bottom=0,o.right=0),t.draggable&&t.size!=="fullscreen"&&t.mode==="dialog"&&(o.transform=`translate3d(${c.value-u}px, ${s.value-y}px, 0px)`),o}),h=e.computed(()=>{const o={};return t.draggable&&t.size!=="fullscreen"&&t.mode==="dialog"&&(o.cursor="move"),o}),_=e.computed(()=>{var p;const o={};return t.maxHeight&&(o.maxHeight=`calc(${(p=f(t.maxHeight))==null?void 0:p.replace("%","vh")} - 50px)`),t.mode==="drawer"&&(o.maxHeight=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.size==="fullscreen"&&(o.maxHeight=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),o});function b(){const o=v.value;if(t.form&&o){const p=o.querySelector(`form[name="${t.form}"]`);p&&p.dispatchEvent(new Event("submit"))}r("submit")}function k(){l==null||l.close(t.id)}function S(){window&&window.addEventListener("resize",()=>{e.triggerRef(m),e.triggerRef(v),u=v.value.offsetLeft,y=v.value.offsetTop})}function M(){if(t.closeable&&t.esc){const o=({key:p})=>{p==="Escape"&&(l==null||l.close(t.id),window.removeEventListener("keydown",o))};window.addEventListener("keydown",o)}}function B(){u=v.value.offsetLeft,y=v.value.offsetTop}return e.onMounted(()=>{M(),S()}),e.onUnmounted(()=>{}),(o,p)=>(e.openBlock(),e.createElementBlock("div",X,[e.createElementVNode("div",{ref_key:"wrapperRef",ref:m,class:"modal-wrapper",style:e.normalizeStyle(w.value),onClick:p[0]||(p[0]=e.withModifiers(C=>o.maskClosable&&d(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${o.mode}-mode`]:!0}]),style:e.normalizeStyle(x.value)},[o.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:a,class:"modal-header",style:e.normalizeStyle(h.value),onMousedown:B},[e.createElementVNode("div",Y,e.toDisplayString(o.title),1),e.createElementVNode("div",q,[o.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:d})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(_.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),e.normalizeProps(e.guardReactiveProps(o.componentProps)),null,16))],4),o.footer?(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("button",{class:"submit-button",form:o.form,type:"submit",onClick:b}," 确定 ",8,j),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:k}," 取消 ")])):e.createCommentVNode("",!0)],6)],4)]))}});const R=(n,i)=>{const t=n.__vccOpts||n;for(const[r,l]of i)t[r]=l;return t},L=R(U,[["__scopeId","data-v-581eba51"]]),J={key:0,class:"modal-teleport"},Q={name:"ModalProvider",inheritAttrs:!0},Z=e.defineComponent({...Q,props:{appendToBody:{type:Boolean,default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(n,{expose:i}){const t=e.shallowRef([]),r=e.ref(!1);async function l(a,c,s){const d=e.defineAsyncComponent(()=>Promise.resolve(a));return new Promise(f=>{t.value.push({id:Math.random().toString(32).slice(2),component:d,props:c,options:s,resolve:f,onSubmit:e.ref(()=>{})}),e.triggerRef(t)})}function u(a,c){const s=t.value.findIndex(f=>f.id===a);if(s<0)return;const d=t.value[s];d==null||d.resolve(c),t.value.splice(s,1),e.triggerRef(t)}function y(){t.value.forEach(a=>{a.resolve()}),t.value=[],e.triggerRef(t)}function m(a){return t.value.find(c=>c.id===a)}function v(a,c){const s=t.value.find(d=>d.id===a);s&&(s.onSubmit.value=c)}return e.provide(E,{open:l,close:u,closeAll:y,getElement:m,addSubmitListener:v}),i({elements:t}),e.onMounted(()=>{r.value=!0}),(a,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(a.$slots,"default",{},void 0,!0),r.value?(e.openBlock(),e.createElementBlock("div",J,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!a.appendToBody,to:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,s=>(e.openBlock(),e.createBlock(L,e.mergeProps({id:s.id,key:s.id,component:s.component,"component-props":s.props,"max-height":a.maxHeight,"max-width":a.maxWidth,sizes:a.sizes},s.options,{onSubmit:s.onSubmit.value}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled"]))])):e.createCommentVNode("",!0)],64))}});const ee=R(Z,[["__scopeId","data-v-1ef03c20"]]);function A(n,i){var r,l;let t=n==null?void 0:n.parent;for(;t&&((r=t==null?void 0:t.type)==null?void 0:r.name)!==i;)t=t.parent;return((l=t==null?void 0:t.type)==null?void 0:l.name)===i?t:null}function te(){const n=e.inject(E),i=e.getCurrentInstance();return{open(t,r,l){if(!n)throw new Error("Not Found Modal Provider Component");return n.open(t,r||{},l||{})},close(t){var u;if(!n)throw new Error("Not Found Modal Provider Component");const r=A(i,"ModalContainer"),l=(u=r==null?void 0:r.props)==null?void 0:u.id;if(!l)throw new Error("Not Found Current Modal Container");n.close(l,t)},closeAll(){if(!n)throw new Error("Not Found Modal Provider Component");n.closeAll()},onSubmit(t){const r=A(i,"ModalContainer");if(!(r==null?void 0:r.props.id))throw new Error("Not Found Current Modal Container")}}}function oe(n){var u;const i=e.inject(E),t=e.getCurrentInstance(),r=A(t,"ModalContainer"),l=(u=r==null?void 0:r.props)==null?void 0:u.id;i&&l&&i.addSubmitListener(l,n)}exports.ModalContainer=L;exports.ModalProvider=ee;exports.onSubmit=oe;exports.useModal=te;
|