@kapiuara/ui 0.10.0 → 0.12.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 (92) hide show
  1. package/README.md +10 -5
  2. package/dist/components/data/KapiBarChart.d.ts +93 -0
  3. package/dist/components/data/KapiBarChart.js +88 -0
  4. package/dist/components/data/KapiEventCalendar.d.ts +70 -0
  5. package/dist/components/data/KapiEventCalendar.js +225 -0
  6. package/dist/components/data/KapiHeatmap.d.ts +62 -0
  7. package/dist/components/data/KapiHeatmap.js +120 -0
  8. package/dist/components/data/KapiLineChart.d.ts +59 -0
  9. package/dist/components/data/KapiLineChart.js +106 -0
  10. package/dist/components/data/KapiPaginationFooter.js +1 -0
  11. package/dist/components/data/KapiSparkline.d.ts +41 -0
  12. package/dist/components/data/KapiSparkline.js +55 -0
  13. package/dist/components/data/KapiTable.d.ts +25 -2
  14. package/dist/components/data/KapiTable.js +371 -359
  15. package/dist/components/data/barChartLogic.d.ts +59 -0
  16. package/dist/components/data/barChartLogic.js +53 -0
  17. package/dist/components/data/chartFrame.d.ts +112 -0
  18. package/dist/components/data/chartFrame.js +89 -0
  19. package/dist/components/data/eventCalendarLogic.d.ts +70 -0
  20. package/dist/components/data/eventCalendarLogic.js +45 -0
  21. package/dist/components/data/heatmapLogic.d.ts +15 -0
  22. package/dist/components/data/heatmapLogic.js +15 -0
  23. package/dist/components/data/index.d.ts +20 -1
  24. package/dist/components/data/lineChartLogic.d.ts +30 -0
  25. package/dist/components/data/lineChartLogic.js +21 -0
  26. package/dist/components/data/sparklineLogic.d.ts +28 -0
  27. package/dist/components/data/sparklineLogic.js +18 -0
  28. package/dist/components/display/KapiStat.d.ts +1 -1
  29. package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
  30. package/dist/components/inputs/KapiDatePicker.js +120 -106
  31. package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
  32. package/dist/components/inputs/KapiDateRangePicker.js +146 -111
  33. package/dist/components/inputs/KapiFacetedSearch.d.ts +9 -2
  34. package/dist/components/inputs/KapiFacetedSearch.js +3 -3
  35. package/dist/components/inputs/KapiSearchChip.d.ts +79 -0
  36. package/dist/components/inputs/KapiSearchChip.js +73 -0
  37. package/dist/components/inputs/datePickerLogic.d.ts +9 -0
  38. package/dist/components/inputs/datePickerLogic.js +25 -25
  39. package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
  40. package/dist/components/inputs/dateRangeLogic.js +48 -22
  41. package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
  42. package/dist/components/inputs/index.d.ts +2 -0
  43. package/dist/components/inputs/searchChipLogic.d.ts +33 -0
  44. package/dist/components/inputs/searchChipLogic.js +13 -0
  45. package/dist/components/labelsLogic.d.ts +11 -1
  46. package/dist/components/layout/KapiContextSlot.js +108 -88
  47. package/dist/components/layout/KapiMasonry.d.ts +30 -0
  48. package/dist/components/layout/KapiMasonry.js +33 -0
  49. package/dist/components/layout/KapiPageHeader.js +89 -71
  50. package/dist/components/layout/KapiRail.d.ts +8 -2
  51. package/dist/components/layout/KapiRail.js +118 -67
  52. package/dist/components/layout/KapiShell.js +67 -37
  53. package/dist/components/layout/index.d.ts +2 -0
  54. package/dist/components/layout/masonryLogic.d.ts +40 -0
  55. package/dist/components/layout/masonryLogic.js +8 -0
  56. package/dist/components/layout/railLogic.d.ts +41 -1
  57. package/dist/components/layout/railLogic.js +36 -4
  58. package/dist/components/layout/reopenBus.d.ts +53 -0
  59. package/dist/components/layout/reopenBus.js +6 -0
  60. package/dist/components/layout/useMasonrySpans.d.ts +32 -0
  61. package/dist/components/layout/useMasonrySpans.js +44 -0
  62. package/dist/components/layout/useRailOverflow.d.ts +17 -0
  63. package/dist/components/layout/useRailOverflow.js +41 -0
  64. package/dist/components/locale/labelRegistry.d.ts +12 -1
  65. package/dist/components/navigation/KapiFilterChips.js +1 -1
  66. package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
  67. package/dist/components/navigation/filterChipsLogic.js +3 -3
  68. package/dist/components/overlays/KapiConfirm.d.ts +14 -2
  69. package/dist/components/overlays/KapiConfirm.js +2 -2
  70. package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
  71. package/dist/components/overlays/KapiContextMenu.js +2 -1
  72. package/dist/components/overlays/KapiDropdown.d.ts +3 -1
  73. package/dist/components/overlays/KapiDropdown.js +29 -26
  74. package/dist/components/overlays/KapiMenuButton.js +1 -0
  75. package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
  76. package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
  77. package/dist/hooks/breakpointOpenLogic.js +2 -2
  78. package/dist/hooks/dataColorLogic.d.ts +23 -0
  79. package/dist/hooks/index.d.ts +1 -1
  80. package/dist/hooks/numberFormatLogic.d.ts +7 -0
  81. package/dist/hooks/numberFormatLogic.js +5 -2
  82. package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
  83. package/dist/hooks/themeContrastLogic.js +1 -0
  84. package/dist/hooks/themeDeriveLogic.d.ts +8 -0
  85. package/dist/hooks/themeDeriveLogic.js +4 -2
  86. package/dist/hooks/useKapiTheme.js +27 -27
  87. package/dist/hooks/useMediaQuery.d.ts +7 -0
  88. package/dist/hooks/useMediaQuery.js +4 -4
  89. package/dist/index.js +149 -137
  90. package/dist/kapi.css +1 -1
  91. package/dist/kapi.layered.css +1 -1
  92. package/package.json +2 -6
