@situaction/traq-ui-ste 1.1.25 → 1.1.26
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.
|
@@ -11,6 +11,7 @@ export interface TabsProps {
|
|
|
11
11
|
position?: 'center' | 'right' | 'left';
|
|
12
12
|
/** Callback function to handle tab selection, receiving the selected tab's label */
|
|
13
13
|
onTabSelect: (selectedItem: string | ReactNode) => void;
|
|
14
|
+
fullWidth?: boolean;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* Tabs component that allows tab navigation with text, icons, or buttons.
|
|
@@ -1,76 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as H, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as s, useLayoutEffect as $ } from "react";
|
|
3
3
|
import '../../styles/index.css';import '../../styles/Tabs.css';/* empty css */
|
|
4
|
-
import { Button as
|
|
5
|
-
import { IconButton as
|
|
6
|
-
const p = "
|
|
7
|
-
"tab-container": "_tab-
|
|
8
|
-
"tab-container-button": "_tab-container-
|
|
9
|
-
"tab-container-icon": "_tab-container-
|
|
10
|
-
"tab-container-text": "_tab-container-
|
|
11
|
-
"tab-items": "_tab-
|
|
12
|
-
"tab-items-button": "_tab-items-
|
|
13
|
-
"
|
|
14
|
-
"selected-
|
|
4
|
+
import { Button as C } from "../button/Button.js";
|
|
5
|
+
import { IconButton as N } from "../icon-button/IconButton.js";
|
|
6
|
+
const p = "_underline_1twz4_63", n = {
|
|
7
|
+
"tab-container": "_tab-container_1twz4_23",
|
|
8
|
+
"tab-container-button": "_tab-container-button_1twz4_27",
|
|
9
|
+
"tab-container-icon": "_tab-container-icon_1twz4_32",
|
|
10
|
+
"tab-container-text": "_tab-container-text_1twz4_32",
|
|
11
|
+
"tab-items": "_tab-items_1twz4_35",
|
|
12
|
+
"tab-items-button": "_tab-items-button_1twz4_39",
|
|
13
|
+
"tab-full-width": "_tab-full-width_1twz4_44",
|
|
14
|
+
"selected-button": "_selected-button_1twz4_50",
|
|
15
|
+
"selected-text": "_selected-text_1twz4_56",
|
|
15
16
|
underline: p,
|
|
16
|
-
"flexHorizontal-center": "_flexHorizontal-
|
|
17
|
-
"flexHorizontal-left": "_flexHorizontal-
|
|
18
|
-
"flexHorizontal-right": "_flexHorizontal-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
"flexHorizontal-center": "_flexHorizontal-center_1twz4_71",
|
|
18
|
+
"flexHorizontal-left": "_flexHorizontal-left_1twz4_77",
|
|
19
|
+
"flexHorizontal-right": "_flexHorizontal-right_1twz4_83"
|
|
20
|
+
}, A = ({
|
|
21
|
+
listItems: i,
|
|
22
|
+
type: o,
|
|
23
|
+
onTabSelect: f,
|
|
24
|
+
defaultActiveTab: d = 0,
|
|
25
|
+
position: m = "left",
|
|
26
|
+
fullWidth: z = !1
|
|
27
|
+
}) => {
|
|
28
|
+
const [l, w] = u(d), [x, h] = u({}), c = s(null), g = s(null), _ = s([]), b = (t) => {
|
|
29
|
+
w(t), f(i[t]);
|
|
30
|
+
}, v = (t) => {
|
|
31
|
+
if (c.current && t) {
|
|
32
|
+
const e = t.getBoundingClientRect(), r = c.current.getBoundingClientRect();
|
|
33
|
+
h({
|
|
34
|
+
left: `${e.left - r.left}px`,
|
|
31
35
|
width: `${e.width}px`
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
|
-
},
|
|
35
|
-
n[`flexHorizontal-${
|
|
36
|
-
|
|
38
|
+
}, R = [
|
|
39
|
+
n[`flexHorizontal-${m}`],
|
|
40
|
+
o === "button" ? n["tab-items-button"] : n["tab-items"]
|
|
37
41
|
].filter(Boolean).join(" ");
|
|
38
|
-
return
|
|
39
|
-
const t =
|
|
40
|
-
t &&
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
/* @__PURE__ */
|
|
42
|
+
return $(() => {
|
|
43
|
+
const t = _.current[l];
|
|
44
|
+
t && requestAnimationFrame(() => {
|
|
45
|
+
v(t);
|
|
46
|
+
});
|
|
47
|
+
}, [l, i.length]), /* @__PURE__ */ H("div", { className: `tab ${n["tab-container"]} ${n[`tab-container-${o}`]} ${z && n["tab-full-width"]}`, ref: c, children: [
|
|
48
|
+
/* @__PURE__ */ a("div", { className: R, children: i.map((t, e) => /* @__PURE__ */ a(
|
|
45
49
|
"div",
|
|
46
50
|
{
|
|
47
|
-
ref: (
|
|
48
|
-
className:
|
|
49
|
-
children:
|
|
50
|
-
|
|
51
|
+
ref: (r) => _.current[e] = r,
|
|
52
|
+
className: o === "button" && e === l ? n["selected-button"] : "",
|
|
53
|
+
children: o === "icon" ? /* @__PURE__ */ a(
|
|
54
|
+
N,
|
|
51
55
|
{
|
|
52
56
|
mode: "icon",
|
|
53
57
|
size: "s",
|
|
54
|
-
selected: e ===
|
|
55
|
-
onClick: () =>
|
|
58
|
+
selected: e === l,
|
|
59
|
+
onClick: () => b(e),
|
|
56
60
|
children: t
|
|
57
61
|
}
|
|
58
|
-
) : /* @__PURE__ */
|
|
59
|
-
|
|
62
|
+
) : /* @__PURE__ */ a("div", { className: e === l ? n["selected-text"] : void 0, children: /* @__PURE__ */ a(
|
|
63
|
+
C,
|
|
60
64
|
{
|
|
61
65
|
size: "s",
|
|
62
66
|
label: t,
|
|
63
|
-
mode:
|
|
64
|
-
selected: e ===
|
|
65
|
-
onClick: () =>
|
|
67
|
+
mode: o === "text" ? "text" : "ghost",
|
|
68
|
+
selected: e === l,
|
|
69
|
+
onClick: () => b(e)
|
|
66
70
|
}
|
|
67
71
|
) })
|
|
68
72
|
},
|
|
69
73
|
e
|
|
70
74
|
)) }),
|
|
71
|
-
|
|
75
|
+
o !== "button" && /* @__PURE__ */ a("div", { ref: g, className: n.underline, style: x })
|
|
72
76
|
] });
|
|
73
77
|
};
|
|
74
78
|
export {
|
|
75
|
-
|
|
79
|
+
A as Tabs
|
|
76
80
|
};
|
package/dist/styles/Tabs.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._tab-
|
|
1
|
+
._tab-container_1twz4_23{position:relative;line-height:1.25rem}._tab-container-button_1twz4_27{border-radius:.375rem;border:1px solid var(--tabs-button-border);background:var(--tabs-button-background)}._tab-container-icon_1twz4_32,._tab-container-text_1twz4_32{border-bottom:1px solid var(--tabs-line-border)}._tab-items_1twz4_35{gap:2.25rem;padding:.625rem .125rem}._tab-items-button_1twz4_39{gap:.25rem;padding:.125rem}._tab-full-width_1twz4_44{width:100%;display:flex;justify-content:center}._selected-button_1twz4_50{border:1px solid var(--button-tertiary-default-border);background:var(--tabs-button-background-button);border-radius:.25rem}._selected-text_1twz4_56>button{font-weight:600!important}._selected-text_1twz4_56>button:hover{background-color:transparent!important}._underline_1twz4_63{position:absolute;bottom:0;height:2px;background-color:var(--tabs-cell-active-border);transition:all .3s ease}._flexHorizontal-center_1twz4_71{display:flex;justify-content:center;align-items:center;flex-direction:row}._flexHorizontal-left_1twz4_77{display:flex;justify-content:flex-start;align-items:center;flex-direction:row}._flexHorizontal-right_1twz4_83{display:flex;justify-content:flex-end;align-items:center;flex-direction:row}
|