@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.
@@ -129,10 +129,10 @@ var u = {
129
129
  "aria-expanded": $,
130
130
  "aria-controls": N,
131
131
  "aria-activedescendant": $ && Q >= 0 ? F(Q) : void 0,
132
- "aria-busy": X || void 0,
133
132
  ...t(A ? null : je, {
134
133
  id: M,
135
134
  describedBy: n(P, O["aria-describedby"]),
135
+ busy: X || void 0,
136
136
  invalid: x ? x === "err" : void 0
137
137
  }),
138
138
  required: C,
@@ -20,6 +20,10 @@ export type KapiFacetedSearchLabels = {
20
20
  valueOf: string;
21
21
  /** Botón que quita todos los filtros (con `onClearAll`). */
22
22
  clearAll: string;
23
+ /** Mientras `loadOptions` de la faceta está resolviendo. */
24
+ loading: string;
25
+ /** Cuando `loadOptions` falla: el menú lo dice en vez de quedar vacío, que parece "sin datos". */
26
+ loadError: string;
23
27
  };
24
28
  export declare const DEFAULT_FACETED_SEARCH_LABELS: KapiFacetedSearchLabels;
25
29
  /** Atributos nativos (`id`, `style`, `data-*`…) van a la región `role="search"` (el rol es propio). */
@@ -30,6 +34,15 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
30
34
  chips: ReadonlyArray<KapiFacetChip>;
31
35
  /** Texto libre confirmado con Enter. */
32
36
  onText: (text: string) => void;
37
+ /** Espera tras la última tecla antes de llamar a `loadOptions` de la faceta, en ms. @default 300 */
38
+ loadDelay?: number;
39
+ /**
40
+ * Cambiar este valor tira el resultado cacheado y vuelve a pedir. Es la única forma de refrescar
41
+ * lo que cargó `loadOptions`, porque ese estado vive adentro del componente y el consumidor no
42
+ * lo puede alcanzar. Los datos que el consumidor YA tiene (filas, opciones estáticas) se
43
+ * refrescan pasando props nuevas: para eso no hace falta esto.
44
+ */
45
+ reloadKey?: unknown;
33
46
  /**
34
47
  * Con esta prop, la barra muestra "Limpiar todo" mientras haya algún chip; al tocarlo se llama una
35
48
  * sola vez (la pantalla vacía sus filtros de una, sin quitar chip por chip).
@@ -45,4 +58,4 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
45
58
  * Teclado: flechas y Enter en el desplegable, Backspace con el campo vacío suelta la faceta pendiente
46
59
  * y después el último chip, Escape cancela la faceta pendiente.
47
60
  */
48
- export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;
61
+ export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, loadDelay, reloadKey, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;
@@ -1,17 +1,18 @@
1
1
  "use client";
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
- import { joinClasses as t } from "../rootProps.js";
4
- import { KapiDatePicker as n } from "./KapiDatePicker.js";
5
- import { KapiDateRangePicker as r } from "./KapiDateRangePicker.js";
6
- import { KapiTag as i } from "../display/KapiTag.js";
7
- import { KapiPopover as a } from "../overlays/KapiPopover.js";
8
- import { facetKeyAction as o, facetMenuItems as s, facetOptionName as c, isDateFacet as l, moveActive as u, toDateRangeValue as d, toDateValue as f } from "./facetedSearchLogic.js";
3
+ import { createLoadSequencer as t } from "./asyncSelectLogic.js";
4
+ import { joinClasses as n } from "../rootProps.js";
5
+ import { KapiDatePicker as r } from "./KapiDatePicker.js";
6
+ import { KapiDateRangePicker as i } from "./KapiDateRangePicker.js";
7
+ import { KapiTag as a } from "../display/KapiTag.js";
8
+ import { KapiPopover as o } from "../overlays/KapiPopover.js";
9
+ import { facetKeyAction as ee, facetMenuItems as te, facetOptionName as ne, isDateFacet as s, moveActive as re, toDateRangeValue as c, toDateValue as l } from "./facetedSearchLogic.js";
9
10
  /* empty css */
10
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { useId as g, useRef as _, useState as v } from "react";
12
- import { Search as y } from "lucide-react";
11
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
12
+ import { useEffect as p, useId as m, useRef as h, useState as g } from "react";
13
+ import { Search as ie } from "lucide-react";
13
14
  //#region src/components/inputs/KapiFacetedSearch.tsx
14
- var b = {
15
+ var _ = {
15
16
  input: "Buscar o filtrar",
16
17
  region: "Búsqueda",
17
18
  placeholder: "Buscar o filtrar…",
@@ -20,171 +21,232 @@ var b = {
20
21
  empty: "Sin opciones",
21
22
  remove: "Quitar",
22
23
  valueOf: "Valor de",
23
- clearAll: "Limpiar todo"
24
+ clearAll: "Limpiar todo",
25
+ loading: "Buscando…",
26
+ loadError: "No se pudieron cargar los valores"
24
27
  };
25
- function x({ facets: x, chips: S, onText: C, onClearAll: w, labels: T, className: E, onMouseDown: D, "aria-label": O, ...k }) {
26
- let A = e("facetedSearch", b, T), j = g(), M = `${j}-list`, N = _(null), P = _(null), F = _(null), [I, L] = v(""), [R, z] = v(null), [B, V] = v(!1), [H, U] = v(-1), W = s(x, R, I), G = l(R), K = B && !G, q = () => requestAnimationFrame(() => P.current?.focus()), J = () => {
27
- L(""), z(null), U(-1);
28
- }, Y = () => {
29
- J(), V(!1), q();
30
- }, X = (e) => {
31
- e.type === "text" ? (C(e.text), Y()) : e.type === "option" ? (R?.apply(e.option.value), Y()) : e.facet.kind === "flag" ? (e.facet.apply("true"), Y()) : (z(e.facet), L(""), U(-1), V(!0), l(e.facet) ? requestAnimationFrame(() => F.current?.focus()) : q());
32
- }, Z = (e) => {
33
- let t = o(e.key, {
34
- input: I,
35
- pending: !!R,
36
- active: H,
37
- open: K,
38
- chips: S.length
28
+ function v({ facets: v, chips: y, onText: b, onClearAll: x, loadDelay: S = 300, reloadKey: C, labels: ae, className: oe, onMouseDown: se, "aria-label": ce, ...le }) {
29
+ let w = e("facetedSearch", _, ae), T = m(), E = `${T}-list`, D = h(null), O = h(null), k = h(null), [A, j] = g(""), [M, N] = g(null), [ue, P] = g(!1), [F, I] = g(-1), [L, R] = g(null), [z] = g(t), B = h(C);
30
+ p(() => {
31
+ Object.is(B.current, C) || (B.current = C, z.cancel(), R(null));
32
+ }, [C, z]);
33
+ let V = A.trim(), H = typeof M?.loadOptions == "function", U = H && L?.key === M?.key && L?.query === V ? L : null, W = H && !U, G = te(v, M, A, U && !U.error ? U.options : void 0), K = s(M), q = ue && !K, J = h(M?.loadOptions);
34
+ p(() => {
35
+ J.current = M?.loadOptions;
36
+ }), p(() => {
37
+ if (!H || !q || U) return;
38
+ let e = M?.key ?? "", t = setTimeout(() => {
39
+ let t = J.current;
40
+ if (!t) return;
41
+ let n = z.start(), r;
42
+ try {
43
+ r = t(V, { signal: n.signal });
44
+ } catch (e) {
45
+ r = Promise.reject(e);
46
+ }
47
+ r.then((t) => {
48
+ n.isCurrent() && (R({
49
+ key: e,
50
+ query: V,
51
+ options: t,
52
+ error: !1
53
+ }), I(-1));
54
+ }, () => {
55
+ n.isCurrent() && R({
56
+ key: e,
57
+ query: V,
58
+ options: [],
59
+ error: !0
60
+ });
61
+ });
62
+ }, S);
63
+ return () => clearTimeout(t);
64
+ }, [
65
+ H,
66
+ q,
67
+ U,
68
+ V,
69
+ S,
70
+ M?.key,
71
+ z
72
+ ]), p(() => ((!q || !M) && (z.cancel(), R((e) => e?.error ? null : e)), () => z.cancel()), [
73
+ q,
74
+ M,
75
+ z
76
+ ]);
77
+ let Y = () => requestAnimationFrame(() => O.current?.focus()), X = () => {
78
+ j(""), N(null), I(-1);
79
+ }, Z = () => {
80
+ X(), P(!1), Y();
81
+ }, Q = (e) => {
82
+ e.type === "text" ? (b(e.text), Z()) : e.type === "option" ? (M?.apply(e.option.value), Z()) : e.facet.kind === "flag" ? (e.facet.apply("true"), Z()) : (N(e.facet), j(""), I(-1), P(!0), s(e.facet) ? requestAnimationFrame(() => k.current?.focus()) : Y());
83
+ }, de = (e) => {
84
+ let t = ee(e.key, {
85
+ input: A,
86
+ pending: !!M,
87
+ active: F,
88
+ open: q,
89
+ chips: y.length
39
90
  });
40
91
  if (t) switch (e.preventDefault(), t) {
41
92
  case "next":
42
93
  case "prev":
43
- V(!0), U((e) => u(K ? e : -1, W.length, t === "next" ? 1 : -1));
94
+ P(!0), I((e) => re(q ? e : -1, G.length, t === "next" ? 1 : -1));
44
95
  break;
45
96
  case "select": {
46
- let e = W[H];
47
- e && X(e);
97
+ let e = G[F];
98
+ e && Q(e);
48
99
  break;
49
100
  }
50
101
  case "text":
51
- C(I.trim()), Y();
102
+ b(A.trim()), Z();
52
103
  break;
53
104
  case "cancel":
54
- J();
105
+ X();
55
106
  break;
56
107
  case "close":
57
- V(!1), U(-1);
108
+ P(!1), I(-1);
58
109
  break;
59
110
  case "dropPending":
60
- z(null), U(-1);
111
+ N(null), I(-1);
61
112
  break;
62
- case "removeLast": S[S.length - 1]?.onRemove();
113
+ case "removeLast": y[y.length - 1]?.onRemove();
63
114
  }
64
- }, Q = (e) => {
115
+ }, fe = (e) => {
65
116
  let t = e.target.value === "";
66
- (e.key === "Escape" || e.key === "Backspace" && t) && (e.preventDefault(), J(), q());
67
- }, $ = (e) => `${j}-opt-${e}`;
68
- return /* @__PURE__ */ h("div", {
69
- ...k,
70
- ref: N,
71
- className: t("kapi-facets", E),
117
+ (e.key === "Escape" || e.key === "Backspace" && t) && (e.preventDefault(), X(), Y());
118
+ }, $ = (e) => `${T}-opt-${e}`;
119
+ return /* @__PURE__ */ f("div", {
120
+ ...le,
121
+ ref: D,
122
+ className: n("kapi-facets", oe),
72
123
  role: "search",
73
- "aria-label": O ?? A.region,
124
+ "aria-label": ce ?? w.region,
74
125
  onMouseDown: (e) => {
75
- D?.(e), !e.defaultPrevented && e.target === e.currentTarget && (e.preventDefault(), P.current?.focus(), V(!0));
126
+ se?.(e), !e.defaultPrevented && e.target === e.currentTarget && (e.preventDefault(), O.current?.focus(), P(!0));
76
127
  },
77
128
  children: [
78
- /* @__PURE__ */ m(y, {
129
+ /* @__PURE__ */ d(ie, {
79
130
  className: "kapi-facets__icon",
80
131
  size: 15,
81
132
  "aria-hidden": !0
82
133
  }),
83
- S.map((e) => /* @__PURE__ */ m(i, {
134
+ y.map((e) => /* @__PURE__ */ d(a, {
84
135
  size: "sm",
85
136
  onRemove: () => {
86
- e.onRemove(), q();
137
+ e.onRemove(), Y();
87
138
  },
88
- removeLabel: `${A.remove} ${e.label}`,
139
+ removeLabel: `${w.remove} ${e.label}`,
89
140
  children: e.label
90
141
  }, e.key)),
91
- R && /* @__PURE__ */ h(i, {
142
+ M && /* @__PURE__ */ f(a, {
92
143
  size: "sm",
93
144
  tone: "primary",
94
145
  className: "kapi-facets__pending",
95
- children: [R.label, ":"]
146
+ children: [M.label, ":"]
96
147
  }),
97
- G && R ? /* @__PURE__ */ m("span", {
148
+ K && M ? /* @__PURE__ */ d("span", {
98
149
  className: "kapi-facets__date",
99
- onKeyDown: Q,
100
- children: R.kind === "dateRange" ? /* @__PURE__ */ m(r, {
101
- ref: F,
102
- "aria-label": `${A.valueOf} ${R.label}`,
150
+ onKeyDown: fe,
151
+ children: M.kind === "dateRange" ? /* @__PURE__ */ d(i, {
152
+ ref: k,
153
+ "aria-label": `${w.valueOf} ${M.label}`,
103
154
  onChange: ({ from: e, to: t }) => {
104
- e && t && (R.apply(d(e, t)), Y());
155
+ e && t && (M.apply(c(e, t)), Z());
105
156
  }
106
- }) : /* @__PURE__ */ m(n, {
107
- ref: F,
108
- "aria-label": `${A.valueOf} ${R.label}`,
157
+ }) : /* @__PURE__ */ d(r, {
158
+ ref: k,
159
+ "aria-label": `${w.valueOf} ${M.label}`,
109
160
  onChange: (e) => {
110
- e && (R.apply(f(e)), Y());
161
+ e && (M.apply(l(e)), Z());
111
162
  }
112
163
  })
113
- }) : /* @__PURE__ */ m("input", {
114
- ref: P,
164
+ }) : /* @__PURE__ */ d("input", {
165
+ ref: O,
115
166
  className: "kapi-facets__input",
116
167
  type: "text",
117
168
  role: "combobox",
118
169
  autoComplete: "off",
119
- "aria-label": A.input,
120
- "aria-expanded": K,
121
- "aria-controls": M,
170
+ "aria-label": w.input,
171
+ "aria-expanded": q,
172
+ "aria-controls": E,
122
173
  "aria-autocomplete": "list",
123
- "aria-activedescendant": K && H >= 0 ? $(H) : void 0,
124
- placeholder: S.length === 0 && !R ? A.placeholder : void 0,
125
- value: I,
126
- onFocus: () => V(!0),
127
- onClick: () => V(!0),
174
+ "aria-activedescendant": q && F >= 0 ? $(F) : void 0,
175
+ placeholder: y.length === 0 && !M ? w.placeholder : void 0,
176
+ value: A,
177
+ onFocus: () => P(!0),
178
+ onClick: () => P(!0),
128
179
  onBlur: (e) => {
129
180
  let t = e.relatedTarget;
130
- (!t || !N.current?.contains(t)) && V(!1);
181
+ (!t || !D.current?.contains(t)) && P(!1);
131
182
  },
132
183
  onChange: (e) => {
133
- L(e.target.value), V(!0), U(-1);
184
+ j(e.target.value), P(!0), I(-1);
134
185
  },
135
- onKeyDown: Z
186
+ onKeyDown: de
136
187
  }),
137
- w && S.length > 0 && /* @__PURE__ */ m("button", {
188
+ x && y.length > 0 && /* @__PURE__ */ d("button", {
138
189
  type: "button",
139
190
  className: "kapi-facets__clear",
140
191
  onClick: () => {
141
- w(), J(), q();
192
+ x(), X(), Y();
142
193
  },
143
- children: A.clearAll
194
+ children: w.clearAll
144
195
  }),
145
- /* @__PURE__ */ h(a, {
146
- open: K,
147
- anchorRef: N,
148
- onClose: () => V(!1),
196
+ /* @__PURE__ */ f(o, {
197
+ open: q,
198
+ anchorRef: D,
199
+ onClose: () => P(!1),
149
200
  matchAnchorWidth: !0,
150
201
  role: "listbox",
151
- id: M,
152
- "aria-label": R ? R.label : A.input,
202
+ id: E,
203
+ "aria-label": M ? M.label : w.input,
153
204
  closeOnEscape: !1,
154
205
  restoreFocus: !1,
155
206
  className: "kapi-facets__menu",
156
- children: [W.length === 0 && /* @__PURE__ */ m("div", {
157
- className: "kapi-facets__empty",
158
- children: A.empty
159
- }), W.map((e, t) => /* @__PURE__ */ m("div", {
160
- id: $(t),
161
- role: "option",
162
- "aria-selected": t === H,
163
- "aria-label": e.type === "option" ? c(e.option) : void 0,
164
- className: `kapi-facets__opt${t === H ? " kapi-facets__opt--active" : ""}`,
165
- onMouseDown: (e) => e.preventDefault(),
166
- onMouseEnter: () => U(t),
167
- onClick: () => X(e),
168
- children: e.type === "text" ? /* @__PURE__ */ h("span", { children: [
169
- A.searchFor,
170
- " “",
171
- e.text,
172
- "”"
173
- ] }) : e.type === "option" ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", { children: e.option.label }), e.option.count !== void 0 && /* @__PURE__ */ m("span", {
174
- className: "kapi-facets__count",
175
- "aria-hidden": "true",
176
- children: e.option.count
177
- })] }) : /* @__PURE__ */ h("span", { children: [/* @__PURE__ */ m("span", {
178
- className: "kapi-facets__facet",
179
- children: e.facet.label
180
- }), e.facet.kind !== "flag" && /* @__PURE__ */ h("span", {
181
- className: "kapi-facets__hint",
182
- children: [" · ", A.pickValue]
183
- })] })
184
- }, e.type === "facet" ? `f-${e.facet.key}` : e.type === "option" ? `o-${e.option.value}` : "t"))]
207
+ children: [
208
+ W && /* @__PURE__ */ d("div", {
209
+ className: "kapi-facets__empty",
210
+ children: w.loading
211
+ }),
212
+ !W && U?.error && /* @__PURE__ */ d("div", {
213
+ className: "kapi-facets__empty kapi-facets__empty--err",
214
+ children: w.loadError
215
+ }),
216
+ !W && !U?.error && G.length === 0 && /* @__PURE__ */ d("div", {
217
+ className: "kapi-facets__empty",
218
+ children: w.empty
219
+ }),
220
+ !W && !U?.error && G.map((e, t) => /* @__PURE__ */ d("div", {
221
+ id: $(t),
222
+ role: "option",
223
+ "aria-selected": t === F,
224
+ "aria-label": e.type === "option" ? ne(e.option) : void 0,
225
+ className: `kapi-facets__opt${t === F ? " kapi-facets__opt--active" : ""}`,
226
+ onMouseDown: (e) => e.preventDefault(),
227
+ onMouseEnter: () => I(t),
228
+ onClick: () => Q(e),
229
+ children: e.type === "text" ? /* @__PURE__ */ f("span", { children: [
230
+ w.searchFor,
231
+ " “",
232
+ e.text,
233
+ "”"
234
+ ] }) : e.type === "option" ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: e.option.label }), e.option.count !== void 0 && /* @__PURE__ */ d("span", {
235
+ className: "kapi-facets__count",
236
+ "aria-hidden": "true",
237
+ children: e.option.count
238
+ })] }) : /* @__PURE__ */ f("span", { children: [/* @__PURE__ */ d("span", {
239
+ className: "kapi-facets__facet",
240
+ children: e.facet.label
241
+ }), e.facet.kind !== "flag" && /* @__PURE__ */ f("span", {
242
+ className: "kapi-facets__hint",
243
+ children: [" · ", w.pickValue]
244
+ })] })
245
+ }, e.type === "facet" ? `f-${e.facet.key}` : e.type === "option" ? `o-${e.option.value}` : "t"))
246
+ ]
185
247
  })
186
248
  ]
187
249
  });
188
250
  }
189
251
  //#endregion
190
- export { b as DEFAULT_FACETED_SEARCH_LABELS, x as KapiFacetedSearch };
252
+ export { _ as DEFAULT_FACETED_SEARCH_LABELS, v as KapiFacetedSearch };
@@ -1,6 +1,10 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
2
  import { type KapiFieldContextValue } from "./fieldLogic";
3
- export type KapiFieldStatus = "ok" | "err";
3
+ /**
4
+ * `pending` es para mientras una validación asíncrona resuelve: el campo se marca ocupado pero NO
5
+ * inválido, porque pintarlo en rojo antes de saber el resultado le miente a quien lo está usando.
6
+ */
7
+ export type KapiFieldStatus = "ok" | "err" | "pending";
4
8
  export type { KapiFieldContextValue };
5
9
  /** Atributos nativos (`id`, `style`, `data-*`…) van al contenedor; el `id` del control es `htmlFor`. */
6
10
  export type KapiFieldProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
@@ -14,7 +18,11 @@ export type KapiFieldProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
14
18
  help?: ReactNode | undefined;
15
19
  /** `id` del texto de ayuda. Opcional: sin él se deriva del id del control. */
16
20
  helpId?: string | undefined;
17
- /** Estado de validación: pinta la ayuda y le pone ícono; con `err` el control queda `aria-invalid`. */
21
+ /**
22
+ * Estado de validación: pinta la ayuda y le pone ícono. Con `err` el control queda `aria-invalid`
23
+ * y la ayuda interrumpe (`role="alert"`); con `pending` queda `aria-busy` y la ayuda se anuncia
24
+ * sin interrumpir (`aria-live="polite"`), que es lo que corresponde cuando todavía no pasó nada.
25
+ */
18
26
  status?: KapiFieldStatus | undefined;
19
27
  /** El control del campo (input, select…); recibe `id`, `aria-describedby` y estado del contexto. */
20
28
  children: ReactNode;
@@ -2,54 +2,61 @@
2
2
  import { fieldIds as e } from "./fieldLogic.js";
3
3
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
4
4
  import { createContext as r, useContext as i, useId as a, useMemo as o } from "react";
5
- import { AlertTriangle as s, CheckCircle2 as c } from "lucide-react";
5
+ import { AlertTriangle as s, CheckCircle2 as c, LoaderCircle as l } from "lucide-react";
6
6
  //#region src/components/inputs/KapiField.tsx
7
- var l = r(null), u = () => i(l), d = (e = "") => ["kapi-field", e].filter(Boolean).join(" "), f = (e) => ["kapi-help", e && `kapi-help--${e}`].filter(Boolean).join(" "), p = ({ label: r, htmlFor: i, required: u = !1, help: p, helpId: m, status: h, className: g, children: _, ...v }) => {
8
- let y = a(), b = !!p, { controlId: x, labelId: S, helpId: C } = e({
7
+ var u = r(null), d = () => i(u), f = (e = "") => ["kapi-field", e].filter(Boolean).join(" "), p = (e) => ["kapi-help", e && `kapi-help--${e}`].filter(Boolean).join(" "), m = ({ label: r, htmlFor: i, required: d = !1, help: m, helpId: h, status: g, className: _, children: v, ...y }) => {
8
+ let b = a(), x = !!m, { controlId: S, labelId: C, helpId: w } = e({
9
9
  htmlFor: i,
10
- autoId: y,
11
- helpId: m,
12
- hasHelp: b
13
- }), w = o(() => ({
14
- controlId: x,
15
- labelId: r == null ? void 0 : S,
16
- helpId: C,
17
- required: u,
18
- invalid: h === "err"
10
+ autoId: b,
11
+ helpId: h,
12
+ hasHelp: x
13
+ }), T = o(() => ({
14
+ controlId: S,
15
+ labelId: r == null ? void 0 : C,
16
+ helpId: w,
17
+ required: d,
18
+ invalid: g === "err",
19
+ busy: g === "pending"
19
20
  }), [
20
- x,
21
21
  S,
22
- r,
23
22
  C,
24
- u,
25
- h
23
+ r,
24
+ w,
25
+ d,
26
+ g
26
27
  ]);
27
- return /* @__PURE__ */ t(l.Provider, {
28
- value: w,
28
+ return /* @__PURE__ */ t(u.Provider, {
29
+ value: T,
29
30
  children: /* @__PURE__ */ n("div", {
30
- ...v,
31
- className: d(g),
31
+ ...y,
32
+ className: f(_),
32
33
  children: [
33
34
  r != null && /* @__PURE__ */ n("label", {
34
- id: S,
35
- htmlFor: x,
36
- children: [r, u && " *"]
37
- }),
38
- _,
39
- b ? /* @__PURE__ */ n("span", {
40
35
  id: C,
41
- className: f(h),
42
- role: h === "err" ? "alert" : void 0,
36
+ htmlFor: S,
37
+ children: [r, d && " *"]
38
+ }),
39
+ v,
40
+ x ? /* @__PURE__ */ n("span", {
41
+ id: w,
42
+ className: p(g),
43
+ role: g === "err" ? "alert" : void 0,
44
+ "aria-live": g === "pending" ? "polite" : void 0,
43
45
  children: [
44
- h === "ok" && /* @__PURE__ */ t(c, {
46
+ g === "ok" && /* @__PURE__ */ t(c, {
45
47
  size: 13,
46
48
  strokeWidth: 2.2
47
49
  }),
48
- h === "err" && /* @__PURE__ */ t(s, {
50
+ g === "err" && /* @__PURE__ */ t(s, {
49
51
  size: 13,
50
52
  strokeWidth: 2.2
51
53
  }),
52
- p
54
+ g === "pending" && /* @__PURE__ */ t(l, {
55
+ size: 13,
56
+ strokeWidth: 2.2,
57
+ className: "kapi-spinner"
58
+ }),
59
+ m
53
60
  ]
54
61
  }) : null
55
62
  ]
@@ -57,4 +64,4 @@ var l = r(null), u = () => i(l), d = (e = "") => ["kapi-field", e].filter(Boolea
57
64
  });
58
65
  };
59
66
  //#endregion
60
- export { p as KapiField, d as fieldClasses, f as helpClasses, u as useKapiField };
67
+ export { m as KapiField, f as fieldClasses, p as helpClasses, d as useKapiField };
@@ -40,6 +40,13 @@ export interface KapiSelectBaseProps<T = unknown> {
40
40
  }) => Promise<KapiSelectEntry<T>[]>;
41
41
  /** Espera tras la última tecla antes de llamar a `loadOptions`, en ms. @default 300 */
42
42
  loadDelay?: number;
43
+ /**
44
+ * Cambiar este valor tira el resultado cacheado y vuelve a pedir. Es la única forma de refrescar
45
+ * lo que cargó `loadOptions`, porque ese estado vive adentro del componente y el consumidor no
46
+ * lo puede alcanzar. Los datos que el consumidor YA tiene (filas, opciones estáticas) se
47
+ * refrescan pasando props nuevas: para eso no hace falta esto.
48
+ */
49
+ reloadKey?: unknown;
43
50
  /** Ofrece "Crear “texto”" si ninguna opción coincide exacto; si devuelve una opción, se elige. Una promesa debe terminar (resolver o rechazar): mientras está pendiente no se puede crear otra. */
44
51
  onCreate?: (text: string) => KapiSelectOption<T> | void | Promise<KapiSelectOption<T> | void>;
45
52
  /** Filtrar tipeando. Default `true`. */