@sito/dashboard 0.0.74 → 0.0.76

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.
Files changed (72) hide show
  1. package/dist/Badge-DSSlox-y.cjs +1 -0
  2. package/dist/Badge-DW9i2Rh6.js +10 -0
  3. package/dist/Badge.cjs +1 -1
  4. package/dist/Badge.js +1 -1
  5. package/dist/Button-BxyXUUMe.cjs +1 -0
  6. package/dist/Button-C6icqzyN.js +25 -0
  7. package/dist/Button.cjs +1 -1
  8. package/dist/Button.js +1 -1
  9. package/dist/Chip-6bEZ7uwv.js +43 -0
  10. package/dist/Chip-N4r2Xf9l.cjs +1 -0
  11. package/dist/Chip.cjs +1 -1
  12. package/dist/Chip.js +1 -1
  13. package/dist/FileInput-C7ZYKt_i.js +100 -0
  14. package/dist/FileInput-Cz2R3z3k.cjs +1 -0
  15. package/dist/Form.cjs +1 -1
  16. package/dist/Form.js +2 -2
  17. package/dist/{IconButton-BpsTEj0z.js → IconButton-CqPk_OXG.js} +9 -8
  18. package/dist/IconButton-DVZCHIHB.cjs +1 -0
  19. package/dist/IconButton.cjs +1 -1
  20. package/dist/IconButton.css +1 -1
  21. package/dist/IconButton.js +1 -1
  22. package/dist/Loading-BTwXNOEv.js +27 -0
  23. package/dist/Loading-C70yH2dC.cjs +1 -0
  24. package/dist/Loading.cjs +1 -1
  25. package/dist/Loading.js +1 -1
  26. package/dist/SelectInput-BKFTGaAm.js +569 -0
  27. package/dist/SelectInput-C4wtTiHe.cjs +1 -0
  28. package/dist/SelectInput.css +1 -1
  29. package/dist/Table-BofsZtu9.cjs +1 -0
  30. package/dist/{Table-DO7FFraQ.js → Table-Mx5SOKp_.js} +311 -281
  31. package/dist/Table.cjs +1 -1
  32. package/dist/Table.js +1 -1
  33. package/dist/Tooltip-B7LXJBLs.cjs +1 -0
  34. package/dist/Tooltip-p-nQtZ5Y.js +38 -0
  35. package/dist/Tooltip.cjs +1 -1
  36. package/dist/Tooltip.js +1 -1
  37. package/dist/Translation.cjs +1 -1
  38. package/dist/Translation.js +1 -1
  39. package/dist/TranslationProvider-BmV4WUQy.cjs +1 -0
  40. package/dist/TranslationProvider-DNybGe-x.js +19 -0
  41. package/dist/classNames-DDRjbGA1.js +20 -0
  42. package/dist/classNames-DHAzUjfZ.cjs +1 -0
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.css +1 -1
  45. package/dist/index.js +76 -74
  46. package/dist/lib/classNames.d.ts +7 -0
  47. package/dist/lib/index.d.ts +1 -0
  48. package/dist/lib.cjs +1 -1
  49. package/dist/lib.js +4 -2
  50. package/dist/providers/FiltersProvider/FiltersProvider.d.ts +1 -1
  51. package/dist/providers/TableOptions/TableOptionsProvider.d.ts +3 -3
  52. package/dist/providers/Translation/TranslationProvider.d.ts +2 -6
  53. package/dist/providers/Translation/types.d.ts +4 -0
  54. package/package.json +1 -1
  55. package/dist/Badge-CIeYthEy.js +0 -9
  56. package/dist/Badge-Z78MlGoQ.cjs +0 -1
  57. package/dist/Button-BlYa3uPc.cjs +0 -1
  58. package/dist/Button-D73-swfo.js +0 -24
  59. package/dist/Chip-C5ogKbFn.js +0 -37
  60. package/dist/Chip-D17UJHW6.cjs +0 -1
  61. package/dist/FileInput-CqzVk1gQ.cjs +0 -1
  62. package/dist/FileInput-Cr4TxWUg.js +0 -93
  63. package/dist/IconButton-CVnmT2E9.cjs +0 -1
  64. package/dist/Loading-B_c_4XLr.js +0 -26
  65. package/dist/Loading-CNECRan-.cjs +0 -1
  66. package/dist/SelectInput-Dm7gv03Z.js +0 -521
  67. package/dist/SelectInput-dYjrdopP.cjs +0 -1
  68. package/dist/Table-C03frnWb.cjs +0 -1
  69. package/dist/Tooltip-B4E-FRwY.js +0 -37
  70. package/dist/Tooltip-BSKAgRkc.cjs +0 -1
  71. package/dist/TranslationProvider-BR4s--Vu.js +0 -19
  72. package/dist/TranslationProvider-Czr0WIDH.cjs +0 -1
