vue3-router-tab 1.2.7 → 1.2.9

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,7 +1,7 @@
1
1
  import './vue3-router-tab.css';
2
- import { reactive as ge, ref as $, shallowRef as ft, computed as k, watch as A, nextTick as L, inject as Pe, getCurrentInstance as je, onMounted as ve, defineComponent as Oe, provide as dt, onBeforeUnmount as bt, resolveComponent as pt, createElementBlock as x, openBlock as P, createElementVNode as U, createCommentVNode as V, normalizeClass as J, renderSlot as ue, createVNode as q, TransitionGroup as gt, mergeProps as Q, withCtx as Z, Fragment as ce, renderList as Ae, withModifiers as fe, toDisplayString as Ee, normalizeProps as vt, Transition as Ie, createBlock as de, KeepAlive as mt, resolveDynamicComponent as xe, normalizeStyle as ht, isRef as yt, isReadonly as Tt } from "vue";
3
- import { RouterView as kt } from "vue-router";
4
- function wt(e = {}) {
2
+ import { reactive as ge, ref as $, shallowRef as bt, computed as k, watch as A, nextTick as _, inject as Ae, getCurrentInstance as Oe, onMounted as me, defineComponent as Ue, provide as pt, onBeforeUnmount as gt, resolveComponent as mt, createElementBlock as I, openBlock as P, createElementVNode as O, createCommentVNode as U, normalizeClass as J, renderSlot as ue, createVNode as q, TransitionGroup as vt, mergeProps as Q, withCtx as Z, Fragment as ce, renderList as Ee, withModifiers as fe, toDisplayString as Ke, normalizeProps as yt, Transition as Ie, createBlock as de, KeepAlive as ht, resolveDynamicComponent as xe, normalizeStyle as Tt, isRef as kt, isReadonly as wt } from "vue";
3
+ import { RouterView as Ct } from "vue-router";
4
+ function Rt(e = {}) {
5
5
  return {
6
6
  initialTabs: e.initialTabs ?? [],
7
7
  keepAlive: e.keepAlive ?? !0,
@@ -11,255 +11,261 @@ function wt(e = {}) {
11
11
  defaultRoute: e.defaultRoute ?? "/"
12
12
  };
13
13
  }
14
- function N(e, o) {
15
- const n = e.resolve(o);
16
- if (!n || !n.matched.length)
17
- throw new Error(`[RouterTabs] Unable to resolve route: ${String(o)}`);
18
- return n;
14
+ function V(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;
19
19
  }
20
- const Rt = {
20
+ const Pt = {
21
21
  path: (e) => e.path,
22
22
  fullpath: (e) => e.fullPath,
23
23
  fullname: (e) => e.fullPath,
24
24
  full: (e) => e.fullPath,
25
25
  name: (e) => e.name ? String(e.name) : e.fullPath
26
26
  };
27
- function z(e) {
28
- const o = e.meta?.key;
29
- if (typeof o == "function") {
30
- const n = o(e);
31
- if (typeof n == "string" && n.length) return n;
32
- } else if (typeof o == "string" && o.length) {
33
- const n = Rt[o.toLowerCase()];
34
- return n ? n(e) : o;
27
+ function N(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 = Pt[n.toLowerCase()];
34
+ return o ? o(e) : n;
35
35
  }
36
36
  return e.fullPath;
37
37
  }
38
- function me(e, o) {
39
- const n = e.meta?.keepAlive;
40
- return typeof n == "boolean" ? n : o;
38
+ function ve(e, n) {
39
+ const o = e.meta?.keepAlive;
40
+ return typeof o == "boolean" ? o : n;
41
41
  }
42
- function he(e, o) {
43
- const n = e.meta?.reuse;
44
- return typeof n == "boolean" ? n : o;
42
+ function ye(e, n) {
43
+ const o = e.meta?.reuse;
44
+ return typeof o == "boolean" ? o : n;
45
45
  }
46
- function Ue(e) {
47
- const o = e.meta ?? {}, n = {};
48
- return "title" in o && (n.title = o.title), "tips" in o && (n.tips = o.tips), "icon" in o && (n.icon = o.icon), "closable" in o && (n.closable = o.closable), "tabClass" in o && (n.tabClass = o.tabClass), "target" in o && (n.target = o.target), "href" in o && (n.href = o.href), n;
46
+ function Ve(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;
49
49
  }
50
- function ee(e, o, n) {
51
- const l = Ue(e);
50
+ function ee(e, n, o) {
51
+ const l = Ve(e);
52
52
  return {
53
- id: z(e),
53
+ id: N(e),
54
54
  to: e.fullPath,
55
55
  fullPath: e.fullPath,
56
56
  matched: e,
57
- alive: me(e, n),
58
- reusable: he(e, !1),
57
+ alive: ve(e, o),
58
+ reusable: ye(e, !1),
59
59
  closable: l.closable ?? !0,
60
+ renderKey: typeof n.renderKey == "number" ? n.renderKey : 0,
60
61
  ...l,
61
- ...o
62
+ ...n
62
63
  };
63
64
  }
64
- function be(e, o, n, l) {
65
- if (!e.find((p) => p.id === o.id)) {
66
- if (n === "next" && l) {
67
- const p = e.findIndex((y) => y.id === l);
65
+ function be(e, n, o, l) {
66
+ if (!e.find((p) => p.id === n.id)) {
67
+ if (o === "next" && l) {
68
+ const p = e.findIndex((T) => T.id === l);
68
69
  if (p !== -1) {
69
- e.splice(p + 1, 0, o);
70
+ e.splice(p + 1, 0, n);
70
71
  return;
71
72
  }
72
73
  }
73
- e.push(o);
74
+ e.push(n);
74
75
  }
75
76
  }
76
- function Se(e, o, n) {
77
- if (!o || o <= 0) return;
78
- const l = e.filter((i) => i.alive);
79
- for (; l.length > o; ) {
80
- const i = l.shift();
81
- if (!i || i.id === n) continue;
82
- const p = e.findIndex((y) => y.id === i.id);
77
+ function Se(e, n, o) {
78
+ if (!n || n <= 0) return;
79
+ const l = e.filter((r) => r.alive);
80
+ for (; l.length > n; ) {
81
+ const r = l.shift();
82
+ if (!r || r.id === o) continue;
83
+ const p = e.findIndex((T) => T.id === r.id);
83
84
  p > -1 && (e[p].alive = !1);
84
85
  }
85
86
  }
86
- function Ct(e) {
87
+ function At(e) {
87
88
  return {
88
89
  to: e.to,
89
90
  title: e.title,
90
91
  tips: e.tips,
91
92
  icon: e.icon,
92
93
  tabClass: e.tabClass,
93
- closable: e.closable
94
+ closable: e.closable,
95
+ renderKey: e.renderKey
94
96
  };
95
97
  }
96
- function Pt(e) {
97
- const o = {};
98
- return "title" in e && (o.title = e.title), "tips" in e && (o.tips = e.tips), "icon" in e && (o.icon = e.icon), "tabClass" in e && (o.tabClass = e.tabClass), "closable" in e && (o.closable = e.closable), o;
98
+ function Et(e) {
99
+ const n = {};
100
+ 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), "renderKey" in e && typeof e.renderKey == "number" && (n.renderKey = e.renderKey), n;
99
101
  }
100
- function At(e, o = {}) {
101
- const n = wt(o), l = ge([]), i = $(null), p = ft(), y = $(null), s = k(() => l.filter((r) => r.alive).map((r) => r.id));
102
+ function Kt(e, n = {}) {
103
+ const o = Rt(n), l = ge([]), r = $(null), p = bt(), T = $(null), s = k(
104
+ () => l.filter((i) => i.alive).map((i) => `${i.id}::${i.renderKey}`)
105
+ );
102
106
  let c = !1;
103
- function g(r) {
104
- const d = typeof r.matched == "object" ? r : N(e, r);
107
+ function g(i) {
108
+ const b = typeof i.matched == "object" ? i : V(e, i);
105
109
  return {
106
- key: z(d),
107
- fullPath: d.fullPath,
108
- alive: me(d, n.keepAlive),
109
- reusable: he(d, !1),
110
- matched: d
110
+ key: N(b),
111
+ fullPath: b.fullPath,
112
+ alive: ve(b, o.keepAlive),
113
+ reusable: ye(b, !1),
114
+ matched: b
111
115
  };
112
116
  }
113
- function R(r) {
114
- const d = z(r);
115
- let b = l.find((T) => T.id === d);
116
- return b ? (b.fullPath = r.fullPath, b.to = r.fullPath, b.matched = r, b.alive = me(r, n.keepAlive), b.reusable = he(r, b.reusable), Object.assign(b, Ue(r)), b) : (b = ee(r, {}, n.keepAlive), be(l, b, n.appendPosition, i.value), Se(l, n.maxAlive, i.value), b);
117
+ function R(i) {
118
+ const b = N(i);
119
+ let d = l.find((h) => h.id === b);
120
+ return d ? (d.fullPath = i.fullPath, d.to = i.fullPath, d.matched = i, d.alive = ve(i, o.keepAlive), d.reusable = ye(i, d.reusable), Object.assign(d, Ve(i)), d) : (d = ee(i, {}, o.keepAlive), be(l, d, o.appendPosition, r.value), Se(l, o.maxAlive, r.value), d);
117
121
  }
118
- async function D(r, d = !1, b = !0) {
119
- const T = N(e, r), C = z(T), E = i.value === C;
120
- b === "sameTab" && (b = E), b && await j(C, !0), await e[d ? "replace" : "push"](T), E && await h();
122
+ async function S(i, b = !1, d = !0) {
123
+ const h = V(e, i), w = N(h), E = r.value === w;
124
+ d === "sameTab" && (d = E), d && await L(w, !0), await e[b ? "replace" : "push"](h), E && await y();
121
125
  }
122
- function M(r) {
123
- const d = l.findIndex((S) => S.id === r);
124
- if (d === -1) return n.defaultRoute;
125
- const b = l[d + 1], T = l[d - 1], C = l.find((S) => S.id !== r), E = b || T || C;
126
- return E ? E.to : n.defaultRoute;
126
+ function B(i) {
127
+ const b = l.findIndex((x) => x.id === i);
128
+ if (b === -1) return o.defaultRoute;
129
+ const d = l[b + 1], h = l[b - 1], w = l.find((x) => x.id !== i), E = d || h || w;
130
+ return E ? E.to : o.defaultRoute;
127
131
  }
128
- async function _(r = i.value, d = {}) {
129
- if (!r) return;
130
- if (!d.force && n.keepLastTab && l.length === 1)
132
+ async function z(i = r.value, b = {}) {
133
+ if (!i) return;
134
+ if (!b.force && o.keepLastTab && l.length === 1)
131
135
  throw new Error("[RouterTabs] Unable to close the final tab when keepLastTab is true.");
132
- const T = i.value === r && d.redirect !== null, C = T ? d.redirect ?? M(r) : null;
133
- await Y(r, { force: d.force }), d.redirect !== null && T && C && await e.replace(C);
136
+ const h = r.value === i && b.redirect !== null, w = h ? b.redirect ?? B(i) : null;
137
+ await Y(i, { force: b.force }), b.redirect !== null && h && w && await e.replace(w);
134
138
  }
135
- async function Y(r, d = {}) {
136
- const b = l.findIndex((T) => T.id === r);
137
- b !== -1 && (l.splice(b, 1), y.value === r && (y.value = null), i.value === r && (i.value = null, p.value = void 0));
139
+ async function Y(i, b = {}) {
140
+ const d = l.findIndex((h) => h.id === i);
141
+ d !== -1 && (l.splice(d, 1), T.value === i && (T.value = null), r.value === i && (r.value = null, p.value = void 0));
138
142
  }
139
- async function j(r = i.value ?? void 0, d = !1) {
140
- if (!r) return;
141
- const b = l.find((T) => T.id === r);
142
- b && (n.keepAlive && b.alive && (b.alive = !1, await L(), b.alive = !0, await L()), y.value = r, await L(), d || await L(), y.value = null);
143
+ async function L(i = r.value ?? void 0, b = !1) {
144
+ if (!i) return;
145
+ const d = l.find((w) => w.id === i);
146
+ if (!d) return;
147
+ const h = o.keepAlive && d.alive;
148
+ h && (d.alive = !1, await _()), d.renderKey = (d.renderKey ?? 0) + 1, h && (d.alive = !0, await _()), T.value = i, await _(), T.value = null;
143
149
  }
144
- async function ae(r = !1) {
145
- for (const d of l)
146
- await j(d.id, r);
150
+ async function ae(i = !1) {
151
+ for (const b of l)
152
+ await L(b.id, i);
147
153
  }
148
- async function ie(r = n.defaultRoute) {
149
- l.splice(0, l.length), i.value = null, p.value = void 0;
150
- for (const d of n.initialTabs) {
151
- const b = N(e, d.to), T = ee(b, d, n.keepAlive);
152
- l.push(T);
154
+ async function re(i = o.defaultRoute) {
155
+ l.splice(0, l.length), r.value = null, p.value = void 0;
156
+ for (const b of o.initialTabs) {
157
+ const d = V(e, b.to), h = ee(d, b, o.keepAlive);
158
+ l.push(h);
153
159
  }
154
- await e.replace(r);
160
+ await e.replace(i);
155
161
  }
156
- async function h() {
157
- const r = i.value;
158
- r && await j(r, !0);
162
+ async function y() {
163
+ const i = r.value;
164
+ i && await L(i, !0);
159
165
  }
160
- function G(r) {
161
- return typeof r.matched == "object" ? z(r) : z(N(e, r));
166
+ function G(i) {
167
+ return typeof i.matched == "object" ? N(i) : N(V(e, i));
162
168
  }
163
- function K() {
164
- const r = l.find((d) => d.id === i.value);
169
+ function M() {
170
+ const i = l.find((b) => b.id === r.value);
165
171
  return {
166
- tabs: l.map(Ct),
167
- active: r ? r.to : null
172
+ tabs: l.map(At),
173
+ active: i ? i.to : null
168
174
  };
169
175
  }
170
- async function B(r) {
171
- c = !0, l.splice(0, l.length), i.value = null, p.value = void 0;
172
- const d = r?.tabs ?? [];
173
- for (const T of d)
176
+ async function D(i) {
177
+ c = !0, l.splice(0, l.length), r.value = null, p.value = void 0;
178
+ const b = i?.tabs ?? [];
179
+ for (const h of b)
174
180
  try {
175
- const C = N(e, T.to), E = Pt(T), S = ee(C, E, n.keepAlive);
176
- be(l, S, "last", null);
181
+ const w = V(e, h.to), E = Et(h), x = ee(w, E, o.keepAlive);
182
+ be(l, x, "last", null);
177
183
  } catch {
178
184
  }
179
185
  c = !1;
180
- const b = r?.active ?? d[d.length - 1]?.to ?? n.defaultRoute;
181
- if (b)
186
+ const d = i?.active ?? b[b.length - 1]?.to ?? o.defaultRoute;
187
+ if (d)
182
188
  try {
183
- await e.replace(b);
189
+ await e.replace(d);
184
190
  } catch {
185
191
  }
186
192
  }
187
193
  return A(
188
194
  () => e.currentRoute.value,
189
- (r) => {
195
+ (i) => {
190
196
  if (c) return;
191
- const d = R(r);
192
- i.value = d.id, p.value = d, Se(l, n.maxAlive, i.value);
197
+ const b = R(i);
198
+ r.value = b.id, p.value = b, Se(l, o.maxAlive, r.value);
193
199
  },
194
200
  { immediate: !0 }
195
- ), n.initialTabs.length && n.initialTabs.forEach((r) => {
196
- const d = N(e, r.to), b = ee(d, r, n.keepAlive);
197
- be(l, b, "last", null);
201
+ ), o.initialTabs.length && o.initialTabs.forEach((i) => {
202
+ const b = V(e, i.to), d = ee(b, i, o.keepAlive);
203
+ be(l, d, "last", null);
198
204
  }), {
199
- options: n,
205
+ options: o,
200
206
  tabs: l,
201
- activeId: i,
207
+ activeId: r,
202
208
  current: p,
203
209
  includeKeys: s,
204
- refreshingKey: y,
205
- openTab: D,
206
- closeTab: _,
210
+ refreshingKey: T,
211
+ openTab: S,
212
+ closeTab: z,
207
213
  removeTab: Y,
208
- refreshTab: j,
214
+ refreshTab: L,
209
215
  refreshAll: ae,
210
- reset: ie,
211
- reload: h,
216
+ reset: re,
217
+ reload: y,
212
218
  getRouteKey: G,
213
219
  matchRoute: g,
214
- snapshot: K,
215
- hydrate: B
220
+ snapshot: M,
221
+ hydrate: D
216
222
  };
217
223
  }
218
224
  function De(e) {
219
225
  return e ? typeof e == "string" ? { name: e } : e : {};
220
226
  }
221
227
  const oe = Symbol("RouterTabsContext"), ne = "router-tabs:snapshot";
222
- function Be(e = {}) {
223
- const { optional: o = !1 } = e, n = Pe(oe, null);
224
- if (n) return n;
225
- const l = Pe("$tabs", null);
228
+ function $e(e = {}) {
229
+ const { optional: n = !1 } = e, o = Ae(oe, null);
230
+ if (o) return o;
231
+ const l = Ae("$tabs", null);
226
232
  if (l) return l;
227
- const p = je()?.appContext.config.globalProperties.$tabs;
233
+ const p = Oe()?.appContext.config.globalProperties.$tabs;
228
234
  if (p) return p;
229
- if (!o)
235
+ if (!n)
230
236
  throw new Error("[RouterTabs] useRouterTabs must be used within <router-tab>.");
231
237
  return null;
232
238
  }
233
- const Et = 864e5;
234
- function It(e) {
239
+ const It = 864e5;
240
+ function xt(e) {
235
241
  if (typeof document > "u") return null;
236
- const o = `${encodeURIComponent(e)}=`, n = document.cookie ? document.cookie.split("; ") : [];
237
- for (const l of n)
238
- if (l.startsWith(o))
239
- return decodeURIComponent(l.slice(o.length));
242
+ const n = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
243
+ for (const l of o)
244
+ if (l.startsWith(n))
245
+ return decodeURIComponent(l.slice(n.length));
240
246
  return null;
241
247
  }
242
- function $e(e, o, n) {
248
+ function Be(e, n, o) {
243
249
  if (typeof document > "u") return;
244
250
  const {
245
251
  expiresInDays: l = 7,
246
- path: i = "/",
252
+ path: r = "/",
247
253
  domain: p,
248
- secure: y,
254
+ secure: T,
249
255
  sameSite: s = "lax"
250
- } = n, c = [`${encodeURIComponent(e)}=${encodeURIComponent(o)}`];
256
+ } = o, c = [`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];
251
257
  if (l !== 1 / 0) {
252
- const g = new Date(Date.now() + l * Et).toUTCString();
258
+ const g = new Date(Date.now() + l * It).toUTCString();
253
259
  c.push(`Expires=${g}`);
254
260
  }
255
- i && c.push(`Path=${i}`), p && c.push(`Domain=${p}`), y && c.push("Secure"), s && c.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = c.join("; ");
261
+ r && c.push(`Path=${r}`), p && c.push(`Domain=${p}`), T && c.push("Secure"), s && c.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = c.join("; ");
256
262
  }
257
- function Me(e, o) {
263
+ function Me(e, n) {
258
264
  if (typeof document > "u") return;
259
- const { path: n = "/", domain: l } = o, i = [`${encodeURIComponent(e)}=`];
260
- i.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), n && i.push(`Path=${n}`), l && i.push(`Domain=${l}`), document.cookie = i.join("; ");
265
+ const { path: o = "/", domain: l } = n, r = [`${encodeURIComponent(e)}=`];
266
+ r.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && r.push(`Path=${o}`), l && r.push(`Domain=${l}`), document.cookie = r.join("; ");
261
267
  }
262
- const xt = (e) => JSON.stringify(e ?? null), St = (e) => {
268
+ const St = (e) => JSON.stringify(e ?? null), Dt = (e) => {
263
269
  if (!e) return null;
264
270
  try {
265
271
  return JSON.parse(e);
@@ -267,19 +273,19 @@ const xt = (e) => JSON.stringify(e ?? null), St = (e) => {
267
273
  return null;
268
274
  }
269
275
  };
270
- function Ve(e = {}) {
276
+ function Ne(e = {}) {
271
277
  const {
272
- cookieKey: o = ne,
273
- serialize: n = xt,
274
- deserialize: l = St
275
- } = e, i = Be({ optional: !0 }), p = $(!0), y = (s) => {
276
- ve(async () => {
277
- const c = l(It(o));
278
+ cookieKey: n = ne,
279
+ serialize: o = St,
280
+ deserialize: l = Dt
281
+ } = e, r = $e({ optional: !0 }), p = $(!0), T = (s) => {
282
+ me(async () => {
283
+ const c = l(xt(n));
278
284
  if (c && c.tabs?.length)
279
285
  try {
280
286
  if (p.value = !0, await s.hydrate(c), c.active) {
281
- await L();
282
- const R = s.tabs.find((D) => D.to === c.active);
287
+ await _();
288
+ const R = s.tabs.find((S) => S.to === c.active);
283
289
  R && (s.activeId.value = R.id, s.current.value = R);
284
290
  }
285
291
  } finally {
@@ -296,7 +302,7 @@ function Ve(e = {}) {
296
302
  else
297
303
  p.value = !1;
298
304
  const g = s.snapshot();
299
- g.tabs.length ? $e(o, n(g), e) : Me(o, e), p.value = !1;
305
+ g.tabs.length ? Be(n, o(g), e) : Me(n, e), p.value = !1;
300
306
  }), A(
301
307
  () => ({
302
308
  tabs: s.tabs.map((c) => ({
@@ -305,26 +311,27 @@ function Ve(e = {}) {
305
311
  tips: c.tips,
306
312
  icon: c.icon,
307
313
  tabClass: c.tabClass,
308
- closable: c.closable
314
+ closable: c.closable,
315
+ renderKey: c.renderKey
309
316
  })),
310
317
  active: s.activeId.value
311
318
  }),
312
319
  () => {
313
320
  if (p.value) return;
314
321
  const c = s.snapshot();
315
- c.tabs.length ? $e(o, n(c), e) : Me(o, e);
322
+ c.tabs.length ? Be(n, o(c), e) : Me(n, e);
316
323
  },
317
324
  { deep: !0 }
318
325
  );
319
326
  };
320
- i ? y(i) : ve(() => {
321
- const s = Be({ optional: !0 });
322
- s && y(s);
327
+ r ? T(r) : me(() => {
328
+ const s = $e({ optional: !0 });
329
+ s && T(s);
323
330
  });
324
331
  }
325
- const Dt = Oe({
332
+ const $t = Ue({
326
333
  name: "RouterTab",
327
- components: { RouterView: kt },
334
+ components: { RouterView: Ct },
328
335
  props: {
329
336
  tabs: {
330
337
  type: Array,
@@ -376,14 +383,14 @@ const Dt = Oe({
376
383
  }
377
384
  },
378
385
  emits: ["tab-sort", "tab-sorted"],
379
- setup(e, { emit: o }) {
380
- const n = je();
381
- if (!n)
386
+ setup(e, { emit: n }) {
387
+ const o = Oe();
388
+ if (!o)
382
389
  throw new Error("[RouterTab] component must be used within a Vue application context.");
383
- const l = n.appContext.app.config.globalProperties.$router;
390
+ const l = o.appContext.app.config.globalProperties.$router;
384
391
  if (!l)
385
392
  throw new Error("[RouterTab] Vue Router is required. Make sure to call app.use(router) before RouterTab.");
386
- const i = At(l, {
393
+ const r = Kt(l, {
387
394
  initialTabs: e.tabs,
388
395
  keepAlive: e.keepAlive,
389
396
  maxAlive: e.maxAlive,
@@ -391,43 +398,43 @@ const Dt = Oe({
391
398
  appendPosition: e.append,
392
399
  defaultRoute: e.defaultPage
393
400
  });
394
- dt(oe, i), n.appContext.config.globalProperties.$tabs = i;
395
- const p = k(() => !!n?.slots?.default), y = k(() => !!n?.slots?.start), s = k(() => !!n?.slots?.end), c = $(0), g = k(() => {
401
+ pt(oe, r), o.appContext.config.globalProperties.$tabs = r;
402
+ const p = k(() => !!o?.slots?.default), T = k(() => !!o?.slots?.start), s = k(() => !!o?.slots?.end), c = $(0), g = k(() => {
396
403
  c.value;
397
404
  const t = {};
398
- return i.tabs.forEach((a) => {
399
- const f = typeof a.title == "string" ? a.title : String(a.title || re(a));
405
+ return r.tabs.forEach((a) => {
406
+ const f = typeof a.title == "string" ? a.title : String(a.title || ie(a));
400
407
  t[a.id] = f;
401
408
  }), t;
402
409
  });
403
410
  function R() {
404
411
  c.value++;
405
412
  }
406
- const D = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map();
407
- function _(t, a) {
408
- if (!a || D.has(t)) return;
409
- D.set(t, a);
410
- const f = i.tabs.find((m) => i.getRouteKey(m.to) === t);
413
+ const S = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
414
+ function z(t, a) {
415
+ if (!a || S.has(t)) return;
416
+ S.set(t, a);
417
+ const f = r.tabs.find((v) => r.getRouteKey(v.to) === t);
411
418
  if (!f) return;
412
- const v = [];
419
+ const m = [];
413
420
  if (a.routeTabTitle !== void 0) {
414
- const m = A(
421
+ const v = A(
415
422
  () => {
416
423
  const u = a.routeTabTitle;
417
424
  return u && typeof u == "object" && "value" in u ? u.value : u;
418
425
  },
419
426
  (u) => {
420
427
  if (u != null) {
421
- const O = String(u);
422
- f.title = O, R();
428
+ const j = String(u);
429
+ f.title = j, R();
423
430
  }
424
431
  },
425
432
  { immediate: !0 }
426
433
  );
427
- v.push(m);
434
+ m.push(v);
428
435
  }
429
436
  if (a.routeTabIcon !== void 0) {
430
- const m = A(
437
+ const v = A(
431
438
  () => {
432
439
  const u = a.routeTabIcon;
433
440
  return u && typeof u == "object" && "value" in u ? u.value : u;
@@ -437,10 +444,10 @@ const Dt = Oe({
437
444
  },
438
445
  { immediate: !0 }
439
446
  );
440
- v.push(m);
447
+ m.push(v);
441
448
  }
442
449
  if (a.routeTabClosable !== void 0) {
443
- const m = A(
450
+ const v = A(
444
451
  () => {
445
452
  const u = a.routeTabClosable;
446
453
  return u && typeof u == "object" && "value" in u ? u.value : u;
@@ -450,10 +457,10 @@ const Dt = Oe({
450
457
  },
451
458
  { immediate: !0 }
452
459
  );
453
- v.push(m);
460
+ m.push(v);
454
461
  }
455
462
  if (a.routeTabMeta !== void 0) {
456
- const m = A(
463
+ const v = A(
457
464
  () => {
458
465
  const u = a.routeTabMeta;
459
466
  return u && typeof u == "object" && "value" in u ? u.value : u;
@@ -463,33 +470,33 @@ const Dt = Oe({
463
470
  },
464
471
  { immediate: !0, deep: !0 }
465
472
  );
466
- v.push(m);
473
+ m.push(v);
467
474
  }
468
- M.set(t, v);
475
+ B.set(t, m);
469
476
  }
470
477
  function Y(t) {
471
- const a = M.get(t);
472
- a && (a.forEach((f) => f()), M.delete(t)), D.delete(t);
478
+ const a = B.get(t);
479
+ a && (a.forEach((f) => f()), B.delete(t)), S.delete(t);
473
480
  }
474
- function j(t, a) {
475
- t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? _(a, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && _(a, t.$) : t === null && Y(a);
481
+ function L(t, a) {
482
+ t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? z(a, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && z(a, t.$) : t === null && Y(a);
476
483
  }
477
484
  if (e.cookieKey !== null || e.persistence) {
478
485
  const t = {
479
486
  ...e.persistence ?? {}
480
487
  };
481
- e.cookieKey !== null ? t.cookieKey = e.cookieKey || ne : t.cookieKey || (t.cookieKey = ne), Ve(t);
488
+ e.cookieKey !== null ? t.cookieKey = e.cookieKey || ne : t.cookieKey || (t.cookieKey = ne), Ne(t);
482
489
  }
483
- const ae = k(() => De(e.tabTransition)), ie = k(() => De(e.pageTransition)), h = ge({
490
+ const ae = k(() => De(e.tabTransition)), re = k(() => De(e.pageTransition)), y = ge({
484
491
  visible: !1,
485
492
  target: null,
486
493
  position: { x: 0, y: 0 }
487
- }), G = $(null), K = $([]), B = $(-1), r = ge({
494
+ }), G = $(null), M = $([]), D = $(-1), i = ge({
488
495
  dragging: !1,
489
496
  dragIndex: -1,
490
497
  dropIndex: -1,
491
498
  dragTab: null
492
- }), d = [
499
+ }), b = [
493
500
  "refresh",
494
501
  "refreshAll",
495
502
  "close",
@@ -497,133 +504,133 @@ const Dt = Oe({
497
504
  "closeRights",
498
505
  "closeOthers"
499
506
  ];
500
- function b(t) {
501
- return i.tabs.findIndex((a) => a.id === t);
507
+ function d(t) {
508
+ return r.tabs.findIndex((a) => a.id === t);
502
509
  }
503
- function T(t) {
504
- const a = b(t.id);
505
- return a > 0 ? i.tabs.slice(0, a) : [];
510
+ function h(t) {
511
+ const a = d(t.id);
512
+ return a > 0 ? r.tabs.slice(0, a) : [];
506
513
  }
507
- function C(t) {
508
- const a = b(t.id);
509
- return a > -1 ? i.tabs.slice(a + 1) : [];
514
+ function w(t) {
515
+ const a = d(t.id);
516
+ return a > -1 ? r.tabs.slice(a + 1) : [];
510
517
  }
511
518
  function E(t) {
512
- return i.tabs.filter((a) => a.id !== t.id);
519
+ return r.tabs.filter((a) => a.id !== t.id);
513
520
  }
514
- async function S(t, a) {
515
- const f = t.filter((v) => v.closable !== !1);
521
+ async function x(t, a) {
522
+ const f = t.filter((m) => m.closable !== !1);
516
523
  if (f.length) {
517
- for (const v of f)
518
- i.activeId.value === v.id ? await i.closeTab(v.id, { redirect: a.to, force: !0 }) : await i.removeTab(v.id, { force: !0 });
519
- i.activeId.value !== a.id && await i.openTab(a.to, !0, !1);
524
+ for (const m of f)
525
+ r.activeId.value === m.id ? await r.closeTab(m.id, { redirect: a.to, force: !0 }) : await r.removeTab(m.id, { force: !0 });
526
+ r.activeId.value !== a.id && await r.openTab(a.to, !0, !1);
520
527
  }
521
528
  }
522
- const Fe = {
529
+ const He = {
523
530
  refresh: {
524
531
  label: "Refresh",
525
532
  handler: async ({ target: t }) => {
526
- await i.refreshTab(t.id, !0);
533
+ await r.refreshTab(t.id, !0);
527
534
  }
528
535
  },
529
536
  refreshAll: {
530
537
  label: "Refresh All",
531
538
  handler: async () => {
532
- await i.refreshAll(!0);
539
+ await r.refreshAll(!0);
533
540
  }
534
541
  },
535
542
  close: {
536
543
  label: "Close",
537
544
  handler: async ({ target: t }) => {
538
- await i.closeTab(t.id);
545
+ await r.closeTab(t.id);
539
546
  },
540
547
  enable: ({ target: t }) => le(t)
541
548
  },
542
549
  closeLefts: {
543
550
  label: "Close to the Left",
544
551
  handler: async ({ target: t }) => {
545
- await S(T(t), t);
552
+ await x(h(t), t);
546
553
  },
547
- enable: ({ target: t }) => T(t).some((a) => a.closable !== !1)
554
+ enable: ({ target: t }) => h(t).some((a) => a.closable !== !1)
548
555
  },
549
556
  closeRights: {
550
557
  label: "Close to the Right",
551
558
  handler: async ({ target: t }) => {
552
- await S(C(t), t);
559
+ await x(w(t), t);
553
560
  },
554
- enable: ({ target: t }) => C(t).some((a) => a.closable !== !1)
561
+ enable: ({ target: t }) => w(t).some((a) => a.closable !== !1)
555
562
  },
556
563
  closeOthers: {
557
564
  label: "Close Others",
558
565
  handler: async ({ target: t }) => {
559
- await S(E(t), t);
566
+ await x(E(t), t);
560
567
  },
561
568
  enable: ({ target: t }) => E(t).some((a) => a.closable !== !1)
562
569
  }
563
570
  };
564
- function I() {
565
- h.visible = !1, h.target = null, B.value = -1, K.value = [];
571
+ function K() {
572
+ y.visible = !1, y.target = null, D.value = -1, M.value = [];
566
573
  }
567
- function He(t, a) {
568
- e.contextmenu && (h.visible = !0, h.target = t, h.position.x = a.clientX, h.position.y = a.clientY, document.addEventListener("click", I, { once: !0 }), L(() => {
569
- We();
574
+ function Je(t, a) {
575
+ e.contextmenu && (y.visible = !0, y.target = t, y.position.x = a.clientX, y.position.y = a.clientY, document.addEventListener("click", K, { once: !0 }), _(() => {
576
+ Ge();
570
577
  }));
571
578
  }
572
- function Je(t, a) {
573
- const f = typeof t == "string" ? { id: t } : t, v = Fe[f.id], m = f.label ?? v?.label ?? String(f.id), u = f.visible ?? v?.visible ?? !0;
579
+ function We(t, a) {
580
+ const f = typeof t == "string" ? { id: t } : t, m = He[f.id], v = f.label ?? m?.label ?? String(f.id), u = f.visible ?? m?.visible ?? !0;
574
581
  if (!(typeof u == "function" ? u(a) : u !== !1)) return null;
575
- const se = f.enable ?? v?.enable ?? !0, ut = typeof se == "function" ? se(a) : se !== !1, Ce = f.handler ?? v?.handler;
576
- if (!Ce) return null;
577
- const ct = async () => {
578
- await Promise.resolve(Ce(a));
582
+ const se = f.enable ?? m?.enable ?? !0, ft = typeof se == "function" ? se(a) : se !== !1, Pe = f.handler ?? m?.handler;
583
+ if (!Pe) return null;
584
+ const dt = async () => {
585
+ await Promise.resolve(Pe(a));
579
586
  };
580
587
  return {
581
588
  id: String(f.id),
582
- label: m,
583
- disabled: !ut,
584
- action: ct
589
+ label: v,
590
+ disabled: !ft,
591
+ action: dt
585
592
  };
586
593
  }
587
594
  const F = k(() => {
588
- if (!h.visible || !h.target || e.contextmenu === !1) return [];
589
- const t = Array.isArray(e.contextmenu) ? e.contextmenu : d, a = { target: h.target, controller: i };
590
- return t.map((f) => Je(f, a)).filter((f) => !!f);
595
+ if (!y.visible || !y.target || e.contextmenu === !1) return [];
596
+ const t = Array.isArray(e.contextmenu) ? e.contextmenu : b, a = { target: y.target, controller: r };
597
+ return t.map((f) => We(f, a)).filter((f) => !!f);
591
598
  });
592
- function We() {
599
+ function Ge() {
593
600
  const t = G.value;
594
601
  if (!t) return;
595
- const a = 8, { innerWidth: f, innerHeight: v } = window, m = t.getBoundingClientRect();
596
- let u = h.position.x, O = h.position.y;
597
- m.right > f - a && (u = Math.max(a, f - m.width - a)), m.bottom > v - a && (O = Math.max(a, v - m.height - a)), (u !== h.position.x || O !== h.position.y) && (h.position.x = u, h.position.y = O);
602
+ const a = 8, { innerWidth: f, innerHeight: m } = window, v = t.getBoundingClientRect();
603
+ let u = y.position.x, j = y.position.y;
604
+ v.right > f - a && (u = Math.max(a, f - v.width - a)), v.bottom > m - a && (j = Math.max(a, m - v.height - a)), (u !== y.position.x || j !== y.position.y) && (y.position.x = u, y.position.y = j);
598
605
  }
599
- function Ge(t, a) {
600
- K.value[a] = t ?? null;
606
+ function Xe(t, a) {
607
+ M.value[a] = t ?? null;
601
608
  }
602
- function Xe(t) {
609
+ function qe(t) {
603
610
  if (t < 0) return;
604
- K.value[t]?.focus({ preventScroll: !0 });
611
+ M.value[t]?.focus({ preventScroll: !0 });
605
612
  }
606
613
  function X(t, a, f = F.value) {
607
614
  if (!f.length) return -1;
608
- const v = f.length;
609
- let m = t;
610
- for (let u = 0; u < v; u++)
611
- if (m = (m + a + v) % v, !f[m].disabled) return m;
615
+ const m = f.length;
616
+ let v = t;
617
+ for (let u = 0; u < m; u++)
618
+ if (v = (v + a + m) % m, !f[v].disabled) return v;
612
619
  return -1;
613
620
  }
614
621
  function H(t) {
615
- B.value = t, !(t < 0) && L(() => Xe(t));
622
+ D.value = t, !(t < 0) && _(() => qe(t));
616
623
  }
617
624
  function ke(t) {
618
- const a = X(B.value, t);
625
+ const a = X(D.value, t);
619
626
  a !== -1 && H(a);
620
627
  }
621
- function qe(t) {
622
- if (!h.visible) return;
628
+ function Qe(t) {
629
+ if (!y.visible) return;
623
630
  const a = t.key, f = F.value;
624
631
  if (!f.length) return;
625
632
  if (a === "Tab") {
626
- I();
633
+ K();
627
634
  return;
628
635
  }
629
636
  if ([
@@ -656,74 +663,81 @@ const Dt = Oe({
656
663
  case "Enter":
657
664
  case " ":
658
665
  case "Spacebar": {
659
- const m = B.value;
660
- if (m > -1) {
661
- const u = f[m];
666
+ const v = D.value;
667
+ if (v > -1) {
668
+ const u = f[v];
662
669
  u.disabled || we(u);
663
670
  }
664
671
  break;
665
672
  }
666
673
  case "Escape":
667
- I();
674
+ K();
668
675
  break;
669
676
  }
670
677
  }
671
678
  async function we(t) {
672
- t.disabled || (I(), await t.action());
679
+ t.disabled || (K(), await t.action());
673
680
  }
674
- function re(t) {
681
+ function ie(t) {
675
682
  return typeof t.title == "string" && t.title.trim() ? t.title : Array.isArray(t.title) && t.title.length && String(t.title[0]).trim() ? String(t.title[0]) : "Untitled";
676
683
  }
677
- function Qe(t) {
678
- return g.value[t.id] || re(t);
684
+ function Ze(t) {
685
+ return g.value[t.id] || ie(t);
686
+ }
687
+ function Ce(t) {
688
+ const a = r.getRouteKey(t), m = r.tabs.find((v) => v.id === a)?.renderKey ?? 0;
689
+ return `${a}::${m}`;
690
+ }
691
+ function et(t) {
692
+ return `${Ce(t)}::refresh`;
679
693
  }
680
694
  function le(t) {
681
- return !(t.closable === !1 || i.options.keepLastTab && i.tabs.length <= 1);
695
+ return !(t.closable === !1 || r.options.keepLastTab && r.tabs.length <= 1);
682
696
  }
683
- async function Ze(t) {
684
- await i.closeTab(t.id);
697
+ async function tt(t) {
698
+ await r.closeTab(t.id);
685
699
  }
686
- function et(t) {
700
+ function nt(t) {
687
701
  if (t.href && typeof window < "u") {
688
702
  t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
689
703
  return;
690
704
  }
691
- i.activeId.value !== t.id && i.openTab(t.to, !1);
705
+ r.activeId.value !== t.id && r.openTab(t.to, !1);
692
706
  }
693
- function tt(t) {
707
+ function ot(t) {
694
708
  return [
695
709
  "router-tab__item",
696
710
  {
697
- "is-active": i.activeId.value === t.id,
711
+ "is-active": r.activeId.value === t.id,
698
712
  "is-closable": le(t),
699
- "is-dragging": r.dragging && r.dragTab?.id === t.id,
700
- "is-drag-over": r.dropIndex === b(t.id)
713
+ "is-dragging": i.dragging && i.dragTab?.id === t.id,
714
+ "is-drag-over": i.dropIndex === d(t.id)
701
715
  },
702
716
  t.tabClass
703
717
  ];
704
718
  }
705
- function nt(t) {
706
- return i.refreshingKey.value === i.getRouteKey(t);
719
+ function at(t) {
720
+ return r.refreshingKey.value === r.getRouteKey(t);
707
721
  }
708
- function ot(t, a, f) {
709
- e.sortable && (r.dragging = !0, r.dragIndex = a, r.dragTab = t, f.dataTransfer && (f.dataTransfer.effectAllowed = "move", f.dataTransfer.setData("text/plain", t.id)), o("tab-sort", { tab: t, index: a }));
722
+ function rt(t, a, f) {
723
+ e.sortable && (i.dragging = !0, i.dragIndex = a, i.dragTab = t, f.dataTransfer && (f.dataTransfer.effectAllowed = "move", f.dataTransfer.setData("text/plain", t.id)), n("tab-sort", { tab: t, index: a }));
710
724
  }
711
- function at(t, a) {
712
- !e.sortable || !r.dragging || (a.preventDefault(), a.dataTransfer && (a.dataTransfer.dropEffect = "move"));
725
+ function it(t, a) {
726
+ !e.sortable || !i.dragging || (a.preventDefault(), a.dataTransfer && (a.dataTransfer.dropEffect = "move"));
713
727
  }
714
- function it(t) {
715
- !e.sortable || !r.dragging || (r.dropIndex = t);
728
+ function lt(t) {
729
+ !e.sortable || !i.dragging || (i.dropIndex = t);
716
730
  }
717
- function rt() {
718
- !e.sortable || r.dragging;
731
+ function st() {
732
+ !e.sortable || i.dragging;
719
733
  }
720
- function lt(t, a) {
721
- if (!(!e.sortable || !r.dragging)) {
722
- if (a.preventDefault(), r.dragIndex !== -1 && r.dragIndex !== t) {
723
- const f = i.tabs.splice(r.dragIndex, 1)[0];
724
- i.tabs.splice(t, 0, f), o("tab-sorted", {
734
+ function ut(t, a) {
735
+ if (!(!e.sortable || !i.dragging)) {
736
+ if (a.preventDefault(), i.dragIndex !== -1 && i.dragIndex !== t) {
737
+ const f = r.tabs.splice(i.dragIndex, 1)[0];
738
+ r.tabs.splice(t, 0, f), n("tab-sorted", {
725
739
  tab: f,
726
- fromIndex: r.dragIndex,
740
+ fromIndex: i.dragIndex,
727
741
  toIndex: t
728
742
  });
729
743
  }
@@ -731,103 +745,105 @@ const Dt = Oe({
731
745
  }
732
746
  }
733
747
  function Re() {
734
- r.dragging = !1, r.dragIndex = -1, r.dropIndex = -1, r.dragTab = null;
748
+ i.dragging = !1, i.dragIndex = -1, i.dropIndex = -1, i.dragTab = null;
735
749
  }
736
- ve(() => {
737
- document.addEventListener("keydown", I);
738
- }), bt(() => {
739
- document.removeEventListener("keydown", I), n.appContext.config.globalProperties.$tabs = null, M.forEach((t) => {
750
+ me(() => {
751
+ document.addEventListener("keydown", K);
752
+ }), gt(() => {
753
+ document.removeEventListener("keydown", K), o.appContext.config.globalProperties.$tabs = null, B.forEach((t) => {
740
754
  t.forEach((a) => a());
741
- }), M.clear(), D.clear();
755
+ }), B.clear(), S.clear();
742
756
  }), A(
743
757
  () => e.keepAlive,
744
758
  (t) => {
745
- i.options.keepAlive = t;
759
+ r.options.keepAlive = t;
746
760
  }
747
761
  ), A(
748
- () => i.activeId.value,
749
- () => I()
762
+ () => r.activeId.value,
763
+ () => K()
750
764
  ), A(
751
765
  () => e.contextmenu,
752
766
  (t) => {
753
- t || I();
767
+ t || K();
754
768
  }
755
769
  ), A(
756
770
  () => F.value.length,
757
771
  (t) => {
758
- h.visible && t === 0 && I();
772
+ y.visible && t === 0 && K();
759
773
  }
760
774
  ), A(F, (t) => {
761
- if (K.value = new Array(t.length).fill(null), !h.visible) return;
775
+ if (M.value = new Array(t.length).fill(null), !y.visible) return;
762
776
  const a = X(-1, 1, t);
763
777
  H(a);
764
778
  }), A(
765
- () => h.visible,
779
+ () => y.visible,
766
780
  (t) => {
767
- t || (B.value = -1, K.value = []);
781
+ t || (D.value = -1, M.value = []);
768
782
  }
769
783
  );
770
- const st = i.includeKeys;
784
+ const ct = r.includeKeys;
771
785
  return {
772
- controller: i,
773
- tabs: i.tabs,
774
- includeKeys: st,
786
+ controller: r,
787
+ tabs: r.tabs,
788
+ includeKeys: ct,
775
789
  tabTransitionProps: ae,
776
- pageTransitionProps: ie,
777
- buildTabClass: tt,
778
- activate: et,
779
- close: Ze,
780
- context: h,
790
+ pageTransitionProps: re,
791
+ buildTabClass: ot,
792
+ activate: nt,
793
+ close: tt,
794
+ context: y,
781
795
  menuItems: F,
782
796
  handleMenuAction: we,
783
- showContextMenu: He,
784
- hideContextMenu: I,
785
- getTabTitle: re,
797
+ showContextMenu: Je,
798
+ hideContextMenu: K,
799
+ getTabTitle: ie,
786
800
  isClosable: le,
787
- isRefreshing: nt,
801
+ isRefreshing: at,
788
802
  hasCustomSlot: p,
789
- hasStartSlot: y,
803
+ hasStartSlot: T,
790
804
  hasEndSlot: s,
791
- onDragStart: ot,
792
- onDragOver: at,
793
- onDragEnter: it,
794
- onDragLeave: rt,
795
- onDrop: lt,
805
+ onDragStart: rt,
806
+ onDragOver: it,
807
+ onDragEnter: lt,
808
+ onDragLeave: st,
809
+ onDrop: ut,
796
810
  onDragEnd: Re,
797
- setupComponentWatching: _,
811
+ setupComponentWatching: z,
798
812
  cleanupComponentWatching: Y,
799
- handleComponentRef: j,
800
- getReactiveTabTitle: Qe,
813
+ handleComponentRef: L,
814
+ getReactiveTabTitle: Ze,
815
+ getComponentCacheKey: Ce,
816
+ getRefreshComponentKey: et,
801
817
  triggerTabUpdate: R,
802
818
  menuRef: G,
803
- highlightedIndex: B,
804
- setMenuItemRef: Ge,
805
- onMenuKeydown: qe,
819
+ highlightedIndex: D,
820
+ setMenuItemRef: Xe,
821
+ onMenuKeydown: Qe,
806
822
  highlightMenuIndex: H
807
823
  };
808
824
  }
809
- }), Bt = (e, o) => {
810
- const n = e.__vccOpts || e;
811
- for (const [l, i] of o)
812
- n[l] = i;
813
- return n;
814
- }, $t = { class: "router-tab" }, Mt = { class: "router-tab__header" }, Kt = { class: "router-tab__scroll" }, Lt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], jt = ["title"], Ot = ["onClick"], Ut = { class: "router-tab__container" }, Vt = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
815
- function Nt(e, o, n, l, i, p) {
816
- const y = pt("RouterView");
817
- return P(), x("div", $t, [
818
- U("header", Mt, [
819
- U("div", {
825
+ }), Bt = (e, n) => {
826
+ const o = e.__vccOpts || e;
827
+ for (const [l, r] of n)
828
+ o[l] = r;
829
+ return o;
830
+ }, Mt = { class: "router-tab" }, Lt = { class: "router-tab__header" }, jt = { class: "router-tab__scroll" }, Ot = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], Ut = ["title"], Vt = ["onClick"], Nt = { class: "router-tab__container" }, _t = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
831
+ function zt(e, n, o, l, r, p) {
832
+ const T = mt("RouterView");
833
+ return P(), I("div", Mt, [
834
+ O("header", Lt, [
835
+ O("div", {
820
836
  class: J(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
821
837
  }, [
822
838
  ue(e.$slots, "start")
823
839
  ], 2),
824
- U("div", Kt, [
825
- q(gt, Q({
840
+ O("div", jt, [
841
+ q(vt, Q({
826
842
  tag: "ul",
827
843
  class: "router-tab__nav"
828
844
  }, e.tabTransitionProps), {
829
845
  default: Z(() => [
830
- (P(!0), x(ce, null, Ae(e.tabs, (s, c) => (P(), x("li", {
846
+ (P(!0), I(ce, null, Ee(e.tabs, (s, c) => (P(), I("li", {
831
847
  key: s.id,
832
848
  class: J(e.buildTabClass(s)),
833
849
  "data-title": e.getTabTitle(s),
@@ -838,66 +854,66 @@ function Nt(e, o, n, l, i, p) {
838
854
  onDragstart: (g) => e.onDragStart(s, c, g),
839
855
  onDragover: (g) => e.onDragOver(c, g),
840
856
  onDragenter: (g) => e.onDragEnter(c),
841
- onDragleave: o[0] || (o[0] = (...g) => e.onDragLeave && e.onDragLeave(...g)),
857
+ onDragleave: n[0] || (n[0] = (...g) => e.onDragLeave && e.onDragLeave(...g)),
842
858
  onDrop: (g) => e.onDrop(c, g),
843
- onDragend: o[1] || (o[1] = (...g) => e.onDragEnd && e.onDragEnd(...g))
859
+ onDragend: n[1] || (n[1] = (...g) => e.onDragEnd && e.onDragEnd(...g))
844
860
  }, [
845
- s.icon ? (P(), x("i", {
861
+ s.icon ? (P(), I("i", {
846
862
  key: 0,
847
863
  class: J(["router-tab__item-icon", s.icon])
848
- }, null, 2)) : V("", !0),
849
- U("span", {
864
+ }, null, 2)) : U("", !0),
865
+ O("span", {
850
866
  class: "router-tab__item-title",
851
867
  title: e.getReactiveTabTitle(s)
852
- }, Ee(e.getReactiveTabTitle(s)), 9, jt),
853
- e.isClosable(s) ? (P(), x("a", {
868
+ }, Ke(e.getReactiveTabTitle(s)), 9, Ut),
869
+ e.isClosable(s) ? (P(), I("a", {
854
870
  key: 1,
855
871
  class: "router-tab__item-close",
856
872
  onClick: fe((g) => e.close(s), ["stop"])
857
- }, null, 8, Ot)) : V("", !0)
858
- ], 42, Lt))), 128))
873
+ }, null, 8, Vt)) : U("", !0)
874
+ ], 42, Ot))), 128))
859
875
  ]),
860
876
  _: 1
861
877
  }, 16)
862
878
  ]),
863
- U("div", {
879
+ O("div", {
864
880
  class: J(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
865
881
  }, [
866
882
  ue(e.$slots, "end")
867
883
  ], 2)
868
884
  ]),
869
- U("div", Ut, [
870
- q(y, null, {
885
+ O("div", Nt, [
886
+ q(T, null, {
871
887
  default: Z((s) => [
872
- e.hasCustomSlot ? ue(e.$slots, "default", vt(Q({ key: 0 }, {
888
+ e.hasCustomSlot ? ue(e.$slots, "default", yt(Q({ key: 0 }, {
873
889
  ...s,
874
890
  controller: e.controller,
875
891
  // Expose a ref binder so custom slots can keep reactivity
876
892
  pageRef: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route))
877
- }))) : (P(), x(ce, { key: 1 }, [
893
+ }))) : (P(), I(ce, { key: 1 }, [
878
894
  q(Ie, Q(e.pageTransitionProps, { appear: "" }), {
879
895
  default: Z(() => [
880
- e.controller.options.keepAlive ? (P(), de(mt, {
896
+ e.controller.options.keepAlive ? (P(), de(ht, {
881
897
  key: 0,
882
898
  include: e.includeKeys,
883
899
  max: e.controller.options.maxAlive || void 0
884
900
  }, [
885
- e.isRefreshing(s.route) ? V("", !0) : (P(), de(xe(s.Component), {
886
- key: e.controller.getRouteKey(s.route),
901
+ e.isRefreshing(s.route) ? U("", !0) : (P(), de(xe(s.Component), {
902
+ key: e.getComponentCacheKey(s.route),
887
903
  ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
888
904
  class: "router-tab-page"
889
905
  }))
890
- ], 1032, ["include", "max"])) : V("", !0)
906
+ ], 1032, ["include", "max"])) : U("", !0)
891
907
  ]),
892
908
  _: 2
893
909
  }, 1040),
894
910
  q(Ie, Q(e.pageTransitionProps, { appear: "" }), {
895
911
  default: Z(() => [
896
912
  !e.controller.options.keepAlive || e.isRefreshing(s.route) ? (P(), de(xe(s.Component), {
897
- key: e.controller.getRouteKey(s.route) + (e.isRefreshing(s.route) ? "-refresh" : ""),
913
+ key: e.getRefreshComponentKey(s.route),
898
914
  ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
899
915
  class: "router-tab-page"
900
- })) : V("", !0)
916
+ })) : U("", !0)
901
917
  ]),
902
918
  _: 2
903
919
  }, 1040)
@@ -906,15 +922,15 @@ function Nt(e, o, n, l, i, p) {
906
922
  _: 3
907
923
  })
908
924
  ]),
909
- e.context.visible && e.context.target ? (P(), x("div", {
925
+ e.context.visible && e.context.target ? (P(), I("div", {
910
926
  key: 0,
911
927
  ref: "menuRef",
912
928
  class: "router-tab__contextmenu",
913
929
  role: "menu",
914
- onKeydown: o[2] || (o[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
915
- style: ht({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
930
+ onKeydown: n[2] || (n[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
931
+ style: Tt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
916
932
  }, [
917
- (P(!0), x(ce, null, Ae(e.menuItems, (s, c) => (P(), x("a", {
933
+ (P(!0), I(ce, null, Ee(e.menuItems, (s, c) => (P(), I("a", {
918
934
  key: s.id,
919
935
  role: "menuitem",
920
936
  class: J(["router-tab__contextmenu-item", { "is-focused": c === e.highlightedIndex }]),
@@ -925,14 +941,14 @@ function Nt(e, o, n, l, i, p) {
925
941
  ref: (g) => e.setMenuItemRef(g, c),
926
942
  onMouseenter: (g) => !s.disabled && e.highlightMenuIndex(c),
927
943
  onClick: (g) => e.handleMenuAction(s)
928
- }, Ee(s.label), 43, Vt))), 128))
929
- ], 36)) : V("", !0)
944
+ }, Ke(s.label), 43, _t))), 128))
945
+ ], 36)) : U("", !0)
930
946
  ]);
931
947
  }
932
- const Ke = /* @__PURE__ */ Bt(Dt, [["render", Nt]]), zt = {
948
+ const Le = /* @__PURE__ */ Bt($t, [["render", zt]]), Yt = {
933
949
  class: "router-tabs",
934
950
  "aria-hidden": "true"
935
- }, pe = /* @__PURE__ */ Oe({
951
+ }, pe = /* @__PURE__ */ Ue({
936
952
  name: "RouterTabs",
937
953
  __name: "RouterTabs",
938
954
  props: {
@@ -947,11 +963,11 @@ const Ke = /* @__PURE__ */ Bt(Dt, [["render", Nt]]), zt = {
947
963
  fallbackRoute: {}
948
964
  },
949
965
  setup(e) {
950
- return Ve(e), (n, l) => (P(), x("span", zt));
966
+ return Ne(e), (o, l) => (P(), I("span", Yt));
951
967
  }
952
- }), Ne = "tab-theme-style", ze = "tab-theme-primary-color", _t = "system", _e = "(prefers-color-scheme: dark)";
968
+ }), _e = "tab-theme-style", ze = "tab-theme-primary-color", Ft = "system", Ye = "(prefers-color-scheme: dark)";
953
969
  let W = null;
954
- const w = {
970
+ const C = {
955
971
  primary: "#034960",
956
972
  background: "#ffffff",
957
973
  text: "#1e293b",
@@ -965,7 +981,7 @@ const w = {
965
981
  activeButtonBackground: "#034960",
966
982
  activeButtonColor: "#ffffff",
967
983
  iconColor: "#475569"
968
- }, Yt = {
984
+ }, Ht = {
969
985
  primary: "#38bdf8",
970
986
  background: "#0f172a",
971
987
  text: "#f1f5f9",
@@ -981,61 +997,61 @@ const w = {
981
997
  activeButtonColor: "#0f172a",
982
998
  iconColor: "#cbd5e1"
983
999
  };
984
- function Ft(e) {
1000
+ function Jt(e) {
985
1001
  if (typeof window > "u") return null;
986
- const o = window.localStorage.getItem(e);
987
- if (!o) return null;
1002
+ const n = window.localStorage.getItem(e);
1003
+ if (!n) return null;
988
1004
  try {
989
- const n = JSON.parse(o);
990
- return n && typeof n == "object" ? n : null;
1005
+ const o = JSON.parse(n);
1006
+ return o && typeof o == "object" ? o : null;
991
1007
  } catch {
992
1008
  return null;
993
1009
  }
994
1010
  }
995
- function ye(e) {
996
- typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? w.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? w.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? w.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? w.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? w.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? w.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? w.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? w.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? w.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? w.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? w.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? w.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? w.iconColor));
1011
+ function he(e) {
1012
+ typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? C.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? C.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? C.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? C.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? C.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? C.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? C.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? C.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? C.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? C.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? C.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? C.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? C.iconColor));
997
1013
  }
998
- function Ye(e) {
1014
+ function Fe(e) {
999
1015
  if (typeof document > "u") return;
1000
- const o = document.documentElement, n = window.matchMedia(_e), l = () => {
1001
- o.dataset.theme = n.matches ? "dark" : "light";
1016
+ const n = document.documentElement, o = window.matchMedia(Ye), l = () => {
1017
+ n.dataset.theme = o.matches ? "dark" : "light";
1002
1018
  };
1003
- W && (n.removeEventListener("change", W), W = null), e === "system" ? (l(), W = () => l(), n.addEventListener("change", W)) : o.dataset.theme = e;
1019
+ W && (o.removeEventListener("change", W), W = null), e === "system" ? (l(), W = () => l(), o.addEventListener("change", W)) : n.dataset.theme = e;
1004
1020
  }
1005
- function Ht(e = {}) {
1021
+ function Wt(e = {}) {
1006
1022
  if (typeof window > "u") return;
1007
1023
  const {
1008
- styleKey: o = Ne,
1009
- primaryKey: n = ze,
1010
- defaultStyle: l = _t,
1011
- defaultPrimary: i
1012
- } = e, p = window.localStorage.getItem(o) ?? l;
1013
- Ye(p);
1014
- const s = p === "dark" || p === "system" && window.matchMedia(_e).matches ? { ...Yt } : { ...w };
1015
- i && (s.primary = i);
1016
- const c = Ft(n);
1017
- ye(c ? {
1024
+ styleKey: n = _e,
1025
+ primaryKey: o = ze,
1026
+ defaultStyle: l = Ft,
1027
+ defaultPrimary: r
1028
+ } = e, p = window.localStorage.getItem(n) ?? l;
1029
+ Fe(p);
1030
+ const s = p === "dark" || p === "system" && window.matchMedia(Ye).matches ? { ...Ht } : { ...C };
1031
+ r && (s.primary = r);
1032
+ const c = Jt(o);
1033
+ he(c ? {
1018
1034
  ...s,
1019
1035
  ...c
1020
1036
  } : s);
1021
1037
  }
1022
- function Gt(e, o) {
1038
+ function qt(e, n) {
1023
1039
  if (typeof window > "u") return;
1024
- const n = o?.styleKey ?? Ne;
1025
- window.localStorage.setItem(n, e), Ye(e);
1040
+ const o = n?.styleKey ?? _e;
1041
+ window.localStorage.setItem(o, e), Fe(e);
1026
1042
  }
1027
- function Xt(e, o) {
1043
+ function Qt(e, n) {
1028
1044
  if (typeof window > "u") return;
1029
- const n = o?.primaryKey ?? ze;
1030
- window.localStorage.setItem(n, JSON.stringify(e)), ye(e);
1045
+ const o = n?.primaryKey ?? ze;
1046
+ window.localStorage.setItem(o, JSON.stringify(e)), he(e);
1031
1047
  }
1032
- function te(e, o) {
1033
- if (yt(e)) {
1034
- const l = !Tt(e);
1048
+ function te(e, n) {
1049
+ if (kt(e)) {
1050
+ const l = !wt(e);
1035
1051
  return {
1036
1052
  value: e,
1037
- update: l ? (i) => {
1038
- e.value = i;
1053
+ update: l ? (r) => {
1054
+ e.value = r;
1039
1055
  } : () => {
1040
1056
  }
1041
1057
  };
@@ -1046,90 +1062,90 @@ function te(e, o) {
1046
1062
  update: () => {
1047
1063
  }
1048
1064
  };
1049
- const n = $(
1050
- e === void 0 ? o : e
1065
+ const o = $(
1066
+ e === void 0 ? n : e
1051
1067
  );
1052
1068
  return {
1053
- value: n,
1069
+ value: o,
1054
1070
  update: (l) => {
1055
- n.value = l;
1071
+ o.value = l;
1056
1072
  }
1057
1073
  };
1058
1074
  }
1059
1075
  function Te(e = {}) {
1060
- const o = te(e.title, "Untitled"), n = te(e.icon, ""), l = te(e.closable, !0), i = te(e.meta, {});
1076
+ const n = te(e.title, "Untitled"), o = te(e.icon, ""), l = te(e.closable, !0), r = te(e.meta, {});
1061
1077
  return {
1062
- routeTabTitle: o.value,
1063
- routeTabIcon: n.value,
1078
+ routeTabTitle: n.value,
1079
+ routeTabIcon: o.value,
1064
1080
  routeTabClosable: l.value,
1065
- routeTabMeta: i.value,
1066
- updateTitle: o.update,
1067
- updateIcon: n.update,
1081
+ routeTabMeta: r.value,
1082
+ updateTitle: n.update,
1083
+ updateIcon: o.update,
1068
1084
  updateClosable: l.update,
1069
- updateMeta: i.update
1085
+ updateMeta: r.update
1070
1086
  };
1071
1087
  }
1072
- function qt(e, o = "Page") {
1088
+ function Zt(e, n = "Page") {
1073
1089
  return Te({
1074
- title: k(() => e.value ? "Loading..." : o),
1090
+ title: k(() => e.value ? "Loading..." : n),
1075
1091
  icon: k(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
1076
1092
  closable: k(() => !e.value)
1077
1093
  });
1078
1094
  }
1079
- function Qt(e, o = "Page", n = "mdi-page") {
1095
+ function en(e, n = "Page", o = "mdi-page") {
1080
1096
  return Te({
1081
- title: k(() => e.value > 0 ? `${o} (${e.value})` : o),
1082
- icon: k(() => e.value > 0 ? "mdi-bell-badge" : n)
1097
+ title: k(() => e.value > 0 ? `${n} (${e.value})` : n),
1098
+ icon: k(() => e.value > 0 ? "mdi-bell-badge" : o)
1083
1099
  });
1084
1100
  }
1085
- function Zt(e, o = "Page") {
1086
- const n = {
1101
+ function tn(e, n = "Page") {
1102
+ const o = {
1087
1103
  normal: { suffix: "", icon: "mdi-page" },
1088
1104
  loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
1089
1105
  error: { suffix: " - Error", icon: "mdi-alert" },
1090
1106
  success: { suffix: " - Success", icon: "mdi-check-circle" }
1091
1107
  };
1092
1108
  return Te({
1093
- title: k(() => o + n[e.value].suffix),
1094
- icon: k(() => n[e.value].icon),
1109
+ title: k(() => n + o[e.value].suffix),
1110
+ icon: k(() => o[e.value].icon),
1095
1111
  closable: k(() => e.value !== "loading")
1096
1112
  });
1097
1113
  }
1098
- let Le = !1;
1099
- const en = {
1100
- install(e, o) {
1101
- if (Le) return;
1102
- Le = !0;
1114
+ let je = !1;
1115
+ const nn = {
1116
+ install(e, n) {
1117
+ if (je) return;
1118
+ je = !0;
1103
1119
  const {
1104
- initTheme: n = !0,
1120
+ initTheme: o = !0,
1105
1121
  themeOptions: l,
1106
- componentName: i = Ke.name || "RouterTab",
1122
+ componentName: r = Le.name || "RouterTab",
1107
1123
  tabsComponentName: p = pe.name || "RouterTabs"
1108
- } = o ?? {};
1109
- n && Ht(l ?? {}), e.component(i, Ke), e.component(p, pe), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", pe), Object.defineProperty(e.config.globalProperties, "$tabs", {
1124
+ } = n ?? {};
1125
+ o && Wt(l ?? {}), e.component(r, Le), e.component(p, pe), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", pe), Object.defineProperty(e.config.globalProperties, "$tabs", {
1110
1126
  configurable: !0,
1111
1127
  enumerable: !1,
1112
1128
  get() {
1113
1129
  return e._context.provides[oe];
1114
1130
  },
1115
- set(y) {
1116
- y && e.provide(oe, y);
1131
+ set(T) {
1132
+ T && e.provide(oe, T);
1117
1133
  }
1118
1134
  });
1119
1135
  }
1120
1136
  };
1121
1137
  export {
1122
- Ke as RouterTab,
1138
+ Le as RouterTab,
1123
1139
  pe as RouterTabs,
1124
- en as default,
1125
- Ht as initRouterTabsTheme,
1140
+ nn as default,
1141
+ Wt as initRouterTabsTheme,
1126
1142
  oe as routerTabsKey,
1127
- Xt as setRouterTabsPrimary,
1128
- Gt as setRouterTabsTheme,
1129
- qt as useLoadingTab,
1130
- Qt as useNotificationTab,
1143
+ Qt as setRouterTabsPrimary,
1144
+ qt as setRouterTabsTheme,
1145
+ Zt as useLoadingTab,
1146
+ en as useNotificationTab,
1131
1147
  Te as useReactiveTab,
1132
- Be as useRouterTabs,
1133
- Ve as useRouterTabsPersistence,
1134
- Zt as useStatusTab
1148
+ $e as useRouterTabs,
1149
+ Ne as useRouterTabsPersistence,
1150
+ tn as useStatusTab
1135
1151
  };