@situaction/traq-ui-ste 1.2.8 → 1.2.9
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 +77 -66
- package/dist/styles/Tabs.css +1 -1
- package/package.json +1 -1
|
@@ -1,121 +1,132 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as R, useRef as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { IconButton as
|
|
5
|
-
import '../../styles/Tabs.css';const
|
|
6
|
-
"tab-container": "_tab-
|
|
7
|
-
"tab-container-button": "_tab-container-
|
|
8
|
-
"tab-container-icon": "_tab-container-
|
|
9
|
-
"tab-container-text": "_tab-container-
|
|
10
|
-
"tab-items": "_tab-
|
|
11
|
-
"tab-items-button": "_tab-items-
|
|
12
|
-
"tab-
|
|
13
|
-
"
|
|
14
|
-
"selected-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"flexHorizontal-
|
|
19
|
-
|
|
1
|
+
import { jsxs as p, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useRef as C, useEffect as u, useLayoutEffect as y } from "react";
|
|
3
|
+
import { Button as B } from "../button/Button.js";
|
|
4
|
+
import { IconButton as E } from "../icon-button/IconButton.js";
|
|
5
|
+
import '../../styles/Tabs.css';const F = "_underline_1rcir_81", n = {
|
|
6
|
+
"tab-container": "_tab-container_1rcir_30",
|
|
7
|
+
"tab-container-button": "_tab-container-button_1rcir_34",
|
|
8
|
+
"tab-container-icon": "_tab-container-icon_1rcir_39",
|
|
9
|
+
"tab-container-text": "_tab-container-text_1rcir_39",
|
|
10
|
+
"tab-items": "_tab-items_1rcir_42",
|
|
11
|
+
"tab-items-button": "_tab-items-button_1rcir_46",
|
|
12
|
+
"tab-type-button": "_tab-type-button_1rcir_50",
|
|
13
|
+
"tab-full-width": "_tab-full-width_1rcir_56",
|
|
14
|
+
"selected-button": "_selected-button_1rcir_62",
|
|
15
|
+
"noSelect-button": "_noSelect-button_1rcir_69",
|
|
16
|
+
"selected-text": "_selected-text_1rcir_73",
|
|
17
|
+
underline: F,
|
|
18
|
+
"flexHorizontal-center": "_flexHorizontal-center_1rcir_89",
|
|
19
|
+
"flexHorizontal-left": "_flexHorizontal-left_1rcir_95",
|
|
20
|
+
"flexHorizontal-right": "_flexHorizontal-right_1rcir_101"
|
|
21
|
+
}, N = (o, r) => {
|
|
20
22
|
if (!Number.isFinite(o)) return 0;
|
|
21
|
-
const
|
|
22
|
-
return Math.min(Math.max(o, 0),
|
|
23
|
+
const d = Math.max(0, r);
|
|
24
|
+
return Math.min(Math.max(o, 0), d);
|
|
23
25
|
}, D = ({
|
|
24
26
|
listItems: o,
|
|
25
27
|
type: r,
|
|
26
|
-
onTabSelect:
|
|
28
|
+
onTabSelect: d,
|
|
27
29
|
activeTab: _,
|
|
28
30
|
defaultActiveTab: f = 0,
|
|
29
|
-
position:
|
|
30
|
-
fullWidth:
|
|
31
|
+
position: x = "left",
|
|
32
|
+
fullWidth: S = !1,
|
|
31
33
|
disabledTabs: g = []
|
|
32
34
|
}) => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
+
const l = _ !== void 0, [$, v] = R(f), m = N(
|
|
36
|
+
l ? _ : $,
|
|
35
37
|
(o.length || 1) - 1
|
|
36
|
-
), [
|
|
37
|
-
g.includes(t) || (
|
|
38
|
+
), [H, A] = R({}), s = C(null), z = C([]), h = (t) => {
|
|
39
|
+
g.includes(t) || (l || v(t), d(o[t], t));
|
|
38
40
|
}, w = (t) => {
|
|
39
|
-
if (!
|
|
40
|
-
const e =
|
|
41
|
+
if (!s.current || !t || r === "button") return;
|
|
42
|
+
const e = s.current.getBoundingClientRect();
|
|
41
43
|
if (e.width === 0) {
|
|
42
44
|
requestAnimationFrame(() => w(t));
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
left: `${
|
|
48
|
-
width: `${
|
|
47
|
+
const c = t.getBoundingClientRect();
|
|
48
|
+
A({
|
|
49
|
+
left: `${c.left - e.left}px`,
|
|
50
|
+
width: `${c.width}px`
|
|
49
51
|
});
|
|
50
52
|
}, a = () => {
|
|
51
|
-
const t = z.current[
|
|
53
|
+
const t = z.current[m] ?? null;
|
|
52
54
|
requestAnimationFrame(
|
|
53
55
|
() => requestAnimationFrame(() => w(t))
|
|
54
56
|
);
|
|
55
57
|
};
|
|
56
58
|
u(() => {
|
|
57
|
-
|
|
58
|
-
}, [_]),
|
|
59
|
+
l && a();
|
|
60
|
+
}, [_]), y(() => {
|
|
59
61
|
a();
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
}, [f, o.length,
|
|
62
|
+
}, [m, x, o.length]), u(() => {
|
|
63
|
+
l || v(N(f, (o.length || 1) - 1));
|
|
64
|
+
}, [f, o.length, l]), u(() => {
|
|
63
65
|
var t, e;
|
|
64
66
|
(e = (t = document.fonts) == null ? void 0 : t.ready) == null || e.then(() => a());
|
|
65
67
|
}, []), u(() => {
|
|
66
68
|
const t = () => a();
|
|
67
69
|
return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
68
70
|
}, []), u(() => {
|
|
69
|
-
if (!
|
|
71
|
+
if (!s.current) return;
|
|
70
72
|
const t = new ResizeObserver(() => a());
|
|
71
|
-
return t.observe(
|
|
73
|
+
return t.observe(s.current), () => t.disconnect();
|
|
72
74
|
}, []);
|
|
73
|
-
const
|
|
74
|
-
n[`flexHorizontal-${
|
|
75
|
+
const j = [
|
|
76
|
+
n[`flexHorizontal-${x}`],
|
|
75
77
|
r === "button" ? n["tab-items-button"] : n["tab-items"]
|
|
76
78
|
].filter(Boolean).join(" ");
|
|
77
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ p(
|
|
78
80
|
"div",
|
|
79
81
|
{
|
|
80
|
-
className: `tab ${n["tab-container"]} ${n[`tab-container-${r}`]} ${
|
|
81
|
-
ref:
|
|
82
|
+
className: `tab ${n["tab-container"]} ${n[`tab-container-${r}`]} ${S && n["tab-full-width"]}`,
|
|
83
|
+
ref: s,
|
|
82
84
|
children: [
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
const
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ i("div", { className: j, children: o.map((t, e) => {
|
|
86
|
+
const c = g.includes(e), b = e === m;
|
|
87
|
+
return /* @__PURE__ */ i(
|
|
86
88
|
"div",
|
|
87
89
|
{
|
|
88
|
-
ref: (
|
|
89
|
-
className:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
ref: (k) => z.current[e] = k,
|
|
91
|
+
className: [
|
|
92
|
+
r === "button" && b ? n["selected-button"] : n["noSelect-button"],
|
|
93
|
+
typeof t != "string" ? n["noSelect-button"] : "",
|
|
94
|
+
c ? n["tab-disabled"] : ""
|
|
95
|
+
].filter(Boolean).join(" "),
|
|
96
|
+
children: r === "icon" ? /* @__PURE__ */ i(
|
|
97
|
+
E,
|
|
95
98
|
{
|
|
96
99
|
mode: "icon",
|
|
97
100
|
size: "s",
|
|
98
|
-
selected:
|
|
99
|
-
onClick: () =>
|
|
100
|
-
disabled:
|
|
101
|
+
selected: b,
|
|
102
|
+
onClick: () => h(e),
|
|
103
|
+
disabled: c,
|
|
101
104
|
children: t
|
|
102
105
|
}
|
|
103
|
-
) :
|
|
104
|
-
|
|
106
|
+
) : r === "button" ? /* @__PURE__ */ i(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: n["tab-type-button"],
|
|
110
|
+
onClick: () => h(e),
|
|
111
|
+
children: t
|
|
112
|
+
}
|
|
113
|
+
) : /* @__PURE__ */ i("div", { className: `${b ? n["selected-text"] : void 0}`, children: /* @__PURE__ */ i(
|
|
114
|
+
B,
|
|
105
115
|
{
|
|
106
116
|
size: "s",
|
|
107
117
|
label: t,
|
|
108
118
|
mode: r === "text" ? "text" : "ghost",
|
|
109
|
-
selected:
|
|
110
|
-
onClick: () =>
|
|
111
|
-
disabled:
|
|
119
|
+
selected: b,
|
|
120
|
+
onClick: () => h(e),
|
|
121
|
+
disabled: c,
|
|
122
|
+
fullWidth: !0
|
|
112
123
|
}
|
|
113
124
|
) })
|
|
114
125
|
},
|
|
115
126
|
e
|
|
116
127
|
);
|
|
117
128
|
}) }),
|
|
118
|
-
r !== "button" && /* @__PURE__ */
|
|
129
|
+
r !== "button" && /* @__PURE__ */ i("div", { className: n.underline, style: H })
|
|
119
130
|
]
|
|
120
131
|
}
|
|
121
132
|
);
|
package/dist/styles/Tabs.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._tab-
|
|
1
|
+
._tab-container_1rcir_30{position:relative;line-height:1.25rem}._tab-container-button_1rcir_34{border-radius:.375rem;border:1px solid var(--tabs-button-border);background:var(--tabs-button-background)}._tab-container-icon_1rcir_39,._tab-container-text_1rcir_39{border-bottom:1px solid var(--tabs-line-border)}._tab-items_1rcir_42{gap:2.25rem;padding:.625rem .125rem}._tab-items-button_1rcir_46{gap:.25rem;padding:.125rem}._tab-type-button_1rcir_50{padding:.375rem .75rem;display:flex;align-items:center}._tab-full-width_1rcir_56{width:100%;display:flex;justify-content:center}._selected-button_1rcir_62{height:100%;border:1px solid var(--button-tertiary-default-border);background:var(--tabs-button-background-button);border-radius:.25rem}._noSelect-button_1rcir_69{padding:1px 0}._selected-text_1rcir_73>button{height:100%;font-weight:600!important}._selected-text_1rcir_73>button:hover{background-color:transparent!important}._underline_1rcir_81{position:absolute;bottom:0;height:2px;background-color:var(--tabs-cell-active-border);transition:all .3s ease}._flexHorizontal-center_1rcir_89{display:flex;justify-content:center;align-items:center;flex-direction:row}._flexHorizontal-left_1rcir_95{display:flex;justify-content:flex-start;align-items:center;flex-direction:row}._flexHorizontal-right_1rcir_101{display:flex;justify-content:flex-end;align-items:center;flex-direction:row}
|