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