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