@purpurds/tabs 5.31.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +2 -2
- package/dist/tabs.cjs.js +2 -2
- package/dist/tabs.cjs.js.map +1 -1
- package/dist/tabs.es.js +135 -135
- package/dist/tabs.es.js.map +1 -1
- package/package.json +5 -5
package/dist/tabs.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as T, jsxs as ee } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import E, { createContext as ne, useMemo as H, createElement as g, useContext as
|
|
2
|
+
import * as _e from "react";
|
|
3
|
+
import E, { createContext as ne, useMemo as H, createElement as g, useContext as ve, useCallback as L, forwardRef as w, Children as P, isValidElement as K, cloneElement as se, Fragment as qe, useLayoutEffect as Le, useEffect as N, useRef as R, useState as O, useReducer as Ue } from "react";
|
|
4
4
|
import { flushSync as Ve } from "react-dom";
|
|
5
5
|
function Be(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -114,20 +114,20 @@ function ae(e, t = []) {
|
|
|
114
114
|
...n,
|
|
115
115
|
c
|
|
116
116
|
];
|
|
117
|
-
function i(
|
|
118
|
-
const { scope:
|
|
117
|
+
function i(l) {
|
|
118
|
+
const { scope: m, children: _, ...f } = l, h = (m == null ? void 0 : m[e][u]) || a, $ = H(
|
|
119
119
|
() => f,
|
|
120
120
|
Object.values(f)
|
|
121
121
|
);
|
|
122
122
|
return /* @__PURE__ */ g(h.Provider, {
|
|
123
123
|
value: $
|
|
124
|
-
},
|
|
124
|
+
}, _);
|
|
125
125
|
}
|
|
126
|
-
function p(
|
|
127
|
-
const
|
|
126
|
+
function p(l, m) {
|
|
127
|
+
const _ = (m == null ? void 0 : m[e][u]) || a, f = ve(_);
|
|
128
128
|
if (f) return f;
|
|
129
129
|
if (c !== void 0) return c;
|
|
130
|
-
throw new Error(`\`${
|
|
130
|
+
throw new Error(`\`${l}\` must be used within \`${r}\``);
|
|
131
131
|
}
|
|
132
132
|
return i.displayName = r + "Provider", [
|
|
133
133
|
i,
|
|
@@ -169,10 +169,10 @@ function Je(...e) {
|
|
|
169
169
|
);
|
|
170
170
|
return function(r) {
|
|
171
171
|
const c = o.reduce((a, { useScope: u, scopeName: i }) => {
|
|
172
|
-
const
|
|
172
|
+
const l = u(r)[`__scope${i}`];
|
|
173
173
|
return {
|
|
174
174
|
...a,
|
|
175
|
-
...
|
|
175
|
+
...l
|
|
176
176
|
};
|
|
177
177
|
}, {});
|
|
178
178
|
return H(
|
|
@@ -196,7 +196,7 @@ function xe(...e) {
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
function X(...e) {
|
|
199
|
-
return
|
|
199
|
+
return L(xe(...e), e);
|
|
200
200
|
}
|
|
201
201
|
const J = /* @__PURE__ */ w((e, t) => {
|
|
202
202
|
const { children: n, ...o } = e, s = P.toArray(n), r = s.find(tt);
|
|
@@ -250,30 +250,30 @@ function rt(e) {
|
|
|
250
250
|
current: null
|
|
251
251
|
},
|
|
252
252
|
itemMap: /* @__PURE__ */ new Map()
|
|
253
|
-
}), c = (
|
|
254
|
-
const { scope: f, children: h } =
|
|
253
|
+
}), c = (_) => {
|
|
254
|
+
const { scope: f, children: h } = _, $ = E.useRef(null), b = E.useRef(/* @__PURE__ */ new Map()).current;
|
|
255
255
|
return /* @__PURE__ */ E.createElement(s, {
|
|
256
256
|
scope: f,
|
|
257
257
|
itemMap: b,
|
|
258
258
|
collectionRef: $
|
|
259
259
|
}, h);
|
|
260
|
-
}, a = e + "CollectionSlot", u = /* @__PURE__ */ E.forwardRef((
|
|
261
|
-
const { scope: h, children: $ } =
|
|
260
|
+
}, a = e + "CollectionSlot", u = /* @__PURE__ */ E.forwardRef((_, f) => {
|
|
261
|
+
const { scope: h, children: $ } = _, b = r(a, h), v = X(f, b.collectionRef);
|
|
262
262
|
return /* @__PURE__ */ E.createElement(J, {
|
|
263
|
-
ref:
|
|
263
|
+
ref: v
|
|
264
264
|
}, $);
|
|
265
|
-
}), i = e + "CollectionItemSlot", p = "data-radix-collection-item",
|
|
266
|
-
const { scope: h, children: $, ...b } =
|
|
267
|
-
return E.useEffect(() => (y.itemMap.set(
|
|
268
|
-
ref:
|
|
265
|
+
}), i = e + "CollectionItemSlot", p = "data-radix-collection-item", l = /* @__PURE__ */ E.forwardRef((_, f) => {
|
|
266
|
+
const { scope: h, children: $, ...b } = _, v = E.useRef(null), U = X(f, v), y = r(i, h);
|
|
267
|
+
return E.useEffect(() => (y.itemMap.set(v, {
|
|
268
|
+
ref: v,
|
|
269
269
|
...b
|
|
270
|
-
}), () => void y.itemMap.delete(
|
|
270
|
+
}), () => void y.itemMap.delete(v))), /* @__PURE__ */ E.createElement(J, {
|
|
271
271
|
[p]: "",
|
|
272
|
-
ref:
|
|
272
|
+
ref: U
|
|
273
273
|
}, $);
|
|
274
274
|
});
|
|
275
|
-
function
|
|
276
|
-
const f = r(e + "CollectionConsumer",
|
|
275
|
+
function m(_) {
|
|
276
|
+
const f = r(e + "CollectionConsumer", _);
|
|
277
277
|
return E.useCallback(() => {
|
|
278
278
|
const $ = f.collectionRef.current;
|
|
279
279
|
if (!$) return [];
|
|
@@ -290,18 +290,18 @@ function rt(e) {
|
|
|
290
290
|
{
|
|
291
291
|
Provider: c,
|
|
292
292
|
Slot: u,
|
|
293
|
-
ItemSlot:
|
|
293
|
+
ItemSlot: l
|
|
294
294
|
},
|
|
295
|
-
|
|
295
|
+
m,
|
|
296
296
|
o
|
|
297
297
|
];
|
|
298
298
|
}
|
|
299
299
|
const oe = globalThis != null && globalThis.document ? Le : () => {
|
|
300
|
-
}, ot =
|
|
300
|
+
}, ot = _e.useId || (() => {
|
|
301
301
|
});
|
|
302
302
|
let ct = 0;
|
|
303
303
|
function Ie(e) {
|
|
304
|
-
const [t, n] =
|
|
304
|
+
const [t, n] = _e.useState(ot());
|
|
305
305
|
return oe(() => {
|
|
306
306
|
e || n(
|
|
307
307
|
(o) => o ?? String(ct++)
|
|
@@ -358,10 +358,10 @@ function Ce({ prop: e, defaultProp: t, onChange: n = () => {
|
|
|
358
358
|
const [o, s] = at({
|
|
359
359
|
defaultProp: t,
|
|
360
360
|
onChange: n
|
|
361
|
-
}), r = e !== void 0, c = r ? e : o, a = ie(n), u =
|
|
361
|
+
}), r = e !== void 0, c = r ? e : o, a = ie(n), u = L((i) => {
|
|
362
362
|
if (r) {
|
|
363
|
-
const
|
|
364
|
-
|
|
363
|
+
const l = typeof i == "function" ? i(e) : i;
|
|
364
|
+
l !== e && a(l);
|
|
365
365
|
} else s(i);
|
|
366
366
|
}, [
|
|
367
367
|
r,
|
|
@@ -386,55 +386,55 @@ function at({ defaultProp: e, onChange: t }) {
|
|
|
386
386
|
}
|
|
387
387
|
const it = /* @__PURE__ */ ne(void 0);
|
|
388
388
|
function ye(e) {
|
|
389
|
-
const t =
|
|
389
|
+
const t = ve(it);
|
|
390
390
|
return e || t || "ltr";
|
|
391
391
|
}
|
|
392
392
|
const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
393
393
|
bubbles: !1,
|
|
394
394
|
cancelable: !0
|
|
395
|
-
}, ue = "RovingFocusGroup", [ce, Se,
|
|
396
|
-
|
|
397
|
-
]), [ft, pt] =
|
|
395
|
+
}, ue = "RovingFocusGroup", [ce, Se, dt] = rt(ue), [lt, we] = ae(ue, [
|
|
396
|
+
dt
|
|
397
|
+
]), [ft, pt] = lt(ue), bt = /* @__PURE__ */ w((e, t) => /* @__PURE__ */ g(ce.Provider, {
|
|
398
398
|
scope: e.__scopeRovingFocusGroup
|
|
399
399
|
}, /* @__PURE__ */ g(ce.Slot, {
|
|
400
400
|
scope: e.__scopeRovingFocusGroup
|
|
401
401
|
}, /* @__PURE__ */ g($t, C({}, e, {
|
|
402
402
|
ref: t
|
|
403
403
|
}))))), $t = /* @__PURE__ */ w((e, t) => {
|
|
404
|
-
const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e,
|
|
404
|
+
const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, l = R(null), m = X(t, l), _ = ye(r), [f = null, h] = Ce({
|
|
405
405
|
prop: c,
|
|
406
406
|
defaultProp: a,
|
|
407
407
|
onChange: u
|
|
408
|
-
}), [$, b] = O(!1),
|
|
408
|
+
}), [$, b] = O(!1), v = ie(i), U = Se(n), y = R(!1), [j, V] = O(0);
|
|
409
409
|
return N(() => {
|
|
410
|
-
const x =
|
|
410
|
+
const x = l.current;
|
|
411
411
|
if (x)
|
|
412
|
-
return x.addEventListener(te,
|
|
412
|
+
return x.addEventListener(te, v), () => x.removeEventListener(te, v);
|
|
413
413
|
}, [
|
|
414
|
-
|
|
414
|
+
v
|
|
415
415
|
]), /* @__PURE__ */ g(ft, {
|
|
416
416
|
scope: n,
|
|
417
417
|
orientation: o,
|
|
418
|
-
dir:
|
|
418
|
+
dir: _,
|
|
419
419
|
loop: s,
|
|
420
420
|
currentTabStopId: f,
|
|
421
|
-
onItemFocus:
|
|
421
|
+
onItemFocus: L(
|
|
422
422
|
(x) => h(x),
|
|
423
423
|
[
|
|
424
424
|
h
|
|
425
425
|
]
|
|
426
426
|
),
|
|
427
|
-
onItemShiftTab:
|
|
427
|
+
onItemShiftTab: L(
|
|
428
428
|
() => b(!0),
|
|
429
429
|
[]
|
|
430
430
|
),
|
|
431
|
-
onFocusableItemAdd:
|
|
431
|
+
onFocusableItemAdd: L(
|
|
432
432
|
() => V(
|
|
433
433
|
(x) => x + 1
|
|
434
434
|
),
|
|
435
435
|
[]
|
|
436
436
|
),
|
|
437
|
-
onFocusableItemRemove:
|
|
437
|
+
onFocusableItemRemove: L(
|
|
438
438
|
() => V(
|
|
439
439
|
(x) => x - 1
|
|
440
440
|
),
|
|
@@ -444,7 +444,7 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
|
444
444
|
tabIndex: $ || j === 0 ? -1 : 0,
|
|
445
445
|
"data-orientation": o
|
|
446
446
|
}, p, {
|
|
447
|
-
ref:
|
|
447
|
+
ref: m,
|
|
448
448
|
style: {
|
|
449
449
|
outline: "none",
|
|
450
450
|
...e.style
|
|
@@ -457,18 +457,18 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
|
457
457
|
if (x.target === x.currentTarget && W && !$) {
|
|
458
458
|
const k = new CustomEvent(te, ut);
|
|
459
459
|
if (x.currentTarget.dispatchEvent(k), !k.defaultPrevented) {
|
|
460
|
-
const
|
|
461
|
-
(
|
|
462
|
-
), z =
|
|
463
|
-
(
|
|
464
|
-
), Q =
|
|
465
|
-
(
|
|
460
|
+
const D = U().filter(
|
|
461
|
+
(d) => d.focusable
|
|
462
|
+
), z = D.find(
|
|
463
|
+
(d) => d.active
|
|
464
|
+
), Q = D.find(
|
|
465
|
+
(d) => d.id === f
|
|
466
466
|
), Y = [
|
|
467
467
|
z,
|
|
468
468
|
Q,
|
|
469
|
-
...
|
|
469
|
+
...D
|
|
470
470
|
].filter(Boolean).map(
|
|
471
|
-
(
|
|
471
|
+
(d) => d.ref.current
|
|
472
472
|
);
|
|
473
473
|
Te(Y);
|
|
474
474
|
}
|
|
@@ -480,15 +480,15 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
|
480
480
|
() => b(!1)
|
|
481
481
|
)
|
|
482
482
|
})));
|
|
483
|
-
}),
|
|
484
|
-
const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = Ie(), u = r || a, i = pt(
|
|
483
|
+
}), mt = "RovingFocusGroupItem", _t = /* @__PURE__ */ w((e, t) => {
|
|
484
|
+
const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = Ie(), u = r || a, i = pt(mt, n), p = i.currentTabStopId === u, l = Se(n), { onFocusableItemAdd: m, onFocusableItemRemove: _ } = i;
|
|
485
485
|
return N(() => {
|
|
486
486
|
if (o)
|
|
487
|
-
return
|
|
487
|
+
return m(), () => _();
|
|
488
488
|
}, [
|
|
489
489
|
o,
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
m,
|
|
491
|
+
_
|
|
492
492
|
]), /* @__PURE__ */ g(ce.ItemSlot, {
|
|
493
493
|
scope: n,
|
|
494
494
|
id: u,
|
|
@@ -515,16 +515,16 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
|
515
515
|
const h = ht(f, i.orientation, i.dir);
|
|
516
516
|
if (h !== void 0) {
|
|
517
517
|
f.preventDefault();
|
|
518
|
-
let b =
|
|
519
|
-
(
|
|
518
|
+
let b = l().filter(
|
|
519
|
+
(v) => v.focusable
|
|
520
520
|
).map(
|
|
521
|
-
(
|
|
521
|
+
(v) => v.ref.current
|
|
522
522
|
);
|
|
523
523
|
if (h === "last") b.reverse();
|
|
524
524
|
else if (h === "prev" || h === "next") {
|
|
525
525
|
h === "prev" && b.reverse();
|
|
526
|
-
const
|
|
527
|
-
b = i.loop ? xt(b,
|
|
526
|
+
const v = b.indexOf(f.currentTarget);
|
|
527
|
+
b = i.loop ? xt(b, v + 1) : b.slice(v + 1);
|
|
528
528
|
}
|
|
529
529
|
setTimeout(
|
|
530
530
|
() => Te(b)
|
|
@@ -532,7 +532,7 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
|
|
|
532
532
|
}
|
|
533
533
|
})
|
|
534
534
|
})));
|
|
535
|
-
}),
|
|
535
|
+
}), vt = {
|
|
536
536
|
ArrowLeft: "prev",
|
|
537
537
|
ArrowUp: "prev",
|
|
538
538
|
ArrowRight: "next",
|
|
@@ -554,7 +554,7 @@ function ht(e, t, n) {
|
|
|
554
554
|
"ArrowUp",
|
|
555
555
|
"ArrowDown"
|
|
556
556
|
].includes(o)))
|
|
557
|
-
return
|
|
557
|
+
return vt[o];
|
|
558
558
|
}
|
|
559
559
|
function Te(e) {
|
|
560
560
|
const t = document.activeElement;
|
|
@@ -566,7 +566,7 @@ function xt(e, t) {
|
|
|
566
566
|
(n, o) => e[(t + o) % e.length]
|
|
567
567
|
);
|
|
568
568
|
}
|
|
569
|
-
const It = bt, Ct =
|
|
569
|
+
const It = bt, Ct = _t;
|
|
570
570
|
function yt(e, t) {
|
|
571
571
|
return Ue((n, o) => {
|
|
572
572
|
const s = t[n][o];
|
|
@@ -604,21 +604,21 @@ function St(e) {
|
|
|
604
604
|
]), oe(() => {
|
|
605
605
|
const i = o.current, p = s.current;
|
|
606
606
|
if (p !== e) {
|
|
607
|
-
const
|
|
608
|
-
e ? u("MOUNT") :
|
|
607
|
+
const m = r.current, _ = Z(i);
|
|
608
|
+
e ? u("MOUNT") : _ === "none" || (i == null ? void 0 : i.display) === "none" ? u("UNMOUNT") : u(p && m !== _ ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
|
|
609
609
|
}
|
|
610
610
|
}, [
|
|
611
611
|
e,
|
|
612
612
|
u
|
|
613
613
|
]), oe(() => {
|
|
614
614
|
if (t) {
|
|
615
|
-
const i = (
|
|
616
|
-
const
|
|
617
|
-
|
|
615
|
+
const i = (l) => {
|
|
616
|
+
const _ = Z(o.current).includes(l.animationName);
|
|
617
|
+
l.target === t && _ && Ve(
|
|
618
618
|
() => u("ANIMATION_END")
|
|
619
619
|
);
|
|
620
|
-
}, p = (
|
|
621
|
-
|
|
620
|
+
}, p = (l) => {
|
|
621
|
+
l.target === t && (r.current = Z(o.current));
|
|
622
622
|
};
|
|
623
623
|
return t.addEventListener("animationstart", p), t.addEventListener("animationcancel", i), t.addEventListener("animationend", i), () => {
|
|
624
624
|
t.removeEventListener("animationstart", p), t.removeEventListener("animationcancel", i), t.removeEventListener("animationend", i);
|
|
@@ -633,7 +633,7 @@ function St(e) {
|
|
|
633
633
|
"mounted",
|
|
634
634
|
"unmountSuspended"
|
|
635
635
|
].includes(a),
|
|
636
|
-
ref:
|
|
636
|
+
ref: L((i) => {
|
|
637
637
|
i && (o.current = getComputedStyle(i)), n(i);
|
|
638
638
|
}, [])
|
|
639
639
|
};
|
|
@@ -643,8 +643,8 @@ function Z(e) {
|
|
|
643
643
|
}
|
|
644
644
|
const Ae = "Tabs", [wt, nn] = ae(Ae, [
|
|
645
645
|
we
|
|
646
|
-
]), Ee = we(), [Tt,
|
|
647
|
-
const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = ye(a), [
|
|
646
|
+
]), Ee = we(), [Tt, de] = wt(Ae), Nt = /* @__PURE__ */ w((e, t) => {
|
|
647
|
+
const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = ye(a), [l, m] = Ce({
|
|
648
648
|
prop: o,
|
|
649
649
|
onChange: s,
|
|
650
650
|
defaultProp: r
|
|
@@ -652,8 +652,8 @@ const Ae = "Tabs", [wt, nn] = ae(Ae, [
|
|
|
652
652
|
return /* @__PURE__ */ g(Tt, {
|
|
653
653
|
scope: n,
|
|
654
654
|
baseId: Ie(),
|
|
655
|
-
value:
|
|
656
|
-
onValueChange:
|
|
655
|
+
value: l,
|
|
656
|
+
onValueChange: m,
|
|
657
657
|
orientation: c,
|
|
658
658
|
dir: p,
|
|
659
659
|
activationMode: u
|
|
@@ -664,7 +664,7 @@ const Ae = "Tabs", [wt, nn] = ae(Ae, [
|
|
|
664
664
|
ref: t
|
|
665
665
|
})));
|
|
666
666
|
}), At = "TabsList", Et = /* @__PURE__ */ w((e, t) => {
|
|
667
|
-
const { __scopeTabs: n, loop: o = !0, ...s } = e, r =
|
|
667
|
+
const { __scopeTabs: n, loop: o = !0, ...s } = e, r = de(At, n), c = Ee(n);
|
|
668
668
|
return /* @__PURE__ */ g(It, C({
|
|
669
669
|
asChild: !0
|
|
670
670
|
}, c, {
|
|
@@ -678,7 +678,7 @@ const Ae = "Tabs", [wt, nn] = ae(Ae, [
|
|
|
678
678
|
ref: t
|
|
679
679
|
})));
|
|
680
680
|
}), Pt = "TabsTrigger", Rt = /* @__PURE__ */ w((e, t) => {
|
|
681
|
-
const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c =
|
|
681
|
+
const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c = de(Pt, n), a = Ee(n), u = Pe(c.baseId, o), i = Re(c.baseId, o), p = o === c.value;
|
|
682
682
|
return /* @__PURE__ */ g(Ct, C({
|
|
683
683
|
asChild: !0
|
|
684
684
|
}, a, {
|
|
@@ -695,47 +695,47 @@ const Ae = "Tabs", [wt, nn] = ae(Ae, [
|
|
|
695
695
|
id: u
|
|
696
696
|
}, r, {
|
|
697
697
|
ref: t,
|
|
698
|
-
onMouseDown: F(e.onMouseDown, (
|
|
699
|
-
!s &&
|
|
698
|
+
onMouseDown: F(e.onMouseDown, (l) => {
|
|
699
|
+
!s && l.button === 0 && l.ctrlKey === !1 ? c.onValueChange(o) : l.preventDefault();
|
|
700
700
|
}),
|
|
701
|
-
onKeyDown: F(e.onKeyDown, (
|
|
701
|
+
onKeyDown: F(e.onKeyDown, (l) => {
|
|
702
702
|
[
|
|
703
703
|
" ",
|
|
704
704
|
"Enter"
|
|
705
|
-
].includes(
|
|
705
|
+
].includes(l.key) && c.onValueChange(o);
|
|
706
706
|
}),
|
|
707
707
|
onFocus: F(e.onFocus, () => {
|
|
708
|
-
const
|
|
709
|
-
!p && !s &&
|
|
708
|
+
const l = c.activationMode !== "manual";
|
|
709
|
+
!p && !s && l && c.onValueChange(o);
|
|
710
710
|
})
|
|
711
711
|
})));
|
|
712
712
|
}), Mt = "TabsContent", Ft = /* @__PURE__ */ w((e, t) => {
|
|
713
|
-
const { __scopeTabs: n, value: o, forceMount: s, children: r, ...c } = e, a =
|
|
713
|
+
const { __scopeTabs: n, value: o, forceMount: s, children: r, ...c } = e, a = de(Mt, n), u = Pe(a.baseId, o), i = Re(a.baseId, o), p = o === a.value, l = R(p);
|
|
714
714
|
return N(() => {
|
|
715
|
-
const
|
|
716
|
-
() =>
|
|
715
|
+
const m = requestAnimationFrame(
|
|
716
|
+
() => l.current = !1
|
|
717
717
|
);
|
|
718
|
-
return () => cancelAnimationFrame(
|
|
718
|
+
return () => cancelAnimationFrame(m);
|
|
719
719
|
}, []), /* @__PURE__ */ g(
|
|
720
720
|
Ne,
|
|
721
721
|
{
|
|
722
722
|
present: s || p
|
|
723
723
|
},
|
|
724
|
-
({ present:
|
|
724
|
+
({ present: m }) => /* @__PURE__ */ g(G.div, C({
|
|
725
725
|
"data-state": p ? "active" : "inactive",
|
|
726
726
|
"data-orientation": a.orientation,
|
|
727
727
|
role: "tabpanel",
|
|
728
728
|
"aria-labelledby": u,
|
|
729
|
-
hidden: !
|
|
729
|
+
hidden: !m,
|
|
730
730
|
id: i,
|
|
731
731
|
tabIndex: 0
|
|
732
732
|
}, c, {
|
|
733
733
|
ref: t,
|
|
734
734
|
style: {
|
|
735
735
|
...e.style,
|
|
736
|
-
animationDuration:
|
|
736
|
+
animationDuration: l.current ? "0s" : void 0
|
|
737
737
|
}
|
|
738
|
-
}),
|
|
738
|
+
}), m && r)
|
|
739
739
|
);
|
|
740
740
|
});
|
|
741
741
|
function Pe(e, t) {
|
|
@@ -785,9 +785,9 @@ var Me = { exports: {} };
|
|
|
785
785
|
})();
|
|
786
786
|
})(Me);
|
|
787
787
|
var Vt = Me.exports;
|
|
788
|
-
const
|
|
788
|
+
const le = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
789
789
|
"purpur-tab-content": "_purpur-tab-content_1x2zs_1"
|
|
790
|
-
}, Gt =
|
|
790
|
+
}, Gt = le.bind(Bt), jt = "purpur-tab-content", kt = w(
|
|
791
791
|
({ children: e, tabId: t, "data-testid": n, className: o, ...s }, r) => /* @__PURE__ */ T(
|
|
792
792
|
Lt,
|
|
793
793
|
{
|
|
@@ -805,7 +805,7 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
805
805
|
"purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_18g3c_33",
|
|
806
806
|
"purpur-tab-header--line": "_purpur-tab-header--line_18g3c_36",
|
|
807
807
|
"purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_18g3c_48"
|
|
808
|
-
}, Wt =
|
|
808
|
+
}, Wt = le.bind(Kt), me = "purpur-tab-header", Yt = w(
|
|
809
809
|
({
|
|
810
810
|
index: e,
|
|
811
811
|
tabId: t,
|
|
@@ -818,7 +818,7 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
818
818
|
qt,
|
|
819
819
|
{
|
|
820
820
|
id: `${t}-trigger`,
|
|
821
|
-
className: Wt([
|
|
821
|
+
className: Wt([me, `${me}--${n}${o ? "-negative" : ""}`]),
|
|
822
822
|
value: t,
|
|
823
823
|
"data-testid": r,
|
|
824
824
|
"data-index": e,
|
|
@@ -842,7 +842,7 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
842
842
|
"purpur-tabs--contained-negative": "_purpur-tabs--contained-negative_1dpqy_103",
|
|
843
843
|
"purpur-tabs__content-container": "_purpur-tabs__content-container_1dpqy_106",
|
|
844
844
|
"purpur-tabs--fullWidth": "_purpur-tabs--fullWidth_1dpqy_115"
|
|
845
|
-
}, rn = ["line", "contained"], Ht = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }),
|
|
845
|
+
}, rn = ["line", "contained"], Ht = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), q = le.bind(Zt), S = "purpur-tabs", Xt = (e, t) => {
|
|
846
846
|
var u;
|
|
847
847
|
if (typeof (e == null ? void 0 : e.getBoundingClientRect) != "function" || typeof (t == null ? void 0 : t.scroll) != "function")
|
|
848
848
|
return;
|
|
@@ -861,43 +861,43 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
861
861
|
value: u,
|
|
862
862
|
...i
|
|
863
863
|
}) => {
|
|
864
|
-
const [p,
|
|
864
|
+
const [p, l] = O({}), [m, _] = O(0), [f, h] = O(0), $ = P.toArray(e).filter(zt), b = R(), v = R(new Array($.length)), U = 200, y = t === "line", j = q([
|
|
865
865
|
S,
|
|
866
866
|
`${S}--${t}${n ? "-negative" : ""}`,
|
|
867
867
|
{ [`${S}--fullWidth`]: o },
|
|
868
868
|
r
|
|
869
|
-
]), V = P.map($, ({ props: { tabId:
|
|
870
|
-
const
|
|
871
|
-
return
|
|
869
|
+
]), V = P.map($, ({ props: { tabId: d } }) => d), x = () => {
|
|
870
|
+
const d = V.findIndex((I) => I === c);
|
|
871
|
+
return d >= 0 ? d : 0;
|
|
872
872
|
};
|
|
873
873
|
N(() => {
|
|
874
|
-
u && k($.findIndex((
|
|
874
|
+
u && k($.findIndex((d) => d.props.tabId === u));
|
|
875
875
|
}, [$, u]);
|
|
876
876
|
const [W, k] = O(x);
|
|
877
877
|
if (new Set(V).size !== V.length)
|
|
878
878
|
throw new Error("tabId must be unique");
|
|
879
|
-
const
|
|
879
|
+
const D = (d, I) => I || a ? `${I || a}-${d}` : void 0, z = () => {
|
|
880
880
|
if (!y)
|
|
881
881
|
return;
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
}, Q = (
|
|
885
|
-
y && !u && k($.findIndex((I) => I.props.tabId ===
|
|
886
|
-
}, fe = (
|
|
882
|
+
const d = v.current[W];
|
|
883
|
+
_((d == null ? void 0 : d.offsetLeft) || 0), h((d == null ? void 0 : d.getBoundingClientRect().width) || 0);
|
|
884
|
+
}, Q = (d) => {
|
|
885
|
+
y && !u && k($.findIndex((I) => I.props.tabId === d)), s == null || s(Ht(d));
|
|
886
|
+
}, fe = (d) => {
|
|
887
887
|
if (b != null && b.current) {
|
|
888
|
-
const { scrollLeft: I } = b.current, B =
|
|
888
|
+
const { scrollLeft: I } = b.current, B = d === "left" ? -200 : U;
|
|
889
889
|
b.current.scroll({ left: I + B, behavior: "smooth" });
|
|
890
890
|
}
|
|
891
|
-
}, Y = ({ side:
|
|
891
|
+
}, Y = ({ side: d }) => /* @__PURE__ */ T(
|
|
892
892
|
"button",
|
|
893
893
|
{
|
|
894
|
-
className:
|
|
895
|
-
onClick: () => fe(
|
|
894
|
+
className: q(`${S}__scroll-button`, `${S}__scroll-button--${d}`),
|
|
895
|
+
onClick: () => fe(d),
|
|
896
896
|
type: "button",
|
|
897
897
|
"aria-hidden": "true",
|
|
898
898
|
tabIndex: -1,
|
|
899
|
-
"data-testid":
|
|
900
|
-
children: /* @__PURE__ */ T(he, { svg:
|
|
899
|
+
"data-testid": D("scroll-button"),
|
|
900
|
+
children: /* @__PURE__ */ T(he, { svg: d === "left" ? ze : Ke, size: "md" })
|
|
901
901
|
}
|
|
902
902
|
);
|
|
903
903
|
return N(() => (window.addEventListener("resize", z), () => {
|
|
@@ -905,14 +905,14 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
905
905
|
}), []), N(() => {
|
|
906
906
|
z();
|
|
907
907
|
}, [W, o, $.length, t]), N(() => {
|
|
908
|
-
const
|
|
908
|
+
const d = (M) => {
|
|
909
909
|
if (M.every((A) => A.isIntersecting) && M.length === $.length) {
|
|
910
|
-
|
|
910
|
+
l({});
|
|
911
911
|
return;
|
|
912
912
|
}
|
|
913
913
|
M.forEach((A) => {
|
|
914
914
|
const be = Number(A.target.getAttribute("data-index")), Fe = be === 0, Oe = be === $.length - 1;
|
|
915
|
-
|
|
915
|
+
l((De) => ({
|
|
916
916
|
...De,
|
|
917
917
|
...Fe && {
|
|
918
918
|
[`${S}__wrapper--scroll-end`]: !A.isIntersecting
|
|
@@ -922,10 +922,10 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
922
922
|
}
|
|
923
923
|
}));
|
|
924
924
|
});
|
|
925
|
-
}, I = new IntersectionObserver(
|
|
925
|
+
}, I = new IntersectionObserver(d, {
|
|
926
926
|
threshold: [0.99],
|
|
927
927
|
root: b.current
|
|
928
|
-
}), B =
|
|
928
|
+
}), B = v.current;
|
|
929
929
|
return B.forEach((M) => I.observe(M)), () => {
|
|
930
930
|
B.forEach((M) => I.unobserve(M));
|
|
931
931
|
};
|
|
@@ -938,26 +938,26 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
938
938
|
className: j,
|
|
939
939
|
value: u,
|
|
940
940
|
...i,
|
|
941
|
-
children: /* @__PURE__ */ ee("div", { className:
|
|
942
|
-
/* @__PURE__ */ ee("div", { className:
|
|
941
|
+
children: /* @__PURE__ */ ee("div", { className: q(`${S}__container`), children: [
|
|
942
|
+
/* @__PURE__ */ ee("div", { className: q([`${S}__wrapper`, p]), children: [
|
|
943
943
|
/* @__PURE__ */ ee(
|
|
944
944
|
Dt,
|
|
945
945
|
{
|
|
946
|
-
ref: (
|
|
947
|
-
b.current =
|
|
946
|
+
ref: (d) => {
|
|
947
|
+
b.current = d;
|
|
948
948
|
},
|
|
949
|
-
className:
|
|
949
|
+
className: q(`${S}__list`),
|
|
950
950
|
children: [
|
|
951
|
-
P.map($, (
|
|
952
|
-
const { name: B, tabId: M, "data-testid": pe } =
|
|
951
|
+
P.map($, (d, I) => {
|
|
952
|
+
const { name: B, tabId: M, "data-testid": pe } = d.props;
|
|
953
953
|
return /* @__PURE__ */ T(
|
|
954
954
|
Yt,
|
|
955
955
|
{
|
|
956
|
-
"data-testid":
|
|
956
|
+
"data-testid": D("header", pe),
|
|
957
957
|
index: I,
|
|
958
958
|
tabId: M,
|
|
959
959
|
ref: (A) => {
|
|
960
|
-
A && (
|
|
960
|
+
A && (v.current[I] = A);
|
|
961
961
|
},
|
|
962
962
|
onFocus: (A) => {
|
|
963
963
|
Xt(A.target, b.current);
|
|
@@ -971,12 +971,12 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
971
971
|
y && /* @__PURE__ */ T(
|
|
972
972
|
"div",
|
|
973
973
|
{
|
|
974
|
-
className:
|
|
974
|
+
className: q(`${S}__selected-border`),
|
|
975
975
|
style: {
|
|
976
976
|
width: f,
|
|
977
|
-
transform: `translateX(${
|
|
977
|
+
transform: `translateX(${m}px)`
|
|
978
978
|
},
|
|
979
|
-
"data-testid":
|
|
979
|
+
"data-testid": D("selected-border")
|
|
980
980
|
}
|
|
981
981
|
)
|
|
982
982
|
]
|
|
@@ -985,7 +985,7 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
|
|
|
985
985
|
/* @__PURE__ */ T(Y, { side: "left" }),
|
|
986
986
|
/* @__PURE__ */ T(Y, { side: "right" })
|
|
987
987
|
] }),
|
|
988
|
-
/* @__PURE__ */ T("div", { className:
|
|
988
|
+
/* @__PURE__ */ T("div", { className: q(`${S}__content-container`), children: P.map($, (d) => d) })
|
|
989
989
|
] })
|
|
990
990
|
}
|
|
991
991
|
);
|