@situaction/traq-ui-ste 1.2.31 → 1.2.32
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
|
};
|