@@ -1,172 +1,207 @@
1
1
  "use client";
2
2
  import { assignRef as e, fieldControlProps as t, focusLeaves as n } from "./fieldLogic.js";
3
3
  import { useKapiField as ee } from "./KapiField.js";
4
- import { useKapiLocale as r, useLabels as te } from "../locale/KapiLocaleProvider.js";
5
- import { DEFAULT_CALENDAR_LABELS as i, calendarNames as a, formDateValue as o, monthTitle as s } from "./datePickerLogic.js";
6
- import { KapiCalendarGrid as ne } from "./KapiCalendarGrid.js";
7
- import { useCalendarFocus as re } from "./useCalendarFocus.js";
8
- import { useDatePopSide as ie } from "./useDatePopSide.js";
4
+ import { useKapiLocale as te, useLabels as ne } from "../locale/KapiLocaleProvider.js";
5
+ import { DEFAULT_CALENDAR_LABELS as r, calendarNames as i, chipFieldSize as re, formDateValue as a, monthTitle as ie } from "./datePickerLogic.js";
6
+ import { KapiCalendarGrid as ae } from "./KapiCalendarGrid.js";
7
+ import { useCalendarFocus as oe } from "./useCalendarFocus.js";
8
+ import { useDatePopSide as se } from "./useDatePopSide.js";
9
9
  /* empty css */
10
- import { EMPTY_RANGE as c, formatRange as l, isCompleteRange as ae, maskRangeInput as oe, parseRangeText as u, pickRangeDay as d, rangeDayState as f, sameRange as p } from "./dateRangeLogic.js";
11
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
12
- import { useEffect as _, useMemo as se, useRef as v, useState as y } from "react";
13
- import { Calendar as ce, ChevronLeft as le, ChevronRight as ue } from "lucide-react";
10
+ import { EMPTY_RANGE as o, formatRange as s, isCompleteRange as ce, maskRangeInput as le, openEndedDay as ue, parseRangeText as de, pickRangeDay as fe, rangeDayState as c, sameRange as l } from "./dateRangeLogic.js";
11
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
12
+ import { useEffect as pe, useId as me, useMemo as he, useRef as p, useState as m } from "react";
13
+ import { Calendar as ge, ChevronLeft as _e, ChevronRight as ve } from "lucide-react";
14
14
  //#region src/components/inputs/KapiDateRangePicker.tsx
