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