vue3-router-tab 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue3-router-tab.js +391 -389
- package/dist/vue3-router-tab.umd.cjs +1 -1
- package/lib/components/RouterTab.vue +29 -18
- package/lib/core/createRouterTabs.ts +9 -4
- 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 be, ref as $, shallowRef as dt, computed as k, watch as A, nextTick as j, inject as Re, getCurrentInstance as je, onMounted as pe, defineComponent as Oe, provide as bt, onBeforeUnmount as pt, resolveComponent as gt, createElementBlock as S, openBlock as P, createElementVNode as L, withDirectives as mt, normalizeClass as H, renderSlot as re, createVNode as Pe, TransitionGroup as vt, mergeProps as le, withCtx as se, Fragment as Ae, renderList as Ke, withModifiers as ue, createCommentVNode as Ee, toDisplayString as Ie, createBlock as J, normalizeProps as yt, Transition as ht, resolveDynamicComponent as ce, KeepAlive as Tt, normalizeStyle as kt, vShow as wt, isRef as Ct, isReadonly as Rt } 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,
|
|
@@ -17,7 +17,7 @@ function V(e, n) {
|
|
|
17
17
|
throw new Error(`[RouterTabs] Unable to resolve route: ${String(n)}`);
|
|
18
18
|
return o;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const Kt = {
|
|
21
21
|
path: (e) => e.path,
|
|
22
22
|
fullpath: (e) => e.fullPath,
|
|
23
23
|
fullname: (e) => e.fullPath,
|
|
@@ -30,39 +30,39 @@ function N(e) {
|
|
|
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 = Kt[n.toLowerCase()];
|
|
34
34
|
return o ? o(e) : n;
|
|
35
35
|
}
|
|
36
36
|
return e.fullPath;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function ge(e, n) {
|
|
39
39
|
const o = e.meta?.keepAlive;
|
|
40
40
|
return typeof o == "boolean" ? o : n;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function me(e, n) {
|
|
43
43
|
const o = e.meta?.reuse;
|
|
44
44
|
return typeof o == "boolean" ? o : n;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Ue(e) {
|
|
47
47
|
const n = e.meta ?? {}, o = {};
|
|
48
48
|
return "title" in n && (o.title = n.title), "tips" in n && (o.tips = n.tips), "icon" in n && (o.icon = n.icon), "closable" in n && (o.closable = n.closable), "tabClass" in n && (o.tabClass = n.tabClass), "target" in n && (o.target = n.target), "href" in n && (o.href = n.href), o;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const l =
|
|
50
|
+
function q(e, n, o) {
|
|
51
|
+
const l = Ue(e);
|
|
52
52
|
return {
|
|
53
53
|
id: N(e),
|
|
54
54
|
to: e.fullPath,
|
|
55
55
|
fullPath: e.fullPath,
|
|
56
56
|
matched: e,
|
|
57
|
-
alive:
|
|
58
|
-
reusable:
|
|
57
|
+
alive: ge(e, o),
|
|
58
|
+
reusable: me(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 fe(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);
|
|
@@ -74,17 +74,17 @@ function be(e, n, o, l) {
|
|
|
74
74
|
e.push(n);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
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 Et(e) {
|
|
88
88
|
return {
|
|
89
89
|
to: e.to,
|
|
90
90
|
title: e.title,
|
|
@@ -95,95 +95,95 @@ function At(e) {
|
|
|
95
95
|
renderKey: e.renderKey
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function It(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 xt(e, n = {}) {
|
|
103
|
+
const o = At(n), l = be([]), i = $(null), p = dt(), T = $(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 g(
|
|
108
|
-
const b = typeof
|
|
107
|
+
function g(r) {
|
|
108
|
+
const b = typeof r.matched == "object" ? r : V(e, r);
|
|
109
109
|
return {
|
|
110
110
|
key: N(b),
|
|
111
111
|
fullPath: b.fullPath,
|
|
112
|
-
alive:
|
|
113
|
-
reusable:
|
|
112
|
+
alive: ge(b, o.keepAlive),
|
|
113
|
+
reusable: me(b, !1),
|
|
114
114
|
matched: b
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function R(
|
|
118
|
-
const b = N(
|
|
117
|
+
function R(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 = ge(r, o.keepAlive), d.reusable = me(r, d.reusable), typeof d.renderKey != "number" && (d.renderKey = 0), Object.assign(d, Ue(r)), d) : (d = q(r, {}, o.keepAlive), fe(l, d, o.appendPosition, i.value), xe(l, o.maxAlive, i.value), d);
|
|
121
121
|
}
|
|
122
|
-
async function
|
|
123
|
-
const h = V(e,
|
|
124
|
-
d === "sameTab" && (d =
|
|
122
|
+
async function x(r, b = !1, d = !0) {
|
|
123
|
+
const h = V(e, r), w = N(h), K = i.value === w;
|
|
124
|
+
d === "sameTab" && (d = K), d && await O(w, !0), await e[b ? "replace" : "push"](h), K && await y();
|
|
125
125
|
}
|
|
126
|
-
function B(
|
|
127
|
-
const b = l.findIndex((
|
|
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((
|
|
130
|
-
return
|
|
129
|
+
const d = l[b + 1], h = l[b - 1], w = l.find((I) => I.id !== r), K = d || h || w;
|
|
130
|
+
return K ? K.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
|
|
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
|
|
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 = V(e, b.to), h =
|
|
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(Et),
|
|
173
|
+
active: r ? r.to : null
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
-
async function D(
|
|
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 = V(e, h.to),
|
|
182
|
-
|
|
181
|
+
const w = V(e, h.to), K = It(h), I = q(w, K, o.keepAlive);
|
|
182
|
+
fe(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);
|
|
@@ -192,28 +192,28 @@ function Kt(e, n = {}) {
|
|
|
192
192
|
}
|
|
193
193
|
return A(
|
|
194
194
|
() => e.currentRoute.value,
|
|
195
|
-
(
|
|
195
|
+
(r) => {
|
|
196
196
|
if (c) return;
|
|
197
|
-
const b = R(
|
|
198
|
-
|
|
197
|
+
const b = R(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 = V(e,
|
|
203
|
-
|
|
201
|
+
), o.initialTabs.length && o.initialTabs.forEach((r) => {
|
|
202
|
+
const b = V(e, r.to), d = q(b, r, o.keepAlive);
|
|
203
|
+
fe(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: x,
|
|
212
212
|
closeTab: z,
|
|
213
|
-
removeTab:
|
|
214
|
-
refreshTab:
|
|
215
|
-
refreshAll:
|
|
216
|
-
reset:
|
|
213
|
+
removeTab: _,
|
|
214
|
+
refreshTab: O,
|
|
215
|
+
refreshAll: te,
|
|
216
|
+
reset: ne,
|
|
217
217
|
reload: y,
|
|
218
218
|
getRouteKey: G,
|
|
219
219
|
matchRoute: g,
|
|
@@ -224,20 +224,20 @@ function Kt(e, n = {}) {
|
|
|
224
224
|
function De(e) {
|
|
225
225
|
return e ? typeof e == "string" ? { name: e } : e : {};
|
|
226
226
|
}
|
|
227
|
-
const
|
|
228
|
-
function
|
|
229
|
-
const { optional: n = !1 } = e, o =
|
|
227
|
+
const ee = Symbol("RouterTabsContext"), Z = "router-tabs:snapshot";
|
|
228
|
+
function Se(e = {}) {
|
|
229
|
+
const { optional: n = !1 } = e, o = Re(ee, null);
|
|
230
230
|
if (o) return o;
|
|
231
|
-
const l =
|
|
231
|
+
const l = Re("$tabs", null);
|
|
232
232
|
if (l) return l;
|
|
233
|
-
const p =
|
|
233
|
+
const p = je()?.appContext.config.globalProperties.$tabs;
|
|
234
234
|
if (p) return p;
|
|
235
235
|
if (!n)
|
|
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 $e(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 g = new Date(Date.now() + l *
|
|
258
|
+
const g = new Date(Date.now() + l * Dt).toUTCString();
|
|
259
259
|
c.push(`Expires=${g}`);
|
|
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
|
-
function
|
|
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 $t = (e) => JSON.stringify(e ?? null), Bt = (e) => {
|
|
269
269
|
if (!e) return null;
|
|
270
270
|
try {
|
|
271
271
|
return JSON.parse(e);
|
|
@@ -273,19 +273,19 @@ const St = (e) => JSON.stringify(e ?? null), Dt = (e) => {
|
|
|
273
273
|
return null;
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
function
|
|
276
|
+
function Ve(e = {}) {
|
|
277
277
|
const {
|
|
278
|
-
cookieKey: n =
|
|
279
|
-
serialize: o =
|
|
280
|
-
deserialize: l =
|
|
281
|
-
} = e,
|
|
282
|
-
|
|
283
|
-
const c = l(
|
|
278
|
+
cookieKey: n = Z,
|
|
279
|
+
serialize: o = $t,
|
|
280
|
+
deserialize: l = Bt
|
|
281
|
+
} = e, i = Se({ optional: !0 }), p = $(!0), T = (s) => {
|
|
282
|
+
pe(async () => {
|
|
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 R = s.tabs.find((
|
|
287
|
+
await j();
|
|
288
|
+
const R = s.tabs.find((x) => x.to === c.active);
|
|
289
289
|
R && (s.activeId.value = R.id, s.current.value = R);
|
|
290
290
|
}
|
|
291
291
|
} finally {
|
|
@@ -302,7 +302,7 @@ function Ne(e = {}) {
|
|
|
302
302
|
else
|
|
303
303
|
p.value = !1;
|
|
304
304
|
const g = s.snapshot();
|
|
305
|
-
g.tabs.length ?
|
|
305
|
+
g.tabs.length ? $e(n, o(g), e) : Be(n, e), p.value = !1;
|
|
306
306
|
}), A(
|
|
307
307
|
() => ({
|
|
308
308
|
tabs: s.tabs.map((c) => ({
|
|
@@ -319,19 +319,19 @@ function Ne(e = {}) {
|
|
|
319
319
|
() => {
|
|
320
320
|
if (p.value) return;
|
|
321
321
|
const c = s.snapshot();
|
|
322
|
-
c.tabs.length ?
|
|
322
|
+
c.tabs.length ? $e(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) : pe(() => {
|
|
328
|
+
const s = Se({ optional: !0 });
|
|
329
329
|
s && T(s);
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
|
-
const
|
|
332
|
+
const Mt = Oe({
|
|
333
333
|
name: "RouterTab",
|
|
334
|
-
components: { RouterView:
|
|
334
|
+
components: { RouterView: Pt },
|
|
335
335
|
props: {
|
|
336
336
|
tabs: {
|
|
337
337
|
type: Array,
|
|
@@ -371,7 +371,7 @@ const $t = Ue({
|
|
|
371
371
|
},
|
|
372
372
|
cookieKey: {
|
|
373
373
|
type: String,
|
|
374
|
-
default:
|
|
374
|
+
default: Z
|
|
375
375
|
},
|
|
376
376
|
persistence: {
|
|
377
377
|
type: Object,
|
|
@@ -384,13 +384,13 @@ const $t = Ue({
|
|
|
384
384
|
},
|
|
385
385
|
emits: ["tab-sort", "tab-sorted"],
|
|
386
386
|
setup(e, { emit: n }) {
|
|
387
|
-
const o =
|
|
387
|
+
const o = je();
|
|
388
388
|
if (!o)
|
|
389
389
|
throw new Error("[RouterTab] component must be used within a Vue application context.");
|
|
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 = xt(l, {
|
|
394
394
|
initialTabs: e.tabs,
|
|
395
395
|
keepAlive: e.keepAlive,
|
|
396
396
|
maxAlive: e.maxAlive,
|
|
@@ -398,23 +398,23 @@ const $t = Ue({
|
|
|
398
398
|
appendPosition: e.append,
|
|
399
399
|
defaultRoute: e.defaultPage
|
|
400
400
|
});
|
|
401
|
-
|
|
401
|
+
bt(ee, i), o.appContext.config.globalProperties.$tabs = i;
|
|
402
402
|
const p = k(() => !!o?.slots?.default), T = k(() => !!o?.slots?.start), s = k(() => !!o?.slots?.end), c = $(0), g = k(() => {
|
|
403
403
|
c.value;
|
|
404
404
|
const t = {};
|
|
405
|
-
return
|
|
406
|
-
const f = typeof a.title == "string" ? a.title : String(a.title ||
|
|
405
|
+
return i.tabs.forEach((a) => {
|
|
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
410
|
function R() {
|
|
411
411
|
c.value++;
|
|
412
412
|
}
|
|
413
|
-
const
|
|
413
|
+
const x = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
|
414
414
|
function z(t, a) {
|
|
415
|
-
if (!a ||
|
|
416
|
-
|
|
417
|
-
const f =
|
|
415
|
+
if (!a || x.has(t)) return;
|
|
416
|
+
x.set(t, a);
|
|
417
|
+
const f = i.tabs.find((v) => i.getRouteKey(v.to) === t);
|
|
418
418
|
if (!f) return;
|
|
419
419
|
const m = [];
|
|
420
420
|
if (a.routeTabTitle !== void 0) {
|
|
@@ -425,8 +425,8 @@ const $t = Ue({
|
|
|
425
425
|
},
|
|
426
426
|
(u) => {
|
|
427
427
|
if (u != null) {
|
|
428
|
-
const
|
|
429
|
-
f.title =
|
|
428
|
+
const U = String(u);
|
|
429
|
+
f.title = U, R();
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
432
|
{ immediate: !0 }
|
|
@@ -474,24 +474,24 @@ const $t = Ue({
|
|
|
474
474
|
}
|
|
475
475
|
B.set(t, m);
|
|
476
476
|
}
|
|
477
|
-
function
|
|
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)), x.delete(t);
|
|
480
480
|
}
|
|
481
|
-
function
|
|
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 &&
|
|
481
|
+
function O(t, a) {
|
|
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) {
|
|
485
485
|
const t = {
|
|
486
486
|
...e.persistence ?? {}
|
|
487
487
|
};
|
|
488
|
-
e.cookieKey !== null ? t.cookieKey = e.cookieKey ||
|
|
488
|
+
e.cookieKey !== null ? t.cookieKey = e.cookieKey || Z : t.cookieKey || (t.cookieKey = Z), Ve(t);
|
|
489
489
|
}
|
|
490
|
-
const
|
|
490
|
+
const te = k(() => De(e.tabTransition)), ne = k(() => De(e.pageTransition)), y = be({
|
|
491
491
|
visible: !1,
|
|
492
492
|
target: null,
|
|
493
493
|
position: { x: 0, y: 0 }
|
|
494
|
-
}), G = $(null), M = $([]), D = $(-1),
|
|
494
|
+
}), G = $(null), M = $([]), D = $(-1), r = be({
|
|
495
495
|
dragging: !1,
|
|
496
496
|
dragIndex: -1,
|
|
497
497
|
dropIndex: -1,
|
|
@@ -505,112 +505,114 @@ const $t = Ue({
|
|
|
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 K(t) {
|
|
519
|
+
return i.tabs.filter((a) => a.id !== t.id);
|
|
520
520
|
}
|
|
521
|
-
async function
|
|
521
|
+
async function I(t, a) {
|
|
522
522
|
const f = t.filter((m) => m.closable !== !1);
|
|
523
523
|
if (f.length) {
|
|
524
524
|
for (const m of f)
|
|
525
|
-
|
|
526
|
-
|
|
525
|
+
i.activeId.value === m.id ? await i.closeTab(m.id, { redirect: a.to, force: !0 }) : await i.removeTab(m.id, { force: !0 });
|
|
526
|
+
i.activeId.value !== a.id && await i.openTab(a.to, !0, !1);
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
const
|
|
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
|
-
enable: ({ target: t }) =>
|
|
547
|
+
enable: ({ target: t }) => ae(t)
|
|
548
548
|
},
|
|
549
549
|
closeLefts: {
|
|
550
550
|
label: "Close to the Left",
|
|
551
551
|
handler: async ({ target: t }) => {
|
|
552
|
-
await
|
|
552
|
+
await I(h(t), t);
|
|
553
553
|
},
|
|
554
554
|
enable: ({ target: t }) => h(t).some((a) => a.closable !== !1)
|
|
555
555
|
},
|
|
556
556
|
closeRights: {
|
|
557
557
|
label: "Close to the Right",
|
|
558
558
|
handler: async ({ target: t }) => {
|
|
559
|
-
await
|
|
559
|
+
await I(w(t), t);
|
|
560
560
|
},
|
|
561
561
|
enable: ({ target: t }) => w(t).some((a) => a.closable !== !1)
|
|
562
562
|
},
|
|
563
563
|
closeOthers: {
|
|
564
564
|
label: "Close Others",
|
|
565
565
|
handler: async ({ target: t }) => {
|
|
566
|
-
await
|
|
566
|
+
await I(K(t), t);
|
|
567
567
|
},
|
|
568
|
-
enable: ({ target: t }) =>
|
|
568
|
+
enable: ({ target: t }) => K(t).some((a) => a.closable !== !1)
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
|
-
function
|
|
571
|
+
function E() {
|
|
572
572
|
y.visible = !1, y.target = null, D.value = -1, M.value = [];
|
|
573
573
|
}
|
|
574
|
-
function
|
|
575
|
-
e.contextmenu && (y.
|
|
576
|
-
|
|
574
|
+
function He(t, a) {
|
|
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
|
-
function
|
|
580
|
-
const f = typeof t == "string" ? { id: t } : t, m =
|
|
581
|
+
function Je(t, a) {
|
|
582
|
+
const f = typeof t == "string" ? { id: t } : t, m = Fe[f.id], v = f.label ?? m?.label ?? String(f.id), u = f.visible ?? m?.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 ?? m?.enable ?? !0, ct = typeof ie == "function" ? ie(a) : ie !== !1, Ce = f.handler ?? m?.handler;
|
|
585
|
+
if (!Ce) return null;
|
|
586
|
+
const ft = async () => {
|
|
587
|
+
await Promise.resolve(Ce(a));
|
|
586
588
|
};
|
|
587
589
|
return {
|
|
588
590
|
id: String(f.id),
|
|
589
591
|
label: v,
|
|
590
|
-
disabled: !
|
|
591
|
-
action:
|
|
592
|
+
disabled: !ct,
|
|
593
|
+
action: ft
|
|
592
594
|
};
|
|
593
595
|
}
|
|
594
|
-
const
|
|
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:
|
|
597
|
-
return t.map((f) =>
|
|
598
|
+
const t = Array.isArray(e.contextmenu) ? e.contextmenu : b, a = { target: y.target, controller: i };
|
|
599
|
+
return t.map((f) => Je(f, a)).filter((f) => !!f);
|
|
598
600
|
});
|
|
599
|
-
function
|
|
601
|
+
function We() {
|
|
600
602
|
const t = G.value;
|
|
601
603
|
if (!t) return;
|
|
602
604
|
const a = 8, { innerWidth: f, innerHeight: m } = window, v = t.getBoundingClientRect();
|
|
603
|
-
let u = y.position.x,
|
|
604
|
-
v.right > f - a && (u = Math.max(a, f - v.width - a)), v.bottom > m - a && (
|
|
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 > m - a && (U = Math.max(a, m - v.height - a)), (u !== y.position.x || U !== y.position.y) && (y.position.x = u, y.position.y = U);
|
|
605
607
|
}
|
|
606
|
-
function
|
|
608
|
+
function Ge(t, a) {
|
|
607
609
|
M.value[a] = t ?? null;
|
|
608
610
|
}
|
|
609
|
-
function
|
|
611
|
+
function Xe(t) {
|
|
610
612
|
if (t < 0) return;
|
|
611
613
|
M.value[t]?.focus({ preventScroll: !0 });
|
|
612
614
|
}
|
|
613
|
-
function X(t, a, f =
|
|
615
|
+
function X(t, a, f = Y.value) {
|
|
614
616
|
if (!f.length) return -1;
|
|
615
617
|
const m = f.length;
|
|
616
618
|
let v = t;
|
|
@@ -618,19 +620,19 @@ const $t = Ue({
|
|
|
618
620
|
if (v = (v + a + m) % m, !f[v].disabled) return v;
|
|
619
621
|
return -1;
|
|
620
622
|
}
|
|
621
|
-
function
|
|
622
|
-
D.value = t, !(t < 0) &&
|
|
623
|
+
function F(t) {
|
|
624
|
+
D.value = t, !(t < 0) && j(() => Xe(t));
|
|
623
625
|
}
|
|
624
|
-
function
|
|
626
|
+
function he(t) {
|
|
625
627
|
const a = X(D.value, t);
|
|
626
|
-
a !== -1 &&
|
|
628
|
+
a !== -1 && F(a);
|
|
627
629
|
}
|
|
628
|
-
function
|
|
630
|
+
function qe(t) {
|
|
629
631
|
if (!y.visible) return;
|
|
630
|
-
const a = t.key, f =
|
|
632
|
+
const a = t.key, f = Y.value;
|
|
631
633
|
if (!f.length) return;
|
|
632
634
|
if (a === "Tab") {
|
|
633
|
-
|
|
635
|
+
E();
|
|
634
636
|
return;
|
|
635
637
|
}
|
|
636
638
|
if ([
|
|
@@ -648,17 +650,17 @@ const $t = Ue({
|
|
|
648
650
|
switch (t.preventDefault(), a) {
|
|
649
651
|
case "ArrowDown":
|
|
650
652
|
case "ArrowRight":
|
|
651
|
-
|
|
653
|
+
he(1);
|
|
652
654
|
break;
|
|
653
655
|
case "ArrowUp":
|
|
654
656
|
case "ArrowLeft":
|
|
655
|
-
|
|
657
|
+
he(-1);
|
|
656
658
|
break;
|
|
657
659
|
case "Home":
|
|
658
|
-
|
|
660
|
+
F(X(-1, 1));
|
|
659
661
|
break;
|
|
660
662
|
case "End":
|
|
661
|
-
|
|
663
|
+
F(X(f.length, -1));
|
|
662
664
|
break;
|
|
663
665
|
case "Enter":
|
|
664
666
|
case " ":
|
|
@@ -666,191 +668,194 @@ const $t = Ue({
|
|
|
666
668
|
const v = D.value;
|
|
667
669
|
if (v > -1) {
|
|
668
670
|
const u = f[v];
|
|
669
|
-
u.disabled ||
|
|
671
|
+
u.disabled || Te(u);
|
|
670
672
|
}
|
|
671
673
|
break;
|
|
672
674
|
}
|
|
673
675
|
case "Escape":
|
|
674
|
-
|
|
676
|
+
E();
|
|
675
677
|
break;
|
|
676
678
|
}
|
|
677
679
|
}
|
|
678
|
-
async function
|
|
679
|
-
t.disabled || (
|
|
680
|
+
async function Te(t) {
|
|
681
|
+
t.disabled || (E(), await t.action());
|
|
680
682
|
}
|
|
681
|
-
function
|
|
683
|
+
function oe(t) {
|
|
682
684
|
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
685
|
}
|
|
684
|
-
function
|
|
685
|
-
return g.value[t.id] ||
|
|
686
|
+
function Qe(t) {
|
|
687
|
+
return g.value[t.id] || oe(t);
|
|
686
688
|
}
|
|
687
|
-
function
|
|
688
|
-
const a =
|
|
689
|
+
function ke(t) {
|
|
690
|
+
const a = i.getRouteKey(t), m = i.tabs.find((v) => v.id === a)?.renderKey ?? 0;
|
|
689
691
|
return `${a}::${m}`;
|
|
690
692
|
}
|
|
691
|
-
function
|
|
692
|
-
return `${
|
|
693
|
+
function Ze(t) {
|
|
694
|
+
return `${ke(t)}::refresh`;
|
|
693
695
|
}
|
|
694
|
-
function
|
|
695
|
-
return !(t.closable === !1 ||
|
|
696
|
+
function ae(t) {
|
|
697
|
+
return !(t.closable === !1 || i.options.keepLastTab && i.tabs.length <= 1);
|
|
696
698
|
}
|
|
697
|
-
async function
|
|
698
|
-
await
|
|
699
|
+
async function et(t) {
|
|
700
|
+
await i.closeTab(t.id);
|
|
699
701
|
}
|
|
700
|
-
function
|
|
702
|
+
function tt(t) {
|
|
701
703
|
if (t.href && typeof window < "u") {
|
|
702
704
|
t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
|
|
703
705
|
return;
|
|
704
706
|
}
|
|
705
|
-
|
|
707
|
+
i.activeId.value !== t.id && i.openTab(t.to, !1);
|
|
706
708
|
}
|
|
707
|
-
function
|
|
709
|
+
function nt(t) {
|
|
708
710
|
return [
|
|
709
711
|
"router-tab__item",
|
|
710
712
|
{
|
|
711
|
-
"is-active":
|
|
712
|
-
"is-closable":
|
|
713
|
-
"is-dragging":
|
|
714
|
-
"is-drag-over":
|
|
713
|
+
"is-active": i.activeId.value === t.id,
|
|
714
|
+
"is-closable": ae(t),
|
|
715
|
+
"is-dragging": r.dragging && r.dragTab?.id === t.id,
|
|
716
|
+
"is-drag-over": r.dropIndex === d(t.id)
|
|
715
717
|
},
|
|
716
718
|
t.tabClass
|
|
717
719
|
];
|
|
718
720
|
}
|
|
719
|
-
function
|
|
720
|
-
return
|
|
721
|
+
function ot(t) {
|
|
722
|
+
return i.refreshingKey.value === i.getRouteKey(t);
|
|
721
723
|
}
|
|
722
|
-
function
|
|
723
|
-
e.sortable && (
|
|
724
|
+
function at(t, a, f) {
|
|
725
|
+
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
726
|
}
|
|
725
727
|
function it(t, a) {
|
|
726
|
-
!e.sortable || !
|
|
728
|
+
!e.sortable || !r.dragging || (a.preventDefault(), a.dataTransfer && (a.dataTransfer.dropEffect = "move"));
|
|
727
729
|
}
|
|
728
|
-
function
|
|
729
|
-
!e.sortable || !
|
|
730
|
+
function rt(t) {
|
|
731
|
+
!e.sortable || !r.dragging || (r.dropIndex = t);
|
|
730
732
|
}
|
|
731
|
-
function
|
|
732
|
-
!e.sortable ||
|
|
733
|
+
function lt() {
|
|
734
|
+
!e.sortable || r.dragging;
|
|
733
735
|
}
|
|
734
|
-
function
|
|
735
|
-
if (!(!e.sortable || !
|
|
736
|
-
if (a.preventDefault(),
|
|
737
|
-
const f =
|
|
738
|
-
|
|
736
|
+
function st(t, a) {
|
|
737
|
+
if (!(!e.sortable || !r.dragging)) {
|
|
738
|
+
if (a.preventDefault(), r.dragIndex !== -1 && r.dragIndex !== t) {
|
|
739
|
+
const f = i.tabs.splice(r.dragIndex, 1)[0];
|
|
740
|
+
i.tabs.splice(t, 0, f), n("tab-sorted", {
|
|
739
741
|
tab: f,
|
|
740
|
-
fromIndex:
|
|
742
|
+
fromIndex: r.dragIndex,
|
|
741
743
|
toIndex: t
|
|
742
744
|
});
|
|
743
745
|
}
|
|
744
|
-
|
|
746
|
+
we();
|
|
745
747
|
}
|
|
746
748
|
}
|
|
747
|
-
function
|
|
748
|
-
|
|
749
|
+
function we() {
|
|
750
|
+
r.dragging = !1, r.dragIndex = -1, r.dropIndex = -1, r.dragTab = null;
|
|
749
751
|
}
|
|
750
|
-
|
|
751
|
-
document.addEventListener("keydown",
|
|
752
|
-
}),
|
|
753
|
-
document.removeEventListener("keydown",
|
|
752
|
+
pe(() => {
|
|
753
|
+
document.addEventListener("keydown", E);
|
|
754
|
+
}), pt(() => {
|
|
755
|
+
document.removeEventListener("keydown", E), o.appContext.config.globalProperties.$tabs = null, B.forEach((t) => {
|
|
754
756
|
t.forEach((a) => a());
|
|
755
|
-
}), B.clear(),
|
|
757
|
+
}), B.clear(), x.clear();
|
|
756
758
|
}), A(
|
|
757
759
|
() => e.keepAlive,
|
|
758
760
|
(t) => {
|
|
759
|
-
|
|
761
|
+
i.options.keepAlive = t;
|
|
760
762
|
}
|
|
761
763
|
), A(
|
|
762
|
-
() =>
|
|
763
|
-
() =>
|
|
764
|
+
() => i.activeId.value,
|
|
765
|
+
() => E()
|
|
764
766
|
), A(
|
|
765
767
|
() => e.contextmenu,
|
|
766
768
|
(t) => {
|
|
767
|
-
t ||
|
|
769
|
+
t || E();
|
|
768
770
|
}
|
|
769
771
|
), A(
|
|
770
|
-
() =>
|
|
772
|
+
() => Y.value.length,
|
|
771
773
|
(t) => {
|
|
772
|
-
y.visible && t === 0 &&
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
774
|
+
y.visible && t === 0 && E();
|
|
775
|
+
},
|
|
776
|
+
{ flush: "post" }
|
|
777
|
+
// Run after component updates to prevent blocking render
|
|
778
|
+
), A(Y, (t) => {
|
|
779
|
+
if (!y.visible) return;
|
|
780
|
+
M.value = new Array(t.length).fill(null);
|
|
776
781
|
const a = X(-1, 1, t);
|
|
777
|
-
|
|
778
|
-
}), A(
|
|
782
|
+
F(a);
|
|
783
|
+
}, { flush: "post" }), A(
|
|
779
784
|
() => y.visible,
|
|
780
785
|
(t) => {
|
|
781
786
|
t || (D.value = -1, M.value = []);
|
|
782
787
|
}
|
|
783
788
|
);
|
|
784
|
-
const
|
|
789
|
+
const ut = i.includeKeys;
|
|
785
790
|
return {
|
|
786
|
-
controller:
|
|
787
|
-
tabs:
|
|
788
|
-
includeKeys:
|
|
789
|
-
tabTransitionProps:
|
|
790
|
-
pageTransitionProps:
|
|
791
|
-
buildTabClass:
|
|
792
|
-
activate:
|
|
793
|
-
close:
|
|
791
|
+
controller: i,
|
|
792
|
+
tabs: i.tabs,
|
|
793
|
+
includeKeys: ut,
|
|
794
|
+
tabTransitionProps: te,
|
|
795
|
+
pageTransitionProps: ne,
|
|
796
|
+
buildTabClass: nt,
|
|
797
|
+
activate: tt,
|
|
798
|
+
close: et,
|
|
794
799
|
context: y,
|
|
795
|
-
menuItems:
|
|
796
|
-
handleMenuAction:
|
|
797
|
-
showContextMenu:
|
|
798
|
-
hideContextMenu:
|
|
799
|
-
getTabTitle:
|
|
800
|
-
isClosable:
|
|
801
|
-
isRefreshing:
|
|
800
|
+
menuItems: Y,
|
|
801
|
+
handleMenuAction: Te,
|
|
802
|
+
showContextMenu: He,
|
|
803
|
+
hideContextMenu: E,
|
|
804
|
+
getTabTitle: oe,
|
|
805
|
+
isClosable: ae,
|
|
806
|
+
isRefreshing: ot,
|
|
802
807
|
hasCustomSlot: p,
|
|
803
808
|
hasStartSlot: T,
|
|
804
809
|
hasEndSlot: s,
|
|
805
|
-
onDragStart:
|
|
810
|
+
onDragStart: at,
|
|
806
811
|
onDragOver: it,
|
|
807
|
-
onDragEnter:
|
|
808
|
-
onDragLeave:
|
|
809
|
-
onDrop:
|
|
810
|
-
onDragEnd:
|
|
812
|
+
onDragEnter: rt,
|
|
813
|
+
onDragLeave: lt,
|
|
814
|
+
onDrop: st,
|
|
815
|
+
onDragEnd: we,
|
|
811
816
|
setupComponentWatching: z,
|
|
812
|
-
cleanupComponentWatching:
|
|
813
|
-
handleComponentRef:
|
|
814
|
-
getReactiveTabTitle:
|
|
815
|
-
getComponentCacheKey:
|
|
816
|
-
getRefreshComponentKey:
|
|
817
|
+
cleanupComponentWatching: _,
|
|
818
|
+
handleComponentRef: O,
|
|
819
|
+
getReactiveTabTitle: Qe,
|
|
820
|
+
getComponentCacheKey: ke,
|
|
821
|
+
getRefreshComponentKey: Ze,
|
|
817
822
|
triggerTabUpdate: R,
|
|
818
823
|
menuRef: G,
|
|
819
824
|
highlightedIndex: D,
|
|
820
|
-
setMenuItemRef:
|
|
821
|
-
onMenuKeydown:
|
|
822
|
-
highlightMenuIndex:
|
|
825
|
+
setMenuItemRef: Ge,
|
|
826
|
+
onMenuKeydown: qe,
|
|
827
|
+
highlightMenuIndex: F
|
|
823
828
|
};
|
|
824
829
|
}
|
|
825
|
-
}),
|
|
830
|
+
}), Lt = (e, n) => {
|
|
826
831
|
const o = e.__vccOpts || e;
|
|
827
|
-
for (const [l,
|
|
828
|
-
o[l] =
|
|
832
|
+
for (const [l, i] of n)
|
|
833
|
+
o[l] = i;
|
|
829
834
|
return o;
|
|
830
|
-
},
|
|
831
|
-
function
|
|
832
|
-
const T =
|
|
833
|
-
return P(),
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
class:
|
|
835
|
+
}, jt = { class: "router-tab" }, Ot = { class: "router-tab__header" }, Ut = { class: "router-tab__scroll" }, Vt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], Nt = ["title"], zt = ["onClick"], _t = { class: "router-tab__container" }, Yt = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
|
|
836
|
+
function Ft(e, n, o, l, i, p) {
|
|
837
|
+
const T = gt("RouterView");
|
|
838
|
+
return P(), S("div", jt, [
|
|
839
|
+
L("header", Ot, [
|
|
840
|
+
L("div", {
|
|
841
|
+
class: H(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
|
|
837
842
|
}, [
|
|
838
|
-
|
|
843
|
+
re(e.$slots, "start")
|
|
839
844
|
], 2),
|
|
840
|
-
|
|
841
|
-
|
|
845
|
+
L("div", Ut, [
|
|
846
|
+
Pe(vt, le({
|
|
842
847
|
tag: "ul",
|
|
843
848
|
class: "router-tab__nav"
|
|
844
849
|
}, e.tabTransitionProps), {
|
|
845
|
-
default:
|
|
846
|
-
(P(!0),
|
|
850
|
+
default: se(() => [
|
|
851
|
+
(P(!0), S(Ae, null, Ke(e.tabs, (s, c) => (P(), S("li", {
|
|
847
852
|
key: s.id,
|
|
848
|
-
class:
|
|
853
|
+
class: H(e.buildTabClass(s)),
|
|
849
854
|
"data-title": e.getTabTitle(s),
|
|
850
855
|
draggable: e.sortable,
|
|
851
856
|
onClick: (g) => e.activate(s),
|
|
852
|
-
onAuxclick:
|
|
853
|
-
onContextmenu:
|
|
857
|
+
onAuxclick: ue((g) => e.close(s), ["middle", "prevent"]),
|
|
858
|
+
onContextmenu: ue((g) => e.showContextMenu(s, g), ["prevent"]),
|
|
854
859
|
onDragstart: (g) => e.onDragStart(s, c, g),
|
|
855
860
|
onDragover: (g) => e.onDragOver(c, g),
|
|
856
861
|
onDragenter: (g) => e.onDragEnter(c),
|
|
@@ -858,82 +863,77 @@ function zt(e, n, o, l, r, p) {
|
|
|
858
863
|
onDrop: (g) => e.onDrop(c, g),
|
|
859
864
|
onDragend: n[1] || (n[1] = (...g) => e.onDragEnd && e.onDragEnd(...g))
|
|
860
865
|
}, [
|
|
861
|
-
s.icon ? (P(),
|
|
866
|
+
s.icon ? (P(), S("i", {
|
|
862
867
|
key: 0,
|
|
863
|
-
class:
|
|
864
|
-
}, null, 2)) :
|
|
865
|
-
|
|
868
|
+
class: H(["router-tab__item-icon", s.icon])
|
|
869
|
+
}, null, 2)) : Ee("", !0),
|
|
870
|
+
L("span", {
|
|
866
871
|
class: "router-tab__item-title",
|
|
867
872
|
title: e.getReactiveTabTitle(s)
|
|
868
|
-
},
|
|
869
|
-
e.isClosable(s) ? (P(),
|
|
873
|
+
}, Ie(e.getReactiveTabTitle(s)), 9, Nt),
|
|
874
|
+
e.isClosable(s) ? (P(), S("a", {
|
|
870
875
|
key: 1,
|
|
871
876
|
class: "router-tab__item-close",
|
|
872
|
-
onClick:
|
|
873
|
-
}, null, 8,
|
|
874
|
-
], 42,
|
|
877
|
+
onClick: ue((g) => e.close(s), ["stop"])
|
|
878
|
+
}, null, 8, zt)) : Ee("", !0)
|
|
879
|
+
], 42, Vt))), 128))
|
|
875
880
|
]),
|
|
876
881
|
_: 1
|
|
877
882
|
}, 16)
|
|
878
883
|
]),
|
|
879
|
-
|
|
880
|
-
class:
|
|
884
|
+
L("div", {
|
|
885
|
+
class: H(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
|
|
881
886
|
}, [
|
|
882
|
-
|
|
887
|
+
re(e.$slots, "end")
|
|
883
888
|
], 2)
|
|
884
889
|
]),
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
default:
|
|
888
|
-
e.hasCustomSlot ?
|
|
890
|
+
L("div", _t, [
|
|
891
|
+
Pe(T, null, {
|
|
892
|
+
default: se((s) => [
|
|
893
|
+
e.hasCustomSlot ? re(e.$slots, "default", yt(le({ key: 0 }, {
|
|
889
894
|
...s,
|
|
890
895
|
controller: e.controller,
|
|
891
896
|
// Expose a ref binder so custom slots can keep reactivity
|
|
892
897
|
pageRef: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route))
|
|
893
|
-
}))) : (P(),
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
e.
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
], 1032, ["include", "max"])) : U("", !0)
|
|
907
|
-
]),
|
|
908
|
-
_: 2
|
|
909
|
-
}, 1040),
|
|
910
|
-
q(Ie, Q(e.pageTransitionProps, { appear: "" }), {
|
|
911
|
-
default: Z(() => [
|
|
912
|
-
!e.controller.options.keepAlive || e.isRefreshing(s.route) ? (P(), de(xe(s.Component), {
|
|
913
|
-
key: e.getRefreshComponentKey(s.route),
|
|
898
|
+
}))) : (P(), J(ht, le({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
|
|
899
|
+
default: se(() => [
|
|
900
|
+
e.isRefreshing(s.route) ? (P(), J(ce(s.Component), {
|
|
901
|
+
key: e.getRefreshComponentKey(s.route),
|
|
902
|
+
ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
|
|
903
|
+
class: "router-tab-page"
|
|
904
|
+
})) : e.controller.options.keepAlive ? (P(), J(Tt, {
|
|
905
|
+
key: 1,
|
|
906
|
+
include: e.includeKeys,
|
|
907
|
+
max: e.controller.options.maxAlive || void 0
|
|
908
|
+
}, [
|
|
909
|
+
(P(), J(ce(s.Component), {
|
|
910
|
+
key: e.getComponentCacheKey(s.route),
|
|
914
911
|
ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
|
|
915
912
|
class: "router-tab-page"
|
|
916
|
-
}))
|
|
917
|
-
]),
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
913
|
+
}))
|
|
914
|
+
], 1032, ["include", "max"])) : (P(), J(ce(s.Component), {
|
|
915
|
+
key: e.getComponentCacheKey(s.route),
|
|
916
|
+
ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
|
|
917
|
+
class: "router-tab-page"
|
|
918
|
+
}))
|
|
919
|
+
]),
|
|
920
|
+
_: 2
|
|
921
|
+
}, 1040))
|
|
921
922
|
]),
|
|
922
923
|
_: 3
|
|
923
924
|
})
|
|
924
925
|
]),
|
|
925
|
-
|
|
926
|
-
key: 0,
|
|
926
|
+
mt(L("div", {
|
|
927
927
|
ref: "menuRef",
|
|
928
928
|
class: "router-tab__contextmenu",
|
|
929
929
|
role: "menu",
|
|
930
930
|
onKeydown: n[2] || (n[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
|
|
931
|
-
style:
|
|
931
|
+
style: kt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
|
|
932
932
|
}, [
|
|
933
|
-
(P(!0),
|
|
933
|
+
(P(!0), S(Ae, null, Ke(e.menuItems, (s, c) => (P(), S("a", {
|
|
934
934
|
key: s.id,
|
|
935
935
|
role: "menuitem",
|
|
936
|
-
class:
|
|
936
|
+
class: H(["router-tab__contextmenu-item", { "is-focused": c === e.highlightedIndex }]),
|
|
937
937
|
"aria-disabled": s.disabled,
|
|
938
938
|
disabled: s.disabled,
|
|
939
939
|
tabindex: s.disabled ? -1 : c === e.highlightedIndex ? 0 : -1,
|
|
@@ -941,14 +941,16 @@ function zt(e, n, o, l, r, p) {
|
|
|
941
941
|
ref: (g) => e.setMenuItemRef(g, c),
|
|
942
942
|
onMouseenter: (g) => !s.disabled && e.highlightMenuIndex(c),
|
|
943
943
|
onClick: (g) => e.handleMenuAction(s)
|
|
944
|
-
},
|
|
945
|
-
], 36)
|
|
944
|
+
}, Ie(s.label), 43, Yt))), 128))
|
|
945
|
+
], 36), [
|
|
946
|
+
[wt, e.context.visible && e.context.target]
|
|
947
|
+
])
|
|
946
948
|
]);
|
|
947
949
|
}
|
|
948
|
-
const
|
|
950
|
+
const Me = /* @__PURE__ */ Lt(Mt, [["render", Ft]]), Ht = {
|
|
949
951
|
class: "router-tabs",
|
|
950
952
|
"aria-hidden": "true"
|
|
951
|
-
},
|
|
953
|
+
}, de = /* @__PURE__ */ Oe({
|
|
952
954
|
name: "RouterTabs",
|
|
953
955
|
__name: "RouterTabs",
|
|
954
956
|
props: {
|
|
@@ -963,9 +965,9 @@ const Le = /* @__PURE__ */ Bt($t, [["render", zt]]), Yt = {
|
|
|
963
965
|
fallbackRoute: {}
|
|
964
966
|
},
|
|
965
967
|
setup(e) {
|
|
966
|
-
return
|
|
968
|
+
return Ve(e), (o, l) => (P(), S("span", Ht));
|
|
967
969
|
}
|
|
968
|
-
}),
|
|
970
|
+
}), Ne = "tab-theme-style", ze = "tab-theme-primary-color", Jt = "system", _e = "(prefers-color-scheme: dark)";
|
|
969
971
|
let W = null;
|
|
970
972
|
const C = {
|
|
971
973
|
primary: "#034960",
|
|
@@ -981,7 +983,7 @@ const C = {
|
|
|
981
983
|
activeButtonBackground: "#034960",
|
|
982
984
|
activeButtonColor: "#ffffff",
|
|
983
985
|
iconColor: "#475569"
|
|
984
|
-
},
|
|
986
|
+
}, Wt = {
|
|
985
987
|
primary: "#38bdf8",
|
|
986
988
|
background: "#0f172a",
|
|
987
989
|
text: "#f1f5f9",
|
|
@@ -997,7 +999,7 @@ const C = {
|
|
|
997
999
|
activeButtonColor: "#0f172a",
|
|
998
1000
|
iconColor: "#cbd5e1"
|
|
999
1001
|
};
|
|
1000
|
-
function
|
|
1002
|
+
function Gt(e) {
|
|
1001
1003
|
if (typeof window > "u") return null;
|
|
1002
1004
|
const n = window.localStorage.getItem(e);
|
|
1003
1005
|
if (!n) return null;
|
|
@@ -1008,50 +1010,50 @@ function Jt(e) {
|
|
|
1008
1010
|
return null;
|
|
1009
1011
|
}
|
|
1010
1012
|
}
|
|
1011
|
-
function
|
|
1013
|
+
function ve(e) {
|
|
1012
1014
|
typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? C.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? C.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? C.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? C.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? C.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? C.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? C.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? C.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? C.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? C.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? C.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? C.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? C.iconColor));
|
|
1013
1015
|
}
|
|
1014
|
-
function
|
|
1016
|
+
function Ye(e) {
|
|
1015
1017
|
if (typeof document > "u") return;
|
|
1016
|
-
const n = document.documentElement, o = window.matchMedia(
|
|
1018
|
+
const n = document.documentElement, o = window.matchMedia(_e), l = () => {
|
|
1017
1019
|
n.dataset.theme = o.matches ? "dark" : "light";
|
|
1018
1020
|
};
|
|
1019
1021
|
W && (o.removeEventListener("change", W), W = null), e === "system" ? (l(), W = () => l(), o.addEventListener("change", W)) : n.dataset.theme = e;
|
|
1020
1022
|
}
|
|
1021
|
-
function
|
|
1023
|
+
function Xt(e = {}) {
|
|
1022
1024
|
if (typeof window > "u") return;
|
|
1023
1025
|
const {
|
|
1024
|
-
styleKey: n =
|
|
1026
|
+
styleKey: n = Ne,
|
|
1025
1027
|
primaryKey: o = ze,
|
|
1026
|
-
defaultStyle: l =
|
|
1027
|
-
defaultPrimary:
|
|
1028
|
+
defaultStyle: l = Jt,
|
|
1029
|
+
defaultPrimary: i
|
|
1028
1030
|
} = e, p = window.localStorage.getItem(n) ?? l;
|
|
1029
|
-
|
|
1030
|
-
const s = p === "dark" || p === "system" && window.matchMedia(
|
|
1031
|
-
|
|
1032
|
-
const c =
|
|
1033
|
-
|
|
1031
|
+
Ye(p);
|
|
1032
|
+
const s = p === "dark" || p === "system" && window.matchMedia(_e).matches ? { ...Wt } : { ...C };
|
|
1033
|
+
i && (s.primary = i);
|
|
1034
|
+
const c = Gt(o);
|
|
1035
|
+
ve(c ? {
|
|
1034
1036
|
...s,
|
|
1035
1037
|
...c
|
|
1036
1038
|
} : s);
|
|
1037
1039
|
}
|
|
1038
|
-
function
|
|
1040
|
+
function Zt(e, n) {
|
|
1039
1041
|
if (typeof window > "u") return;
|
|
1040
|
-
const o = n?.styleKey ??
|
|
1041
|
-
window.localStorage.setItem(o, e),
|
|
1042
|
+
const o = n?.styleKey ?? Ne;
|
|
1043
|
+
window.localStorage.setItem(o, e), Ye(e);
|
|
1042
1044
|
}
|
|
1043
|
-
function
|
|
1045
|
+
function en(e, n) {
|
|
1044
1046
|
if (typeof window > "u") return;
|
|
1045
1047
|
const o = n?.primaryKey ?? ze;
|
|
1046
|
-
window.localStorage.setItem(o, JSON.stringify(e)),
|
|
1048
|
+
window.localStorage.setItem(o, JSON.stringify(e)), ve(e);
|
|
1047
1049
|
}
|
|
1048
|
-
function
|
|
1049
|
-
if (
|
|
1050
|
-
const l = !
|
|
1050
|
+
function Q(e, n) {
|
|
1051
|
+
if (Ct(e)) {
|
|
1052
|
+
const l = !Rt(e);
|
|
1051
1053
|
return {
|
|
1052
1054
|
value: e,
|
|
1053
|
-
update: l ? (
|
|
1054
|
-
e.value =
|
|
1055
|
+
update: l ? (i) => {
|
|
1056
|
+
e.value = i;
|
|
1055
1057
|
} : () => {
|
|
1056
1058
|
}
|
|
1057
1059
|
};
|
|
@@ -1072,80 +1074,80 @@ function te(e, n) {
|
|
|
1072
1074
|
}
|
|
1073
1075
|
};
|
|
1074
1076
|
}
|
|
1075
|
-
function
|
|
1076
|
-
const n =
|
|
1077
|
+
function ye(e = {}) {
|
|
1078
|
+
const n = Q(e.title, "Untitled"), o = Q(e.icon, ""), l = Q(e.closable, !0), i = Q(e.meta, {});
|
|
1077
1079
|
return {
|
|
1078
1080
|
routeTabTitle: n.value,
|
|
1079
1081
|
routeTabIcon: o.value,
|
|
1080
1082
|
routeTabClosable: l.value,
|
|
1081
|
-
routeTabMeta:
|
|
1083
|
+
routeTabMeta: i.value,
|
|
1082
1084
|
updateTitle: n.update,
|
|
1083
1085
|
updateIcon: o.update,
|
|
1084
1086
|
updateClosable: l.update,
|
|
1085
|
-
updateMeta:
|
|
1087
|
+
updateMeta: i.update
|
|
1086
1088
|
};
|
|
1087
1089
|
}
|
|
1088
|
-
function
|
|
1089
|
-
return
|
|
1090
|
+
function tn(e, n = "Page") {
|
|
1091
|
+
return ye({
|
|
1090
1092
|
title: k(() => e.value ? "Loading..." : n),
|
|
1091
1093
|
icon: k(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
|
|
1092
1094
|
closable: k(() => !e.value)
|
|
1093
1095
|
});
|
|
1094
1096
|
}
|
|
1095
|
-
function
|
|
1096
|
-
return
|
|
1097
|
+
function nn(e, n = "Page", o = "mdi-page") {
|
|
1098
|
+
return ye({
|
|
1097
1099
|
title: k(() => e.value > 0 ? `${n} (${e.value})` : n),
|
|
1098
1100
|
icon: k(() => e.value > 0 ? "mdi-bell-badge" : o)
|
|
1099
1101
|
});
|
|
1100
1102
|
}
|
|
1101
|
-
function
|
|
1103
|
+
function on(e, n = "Page") {
|
|
1102
1104
|
const o = {
|
|
1103
1105
|
normal: { suffix: "", icon: "mdi-page" },
|
|
1104
1106
|
loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
|
|
1105
1107
|
error: { suffix: " - Error", icon: "mdi-alert" },
|
|
1106
1108
|
success: { suffix: " - Success", icon: "mdi-check-circle" }
|
|
1107
1109
|
};
|
|
1108
|
-
return
|
|
1110
|
+
return ye({
|
|
1109
1111
|
title: k(() => n + o[e.value].suffix),
|
|
1110
1112
|
icon: k(() => o[e.value].icon),
|
|
1111
1113
|
closable: k(() => e.value !== "loading")
|
|
1112
1114
|
});
|
|
1113
1115
|
}
|
|
1114
|
-
let
|
|
1115
|
-
const
|
|
1116
|
+
let Le = !1;
|
|
1117
|
+
const an = {
|
|
1116
1118
|
install(e, n) {
|
|
1117
|
-
if (
|
|
1118
|
-
|
|
1119
|
+
if (Le) return;
|
|
1120
|
+
Le = !0;
|
|
1119
1121
|
const {
|
|
1120
1122
|
initTheme: o = !0,
|
|
1121
1123
|
themeOptions: l,
|
|
1122
|
-
componentName:
|
|
1123
|
-
tabsComponentName: p =
|
|
1124
|
+
componentName: i = Me.name || "RouterTab",
|
|
1125
|
+
tabsComponentName: p = de.name || "RouterTabs"
|
|
1124
1126
|
} = n ?? {};
|
|
1125
|
-
o &&
|
|
1127
|
+
o && Xt(l ?? {}), e.component(i, Me), e.component(p, de), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", de), Object.defineProperty(e.config.globalProperties, "$tabs", {
|
|
1126
1128
|
configurable: !0,
|
|
1127
1129
|
enumerable: !1,
|
|
1128
1130
|
get() {
|
|
1129
|
-
return e._context.provides[
|
|
1131
|
+
return e._context.provides[ee];
|
|
1130
1132
|
},
|
|
1131
1133
|
set(T) {
|
|
1132
|
-
T && e.provide(
|
|
1134
|
+
T && e.provide(ee, T);
|
|
1133
1135
|
}
|
|
1134
1136
|
});
|
|
1135
1137
|
}
|
|
1136
1138
|
};
|
|
1137
1139
|
export {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1140
|
+
Me as RouterTab,
|
|
1141
|
+
de as RouterTabs,
|
|
1142
|
+
an as default,
|
|
1143
|
+
Xt as initRouterTabsTheme,
|
|
1144
|
+
ee as routerTabsKey,
|
|
1145
|
+
en as setRouterTabsPrimary,
|
|
1146
|
+
Zt as setRouterTabsTheme,
|
|
1147
|
+
tn as useLoadingTab,
|
|
1148
|
+
nn as useNotificationTab,
|
|
1149
|
+
ye as useReactiveTab,
|
|
1150
|
+
Se as useRouterTabs,
|
|
1151
|
+
Ve as useRouterTabsPersistence,
|
|
1152
|
+
on as useStatusTab
|
|
1151
1153
|
};
|