@kapiuara/ui 0.10.0 → 0.11.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 (81) hide show
  1. package/README.md +10 -5
  2. package/dist/components/data/KapiBarChart.d.ts +84 -0
  3. package/dist/components/data/KapiBarChart.js +87 -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 +50 -0
  9. package/dist/components/data/KapiLineChart.js +105 -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.js +371 -359
  14. package/dist/components/data/barChartLogic.d.ts +59 -0
  15. package/dist/components/data/barChartLogic.js +53 -0
  16. package/dist/components/data/chartFrame.d.ts +96 -0
  17. package/dist/components/data/chartFrame.js +89 -0
  18. package/dist/components/data/eventCalendarLogic.d.ts +70 -0
  19. package/dist/components/data/eventCalendarLogic.js +45 -0
  20. package/dist/components/data/heatmapLogic.d.ts +15 -0
  21. package/dist/components/data/heatmapLogic.js +15 -0
  22. package/dist/components/data/index.d.ts +19 -0
  23. package/dist/components/data/lineChartLogic.d.ts +30 -0
  24. package/dist/components/data/lineChartLogic.js +21 -0
  25. package/dist/components/data/sparklineLogic.d.ts +28 -0
  26. package/dist/components/data/sparklineLogic.js +18 -0
  27. package/dist/components/display/KapiStat.d.ts +1 -1
  28. package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
  29. package/dist/components/inputs/KapiDatePicker.js +120 -106
  30. package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
  31. package/dist/components/inputs/KapiDateRangePicker.js +146 -111
  32. package/dist/components/inputs/datePickerLogic.d.ts +9 -0
  33. package/dist/components/inputs/datePickerLogic.js +25 -25
  34. package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
  35. package/dist/components/inputs/dateRangeLogic.js +48 -22
  36. package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
  37. package/dist/components/layout/KapiContextSlot.js +108 -88
  38. package/dist/components/layout/KapiMasonry.d.ts +30 -0
  39. package/dist/components/layout/KapiMasonry.js +33 -0
  40. package/dist/components/layout/KapiPageHeader.js +89 -71
  41. package/dist/components/layout/KapiRail.d.ts +8 -2
  42. package/dist/components/layout/KapiRail.js +118 -67
  43. package/dist/components/layout/KapiShell.js +67 -37
  44. package/dist/components/layout/index.d.ts +2 -0
  45. package/dist/components/layout/masonryLogic.d.ts +40 -0
  46. package/dist/components/layout/masonryLogic.js +8 -0
  47. package/dist/components/layout/railLogic.d.ts +41 -1
  48. package/dist/components/layout/railLogic.js +36 -4
  49. package/dist/components/layout/reopenBus.d.ts +53 -0
  50. package/dist/components/layout/reopenBus.js +6 -0
  51. package/dist/components/layout/useMasonrySpans.d.ts +32 -0
  52. package/dist/components/layout/useMasonrySpans.js +44 -0
  53. package/dist/components/layout/useRailOverflow.d.ts +17 -0
  54. package/dist/components/layout/useRailOverflow.js +41 -0
  55. package/dist/components/locale/labelRegistry.d.ts +10 -1
  56. package/dist/components/navigation/KapiFilterChips.js +1 -1
  57. package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
  58. package/dist/components/navigation/filterChipsLogic.js +3 -3
  59. package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
  60. package/dist/components/overlays/KapiContextMenu.js +2 -1
  61. package/dist/components/overlays/KapiDropdown.d.ts +3 -1
  62. package/dist/components/overlays/KapiDropdown.js +29 -26
  63. package/dist/components/overlays/KapiMenuButton.js +1 -0
  64. package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
  65. package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
  66. package/dist/hooks/breakpointOpenLogic.js +2 -2
  67. package/dist/hooks/dataColorLogic.d.ts +23 -0
  68. package/dist/hooks/index.d.ts +1 -1
  69. package/dist/hooks/numberFormatLogic.d.ts +7 -0
  70. package/dist/hooks/numberFormatLogic.js +5 -2
  71. package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
  72. package/dist/hooks/themeContrastLogic.js +1 -0
  73. package/dist/hooks/themeDeriveLogic.d.ts +8 -0
  74. package/dist/hooks/themeDeriveLogic.js +4 -2
  75. package/dist/hooks/useKapiTheme.js +27 -27
  76. package/dist/hooks/useMediaQuery.d.ts +7 -0
  77. package/dist/hooks/useMediaQuery.js +4 -4
  78. package/dist/index.js +125 -114
  79. package/dist/kapi.css +1 -1
  80. package/dist/kapi.layered.css +1 -1
  81. 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 };
