vue3-router-tab 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -2
- package/dist/vue3-router-tab.css +1 -1
- package/dist/vue3-router-tab.js +592 -460
- package/dist/vue3-router-tab.umd.cjs +1 -1
- package/lib/components/RouterTab.vue +179 -15
- package/lib/core/createRouterTabs.ts +18 -14
- package/lib/index.ts +12 -0
- package/lib/scss/index.scss +12 -0
- package/lib/theme.ts +2 -2
- package/lib/useReactiveTab.ts +130 -0
- package/package.json +8 -3
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 le, ref as K, shallowRef as qe, computed as h, watch as x, nextTick as se, inject as ge, getCurrentInstance as De, onMounted as ue, defineComponent as Be, provide as Qe, onBeforeUnmount as Xe, resolveComponent as Ze, createElementBlock as I, openBlock as w, createElementVNode as S, createCommentVNode as M, renderSlot as ne, createVNode as J, TransitionGroup as et, mergeProps as G, withCtx as W, Fragment as oe, renderList as ye, withModifiers as H, normalizeClass as he, toDisplayString as Te, normalizeProps as tt, Transition as ke, createBlock as ae, KeepAlive as nt, resolveDynamicComponent as Ce, normalizeStyle as ot } from "vue";
|
|
3
|
+
import { RouterView as at } from "vue-router";
|
|
4
|
+
function it(e = {}) {
|
|
5
5
|
return {
|
|
6
6
|
initialTabs: e.initialTabs ?? [],
|
|
7
7
|
keepAlive: e.keepAlive ?? !0,
|
|
@@ -11,79 +11,70 @@ function qe(e = {}) {
|
|
|
11
11
|
defaultRoute: e.defaultRoute ?? "/"
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
throw new Error(`[RouterTabs] Unable to resolve route: ${String(
|
|
18
|
-
return
|
|
14
|
+
function _(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 rt = {
|
|
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 j(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 = rt[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 ce(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 fe(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 $e(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
|
|
51
|
-
const
|
|
50
|
+
function q(e, n, o) {
|
|
51
|
+
const i = $e(e);
|
|
52
52
|
return {
|
|
53
|
-
id:
|
|
53
|
+
id: j(e),
|
|
54
54
|
to: e.fullPath,
|
|
55
55
|
fullPath: e.fullPath,
|
|
56
56
|
matched: e,
|
|
57
|
-
alive:
|
|
58
|
-
reusable:
|
|
59
|
-
closable:
|
|
60
|
-
...
|
|
61
|
-
...
|
|
57
|
+
alive: ce(e, o),
|
|
58
|
+
reusable: fe(e, !1),
|
|
59
|
+
closable: i.closable ?? !0,
|
|
60
|
+
...i,
|
|
61
|
+
...n
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
if (t === "next" && r) {
|
|
67
|
-
const b = e.findIndex((m) => m.id === r);
|
|
68
|
-
if (b > -1) {
|
|
69
|
-
e.splice(b + 1, 0, o);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
e.push(o);
|
|
74
|
-
}
|
|
64
|
+
function ie(e, n, o, i) {
|
|
65
|
+
e.find((p) => p.id === n.id) || e.push(n);
|
|
75
66
|
}
|
|
76
|
-
function
|
|
77
|
-
if (!
|
|
78
|
-
const
|
|
79
|
-
for (;
|
|
80
|
-
const a =
|
|
81
|
-
if (!a || a.id ===
|
|
82
|
-
const
|
|
83
|
-
|
|
67
|
+
function Re(e, n, o) {
|
|
68
|
+
if (!n || n <= 0) return;
|
|
69
|
+
const i = e.filter((a) => a.alive);
|
|
70
|
+
for (; i.length > n; ) {
|
|
71
|
+
const a = i.shift();
|
|
72
|
+
if (!a || a.id === o) continue;
|
|
73
|
+
const p = e.findIndex((y) => y.id === a.id);
|
|
74
|
+
p > -1 && (e[p].alive = !1);
|
|
84
75
|
}
|
|
85
76
|
}
|
|
86
|
-
function
|
|
77
|
+
function lt(e) {
|
|
87
78
|
return {
|
|
88
79
|
to: e.to,
|
|
89
80
|
title: e.title,
|
|
@@ -93,173 +84,171 @@ function We(e) {
|
|
|
93
84
|
closable: e.closable
|
|
94
85
|
};
|
|
95
86
|
}
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
return "title" in e && (
|
|
87
|
+
function st(e) {
|
|
88
|
+
const n = {};
|
|
89
|
+
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), n;
|
|
99
90
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
let
|
|
103
|
-
function
|
|
104
|
-
const
|
|
91
|
+
function ut(e, n = {}) {
|
|
92
|
+
const o = it(n), i = le([]), a = K(null), p = qe(), y = K(null), s = h(() => i.filter((l) => l.alive).map((l) => l.id));
|
|
93
|
+
let u = !1;
|
|
94
|
+
function m(l) {
|
|
95
|
+
const f = typeof l.matched == "object" ? l : _(e, l);
|
|
105
96
|
return {
|
|
106
|
-
key:
|
|
107
|
-
fullPath:
|
|
108
|
-
alive:
|
|
109
|
-
reusable:
|
|
110
|
-
matched:
|
|
97
|
+
key: j(f),
|
|
98
|
+
fullPath: f.fullPath,
|
|
99
|
+
alive: ce(f, o.keepAlive),
|
|
100
|
+
reusable: fe(f, !1),
|
|
101
|
+
matched: f
|
|
111
102
|
};
|
|
112
103
|
}
|
|
113
|
-
function
|
|
114
|
-
const
|
|
115
|
-
let d =
|
|
116
|
-
return d ? (d.fullPath =
|
|
104
|
+
function k(l) {
|
|
105
|
+
const f = j(l);
|
|
106
|
+
let d = i.find((v) => v.id === f);
|
|
107
|
+
return d ? (d.fullPath = l.fullPath, d.to = l.fullPath, d.matched = l, d.alive = ce(l, o.keepAlive), d.reusable = fe(l, d.reusable), Object.assign(d, $e(l)), d) : (d = q(l, {}, o.keepAlive), ie(i, d, o.appendPosition, a.value), Re(i, o.maxAlive, a.value), d);
|
|
117
108
|
}
|
|
118
|
-
async function
|
|
119
|
-
const
|
|
120
|
-
d === "sameTab" && (d =
|
|
109
|
+
async function B(l, f = !1, d = !0) {
|
|
110
|
+
const v = _(e, l), P = j(v), D = a.value === P;
|
|
111
|
+
d === "sameTab" && (d = D), d && await L(P, !0), await e[f ? "replace" : "push"](v), D && await N();
|
|
121
112
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
|
|
113
|
+
function O(l) {
|
|
114
|
+
const f = i.findIndex(($) => $.id === l);
|
|
115
|
+
if (f === -1) return o.defaultRoute;
|
|
116
|
+
const d = i[f + 1], v = i[f - 1], P = i.find(($) => $.id !== l), D = d || v || P;
|
|
117
|
+
return D ? D.to : o.defaultRoute;
|
|
125
118
|
}
|
|
126
|
-
async function
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const d = c.redirect ?? _(i);
|
|
133
|
-
d && await e.replace(d);
|
|
134
|
-
} else c.redirect && await e.replace(c.redirect);
|
|
135
|
-
}
|
|
119
|
+
async function A(l = a.value, f = {}) {
|
|
120
|
+
if (!l) return;
|
|
121
|
+
if (!f.force && o.keepLastTab && i.length === 1)
|
|
122
|
+
throw new Error("[RouterTabs] Unable to close the final tab when keepLastTab is true.");
|
|
123
|
+
const v = a.value === l && f.redirect !== null, P = v ? f.redirect ?? O(l) : null;
|
|
124
|
+
await z(l, { force: f.force }), f.redirect !== null && v && P && await e.replace(P);
|
|
136
125
|
}
|
|
137
|
-
async function
|
|
138
|
-
const d =
|
|
139
|
-
d !== -1 && (
|
|
126
|
+
async function z(l, f = {}) {
|
|
127
|
+
const d = i.findIndex((v) => v.id === l);
|
|
128
|
+
d !== -1 && (i.splice(d, 1), y.value === l && (y.value = null), a.value === l && (a.value = null, p.value = void 0));
|
|
140
129
|
}
|
|
141
|
-
async function
|
|
142
|
-
|
|
130
|
+
async function L(l = a.value ?? void 0, f = !1) {
|
|
131
|
+
l && (y.value = l, await se(), f || await se(), y.value = null);
|
|
143
132
|
}
|
|
144
|
-
async function
|
|
145
|
-
for (const
|
|
146
|
-
await
|
|
133
|
+
async function R(l = !1) {
|
|
134
|
+
for (const f of i)
|
|
135
|
+
await L(f.id, l);
|
|
147
136
|
}
|
|
148
|
-
async function
|
|
149
|
-
|
|
150
|
-
for (const
|
|
151
|
-
const d =
|
|
152
|
-
|
|
137
|
+
async function g(l = o.defaultRoute) {
|
|
138
|
+
i.splice(0, i.length), a.value = null, p.value = void 0;
|
|
139
|
+
for (const f of o.initialTabs) {
|
|
140
|
+
const d = _(e, f.to), v = q(d, f, o.keepAlive);
|
|
141
|
+
i.push(v);
|
|
153
142
|
}
|
|
154
|
-
await e.replace(
|
|
143
|
+
await e.replace(l);
|
|
155
144
|
}
|
|
156
|
-
async function
|
|
157
|
-
const
|
|
158
|
-
|
|
145
|
+
async function N() {
|
|
146
|
+
const l = a.value;
|
|
147
|
+
l && await L(l, !0);
|
|
159
148
|
}
|
|
160
|
-
function
|
|
161
|
-
return typeof
|
|
149
|
+
function U(l) {
|
|
150
|
+
return typeof l.matched == "object" ? j(l) : j(_(e, l));
|
|
162
151
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
152
|
+
function Y() {
|
|
153
|
+
const l = i.find((f) => f.id === a.value);
|
|
165
154
|
return {
|
|
166
|
-
tabs:
|
|
167
|
-
active:
|
|
155
|
+
tabs: i.map(lt),
|
|
156
|
+
active: l ? l.to : null
|
|
168
157
|
};
|
|
169
158
|
}
|
|
170
|
-
async function
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
for (const
|
|
159
|
+
async function F(l) {
|
|
160
|
+
u = !0, i.splice(0, i.length), a.value = null, p.value = void 0;
|
|
161
|
+
const f = l?.tabs ?? [];
|
|
162
|
+
for (const v of f)
|
|
174
163
|
try {
|
|
175
|
-
const P =
|
|
176
|
-
|
|
164
|
+
const P = _(e, v.to), D = st(v), $ = q(P, D, o.keepAlive);
|
|
165
|
+
ie(i, $, "last", null);
|
|
177
166
|
} catch {
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
const d =
|
|
168
|
+
u = !1;
|
|
169
|
+
const d = l?.active ?? f[f.length - 1]?.to ?? o.defaultRoute;
|
|
181
170
|
if (d)
|
|
182
171
|
try {
|
|
183
172
|
await e.replace(d);
|
|
184
173
|
} catch {
|
|
185
174
|
}
|
|
186
175
|
}
|
|
187
|
-
return
|
|
176
|
+
return x(
|
|
188
177
|
() => e.currentRoute.value,
|
|
189
|
-
(
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
a.value =
|
|
178
|
+
(l) => {
|
|
179
|
+
if (u) return;
|
|
180
|
+
const f = k(l);
|
|
181
|
+
a.value = f.id, p.value = f, Re(i, o.maxAlive, a.value);
|
|
193
182
|
},
|
|
194
183
|
{ immediate: !0 }
|
|
195
|
-
),
|
|
196
|
-
const
|
|
197
|
-
|
|
184
|
+
), o.initialTabs.length && o.initialTabs.forEach((l) => {
|
|
185
|
+
const f = _(e, l.to), d = q(f, l, o.keepAlive);
|
|
186
|
+
ie(i, d);
|
|
198
187
|
}), {
|
|
199
|
-
options:
|
|
200
|
-
tabs:
|
|
188
|
+
options: o,
|
|
189
|
+
tabs: i,
|
|
201
190
|
activeId: a,
|
|
202
|
-
current:
|
|
203
|
-
includeKeys:
|
|
204
|
-
refreshingKey:
|
|
205
|
-
openTab:
|
|
206
|
-
closeTab:
|
|
207
|
-
removeTab:
|
|
208
|
-
refreshTab:
|
|
209
|
-
refreshAll:
|
|
210
|
-
reset:
|
|
211
|
-
reload:
|
|
212
|
-
getRouteKey:
|
|
213
|
-
matchRoute:
|
|
214
|
-
snapshot:
|
|
215
|
-
hydrate:
|
|
191
|
+
current: p,
|
|
192
|
+
includeKeys: s,
|
|
193
|
+
refreshingKey: y,
|
|
194
|
+
openTab: B,
|
|
195
|
+
closeTab: A,
|
|
196
|
+
removeTab: z,
|
|
197
|
+
refreshTab: L,
|
|
198
|
+
refreshAll: R,
|
|
199
|
+
reset: g,
|
|
200
|
+
reload: N,
|
|
201
|
+
getRouteKey: U,
|
|
202
|
+
matchRoute: m,
|
|
203
|
+
snapshot: Y,
|
|
204
|
+
hydrate: F
|
|
216
205
|
};
|
|
217
206
|
}
|
|
218
|
-
function
|
|
207
|
+
function we(e) {
|
|
219
208
|
return e ? typeof e == "string" ? { name: e } : e : {};
|
|
220
209
|
}
|
|
221
|
-
const
|
|
222
|
-
function
|
|
223
|
-
const { optional:
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
if (!
|
|
210
|
+
const X = Symbol("RouterTabsContext"), Q = "router-tabs:snapshot";
|
|
211
|
+
function Pe(e = {}) {
|
|
212
|
+
const { optional: n = !1 } = e, o = ge(X, null);
|
|
213
|
+
if (o) return o;
|
|
214
|
+
const i = ge("$tabs", null);
|
|
215
|
+
if (i) return i;
|
|
216
|
+
const p = De()?.appContext.config.globalProperties.$tabs;
|
|
217
|
+
if (p) return p;
|
|
218
|
+
if (!n)
|
|
230
219
|
throw new Error("[RouterTabs] useRouterTabs must be used within <router-tab>.");
|
|
231
220
|
return null;
|
|
232
221
|
}
|
|
233
|
-
const
|
|
234
|
-
function
|
|
222
|
+
const ct = 864e5;
|
|
223
|
+
function ft(e) {
|
|
235
224
|
if (typeof document > "u") return null;
|
|
236
|
-
const
|
|
237
|
-
for (const
|
|
238
|
-
if (
|
|
239
|
-
return decodeURIComponent(
|
|
225
|
+
const n = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
|
|
226
|
+
for (const i of o)
|
|
227
|
+
if (i.startsWith(n))
|
|
228
|
+
return decodeURIComponent(i.slice(n.length));
|
|
240
229
|
return null;
|
|
241
230
|
}
|
|
242
|
-
function
|
|
231
|
+
function Ae(e, n, o) {
|
|
243
232
|
if (typeof document > "u") return;
|
|
244
233
|
const {
|
|
245
|
-
expiresInDays:
|
|
234
|
+
expiresInDays: i = 7,
|
|
246
235
|
path: a = "/",
|
|
247
|
-
domain:
|
|
248
|
-
secure:
|
|
249
|
-
sameSite:
|
|
250
|
-
} =
|
|
251
|
-
if (
|
|
252
|
-
const
|
|
253
|
-
|
|
236
|
+
domain: p,
|
|
237
|
+
secure: y,
|
|
238
|
+
sameSite: s = "lax"
|
|
239
|
+
} = o, u = [`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];
|
|
240
|
+
if (i !== 1 / 0) {
|
|
241
|
+
const m = new Date(Date.now() + i * ct).toUTCString();
|
|
242
|
+
u.push(`Expires=${m}`);
|
|
254
243
|
}
|
|
255
|
-
a &&
|
|
244
|
+
a && u.push(`Path=${a}`), p && u.push(`Domain=${p}`), y && u.push("Secure"), s && u.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = u.join("; ");
|
|
256
245
|
}
|
|
257
|
-
function
|
|
246
|
+
function Ee(e, n) {
|
|
258
247
|
if (typeof document > "u") return;
|
|
259
|
-
const { path:
|
|
260
|
-
a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"),
|
|
248
|
+
const { path: o = "/", domain: i } = n, a = [`${encodeURIComponent(e)}=`];
|
|
249
|
+
a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && a.push(`Path=${o}`), i && a.push(`Domain=${i}`), document.cookie = a.join("; ");
|
|
261
250
|
}
|
|
262
|
-
const
|
|
251
|
+
const dt = (e) => JSON.stringify(e ?? null), bt = (e) => {
|
|
263
252
|
if (!e) return null;
|
|
264
253
|
try {
|
|
265
254
|
return JSON.parse(e);
|
|
@@ -267,62 +256,62 @@ const nt = (e) => JSON.stringify(e ?? null), ot = (e) => {
|
|
|
267
256
|
return null;
|
|
268
257
|
}
|
|
269
258
|
};
|
|
270
|
-
function
|
|
259
|
+
function Ke(e = {}) {
|
|
271
260
|
const {
|
|
272
|
-
cookieKey:
|
|
273
|
-
serialize:
|
|
274
|
-
deserialize:
|
|
275
|
-
} = e, a =
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
261
|
+
cookieKey: n = Q,
|
|
262
|
+
serialize: o = dt,
|
|
263
|
+
deserialize: i = bt
|
|
264
|
+
} = e, a = Pe({ optional: !0 }), p = K(!0), y = (s) => {
|
|
265
|
+
ue(async () => {
|
|
266
|
+
const u = i(ft(n));
|
|
267
|
+
if (u && u.tabs?.length)
|
|
279
268
|
try {
|
|
280
|
-
if (
|
|
281
|
-
await
|
|
282
|
-
const
|
|
283
|
-
|
|
269
|
+
if (p.value = !0, await s.hydrate(u), u.active) {
|
|
270
|
+
await se();
|
|
271
|
+
const k = s.tabs.find((B) => B.to === u.active);
|
|
272
|
+
k && (s.activeId.value = k.id, s.current.value = k);
|
|
284
273
|
}
|
|
285
274
|
} finally {
|
|
286
|
-
|
|
275
|
+
p.value = !1;
|
|
287
276
|
}
|
|
288
277
|
else
|
|
289
278
|
try {
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
await
|
|
279
|
+
p.value = !0;
|
|
280
|
+
const k = e.fallbackRoute ?? s.options.defaultRoute;
|
|
281
|
+
await s.reset(k);
|
|
293
282
|
} finally {
|
|
294
|
-
|
|
283
|
+
p.value = !1;
|
|
295
284
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
}),
|
|
285
|
+
const m = s.snapshot();
|
|
286
|
+
m.tabs.length ? Ae(n, o(m), e) : Ee(n, e), p.value = !1;
|
|
287
|
+
}), x(
|
|
299
288
|
() => ({
|
|
300
|
-
tabs:
|
|
301
|
-
to:
|
|
302
|
-
title:
|
|
303
|
-
tips:
|
|
304
|
-
icon:
|
|
305
|
-
tabClass:
|
|
306
|
-
closable:
|
|
289
|
+
tabs: s.tabs.map((u) => ({
|
|
290
|
+
to: u.to,
|
|
291
|
+
title: u.title,
|
|
292
|
+
tips: u.tips,
|
|
293
|
+
icon: u.icon,
|
|
294
|
+
tabClass: u.tabClass,
|
|
295
|
+
closable: u.closable
|
|
307
296
|
})),
|
|
308
|
-
active:
|
|
297
|
+
active: s.activeId.value
|
|
309
298
|
}),
|
|
310
299
|
() => {
|
|
311
|
-
if (
|
|
312
|
-
const
|
|
313
|
-
|
|
300
|
+
if (p.value) return;
|
|
301
|
+
const u = s.snapshot();
|
|
302
|
+
u.tabs.length ? Ae(n, o(u), e) : Ee(n, e);
|
|
314
303
|
},
|
|
315
304
|
{ deep: !0 }
|
|
316
305
|
);
|
|
317
306
|
};
|
|
318
|
-
a ?
|
|
319
|
-
const
|
|
320
|
-
|
|
307
|
+
a ? y(a) : ue(() => {
|
|
308
|
+
const s = Pe({ optional: !0 });
|
|
309
|
+
s && y(s);
|
|
321
310
|
});
|
|
322
311
|
}
|
|
323
|
-
const
|
|
312
|
+
const pt = Be({
|
|
324
313
|
name: "RouterTab",
|
|
325
|
-
components: { RouterView:
|
|
314
|
+
components: { RouterView: at },
|
|
326
315
|
props: {
|
|
327
316
|
tabs: {
|
|
328
317
|
type: Array,
|
|
@@ -362,7 +351,7 @@ const at = Ae({
|
|
|
362
351
|
},
|
|
363
352
|
cookieKey: {
|
|
364
353
|
type: String,
|
|
365
|
-
default:
|
|
354
|
+
default: Q
|
|
366
355
|
},
|
|
367
356
|
persistence: {
|
|
368
357
|
type: Object,
|
|
@@ -371,21 +360,17 @@ const at = Ae({
|
|
|
371
360
|
sortable: {
|
|
372
361
|
type: Boolean,
|
|
373
362
|
default: !0
|
|
374
|
-
},
|
|
375
|
-
titleResolver: {
|
|
376
|
-
type: Function,
|
|
377
|
-
default: null
|
|
378
363
|
}
|
|
379
364
|
},
|
|
380
365
|
emits: ["tab-sort", "tab-sorted"],
|
|
381
|
-
setup(e, { emit:
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
366
|
+
setup(e, { emit: n }) {
|
|
367
|
+
const o = De();
|
|
368
|
+
if (!o)
|
|
384
369
|
throw new Error("[RouterTab] component must be used within a Vue application context.");
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
370
|
+
const i = o.appContext.app.config.globalProperties.$router;
|
|
371
|
+
if (!i)
|
|
387
372
|
throw new Error("[RouterTab] Vue Router is required. Make sure to call app.use(router) before RouterTab.");
|
|
388
|
-
const a =
|
|
373
|
+
const a = ut(i, {
|
|
389
374
|
initialTabs: e.tabs,
|
|
390
375
|
keepAlive: e.keepAlive,
|
|
391
376
|
maxAlive: e.maxAlive,
|
|
@@ -393,24 +378,105 @@ const at = Ae({
|
|
|
393
378
|
appendPosition: e.append,
|
|
394
379
|
defaultRoute: e.defaultPage
|
|
395
380
|
});
|
|
396
|
-
|
|
397
|
-
const
|
|
381
|
+
Qe(X, a), o.appContext.config.globalProperties.$tabs = a;
|
|
382
|
+
const p = h(() => !!o?.slots?.default), y = K(0), s = h(() => {
|
|
383
|
+
y.value;
|
|
384
|
+
const t = {};
|
|
385
|
+
return a.tabs.forEach((r) => {
|
|
386
|
+
const b = typeof r.title == "string" ? r.title : String(r.title || Z(r));
|
|
387
|
+
t[r.id] = b;
|
|
388
|
+
}), t;
|
|
389
|
+
});
|
|
390
|
+
function u() {
|
|
391
|
+
y.value++;
|
|
392
|
+
}
|
|
393
|
+
const m = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
|
|
394
|
+
function B(t, r) {
|
|
395
|
+
if (!r || m.has(t)) return;
|
|
396
|
+
m.set(t, r);
|
|
397
|
+
const b = a.tabs.find((E) => a.getRouteKey(E.to) === t);
|
|
398
|
+
if (!b) return;
|
|
399
|
+
const T = [];
|
|
400
|
+
if (r.routeTabTitle !== void 0) {
|
|
401
|
+
const E = x(
|
|
402
|
+
() => {
|
|
403
|
+
const c = r.routeTabTitle;
|
|
404
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
405
|
+
},
|
|
406
|
+
(c) => {
|
|
407
|
+
if (c != null) {
|
|
408
|
+
const me = String(c);
|
|
409
|
+
b.title = me, u();
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
{ immediate: !0 }
|
|
413
|
+
);
|
|
414
|
+
T.push(E);
|
|
415
|
+
}
|
|
416
|
+
if (r.routeTabIcon !== void 0) {
|
|
417
|
+
const E = x(
|
|
418
|
+
() => {
|
|
419
|
+
const c = r.routeTabIcon;
|
|
420
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
421
|
+
},
|
|
422
|
+
(c) => {
|
|
423
|
+
c != null && (b.icon = String(c), u());
|
|
424
|
+
},
|
|
425
|
+
{ immediate: !0 }
|
|
426
|
+
);
|
|
427
|
+
T.push(E);
|
|
428
|
+
}
|
|
429
|
+
if (r.routeTabClosable !== void 0) {
|
|
430
|
+
const E = x(
|
|
431
|
+
() => {
|
|
432
|
+
const c = r.routeTabClosable;
|
|
433
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
434
|
+
},
|
|
435
|
+
(c) => {
|
|
436
|
+
c != null && (b.closable = !!c, u());
|
|
437
|
+
},
|
|
438
|
+
{ immediate: !0 }
|
|
439
|
+
);
|
|
440
|
+
T.push(E);
|
|
441
|
+
}
|
|
442
|
+
if (r.routeTabMeta !== void 0) {
|
|
443
|
+
const E = x(
|
|
444
|
+
() => {
|
|
445
|
+
const c = r.routeTabMeta;
|
|
446
|
+
return c && typeof c == "object" && "value" in c ? c.value : c;
|
|
447
|
+
},
|
|
448
|
+
(c) => {
|
|
449
|
+
c && typeof c == "object" && (Object.assign(b, c), u());
|
|
450
|
+
},
|
|
451
|
+
{ immediate: !0, deep: !0 }
|
|
452
|
+
);
|
|
453
|
+
T.push(E);
|
|
454
|
+
}
|
|
455
|
+
k.set(t, T);
|
|
456
|
+
}
|
|
457
|
+
function O(t) {
|
|
458
|
+
const r = k.get(t);
|
|
459
|
+
r && (r.forEach((b) => b()), k.delete(t)), m.delete(t);
|
|
460
|
+
}
|
|
461
|
+
function A(t, r) {
|
|
462
|
+
t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? B(r, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && B(r, t.$) : t === null && O(r);
|
|
463
|
+
}
|
|
398
464
|
if (e.cookieKey !== null || e.persistence) {
|
|
399
|
-
const
|
|
465
|
+
const t = {
|
|
400
466
|
...e.persistence ?? {}
|
|
401
467
|
};
|
|
402
|
-
e.cookieKey !== null ?
|
|
468
|
+
e.cookieKey !== null ? t.cookieKey = e.cookieKey || Q : t.cookieKey || (t.cookieKey = Q), Ke(t);
|
|
403
469
|
}
|
|
404
|
-
const
|
|
470
|
+
const z = h(() => we(e.tabTransition)), L = h(() => we(e.pageTransition)), R = le({
|
|
405
471
|
visible: !1,
|
|
406
472
|
target: null,
|
|
407
473
|
position: { x: 0, y: 0 }
|
|
408
|
-
}),
|
|
474
|
+
}), g = le({
|
|
409
475
|
dragging: !1,
|
|
410
476
|
dragIndex: -1,
|
|
411
477
|
dropIndex: -1,
|
|
412
478
|
dragTab: null
|
|
413
|
-
}),
|
|
479
|
+
}), N = [
|
|
414
480
|
"refresh",
|
|
415
481
|
"refreshAll",
|
|
416
482
|
"close",
|
|
@@ -418,33 +484,33 @@ const at = Ae({
|
|
|
418
484
|
"closeRights",
|
|
419
485
|
"closeOthers"
|
|
420
486
|
];
|
|
421
|
-
function
|
|
422
|
-
return a.tabs.findIndex((
|
|
487
|
+
function U(t) {
|
|
488
|
+
return a.tabs.findIndex((r) => r.id === t);
|
|
423
489
|
}
|
|
424
|
-
function
|
|
425
|
-
const
|
|
426
|
-
return
|
|
490
|
+
function Y(t) {
|
|
491
|
+
const r = U(t.id);
|
|
492
|
+
return r > 0 ? a.tabs.slice(0, r) : [];
|
|
427
493
|
}
|
|
428
|
-
function
|
|
429
|
-
const
|
|
430
|
-
return
|
|
494
|
+
function F(t) {
|
|
495
|
+
const r = U(t.id);
|
|
496
|
+
return r > -1 ? a.tabs.slice(r + 1) : [];
|
|
431
497
|
}
|
|
432
|
-
function
|
|
433
|
-
return a.tabs.filter((
|
|
498
|
+
function l(t) {
|
|
499
|
+
return a.tabs.filter((r) => r.id !== t.id);
|
|
434
500
|
}
|
|
435
|
-
async function
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
for (const
|
|
439
|
-
a.activeId.value ===
|
|
440
|
-
a.activeId.value !==
|
|
501
|
+
async function f(t, r) {
|
|
502
|
+
const b = t.filter((T) => T.closable !== !1);
|
|
503
|
+
if (b.length) {
|
|
504
|
+
for (const T of b)
|
|
505
|
+
a.activeId.value === T.id ? await a.closeTab(T.id, { redirect: r.to, force: !0 }) : await a.removeTab(T.id, { force: !0 });
|
|
506
|
+
a.activeId.value !== r.id && await a.openTab(r.to, !0, !1);
|
|
441
507
|
}
|
|
442
508
|
}
|
|
443
|
-
const
|
|
509
|
+
const d = {
|
|
444
510
|
refresh: {
|
|
445
511
|
label: "Refresh",
|
|
446
|
-
handler: async ({ target:
|
|
447
|
-
await a.refreshTab(
|
|
512
|
+
handler: async ({ target: t }) => {
|
|
513
|
+
await a.refreshTab(t.id, !0);
|
|
448
514
|
}
|
|
449
515
|
},
|
|
450
516
|
refreshAll: {
|
|
@@ -455,250 +521,265 @@ const at = Ae({
|
|
|
455
521
|
},
|
|
456
522
|
close: {
|
|
457
523
|
label: "Close",
|
|
458
|
-
handler: async ({ target:
|
|
459
|
-
await a.closeTab(
|
|
524
|
+
handler: async ({ target: t }) => {
|
|
525
|
+
await a.closeTab(t.id);
|
|
460
526
|
},
|
|
461
|
-
enable: ({ target:
|
|
527
|
+
enable: ({ target: t }) => ee(t)
|
|
462
528
|
},
|
|
463
529
|
closeLefts: {
|
|
464
530
|
label: "Close to the Left",
|
|
465
|
-
handler: async ({ target:
|
|
466
|
-
await
|
|
531
|
+
handler: async ({ target: t }) => {
|
|
532
|
+
await f(Y(t), t);
|
|
467
533
|
},
|
|
468
|
-
enable: ({ target:
|
|
534
|
+
enable: ({ target: t }) => Y(t).some((r) => r.closable !== !1)
|
|
469
535
|
},
|
|
470
536
|
closeRights: {
|
|
471
537
|
label: "Close to the Right",
|
|
472
|
-
handler: async ({ target:
|
|
473
|
-
await
|
|
538
|
+
handler: async ({ target: t }) => {
|
|
539
|
+
await f(F(t), t);
|
|
474
540
|
},
|
|
475
|
-
enable: ({ target:
|
|
541
|
+
enable: ({ target: t }) => F(t).some((r) => r.closable !== !1)
|
|
476
542
|
},
|
|
477
543
|
closeOthers: {
|
|
478
544
|
label: "Close Others",
|
|
479
|
-
handler: async ({ target:
|
|
480
|
-
await
|
|
545
|
+
handler: async ({ target: t }) => {
|
|
546
|
+
await f(l(t), t);
|
|
481
547
|
},
|
|
482
|
-
enable: ({ target:
|
|
548
|
+
enable: ({ target: t }) => l(t).some((r) => r.closable !== !1)
|
|
483
549
|
}
|
|
484
550
|
};
|
|
485
|
-
function
|
|
486
|
-
|
|
551
|
+
function v() {
|
|
552
|
+
R.visible = !1, R.target = null;
|
|
487
553
|
}
|
|
488
|
-
function
|
|
489
|
-
e.contextmenu && (
|
|
554
|
+
function P(t, r) {
|
|
555
|
+
e.contextmenu && (R.visible = !0, R.target = t, R.position.x = r.clientX, R.position.y = r.clientY, document.addEventListener("click", v, { once: !0 }));
|
|
490
556
|
}
|
|
491
|
-
function
|
|
492
|
-
const
|
|
493
|
-
if (!(typeof
|
|
494
|
-
const
|
|
495
|
-
if (!
|
|
496
|
-
const
|
|
497
|
-
await Promise.resolve(
|
|
557
|
+
function D(t, r) {
|
|
558
|
+
const b = typeof t == "string" ? { id: t } : t, T = d[b.id], E = b.label ?? T?.label ?? String(b.id), c = b.visible ?? T?.visible ?? !0;
|
|
559
|
+
if (!(typeof c == "function" ? c(r) : c !== !1)) return null;
|
|
560
|
+
const te = b.enable ?? T?.enable ?? !0, We = typeof te == "function" ? te(r) : te !== !1, ve = b.handler ?? T?.handler;
|
|
561
|
+
if (!ve) return null;
|
|
562
|
+
const He = async () => {
|
|
563
|
+
await Promise.resolve(ve(r));
|
|
498
564
|
};
|
|
499
565
|
return {
|
|
500
|
-
id: String(
|
|
501
|
-
label:
|
|
502
|
-
disabled: !
|
|
503
|
-
action:
|
|
566
|
+
id: String(b.id),
|
|
567
|
+
label: E,
|
|
568
|
+
disabled: !We,
|
|
569
|
+
action: He
|
|
504
570
|
};
|
|
505
571
|
}
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
508
|
-
const
|
|
509
|
-
return
|
|
572
|
+
const $ = h(() => {
|
|
573
|
+
if (!R.visible || !R.target || e.contextmenu === !1) return [];
|
|
574
|
+
const t = Array.isArray(e.contextmenu) ? e.contextmenu : N, r = { target: R.target, controller: a };
|
|
575
|
+
return t.map((b) => D(b, r)).filter((b) => !!b);
|
|
510
576
|
});
|
|
511
|
-
async function
|
|
512
|
-
|
|
577
|
+
async function Me(t) {
|
|
578
|
+
t.disabled || (v(), await t.action());
|
|
513
579
|
}
|
|
514
|
-
function
|
|
515
|
-
return
|
|
580
|
+
function Z(t) {
|
|
581
|
+
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";
|
|
516
582
|
}
|
|
517
|
-
function
|
|
518
|
-
return
|
|
583
|
+
function _e(t) {
|
|
584
|
+
return s.value[t.id] || Z(t);
|
|
519
585
|
}
|
|
520
|
-
|
|
521
|
-
|
|
586
|
+
function ee(t) {
|
|
587
|
+
return !(t.closable === !1 || a.options.keepLastTab && a.tabs.length <= 1);
|
|
522
588
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
589
|
+
async function je(t) {
|
|
590
|
+
await a.closeTab(t.id);
|
|
525
591
|
}
|
|
526
|
-
function
|
|
592
|
+
function Oe(t) {
|
|
593
|
+
a.activeId.value !== t.id && a.openTab(t.to, !1);
|
|
594
|
+
}
|
|
595
|
+
function Ue(t) {
|
|
527
596
|
return [
|
|
528
597
|
"router-tab__item",
|
|
529
598
|
{
|
|
530
|
-
"is-active": a.activeId.value ===
|
|
531
|
-
"is-closable":
|
|
532
|
-
"is-dragging":
|
|
533
|
-
"is-drag-over":
|
|
599
|
+
"is-active": a.activeId.value === t.id,
|
|
600
|
+
"is-closable": ee(t),
|
|
601
|
+
"is-dragging": g.dragging && g.dragTab?.id === t.id,
|
|
602
|
+
"is-drag-over": g.dropIndex === U(t.id)
|
|
534
603
|
},
|
|
535
|
-
|
|
604
|
+
t.tabClass
|
|
536
605
|
];
|
|
537
606
|
}
|
|
538
|
-
function
|
|
539
|
-
return a.refreshingKey.value === a.getRouteKey(
|
|
607
|
+
function Ve(t) {
|
|
608
|
+
return a.refreshingKey.value === a.getRouteKey(t);
|
|
540
609
|
}
|
|
541
|
-
function
|
|
542
|
-
e.sortable && (
|
|
610
|
+
function ze(t, r, b) {
|
|
611
|
+
e.sortable && (g.dragging = !0, g.dragIndex = r, g.dragTab = t, b.dataTransfer && (b.dataTransfer.effectAllowed = "move", b.dataTransfer.setData("text/plain", t.id)), n("tab-sort", { tab: t, index: r }));
|
|
543
612
|
}
|
|
544
|
-
function
|
|
545
|
-
!e.sortable || !
|
|
613
|
+
function Ne(t, r) {
|
|
614
|
+
!e.sortable || !g.dragging || (r.preventDefault(), r.dataTransfer && (r.dataTransfer.dropEffect = "move"));
|
|
546
615
|
}
|
|
547
|
-
function
|
|
548
|
-
!e.sortable || !
|
|
616
|
+
function Ye(t) {
|
|
617
|
+
!e.sortable || !g.dragging || (g.dropIndex = t);
|
|
549
618
|
}
|
|
550
|
-
function
|
|
551
|
-
!e.sortable ||
|
|
619
|
+
function Fe() {
|
|
620
|
+
!e.sortable || g.dragging;
|
|
552
621
|
}
|
|
553
|
-
function
|
|
554
|
-
if (!(!e.sortable || !
|
|
555
|
-
if (
|
|
556
|
-
const
|
|
557
|
-
a.tabs.splice(
|
|
558
|
-
tab:
|
|
559
|
-
fromIndex:
|
|
560
|
-
toIndex:
|
|
622
|
+
function Je(t, r) {
|
|
623
|
+
if (!(!e.sortable || !g.dragging)) {
|
|
624
|
+
if (r.preventDefault(), g.dragIndex !== -1 && g.dragIndex !== t) {
|
|
625
|
+
const b = a.tabs.splice(g.dragIndex, 1)[0];
|
|
626
|
+
a.tabs.splice(t, 0, b), n("tab-sorted", {
|
|
627
|
+
tab: b,
|
|
628
|
+
fromIndex: g.dragIndex,
|
|
629
|
+
toIndex: t
|
|
561
630
|
});
|
|
562
631
|
}
|
|
563
|
-
|
|
632
|
+
pe();
|
|
564
633
|
}
|
|
565
634
|
}
|
|
566
|
-
function
|
|
567
|
-
|
|
635
|
+
function pe() {
|
|
636
|
+
g.dragging = !1, g.dragIndex = -1, g.dropIndex = -1, g.dragTab = null;
|
|
568
637
|
}
|
|
569
|
-
|
|
570
|
-
document.addEventListener("keydown",
|
|
571
|
-
}),
|
|
572
|
-
document.removeEventListener("keydown",
|
|
573
|
-
|
|
638
|
+
ue(() => {
|
|
639
|
+
document.addEventListener("keydown", v);
|
|
640
|
+
}), Xe(() => {
|
|
641
|
+
document.removeEventListener("keydown", v), o.appContext.config.globalProperties.$tabs = null, k.forEach((t) => {
|
|
642
|
+
t.forEach((r) => r());
|
|
643
|
+
}), k.clear(), m.clear();
|
|
644
|
+
}), x(
|
|
574
645
|
() => e.keepAlive,
|
|
575
|
-
(
|
|
576
|
-
a.options.keepAlive =
|
|
646
|
+
(t) => {
|
|
647
|
+
a.options.keepAlive = t;
|
|
577
648
|
}
|
|
578
|
-
),
|
|
649
|
+
), x(
|
|
579
650
|
() => a.activeId.value,
|
|
580
|
-
() =>
|
|
581
|
-
),
|
|
651
|
+
() => v()
|
|
652
|
+
), x(
|
|
582
653
|
() => e.contextmenu,
|
|
583
|
-
(
|
|
584
|
-
|
|
654
|
+
(t) => {
|
|
655
|
+
t || v();
|
|
585
656
|
}
|
|
586
|
-
),
|
|
587
|
-
() =>
|
|
588
|
-
(
|
|
589
|
-
|
|
657
|
+
), x(
|
|
658
|
+
() => $.value.length,
|
|
659
|
+
(t) => {
|
|
660
|
+
R.visible && t === 0 && v();
|
|
590
661
|
}
|
|
591
662
|
);
|
|
592
|
-
const
|
|
663
|
+
const Ge = a.includeKeys;
|
|
593
664
|
return {
|
|
594
665
|
controller: a,
|
|
595
666
|
tabs: a.tabs,
|
|
596
|
-
includeKeys:
|
|
597
|
-
tabTransitionProps:
|
|
598
|
-
pageTransitionProps:
|
|
599
|
-
buildTabClass:
|
|
600
|
-
activate:
|
|
601
|
-
close:
|
|
602
|
-
context:
|
|
603
|
-
menuItems:
|
|
604
|
-
handleMenuAction:
|
|
605
|
-
showContextMenu:
|
|
606
|
-
hideContextMenu:
|
|
607
|
-
getTabTitle:
|
|
608
|
-
isClosable:
|
|
609
|
-
isRefreshing:
|
|
610
|
-
hasCustomSlot:
|
|
611
|
-
onDragStart:
|
|
612
|
-
onDragOver:
|
|
613
|
-
onDragEnter:
|
|
614
|
-
onDragLeave:
|
|
615
|
-
onDrop:
|
|
616
|
-
onDragEnd:
|
|
667
|
+
includeKeys: Ge,
|
|
668
|
+
tabTransitionProps: z,
|
|
669
|
+
pageTransitionProps: L,
|
|
670
|
+
buildTabClass: Ue,
|
|
671
|
+
activate: Oe,
|
|
672
|
+
close: je,
|
|
673
|
+
context: R,
|
|
674
|
+
menuItems: $,
|
|
675
|
+
handleMenuAction: Me,
|
|
676
|
+
showContextMenu: P,
|
|
677
|
+
hideContextMenu: v,
|
|
678
|
+
getTabTitle: Z,
|
|
679
|
+
isClosable: ee,
|
|
680
|
+
isRefreshing: Ve,
|
|
681
|
+
hasCustomSlot: p,
|
|
682
|
+
onDragStart: ze,
|
|
683
|
+
onDragOver: Ne,
|
|
684
|
+
onDragEnter: Ye,
|
|
685
|
+
onDragLeave: Fe,
|
|
686
|
+
onDrop: Je,
|
|
687
|
+
onDragEnd: pe,
|
|
688
|
+
setupComponentWatching: B,
|
|
689
|
+
cleanupComponentWatching: O,
|
|
690
|
+
handleComponentRef: A,
|
|
691
|
+
getReactiveTabTitle: _e,
|
|
692
|
+
triggerTabUpdate: u
|
|
617
693
|
};
|
|
618
694
|
}
|
|
619
|
-
}),
|
|
620
|
-
const
|
|
621
|
-
for (const [
|
|
622
|
-
|
|
623
|
-
return
|
|
624
|
-
},
|
|
625
|
-
function
|
|
626
|
-
const
|
|
627
|
-
return
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
695
|
+
}), mt = (e, n) => {
|
|
696
|
+
const o = e.__vccOpts || e;
|
|
697
|
+
for (const [i, a] of n)
|
|
698
|
+
o[i] = a;
|
|
699
|
+
return o;
|
|
700
|
+
}, vt = { class: "router-tab" }, gt = { class: "router-tab__header" }, yt = { class: "router-tab__slot-start" }, ht = { class: "router-tab__scroll" }, Tt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], kt = ["title"], Ct = ["onClick"], Rt = { class: "router-tab__slot-end" }, wt = { class: "router-tab__container" }, Pt = ["aria-disabled", "onClick"];
|
|
701
|
+
function At(e, n, o, i, a, p) {
|
|
702
|
+
const y = Ze("RouterView");
|
|
703
|
+
return w(), I("div", vt, [
|
|
704
|
+
S("header", gt, [
|
|
705
|
+
S("div", yt, [
|
|
706
|
+
ne(e.$slots, "start")
|
|
631
707
|
]),
|
|
632
|
-
|
|
633
|
-
|
|
708
|
+
S("div", ht, [
|
|
709
|
+
J(et, G({
|
|
634
710
|
tag: "ul",
|
|
635
711
|
class: "router-tab__nav"
|
|
636
712
|
}, e.tabTransitionProps), {
|
|
637
|
-
default:
|
|
638
|
-
(
|
|
639
|
-
key:
|
|
640
|
-
class:
|
|
641
|
-
"data-title": e.getTabTitle(
|
|
713
|
+
default: W(() => [
|
|
714
|
+
(w(!0), I(oe, null, ye(e.tabs, (s, u) => (w(), I("li", {
|
|
715
|
+
key: s.id,
|
|
716
|
+
class: he(e.buildTabClass(s)),
|
|
717
|
+
"data-title": e.getTabTitle(s),
|
|
642
718
|
draggable: e.sortable,
|
|
643
|
-
onClick: (
|
|
644
|
-
onAuxclick:
|
|
645
|
-
onContextmenu:
|
|
646
|
-
onDragstart: (
|
|
647
|
-
onDragover: (
|
|
648
|
-
onDragenter: (
|
|
649
|
-
onDragleave:
|
|
650
|
-
onDrop: (
|
|
651
|
-
onDragend:
|
|
719
|
+
onClick: (m) => e.activate(s),
|
|
720
|
+
onAuxclick: H((m) => e.close(s), ["middle", "prevent"]),
|
|
721
|
+
onContextmenu: H((m) => e.showContextMenu(s, m), ["prevent"]),
|
|
722
|
+
onDragstart: (m) => e.onDragStart(s, u, m),
|
|
723
|
+
onDragover: (m) => e.onDragOver(u, m),
|
|
724
|
+
onDragenter: (m) => e.onDragEnter(u),
|
|
725
|
+
onDragleave: n[0] || (n[0] = (...m) => e.onDragLeave && e.onDragLeave(...m)),
|
|
726
|
+
onDrop: (m) => e.onDrop(u, m),
|
|
727
|
+
onDragend: n[1] || (n[1] = (...m) => e.onDragEnd && e.onDragEnd(...m))
|
|
652
728
|
}, [
|
|
653
|
-
|
|
654
|
-
class: "router-tab__item-title",
|
|
655
|
-
title: e.getTabTitle(l)
|
|
656
|
-
}, [
|
|
657
|
-
l.icon ? (v(), T("i", {
|
|
658
|
-
key: 0,
|
|
659
|
-
class: pe(["router-tab__item-icon", l.icon])
|
|
660
|
-
}, null, 2)) : I("", !0),
|
|
661
|
-
Ye(" " + me(e.getTabTitle(l)), 1)
|
|
662
|
-
], 8, ft),
|
|
663
|
-
e.isClosable(l) ? (v(), T("a", {
|
|
729
|
+
s.icon ? (w(), I("i", {
|
|
664
730
|
key: 0,
|
|
731
|
+
class: he(["router-tab__item-icon", s.icon])
|
|
732
|
+
}, null, 2)) : M("", !0),
|
|
733
|
+
S("span", {
|
|
734
|
+
class: "router-tab__item-title",
|
|
735
|
+
title: e.getReactiveTabTitle(s)
|
|
736
|
+
}, Te(e.getReactiveTabTitle(s)), 9, kt),
|
|
737
|
+
e.isClosable(s) ? (w(), I("a", {
|
|
738
|
+
key: 1,
|
|
665
739
|
class: "router-tab__item-close",
|
|
666
|
-
onClick:
|
|
667
|
-
}, null, 8,
|
|
668
|
-
], 42,
|
|
740
|
+
onClick: H((m) => e.close(s), ["stop"])
|
|
741
|
+
}, null, 8, Ct)) : M("", !0)
|
|
742
|
+
], 42, Tt))), 128))
|
|
669
743
|
]),
|
|
670
744
|
_: 1
|
|
671
745
|
}, 16)
|
|
672
746
|
]),
|
|
673
|
-
|
|
674
|
-
|
|
747
|
+
S("div", Rt, [
|
|
748
|
+
ne(e.$slots, "end")
|
|
675
749
|
])
|
|
676
750
|
]),
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
default:
|
|
680
|
-
e.hasCustomSlot ?
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
751
|
+
S("div", wt, [
|
|
752
|
+
J(y, null, {
|
|
753
|
+
default: W((s) => [
|
|
754
|
+
e.hasCustomSlot ? ne(e.$slots, "default", tt(G({ key: 0 }, {
|
|
755
|
+
...s,
|
|
756
|
+
controller: e.controller,
|
|
757
|
+
// Expose a ref binder so custom slots can keep reactivity
|
|
758
|
+
pageRef: (u) => e.handleComponentRef(u, e.controller.getRouteKey(s.route))
|
|
759
|
+
}))) : (w(), I(oe, { key: 1 }, [
|
|
760
|
+
J(ke, G(e.pageTransitionProps, { appear: "" }), {
|
|
761
|
+
default: W(() => [
|
|
762
|
+
e.controller.options.keepAlive ? (w(), ae(nt, {
|
|
684
763
|
key: 0,
|
|
685
764
|
include: e.includeKeys,
|
|
686
765
|
max: e.controller.options.maxAlive || void 0
|
|
687
766
|
}, [
|
|
688
|
-
e.isRefreshing(
|
|
689
|
-
key: e.controller.getRouteKey(
|
|
767
|
+
e.isRefreshing(s.route) ? M("", !0) : (w(), ae(Ce(s.Component), {
|
|
768
|
+
key: e.controller.getRouteKey(s.route),
|
|
769
|
+
ref: (u) => e.handleComponentRef(u, e.controller.getRouteKey(s.route)),
|
|
690
770
|
class: "router-tab-page"
|
|
691
771
|
}))
|
|
692
|
-
], 1032, ["include", "max"])) :
|
|
772
|
+
], 1032, ["include", "max"])) : M("", !0)
|
|
693
773
|
]),
|
|
694
774
|
_: 2
|
|
695
775
|
}, 1040),
|
|
696
|
-
|
|
697
|
-
default:
|
|
698
|
-
!e.controller.options.keepAlive || e.isRefreshing(
|
|
699
|
-
key: e.controller.getRouteKey(
|
|
776
|
+
J(ke, G(e.pageTransitionProps, { appear: "" }), {
|
|
777
|
+
default: W(() => [
|
|
778
|
+
!e.controller.options.keepAlive || e.isRefreshing(s.route) ? (w(), ae(Ce(s.Component), {
|
|
779
|
+
key: e.controller.getRouteKey(s.route) + (e.isRefreshing(s.route) ? "-refresh" : ""),
|
|
780
|
+
ref: (u) => e.handleComponentRef(u, e.controller.getRouteKey(s.route)),
|
|
700
781
|
class: "router-tab-page"
|
|
701
|
-
})) :
|
|
782
|
+
})) : M("", !0)
|
|
702
783
|
]),
|
|
703
784
|
_: 2
|
|
704
785
|
}, 1040)
|
|
@@ -707,24 +788,24 @@ function gt(e, o, t, r, a, b) {
|
|
|
707
788
|
_: 3
|
|
708
789
|
})
|
|
709
790
|
]),
|
|
710
|
-
e.context.visible && e.context.target ? (
|
|
791
|
+
e.context.visible && e.context.target ? (w(), I("div", {
|
|
711
792
|
key: 0,
|
|
712
793
|
class: "router-tab__contextmenu",
|
|
713
|
-
style:
|
|
794
|
+
style: ot({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
|
|
714
795
|
}, [
|
|
715
|
-
(
|
|
716
|
-
key:
|
|
796
|
+
(w(!0), I(oe, null, ye(e.menuItems, (s) => (w(), I("a", {
|
|
797
|
+
key: s.id,
|
|
717
798
|
class: "router-tab__contextmenu-item",
|
|
718
|
-
"aria-disabled":
|
|
719
|
-
onClick:
|
|
720
|
-
},
|
|
721
|
-
], 4)) :
|
|
799
|
+
"aria-disabled": s.disabled,
|
|
800
|
+
onClick: H((u) => e.handleMenuAction(s), ["prevent"])
|
|
801
|
+
}, Te(s.label), 9, Pt))), 128))
|
|
802
|
+
], 4)) : M("", !0)
|
|
722
803
|
]);
|
|
723
804
|
}
|
|
724
|
-
const
|
|
805
|
+
const Ie = /* @__PURE__ */ mt(pt, [["render", At]]), Et = {
|
|
725
806
|
class: "router-tabs",
|
|
726
807
|
"aria-hidden": "true"
|
|
727
|
-
},
|
|
808
|
+
}, re = /* @__PURE__ */ Be({
|
|
728
809
|
name: "RouterTabs",
|
|
729
810
|
__name: "RouterTabs",
|
|
730
811
|
props: {
|
|
@@ -739,11 +820,11 @@ const we = /* @__PURE__ */ rt(at, [["render", gt]]), vt = {
|
|
|
739
820
|
fallbackRoute: {}
|
|
740
821
|
},
|
|
741
822
|
setup(e) {
|
|
742
|
-
return
|
|
823
|
+
return Ke(e), (o, i) => (w(), I("span", Et));
|
|
743
824
|
}
|
|
744
|
-
}),
|
|
745
|
-
let
|
|
746
|
-
const
|
|
825
|
+
}), Le = "tab-theme-style", It = "tab-theme-primary-color", xt = "system", Dt = "(prefers-color-scheme: dark)";
|
|
826
|
+
let V = null;
|
|
827
|
+
const C = {
|
|
747
828
|
primary: "#034960",
|
|
748
829
|
background: "#ffffff",
|
|
749
830
|
text: "#1e293b",
|
|
@@ -751,13 +832,13 @@ const y = {
|
|
|
751
832
|
activeBackground: "#034960",
|
|
752
833
|
activeText: "#ffffff",
|
|
753
834
|
activeBorder: "#034960",
|
|
754
|
-
headerBackground: "#
|
|
835
|
+
headerBackground: "#ffffff",
|
|
755
836
|
buttonBackground: "#f8fafc",
|
|
756
837
|
buttonColor: "#034960",
|
|
757
838
|
activeButtonBackground: "#034960",
|
|
758
839
|
activeButtonColor: "#ffffff",
|
|
759
840
|
iconColor: "#475569"
|
|
760
|
-
},
|
|
841
|
+
}, Bt = {
|
|
761
842
|
primary: "#38bdf8",
|
|
762
843
|
background: "#0f172a",
|
|
763
844
|
text: "#f1f5f9",
|
|
@@ -773,59 +854,110 @@ const y = {
|
|
|
773
854
|
activeButtonColor: "#0f172a",
|
|
774
855
|
iconColor: "#cbd5e1"
|
|
775
856
|
};
|
|
776
|
-
function
|
|
777
|
-
typeof document > "u" || (
|
|
857
|
+
function de(e) {
|
|
858
|
+
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));
|
|
778
859
|
}
|
|
779
|
-
function
|
|
860
|
+
function Se(e) {
|
|
780
861
|
if (typeof document > "u") return;
|
|
781
|
-
const
|
|
782
|
-
|
|
862
|
+
const n = document.documentElement, o = window.matchMedia(Dt), i = () => {
|
|
863
|
+
n.dataset.theme = o.matches ? "dark" : "light";
|
|
783
864
|
};
|
|
784
|
-
|
|
865
|
+
V && (o.removeEventListener("change", V), V = null), e === "system" ? (i(), V = () => i(), o.addEventListener("change", V)) : n.dataset.theme = e;
|
|
785
866
|
}
|
|
786
|
-
function
|
|
867
|
+
function $t(e = {}) {
|
|
787
868
|
if (typeof window > "u") return;
|
|
788
869
|
const {
|
|
789
|
-
styleKey:
|
|
790
|
-
defaultStyle:
|
|
791
|
-
} = e,
|
|
792
|
-
|
|
870
|
+
styleKey: n = Le,
|
|
871
|
+
defaultStyle: o = xt
|
|
872
|
+
} = e, i = window.localStorage.getItem(n) ?? o;
|
|
873
|
+
Se(i), de(i === "dark" ? Bt : C);
|
|
793
874
|
}
|
|
794
|
-
function
|
|
875
|
+
function St(e, n) {
|
|
795
876
|
if (typeof window > "u") return;
|
|
796
|
-
const
|
|
797
|
-
window.localStorage.setItem(
|
|
877
|
+
const o = n?.styleKey ?? Le;
|
|
878
|
+
window.localStorage.setItem(o, e), Se(e);
|
|
798
879
|
}
|
|
799
|
-
function
|
|
880
|
+
function Mt(e, n) {
|
|
800
881
|
if (typeof window > "u") return;
|
|
801
|
-
const
|
|
802
|
-
window.localStorage.setItem(
|
|
882
|
+
const o = n?.primaryKey ?? It;
|
|
883
|
+
window.localStorage.setItem(o, JSON.stringify(e)), de(e);
|
|
884
|
+
}
|
|
885
|
+
function be(e = {}) {
|
|
886
|
+
const n = K(e.title || "Untitled"), o = K(e.icon || "mdi-tab"), i = K(e.closable !== !1), a = K(e.meta || {}), p = typeof e.title == "function" ? h(e.title) : n, y = typeof e.icon == "function" ? h(e.icon) : o, s = typeof e.closable == "function" ? h(e.closable) : i, u = typeof e.meta == "function" ? h(e.meta) : a;
|
|
887
|
+
return {
|
|
888
|
+
routeTabTitle: p,
|
|
889
|
+
routeTabIcon: y,
|
|
890
|
+
routeTabClosable: s,
|
|
891
|
+
routeTabMeta: u,
|
|
892
|
+
updateTitle: (A) => {
|
|
893
|
+
"value" in n && (n.value = A);
|
|
894
|
+
},
|
|
895
|
+
updateIcon: (A) => {
|
|
896
|
+
"value" in o && (o.value = A);
|
|
897
|
+
},
|
|
898
|
+
updateClosable: (A) => {
|
|
899
|
+
"value" in i && (i.value = A);
|
|
900
|
+
},
|
|
901
|
+
updateMeta: (A) => {
|
|
902
|
+
"value" in a && (a.value = A);
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
function _t(e, n = "Page") {
|
|
907
|
+
return be({
|
|
908
|
+
title: h(() => e.value ? "Loading..." : n),
|
|
909
|
+
icon: h(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
|
|
910
|
+
closable: h(() => !e.value)
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
function jt(e, n = "Page", o = "mdi-page") {
|
|
914
|
+
return be({
|
|
915
|
+
title: h(() => e.value > 0 ? `${n} (${e.value})` : n),
|
|
916
|
+
icon: h(() => e.value > 0 ? "mdi-bell-badge" : o)
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
function Ot(e, n = "Page") {
|
|
920
|
+
const o = {
|
|
921
|
+
normal: { suffix: "", icon: "mdi-page" },
|
|
922
|
+
loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
|
|
923
|
+
error: { suffix: " - Error", icon: "mdi-alert" },
|
|
924
|
+
success: { suffix: " - Success", icon: "mdi-check-circle" }
|
|
925
|
+
};
|
|
926
|
+
return be({
|
|
927
|
+
title: h(() => n + o[e.value].suffix),
|
|
928
|
+
icon: h(() => o[e.value].icon),
|
|
929
|
+
closable: h(() => e.value !== "loading")
|
|
930
|
+
});
|
|
803
931
|
}
|
|
804
|
-
const
|
|
932
|
+
const xe = {
|
|
805
933
|
install(e) {
|
|
806
|
-
if (
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
e.component(
|
|
934
|
+
if (xe._installed) return;
|
|
935
|
+
xe._installed = !0, $t();
|
|
936
|
+
const n = Ie.name || "RouterTab", o = re.name || "RouterTabs";
|
|
937
|
+
e.component(n, Ie), e.component(o, re), o !== "router-tabs" && e.component("router-tabs", re), Object.defineProperty(e.config.globalProperties, "$tabs", {
|
|
810
938
|
configurable: !0,
|
|
811
939
|
enumerable: !1,
|
|
812
940
|
get() {
|
|
813
|
-
return e._context.provides[
|
|
941
|
+
return e._context.provides[X];
|
|
814
942
|
},
|
|
815
|
-
set(
|
|
816
|
-
|
|
943
|
+
set(i) {
|
|
944
|
+
i && e.provide(X, i);
|
|
817
945
|
}
|
|
818
946
|
});
|
|
819
947
|
}
|
|
820
948
|
};
|
|
821
949
|
export {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
950
|
+
Ie as RouterTab,
|
|
951
|
+
re as RouterTabs,
|
|
952
|
+
xe as default,
|
|
953
|
+
$t as initRouterTabsTheme,
|
|
954
|
+
X as routerTabsKey,
|
|
955
|
+
Mt as setRouterTabsPrimary,
|
|
956
|
+
St as setRouterTabsTheme,
|
|
957
|
+
_t as useLoadingTab,
|
|
958
|
+
jt as useNotificationTab,
|
|
959
|
+
be as useReactiveTab,
|
|
960
|
+
Pe as useRouterTabs,
|
|
961
|
+
Ke as useRouterTabsPersistence,
|
|
962
|
+
Ot as useStatusTab
|
|
831
963
|
};
|