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