@sito/dashboard 0.0.77 → 0.0.79

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