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