15
- var b = {
16
- ...i,
15
+ var h = {
16
+ ...r,
17
17
  pickStart: "Elige la fecha de inicio",
18
- pickEnd: "Elige la fecha de fin"
19
- }, de = (e) => `${e.from?.getTime() ?? ""}-${e.to?.getTime() ?? ""}`, x = ({ value: i = c, onChange: x, placeholder: fe = "dd/mm/aaaa – dd/mm/aaaa", disabled: S = !1, id: pe, name: C, className: me, style: he, "aria-label": w, labels: ge, ref: T, onBlur: E }) => {
20
- let D = r(), O = se(() => D ? {
21
- ...b,
22
- ...a(D)
23
- } : b, [D]), k = te("calendar", O, ge), A = ee(), [j, M] = y(!1), [N, P] = y(i), [F, I] = y(i), [L, R] = y(null), [z, B] = y(() => l(i)), [V, H] = y(() => i.from ?? /* @__PURE__ */ new Date()), U = v(null), W = v(null), G = v(null), { inputRef: _e, focusRequest: ve, openFromKeyboard: K, openFromFocus: ye, returnFocus: q } = re(M), J = de(i), [be, xe] = y(J);
24
- be !== J && (xe(J), P(i), I(i), B(l(i)), i.from && H(i.from));
25
- let Y = () => {
26
- M(!1), I(N), R(null);
27
- }, X = v(Y);
28
- X.current = Y, _(() => {
18
+ pickEnd: "Elige la fecha de fin",
19
+ openEnd: "Desde esta fecha",
20
+ openStart: "Hasta esta fecha"
21
+ }, ye = (e) => `${e.from?.getTime() ?? ""}-${e.to?.getTime() ?? ""}`, g = ({ value: r = o, onChange: g, placeholder: _ = "dd/mm/aaaa – dd/mm/aaaa", icon: v, label: y, disabled: b = !1, id: be, name: x, className: xe, style: Se, "aria-label": Ce, labels: we, ref: Te, onBlur: S }) => {
22
+ let C = te(), w = he(() => C ? {
23
+ ...h,
24
+ ...i(C)
25
+ } : h, [C]), T = ne("calendar", w, we), E = ee(), D = !!v || !!y, O = me(), k = be ?? E?.controlId ?? (D ? O : void 0), [A, j] = m(!1), [M, N] = m(r), [P, F] = m(r), [Ee, I] = m(null), [L, R] = m(() => s(r)), [z, B] = m(() => r.from ?? /* @__PURE__ */ new Date()), V = p(null), H = p(null), U = p(null), { inputRef: De, focusRequest: Oe, openFromKeyboard: W, openFromFocus: ke, returnFocus: G } = oe(j), K = ye(r), [Ae, je] = m(K);
26
+ Ae !== K && (je(K), N(r), F(r), R(s(r)), r.from && B(r.from));
27
+ let q = () => {
28
+ j(!1), F(M), I(null);
29
+ }, J = p(q);
30
+ J.current = q, pe(() => {
29
31
  let e = (e) => {
30
- let t = U.current;
32
+ let t = V.current;
31
33
  if (!t || t.contains(e.target)) return;
32
34
  let n = document.activeElement;
33
- n instanceof HTMLElement && G.current?.contains(n) && n.blur(), X.current();
35
+ n instanceof HTMLElement && U.current?.contains(n) && n.blur(), J.current();
34
36
  };
35
37
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
36
38
  }, []);
37
- let Z = (e) => {
38
- P(e), I(e), B(l(e)), x?.(e);
39
- }, Se = () => {
40
- let e = u(z);
41
- e === null ? (N.from || N.to) && Z(c) : e === void 0 ? B(l(N)) : (p(e, N) ? B(l(e)) : Z(e), e.from && H(e.from));
42
- }, Ce = (e) => {
43
- let t = d(F, e);
44
- R(null), ae(t) ? (Z(t), q()) : I(t);
45
- }, Q = (e) => H(new Date(V.getFullYear(), V.getMonth() + e, 1)), $ = !!F.from && !F.to, we = ie(j && !S, W, G);
46
- return /* @__PURE__ */ g("div", {
39
+ let Y = (e) => {
40
+ N(e), F(e), R(s(e)), g?.(e);
41
+ }, Me = () => {
42
+ let e = de(L);
43
+ e === null ? (M.from || M.to) && Y(o) : e === void 0 ? R(s(M)) : (l(e, M) ? R(s(e)) : Y(e), e.from && B(e.from));
44
+ }, Ne = (e) => {
45
+ let t = fe(P, e);
46
+ I(null), ce(t) ? (Y(t), G()) : F(t);
47
+ }, X = (e) => {
48
+ I(null), Y(e), G();
49
+ }, Z = (e) => B(new Date(z.getFullYear(), z.getMonth() + e, 1)), Q = !!P.from && !P.to, $ = ue(P), Pe = se(A && !b, H, U);
50
+ return /* @__PURE__ */ f("div", {
47
51
  className: [
48
52
  "kapi-dp",
49
53
  "kapi-dp--range",
50
- me
54
+ D && "kapi-dp--chip",
55
+ xe
51
56
  ].filter(Boolean).join(" "),
52
- style: he,
53
- ref: U,
57
+ style: Se,
58
+ ref: V,
54
59
  onBlur: (e) => {
55
- n(e.relatedTarget, e.currentTarget) && E?.(e);
60
+ n(e.relatedTarget, e.currentTarget) && S?.(e);
56
61
  },
57
62
  children: [
58
- /* @__PURE__ */ g("div", {
59
- className: "kapi-dp__field",
60
- ref: W,
61
- children: [/* @__PURE__ */ h("input", {
62
- ref: (t) => {
63
- _e.current = t, e(T, t);
64
- },
65
- ...t(A, { id: pe }),
66
- className: "kapi-input kapi-dp__input",
67
- value: z,
68
- placeholder: fe,
69
- disabled: S,
70
- "aria-label": w,
71
- autoComplete: "off",
72
- inputMode: "numeric",
73
- onChange: (e) => B(oe(e.target.value)),
74
- onFocus: ye,
75
- onBlur: Se,
76
- onKeyDown: (e) => {
77
- e.key === "Escape" && Y(), e.key === "ArrowDown" && (e.preventDefault(), K());
78
- }
79
- }), /* @__PURE__ */ h("button", {
80
- type: "button",
81
- className: "kapi-dp__toggle",
82
- disabled: S,
83
- "aria-label": k.openPicker,
84
- "aria-expanded": j,
85
- onClick: () => j ? Y() : K(),
86
- children: /* @__PURE__ */ h(ce, {
87
- size: 16,
88
- strokeWidth: 1.9
63
+ /* @__PURE__ */ f("div", {
64
+ className: ["kapi-dp__field", D && "kapi-filterchip"].filter(Boolean).join(" "),
65
+ ref: H,
66
+ children: [
67
+ v,
68
+ y && /* @__PURE__ */ f("label", {
69
+ className: "kapi-dp__label",
70
+ htmlFor: k,
71
+ children: [y, ":"]
72
+ }),
73
+ /* @__PURE__ */ d("input", {
74
+ ref: (t) => {
75
+ De.current = t, e(Te, t);
76
+ },
77
+ ...t(E, { id: k }),
78
+ ...D ? { size: re(_) } : {},
79
+ className: "kapi-input kapi-dp__input",
80
+ value: L,
81
+ placeholder: _,
82
+ disabled: b,
83
+ "aria-label": Ce,
84
+ autoComplete: "off",
85
+ inputMode: "numeric",
86
+ onChange: (e) => R(le(e.target.value)),
87
+ onFocus: ke,
88
+ onBlur: Me,
89
+ onKeyDown: (e) => {
90
+ e.key === "Escape" && q(), e.key === "ArrowDown" && (e.preventDefault(), W());
91
+ }
92
+ }),
93
+ /* @__PURE__ */ d("button", {
94
+ type: "button",
95
+ className: "kapi-dp__toggle",
96
+ disabled: b,
97
+ "aria-label": T.openPicker,
98
+ "aria-expanded": A,
99
+ onClick: () => A ? q() : W(),
100
+ children: /* @__PURE__ */ d(ge, {
101
+ size: 16,
102
+ strokeWidth: 1.9
103
+ })
89
104
  })
90
- })]
105
+ ]
91
106
  }),
92
- C && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("input", {
107
+ x && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("input", {
93
108
  type: "hidden",
94
- name: `${C}.from`,
95
- value: o(N.from, "date"),
96
- disabled: S
97
- }), /* @__PURE__ */ h("input", {
109
+ name: `${x}.from`,
110
+ value: a(M.from, "date"),
111
+ disabled: b
112
+ }), /* @__PURE__ */ d("input", {
98
113
  type: "hidden",
99
- name: `${C}.to`,
100
- value: o(N.to, "date"),
101
- disabled: S
114
+ name: `${x}.to`,
115
+ value: a(M.to, "date"),
116
+ disabled: b
102
117
  })] }),
103
- j && !S && /* @__PURE__ */ h("div", {
104
- ref: G,
105
- className: `kapi-dp__pop${we === "top" ? " kapi-dp__pop--up" : ""}`,
118
+ A && !b && /* @__PURE__ */ d("div", {
119
+ ref: U,
120
+ className: `kapi-dp__pop${Pe === "top" ? " kapi-dp__pop--up" : ""}`,
106
121
  onKeyDown: (e) => {
107
- e.key === "Escape" && (e.preventDefault(), Y(), q());
122
+ e.key === "Escape" && (e.preventDefault(), q(), G());
108
123
  },
109
- children: /* @__PURE__ */ g("div", {
124
+ children: /* @__PURE__ */ f("div", {
110
125
  className: "kapi-dp__cal",
111
126
  children: [
112
- /* @__PURE__ */ g("div", {
127
+ /* @__PURE__ */ f("div", {
113
128
  className: "kapi-dp__head",
114
129
  children: [
115
- /* @__PURE__ */ h("button", {
130
+ /* @__PURE__ */ d("button", {
116
131
  type: "button",
117
132
  className: "kapi-dp__nav",
118
- "aria-label": k.prevMonth,
119
- onClick: () => Q(-1),
120
- children: /* @__PURE__ */ h(le, {
133
+ "aria-label": T.prevMonth,
134
+ onClick: () => Z(-1),
135
+ children: /* @__PURE__ */ d(_e, {
121
136
  size: 15,
122
137
  strokeWidth: 2.2
123
138
  })
124
139
  }),
125
- /* @__PURE__ */ h("span", {
140
+ /* @__PURE__ */ d("span", {
126
141
  className: "kapi-dp__title",
127
- children: s(V, k.months)
142
+ children: ie(z, T.months)
128
143
  }),
129
- /* @__PURE__ */ h("button", {
144
+ /* @__PURE__ */ d("button", {
130
145
  type: "button",
131
146
  className: "kapi-dp__nav",
132
- "aria-label": k.nextMonth,
133
- onClick: () => Q(1),
134
- children: /* @__PURE__ */ h(ue, {
147
+ "aria-label": T.nextMonth,
148
+ onClick: () => Z(1),
149
+ children: /* @__PURE__ */ d(ve, {
135
150
  size: 15,
136
151
  strokeWidth: 2.2
137
152
  })
138
153
  })
139
154
  ]
140
155
  }),
141
- /* @__PURE__ */ h(ne, {
142
- view: V,
143
- onViewChange: H,
144
- labels: k,
145
- focusTarget: F.from,
146
- focusRequest: ve,
147
- isSelected: (e) => f(e, F, null) !== null,
156
+ /* @__PURE__ */ d(ae, {
157
+ view: z,
158
+ onViewChange: B,
159
+ labels: T,
160
+ focusTarget: P.from,
161
+ focusRequest: Oe,
162
+ isSelected: (e) => c(e, P, null) !== null,
148
163
  dayClassName: (e) => {
149
- let t = f(e, F, $ ? L : null);
164
+ let t = c(e, P, Q ? Ee : null);
150
165
  return [(t === "start" || t === "end" || t === "single") && "kapi-dp__day--sel", t && `kapi-dp__day--${t}`].filter(Boolean).join(" ");
151
166
  },
152
- onPick: Ce,
167
+ onPick: Ne,
153
168
  onDayHover: (e) => {
154
- e === null ? R(null) : $ && R(e);
169
+ e === null ? I(null) : Q && I(e);
155
170
  }
156
171
  }),
157
- /* @__PURE__ */ g("div", {
172
+ /* @__PURE__ */ f("div", {
158
173
  className: "kapi-dp__foot",
159
- children: [/* @__PURE__ */ h("button", {
174
+ children: [/* @__PURE__ */ d("button", {
160
175
  type: "button",
161
176
  className: "kapi-dp__link",
162
177
  onClick: () => {
163
- Z(c), M(!1);
178
+ Y(o), j(!1);
164
179
  },
165
- children: k.clear
166
- }), /* @__PURE__ */ h("span", {
180
+ children: T.clear
181
+ }), /* @__PURE__ */ d("span", {
167
182
  className: "kapi-dp__hint",
168
183
  "aria-live": "polite",
169
- children: $ ? k.pickEnd : k.pickStart
184
+ children: Q ? T.pickEnd : T.pickStart
185
+ })]
186
+ }),
187
+ $ && /* @__PURE__ */ f("div", {
188
+ className: "kapi-dp__open",
189
+ children: [/* @__PURE__ */ d("button", {
190
+ type: "button",
191
+ className: "kapi-dp__link",
192
+ onClick: () => X({
193
+ from: $,
194
+ to: null
195
+ }),
196
+ children: T.openEnd
197
+ }), /* @__PURE__ */ d("button", {
198
+ type: "button",
199
+ className: "kapi-dp__link",
200
+ onClick: () => X({
201
+ from: null,
202
+ to: $
203
+ }),
204
+ children: T.openStart
170
205
  })]
171
206
  })
172
207
  ]
@@ -176,4 +211,4 @@ var b = {
176
211
  });
177
212
  };
178
213
  //#endregion
179
- export { b as DEFAULT_DATE_RANGE_LABELS, x as KapiDateRangePicker };
214
+ export { h as DEFAULT_DATE_RANGE_LABELS, g as KapiDateRangePicker };
@@ -18,8 +18,15 @@ export type KapiFacetedSearchLabels = {
18
18
  empty: string;
19
19
  /** Prefijo del botón × de cada chip ("Quitar Estado: Pendiente"). */
20
20
  remove: string;
21
- /** Prefijo del nombre accesible del campo de fecha ("Valor de Fecha desde"). */
22
- valueOf: string;
21
+ /**
22
+ * Prefijo del nombre accesible del campo de fecha ("Valor de Fecha desde").
23
+ * Se llamaba `valueOf`, y ese nombre rompía la prop entera: `Object.prototype` le presta un
24
+ * `valueOf` a todo objeto literal, así que TypeScript lo veía en el tipo aparente de cualquier
25
+ * override parcial, comparaba `() => Object` contra `string` y rechazaba `labels` completo
26
+ * (TS2322 nombrando una clave que el consumidor nunca escribió). Ninguna clave de labels puede
27
+ * llamarse como un miembro de `Object.prototype`; lo fija `components/labels.types.test.tsx`.
28
+ */
29
+ valuePrefix: string;
23
30
  /** Botón que quita todos los filtros (con `onClearAll`). */
24
31
  clearAll: string;
25
32
  /** Mientras `loadOptions` de la faceta está resolviendo. */
@@ -21,7 +21,7 @@ var f = {
21
21
  typeValue: "escribir texto…",
22
22
  empty: "Sin opciones",
23
23
  remove: "Quitar",
24
- valueOf: "Valor de",
24
+ valuePrefix: "Valor de",
25
25
  clearAll: "Limpiar todo",
26
26
  loading: "Buscando…",
27
27
  loadError: "No se pudieron cargar los valores",
@@ -188,13 +188,13 @@ function p({ facets: p, chips: m, onText: fe, onClearAll: h, loadDelay: g = 300,
188
188
  onKeyDown: Ce,
189
189
  children: E.kind === "dateRange" ? /* @__PURE__ */ s(ee, {
190
190
  ref: C,
191
- "aria-label": `${v.valueOf} ${E.label}`,
191
+ "aria-label": `${v.valuePrefix} ${E.label}`,
192
192
  onChange: ({ from: e, to: t }) => {
193
193
  e && t && (E.apply(se(e, t), O ?? "eq"), Z());
194
194
  }
195
195
  }) : /* @__PURE__ */ s(r, {
196
196
  ref: C,
197
- "aria-label": `${v.valueOf} ${E.label}`,
197
+ "aria-label": `${v.valuePrefix} ${E.label}`,
198
198
  onChange: (e) => {
199
199
  e && (E.apply(ce(e), O ?? "eq"), Z());
200
200
  }
@@ -0,0 +1,79 @@
1
+ import { type ChangeEvent, type CSSProperties, type InputHTMLAttributes, type Ref } from "react";
2
+ import type { KapiLabelsOverride } from "../labelsLogic";
3
+ import "./KapiSearchChip.css";
4
+ export type KapiSearchChipLabels = {
5
+ /** Placeholder por defecto, cuando el consumidor no pasa el suyo. */
6
+ placeholder: string;
7
+ /** Nombre accesible del campo cuando no hay `aria-label` ni placeholder del que derivarlo. */
8
+ search: string;
9
+ /** Nombre accesible del botón que vacía el campo. */
10
+ clear: string;
11
+ };
12
+ export declare const DEFAULT_SEARCH_CHIP_LABELS: KapiSearchChipLabels;
13
+ /**
14
+ * `type`, `value` y `onChange` los fija el componente; `defaultValue` no aplica (es controlado).
15
+ * `className` y `style` se redeclaran porque van a la caja, no al `<input>`.
16
+ */
17
+ export type KapiSearchChipProps = Omit<InputHTMLAttributes<HTMLInputElement>, "aria-label" | "className" | "defaultValue" | "disabled" | "onChange" | "onSubmit" | "placeholder" | "style" | "type" | "value"> & {
18
+ /** Texto del campo (controlado). */
19
+ value: string;
20
+ /** Recibe el evento del `<input>`, como `KapiInput`; el botón de limpiar dispara uno real con `""`. */
21
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
22
+ /** Pista dentro del campo. De aquí sale el nombre accesible si no se pasa `aria-label`. @default "Buscar…" */
23
+ placeholder?: string | undefined;
24
+ /** Nombre accesible del campo. Sin él se deriva del `placeholder` sin su elipsis. */
25
+ "aria-label"?: string | undefined;
26
+ /** Enter llama a esto con el texto actual y frena el envío del `<form>` que lo contenga. Sin la prop, Enter no se toca. */
27
+ onSubmit?: ((value: string) => void) | undefined;
28
+ /** Apaga el campo y esconde el botón de limpiar; la caja se pinta como un chip de `KapiDropdown` deshabilitado. @default false */
29
+ disabled?: boolean | undefined;
30
+ /** Textos fijos (clave `searchChip`). */
31
+ labels?: KapiLabelsOverride<KapiSearchChipLabels> | undefined;
32
+ /** Clase de la caja visible (la que ocupa el lugar en la fila de filtros), no del `<input>`. */
33
+ className?: string | undefined;
34
+ /** Estilos en línea de la caja visible. */
35
+ style?: CSSProperties | undefined;
36
+ /** Ref al `<input>` (React 19 pasa `ref` como prop). */
37
+ ref?: Ref<HTMLInputElement>;
38
+ };
39
+ /**
40
+ * Campo de búsqueda de una fila de filtros, con la MISMA caja que el chip de `KapiDropdown`.
41
+ *
42
+ * POR QUÉ EXISTE. Entre `KapiFacetedSearch` —potente, pensado para muchos filtros combinables— y un
43
+ * `<input>` pelado no había nada, así que el caso más común de todos, «un campo de texto al lado de
44
+ * dos o tres desplegables», se escribía a mano. En una sola app consumidora eso son 31 pantallas
45
+ * repitiendo el mismo marcado: un `<label class="kapi-filterchip">`, una lupa de `lucide-react` con
46
+ * su tamaño y su color puestos a dedo, y un `<input>` con el placeholder y el `aria-label` copiados
47
+ * uno del otro. Nada de eso es decisión de una pantalla: es la caja, el ícono y el nombre accesible
48
+ * del design system, puestos 31 veces, que es lo mismo que decir 31 oportunidades de que queden
49
+ * distintos. Y se desincronizan en silencio: el ícono y la caja los pone el consumidor, así que un
50
+ * cambio de tokens o de tamaño del chip del dropdown no los alcanza y la fila queda despareja sin
51
+ * que falle nada.
52
+ *
53
+ * CÓMO EMPATA CON EL DROPDOWN. La caja no es propia: es la misma clase `.kapi-filterchip` que usa el
54
+ * `<button>` disparador de `KapiDropdown` (y el modo `chip` de `KapiDatePicker`). De ahí salen el
55
+ * fondo, el borde, el radio, el padding y el alto —incluido el alto táctil de 44px que `touch.css`
56
+ * le sube a esa clase—, así que empatan por construcción y no porque alguien los igualó una vez.
57
+ * Lo propio es sólo lo que la caja no da: la lupa en `var(--kapi-primary)` por CSS (no por una prop
58
+ * `color` en cada pantalla), el input plano de adentro y el botón de limpiar.
59
+ *
60
+ * LA LUPA NO ES CONFIGURABLE, a diferencia del `icon` de `KapiDropdown`, y es a propósito: el ícono
61
+ * puesto por el consumidor es justo el que se desincronizaba. Un chip de filtro con otro ícono ya
62
+ * existe y es `KapiDropdown`.
63
+ *
64
+ * ESCAPE NO LIMPIA EL CAMPO, aunque sea el reflejo de un buscador nativo: una fila de filtros vive
65
+ * dentro de modales, paneles y offcanvas, y ahí Escape es «cerrar». Robárselo —o peor, hacerle
66
+ * `stopPropagation`— rompe el cierre del overlay que lo contiene, que es un daño mayor que el atajo
67
+ * que se gana. Para vaciar está el botón, que además es alcanzable con el teclado.
68
+ *
69
+ * NO LLEVA `KapiField` NI `status`. Es un control de filtro, no un campo de formulario: no hay nada
70
+ * que validar y no tiene etiqueta ni ayuda arriba o abajo, porque cualquiera de las dos lo
71
+ * desalinearía del dropdown de al lado, que es el único requisito que tiene. El contrato de campo
72
+ * igual se respeta por donde importa: `name`, `onBlur`, `required`, `aria-invalid` y el resto de los
73
+ * atributos nativos pasan al `<input>`, y `ref` apunta a él.
74
+ *
75
+ * PASSTHROUGH. Los atributos nativos van al `<input>`, que es el control; `className` y `style` van
76
+ * a la caja, que es la superficie visible y la que ocupa el lugar en la fila (es donde el marcado a
77
+ * mano ponía su clase de layout). Mismo criterio que `KapiInput` con adornos.
78
+ */
79
+ export declare const KapiSearchChip: ({ value, onChange, onSubmit, disabled, placeholder, "aria-label": ariaLabel, labels, className, style, ref, onKeyDown, ...inputRest }: KapiSearchChipProps) => import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { assignRef as e } from "./fieldLogic.js";
3
+ import { useLabels as t } from "../locale/KapiLocaleProvider.js";
4
+ import { searchChipClasses as n, searchChipName as r } from "./searchChipLogic.js";
5
+ /* empty css */
6
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
+ import { useRef as o } from "react";
8
+ import { Search as s, X as c } from "lucide-react";
9
+ //#region src/components/inputs/KapiSearchChip.tsx
10
+ var l = {
11
+ placeholder: "Buscar…",
12
+ search: "Buscar",
13
+ clear: "Limpiar la búsqueda"
14
+ }, u = (e) => {
15
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 }));
16
+ }, d = ({ value: d, onChange: f, onSubmit: p, disabled: m = !1, placeholder: h, "aria-label": g, labels: _, className: v, style: y, ref: b, onKeyDown: x, ...S }) => {
17
+ let C = t("searchChip", l, _), w = o(null), T = h ?? C.placeholder, E = r({
18
+ ariaLabel: g,
19
+ placeholder: T,
20
+ fallback: C.search
21
+ }), D = d !== "" && !m && !S.readOnly, O = (t) => {
22
+ w.current = t, e(b, t);
23
+ }, k = () => {
24
+ let e = w.current;
25
+ e && (u(e), e.focus());
26
+ }, A = (e) => {
27
+ e.target === w.current || m || (e.preventDefault(), w.current?.focus());
28
+ }, j = (e) => {
29
+ x?.(e), !e.defaultPrevented && e.key === "Enter" && p && (e.preventDefault(), p(e.currentTarget.value));
30
+ };
31
+ return /* @__PURE__ */ a("div", {
32
+ className: n({
33
+ disabled: m,
34
+ className: v
35
+ }),
36
+ style: y,
37
+ onMouseDown: A,
38
+ children: [
39
+ /* @__PURE__ */ i(s, {
40
+ className: "kapi-searchchip__icon",
41
+ size: 15,
42
+ strokeWidth: 1.9,
43
+ "aria-hidden": "true"
44
+ }),
45
+ /* @__PURE__ */ i("input", {
46
+ ...S,
47
+ ref: O,
48
+ type: "search",
49
+ className: "kapi-searchchip__input",
50
+ autoComplete: S.autoComplete ?? "off",
51
+ "aria-label": E,
52
+ placeholder: T,
53
+ disabled: m,
54
+ value: d,
55
+ onChange: f,
56
+ onKeyDown: j
57
+ }),
58
+ D && /* @__PURE__ */ i("button", {
59
+ type: "button",
60
+ className: "kapi-searchchip__clear",
61
+ "aria-label": C.clear,
62
+ onClick: k,
63
+ children: /* @__PURE__ */ i(c, {
64
+ size: 14,
65
+ strokeWidth: 2.2,
66
+ "aria-hidden": "true"
67
+ })
68
+ })
69
+ ]
70
+ });
71
+ };
72
+ //#endregion
73
+ export { l as DEFAULT_SEARCH_CHIP_LABELS, d as KapiSearchChip };
@@ -48,6 +48,15 @@ export declare const pad: (n: number) => string;
48
48
  * elegido no cae en la grilla (p. ej. tipeado), se suma en orden para que siga marcado.
49
49
  */
50
50
  export declare const minuteOptions: (step?: number, selected?: number | null) => number[];
51
+ /**
52
+ * Ancho del campo cuando el picker se dibuja como chip de filtro, en caracteres (`size` del input).
53
+ * Hace falta porque el chip se achica a su contenido y ahí el `width: 100%` de `.kapi-input` no
54
+ * resuelve a nada util: sin `size` el input se queda en los 20 caracteres que el HTML da por
55
+ * omisión, de más para `dd/mm/aaaa` y de menos para `dd/mm/aaaa – dd/mm/aaaa`. Se deriva del
56
+ * placeholder porque es exactamente el molde que se va a tipear, así un placeholder propio también
57
+ * ajusta el ancho. Nunca 0: `size="0"` es inválido y el navegador lo descarta.
58
+ */
59
+ export declare const chipFieldSize: (placeholder: string) => number;
51
60
  export declare const hasCalendar: (mode: KapiDatePickerMode) => boolean;
52
61
  export declare const hasTime: (mode: KapiDatePickerMode) => boolean;
53
62
  export declare const sameDay: (a: Date | null | undefined, b: Date | null | undefined) => boolean;
@@ -80,8 +80,8 @@ var e = [
80
80
  }, d = (t, n = e) => `${n[t.getMonth()] ?? ""} ${t.getFullYear()}`, f = (e) => String(e).padStart(2, "0"), p = (e = 1, t) => {
81
81
  let n = Number.isInteger(e) && e >= 1 && e <= 59 ? e : 1, r = Array.from({ length: Math.ceil(60 / n) }, (e, t) => t * n);
82
82
  return t != null && !r.includes(t) && r.push(t), r.sort((e, t) => e - t);
83
- }, m = (e) => e === "date" || e === "datetime", h = (e) => e === "time" || e === "datetime", g = (e, t) => !!e && !!t && e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), _ = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth(), v = (e) => (e.getDay() + 6) % 7, y = /* @__PURE__ */ new Map(), b = (e) => {
84
- if (y.has(e)) return y.get(e) ?? null;
83
+ }, m = (e) => Math.max(e.trim().length, 1), h = (e) => e === "date" || e === "datetime", g = (e) => e === "time" || e === "datetime", _ = (e, t) => !!e && !!t && e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), v = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth(), y = (e) => (e.getDay() + 6) % 7, b = /* @__PURE__ */ new Map(), x = (e) => {
84
+ if (b.has(e)) return b.get(e) ?? null;
85
85
  let t = null;
86
86
  try {
87
87
  new Intl.Locale(e).language !== "es" && (t = new Intl.DateTimeFormat(e, {
@@ -94,30 +94,30 @@ var e = [
94
94
  } catch {
95
95
  t = null;
96
96
  }
97
- return y.set(e, t), t;
98
- }, x = (e, t = r, n) => {
99
- let i = n ? b(n) : null;
100
- return i ? i.format(e) : `${t.weekdayNames[v(e)] ?? ""} ${e.getDate()} de ${t.months[e.getMonth()] ?? ""} de ${e.getFullYear()}`;
101
- }, S = (e) => {
97
+ return b.set(e, t), t;
98
+ }, S = (e, t = r, n) => {
99
+ let i = n ? x(n) : null;
100
+ return i ? i.format(e) : `${t.weekdayNames[y(e)] ?? ""} ${e.getDate()} de ${t.months[e.getMonth()] ?? ""} de ${e.getFullYear()}`;
101
+ }, C = (e) => {
102
102
  let t = [];
103
103
  for (let n = 0; n < e.length; n += 7) t.push(e.slice(n, n + 7));
104
104
  return t;
105
- }, C = (e, t) => {
105
+ }, w = (e, t) => {
106
106
  let n = new Date(e.getFullYear(), e.getMonth() + t, 1), r = new Date(n.getFullYear(), n.getMonth() + 1, 0).getDate();
107
107
  return new Date(n.getFullYear(), n.getMonth(), Math.min(e.getDate(), r));
108
- }, w = (e, t) => new Date(e.getFullYear(), e.getMonth(), e.getDate() + t), T = (e, t) => {
108
+ }, T = (e, t) => new Date(e.getFullYear(), e.getMonth(), e.getDate() + t), E = (e, t) => {
109
109
  switch (t.key) {
110
- case "ArrowRight": return w(e, 1);
111
- case "ArrowLeft": return w(e, -1);
112
- case "ArrowDown": return w(e, 7);
113
- case "ArrowUp": return w(e, -7);
114
- case "Home": return w(e, -v(e));
115
- case "End": return w(e, 6 - v(e));
116
- case "PageUp": return C(e, t.shiftKey ? -12 : -1);
117
- case "PageDown": return C(e, t.shiftKey ? 12 : 1);
110
+ case "ArrowRight": return T(e, 1);
111
+ case "ArrowLeft": return T(e, -1);
112
+ case "ArrowDown": return T(e, 7);
113
+ case "ArrowUp": return T(e, -7);
114
+ case "Home": return T(e, -y(e));
115
+ case "End": return T(e, 6 - y(e));
116
+ case "PageUp": return w(e, t.shiftKey ? -12 : -1);
117
+ case "PageDown": return w(e, t.shiftKey ? 12 : 1);
118
118
  default: return;
119
119
  }
120
- }, E = (e, t) => {
120
+ }, D = (e, t) => {
121
121
  let n = (new Date(e, t, 1).getDay() + 6) % 7, r = new Date(e, t + 1, 0).getDate(), i = new Date(e, t, 0).getDate(), a = [];
122
122
  for (let r = n - 1; r >= 0; --r) a.push({
123
123
  day: i - r,
@@ -135,15 +135,15 @@ var e = [
135
135
  date: new Date(e, t + 1, n)
136
136
  });
137
137
  return a;
138
- }, D = (e, t) => e ? [m(t) ? `${f(e.getDate())}/${f(e.getMonth() + 1)}/${e.getFullYear()}` : "", h(t) ? `${f(e.getHours())}:${f(e.getMinutes())}` : ""].filter(Boolean).join(" ") : "", O = (e, t) => {
138
+ }, O = (e, t) => e ? [h(t) ? `${f(e.getDate())}/${f(e.getMonth() + 1)}/${e.getFullYear()}` : "", g(t) ? `${f(e.getHours())}:${f(e.getMinutes())}` : ""].filter(Boolean).join(" ") : "", k = (e, t) => {
139
139
  if (!e) return "";
140
140
  let n = `${String(e.getFullYear()).padStart(4, "0")}-${f(e.getMonth() + 1)}-${f(e.getDate())}`, r = `${f(e.getHours())}:${f(e.getMinutes())}`;
141
141
  return t === "time" ? r : t === "datetime" ? `${n}T${r}` : n;
142
- }, k = (e, t) => {
142
+ }, A = (e, t) => {
143
143
  let n = (e || "").replace(/\D/g, ""), r;
144
- if (m(t)) {
144
+ if (h(t)) {
145
145
  let e = n.slice(0, 8);
146
- if (r = e.slice(0, 2), e.length > 2 && (r += `/${e.slice(2, 4)}`), e.length > 4 && (r += `/${e.slice(4, 8)}`), h(t)) {
146
+ if (r = e.slice(0, 2), e.length > 2 && (r += `/${e.slice(2, 4)}`), e.length > 4 && (r += `/${e.slice(4, 8)}`), g(t)) {
147
147
  let e = n.slice(8, 12);
148
148
  e.length && (r += ` ${e.slice(0, 2)}`), e.length > 2 && (r += `:${e.slice(2, 4)}`);
149
149
  }
@@ -152,10 +152,10 @@ var e = [
152
152
  r = e.slice(0, 2), e.length > 2 && (r += `:${e.slice(2, 4)}`);
153
153
  }
154
154
  return r;
155
- }, A = (e, t, n = null, r = /* @__PURE__ */ new Date()) => {
155
+ }, j = (e, t, n = null, r = /* @__PURE__ */ new Date()) => {
156
156
  let i = (e || "").trim();
157
157
  if (!i) return null;
158
- let a = m(t), o = h(t), s = i.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4})/), c = i.match(/(\d{1,2}):(\d{2})/), l;
158
+ let a = h(t), o = g(t), s = i.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4})/), c = i.match(/(\d{1,2}):(\d{2})/), l;
159
159
  if (a) {
160
160
  if (!s) return;
161
161
  let e = Number(s[3].length === 2 ? `20${s[3]}` : s[3]), t = Number(s[2]) - 1, n = Number(s[1]);
@@ -171,4 +171,4 @@ var e = [
171
171
  return l;
172
172
  };
173
173
  //#endregion
174
- export { r as DEFAULT_CALENDAR_LABELS, e as MESES, t as WEEKDAYS, n as WEEKDAY_NAMES, E as buildDays, x as calendarDayLabel, l as calendarNames, S as calendarRows, O as formDateValue, D as formatValue, m as hasCalendar, h as hasTime, u as localizedCalendarLabels, k as maskInput, p as minuteOptions, d as monthTitle, T as moveCalendarFocus, f as pad, A as parseText, g as sameDay, _ as sameMonth };
174
+ export { r as DEFAULT_CALENDAR_LABELS, e as MESES, t as WEEKDAYS, n as WEEKDAY_NAMES, D as buildDays, S as calendarDayLabel, l as calendarNames, C as calendarRows, m as chipFieldSize, k as formDateValue, O as formatValue, h as hasCalendar, g as hasTime, u as localizedCalendarLabels, A as maskInput, p as minuteOptions, d as monthTitle, E as moveCalendarFocus, f as pad, j as parseText, _ as sameDay, v as sameMonth };