vue3-router-tab 1.2.4 → 1.2.6

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