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.
@@ -1,36 +1,35 @@
1
1
  import './vue3-router-tab.css';
2
- import { defineComponent as ae, inject as z, computed as S, unref as Ve, provide as U, ref as J, watch as x, h as Ie, getCurrentInstance as se, reactive as _e, shallowRef as Ke, nextTick as re, onMounted as Ae, onBeforeUnmount as Ne, resolveComponent as $e, createElementBlock as A, openBlock as T, createElementVNode as I, createCommentVNode as K, renderSlot as le, createVNode as j, TransitionGroup as Le, mergeProps as Q, withCtx as M, Fragment as ce, renderList as ue, withModifiers as B, normalizeClass as fe, createTextVNode as De, toDisplayString as de, Transition as pe, createBlock as W, KeepAlive as je, resolveDynamicComponent as be, normalizeStyle as Me } from "vue";
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 Ge = typeof document < "u", Ue = Object.assign, ze = Array.isArray;
10
- function Je(e) {
11
- const n = Array.from(arguments).slice(1);
12
- console.warn.apply(console, ["[Vue Router warn]: " + e].concat(n));
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 He(e, n) {
15
- return (e.aliasOf || e) === (n.aliasOf || n);
13
+ function Ge(e, t) {
14
+ return (e.aliasOf || e) === (t.aliasOf || t);
16
15
  }
17
- var ve;
16
+ var de;
18
17
  (function(e) {
19
18
  e.pop = "pop", e.push = "push";
20
- })(ve || (ve = {}));
21
- var he;
19
+ })(de || (de = {}));
20
+ var pe;
22
21
  (function(e) {
23
22
  e.back = "back", e.forward = "forward", e.unknown = "";
24
- })(he || (he = {}));
23
+ })(pe || (pe = {}));
25
24
  Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
26
- var me;
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
- })(me || (me = {}));
30
- const qe = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : ""), ye = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
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 ge = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : ""), Xe = /* @__PURE__ */ ae({
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: n, slots: a }) {
48
- process.env.NODE_ENV !== "production" && Fe();
49
- const t = z(ge), i = S(() => e.route || t.value), u = z(ye, 0), d = S(() => {
50
- let h = Ve(u);
51
- const { matched: b } = i.value;
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[h]) && !m.components; )
54
- h++;
55
- return h;
56
- }), f = S(() => i.value.matched[d.value]);
57
- U(ye, S(() => d.value + 1)), U(qe, f), U(ge, i);
58
- const p = J();
59
- return x(() => [p.value, f.value, e.name], ([h, b, m], [k, y, C]) => {
60
- b && (b.instances[m] = h, y && y !== b && h && h === k && (b.leaveGuards.size || (b.leaveGuards = y.leaveGuards), b.updateGuards.size || (b.updateGuards = y.updateGuards))), h && b && // if there is no instance but to and from are the same this might be
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
- (!y || !He(b, y) || !k) && (b.enterCallbacks[m] || []).forEach((_) => _(h));
61
+ (!h || !Ge(v, h) || !k) && (v.enterCallbacks[m] || []).forEach((_) => _(b));
63
62
  }, { flush: "post" }), () => {
64
- const h = i.value, b = e.name, m = f.value, k = m && m.components[b];
63
+ const b = s.value, v = e.name, m = l.value, k = m && m.components[v];
65
64
  if (!k)
66
- return we(a.default, { Component: k, route: h });
67
- const y = m.props[b], C = y ? y === !0 ? h.params : typeof y == "function" ? y(h) : y : null, g = Ie(k, Ue({}, C, n, {
68
- onVnodeUnmounted: (E) => {
69
- E.component.isUnmounted && (m.instances[b] = null);
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: p
70
+ ref: r
72
71
  }));
73
- if (process.env.NODE_ENV !== "production" && Ge && g.ref) {
74
- const E = {
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(g.ref) ? g.ref.map((P) => P.i) : [g.ref.i]).forEach((P) => {
81
- P.__vrv_devtools = E;
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
- we(a.default, { Component: g, route: h }) || g
86
+ he(o.default, { Component: R, route: b }) || R
88
87
  );
89
88
  };
90
89
  }
91
90
  });
