@situaction/traq-ui-ste 1.2.1 → 1.2.3

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,207 @@
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 r } 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, o = (c == null ? void 0 : c.label) || F || "Sélectionner";
47
+ return x === "icon" && e ? /* @__PURE__ */ r(I, { ref: d, mode: "tertiary", size: C, onClick: () => f(!t), children: /* @__PURE__ */ r(_, { icon: c.icon }) }) : x === "text" ? /* @__PURE__ */ r(
48
+ W,
44
49
  {
45
50
  ref: d,
46
51
  mode: "tertiary",
47
52
  label: o,
48
- childrenRight: /* @__PURE__ */ r(_, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
49
- size: p,
50
- fullWidth: T,
51
- onClick: () => u(!n)
53
+ childrenRight: /* @__PURE__ */ r(_, { 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__ */ r(
59
+ W,
55
60
  {
56
61
  ref: d,
57
62
  mode: "tertiary",
58
63
  label: o,
59
- size: p,
60
- fullWidth: T,
64
+ size: C,
65
+ fullWidth: S,
61
66
  childrenLeft: e && /* @__PURE__ */ r(_, { icon: c.icon }),
62
- childrenRight: /* @__PURE__ */ r(_, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
63
- onClick: () => u(!n)
67
+ childrenRight: /* @__PURE__ */ r(_, { icon: t ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
68
+ onClick: () => f(!t)
64
69
  }
65
70
  ) : /* @__PURE__ */ r(
66
- N,
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) => {
77
- if (!n) return;
81
+ }, E = m(null), g = m({}), [R, v] = b(""), h = m(null), K = m({}), j = s.filter(
82
+ (e) => (e.label ?? "").toLowerCase().includes($.toLowerCase())
83
+ ), N = (e) => {
84
+ if (!t) return;
78
85
  const o = e.key.length === 1 ? e.key.toLowerCase() : "";
79
86
  if (!o) return;
80
- const a = y + o;
87
+ const a = R + o;
81
88
  v(a);
82
- const i = s.find((t) => {
89
+ const i = s.find((n) => {
83
90
  var l;
84
- return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(a);
91
+ return (l = n.label) == null ? void 0 : l.toLowerCase().startsWith(a);
85
92
  });
86
93
  if (i) {
87
- const t = k.current[i.value];
88
- t == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
94
+ const n = g.current[i.value];
95
+ n == null || n.scrollIntoView({ behavior: "smooth", block: "nearest" });
89
96
  }
90
- f.current && clearTimeout(f.current), f.current = setTimeout(() => {
97
+ h.current && clearTimeout(h.current), h.current = setTimeout(() => {
91
98
  v("");
92
99
  }, 500);
93
100
  };
94
- w(() => (n ? window.addEventListener("keydown", S) : (window.removeEventListener("keydown", S), v("")), () => {
95
- window.removeEventListener("keydown", S);
96
- }), [n, y, s]), w(() => {
101
+ p(() => (t ? window.addEventListener("keydown", N) : (window.removeEventListener("keydown", N), v("")), () => {
102
+ window.removeEventListener("keydown", N);
103
+ }), [t, R, s]), p(() => {
97
104
  const e = (o) => {
98
- if (!n) return;
105
+ if (!t) return;
99
106
  const a = o.key.length === 1 ? o.key.toLowerCase() : "";
100
107
  if (!a) return;
101
- const i = y + a;
108
+ const i = R + a;
102
109
  v(i);
103
- const t = s.find(
110
+ const n = s.find(
104
111
  (l) => {
105
- var x;
106
- return (x = l.label) == null ? void 0 : x.toLowerCase().startsWith(i);
112
+ var T;
113
+ return (T = l.label) == null ? void 0 : T.toLowerCase().startsWith(i);
107
114
  }
108
115
  );
109
- if (t && E.current && t.value in k.current && k.current[t.value]) {
110
- const l = E.current, x = k.current[t.value];
116
+ if (n && E.current && n.value in g.current && g.current[n.value]) {
117
+ const l = E.current, T = g.current[n.value];
111
118
  l.scrollTo({
112
- top: x.offsetTop - l.offsetTop,
119
+ top: T.offsetTop - l.offsetTop,
113
120
  behavior: "smooth"
114
121
  });
115
122
  }
116
- f.current && clearTimeout(f.current), f.current = setTimeout(() => {
123
+ h.current && clearTimeout(h.current), h.current = setTimeout(() => {
117
124
  v("");
118
125
  }, 700);
119
126
  };
120
127
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
121
- }, [n, s, y]), w(() => {
122
- if (!n) return;
128
+ }, [t, s, R]), p(() => {
129
+ if (!t) return;
123
130
  const e = (o) => {
124
131
  const a = o.key.toLowerCase();
125
132
  if (a.length === 1) {
126
133
  const i = s.find(
127
- (t) => {
134
+ (n) => {
128
135
  var l;
129
- return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(a);
136
+ return (l = n.label) == null ? void 0 : l.toLowerCase().startsWith(a);
130
137
  }
131
138
  );
132
139
  if (i) {
133
- const t = K.current[i.value];
134
- t && t.scrollIntoView({ block: "start", behavior: "smooth" });
140
+ const n = K.current[i.value];
141
+ n && n.scrollIntoView({ block: "start", behavior: "smooth" });
135
142
  }
136
143
  }
137
144
  };
138
145
  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) {
146
+ }, [t, s]);
147
+ const d = m(null);
148
+ return p(() => {
149
+ if (t && d.current) {
143
150
  const e = d.current.getBoundingClientRect().height;
144
- F(L || {
151
+ P(y || {
145
152
  top: `${e + 6}px`,
146
153
  left: "0px"
147
154
  });
148
155
  }
149
- }, [n]), /* @__PURE__ */ $("div", { className: m.selectContainer, children: [
150
- W(),
156
+ }, [t]), /* @__PURE__ */ w("div", { className: u.selectContainer, children: [
157
+ G(),
151
158
  /* @__PURE__ */ r(
152
- z,
159
+ J,
153
160
  {
154
- ref: U,
161
+ ref: A,
155
162
  anchorRef: d,
156
- open: n,
157
- onClose: () => u(!1),
158
- position: V,
163
+ open: t,
164
+ onClose: () => f(!1),
165
+ position: M,
159
166
  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
- )) })
167
+ className: u.modal,
168
+ autoCloseCondition: V,
169
+ children: /* @__PURE__ */ w("div", { children: [
170
+ z && /* @__PURE__ */ w("div", { children: [
171
+ /* @__PURE__ */ r(
172
+ H,
173
+ {
174
+ type: "text",
175
+ placeholder: U,
176
+ status: "ghost",
177
+ sizeStyle: "s",
178
+ value: $,
179
+ onChange: (e) => q(e.target.value)
180
+ }
181
+ ),
182
+ /* @__PURE__ */ r("div", { className: u.searchWrapper })
183
+ ] }),
184
+ /* @__PURE__ */ w("div", { className: u.selectList, ref: E, children: [
185
+ j.map((e) => /* @__PURE__ */ w(
186
+ "div",
187
+ {
188
+ ref: (o) => K.current[e.value] = o,
189
+ className: `${u.children} ${(c == null ? void 0 : c.value) === e.value ? u.active : ""}`,
190
+ onClick: () => D(e),
191
+ children: [
192
+ e.icon && /* @__PURE__ */ r(_, { icon: e.icon, size: 16 }),
193
+ e.label && /* @__PURE__ */ r("div", { className: u.itemLabel, children: e.label })
194
+ ]
195
+ },
196
+ e.value
197
+ )),
198
+ j.length === 0 && /* @__PURE__ */ r("div", { className: `${u.noResults} textSmall`, children: "Aucun résultat" })
199
+ ] })
200
+ ] })
175
201
  }
176
202
  )
177
203
  ] });
178
204
  };
179
205
  export {
180
- ce as Select
206
+ me as Select
181
207
  };
@@ -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.3",
4
4
  "description": "library react component Situaction",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",