vue3-router-tab 1.3.4 → 1.3.5

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