@kapiuara/ui 0.5.0 → 0.7.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.
Files changed (74) hide show
  1. package/README.md +123 -5
  2. package/dist/components/chat/KapiChatDivider.d.ts +15 -0
  3. package/dist/components/chat/KapiChatDivider.js +17 -0
  4. package/dist/components/chat/KapiChatList.d.ts +57 -0
  5. package/dist/components/chat/KapiChatList.js +71 -0
  6. package/dist/components/chat/KapiChatThread.d.ts +35 -0
  7. package/dist/components/chat/KapiChatThread.js +85 -0
  8. package/dist/components/chat/KapiComposer.d.ts +60 -0
  9. package/dist/components/chat/KapiComposer.js +91 -0
  10. package/dist/components/chat/KapiMessageBubble.d.ts +43 -0
  11. package/dist/components/chat/KapiMessageBubble.js +67 -0
  12. package/dist/components/chat/KapiTypingIndicator.d.ts +27 -0
  13. package/dist/components/chat/KapiTypingIndicator.js +34 -0
  14. package/dist/components/chat/chatLogic.d.ts +76 -0
  15. package/dist/components/chat/chatLogic.js +34 -0
  16. package/dist/components/chat/index.d.ts +14 -0
  17. package/dist/components/data/KapiTable.d.ts +25 -1
  18. package/dist/components/data/KapiTable.js +408 -390
  19. package/dist/components/data/index.d.ts +1 -1
  20. package/dist/components/data/tableLogic.d.ts +7 -0
  21. package/dist/components/data/tableLogic.js +21 -16
  22. package/dist/components/display/KapiCommentComposer.d.ts +4 -0
  23. package/dist/components/display/KapiCommentComposer.js +43 -46
  24. package/dist/components/display/commentLogic.d.ts +9 -2
  25. package/dist/components/display/commentLogic.js +1 -1
  26. package/dist/components/display/index.d.ts +1 -0
  27. package/dist/components/inputs/KapiButton.d.ts +9 -2
  28. package/dist/components/inputs/KapiButton.js +25 -15
  29. package/dist/components/inputs/KapiFacetedSearch.d.ts +29 -5
  30. package/dist/components/inputs/KapiFacetedSearch.js +161 -119
  31. package/dist/components/inputs/KapiSegmented.d.ts +2 -1
  32. package/dist/components/inputs/KapiSegmented.js +45 -44
  33. package/dist/components/inputs/facetedSearchLogic.d.ts +40 -9
  34. package/dist/components/inputs/facetedSearchLogic.js +38 -20
  35. package/dist/components/inputs/index.d.ts +2 -2
  36. package/dist/components/layout/KapiPanelParts.js +9 -9
  37. package/dist/components/layout/KapiRail.d.ts +1 -1
  38. package/dist/components/layout/KapiRail.js +60 -53
  39. package/dist/components/layout/KapiShell.d.ts +9 -2
  40. package/dist/components/layout/KapiShell.js +22 -22
  41. package/dist/components/locale/labelRegistry.d.ts +10 -0
  42. package/dist/components/navigation/KapiContextPanel.js +86 -86
  43. package/dist/components/navigation/KapiPanelGroup.js +18 -18
  44. package/dist/components/navigation/KapiTabs.d.ts +3 -1
  45. package/dist/components/navigation/KapiTabs.js +47 -46
  46. package/dist/components/navigation/MiniNavItem.js +1 -1
  47. package/dist/components/overlays/KapiCanvasForm.js +2 -6
  48. package/dist/components/overlays/KapiConfirm.js +1 -6
  49. package/dist/hooks/colorLogic.d.ts +26 -0
  50. package/dist/hooks/colorLogic.js +53 -0
  51. package/dist/hooks/dateFormat.d.ts +7 -0
  52. package/dist/hooks/dateFormat.js +16 -2
  53. package/dist/hooks/index.d.ts +7 -1
  54. package/dist/hooks/numberFormatLogic.d.ts +6 -0
  55. package/dist/hooks/numberFormatLogic.js +7 -0
  56. package/dist/hooks/rightClick.d.ts +10 -0
  57. package/dist/hooks/rightClick.js +10 -4
  58. package/dist/hooks/themeColorsLogic.d.ts +11 -0
  59. package/dist/hooks/themeColorsLogic.js +37 -0
  60. package/dist/hooks/themeContrastLogic.d.ts +23 -0
  61. package/dist/hooks/themeContrastLogic.js +46 -0
  62. package/dist/hooks/themeDeriveLogic.d.ts +52 -0
  63. package/dist/hooks/themeDeriveLogic.js +103 -0
  64. package/dist/hooks/useDragScroll.js +26 -23
  65. package/dist/hooks/useGlobalRightClick.js +28 -25
  66. package/dist/hooks/useKapiTheme.d.ts +28 -4
  67. package/dist/hooks/useKapiTheme.js +82 -50
  68. package/dist/hooks/useSubmitDraft.d.ts +34 -0
  69. package/dist/hooks/useSubmitDraft.js +28 -0
  70. package/dist/index.d.ts +1 -0
  71. package/dist/index.js +129 -119
  72. package/dist/kapi.css +1 -1
  73. package/dist/kapi.layered.css +1 -1
  74. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  export { KapiTable, DEFAULT_TABLE_LABELS } from "./KapiTable";
