@situaction/traq-ui-ste 1.2.32 → 1.2.33
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/components/tabs/Tabs.js +70 -74
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { IconButton as
|
|
5
|
-
import '../../styles/Tabs.css';const
|
|
1
|
+
import { jsxs as p, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as j, useCallback as A, useEffect as u, useLayoutEffect as F } from "react";
|
|
3
|
+
import { Button as q } from "../button/Button.js";
|
|
4
|
+
import { IconButton as L } from "../icon-button/IconButton.js";
|
|
5
|
+
import '../../styles/Tabs.css';const M = "_underline_1jy9f_82", n = {
|
|
6
6
|
"tab-container": "_tab-container_1jy9f_30",
|
|
7
7
|
"tab-container-button": "_tab-container-button_1jy9f_34",
|
|
8
8
|
"tab-container-icon": "_tab-container-icon_1jy9f_39",
|
|
@@ -14,56 +14,52 @@ import '../../styles/Tabs.css';const q = "_underline_1jy9f_82", n = {
|
|
|
14
14
|
"selected-button": "_selected-button_1jy9f_63",
|
|
15
15
|
"noSelect-button": "_noSelect-button_1jy9f_70",
|
|
16
16
|
"selected-text": "_selected-text_1jy9f_74",
|
|
17
|
-
underline:
|
|
17
|
+
underline: M,
|
|
18
18
|
"flexHorizontal-center": "_flexHorizontal-center_1jy9f_90",
|
|
19
19
|
"flexHorizontal-left": "_flexHorizontal-left_1jy9f_96",
|
|
20
20
|
"flexHorizontal-right": "_flexHorizontal-right_1jy9f_102"
|
|
21
|
-
},
|
|
21
|
+
}, S = (i, o) => {
|
|
22
22
|
if (!Number.isFinite(i)) return 0;
|
|
23
|
-
const
|
|
24
|
-
return Math.min(Math.max(i, 0),
|
|
25
|
-
},
|
|
23
|
+
const d = Math.max(0, o);
|
|
24
|
+
return Math.min(Math.max(i, 0), d);
|
|
25
|
+
}, G = ({
|
|
26
26
|
listItems: i,
|
|
27
27
|
type: o,
|
|
28
|
-
onTabSelect:
|
|
29
|
-
activeTab:
|
|
30
|
-
defaultActiveTab:
|
|
31
|
-
position:
|
|
32
|
-
fullWidth:
|
|
33
|
-
disabledTabs:
|
|
28
|
+
onTabSelect: d,
|
|
29
|
+
activeTab: _,
|
|
30
|
+
defaultActiveTab: m = 0,
|
|
31
|
+
position: v = "left",
|
|
32
|
+
fullWidth: h = !1,
|
|
33
|
+
disabledTabs: z = []
|
|
34
34
|
}) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const l = _ !== void 0, [H, g] = N(m), f = S(
|
|
36
|
+
l ? _ : H,
|
|
37
37
|
(i.length || 1) - 1
|
|
38
|
-
), [
|
|
39
|
-
|
|
40
|
-
},
|
|
38
|
+
), [$, B] = N({}), a = j(null), w = j([]), R = j([]), x = (t) => {
|
|
39
|
+
z.includes(t) || (l || g(t), d(i[t], t));
|
|
40
|
+
}, C = (t) => {
|
|
41
41
|
if (!a.current || !t || o === "button") return;
|
|
42
42
|
const e = a.current.getBoundingClientRect();
|
|
43
43
|
if (e.width === 0) {
|
|
44
|
-
requestAnimationFrame(() =>
|
|
44
|
+
requestAnimationFrame(() => C(t));
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const s = t.getBoundingClientRect();
|
|
48
|
-
|
|
48
|
+
B({
|
|
49
49
|
left: `${s.left - e.left}px`,
|
|
50
50
|
width: `${s.width}px`
|
|
51
51
|
});
|
|
52
|
-
}, r =
|
|
53
|
-
const t =
|
|
54
|
-
requestAnimationFrame(
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
}, [m, o]);
|
|
52
|
+
}, r = A(() => {
|
|
53
|
+
const t = (h ? R.current[f] : null) ?? w.current[f] ?? null;
|
|
54
|
+
requestAnimationFrame(() => requestAnimationFrame(() => C(t)));
|
|
55
|
+
}, [f, o, h]);
|
|
58
56
|
u(() => {
|
|
59
|
-
|
|
60
|
-
}, [
|
|
57
|
+
l && r();
|
|
58
|
+
}, [l, r, _]), F(() => {
|
|
61
59
|
r();
|
|
62
|
-
}, [r,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
}, [_, i.length, c]), u(() => {
|
|
60
|
+
}, [r, v, i.length]), u(() => {
|
|
61
|
+
l || g(S(m, (i.length || 1) - 1));
|
|
62
|
+
}, [m, i.length, l]), u(() => {
|
|
67
63
|
var t, e;
|
|
68
64
|
(e = (t = document.fonts) == null ? void 0 : t.ready) == null || e.then(() => r());
|
|
69
65
|
}, [r]), u(() => {
|
|
@@ -74,65 +70,65 @@ import '../../styles/Tabs.css';const q = "_underline_1jy9f_82", n = {
|
|
|
74
70
|
const t = new ResizeObserver(() => r());
|
|
75
71
|
return t.observe(a.current), () => t.disconnect();
|
|
76
72
|
}, [r]);
|
|
77
|
-
const
|
|
78
|
-
n[`flexHorizontal-${
|
|
73
|
+
const k = [
|
|
74
|
+
n[`flexHorizontal-${v}`],
|
|
79
75
|
o === "button" ? n["tab-items-button"] : n["tab-items"]
|
|
80
76
|
].filter(Boolean).join(" ");
|
|
81
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ p(
|
|
82
78
|
"div",
|
|
83
79
|
{
|
|
84
|
-
className: `tab ${n["tab-container"]} ${n[`tab-container-${o}`]} ${
|
|
80
|
+
className: `tab ${n["tab-container"]} ${n[`tab-container-${o}`]} ${h && n["tab-full-width"]}`,
|
|
85
81
|
ref: a,
|
|
86
82
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
const s =
|
|
89
|
-
return /* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ c("div", { className: k, children: i.map((t, e) => {
|
|
84
|
+
const s = z.includes(e), b = e === f;
|
|
85
|
+
return /* @__PURE__ */ c(
|
|
90
86
|
"div",
|
|
91
87
|
{
|
|
92
|
-
ref: (
|
|
88
|
+
ref: (y) => w.current[e] = y,
|
|
93
89
|
className: [
|
|
94
|
-
o === "button" &&
|
|
90
|
+
o === "button" && b ? n["selected-button"] : n["noSelect-button"],
|
|
95
91
|
typeof t != "string" ? n["noSelect-button"] : "",
|
|
96
92
|
s ? n["tab-disabled"] : ""
|
|
97
93
|
].filter(Boolean).join(" "),
|
|
98
|
-
children:
|
|
99
|
-
|
|
94
|
+
children: /* @__PURE__ */ c(
|
|
95
|
+
"span",
|
|
100
96
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
ref: (y) => R.current[e] = y,
|
|
98
|
+
style: { display: "inline-flex" },
|
|
99
|
+
children: o === "icon" ? /* @__PURE__ */ c(
|
|
100
|
+
L,
|
|
101
|
+
{
|
|
102
|
+
mode: "icon",
|
|
103
|
+
size: "s",
|
|
104
|
+
selected: b,
|
|
105
|
+
onClick: () => x(e),
|
|
106
|
+
disabled: s,
|
|
107
|
+
children: t
|
|
108
|
+
}
|
|
109
|
+
) : o === "button" ? /* @__PURE__ */ c("div", { className: n["tab-type-button"], onClick: () => x(e), children: t }) : /* @__PURE__ */ c("div", { className: b ? n["selected-text"] : void 0, children: /* @__PURE__ */ c(
|
|
110
|
+
q,
|
|
111
|
+
{
|
|
112
|
+
size: "s",
|
|
113
|
+
label: t,
|
|
114
|
+
mode: o === "text" ? "text" : "ghost",
|
|
115
|
+
selected: b,
|
|
116
|
+
onClick: () => x(e),
|
|
117
|
+
disabled: s,
|
|
118
|
+
fullWidth: !0
|
|
119
|
+
}
|
|
120
|
+
) })
|
|
107
121
|
}
|
|
108
|
-
)
|
|
109
|
-
"div",
|
|
110
|
-
{
|
|
111
|
-
className: n["tab-type-button"],
|
|
112
|
-
onClick: () => h(e),
|
|
113
|
-
children: t
|
|
114
|
-
}
|
|
115
|
-
) : /* @__PURE__ */ l("div", { className: f ? n["selected-text"] : void 0, children: /* @__PURE__ */ l(
|
|
116
|
-
F,
|
|
117
|
-
{
|
|
118
|
-
size: "s",
|
|
119
|
-
label: t,
|
|
120
|
-
mode: o === "text" ? "text" : "ghost",
|
|
121
|
-
selected: f,
|
|
122
|
-
onClick: () => h(e),
|
|
123
|
-
disabled: s,
|
|
124
|
-
fullWidth: !0
|
|
125
|
-
}
|
|
126
|
-
) })
|
|
122
|
+
)
|
|
127
123
|
},
|
|
128
124
|
e
|
|
129
125
|
);
|
|
130
126
|
}) }),
|
|
131
|
-
o !== "button" && /* @__PURE__ */
|
|
127
|
+
o !== "button" && /* @__PURE__ */ c("div", { className: n.underline, style: $ })
|
|
132
128
|
]
|
|
133
129
|
}
|
|
134
130
|
);
|
|
135
131
|
};
|
|
136
132
|
export {
|
|
137
|
-
|
|
133
|
+
G as Tabs
|
|
138
134
|
};
|