@situaction/traq-ui-ste 1.2.30 → 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,6 +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
+ iconSize?: number;
7
8
  value: string;
8
9
  };
9
10
  export interface SelectProps {
@@ -39,10 +40,11 @@ export interface SelectProps {
39
40
  /** Enable a search input inside the select modal to filter options **/
40
41
  searchable?: boolean;
41
42
  fullWidth?: boolean;
43
+ iconSize?: number;
42
44
  }
43
45
  /**
44
46
  * Select component that allows users to choose an option from a list.
45
47
  * It supports three display modes: 'all' (icon + text), 'icon' (only icon), and 'text' (only text).
46
48
  * The selected value is displayed in a button, and a modal opens to show the list of options.
47
49
  */
48
- 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 G } from "../input/Input.js";
5
- import { IconButton as H } from "../icon-button/IconButton.js";
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 J } from "../modal/Modal.js";
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 Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_133eb_78", Z = "_selectList_133eb_82", O = "_modal_133eb_91", I = "_itemLabel_133eb_98", ee = "_searchWrapper_133eb_103", te = "_noResults_133eb_109", f = {
14
- selectContainer: Q,
15
- children: X,
16
- active: Y,
17
- selectList: Z,
18
- modal: O,
19
- itemLabel: I,
20
- searchWrapper: ee,
21
- noResults: te
22
- }, me = ({
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: B,
27
+ onSelect: z,
28
28
  positionOverride: b,
29
29
  placeholder: x = "Sélectionner",
30
- searchPlaceholder: V,
30
+ searchPlaceholder: U,
31
31
  autoCloseCondition: w,
32
- searchable: z = !1,
33
- fullWidth: T = !1
32
+ searchable: V = !1,
33
+ fullWidth: S = !1,
34
+ iconSize: A = 20
34
35
  }) => {
35
- const [t, l] = y(!1), [A, K] = y({
36
+ const [t, l] = y(!1), [F, B] = y({
36
37
  top: "calc(100% + 6px)",
37
38
  left: "0px"
38
- }), [n, S] = y(k ?? null), [$, F] = y(""), u = v(null), j = v(null), N = v(null), P = v({}), D = v({}), p = v(null);
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
- S(k || null);
41
+ T(k || null);
41
42
  }, [k]), d(() => {
42
- b && K(b);
43
+ b && B(b);
43
44
  }, [b]);
44
- const M = (e) => {
45
- S(e), l(!1), B && B(e);
46
- }, q = () => {
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(H, { ref: u, mode: "tertiary", size: g, onClick: () => l(!t), children: /* @__PURE__ */ s(_, { icon: n.icon }) }) : E === "text" ? /* @__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 Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_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: T,
57
+ fullWidth: S,
57
58
  onClick: () => l(!t),
58
59
  "aria-expanded": t,
59
60
  "aria-haspopup": "listbox"
@@ -65,7 +66,7 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
65
66
  mode: "tertiary",
66
67
  label: n ? r : x,
67
68
  size: g,
68
- fullWidth: T,
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 Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
77
78
  {
78
79
  ref: u,
79
80
  mode: "tertiary",
80
- fullWidth: T,
81
+ fullWidth: S,
81
82
  label: x ?? "Sélectionner",
82
83
  size: g,
83
84
  onClick: () => l(!t),
@@ -85,8 +86,8 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
85
86
  "aria-haspopup": "listbox"
86
87
  }
87
88
  );
88
- }, U = h.filter(
89
- (e) => String(e.label ?? "").toLowerCase().includes($.toLowerCase())
89
+ }, D = h.filter(
90
+ (e) => String(e.label ?? "").toLowerCase().includes(K.toLowerCase())
90
91
  ), [C, R] = y("");
91
92
  return d(() => {
92
93
  if (t) {
@@ -137,7 +138,7 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
137
138
  return (a = o.label) == null ? void 0 : a.toLowerCase().startsWith(c);
138
139
  });
139
140
  if (i) {
140
- const o = D.current[i.value];
141
+ const o = j.current[i.value];
141
142
  o && o.scrollIntoView({ block: "start", behavior: "smooth" });
142
143
  }
143
144
  }
@@ -146,12 +147,12 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
146
147
  }, [t, h]), d(() => {
147
148
  if (t && u.current) {
148
149
  const e = u.current.getBoundingClientRect().height;
149
- K(b || { top: `${e + 6}px`, left: "0px" });
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 = j.current;
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,49 +165,49 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_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
- q(),
168
+ G(),
168
169
  /* @__PURE__ */ s(
169
- J,
170
+ Q,
170
171
  {
171
172
  anchorRef: u,
172
173
  open: t,
173
174
  onClose: () => l(!1),
174
- position: A,
175
+ position: F,
175
176
  disableOverlay: !0,
176
177
  className: f.modal,
177
178
  autoCloseCondition: w,
178
- children: /* @__PURE__ */ L("div", { ref: j, children: [
179
- z && /* @__PURE__ */ L("div", { children: [
179
+ children: /* @__PURE__ */ L("div", { ref: $, children: [
180
+ V && /* @__PURE__ */ L("div", { children: [
180
181
  /* @__PURE__ */ s(
181
- G,
182
+ H,
182
183
  {
183
184
  type: "text",
184
- placeholder: V,
185
+ placeholder: U,
185
186
  status: "ghost",
186
187
  sizeStyle: "s",
187
- value: $,
188
- onChange: (e) => F(e.target.value)
188
+ value: K,
189
+ onChange: (e) => M(e.target.value)
189
190
  }
190
191
  ),
191
192
  /* @__PURE__ */ s("div", { className: f.searchWrapper })
192
193
  ] }),
193
194
  /* @__PURE__ */ L("div", { className: f.selectList, ref: N, children: [
194
- U.map((e) => /* @__PURE__ */ L(
195
+ D.map((e) => /* @__PURE__ */ L(
195
196
  "div",
196
197
  {
197
- ref: (r) => D.current[e.value] = r,
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: () => M(e),
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: 16 }),
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
  },
207
208
  e.value
208
209
  )),
209
- U.length === 0 && /* @__PURE__ */ s("div", { className: `${f.noResults} textSmall`, children: "Aucun résultat" })
210
+ D.length === 0 && /* @__PURE__ */ s("div", { className: `${f.noResults} textSmall`, children: "Aucun résultat" })
210
211
  ] })
211
212
  ] })
212
213
  }
@@ -214,5 +215,5 @@ const Q = "_selectContainer_133eb_54", X = "_children_133eb_61", Y = "_active_13
214
215
  ] });
215
216
  };
216
217
  export {
217
- me as Select
218
+ pe as Select
218
219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situaction/traq-ui-ste",
3
- "version": "1.2.30",
3
+ "version": "1.2.32",
4
4
  "description": "library react component Situaction",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",