2
- export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableLabels, KapiTableProps } from "./KapiTable";
2
+ export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableLabels, KapiTableProps, KapiTableSelectionPreset } from "./KapiTable";
3
3
  export { KapiTableFilter, DEFAULT_TABLE_FILTER_LABELS } from "./KapiTableFilter";
4
4
  export type { KapiTableFilterProps, KapiTableFilterLabels } from "./KapiTableFilter";
5
5
  export { KapiPagination } from "./KapiPagination";
@@ -1,5 +1,7 @@
1
1
  /** Ancho de la columna de checkboxes (px). Las columnas sticky arrancan después de ésta. */
2
2
  export declare const CHECKBOX_COL_WIDTH = 46;
3
+ /** Ancho de la columna de selección cuando la cabecera suma el menú de condiciones (`selectionPresets`). */
4
+ export declare const CHECKBOX_PRESETS_COL_WIDTH = 80;
3
5
  /** Ancho de la columna del expansor de fila (px). Las columnas sticky arrancan después de ésta. */
4
6
  export declare const EXPANDER_COL_WIDTH = 44;
5
7
  /** Ancho asumido para una columna sticky sin `width`. */
@@ -113,6 +115,11 @@ export declare const toggleAllIds: <K>(selected: ReadonlySet<K>, rowIds: Readonl
113
115
  export declare const rangeBetween: <K>(ids: ReadonlyArray<K>, anchorId: K, targetId: K) => K[];
114
116
  /** Suma (`select`) o quita el tramo `rangeIds` de la selección, sin mutar. Respeta los ids fuera del tramo. */
115
117
  export declare const applyRangeSelection: <K>(selected: ReadonlySet<K>, rangeIds: ReadonlyArray<K>, select: boolean) => Set<K>;
118
+ /**
119
+ * Selection after picking a condition: inside `rowIds` (what the table knows) the selection becomes
120
+ * exactly `nextIds`; ids of `selected` outside `rowIds` are kept. Does not mutate.
121
+ */
122
+ export declare const selectOnlyWithin: <K>(selected: ReadonlySet<K>, rowIds: ReadonlyArray<K>, nextIds: ReadonlyArray<K>) => Set<K>;
116
123
  /** Mapa `key → mostrada`. Una clave ausente cuenta como visible. */
117
124
  export type KapiTableColumnVisibility = Record<string, boolean>;
118
125
  /** Columnas que se muestran: todas salvo las marcadas explícitamente con `false`. */
@@ -106,33 +106,38 @@ var e = (e, t = 0, n = 170) => {
106
106
  }, y = (e, t, n) => {
107
107
  let r = new Set(e);
108
108
  return t.forEach((e) => n ? r.add(e) : r.delete(e)), r;
109
- }, b = (e, t) => e.filter((e) => t?.[e.key] !== !1), x = (e, t) => ({
109
+ }, b = (e, t, n) => {
110
+ let r = new Set(t), i = /* @__PURE__ */ new Set();
111
+ return e.forEach((e) => {
112
+ r.has(e) || i.add(e);
113
+ }), n.forEach((e) => i.add(e)), i;
114
+ }, x = (e, t) => e.filter((e) => t?.[e.key] !== !1), S = (e, t) => ({
110
115
  ...e,
111
116
  [t]: e?.[t] === !1
112
- }), S = (e, t = 60) => Math.max(t, Math.round(e)), C = (e, t) => t?.[e.key] ?? e.width, w = (e, t, n, r, i = 60) => ({
117
+ }), C = (e, t = 60) => Math.max(t, Math.round(e)), w = (e, t) => t?.[e.key] ?? e.width, T = (e, t, n, r, i = 60) => ({
113
118
  ...e,
114
- [t]: S(n + r, i)
115
- }), T = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), E = (e) => T(e).split(/\s+/).filter(Boolean), D = (e) => e == null ? "" : e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : T(String(e)), O = (e, t) => {
119
+ [t]: C(n + r, i)
120
+ }), E = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), D = (e) => E(e).split(/\s+/).filter(Boolean), O = (e) => e == null ? "" : e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : E(String(e)), k = (e, t) => {
116
121
  if (t.length === 0) return !0;
117
- let n = e.map(D);
122
+ let n = e.map(O);
118
123
  return t.every((e) => n.some((t) => t.includes(e)));
119
- }, k = (e, t, n) => {
120
- let r = E(n);
121
- return r.length === 0 ? e : e.filter((e) => O(t(e), r));
122
- }, A = (e) => E(e.text).length > 0, j = (e, t) => {
124
+ }, A = (e, t, n) => {
125
+ let r = D(n);
126
+ return r.length === 0 ? e : e.filter((e) => k(t(e), r));
127
+ }, j = (e) => D(e.text).length > 0, M = (e, t) => {
123
128
  let n = e.filter((e) => e.filterable !== !1), r = t === null ? void 0 : n.find((e) => e.key === t);
124
129
  return r ? [r] : n;
125
- }, M = /^[+-]?\d+([.,]\d+)?$/, N = /^[=+\-@\t\r]/, P = (e, t = ",") => {
130
+ }, N = /^[+-]?\d+([.,]\d+)?$/, P = /^[=+\-@\t\r]/, F = (e, t = ",") => {
126
131
  if (e == null) return "";
127
132
  let n;
128
- return n = e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : String(e), typeof e == "string" && N.test(n) && !M.test(n) && (n = `'${n}`), n.includes("\"") || n.includes(t) || /[\r\n]/.test(n) ? `"${n.replace(/"/g, "\"\"")}"` : n;
129
- }, F = (e, t, n = ",") => [e, ...t].map((e) => e.map((e) => P(e, n)).join(n)).join("\r\n"), I = (e) => typeof e.label == "string" || typeof e.label == "number" ? String(e.label) : e.key, L = (e) => {
133
+ return n = e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : String(e), typeof e == "string" && P.test(n) && !N.test(n) && (n = `'${n}`), n.includes("\"") || n.includes(t) || /[\r\n]/.test(n) ? `"${n.replace(/"/g, "\"\"")}"` : n;
134
+ }, I = (e, t, n = ",") => [e, ...t].map((e) => e.map((e) => F(e, n)).join(n)).join("\r\n"), L = (e) => typeof e.label == "string" || typeof e.label == "number" ? String(e.label) : e.key, R = (e) => {
130
135
  let t = e?.trim() || "tabla";
131
136
  return /\.csv$/i.test(t) ? t : `${t}.csv`;
132
- }, R = (e) => j(e, null).map((e) => ({
137
+ }, z = (e) => M(e, null).map((e) => ({
133
138
  value: e.key,
134
- label: I(e)
135
- })), z = (e, t, n, r, i) => {
139
+ label: L(e)
140
+ })), B = (e, t, n, r, i) => {
136
141
  let a;
137
142
  if (i) a = i(e);
138
143
  else {
@@ -142,4 +147,4 @@ var e = (e, t = 0, n = 170) => {
142
147
  return a?.trim() ? `${r.selectRowNamed} ${a.trim()}` : `${r.selectRow} ${n}`;
143
148
  };
144
149
  //#endregion
145
- export { y as applyRangeSelection, F as buildCsv, S as clampColumnWidth, l as compareSortValues, i as computePagination, e as computeStickyOffsets, n as computeVisibleRange, P as csvCell, L as csvFileName, I as csvHeaderOf, C as effectiveColumnWidth, R as filterColumnOptions, k as filterRows, j as filterSearchColumns, E as filterTerms, A as isFilterActive, t as lastStickyIndex, r as nextScrollWindow, m as nextSortState, T as normalizeFilterText, p as paginateRows, v as rangeBetween, d as readCell, w as resizeColumn, O as rowMatchesFilter, z as rowSelectLabel, c as safeLocale, h as selectionState, u as sortRows, f as sortRowsByColumn, _ as toggleAllIds, x as toggleColumnVisibility, g as toggleId, b as visibleColumnsOf };
150
+ export { y as applyRangeSelection, I as buildCsv, C as clampColumnWidth, l as compareSortValues, i as computePagination, e as computeStickyOffsets, n as computeVisibleRange, F as csvCell, R as csvFileName, L as csvHeaderOf, w as effectiveColumnWidth, z as filterColumnOptions, A as filterRows, M as filterSearchColumns, D as filterTerms, j as isFilterActive, t as lastStickyIndex, r as nextScrollWindow, m as nextSortState, E as normalizeFilterText, p as paginateRows, v as rangeBetween, d as readCell, T as resizeColumn, k as rowMatchesFilter, B as rowSelectLabel, c as safeLocale, b as selectOnlyWithin, h as selectionState, u as sortRows, f as sortRowsByColumn, _ as toggleAllIds, S as toggleColumnVisibility, g as toggleId, x as visibleColumnsOf };
@@ -45,5 +45,9 @@ export type KapiCommentComposerProps = Omit<TextareaHTMLAttributes<HTMLTextAreaE
45
45
  /** Ref al `<textarea>`. */
46
46
  ref?: Ref<HTMLTextAreaElement>;
47
47
  };
48
+ /**
49
+ * Compositor de comentarios: textarea que crece con el texto + botón de envío. Ctrl/Cmd+Enter envía,
50
+ * Enter solo hace salto de línea; el botón queda deshabilitado mientras no haya texto.
51
+ */
48
52
  export declare const KapiCommentComposer: ({ value: valueProp, defaultValue, onChange, onSubmit, loading, invalid, required, disabled, className, style, labels, ref, placeholder, onKeyDown, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: KapiCommentComposerProps) => import("react").JSX.Element;
49
53
  export {};
@@ -6,71 +6,68 @@ import { useLabels as i } from "../locale/KapiLocaleProvider.js";
6
6
  import { joinClasses as a } from "../rootProps.js";
7
7
  import { KapiTextarea as o } from "../inputs/KapiTextarea.js";
8
8
  /* empty css */
9
- import { canSubmitComment as s, draftAfterSubmit as c, isSubmitShortcut as l } from "./commentLogic.js";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
- import { useId as f, useRef as p, useState as m } from "react";
9
+ import { isSubmitShortcut as s } from "./commentLogic.js";
10
+ import { useSubmitDraft as c } from "../../hooks/useSubmitDraft.js";
11
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
12
+ import { useId as d } from "react";
12
13
  //#region src/components/display/KapiCommentComposer.tsx
13
- var h = {
14
+ var f = {
14
15
  label: "Comentario",
15
16
  placeholder: "Escribe un comentario…",
16
17
  submit: "Comentar",
17
18
  shortcut: "Ctrl o ⌘ + Enter para enviar"
18
- }, g = (e) => typeof e?.then == "function", _ = ({ value: _, defaultValue: v = "", onChange: y, onSubmit: b, loading: x = !1, invalid: S, required: C, disabled: w, className: T, style: E, labels: D, ref: O, placeholder: k, onKeyDown: A, "aria-label": j, "aria-labelledby": M, "aria-describedby": N, ...P }) => {
19
- let F = i("commentComposer", h, D), I = r(), [L, R] = m(v), z = _ ?? L, B = f(), V = p(null), [H, U] = m(!1), W = x || H, G = s(z, {
20
- disabled: w,
21
- loading: W
22
- }), K = (e) => {
23
- _ === void 0 && R(e), y?.(e);
24
- }, q = () => {
25
- if (!G) return;
26
- let e = z.trim(), t = b(e);
27
- V.current?.focus(), g(t) ? (U(!0), Promise.resolve(t).then(() => {
28
- _ === void 0 && R((t) => c(t, e));
29
- }, (e) => console.error(e)).finally(() => U(!1))) : _ === void 0 && R("");
30
- }, J = (e) => {
31
- A?.(e), !e.defaultPrevented && l({
19
+ }, p = ({ value: p, defaultValue: m, onChange: h, onSubmit: g, loading: _ = !1, invalid: v, required: y, disabled: b, className: x, style: S, labels: C, ref: w, placeholder: T, onKeyDown: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k, ...A }) => {
20
+ let j = i("commentComposer", f, C), M = r(), N = d(), { text: P, setText: F, submit: I, busy: L, canSubmit: R, boxRef: z } = c({
21
+ value: p,
22
+ defaultValue: m,
23
+ onChange: h,
24
+ onSubmit: g,
25
+ disabled: b,
26
+ loading: _
27
+ }), B = (e) => {
28
+ E?.(e), !e.defaultPrevented && s({
32
29
  ...e,
33
30
  isComposing: e.nativeEvent.isComposing
34
- }) && (e.preventDefault(), q());
35
- }, Y = j !== void 0 || M !== void 0 || I !== null;
36
- return /* @__PURE__ */ d("div", {
37
- className: a("kapi-composer", T),
38
- style: E,
39
- children: [/* @__PURE__ */ u(o, {
40
- ...P,
31
+ }) && (e.preventDefault(), I());
32
+ }, V = D !== void 0 || O !== void 0 || M !== null;
33
+ return /* @__PURE__ */ u("div", {
34
+ className: a("kapi-composer", x),
35
+ style: S,
36
+ children: [/* @__PURE__ */ l(o, {
37
+ ...A,
41
38
  ref: (e) => {
42
- V.current = e, t(O, e);
39
+ z.current = e, t(w, e);
43
40
  },
44
41
  className: "kapi-composer__input",
45
42
  autosize: !0,
46
43
  maxRows: 8,
47
44
  rows: 2,
48
- value: z,
49
- disabled: w,
50
- placeholder: k ?? F.placeholder,
51
- "aria-label": Y ? j : F.label,
52
- "aria-labelledby": M,
53
- "aria-describedby": n(N, B),
54
- ...C === void 0 ? {} : { required: C },
55
- ...S ? { status: "err" } : {},
56
- onChange: (e) => K(e.target.value),
57
- onKeyDown: J
58
- }), /* @__PURE__ */ d("div", {
45
+ value: P,
46
+ disabled: b,
47
+ placeholder: T ?? j.placeholder,
48
+ "aria-label": V ? D : j.label,
49
+ "aria-labelledby": O,
50
+ "aria-describedby": n(k, N),
51
+ ...y === void 0 ? {} : { required: y },
52
+ ...v ? { status: "err" } : {},
53
+ onChange: (e) => F(e.target.value),
54
+ onKeyDown: B
55
+ }), /* @__PURE__ */ u("div", {
59
56
  className: "kapi-composer__foot",
60
- children: [/* @__PURE__ */ u("span", {
61
- id: B,
57
+ children: [/* @__PURE__ */ l("span", {
58
+ id: N,
62
59
  className: "kapi-composer__hint",
63
- children: F.shortcut
64
- }), /* @__PURE__ */ u(e, {
60
+ children: j.shortcut
61
+ }), /* @__PURE__ */ l(e, {
65
62
  variant: "primary",
66
63
  size: "sm",
67
- disabled: !G,
68
- "aria-busy": W || void 0,
69
- onClick: q,
70
- children: F.submit
64
+ disabled: !R,
65
+ "aria-busy": L || void 0,
66
+ onClick: I,
67
+ children: j.submit
71
68
  })]
72
69
  })]
73
70
  });
74
71
  };
75
72
  //#endregion
76
- export { h as DEFAULT_COMMENT_COMPOSER_LABELS, _ as KapiCommentComposer };
73
+ export { f as DEFAULT_COMMENT_COMPOSER_LABELS, p as KapiCommentComposer };
@@ -3,13 +3,20 @@ export declare const canSubmitComment: (text: string, { disabled, loading }?: {
3
3
  disabled?: boolean | undefined;
4
4
  loading?: boolean | undefined;
5
5
  }) => boolean;
6
- /** Ctrl+Enter o Cmd+Enter envían; Enter solo es salto de línea. Nunca en medio de una composición (IME). */
6
+ /** Atajo que envía: `"modifier"` (Ctrl/Cmd+Enter) o `"enter"` (Enter solo). */
7
+ export type KapiSubmitShortcut = "modifier" | "enter";
8
+ /**
9
+ * Decide si una tecla envía. Con `"modifier"` (default) envían Ctrl+Enter y Cmd+Enter, y Enter solo es
10
+ * salto de línea. Con `"enter"` envía Enter; Shift+Enter, Ctrl+Enter y Cmd+Enter son salto de línea.
11
+ * En ambos modos, nunca en medio de una composición (IME).
12
+ */
7
13
  export declare const isSubmitShortcut: (e: {
8
14
  key: string;
9
15
  ctrlKey: boolean;
10
16
  metaKey: boolean;
17
+ shiftKey?: boolean | undefined;
11
18
  isComposing?: boolean | undefined;
12
- }) => boolean;
19
+ }, mode?: KapiSubmitShortcut) => boolean;
13
20
  /**
14
21
  * Borrador que queda después de un envío que resolvió: lo enviado se quita del principio (lo escrito
15
22
  * mientras el envío corría se conserva, sin repetir lo que ya se publicó); si el borrador cambió de otra
@@ -1,5 +1,5 @@
1
1
  //#region src/components/display/commentLogic.ts
2
- var e = (e, { disabled: t = !1, loading: n = !1 } = {}) => !t && !n && e.trim().length > 0, t = (e) => e.key === "Enter" && (e.ctrlKey || e.metaKey) && !e.isComposing, n = (e, t) => {
2
+ var e = (e, { disabled: t = !1, loading: n = !1 } = {}) => !t && !n && e.trim().length > 0, t = (e, t = "modifier") => e.key !== "Enter" || e.isComposing ? !1 : t === "enter" ? !e.ctrlKey && !e.metaKey && !e.shiftKey : e.ctrlKey || e.metaKey, n = (e, t) => {
3
3
  let n = e.trimStart(), r = n.slice(t.length);
4
4
  return !n.startsWith(t) || /^[\p{L}\p{N}]/u.test(r) ? e : r.trimStart();
5
5
  };
@@ -38,3 +38,4 @@ export type { KapiCommentProps } from "./KapiComment";
38
38
  export { KapiCommentComposer, DEFAULT_COMMENT_COMPOSER_LABELS } from "./KapiCommentComposer";
39
39
  export type { KapiCommentComposerLabels, KapiCommentComposerProps } from "./KapiCommentComposer";
40
40
  export { canSubmitComment, isSubmitShortcut } from "./commentLogic";
41
+ export type { KapiSubmitShortcut } from "./commentLogic";
@@ -14,10 +14,17 @@ export type KapiButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "chi
14
14
  icon?: ReactNode;
15
15
  /** Texto del botón (va a la derecha del `icon`). */
16
16
  children?: ReactNode;
17
+ /**
18
+ * Acción en curso: deshabilita el botón (`disabled` nativo, así que tampoco manda el formulario con Enter),
19
+ * marca `aria-busy` y dibuja un spinner centrado sin cambiar el ancho. El botón pierde el foco al
20
+ * deshabilitarse, por eso el anuncio del estado pertenece a una región viva de la app, no al botón.
21
+ * @default false
22
+ */
23
+ loading?: boolean;
17
24
  /** Ref al `<button>` nativo. */
18
25
  ref?: Ref<HTMLButtonElement>;
19
26
  };
20
27
  /** Clases de un botón. Pura y exportada: es lo que se testea (no el markup). */
21
- export declare const buttonClasses: ({ variant, size, iconOnly, bordered, className }?: Pick<KapiButtonProps, "variant" | "size" | "iconOnly" | "bordered" | "className">) => string;
28
+ export declare const buttonClasses: ({ variant, size, iconOnly, bordered, loading, className }?: Pick<KapiButtonProps, "variant" | "size" | "iconOnly" | "bordered" | "loading" | "className">) => string;
22
29
  /** Botón base: variantes de color, tamaños, sólo ícono y borde. Acepta los atributos nativos de `<button>`. */
23
- export declare const KapiButton: ({ variant, size, iconOnly, bordered, icon, className, type, children, ref, ...rest }: KapiButtonProps) => import("react").JSX.Element;
30
+ export declare const KapiButton: ({ variant, size, iconOnly, bordered, icon, loading, disabled, className, type, children, ref, ...rest }: KapiButtonProps) => import("react").JSX.Element;
@@ -1,25 +1,35 @@
1
1
  "use client";
2
- import { jsxs as e } from "react/jsx-runtime";
2
+ import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  //#region src/components/inputs/KapiButton.tsx
4
- var t = ({ variant: e = "default", size: t = "md", iconOnly: n = !1, bordered: r = !1, className: i = "" } = {}) => [
4
+ var r = ({ variant: e = "default", size: t = "md", iconOnly: n = !1, bordered: r = !1, loading: i = !1, className: a = "" } = {}) => [
5
5
  "kapi-btn",
6
6
  e !== "default" && `kapi-btn--${e}`,
7
7
  t !== "md" && `kapi-btn--${t}`,
8
8
  n && "kapi-btn--iconbtn",
9
9
  r && "kapi-btn--bordered",
10
- i
11
- ].filter(Boolean).join(" "), n = ({ variant: n = "default", size: r = "md", iconOnly: i = !1, bordered: a = !1, icon: o, className: s, type: c = "button", children: l, ref: u, ...d }) => /* @__PURE__ */ e("button", {
12
- ref: u,
13
- type: c,
14
- className: t({
15
- variant: n,
16
- size: r,
17
- iconOnly: i,
18
- bordered: a,
19
- className: s
10
+ i && "is-loading",
11
+ a
12
+ ].filter(Boolean).join(" "), i = ({ variant: i = "default", size: a = "md", iconOnly: o = !1, bordered: s = !1, icon: c, loading: l = !1, disabled: u, className: d, type: f = "button", children: p, ref: m, ...h }) => /* @__PURE__ */ t("button", {
13
+ ref: m,
14
+ type: f,
15
+ className: r({
16
+ variant: i,
17
+ size: a,
18
+ iconOnly: o,
19
+ bordered: s,
20
+ loading: l,
21
+ className: d
20
22
  }),
21
- ...d,
22
- children: [o, l]
23
+ ...h,
24
+ disabled: l || u,
25
+ ...l ? { "aria-busy": !0 } : {},
26
+ children: l ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("span", {
27
+ className: "kapi-spinner kapi-btn__spinner",
28
+ "aria-hidden": "true"
29
+ }), /* @__PURE__ */ n("span", {
30
+ className: "kapi-btn__content",
31
+ children: [c, p]
32
+ })] }) : /* @__PURE__ */ n(e, { children: [c, p] })
23
33
  });
24
34
  //#endregion
25
- export { n as KapiButton, t as buttonClasses };
35
+ export { i as KapiButton, r as buttonClasses };
@@ -11,8 +11,10 @@ export type KapiFacetedSearchLabels = {
11
11
  placeholder: string;
12
12
  /** "Buscar “texto”" en el desplegable. */
13
13
  searchFor: string;
14
- /** Pista al lado de las facetas que piden valor. */
14
+ /** Pista al lado de las facetas que piden elegir un valor. */
15
15
  pickValue: string;
16
+ /** Pista al lado de las facetas de texto (`kind: "text"`), que piden escribirlo. */
17
+ typeValue: string;
16
18
  empty: string;
17
19
  /** Prefijo del botón × de cada chip ("Quitar Estado: Pendiente"). */
18
20
  remove: string;
@@ -24,15 +26,35 @@ export type KapiFacetedSearchLabels = {
24
26
  loading: string;
25
27
  /** Cuando `loadOptions` falla: el menú lo dice en vez de quedar vacío, que parece "sin datos". */
26
28
  loadError: string;
29
+ /** Nombre accesible del desplegable mientras se elige la comparación ("Estado: Cómo comparar"). */
30
+ pickOperator: string;
31
+ /** Comparación `eq`. */
32
+ operatorEq: string;
33
+ /** Comparación `ne`. */
34
+ operatorNe: string;
35
+ /** Comparación `contains`. */
36
+ operatorContains: string;
37
+ /** Comparación `startsWith`. */
38
+ operatorStartsWith: string;
39
+ /** Comparación `endsWith`. */
40
+ operatorEndsWith: string;
41
+ /** Comparación `gt`. */
42
+ operatorGt: string;
43
+ /** Comparación `gte`. */
44
+ operatorGte: string;
45
+ /** Comparación `lt`. */
46
+ operatorLt: string;
47
+ /** Comparación `lte`. */
48
+ operatorLte: string;
27
49
  };
28
50
  export declare const DEFAULT_FACETED_SEARCH_LABELS: KapiFacetedSearchLabels;
29
51
  /** Atributos nativos (`id`, `style`, `data-*`…) van a la región `role="search"` (el rol es propio). */
30
52
  export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "role"> & {
31
- /** Facetas que se pueden elegir (lista, fecha o flag), cada una con su `apply`. */
53
+ /** Facetas que se pueden elegir (lista, texto, fecha o flag), cada una con su `apply`. */
32
54
  facets: ReadonlyArray<KapiFacet>;
33
55
  /** Filtros activos, como chips removibles (el estado lo tiene la pantalla). */
34
56
  chips: ReadonlyArray<KapiFacetChip>;
35
- /** Texto libre confirmado con Enter. */
57
+ /** Texto libre confirmado con Enter, sin campo elegido. Con una faceta `text` pendiente va a su `apply`. */
36
58
  onText: (text: string) => void;
37
59
  /** Espera tras la última tecla antes de llamar a `loadOptions` de la faceta, en ms. @default 300 */
38
60
  loadDelay?: number;
@@ -55,7 +77,9 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
55
77
  * Búsqueda facetada (patrón Gmail/Jira): un solo campo donde se tipea texto libre (Enter) o se elige
56
78
  * una faceta y su valor; cada filtro activo queda como chip removible. Tonta a propósito: recibe las
57
79
  * facetas y los chips, y avisa con `onText` y el `apply` de cada faceta; no sabe de tablas ni backends.
58
- * Teclado: flechas y Enter en el desplegable, Backspace con el campo vacío suelta la faceta pendiente
59
- * y después el último chip, Escape cancela la faceta pendiente.
80
+ * Una faceta `text` es búsqueda libre sobre un campo elegido: el texto va a su `apply`, no a `onText`.
81
+ * Si la faceta declara `operators` (dos o más), antes del valor se elige cómo comparar.
82
+ * Teclado: flechas y Enter en el desplegable, Backspace con el campo vacío suelta el operador elegido,
83
+ * después la faceta pendiente y después el último chip, Escape cancela la faceta pendiente.
60
84
  */
61
85
  export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, loadDelay, reloadKey, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;