@inertia-vuetify/modal 0.0.0-stage → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +50 -0
- package/README.md +371 -2
- package/dist/CloseButton.vue.d.ts +3 -0
- package/dist/Deferred.vue.d.ts +16 -0
- package/dist/ModalBtn.vue.d.ts +17 -0
- package/dist/ModalContent.vue.d.ts +33 -0
- package/dist/ModalLink.vue.d.ts +201 -0
- package/dist/ModalRenderer.vue.d.ts +6 -0
- package/dist/ModalRoot.vue.d.ts +13 -0
- package/dist/WhenVisible.vue.d.ts +24 -0
- package/dist/app.d.ts +5 -0
- package/dist/cache.d.ts +12 -0
- package/dist/config.d.ts +16 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/index.d.ts +14 -0
- package/dist/inertia-modal-vuetify.js +1140 -0
- package/dist/keys.d.ts +2 -0
- package/dist/modalStack.d.ts +64 -0
- package/dist/transitions.d.ts +10 -0
- package/dist/types.d.ts +109 -0
- package/dist/useModal.d.ts +3 -0
- package/package.json +71 -4
- package/src/CloseButton.vue +13 -0
- package/src/Deferred.vue +21 -0
- package/src/HeadlessModal.vue +174 -0
- package/src/Modal.vue +120 -0
- package/src/ModalBtn.vue +28 -0
- package/src/ModalContent.vue +238 -0
- package/src/ModalLink.vue +189 -0
- package/src/ModalRenderer.vue +21 -0
- package/src/ModalRoot.vue +152 -0
- package/src/WhenVisible.vue +90 -0
- package/src/app.ts +17 -0
- package/src/cache.ts +67 -0
- package/src/config.ts +116 -0
- package/src/helpers.ts +18 -0
- package/src/index.ts +15 -0
- package/src/keys.ts +3 -0
- package/src/modalStack.ts +525 -0
- package/src/transitions.ts +30 -0
- package/src/types.ts +121 -0
- package/src/useModal.ts +7 -0
|
@@ -0,0 +1,1140 @@
|
|
|
1
|
+
import * as e from "@inertiaui/vanilla";
|
|
2
|
+
import { except as t, generateId as n, kebabCase as r, markAriaHidden as i, only as a, prefersReducedMotion as o, rejectNullValues as s, sameUrlPath as c } from "@inertiaui/vanilla";
|
|
3
|
+
import { Fragment as l, Transition as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createSlots as g, createTextVNode as _, createVNode as v, defineComponent as y, guardReactiveProps as b, h as x, inject as S, markRaw as C, mergeProps as w, nextTick as ee, normalizeClass as te, normalizeProps as T, normalizeStyle as ne, onBeforeUnmount as E, onMounted as D, onUnmounted as O, openBlock as k, provide as A, reactive as j, readonly as M, ref as N, renderSlot as P, resolveDynamicComponent as F, toDisplayString as re, toRef as ie, toValue as ae, unref as I, useAttrs as oe, useId as se, useSlots as ce, useTemplateRef as le, watch as L, withCtx as R } from "vue";
|
|
4
|
+
import { http as z, progress as B, router as V, usePage as ue } from "@inertiajs/vue3";
|
|
5
|
+
import { mergeDataIntoQueryString as de } from "@inertiajs/core";
|
|
6
|
+
import { useDefaults as fe, useDisplay as pe, useLocale as me, useRtl as he } from "vuetify";
|
|
7
|
+
import { VCard as ge, VCardActions as _e, VCardItem as ve } from "vuetify/components/VCard";
|
|
8
|
+
import { VDialog as ye } from "vuetify/components/VDialog";
|
|
9
|
+
import { VBtn as be } from "vuetify/components/VBtn";
|
|
10
|
+
// src/helpers.ts
|
|
11
|
+
function xe(e) {
|
|
12
|
+
return typeof e == "string" ? JSON.parse(e) : e;
|
|
13
|
+
}
|
|
14
|
+
var Se = null;
|
|
15
|
+
function H(e = "inertiaui_modal_") {
|
|
16
|
+
return Se?.() ?? n(e);
|
|
17
|
+
}
|
|
18
|
+
// src/cache.ts
|
|
19
|
+
var U = class {
|
|
20
|
+
cache = /* @__PURE__ */ new Map();
|
|
21
|
+
timers = /* @__PURE__ */ new Map();
|
|
22
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
23
|
+
static key(e, t, n) {
|
|
24
|
+
return `${e}:${t}:${JSON.stringify(n)}`;
|
|
25
|
+
}
|
|
26
|
+
get(e) {
|
|
27
|
+
let t = this.cache.get(e);
|
|
28
|
+
return t ? Date.now() > t.expiresAt ? (this.delete(e), null) : t.response : null;
|
|
29
|
+
}
|
|
30
|
+
set(e, t, n) {
|
|
31
|
+
this.delete(e), this.cache.set(e, {
|
|
32
|
+
response: t,
|
|
33
|
+
expiresAt: Date.now() + n
|
|
34
|
+
}), n > 0 && this.timers.set(e, setTimeout(() => this.delete(e), n));
|
|
35
|
+
}
|
|
36
|
+
delete(e) {
|
|
37
|
+
this.cache.delete(e);
|
|
38
|
+
let t = this.timers.get(e);
|
|
39
|
+
t && (clearTimeout(t), this.timers.delete(e));
|
|
40
|
+
}
|
|
41
|
+
getInFlight(e) {
|
|
42
|
+
return this.inFlight.get(e);
|
|
43
|
+
}
|
|
44
|
+
setInFlight(e, t) {
|
|
45
|
+
this.inFlight.set(e, t);
|
|
46
|
+
}
|
|
47
|
+
deleteInFlight(e) {
|
|
48
|
+
this.inFlight.delete(e);
|
|
49
|
+
}
|
|
50
|
+
}, W = {
|
|
51
|
+
type: "modal",
|
|
52
|
+
navigate: !1,
|
|
53
|
+
appElement: "#app",
|
|
54
|
+
modal: {
|
|
55
|
+
closeButton: !0,
|
|
56
|
+
closeExplicitly: !1,
|
|
57
|
+
closeOnClickOutside: !0,
|
|
58
|
+
maxWidth: "2xl",
|
|
59
|
+
paddingClasses: "pa-4 pa-sm-6",
|
|
60
|
+
panelClasses: "",
|
|
61
|
+
position: "center",
|
|
62
|
+
fullscreen: "sm"
|
|
63
|
+
},
|
|
64
|
+
slideover: {
|
|
65
|
+
closeButton: !0,
|
|
66
|
+
closeExplicitly: !1,
|
|
67
|
+
closeOnClickOutside: !0,
|
|
68
|
+
maxWidth: "md",
|
|
69
|
+
paddingClasses: "pa-4 pa-sm-6",
|
|
70
|
+
panelClasses: "",
|
|
71
|
+
position: "right",
|
|
72
|
+
fullscreen: !1
|
|
73
|
+
}
|
|
74
|
+
}, G;
|
|
75
|
+
function Ce() {
|
|
76
|
+
G = structuredClone(W);
|
|
77
|
+
}
|
|
78
|
+
function we(e, t) {
|
|
79
|
+
if (typeof e == "object") {
|
|
80
|
+
G = {
|
|
81
|
+
type: e.type ?? W.type,
|
|
82
|
+
navigate: e.navigate ?? W.navigate,
|
|
83
|
+
appElement: e.appElement === void 0 ? W.appElement : e.appElement,
|
|
84
|
+
modal: {
|
|
85
|
+
...W.modal,
|
|
86
|
+
...e.modal
|
|
87
|
+
},
|
|
88
|
+
slideover: {
|
|
89
|
+
...W.slideover,
|
|
90
|
+
...e.slideover
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let n = e.split("."), r = G;
|
|
96
|
+
for (let e of n.slice(0, -1)) r = r[e] ??= {};
|
|
97
|
+
r[n[n.length - 1]] = t;
|
|
98
|
+
}
|
|
99
|
+
function K(e) {
|
|
100
|
+
if (e === void 0) return G;
|
|
101
|
+
let t = G;
|
|
102
|
+
for (let n of e.split(".")) {
|
|
103
|
+
if (typeof t != "object" || !t) return null;
|
|
104
|
+
t = t[n];
|
|
105
|
+
}
|
|
106
|
+
return t ?? null;
|
|
107
|
+
}
|
|
108
|
+
function q(e, t) {
|
|
109
|
+
return K(`${e ? "slideover" : "modal"}.${t}`);
|
|
110
|
+
}
|
|
111
|
+
var Te = {
|
|
112
|
+
sm: "384px",
|
|
113
|
+
md: "448px",
|
|
114
|
+
lg: "512px",
|
|
115
|
+
xl: "576px",
|
|
116
|
+
"2xl": "672px",
|
|
117
|
+
"3xl": "768px",
|
|
118
|
+
"4xl": "896px",
|
|
119
|
+
"5xl": "1024px",
|
|
120
|
+
"6xl": "1152px",
|
|
121
|
+
"7xl": "1280px"
|
|
122
|
+
};
|
|
123
|
+
function J(e) {
|
|
124
|
+
return Te[e ?? ""] ?? Te["2xl"];
|
|
125
|
+
}
|
|
126
|
+
function Ee(e) {
|
|
127
|
+
return e === "top" || e === "bottom" ? e : "center";
|
|
128
|
+
}
|
|
129
|
+
Ce();
|
|
130
|
+
// src/modalStack.ts
|
|
131
|
+
var Y = N(null), X = N([]), De = N({}), Z = null, Q = new U();
|
|
132
|
+
function Oe(e, t = H()) {
|
|
133
|
+
return {
|
|
134
|
+
...e,
|
|
135
|
+
Accept: "text/html, application/xhtml+xml",
|
|
136
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
137
|
+
"X-Inertia": "true",
|
|
138
|
+
"X-Inertia-Version": ue().version ?? "",
|
|
139
|
+
"X-InertiaUI-Modal": t,
|
|
140
|
+
"X-InertiaUI-Modal-Base-Url": Y.value ?? ""
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function ke(e, t = {}) {
|
|
144
|
+
if (e.startsWith("#")) return Promise.resolve();
|
|
145
|
+
let n = t.method ?? "get", [r, i] = de(n, e, t.data ?? {}, t.queryStringArrayFormat ?? "brackets"), a = U.key(n, r, i);
|
|
146
|
+
if (Q.get(a)) return Promise.resolve();
|
|
147
|
+
let o = Q.getInFlight(a);
|
|
148
|
+
if (o) return o.then(() => {});
|
|
149
|
+
t.onPrefetching?.();
|
|
150
|
+
let s = z.getClient().request({
|
|
151
|
+
url: r,
|
|
152
|
+
method: n,
|
|
153
|
+
data: i,
|
|
154
|
+
headers: Oe(t.headers ?? {})
|
|
155
|
+
}).then((e) => (Q.set(a, e, t.cacheFor ?? 3e4), t.onPrefetched?.(), e)).finally(() => Q.deleteInFlight(a));
|
|
156
|
+
return Q.setInFlight(a, s), s.then(() => {});
|
|
157
|
+
}
|
|
158
|
+
var Ae = (e) => {}, je = class {
|
|
159
|
+
id;
|
|
160
|
+
isOpen = !1;
|
|
161
|
+
shouldRender = !1;
|
|
162
|
+
listeners = {};
|
|
163
|
+
component;
|
|
164
|
+
props;
|
|
165
|
+
response;
|
|
166
|
+
config;
|
|
167
|
+
onCloseCallback;
|
|
168
|
+
afterLeaveCallback;
|
|
169
|
+
index;
|
|
170
|
+
onTopOfStack;
|
|
171
|
+
name;
|
|
172
|
+
constructor(e, t, n, r, i) {
|
|
173
|
+
this.id = t.id ?? H(), this.component = e, this.props = N(t.props ?? {}), this.response = t, this.config = n ?? {}, this.onCloseCallback = r ?? null, this.afterLeaveCallback = i ?? null, this.index = d(() => X.value.findIndex((e) => e.id === this.id)), this.onTopOfStack = d(() => X.value.length < 2 || X.value.findLast((e) => e.shouldRender)?.id === this.id);
|
|
174
|
+
}
|
|
175
|
+
getComponentPropKeys = () => {
|
|
176
|
+
let e = this.component?.props;
|
|
177
|
+
return Array.isArray(e) ? e : e ? Object.keys(e) : [];
|
|
178
|
+
};
|
|
179
|
+
getParentModal = () => {
|
|
180
|
+
let e = this.index.value;
|
|
181
|
+
return e < 1 ? null : X.value.slice(0, e).findLast((e) => e.isOpen) ?? null;
|
|
182
|
+
};
|
|
183
|
+
getChildModal = () => {
|
|
184
|
+
let e = this.index.value;
|
|
185
|
+
return e === X.value.length - 1 ? null : X.value.slice(e + 1).find((e) => e.isOpen) ?? null;
|
|
186
|
+
};
|
|
187
|
+
show = () => {
|
|
188
|
+
let e = X.value[this.index.value];
|
|
189
|
+
e && !e.isOpen && (e.isOpen = !0, e.shouldRender = !0);
|
|
190
|
+
};
|
|
191
|
+
close = () => {
|
|
192
|
+
let e = X.value[this.index.value];
|
|
193
|
+
e?.isOpen && (Object.keys(this.listeners).forEach((e) => this.off(e)), e.isOpen = !1, this.onCloseCallback?.(), this.onCloseCallback = null);
|
|
194
|
+
};
|
|
195
|
+
setOpen = (e) => {
|
|
196
|
+
e ? this.show() : this.close();
|
|
197
|
+
};
|
|
198
|
+
afterLeave = () => {
|
|
199
|
+
let e = this.index.value, t = X.value[e];
|
|
200
|
+
if (t) {
|
|
201
|
+
if (t.isOpen) return;
|
|
202
|
+
t.shouldRender = !1, this.afterLeaveCallback?.(), this.afterLeaveCallback = null;
|
|
203
|
+
}
|
|
204
|
+
if (e !== 0) return;
|
|
205
|
+
X.value = [];
|
|
206
|
+
let n = Y.value;
|
|
207
|
+
Y.value = null, Z = n, n && typeof window < "u" && !c(n, window.location.href) && V.push({
|
|
208
|
+
url: n,
|
|
209
|
+
preserveScroll: !0,
|
|
210
|
+
preserveState: !0,
|
|
211
|
+
props: (e) => ({
|
|
212
|
+
...e,
|
|
213
|
+
_inertiaui_modal: void 0
|
|
214
|
+
})
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
on = (e, t) => {
|
|
218
|
+
e = r(e), this.listeners[e] = this.listeners[e] ?? [], this.listeners[e].push(t);
|
|
219
|
+
};
|
|
220
|
+
off = (e, t) => {
|
|
221
|
+
e = r(e), t ? this.listeners[e] = this.listeners[e]?.filter((e) => e !== t) ?? [] : delete this.listeners[e];
|
|
222
|
+
};
|
|
223
|
+
emit = (e, ...t) => {
|
|
224
|
+
this.listeners[r(e)]?.forEach((e) => e(...t));
|
|
225
|
+
};
|
|
226
|
+
registerEventListenersFromAttrs = (e) => {
|
|
227
|
+
let t = Object.keys(e).filter((e) => e.startsWith("on")).map((t) => {
|
|
228
|
+
let n = r(t).replace(/^on-/, ""), i = e[t];
|
|
229
|
+
return this.on(n, i), () => this.off(n, i);
|
|
230
|
+
});
|
|
231
|
+
return () => t.forEach((e) => e());
|
|
232
|
+
};
|
|
233
|
+
reload = async (e = {}) => {
|
|
234
|
+
if (!this.response.url) return;
|
|
235
|
+
let n = t(e.only ?? Object.keys(this.response.props), e.except ?? []), r = e.method ?? "get", i = e.data ?? {};
|
|
236
|
+
e.onStart?.();
|
|
237
|
+
try {
|
|
238
|
+
let t = await z.getClient().request({
|
|
239
|
+
url: this.response.url,
|
|
240
|
+
method: r,
|
|
241
|
+
data: r === "get" ? void 0 : i,
|
|
242
|
+
params: r === "get" ? i : void 0,
|
|
243
|
+
headers: {
|
|
244
|
+
...e.headers,
|
|
245
|
+
Accept: "text/html, application/xhtml+xml",
|
|
246
|
+
"X-Inertia": "true",
|
|
247
|
+
"X-Inertia-Partial-Component": this.response.component,
|
|
248
|
+
"X-Inertia-Version": this.response.version ?? "",
|
|
249
|
+
"X-Inertia-Partial-Data": n.join(","),
|
|
250
|
+
"X-InertiaUI-Modal": H(),
|
|
251
|
+
"X-InertiaUI-Modal-Base-Url": Y.value ?? ""
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
this.updateProps(xe(t.data).props), e.onSuccess?.(t);
|
|
255
|
+
} catch (t) {
|
|
256
|
+
e.onError?.(t);
|
|
257
|
+
} finally {
|
|
258
|
+
e.onFinish?.();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
updateProps = (e) => {
|
|
262
|
+
Object.assign(this.props.value, e);
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
function Me(e, t) {
|
|
266
|
+
De.value[e] = {
|
|
267
|
+
name: e,
|
|
268
|
+
callback: t
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function Ne(e, t, n, r, i) {
|
|
272
|
+
let a = De.value[e];
|
|
273
|
+
if (!a) throw Error(`The local modal "${e}" has not been registered.`);
|
|
274
|
+
let o = He(null, { props: i ?? {} }, t, n, r);
|
|
275
|
+
return o.name = e, a.callback(o), o;
|
|
276
|
+
}
|
|
277
|
+
function Pe(e) {
|
|
278
|
+
e.close(), X.value = X.value.filter((t) => t.id !== e.id), e.afterLeaveCallback?.(), e.afterLeaveCallback = null;
|
|
279
|
+
}
|
|
280
|
+
function Fe(e) {
|
|
281
|
+
return typeof e == "object" && !!e && typeof e.component == "string";
|
|
282
|
+
}
|
|
283
|
+
function Ie(e, t, n) {
|
|
284
|
+
e && t && typeof window < "u" && V.push({
|
|
285
|
+
url: e,
|
|
286
|
+
preserveScroll: !0,
|
|
287
|
+
preserveState: !0,
|
|
288
|
+
props: (e) => ({
|
|
289
|
+
...e,
|
|
290
|
+
_inertiaui_modal: {
|
|
291
|
+
...n,
|
|
292
|
+
baseUrl: Y.value
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function Le(e, t = {}, n = null, r = null) {
|
|
298
|
+
return Fe(e) ? V.resolveComponent(e.component).then((i) => He(C(i), e, t, n, r)) : Promise.reject(/* @__PURE__ */ Error("Invalid modal response. This usually happens when the server returns a redirect (e.g., due to session expiration). Check if the user is still authenticated."));
|
|
299
|
+
}
|
|
300
|
+
function Re(e) {
|
|
301
|
+
try {
|
|
302
|
+
e ? B.start() : B.finish();
|
|
303
|
+
} catch {}
|
|
304
|
+
}
|
|
305
|
+
async function ze(e, t, n = {}, r = {}, i = {}, a = null, o = null, s = "brackets", c = !1, l = null, u = null, d = null, f = null) {
|
|
306
|
+
if (e.startsWith("#")) return Ne(e.substring(1), i, a, o, f);
|
|
307
|
+
let [p, m] = de(t, e, n, s), h = (e) => {
|
|
308
|
+
let t = xe(e.data);
|
|
309
|
+
return u?.(e), Le(t, i, a, o).then((e) => (Ie(t.url, c, t), e));
|
|
310
|
+
};
|
|
311
|
+
X.value.length === 0 && (Y.value = typeof window < "u" ? window.location.href : "");
|
|
312
|
+
let g = Q.get(U.key(t, p, m));
|
|
313
|
+
return g ? h(g) : (l?.(), Re(!0), z.getClient().request({
|
|
314
|
+
url: p,
|
|
315
|
+
method: t,
|
|
316
|
+
data: m,
|
|
317
|
+
headers: Oe(r)
|
|
318
|
+
}).then(h, (e) => {
|
|
319
|
+
throw d?.(e), e;
|
|
320
|
+
}).finally(() => Re(!1)));
|
|
321
|
+
}
|
|
322
|
+
function Be(e, t = {}) {
|
|
323
|
+
return ze(e, t.method ?? "get", t.data ?? {}, t.headers ?? {}, t.config ?? {}, t.onClose, t.onAfterLeave, t.queryStringArrayFormat ?? "brackets", t.navigate ?? K("navigate"), t.onStart, t.onSuccess, t.onError, t.props ?? null).then((e) => (Object.entries(t.listeners ?? {}).forEach(([t, n]) => e.on(r(t), n)), e));
|
|
324
|
+
}
|
|
325
|
+
function Ve(e) {
|
|
326
|
+
Object.values(e.response.meta?.deferredProps ?? {}).forEach((t) => e.reload({ only: t }));
|
|
327
|
+
}
|
|
328
|
+
function He(e, t, n, r, i) {
|
|
329
|
+
let a = new je(e, t, n, r, i);
|
|
330
|
+
return X.value.push(j(a)), Ve(a), ee(() => a.show()), a;
|
|
331
|
+
}
|
|
332
|
+
var Ue = [
|
|
333
|
+
"closeButton",
|
|
334
|
+
"closeExplicitly",
|
|
335
|
+
"closeOnClickOutside",
|
|
336
|
+
"maxWidth",
|
|
337
|
+
"paddingClasses",
|
|
338
|
+
"panelClasses",
|
|
339
|
+
"position",
|
|
340
|
+
"slideover",
|
|
341
|
+
"fullscreen"
|
|
342
|
+
];
|
|
343
|
+
function $() {
|
|
344
|
+
return {
|
|
345
|
+
setComponentResolver: () => {},
|
|
346
|
+
getBaseUrl: () => Y.value,
|
|
347
|
+
setBaseUrl: (e) => Y.value = e,
|
|
348
|
+
isClosingToBaseUrl: (e) => Z ? new URL(Z, "http://x").pathname === new URL(e, "http://x").pathname : !1,
|
|
349
|
+
clearClosingToBaseUrl: () => Z = null,
|
|
350
|
+
stack: M(X),
|
|
351
|
+
push: He,
|
|
352
|
+
pushFromResponseData: Le,
|
|
353
|
+
closeAll: (e = !1) => {
|
|
354
|
+
e ? X.value = [] : [...X.value].toReversed().forEach((e) => e.close());
|
|
355
|
+
},
|
|
356
|
+
reset: () => X.value = [],
|
|
357
|
+
visit: ze,
|
|
358
|
+
registerLocalModal: Me,
|
|
359
|
+
removeLocalModal: (e) => delete De.value[e]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
// src/ModalRenderer.vue
|
|
363
|
+
var We = /* @__PURE__ */ y({
|
|
364
|
+
__name: "ModalRenderer",
|
|
365
|
+
props: { index: {} },
|
|
366
|
+
setup(e) {
|
|
367
|
+
let t = e, n = $(), r = d(() => n.stack.value[t.index]);
|
|
368
|
+
return A("modalContext", r), (e, t) => r.value?.component ? (k(), f(F(r.value.component), w({ key: 0 }, I(a)(r.value.props, r.value.getComponentPropKeys(), !0), { onModalEvent: t[0] ||= (e, ...t) => r.value.emit(e, ...t) }), null, 16)) : p("", !0);
|
|
369
|
+
}
|
|
370
|
+
}), Ge = /* @__PURE__ */ y({
|
|
371
|
+
__name: "ModalRoot",
|
|
372
|
+
setup(e) {
|
|
373
|
+
let t = $(), n = ue(), r = !1, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = (e) => e.id || `${e.component}:${e.url}`, s = (e) => e?._inertiaui_modal;
|
|
374
|
+
O(V.on("start", ({ detail: { visit: e } }) => {
|
|
375
|
+
r = !0, e.method !== "get" && a.set(e.id, !1);
|
|
376
|
+
})), O(V.on("success", ({ detail: { page: e, visitId: t } }) => {
|
|
377
|
+
t && a.has(t) && !s(e.props) && a.set(t, !0);
|
|
378
|
+
})), O(V.on("finish", ({ detail: { visit: e } }) => {
|
|
379
|
+
r = !1, a.get(e.id) && t.closeAll(), a.delete(e.id);
|
|
380
|
+
})), O(V.on("navigate", ({ detail: { page: e } }) => {
|
|
381
|
+
let n = s(e.props);
|
|
382
|
+
if (t.isClosingToBaseUrl(e.url)) {
|
|
383
|
+
t.clearClosingToBaseUrl(), t.closeAll(!0), t.setBaseUrl(null);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (!n || !c(e.url, n.url)) {
|
|
387
|
+
t.closeAll(!0), t.setBaseUrl(null);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
let a = o(n), l = t.stack.value;
|
|
391
|
+
i.has(a) || n.id && l.some((e) => e.id === n.id) || l.some((e) => e.response.component === n.component && c(e.response.url, n.url)) || (t.setBaseUrl(n.baseUrl ?? null), i.add(a), t.pushFromResponseData(n, {}, () => {
|
|
392
|
+
n.baseUrl ? (t.setBaseUrl(null), !r && typeof window < "u" && window.location.href !== n.baseUrl && V.visit(n.baseUrl, {
|
|
393
|
+
preserveScroll: !0,
|
|
394
|
+
preserveState: !0
|
|
395
|
+
})) : console.error("No base url in modal response data so cannot navigate back");
|
|
396
|
+
}).finally(() => i.delete(a)));
|
|
397
|
+
}));
|
|
398
|
+
let u = typeof window > "u" ? void 0 : z.onRequest((e) => {
|
|
399
|
+
let r = t.getBaseUrl() ?? s(n.props)?.baseUrl;
|
|
400
|
+
return r && (e.headers = {
|
|
401
|
+
...e.headers,
|
|
402
|
+
"X-InertiaUI-Modal-Base-Url": r
|
|
403
|
+
}), e;
|
|
404
|
+
});
|
|
405
|
+
return O(() => u?.()), L(() => s(n.props), (e, n) => {
|
|
406
|
+
if (!e) return;
|
|
407
|
+
let r = (t) => t.component === e.component && c(t.url, e.url);
|
|
408
|
+
n && r(n) ? t.stack.value[0]?.updateProps(e.props ?? {}) : n || t.stack.value.find((e) => r(e.response))?.updateProps(e.props ?? {});
|
|
409
|
+
}), (e, n) => (k(), m(l, null, [P(e.$slots, "default"), I(t).stack.value.length ? (k(), f(We, {
|
|
410
|
+
key: 0,
|
|
411
|
+
index: 0
|
|
412
|
+
})) : p("", !0)], 64));
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
// src/app.ts
|
|
416
|
+
function Ke(e, t) {
|
|
417
|
+
return () => x(Ge, () => x(e, t));
|
|
418
|
+
}
|
|
419
|
+
function qe(e) {
|
|
420
|
+
let t = e._component, n = t.render;
|
|
421
|
+
n && (t.render = () => x(Ge, () => n()));
|
|
422
|
+
}
|
|
423
|
+
// src/Deferred.vue
|
|
424
|
+
var Je = /* @__PURE__ */ y({
|
|
425
|
+
__name: "Deferred",
|
|
426
|
+
props: { data: {} },
|
|
427
|
+
setup(e) {
|
|
428
|
+
let t = e, n = S("modalContext");
|
|
429
|
+
if (!n) throw Error("Deferred component must be used inside a Modal component");
|
|
430
|
+
let r = d(() => [t.data].flat().every((e) => n.value?.props[e] !== void 0));
|
|
431
|
+
return (e, t) => r.value ? P(e.$slots, "default", {}, void 0, void 0, 0) : P(e.$slots, "fallback", {}, void 0, void 0, 1);
|
|
432
|
+
}
|
|
433
|
+
}), Ye = /* @__PURE__ */ y({
|
|
434
|
+
inheritAttrs: !1,
|
|
435
|
+
__name: "HeadlessModal",
|
|
436
|
+
props: {
|
|
437
|
+
name: String,
|
|
438
|
+
slideover: {
|
|
439
|
+
type: Boolean,
|
|
440
|
+
default: null
|
|
441
|
+
},
|
|
442
|
+
closeButton: {
|
|
443
|
+
type: Boolean,
|
|
444
|
+
default: null
|
|
445
|
+
},
|
|
446
|
+
closeExplicitly: {
|
|
447
|
+
type: Boolean,
|
|
448
|
+
default: null
|
|
449
|
+
},
|
|
450
|
+
closeOnClickOutside: {
|
|
451
|
+
type: Boolean,
|
|
452
|
+
default: null
|
|
453
|
+
},
|
|
454
|
+
maxWidth: {
|
|
455
|
+
type: String,
|
|
456
|
+
default: null
|
|
457
|
+
},
|
|
458
|
+
paddingClasses: {
|
|
459
|
+
type: [Boolean, String],
|
|
460
|
+
default: null
|
|
461
|
+
},
|
|
462
|
+
panelClasses: {
|
|
463
|
+
type: [Boolean, String],
|
|
464
|
+
default: null
|
|
465
|
+
},
|
|
466
|
+
position: {
|
|
467
|
+
type: String,
|
|
468
|
+
default: null
|
|
469
|
+
},
|
|
470
|
+
fullscreen: {
|
|
471
|
+
type: [
|
|
472
|
+
Boolean,
|
|
473
|
+
String,
|
|
474
|
+
Number
|
|
475
|
+
],
|
|
476
|
+
default: null
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
emits: [
|
|
480
|
+
"modal-event",
|
|
481
|
+
"focus",
|
|
482
|
+
"blur",
|
|
483
|
+
"close",
|
|
484
|
+
"success"
|
|
485
|
+
],
|
|
486
|
+
setup(e, { expose: t, emit: n }) {
|
|
487
|
+
let r = e, i = n, a = $(), o = r.name ? N(null) : S("modalContext", N(null)), s = d(() => {
|
|
488
|
+
let e = o.value?.config?.slideover ?? r.slideover ?? K("type") === "slideover";
|
|
489
|
+
return {
|
|
490
|
+
slideover: e,
|
|
491
|
+
closeButton: r.closeButton ?? q(e, "closeButton"),
|
|
492
|
+
closeExplicitly: r.closeExplicitly ?? q(e, "closeExplicitly"),
|
|
493
|
+
closeOnClickOutside: r.closeOnClickOutside ?? q(e, "closeOnClickOutside"),
|
|
494
|
+
maxWidth: r.maxWidth ?? q(e, "maxWidth"),
|
|
495
|
+
paddingClasses: r.paddingClasses ?? q(e, "paddingClasses"),
|
|
496
|
+
panelClasses: r.panelClasses ?? q(e, "panelClasses"),
|
|
497
|
+
position: r.position ?? q(e, "position"),
|
|
498
|
+
fullscreen: r.fullscreen ?? q(e, "fullscreen"),
|
|
499
|
+
...o.value?.config
|
|
500
|
+
};
|
|
501
|
+
}), c = oe(), u;
|
|
502
|
+
function h() {
|
|
503
|
+
u = o.value?.registerEventListenersFromAttrs(c);
|
|
504
|
+
}
|
|
505
|
+
r.name && (a.registerLocalModal(r.name, (e) => {
|
|
506
|
+
let t = o.value;
|
|
507
|
+
t?.shouldRender && t.id !== e.id && Pe(t), o.value = j(e), h();
|
|
508
|
+
}), E(() => a.removeLocalModal(r.name))), D(() => {
|
|
509
|
+
r.name || h();
|
|
510
|
+
}), E(() => u?.());
|
|
511
|
+
function g(e, ...t) {
|
|
512
|
+
i("modal-event", e, ...t);
|
|
513
|
+
}
|
|
514
|
+
t({
|
|
515
|
+
emit: g,
|
|
516
|
+
afterLeave: () => o.value?.afterLeave(),
|
|
517
|
+
close: () => o.value?.close(),
|
|
518
|
+
reload: (...e) => o.value?.reload(...e),
|
|
519
|
+
setOpen: (e) => o.value?.setOpen(e),
|
|
520
|
+
getChildModal: () => o.value?.getChildModal(),
|
|
521
|
+
getParentModal: () => o.value?.getParentModal(),
|
|
522
|
+
get config() {
|
|
523
|
+
return o.value?.config;
|
|
524
|
+
},
|
|
525
|
+
get id() {
|
|
526
|
+
return o.value?.id;
|
|
527
|
+
},
|
|
528
|
+
get index() {
|
|
529
|
+
return o.value?.index;
|
|
530
|
+
},
|
|
531
|
+
get isOpen() {
|
|
532
|
+
return o.value?.isOpen;
|
|
533
|
+
},
|
|
534
|
+
get modalContext() {
|
|
535
|
+
return o.value;
|
|
536
|
+
},
|
|
537
|
+
get onTopOfStack() {
|
|
538
|
+
return o.value?.onTopOfStack;
|
|
539
|
+
},
|
|
540
|
+
get shouldRender() {
|
|
541
|
+
return o.value?.shouldRender;
|
|
542
|
+
}
|
|
543
|
+
}), L(() => o.value?.onTopOfStack, (e, t) => {
|
|
544
|
+
e && !t ? i("focus") : !e && t && i("blur");
|
|
545
|
+
}), L(() => o.value?.isOpen, (e, t) => {
|
|
546
|
+
e ? i("success") : t === !0 && i("close");
|
|
547
|
+
}, { immediate: !0 });
|
|
548
|
+
let _ = d(() => {
|
|
549
|
+
let e = o.value;
|
|
550
|
+
return e ? a.stack.value.find((t) => t.shouldRender && t.index > e.index)?.index : void 0;
|
|
551
|
+
});
|
|
552
|
+
return (e, t) => (k(), m(l, null, [I(o)?.shouldRender ? P(e.$slots, "default", w(I(o).props, {
|
|
553
|
+
id: I(o).id,
|
|
554
|
+
afterLeave: I(o).afterLeave,
|
|
555
|
+
close: I(o).close,
|
|
556
|
+
config: s.value,
|
|
557
|
+
emit: g,
|
|
558
|
+
getChildModal: I(o).getChildModal,
|
|
559
|
+
getParentModal: I(o).getParentModal,
|
|
560
|
+
index: I(o).index,
|
|
561
|
+
isOpen: I(o).isOpen,
|
|
562
|
+
modalContext: I(o),
|
|
563
|
+
onTopOfStack: I(o).onTopOfStack,
|
|
564
|
+
reload: I(o).reload,
|
|
565
|
+
setOpen: I(o).setOpen,
|
|
566
|
+
shouldRender: I(o).shouldRender
|
|
567
|
+
}), void 0, void 0, 0) : p("", !0), _.value ? (k(), f(We, {
|
|
568
|
+
key: 1,
|
|
569
|
+
index: _.value
|
|
570
|
+
}, null, 8, ["index"])) : p("", !0)], 64));
|
|
571
|
+
}
|
|
572
|
+
}), Xe = Symbol("inertia-modal-request-close"), Ze = /* @__PURE__ */ y({
|
|
573
|
+
__name: "CloseButton",
|
|
574
|
+
setup(e) {
|
|
575
|
+
let t = S(Xe), { t: n } = me();
|
|
576
|
+
return (e, r) => (k(), f(I(be), {
|
|
577
|
+
class: "im-close-button",
|
|
578
|
+
icon: "$close",
|
|
579
|
+
variant: "text",
|
|
580
|
+
size: "small",
|
|
581
|
+
"aria-label": I(n)("$vuetify.close"),
|
|
582
|
+
onClick: r[0] ||= (e) => I(t)?.()
|
|
583
|
+
}, null, 8, ["aria-label"]));
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
// src/transitions.ts
|
|
587
|
+
function Qe(e) {
|
|
588
|
+
let t = () => o() ? { opacity: 0 } : { transform: e };
|
|
589
|
+
return {
|
|
590
|
+
component: u,
|
|
591
|
+
css: !1,
|
|
592
|
+
onEnter: (e, n) => $e(e, [t(), {}], 225, "cubic-bezier(0, 0, 0.2, 1)", n),
|
|
593
|
+
onLeave: (e, n) => $e(e, [{}, t()], 195, "cubic-bezier(0.4, 0, 1, 1)", n)
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function $e(e, t, n, r, i) {
|
|
597
|
+
if (!e.animate) return i();
|
|
598
|
+
e.animate(t, {
|
|
599
|
+
duration: n,
|
|
600
|
+
easing: r
|
|
601
|
+
}).finished.then(() => i(), () => i());
|
|
602
|
+
}
|
|
603
|
+
// src/ModalContent.vue?vue&type=script&setup=true&lang.ts
|
|
604
|
+
var et = ["id"], tt = {
|
|
605
|
+
key: 1,
|
|
606
|
+
class: "position-absolute top-0 pa-2",
|
|
607
|
+
style: {
|
|
608
|
+
"inset-inline-end": "0",
|
|
609
|
+
"z-index": "1"
|
|
610
|
+
}
|
|
611
|
+
}, nt = /* @__PURE__ */ y({
|
|
612
|
+
__name: "ModalContent",
|
|
613
|
+
props: {
|
|
614
|
+
modalContext: {},
|
|
615
|
+
config: {},
|
|
616
|
+
title: {},
|
|
617
|
+
beforeClose: { type: Function },
|
|
618
|
+
dialogProps: {},
|
|
619
|
+
cardProps: {}
|
|
620
|
+
},
|
|
621
|
+
emits: ["after-leave"],
|
|
622
|
+
setup(e, { emit: t }) {
|
|
623
|
+
let n = e, r = t, a = ce();
|
|
624
|
+
A("modalContext", ie(n, "modalContext")), A(Xe, M), fe({}, "InertiaModal");
|
|
625
|
+
let { isRtl: o } = he(), s = pe(), c = se(), l = N(!1), u = le("dialog"), y = typeof document < "u" && document.activeElement !== document.body ? document.activeElement : null, b = d(() => n.config.slideover ? "slideover" : "modal"), x = d(() => !!n.title || !!a.title), S = d(() => n.config.closeButton !== !1), C = d(() => {
|
|
626
|
+
let e = n.config.fullscreen;
|
|
627
|
+
return e === "mobile" ? s.mobile.value : typeof e == "string" ? s.width.value < s.thresholds.value[e] : typeof e == "number" ? s.width.value < e : !!e;
|
|
628
|
+
}), ee = d(() => {
|
|
629
|
+
let { maxWidth: e, position: t, slideover: r } = n.config, i = [`im-${b.value}-dialog`, { [`im-slideover-${t}`]: r && t !== "right" }];
|
|
630
|
+
if (!r) return C.value ? {
|
|
631
|
+
fullscreen: !0,
|
|
632
|
+
transition: "dialog-bottom-transition",
|
|
633
|
+
contentClass: i
|
|
634
|
+
} : {
|
|
635
|
+
location: Ee(t),
|
|
636
|
+
maxWidth: J(e),
|
|
637
|
+
target: y ?? void 0,
|
|
638
|
+
contentClass: i
|
|
639
|
+
};
|
|
640
|
+
if (t === "bottom") return {
|
|
641
|
+
location: "bottom",
|
|
642
|
+
width: "100%",
|
|
643
|
+
maxWidth: J(e),
|
|
644
|
+
fullscreen: C.value,
|
|
645
|
+
contentClass: i,
|
|
646
|
+
transition: Qe("translateY(100%)")
|
|
647
|
+
};
|
|
648
|
+
let a = t === "left";
|
|
649
|
+
return {
|
|
650
|
+
location: a === o.value ? "right" : "left",
|
|
651
|
+
width: "100%",
|
|
652
|
+
maxWidth: J(e),
|
|
653
|
+
height: "100%",
|
|
654
|
+
maxHeight: "100%",
|
|
655
|
+
fullscreen: C.value,
|
|
656
|
+
contentClass: i,
|
|
657
|
+
transition: Qe(`translateX(${a ? "-100%" : "100%"})`)
|
|
658
|
+
};
|
|
659
|
+
}), T = d(() => n.modalContext.onTopOfStack ? n.dialogProps?.scrim : !1), O = d(() => ({
|
|
660
|
+
margin: n.config.slideover && !C.value ? 0 : void 0,
|
|
661
|
+
filter: n.modalContext.onTopOfStack ? void 0 : "blur(4px)",
|
|
662
|
+
transition: "filter 0.3s"
|
|
663
|
+
})), j = !1;
|
|
664
|
+
async function M() {
|
|
665
|
+
if (!j) {
|
|
666
|
+
j = !0;
|
|
667
|
+
try {
|
|
668
|
+
await n.beforeClose?.() === !1 ? u.value?.animateClick() : n.modalContext.close();
|
|
669
|
+
} finally {
|
|
670
|
+
j = !1;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
let F = "close";
|
|
675
|
+
function ae() {
|
|
676
|
+
n.modalContext.onTopOfStack ? !n.config.closeExplicitly && n.config.closeOnClickOutside === !1 && (F = "refuse") : F = "ignore";
|
|
677
|
+
}
|
|
678
|
+
function oe(e) {
|
|
679
|
+
let t = F;
|
|
680
|
+
F = "close", !(e || t === "ignore") && (t === "refuse" ? u.value?.animateClick() : M());
|
|
681
|
+
}
|
|
682
|
+
function z() {
|
|
683
|
+
r("after-leave"), n.modalContext.afterLeave();
|
|
684
|
+
}
|
|
685
|
+
let B = null;
|
|
686
|
+
function V(e) {
|
|
687
|
+
let t = K("appElement");
|
|
688
|
+
e ? typeof t == "string" && (B ??= i(t)) : (l.value = !1, B?.(), B = null, y?.focus({ preventScroll: !0 }));
|
|
689
|
+
}
|
|
690
|
+
return D(() => L(() => n.modalContext.isOpen, V, {
|
|
691
|
+
immediate: !0,
|
|
692
|
+
flush: "post"
|
|
693
|
+
})), E(() => V(!1)), (t, n) => (k(), f(I(ye), w({
|
|
694
|
+
ref_key: "dialog",
|
|
695
|
+
ref: u
|
|
696
|
+
}, {
|
|
697
|
+
...ee.value,
|
|
698
|
+
...e.dialogProps
|
|
699
|
+
}, {
|
|
700
|
+
"model-value": e.modalContext.isOpen,
|
|
701
|
+
persistent: e.config.closeExplicitly && e.modalContext.onTopOfStack || void 0,
|
|
702
|
+
scrim: T.value,
|
|
703
|
+
"close-on-back": !1,
|
|
704
|
+
"content-props": { style: O.value },
|
|
705
|
+
"aria-labelledby": x.value ? I(c) : void 0,
|
|
706
|
+
"aria-hidden": !e.modalContext.onTopOfStack || void 0,
|
|
707
|
+
"data-inertiaui-modal-id": e.modalContext.id,
|
|
708
|
+
"data-inertiaui-modal-index": e.modalContext.index,
|
|
709
|
+
"onClick:outside": ae,
|
|
710
|
+
"onUpdate:modelValue": oe,
|
|
711
|
+
onAfterEnter: n[0] ||= (e) => l.value = !0,
|
|
712
|
+
onAfterLeave: z
|
|
713
|
+
}), {
|
|
714
|
+
default: R(() => [v(I(ge), w({
|
|
715
|
+
class: `im-${b.value}-wrapper`,
|
|
716
|
+
rounded: e.config.slideover ? 0 : void 0,
|
|
717
|
+
"data-inertiaui-modal-entered": l.value
|
|
718
|
+
}, e.cardProps), {
|
|
719
|
+
default: R(() => [
|
|
720
|
+
x.value ? (k(), f(I(ve), {
|
|
721
|
+
key: 0,
|
|
722
|
+
class: te(`im-${b.value}-title`)
|
|
723
|
+
}, g({
|
|
724
|
+
title: R(() => [h("span", { id: I(c) }, [P(t.$slots, "title", { requestClose: M }, () => [_(re(e.title), 1)])], 8, et)]),
|
|
725
|
+
_: 2
|
|
726
|
+
}, [S.value ? {
|
|
727
|
+
name: "append",
|
|
728
|
+
fn: R(() => [v(Ze)]),
|
|
729
|
+
key: "0"
|
|
730
|
+
} : void 0]), 1032, ["class"])) : S.value ? (k(), m("div", tt, [v(Ze)])) : p("", !0),
|
|
731
|
+
h("div", {
|
|
732
|
+
class: te([
|
|
733
|
+
`im-${b.value}-content`,
|
|
734
|
+
e.config.paddingClasses,
|
|
735
|
+
e.config.panelClasses
|
|
736
|
+
]),
|
|
737
|
+
style: ne({
|
|
738
|
+
flex: "1 1 auto",
|
|
739
|
+
minHeight: 0,
|
|
740
|
+
overflowY: "auto",
|
|
741
|
+
paddingTop: x.value ? 0 : void 0
|
|
742
|
+
})
|
|
743
|
+
}, [P(t.$slots, "default", { requestClose: M })], 6),
|
|
744
|
+
a.actions ? (k(), f(I(_e), {
|
|
745
|
+
key: 2,
|
|
746
|
+
class: te(`im-${b.value}-actions`)
|
|
747
|
+
}, {
|
|
748
|
+
default: R(() => [P(t.$slots, "actions", { requestClose: M })]),
|
|
749
|
+
_: 3
|
|
750
|
+
}, 8, ["class"])) : p("", !0)
|
|
751
|
+
]),
|
|
752
|
+
_: 3
|
|
753
|
+
}, 16, [
|
|
754
|
+
"class",
|
|
755
|
+
"rounded",
|
|
756
|
+
"data-inertiaui-modal-entered"
|
|
757
|
+
])]),
|
|
758
|
+
_: 3
|
|
759
|
+
}, 16, [
|
|
760
|
+
"model-value",
|
|
761
|
+
"persistent",
|
|
762
|
+
"scrim",
|
|
763
|
+
"content-props",
|
|
764
|
+
"aria-labelledby",
|
|
765
|
+
"aria-hidden",
|
|
766
|
+
"data-inertiaui-modal-id",
|
|
767
|
+
"data-inertiaui-modal-index"
|
|
768
|
+
]));
|
|
769
|
+
}
|
|
770
|
+
}), rt = /* @__PURE__ */ y({
|
|
771
|
+
__name: "Modal",
|
|
772
|
+
props: {
|
|
773
|
+
name: String,
|
|
774
|
+
slideover: {
|
|
775
|
+
type: Boolean,
|
|
776
|
+
default: null
|
|
777
|
+
},
|
|
778
|
+
closeButton: {
|
|
779
|
+
type: Boolean,
|
|
780
|
+
default: null
|
|
781
|
+
},
|
|
782
|
+
closeExplicitly: {
|
|
783
|
+
type: Boolean,
|
|
784
|
+
default: null
|
|
785
|
+
},
|
|
786
|
+
closeOnClickOutside: {
|
|
787
|
+
type: Boolean,
|
|
788
|
+
default: null
|
|
789
|
+
},
|
|
790
|
+
maxWidth: {
|
|
791
|
+
type: String,
|
|
792
|
+
default: null
|
|
793
|
+
},
|
|
794
|
+
paddingClasses: {
|
|
795
|
+
type: [Boolean, String],
|
|
796
|
+
default: null
|
|
797
|
+
},
|
|
798
|
+
panelClasses: {
|
|
799
|
+
type: [Boolean, String],
|
|
800
|
+
default: null
|
|
801
|
+
},
|
|
802
|
+
position: {
|
|
803
|
+
type: String,
|
|
804
|
+
default: null
|
|
805
|
+
},
|
|
806
|
+
title: String,
|
|
807
|
+
fullscreen: {
|
|
808
|
+
type: [
|
|
809
|
+
Boolean,
|
|
810
|
+
String,
|
|
811
|
+
Number
|
|
812
|
+
],
|
|
813
|
+
default: null
|
|
814
|
+
},
|
|
815
|
+
beforeClose: Function,
|
|
816
|
+
dialogProps: Object,
|
|
817
|
+
cardProps: Object
|
|
818
|
+
},
|
|
819
|
+
emits: [
|
|
820
|
+
"after-leave",
|
|
821
|
+
"blur",
|
|
822
|
+
"close",
|
|
823
|
+
"focus",
|
|
824
|
+
"success"
|
|
825
|
+
],
|
|
826
|
+
setup(e, { expose: t, emit: n }) {
|
|
827
|
+
let r = e, i = n, a = d(() => ({
|
|
828
|
+
name: r.name,
|
|
829
|
+
slideover: r.slideover,
|
|
830
|
+
closeButton: r.closeButton,
|
|
831
|
+
closeExplicitly: r.closeExplicitly,
|
|
832
|
+
closeOnClickOutside: r.closeOnClickOutside,
|
|
833
|
+
maxWidth: r.maxWidth,
|
|
834
|
+
paddingClasses: r.paddingClasses,
|
|
835
|
+
panelClasses: r.panelClasses,
|
|
836
|
+
position: r.position,
|
|
837
|
+
fullscreen: r.fullscreen
|
|
838
|
+
})), o = le("modal");
|
|
839
|
+
return t({
|
|
840
|
+
afterLeave: () => o.value?.afterLeave(),
|
|
841
|
+
close: () => o.value?.close(),
|
|
842
|
+
emit: (e, ...t) => o.value?.emit(e, ...t),
|
|
843
|
+
getChildModal: () => o.value?.getChildModal(),
|
|
844
|
+
getParentModal: () => o.value?.getParentModal(),
|
|
845
|
+
reload: (e) => o.value?.reload(e),
|
|
846
|
+
setOpen: (e) => o.value?.setOpen(e),
|
|
847
|
+
get config() {
|
|
848
|
+
return o.value?.config;
|
|
849
|
+
},
|
|
850
|
+
get id() {
|
|
851
|
+
return o.value?.id;
|
|
852
|
+
},
|
|
853
|
+
get index() {
|
|
854
|
+
return o.value?.index;
|
|
855
|
+
},
|
|
856
|
+
get isOpen() {
|
|
857
|
+
return o.value?.isOpen;
|
|
858
|
+
},
|
|
859
|
+
get modalContext() {
|
|
860
|
+
return o.value?.modalContext;
|
|
861
|
+
},
|
|
862
|
+
get onTopOfStack() {
|
|
863
|
+
return o.value?.onTopOfStack;
|
|
864
|
+
},
|
|
865
|
+
get shouldRender() {
|
|
866
|
+
return o.value?.shouldRender;
|
|
867
|
+
}
|
|
868
|
+
}), (t, n) => (k(), f(Ye, w({
|
|
869
|
+
ref_key: "modal",
|
|
870
|
+
ref: o
|
|
871
|
+
}, a.value, {
|
|
872
|
+
onSuccess: n[1] ||= (e) => i("success"),
|
|
873
|
+
onClose: n[2] ||= (e) => i("close"),
|
|
874
|
+
onFocus: n[3] ||= (e) => i("focus"),
|
|
875
|
+
onBlur: n[4] ||= (e) => i("blur")
|
|
876
|
+
}), {
|
|
877
|
+
default: R((r) => [(k(), f(nt, {
|
|
878
|
+
key: r.id,
|
|
879
|
+
"modal-context": r.modalContext,
|
|
880
|
+
config: r.config,
|
|
881
|
+
title: e.title,
|
|
882
|
+
"before-close": e.beforeClose,
|
|
883
|
+
"dialog-props": e.dialogProps,
|
|
884
|
+
"card-props": e.cardProps,
|
|
885
|
+
onAfterLeave: n[0] ||= (e) => i("after-leave")
|
|
886
|
+
}, g({
|
|
887
|
+
default: R(({ requestClose: e }) => [P(t.$slots, "default", T(b({
|
|
888
|
+
...r,
|
|
889
|
+
requestClose: e
|
|
890
|
+
})))]),
|
|
891
|
+
_: 2
|
|
892
|
+
}, [t.$slots.title ? {
|
|
893
|
+
name: "title",
|
|
894
|
+
fn: R(({ requestClose: e }) => [P(t.$slots, "title", T(b({
|
|
895
|
+
...r,
|
|
896
|
+
requestClose: e
|
|
897
|
+
})))]),
|
|
898
|
+
key: "0"
|
|
899
|
+
} : void 0, t.$slots.actions ? {
|
|
900
|
+
name: "actions",
|
|
901
|
+
fn: R(({ requestClose: e }) => [P(t.$slots, "actions", T(b({
|
|
902
|
+
...r,
|
|
903
|
+
requestClose: e
|
|
904
|
+
})))]),
|
|
905
|
+
key: "1"
|
|
906
|
+
} : void 0]), 1032, [
|
|
907
|
+
"modal-context",
|
|
908
|
+
"config",
|
|
909
|
+
"title",
|
|
910
|
+
"before-close",
|
|
911
|
+
"dialog-props",
|
|
912
|
+
"card-props"
|
|
913
|
+
]))]),
|
|
914
|
+
_: 3
|
|
915
|
+
}, 16));
|
|
916
|
+
}
|
|
917
|
+
}), it = /* @__PURE__ */ y({
|
|
918
|
+
inheritAttrs: !1,
|
|
919
|
+
__name: "ModalLink",
|
|
920
|
+
props: {
|
|
921
|
+
href: {
|
|
922
|
+
type: String,
|
|
923
|
+
required: !0
|
|
924
|
+
},
|
|
925
|
+
method: {
|
|
926
|
+
type: String,
|
|
927
|
+
default: "get"
|
|
928
|
+
},
|
|
929
|
+
data: {
|
|
930
|
+
type: Object,
|
|
931
|
+
default: () => ({})
|
|
932
|
+
},
|
|
933
|
+
as: {
|
|
934
|
+
type: [String, Object],
|
|
935
|
+
default: "a"
|
|
936
|
+
},
|
|
937
|
+
headers: {
|
|
938
|
+
type: Object,
|
|
939
|
+
default: () => ({})
|
|
940
|
+
},
|
|
941
|
+
queryStringArrayFormat: {
|
|
942
|
+
type: String,
|
|
943
|
+
default: "brackets"
|
|
944
|
+
},
|
|
945
|
+
navigate: {
|
|
946
|
+
type: Boolean,
|
|
947
|
+
default: null
|
|
948
|
+
},
|
|
949
|
+
prefetch: {
|
|
950
|
+
type: [
|
|
951
|
+
Boolean,
|
|
952
|
+
String,
|
|
953
|
+
Array
|
|
954
|
+
],
|
|
955
|
+
default: !1
|
|
956
|
+
},
|
|
957
|
+
cacheFor: {
|
|
958
|
+
type: Number,
|
|
959
|
+
default: 3e4
|
|
960
|
+
},
|
|
961
|
+
closeButton: {
|
|
962
|
+
type: Boolean,
|
|
963
|
+
default: null
|
|
964
|
+
},
|
|
965
|
+
closeExplicitly: {
|
|
966
|
+
type: Boolean,
|
|
967
|
+
default: null
|
|
968
|
+
},
|
|
969
|
+
closeOnClickOutside: {
|
|
970
|
+
type: Boolean,
|
|
971
|
+
default: null
|
|
972
|
+
},
|
|
973
|
+
maxWidth: {
|
|
974
|
+
type: String,
|
|
975
|
+
default: null
|
|
976
|
+
},
|
|
977
|
+
paddingClasses: {
|
|
978
|
+
type: [Boolean, String],
|
|
979
|
+
default: null
|
|
980
|
+
},
|
|
981
|
+
panelClasses: {
|
|
982
|
+
type: [Boolean, String],
|
|
983
|
+
default: null
|
|
984
|
+
},
|
|
985
|
+
position: {
|
|
986
|
+
type: String,
|
|
987
|
+
default: null
|
|
988
|
+
},
|
|
989
|
+
slideover: {
|
|
990
|
+
type: Boolean,
|
|
991
|
+
default: null
|
|
992
|
+
},
|
|
993
|
+
fullscreen: {
|
|
994
|
+
type: [
|
|
995
|
+
Boolean,
|
|
996
|
+
String,
|
|
997
|
+
Number
|
|
998
|
+
],
|
|
999
|
+
default: null
|
|
1000
|
+
}
|
|
1001
|
+
},
|
|
1002
|
+
emits: [
|
|
1003
|
+
"after-leave",
|
|
1004
|
+
"blur",
|
|
1005
|
+
"close",
|
|
1006
|
+
"error",
|
|
1007
|
+
"focus",
|
|
1008
|
+
"start",
|
|
1009
|
+
"success",
|
|
1010
|
+
"prefetching",
|
|
1011
|
+
"prefetched"
|
|
1012
|
+
],
|
|
1013
|
+
setup(e, { emit: t }) {
|
|
1014
|
+
let n = e, r = t, i = N(!1), o = $(), c = N(null);
|
|
1015
|
+
A("modalContext", c);
|
|
1016
|
+
let l = d(() => n.navigate ?? K("navigate")), u = d(() => n.prefetch === !0 ? ["hover"] : n.prefetch === !1 ? [] : [n.prefetch].flat());
|
|
1017
|
+
function p() {
|
|
1018
|
+
ke(n.href, {
|
|
1019
|
+
method: n.method,
|
|
1020
|
+
data: n.data,
|
|
1021
|
+
headers: n.headers,
|
|
1022
|
+
queryStringArrayFormat: n.queryStringArrayFormat,
|
|
1023
|
+
cacheFor: n.cacheFor,
|
|
1024
|
+
onPrefetching: () => r("prefetching"),
|
|
1025
|
+
onPrefetched: () => r("prefetched")
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
let m;
|
|
1029
|
+
function h() {
|
|
1030
|
+
u.value.includes("hover") && (m = setTimeout(p, 75));
|
|
1031
|
+
}
|
|
1032
|
+
function g() {
|
|
1033
|
+
clearTimeout(m);
|
|
1034
|
+
}
|
|
1035
|
+
function _(e) {
|
|
1036
|
+
u.value.includes("click") && e.button === 0 && p();
|
|
1037
|
+
}
|
|
1038
|
+
D(() => {
|
|
1039
|
+
u.value.includes("mount") && p();
|
|
1040
|
+
});
|
|
1041
|
+
let v = !1;
|
|
1042
|
+
L(() => c.value?.onTopOfStack, (e) => {
|
|
1043
|
+
c.value && (e && v ? r("focus") : e || r("blur"), v = !e);
|
|
1044
|
+
});
|
|
1045
|
+
let y = oe(), b;
|
|
1046
|
+
E(() => {
|
|
1047
|
+
b?.(), clearTimeout(m);
|
|
1048
|
+
}), L(c, (e, t) => {
|
|
1049
|
+
e && !t && (b = e.registerEventListenersFromAttrs(y), r("success"));
|
|
1050
|
+
});
|
|
1051
|
+
function x() {
|
|
1052
|
+
c.value = null, r("after-leave");
|
|
1053
|
+
}
|
|
1054
|
+
function S(e) {
|
|
1055
|
+
(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) && e.currentTarget instanceof HTMLAnchorElement || (e.preventDefault(), !i.value && (n.href.startsWith("#") || (i.value = !0, r("start")), o.visit(n.href, n.method, n.data, n.headers, s(a(n, Ue)), () => r("close"), x, n.queryStringArrayFormat, l.value).then((e) => c.value = j(e)).catch((e) => {
|
|
1056
|
+
console.error(e), r("error", e);
|
|
1057
|
+
}).finally(() => i.value = !1)));
|
|
1058
|
+
}
|
|
1059
|
+
return (t, n) => (k(), f(F(e.as), w(t.$attrs, {
|
|
1060
|
+
href: e.href,
|
|
1061
|
+
onClick: S,
|
|
1062
|
+
onMouseenter: h,
|
|
1063
|
+
onMouseleave: g,
|
|
1064
|
+
onMousedown: _
|
|
1065
|
+
}), {
|
|
1066
|
+
default: R(() => [P(t.$slots, "default", { loading: i.value })]),
|
|
1067
|
+
_: 3
|
|
1068
|
+
}, 16, ["href"]));
|
|
1069
|
+
}
|
|
1070
|
+
}), at = /* @__PURE__ */ y({
|
|
1071
|
+
inheritAttrs: !1,
|
|
1072
|
+
__name: "ModalBtn",
|
|
1073
|
+
props: { href: {} },
|
|
1074
|
+
setup(e) {
|
|
1075
|
+
let t = N(!1);
|
|
1076
|
+
return (n, r) => (k(), f(it, w(n.$attrs, {
|
|
1077
|
+
as: I(be),
|
|
1078
|
+
href: e.href,
|
|
1079
|
+
loading: t.value,
|
|
1080
|
+
onStart: r[0] ||= (e) => t.value = !0,
|
|
1081
|
+
onSuccess: r[1] ||= (e) => t.value = !1,
|
|
1082
|
+
onError: r[2] ||= (e) => t.value = !1
|
|
1083
|
+
}), {
|
|
1084
|
+
default: R((e) => [P(n.$slots, "default", T(b(e)))]),
|
|
1085
|
+
_: 3
|
|
1086
|
+
}, 16, [
|
|
1087
|
+
"as",
|
|
1088
|
+
"href",
|
|
1089
|
+
"loading"
|
|
1090
|
+
]));
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
// src/useModal.ts
|
|
1094
|
+
function ot() {
|
|
1095
|
+
return ae(S("modalContext", null));
|
|
1096
|
+
}
|
|
1097
|
+
// src/WhenVisible.vue
|
|
1098
|
+
var st = /* @__PURE__ */ y({
|
|
1099
|
+
__name: "WhenVisible",
|
|
1100
|
+
props: {
|
|
1101
|
+
data: {},
|
|
1102
|
+
params: {},
|
|
1103
|
+
buffer: { default: 0 },
|
|
1104
|
+
as: { default: "div" },
|
|
1105
|
+
always: { type: Boolean }
|
|
1106
|
+
},
|
|
1107
|
+
setup(e) {
|
|
1108
|
+
let t = e, n = S("modalContext");
|
|
1109
|
+
if (!n) throw Error("WhenVisible component must be used inside a Modal component");
|
|
1110
|
+
let r = N(!1), i = le("root"), a = !1, o;
|
|
1111
|
+
function s() {
|
|
1112
|
+
if (t.data) return { only: [t.data].flat() };
|
|
1113
|
+
if (!t.params) throw Error("You must provide either a `data` or `params` prop.");
|
|
1114
|
+
return t.params;
|
|
1115
|
+
}
|
|
1116
|
+
return D(() => {
|
|
1117
|
+
i.value && (o = new IntersectionObserver(([e]) => {
|
|
1118
|
+
if (!e.isIntersecting || (t.always || o?.disconnect(), a)) return;
|
|
1119
|
+
a = !0;
|
|
1120
|
+
let i = s();
|
|
1121
|
+
n.value?.reload({
|
|
1122
|
+
...i,
|
|
1123
|
+
onStart: () => {
|
|
1124
|
+
a = !0, i.onStart?.();
|
|
1125
|
+
},
|
|
1126
|
+
onFinish: () => {
|
|
1127
|
+
r.value = !0, a = !1, i.onFinish?.();
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}, { rootMargin: `${t.buffer}px` }), o.observe(i.value));
|
|
1131
|
+
}), O(() => o?.disconnect()), (t, n) => (k(), f(F(e.as), {
|
|
1132
|
+
ref_key: "root",
|
|
1133
|
+
ref: i
|
|
1134
|
+
}, {
|
|
1135
|
+
default: R(() => [r.value ? P(t.$slots, "default", {}, void 0, void 0, 0) : P(t.$slots, "fallback", {}, void 0, void 0, 1)]),
|
|
1136
|
+
_: 3
|
|
1137
|
+
}, 512));
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
export { Je as Deferred, Ye as HeadlessModal, rt as Modal, at as ModalBtn, je as ModalInstance, it as ModalLink, Ge as ModalRoot, st as WhenVisible, e as dialogUtils, K as getConfig, Ee as getDialogLocation, J as getMaxWidth, Ae as initFromPageProps, Ue as modalPropNames, ke as prefetch, we as putConfig, Ke as renderApp, Ce as resetConfig, ot as useModal, $ as useModalStack, Be as visitModal, qe as withInertiaModal };
|