@@ -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 };
@@ -11,21 +11,40 @@ export declare const isCompleteRange: (range: KapiDateRange) => boolean;
11
11
  export declare const sameRange: (a: KapiDateRange, b: KapiDateRange) => boolean;
12
12
  /**
13
13
  * Click en un día del calendario: el primero arranca el rango, el segundo lo cierra (ordenando las
14
- * puntas). Con un rango ya completo, el click empieza uno nuevo.
14
+ * puntas). Con un rango ya completo, el click empieza uno nuevo. Con un `hasta` abierto vigente, en
15
+ * cambio, el click completa el `desde` en vez de empezar de cero: descartarlo perdería la punta que
16
+ * el usuario ya había elegido.
15
17
  */
16
18
  export declare const pickRangeDay: (range: KapiDateRange, day: Date) => KapiDateRange;
19
+ /**
20
+ * El único día elegido del borrador: la punta que se puede confirmar dejando la otra abierta.
21
+ * `null` con las dos puntas o con ninguna, que es cuando no hay nada que dejar abierto.
22
+ */
23
+ export declare const openEndedDay: (range: KapiDateRange) => Date | null;
17
24
  export type RangeDayState = "start" | "end" | "in" | "single" | null;
18
25
  /**
19
26
  * Cómo se pinta un día: extremo inicial/final, intermedio, rango de un día o nada. Con sólo el inicio
20
27
  * elegido, `hover` previsualiza el rango hacia el día bajo el puntero (en cualquier dirección).
21
28
  */
22
29
  export declare const rangeDayState: (day: Date, range: KapiDateRange, hover?: Date | null) => RangeDayState;
23
- /** `dd/mm/aaaa – dd/mm/aaaa`; con sólo el inicio, la primera fecha; vacío sin nada. */
30
+ /**
31
+ * `dd/mm/aaaa – dd/mm/aaaa`; vacío sin nada. Una punta sola se muestra CON el separador
32
+ * (`10/03/2026 –`, `– 10/03/2026`): deja ver que la otra está abierta a propósito, en vez de
33
+ * parecer un rango a medio llenar.
34
+ */
24
35
  export declare const formatRange: (range: KapiDateRange) => string;
25
- /** Máscara de teclado: 16 dígitos repartidos en `dd/mm/aaaa – dd/mm/aaaa`. */
36
+ /**
37
+ * Máscara de teclado: 16 dígitos repartidos en `dd/mm/aaaa – dd/mm/aaaa`. El guion es DATO y no
38
+ * ruido —de qué lado está dice qué punta se está escribiendo—, así que cada lado se enmascara por
39
+ * separado; sin guion se reparten los 16 dígitos como siempre, así tipear derecho sigue armando el
40
+ * rango completo sin tocar una tecla nueva.
41
+ */
26
42
  export declare const maskRangeInput: (raw: string) => string;
27
43
  /**
28
44
  * Parsea el texto tipeado. `null`: vacío (borrar). `undefined`: incompleto o inválido (el caller
29
- * restaura el último rango válido). Si las fechas vienen invertidas, las ordena.
45
+ * restaura el último rango válido). Si las fechas vienen invertidas, las ordena. Acepta una sola
46
+ * punta, pero sólo con el separador escrito: `10/03/2026 –` es "sólo desde" y `– 10/03/2026` es
47
+ * "sólo hasta". Una fecha sin separador sigue siendo borrador, porque sola no dice qué punta es; el
48
+ * separador solo también, porque vaciar el campo es la forma de no filtrar.
30
49
  */
31
50
  export declare const parseRangeText: (text: string) => KapiDateRange | null | undefined;
