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