asma-ui-core 3.45.1 → 3.45.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { cn as n } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { ChevronRightIcon as
|
|
4
|
-
import { ChevronLeftIcon as
|
|
5
|
-
import { consumerOverrides as
|
|
6
|
-
import { TabsContext as
|
|
7
|
-
import { Children as
|
|
8
|
-
import { jsx as l, jsxs as
|
|
9
|
-
var I = 120,
|
|
10
|
-
const a =
|
|
2
|
+
import { resolveSx as M } from "../../../helpers/sx.js";
|
|
3
|
+
import { ChevronRightIcon as V } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
|
|
4
|
+
import { ChevronLeftIcon as _ } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
|
|
5
|
+
import { consumerOverrides as q } from "../../../helpers/classOverride.js";
|
|
6
|
+
import { TabsContext as z } from "./TabsContext.js";
|
|
7
|
+
import { Children as F, cloneElement as G, isValidElement as J, useCallback as u, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
|
|
8
|
+
import { jsx as l, jsxs as B } from "react/jsx-runtime";
|
|
9
|
+
var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: b = "default", className: x, sx: N, children: y }) => {
|
|
10
|
+
const a = E(null), d = E(/* @__PURE__ */ new Map()), [h, O] = A({
|
|
11
11
|
left: 0,
|
|
12
12
|
width: 0,
|
|
13
13
|
disabled: !1
|
|
14
|
-
}), [c, W] =
|
|
14
|
+
}), [c, W] = A({
|
|
15
15
|
left: !1,
|
|
16
16
|
right: !1
|
|
17
17
|
}), p = g === "scrollable", v = u((e, t) => {
|
|
18
18
|
t ? d.current.set(e, t) : d.current.delete(e);
|
|
19
|
-
}, []),
|
|
19
|
+
}, []), S = u((e, t) => m?.(e, t), [m]), f = u(() => {
|
|
20
20
|
const e = d.current.get(i), t = a.current;
|
|
21
21
|
if (e && O({
|
|
22
22
|
left: e.offsetLeft,
|
|
@@ -30,19 +30,19 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}, [i]);
|
|
33
|
-
|
|
33
|
+
Q(() => {
|
|
34
34
|
f();
|
|
35
35
|
const e = a.current;
|
|
36
36
|
if (!e) return;
|
|
37
37
|
const t = new ResizeObserver(f);
|
|
38
38
|
return t.observe(e), () => t.disconnect();
|
|
39
39
|
}, [f, y]);
|
|
40
|
-
const
|
|
40
|
+
const k = (e) => {
|
|
41
41
|
a.current?.scrollBy({
|
|
42
42
|
left: e,
|
|
43
43
|
behavior: "smooth"
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, D = (e) => {
|
|
46
46
|
if (![
|
|
47
47
|
"ArrowRight",
|
|
48
48
|
"ArrowLeft",
|
|
@@ -55,42 +55,42 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
55
55
|
const o = t.findIndex((s) => s === document.activeElement);
|
|
56
56
|
let r = o;
|
|
57
57
|
e.key === "ArrowRight" ? r = (o + 1) % t.length : e.key === "ArrowLeft" ? r = (o - 1 + t.length) % t.length : e.key === "Home" ? r = 0 : e.key === "End" && (r = t.length - 1), t[r]?.focus();
|
|
58
|
-
},
|
|
58
|
+
}, L = p && w !== !1, R = w === !0, P = L && (R || c.left), T = L && (R || c.right), H = q(x, "padding-x"), K = U(() => ({
|
|
59
59
|
value: i,
|
|
60
60
|
size: b,
|
|
61
|
-
onSelect:
|
|
61
|
+
onSelect: S,
|
|
62
62
|
register: v
|
|
63
63
|
}), [
|
|
64
64
|
i,
|
|
65
65
|
b,
|
|
66
|
-
|
|
66
|
+
S,
|
|
67
67
|
v
|
|
68
|
-
]),
|
|
69
|
-
return /* @__PURE__ */ l(
|
|
70
|
-
value:
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
className: n("relative flex items-center rounded-t-lg bg-white", !
|
|
73
|
-
style:
|
|
68
|
+
]), C = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
|
|
69
|
+
return /* @__PURE__ */ l(z.Provider, {
|
|
70
|
+
value: K,
|
|
71
|
+
children: /* @__PURE__ */ B("div", {
|
|
72
|
+
className: n("relative flex items-center rounded-t-lg bg-white", !H && "px-4", x),
|
|
73
|
+
style: M(N),
|
|
74
74
|
children: [
|
|
75
|
-
|
|
75
|
+
P && /* @__PURE__ */ l("button", {
|
|
76
76
|
type: "button",
|
|
77
77
|
"aria-label": "scroll tabs left",
|
|
78
|
-
className: n(
|
|
78
|
+
className: n(C, "mr-2"),
|
|
79
79
|
disabled: !c.left,
|
|
80
|
-
onClick: () =>
|
|
81
|
-
children: /* @__PURE__ */ l(
|
|
80
|
+
onClick: () => k(-I),
|
|
81
|
+
children: /* @__PURE__ */ l(_, {
|
|
82
82
|
width: 24,
|
|
83
83
|
height: 24
|
|
84
84
|
})
|
|
85
85
|
}),
|
|
86
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ B("div", {
|
|
87
87
|
ref: a,
|
|
88
88
|
role: "tablist",
|
|
89
89
|
"aria-orientation": "horizontal",
|
|
90
|
-
onKeyDown:
|
|
90
|
+
onKeyDown: D,
|
|
91
91
|
onScroll: f,
|
|
92
92
|
className: n("relative flex border-x-0 border-b border-t-0 border-solid border-delta-200 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", p ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", b === "small" && "min-h-9"),
|
|
93
|
-
children: [
|
|
93
|
+
children: [F.map(y, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
|
|
94
94
|
"aria-hidden": !0,
|
|
95
95
|
className: n("absolute bottom-0 h-0.5 transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
|
|
96
96
|
style: {
|
|
@@ -99,13 +99,13 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
99
99
|
}
|
|
100
100
|
})]
|
|
101
101
|
}),
|
|
102
|
-
|
|
102
|
+
T && /* @__PURE__ */ l("button", {
|
|
103
103
|
type: "button",
|
|
104
104
|
"aria-label": "scroll tabs right",
|
|
105
|
-
className: n(
|
|
105
|
+
className: n(C, "ml-2"),
|
|
106
106
|
disabled: !c.right,
|
|
107
|
-
onClick: () =>
|
|
108
|
-
children: /* @__PURE__ */ l(
|
|
107
|
+
onClick: () => k(I),
|
|
108
|
+
children: /* @__PURE__ */ l(V, {
|
|
109
109
|
width: 24,
|
|
110
110
|
height: 24
|
|
111
111
|
})
|
|
@@ -115,5 +115,5 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
export {
|
|
118
|
-
|
|
118
|
+
le as StyledTabs
|
|
119
119
|
};
|