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