@kapiuara/ui 0.3.1 → 0.5.0

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.
@@ -5,23 +5,23 @@ import { resolveGroupSize as ee, selectControlId as te } from "./inputGroupLogic
5
5
  import { useKapiInputGroup as ne } from "./KapiInputGroup.js";
6
6
  import { useLabels as re } from "../locale/KapiLocaleProvider.js";
7
7
  import { resolveKapiRoot as ie } from "../../hooks/kapiRoot.js";
8
- import { SELECT_MENU_PLACEMENT as ae, displayLabel as oe, filterOptions as se, findTypeaheadIndex as ce, flattenOptions as le, indexEntries as ue, initialActiveIndex as de, nextActiveIndex as i, normalizeValue as a, selectedOptions as fe, toggleValue as pe } from "./selectLogic.js";
9
- import { createLoadSequencer as me, isCreateRow as he, menuItems as ge, mergeKnownOptions as o, selectedFromKnown as _e, withCreated as ve } from "./asyncSelectLogic.js";
8
+ import { SELECT_MENU_PLACEMENT as ae, displayLabel as oe, filterOptions as se, findTypeaheadIndex as ce, flattenOptions as le, indexEntries as ue, initialActiveIndex as de, nextActiveIndex as i, normalizeValue as fe, selectedOptions as pe, toggleValue as me } from "./selectLogic.js";
9
+ import { createLoadSequencer as he, isCreateRow as ge, menuItems as _e, mergeKnownOptions as a, selectedFromKnown as ve, withCreated as ye } from "./asyncSelectLogic.js";
10
10
  /* empty css */
11
- import { usePlacement as ye } from "../../hooks/usePlacement.js";
12
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
13
- import { useCallback as l, useEffect as u, useId as be, useLayoutEffect as xe, useMemo as d, useRef as f, useState as p } from "react";
14
- import { Check as Se, ChevronDown as Ce, X as we } from "lucide-react";
15
- import { createPortal as Te } from "react-dom";
11
+ import { usePlacement as be } from "../../hooks/usePlacement.js";
12
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
13
+ import { useCallback as c, useEffect as l, useId as xe, useLayoutEffect as Se, useMemo as u, useRef as d, useState as f } from "react";
14
+ import { Check as Ce, ChevronDown as we, X as Te } from "lucide-react";
15
+ import { createPortal as Ee } from "react-dom";
16
16
  //#region src/components/inputs/KapiSelect.tsx
