@situaction/traq-ui-ste 1.2.1 → 1.2.2

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.
@@ -32,8 +32,11 @@ export interface SelectProps {
32
32
  };
33
33
  /** Text displayed when no item is selected */
34
34
  placeholder?: string;
35
+ searchPlaceholder?: string;
35
36
  /** Condition to close the modal */
36
37
  autoCloseCondition: boolean;
38
+ /** Enable a search input inside the select modal to filter options */
39
+ searchable?: boolean;
37
40
  fullWidth?: boolean;
38
41
  }
39
42
  /**
@@ -41,4 +44,4 @@ export interface SelectProps {
41
44
  * It supports three display modes: 'all' (icon + text), 'icon' (only icon), and 'text' (only text).
42
45
  * The selected value is displayed in a button, and a modal opens to show the list of options.
43
46
  */
44
- export declare const Select: ({ selected, size, listItem, modeDisplay, onSelect, positionOverride, placeholder, autoCloseCondition, fullWidth }: SelectProps) => import("react/jsx-runtime").JSX.Element;
47
+ export declare const Select: ({ selected, size, listItem, modeDisplay, onSelect, positionOverride, placeholder, searchPlaceholder, autoCloseCondition, searchable, fullWidth }: SelectProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,181 +1,210 @@
1
- import { jsxs as $, jsx as r } from "react/jsx-runtime";
2
- import { useState as g, useRef as h, useEffect as w } from "react";
3
- import { Button as N } from "../button/Button.js";
4
- import { IconButton as q } from "../icon-button/IconButton.js";
1
+ import { jsxs as w, jsx as o } from "react/jsx-runtime";
2
+ import { useState as b, useRef as m, useEffect as p } from "react";
3
+ import { Button as W } from "../button/Button.js";
4
+ import { Input as H } from "../input/Input.js";
5
+ import { IconButton as I } from "../icon-button/IconButton.js";
5
6
  import { Icon as _ } from "../icon/Icon.js";
6
- import { Modal as z } from "../modal/Modal.js";
7
+ import { Modal as J } from "../modal/Modal.js";
7
8
  import "../theme/ThemeContext.js";
8
9
  import '../../styles/Size.css';import '../../styles/Select.css';/* empty css */
9
- const A = "_selectContainer_1o5wx_54", D = "_selected_1o5wx_57", G = "_children_1o5wx_61", H = "_active_1o5wx_78", J = "_selectList_1o5wx_82", O = "_modal_1o5wx_91", Q = "_dropdownFadeIn_1o5wx_1", X = "_itemLabel_1o5wx_98", m = {
10
- selectContainer: A,
11
- selected: D,
12
- children: G,
13
- active: H,
14
- selectList: J,
15
- modal: O,
16
- dropdownFadeIn: Q,
17
- itemLabel: X
18
- }, ce = ({
19
- selected: b,
20
- size: p = "m",
10
+ const O = "_selectContainer_133eb_54", Q = "_selected_133eb_57", X = "_children_133eb_61", Y = "_active_133eb_78", Z = "_selectList_133eb_82", ee = "_modal_133eb_91", te = "_dropdownFadeIn_133eb_1", ne = "_itemLabel_133eb_98", re = "_searchWrapper_133eb_103", oe = "_noResults_133eb_109", u = {
11
+ selectContainer: O,
12
+ selected: Q,
13
+ children: X,
14
+ active: Y,
15
+ selectList: Z,
16
+ modal: ee,
17
+ dropdownFadeIn: te,
18
+ itemLabel: ne,
19
+ searchWrapper: re,
20
+ noResults: oe
21
+ }, me = ({
22
+ selected: L,
23
+ size: C = "m",
21
24
  listItem: s,
22
- modeDisplay: R = "all",
25
+ modeDisplay: x = "all",
23
26
  onSelect: B,
24
- positionOverride: L,
25
- placeholder: P = "Sélectionner",
26
- autoCloseCondition: j,
27
- fullWidth: T = !1
27
+ positionOverride: y,
28
+ placeholder: F = "Sélectionner",
29
+ searchPlaceholder: U,
30
+ autoCloseCondition: V,
31
+ searchable: z = !1,
32
+ fullWidth: S = !1
28
33
  }) => {
29
- const [n, u] = g(!1), U = h(null), [V, F] = g({
34
+ const [t, f] = b(!1), A = m(null), [M, P] = b({
30
35
  top: "calc(100% + 6px)",
31
36
  left: "0px"
32
- }), [c, C] = g(b ?? null);
33
- w(() => {
34
- b ? C(b) : s.length > 0 ? C(s[0]) : C(null);
35
- }, [b, s]), w(() => {
36
- L && F(L);
37
- }, [L]);
38
- const M = (e) => {
39
- C(e), u(!1), B && B(e);
40
- }, W = () => {
41
- const e = c == null ? void 0 : c.icon, o = (c == null ? void 0 : c.label) || P || "Sélectionner";
42
- return R === "icon" && e ? /* @__PURE__ */ r(q, { ref: d, mode: "tertiary", size: p, onClick: () => u(!n), children: /* @__PURE__ */ r(_, { icon: c.icon }) }) : R === "text" ? /* @__PURE__ */ r(
43
- N,
37
+ }), [c, k] = b(L ?? null), [$, q] = b("");
38
+ p(() => {
39
+ L ? k(L) : s.length > 0 ? k(s[0]) : k(null);
40
+ }, [L, s]), p(() => {
41
+ y && P(y);
42
+ }, [y]);
43
+ const D = (e) => {
44
+ k(e), f(!1), B && B(e);
45
+ }, G = () => {
46
+ const e = c == null ? void 0 : c.icon, n = (c == null ? void 0 : c.label) || F || "Sélectionner";
47
+ return x === "icon" && e ? /* @__PURE__ */ o(I, { ref: d, mode: "tertiary", size: C, onClick: () => f(!t), children: /* @__PURE__ */ o(_, { icon: c.icon }) }) : x === "text" ? /* @__PURE__ */ o(
48
+ W,
44
49
  {
45
50
  ref: d,
46
51
  mode: "tertiary",
47
- label: o,
48
- childrenRight: /* @__PURE__ */ r(_, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
49
- size: p,
50
- fullWidth: T,
51
- onClick: () => u(!n)
52
+ label: n,
53
+ childrenRight: /* @__PURE__ */ o(_, { icon: t ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
54
+ size: C,
55
+ fullWidth: S,
56
+ onClick: () => f(!t)
52
57
  }
53
- ) : R === "all" ? /* @__PURE__ */ r(
54
- N,
58
+ ) : x === "all" ? /* @__PURE__ */ o(
59
+ W,
55
60
  {
56
61
  ref: d,
57
62
  mode: "tertiary",
58
- label: o,
59
- size: p,
60
- fullWidth: T,
61
- childrenLeft: e && /* @__PURE__ */ r(_, { icon: c.icon }),
62
- childrenRight: /* @__PURE__ */ r(_, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
63
- onClick: () => u(!n)
63
+ label: n,
64
+ size: C,
65
+ fullWidth: S,
66
+ childrenLeft: e && /* @__PURE__ */ o(_, { icon: c.icon }),
67
+ childrenRight: /* @__PURE__ */ o(_, { icon: t ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
68
+ onClick: () => f(!t)
64
69
  }
65
- ) : /* @__PURE__ */ r(
66
- N,
70
+ ) : /* @__PURE__ */ o(
71
+ W,
67
72
  {
68
73
  ref: d,
69
74
  mode: "tertiary",
70
- fullWidth: T,
71
- label: P ?? "Sélectionner",
72
- size: p,
73
- onClick: () => u(!n)
75
+ fullWidth: S,
76
+ label: F ?? "Sélectionner",
77
+ size: C,
78
+ onClick: () => f(!t)
74
79
  }
75
80
  );
76
- }, E = h(null), k = h({}), [y, v] = g(""), f = h(null), K = h({}), S = (e) => {
81
+ }, E = m(null), g = m({}), [R, v] = b(""), h = m(null), K = m({}), j = s.filter(
82
+ (e) => {
83
+ var n;
84
+ return (n = e.label) == null ? void 0 : n.toLowerCase().includes($.toLowerCase());
85
+ }
86
+ ), N = (e) => {
87
+ if (!t) return;
88
+ const n = e.key.length === 1 ? e.key.toLowerCase() : "";
77
89
  if (!n) return;
78
- const o = e.key.length === 1 ? e.key.toLowerCase() : "";
79
- if (!o) return;
80
- const a = y + o;
90
+ const a = R + n;
81
91
  v(a);
82
- const i = s.find((t) => {
92
+ const i = s.find((r) => {
83
93
  var l;
84
- return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(a);
94
+ return (l = r.label) == null ? void 0 : l.toLowerCase().startsWith(a);
85
95
  });
86
96
  if (i) {
87
- const t = k.current[i.value];
88
- t == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
97
+ const r = g.current[i.value];
98
+ r == null || r.scrollIntoView({ behavior: "smooth", block: "nearest" });
89
99
  }
90
- f.current && clearTimeout(f.current), f.current = setTimeout(() => {
100
+ h.current && clearTimeout(h.current), h.current = setTimeout(() => {
91
101
  v("");
92
102
  }, 500);
93
103
  };
94
- w(() => (n ? window.addEventListener("keydown", S) : (window.removeEventListener("keydown", S), v("")), () => {
95
- window.removeEventListener("keydown", S);
96
- }), [n, y, s]), w(() => {
97
- const e = (o) => {
98
- if (!n) return;
99
- const a = o.key.length === 1 ? o.key.toLowerCase() : "";
104
+ p(() => (t ? window.addEventListener("keydown", N) : (window.removeEventListener("keydown", N), v("")), () => {
105
+ window.removeEventListener("keydown", N);
106
+ }), [t, R, s]), p(() => {
107
+ const e = (n) => {
108
+ if (!t) return;
109
+ const a = n.key.length === 1 ? n.key.toLowerCase() : "";
100
110
  if (!a) return;
101
- const i = y + a;
111
+ const i = R + a;
102
112
  v(i);
103
- const t = s.find(
113
+ const r = s.find(
104
114
  (l) => {
105
- var x;
106
- return (x = l.label) == null ? void 0 : x.toLowerCase().startsWith(i);
115
+ var T;
116
+ return (T = l.label) == null ? void 0 : T.toLowerCase().startsWith(i);
107
117
  }
108
118
  );
109
- if (t && E.current && t.value in k.current && k.current[t.value]) {
110
- const l = E.current, x = k.current[t.value];
119
+ if (r && E.current && r.value in g.current && g.current[r.value]) {
120
+ const l = E.current, T = g.current[r.value];
111
121
  l.scrollTo({
112
- top: x.offsetTop - l.offsetTop,
122
+ top: T.offsetTop - l.offsetTop,
113
123
  behavior: "smooth"
114
124
  });
115
125
  }
116
- f.current && clearTimeout(f.current), f.current = setTimeout(() => {
126
+ h.current && clearTimeout(h.current), h.current = setTimeout(() => {
117
127
  v("");
118
128
  }, 700);
119
129
  };
120
130
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
121
- }, [n, s, y]), w(() => {
122
- if (!n) return;
123
- const e = (o) => {
124
- const a = o.key.toLowerCase();
131
+ }, [t, s, R]), p(() => {
132
+ if (!t) return;
133
+ const e = (n) => {
134
+ const a = n.key.toLowerCase();
125
135
  if (a.length === 1) {
126
136
  const i = s.find(
127
- (t) => {
137
+ (r) => {
128
138
  var l;
129
- return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(a);
139
+ return (l = r.label) == null ? void 0 : l.toLowerCase().startsWith(a);
130
140
  }
131
141
  );
132
142
  if (i) {
133
- const t = K.current[i.value];
134
- t && t.scrollIntoView({ block: "start", behavior: "smooth" });
143
+ const r = K.current[i.value];
144
+ r && r.scrollIntoView({ block: "start", behavior: "smooth" });
135
145
  }
136
146
  }
137
147
  };
138
148
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
139
- }, [n, s]);
140
- const d = h(null);
141
- return w(() => {
142
- if (n && d.current) {
149
+ }, [t, s]);
150
+ const d = m(null);
151
+ return p(() => {
152
+ if (t && d.current) {
143
153
  const e = d.current.getBoundingClientRect().height;
144
- F(L || {
154
+ P(y || {
145
155
  top: `${e + 6}px`,
146
156
  left: "0px"
147
157
  });
148
158
  }
149
- }, [n]), /* @__PURE__ */ $("div", { className: m.selectContainer, children: [
150
- W(),
151
- /* @__PURE__ */ r(
152
- z,
159
+ }, [t]), /* @__PURE__ */ w("div", { className: u.selectContainer, children: [
160
+ G(),
161
+ /* @__PURE__ */ o(
162
+ J,
153
163
  {
154
- ref: U,
164
+ ref: A,
155
165
  anchorRef: d,
156
- open: n,
157
- onClose: () => u(!1),
158
- position: V,
166
+ open: t,
167
+ onClose: () => f(!1),
168
+ position: M,
159
169
  disableOverlay: !0,
160
- className: m.modal,
161
- autoCloseCondition: j,
162
- children: /* @__PURE__ */ r("div", { className: m.selectList, ref: E, children: s.map((e) => /* @__PURE__ */ $(
163
- "div",
164
- {
165
- ref: (o) => K.current[e.value] = o,
166
- className: `${m.children} ${(c == null ? void 0 : c.value) === e.value ? m.active : ""}`,
167
- onClick: () => M(e),
168
- children: [
169
- e.icon && /* @__PURE__ */ r(_, { icon: e.icon, size: 16 }),
170
- e.label && /* @__PURE__ */ r("div", { className: m.itemLabel, children: e.label })
171
- ]
172
- },
173
- e.value
174
- )) })
170
+ className: u.modal,
171
+ autoCloseCondition: V,
172
+ children: /* @__PURE__ */ w("div", { children: [
173
+ z && /* @__PURE__ */ w("div", { children: [
174
+ /* @__PURE__ */ o(
175
+ H,
176
+ {
177
+ type: "text",
178
+ placeholder: U,
179
+ status: "ghost",
180
+ sizeStyle: "s",
181
+ value: $,
182
+ onChange: (e) => q(e.target.value)
183
+ }
184
+ ),
185
+ /* @__PURE__ */ o("div", { className: u.searchWrapper })
186
+ ] }),
187
+ /* @__PURE__ */ w("div", { className: u.selectList, ref: E, children: [
188
+ j.map((e) => /* @__PURE__ */ w(
189
+ "div",
190
+ {
191
+ ref: (n) => K.current[e.value] = n,
192
+ className: `${u.children} ${(c == null ? void 0 : c.value) === e.value ? u.active : ""}`,
193
+ onClick: () => D(e),
194
+ children: [
195
+ e.icon && /* @__PURE__ */ o(_, { icon: e.icon, size: 16 }),
196
+ e.label && /* @__PURE__ */ o("div", { className: u.itemLabel, children: e.label })
197
+ ]
198
+ },
199
+ e.value
200
+ )),
201
+ j.length === 0 && /* @__PURE__ */ o("div", { className: `${u.noResults} textSmall`, children: "Aucun résultat" })
202
+ ] })
203
+ ] })
175
204
  }
176
205
  )
177
206
  ] });
178
207
  };
179
208
  export {
180
- ce as Select
209
+ me as Select
181
210
  };
@@ -1 +1 @@
1
- ._selectContainer_1o5wx_54{position:relative}._selectContainer_1o5wx_54 ._selected_1o5wx_57{background:var(--button-tertiary-pressed-background);border-radius:var(--spacing-xs-6)}._selectContainer_1o5wx_54 ._children_1o5wx_61{padding:var(--spacing-xs-6) var(--spacing-xs-5);box-sizing:border-box;width:100%;gap:.5rem;cursor:pointer;font-style:normal;line-height:1.25rem;display:flex;justify-content:flex-start;align-items:center;flex-direction:row}._selectContainer_1o5wx_54 ._children_1o5wx_61:hover{background:var(--dropdown-line-background-hover);border-radius:var(--spacing-xs-6)}._selectContainer_1o5wx_54 ._children_1o5wx_61._active_1o5wx_78{background:var(--button-tertiary-pressed-background);border-radius:var(--spacing-xs-6)}._selectContainer_1o5wx_54 ._selectList_1o5wx_82{max-height:200px;overflow-y:auto;gap:.125rem;display:flex;justify-content:flex-start;align-items:stretch;flex-direction:column}._selectContainer_1o5wx_54 ._modal_1o5wx_91{box-shadow:0 4px 4px 0 var(--shadow-color-lowest);border-radius:4px;padding:.25rem;animation:_dropdownFadeIn_1o5wx_1 .2s ease-out;transform-origin:top left}._selectContainer_1o5wx_54 ._itemLabel_1o5wx_98{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@keyframes _dropdownFadeIn_1o5wx_1{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}
1
+ ._selectContainer_133eb_54{position:relative}._selectContainer_133eb_54 ._selected_133eb_57{background:var(--button-tertiary-pressed-background);border-radius:var(--spacing-xs-6)}._selectContainer_133eb_54 ._children_133eb_61{padding:var(--spacing-xs-6) var(--spacing-xs-5);box-sizing:border-box;width:100%;gap:.5rem;cursor:pointer;font-style:normal;line-height:1.25rem;display:flex;justify-content:flex-start;align-items:center;flex-direction:row}._selectContainer_133eb_54 ._children_133eb_61:hover{background:var(--dropdown-line-background-hover);border-radius:var(--spacing-xs-6)}._selectContainer_133eb_54 ._children_133eb_61._active_133eb_78{background:var(--button-tertiary-pressed-background);border-radius:var(--spacing-xs-6)}._selectContainer_133eb_54 ._selectList_133eb_82{max-height:200px;overflow-y:auto;gap:.125rem;display:flex;justify-content:flex-start;align-items:stretch;flex-direction:column}._selectContainer_133eb_54 ._modal_133eb_91{box-shadow:0 4px 4px 0 var(--shadow-color-lowest);border-radius:4px;padding:.25rem;animation:_dropdownFadeIn_133eb_1 .2s ease-out;transform-origin:top left}._selectContainer_133eb_54 ._itemLabel_133eb_98{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._selectContainer_133eb_54 ._searchWrapper_133eb_103{background-color:var(--general-border-window);height:1px;width:100%;margin-bottom:.25rem}._selectContainer_133eb_54 ._noResults_133eb_109{text-align:center;padding:.5rem 0}@keyframes _dropdownFadeIn_133eb_1{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situaction/traq-ui-ste",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "library react component Situaction",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",