bitboss-ui 0.2.66 → 0.2.67
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.
- package/dist/index101.js +3 -3
- package/dist/index103.js +2 -2
- package/dist/index109.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index111.js +4 -4
- package/dist/index113.js +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.js +1 -1
- package/dist/index118.js +1 -1
- package/dist/index119.js +1 -1
- package/dist/index121.js +1 -1
- package/dist/index125.js +1 -1
- package/dist/index126.js +1 -1
- package/dist/index15.js +8 -8
- package/dist/index17.js +9 -9
- package/dist/index19.js +3 -3
- package/dist/index196.js +2 -235
- package/dist/index196.js.map +1 -1
- package/dist/index198.js +5 -2
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +16 -4
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +16 -5
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +18 -15
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +17 -13
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +28 -18
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +8 -20
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +2 -29
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +368 -8
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +134 -2
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +2 -2
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +174 -3
- package/dist/index209.js.map +1 -1
- package/dist/index21.js +2 -2
- package/dist/index210.js +23 -3
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +363 -111
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +2 -2
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +4 -6
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +3 -368
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +31 -369
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +6 -2
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +3 -2
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +3 -134
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +226 -165
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +121 -23
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +2 -3
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +2 -35
- package/dist/index222.js.map +1 -1
- package/dist/index224.js +6 -79
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +17 -6
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +79 -17
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +6 -2
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +2 -160
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +297 -1
- package/dist/index229.js.map +1 -1
- package/dist/index23.js +1 -1
- package/dist/index230.js +2 -69
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +2 -5
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +117 -2
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +106 -4
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +2 -295
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +2 -6
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +2 -2
- package/dist/index238.js +160 -2
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +1 -4
- package/dist/index239.js.map +1 -1
- package/dist/index240.js +5 -2
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +4 -2
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +2 -224
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +68 -257
- package/dist/index243.js.map +1 -1
- package/dist/index245.js +428 -99
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +89 -2
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +218 -111
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +252 -429
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +197 -86
- package/dist/index249.js.map +1 -1
- package/dist/index25.js +2 -2
- package/dist/index250.js +2 -200
- package/dist/index250.js.map +1 -1
- package/dist/index254.js +3 -2
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +2 -3
- package/dist/index255.js.map +1 -1
- package/dist/index29.js +3 -3
- package/dist/index31.js +8 -8
- package/dist/index33.js +2 -2
- package/dist/index35.js +2 -2
- package/dist/index47.js +1 -1
- package/dist/index49.js +1 -1
- package/dist/index65.js +4 -4
- package/dist/index69.js +2 -2
- package/dist/index72.js +1 -1
- package/dist/index75.js +1 -1
- package/dist/index77.js +1 -1
- package/dist/index79.js +4 -4
- package/dist/index81.js +1 -1
- package/dist/index99.js +112 -101
- package/dist/index99.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index77.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as x, computed as y, ref as p, onMounted as A, onBeforeUnmount as B, openBlock as k, createElementBlock as V, createElementVNode as u, renderSlot as g, createTextVNode as b, Fragment as E, renderList as P, normalizeClass as W, toDisplayString as h, nextTick as z } from "vue";
|
|
2
|
-
import R from "./
|
|
2
|
+
import R from "./index226.js";
|
|
3
3
|
const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["disabled", "onClick"], D = ["disabled"], O = /* @__PURE__ */ x({
|
|
4
4
|
__name: "BbPagination",
|
|
5
5
|
props: {
|
package/dist/index79.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineComponent as V, ref as a, computed as _, openBlock as p, createElementBlock as h, mergeProps as B, createElementVNode as d, renderSlot as P, normalizeProps as I, guardReactiveProps as R, unref as g, createBlock as D, Teleport as U, normalizeClass as W, normalizeStyle as j, createCommentVNode as y, withCtx as G, nextTick as J } from "vue";
|
|
2
|
-
import { useFloating as K, arrow as Q } from "./
|
|
3
|
-
import { useFocusTrap as X } from "./
|
|
2
|
+
import { useFloating as K, arrow as Q } from "./index220.js";
|
|
3
|
+
import { useFocusTrap as X } from "./index215.js";
|
|
4
4
|
import { useId as Y } from "./index7.js";
|
|
5
5
|
import { wait as E } from "./index122.js";
|
|
6
6
|
import Z from "./index9.js";
|
|
7
7
|
import "./index10.js";
|
|
8
|
-
import { autoUpdate as ee, flip as oe, shift as te } from "./
|
|
9
|
-
import { offset as ae } from "./
|
|
8
|
+
import { autoUpdate as ee, flip as oe, shift as te } from "./index206.js";
|
|
9
|
+
import { offset as ae } from "./index211.js";
|
|
10
10
|
const re = ["id"], ne = {
|
|
11
11
|
key: 1,
|
|
12
12
|
class: "bb-popover__bubble"
|
package/dist/index81.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as a, computed as l, openBlock as s, createElementBlock as n, normalizeClass as m, createElementVNode as i, normalizeStyle as c } from "vue";
|
|
2
|
-
import { clamp as p } from "./
|
|
2
|
+
import { clamp as p } from "./index196.js";
|
|
3
3
|
import { getAsPercentageBetween as d } from "./index121.js";
|
|
4
4
|
const v = /* @__PURE__ */ a({
|
|
5
5
|
__name: "BbProgress",
|
package/dist/index99.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as D, getCurrentInstance as z, ref as K, computed as
|
|
1
|
+
import { defineComponent as D, getCurrentInstance as z, ref as K, computed as p, watch as _, openBlock as u, createElementBlock as d, unref as H, normalizeClass as g, createElementVNode as m, Fragment as w, renderList as B, createVNode as J, withCtx as O, renderSlot as q, toDisplayString as j, createCommentVNode as G } from "vue";
|
|
2
2
|
import { useId as M } from "./index7.js";
|
|
3
3
|
import { useRoute as Q } from "./index129.js";
|
|
4
4
|
import { useRouter as W } from "./index130.js";
|
|
5
5
|
import { wait as X } from "./index122.js";
|
|
6
6
|
import Y from "./index9.js";
|
|
7
7
|
import "./index10.js";
|
|
8
|
-
const Z = ["id"], ee = {
|
|
8
|
+
const Z = ["id"], ee = { class: "bb-tab__label-boundary" }, te = {
|
|
9
9
|
class: "bb-tab__label-container",
|
|
10
10
|
role: "tablist"
|
|
11
|
-
}, ae = { class: "bb-tab__label" }, le = { class: "bb-tab__panes-container" },
|
|
11
|
+
}, ae = { class: "bb-tab__label" }, le = { class: "bb-tab__panes-container" }, se = ["id", "aria-labelledby"], be = /* @__PURE__ */ D({
|
|
12
12
|
__name: "BbTab",
|
|
13
13
|
props: {
|
|
14
14
|
disabled: { type: Boolean },
|
|
@@ -22,47 +22,47 @@ const Z = ["id"], ee = {
|
|
|
22
22
|
},
|
|
23
23
|
emits: ["update:modelValue"],
|
|
24
24
|
setup(F, { expose: N, emit: A }) {
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
() =>
|
|
28
|
-
),
|
|
29
|
-
if (
|
|
25
|
+
var T, S, x, I, V, L, C;
|
|
26
|
+
const a = F, P = A, o = Q(), v = W(), k = a.id ?? M().id.value, b = `bb-tab_${k}`, $ = !!((S = (T = z()) == null ? void 0 : T.proxy) != null && S.$inertia), l = K(null), i = p(
|
|
27
|
+
() => a.items.findIndex((e) => e.key === l.value)
|
|
28
|
+
), y = p(() => i.value === 0), f = p(() => i.value === a.items.length - 1);
|
|
29
|
+
if (a.items.forEach((e) => {
|
|
30
30
|
if (!e.key)
|
|
31
31
|
throw console.error("A tab item has no key", e), new Error("A tab item has no key " + JSON.stringify(e));
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
else if (
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
}), a.navigation && ((I = (x = o.value) == null ? void 0 : x.query) != null && I[a.querykey]))
|
|
33
|
+
l.value = (L = (V = o.value) == null ? void 0 : V.query) == null ? void 0 : L[a.querykey];
|
|
34
|
+
else if (a.navigation && $ && ((C = globalThis == null ? void 0 : globalThis.location) != null && C.href) && new URL(globalThis.location.href).searchParams.get(a.querykey))
|
|
35
|
+
l.value = new URL(globalThis.location.href).searchParams.get(
|
|
36
|
+
a.querykey
|
|
37
37
|
);
|
|
38
|
-
else if (
|
|
39
|
-
|
|
40
|
-
else if (
|
|
41
|
-
const e =
|
|
38
|
+
else if (a.modelValue)
|
|
39
|
+
l.value = a.modelValue;
|
|
40
|
+
else if (a.items[0]) {
|
|
41
|
+
const e = a.items.find((t) => !t.disabled);
|
|
42
42
|
if (!e)
|
|
43
43
|
throw new Error(
|
|
44
44
|
"No tab has been selected so it defaulted to the first available. Still, all the tabs are disabled so no tab can be selected."
|
|
45
45
|
);
|
|
46
46
|
const s = e.key;
|
|
47
|
-
|
|
47
|
+
l.value = s;
|
|
48
48
|
}
|
|
49
49
|
const c = async (e, s = !1) => {
|
|
50
|
-
var
|
|
51
|
-
if (
|
|
52
|
-
|
|
50
|
+
var t, n, E, R;
|
|
51
|
+
if (a.navigation && o.value && ((n = (t = o.value) == null ? void 0 : t.query) == null ? void 0 : n[a.querykey]) !== e)
|
|
52
|
+
v == null || v.push({
|
|
53
53
|
...o,
|
|
54
|
-
query: { ...(
|
|
54
|
+
query: { ...(E = o.value) == null ? void 0 : E.query, [a.querykey]: e },
|
|
55
55
|
replace: s
|
|
56
56
|
});
|
|
57
|
-
else if (
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
s ? history.replaceState({}, "",
|
|
57
|
+
else if (a.navigation && $ && ((R = globalThis == null ? void 0 : globalThis.location) != null && R.href) && new URL(globalThis.location.href).searchParams.get(a.querykey) !== e) {
|
|
58
|
+
const h = new URL(globalThis.location.href);
|
|
59
|
+
h.searchParams.set(a.querykey, e), X(0).then(() => {
|
|
60
|
+
s ? history.replaceState({}, "", h.toString()) : history.pushState({}, "", h.toString());
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
a.modelValue !== e && P("update:modelValue", e), l.value = e;
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
l.value && c(l.value, !0);
|
|
66
66
|
const r = (e) => {
|
|
67
67
|
var s = null;
|
|
68
68
|
switch (e) {
|
|
@@ -70,25 +70,25 @@ const Z = ["id"], ee = {
|
|
|
70
70
|
s = 0;
|
|
71
71
|
break;
|
|
72
72
|
case "previous":
|
|
73
|
-
s = (i.value +
|
|
73
|
+
s = (i.value + a.items.length - 1) % a.items.length;
|
|
74
74
|
break;
|
|
75
75
|
case "next":
|
|
76
|
-
s = (i.value + 1) %
|
|
76
|
+
s = (i.value + 1) % a.items.length;
|
|
77
77
|
break;
|
|
78
78
|
case "last":
|
|
79
|
-
s =
|
|
79
|
+
s = a.items.length - 1;
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
if (s === null)
|
|
83
83
|
throw new Error("Could not navigate to next tab");
|
|
84
|
-
if (
|
|
84
|
+
if (a.items[s].disabled)
|
|
85
85
|
return;
|
|
86
|
-
const
|
|
87
|
-
`#${
|
|
86
|
+
const t = a.items[s].key, n = document.querySelector(
|
|
87
|
+
`#${b}_tab_${t}`
|
|
88
88
|
);
|
|
89
|
-
n == null || n.focus(), c(
|
|
89
|
+
n == null || n.focus(), c(t);
|
|
90
90
|
}, U = (e) => {
|
|
91
|
-
if (!
|
|
91
|
+
if (!a.disabled)
|
|
92
92
|
if (e.key === "ArrowRight")
|
|
93
93
|
r("next");
|
|
94
94
|
else if (e.key === "ArrowLeft")
|
|
@@ -100,110 +100,121 @@ const Z = ["id"], ee = {
|
|
|
100
100
|
else
|
|
101
101
|
return;
|
|
102
102
|
};
|
|
103
|
-
return
|
|
104
|
-
() =>
|
|
103
|
+
return _(
|
|
104
|
+
() => a.modelValue,
|
|
105
105
|
(e) => {
|
|
106
106
|
e && c(e);
|
|
107
107
|
}
|
|
108
|
-
),
|
|
108
|
+
), _(
|
|
109
109
|
() => {
|
|
110
110
|
var e, s;
|
|
111
|
-
return (s = (e = o.value) == null ? void 0 : e.query) == null ? void 0 : s[
|
|
111
|
+
return (s = (e = o.value) == null ? void 0 : e.query) == null ? void 0 : s[a.querykey];
|
|
112
112
|
},
|
|
113
113
|
(e) => {
|
|
114
114
|
e && typeof e == "string" && c(e);
|
|
115
115
|
}
|
|
116
|
+
), _(
|
|
117
|
+
l,
|
|
118
|
+
() => {
|
|
119
|
+
const e = document.querySelector(
|
|
120
|
+
`#${k} [role=tablist] .bb-tab__btn--active`
|
|
121
|
+
);
|
|
122
|
+
e == null || e.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
123
|
+
},
|
|
124
|
+
{ flush: "post" }
|
|
116
125
|
), N({
|
|
117
|
-
isFirst:
|
|
126
|
+
isFirst: y,
|
|
118
127
|
isLast: f,
|
|
119
|
-
current:
|
|
128
|
+
current: l,
|
|
120
129
|
currentIndex: i,
|
|
121
130
|
goTo: r
|
|
122
131
|
}), (e, s) => (u(), d("div", {
|
|
123
|
-
id: H(
|
|
124
|
-
class:
|
|
132
|
+
id: H(k),
|
|
133
|
+
class: g(["bb-tab", {
|
|
125
134
|
[`bb-tab--${e.direction}`]: !0,
|
|
126
135
|
"bb-tab--disabled": !0
|
|
127
136
|
}])
|
|
128
137
|
}, [
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
disabled: !!(a.disabled || e.disabled),
|
|
149
|
-
goTo: r,
|
|
150
|
-
isFirst: b.value,
|
|
151
|
-
isLast: f.value,
|
|
152
|
-
selected: t.value === a.key,
|
|
153
|
-
text: a.label,
|
|
154
|
-
value: a.key
|
|
155
|
-
}, () => [
|
|
156
|
-
_(e.$slots, "label", {
|
|
157
|
-
current: t.value,
|
|
138
|
+
m("div", ee, [
|
|
139
|
+
m("ul", te, [
|
|
140
|
+
(u(!0), d(w, null, B(e.items, (t) => (u(), d("li", {
|
|
141
|
+
key: t.key,
|
|
142
|
+
role: "presentation"
|
|
143
|
+
}, [
|
|
144
|
+
J(Y, {
|
|
145
|
+
id: `${b}_tab_${t.key}`,
|
|
146
|
+
"aria-selected": l.value === t.key,
|
|
147
|
+
class: g(["bb-tab__btn", { "bb-tab__btn--active": l.value === t.key }]),
|
|
148
|
+
disabled: t.disabled || e.disabled,
|
|
149
|
+
role: "tab",
|
|
150
|
+
tabindex: l.value === t.key ? 0 : -1,
|
|
151
|
+
onClick: (n) => c(t.key),
|
|
152
|
+
onKeydown: U
|
|
153
|
+
}, {
|
|
154
|
+
default: O(() => [
|
|
155
|
+
q(e.$slots, `label-${t.key}`, {
|
|
156
|
+
current: l.value,
|
|
158
157
|
currentIndex: i.value,
|
|
159
|
-
disabled: !!(
|
|
158
|
+
disabled: !!(t.disabled || e.disabled),
|
|
160
159
|
goTo: r,
|
|
161
|
-
isFirst:
|
|
160
|
+
isFirst: y.value,
|
|
162
161
|
isLast: f.value,
|
|
163
|
-
selected:
|
|
164
|
-
text:
|
|
165
|
-
value:
|
|
162
|
+
selected: l.value === t.key,
|
|
163
|
+
text: t.label,
|
|
164
|
+
value: t.key
|
|
166
165
|
}, () => [
|
|
167
|
-
|
|
166
|
+
q(e.$slots, "label", {
|
|
167
|
+
current: l.value,
|
|
168
|
+
currentIndex: i.value,
|
|
169
|
+
disabled: !!(t.disabled || e.disabled),
|
|
170
|
+
goTo: r,
|
|
171
|
+
isFirst: y.value,
|
|
172
|
+
isLast: f.value,
|
|
173
|
+
selected: l.value === t.key,
|
|
174
|
+
text: t.label,
|
|
175
|
+
value: t.key
|
|
176
|
+
}, () => [
|
|
177
|
+
m("span", ae, j(t.label), 1)
|
|
178
|
+
])
|
|
168
179
|
])
|
|
169
|
-
])
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
])
|
|
180
|
+
]),
|
|
181
|
+
_: 2
|
|
182
|
+
}, 1032, ["id", "aria-selected", "class", "disabled", "tabindex", "onClick"])
|
|
183
|
+
]))), 128))
|
|
184
|
+
])
|
|
174
185
|
]),
|
|
175
|
-
|
|
176
|
-
(u(!0), d(
|
|
177
|
-
key:
|
|
186
|
+
m("div", le, [
|
|
187
|
+
(u(!0), d(w, null, B(e.items, (t) => (u(), d(w, {
|
|
188
|
+
key: t.key
|
|
178
189
|
}, [
|
|
179
|
-
|
|
190
|
+
l.value === t.key || e.eager || t.eager ? (u(), d("section", {
|
|
180
191
|
key: 0,
|
|
181
|
-
id: `${
|
|
182
|
-
"aria-labelledby": `${
|
|
183
|
-
class:
|
|
184
|
-
"bb-tab__pane--shown":
|
|
192
|
+
id: `${b}_tabpanel_${t.key}`,
|
|
193
|
+
"aria-labelledby": `${b}_tab_${t.key}`,
|
|
194
|
+
class: g(["bb-tab__pane", {
|
|
195
|
+
"bb-tab__pane--shown": l.value === t.key
|
|
185
196
|
}]),
|
|
186
197
|
role: "tabpanel",
|
|
187
198
|
tabindex: "0"
|
|
188
199
|
}, [
|
|
189
|
-
|
|
190
|
-
current:
|
|
200
|
+
q(e.$slots, t.key, {
|
|
201
|
+
current: l.value,
|
|
191
202
|
currentIndex: i.value,
|
|
192
|
-
disabled: !!(
|
|
203
|
+
disabled: !!(t.disabled || e.disabled),
|
|
193
204
|
goTo: r,
|
|
194
|
-
isFirst:
|
|
205
|
+
isFirst: y.value,
|
|
195
206
|
isLast: f.value,
|
|
196
|
-
selected:
|
|
197
|
-
text:
|
|
198
|
-
value:
|
|
207
|
+
selected: l.value === t.key,
|
|
208
|
+
text: t.label,
|
|
209
|
+
value: t.key
|
|
199
210
|
})
|
|
200
|
-
], 10,
|
|
211
|
+
], 10, se)) : G("", !0)
|
|
201
212
|
], 64))), 128))
|
|
202
213
|
])
|
|
203
214
|
], 10, Z));
|
|
204
215
|
}
|
|
205
216
|
});
|
|
206
217
|
export {
|
|
207
|
-
|
|
218
|
+
be as default
|
|
208
219
|
};
|
|
209
220
|
//# sourceMappingURL=index99.js.map
|
package/dist/index99.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index99.js","sources":["../src/components/BbTab/BbTab.vue"],"sourcesContent":["<template>\n\t<div\n\t\t:id=\"id\"\n\t\tclass=\"bb-tab\"\n\t\t:class=\"{\n\t\t\t[`bb-tab--${direction}`]: true,\n\t\t\t'bb-tab--disabled': true,\n\t\t}\"\n\t>\n\t\t<ul class=\"bb-tab__label-container\" role=\"tablist\">\n\t\t\t<li v-for=\"tab in items\" :key=\"tab.key\" role=\"presentation\">\n\t\t\t\t<BaseButton\n\t\t\t\t\t:id=\"`${instanceid}_tab_${tab.key}`\"\n\t\t\t\t\t:aria-selected=\"selectedTab === tab.key\"\n\t\t\t\t\tclass=\"bb-tab__btn\"\n\t\t\t\t\t:class=\"{ 'bb-tab__btn--active': selectedTab === tab.key }\"\n\t\t\t\t\t:disabled=\"tab.disabled || disabled\"\n\t\t\t\t\t:role=\"'tab'\"\n\t\t\t\t\t:tabindex=\"selectedTab === tab.key ? 0 : -1\"\n\t\t\t\t\t@click=\"onTabSelected(tab.key)\"\n\t\t\t\t\t@keydown=\"onKeydown\"\n\t\t\t\t>\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t:name=\"`label-${tab.key}`\"\n\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t\tname=\"label\"\n\t\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span class=\"bb-tab__label\">{{ tab.label }}</span>\n\t\t\t\t\t\t</slot>\n\t\t\t\t\t</slot>\n\t\t\t\t</BaseButton>\n\t\t\t</li>\n\t\t</ul>\n\t\t<div class=\"bb-tab__panes-container\">\n\t\t\t<template v-for=\"tab in items\" :key=\"tab.key\">\n\t\t\t\t<section\n\t\t\t\t\tv-if=\"selectedTab === tab.key || eager || tab.eager\"\n\t\t\t\t\t:id=\"`${instanceid}_tabpanel_${tab.key}`\"\n\t\t\t\t\t:aria-labelledby=\"`${instanceid}_tab_${tab.key}`\"\n\t\t\t\t\tclass=\"bb-tab__pane\"\n\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t'bb-tab__pane--shown': selectedTab === tab.key,\n\t\t\t\t\t}\"\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\ttabindex=\"0\"\n\t\t\t\t>\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t:name=\"tab.key\"\n\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t></slot>\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, getCurrentInstance, computed } from 'vue';\nimport { useId } from '@/composables/useId';\nimport { useRoute } from '@/composables/useRoute';\nimport { useRouter } from '@/composables/useRouter';\nimport { wait } from '@/utilities/functions/wait';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport type { CommonProps } from '@/types/CommonProps';\n\nexport type BbTabItem = Pick<CommonProps, 'disabled'> & {\n\t/**\n\t * Used to render a tab even when not visible.\n\t * It's useful if you want the content of a tab in the DOM\n\t * immediately rendered\n\t * even when not visible for SEO purposes.\n\t */\n\teager?: boolean;\n\t/**\n\t * String that identifies the tab.\n\t */\n\tkey: string;\n\t/**\n\t * Label to use as the tab text.\n\t */\n\tlabel?: string;\n};\n\nexport type BbTabProps = Pick<CommonProps, 'disabled' | 'eager' | 'id'> & {\n\t/**\n\t * Direction of the tabs component\n\t */\n\tdirection?: 'horizontal' | 'vertical';\n\t/**\n\t * Array of items that define the tabs in the component.\n\t */\n\titems: BbTabItem[];\n\t/**\n\t * The current tab. Used by v-model.\n\t */\n\tmodelValue?: null | BbTabItem['key'];\n\t/**\n\t * Synchronizes the current tab with the url.\n\t */\n\tnavigation?: boolean;\n\t/**\n\t * Defines the query key to reference for maintaining navigation\n\t */\n\tquerykey?: string;\n};\n\nconst props = withDefaults(defineProps<BbTabProps>(), {\n\tdirection: 'horizontal',\n\tquerykey: 'tab',\n});\n\nexport type BbTabEvents = {\n\t(e: 'update:modelValue', value: (typeof props.items)[number]['key']): void;\n};\nconst emit = defineEmits<BbTabEvents>();\n\ntype BbStepSlots = {\n\tlabel?: (props: {\n\t\tcurrent: string | null;\n\t\tcurrentIndex: number;\n\t\tdisabled: boolean;\n\t\tisFirst: boolean;\n\t\tisLast: boolean;\n\t\tselected: boolean;\n\t\ttext: BbTabItem['label'];\n\t\tvalue: string;\n\t\tgoTo: typeof goTo;\n\t}) => any;\n} & {\n\t[key: string]: (props: {\n\t\tcurrent: string | null;\n\t\tcurrentIndex: number;\n\t\tdisabled: boolean;\n\t\tisFirst: boolean;\n\t\tisLast: boolean;\n\t\tselected: boolean;\n\t\ttext: BbTabItem['label'];\n\t\tvalue: string;\n\t\tgoTo: typeof goTo;\n\t}) => any;\n};\n\ndefineSlots<BbStepSlots>();\n\nconst route = useRoute();\nconst router = useRouter();\n\nconst id = props.id ?? useId().id.value;\nconst instanceid = `bb-tab_${id}`;\n\n/* Ignore because possibly undefined */\n// @ts-expect-error possibly undef\nconst isInertia = !!getCurrentInstance()?.proxy?.$inertia;\n\nconst selectedTab = ref<BbTabItem['key'] | null>(null);\n\nconst currentTabIndex = computed(() =>\n\tprops.items.findIndex((el) => el.key === selectedTab.value)\n);\nconst isFirst = computed(() => currentTabIndex.value === 0);\nconst isLast = computed(() => currentTabIndex.value === props.items.length - 1);\n\nprops.items.forEach((item) => {\n\tif (!item.key) {\n\t\tconsole.error(`A tab item has no key`, item);\n\t\tthrow new Error('A tab item has no key ' + JSON.stringify(item));\n\t}\n});\n\n/* \nThis section retrieves the current tab that should be selected\n*/\n// Retrieve tab from url on load for vue apps\nif (props.navigation && route.value?.query?.[props.querykey]) {\n\tselectedTab.value = route.value?.query?.[props.querykey] as string;\n\t// Retrieve tab from url on load for inertia app\n} else if (\n\tprops.navigation &&\n\tisInertia &&\n\tglobalThis?.location?.href &&\n\tnew URL(globalThis.location.href).searchParams.get(props.querykey)\n) {\n\tselectedTab.value = new URL(globalThis.location.href).searchParams.get(\n\t\tprops.querykey\n\t) as string;\n\t// Else whatever tab is passed first\n} else if (props.modelValue) {\n\tselectedTab.value = props.modelValue;\n\t// Else whatever tab is passed first\n} else if (props.items[0]) {\n\tconst firstSelectableTab = props.items.find((item) => !item.disabled);\n\tif (!firstSelectableTab) {\n\t\tthrow new Error(\n\t\t\t'No tab has been selected so it defaulted to the first available. Still, all the tabs are disabled so no tab can be selected.'\n\t\t);\n\t}\n\tconst key = firstSelectableTab.key;\n\tselectedTab.value = key;\n}\n/* \nOnce the current tab is found update external variables\n*/\n\nconst onTabSelected = async (tab: BbTabItem['key'], replace = false) => {\n\t/* For Vue or Nuxt context */\n\tif (\n\t\tprops.navigation &&\n\t\troute.value &&\n\t\troute.value?.query?.[props.querykey] !== tab\n\t) {\n\t\trouter?.push({\n\t\t\t...route,\n\t\t\tquery: { ...route.value?.query, [props.querykey]: tab },\n\t\t\treplace,\n\t\t});\n\t\t/* Inertia context */\n\t} else if (\n\t\tprops.navigation &&\n\t\tisInertia &&\n\t\tglobalThis?.location?.href &&\n\t\tnew URL(globalThis.location.href).searchParams.get(props.querykey) !== tab\n\t) {\n\t\tconst url = new URL(globalThis.location.href);\n\t\turl.searchParams.set(props.querykey, tab);\n\t\twait(0).then(() => {\n\t\t\tif (replace) {\n\t\t\t\thistory.replaceState({}, '', url.toString());\n\t\t\t} else {\n\t\t\t\thistory.pushState({}, '', url.toString());\n\t\t\t}\n\t\t});\n\t}\n\tif (props.modelValue !== tab) {\n\t\temit('update:modelValue', tab);\n\t}\n\tselectedTab.value = tab;\n};\n\nif (selectedTab.value) {\n\tonTabSelected(selectedTab.value, true);\n}\n\nconst goTo = (target: 'first' | 'previous' | 'next' | 'last') => {\n\tvar nextTabIndex: number | null = null;\n\tswitch (target) {\n\t\tcase 'first':\n\t\t\tnextTabIndex = 0;\n\t\t\tbreak;\n\t\tcase 'previous':\n\t\t\tnextTabIndex =\n\t\t\t\t(currentTabIndex.value + props.items.length - 1) % props.items.length;\n\t\t\tbreak;\n\t\tcase 'next':\n\t\t\tnextTabIndex = (currentTabIndex.value + 1) % props.items.length;\n\t\t\tbreak;\n\t\tcase 'last':\n\t\t\tnextTabIndex = props.items.length - 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\tif (nextTabIndex === null) {\n\t\tthrow new Error('Could not navigate to next tab');\n\t}\n\tif (props.items[nextTabIndex].disabled) return;\n\tconst targetKey = props.items[nextTabIndex].key;\n\tconst button: HTMLButtonElement | null = document.querySelector(\n\t\t`#${instanceid}_tab_${targetKey}`\n\t);\n\tbutton?.focus();\n\tonTabSelected(targetKey);\n};\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (props.disabled) return;\n\tif (event.key === 'ArrowRight') {\n\t\tgoTo('next');\n\t} else if (event.key === 'ArrowLeft') {\n\t\tgoTo('previous');\n\t} else if (event.key === 'Home') {\n\t\tevent.preventDefault();\n\t\tgoTo('first');\n\t} else if (event.key === 'End') {\n\t\tevent.preventDefault();\n\t\tgoTo('last');\n\t} else {\n\t\treturn;\n\t}\n};\n\nwatch(\n\t() => props.modelValue,\n\t(value) => {\n\t\tif (value) {\n\t\t\tonTabSelected(value);\n\t\t}\n\t}\n);\n\nwatch(\n\t() => route.value?.query?.[props.querykey],\n\t(value) => {\n\t\tif (value && typeof value === 'string') {\n\t\t\tonTabSelected(value);\n\t\t}\n\t}\n);\n\ndefineExpose({\n\tisFirst,\n\tisLast,\n\tcurrent: selectedTab,\n\tcurrentIndex: currentTabIndex,\n\tgoTo,\n});\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbTab';\n</style>\n"],"names":["props","__props","emit","__emit","route","useRoute","router","useRouter","id","useId","instanceid","isInertia","_b","_a","getCurrentInstance","selectedTab","ref","currentTabIndex","computed","el","isFirst","isLast","item","_d","_c","_f","_e","_g","firstSelectableTab","key","onTabSelected","tab","replace","url","wait","goTo","target","nextTabIndex","targetKey","button","onKeydown","event","watch","value","__expose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqIA,UAAMA,IAAQC,GAQRC,IAAOC,GA8BPC,IAAQC,KACRC,IAASC,KAETC,IAAKR,EAAM,MAAMS,IAAQ,GAAG,OAC5BC,IAAa,UAAUF,CAAE,IAIzBG,IAAY,CAAC,GAACC,KAAAC,IAAAC,EAAA,MAAA,gBAAAD,EAAsB,UAAtB,QAAAD,EAA6B,WAE3CG,IAAcC,EAA6B,IAAI,GAE/CC,IAAkBC;AAAA,MAAS,MAChClB,EAAM,MAAM,UAAU,CAACmB,MAAOA,EAAG,QAAQJ,EAAY,KAAK;AAAA,IAAA,GAErDK,IAAUF,EAAS,MAAMD,EAAgB,UAAU,CAAC,GACpDI,IAASH,EAAS,MAAMD,EAAgB,UAAUjB,EAAM,MAAM,SAAS,CAAC;AAa9E,QAX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RT,EAAcQ,CAAS;AAAA,IAAA,GAGlBE,IAAY,CAACC,MAAyB;AAC3C,UAAI,CAAAzC,EAAM;AACN,YAAAyC,EAAM,QAAQ;AACjB,UAAAN,EAAK,MAAM;AAAA,iBACDM,EAAM,QAAQ;AACxB,UAAAN,EAAK,UAAU;AAAA,iBACLM,EAAM,QAAQ;AACxB,UAAAA,EAAM,eAAe,GACrBN,EAAK,OAAO;AAAA,iBACFM,EAAM,QAAQ;AACxB,UAAAA,EAAM,eAAe,GACrBN,EAAK,MAAM;AAAA;AAEX;AAAA,IACD;AAGD,WAAAO;AAAA,MACC,MAAM1C,EAAM;AAAA,MACZ,CAAC2C,MAAU;AACV,QAAIA,KACHb,EAAca,CAAK;AAAA,MAErB;AAAA,IAAA,GAGDD;AAAA,MACC,MAAA;;AAAM,gBAAA9B,KAAAC,IAAAT,EAAM,UAAN,gBAAAS,EAAa,UAAb,gBAAAD,EAAqBZ,EAAM;AAAA;AAAA,MACjC,CAAC2C,MAAU;AACN,QAAAA,KAAS,OAAOA,KAAU,YAC7Bb,EAAca,CAAK;AAAA,MAErB;AAAA,IAAA,GAGYC,EAAA;AAAA,MACZ,SAAAxB;AAAA,MACA,QAAAC;AAAA,MACA,SAASN;AAAA,MACT,cAAcE;AAAA,MACd,MAAAkB;AAAA,IAAA,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index99.js","sources":["../src/components/BbTab/BbTab.vue"],"sourcesContent":["<template>\n\t<div\n\t\t:id=\"id\"\n\t\tclass=\"bb-tab\"\n\t\t:class=\"{\n\t\t\t[`bb-tab--${direction}`]: true,\n\t\t\t'bb-tab--disabled': true,\n\t\t}\"\n\t>\n\t\t<div class=\"bb-tab__label-boundary\">\n\t\t\t<ul class=\"bb-tab__label-container\" role=\"tablist\">\n\t\t\t\t<li v-for=\"tab in items\" :key=\"tab.key\" role=\"presentation\">\n\t\t\t\t\t<BaseButton\n\t\t\t\t\t\t:id=\"`${instanceid}_tab_${tab.key}`\"\n\t\t\t\t\t\t:aria-selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\tclass=\"bb-tab__btn\"\n\t\t\t\t\t\t:class=\"{ 'bb-tab__btn--active': selectedTab === tab.key }\"\n\t\t\t\t\t\t:disabled=\"tab.disabled || disabled\"\n\t\t\t\t\t\t:role=\"'tab'\"\n\t\t\t\t\t\t:tabindex=\"selectedTab === tab.key ? 0 : -1\"\n\t\t\t\t\t\t@click=\"onTabSelected(tab.key)\"\n\t\t\t\t\t\t@keydown=\"onKeydown\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t\t:name=\"`label-${tab.key}`\"\n\t\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t\t\tname=\"label\"\n\t\t\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span class=\"bb-tab__label\">{{ tab.label }}</span>\n\t\t\t\t\t\t\t</slot>\n\t\t\t\t\t\t</slot>\n\t\t\t\t\t</BaseButton>\n\t\t\t\t</li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<div class=\"bb-tab__panes-container\">\n\t\t\t<template v-for=\"tab in items\" :key=\"tab.key\">\n\t\t\t\t<section\n\t\t\t\t\tv-if=\"selectedTab === tab.key || eager || tab.eager\"\n\t\t\t\t\t:id=\"`${instanceid}_tabpanel_${tab.key}`\"\n\t\t\t\t\t:aria-labelledby=\"`${instanceid}_tab_${tab.key}`\"\n\t\t\t\t\tclass=\"bb-tab__pane\"\n\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t'bb-tab__pane--shown': selectedTab === tab.key,\n\t\t\t\t\t}\"\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\ttabindex=\"0\"\n\t\t\t\t>\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:current=\"selectedTab\"\n\t\t\t\t\t\t:current-index=\"currentTabIndex\"\n\t\t\t\t\t\t:disabled=\"!!(tab.disabled || disabled)\"\n\t\t\t\t\t\t:go-to=\"goTo\"\n\t\t\t\t\t\t:is-first=\"isFirst\"\n\t\t\t\t\t\t:is-last=\"isLast\"\n\t\t\t\t\t\t:name=\"tab.key\"\n\t\t\t\t\t\t:selected=\"selectedTab === tab.key\"\n\t\t\t\t\t\t:text=\"tab.label\"\n\t\t\t\t\t\t:value=\"tab.key\"\n\t\t\t\t\t></slot>\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, getCurrentInstance, computed } from 'vue';\nimport { useId } from '@/composables/useId';\nimport { useRoute } from '@/composables/useRoute';\nimport { useRouter } from '@/composables/useRouter';\nimport { wait } from '@/utilities/functions/wait';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport type { CommonProps } from '@/types/CommonProps';\n\nexport type BbTabItem = Pick<CommonProps, 'disabled'> & {\n\t/**\n\t * Used to render a tab even when not visible.\n\t * It's useful if you want the content of a tab in the DOM\n\t * immediately rendered\n\t * even when not visible for SEO purposes.\n\t */\n\teager?: boolean;\n\t/**\n\t * String that identifies the tab.\n\t */\n\tkey: string;\n\t/**\n\t * Label to use as the tab text.\n\t */\n\tlabel?: string;\n};\n\nexport type BbTabProps = Pick<CommonProps, 'disabled' | 'eager' | 'id'> & {\n\t/**\n\t * Direction of the tabs component\n\t */\n\tdirection?: 'horizontal' | 'vertical';\n\t/**\n\t * Array of items that define the tabs in the component.\n\t */\n\titems: BbTabItem[];\n\t/**\n\t * The current tab. Used by v-model.\n\t */\n\tmodelValue?: null | BbTabItem['key'];\n\t/**\n\t * Synchronizes the current tab with the url.\n\t */\n\tnavigation?: boolean;\n\t/**\n\t * Defines the query key to reference for maintaining navigation\n\t */\n\tquerykey?: string;\n};\n\nconst props = withDefaults(defineProps<BbTabProps>(), {\n\tdirection: 'horizontal',\n\tquerykey: 'tab',\n});\n\nexport type BbTabEvents = {\n\t(e: 'update:modelValue', value: (typeof props.items)[number]['key']): void;\n};\nconst emit = defineEmits<BbTabEvents>();\n\ntype BbStepSlots = {\n\tlabel?: (props: {\n\t\tcurrent: string | null;\n\t\tcurrentIndex: number;\n\t\tdisabled: boolean;\n\t\tisFirst: boolean;\n\t\tisLast: boolean;\n\t\tselected: boolean;\n\t\ttext: BbTabItem['label'];\n\t\tvalue: string;\n\t\tgoTo: typeof goTo;\n\t}) => any;\n} & {\n\t[key: string]: (props: {\n\t\tcurrent: string | null;\n\t\tcurrentIndex: number;\n\t\tdisabled: boolean;\n\t\tisFirst: boolean;\n\t\tisLast: boolean;\n\t\tselected: boolean;\n\t\ttext: BbTabItem['label'];\n\t\tvalue: string;\n\t\tgoTo: typeof goTo;\n\t}) => any;\n};\n\ndefineSlots<BbStepSlots>();\n\nconst route = useRoute();\nconst router = useRouter();\n\nconst id = props.id ?? useId().id.value;\nconst instanceid = `bb-tab_${id}`;\n\n/* Ignore because possibly undefined */\n// @ts-expect-error possibly undef\nconst isInertia = !!getCurrentInstance()?.proxy?.$inertia;\n\nconst selectedTab = ref<BbTabItem['key'] | null>(null);\n\nconst currentTabIndex = computed(() =>\n\tprops.items.findIndex((el) => el.key === selectedTab.value)\n);\nconst isFirst = computed(() => currentTabIndex.value === 0);\nconst isLast = computed(() => currentTabIndex.value === props.items.length - 1);\n\nprops.items.forEach((item) => {\n\tif (!item.key) {\n\t\tconsole.error(`A tab item has no key`, item);\n\t\tthrow new Error('A tab item has no key ' + JSON.stringify(item));\n\t}\n});\n\n/* \nThis section retrieves the current tab that should be selected\n*/\n// Retrieve tab from url on load for vue apps\nif (props.navigation && route.value?.query?.[props.querykey]) {\n\tselectedTab.value = route.value?.query?.[props.querykey] as string;\n\t// Retrieve tab from url on load for inertia app\n} else if (\n\tprops.navigation &&\n\tisInertia &&\n\tglobalThis?.location?.href &&\n\tnew URL(globalThis.location.href).searchParams.get(props.querykey)\n) {\n\tselectedTab.value = new URL(globalThis.location.href).searchParams.get(\n\t\tprops.querykey\n\t) as string;\n\t// Else whatever tab is passed first\n} else if (props.modelValue) {\n\tselectedTab.value = props.modelValue;\n\t// Else whatever tab is passed first\n} else if (props.items[0]) {\n\tconst firstSelectableTab = props.items.find((item) => !item.disabled);\n\tif (!firstSelectableTab) {\n\t\tthrow new Error(\n\t\t\t'No tab has been selected so it defaulted to the first available. Still, all the tabs are disabled so no tab can be selected.'\n\t\t);\n\t}\n\tconst key = firstSelectableTab.key;\n\tselectedTab.value = key;\n}\n/* \nOnce the current tab is found update external variables\n*/\n\nconst onTabSelected = async (tab: BbTabItem['key'], replace = false) => {\n\t/* For Vue or Nuxt context */\n\tif (\n\t\tprops.navigation &&\n\t\troute.value &&\n\t\troute.value?.query?.[props.querykey] !== tab\n\t) {\n\t\trouter?.push({\n\t\t\t...route,\n\t\t\tquery: { ...route.value?.query, [props.querykey]: tab },\n\t\t\treplace,\n\t\t});\n\t\t/* Inertia context */\n\t} else if (\n\t\tprops.navigation &&\n\t\tisInertia &&\n\t\tglobalThis?.location?.href &&\n\t\tnew URL(globalThis.location.href).searchParams.get(props.querykey) !== tab\n\t) {\n\t\tconst url = new URL(globalThis.location.href);\n\t\turl.searchParams.set(props.querykey, tab);\n\t\twait(0).then(() => {\n\t\t\tif (replace) {\n\t\t\t\thistory.replaceState({}, '', url.toString());\n\t\t\t} else {\n\t\t\t\thistory.pushState({}, '', url.toString());\n\t\t\t}\n\t\t});\n\t}\n\tif (props.modelValue !== tab) {\n\t\temit('update:modelValue', tab);\n\t}\n\tselectedTab.value = tab;\n};\n\nif (selectedTab.value) {\n\tonTabSelected(selectedTab.value, true);\n}\n\nconst goTo = (target: 'first' | 'previous' | 'next' | 'last') => {\n\tvar nextTabIndex: number | null = null;\n\tswitch (target) {\n\t\tcase 'first':\n\t\t\tnextTabIndex = 0;\n\t\t\tbreak;\n\t\tcase 'previous':\n\t\t\tnextTabIndex =\n\t\t\t\t(currentTabIndex.value + props.items.length - 1) % props.items.length;\n\t\t\tbreak;\n\t\tcase 'next':\n\t\t\tnextTabIndex = (currentTabIndex.value + 1) % props.items.length;\n\t\t\tbreak;\n\t\tcase 'last':\n\t\t\tnextTabIndex = props.items.length - 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\tif (nextTabIndex === null) {\n\t\tthrow new Error('Could not navigate to next tab');\n\t}\n\tif (props.items[nextTabIndex].disabled) return;\n\tconst targetKey = props.items[nextTabIndex].key;\n\tconst button: HTMLButtonElement | null = document.querySelector(\n\t\t`#${instanceid}_tab_${targetKey}`\n\t);\n\tbutton?.focus();\n\tonTabSelected(targetKey);\n};\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (props.disabled) return;\n\tif (event.key === 'ArrowRight') {\n\t\tgoTo('next');\n\t} else if (event.key === 'ArrowLeft') {\n\t\tgoTo('previous');\n\t} else if (event.key === 'Home') {\n\t\tevent.preventDefault();\n\t\tgoTo('first');\n\t} else if (event.key === 'End') {\n\t\tevent.preventDefault();\n\t\tgoTo('last');\n\t} else {\n\t\treturn;\n\t}\n};\n\nwatch(\n\t() => props.modelValue,\n\t(value) => {\n\t\tif (value) {\n\t\t\tonTabSelected(value);\n\t\t}\n\t}\n);\n\nwatch(\n\t() => route.value?.query?.[props.querykey],\n\t(value) => {\n\t\tif (value && typeof value === 'string') {\n\t\t\tonTabSelected(value);\n\t\t}\n\t}\n);\n\nwatch(\n\tselectedTab,\n\t() => {\n\t\tconst element = document.querySelector(\n\t\t\t`#${id} [role=tablist] .bb-tab__btn--active`\n\t\t);\n\t\telement?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n\t},\n\t{ flush: 'post' }\n);\n\ndefineExpose({\n\tisFirst,\n\tisLast,\n\tcurrent: selectedTab,\n\tcurrentIndex: currentTabIndex,\n\tgoTo,\n});\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbTab';\n</style>\n"],"names":["props","__props","emit","__emit","route","useRoute","router","useRouter","id","useId","instanceid","isInertia","_b","_a","getCurrentInstance","selectedTab","ref","currentTabIndex","computed","el","isFirst","isLast","item","_d","_c","_f","_e","_g","firstSelectableTab","key","onTabSelected","tab","replace","url","wait","goTo","target","nextTabIndex","targetKey","button","onKeydown","event","watch","value","element","__expose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuIA,UAAMA,IAAQC,GAQRC,IAAOC,GA8BPC,IAAQC,KACRC,IAASC,KAETC,IAAKR,EAAM,MAAMS,IAAQ,GAAG,OAC5BC,IAAa,UAAUF,CAAE,IAIzBG,IAAY,CAAC,GAACC,KAAAC,IAAAC,EAAA,MAAA,gBAAAD,EAAsB,UAAtB,QAAAD,EAA6B,WAE3CG,IAAcC,EAA6B,IAAI,GAE/CC,IAAkBC;AAAA,MAAS,MAChClB,EAAM,MAAM,UAAU,CAACmB,MAAOA,EAAG,QAAQJ,EAAY,KAAK;AAAA,IAAA,GAEr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