92
- function we(e, n) {
91
+ function he(e, t) {
93
92
  if (!e)
94
93
  return null;
95
- const a = e(n);
96
- return a.length === 1 ? a[0] : a;
94
+ const o = e(t);
95
+ return o.length === 1 ? o[0] : o;
97
96
  }
98
- const Ye = Xe;
99
- function Fe() {
100
- const e = se(), n = e.parent && e.parent.type.name, a = e.parent && e.parent.subTree && e.parent.subTree.type;
101
- if (n && (n === "KeepAlive" || n.includes("Transition")) && typeof a == "object" && a.name === "RouterView") {
102
- const t = n === "KeepAlive" ? "keep-alive" : "transition";
103
- Je(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
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
- <${t}>
106
+ <${n}>
108
107
  <component :is="Component" />
109
- </${t}>
108
+ </${n}>
110
109
  </router-view>`);
111
110
  }
112
111
  }
113
- function Qe(e = {}) {
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 N(e, n) {
124
- const a = e.resolve(n);
125
- if (!a || !a.matched.length)
126
- throw new Error(`[RouterTabs] Unable to resolve route: ${String(n)}`);
127
- return a;
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 We = {
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 $(e) {
137
- const n = e.meta?.key;
138
- if (typeof n == "function") {
139
- const a = n(e);
140
- if (typeof a == "string" && a.length) return a;
141
- } else if (typeof n == "string" && n.length) {
142
- const a = We[n.toLowerCase()];
143
- return a ? a(e) : n;
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 ne(e, n) {
148
- const a = e.meta?.keepAlive;
149
- return typeof a == "boolean" ? a : n;
146
+ function Z(e, t) {
147
+ const o = e.meta?.keepAlive;
148
+ return typeof o == "boolean" ? o : t;
150
149
  }
151
- function oe(e, n) {
152
- const a = e.meta?.reuse;
153
- return typeof a == "boolean" ? a : n;
150
+ function ee(e, t) {
151
+ const o = e.meta?.reuse;
152
+ return typeof o == "boolean" ? o : t;
154
153
  }
155
- function Se(e) {
156
- const n = e.meta ?? {}, a = {};
157
- return "title" in n && (a.title = n.title), "tips" in n && (a.tips = n.tips), "icon" in n && (a.icon = n.icon), "closable" in n && (a.closable = n.closable), "tabClass" in n && (a.tabClass = n.tabClass), "target" in n && (a.target = n.target), "href" in n && (a.href = n.href), a;
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 G(e, n, a) {
160
- const t = Se(e);
158
+ function M(e, t, o) {
159
+ const n = Ae(e);
161
160
  return {
162
- id: $(e),
161
+ id: V(e),
163
162
  to: e.fullPath,
164
163
  fullPath: e.fullPath,
165
164
  matched: e,
166
- alive: ne(e, a),
167
- reusable: oe(e, !1),
168
- closable: t.closable ?? !0,
169
- ...t,
170
- ...n
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 Z(e, n, a, t) {
174
- if (!e.find((u) => u.id === n.id)) {
175
- if (a === "next" && t) {
176
- const u = e.findIndex((d) => d.id === t);
177
- if (u > -1) {
178
- e.splice(u + 1, 0, n);
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(n);
181
+ e.push(t);
183
182
  }
184
183
  }
185
- function Te(e, n, a) {
186
- if (!n || n <= 0) return;
187
- const t = e.filter((i) => i.alive);
188
- for (; t.length > n; ) {
189
- const i = t.shift();
190
- if (!i || i.id === a) continue;
191
- const u = e.findIndex((d) => d.id === i.id);
192
- u > -1 && (e[u].alive = !1);
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 Ze(e) {
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 et(e) {
206
- const n = {};
207
- 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;
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 tt(e, n = {}) {
210
- const a = Qe(n), t = _e([]), i = J(null), u = Ke(), d = J(null), f = S(() => t.filter((s) => s.alive).map((s) => s.id));
211
- let p = !1;
212
- function h(s) {
213
- const r = typeof s.matched == "object" ? s : N(e, s);
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: $(r),
216
- fullPath: r.fullPath,
217
- alive: ne(r, a.keepAlive),
218
- reusable: oe(r, !1),
219
- matched: r
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 b(s) {
223
- const r = $(s);
224
- let l = t.find((w) => w.id === r);
225
- return l ? (l.fullPath = s.fullPath, l.to = s.fullPath, l.matched = s, l.alive = ne(s, a.keepAlive), l.reusable = oe(s, l.reusable), Object.assign(l, Se(s)), l) : (l = G(s, {}, a.keepAlive), Z(t, l, a.appendPosition, i.value), Te(t, a.maxAlive, i.value), l);
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(s, r = !1, l = !0) {
228
- const w = N(e, s), O = $(w), V = i.value === O;
229
- l === "sameTab" && (l = V), l && await _(O, !0), await e[r ? "replace" : "push"](w), V && await L();
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(s) {
232
- const r = t.findIndex((w) => w.id === s), l = t[r] || t[r - 1] || t[0];
233
- return l ? l.to : a.defaultRoute;
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 y(s = i.value, r = {}) {
236
- if (s) {
237
- if (!r.force && a.keepLastTab && t.length === 1)
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 C(s, { force: r.force }), r.redirect !== null)
240
- if (i.value === s) {
241
- const l = r.redirect ?? k(s);
242
- l && await e.replace(l);
243
- } else r.redirect && await e.replace(r.redirect);
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 C(s, r = {}) {
247
- const l = t.findIndex((w) => w.id === s);
248
- l !== -1 && (t.splice(l, 1), d.value === s && (d.value = null), i.value === s && (i.value = null, u.value = void 0));
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 _(s = i.value ?? void 0, r = !1) {
251
- s && (d.value = s, await re(), r || await re(), d.value = null);
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 g(s = !1) {
254
- for (const r of t)
255
- await _(r.id, s);
252
+ async function R(i = !1) {
253
+ for (const c of n)
254
+ await _(c.id, i);
256
255
  }
257
- async function E(s = a.defaultRoute) {
258
- t.splice(0, t.length), i.value = null, u.value = void 0;
259
- for (const r of a.initialTabs) {
260
- const l = N(e, r.to), w = G(l, r, a.keepAlive);
261
- t.push(w);
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(s);
262
+ await e.replace(i);
264
263
  }
265
- async function L() {
266
- const s = i.value;
267
- s && await _(s, !0);
264
+ async function O() {
265
+ const i = s.value;
266
+ i && await _(i, !0);
268
267
  }
269
- function P(s) {
270
- return typeof s.matched == "object" ? $(s) : $(N(e, s));
268
+ function S(i) {
269
+ return typeof i.matched == "object" ? V(i) : V(I(e, i));
271
270
  }
272
- function q() {
273
- const s = t.find((r) => r.id === i.value);
271
+ function N() {
272
+ const i = n.find((c) => c.id === s.value);
274
273
  return {
275
- tabs: t.map(Ze),
276
- active: s ? s.to : null
274
+ tabs: n.map(Fe),
275
+ active: i ? i.to : null
277
276
  };
278
277
  }
279
- async function X(s) {
280
- p = !0, t.splice(0, t.length), i.value = null, u.value = void 0;
281
- const r = s?.tabs ?? [];
282
- for (const w of r)
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 O = N(e, w.to), V = et(w), D = G(O, V, a.keepAlive);
285
- Z(t, D, "last", null);
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
- p = !1;
289
- const l = s?.active ?? r[r.length - 1]?.to ?? a.defaultRoute;
290
- if (l)
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(l);
291
+ await e.replace(u);
293
292
  } catch {
294
293
  }
295
294
  }
296
- return x(
295
+ return E(
297
296
  () => e.currentRoute.value,
298
- (s) => {
299
- if (p) return;
300
- const r = b(s);
301
- i.value = r.id, u.value = r, Te(t, a.maxAlive, i.value);
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
- ), a.initialTabs.length && a.initialTabs.forEach((s) => {
305
- const r = N(e, s.to), l = G(r, s, a.keepAlive);
306
- Z(t, l, "last", null);
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: a,
309
- tabs: t,
310
- activeId: i,
311
- current: u,
312
- includeKeys: f,
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: y,
316
- removeTab: C,
314
+ closeTab: h,
315
+ removeTab: T,
317
316
  refreshTab: _,
318
- refreshAll: g,
319
- reset: E,
320
- reload: L,
321
- getRouteKey: P,
322
- matchRoute: h,
323
- snapshot: q,
324
- hydrate: X
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 ke(e) {
326
+ function ge(e) {
328
327
  return e ? typeof e == "string" ? { name: e } : e : {};
329
328
  }
330
- const H = Symbol("RouterTabsContext"), ee = typeof window < "u" && "sessionStorage" in window, nt = ae({
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
- storage: {
371
- type: [Boolean, String],
372
- default: !1
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 n = se();
377
- if (!n)
477
+ const t = ne();
478
+ if (!t)
378
479
  throw new Error("[RouterTab] component must be used within a Vue application context.");
379
- const a = n.appContext.app.config.globalProperties.$router;
380
- if (!a)
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 t = tt(a, {
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(H, t), n.appContext.config.globalProperties.$tabs = t;
391
- const i = S(() => ke(e.tabTransition)), u = S(() => ke(e.pageTransition)), d = _e({
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
- }), f = S(() => !e.storage || !ee ? null : typeof e.storage == "string" ? e.storage : `router-tabs:${(a.options?.history?.base ?? "") || "default"}`);
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 b(o) {
406
- return t.tabs.findIndex((c) => c.id === o);
509
+ function r(a) {
510
+ return n.tabs.findIndex((f) => f.id === a);
407
511
  }
408
- function m(o) {
409
- const c = b(o.id);
410
- return c > 0 ? t.tabs.slice(0, c) : [];
512
+ function b(a) {
513
+ const f = r(a.id);
514
+ return f > 0 ? n.tabs.slice(0, f) : [];
411
515
  }
412
- function k(o) {
413
- const c = b(o.id);
414
- return c > -1 ? t.tabs.slice(c + 1) : [];
516
+ function v(a) {
517
+ const f = r(a.id);
518
+ return f > -1 ? n.tabs.slice(f + 1) : [];
415
519
  }
416
- function y(o) {
417
- return t.tabs.filter((c) => c.id !== o.id);
520
+ function m(a) {
521
+ return n.tabs.filter((f) => f.id !== a.id);
418
522
  }
419
- async function C(o, c) {
420
- const v = o.filter((R) => R.closable !== !1);
421
- if (v.length) {
422
- for (const R of v)
423
- t.activeId.value === R.id ? await t.closeTab(R.id, { redirect: c.to, force: !0 }) : await t.removeTab(R.id, { force: !0 });
424
- t.activeId.value !== c.id && await t.openTab(c.to, !0, !1);
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: o }) => {
431
- await t.refreshTab(o.id, !0);
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 t.refreshAll(!0);
541
+ await n.refreshAll(!0);
438
542
  }
439
543
  },
440
544
  close: {
441
545
  label: "Close",
442
- handler: async ({ target: o }) => {
443
- await t.closeTab(o.id);
546
+ handler: async ({ target: a }) => {
547
+ await n.closeTab(a.id);
444
548
  },
445
- enable: ({ target: o }) => s(o)
549
+ enable: ({ target: a }) => N(a)
446
550
  },
447
551
  closeLefts: {
448
552
  label: "Close to the Left",
449
- handler: async ({ target: o }) => {
450
- await C(m(o), o);
553
+ handler: async ({ target: a }) => {
554
+ await k(b(a), a);
451
555
  },
452
- enable: ({ target: o }) => m(o).some((c) => c.closable !== !1)
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: o }) => {
457
- await C(k(o), o);
560
+ handler: async ({ target: a }) => {
561
+ await k(v(a), a);
458
562
  },
459
- enable: ({ target: o }) => k(o).some((c) => c.closable !== !1)
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: o }) => {
464
- await C(y(o), o);
567
+ handler: async ({ target: a }) => {
568
+ await k(m(a), a);
465
569
  },
466
- enable: ({ target: o }) => y(o).some((c) => c.closable !== !1)
570
+ enable: ({ target: a }) => m(a).some((f) => f.closable !== !1)
467
571
  }
468
572
  };
469
- function g() {
573
+ function T() {
470
574
  d.visible = !1, d.target = null;
471
575
  }
472
- function E(o, c) {
473
- e.contextmenu && (d.visible = !0, d.target = o, d.position.x = c.clientX, d.position.y = c.clientY, document.addEventListener("click", g, { once: !0 }));
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 L(o, c) {
476
- const v = typeof o == "string" ? { id: o } : o, R = _[v.id], xe = v.label ?? R?.label ?? String(v.id), Y = v.visible ?? R?.visible ?? !0;
477
- if (!(typeof Y == "function" ? Y(c) : Y !== !1)) return null;
478
- const F = v.enable ?? R?.enable ?? !0, Ee = typeof F == "function" ? F(c) : F !== !1, ie = v.handler ?? R?.handler;
479
- if (!ie) return null;
480
- const Oe = async () => {
481
- await Promise.resolve(ie(c));
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(v.id),
485
- label: xe,
486
- disabled: !Ee,
487
- action: Oe
588
+ id: String(g.id),
589
+ label: Pe,
590
+ disabled: !Se,
591
+ action: Ee
488
592
  };
489
593
  }
490
- const P = S(() => {
594
+ const x = P(() => {
491
595
  if (!d.visible || !d.target || e.contextmenu === !1) return [];
492
- const o = Array.isArray(e.contextmenu) ? e.contextmenu : h, c = { target: d.target, controller: t };
493
- return o.map((v) => L(v, c)).filter((v) => !!v);
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 q(o) {
496
- o.disabled || (g(), await o.action());
599
+ async function O(a) {
600
+ a.disabled || (T(), await a.action());
497
601
  }
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;
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 s(o) {
502
- return !(o.closable === !1 || t.options.keepLastTab && t.tabs.length <= 1);
605
+ function N(a) {
606
+ return !(a.closable === !1 || n.options.keepLastTab && n.tabs.length <= 1);
503
607
  }
504
- async function r(o) {
505
- await t.closeTab(o.id);
608
+ async function J(a) {
609
+ await n.closeTab(a.id);
506
610
  }
507
- function l(o) {
508
- t.activeId.value !== o.id && t.openTab(o.to, !1);
611
+ function i(a) {
612
+ n.activeId.value !== a.id && n.openTab(a.to, !1);
509
613
  }
510
- function w(o) {
614
+ function c(a) {
511
615
  return [
512
616
  "router-tab__item",
513
617
  {
514
- "is-active": t.activeId.value === o.id,
515
- "is-closable": s(o)
618
+ "is-active": n.activeId.value === a.id,
619
+ "is-closable": N(a)
516
620
  },
517
- o.tabClass
621
+ a.tabClass
518
622
  ];
519
623
  }
520
- function O(o) {
521
- return t.refreshingKey.value === t.getRouteKey(o);
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
- Ae(() => {
547
- document.addEventListener("keydown", g), V();
548
- }), Ne(() => {
549
- document.removeEventListener("keydown", g), n.appContext.config.globalProperties.$tabs = null, D();
550
- }), x(
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
- (o) => {
553
- t.options.keepAlive = o;
633
+ (a) => {
634
+ n.options.keepAlive = a;
554
635
  }
555
- ), x(
556
- () => t.activeId.value,
557
- () => g()
558
- ), x(
636
+ ), E(
637
+ () => n.activeId.value,
638
+ () => T()
639
+ ), E(
559
640
  () => e.contextmenu,
560
- (o) => {
561
- o || g();
641
+ (a) => {
642
+ a || T();
562
643
  }
563
- ), x(
564
- () => P.value.length,
565
- (o) => {
566
- d.visible && o === 0 && g();
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 Pe = t.includeKeys;
650
+ const y = n.includeKeys;
587
651
  return {
588
- controller: t,
589
- tabs: t.tabs,
590
- includeKeys: Pe,
591
- tabTransitionProps: i,
592
- pageTransitionProps: u,
593
- buildTabClass: w,
594
- activate: l,
595
- close: r,
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: P,
598
- handleMenuAction: q,
599
- showContextMenu: E,
600
- hideContextMenu: g,
601
- tabTitle: X,
602
- isClosable: s,
603
- isRefreshing: O
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
- }), ot = (e, n) => {
607
- const a = e.__vccOpts || e;
608
- for (const [t, i] of n)
609
- a[t] = i;
610
- return a;
611
- }, at = { class: "router-tab" }, st = { class: "router-tab__header" }, it = { class: "router-tab__slot-start" }, rt = { class: "router-tab__scroll" }, lt = ["onClick", "onAuxclick", "onContextmenu"], ct = ["title"], ut = ["onClick"], ft = { class: "router-tab__slot-end" }, dt = { class: "router-tab__container" }, pt = ["aria-disabled", "onClick"];
612
- function bt(e, n, a, t, i, u) {
613
- const d = $e("RouterView");
614
- return T(), A("div", at, [
615
- I("header", st, [
616
- I("div", it, [
617
- le(e.$slots, "start")
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
- I("div", rt, [
620
- j(Le, Q({
683
+ $("div", ut, [
684
+ D(Ne, q({
621
685
  tag: "ul",
622
686
  class: "router-tab__nav"
623
687
  }, e.tabTransitionProps), {
624
- default: M(() => [
625
- (T(!0), A(ce, null, ue(e.tabs, (f) => (T(), A("li", {
626
- key: f.id,
627
- class: fe(e.buildTabClass(f)),
628
- onClick: (p) => e.activate(f),
629
- onAuxclick: B((p) => e.close(f), ["middle", "prevent"]),
630
- onContextmenu: B((p) => e.showContextMenu(f, p), ["prevent"])
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
- I("span", {
696
+ $("span", {
633
697
  class: "router-tab__item-title",
634
- title: e.tabTitle(f)
698
+ title: e.tabTitle(l)
635
699
  }, [
636
- f.icon ? (T(), A("i", {
700
+ l.icon ? (w(), A("i", {
637
701
  key: 0,
638
- class: fe(["router-tab__item-icon", f.icon])
702
+ class: re(["router-tab__item-icon", l.icon])
639
703
  }, null, 2)) : K("", !0),
640
- De(" " + de(e.tabTitle(f)), 1)
641
- ], 8, ct),
642
- e.isClosable(f) ? (T(), A("a", {
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
- onClick: B((p) => e.close(f), ["stop"])
646
- }, null, 8, ut)) : K("", !0)
647
- ], 42, lt))), 128))
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
- I("div", ft, [
653
- le(e.$slots, "end")
717
+ $("div", bt, [
718
+ ie(e.$slots, "end")
654
719
  ])
655
720
  ]),
656
- I("div", dt, [
657
- j(d, null, {
658
- default: M(({ Component: f, route: p }) => [
659
- j(pe, Q(e.pageTransitionProps, { appear: "" }), {
660
- default: M(() => [
661
- e.controller.options.keepAlive ? (T(), W(je, {
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(p) ? K("", !0) : (T(), W(be(f), {
667
- key: e.controller.getRouteKey(p),
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
- j(pe, Q(e.pageTransitionProps, { appear: "" }), {
675
- default: M(() => [
676
- !e.controller.options.keepAlive || e.isRefreshing(p) ? (T(), W(be(f), {
677
- key: e.controller.getRouteKey(p) + (e.isRefreshing(p) ? "-refresh" : ""),
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 ? (T(), A("div", {
752
+ e.context.visible && e.context.target ? (w(), A("div", {
688
753
  key: 0,
689
754
  class: "router-tab__contextmenu",
690
- style: Me({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
755
+ style: je({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
691
756
  }, [
692
- (T(!0), A(ce, null, ue(e.menuItems, (f) => (T(), A("a", {
693
- key: f.id,
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": f.disabled,
696
- onClick: B((p) => e.handleMenuAction(f), ["prevent"])
697
- }, de(f.label), 9, pt))), 128))
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__ */ ot(nt, [["render", bt]]);
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
- }, te = /* @__PURE__ */ ae({
769
+ }, F = /* @__PURE__ */ te({
790
770
  name: "RouterTabs",
791
- __name: "RouterTabsPinia",
771
+ __name: "RouterTabs",
792
772
  props: {
793
- storeId: {},
794
- storageKey: {},
795
- storage: {},
796
- fallbackRoute: {},
797
- store: { type: [Function, Object] }
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 gt(e), (a, t) => (T(), A("span", wt));
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 n = Re.name || "RouterTab", a = te.name || "RouterTabs";
807
- e.component(n, Re), e.component(a, te), a !== "router-tabs" && e.component("router-tabs", te), Object.defineProperty(e.config.globalProperties, "$tabs", {
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[H];
795
+ return e._context.provides[G];
812
796
  },
813
- set(t) {
814
- t && e.provide(H, t);
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
- te as RouterTabs,
822
- te as RouterTabsPinia,
805
+ F as RouterTabs,
823
806
  Ce as default,
824
- H as routerTabsKey,
825
- vt as useRouterTabs,
826
- gt as useRouterTabsPiniaPersistence
807
+ G as routerTabsKey,
808
+ Te as useRouterTabs,
809
+ xe as useRouterTabsPersistence
827
810
  };