vue3-router-tab 1.4.1 → 1.4.2
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 +288 -296
- package/dist/vue3-router-tab.umd.cjs +1 -1
- package/lib/components/RouterTab.vue +1 -15
- 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 ie, ref as x, shallowRef 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 De, getCurrentInstance as Ye, onMounted as Fe, onBeforeMount as Ct, defineComponent as Ce, provide as Kt, onErrorCaptured as Et, onBeforeUnmount as $t, h as Pt, resolveComponent as At, createElementBlock as B, openBlock as $, createElementVNode as V, withDirectives as St, normalizeClass as q, renderSlot as me, createVNode as It, TransitionGroup as xt, mergeProps as he, withCtx as ye, Fragment as Te, renderList as Me, withModifiers as we, createCommentVNode as te, toDisplayString as Le, createBlock as X, normalizeProps as Bt, KeepAlive as Dt, resolveDynamicComponent as Oe, 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,
|
|
@@ -11,13 +11,13 @@ function zt(e = {}) {
|
|
|
11
11
|
defaultRoute: e.defaultRoute ?? "/"
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function _(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 Nt = {
|
|
21
21
|
path: (e) => e.path,
|
|
22
22
|
fullpath: (e) => e.fullPath,
|
|
23
23
|
fullname: (e) => e.fullPath,
|
|
@@ -30,7 +30,7 @@ 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;
|
|
@@ -43,12 +43,12 @@ 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 He(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
50
|
function ne(e, r, o) {
|
|
51
|
-
const s =
|
|
51
|
+
const s = He(e);
|
|
52
52
|
return {
|
|
53
53
|
id: z(e),
|
|
54
54
|
to: e.fullPath,
|
|
@@ -62,12 +62,12 @@ function ne(e, r, o) {
|
|
|
62
62
|
...r
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
if (!e.find((
|
|
65
|
+
function Re(e, r, o, s) {
|
|
66
|
+
if (!e.find((p) => p.id === r.id)) {
|
|
67
67
|
if (o === "next" && s) {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
e.splice(
|
|
68
|
+
const p = e.findIndex((w) => w.id === s);
|
|
69
|
+
if (p !== -1) {
|
|
70
|
+
e.splice(p + 1, 0, r);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -76,18 +76,18 @@ function we(e, r, o, s) {
|
|
|
76
76
|
}
|
|
77
77
|
function oe(e, r, o, s) {
|
|
78
78
|
if (!r || r <= 0) return;
|
|
79
|
-
const a = e.filter((
|
|
79
|
+
const a = e.filter((p) => p.alive);
|
|
80
80
|
for (; a.length > r; ) {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const i = e[
|
|
86
|
-
s.delete(
|
|
81
|
+
const p = a.shift();
|
|
82
|
+
if (!p || p.id === o) continue;
|
|
83
|
+
const w = e.findIndex((i) => i.id === p.id);
|
|
84
|
+
if (w > -1) {
|
|
85
|
+
const i = e[w], m = `${i.id}::${i.renderKey ?? 0}`;
|
|
86
|
+
s.delete(m), 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,15 +98,15 @@ 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 = ie([]), a = x(null), p = kt(), w = x(null), i = ie(/* @__PURE__ */ new Set()), m = K(() => Array.from(i));
|
|
107
|
+
let v = !1;
|
|
108
108
|
function T(u) {
|
|
109
|
-
const d = typeof u.matched == "object" ? u :
|
|
109
|
+
const d = typeof u.matched == "object" ? u : _(e, u);
|
|
110
110
|
return {
|
|
111
111
|
key: z(d),
|
|
112
112
|
fullPath: d.fullPath,
|
|
@@ -118,49 +118,49 @@ function Wt(e, r = {}) {
|
|
|
118
118
|
function I(u) {
|
|
119
119
|
const d = z(u);
|
|
120
120
|
let c = s.find((y) => y.id === d);
|
|
121
|
-
const
|
|
121
|
+
const h = Ke(u, o.keepAlive);
|
|
122
122
|
if (c) {
|
|
123
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
124
|
const y = `${d}::${c.renderKey}`;
|
|
125
|
-
return
|
|
125
|
+
return h ? 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, He(u)), c;
|
|
126
126
|
}
|
|
127
127
|
if (c = ne(u, {}, o.keepAlive), c.alive) {
|
|
128
128
|
const y = `${d}::${c.renderKey ?? 0}`;
|
|
129
129
|
i.add(y);
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return Re(s, c, o.appendPosition, a.value), oe(s, o.maxAlive, a.value, i), c;
|
|
132
132
|
}
|
|
133
133
|
async function A(u, d = !1, c = "sameTab") {
|
|
134
|
-
const
|
|
135
|
-
c === "sameTab" && (c = E), c && await j(y, !0), await e[d ? "replace" : "push"](
|
|
134
|
+
const h = _(e, u), y = z(h), E = a.value === y;
|
|
135
|
+
c === "sameTab" && (c = E), c && await j(y, !0), await e[d ? "replace" : "push"](h), E && await F();
|
|
136
136
|
}
|
|
137
137
|
function L(u) {
|
|
138
138
|
const d = s.findIndex((C) => C.id === u);
|
|
139
139
|
if (d === -1) return o.defaultRoute;
|
|
140
|
-
const c = s[d + 1],
|
|
140
|
+
const c = s[d + 1], h = s[d - 1], y = s.find((C) => C.id !== u), E = c || h || y;
|
|
141
141
|
return E ? E.to : o.defaultRoute;
|
|
142
142
|
}
|
|
143
143
|
async function O(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
|
|
148
|
-
await Y(u, { force: d.force }), d.redirect !== null &&
|
|
147
|
+
const h = a.value === u && d.redirect !== null, y = h ? d.redirect ?? L(u) : null;
|
|
148
|
+
await Y(u, { force: d.force }), d.redirect !== null && h && y && await e.replace(y);
|
|
149
149
|
}
|
|
150
150
|
async function Y(u, d = {}) {
|
|
151
151
|
const c = s.findIndex((E) => E.id === u);
|
|
152
152
|
if (c === -1) return;
|
|
153
|
-
const
|
|
154
|
-
i.delete(y),
|
|
153
|
+
const h = s[c], y = `${u}::${h.renderKey ?? 0}`;
|
|
154
|
+
i.delete(y), h.alive = !1, s.splice(c, 1), w.value === u && (w.value = null), a.value === u && (a.value = null, p.value = void 0);
|
|
155
155
|
}
|
|
156
156
|
async function j(u = a.value ?? void 0, d = !1) {
|
|
157
157
|
if (!u) return;
|
|
158
158
|
const c = s.find((C) => C.id === u);
|
|
159
159
|
if (!c) return;
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const h = o.keepAlive && c.alive, y = `${u}::${c.renderKey ?? 0}`;
|
|
161
|
+
h && (i.delete(y), c.alive = !1, await M()), c.renderKey = (c.renderKey ?? 0) + 1;
|
|
162
162
|
const E = `${u}::${c.renderKey}`;
|
|
163
|
-
|
|
163
|
+
h && (i.add(E), c.alive = !0), w.value = u, await M(), d || await M(), w.value = null;
|
|
164
164
|
}
|
|
165
165
|
async function se(u = !1) {
|
|
166
166
|
for (const d of s)
|
|
@@ -169,11 +169,11 @@ function Wt(e, r = {}) {
|
|
|
169
169
|
function ue(u, d) {
|
|
170
170
|
const c = s.find((y) => y.id === u);
|
|
171
171
|
if (!c) return;
|
|
172
|
-
const
|
|
173
|
-
d ? (i.add(
|
|
172
|
+
const h = `${u}::${c.renderKey ?? 0}`;
|
|
173
|
+
d ? (i.add(h), c.alive = !0, oe(s, o.maxAlive, a.value, i)) : (i.delete(h), c.alive = !1);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
const d = s.find((
|
|
175
|
+
function R(u) {
|
|
176
|
+
const d = s.find((h) => h.id === u);
|
|
177
177
|
if (!d) return;
|
|
178
178
|
const c = `${u}::${d.renderKey ?? 0}`;
|
|
179
179
|
i.delete(c), d.alive = !1, d.renderKey = (d.renderKey ?? 0) + 1;
|
|
@@ -184,13 +184,13 @@ function Wt(e, r = {}) {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
function U() {
|
|
187
|
-
return
|
|
187
|
+
return m.value.slice();
|
|
188
188
|
}
|
|
189
189
|
async function D(u = o.defaultRoute) {
|
|
190
|
-
s.splice(0, s.length), a.value = null,
|
|
190
|
+
s.splice(0, s.length), a.value = null, p.value = void 0;
|
|
191
191
|
for (const d of o.initialTabs) {
|
|
192
|
-
const c =
|
|
193
|
-
s.push(
|
|
192
|
+
const c = _(e, d.to), h = ne(c, d, o.keepAlive);
|
|
193
|
+
s.push(h);
|
|
194
194
|
}
|
|
195
195
|
await e.replace(u);
|
|
196
196
|
}
|
|
@@ -199,65 +199,65 @@ function Wt(e, r = {}) {
|
|
|
199
199
|
u && await j(u, !0);
|
|
200
200
|
}
|
|
201
201
|
function H(u) {
|
|
202
|
-
return typeof u.matched == "object" ? z(u) : z(
|
|
202
|
+
return typeof u.matched == "object" ? z(u) : z(_(e, u));
|
|
203
203
|
}
|
|
204
204
|
function k() {
|
|
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
211
|
async function ce(u) {
|
|
212
|
-
|
|
212
|
+
v = !0, s.splice(0, s.length), a.value = null, p.value = void 0;
|
|
213
213
|
const d = u?.tabs ?? [];
|
|
214
|
-
for (const
|
|
214
|
+
for (const h of d)
|
|
215
215
|
try {
|
|
216
|
-
const y =
|
|
217
|
-
|
|
216
|
+
const y = _(e, h.to), E = Yt(h), C = ne(y, E, o.keepAlive);
|
|
217
|
+
Re(s, C, "last", null);
|
|
218
218
|
} catch (y) {
|
|
219
|
-
console.warn("[RouterTabs] Failed to restore tab",
|
|
219
|
+
console.warn("[RouterTabs] Failed to restore tab", h, y);
|
|
220
220
|
}
|
|
221
|
-
|
|
221
|
+
v = !1;
|
|
222
222
|
const c = u?.active ?? d[d.length - 1]?.to ?? o.defaultRoute;
|
|
223
223
|
if (c)
|
|
224
224
|
try {
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
225
|
+
const h = _(e, c), y = e.currentRoute.value;
|
|
226
|
+
if (h.fullPath === y.fullPath) {
|
|
227
227
|
const E = I(y);
|
|
228
|
-
a.value = E.id,
|
|
228
|
+
a.value = E.id, p.value = E, oe(s, o.maxAlive, a.value, i);
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
-
await e.replace(
|
|
232
|
-
} catch (
|
|
233
|
-
console.warn("[RouterTabs] Failed to navigate to restored route", c,
|
|
231
|
+
await e.replace(h);
|
|
232
|
+
} catch (h) {
|
|
233
|
+
console.warn("[RouterTabs] Failed to navigate to restored route", c, h);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
return S(
|
|
237
237
|
() => e.currentRoute.value,
|
|
238
238
|
(u) => {
|
|
239
|
-
if (
|
|
239
|
+
if (v) return;
|
|
240
240
|
const d = I(u);
|
|
241
|
-
a.value = d.id,
|
|
241
|
+
a.value = d.id, p.value = d, oe(s, o.maxAlive, a.value, i);
|
|
242
242
|
},
|
|
243
243
|
{ immediate: !0 }
|
|
244
244
|
), o.initialTabs.length && o.initialTabs.forEach((u) => {
|
|
245
|
-
const d =
|
|
246
|
-
|
|
245
|
+
const d = _(e, u.to), c = ne(d, u, o.keepAlive);
|
|
246
|
+
Re(s, c, "last", null);
|
|
247
247
|
}), {
|
|
248
248
|
options: o,
|
|
249
249
|
tabs: s,
|
|
250
250
|
activeId: a,
|
|
251
|
-
current:
|
|
252
|
-
includeKeys:
|
|
253
|
-
refreshingKey:
|
|
251
|
+
current: p,
|
|
252
|
+
includeKeys: m,
|
|
253
|
+
refreshingKey: w,
|
|
254
254
|
openTab: A,
|
|
255
255
|
closeTab: O,
|
|
256
256
|
removeTab: Y,
|
|
257
257
|
refreshTab: j,
|
|
258
258
|
refreshAll: se,
|
|
259
259
|
setTabAlive: ue,
|
|
260
|
-
evictCache:
|
|
260
|
+
evictCache: R,
|
|
261
261
|
clearCache: Z,
|
|
262
262
|
getCacheKeys: U,
|
|
263
263
|
reset: D,
|
|
@@ -269,23 +269,23 @@ function Wt(e, r = {}) {
|
|
|
269
269
|
ensureTab: I
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function je(e) {
|
|
273
273
|
return e ? typeof e == "string" ? { name: e } : e : {};
|
|
274
274
|
}
|
|
275
275
|
const le = Symbol("RouterTabsContext"), ae = "router-tabs:snapshot";
|
|
276
|
-
function
|
|
277
|
-
const { optional: r = !1 } = e, o =
|
|
276
|
+
function Ue(e = {}) {
|
|
277
|
+
const { optional: r = !1 } = e, o = De(le, null);
|
|
278
278
|
if (o) return o;
|
|
279
|
-
const s =
|
|
279
|
+
const s = De("$tabs", null);
|
|
280
280
|
if (s) return s;
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
281
|
+
const p = Ye()?.appContext.config.globalProperties.$tabs;
|
|
282
|
+
if (p) return p;
|
|
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)
|
|
@@ -293,27 +293,27 @@ function Gt(e) {
|
|
|
293
293
|
return decodeURIComponent(s.slice(r.length));
|
|
294
294
|
return null;
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function Ve(e, r, o) {
|
|
297
297
|
if (typeof document > "u") return;
|
|
298
298
|
const {
|
|
299
299
|
expiresInDays: s = 7,
|
|
300
300
|
path: a = "/",
|
|
301
|
-
domain:
|
|
302
|
-
secure:
|
|
301
|
+
domain: p,
|
|
302
|
+
secure: w,
|
|
303
303
|
sameSite: i = "lax"
|
|
304
|
-
} = o,
|
|
304
|
+
} = o, m = [`${encodeURIComponent(e)}=${encodeURIComponent(r)}`];
|
|
305
305
|
if (s !== 1 / 0) {
|
|
306
|
-
const
|
|
307
|
-
|
|
306
|
+
const v = new Date(Date.now() + s * Ht).toUTCString();
|
|
307
|
+
m.push(`Expires=${v}`);
|
|
308
308
|
}
|
|
309
|
-
a &&
|
|
309
|
+
a && m.push(`Path=${a}`), p && m.push(`Domain=${p}`), w && m.push("Secure"), i && m.push(`SameSite=${i.charAt(0).toUpperCase()}${i.slice(1)}`), document.cookie = m.join("; ");
|
|
310
310
|
}
|
|
311
311
|
function _e(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);
|
|
@@ -321,16 +321,16 @@ const qt = (e) => JSON.stringify(e ?? null), Xt = (e) => {
|
|
|
321
321
|
return null;
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
|
-
function
|
|
324
|
+
function We(e = {}) {
|
|
325
325
|
const {
|
|
326
326
|
cookieKey: r = ae,
|
|
327
|
-
serialize: o =
|
|
328
|
-
deserialize: s =
|
|
329
|
-
} = e, a =
|
|
330
|
-
const
|
|
331
|
-
|
|
327
|
+
serialize: o = Jt,
|
|
328
|
+
deserialize: s = Gt
|
|
329
|
+
} = e, a = Ue({ optional: !0 }), p = x(!0), w = (i, m = "hook") => {
|
|
330
|
+
const v = async () => {
|
|
331
|
+
p.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
336
|
await M();
|
|
@@ -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 ?
|
|
345
|
+
I.tabs.length ? Ve(r, o(I), e) : _e(r, e);
|
|
346
346
|
} finally {
|
|
347
|
-
|
|
347
|
+
p.value = !1;
|
|
348
348
|
}
|
|
349
349
|
};
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
m === "immediate" ? v() : Ct(() => {
|
|
351
|
+
v();
|
|
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 (p.value) return;
|
|
367
367
|
const T = i.snapshot();
|
|
368
|
-
T.tabs.length ?
|
|
368
|
+
T.tabs.length ? Ve(r, o(T), e) : _e(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) : Fe(() => {
|
|
374
|
+
const i = Ue({ optional: !0 });
|
|
375
|
+
i && w(i, "immediate");
|
|
376
|
+
}), { hydrating: p };
|
|
377
377
|
}
|
|
378
|
-
const
|
|
378
|
+
const qt = Ce({
|
|
379
379
|
name: "RouterTab",
|
|
380
|
-
components: { RouterView:
|
|
380
|
+
components: { RouterView: Vt },
|
|
381
381
|
props: {
|
|
382
382
|
tabs: {
|
|
383
383
|
type: Array,
|
|
@@ -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 = Ye();
|
|
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,9 +444,9 @@ const Qt = Ce({
|
|
|
444
444
|
appendPosition: e.append,
|
|
445
445
|
defaultRoute: e.defaultPage
|
|
446
446
|
});
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
447
|
+
Kt(le, a), o.appContext.config.globalProperties.$tabs = a;
|
|
448
|
+
const p = K(() => !!o?.slots?.default), w = K(() => !!o?.slots?.start), i = K(() => !!o?.slots?.end), m = x(0), v = K(() => {
|
|
449
|
+
m.value;
|
|
450
450
|
const t = {};
|
|
451
451
|
return a.tabs.forEach((n) => {
|
|
452
452
|
const l = typeof n.title == "string" ? n.title : String(n.title || fe(n));
|
|
@@ -454,7 +454,7 @@ const Qt = Ce({
|
|
|
454
454
|
}), t;
|
|
455
455
|
});
|
|
456
456
|
function T() {
|
|
457
|
-
|
|
457
|
+
m.value++;
|
|
458
458
|
}
|
|
459
459
|
const I = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
|
|
460
460
|
function L(t, n) {
|
|
@@ -476,8 +476,8 @@ const Qt = Ce({
|
|
|
476
476
|
},
|
|
477
477
|
(f) => {
|
|
478
478
|
if (f != null) {
|
|
479
|
-
const
|
|
480
|
-
l.title =
|
|
479
|
+
const N = String(f);
|
|
480
|
+
l.title = N, T();
|
|
481
481
|
}
|
|
482
482
|
},
|
|
483
483
|
{ immediate: !0 }
|
|
@@ -560,15 +560,15 @@ const Qt = Ce({
|
|
|
560
560
|
console.error(`[RouterTab] Error handling component ref for ${n}:`, l), O(n);
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
|
-
|
|
563
|
+
Et((t, n, l) => (console.error("[RouterTab] Error captured from component:", t, l), !1));
|
|
564
564
|
let j = 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 || ae : t.cookieKey || (t.cookieKey = ae), j =
|
|
569
|
+
e.cookieKey !== null ? t.cookieKey = e.cookieKey || ae : t.cookieKey || (t.cookieKey = ae), j = We(t).hydrating;
|
|
570
570
|
}
|
|
571
|
-
const se = K(() =>
|
|
571
|
+
const se = K(() => je(e.tabTransition)), ue = K(() => je(e.pageTransition)), R = ie({
|
|
572
572
|
visible: !1,
|
|
573
573
|
target: null,
|
|
574
574
|
position: { x: 0, y: 0 }
|
|
@@ -596,7 +596,7 @@ const Qt = Ce({
|
|
|
596
596
|
const n = u(t.id);
|
|
597
597
|
return n > -1 ? a.tabs.slice(n + 1) : [];
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function h(t) {
|
|
600
600
|
return a.tabs.filter((n) => n.id !== t.id);
|
|
601
601
|
}
|
|
602
602
|
async function y(t, n) {
|
|
@@ -644,52 +644,52 @@ const Qt = Ce({
|
|
|
644
644
|
closeOthers: {
|
|
645
645
|
label: "Close Others",
|
|
646
646
|
handler: async ({ target: t }) => {
|
|
647
|
-
await y(
|
|
647
|
+
await y(h(t), t);
|
|
648
648
|
},
|
|
649
|
-
enable: ({ target: t }) =>
|
|
649
|
+
enable: ({ target: t }) => h(t).some((n) => n.closable !== !1)
|
|
650
650
|
}
|
|
651
651
|
};
|
|
652
652
|
function C() {
|
|
653
|
-
|
|
653
|
+
R.visible = !1, R.target = null, D.value = -1, U.value = [];
|
|
654
654
|
}
|
|
655
|
-
function
|
|
656
|
-
e.contextmenu && (
|
|
657
|
-
|
|
658
|
-
|
|
655
|
+
function Qe(t, n) {
|
|
656
|
+
e.contextmenu && (R.target = t, R.position.x = n.clientX, R.position.y = n.clientY, M(() => {
|
|
657
|
+
R.visible = !0, document.addEventListener("click", C, { once: !0 }), M(() => {
|
|
658
|
+
et();
|
|
659
659
|
});
|
|
660
660
|
}));
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function Ze(t, n) {
|
|
663
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;
|
|
664
664
|
if (!(typeof f == "function" ? f(n) : f !== !1)) return null;
|
|
665
|
-
const ve = l.enable ?? b?.enable ?? !0,
|
|
666
|
-
if (!
|
|
667
|
-
const
|
|
668
|
-
await Promise.resolve(
|
|
665
|
+
const ve = l.enable ?? b?.enable ?? !0, wt = typeof ve == "function" ? ve(n) : ve !== !1, Be = l.handler ?? b?.handler;
|
|
666
|
+
if (!Be) return null;
|
|
667
|
+
const Rt = async () => {
|
|
668
|
+
await Promise.resolve(Be(n));
|
|
669
669
|
};
|
|
670
670
|
return {
|
|
671
671
|
id: String(l.id),
|
|
672
672
|
label: g,
|
|
673
|
-
disabled: !
|
|
674
|
-
action:
|
|
673
|
+
disabled: !wt,
|
|
674
|
+
action: Rt
|
|
675
675
|
};
|
|
676
676
|
}
|
|
677
677
|
const W = K(() => {
|
|
678
|
-
if (!
|
|
679
|
-
const t = Array.isArray(e.contextmenu) ? e.contextmenu : ce, n = { target:
|
|
680
|
-
return t.map((l) =>
|
|
678
|
+
if (!R.visible || !R.target || e.contextmenu === !1) return [];
|
|
679
|
+
const t = Array.isArray(e.contextmenu) ? e.contextmenu : ce, n = { target: R.target, controller: a };
|
|
680
|
+
return t.map((l) => Ze(l, n)).filter((l) => !!l);
|
|
681
681
|
});
|
|
682
|
-
function
|
|
682
|
+
function et() {
|
|
683
683
|
const t = Z.value;
|
|
684
684
|
if (!t) return;
|
|
685
685
|
const n = 8, { innerWidth: l, innerHeight: b } = window, g = t.getBoundingClientRect();
|
|
686
|
-
let f =
|
|
687
|
-
g.right > l - n && (f = Math.max(n, l - g.width - n)), g.bottom > b - n && (
|
|
686
|
+
let f = R.position.x, N = R.position.y;
|
|
687
|
+
g.right > l - n && (f = Math.max(n, l - g.width - n)), g.bottom > b - n && (N = Math.max(n, b - g.height - n)), (f !== R.position.x || N !== R.position.y) && (R.position.x = f, R.position.y = N);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function tt(t, n) {
|
|
690
690
|
U.value[n] = t ?? null;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function nt(t) {
|
|
693
693
|
if (t < 0) return;
|
|
694
694
|
U.value[t]?.focus({ preventScroll: !0 });
|
|
695
695
|
}
|
|
@@ -702,14 +702,14 @@ const Qt = Ce({
|
|
|
702
702
|
return -1;
|
|
703
703
|
}
|
|
704
704
|
function J(t) {
|
|
705
|
-
D.value = t, !(t < 0) && M(() =>
|
|
705
|
+
D.value = t, !(t < 0) && M(() => nt(t));
|
|
706
706
|
}
|
|
707
707
|
function Ae(t) {
|
|
708
708
|
const n = ee(D.value, t);
|
|
709
709
|
n !== -1 && J(n);
|
|
710
710
|
}
|
|
711
|
-
function
|
|
712
|
-
if (!
|
|
711
|
+
function ot(t) {
|
|
712
|
+
if (!R.visible) return;
|
|
713
713
|
const n = t.key, l = W.value;
|
|
714
714
|
if (!l.length) return;
|
|
715
715
|
if (n === "Tab") {
|
|
@@ -764,36 +764,36 @@ const Qt = Ce({
|
|
|
764
764
|
function fe(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
|
-
function
|
|
768
|
-
return
|
|
767
|
+
function rt(t) {
|
|
768
|
+
return v.value[t.id] || fe(t);
|
|
769
769
|
}
|
|
770
770
|
function Ie(t, n) {
|
|
771
771
|
return Ce({
|
|
772
772
|
name: n,
|
|
773
773
|
setup(l, { attrs: b, slots: g }) {
|
|
774
|
-
return () =>
|
|
774
|
+
return () => Pt(t, b, g);
|
|
775
775
|
}
|
|
776
776
|
});
|
|
777
777
|
}
|
|
778
778
|
const G = /* @__PURE__ */ new Map(), de = x(0);
|
|
779
|
-
function
|
|
779
|
+
function at(t, n, l) {
|
|
780
780
|
G.has(l) || (G.set(l, n), de.value++), t && Y(t, l);
|
|
781
781
|
}
|
|
782
|
-
function
|
|
782
|
+
function it(t, n) {
|
|
783
783
|
return t && ((!t.name || t.name !== n) && (t.name = n), t);
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function lt(t, n) {
|
|
786
786
|
if (!t) return t;
|
|
787
787
|
const l = G.get(n);
|
|
788
788
|
if (l) return l;
|
|
789
789
|
const b = Ie(t, n);
|
|
790
790
|
return G.set(n, b), de.value++, b;
|
|
791
791
|
}
|
|
792
|
-
function
|
|
792
|
+
function st(t) {
|
|
793
793
|
const n = a.getRouteKey(t), l = s.currentRoute.value, b = a.getRouteKey(l);
|
|
794
794
|
return n === b;
|
|
795
795
|
}
|
|
796
|
-
function
|
|
796
|
+
function ut(t) {
|
|
797
797
|
const n = a.getRouteKey(t), l = a.tabs.find((f) => f.id === n);
|
|
798
798
|
if (!l)
|
|
799
799
|
return console.warn("[RouterTab] Tab not found for route:", n), `${n}::0`;
|
|
@@ -807,16 +807,13 @@ const Qt = Ce({
|
|
|
807
807
|
isIncluded: pe.value.includes(g)
|
|
808
808
|
}), g;
|
|
809
809
|
}
|
|
810
|
-
function ct(t) {
|
|
811
|
-
return `${xe(t)}::refresh`;
|
|
812
|
-
}
|
|
813
810
|
function be(t) {
|
|
814
811
|
return !(t.closable === !1 || a.options.keepLastTab && a.tabs.length <= 1);
|
|
815
812
|
}
|
|
816
|
-
async function
|
|
813
|
+
async function ct(t) {
|
|
817
814
|
await a.closeTab(t.id);
|
|
818
815
|
}
|
|
819
|
-
function
|
|
816
|
+
function ft(t, n) {
|
|
820
817
|
n ? H.set(t, n) : H.delete(t);
|
|
821
818
|
}
|
|
822
819
|
function ge(t) {
|
|
@@ -832,14 +829,14 @@ const Qt = Ce({
|
|
|
832
829
|
}
|
|
833
830
|
});
|
|
834
831
|
}
|
|
835
|
-
function
|
|
832
|
+
function dt(t) {
|
|
836
833
|
if (t.href && typeof window < "u") {
|
|
837
834
|
t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
|
|
838
835
|
return;
|
|
839
836
|
}
|
|
840
837
|
a.activeId.value !== t.id && (a.openTab(t.to, !1), ge(t.id));
|
|
841
838
|
}
|
|
842
|
-
function
|
|
839
|
+
function bt(t) {
|
|
843
840
|
return [
|
|
844
841
|
"router-tab__item",
|
|
845
842
|
{
|
|
@@ -851,30 +848,27 @@ const Qt = Ce({
|
|
|
851
848
|
t.tabClass
|
|
852
849
|
];
|
|
853
850
|
}
|
|
854
|
-
function
|
|
855
|
-
return a.refreshingKey.value === a.getRouteKey(t);
|
|
856
|
-
}
|
|
857
|
-
function vt(t) {
|
|
851
|
+
function gt(t) {
|
|
858
852
|
const n = a.getRouteKey(t), l = a.tabs.find((b) => b.id === n);
|
|
859
853
|
return l ? l.alive : !1;
|
|
860
854
|
}
|
|
861
|
-
function
|
|
855
|
+
function pt(t) {
|
|
862
856
|
const n = a.getRouteKey(t);
|
|
863
857
|
return !!a.tabs.find((b) => b.id === n);
|
|
864
858
|
}
|
|
865
|
-
function
|
|
859
|
+
function vt(t, n, l) {
|
|
866
860
|
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 }));
|
|
867
861
|
}
|
|
868
|
-
function
|
|
862
|
+
function mt(t, n) {
|
|
869
863
|
!e.sortable || !k.dragging || (n.preventDefault(), n.dataTransfer && (n.dataTransfer.dropEffect = "move"));
|
|
870
864
|
}
|
|
871
|
-
function
|
|
865
|
+
function ht(t) {
|
|
872
866
|
!e.sortable || !k.dragging || (k.dropIndex = t);
|
|
873
867
|
}
|
|
874
|
-
function
|
|
868
|
+
function yt() {
|
|
875
869
|
!e.sortable || k.dragging;
|
|
876
870
|
}
|
|
877
|
-
function
|
|
871
|
+
function Tt(t, n) {
|
|
878
872
|
if (!(!e.sortable || !k.dragging)) {
|
|
879
873
|
if (n.preventDefault(), k.dragIndex !== -1 && k.dragIndex !== t) {
|
|
880
874
|
const l = a.tabs.splice(k.dragIndex, 1)[0];
|
|
@@ -884,15 +878,15 @@ const Qt = Ce({
|
|
|
884
878
|
toIndex: t
|
|
885
879
|
});
|
|
886
880
|
}
|
|
887
|
-
|
|
881
|
+
xe();
|
|
888
882
|
}
|
|
889
883
|
}
|
|
890
|
-
function
|
|
884
|
+
function xe() {
|
|
891
885
|
k.dragging = !1, k.dragIndex = -1, k.dropIndex = -1, k.dragTab = null;
|
|
892
886
|
}
|
|
893
|
-
|
|
887
|
+
Fe(() => {
|
|
894
888
|
document.addEventListener("keydown", C);
|
|
895
|
-
}),
|
|
889
|
+
}), $t(() => {
|
|
896
890
|
document.removeEventListener("keydown", C), o.appContext.config.globalProperties.$tabs = null, A.forEach((t) => {
|
|
897
891
|
t.forEach((n) => {
|
|
898
892
|
try {
|
|
@@ -928,17 +922,17 @@ const Qt = Ce({
|
|
|
928
922
|
), S(
|
|
929
923
|
() => W.value.length,
|
|
930
924
|
(t) => {
|
|
931
|
-
|
|
925
|
+
R.visible && t === 0 && C();
|
|
932
926
|
},
|
|
933
927
|
{ flush: "post" }
|
|
934
928
|
// Run after component updates to prevent blocking render
|
|
935
929
|
), S(W, (t) => {
|
|
936
|
-
if (!
|
|
930
|
+
if (!R.visible) return;
|
|
937
931
|
U.value = new Array(t.length).fill(null);
|
|
938
932
|
const n = ee(-1, 1, t);
|
|
939
933
|
J(n);
|
|
940
934
|
}, { flush: "post" }), S(
|
|
941
|
-
() =>
|
|
935
|
+
() => R.visible,
|
|
942
936
|
(t) => {
|
|
943
937
|
t || (D.value = -1, U.value = []);
|
|
944
938
|
}
|
|
@@ -951,96 +945,94 @@ const Qt = Ce({
|
|
|
951
945
|
persistenceHydrating: j,
|
|
952
946
|
componentCache: G,
|
|
953
947
|
componentCacheTrigger: de,
|
|
954
|
-
cacheCurrentComponent:
|
|
948
|
+
cacheCurrentComponent: at,
|
|
955
949
|
tabTransitionProps: se,
|
|
956
950
|
pageTransitionProps: ue,
|
|
957
|
-
buildTabClass:
|
|
958
|
-
activate:
|
|
959
|
-
close:
|
|
960
|
-
context:
|
|
951
|
+
buildTabClass: bt,
|
|
952
|
+
activate: dt,
|
|
953
|
+
close: ct,
|
|
954
|
+
context: R,
|
|
961
955
|
menuItems: W,
|
|
962
956
|
handleMenuAction: Se,
|
|
963
|
-
showContextMenu:
|
|
957
|
+
showContextMenu: Qe,
|
|
964
958
|
hideContextMenu: C,
|
|
965
959
|
getTabTitle: fe,
|
|
966
960
|
isClosable: be,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
hasStartSlot: R,
|
|
961
|
+
isTabCached: gt,
|
|
962
|
+
isTabReady: pt,
|
|
963
|
+
hasCustomSlot: p,
|
|
964
|
+
hasStartSlot: w,
|
|
972
965
|
hasEndSlot: i,
|
|
973
|
-
onDragStart:
|
|
974
|
-
onDragOver:
|
|
975
|
-
onDragEnter:
|
|
976
|
-
onDragLeave:
|
|
977
|
-
onDrop:
|
|
978
|
-
onDragEnd:
|
|
966
|
+
onDragStart: vt,
|
|
967
|
+
onDragOver: mt,
|
|
968
|
+
onDragEnter: ht,
|
|
969
|
+
onDragLeave: yt,
|
|
970
|
+
onDrop: Tt,
|
|
971
|
+
onDragEnd: xe,
|
|
979
972
|
setupComponentWatching: L,
|
|
980
973
|
cleanupComponentWatching: O,
|
|
981
974
|
handleComponentRef: Y,
|
|
982
|
-
getReactiveTabTitle:
|
|
983
|
-
getComponentCacheKey:
|
|
984
|
-
getRefreshComponentKey: ct,
|
|
975
|
+
getReactiveTabTitle: rt,
|
|
976
|
+
getComponentCacheKey: ut,
|
|
985
977
|
createNamedComponent: Ie,
|
|
986
|
-
ensureNamedComponent:
|
|
987
|
-
getNamedComponent:
|
|
988
|
-
shouldRenderRoute:
|
|
978
|
+
ensureNamedComponent: it,
|
|
979
|
+
getNamedComponent: lt,
|
|
980
|
+
shouldRenderRoute: st,
|
|
989
981
|
triggerTabUpdate: T,
|
|
990
982
|
menuRef: Z,
|
|
991
983
|
highlightedIndex: D,
|
|
992
|
-
setMenuItemRef:
|
|
993
|
-
onMenuKeydown:
|
|
984
|
+
setMenuItemRef: tt,
|
|
985
|
+
onMenuKeydown: ot,
|
|
994
986
|
highlightMenuIndex: J,
|
|
995
987
|
scrollContainer: F,
|
|
996
|
-
setTabRef:
|
|
988
|
+
setTabRef: ft,
|
|
997
989
|
scrollTabIntoView: ge
|
|
998
990
|
};
|
|
999
991
|
}
|
|
1000
|
-
}),
|
|
992
|
+
}), Xt = (e, r) => {
|
|
1001
993
|
const o = e.__vccOpts || e;
|
|
1002
994
|
for (const [s, a] of r)
|
|
1003
995
|
o[s] = a;
|
|
1004
996
|
return o;
|
|
1005
|
-
},
|
|
997
|
+
}, Qt = { class: "router-tab" }, Zt = { class: "router-tab__header" }, en = {
|
|
1006
998
|
class: "router-tab__scroll",
|
|
1007
999
|
ref: "scrollContainer"
|
|
1008
|
-
},
|
|
1000
|
+
}, tn = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], nn = ["title"], on = ["onClick"], rn = { class: "router-tab__container" }, an = {
|
|
1009
1001
|
key: 1,
|
|
1010
1002
|
class: "router-tab__hydrating",
|
|
1011
1003
|
"aria-hidden": "true"
|
|
1012
|
-
},
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1015
|
-
return $(), B("div",
|
|
1016
|
-
V("header",
|
|
1004
|
+
}, ln = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
|
|
1005
|
+
function sn(e, r, o, s, a, p) {
|
|
1006
|
+
const w = At("RouterView");
|
|
1007
|
+
return $(), B("div", Qt, [
|
|
1008
|
+
V("header", Zt, [
|
|
1017
1009
|
V("div", {
|
|
1018
1010
|
class: q(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
|
|
1019
1011
|
}, [
|
|
1020
|
-
|
|
1012
|
+
me(e.$slots, "start")
|
|
1021
1013
|
], 2),
|
|
1022
|
-
V("div",
|
|
1023
|
-
|
|
1014
|
+
V("div", en, [
|
|
1015
|
+
It(xt, he({
|
|
1024
1016
|
tag: "ul",
|
|
1025
1017
|
class: "router-tab__nav"
|
|
1026
1018
|
}, e.tabTransitionProps), {
|
|
1027
1019
|
default: ye(() => [
|
|
1028
|
-
($(!0), B(Te, null,
|
|
1020
|
+
($(!0), B(Te, null, Me(e.tabs, (i, m) => ($(), B("li", {
|
|
1029
1021
|
key: i.id,
|
|
1030
1022
|
class: q(e.buildTabClass(i)),
|
|
1031
1023
|
"data-title": e.getTabTitle(i),
|
|
1032
1024
|
draggable: e.sortable,
|
|
1033
1025
|
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] = (...
|
|
1026
|
+
ref: (v) => e.setTabRef(i.id, v),
|
|
1027
|
+
onClick: (v) => e.activate(i),
|
|
1028
|
+
onAuxclick: we((v) => e.close(i), ["middle", "prevent"]),
|
|
1029
|
+
onContextmenu: we((v) => e.showContextMenu(i, v), ["prevent"]),
|
|
1030
|
+
onDragstart: (v) => e.onDragStart(i, m, v),
|
|
1031
|
+
onDragover: (v) => e.onDragOver(m, v),
|
|
1032
|
+
onDragenter: (v) => e.onDragEnter(m),
|
|
1033
|
+
onDragleave: r[0] || (r[0] = (...v) => e.onDragLeave && e.onDragLeave(...v)),
|
|
1034
|
+
onDrop: (v) => e.onDrop(m, v),
|
|
1035
|
+
onDragend: r[1] || (r[1] = (...v) => e.onDragEnd && e.onDragEnd(...v))
|
|
1044
1036
|
}, [
|
|
1045
1037
|
i.icon ? ($(), B("i", {
|
|
1046
1038
|
key: 0,
|
|
@@ -1049,13 +1041,13 @@ function cn(e, r, o, s, a, v) {
|
|
|
1049
1041
|
V("span", {
|
|
1050
1042
|
class: "router-tab__item-title",
|
|
1051
1043
|
title: e.getReactiveTabTitle(i)
|
|
1052
|
-
},
|
|
1044
|
+
}, Le(e.getReactiveTabTitle(i)), 9, nn),
|
|
1053
1045
|
e.isClosable(i) ? ($(), B("a", {
|
|
1054
1046
|
key: 1,
|
|
1055
1047
|
class: "router-tab__item-close",
|
|
1056
|
-
onClick:
|
|
1057
|
-
}, null, 8,
|
|
1058
|
-
], 42,
|
|
1048
|
+
onClick: we((v) => e.close(i), ["stop"])
|
|
1049
|
+
}, null, 8, on)) : te("", !0)
|
|
1050
|
+
], 42, tn))), 128))
|
|
1059
1051
|
]),
|
|
1060
1052
|
_: 1
|
|
1061
1053
|
}, 16)
|
|
@@ -1063,32 +1055,32 @@ function cn(e, r, o, s, a, v) {
|
|
|
1063
1055
|
V("div", {
|
|
1064
1056
|
class: q(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
|
|
1065
1057
|
}, [
|
|
1066
|
-
|
|
1058
|
+
me(e.$slots, "end")
|
|
1067
1059
|
], 2)
|
|
1068
1060
|
]),
|
|
1069
|
-
V("div",
|
|
1070
|
-
e.persistenceHydrating ? ($(), B("div",
|
|
1071
|
-
default: ye(({ Component: i, route:
|
|
1072
|
-
e.hasCustomSlot ?
|
|
1061
|
+
V("div", rn, [
|
|
1062
|
+
e.persistenceHydrating ? ($(), B("div", an)) : ($(), X(w, { key: 0 }, {
|
|
1063
|
+
default: ye(({ Component: i, route: m }) => [
|
|
1064
|
+
e.hasCustomSlot ? me(e.$slots, "default", Bt(he({ key: 0 }, {
|
|
1073
1065
|
Component: i,
|
|
1074
|
-
route:
|
|
1066
|
+
route: m,
|
|
1075
1067
|
controller: e.controller,
|
|
1076
|
-
pageRef: (
|
|
1068
|
+
pageRef: (v) => e.handleComponentRef(v, e.controller.getRouteKey(m))
|
|
1077
1069
|
}))) : ($(), B(Te, { key: 1 }, [
|
|
1078
|
-
e.controller.options.keepAlive ? ($(), X(
|
|
1070
|
+
e.controller.options.keepAlive ? ($(), X(Dt, {
|
|
1079
1071
|
key: 0,
|
|
1080
1072
|
include: e.includeKeys
|
|
1081
1073
|
}, [
|
|
1082
|
-
i ? ($(), X(
|
|
1083
|
-
key: e.
|
|
1084
|
-
ref: (
|
|
1074
|
+
i ? ($(), X(Oe(e.getNamedComponent(i, e.getComponentCacheKey(m))), {
|
|
1075
|
+
key: e.getComponentCacheKey(m),
|
|
1076
|
+
ref: (v) => e.handleComponentRef(v, e.controller.getRouteKey(m)),
|
|
1085
1077
|
class: "router-tab-page"
|
|
1086
1078
|
})) : te("", !0)
|
|
1087
|
-
], 1032, ["include"])) : ($(), X(
|
|
1079
|
+
], 1032, ["include"])) : ($(), X(Mt, he({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
|
|
1088
1080
|
default: ye(() => [
|
|
1089
|
-
i ? ($(), X(
|
|
1090
|
-
key: e.controller.getRouteKey(
|
|
1091
|
-
ref: (
|
|
1081
|
+
i ? ($(), X(Oe(i), {
|
|
1082
|
+
key: e.controller.getRouteKey(m),
|
|
1083
|
+
ref: (v) => e.handleComponentRef(v, e.controller.getRouteKey(m)),
|
|
1092
1084
|
class: "router-tab-page"
|
|
1093
1085
|
})) : te("", !0)
|
|
1094
1086
|
]),
|
|
@@ -1099,31 +1091,31 @@ function cn(e, r, o, s, a, v) {
|
|
|
1099
1091
|
_: 3
|
|
1100
1092
|
}))
|
|
1101
1093
|
]),
|
|
1102
|
-
|
|
1094
|
+
St(V("div", {
|
|
1103
1095
|
ref: "menuRef",
|
|
1104
1096
|
class: "router-tab__contextmenu",
|
|
1105
1097
|
role: "menu",
|
|
1106
1098
|
onKeydown: r[2] || (r[2] = (...i) => e.onMenuKeydown && e.onMenuKeydown(...i)),
|
|
1107
|
-
style:
|
|
1099
|
+
style: Lt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
|
|
1108
1100
|
}, [
|
|
1109
|
-
($(!0), B(Te, null,
|
|
1101
|
+
($(!0), B(Te, null, Me(e.menuItems, (i, m) => ($(), B("a", {
|
|
1110
1102
|
key: i.id,
|
|
1111
1103
|
role: "menuitem",
|
|
1112
|
-
class: q(["router-tab__contextmenu-item", { "is-focused":
|
|
1104
|
+
class: q(["router-tab__contextmenu-item", { "is-focused": m === e.highlightedIndex }]),
|
|
1113
1105
|
"aria-disabled": i.disabled,
|
|
1114
1106
|
disabled: i.disabled,
|
|
1115
|
-
tabindex: i.disabled ? -1 :
|
|
1107
|
+
tabindex: i.disabled ? -1 : m === e.highlightedIndex ? 0 : -1,
|
|
1116
1108
|
ref_for: !0,
|
|
1117
|
-
ref: (
|
|
1118
|
-
onMouseenter: (
|
|
1119
|
-
onClick: (
|
|
1120
|
-
},
|
|
1109
|
+
ref: (v) => e.setMenuItemRef(v, m),
|
|
1110
|
+
onMouseenter: (v) => !i.disabled && e.highlightMenuIndex(m),
|
|
1111
|
+
onClick: (v) => e.handleMenuAction(i)
|
|
1112
|
+
}, Le(i.label), 43, ln))), 128))
|
|
1121
1113
|
], 36), [
|
|
1122
|
-
[
|
|
1114
|
+
[Ot, e.context.visible && e.context.target]
|
|
1123
1115
|
])
|
|
1124
1116
|
]);
|
|
1125
1117
|
}
|
|
1126
|
-
const
|
|
1118
|
+
const Ne = /* @__PURE__ */ Xt(qt, [["render", sn]]), un = {
|
|
1127
1119
|
class: "router-tabs",
|
|
1128
1120
|
"aria-hidden": "true"
|
|
1129
1121
|
}, ke = /* @__PURE__ */ Ce({
|
|
@@ -1141,9 +1133,9 @@ const ze = /* @__PURE__ */ Zt(Qt, [["render", cn]]), fn = {
|
|
|
1141
1133
|
fallbackRoute: {}
|
|
1142
1134
|
},
|
|
1143
1135
|
setup(e) {
|
|
1144
|
-
return
|
|
1136
|
+
return We(e), (o, s) => ($(), B("span", un));
|
|
1145
1137
|
}
|
|
1146
|
-
}),
|
|
1138
|
+
}), Je = "tab-theme-style", Ge = "tab-theme-primary-color", cn = "system", qe = "(prefers-color-scheme: dark)";
|
|
1147
1139
|
let Q = null;
|
|
1148
1140
|
const P = {
|
|
1149
1141
|
primary: "#034960",
|
|
@@ -1159,7 +1151,7 @@ const P = {
|
|
|
1159
1151
|
activeButtonBackground: "#034960",
|
|
1160
1152
|
activeButtonColor: "#ffffff",
|
|
1161
1153
|
iconColor: "#475569"
|
|
1162
|
-
},
|
|
1154
|
+
}, fn = {
|
|
1163
1155
|
primary: "#38bdf8",
|
|
1164
1156
|
background: "#0f172a",
|
|
1165
1157
|
text: "#f1f5f9",
|
|
@@ -1175,7 +1167,7 @@ const P = {
|
|
|
1175
1167
|
activeButtonColor: "#0f172a",
|
|
1176
1168
|
iconColor: "#cbd5e1"
|
|
1177
1169
|
};
|
|
1178
|
-
function
|
|
1170
|
+
function dn(e) {
|
|
1179
1171
|
if (typeof window > "u") return null;
|
|
1180
1172
|
const r = window.localStorage.getItem(e);
|
|
1181
1173
|
if (!r) return null;
|
|
@@ -1189,43 +1181,43 @@ function gn(e) {
|
|
|
1189
1181
|
function $e(e) {
|
|
1190
1182
|
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
1183
|
}
|
|
1192
|
-
function
|
|
1184
|
+
function Xe(e) {
|
|
1193
1185
|
if (typeof document > "u") return;
|
|
1194
|
-
const r = document.documentElement, o = window.matchMedia(
|
|
1186
|
+
const r = document.documentElement, o = window.matchMedia(qe), s = () => {
|
|
1195
1187
|
r.dataset.theme = o.matches ? "dark" : "light";
|
|
1196
1188
|
};
|
|
1197
1189
|
Q && (o.removeEventListener("change", Q), Q = null), e === "system" ? (s(), Q = () => s(), o.addEventListener("change", Q)) : r.dataset.theme = e;
|
|
1198
1190
|
}
|
|
1199
|
-
function
|
|
1191
|
+
function bn(e = {}) {
|
|
1200
1192
|
if (typeof window > "u") return;
|
|
1201
1193
|
const {
|
|
1202
|
-
styleKey: r =
|
|
1203
|
-
primaryKey: o =
|
|
1204
|
-
defaultStyle: s =
|
|
1194
|
+
styleKey: r = Je,
|
|
1195
|
+
primaryKey: o = Ge,
|
|
1196
|
+
defaultStyle: s = cn,
|
|
1205
1197
|
defaultPrimary: a
|
|
1206
|
-
} = e,
|
|
1207
|
-
|
|
1208
|
-
const i =
|
|
1198
|
+
} = e, p = window.localStorage.getItem(r) ?? s;
|
|
1199
|
+
Xe(p);
|
|
1200
|
+
const i = p === "dark" || p === "system" && window.matchMedia(qe).matches ? { ...fn } : { ...P };
|
|
1209
1201
|
a && (i.primary = a);
|
|
1210
|
-
const
|
|
1211
|
-
$e(
|
|
1202
|
+
const m = dn(o);
|
|
1203
|
+
$e(m ? {
|
|
1212
1204
|
...i,
|
|
1213
|
-
...
|
|
1205
|
+
...m
|
|
1214
1206
|
} : i);
|
|
1215
1207
|
}
|
|
1216
|
-
function
|
|
1208
|
+
function vn(e, r) {
|
|
1217
1209
|
if (typeof window > "u") return;
|
|
1218
|
-
const o = r?.styleKey ??
|
|
1219
|
-
window.localStorage.setItem(o, e),
|
|
1210
|
+
const o = r?.styleKey ?? Je;
|
|
1211
|
+
window.localStorage.setItem(o, e), Xe(e);
|
|
1220
1212
|
}
|
|
1221
|
-
function
|
|
1213
|
+
function mn(e, r) {
|
|
1222
1214
|
if (typeof window > "u") return;
|
|
1223
|
-
const o = r?.primaryKey ??
|
|
1215
|
+
const o = r?.primaryKey ?? Ge;
|
|
1224
1216
|
window.localStorage.setItem(o, JSON.stringify(e)), $e(e);
|
|
1225
1217
|
}
|
|
1226
1218
|
function re(e, r) {
|
|
1227
|
-
if (
|
|
1228
|
-
const s = !
|
|
1219
|
+
if (jt(e)) {
|
|
1220
|
+
const s = !Ut(e);
|
|
1229
1221
|
return {
|
|
1230
1222
|
value: e,
|
|
1231
1223
|
update: s ? (a) => {
|
|
@@ -1263,20 +1255,20 @@ function Pe(e = {}) {
|
|
|
1263
1255
|
updateMeta: a.update
|
|
1264
1256
|
};
|
|
1265
1257
|
}
|
|
1266
|
-
function
|
|
1258
|
+
function hn(e, r = "Page") {
|
|
1267
1259
|
return Pe({
|
|
1268
1260
|
title: K(() => e.value ? "Loading..." : r),
|
|
1269
1261
|
icon: K(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
|
|
1270
1262
|
closable: K(() => !e.value)
|
|
1271
1263
|
});
|
|
1272
1264
|
}
|
|
1273
|
-
function
|
|
1265
|
+
function yn(e, r = "Page", o = "mdi-page") {
|
|
1274
1266
|
return Pe({
|
|
1275
1267
|
title: K(() => e.value > 0 ? `${r} (${e.value})` : r),
|
|
1276
1268
|
icon: K(() => e.value > 0 ? "mdi-bell-badge" : o)
|
|
1277
1269
|
});
|
|
1278
1270
|
}
|
|
1279
|
-
function
|
|
1271
|
+
function Tn(e, r = "Page") {
|
|
1280
1272
|
const o = {
|
|
1281
1273
|
normal: { suffix: "", icon: "mdi-page" },
|
|
1282
1274
|
loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
|
|
@@ -1289,41 +1281,41 @@ function wn(e, r = "Page") {
|
|
|
1289
1281
|
closable: K(() => e.value !== "loading")
|
|
1290
1282
|
});
|
|
1291
1283
|
}
|
|
1292
|
-
let
|
|
1293
|
-
const
|
|
1284
|
+
let ze = !1;
|
|
1285
|
+
const wn = {
|
|
1294
1286
|
install(e, r) {
|
|
1295
|
-
if (
|
|
1296
|
-
|
|
1287
|
+
if (ze) return;
|
|
1288
|
+
ze = !0;
|
|
1297
1289
|
const {
|
|
1298
1290
|
initTheme: o = !0,
|
|
1299
1291
|
themeOptions: s,
|
|
1300
|
-
componentName: a =
|
|
1301
|
-
tabsComponentName:
|
|
1292
|
+
componentName: a = Ne.name || "RouterTab",
|
|
1293
|
+
tabsComponentName: p = ke.name || "RouterTabs"
|
|
1302
1294
|
} = r ?? {};
|
|
1303
|
-
o &&
|
|
1295
|
+
o && bn(s ?? {}), e.component(a, Ne), e.component(p, ke), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", ke), Object.defineProperty(e.config.globalProperties, "$tabs", {
|
|
1304
1296
|
configurable: !0,
|
|
1305
1297
|
enumerable: !1,
|
|
1306
1298
|
get() {
|
|
1307
1299
|
return e._context.provides[le];
|
|
1308
1300
|
},
|
|
1309
|
-
set(
|
|
1310
|
-
|
|
1301
|
+
set(w) {
|
|
1302
|
+
w && e.provide(le, w);
|
|
1311
1303
|
}
|
|
1312
1304
|
});
|
|
1313
1305
|
}
|
|
1314
1306
|
};
|
|
1315
1307
|
export {
|
|
1316
|
-
|
|
1308
|
+
Ne as RouterTab,
|
|
1317
1309
|
ke as RouterTabs,
|
|
1318
|
-
|
|
1319
|
-
|
|
1310
|
+
wn as default,
|
|
1311
|
+
bn as initRouterTabsTheme,
|
|
1320
1312
|
le as routerTabsKey,
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1313
|
+
mn as setRouterTabsPrimary,
|
|
1314
|
+
vn as setRouterTabsTheme,
|
|
1315
|
+
hn as useLoadingTab,
|
|
1316
|
+
yn as useNotificationTab,
|
|
1325
1317
|
Pe as useReactiveTab,
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1318
|
+
Ue as useRouterTabs,
|
|
1319
|
+
We as useRouterTabsPersistence,
|
|
1320
|
+
Tn as useStatusTab
|
|
1329
1321
|
};
|