@purpurds/tabs 5.10.1 → 5.11.1
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 +1 -1
- package/dist/tab-content.d.ts +1 -1
- package/dist/tab-content.d.ts.map +1 -1
- package/dist/tabs.cjs.js +1 -1
- package/dist/tabs.cjs.js.map +1 -1
- package/dist/tabs.es.js +116 -125
- package/dist/tabs.es.js.map +1 -1
- package/package.json +13 -13
- package/src/tab-content.test.tsx +2 -2
- package/src/tabs.stories.tsx +30 -5
- package/readme.mdx +0 -56
- package/src/tab-content.stories.tsx +0 -43
package/dist/tabs.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as T, jsxs as ee } from "react/jsx-runtime";
|
|
2
2
|
import * as ve from "react";
|
|
3
|
-
import A, { createContext as ne, useMemo as W, createElement as x, useContext as me, useCallback as
|
|
3
|
+
import A, { createContext as ne, useMemo as W, createElement as x, useContext as me, useCallback as B, forwardRef as S, Children as E, isValidElement as k, cloneElement as se, Fragment as Fe, useLayoutEffect as De, useEffect as P, useRef as R, useState as D, useReducer as qe } from "react";
|
|
4
4
|
import { flushSync as Le } from "react-dom";
|
|
5
5
|
function Ue(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -41,8 +41,8 @@ var _e = { exports: {} };
|
|
|
41
41
|
e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
|
|
42
42
|
})();
|
|
43
43
|
})(_e);
|
|
44
|
-
var
|
|
45
|
-
const
|
|
44
|
+
var Be = _e.exports;
|
|
45
|
+
const Ve = /* @__PURE__ */ Ue(Be), Ge = {
|
|
46
46
|
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
47
47
|
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
48
48
|
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
@@ -50,7 +50,7 @@ const Be = /* @__PURE__ */ Ue(Ve), je = {
|
|
|
50
50
|
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
51
51
|
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
52
52
|
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
53
|
-
},
|
|
53
|
+
}, je = {
|
|
54
54
|
name: "chevron-left",
|
|
55
55
|
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M16.175 3.905a.9.9 0 0 1-.08 1.27L8.36 12l7.736 6.825a.9.9 0 0 1-1.191 1.35l-8.5-7.5a.9.9 0 0 1 0-1.35l8.5-7.5a.9.9 0 0 1 1.27.08Z" clip-rule="evenodd"/></svg>',
|
|
56
56
|
keywords: ["chevron-left"],
|
|
@@ -60,7 +60,7 @@ const Be = /* @__PURE__ */ Ue(Ve), je = {
|
|
|
60
60
|
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M7.809 3.924a.9.9 0 0 0 .115 1.267L16.094 12l-8.17 6.809a.9.9 0 0 0 1.152 1.382l9-7.5a.9.9 0 0 0 0-1.382l-9-7.5a.9.9 0 0 0-1.267.115Z" clip-rule="evenodd"/></svg>',
|
|
61
61
|
keywords: ["chevron-right"],
|
|
62
62
|
category: "utility"
|
|
63
|
-
},
|
|
63
|
+
}, Ke = Ve.bind(Ge), be = "purpur-icon", ze = "md", We = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ye = ({ content: e = "", title: t } = {}) => {
|
|
64
64
|
const n = [
|
|
65
65
|
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
66
66
|
{ name: "fill", value: "currentColor" },
|
|
@@ -72,15 +72,15 @@ const Be = /* @__PURE__ */ Ue(Ve), je = {
|
|
|
72
72
|
["data-testid"]: e,
|
|
73
73
|
svg: t,
|
|
74
74
|
allyTitle: n,
|
|
75
|
-
className: o
|
|
76
|
-
size: s =
|
|
75
|
+
className: o,
|
|
76
|
+
size: s = ze,
|
|
77
77
|
...r
|
|
78
78
|
}) => {
|
|
79
79
|
const c = Ye({
|
|
80
80
|
content: Ze(t.svg),
|
|
81
81
|
title: n
|
|
82
|
-
}), a =
|
|
83
|
-
return /* @__PURE__ */
|
|
82
|
+
}), a = Ke(o, be, `${be}--${s}`);
|
|
83
|
+
return /* @__PURE__ */ T(
|
|
84
84
|
"span",
|
|
85
85
|
{
|
|
86
86
|
"aria-label": n,
|
|
@@ -91,20 +91,19 @@ const Be = /* @__PURE__ */ Ue(Ve), je = {
|
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
};
|
|
94
|
-
function
|
|
95
|
-
return
|
|
94
|
+
function C() {
|
|
95
|
+
return C = Object.assign ? Object.assign.bind() : function(e) {
|
|
96
96
|
for (var t = 1; t < arguments.length; t++) {
|
|
97
97
|
var n = arguments[t];
|
|
98
98
|
for (var o in n)
|
|
99
99
|
Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
|
|
100
100
|
}
|
|
101
101
|
return e;
|
|
102
|
-
},
|
|
102
|
+
}, C.apply(this, arguments);
|
|
103
103
|
}
|
|
104
104
|
function O(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
|
|
105
105
|
return function(s) {
|
|
106
|
-
if (e == null || e(s), n === !1 || !s.defaultPrevented)
|
|
107
|
-
return t == null ? void 0 : t(s);
|
|
106
|
+
if (e == null || e(s), n === !1 || !s.defaultPrevented) return t == null ? void 0 : t(s);
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
109
|
function ae(e, t = []) {
|
|
@@ -126,10 +125,8 @@ function ae(e, t = []) {
|
|
|
126
125
|
}
|
|
127
126
|
function p(l, $) {
|
|
128
127
|
const v = ($ == null ? void 0 : $[e][u]) || a, d = me(v);
|
|
129
|
-
if (d)
|
|
130
|
-
|
|
131
|
-
if (c !== void 0)
|
|
132
|
-
return c;
|
|
128
|
+
if (d) return d;
|
|
129
|
+
if (c !== void 0) return c;
|
|
133
130
|
throw new Error(`\`${l}\` must be used within \`${r}\``);
|
|
134
131
|
}
|
|
135
132
|
return i.displayName = r + "Provider", [
|
|
@@ -162,8 +159,7 @@ function ae(e, t = []) {
|
|
|
162
159
|
}
|
|
163
160
|
function Xe(...e) {
|
|
164
161
|
const t = e[0];
|
|
165
|
-
if (e.length === 1)
|
|
166
|
-
return t;
|
|
162
|
+
if (e.length === 1) return t;
|
|
167
163
|
const n = () => {
|
|
168
164
|
const o = e.map(
|
|
169
165
|
(s) => ({
|
|
@@ -200,17 +196,17 @@ function ge(...e) {
|
|
|
200
196
|
);
|
|
201
197
|
}
|
|
202
198
|
function Y(...e) {
|
|
203
|
-
return
|
|
199
|
+
return B(ge(...e), e);
|
|
204
200
|
}
|
|
205
201
|
const Z = /* @__PURE__ */ S((e, t) => {
|
|
206
202
|
const { children: n, ...o } = e, s = E.toArray(n), r = s.find(et);
|
|
207
203
|
if (r) {
|
|
208
204
|
const c = r.props.children, a = s.map((u) => u === r ? E.count(c) > 1 ? E.only(null) : /* @__PURE__ */ k(c) ? c.props.children : null : u);
|
|
209
|
-
return /* @__PURE__ */ x(re,
|
|
205
|
+
return /* @__PURE__ */ x(re, C({}, o, {
|
|
210
206
|
ref: t
|
|
211
207
|
}), /* @__PURE__ */ k(c) ? /* @__PURE__ */ se(c, void 0, a) : null);
|
|
212
208
|
}
|
|
213
|
-
return /* @__PURE__ */ x(re,
|
|
209
|
+
return /* @__PURE__ */ x(re, C({}, o, {
|
|
214
210
|
ref: t
|
|
215
211
|
}), n);
|
|
216
212
|
});
|
|
@@ -267,11 +263,11 @@ function nt(e) {
|
|
|
267
263
|
ref: h
|
|
268
264
|
}, m);
|
|
269
265
|
}), i = e + "CollectionItemSlot", p = "data-radix-collection-item", l = /* @__PURE__ */ A.forwardRef((v, d) => {
|
|
270
|
-
const { scope: b, children: m, ..._ } = v, h = A.useRef(null), F = Y(d, h),
|
|
271
|
-
return A.useEffect(() => (
|
|
266
|
+
const { scope: b, children: m, ..._ } = v, h = A.useRef(null), F = Y(d, h), w = r(i, b);
|
|
267
|
+
return A.useEffect(() => (w.itemMap.set(h, {
|
|
272
268
|
ref: h,
|
|
273
269
|
..._
|
|
274
|
-
}), () => void
|
|
270
|
+
}), () => void w.itemMap.delete(h))), /* @__PURE__ */ A.createElement(Z, {
|
|
275
271
|
[p]: "",
|
|
276
272
|
ref: F
|
|
277
273
|
}, m);
|
|
@@ -280,11 +276,10 @@ function nt(e) {
|
|
|
280
276
|
const d = r(e + "CollectionConsumer", v);
|
|
281
277
|
return A.useCallback(() => {
|
|
282
278
|
const m = d.collectionRef.current;
|
|
283
|
-
if (!m)
|
|
284
|
-
return [];
|
|
279
|
+
if (!m) return [];
|
|
285
280
|
const _ = Array.from(m.querySelectorAll(`[${p}]`));
|
|
286
281
|
return Array.from(d.itemMap.values()).sort(
|
|
287
|
-
(
|
|
282
|
+
(w, q) => _.indexOf(w.ref.current) - _.indexOf(q.ref.current)
|
|
288
283
|
);
|
|
289
284
|
}, [
|
|
290
285
|
d.collectionRef,
|
|
@@ -332,12 +327,12 @@ const ct = [
|
|
|
332
327
|
"span",
|
|
333
328
|
"svg",
|
|
334
329
|
"ul"
|
|
335
|
-
],
|
|
330
|
+
], j = ct.reduce((e, t) => {
|
|
336
331
|
const n = /* @__PURE__ */ S((o, s) => {
|
|
337
332
|
const { asChild: r, ...c } = o, a = r ? Z : t;
|
|
338
333
|
return P(() => {
|
|
339
334
|
window[Symbol.for("radix-ui")] = !0;
|
|
340
|
-
}, []), /* @__PURE__ */ x(a,
|
|
335
|
+
}, []), /* @__PURE__ */ x(a, C({}, c, {
|
|
341
336
|
ref: s
|
|
342
337
|
}));
|
|
343
338
|
});
|
|
@@ -363,12 +358,11 @@ function xe({ prop: e, defaultProp: t, onChange: n = () => {
|
|
|
363
358
|
const [o, s] = st({
|
|
364
359
|
defaultProp: t,
|
|
365
360
|
onChange: n
|
|
366
|
-
}), 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 = B((i) => {
|
|
367
362
|
if (r) {
|
|
368
363
|
const l = typeof i == "function" ? i(e) : i;
|
|
369
364
|
l !== e && a(l);
|
|
370
|
-
} else
|
|
371
|
-
s(i);
|
|
365
|
+
} else s(i);
|
|
372
366
|
}, [
|
|
373
367
|
r,
|
|
374
368
|
e,
|
|
@@ -391,31 +385,31 @@ function st({ defaultProp: e, onChange: t }) {
|
|
|
391
385
|
]), n;
|
|
392
386
|
}
|
|
393
387
|
const at = /* @__PURE__ */ ne(void 0);
|
|
394
|
-
function
|
|
388
|
+
function Ie(e) {
|
|
395
389
|
const t = me(at);
|
|
396
390
|
return e || t || "ltr";
|
|
397
391
|
}
|
|
398
392
|
const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
399
393
|
bubbles: !1,
|
|
400
394
|
cancelable: !0
|
|
401
|
-
}, ue = "RovingFocusGroup", [ce,
|
|
395
|
+
}, ue = "RovingFocusGroup", [ce, Ce, ut] = nt(ue), [lt, ye] = ae(ue, [
|
|
402
396
|
ut
|
|
403
397
|
]), [dt, ft] = lt(ue), pt = /* @__PURE__ */ S((e, t) => /* @__PURE__ */ x(ce.Provider, {
|
|
404
398
|
scope: e.__scopeRovingFocusGroup
|
|
405
399
|
}, /* @__PURE__ */ x(ce.Slot, {
|
|
406
400
|
scope: e.__scopeRovingFocusGroup
|
|
407
|
-
}, /* @__PURE__ */ x(bt,
|
|
401
|
+
}, /* @__PURE__ */ x(bt, C({}, e, {
|
|
408
402
|
ref: t
|
|
409
403
|
}))))), bt = /* @__PURE__ */ S((e, t) => {
|
|
410
|
-
const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, l = R(null), $ = Y(t, l), v =
|
|
404
|
+
const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, l = R(null), $ = Y(t, l), v = Ie(r), [d = null, b] = xe({
|
|
411
405
|
prop: c,
|
|
412
406
|
defaultProp: a,
|
|
413
407
|
onChange: u
|
|
414
|
-
}), [m, _] = D(!1), h = ie(i), F =
|
|
408
|
+
}), [m, _] = D(!1), h = ie(i), F = Ce(n), w = R(!1), [q, K] = D(0);
|
|
415
409
|
return P(() => {
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
418
|
-
return
|
|
410
|
+
const I = l.current;
|
|
411
|
+
if (I)
|
|
412
|
+
return I.addEventListener(te, h), () => I.removeEventListener(te, h);
|
|
419
413
|
}, [
|
|
420
414
|
h
|
|
421
415
|
]), /* @__PURE__ */ x(dt, {
|
|
@@ -424,29 +418,29 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
424
418
|
dir: v,
|
|
425
419
|
loop: s,
|
|
426
420
|
currentTabStopId: d,
|
|
427
|
-
onItemFocus:
|
|
428
|
-
(
|
|
421
|
+
onItemFocus: B(
|
|
422
|
+
(I) => b(I),
|
|
429
423
|
[
|
|
430
424
|
b
|
|
431
425
|
]
|
|
432
426
|
),
|
|
433
|
-
onItemShiftTab:
|
|
427
|
+
onItemShiftTab: B(
|
|
434
428
|
() => _(!0),
|
|
435
429
|
[]
|
|
436
430
|
),
|
|
437
|
-
onFocusableItemAdd:
|
|
438
|
-
() =>
|
|
439
|
-
(
|
|
431
|
+
onFocusableItemAdd: B(
|
|
432
|
+
() => K(
|
|
433
|
+
(I) => I + 1
|
|
440
434
|
),
|
|
441
435
|
[]
|
|
442
436
|
),
|
|
443
|
-
onFocusableItemRemove:
|
|
444
|
-
() =>
|
|
445
|
-
(
|
|
437
|
+
onFocusableItemRemove: B(
|
|
438
|
+
() => K(
|
|
439
|
+
(I) => I - 1
|
|
446
440
|
),
|
|
447
441
|
[]
|
|
448
442
|
)
|
|
449
|
-
}, /* @__PURE__ */ x(
|
|
443
|
+
}, /* @__PURE__ */ x(j.div, C({
|
|
450
444
|
tabIndex: m || q === 0 ? -1 : 0,
|
|
451
445
|
"data-orientation": o
|
|
452
446
|
}, p, {
|
|
@@ -456,13 +450,13 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
456
450
|
...e.style
|
|
457
451
|
},
|
|
458
452
|
onMouseDown: O(e.onMouseDown, () => {
|
|
459
|
-
|
|
453
|
+
w.current = !0;
|
|
460
454
|
}),
|
|
461
|
-
onFocus: O(e.onFocus, (
|
|
462
|
-
const H = !
|
|
463
|
-
if (
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
455
|
+
onFocus: O(e.onFocus, (I) => {
|
|
456
|
+
const H = !w.current;
|
|
457
|
+
if (I.target === I.currentTarget && H && !m) {
|
|
458
|
+
const V = new CustomEvent(te, it);
|
|
459
|
+
if (I.currentTarget.dispatchEvent(V), !V.defaultPrevented) {
|
|
466
460
|
const L = F().filter(
|
|
467
461
|
(g) => g.focusable
|
|
468
462
|
), X = L.find(
|
|
@@ -479,7 +473,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
479
473
|
Se(f);
|
|
480
474
|
}
|
|
481
475
|
}
|
|
482
|
-
|
|
476
|
+
w.current = !1;
|
|
483
477
|
}),
|
|
484
478
|
onBlur: O(
|
|
485
479
|
e.onBlur,
|
|
@@ -487,7 +481,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
487
481
|
)
|
|
488
482
|
})));
|
|
489
483
|
}), $t = "RovingFocusGroupItem", vt = /* @__PURE__ */ S((e, t) => {
|
|
490
|
-
const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = he(), u = r || a, i = ft($t, n), p = i.currentTabStopId === u, l =
|
|
484
|
+
const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = he(), u = r || a, i = ft($t, n), p = i.currentTabStopId === u, l = Ce(n), { onFocusableItemAdd: $, onFocusableItemRemove: v } = i;
|
|
491
485
|
return P(() => {
|
|
492
486
|
if (o)
|
|
493
487
|
return $(), () => v();
|
|
@@ -500,7 +494,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
500
494
|
id: u,
|
|
501
495
|
focusable: o,
|
|
502
496
|
active: s
|
|
503
|
-
}, /* @__PURE__ */ x(
|
|
497
|
+
}, /* @__PURE__ */ x(j.span, C({
|
|
504
498
|
tabIndex: p ? 0 : -1,
|
|
505
499
|
"data-orientation": i.orientation
|
|
506
500
|
}, c, {
|
|
@@ -517,8 +511,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
517
511
|
i.onItemShiftTab();
|
|
518
512
|
return;
|
|
519
513
|
}
|
|
520
|
-
if (d.target !== d.currentTarget)
|
|
521
|
-
return;
|
|
514
|
+
if (d.target !== d.currentTarget) return;
|
|
522
515
|
const b = gt(d, i.orientation, i.dir);
|
|
523
516
|
if (b !== void 0) {
|
|
524
517
|
d.preventDefault();
|
|
@@ -527,8 +520,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
|
|
|
527
520
|
).map(
|
|
528
521
|
(h) => h.ref.current
|
|
529
522
|
);
|
|
530
|
-
if (b === "last")
|
|
531
|
-
_.reverse();
|
|
523
|
+
if (b === "last") _.reverse();
|
|
532
524
|
else if (b === "prev" || b === "next") {
|
|
533
525
|
b === "prev" && _.reverse();
|
|
534
526
|
const h = _.indexOf(d.currentTarget);
|
|
@@ -567,22 +559,21 @@ function gt(e, t, n) {
|
|
|
567
559
|
function Se(e) {
|
|
568
560
|
const t = document.activeElement;
|
|
569
561
|
for (const n of e)
|
|
570
|
-
if (n === t || (n.focus(), document.activeElement !== t))
|
|
571
|
-
return;
|
|
562
|
+
if (n === t || (n.focus(), document.activeElement !== t)) return;
|
|
572
563
|
}
|
|
573
564
|
function ht(e, t) {
|
|
574
565
|
return e.map(
|
|
575
566
|
(n, o) => e[(t + o) % e.length]
|
|
576
567
|
);
|
|
577
568
|
}
|
|
578
|
-
const xt = pt,
|
|
579
|
-
function
|
|
569
|
+
const xt = pt, It = vt;
|
|
570
|
+
function Ct(e, t) {
|
|
580
571
|
return qe((n, o) => {
|
|
581
572
|
const s = t[n][o];
|
|
582
573
|
return s ?? n;
|
|
583
574
|
}, e);
|
|
584
575
|
}
|
|
585
|
-
const
|
|
576
|
+
const Te = (e) => {
|
|
586
577
|
const { present: t, children: n } = e, o = yt(t), s = typeof n == "function" ? n({
|
|
587
578
|
present: o.isPresent
|
|
588
579
|
}) : E.only(n), r = Y(o.ref, s.ref);
|
|
@@ -590,9 +581,9 @@ const we = (e) => {
|
|
|
590
581
|
ref: r
|
|
591
582
|
}) : null;
|
|
592
583
|
};
|
|
593
|
-
|
|
584
|
+
Te.displayName = "Presence";
|
|
594
585
|
function yt(e) {
|
|
595
|
-
const [t, n] = D(), o = R({}), s = R(e), r = R("none"), c = e ? "mounted" : "unmounted", [a, u] =
|
|
586
|
+
const [t, n] = D(), o = R({}), s = R(e), r = R("none"), c = e ? "mounted" : "unmounted", [a, u] = Ct(c, {
|
|
596
587
|
mounted: {
|
|
597
588
|
UNMOUNT: "unmounted",
|
|
598
589
|
ANIMATION_OUT: "unmountSuspended"
|
|
@@ -606,14 +597,14 @@ function yt(e) {
|
|
|
606
597
|
}
|
|
607
598
|
});
|
|
608
599
|
return P(() => {
|
|
609
|
-
const i =
|
|
600
|
+
const i = z(o.current);
|
|
610
601
|
r.current = a === "mounted" ? i : "none";
|
|
611
602
|
}, [
|
|
612
603
|
a
|
|
613
604
|
]), oe(() => {
|
|
614
605
|
const i = o.current, p = s.current;
|
|
615
606
|
if (p !== e) {
|
|
616
|
-
const $ = r.current, v =
|
|
607
|
+
const $ = r.current, v = z(i);
|
|
617
608
|
e ? u("MOUNT") : v === "none" || (i == null ? void 0 : i.display) === "none" ? u("UNMOUNT") : u(p && $ !== v ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
|
|
618
609
|
}
|
|
619
610
|
}, [
|
|
@@ -622,12 +613,12 @@ function yt(e) {
|
|
|
622
613
|
]), oe(() => {
|
|
623
614
|
if (t) {
|
|
624
615
|
const i = (l) => {
|
|
625
|
-
const v =
|
|
616
|
+
const v = z(o.current).includes(l.animationName);
|
|
626
617
|
l.target === t && v && Le(
|
|
627
618
|
() => u("ANIMATION_END")
|
|
628
619
|
);
|
|
629
620
|
}, p = (l) => {
|
|
630
|
-
l.target === t && (r.current =
|
|
621
|
+
l.target === t && (r.current = z(o.current));
|
|
631
622
|
};
|
|
632
623
|
return t.addEventListener("animationstart", p), t.addEventListener("animationcancel", i), t.addEventListener("animationend", i), () => {
|
|
633
624
|
t.removeEventListener("animationstart", p), t.removeEventListener("animationcancel", i), t.removeEventListener("animationend", i);
|
|
@@ -642,23 +633,23 @@ function yt(e) {
|
|
|
642
633
|
"mounted",
|
|
643
634
|
"unmountSuspended"
|
|
644
635
|
].includes(a),
|
|
645
|
-
ref:
|
|
636
|
+
ref: B((i) => {
|
|
646
637
|
i && (o.current = getComputedStyle(i)), n(i);
|
|
647
638
|
}, [])
|
|
648
639
|
};
|
|
649
640
|
}
|
|
650
|
-
function
|
|
641
|
+
function z(e) {
|
|
651
642
|
return (e == null ? void 0 : e.animationName) || "none";
|
|
652
643
|
}
|
|
653
|
-
const
|
|
644
|
+
const we = "Tabs", [St, tn] = ae(we, [
|
|
654
645
|
ye
|
|
655
|
-
]), Ne = ye(), [
|
|
656
|
-
const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p =
|
|
646
|
+
]), Ne = ye(), [Tt, le] = St(we), wt = /* @__PURE__ */ S((e, t) => {
|
|
647
|
+
const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = Ie(a), [l, $] = xe({
|
|
657
648
|
prop: o,
|
|
658
649
|
onChange: s,
|
|
659
650
|
defaultProp: r
|
|
660
651
|
});
|
|
661
|
-
return /* @__PURE__ */ x(
|
|
652
|
+
return /* @__PURE__ */ x(Tt, {
|
|
662
653
|
scope: n,
|
|
663
654
|
baseId: he(),
|
|
664
655
|
value: l,
|
|
@@ -666,7 +657,7 @@ const Te = "Tabs", [St, tn] = ae(Te, [
|
|
|
666
657
|
orientation: c,
|
|
667
658
|
dir: p,
|
|
668
659
|
activationMode: u
|
|
669
|
-
}, /* @__PURE__ */ x(
|
|
660
|
+
}, /* @__PURE__ */ x(j.div, C({
|
|
670
661
|
dir: p,
|
|
671
662
|
"data-orientation": c
|
|
672
663
|
}, i, {
|
|
@@ -674,13 +665,13 @@ const Te = "Tabs", [St, tn] = ae(Te, [
|
|
|
674
665
|
})));
|
|
675
666
|
}), Nt = "TabsList", At = /* @__PURE__ */ S((e, t) => {
|
|
676
667
|
const { __scopeTabs: n, loop: o = !0, ...s } = e, r = le(Nt, n), c = Ne(n);
|
|
677
|
-
return /* @__PURE__ */ x(xt,
|
|
668
|
+
return /* @__PURE__ */ x(xt, C({
|
|
678
669
|
asChild: !0
|
|
679
670
|
}, c, {
|
|
680
671
|
orientation: r.orientation,
|
|
681
672
|
dir: r.dir,
|
|
682
673
|
loop: o
|
|
683
|
-
}), /* @__PURE__ */ x(
|
|
674
|
+
}), /* @__PURE__ */ x(j.div, C({
|
|
684
675
|
role: "tablist",
|
|
685
676
|
"aria-orientation": r.orientation
|
|
686
677
|
}, s, {
|
|
@@ -688,12 +679,12 @@ const Te = "Tabs", [St, tn] = ae(Te, [
|
|
|
688
679
|
})));
|
|
689
680
|
}), Et = "TabsTrigger", Pt = /* @__PURE__ */ S((e, t) => {
|
|
690
681
|
const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c = le(Et, n), a = Ne(n), u = Ae(c.baseId, o), i = Ee(c.baseId, o), p = o === c.value;
|
|
691
|
-
return /* @__PURE__ */ x(
|
|
682
|
+
return /* @__PURE__ */ x(It, C({
|
|
692
683
|
asChild: !0
|
|
693
684
|
}, a, {
|
|
694
685
|
focusable: !s,
|
|
695
686
|
active: p
|
|
696
|
-
}), /* @__PURE__ */ x(
|
|
687
|
+
}), /* @__PURE__ */ x(j.button, C({
|
|
697
688
|
type: "button",
|
|
698
689
|
role: "tab",
|
|
699
690
|
"aria-selected": p,
|
|
@@ -726,11 +717,11 @@ const Te = "Tabs", [St, tn] = ae(Te, [
|
|
|
726
717
|
);
|
|
727
718
|
return () => cancelAnimationFrame($);
|
|
728
719
|
}, []), /* @__PURE__ */ x(
|
|
729
|
-
|
|
720
|
+
Te,
|
|
730
721
|
{
|
|
731
722
|
present: s || p
|
|
732
723
|
},
|
|
733
|
-
({ present: $ }) => /* @__PURE__ */ x(
|
|
724
|
+
({ present: $ }) => /* @__PURE__ */ x(j.div, C({
|
|
734
725
|
"data-state": p ? "active" : "inactive",
|
|
735
726
|
"data-orientation": a.orientation,
|
|
736
727
|
role: "tabpanel",
|
|
@@ -753,7 +744,7 @@ function Ae(e, t) {
|
|
|
753
744
|
function Ee(e, t) {
|
|
754
745
|
return `${e}-content-${t}`;
|
|
755
746
|
}
|
|
756
|
-
const Ot =
|
|
747
|
+
const Ot = wt, Ft = At, Dt = Pt, qt = Mt;
|
|
757
748
|
function Lt(e) {
|
|
758
749
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
759
750
|
}
|
|
@@ -794,27 +785,27 @@ var Pe = { exports: {} };
|
|
|
794
785
|
})();
|
|
795
786
|
})(Pe);
|
|
796
787
|
var Ut = Pe.exports;
|
|
797
|
-
const de = /* @__PURE__ */ Lt(Ut),
|
|
788
|
+
const de = /* @__PURE__ */ Lt(Ut), Bt = {
|
|
798
789
|
"purpur-tab-content": "_purpur-tab-content_1x2zs_1"
|
|
799
|
-
},
|
|
800
|
-
({ children: e, tabId: t, "data-testid": n, className: o, ...s }, r) => /* @__PURE__ */
|
|
790
|
+
}, Vt = de.bind(Bt), Gt = "purpur-tab-content", jt = S(
|
|
791
|
+
({ children: e, tabId: t, "data-testid": n, className: o, ...s }, r) => /* @__PURE__ */ T(
|
|
801
792
|
qt,
|
|
802
793
|
{
|
|
803
794
|
ref: r,
|
|
804
|
-
className:
|
|
795
|
+
className: Vt([Gt, o]),
|
|
805
796
|
"data-testid": n,
|
|
806
797
|
value: t,
|
|
807
798
|
...s,
|
|
808
799
|
children: e
|
|
809
800
|
}
|
|
810
801
|
)
|
|
811
|
-
), kt = (e) => !!e && k(e) && !!e.props.name && !!e.props.tabId,
|
|
802
|
+
), kt = (e) => !!e && k(e) && !!e.props.name && !!e.props.tabId, Kt = {
|
|
812
803
|
"purpur-tab-header": "_purpur-tab-header_18g3c_1",
|
|
813
804
|
"purpur-tab-header--contained": "_purpur-tab-header--contained_18g3c_33",
|
|
814
805
|
"purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_18g3c_33",
|
|
815
806
|
"purpur-tab-header--line": "_purpur-tab-header--line_18g3c_36",
|
|
816
807
|
"purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_18g3c_48"
|
|
817
|
-
},
|
|
808
|
+
}, zt = de.bind(Kt), $e = "purpur-tab-header", Wt = S(
|
|
818
809
|
({
|
|
819
810
|
index: e,
|
|
820
811
|
tabId: t,
|
|
@@ -823,11 +814,11 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
823
814
|
onFocus: s,
|
|
824
815
|
"data-testid": r,
|
|
825
816
|
children: c
|
|
826
|
-
}, a) => /* @__PURE__ */
|
|
817
|
+
}, a) => /* @__PURE__ */ T(
|
|
827
818
|
Dt,
|
|
828
819
|
{
|
|
829
820
|
id: `${t}-trigger`,
|
|
830
|
-
className:
|
|
821
|
+
className: zt([$e, `${$e}--${n}${o ? "-negative" : ""}`]),
|
|
831
822
|
value: t,
|
|
832
823
|
"data-testid": r,
|
|
833
824
|
"data-index": e,
|
|
@@ -869,30 +860,30 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
869
860
|
"data-testid": a,
|
|
870
861
|
...u
|
|
871
862
|
}) => {
|
|
872
|
-
const [i, p] = D({}), [l, $] = D(0), [v, d] = D(0), b = E.toArray(e).filter(kt), m = R(), _ = R(new Array(b.length)), h = 200, F = t === "line",
|
|
863
|
+
const [i, p] = D({}), [l, $] = D(0), [v, d] = D(0), b = E.toArray(e).filter(kt), m = R(), _ = R(new Array(b.length)), h = 200, F = t === "line", w = U([
|
|
873
864
|
y,
|
|
874
865
|
`${y}--${t}${n ? "-negative" : ""}`,
|
|
875
866
|
{ [`${y}--fullWidth`]: o },
|
|
876
867
|
r
|
|
877
|
-
]), q = E.map(b, ({ props: { tabId: f } }) => f),
|
|
868
|
+
]), q = E.map(b, ({ props: { tabId: f } }) => f), K = () => {
|
|
878
869
|
const f = q.findIndex((g) => g === c);
|
|
879
870
|
return f >= 0 ? f : 0;
|
|
880
|
-
}, [
|
|
871
|
+
}, [I, H] = D(K);
|
|
881
872
|
if (new Set(q).size !== q.length)
|
|
882
873
|
throw new Error("tabId must be unique");
|
|
883
|
-
const
|
|
874
|
+
const V = (f, g) => g || a ? `${g || a}-${f}` : void 0, L = () => {
|
|
884
875
|
if (!F)
|
|
885
876
|
return;
|
|
886
|
-
const f = _.current[
|
|
877
|
+
const f = _.current[I];
|
|
887
878
|
$((f == null ? void 0 : f.offsetLeft) || 0), d((f == null ? void 0 : f.getBoundingClientRect().width) || 0);
|
|
888
879
|
}, X = (f) => {
|
|
889
880
|
F && H(b.findIndex((g) => g.props.tabId === f)), s == null || s(Zt(f));
|
|
890
881
|
}, J = (f) => {
|
|
891
882
|
if (m != null && m.current) {
|
|
892
|
-
const { scrollLeft: g } = m.current,
|
|
893
|
-
m.current.scroll({ left: g +
|
|
883
|
+
const { scrollLeft: g } = m.current, G = f === "left" ? -h : h;
|
|
884
|
+
m.current.scroll({ left: g + G, behavior: "smooth" });
|
|
894
885
|
}
|
|
895
|
-
}, Q = ({ side: f }) => /* @__PURE__ */
|
|
886
|
+
}, Q = ({ side: f }) => /* @__PURE__ */ T(
|
|
896
887
|
"button",
|
|
897
888
|
{
|
|
898
889
|
className: U(`${y}__scroll-button`, `${y}__scroll-button--${f}`),
|
|
@@ -900,15 +891,15 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
900
891
|
type: "button",
|
|
901
892
|
"aria-hidden": "true",
|
|
902
893
|
tabIndex: -1,
|
|
903
|
-
"data-testid":
|
|
904
|
-
children: /* @__PURE__ */
|
|
894
|
+
"data-testid": V("scroll-button"),
|
|
895
|
+
children: /* @__PURE__ */ T(He, { svg: f === "left" ? je : ke, size: "md" })
|
|
905
896
|
}
|
|
906
897
|
);
|
|
907
898
|
return P(() => (window.addEventListener("resize", L), () => {
|
|
908
899
|
window.removeEventListener("resize", L);
|
|
909
900
|
}), []), P(() => {
|
|
910
901
|
L();
|
|
911
|
-
}, [
|
|
902
|
+
}, [I, o, b.length, t]), P(() => {
|
|
912
903
|
const f = (M) => {
|
|
913
904
|
if (M.every((N) => N.isIntersecting) && M.length === b.length) {
|
|
914
905
|
p({});
|
|
@@ -929,17 +920,17 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
929
920
|
}, g = new IntersectionObserver(f, {
|
|
930
921
|
threshold: [0.99],
|
|
931
922
|
root: m.current
|
|
932
|
-
}),
|
|
933
|
-
return
|
|
934
|
-
|
|
923
|
+
}), G = _.current;
|
|
924
|
+
return G.forEach((M) => g.observe(M)), () => {
|
|
925
|
+
G.forEach((M) => g.unobserve(M));
|
|
935
926
|
};
|
|
936
|
-
}, [b.length]), /* @__PURE__ */
|
|
927
|
+
}, [b.length]), /* @__PURE__ */ T(
|
|
937
928
|
Ot,
|
|
938
929
|
{
|
|
939
930
|
defaultValue: c ?? b[0].props.tabId,
|
|
940
931
|
onValueChange: X,
|
|
941
932
|
"data-testid": a,
|
|
942
|
-
className:
|
|
933
|
+
className: w,
|
|
943
934
|
...u,
|
|
944
935
|
children: /* @__PURE__ */ ee("div", { className: U(`${y}__container`), children: [
|
|
945
936
|
/* @__PURE__ */ ee("div", { className: U([`${y}__wrapper`, i]), children: [
|
|
@@ -952,11 +943,11 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
952
943
|
className: U(`${y}__list`),
|
|
953
944
|
children: [
|
|
954
945
|
E.map(b, (f, g) => {
|
|
955
|
-
const { name:
|
|
956
|
-
return /* @__PURE__ */
|
|
946
|
+
const { name: G, tabId: M, "data-testid": fe } = f.props;
|
|
947
|
+
return /* @__PURE__ */ T(
|
|
957
948
|
Wt,
|
|
958
949
|
{
|
|
959
|
-
"data-testid":
|
|
950
|
+
"data-testid": V("header", fe),
|
|
960
951
|
index: g,
|
|
961
952
|
tabId: M,
|
|
962
953
|
ref: (N) => {
|
|
@@ -967,11 +958,11 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
967
958
|
},
|
|
968
959
|
variant: t,
|
|
969
960
|
negative: n,
|
|
970
|
-
children:
|
|
961
|
+
children: G
|
|
971
962
|
}
|
|
972
963
|
);
|
|
973
964
|
}),
|
|
974
|
-
F && /* @__PURE__ */
|
|
965
|
+
F && /* @__PURE__ */ T(
|
|
975
966
|
"div",
|
|
976
967
|
{
|
|
977
968
|
className: U(`${y}__selected-border`),
|
|
@@ -979,21 +970,21 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
|
|
|
979
970
|
width: v,
|
|
980
971
|
transform: `translateX(${l}px)`
|
|
981
972
|
},
|
|
982
|
-
"data-testid":
|
|
973
|
+
"data-testid": V("selected-border")
|
|
983
974
|
}
|
|
984
975
|
)
|
|
985
976
|
]
|
|
986
977
|
}
|
|
987
978
|
),
|
|
988
|
-
/* @__PURE__ */
|
|
989
|
-
/* @__PURE__ */
|
|
979
|
+
/* @__PURE__ */ T(Q, { side: "left" }),
|
|
980
|
+
/* @__PURE__ */ T(Q, { side: "right" })
|
|
990
981
|
] }),
|
|
991
|
-
/* @__PURE__ */
|
|
982
|
+
/* @__PURE__ */ T("div", { className: U(`${y}__content-container`), children: E.map(b, (f) => f) })
|
|
992
983
|
] })
|
|
993
984
|
}
|
|
994
985
|
);
|
|
995
986
|
};
|
|
996
|
-
Xt.Content =
|
|
987
|
+
Xt.Content = jt;
|
|
997
988
|
export {
|
|
998
989
|
Xt as Tabs,
|
|
999
990
|
Zt as createTabChangeDetailEvent,
|