17
- var Ee = 6, De = 500, Oe = [], ke = (e, t) => `${e} “${t.trim()}”`, Ae = ({ size: e = "md", open: t, disabled: n, multi: r, className: ee }) => [
17
+ var De = 6, Oe = 500, ke = [], Ae = (e, t) => `${e} “${t.trim()}”`, je = ({ size: e = "md", open: t, disabled: n, multi: r, className: ee }) => [
18
18
  "kapisel",
19
19
  `kapisel--${e}`,
20
20
  t && "kapisel--open",
21
21
  n && "kapisel--disabled",
22
22
  r && "kapisel--multi",
23
23
  ee
24
- ].filter(Boolean).join(" "), je = {
24
+ ].filter(Boolean).join(" "), Me = {
25
25
  clear: "Limpiar selección",
26
26
  remove: "Quitar",
27
27
  placeholder: "Seleccionar…",
@@ -30,222 +30,226 @@ var Ee = 6, De = 500, Oe = [], ke = (e, t) => `${e} “${t.trim()}”`, Ae = ({
30
30
  loadError: "No se pudieron cargar las opciones",
31
31
  createError: "No se pudo crear la opción",
32
32
  create: "Crear"
33
- }, Me = (Me) => {
34
- let { options: m = Oe, loadOptions: h, loadDelay: Ne = 300, onCreate: Pe, value: Fe, defaultValue: Ie, multiple: g = !1, searchable: _ = !0, clearable: Le = !1, disabled: v = !1, loading: Re = !1, placeholder: ze, size: Be, renderOption: Ve, noOptionsMessage: He, loadingMessage: Ue, name: We, id: Ge, className: Ke, style: qe, "aria-label": Je, labels: Ye, ref: y, onBlur: Xe } = Me, Ze = Me.onChange, b = re("select", je, Ye), Qe = ze ?? b.placeholder, $e = He ?? b.noOptions, et = Ue ?? b.loading, tt = ne(), nt = ee(Be, tt?.size) ?? "md", rt = r(), it = be(), x = te({
35
- id: Ge,
36
- fieldControlId: rt?.controlId,
37
- autoId: it,
38
- inGroup: tt !== null
39
- }), at = `${x}-listbox`, ot = `${x}-value`, st = (e) => `${x}-opt-${e}`, ct = Fe !== void 0, [lt, ut] = p(() => a(Ie, g)), S = a(ct ? Fe : lt, g), C = d(() => a(S, !0), [S]), [w, T] = p(!1), [E, D] = p(""), [dt, O] = p(-1), k = f(null), A = f(null), ft = f(null), pt = l((t) => {
40
- A.current = t, e(y, t);
41
- }, [y]), mt = l((t) => {
42
- ft.current = t, e(y, t);
43
- }, [y]), j = f(null), ht = f({
33
+ }, Ne = (Ne) => {
34
+ let { options: p = ke, loadOptions: Pe, loadDelay: Fe = 300, reloadKey: m, onCreate: Ie, value: Le, defaultValue: Re, multiple: h = !1, searchable: g = !0, clearable: ze = !1, disabled: _ = !1, loading: Be = !1, placeholder: Ve, size: He, renderOption: Ue, noOptionsMessage: We, loadingMessage: Ge, name: Ke, id: qe, className: Je, style: Ye, "aria-label": Xe, labels: Ze, ref: v, onBlur: Qe } = Ne, $e = Ne.onChange, y = re("select", Me, Ze), et = Ve ?? y.placeholder, tt = We ?? y.noOptions, nt = Ge ?? y.loading, rt = ne(), it = ee(He, rt?.size) ?? "md", at = r(), ot = xe(), b = te({
35
+ id: qe,
36
+ fieldControlId: at?.controlId,
37
+ autoId: ot,
38
+ inGroup: rt !== null
39
+ }), st = `${b}-listbox`, ct = `${b}-value`, lt = (e) => `${b}-opt-${e}`, ut = Le !== void 0, [dt, ft] = f(() => fe(Re, h)), x = fe(ut ? Le : dt, h), S = u(() => fe(x, !0), [x]), [C, w] = f(!1), [T, E] = f(""), [pt, D] = f(-1), O = d(null), k = d(null), mt = d(null), ht = c((t) => {
40
+ k.current = t, e(v, t);
41
+ }, [v]), gt = c((t) => {
42
+ mt.current = t, e(v, t);
43
+ }, [v]), A = d(null), _t = d({
44
44
  buffer: "",
45
45
  timer: void 0
46
- }), M = h !== void 0, N = E.trim(), P = w && !v, F = M || Pe !== void 0, [gt, _t] = p(() => F ? o(/* @__PURE__ */ new Map(), m) : /* @__PURE__ */ new Map()), [vt, yt] = p(m);
47
- F && vt !== m && (yt(m), _t((e) => o(e, m)));
48
- let I = M && (N !== "" || m.length === 0), [L, bt] = p(null), [R] = p(me), z = L?.query === N, xt = I && P && !z, St = I && z && L.error, B = Re || xt, [Ct, wt] = p(!1), V = f(!1), [Tt, H] = p(!1), Et = B || Ct, U = d(() => F ? _e(gt, S) : fe(m, S), [
46
+ }), j = Pe !== void 0, M = T.trim(), N = C && !_, P = j || Ie !== void 0, [vt, yt] = f(() => P ? a(/* @__PURE__ */ new Map(), p) : /* @__PURE__ */ new Map()), [bt, xt] = f(p);
47
+ P && bt !== p && (xt(p), yt((e) => a(e, p)));
48
+ let F = j && (M !== "" || p.length === 0), [I] = f(he), [L, R] = f(null), St = d(m);
49
+ l(() => {
50
+ Object.is(St.current, m) || (St.current = m, I.cancel(), R(null));
51
+ }, [m, I]);
52
+ let z = L?.query === M, B = F && N && !z, Ct = F && z && L.error, V = Be || B, [wt, Tt] = f(!1), Et = d(!1), [Dt, H] = f(!1), Ot = V || wt, U = u(() => P ? ve(vt, x) : pe(p, x), [
53
+ P,
54
+ vt,
55
+ p,
56
+ x
57
+ ]), W = u(() => F ? z ? L.entries : [] : j ? p : g ? se(p, T) : p, [
49
58
  F,
50
- gt,
51
- m,
52
- S
53
- ]), W = d(() => I ? z ? L.entries : [] : M ? m : _ ? se(m, E) : m, [
54
- I,
55
59
  z,
56
60
  L,
57
- M,
58
- m,
59
- _,
60
- E
61
- ]), G = Pe !== void 0 && _ && !Re && !Ct, K = d(() => ge(W, E, G && !xt, ke(b.create, E)), [
61
+ j,
62
+ p,
63
+ g,
64
+ T
65
+ ]), G = Ie !== void 0 && g && !Be && !wt, K = u(() => _e(W, T, G && !B, Ae(y.create, T)), [
62
66
  W,
63
- E,
67
+ T,
64
68
  G,
65
- xt,
66
- b.create
67
- ]), Dt = d(() => ue(W), [W]), q = K.length > 0 && he(K[K.length - 1]) ? K[K.length - 1] : null, J = dt >= 0 && dt < K.length ? dt : -1, Y = U.length > 0, Ot = _ && E !== "", kt = B ? et : Tt ? b.createError : St ? b.loadError : K.length === 0 ? $e : null, At = f(h), X = f({
68
- current: S,
69
- query: E,
69
+ B,
70
+ y.create
71
+ ]), kt = u(() => ue(W), [W]), q = K.length > 0 && ge(K[K.length - 1]) ? K[K.length - 1] : null, J = pt >= 0 && pt < K.length ? pt : -1, Y = U.length > 0, At = g && T !== "", jt = V ? nt : Dt ? y.createError : Ct ? y.loadError : K.length === 0 ? tt : null, Mt = d(Pe), X = d({
72
+ current: x,
73
+ query: T,
70
74
  createAllowed: G,
71
- createPrefix: b.create
75
+ createPrefix: y.create
72
76
  });
73
- u(() => {
74
- At.current = h, X.current = {
75
- current: S,
76
- query: E,
77
+ l(() => {
78
+ Mt.current = Pe, X.current = {
79
+ current: x,
80
+ query: T,
77
81
  createAllowed: G,
78
- createPrefix: b.create
82
+ createPrefix: y.create
79
83
  };
80
- }), u(() => {
81
- if (!I || !P || z) return;
84
+ }), l(() => {
85
+ if (!F || !N || z) return;
82
86
  let e = setTimeout(() => {
83
- let e = At.current;
87
+ let e = Mt.current;
84
88
  if (!e) return;
85
- let t = R.start(), n;
89
+ let t = I.start(), n;
86
90
  try {
87
- n = e(N, { signal: t.signal });
91
+ n = e(M, { signal: t.signal });
88
92
  } catch (e) {
89
93
  n = Promise.reject(e);
90
94
  }
91
95
  n.then((e) => {
92
96
  if (!t.isCurrent()) return;
93
- _t((t) => o(t, e)), bt({
94
- query: N,
97
+ yt((t) => a(t, e)), R({
98
+ query: M,
95
99
  entries: e,
96
100
  error: !1
97
101
  });
98
- let { createAllowed: n, createPrefix: r } = X.current, ee = ge(e, N, n, ke(r, N));
99
- O(i(-1, "first", ee));
102
+ let { createAllowed: n, createPrefix: r } = X.current, ee = _e(e, M, n, Ae(r, M));
103
+ D(i(-1, "first", ee));
100
104
  }, () => {
101
- t.isCurrent() && bt({
102
- query: N,
105
+ t.isCurrent() && R({
106
+ query: M,
103
107
  entries: [],
104
108
  error: !0
105
109
  });
106
110
  });
107
- }, Ne);
111
+ }, Fe);
108
112
  return () => clearTimeout(e);
109
113
  }, [
110
- I,
111
- P,
112
- z,
114
+ F,
113
115
  N,
114
- Ne,
115
- R
116
- ]), u(() => (P || (R.cancel(), bt((e) => e?.error ? null : e), H(!1)), () => R.cancel()), [P, R]);
117
- let jt = () => (_ ? A.current : ft.current)?.focus();
118
- u(() => () => {
119
- clearTimeout(ht.current.timer);
120
- }, []), u(() => {
121
- v && (T(!1), D(""));
122
- }, [v]);
123
- let Z = l((e) => {
124
- ct || ut(e), Ze?.(e);
125
- }, [ct, Ze]), Q = l(() => {
126
- T(!1), D(""), O(-1);
116
+ z,
117
+ M,
118
+ Fe,
119
+ I
120
+ ]), l(() => (N || (I.cancel(), R((e) => e?.error ? null : e), H(!1)), () => I.cancel()), [N, I]);
121
+ let Nt = () => (g ? k.current : mt.current)?.focus();
122
+ l(() => () => {
123
+ clearTimeout(_t.current.timer);
124
+ }, []), l(() => {
125
+ _ && (w(!1), E(""));
126
+ }, [_]);
127
+ let Z = c((e) => {
128
+ ut || ft(e), $e?.(e);
129
+ }, [ut, $e]), Q = c(() => {
130
+ w(!1), E(""), D(-1);
127
131
  }, []), $ = (e = "selected") => {
128
- v || (T(!0), O(de(K, C, e)));
129
- }, Mt = (e) => {
130
- g ? (D(""), O(e === null ? -1 : de(le(m), [e], "selected")), A.current?.focus()) : Q();
131
- }, Nt = (e) => {
132
- if (V.current) return;
132
+ _ || (w(!0), D(de(K, S, e)));
133
+ }, Pt = (e) => {
134
+ h ? (E(""), D(e === null ? -1 : de(le(p), [e], "selected")), k.current?.focus()) : Q();
135
+ }, Ft = (e) => {
136
+ if (Et.current) return;
133
137
  let t = (t) => {
134
- t && (_t((e) => o(e, [t])), Z(ve(X.current.current, t.value, g))), X.current.query.trim() === e && Mt(t ? t.value : null);
138
+ t && (yt((e) => a(e, [t])), Z(ye(X.current.current, t.value, h))), X.current.query.trim() === e && Pt(t ? t.value : null);
135
139
  };
136
140
  H(!1);
137
- let n = Pe?.(e);
141
+ let n = Ie?.(e);
138
142
  if (!(n instanceof Promise)) {
139
143
  t(n);
140
144
  return;
141
145
  }
142
- V.current = !0, wt(!0);
146
+ Et.current = !0, Tt(!0);
143
147
  let r = () => {
144
- V.current = !1, wt(!1);
148
+ Et.current = !1, Tt(!1);
145
149
  };
146
150
  n.then((e) => {
147
151
  r(), t(e);
148
152
  }, (e) => {
149
153
  r(), H(!0), console.error(e);
150
154
  });
151
- }, Pt = (e) => {
155
+ }, It = (e) => {
152
156
  if (e.disabled) return;
153
- if (he(e)) {
154
- Nt(N);
157
+ if (ge(e)) {
158
+ Ft(M);
155
159
  return;
156
160
  }
157
- let t = pe(S, e.value, g);
158
- !g && t === S ? Q() : (Z(t), Mt(e.value));
159
- }, Ft = (e) => {
160
- Z(C.filter((t) => t !== e));
161
- }, It = () => {
162
- Z(g ? [] : null), D(""), jt();
163
- }, { placement: Lt, style: Rt, update: zt } = ye({
164
- open: P,
165
- anchor: k,
166
- floatingRef: j,
161
+ let t = me(x, e.value, h);
162
+ !h && t === x ? Q() : (Z(t), Pt(e.value));
163
+ }, Lt = (e) => {
164
+ Z(S.filter((t) => t !== e));
165
+ }, Rt = () => {
166
+ Z(h ? [] : null), E(""), Nt();
167
+ }, { placement: zt, style: Bt, update: Vt } = be({
168
+ open: N,
169
+ anchor: O,
170
+ floatingRef: A,
167
171
  ...ae,
168
- offset: Ee
172
+ offset: De
169
173
  });
170
- xe(() => {
171
- P && zt();
174
+ Se(() => {
175
+ N && Vt();
172
176
  }, [
173
- P,
177
+ N,
174
178
  K.length,
175
- kt,
176
- zt
177
- ]), u(() => {
178
- if (!P) return;
179
+ jt,
180
+ Vt
181
+ ]), l(() => {
182
+ if (!N) return;
179
183
  let e = (e) => {
180
184
  let t = e.target;
181
- t && (k.current?.contains(t) || j.current?.contains(t)) || Q();
185
+ t && (O.current?.contains(t) || A.current?.contains(t)) || Q();
182
186
  };
183
187
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
184
- }, [P, Q]), u(() => {
185
- if (!P || J < 0) return;
186
- let e = j.current?.querySelector(`[data-kapisel-index="${J}"]`);
188
+ }, [N, Q]), l(() => {
189
+ if (!N || J < 0) return;
190
+ let e = A.current?.querySelector(`[data-kapisel-index="${J}"]`);
187
191
  e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
188
- }, [P, J]);
189
- let Bt = (e) => {
190
- if (v) return;
192
+ }, [N, J]);
193
+ let Ht = (e) => {
194
+ if (_) return;
191
195
  let t = e.target;
192
- j.current?.contains(t) || (t.closest("[data-kapisel-action]") ? e.preventDefault() : t === A.current ? w || $() : (e.preventDefault(), jt(), w ? Q() : $()));
193
- }, Vt = (e) => {
194
- D(e), T(!0), H(!1), O(M ? -1 : i(-1, "first", ge(se(m, e), e, G, ke(b.create, e))));
195
- }, Ht = (e) => {
196
- let t = ht.current;
196
+ A.current?.contains(t) || (t.closest("[data-kapisel-action]") ? e.preventDefault() : t === k.current ? C || $() : (e.preventDefault(), Nt(), C ? Q() : $()));
197
+ }, Ut = (e) => {
198
+ E(e), w(!0), H(!1), D(j ? -1 : i(-1, "first", _e(se(p, e), e, G, Ae(y.create, e))));
199
+ }, Wt = (e) => {
200
+ let t = _t.current;
197
201
  clearTimeout(t.timer), t.buffer += e, t.timer = setTimeout(() => {
198
202
  t.buffer = "";
199
- }, De);
200
- let n = ce(K, t.buffer, w ? J : K.findIndex((e) => C.includes(e.value)));
201
- n < 0 || (w || T(!0), O(n));
202
- }, Ut = (e) => {
203
- if (!v) switch (e.key) {
203
+ }, Oe);
204
+ let n = ce(K, t.buffer, C ? J : K.findIndex((e) => S.includes(e.value)));
205
+ n < 0 || (C || w(!0), D(n));
206
+ }, Gt = (e) => {
207
+ if (!_) switch (e.key) {
204
208
  case "ArrowDown":
205
209
  case "ArrowUp":
206
- if (e.preventDefault(), !w) {
210
+ if (e.preventDefault(), !C) {
207
211
  $(e.key === "ArrowDown" ? "selected" : "last");
208
212
  return;
209
213
  }
210
- O(i(J, e.key === "ArrowDown" ? "next" : "prev", K));
214
+ D(i(J, e.key === "ArrowDown" ? "next" : "prev", K));
211
215
  break;
212
216
  case "Home":
213
217
  case "End":
214
- if (!w) break;
215
- e.preventDefault(), O(i(J, e.key === "Home" ? "first" : "last", K));
218
+ if (!C) break;
219
+ e.preventDefault(), D(i(J, e.key === "Home" ? "first" : "last", K));
216
220
  break;
217
221
  case "Enter":
218
- if (w) {
222
+ if (C) {
219
223
  e.preventDefault();
220
224
  let t = J >= 0 ? K[J] : void 0;
221
- t && Pt(t);
222
- } else _ || (e.preventDefault(), $());
225
+ t && It(t);
226
+ } else g || (e.preventDefault(), $());
223
227
  break;
224
228
  case " ":
225
- if (_) break;
226
- if (e.preventDefault(), !w) $();
229
+ if (g) break;
230
+ if (e.preventDefault(), !C) $();
227
231
  else {
228
232
  let e = J >= 0 ? K[J] : void 0;
229
- e && Pt(e);
233
+ e && It(e);
230
234
  }
231
235
  break;
232
236
  case "Escape":
233
- w && (e.preventDefault(), e.stopPropagation(), Q());
237
+ C && (e.preventDefault(), e.stopPropagation(), Q());
234
238
  break;
235
239
  case "Tab":
236
- w && Q();
240
+ C && Q();
237
241
  break;
238
242
  case "Backspace":
239
- g && E === "" && C.length > 0 && (e.preventDefault(), Ft(C[C.length - 1]));
243
+ h && T === "" && S.length > 0 && (e.preventDefault(), Lt(S[S.length - 1]));
240
244
  break;
241
- default: !_ && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), Ht(e.key));
245
+ default: !g && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), Wt(e.key));
242
246
  }
243
- }, Wt = (e) => {
244
- n(e.relatedTarget, k.current, j.current) && (w && Q(), Xe?.(e));
245
- }, Gt = P ? ie(k.current) : null, Kt = ({ option: e, index: t }) => {
246
- let n = C.includes(e.value), r = t === J;
247
- return /* @__PURE__ */ c("li", {
248
- id: st(t),
247
+ }, Kt = (e) => {
248
+ n(e.relatedTarget, O.current, A.current) && (C && Q(), Qe?.(e));
249
+ }, qt = N ? ie(O.current) : null, Jt = ({ option: e, index: t }) => {
250
+ let n = S.includes(e.value), r = t === J;
251
+ return /* @__PURE__ */ s("li", {
252
+ id: lt(t),
249
253
  role: "option",
250
254
  "aria-selected": n,
251
255
  "aria-disabled": e.disabled || void 0,
@@ -258,186 +262,186 @@ var Ee = 6, De = 500, Oe = [], ke = (e, t) => `${e} “${t.trim()}”`, Ae = ({
258
262
  e.disabled && "kapisel__opt--disabled"
259
263
  ].filter(Boolean).join(" "),
260
264
  onMouseMove: () => {
261
- !e.disabled && !r && O(t);
265
+ !e.disabled && !r && D(t);
262
266
  },
263
- onClick: () => Pt(e),
264
- children: [/* @__PURE__ */ s("span", {
267
+ onClick: () => It(e),
268
+ children: [/* @__PURE__ */ o("span", {
265
269
  className: "kapisel__opt-body",
266
- children: Ve && e !== q ? Ve(e) : e.label
267
- }), n && /* @__PURE__ */ s(Se, {
270
+ children: Ue && e !== q ? Ue(e) : e.label
271
+ }), n && /* @__PURE__ */ o(Ce, {
268
272
  className: "kapisel__check",
269
273
  size: 15,
270
274
  strokeWidth: 2.4,
271
275
  "aria-hidden": "true"
272
276
  })]
273
277
  }, `${e.value}-${t}`);
274
- }, qt = {
278
+ }, Yt = {
275
279
  role: "combobox",
276
- ...t(rt, {
277
- id: x,
278
- describedBy: ot,
279
- labelable: _,
280
- ariaLabel: Je
280
+ ...t(at, {
281
+ id: b,
282
+ describedBy: ct,
283
+ labelable: g,
284
+ ariaLabel: Xe
281
285
  }),
282
286
  "aria-haspopup": "listbox",
283
- "aria-expanded": P,
284
- "aria-controls": P ? at : void 0,
285
- "aria-activedescendant": P && J >= 0 ? st(J) : void 0,
286
- "aria-label": Je,
287
- "aria-disabled": v || void 0,
288
- "aria-busy": Et || void 0
289
- }, Jt = !Y && !Ot && /* @__PURE__ */ s("span", {
287
+ "aria-expanded": N,
288
+ "aria-controls": N ? st : void 0,
289
+ "aria-activedescendant": N && J >= 0 ? lt(J) : void 0,
290
+ "aria-label": Xe,
291
+ "aria-disabled": _ || void 0,
292
+ "aria-busy": Ot || void 0
293
+ }, Xt = !Y && !At && /* @__PURE__ */ o("span", {
290
294
  className: "kapisel__placeholder",
291
295
  "aria-hidden": "true",
292
- children: Qe
296
+ children: et
293
297
  });
294
- return /* @__PURE__ */ c("div", {
295
- ref: k,
296
- className: Ae({
297
- size: nt,
298
- open: P,
299
- disabled: v,
300
- multi: g,
301
- className: Ke
298
+ return /* @__PURE__ */ s("div", {
299
+ ref: O,
300
+ className: je({
301
+ size: it,
302
+ open: N,
303
+ disabled: _,
304
+ multi: h,
305
+ className: Je
302
306
  }),
303
- style: qe,
304
- onMouseDown: Bt,
307
+ style: Ye,
308
+ onMouseDown: Ht,
305
309
  children: [
306
- /* @__PURE__ */ c("div", {
310
+ /* @__PURE__ */ s("div", {
307
311
  className: "kapisel__values",
308
- children: [g && U.map((e) => /* @__PURE__ */ c("span", {
312
+ children: [h && U.map((e) => /* @__PURE__ */ s("span", {
309
313
  className: "kapisel__chip",
310
- children: [/* @__PURE__ */ s("span", {
314
+ children: [/* @__PURE__ */ o("span", {
311
315
  className: "kapisel__chip-label",
312
316
  children: e.label
313
- }), /* @__PURE__ */ s("button", {
317
+ }), /* @__PURE__ */ o("button", {
314
318
  type: "button",
315
319
  tabIndex: -1,
316
320
  "data-kapisel-action": !0,
317
321
  className: "kapisel__chip-x",
318
- "aria-label": `${b.remove} ${e.label}`,
319
- disabled: v,
320
- onClick: () => Ft(e.value),
321
- children: /* @__PURE__ */ s(we, {
322
+ "aria-label": `${y.remove} ${e.label}`,
323
+ disabled: _,
324
+ onClick: () => Lt(e.value),
325
+ children: /* @__PURE__ */ o(Te, {
322
326
  size: 12,
323
327
  strokeWidth: 2.6,
324
328
  "aria-hidden": "true"
325
329
  })
326
330
  })]
327
- }, e.value)), _ ? /* @__PURE__ */ c("div", {
331
+ }, e.value)), g ? /* @__PURE__ */ s("div", {
328
332
  className: "kapisel__inputwrap",
329
333
  children: [
330
- !g && Y && !Ot && /* @__PURE__ */ s("span", {
334
+ !h && Y && !At && /* @__PURE__ */ o("span", {
331
335
  className: "kapisel__single",
332
336
  "aria-hidden": "true",
333
337
  children: U[0]?.label
334
338
  }),
335
- Jt,
336
- /* @__PURE__ */ s("input", {
337
- ...qt,
338
- ref: pt,
339
+ Xt,
340
+ /* @__PURE__ */ o("input", {
341
+ ...Yt,
342
+ ref: ht,
339
343
  type: "text",
340
344
  className: "kapisel__input",
341
345
  autoComplete: "off",
342
346
  "aria-autocomplete": "list",
343
- disabled: v,
344
- value: E,
345
- onChange: (e) => Vt(e.target.value),
346
- onKeyDown: Ut,
347
- onBlur: Wt
347
+ disabled: _,
348
+ value: T,
349
+ onChange: (e) => Ut(e.target.value),
350
+ onKeyDown: Gt,
351
+ onBlur: Kt
348
352
  })
349
353
  ]
350
- }) : /* @__PURE__ */ c("div", {
351
- ...qt,
352
- ref: mt,
354
+ }) : /* @__PURE__ */ s("div", {
355
+ ...Yt,
356
+ ref: gt,
353
357
  className: "kapisel__combo",
354
- tabIndex: v ? -1 : 0,
355
- onKeyDown: Ut,
356
- onBlur: Wt,
357
- children: [!g && Y && /* @__PURE__ */ s("span", {
358
+ tabIndex: _ ? -1 : 0,
359
+ onKeyDown: Gt,
360
+ onBlur: Kt,
361
+ children: [!h && Y && /* @__PURE__ */ o("span", {
358
362
  className: "kapisel__single",
359
363
  "aria-hidden": "true",
360
364
  children: U[0]?.label
361
- }), Jt]
365
+ }), Xt]
362
366
  })]
363
367
  }),
364
- /* @__PURE__ */ s("span", {
365
- id: ot,
368
+ /* @__PURE__ */ o("span", {
369
+ id: ct,
366
370
  className: "kapisel__sr",
367
- children: oe(U, Qe)
371
+ children: oe(U, et)
368
372
  }),
369
- Et && /* @__PURE__ */ s("span", {
373
+ Ot && /* @__PURE__ */ o("span", {
370
374
  className: "kapisel__spinner kapi-spinner kapi-spinner--sm",
371
375
  "aria-hidden": "true"
372
376
  }),
373
- Le && Y && !v && /* @__PURE__ */ s("button", {
377
+ ze && Y && !_ && /* @__PURE__ */ o("button", {
374
378
  type: "button",
375
379
  tabIndex: -1,
376
380
  "data-kapisel-action": !0,
377
381
  className: "kapisel__clear",
378
- "aria-label": b.clear,
379
- onClick: It,
380
- children: /* @__PURE__ */ s(we, {
382
+ "aria-label": y.clear,
383
+ onClick: Rt,
384
+ children: /* @__PURE__ */ o(Te, {
381
385
  size: 15,
382
386
  strokeWidth: 2.4,
383
387
  "aria-hidden": "true"
384
388
  })
385
389
  }),
386
- /* @__PURE__ */ s("span", {
390
+ /* @__PURE__ */ o("span", {
387
391
  className: "kapisel__caret",
388
392
  "aria-hidden": "true",
389
- children: /* @__PURE__ */ s(Ce, {
393
+ children: /* @__PURE__ */ o(we, {
390
394
  size: 17,
391
395
  strokeWidth: 2.2
392
396
  })
393
397
  }),
394
- We && (g ? C.map((e) => /* @__PURE__ */ s("input", {
398
+ Ke && (h ? S.map((e) => /* @__PURE__ */ o("input", {
395
399
  type: "hidden",
396
- name: We,
400
+ name: Ke,
397
401
  value: e
398
- }, e)) : /* @__PURE__ */ s("input", {
402
+ }, e)) : /* @__PURE__ */ o("input", {
399
403
  type: "hidden",
400
- name: We,
401
- value: S ?? ""
404
+ name: Ke,
405
+ value: x ?? ""
402
406
  })),
403
- Gt && Te(/* @__PURE__ */ c("div", {
404
- ref: j,
405
- className: `kapisel__menu kapisel__menu--${Lt?.side === "top" ? "top" : "bottom"}${tt ? " kapisel__menu--hug" : ""}`,
406
- style: Rt,
407
+ qt && Ee(/* @__PURE__ */ s("div", {
408
+ ref: A,
409
+ className: `kapisel__menu kapisel__menu--${zt?.side === "top" ? "top" : "bottom"}${rt ? " kapisel__menu--hug" : ""}`,
410
+ style: Bt,
407
411
  onMouseDown: (e) => e.preventDefault(),
408
- children: [/* @__PURE__ */ c("ul", {
409
- id: at,
412
+ children: [/* @__PURE__ */ s("ul", {
413
+ id: st,
410
414
  role: "listbox",
411
- "aria-multiselectable": g || void 0,
412
- "aria-label": Je,
415
+ "aria-multiselectable": h || void 0,
416
+ "aria-label": Xe,
413
417
  className: "kapisel__list",
414
- hidden: K.length === 0 || B,
415
- children: [!B && Dt.map((e) => e.kind === "option" ? Kt(e.item) : /* @__PURE__ */ c("li", {
418
+ hidden: K.length === 0 || V,
419
+ children: [!V && kt.map((e) => e.kind === "option" ? Jt(e.item) : /* @__PURE__ */ s("li", {
416
420
  role: "presentation",
417
421
  className: "kapisel__group",
418
- children: [/* @__PURE__ */ s("div", {
422
+ children: [/* @__PURE__ */ o("div", {
419
423
  className: "kapisel__group-label",
420
424
  "aria-hidden": "true",
421
425
  children: e.label
422
- }), /* @__PURE__ */ s("ul", {
426
+ }), /* @__PURE__ */ o("ul", {
423
427
  role: "group",
424
428
  "aria-label": e.label,
425
429
  className: "kapisel__group-list",
426
- children: e.items.map(Kt)
430
+ children: e.items.map(Jt)
427
431
  })]
428
- }, e.key)), q && Kt({
432
+ }, e.key)), q && Jt({
429
433
  option: q,
430
434
  index: K.length - 1
431
435
  })]
432
- }), kt && /* @__PURE__ */ s("div", {
436
+ }), jt && /* @__PURE__ */ o("div", {
433
437
  className: "kapisel__status",
434
438
  role: "status",
435
439
  "aria-live": "polite",
436
- children: kt
440
+ children: jt
437
441
  })]
438
- }), Gt)
442
+ }), qt)
439
443
  ]
440
444
  });
441
445
  };
442
446
  //#endregion
443
- export { je as DEFAULT_SELECT_LABELS, Me as KapiSelect, Ae as selectClasses };
447
+ export { Me as DEFAULT_SELECT_LABELS, Ne as KapiSelect, je as selectClasses };