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.
@@ -1,116 +1,7 @@
1
1
  import './vue3-router-tab.css';
2
- import { defineComponent as se, inject as U, computed as S, unref as Ie, provide as G, ref as J, watch as x, h as Ke, getCurrentInstance as ie, reactive as Se, shallowRef as Ne, nextTick as le, onMounted as ne, onBeforeUnmount as $e, resolveComponent as Le, createElementBlock as A, openBlock as T, createElementVNode as I, createCommentVNode as K, renderSlot as ce, createVNode as j, TransitionGroup as De, mergeProps as Q, withCtx as M, Fragment as ue, renderList as fe, withModifiers as B, normalizeClass as de, createTextVNode as je, toDisplayString as pe, Transition as be, createBlock as W, KeepAlive as Me, resolveDynamicComponent as ve, normalizeStyle as Be } from "vue";
3
- import { defineStore as ze } from "pinia";
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 N(e, a) {
124
- const n = e.resolve(a);
125
- if (!n || !n.matched.length)
126
- throw new Error(`[RouterTabs] Unable to resolve route: ${String(a)}`);
127
- return n;
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 Ze = {
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 $(e) {
137
- const a = e.meta?.key;
138
- if (typeof a == "function") {
139
- const n = a(e);
140
- if (typeof n == "string" && n.length) return n;
141
- } else if (typeof a == "string" && a.length) {
142
- const n = Ze[a.toLowerCase()];
143
- return n ? n(e) : a;
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 ae(e, a) {
148
- const n = e.meta?.keepAlive;
149
- return typeof n == "boolean" ? n : a;
38
+ function ee(e, n) {
39
+ const o = e.meta?.keepAlive;
40
+ return typeof o == "boolean" ? o : n;
150
41
  }
151
- function oe(e, a) {
152
- const n = e.meta?.reuse;
153
- return typeof n == "boolean" ? n : a;
42
+ function te(e, n) {
43
+ const o = e.meta?.reuse;
44
+ return typeof o == "boolean" ? o : n;
154
45
  }
155
- function Pe(e) {
156
- const a = e.meta ?? {}, n = {};
157
- return "title" in a && (n.title = a.title), "tips" in a && (n.tips = a.tips), "icon" in a && (n.icon = a.icon), "closable" in a && (n.closable = a.closable), "tabClass" in a && (n.tabClass = a.tabClass), "target" in a && (n.target = a.target), "href" in a && (n.href = a.href), n;
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 z(e, a, n) {
160
- const t = Pe(e);
50
+ function V(e, n, o) {
51
+ const t = Te(e);
161
52
  return {
162
- id: $(e),
53
+ id: _(e),
163
54
  to: e.fullPath,
164
55
  fullPath: e.fullPath,
165
56
  matched: e,
166
- alive: ae(e, n),
167
- reusable: oe(e, !1),
57
+ alive: ee(e, o),
58
+ reusable: te(e, !1),
168
59
  closable: t.closable ?? !0,
169
60
  ...t,
170
- ...a
61
+ ...n
171
62
  };
172
63
  }
173
- function Z(e, a, n, t) {
174
- if (!e.find((p) => p.id === a.id)) {
175
- if (n === "next" && t) {
176
- const p = e.findIndex((d) => d.id === t);
177
- if (p > -1) {
178
- e.splice(p + 1, 0, a);
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(a);
73
+ e.push(n);
183
74
  }
184
75
  }
185
- function ke(e, a, n) {
186
- if (!a || a <= 0) return;
187
- const t = e.filter((l) => l.alive);
188
- for (; t.length > a; ) {
189
- const l = t.shift();
190
- if (!l || l.id === n) continue;
191
- const p = e.findIndex((d) => d.id === l.id);
192
- p > -1 && (e[p].alive = !1);
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 et(e) {
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 tt(e) {
206
- const a = {};
207
- return "title" in e && (a.title = e.title), "tips" in e && (a.tips = e.tips), "icon" in e && (a.icon = e.icon), "tabClass" in e && (a.tabClass = e.tabClass), "closable" in e && (a.closable = e.closable), a;
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 nt(e, a = {}) {
210
- const n = We(a), t = Se([]), l = J(null), p = Ne(), d = J(null), i = S(() => t.filter((s) => s.alive).map((s) => s.id));
211
- let f = !1;
212
- function v(s) {
213
- const r = typeof s.matched == "object" ? s : N(e, s);
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: $(r),
216
- fullPath: r.fullPath,
217
- alive: ae(r, n.keepAlive),
218
- reusable: oe(r, !1),
219
- matched: r
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 b(s) {
223
- const r = $(s);
224
- let c = t.find((w) => w.id === r);
225
- return c ? (c.fullPath = s.fullPath, c.to = s.fullPath, c.matched = s, c.alive = ae(s, n.keepAlive), c.reusable = oe(s, c.reusable), Object.assign(c, Pe(s)), c) : (c = z(s, {}, n.keepAlive), Z(t, c, n.appendPosition, l.value), ke(t, n.maxAlive, l.value), c);
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 m(s, r = !1, c = !0) {
228
- const w = N(e, s), O = $(w), V = l.value === O;
229
- c === "sameTab" && (c = V), c && await _(O, !0), await e[r ? "replace" : "push"](w), V && await L();
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 k(s) {
232
- const r = t.findIndex((w) => w.id === s), c = t[r] || t[r - 1] || t[0];
233
- return c ? c.to : n.defaultRoute;
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 y(s = l.value, r = {}) {
236
- if (s) {
237
- if (!r.force && n.keepLastTab && t.length === 1)
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 C(s, { force: r.force }), r.redirect !== null)
240
- if (l.value === s) {
241
- const c = r.redirect ?? k(s);
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 r.redirect && await e.replace(r.redirect);
134
+ } else s.redirect && await e.replace(s.redirect);
244
135
  }
245
136
  }
246
- async function C(s, r = {}) {
247
- const c = t.findIndex((w) => w.id === s);
248
- c !== -1 && (t.splice(c, 1), d.value === s && (d.value = null), l.value === s && (l.value = null, p.value = void 0));
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 _(s = l.value ?? void 0, r = !1) {
251
- s && (d.value = s, await le(), r || await le(), d.value = null);
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 g(s = !1) {
254
- for (const r of t)
255
- await _(r.id, s);
144
+ async function N(a = !1) {
145
+ for (const s of t)
146
+ await v(s.id, a);
256
147
  }
257
- async function E(s = n.defaultRoute) {
258
- t.splice(0, t.length), l.value = null, p.value = void 0;
259
- for (const r of n.initialTabs) {
260
- const c = N(e, r.to), w = z(c, r, n.keepAlive);
261
- t.push(w);
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(s);
154
+ await e.replace(a);
264
155
  }
265
- async function L() {
266
- const s = l.value;
267
- s && await _(s, !0);
156
+ async function $() {
157
+ const a = r.value;
158
+ a && await v(a, !0);
268
159
  }
269
- function P(s) {
270
- return typeof s.matched == "object" ? $(s) : $(N(e, s));
160
+ function B(a) {
161
+ return typeof a.matched == "object" ? _(a) : _(A(e, a));
271
162
  }
272
- function q() {
273
- const s = t.find((r) => r.id === l.value);
163
+ function F() {
164
+ const a = t.find((s) => s.id === r.value);
274
165
  return {
275
- tabs: t.map(et),
276
- active: s ? s.to : null
166
+ tabs: t.map(ze),
167
+ active: a ? a.to : null
277
168
  };
278
169
  }
279
- async function X(s) {
280
- f = !0, t.splice(0, t.length), l.value = null, p.value = void 0;
281
- const r = s?.tabs ?? [];
282
- for (const w of r)
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 O = N(e, w.to), V = tt(w), D = z(O, V, n.keepAlive);
285
- Z(t, D, "last", null);
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
- f = !1;
289
- const c = s?.active ?? r[r.length - 1]?.to ?? n.defaultRoute;
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 x(
187
+ return P(
297
188
  () => e.currentRoute.value,
298
- (s) => {
299
- if (f) return;
300
- const r = b(s);
301
- l.value = r.id, p.value = r, ke(t, n.maxAlive, l.value);
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
- ), n.initialTabs.length && n.initialTabs.forEach((s) => {
305
- const r = N(e, s.to), c = z(r, s, n.keepAlive);
306
- Z(t, c, "last", null);
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: n,
199
+ options: o,
309
200
  tabs: t,
310
- activeId: l,
311
- current: p,
312
- includeKeys: i,
313
- refreshingKey: d,
314
- openTab: m,
315
- closeTab: y,
316
- removeTab: C,
317
- refreshTab: _,
318
- refreshAll: g,
319
- reset: E,
320
- reload: L,
321
- getRouteKey: P,
322
- matchRoute: v,
323
- snapshot: q,
324
- hydrate: X
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 Re(e) {
218
+ function fe(e) {
328
219
  return e ? typeof e == "string" ? { name: e } : e : {};
329
220
  }
330
- const H = Symbol("RouterTabsContext"), ee = typeof window < "u" && "sessionStorage" in window, at = se({
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: Fe },
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
- storage: {
371
- type: [Boolean, String],
372
- default: !1
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 a = ie();
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 = nt(n, {
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
- G(H, t), a.appContext.config.globalProperties.$tabs = t;
391
- const l = S(() => Re(e.tabTransition)), p = S(() => Re(e.pageTransition)), d = Se({
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
- }), i = S(() => !e.storage || !ee ? null : typeof e.storage == "string" ? e.storage : `router-tabs:${(n.options?.history?.base ?? "") || "default"}`);
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 b(o) {
406
- return t.tabs.findIndex((u) => u.id === o);
403
+ function T(i) {
404
+ return t.tabs.findIndex((f) => f.id === i);
407
405
  }
408
- function m(o) {
409
- const u = b(o.id);
410
- return u > 0 ? t.tabs.slice(0, u) : [];
406
+ function C(i) {
407
+ const f = T(i.id);
408
+ return f > 0 ? t.tabs.slice(0, f) : [];
411
409
  }
412
- function k(o) {
413
- const u = b(o.id);
414
- return u > -1 ? t.tabs.slice(u + 1) : [];
410
+ function S(i) {
411
+ const f = T(i.id);
412
+ return f > -1 ? t.tabs.slice(f + 1) : [];
415
413
  }
416
- function y(o) {
417
- return t.tabs.filter((u) => u.id !== o.id);
414
+ function L(i) {
415
+ return t.tabs.filter((f) => f.id !== i.id);
418
416
  }
419
- async function C(o, u) {
420
- const h = o.filter((R) => R.closable !== !1);
417
+ async function x(i, f) {
418
+ const h = i.filter((y) => y.closable !== !1);
421
419
  if (h.length) {
422
- for (const R of h)
423
- t.activeId.value === R.id ? await t.closeTab(R.id, { redirect: u.to, force: !0 }) : await t.removeTab(R.id, { force: !0 });
424
- t.activeId.value !== u.id && await t.openTab(u.to, !0, !1);
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: o }) => {
431
- await t.refreshTab(o.id, !0);
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: o }) => {
443
- await t.closeTab(o.id);
440
+ handler: async ({ target: i }) => {
441
+ await t.closeTab(i.id);
444
442
  },
445
- enable: ({ target: o }) => s(o)
443
+ enable: ({ target: i }) => I(i)
446
444
  },
447
445
  closeLefts: {
448
446
  label: "Close to the Left",
449
- handler: async ({ target: o }) => {
450
- await C(m(o), o);
447
+ handler: async ({ target: i }) => {
448
+ await x(C(i), i);
451
449
  },
452
- enable: ({ target: o }) => m(o).some((u) => u.closable !== !1)
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: o }) => {
457
- await C(k(o), o);
454
+ handler: async ({ target: i }) => {
455
+ await x(S(i), i);
458
456
  },
459
- enable: ({ target: o }) => k(o).some((u) => u.closable !== !1)
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: o }) => {
464
- await C(y(o), o);
461
+ handler: async ({ target: i }) => {
462
+ await x(L(i), i);
465
463
  },
466
- enable: ({ target: o }) => y(o).some((u) => u.closable !== !1)
464
+ enable: ({ target: i }) => L(i).some((f) => f.closable !== !1)
467
465
  }
468
466
  };
469
- function g() {
470
- d.visible = !1, d.target = null;
467
+ function v() {
468
+ l.visible = !1, l.target = null;
471
469
  }
472
- function E(o, u) {
473
- e.contextmenu && (d.visible = !0, d.target = o, d.position.x = u.clientX, d.position.y = u.clientY, document.addEventListener("click", g, { once: !0 }));
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 L(o, u) {
476
- const h = typeof o == "string" ? { id: o } : o, R = _[h.id], Ee = h.label ?? R?.label ?? String(h.id), Y = h.visible ?? R?.visible ?? !0;
477
- if (!(typeof Y == "function" ? Y(u) : Y !== !1)) return null;
478
- const F = h.enable ?? R?.enable ?? !0, Oe = typeof F == "function" ? F(u) : F !== !1, re = h.handler ?? R?.handler;
479
- if (!re) return null;
480
- const Ve = async () => {
481
- await Promise.resolve(re(u));
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: Ee,
486
- disabled: !Oe,
487
- action: Ve
483
+ label: Ce,
484
+ disabled: !Re,
485
+ action: we
488
486
  };
489
487
  }
490
- const P = S(() => {
491
- if (!d.visible || !d.target || e.contextmenu === !1) return [];
492
- const o = Array.isArray(e.contextmenu) ? e.contextmenu : v, u = { target: d.target, controller: t };
493
- return o.map((h) => L(h, u)).filter((h) => !!h);
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 q(o) {
496
- o.disabled || (g(), await o.action());
493
+ async function B(i) {
494
+ i.disabled || (v(), await i.action());
497
495
  }
498
- function X(o) {
499
- return typeof o.title == "string" ? o.title : Array.isArray(o.title) && o.title.length ? String(o.title[0]) : o.fullPath;
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 s(o) {
502
- return !(o.closable === !1 || t.options.keepLastTab && t.tabs.length <= 1);
499
+ function I(i) {
500
+ return !(i.closable === !1 || t.options.keepLastTab && t.tabs.length <= 1);
503
501
  }
504
- async function r(o) {
505
- await t.closeTab(o.id);
502
+ async function a(i) {
503
+ await t.closeTab(i.id);
506
504
  }
507
- function c(o) {
508
- t.activeId.value !== o.id && t.openTab(o.to, !1);
505
+ function s(i) {
506
+ t.activeId.value !== i.id && t.openTab(i.to, !1);
509
507
  }
510
- function w(o) {
508
+ function c(i) {
511
509
  return [
512
510
  "router-tab__item",
513
511
  {
514
- "is-active": t.activeId.value === o.id,
515
- "is-closable": s(o)
512
+ "is-active": t.activeId.value === i.id,
513
+ "is-closable": I(i)
516
514
  },
517
- o.tabClass
515
+ i.tabClass
518
516
  ];
519
517
  }
520
- function O(o) {
521
- return t.refreshingKey.value === t.getRouteKey(o);
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
- ne(() => {
547
- document.addEventListener("keydown", g), V();
548
- }), $e(() => {
549
- document.removeEventListener("keydown", g), a.appContext.config.globalProperties.$tabs = null, D();
550
- }), x(
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
- (o) => {
553
- t.options.keepAlive = o;
527
+ (i) => {
528
+ t.options.keepAlive = i;
554
529
  }
555
- ), x(
530
+ ), P(
556
531
  () => t.activeId.value,
557
- () => g()
558
- ), x(
532
+ () => v()
533
+ ), P(
559
534
  () => e.contextmenu,
560
- (o) => {
561
- o || g();
535
+ (i) => {
536
+ i || v();
562
537
  }
563
- ), x(
564
- () => P.value.length,
565
- (o) => {
566
- d.visible && o === 0 && g();
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 xe = t.includeKeys;
544
+ const k = t.includeKeys;
587
545
  return {
588
546
  controller: t,
589
547
  tabs: t.tabs,
590
- includeKeys: xe,
591
- tabTransitionProps: l,
592
- pageTransitionProps: p,
593
- buildTabClass: w,
594
- activate: c,
595
- close: r,
596
- context: d,
597
- menuItems: P,
598
- handleMenuAction: q,
599
- showContextMenu: E,
600
- hideContextMenu: g,
601
- tabTitle: X,
602
- isClosable: s,
603
- isRefreshing: O
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
- }), ot = (e, a) => {
607
- const n = e.__vccOpts || e;
608
- for (const [t, l] of a)
609
- n[t] = l;
610
- return n;
611
- }, st = { class: "router-tab" }, it = { class: "router-tab__header" }, rt = { class: "router-tab__slot-start" }, lt = { class: "router-tab__scroll" }, ct = ["onClick", "onAuxclick", "onContextmenu"], ut = ["title"], ft = ["onClick"], dt = { class: "router-tab__slot-end" }, pt = { class: "router-tab__container" }, bt = ["aria-disabled", "onClick"];
612
- function vt(e, a, n, t, l, p) {
613
- const d = Le("RouterView");
614
- return T(), A("div", st, [
615
- I("header", it, [
616
- I("div", rt, [
617
- ce(e.$slots, "start")
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
- I("div", lt, [
620
- j(De, Q({
578
+ R("div", We, [
579
+ E($e, j({
621
580
  tag: "ul",
622
581
  class: "router-tab__nav"
623
582
  }, e.tabTransitionProps), {
624
- default: M(() => [
625
- (T(!0), A(ue, null, fe(e.tabs, (i) => (T(), A("li", {
626
- key: i.id,
627
- class: de(e.buildTabClass(i)),
628
- onClick: (f) => e.activate(i),
629
- onAuxclick: B((f) => e.close(i), ["middle", "prevent"]),
630
- onContextmenu: B((f) => e.showContextMenu(i, f), ["prevent"])
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
- I("span", {
591
+ R("span", {
633
592
  class: "router-tab__item-title",
634
- title: e.tabTitle(i)
593
+ title: e.tabTitle(l)
635
594
  }, [
636
- i.icon ? (T(), A("i", {
595
+ l.icon ? (m(), g("i", {
637
596
  key: 0,
638
- class: de(["router-tab__item-icon", i.icon])
639
- }, null, 2)) : K("", !0),
640
- je(" " + pe(e.tabTitle(i)), 1)
641
- ], 8, ut),
642
- e.isClosable(i) ? (T(), A("a", {
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
- onClick: B((f) => e.close(i), ["stop"])
646
- }, null, 8, ft)) : K("", !0)
647
- ], 42, ct))), 128))
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
- I("div", dt, [
653
- ce(e.$slots, "end")
612
+ R("div", et, [
613
+ H(e.$slots, "end")
654
614
  ])
655
615
  ]),
656
- I("div", pt, [
657
- j(d, null, {
658
- default: M(({ Component: i, route: f }) => [
659
- j(be, Q(e.pageTransitionProps, { appear: "" }), {
660
- default: M(() => [
661
- e.controller.options.keepAlive ? (T(), W(Me, {
662
- key: 0,
663
- include: e.includeKeys,
664
- max: e.controller.options.maxAlive || void 0
665
- }, [
666
- e.isRefreshing(f) ? K("", !0) : (T(), W(ve(i), {
667
- key: e.controller.getRouteKey(f),
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
- ], 1032, ["include", "max"])) : K("", !0)
671
- ]),
672
- _: 2
673
- }, 1040),
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
- _: 1
646
+ _: 3
685
647
  })
686
648
  ]),
687
- e.context.visible && e.context.target ? (T(), A("div", {
649
+ e.context.visible && e.context.target ? (m(), g("div", {
688
650
  key: 0,
689
651
  class: "router-tab__contextmenu",
690
- style: Be({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
652
+ style: Le({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
691
653
  }, [
692
- (T(!0), A(ue, null, fe(e.menuItems, (i) => (T(), A("a", {
693
- key: i.id,
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": i.disabled,
696
- onClick: B((f) => e.handleMenuAction(i), ["prevent"])
697
- }, pe(i.label), 9, bt))), 128))
698
- ], 4)) : K("", !0)
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 Ce = /* @__PURE__ */ ot(at, [["render", vt]]);
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
- }, te = /* @__PURE__ */ se({
666
+ }, X = /* @__PURE__ */ ge({
794
667
  name: "RouterTabs",
795
- __name: "RouterTabsPinia",
668
+ __name: "RouterTabs",
796
669
  props: {
797
- storeId: {},
798
- storageKey: {},
799
- storage: {},
800
- fallbackRoute: {},
801
- store: { type: [Function, Object] }
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 gt(e), (n, t) => (T(), A("span", wt));
681
+ return ke(e), (o, t) => (m(), g("span", ot));
805
682
  }
806
- }), Ae = {
683
+ }), ve = {
807
684
  install(e) {
808
- if (Ae._installed) return;
809
- Ae._installed = !0;
810
- const a = Ce.name || "RouterTab", n = te.name || "RouterTabs";
811
- e.component(a, Ce), e.component(n, te), n !== "router-tabs" && e.component("router-tabs", te), Object.defineProperty(e.config.globalProperties, "$tabs", {
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[H];
692
+ return e._context.provides[D];
816
693
  },
817
694
  set(t) {
818
- t && e.provide(H, t);
695
+ t && e.provide(D, t);
819
696
  }
820
697
  });
821
698
  }
822
699
  };
823
700
  export {
824
- Ce as RouterTab,
825
- te as RouterTabs,
826
- te as RouterTabsPinia,
827
- Ae as default,
828
- H as routerTabsKey,
829
- _e as useRouterTabs,
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
  };