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