@@ -3,42 +3,68 @@ import { formatValue as e, maskInput as t, parseText as n, sameDay as r } from "
3
3
  var i = {
4
4
  from: null,
5
5
  to: null
6
- }, a = " – ", o = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), s = (e, t) => o(e) <= o(t) ? [e, t] : [t, e], c = (e) => !!e.from && !!e.to, l = (e, t) => (e.from ? r(e.from, t.from) : !t.from) && (e.to ? r(e.to, t.to) : !t.to), u = (e, t) => {
7
- let n = o(t);
6
+ }, a = " – ", o = a.trimEnd(), s = a.trimStart(), c = a.trim(), l = (e) => e.replace(/\D/g, ""), u = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), d = (e, t) => u(e) <= u(t) ? [e, t] : [t, e], f = (e) => !!e.from && !!e.to, p = (e, t) => (e.from ? r(e.from, t.from) : !t.from) && (e.to ? r(e.to, t.to) : !t.to), m = (e, t) => {
7
+ let n = u(t);
8
+ if (!e.from && e.to) {
9
+ let [t, r] = d(n, e.to);
10
+ return {
11
+ from: u(t),
12
+ to: u(r)
13
+ };
14
+ }
8
15
  if (!e.from || e.to) return {
9
16
  from: n,
10
17
  to: null
11
18
  };
12
- let [r, i] = s(e.from, n);
19
+ let [r, i] = d(e.from, n);
13
20
  return {
14
- from: o(r),
15
- to: o(i)
21
+ from: u(r),
22
+ to: u(i)
16
23
  };
17
- }, d = (e, t, n) => {
24
+ }, h = (e) => !!e.from == !!e.to ? null : e.from ?? e.to ?? null, g = (e, t, n) => {
18
25
  if (!t.from) return null;
19
26
  let i = t.to ?? n ?? null;
20
27
  if (!i) return r(e, t.from) ? "single" : null;
21
- let [a, c] = s(t.from, i);
22
- if (r(a, c)) return r(e, a) ? "single" : null;
28
+ let [a, o] = d(t.from, i);
29
+ if (r(a, o)) return r(e, a) ? "single" : null;
23
30
  if (r(e, a)) return "start";
24
- if (r(e, c)) return "end";
25
- let l = o(e).getTime();
26
- return l > o(a).getTime() && l < o(c).getTime() ? "in" : null;
27
- }, f = (t) => [e(t.from, "date"), e(t.to, "date")].filter(Boolean).join(a), p = (e) => {
28
- let n = (e || "").replace(/\D/g, "").slice(0, 16), r = t(n.slice(0, 8), "date"), i = t(n.slice(8), "date");
29
- return i ? `${r}${a}${i}` : r;
30
- }, m = (e) => {
31
+ if (r(e, o)) return "end";
32
+ let s = u(e).getTime();
33
+ return s > u(a).getTime() && s < u(o).getTime() ? "in" : null;
34
+ }, _ = (t) => {
35
+ let n = e(t.from, "date"), r = e(t.to, "date");
36
+ return n && r ? `${n}${a}${r}` : n ? `${n}${o}` : r ? `${s}${r}` : "";
37
+ }, v = (e) => {
38
+ let n = e || "", r = n.search(/[–-]/);
39
+ if (r >= 0) {
40
+ let e = t(l(n.slice(0, r)).slice(0, 8), "date"), i = t(l(n.slice(r + 1)).slice(0, 8), "date");
41
+ return e && i ? `${e}${a}${i}` : e ? `${e}${o}` : i ? `${s}${i}` : c;
42
+ }
43
+ let i = l(n).slice(0, 16), u = t(i.slice(0, 8), "date"), d = t(i.slice(8), "date");
44
+ return d ? `${u}${a}${d}` : u;
45
+ }, y = (e) => {
31
46
  let t = (e || "").trim();
32
47
  if (!t) return null;
33
48
  let r = t.split(/\s*[–-]\s*/);
34
49
  if (r.length !== 2) return;
35
50
  let i = n(r[0], "date"), a = n(r[1], "date");
36
- if (!i || !a) return;
37
- let [o, c] = s(i, a);
38
- return {
39
- from: o,
40
- to: c
41
- };
51
+ if (i && a) {
52
+ let [e, t] = d(i, a);
53
+ return {
54
+ from: e,
55
+ to: t
56
+ };
57
+ }
58
+ if (i !== void 0 && a !== void 0) {
59
+ if (i) return {
60
+ from: i,
61
+ to: null
62
+ };
63
+ if (a) return {
64
+ from: null,
65
+ to: a
66
+ };
67
+ }
42
68
  };
43
69
  //#endregion
44
- export { i as EMPTY_RANGE, a as RANGE_SEPARATOR, f as formatRange, c as isCompleteRange, p as maskRangeInput, m as parseRangeText, u as pickRangeDay, d as rangeDayState, l as sameRange };
70
+ export { i as EMPTY_RANGE, a as RANGE_SEPARATOR, _ as formatRange, f as isCompleteRange, v as maskRangeInput, h as openEndedDay, y as parseRangeText, m as pickRangeDay, g as rangeDayState, p as sameRange };
@@ -51,7 +51,7 @@ export type KapiFacetChip = {
51
51
  };
52
52
  /**
53
53
  * Texto del chip: `label: value` cuando hay valor, `label` solo cuando no. Un valor vacío o de puros
54
- * espacios cuenta como ausente, para no dibujar un "Carrera: " colgado. Con un operador que no es `eq`
54
+ * espacios cuenta como ausente, para no dibujar un "Estado: " colgado. Con un operador que no es `eq`
55
55
  * suma su texto: `label operatorText: value`. La función es pura: recibe el texto del operador ya
56
56
  * resuelto (traducido), no lo traduce. Lo usan el texto visible y el nombre accesible del botón de
57
57
  * quitar, así dos chips de la misma faceta no suenan idénticos.