vue3-router-tab 1.3.3 → 1.3.5
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/vue3-router-tab.js +552 -498
- package/dist/vue3-router-tab.umd.cjs +1 -1
- package/lib/components/RouterTab.vue +217 -128
- package/package.json +1 -1
package/dist/vue3-router-tab.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './vue3-router-tab.css';
|
|
2
|
-
import { reactive as
|
|
2
|
+
import { reactive as pe, ref as B, shallowRef as bt, computed as k, watch as A, nextTick as M, inject as Ee, getCurrentInstance as je, onMounted as ge, defineComponent as Oe, provide as pt, onErrorCaptured as gt, onBeforeUnmount as mt, resolveComponent as vt, createElementBlock as S, openBlock as E, createElementVNode as O, withDirectives as ht, normalizeClass as H, renderSlot as le, createVNode as Ae, TransitionGroup as yt, mergeProps as se, withCtx as ue, Fragment as Pe, renderList as Ie, withModifiers as ce, createCommentVNode as q, toDisplayString as $e, createBlock as W, normalizeProps as Tt, Transition as kt, resolveDynamicComponent as fe, KeepAlive as wt, normalizeStyle as Rt, vShow as Ct, isRef as Et, isReadonly as At } from "vue";
|
|
3
3
|
import { RouterView as Pt } from "vue-router";
|
|
4
|
-
function
|
|
4
|
+
function It(e = {}) {
|
|
5
5
|
return {
|
|
6
6
|
initialTabs: e.initialTabs ?? [],
|
|
7
7
|
keepAlive: e.keepAlive ?? !0,
|
|
@@ -11,35 +11,35 @@ function At(e = {}) {
|
|
|
11
11
|
defaultRoute: e.defaultRoute ?? "/"
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function N(e, n) {
|
|
15
15
|
const o = e.resolve(n);
|
|
16
16
|
if (!o || !o.matched.length)
|
|
17
17
|
throw new Error(`[RouterTabs] Unable to resolve route: ${String(n)}`);
|
|
18
18
|
return o;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const $t = {
|
|
21
21
|
path: (e) => e.path,
|
|
22
22
|
fullpath: (e) => e.fullPath,
|
|
23
23
|
fullname: (e) => e.fullPath,
|
|
24
24
|
full: (e) => e.fullPath,
|
|
25
25
|
name: (e) => e.name ? String(e.name) : e.fullPath
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function z(e) {
|
|
28
28
|
const n = e.meta?.key;
|
|
29
29
|
if (typeof n == "function") {
|
|
30
30
|
const o = n(e);
|
|
31
31
|
if (typeof o == "string" && o.length) return o;
|
|
32
32
|
} else if (typeof n == "string" && n.length) {
|
|
33
|
-
const o =
|
|
33
|
+
const o = $t[n.toLowerCase()];
|
|
34
34
|
return o ? o(e) : n;
|
|
35
35
|
}
|
|
36
36
|
return e.fullPath;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function me(e, n) {
|
|
39
39
|
const o = e.meta?.keepAlive;
|
|
40
40
|
return typeof o == "boolean" ? o : n;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function ve(e, n) {
|
|
43
43
|
const o = e.meta?.reuse;
|
|
44
44
|
return typeof o == "boolean" ? o : n;
|
|
45
45
|
}
|
|
@@ -47,44 +47,44 @@ function Ue(e) {
|
|
|
47
47
|
const n = e.meta ?? {}, o = {};
|
|
48
48
|
return "title" in n && (o.title = n.title), "tips" in n && (o.tips = n.tips), "icon" in n && (o.icon = n.icon), "closable" in n && (o.closable = n.closable), "tabClass" in n && (o.tabClass = n.tabClass), "target" in n && (o.target = n.target), "href" in n && (o.href = n.href), o;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Q(e, n, o) {
|
|
51
51
|
const l = Ue(e);
|
|
52
52
|
return {
|
|
53
|
-
id:
|
|
53
|
+
id: z(e),
|
|
54
54
|
to: e.fullPath,
|
|
55
55
|
fullPath: e.fullPath,
|
|
56
56
|
matched: e,
|
|
57
|
-
alive:
|
|
58
|
-
reusable:
|
|
57
|
+
alive: me(e, o),
|
|
58
|
+
reusable: ve(e, !1),
|
|
59
59
|
closable: l.closable ?? !0,
|
|
60
60
|
renderKey: typeof n.renderKey == "number" ? n.renderKey : 0,
|
|
61
61
|
...l,
|
|
62
62
|
...n
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
if (!e.find((
|
|
65
|
+
function de(e, n, o, l) {
|
|
66
|
+
if (!e.find((g) => g.id === n.id)) {
|
|
67
67
|
if (o === "next" && l) {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
e.splice(
|
|
68
|
+
const g = e.findIndex((T) => T.id === l);
|
|
69
|
+
if (g !== -1) {
|
|
70
|
+
e.splice(g + 1, 0, n);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
e.push(n);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function Ke(e, n, o) {
|
|
78
78
|
if (!n || n <= 0) return;
|
|
79
|
-
const l = e.filter((
|
|
79
|
+
const l = e.filter((a) => a.alive);
|
|
80
80
|
for (; l.length > n; ) {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
83
|
-
const
|
|
84
|
-
|
|
81
|
+
const a = l.shift();
|
|
82
|
+
if (!a || a.id === o) continue;
|
|
83
|
+
const g = e.findIndex((T) => T.id === a.id);
|
|
84
|
+
g > -1 && (e[g].alive = !1);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function Kt(e) {
|
|
88
88
|
return {
|
|
89
89
|
to: e.to,
|
|
90
90
|
title: e.title,
|
|
@@ -99,145 +99,145 @@ function xt(e) {
|
|
|
99
99
|
const n = {};
|
|
100
100
|
return "title" in e && (n.title = e.title), "tips" in e && (n.tips = e.tips), "icon" in e && (n.icon = e.icon), "tabClass" in e && (n.tabClass = e.tabClass), "closable" in e && (n.closable = e.closable), "renderKey" in e && typeof e.renderKey == "number" && (n.renderKey = e.renderKey), n;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
const o =
|
|
104
|
-
() => l.filter((
|
|
102
|
+
function Dt(e, n = {}) {
|
|
103
|
+
const o = It(n), l = pe([]), a = B(null), g = bt(), T = B(null), s = k(
|
|
104
|
+
() => l.filter((i) => i.alive).map((i) => `${i.id}::${i.renderKey ?? 0}`)
|
|
105
105
|
);
|
|
106
|
-
let
|
|
107
|
-
function
|
|
108
|
-
const b = typeof
|
|
106
|
+
let f = !1;
|
|
107
|
+
function v(i) {
|
|
108
|
+
const b = typeof i.matched == "object" ? i : N(e, i);
|
|
109
109
|
return {
|
|
110
|
-
key:
|
|
110
|
+
key: z(b),
|
|
111
111
|
fullPath: b.fullPath,
|
|
112
|
-
alive:
|
|
113
|
-
reusable:
|
|
112
|
+
alive: me(b, o.keepAlive),
|
|
113
|
+
reusable: ve(b, !1),
|
|
114
114
|
matched: b
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const b =
|
|
119
|
-
let d = l.find((
|
|
120
|
-
return d ? (d.fullPath =
|
|
117
|
+
function C(i) {
|
|
118
|
+
const b = z(i);
|
|
119
|
+
let d = l.find((y) => y.id === b);
|
|
120
|
+
return d ? (d.fullPath = i.fullPath, d.to = i.fullPath, d.matched = i, d.alive = me(i, o.keepAlive), d.reusable = ve(i, d.reusable), typeof d.renderKey != "number" && (d.renderKey = 0), Object.assign(d, Ue(i)), d) : (d = Q(i, {}, o.keepAlive), de(l, d, o.appendPosition, a.value), Ke(l, o.maxAlive, a.value), d);
|
|
121
121
|
}
|
|
122
|
-
async function $(
|
|
123
|
-
const
|
|
124
|
-
d === "sameTab" && (d =
|
|
122
|
+
async function $(i, b = !1, d = !0) {
|
|
123
|
+
const y = N(e, i), w = z(y), P = a.value === w;
|
|
124
|
+
d === "sameTab" && (d = P), d && await U(w, !0), await e[b ? "replace" : "push"](y), P && await h();
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const b = l.findIndex((
|
|
126
|
+
function L(i) {
|
|
127
|
+
const b = l.findIndex((x) => x.id === i);
|
|
128
128
|
if (b === -1) return o.defaultRoute;
|
|
129
|
-
const d = l[b + 1],
|
|
130
|
-
return
|
|
129
|
+
const d = l[b + 1], y = l[b - 1], w = l.find((x) => x.id !== i), P = d || y || w;
|
|
130
|
+
return P ? P.to : o.defaultRoute;
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
133
|
-
if (!
|
|
132
|
+
async function Y(i = a.value, b = {}) {
|
|
133
|
+
if (!i) return;
|
|
134
134
|
if (!b.force && o.keepLastTab && l.length === 1)
|
|
135
135
|
throw new Error("[RouterTabs] Unable to close the final tab when keepLastTab is true.");
|
|
136
|
-
const
|
|
137
|
-
await
|
|
136
|
+
const y = a.value === i && b.redirect !== null, w = y ? b.redirect ?? L(i) : null;
|
|
137
|
+
await K(i, { force: b.force }), b.redirect !== null && y && w && await e.replace(w);
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
140
|
-
const d = l.findIndex((
|
|
141
|
-
d !== -1 && (l.splice(d, 1), T.value ===
|
|
139
|
+
async function K(i, b = {}) {
|
|
140
|
+
const d = l.findIndex((y) => y.id === i);
|
|
141
|
+
d !== -1 && (l.splice(d, 1), T.value === i && (T.value = null), a.value === i && (a.value = null, g.value = void 0));
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
144
|
-
if (!
|
|
145
|
-
const d = l.find((w) => w.id ===
|
|
143
|
+
async function U(i = a.value ?? void 0, b = !1) {
|
|
144
|
+
if (!i) return;
|
|
145
|
+
const d = l.find((w) => w.id === i);
|
|
146
146
|
if (!d) return;
|
|
147
|
-
const
|
|
148
|
-
|
|
147
|
+
const y = o.keepAlive && d.alive;
|
|
148
|
+
y && (d.alive = !1, await M()), d.renderKey = (d.renderKey ?? 0) + 1, y && (d.alive = !0), T.value = i, await M(), b || await M(), T.value = null;
|
|
149
149
|
}
|
|
150
|
-
async function
|
|
150
|
+
async function ne(i = !1) {
|
|
151
151
|
for (const b of l)
|
|
152
|
-
await
|
|
152
|
+
await U(b.id, i);
|
|
153
153
|
}
|
|
154
|
-
async function
|
|
155
|
-
l.splice(0, l.length),
|
|
154
|
+
async function oe(i = o.defaultRoute) {
|
|
155
|
+
l.splice(0, l.length), a.value = null, g.value = void 0;
|
|
156
156
|
for (const b of o.initialTabs) {
|
|
157
|
-
const d =
|
|
158
|
-
l.push(
|
|
157
|
+
const d = N(e, b.to), y = Q(d, b, o.keepAlive);
|
|
158
|
+
l.push(y);
|
|
159
159
|
}
|
|
160
|
-
await e.replace(
|
|
160
|
+
await e.replace(i);
|
|
161
161
|
}
|
|
162
|
-
async function
|
|
163
|
-
const
|
|
164
|
-
|
|
162
|
+
async function h() {
|
|
163
|
+
const i = a.value;
|
|
164
|
+
i && await U(i, !0);
|
|
165
165
|
}
|
|
166
|
-
function G(
|
|
167
|
-
return typeof
|
|
166
|
+
function G(i) {
|
|
167
|
+
return typeof i.matched == "object" ? z(i) : z(N(e, i));
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
169
|
+
function j() {
|
|
170
|
+
const i = l.find((b) => b.id === a.value);
|
|
171
171
|
return {
|
|
172
|
-
tabs: l.map(
|
|
173
|
-
active:
|
|
172
|
+
tabs: l.map(Kt),
|
|
173
|
+
active: i ? i.to : null
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
-
async function D(
|
|
177
|
-
|
|
178
|
-
const b =
|
|
179
|
-
for (const
|
|
176
|
+
async function D(i) {
|
|
177
|
+
f = !0, l.splice(0, l.length), a.value = null, g.value = void 0;
|
|
178
|
+
const b = i?.tabs ?? [];
|
|
179
|
+
for (const y of b)
|
|
180
180
|
try {
|
|
181
|
-
const w =
|
|
182
|
-
|
|
181
|
+
const w = N(e, y.to), P = xt(y), x = Q(w, P, o.keepAlive);
|
|
182
|
+
de(l, x, "last", null);
|
|
183
183
|
} catch {
|
|
184
184
|
}
|
|
185
|
-
|
|
186
|
-
const d =
|
|
185
|
+
f = !1;
|
|
186
|
+
const d = i?.active ?? b[b.length - 1]?.to ?? o.defaultRoute;
|
|
187
187
|
if (d)
|
|
188
188
|
try {
|
|
189
189
|
await e.replace(d);
|
|
190
190
|
} catch {
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
return
|
|
193
|
+
return A(
|
|
194
194
|
() => e.currentRoute.value,
|
|
195
|
-
(
|
|
196
|
-
if (
|
|
197
|
-
const b =
|
|
198
|
-
|
|
195
|
+
(i) => {
|
|
196
|
+
if (f) return;
|
|
197
|
+
const b = C(i);
|
|
198
|
+
a.value = b.id, g.value = b, Ke(l, o.maxAlive, a.value);
|
|
199
199
|
},
|
|
200
200
|
{ immediate: !0 }
|
|
201
|
-
), o.initialTabs.length && o.initialTabs.forEach((
|
|
202
|
-
const b =
|
|
203
|
-
|
|
201
|
+
), o.initialTabs.length && o.initialTabs.forEach((i) => {
|
|
202
|
+
const b = N(e, i.to), d = Q(b, i, o.keepAlive);
|
|
203
|
+
de(l, d, "last", null);
|
|
204
204
|
}), {
|
|
205
205
|
options: o,
|
|
206
206
|
tabs: l,
|
|
207
|
-
activeId:
|
|
208
|
-
current:
|
|
207
|
+
activeId: a,
|
|
208
|
+
current: g,
|
|
209
209
|
includeKeys: s,
|
|
210
210
|
refreshingKey: T,
|
|
211
211
|
openTab: $,
|
|
212
|
-
closeTab:
|
|
213
|
-
removeTab:
|
|
214
|
-
refreshTab:
|
|
215
|
-
refreshAll:
|
|
216
|
-
reset:
|
|
217
|
-
reload:
|
|
212
|
+
closeTab: Y,
|
|
213
|
+
removeTab: K,
|
|
214
|
+
refreshTab: U,
|
|
215
|
+
refreshAll: ne,
|
|
216
|
+
reset: oe,
|
|
217
|
+
reload: h,
|
|
218
218
|
getRouteKey: G,
|
|
219
|
-
matchRoute:
|
|
220
|
-
snapshot:
|
|
219
|
+
matchRoute: v,
|
|
220
|
+
snapshot: j,
|
|
221
221
|
hydrate: D
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function xe(e) {
|
|
225
225
|
return e ? typeof e == "string" ? { name: e } : e : {};
|
|
226
226
|
}
|
|
227
|
-
const
|
|
227
|
+
const te = Symbol("RouterTabsContext"), ee = "router-tabs:snapshot";
|
|
228
228
|
function De(e = {}) {
|
|
229
|
-
const { optional: n = !1 } = e, o =
|
|
229
|
+
const { optional: n = !1 } = e, o = Ee(te, null);
|
|
230
230
|
if (o) return o;
|
|
231
|
-
const l =
|
|
231
|
+
const l = Ee("$tabs", null);
|
|
232
232
|
if (l) return l;
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
233
|
+
const g = je()?.appContext.config.globalProperties.$tabs;
|
|
234
|
+
if (g) return g;
|
|
235
235
|
if (!n)
|
|
236
236
|
throw new Error("[RouterTabs] useRouterTabs must be used within <router-tab>.");
|
|
237
237
|
return null;
|
|
238
238
|
}
|
|
239
|
-
const
|
|
240
|
-
function
|
|
239
|
+
const St = 864e5;
|
|
240
|
+
function Bt(e) {
|
|
241
241
|
if (typeof document > "u") return null;
|
|
242
242
|
const n = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
|
|
243
243
|
for (const l of o)
|
|
@@ -249,23 +249,23 @@ function Se(e, n, o) {
|
|
|
249
249
|
if (typeof document > "u") return;
|
|
250
250
|
const {
|
|
251
251
|
expiresInDays: l = 7,
|
|
252
|
-
path:
|
|
253
|
-
domain:
|
|
252
|
+
path: a = "/",
|
|
253
|
+
domain: g,
|
|
254
254
|
secure: T,
|
|
255
255
|
sameSite: s = "lax"
|
|
256
|
-
} = o,
|
|
256
|
+
} = o, f = [`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];
|
|
257
257
|
if (l !== 1 / 0) {
|
|
258
|
-
const
|
|
259
|
-
|
|
258
|
+
const v = new Date(Date.now() + l * St).toUTCString();
|
|
259
|
+
f.push(`Expires=${v}`);
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
a && f.push(`Path=${a}`), g && f.push(`Domain=${g}`), T && f.push("Secure"), s && f.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = f.join("; ");
|
|
262
262
|
}
|
|
263
263
|
function Be(e, n) {
|
|
264
264
|
if (typeof document > "u") return;
|
|
265
|
-
const { path: o = "/", domain: l } = n,
|
|
266
|
-
|
|
265
|
+
const { path: o = "/", domain: l } = n, a = [`${encodeURIComponent(e)}=`];
|
|
266
|
+
a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && a.push(`Path=${o}`), l && a.push(`Domain=${l}`), document.cookie = a.join("; ");
|
|
267
267
|
}
|
|
268
|
-
const
|
|
268
|
+
const Mt = (e) => JSON.stringify(e ?? null), Lt = (e) => {
|
|
269
269
|
if (!e) return null;
|
|
270
270
|
try {
|
|
271
271
|
return JSON.parse(e);
|
|
@@ -275,61 +275,61 @@ const Bt = (e) => JSON.stringify(e ?? null), Mt = (e) => {
|
|
|
275
275
|
};
|
|
276
276
|
function Ve(e = {}) {
|
|
277
277
|
const {
|
|
278
|
-
cookieKey: n =
|
|
279
|
-
serialize: o =
|
|
280
|
-
deserialize: l =
|
|
281
|
-
} = e,
|
|
278
|
+
cookieKey: n = ee,
|
|
279
|
+
serialize: o = Mt,
|
|
280
|
+
deserialize: l = Lt
|
|
281
|
+
} = e, a = De({ optional: !0 }), g = B(!0), T = (s) => {
|
|
282
282
|
ge(async () => {
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
283
|
+
const f = l(Bt(n));
|
|
284
|
+
if (f && f.tabs?.length)
|
|
285
285
|
try {
|
|
286
|
-
if (
|
|
287
|
-
await
|
|
288
|
-
const
|
|
289
|
-
|
|
286
|
+
if (g.value = !0, await s.hydrate(f), f.active) {
|
|
287
|
+
await M();
|
|
288
|
+
const C = s.tabs.find(($) => $.to === f.active);
|
|
289
|
+
C && (s.activeId.value = C.id, s.current.value = C);
|
|
290
290
|
}
|
|
291
291
|
} finally {
|
|
292
|
-
|
|
292
|
+
g.value = !1;
|
|
293
293
|
}
|
|
294
294
|
else if (Object.prototype.hasOwnProperty.call(e, "fallbackRoute"))
|
|
295
295
|
try {
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
await s.reset(
|
|
296
|
+
g.value = !0;
|
|
297
|
+
const C = e.fallbackRoute ?? s.options.defaultRoute;
|
|
298
|
+
await s.reset(C);
|
|
299
299
|
} finally {
|
|
300
|
-
|
|
300
|
+
g.value = !1;
|
|
301
301
|
}
|
|
302
302
|
else
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
}),
|
|
303
|
+
g.value = !1;
|
|
304
|
+
const v = s.snapshot();
|
|
305
|
+
v.tabs.length ? Se(n, o(v), e) : Be(n, e), g.value = !1;
|
|
306
|
+
}), A(
|
|
307
307
|
() => ({
|
|
308
|
-
tabs: s.tabs.map((
|
|
309
|
-
to:
|
|
310
|
-
title:
|
|
311
|
-
tips:
|
|
312
|
-
icon:
|
|
313
|
-
tabClass:
|
|
314
|
-
closable:
|
|
315
|
-
renderKey:
|
|
308
|
+
tabs: s.tabs.map((f) => ({
|
|
309
|
+
to: f.to,
|
|
310
|
+
title: f.title,
|
|
311
|
+
tips: f.tips,
|
|
312
|
+
icon: f.icon,
|
|
313
|
+
tabClass: f.tabClass,
|
|
314
|
+
closable: f.closable,
|
|
315
|
+
renderKey: f.renderKey
|
|
316
316
|
})),
|
|
317
317
|
active: s.activeId.value
|
|
318
318
|
}),
|
|
319
319
|
() => {
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
322
|
-
|
|
320
|
+
if (g.value) return;
|
|
321
|
+
const f = s.snapshot();
|
|
322
|
+
f.tabs.length ? Se(n, o(f), e) : Be(n, e);
|
|
323
323
|
},
|
|
324
324
|
{ deep: !0 }
|
|
325
325
|
);
|
|
326
326
|
};
|
|
327
|
-
|
|
327
|
+
a ? T(a) : ge(() => {
|
|
328
328
|
const s = De({ optional: !0 });
|
|
329
329
|
s && T(s);
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
|
-
const
|
|
332
|
+
const jt = Oe({
|
|
333
333
|
name: "RouterTab",
|
|
334
334
|
components: { RouterView: Pt },
|
|
335
335
|
props: {
|
|
@@ -371,7 +371,7 @@ const Lt = Oe({
|
|
|
371
371
|
},
|
|
372
372
|
cookieKey: {
|
|
373
373
|
type: String,
|
|
374
|
-
default:
|
|
374
|
+
default: ee
|
|
375
375
|
},
|
|
376
376
|
persistence: {
|
|
377
377
|
type: Object,
|
|
@@ -390,7 +390,7 @@ const Lt = Oe({
|
|
|
390
390
|
const l = o.appContext.app.config.globalProperties.$router;
|
|
391
391
|
if (!l)
|
|
392
392
|
throw new Error("[RouterTab] Vue Router is required. Make sure to call app.use(router) before RouterTab.");
|
|
393
|
-
const
|
|
393
|
+
const a = Dt(l, {
|
|
394
394
|
initialTabs: e.tabs,
|
|
395
395
|
keepAlive: e.keepAlive,
|
|
396
396
|
maxAlive: e.maxAlive,
|
|
@@ -398,100 +398,143 @@ const Lt = Oe({
|
|
|
398
398
|
appendPosition: e.append,
|
|
399
399
|
defaultRoute: e.defaultPage
|
|
400
400
|
});
|
|
401
|
-
pt(
|
|
402
|
-
const
|
|
403
|
-
|
|
401
|
+
pt(te, a), o.appContext.config.globalProperties.$tabs = a;
|
|
402
|
+
const g = k(() => !!o?.slots?.default), T = k(() => !!o?.slots?.start), s = k(() => !!o?.slots?.end), f = B(0), v = k(() => {
|
|
403
|
+
f.value;
|
|
404
404
|
const t = {};
|
|
405
|
-
return
|
|
406
|
-
const
|
|
407
|
-
t[
|
|
405
|
+
return a.tabs.forEach((r) => {
|
|
406
|
+
const u = typeof r.title == "string" ? r.title : String(r.title || re(r));
|
|
407
|
+
t[r.id] = u;
|
|
408
408
|
}), t;
|
|
409
409
|
});
|
|
410
|
-
function
|
|
411
|
-
|
|
410
|
+
function C() {
|
|
411
|
+
f.value++;
|
|
412
412
|
}
|
|
413
|
-
const $ = /* @__PURE__ */ new Map(),
|
|
414
|
-
function
|
|
415
|
-
if (!
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
413
|
+
const $ = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
|
|
414
|
+
function Y(t, r) {
|
|
415
|
+
if (!(!r || $.has(t)))
|
|
416
|
+
try {
|
|
417
|
+
$.set(t, r);
|
|
418
|
+
const u = a.tabs.find((p) => a.getRouteKey(p.to) === t);
|
|
419
|
+
if (!u) {
|
|
420
|
+
console.warn(`[RouterTab] Cannot setup watching: tab not found for ${t}`);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const m = [];
|
|
424
|
+
if (r.routeTabTitle !== void 0)
|
|
425
|
+
try {
|
|
426
|
+
const p = A(
|
|
427
|
+
() => {
|
|
428
|
+
const c = r.routeTabTitle;
|
|
429
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
430
|
+
},
|
|
431
|
+
(c) => {
|
|
432
|
+
if (c != null) {
|
|
433
|
+
const V = String(c);
|
|
434
|
+
u.title = V, C();
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
{ immediate: !0 }
|
|
438
|
+
);
|
|
439
|
+
m.push(p);
|
|
440
|
+
} catch (p) {
|
|
441
|
+
console.error(`[RouterTab] Error watching routeTabTitle for ${t}:`, p);
|
|
430
442
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
443
|
+
if (r.routeTabIcon !== void 0)
|
|
444
|
+
try {
|
|
445
|
+
const p = A(
|
|
446
|
+
() => {
|
|
447
|
+
const c = r.routeTabIcon;
|
|
448
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
449
|
+
},
|
|
450
|
+
(c) => {
|
|
451
|
+
c != null && (u.icon = String(c), C());
|
|
452
|
+
},
|
|
453
|
+
{ immediate: !0 }
|
|
454
|
+
);
|
|
455
|
+
m.push(p);
|
|
456
|
+
} catch (p) {
|
|
457
|
+
console.error(`[RouterTab] Error watching routeTabIcon for ${t}:`, p);
|
|
458
|
+
}
|
|
459
|
+
if (r.routeTabClosable !== void 0)
|
|
460
|
+
try {
|
|
461
|
+
const p = A(
|
|
462
|
+
() => {
|
|
463
|
+
const c = r.routeTabClosable;
|
|
464
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
465
|
+
},
|
|
466
|
+
(c) => {
|
|
467
|
+
c != null && (u.closable = !!c, C());
|
|
468
|
+
},
|
|
469
|
+
{ immediate: !0 }
|
|
470
|
+
);
|
|
471
|
+
m.push(p);
|
|
472
|
+
} catch (p) {
|
|
473
|
+
console.error(`[RouterTab] Error watching routeTabClosable for ${t}:`, p);
|
|
474
|
+
}
|
|
475
|
+
if (r.routeTabMeta !== void 0)
|
|
476
|
+
try {
|
|
477
|
+
const p = A(
|
|
478
|
+
() => {
|
|
479
|
+
const c = r.routeTabMeta;
|
|
480
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
481
|
+
},
|
|
482
|
+
(c) => {
|
|
483
|
+
c && typeof c == "object" && (Object.assign(u, c), C());
|
|
484
|
+
},
|
|
485
|
+
{ immediate: !0, deep: !0 }
|
|
486
|
+
);
|
|
487
|
+
m.push(p);
|
|
488
|
+
} catch (p) {
|
|
489
|
+
console.error(`[RouterTab] Error watching routeTabMeta for ${t}:`, p);
|
|
490
|
+
}
|
|
491
|
+
L.set(t, m);
|
|
492
|
+
} catch (u) {
|
|
493
|
+
console.error(`[RouterTab] Error in setupComponentWatching for ${t}:`, u), K(t);
|
|
494
|
+
}
|
|
476
495
|
}
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
|
|
496
|
+
function K(t) {
|
|
497
|
+
try {
|
|
498
|
+
const r = L.get(t);
|
|
499
|
+
r && (r.forEach((u) => {
|
|
500
|
+
try {
|
|
501
|
+
u();
|
|
502
|
+
} catch (m) {
|
|
503
|
+
console.error(`[RouterTab] Error cleaning up watcher for ${t}:`, m);
|
|
504
|
+
}
|
|
505
|
+
}), L.delete(t)), $.delete(t);
|
|
506
|
+
} catch (r) {
|
|
507
|
+
console.error(`[RouterTab] Error in cleanupComponentWatching for ${t}:`, r);
|
|
508
|
+
}
|
|
480
509
|
}
|
|
481
|
-
function
|
|
482
|
-
|
|
510
|
+
function U(t, r) {
|
|
511
|
+
try {
|
|
512
|
+
t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? Y(r, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && Y(r, t.$) : t === null && K(r);
|
|
513
|
+
} catch (u) {
|
|
514
|
+
console.error(`[RouterTab] Error handling component ref for ${r}:`, u), K(r);
|
|
515
|
+
}
|
|
483
516
|
}
|
|
484
|
-
if (
|
|
517
|
+
if (gt((t, r, u) => {
|
|
518
|
+
if (console.error("[RouterTab] Error captured from component:", t, u), r && a.activeId.value) {
|
|
519
|
+
const m = a.activeId.value;
|
|
520
|
+
K(m);
|
|
521
|
+
const p = a.tabs.find((c) => c.id === m);
|
|
522
|
+
p && p.alive && (console.warn(`[RouterTab] Removing errored component ${m} from KeepAlive cache`), p.alive = !1, M(() => {
|
|
523
|
+
p.alive = !0;
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
return !1;
|
|
527
|
+
}), e.cookieKey !== null || e.persistence) {
|
|
485
528
|
const t = {
|
|
486
529
|
...e.persistence ?? {}
|
|
487
530
|
};
|
|
488
|
-
e.cookieKey !== null ? t.cookieKey = e.cookieKey ||
|
|
531
|
+
e.cookieKey !== null ? t.cookieKey = e.cookieKey || ee : t.cookieKey || (t.cookieKey = ee), Ve(t);
|
|
489
532
|
}
|
|
490
|
-
const
|
|
533
|
+
const ne = k(() => xe(e.tabTransition)), oe = k(() => xe(e.pageTransition)), h = pe({
|
|
491
534
|
visible: !1,
|
|
492
535
|
target: null,
|
|
493
536
|
position: { x: 0, y: 0 }
|
|
494
|
-
}), G =
|
|
537
|
+
}), G = B(null), j = B([]), D = B(-1), i = pe({
|
|
495
538
|
dragging: !1,
|
|
496
539
|
dragIndex: -1,
|
|
497
540
|
dropIndex: -1,
|
|
@@ -505,135 +548,134 @@ const Lt = Oe({
|
|
|
505
548
|
"closeOthers"
|
|
506
549
|
];
|
|
507
550
|
function d(t) {
|
|
508
|
-
return
|
|
551
|
+
return a.tabs.findIndex((r) => r.id === t);
|
|
509
552
|
}
|
|
510
|
-
function
|
|
511
|
-
const
|
|
512
|
-
return
|
|
553
|
+
function y(t) {
|
|
554
|
+
const r = d(t.id);
|
|
555
|
+
return r > 0 ? a.tabs.slice(0, r) : [];
|
|
513
556
|
}
|
|
514
557
|
function w(t) {
|
|
515
|
-
const
|
|
516
|
-
return
|
|
558
|
+
const r = d(t.id);
|
|
559
|
+
return r > -1 ? a.tabs.slice(r + 1) : [];
|
|
517
560
|
}
|
|
518
|
-
function
|
|
519
|
-
return
|
|
561
|
+
function P(t) {
|
|
562
|
+
return a.tabs.filter((r) => r.id !== t.id);
|
|
520
563
|
}
|
|
521
|
-
async function
|
|
522
|
-
const
|
|
523
|
-
if (
|
|
524
|
-
for (const
|
|
525
|
-
|
|
526
|
-
|
|
564
|
+
async function x(t, r) {
|
|
565
|
+
const u = t.filter((m) => m.closable !== !1);
|
|
566
|
+
if (u.length) {
|
|
567
|
+
for (const m of u)
|
|
568
|
+
a.activeId.value === m.id ? await a.closeTab(m.id, { redirect: r.to, force: !0 }) : await a.removeTab(m.id, { force: !0 });
|
|
569
|
+
a.activeId.value !== r.id && await a.openTab(r.to, !0, !1);
|
|
527
570
|
}
|
|
528
571
|
}
|
|
529
572
|
const Fe = {
|
|
530
573
|
refresh: {
|
|
531
574
|
label: "Refresh",
|
|
532
575
|
handler: async ({ target: t }) => {
|
|
533
|
-
await
|
|
576
|
+
await a.refreshTab(t.id, !0);
|
|
534
577
|
}
|
|
535
578
|
},
|
|
536
579
|
refreshAll: {
|
|
537
580
|
label: "Refresh All",
|
|
538
581
|
handler: async () => {
|
|
539
|
-
await
|
|
582
|
+
await a.refreshAll(!0);
|
|
540
583
|
}
|
|
541
584
|
},
|
|
542
585
|
close: {
|
|
543
586
|
label: "Close",
|
|
544
587
|
handler: async ({ target: t }) => {
|
|
545
|
-
await
|
|
588
|
+
await a.closeTab(t.id);
|
|
546
589
|
},
|
|
547
590
|
enable: ({ target: t }) => ae(t)
|
|
548
591
|
},
|
|
549
592
|
closeLefts: {
|
|
550
593
|
label: "Close to the Left",
|
|
551
594
|
handler: async ({ target: t }) => {
|
|
552
|
-
await
|
|
595
|
+
await x(y(t), t);
|
|
553
596
|
},
|
|
554
|
-
enable: ({ target: t }) =>
|
|
597
|
+
enable: ({ target: t }) => y(t).some((r) => r.closable !== !1)
|
|
555
598
|
},
|
|
556
599
|
closeRights: {
|
|
557
600
|
label: "Close to the Right",
|
|
558
601
|
handler: async ({ target: t }) => {
|
|
559
|
-
await
|
|
602
|
+
await x(w(t), t);
|
|
560
603
|
},
|
|
561
|
-
enable: ({ target: t }) => w(t).some((
|
|
604
|
+
enable: ({ target: t }) => w(t).some((r) => r.closable !== !1)
|
|
562
605
|
},
|
|
563
606
|
closeOthers: {
|
|
564
607
|
label: "Close Others",
|
|
565
608
|
handler: async ({ target: t }) => {
|
|
566
|
-
await
|
|
609
|
+
await x(P(t), t);
|
|
567
610
|
},
|
|
568
|
-
enable: ({ target: t }) =>
|
|
611
|
+
enable: ({ target: t }) => P(t).some((r) => r.closable !== !1)
|
|
569
612
|
}
|
|
570
613
|
};
|
|
571
|
-
function
|
|
572
|
-
|
|
614
|
+
function I() {
|
|
615
|
+
h.visible = !1, h.target = null, D.value = -1, j.value = [];
|
|
573
616
|
}
|
|
574
|
-
function He(t,
|
|
575
|
-
e.contextmenu && (
|
|
576
|
-
|
|
577
|
-
|
|
617
|
+
function He(t, r) {
|
|
618
|
+
e.contextmenu && (h.target = t, h.position.x = r.clientX, h.position.y = r.clientY, M(() => {
|
|
619
|
+
h.visible = !0, document.addEventListener("click", I, { once: !0 }), M(() => {
|
|
620
|
+
Je();
|
|
578
621
|
});
|
|
579
622
|
}));
|
|
580
623
|
}
|
|
581
|
-
function
|
|
582
|
-
const
|
|
583
|
-
if (!(typeof
|
|
584
|
-
const ie =
|
|
585
|
-
if (!
|
|
624
|
+
function We(t, r) {
|
|
625
|
+
const u = typeof t == "string" ? { id: t } : t, m = Fe[u.id], p = u.label ?? m?.label ?? String(u.id), c = u.visible ?? m?.visible ?? !0;
|
|
626
|
+
if (!(typeof c == "function" ? c(r) : c !== !1)) return null;
|
|
627
|
+
const ie = u.enable ?? m?.enable ?? !0, ft = typeof ie == "function" ? ie(r) : ie !== !1, Ce = u.handler ?? m?.handler;
|
|
628
|
+
if (!Ce) return null;
|
|
586
629
|
const dt = async () => {
|
|
587
|
-
await Promise.resolve(
|
|
630
|
+
await Promise.resolve(Ce(r));
|
|
588
631
|
};
|
|
589
632
|
return {
|
|
590
|
-
id: String(
|
|
591
|
-
label:
|
|
633
|
+
id: String(u.id),
|
|
634
|
+
label: p,
|
|
592
635
|
disabled: !ft,
|
|
593
636
|
action: dt
|
|
594
637
|
};
|
|
595
638
|
}
|
|
596
|
-
const
|
|
597
|
-
if (!
|
|
598
|
-
const t = Array.isArray(e.contextmenu) ? e.contextmenu : b,
|
|
599
|
-
return t.map((
|
|
639
|
+
const _ = k(() => {
|
|
640
|
+
if (!h.visible || !h.target || e.contextmenu === !1) return [];
|
|
641
|
+
const t = Array.isArray(e.contextmenu) ? e.contextmenu : b, r = { target: h.target, controller: a };
|
|
642
|
+
return t.map((u) => We(u, r)).filter((u) => !!u);
|
|
600
643
|
});
|
|
601
|
-
function
|
|
644
|
+
function Je() {
|
|
602
645
|
const t = G.value;
|
|
603
646
|
if (!t) return;
|
|
604
|
-
const
|
|
605
|
-
let
|
|
606
|
-
|
|
647
|
+
const r = 8, { innerWidth: u, innerHeight: m } = window, p = t.getBoundingClientRect();
|
|
648
|
+
let c = h.position.x, V = h.position.y;
|
|
649
|
+
p.right > u - r && (c = Math.max(r, u - p.width - r)), p.bottom > m - r && (V = Math.max(r, m - p.height - r)), (c !== h.position.x || V !== h.position.y) && (h.position.x = c, h.position.y = V);
|
|
607
650
|
}
|
|
608
|
-
function Ge(t,
|
|
609
|
-
|
|
610
|
-
M.value[a] = f ?? null;
|
|
651
|
+
function Ge(t, r) {
|
|
652
|
+
j.value[r] = t ?? null;
|
|
611
653
|
}
|
|
612
654
|
function Xe(t) {
|
|
613
655
|
if (t < 0) return;
|
|
614
|
-
|
|
656
|
+
j.value[t]?.focus({ preventScroll: !0 });
|
|
615
657
|
}
|
|
616
|
-
function X(t,
|
|
617
|
-
if (!
|
|
618
|
-
const
|
|
619
|
-
let
|
|
620
|
-
for (let
|
|
621
|
-
if (
|
|
658
|
+
function X(t, r, u = _.value) {
|
|
659
|
+
if (!u.length) return -1;
|
|
660
|
+
const m = u.length;
|
|
661
|
+
let p = t;
|
|
662
|
+
for (let c = 0; c < m; c++)
|
|
663
|
+
if (p = (p + r + m) % m, !u[p].disabled) return p;
|
|
622
664
|
return -1;
|
|
623
665
|
}
|
|
624
666
|
function F(t) {
|
|
625
|
-
D.value = t, !(t < 0) &&
|
|
667
|
+
D.value = t, !(t < 0) && M(() => Xe(t));
|
|
626
668
|
}
|
|
627
|
-
function
|
|
628
|
-
const
|
|
629
|
-
|
|
669
|
+
function Te(t) {
|
|
670
|
+
const r = X(D.value, t);
|
|
671
|
+
r !== -1 && F(r);
|
|
630
672
|
}
|
|
631
673
|
function qe(t) {
|
|
632
|
-
if (!
|
|
633
|
-
const
|
|
634
|
-
if (!
|
|
635
|
-
if (
|
|
636
|
-
|
|
674
|
+
if (!h.visible) return;
|
|
675
|
+
const r = t.key, u = _.value;
|
|
676
|
+
if (!u.length) return;
|
|
677
|
+
if (r === "Tab") {
|
|
678
|
+
I();
|
|
637
679
|
return;
|
|
638
680
|
}
|
|
639
681
|
if ([
|
|
@@ -647,107 +689,107 @@ const Lt = Oe({
|
|
|
647
689
|
" ",
|
|
648
690
|
"Spacebar",
|
|
649
691
|
"Escape"
|
|
650
|
-
].includes(
|
|
651
|
-
switch (t.preventDefault(),
|
|
692
|
+
].includes(r))
|
|
693
|
+
switch (t.preventDefault(), r) {
|
|
652
694
|
case "ArrowDown":
|
|
653
695
|
case "ArrowRight":
|
|
654
|
-
|
|
696
|
+
Te(1);
|
|
655
697
|
break;
|
|
656
698
|
case "ArrowUp":
|
|
657
699
|
case "ArrowLeft":
|
|
658
|
-
|
|
700
|
+
Te(-1);
|
|
659
701
|
break;
|
|
660
702
|
case "Home":
|
|
661
703
|
F(X(-1, 1));
|
|
662
704
|
break;
|
|
663
705
|
case "End":
|
|
664
|
-
F(X(
|
|
706
|
+
F(X(u.length, -1));
|
|
665
707
|
break;
|
|
666
708
|
case "Enter":
|
|
667
709
|
case " ":
|
|
668
710
|
case "Spacebar": {
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
|
|
711
|
+
const p = D.value;
|
|
712
|
+
if (p > -1) {
|
|
713
|
+
const c = u[p];
|
|
714
|
+
c.disabled || ke(c);
|
|
673
715
|
}
|
|
674
716
|
break;
|
|
675
717
|
}
|
|
676
718
|
case "Escape":
|
|
677
|
-
|
|
719
|
+
I();
|
|
678
720
|
break;
|
|
679
721
|
}
|
|
680
722
|
}
|
|
681
|
-
async function
|
|
682
|
-
t.disabled || (
|
|
723
|
+
async function ke(t) {
|
|
724
|
+
t.disabled || (I(), await t.action());
|
|
683
725
|
}
|
|
684
|
-
function
|
|
726
|
+
function re(t) {
|
|
685
727
|
return typeof t.title == "string" && t.title.trim() ? t.title : Array.isArray(t.title) && t.title.length && String(t.title[0]).trim() ? String(t.title[0]) : "Untitled";
|
|
686
728
|
}
|
|
687
729
|
function Qe(t) {
|
|
688
|
-
return
|
|
730
|
+
return v.value[t.id] || re(t);
|
|
689
731
|
}
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
if (!
|
|
693
|
-
return console.warn(
|
|
694
|
-
const
|
|
695
|
-
return `${
|
|
732
|
+
function we(t) {
|
|
733
|
+
const r = a.getRouteKey(t), u = a.tabs.find((p) => p.id === r);
|
|
734
|
+
if (!u)
|
|
735
|
+
return console.warn("[RouterTab] Tab not found for route:", r), `${r}::0`;
|
|
736
|
+
const m = u.renderKey ?? 0;
|
|
737
|
+
return `${r}::${m}`;
|
|
696
738
|
}
|
|
697
739
|
function Ze(t) {
|
|
698
|
-
return `${
|
|
740
|
+
return `${we(t)}::refresh`;
|
|
699
741
|
}
|
|
700
742
|
function ae(t) {
|
|
701
|
-
return !(t.closable === !1 ||
|
|
743
|
+
return !(t.closable === !1 || a.options.keepLastTab && a.tabs.length <= 1);
|
|
702
744
|
}
|
|
703
745
|
async function et(t) {
|
|
704
|
-
await
|
|
746
|
+
await a.closeTab(t.id);
|
|
705
747
|
}
|
|
706
748
|
function tt(t) {
|
|
707
749
|
if (t.href && typeof window < "u") {
|
|
708
750
|
t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
|
|
709
751
|
return;
|
|
710
752
|
}
|
|
711
|
-
|
|
753
|
+
a.activeId.value !== t.id && a.openTab(t.to, !1);
|
|
712
754
|
}
|
|
713
755
|
function nt(t) {
|
|
714
756
|
return [
|
|
715
757
|
"router-tab__item",
|
|
716
758
|
{
|
|
717
|
-
"is-active":
|
|
759
|
+
"is-active": a.activeId.value === t.id,
|
|
718
760
|
"is-closable": ae(t),
|
|
719
|
-
"is-dragging":
|
|
720
|
-
"is-drag-over":
|
|
761
|
+
"is-dragging": i.dragging && i.dragTab?.id === t.id,
|
|
762
|
+
"is-drag-over": i.dropIndex === d(t.id)
|
|
721
763
|
},
|
|
722
764
|
t.tabClass
|
|
723
765
|
];
|
|
724
766
|
}
|
|
725
767
|
function ot(t) {
|
|
726
|
-
return
|
|
768
|
+
return a.refreshingKey.value === a.getRouteKey(t);
|
|
727
769
|
}
|
|
728
|
-
function
|
|
729
|
-
const
|
|
730
|
-
return
|
|
770
|
+
function rt(t) {
|
|
771
|
+
const r = a.getRouteKey(t);
|
|
772
|
+
return a.tabs.some((u) => u.id === r);
|
|
731
773
|
}
|
|
732
|
-
function
|
|
733
|
-
e.sortable && (
|
|
774
|
+
function at(t, r, u) {
|
|
775
|
+
e.sortable && (i.dragging = !0, i.dragIndex = r, i.dragTab = t, u.dataTransfer && (u.dataTransfer.effectAllowed = "move", u.dataTransfer.setData("text/plain", t.id)), n("tab-sort", { tab: t, index: r }));
|
|
734
776
|
}
|
|
735
|
-
function
|
|
736
|
-
!e.sortable || !
|
|
777
|
+
function it(t, r) {
|
|
778
|
+
!e.sortable || !i.dragging || (r.preventDefault(), r.dataTransfer && (r.dataTransfer.dropEffect = "move"));
|
|
737
779
|
}
|
|
738
780
|
function lt(t) {
|
|
739
|
-
!e.sortable || !
|
|
781
|
+
!e.sortable || !i.dragging || (i.dropIndex = t);
|
|
740
782
|
}
|
|
741
783
|
function st() {
|
|
742
|
-
!e.sortable ||
|
|
784
|
+
!e.sortable || i.dragging;
|
|
743
785
|
}
|
|
744
|
-
function ut(t,
|
|
745
|
-
if (!(!e.sortable || !
|
|
746
|
-
if (
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
tab:
|
|
750
|
-
fromIndex:
|
|
786
|
+
function ut(t, r) {
|
|
787
|
+
if (!(!e.sortable || !i.dragging)) {
|
|
788
|
+
if (r.preventDefault(), i.dragIndex !== -1 && i.dragIndex !== t) {
|
|
789
|
+
const u = a.tabs.splice(i.dragIndex, 1)[0];
|
|
790
|
+
a.tabs.splice(t, 0, u), n("tab-sorted", {
|
|
791
|
+
tab: u,
|
|
792
|
+
fromIndex: i.dragIndex,
|
|
751
793
|
toIndex: t
|
|
752
794
|
});
|
|
753
795
|
}
|
|
@@ -755,80 +797,94 @@ const Lt = Oe({
|
|
|
755
797
|
}
|
|
756
798
|
}
|
|
757
799
|
function Re() {
|
|
758
|
-
|
|
800
|
+
i.dragging = !1, i.dragIndex = -1, i.dropIndex = -1, i.dragTab = null;
|
|
759
801
|
}
|
|
760
802
|
ge(() => {
|
|
761
|
-
document.addEventListener("keydown",
|
|
803
|
+
document.addEventListener("keydown", I);
|
|
762
804
|
}), mt(() => {
|
|
763
|
-
document.removeEventListener("keydown",
|
|
764
|
-
t.forEach((
|
|
765
|
-
|
|
766
|
-
|
|
805
|
+
document.removeEventListener("keydown", I), o.appContext.config.globalProperties.$tabs = null, L.forEach((t) => {
|
|
806
|
+
t.forEach((r) => {
|
|
807
|
+
try {
|
|
808
|
+
r();
|
|
809
|
+
} catch (u) {
|
|
810
|
+
console.error("[RouterTab] Error during cleanup:", u);
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
}), L.clear(), $.clear();
|
|
814
|
+
}), A(
|
|
767
815
|
() => e.keepAlive,
|
|
768
816
|
(t) => {
|
|
769
|
-
|
|
817
|
+
a.options.keepAlive = t;
|
|
770
818
|
}
|
|
771
|
-
),
|
|
772
|
-
() =>
|
|
773
|
-
() =>
|
|
774
|
-
),
|
|
819
|
+
), A(
|
|
820
|
+
() => a.activeId.value,
|
|
821
|
+
() => I()
|
|
822
|
+
), A(
|
|
823
|
+
() => a.tabs.length,
|
|
824
|
+
() => {
|
|
825
|
+
const t = new Set(a.tabs.map((u) => u.id));
|
|
826
|
+
Array.from($.keys()).forEach((u) => {
|
|
827
|
+
t.has(u) || (console.log(`[RouterTab] Cleaning up stale component instance: ${u}`), K(u));
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
), A(
|
|
775
831
|
() => e.contextmenu,
|
|
776
832
|
(t) => {
|
|
777
|
-
t ||
|
|
833
|
+
t || I();
|
|
778
834
|
}
|
|
779
|
-
),
|
|
780
|
-
() =>
|
|
835
|
+
), A(
|
|
836
|
+
() => _.value.length,
|
|
781
837
|
(t) => {
|
|
782
|
-
|
|
838
|
+
h.visible && t === 0 && I();
|
|
783
839
|
},
|
|
784
840
|
{ flush: "post" }
|
|
785
841
|
// Run after component updates to prevent blocking render
|
|
786
|
-
),
|
|
787
|
-
if (!
|
|
788
|
-
|
|
789
|
-
const
|
|
790
|
-
F(
|
|
791
|
-
}, { flush: "post" }),
|
|
792
|
-
() =>
|
|
842
|
+
), A(_, (t) => {
|
|
843
|
+
if (!h.visible) return;
|
|
844
|
+
j.value = new Array(t.length).fill(null);
|
|
845
|
+
const r = X(-1, 1, t);
|
|
846
|
+
F(r);
|
|
847
|
+
}, { flush: "post" }), A(
|
|
848
|
+
() => h.visible,
|
|
793
849
|
(t) => {
|
|
794
|
-
t || (D.value = -1,
|
|
850
|
+
t || (D.value = -1, j.value = []);
|
|
795
851
|
}
|
|
796
852
|
);
|
|
797
|
-
const ct =
|
|
853
|
+
const ct = a.includeKeys;
|
|
798
854
|
return {
|
|
799
|
-
controller:
|
|
800
|
-
tabs:
|
|
855
|
+
controller: a,
|
|
856
|
+
tabs: a.tabs,
|
|
801
857
|
includeKeys: ct,
|
|
802
|
-
tabTransitionProps:
|
|
803
|
-
pageTransitionProps:
|
|
858
|
+
tabTransitionProps: ne,
|
|
859
|
+
pageTransitionProps: oe,
|
|
804
860
|
buildTabClass: nt,
|
|
805
861
|
activate: tt,
|
|
806
862
|
close: et,
|
|
807
|
-
context:
|
|
808
|
-
menuItems:
|
|
809
|
-
handleMenuAction:
|
|
863
|
+
context: h,
|
|
864
|
+
menuItems: _,
|
|
865
|
+
handleMenuAction: ke,
|
|
810
866
|
showContextMenu: He,
|
|
811
|
-
hideContextMenu:
|
|
812
|
-
getTabTitle:
|
|
867
|
+
hideContextMenu: I,
|
|
868
|
+
getTabTitle: re,
|
|
813
869
|
isClosable: ae,
|
|
814
870
|
isRefreshing: ot,
|
|
815
|
-
isTabReady:
|
|
816
|
-
hasCustomSlot:
|
|
871
|
+
isTabReady: rt,
|
|
872
|
+
hasCustomSlot: g,
|
|
817
873
|
hasStartSlot: T,
|
|
818
874
|
hasEndSlot: s,
|
|
819
|
-
onDragStart:
|
|
820
|
-
onDragOver:
|
|
875
|
+
onDragStart: at,
|
|
876
|
+
onDragOver: it,
|
|
821
877
|
onDragEnter: lt,
|
|
822
878
|
onDragLeave: st,
|
|
823
879
|
onDrop: ut,
|
|
824
880
|
onDragEnd: Re,
|
|
825
|
-
setupComponentWatching:
|
|
826
|
-
cleanupComponentWatching:
|
|
827
|
-
handleComponentRef:
|
|
881
|
+
setupComponentWatching: Y,
|
|
882
|
+
cleanupComponentWatching: K,
|
|
883
|
+
handleComponentRef: U,
|
|
828
884
|
getReactiveTabTitle: Qe,
|
|
829
|
-
getComponentCacheKey:
|
|
885
|
+
getComponentCacheKey: we,
|
|
830
886
|
getRefreshComponentKey: Ze,
|
|
831
|
-
triggerTabUpdate:
|
|
887
|
+
triggerTabUpdate: C,
|
|
832
888
|
menuRef: G,
|
|
833
889
|
highlightedIndex: D,
|
|
834
890
|
setMenuItemRef: Ge,
|
|
@@ -836,97 +892,95 @@ const Lt = Oe({
|
|
|
836
892
|
highlightMenuIndex: F
|
|
837
893
|
};
|
|
838
894
|
}
|
|
839
|
-
}),
|
|
895
|
+
}), Ot = (e, n) => {
|
|
840
896
|
const o = e.__vccOpts || e;
|
|
841
|
-
for (const [l,
|
|
842
|
-
o[l] =
|
|
897
|
+
for (const [l, a] of n)
|
|
898
|
+
o[l] = a;
|
|
843
899
|
return o;
|
|
844
|
-
},
|
|
845
|
-
function
|
|
846
|
-
const T =
|
|
847
|
-
return
|
|
848
|
-
|
|
849
|
-
|
|
900
|
+
}, Ut = { class: "router-tab" }, Vt = { class: "router-tab__header" }, Nt = { class: "router-tab__scroll" }, zt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], Yt = ["title"], _t = ["onClick"], Ft = { class: "router-tab__container" }, Ht = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
|
|
901
|
+
function Wt(e, n, o, l, a, g) {
|
|
902
|
+
const T = vt("RouterView");
|
|
903
|
+
return E(), S("div", Ut, [
|
|
904
|
+
O("header", Vt, [
|
|
905
|
+
O("div", {
|
|
850
906
|
class: H(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
|
|
851
907
|
}, [
|
|
852
|
-
|
|
908
|
+
le(e.$slots, "start")
|
|
853
909
|
], 2),
|
|
854
|
-
|
|
855
|
-
Ae(yt,
|
|
910
|
+
O("div", Nt, [
|
|
911
|
+
Ae(yt, se({
|
|
856
912
|
tag: "ul",
|
|
857
913
|
class: "router-tab__nav"
|
|
858
914
|
}, e.tabTransitionProps), {
|
|
859
|
-
default:
|
|
860
|
-
(
|
|
915
|
+
default: ue(() => [
|
|
916
|
+
(E(!0), S(Pe, null, Ie(e.tabs, (s, f) => (E(), S("li", {
|
|
861
917
|
key: s.id,
|
|
862
918
|
class: H(e.buildTabClass(s)),
|
|
863
919
|
"data-title": e.getTabTitle(s),
|
|
864
920
|
draggable: e.sortable,
|
|
865
|
-
onClick: (
|
|
866
|
-
onAuxclick: ce((
|
|
867
|
-
onContextmenu: ce((
|
|
868
|
-
onDragstart: (
|
|
869
|
-
onDragover: (
|
|
870
|
-
onDragenter: (
|
|
871
|
-
onDragleave: n[0] || (n[0] = (...
|
|
872
|
-
onDrop: (
|
|
873
|
-
onDragend: n[1] || (n[1] = (...
|
|
921
|
+
onClick: (v) => e.activate(s),
|
|
922
|
+
onAuxclick: ce((v) => e.close(s), ["middle", "prevent"]),
|
|
923
|
+
onContextmenu: ce((v) => e.showContextMenu(s, v), ["prevent"]),
|
|
924
|
+
onDragstart: (v) => e.onDragStart(s, f, v),
|
|
925
|
+
onDragover: (v) => e.onDragOver(f, v),
|
|
926
|
+
onDragenter: (v) => e.onDragEnter(f),
|
|
927
|
+
onDragleave: n[0] || (n[0] = (...v) => e.onDragLeave && e.onDragLeave(...v)),
|
|
928
|
+
onDrop: (v) => e.onDrop(f, v),
|
|
929
|
+
onDragend: n[1] || (n[1] = (...v) => e.onDragEnd && e.onDragEnd(...v))
|
|
874
930
|
}, [
|
|
875
|
-
s.icon ? (
|
|
931
|
+
s.icon ? (E(), S("i", {
|
|
876
932
|
key: 0,
|
|
877
933
|
class: H(["router-tab__item-icon", s.icon])
|
|
878
|
-
}, null, 2)) :
|
|
879
|
-
|
|
934
|
+
}, null, 2)) : q("", !0),
|
|
935
|
+
O("span", {
|
|
880
936
|
class: "router-tab__item-title",
|
|
881
937
|
title: e.getReactiveTabTitle(s)
|
|
882
|
-
},
|
|
883
|
-
e.isClosable(s) ? (
|
|
938
|
+
}, $e(e.getReactiveTabTitle(s)), 9, Yt),
|
|
939
|
+
e.isClosable(s) ? (E(), S("a", {
|
|
884
940
|
key: 1,
|
|
885
941
|
class: "router-tab__item-close",
|
|
886
|
-
onClick: ce((
|
|
887
|
-
}, null, 8, _t)) :
|
|
888
|
-
], 42,
|
|
942
|
+
onClick: ce((v) => e.close(s), ["stop"])
|
|
943
|
+
}, null, 8, _t)) : q("", !0)
|
|
944
|
+
], 42, zt))), 128))
|
|
889
945
|
]),
|
|
890
946
|
_: 1
|
|
891
947
|
}, 16)
|
|
892
948
|
]),
|
|
893
|
-
|
|
949
|
+
O("div", {
|
|
894
950
|
class: H(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
|
|
895
951
|
}, [
|
|
896
|
-
|
|
952
|
+
le(e.$slots, "end")
|
|
897
953
|
], 2)
|
|
898
954
|
]),
|
|
899
|
-
|
|
955
|
+
O("div", Ft, [
|
|
900
956
|
Ae(T, null, {
|
|
901
|
-
default:
|
|
902
|
-
e.hasCustomSlot ?
|
|
957
|
+
default: ue((s) => [
|
|
958
|
+
e.hasCustomSlot ? le(e.$slots, "default", Tt(se({ key: 0 }, {
|
|
903
959
|
...s,
|
|
904
960
|
controller: e.controller,
|
|
905
961
|
// Expose a ref binder so custom slots can keep reactivity
|
|
906
|
-
pageRef: (
|
|
907
|
-
}))) : (
|
|
908
|
-
default:
|
|
909
|
-
|
|
910
|
-
e.
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
(C(), J(de(s.Component), {
|
|
920
|
-
key: e.getComponentCacheKey(s.route),
|
|
921
|
-
ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
|
|
922
|
-
class: "router-tab-page"
|
|
923
|
-
}))
|
|
924
|
-
], 1032, ["include", "max"])) : (C(), J(de(s.Component), {
|
|
962
|
+
pageRef: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route))
|
|
963
|
+
}))) : (E(), W(kt, se({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
|
|
964
|
+
default: ue(() => [
|
|
965
|
+
e.isRefreshing(s.route) ? (E(), W(fe(s.Component), {
|
|
966
|
+
key: e.getRefreshComponentKey(s.route),
|
|
967
|
+
ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
|
|
968
|
+
class: "router-tab-page"
|
|
969
|
+
})) : e.controller.options.keepAlive ? (E(), W(wt, {
|
|
970
|
+
key: 1,
|
|
971
|
+
include: e.includeKeys,
|
|
972
|
+
max: e.controller.options.maxAlive || void 0
|
|
973
|
+
}, [
|
|
974
|
+
e.isTabReady(s.route) ? (E(), W(fe(s.Component), {
|
|
925
975
|
key: e.getComponentCacheKey(s.route),
|
|
926
|
-
ref: (
|
|
976
|
+
ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
|
|
927
977
|
class: "router-tab-page"
|
|
928
|
-
}))
|
|
929
|
-
],
|
|
978
|
+
})) : q("", !0)
|
|
979
|
+
], 1032, ["include", "max"])) : e.isTabReady(s.route) ? (E(), W(fe(s.Component), {
|
|
980
|
+
key: e.getComponentCacheKey(s.route),
|
|
981
|
+
ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
|
|
982
|
+
class: "router-tab-page"
|
|
983
|
+
})) : q("", !0)
|
|
930
984
|
]),
|
|
931
985
|
_: 2
|
|
932
986
|
}, 1040))
|
|
@@ -934,34 +988,34 @@ function Ht(e, n, o, l, i, p) {
|
|
|
934
988
|
_: 3
|
|
935
989
|
})
|
|
936
990
|
]),
|
|
937
|
-
|
|
991
|
+
ht(O("div", {
|
|
938
992
|
ref: "menuRef",
|
|
939
993
|
class: "router-tab__contextmenu",
|
|
940
994
|
role: "menu",
|
|
941
995
|
onKeydown: n[2] || (n[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
|
|
942
|
-
style:
|
|
996
|
+
style: Rt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
|
|
943
997
|
}, [
|
|
944
|
-
(
|
|
998
|
+
(E(!0), S(Pe, null, Ie(e.menuItems, (s, f) => (E(), S("a", {
|
|
945
999
|
key: s.id,
|
|
946
1000
|
role: "menuitem",
|
|
947
|
-
class: H(["router-tab__contextmenu-item", { "is-focused":
|
|
1001
|
+
class: H(["router-tab__contextmenu-item", { "is-focused": f === e.highlightedIndex }]),
|
|
948
1002
|
"aria-disabled": s.disabled,
|
|
949
1003
|
disabled: s.disabled,
|
|
950
|
-
tabindex: s.disabled ? -1 :
|
|
1004
|
+
tabindex: s.disabled ? -1 : f === e.highlightedIndex ? 0 : -1,
|
|
951
1005
|
ref_for: !0,
|
|
952
|
-
ref: (
|
|
953
|
-
onMouseenter: (
|
|
954
|
-
onClick: (
|
|
955
|
-
},
|
|
1006
|
+
ref: (v) => e.setMenuItemRef(v, f),
|
|
1007
|
+
onMouseenter: (v) => !s.disabled && e.highlightMenuIndex(f),
|
|
1008
|
+
onClick: (v) => e.handleMenuAction(s)
|
|
1009
|
+
}, $e(s.label), 43, Ht))), 128))
|
|
956
1010
|
], 36), [
|
|
957
1011
|
[Ct, e.context.visible && e.context.target]
|
|
958
1012
|
])
|
|
959
1013
|
]);
|
|
960
1014
|
}
|
|
961
|
-
const Me = /* @__PURE__ */ jt
|
|
1015
|
+
const Me = /* @__PURE__ */ Ot(jt, [["render", Wt]]), Jt = {
|
|
962
1016
|
class: "router-tabs",
|
|
963
1017
|
"aria-hidden": "true"
|
|
964
|
-
},
|
|
1018
|
+
}, be = /* @__PURE__ */ Oe({
|
|
965
1019
|
name: "RouterTabs",
|
|
966
1020
|
__name: "RouterTabs",
|
|
967
1021
|
props: {
|
|
@@ -976,10 +1030,10 @@ const Me = /* @__PURE__ */ jt(Lt, [["render", Ht]]), Jt = {
|
|
|
976
1030
|
fallbackRoute: {}
|
|
977
1031
|
},
|
|
978
1032
|
setup(e) {
|
|
979
|
-
return Ve(e), (o, l) => (
|
|
1033
|
+
return Ve(e), (o, l) => (E(), S("span", Jt));
|
|
980
1034
|
}
|
|
981
|
-
}), Ne = "tab-theme-style", ze = "tab-theme-primary-color",
|
|
982
|
-
let
|
|
1035
|
+
}), Ne = "tab-theme-style", ze = "tab-theme-primary-color", Gt = "system", Ye = "(prefers-color-scheme: dark)";
|
|
1036
|
+
let J = null;
|
|
983
1037
|
const R = {
|
|
984
1038
|
primary: "#034960",
|
|
985
1039
|
background: "#ffffff",
|
|
@@ -994,7 +1048,7 @@ const R = {
|
|
|
994
1048
|
activeButtonBackground: "#034960",
|
|
995
1049
|
activeButtonColor: "#ffffff",
|
|
996
1050
|
iconColor: "#475569"
|
|
997
|
-
},
|
|
1051
|
+
}, Xt = {
|
|
998
1052
|
primary: "#38bdf8",
|
|
999
1053
|
background: "#0f172a",
|
|
1000
1054
|
text: "#f1f5f9",
|
|
@@ -1010,7 +1064,7 @@ const R = {
|
|
|
1010
1064
|
activeButtonColor: "#0f172a",
|
|
1011
1065
|
iconColor: "#cbd5e1"
|
|
1012
1066
|
};
|
|
1013
|
-
function
|
|
1067
|
+
function qt(e) {
|
|
1014
1068
|
if (typeof window > "u") return null;
|
|
1015
1069
|
const n = window.localStorage.getItem(e);
|
|
1016
1070
|
if (!n) return null;
|
|
@@ -1024,47 +1078,47 @@ function Xt(e) {
|
|
|
1024
1078
|
function he(e) {
|
|
1025
1079
|
typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? R.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? R.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? R.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? R.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? R.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? R.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? R.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? R.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? R.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? R.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? R.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? R.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? R.iconColor));
|
|
1026
1080
|
}
|
|
1027
|
-
function
|
|
1081
|
+
function _e(e) {
|
|
1028
1082
|
if (typeof document > "u") return;
|
|
1029
|
-
const n = document.documentElement, o = window.matchMedia(
|
|
1083
|
+
const n = document.documentElement, o = window.matchMedia(Ye), l = () => {
|
|
1030
1084
|
n.dataset.theme = o.matches ? "dark" : "light";
|
|
1031
1085
|
};
|
|
1032
|
-
|
|
1086
|
+
J && (o.removeEventListener("change", J), J = null), e === "system" ? (l(), J = () => l(), o.addEventListener("change", J)) : n.dataset.theme = e;
|
|
1033
1087
|
}
|
|
1034
|
-
function
|
|
1088
|
+
function Qt(e = {}) {
|
|
1035
1089
|
if (typeof window > "u") return;
|
|
1036
1090
|
const {
|
|
1037
1091
|
styleKey: n = Ne,
|
|
1038
1092
|
primaryKey: o = ze,
|
|
1039
|
-
defaultStyle: l =
|
|
1040
|
-
defaultPrimary:
|
|
1041
|
-
} = e,
|
|
1042
|
-
|
|
1043
|
-
const s =
|
|
1044
|
-
|
|
1045
|
-
const
|
|
1046
|
-
he(
|
|
1093
|
+
defaultStyle: l = Gt,
|
|
1094
|
+
defaultPrimary: a
|
|
1095
|
+
} = e, g = window.localStorage.getItem(n) ?? l;
|
|
1096
|
+
_e(g);
|
|
1097
|
+
const s = g === "dark" || g === "system" && window.matchMedia(Ye).matches ? { ...Xt } : { ...R };
|
|
1098
|
+
a && (s.primary = a);
|
|
1099
|
+
const f = qt(o);
|
|
1100
|
+
he(f ? {
|
|
1047
1101
|
...s,
|
|
1048
|
-
...
|
|
1102
|
+
...f
|
|
1049
1103
|
} : s);
|
|
1050
1104
|
}
|
|
1051
|
-
function
|
|
1105
|
+
function tn(e, n) {
|
|
1052
1106
|
if (typeof window > "u") return;
|
|
1053
1107
|
const o = n?.styleKey ?? Ne;
|
|
1054
|
-
window.localStorage.setItem(o, e),
|
|
1108
|
+
window.localStorage.setItem(o, e), _e(e);
|
|
1055
1109
|
}
|
|
1056
|
-
function
|
|
1110
|
+
function nn(e, n) {
|
|
1057
1111
|
if (typeof window > "u") return;
|
|
1058
1112
|
const o = n?.primaryKey ?? ze;
|
|
1059
1113
|
window.localStorage.setItem(o, JSON.stringify(e)), he(e);
|
|
1060
1114
|
}
|
|
1061
|
-
function
|
|
1062
|
-
if (
|
|
1063
|
-
const l = !
|
|
1115
|
+
function Z(e, n) {
|
|
1116
|
+
if (Et(e)) {
|
|
1117
|
+
const l = !At(e);
|
|
1064
1118
|
return {
|
|
1065
1119
|
value: e,
|
|
1066
|
-
update: l ? (
|
|
1067
|
-
e.value =
|
|
1120
|
+
update: l ? (a) => {
|
|
1121
|
+
e.value = a;
|
|
1068
1122
|
} : () => {
|
|
1069
1123
|
}
|
|
1070
1124
|
};
|
|
@@ -1075,7 +1129,7 @@ function Q(e, n) {
|
|
|
1075
1129
|
update: () => {
|
|
1076
1130
|
}
|
|
1077
1131
|
};
|
|
1078
|
-
const o =
|
|
1132
|
+
const o = B(
|
|
1079
1133
|
e === void 0 ? n : e
|
|
1080
1134
|
);
|
|
1081
1135
|
return {
|
|
@@ -1085,28 +1139,28 @@ function Q(e, n) {
|
|
|
1085
1139
|
}
|
|
1086
1140
|
};
|
|
1087
1141
|
}
|
|
1088
|
-
function
|
|
1089
|
-
const n =
|
|
1142
|
+
function ye(e = {}) {
|
|
1143
|
+
const n = Z(e.title, "Untitled"), o = Z(e.icon, ""), l = Z(e.closable, !0), a = Z(e.meta, {});
|
|
1090
1144
|
return {
|
|
1091
1145
|
routeTabTitle: n.value,
|
|
1092
1146
|
routeTabIcon: o.value,
|
|
1093
1147
|
routeTabClosable: l.value,
|
|
1094
|
-
routeTabMeta:
|
|
1148
|
+
routeTabMeta: a.value,
|
|
1095
1149
|
updateTitle: n.update,
|
|
1096
1150
|
updateIcon: o.update,
|
|
1097
1151
|
updateClosable: l.update,
|
|
1098
|
-
updateMeta:
|
|
1152
|
+
updateMeta: a.update
|
|
1099
1153
|
};
|
|
1100
1154
|
}
|
|
1101
|
-
function
|
|
1102
|
-
return
|
|
1155
|
+
function on(e, n = "Page") {
|
|
1156
|
+
return ye({
|
|
1103
1157
|
title: k(() => e.value ? "Loading..." : n),
|
|
1104
1158
|
icon: k(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
|
|
1105
1159
|
closable: k(() => !e.value)
|
|
1106
1160
|
});
|
|
1107
1161
|
}
|
|
1108
|
-
function
|
|
1109
|
-
return
|
|
1162
|
+
function rn(e, n = "Page", o = "mdi-page") {
|
|
1163
|
+
return ye({
|
|
1110
1164
|
title: k(() => e.value > 0 ? `${n} (${e.value})` : n),
|
|
1111
1165
|
icon: k(() => e.value > 0 ? "mdi-bell-badge" : o)
|
|
1112
1166
|
});
|
|
@@ -1118,46 +1172,46 @@ function an(e, n = "Page") {
|
|
|
1118
1172
|
error: { suffix: " - Error", icon: "mdi-alert" },
|
|
1119
1173
|
success: { suffix: " - Success", icon: "mdi-check-circle" }
|
|
1120
1174
|
};
|
|
1121
|
-
return
|
|
1175
|
+
return ye({
|
|
1122
1176
|
title: k(() => n + o[e.value].suffix),
|
|
1123
1177
|
icon: k(() => o[e.value].icon),
|
|
1124
1178
|
closable: k(() => e.value !== "loading")
|
|
1125
1179
|
});
|
|
1126
1180
|
}
|
|
1127
1181
|
let Le = !1;
|
|
1128
|
-
const
|
|
1182
|
+
const ln = {
|
|
1129
1183
|
install(e, n) {
|
|
1130
1184
|
if (Le) return;
|
|
1131
1185
|
Le = !0;
|
|
1132
1186
|
const {
|
|
1133
1187
|
initTheme: o = !0,
|
|
1134
1188
|
themeOptions: l,
|
|
1135
|
-
componentName:
|
|
1136
|
-
tabsComponentName:
|
|
1189
|
+
componentName: a = Me.name || "RouterTab",
|
|
1190
|
+
tabsComponentName: g = be.name || "RouterTabs"
|
|
1137
1191
|
} = n ?? {};
|
|
1138
|
-
o &&
|
|
1192
|
+
o && Qt(l ?? {}), e.component(a, Me), e.component(g, be), g.toLowerCase() !== "router-tabs" && e.component("router-tabs", be), Object.defineProperty(e.config.globalProperties, "$tabs", {
|
|
1139
1193
|
configurable: !0,
|
|
1140
1194
|
enumerable: !1,
|
|
1141
1195
|
get() {
|
|
1142
|
-
return e._context.provides[
|
|
1196
|
+
return e._context.provides[te];
|
|
1143
1197
|
},
|
|
1144
1198
|
set(T) {
|
|
1145
|
-
T && e.provide(
|
|
1199
|
+
T && e.provide(te, T);
|
|
1146
1200
|
}
|
|
1147
1201
|
});
|
|
1148
1202
|
}
|
|
1149
1203
|
};
|
|
1150
1204
|
export {
|
|
1151
1205
|
Me as RouterTab,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1206
|
+
be as RouterTabs,
|
|
1207
|
+
ln as default,
|
|
1208
|
+
Qt as initRouterTabsTheme,
|
|
1209
|
+
te as routerTabsKey,
|
|
1210
|
+
nn as setRouterTabsPrimary,
|
|
1211
|
+
tn as setRouterTabsTheme,
|
|
1212
|
+
on as useLoadingTab,
|
|
1213
|
+
rn as useNotificationTab,
|
|
1214
|
+
ye as useReactiveTab,
|
|
1161
1215
|
De as useRouterTabs,
|
|
1162
1216
|
Ve as useRouterTabsPersistence,
|
|
1163
1217
|
an as useStatusTab
|