@@ -1,93 +0,0 @@
1
- import "./FileInput.css";
2
- import { jsxs as C, jsx as l } from "react/jsx-runtime";
3
- import { forwardRef as j, useState as R, useCallback as m } from "react";
4
- import { T as x } from "./Tooltip-B4E-FRwY.js";
5
- import { F as q } from "./File-BuJndWMv.js";
6
- import { C as A } from "./Chip-C5ogKbFn.js";
7
- import { I as B } from "./IconButton-BpsTEj0z.js";
8
- import { C as D } from "./Close-rKC9AcNX.js";
9
- function v(t, s = 25) {
10
- if (t.length <= s) return t;
11
- const a = t.lastIndexOf(".");
12
- if (a === -1)
13
- return t.slice(0, s - 3) + "...";
14
- const p = t.slice(0, a), r = t.slice(a), f = s - r.length - 3;
15
- return p.slice(0, f) + "..." + r;
16
- }
17
- const K = j(function(t, s) {
18
- const {
19
- children: a,
20
- label: p,
21
- containerClassName: r = "",
22
- inputClassName: f = "",
23
- labelClassName: F = "",
24
- helperText: N = "",
25
- helperTextClassName: $ = "",
26
- iconClassName: b = "",
27
- multiple: d = !1,
28
- onChange: g,
29
- onClear: o,
30
- ...h
31
- } = t, [n, u] = R([]), I = m(
32
- (e) => {
33
- if (e.target.files) {
34
- const i = Array.from(e.target.files);
35
- u(
36
- (c) => d ? [...c, ...i] : i.slice(0, 1)
37
- );
38
- }
39
- g?.(e);
40
- },
41
- [d, g]
42
- ), w = m(
43
- (e) => {
44
- u((i) => {
45
- const c = i.filter((M, y) => y !== e);
46
- return c.length === 0 && o?.(), c;
47
- });
48
- },
49
- [o]
50
- ), T = m(() => {
51
- u([]), o?.();
52
- }, [o]), k = m(
53
- (e) => {
54
- e.currentTarget.value = "";
55
- },
56
- []
57
- );
58
- return /* @__PURE__ */ C("div", { className: `file-input-container ${r}`, children: [
59
- n.length === 0 && /* @__PURE__ */ C("label", { htmlFor: h.id, className: `${F}`, children: [
60
- p,
61
- /* @__PURE__ */ l(
62
- "input",
63
- {
64
- type: "file",
65
- ref: s,
66
- multiple: d,
67
- onClick: k,
68
- onChange: I,
69
- className: `file-input ${f}`,
70
- ...h
71
- }
72
- ),
73
- h.required ? " *" : ""
74
- ] }),
75
- n.length > 1 && /* @__PURE__ */ l("ul", { className: "file-preview-list", children: n.map((e, i) => /* @__PURE__ */ l("li", { children: /* @__PURE__ */ l(x, { content: e.name, children: /* @__PURE__ */ l(
76
- A,
77
- {
78
- text: v(e.name, 25),
79
- onDelete: () => w(i)
80
- }
81
- ) }) }, `${e.name}-${e.lastModified}`)) }),
82
- n.length === 1 && /* @__PURE__ */ C("div", { className: "file-preview", children: [
83
- /* @__PURE__ */ l(q, { className: `file-icon ${b}` }),
84
- /* @__PURE__ */ l(x, { content: n[0]?.name ?? "", children: /* @__PURE__ */ l("span", { className: "file-preview-name", children: v(n[0]?.name ?? "", 25) }) }),
85
- /* @__PURE__ */ l(B, { icon: /* @__PURE__ */ l(D, {}), onClick: T, type: "button" })
86
- ] }),
87
- a,
88
- !!N && /* @__PURE__ */ l("p", { className: `file-input-helper-text ${$}`, children: N })
89
- ] });
90
- });
91
- export {
92
- K as F
93
- };
@@ -1 +0,0 @@
1
- var m=require("./IconButton.css");const t=require("react/jsx-runtime"),l=n=>{const{children:s,icon:c,type:e="button",className:o="",variant:a="text",color:r="default",iconClassName:i="",...u}=n;return t.jsxs("button",{type:e,className:`icon-button ${o} ${a} ${r}`,...u,children:[t.jsx("span",{className:i,children:c}),s]})};exports.IconButton=l;
@@ -1,26 +0,0 @@
1
- import "./Loading.css";
2
- import { jsx as e } from "react/jsx-runtime";
3
- function n(r) {
4
- const {
5
- color: a = "stroke-blue-800",
6
- className: l = "",
7
- loaderClass: s = "",
8
- strokeWidth: i = "4",
9
- ...c
10
- } = r;
11
- return /* @__PURE__ */ e("div", { ...c, className: `loading ${l}`, children: /* @__PURE__ */ e("div", { className: "loader-container", children: /* @__PURE__ */ e("div", { className: `loader ${s}`, children: /* @__PURE__ */ e("svg", { className: "circular", viewBox: "25 25 50 50", children: /* @__PURE__ */ e(
12
- "circle",
13
- {
14
- className: `path ${a}`,
15
- cx: "50",
16
- cy: "50",
17
- r: "20",
18
- fill: "none",
19
- strokeWidth: i,
20
- strokeMiterlimit: "10"
21
- }
22
- ) }) }) }) });
23
- }
24
- export {
25
- n as L
26
- };
@@ -1 +0,0 @@
1
- var n=require("./Loading.css");const s=require("react/jsx-runtime");function o(e){const{color:i="stroke-blue-800",className:r="",loaderClass:a="",strokeWidth:c="4",...l}=e;return s.jsx("div",{...l,className:`loading ${r}`,children:s.jsx("div",{className:"loader-container",children:s.jsx("div",{className:`loader ${a}`,children:s.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:s.jsx("circle",{className:`path ${i}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:c,strokeMiterlimit:"10"})})})})})}exports.Loading=o;
@@ -1,521 +0,0 @@
1
- import "./SelectInput.css";
2
- import { jsxs as E, jsx as a, Fragment as Y } from "react/jsx-runtime";
3
- import { forwardRef as W, useState as F, useEffect as H, useMemo as j, useRef as U, useCallback as k, useLayoutEffect as Z } from "react";
4
- import { C as M } from "./Chip-C5ogKbFn.js";
5
- import { I as ee } from "./IconButton-BpsTEj0z.js";
6
- import { C as te } from "./Close-rKC9AcNX.js";
7
- const oe = W(function(l, p) {
8
- const {
9
- state: m,
10
- value: t,
11
- onChange: r,
12
- options: x = [],
13
- name: $ = "",
14
- id: w = "",
15
- label: y = "",
16
- containerClassName: A = "",
17
- inputContainerClassName: N = "",
18
- helperText: S = "",
19
- placeholder: T = "",
20
- multiple: d = !1,
21
- ...D
22
- } = l, [i, f] = F("");
23
- H(() => {
24
- if (!d && t && !Array.isArray(t)) {
25
- f(String(t.value ?? t.name ?? ""));
26
- return;
27
- }
28
- f("");
29
- }, [d, t]);
30
- const [g, C] = F(!1), [b, v] = F(-1), s = j(
31
- () => x.filter((e) => {
32
- const n = String(e.value ?? e.name).toLowerCase().includes(i?.toLowerCase());
33
- return Array.isArray(t) && t.length ? n && !t.some((c) => c.id === e.id) : t && !Array.isArray(t) ? n && t.id !== e.id : n;
34
- }),
35
- [x, t, i]
36
- );
37
- H(() => {
38
- if (!g || !s.length) {
39
- v(-1);
40
- return;
41
- }
42
- v(0);
43
- }, [g, s]);
44
- const o = U(null), h = U(null), [O, I] = F(!1), u = U(null);
45
- H(() => {
46
- const e = (c) => {
47
- o.current && !o.current.contains(c.target) && C(!1);
48
- }, n = (c) => {
49
- c.key === "Escape" && C(!1);
50
- };
51
- return document.addEventListener("mousedown", e), document.addEventListener("keydown", n), () => {
52
- document.removeEventListener("mousedown", e), document.removeEventListener("keydown", n);
53
- };
54
- }, []);
55
- const P = k((e) => {
56
- f(e.target.value);
57
- }, []), L = k(
58
- (e) => {
59
- e ? d ? (f(""), Array.isArray(t) && t.length ? r([...t, e]) : r([e])) : (f(String(e.name ?? e.value ?? "")), r(e)) : r(null), C(!1);
60
- },
61
- [d, r, t]
62
- ), K = k(
63
- (e) => {
64
- if (!s.length) {
65
- e.key === "Escape" && C(!1);
66
- return;
67
- }
68
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
69
- if (e.preventDefault(), !g) {
70
- C(!0), v(0);
71
- return;
72
- }
73
- v((n) => {
74
- const c = n >= 0 ? n : 0;
75
- return e.key === "ArrowDown" ? (c + 1 + s.length) % s.length : (c - 1 + s.length) % s.length;
76
- });
77
- return;
78
- }
79
- if (e.key === "Enter" && g) {
80
- e.preventDefault();
81
- const n = b >= 0 ? b : 0;
82
- L(s[n]);
83
- return;
84
- }
85
- e.key === "Escape" && g && (e.preventDefault(), C(!1));
86
- },
87
- [
88
- L,
89
- b,
90
- g,
91
- s
92
- ]
93
- ), R = k(
94
- (e) => {
95
- if (!Array.isArray(t)) {
96
- r(null);
97
- return;
98
- }
99
- const n = t.filter((c, z) => z !== e);
100
- n.length ? r(n) : r(null);
101
- },
102
- [r, t]
103
- ), V = k(() => {
104
- Array.isArray(t) && r([t[0]]);
105
- }, [r, t]);
106
- return Z(() => {
107
- const e = u.current?.offsetWidth ?? 0, n = o.current?.offsetWidth ?? 0;
108
- I(e > n * 0.4);
109
- }, [t]), /* @__PURE__ */ E(
110
- "div",
111
- {
112
- className: `autocomplete-input-container ${A}`,
113
- ref: o,
114
- children: [
115
- /* @__PURE__ */ E("div", { className: "autocomplete-value-input-container", children: [
116
- /* @__PURE__ */ a(
117
- Q,
118
- {
119
- state: m,
120
- name: $,
121
- id: w,
122
- value: i,
123
- onChange: P,
124
- placeholder: T,
125
- helperText: S,
126
- onFocus: () => C(!0),
127
- onKeyDown: K,
128
- label: y,
129
- containerClassName: `autocomplete-text-input ${N}`,
130
- ref: p ?? h,
131
- ...D,
132
- children: !d && t && !Array.isArray(t) && (t.value || t.name) && /* @__PURE__ */ a(
133
- ee,
134
- {
135
- icon: /* @__PURE__ */ a(te, {}),
136
- className: "autocomplete-delete-button",
137
- onClick: (e) => {
138
- L(), e.stopPropagation();
139
- }
140
- }
141
- )
142
- }
143
- ),
144
- d && Array.isArray(t) && t.length ? /* @__PURE__ */ a("ul", { ref: u, className: "autocomplete-value-container", children: O ? /* @__PURE__ */ E(Y, { children: [
145
- /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
146
- M,
147
- {
148
- text: t[0]?.value ?? t[0]?.name,
149
- onDelete: (e) => {
150
- R(0), e.stopPropagation();
151
- }
152
- }
153
- ) }),
154
- t.length > 1 && /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
155
- M,
156
- {
157
- text: `+${t.length - 1}`,
158
- onDelete: (e) => {
159
- V(), e.stopPropagation();
160
- }
161
- }
162
- ) })
163
- ] }) : t.map((e, n) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
164
- M,
165
- {
166
- text: String(e.value ?? e.name),
167
- onDelete: (c) => {
168
- R(n), c.stopPropagation();
169
- }
170
- }
171
- ) }, e.id ?? e.value ?? e.name)) }) : null
172
- ] }),
173
- g && /* @__PURE__ */ a(
174
- "ul",
175
- {
176
- className: "autocomplete-suggestions-container",
177
- style: { width: o.current?.offsetWidth },
178
- children: s.map((e) => /* @__PURE__ */ a(
179
- "li",
180
- {
181
- className: `autocomplete-suggestion-item ${e.id === s[b]?.id ? "highlighted" : ""}`,
182
- onMouseEnter: () => v(
183
- s.findIndex((n) => n.id === e.id)
184
- ),
185
- onClick: (n) => {
186
- L(e), n.stopPropagation();
187
- },
188
- children: e.value ?? e.name
189
- },
190
- e.id ?? e.value ?? e.name
191
- ))
192
- }
193
- )
194
- ]
195
- }
196
- );
197
- });
198
- var B = /* @__PURE__ */ ((l) => (l.error = "error", l.good = "good", l.default = "default", l))(B || {});
199
- const q = (l) => {
200
- switch (l) {
201
- case "error":
202
- return "input-error";
203
- case "good":
204
- return "input-good";
205
- default:
206
- return "input-normal";
207
- }
208
- }, _ = (l) => {
209
- switch (l) {
210
- case "error":
211
- return "input-label-error";
212
- case "good":
213
- return "input-label-good";
214
- default:
215
- return "input-label-normal";
216
- }
217
- }, J = (l) => {
218
- switch (l) {
219
- case "error":
220
- return "input-helper-text-error";
221
- case "good":
222
- return "input-helper-text-good";
223
- default:
224
- return "input-helper-text-normal";
225
- }
226
- }, ce = W(function(l, p) {
227
- const {
228
- checked: m,
229
- onChange: t,
230
- name: r = "",
231
- id: x = "",
232
- label: $ = "",
233
- state: w = B.default,
234
- containerClassName: y = "",
235
- inputClassName: A = "",
236
- labelClassName: N = "",
237
- ...S
238
- } = l;
239
- return /* @__PURE__ */ E("label", { className: `input-check-container ${y}`, children: [
240
- /* @__PURE__ */ a(
241
- "input",
242
- {
243
- id: x,
244
- ref: p,
245
- name: r,
246
- type: "checkbox",
247
- checked: m,
248
- onChange: t,
249
- className: `input-check ${q(w)} ${A}`,
250
- ...S
251
- }
252
- ),
253
- /* @__PURE__ */ a(
254
- "span",
255
- {
256
- className: `input-check-label ${_(w)} ${N}`,
257
- children: $
258
- }
259
- )
260
- ] });
261
- }), G = (l) => l == null ? !1 : Array.isArray(l) ? l.length > 0 : `${l}`.length > 0, Q = W(function(l, p) {
262
- const {
263
- children: m,
264
- state: t = B.default,
265
- label: r = "",
266
- containerClassName: x = "",
267
- inputClassName: $ = "",
268
- labelClassName: w = "",
269
- helperText: y = "",
270
- helperTextClassName: A = "",
271
- value: N,
272
- defaultValue: S,
273
- onChange: T,
274
- onFocus: d,
275
- onBlur: D,
276
- ...i
277
- } = l, f = N !== void 0, [g, C] = F(
278
- () => G(S)
279
- ), b = f ? G(N) : g, v = i.type === "date", s = !!i.placeholder || v, o = (h) => {
280
- f || C(h.currentTarget.value.length > 0), T?.(h);
281
- };
282
- return /* @__PURE__ */ E("div", { className: `text-input-container ${x}`, children: [
283
- /* @__PURE__ */ a(
284
- "input",
285
- {
286
- ref: p,
287
- defaultValue: S,
288
- onChange: o,
289
- onFocus: d,
290
- onBlur: D,
291
- ...f ? { value: N } : {},
292
- className: `text-input ${q(t)} ${$} ${b ? "has-value" : ""} ${i.placeholder ? "has-placeholder" : ""} ${s ? "keep-label-up" : ""}`,
293
- ...i
294
- }
295
- ),
296
- !!r && /* @__PURE__ */ E(
297
- "label",
298
- {
299
- htmlFor: i.id,
300
- className: `text-input-label ${_(t)} ${w}`,
301
- children: [
302
- r,
303
- i.required ? " *" : ""
304
- ]
305
- }
306
- ),
307
- m,
308
- !!y && /* @__PURE__ */ a(
309
- "p",
310
- {
311
- className: `text-input-helper-text ${J(t)} ${A}`,
312
- children: y
313
- }
314
- )
315
- ] });
316
- }), ue = W(function(l, p) {
317
- const {
318
- value: m,
319
- onChange: t,
320
- options: r,
321
- containerClassName: x = "",
322
- inputClassName: $ = "",
323
- labelClassName: w = "",
324
- helperText: y = "",
325
- helperTextClassName: A = "",
326
- label: N = "",
327
- placeholder: S = "",
328
- name: T = "",
329
- id: d = "",
330
- state: D = B.default,
331
- native: i = !0,
332
- disabled: f,
333
- required: g,
334
- autoFocus: C,
335
- children: b,
336
- ...v
337
- } = l, s = U(null), [o, h] = F(!1), [O, I] = F(-1), u = j(
338
- () => r.findIndex(
339
- (e) => String(e.id) === String(m ?? r[0]?.id ?? "")
340
- ),
341
- [r, m]
342
- ), P = j(
343
- () => u >= 0 ? r[u] : void 0,
344
- [r, u]
345
- );
346
- H(() => {
347
- if (!(i || !o)) {
348
- if (!r.length) {
349
- I(-1);
350
- return;
351
- }
352
- I(u >= 0 ? u : 0);
353
- }
354
- }, [i, r.length, u, o]), H(() => {
355
- if (i) return;
356
- const e = (n) => {
357
- s.current && !s.current.contains(n.target) && h(!1);
358
- };
359
- return document.addEventListener("mousedown", e), () => {
360
- document.removeEventListener("mousedown", e);
361
- };
362
- }, [i]);
363
- const L = k(
364
- (e) => {
365
- p && (typeof p == "function" ? p(e) : p.current = e);
366
- },
367
- [p]
368
- ), K = k(
369
- (e) => {
370
- if (!t) return;
371
- const n = {
372
- target: { value: String(e) },
373
- currentTarget: { value: String(e) }
374
- };
375
- t(n);
376
- },
377
- [t]
378
- ), R = k(
379
- (e) => {
380
- const n = r[e];
381
- n && (K(n.id), h(!1));
382
- },
383
- [K, r]
384
- ), V = k(
385
- (e) => {
386
- if (r.length) {
387
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
388
- if (e.preventDefault(), !o) {
389
- h(!0);
390
- const n = u >= 0 ? u : 0;
391
- I(n);
392
- return;
393
- }
394
- I((n) => {
395
- const c = n >= 0 ? n : u;
396
- return e.key === "ArrowDown" ? (c + 1 + r.length) % r.length : (c - 1 + r.length) % r.length;
397
- });
398
- return;
399
- }
400
- if (e.key === "Enter") {
401
- if (!o) {
402
- e.preventDefault(), h(!0), I(u >= 0 ? u : 0);
403
- return;
404
- }
405
- e.preventDefault(), R(O >= 0 ? O : 0);
406
- return;
407
- }
408
- e.key === "Escape" && o && (e.preventDefault(), h(!1));
409
- }
410
- },
411
- [O, r, R, u, o]
412
- );
413
- return i ? /* @__PURE__ */ E("div", { className: `select-input-container ${x}`, children: [
414
- /* @__PURE__ */ a(
415
- "select",
416
- {
417
- ...v,
418
- id: d,
419
- ref: L,
420
- name: T,
421
- value: m,
422
- onChange: t,
423
- className: `select-input ${q(D)} peer ${$}`,
424
- children: r?.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.value ?? e.name ?? e.id }, e.id))
425
- }
426
- ),
427
- /* @__PURE__ */ a(
428
- "label",
429
- {
430
- htmlFor: d,
431
- className: `select-input-label ${_(D)} ${w}`,
432
- children: N
433
- }
434
- ),
435
- b,
436
- y && /* @__PURE__ */ a(
437
- "p",
438
- {
439
- className: `select-input-helper-text ${J(D)} ${A}`,
440
- children: y
441
- }
442
- )
443
- ] }) : /* @__PURE__ */ E(
444
- "div",
445
- {
446
- ref: s,
447
- className: `select-input-container ${x}`,
448
- children: [
449
- /* @__PURE__ */ a(
450
- "select",
451
- {
452
- ...v,
453
- ref: L,
454
- name: T,
455
- id: d,
456
- value: m,
457
- onChange: t,
458
- className: "select-input-native-hidden",
459
- tabIndex: -1,
460
- "aria-hidden": !0,
461
- children: r?.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.value ?? e.name ?? e.id }, e.id))
462
- }
463
- ),
464
- /* @__PURE__ */ a(
465
- Q,
466
- {
467
- id: d,
468
- name: T,
469
- state: D,
470
- value: String(P?.value ?? P?.name ?? ""),
471
- readOnly: !0,
472
- label: N,
473
- helperText: y,
474
- containerClassName: "select-input-text-container",
475
- inputClassName: `select-input-text ${$}`,
476
- labelClassName: w,
477
- helperTextClassName: A,
478
- placeholder: S,
479
- disabled: f,
480
- required: g,
481
- autoFocus: C,
482
- onClick: () => h((e) => !e),
483
- onKeyDown: V,
484
- onFocus: () => h(!0),
485
- role: "combobox",
486
- "aria-expanded": o,
487
- "aria-haspopup": "listbox",
488
- children: b
489
- }
490
- ),
491
- o && /* @__PURE__ */ a("ul", { className: "select-input-options-container", role: "listbox", children: r.map((e, n) => {
492
- const c = String(e.id) === String(m);
493
- return /* @__PURE__ */ a(
494
- "li",
495
- {
496
- role: "option",
497
- "aria-selected": c,
498
- className: `select-input-option-item ${n === O ? "highlighted" : ""}`,
499
- onMouseEnter: () => I(n),
500
- onClick: (X) => {
501
- R(n), X.stopPropagation();
502
- },
503
- children: e.value ?? e.name ?? e.id
504
- },
505
- e.id
506
- );
507
- }) })
508
- ]
509
- }
510
- );
511
- });
512
- export {
513
- oe as A,
514
- ce as C,
515
- ue as S,
516
- Q as T,
517
- B as a,
518
- J as h,
519
- q as i,
520
- _ as l
521
- };
@@ -1 +0,0 @@
1
- var X=require("./SelectInput.css");const r=require("react/jsx-runtime"),l=require("react"),K=require("./Chip-D17UJHW6.cjs"),_=require("./IconButton-CVnmT2E9.cjs"),z=require("./Close-O9P7wJGf.cjs"),G=l.forwardRef(function(s,f){const{state:m,value:t,onChange:a,options:k=[],name:j="",id:v="",label:y="",containerClassName:S="",inputContainerClassName:N="",helperText:$="",placeholder:D="",multiple:h=!1,...A}=s,[o,g]=l.useState("");l.useEffect(()=>{if(!h&&t&&!Array.isArray(t)){g(String(t.value??t.name??""));return}g("")},[h,t]);const[x,C]=l.useState(!1),[w,b]=l.useState(-1),i=l.useMemo(()=>k.filter(e=>{const n=String(e.value??e.name).toLowerCase().includes(o?.toLowerCase());return Array.isArray(t)&&t.length?n&&!t.some(c=>c.id===e.id):t&&!Array.isArray(t)?n&&t.id!==e.id:n}),[k,t,o]);l.useEffect(()=>{if(!x||!i.length){b(-1);return}b(0)},[x,i]);const u=l.useRef(null),p=l.useRef(null),[T,I]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>{const e=c=>{u.current&&!u.current.contains(c.target)&&C(!1)},n=c=>{c.key==="Escape"&&C(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n)}},[]);const F=l.useCallback(e=>{g(e.target.value)},[]),E=l.useCallback(e=>{e?h?(g(""),Array.isArray(t)&&t.length?a([...t,e]):a([e])):(g(String(e.name??e.value??"")),a(e)):a(null),C(!1)},[h,a,t]),q=l.useCallback(e=>{if(!i.length){e.key==="Escape"&&C(!1);return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),!x){C(!0),b(0);return}b(n=>{const c=n>=0?n:0;return e.key==="ArrowDown"?(c+1+i.length)%i.length:(c-1+i.length)%i.length});return}if(e.key==="Enter"&&x){e.preventDefault();const n=w>=0?w:0;E(i[n]);return}e.key==="Escape"&&x&&(e.preventDefault(),C(!1))},[E,w,x,i]),R=l.useCallback(e=>{if(!Array.isArray(t)){a(null);return}const n=t.filter((c,H)=>H!==e);n.length?a(n):a(null)},[a,t]),B=l.useCallback(()=>{Array.isArray(t)&&a([t[0]])},[a,t]);return l.useLayoutEffect(()=>{const e=d.current?.offsetWidth??0,n=u.current?.offsetWidth??0;I(e>n*.4)},[t]),r.jsxs("div",{className:`autocomplete-input-container ${S}`,ref:u,children:[r.jsxs("div",{className:"autocomplete-value-input-container",children:[r.jsx(U,{state:m,name:j,id:v,value:o,onChange:F,placeholder:D,helperText:$,onFocus:()=>C(!0),onKeyDown:q,label:y,containerClassName:`autocomplete-text-input ${N}`,ref:f??p,...A,children:!h&&t&&!Array.isArray(t)&&(t.value||t.name)&&r.jsx(_.IconButton,{icon:r.jsx(z.Close,{}),className:"autocomplete-delete-button",onClick:e=>{E(),e.stopPropagation()}})}),h&&Array.isArray(t)&&t.length?r.jsx("ul",{ref:d,className:"autocomplete-value-container",children:T?r.jsxs(r.Fragment,{children:[r.jsx("li",{children:r.jsx(K.Chip,{text:t[0]?.value??t[0]?.name,onDelete:e=>{R(0),e.stopPropagation()}})}),t.length>1&&r.jsx("li",{children:r.jsx(K.Chip,{text:`+${t.length-1}`,onDelete:e=>{B(),e.stopPropagation()}})})]}):t.map((e,n)=>r.jsx("li",{children:r.jsx(K.Chip,{text:String(e.value??e.name),onDelete:c=>{R(n),c.stopPropagation()}})},e.id??e.value??e.name))}):null]}),x&&r.jsx("ul",{className:"autocomplete-suggestions-container",style:{width:u.current?.offsetWidth},children:i.map(e=>r.jsx("li",{className:`autocomplete-suggestion-item ${e.id===i[w]?.id?"highlighted":""}`,onMouseEnter:()=>b(i.findIndex(n=>n.id===e.id)),onClick:n=>{E(e),n.stopPropagation()},children:e.value??e.name},e.id??e.value??e.name))})]})});var L=(s=>(s.error="error",s.good="good",s.default="default",s))(L||{});const O=s=>{switch(s){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},P=s=>{switch(s){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},M=s=>{switch(s){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}},J=l.forwardRef(function(s,f){const{checked:m,onChange:t,name:a="",id:k="",label:j="",state:v=L.default,containerClassName:y="",inputClassName:S="",labelClassName:N="",...$}=s;return r.jsxs("label",{className:`input-check-container ${y}`,children:[r.jsx("input",{id:k,ref:f,name:a,type:"checkbox",checked:m,onChange:t,className:`input-check ${O(v)} ${S}`,...$}),r.jsx("span",{className:`input-check-label ${P(v)} ${N}`,children:j})]})}),W=s=>s==null?!1:Array.isArray(s)?s.length>0:`${s}`.length>0,U=l.forwardRef(function(s,f){const{children:m,state:t=L.default,label:a="",containerClassName:k="",inputClassName:j="",labelClassName:v="",helperText:y="",helperTextClassName:S="",value:N,defaultValue:$,onChange:D,onFocus:h,onBlur:A,...o}=s,g=N!==void 0,[x,C]=l.useState(()=>W($)),w=g?W(N):x,b=o.type==="date",i=!!o.placeholder||b,u=p=>{g||C(p.currentTarget.value.length>0),D?.(p)};return r.jsxs("div",{className:`text-input-container ${k}`,children:[r.jsx("input",{ref:f,defaultValue:$,onChange:u,onFocus:h,onBlur:A,...g?{value:N}:{},className:`text-input ${O(t)} ${j} ${w?"has-value":""} ${o.placeholder?"has-placeholder":""} ${i?"keep-label-up":""}`,...o}),!!a&&r.jsxs("label",{htmlFor:o.id,className:`text-input-label ${P(t)} ${v}`,children:[a,o.required?" *":""]}),m,!!y&&r.jsx("p",{className:`text-input-helper-text ${M(t)} ${S}`,children:y})]})}),Q=l.forwardRef(function(s,f){const{value:m,onChange:t,options:a,containerClassName:k="",inputClassName:j="",labelClassName:v="",helperText:y="",helperTextClassName:S="",label:N="",placeholder:$="",name:D="",id:h="",state:A=L.default,native:o=!0,disabled:g,required:x,autoFocus:C,children:w,...b}=s,i=l.useRef(null),[u,p]=l.useState(!1),[T,I]=l.useState(-1),d=l.useMemo(()=>a.findIndex(e=>String(e.id)===String(m??a[0]?.id??"")),[a,m]),F=l.useMemo(()=>d>=0?a[d]:void 0,[a,d]);l.useEffect(()=>{if(!(o||!u)){if(!a.length){I(-1);return}I(d>=0?d:0)}},[o,a.length,d,u]),l.useEffect(()=>{if(o)return;const e=n=>{i.current&&!i.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[o]);const E=l.useCallback(e=>{f&&(typeof f=="function"?f(e):f.current=e)},[f]),q=l.useCallback(e=>{if(!t)return;const n={target:{value:String(e)},currentTarget:{value:String(e)}};t(n)},[t]),R=l.useCallback(e=>{const n=a[e];n&&(q(n.id),p(!1))},[q,a]),B=l.useCallback(e=>{if(a.length){if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),!u){p(!0);const n=d>=0?d:0;I(n);return}I(n=>{const c=n>=0?n:d;return e.key==="ArrowDown"?(c+1+a.length)%a.length:(c-1+a.length)%a.length});return}if(e.key==="Enter"){if(!u){e.preventDefault(),p(!0),I(d>=0?d:0);return}e.preventDefault(),R(T>=0?T:0);return}e.key==="Escape"&&u&&(e.preventDefault(),p(!1))}},[T,a,R,d,u]);return o?r.jsxs("div",{className:`select-input-container ${k}`,children:[r.jsx("select",{...b,id:h,ref:E,name:D,value:m,onChange:t,className:`select-input ${O(A)} peer ${j}`,children:a?.map(e=>r.jsx("option",{value:e.id,children:e.value??e.name??e.id},e.id))}),r.jsx("label",{htmlFor:h,className:`select-input-label ${P(A)} ${v}`,children:N}),w,y&&r.jsx("p",{className:`select-input-helper-text ${M(A)} ${S}`,children:y})]}):r.jsxs("div",{ref:i,className:`select-input-container ${k}`,children:[r.jsx("select",{...b,ref:E,name:D,id:h,value:m,onChange:t,className:"select-input-native-hidden",tabIndex:-1,"aria-hidden":!0,children:a?.map(e=>r.jsx("option",{value:e.id,children:e.value??e.name??e.id},e.id))}),r.jsx(U,{id:h,name:D,state:A,value:String(F?.value??F?.name??""),readOnly:!0,label:N,helperText:y,containerClassName:"select-input-text-container",inputClassName:`select-input-text ${j}`,labelClassName:v,helperTextClassName:S,placeholder:$,disabled:g,required:x,autoFocus:C,onClick:()=>p(e=>!e),onKeyDown:B,onFocus:()=>p(!0),role:"combobox","aria-expanded":u,"aria-haspopup":"listbox",children:w}),u&&r.jsx("ul",{className:"select-input-options-container",role:"listbox",children:a.map((e,n)=>{const c=String(e.id)===String(m),H=n===T;return r.jsx("li",{role:"option","aria-selected":c,className:`select-input-option-item ${H?"highlighted":""}`,onMouseEnter:()=>I(n),onClick:V=>{R(n),V.stopPropagation()},children:e.value??e.name??e.id},e.id)})})]})});exports.AutocompleteInput=G;exports.CheckInput=J;exports.SelectInput=Q;exports.State=L;exports.TextInput=U;exports.helperTextStateClassName=M;exports.inputStateClassName=O;exports.labelStateClassName=P;