@situaction/traq-ui-ste 1.2.31 → 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.
|
@@ -4,7 +4,7 @@ import * as PhosphorIcons from "@phosphor-icons/react";
|
|
|
4
4
|
export type SelectItem = {
|
|
5
5
|
label?: string;
|
|
6
6
|
icon?: keyof typeof PhosphorIcons | null;
|
|
7
|
-
|
|
7
|
+
iconSize?: number;
|
|
8
8
|
value: string;
|
|
9
9
|
};
|
|
10
10
|
export interface SelectProps {
|
|
@@ -40,10 +40,11 @@ export interface SelectProps {
|
|
|
40
40
|
/** Enable a search input inside the select modal to filter options **/
|
|
41
41
|
searchable?: boolean;
|
|
42
42
|
fullWidth?: boolean;
|
|
43
|
+
iconSize?: number;
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Select component that allows users to choose an option from a list.
|
|
46
47
|
* It supports three display modes: 'all' (icon + text), 'icon' (only icon), and 'text' (only text).
|
|
47
48
|
* The selected value is displayed in a button, and a modal opens to show the list of options.
|
|
48
49
|
*/
|
|
49
|
-
export declare const Select: ({ selected, size, listItem, modeDisplay, onSelect, positionOverride, placeholder, searchPlaceholder, autoCloseCondition, searchable, fullWidth }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const Select: ({ selected, size, listItem, modeDisplay, onSelect, positionOverride, placeholder, searchPlaceholder, autoCloseCondition, searchable, fullWidth, iconSize }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
import { jsxs as L, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useState as y, useRef as v, useEffect as d } from "react";
|
|
3
3
|
import { Button as W } from "../button/Button.js";
|
|
4
|
-
import { Input as
|
|
5
|
-
import { IconButton as
|
|
4
|
+
import { Input as H } from "../input/Input.js";
|
|
5
|
+
import { IconButton as J } from "../icon-button/IconButton.js";
|
|
6
6
|
import "../accordion/Accordion.js";
|
|
7
7
|
import { Icon as _ } from "../icon/Icon.js";
|
|
8
|
-
import { Modal as
|
|
8
|
+
import { Modal as Q } from "../modal/Modal.js";
|
|
9
9
|
import "../carousel/Carousel.js";
|
|
10
10
|
import "../carousel/FadeCarousel.js";
|
|
11
11
|
import "../theme/ThemeContext.js";
|
|
12
12
|
import '../../styles/Size.css';import '../../styles/Select.css';/* empty css */
|
|
13
|
-
const
|
|
14
|
-
selectContainer:
|
|
15
|
-
children:
|
|
16
|
-
active:
|
|
17
|
-
selectList:
|
|
18
|
-
modal:
|
|
19
|
-
itemLabel:
|
|
20
|
-
searchWrapper:
|
|
21
|
-
noResults:
|
|
22
|
-
},
|
|
13
|
+
const X = "_selectContainer_133eb_54", Y = "_children_133eb_61", Z = "_active_133eb_78", O = "_selectList_133eb_82", I = "_modal_133eb_91", ee = "_itemLabel_133eb_98", te = "_searchWrapper_133eb_103", ne = "_noResults_133eb_109", f = {
|
|
14
|
+
selectContainer: X,
|
|
15
|
+
children: Y,
|
|
16
|
+
active: Z,
|
|
17
|
+
selectList: O,
|
|
18
|
+
modal: I,
|
|
19
|
+
itemLabel: ee,
|
|
20
|
+
searchWrapper: te,
|
|
21
|
+
noResults: ne
|
|
22
|
+
}, pe = ({
|
|
23
23
|
selected: k,
|
|
24
24
|
size: g = "m",
|
|
25
25
|
listItem: h,
|
|
26
26
|
modeDisplay: E = "all",
|
|
27
|
-
onSelect:
|
|
27
|
+
onSelect: z,
|
|
28
28
|
positionOverride: b,
|
|
29
29
|
placeholder: x = "Sélectionner",
|
|
30
30
|
searchPlaceholder: U,
|
|
31
31
|
autoCloseCondition: w,
|
|
32
32
|
searchable: V = !1,
|
|
33
|
-
fullWidth:
|
|
33
|
+
fullWidth: S = !1,
|
|
34
|
+
iconSize: A = 20
|
|
34
35
|
}) => {
|
|
35
|
-
const [t, l] = y(!1), [
|
|
36
|
+
const [t, l] = y(!1), [F, B] = y({
|
|
36
37
|
top: "calc(100% + 6px)",
|
|
37
38
|
left: "0px"
|
|
38
|
-
}), [n,
|
|
39
|
+
}), [n, T] = y(k ?? null), [K, M] = y(""), u = v(null), $ = v(null), N = v(null), P = v({}), j = v({}), p = v(null);
|
|
39
40
|
d(() => {
|
|
40
|
-
|
|
41
|
+
T(k || null);
|
|
41
42
|
}, [k]), d(() => {
|
|
42
|
-
b &&
|
|
43
|
+
b && B(b);
|
|
43
44
|
}, [b]);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
},
|
|
45
|
+
const q = (e) => {
|
|
46
|
+
T(e), l(!1), z && z(e);
|
|
47
|
+
}, G = () => {
|
|
47
48
|
const e = n == null ? void 0 : n.icon, r = (n == null ? void 0 : n.label) ?? x;
|
|
48
|
-
return E === "icon" && e ? /* @__PURE__ */ s(
|
|
49
|
+
return E === "icon" && e ? /* @__PURE__ */ s(J, { ref: u, mode: "tertiary", size: g, onClick: () => l(!t), children: /* @__PURE__ */ s(_, { size: A, icon: n.icon }) }) : E === "text" ? /* @__PURE__ */ s(
|
|
49
50
|
W,
|
|
50
51
|
{
|
|
51
52
|
ref: u,
|
|
@@ -53,7 +54,7 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
53
54
|
label: n ? r : x,
|
|
54
55
|
childrenRight: /* @__PURE__ */ s(_, { icon: t ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
|
|
55
56
|
size: g,
|
|
56
|
-
fullWidth:
|
|
57
|
+
fullWidth: S,
|
|
57
58
|
onClick: () => l(!t),
|
|
58
59
|
"aria-expanded": t,
|
|
59
60
|
"aria-haspopup": "listbox"
|
|
@@ -65,7 +66,7 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
65
66
|
mode: "tertiary",
|
|
66
67
|
label: n ? r : x,
|
|
67
68
|
size: g,
|
|
68
|
-
fullWidth:
|
|
69
|
+
fullWidth: S,
|
|
69
70
|
childrenLeft: e && /* @__PURE__ */ s(_, { icon: n.icon }),
|
|
70
71
|
childrenRight: /* @__PURE__ */ s(_, { icon: t ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
|
|
71
72
|
onClick: () => l(!t),
|
|
@@ -77,7 +78,7 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
77
78
|
{
|
|
78
79
|
ref: u,
|
|
79
80
|
mode: "tertiary",
|
|
80
|
-
fullWidth:
|
|
81
|
+
fullWidth: S,
|
|
81
82
|
label: x ?? "Sélectionner",
|
|
82
83
|
size: g,
|
|
83
84
|
onClick: () => l(!t),
|
|
@@ -86,7 +87,7 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
86
87
|
}
|
|
87
88
|
);
|
|
88
89
|
}, D = h.filter(
|
|
89
|
-
(e) => String(e.label ?? "").toLowerCase().includes(
|
|
90
|
+
(e) => String(e.label ?? "").toLowerCase().includes(K.toLowerCase())
|
|
90
91
|
), [C, R] = y("");
|
|
91
92
|
return d(() => {
|
|
92
93
|
if (t) {
|
|
@@ -146,12 +147,12 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
146
147
|
}, [t, h]), d(() => {
|
|
147
148
|
if (t && u.current) {
|
|
148
149
|
const e = u.current.getBoundingClientRect().height;
|
|
149
|
-
|
|
150
|
+
B(b || { top: `${e + 6}px`, left: "0px" });
|
|
150
151
|
}
|
|
151
152
|
}, [t, b]), d(() => {
|
|
152
153
|
if (!t || !w) return;
|
|
153
154
|
const e = (r) => {
|
|
154
|
-
const c = r.target, i = u.current, o =
|
|
155
|
+
const c = r.target, i = u.current, o = $.current;
|
|
155
156
|
i && i.contains(c) || o && o.contains(c) || l(!1);
|
|
156
157
|
};
|
|
157
158
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), () => {
|
|
@@ -164,28 +165,28 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
164
165
|
};
|
|
165
166
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
166
167
|
}, [t, w]), /* @__PURE__ */ L("div", { className: f.selectContainer, children: [
|
|
167
|
-
|
|
168
|
+
G(),
|
|
168
169
|
/* @__PURE__ */ s(
|
|
169
|
-
|
|
170
|
+
Q,
|
|
170
171
|
{
|
|
171
172
|
anchorRef: u,
|
|
172
173
|
open: t,
|
|
173
174
|
onClose: () => l(!1),
|
|
174
|
-
position:
|
|
175
|
+
position: F,
|
|
175
176
|
disableOverlay: !0,
|
|
176
177
|
className: f.modal,
|
|
177
178
|
autoCloseCondition: w,
|
|
178
|
-
children: /* @__PURE__ */ L("div", { ref:
|
|
179
|
+
children: /* @__PURE__ */ L("div", { ref: $, children: [
|
|
179
180
|
V && /* @__PURE__ */ L("div", { children: [
|
|
180
181
|
/* @__PURE__ */ s(
|
|
181
|
-
|
|
182
|
+
H,
|
|
182
183
|
{
|
|
183
184
|
type: "text",
|
|
184
185
|
placeholder: U,
|
|
185
186
|
status: "ghost",
|
|
186
187
|
sizeStyle: "s",
|
|
187
|
-
value:
|
|
188
|
-
onChange: (e) =>
|
|
188
|
+
value: K,
|
|
189
|
+
onChange: (e) => M(e.target.value)
|
|
189
190
|
}
|
|
190
191
|
),
|
|
191
192
|
/* @__PURE__ */ s("div", { className: f.searchWrapper })
|
|
@@ -196,11 +197,11 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
196
197
|
{
|
|
197
198
|
ref: (r) => j.current[e.value] = r,
|
|
198
199
|
className: `${f.children} ${(n == null ? void 0 : n.value) === e.value ? f.active : ""}`,
|
|
199
|
-
onClick: () =>
|
|
200
|
+
onClick: () => q(e),
|
|
200
201
|
role: "option",
|
|
201
202
|
"aria-selected": (n == null ? void 0 : n.value) === e.value,
|
|
202
203
|
children: [
|
|
203
|
-
e.icon && /* @__PURE__ */ s(_, { icon: e.icon, size: e.
|
|
204
|
+
e.icon && /* @__PURE__ */ s(_, { icon: e.icon, size: e.iconSize ? e.iconSize : 16 }),
|
|
204
205
|
e.label && /* @__PURE__ */ s("div", { className: f.itemLabel, children: e.label })
|
|
205
206
|
]
|
|
206
207
|
},
|
|
@@ -214,5 +215,5 @@ const J = "_selectContainer_133eb_54", Q = "_children_133eb_61", X = "_active_13
|
|
|
214
215
|
] });
|
|
215
216
|
};
|
|
216
217
|
export {
|
|
217
|
-
|
|
218
|
+
pe as Select
|
|
218
219
|
};
|
|
@@ -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
|
};
|