@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.
- package/README.md +10 -5
- package/dist/components/data/KapiBarChart.d.ts +84 -0
- package/dist/components/data/KapiBarChart.js +87 -0
- package/dist/components/data/KapiEventCalendar.d.ts +70 -0
- package/dist/components/data/KapiEventCalendar.js +225 -0
- package/dist/components/data/KapiHeatmap.d.ts +62 -0
- package/dist/components/data/KapiHeatmap.js +120 -0
- package/dist/components/data/KapiLineChart.d.ts +50 -0
- package/dist/components/data/KapiLineChart.js +105 -0
- package/dist/components/data/KapiPaginationFooter.js +1 -0
- package/dist/components/data/KapiSparkline.d.ts +41 -0
- package/dist/components/data/KapiSparkline.js +55 -0
- package/dist/components/data/KapiTable.js +371 -359
- package/dist/components/data/barChartLogic.d.ts +59 -0
- package/dist/components/data/barChartLogic.js +53 -0
- package/dist/components/data/chartFrame.d.ts +96 -0
- package/dist/components/data/chartFrame.js +89 -0
- package/dist/components/data/eventCalendarLogic.d.ts +70 -0
- package/dist/components/data/eventCalendarLogic.js +45 -0
- package/dist/components/data/heatmapLogic.d.ts +15 -0
- package/dist/components/data/heatmapLogic.js +15 -0
- package/dist/components/data/index.d.ts +19 -0
- package/dist/components/data/lineChartLogic.d.ts +30 -0
- package/dist/components/data/lineChartLogic.js +21 -0
- package/dist/components/data/sparklineLogic.d.ts +28 -0
- package/dist/components/data/sparklineLogic.js +18 -0
- package/dist/components/display/KapiStat.d.ts +1 -1
- package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
- package/dist/components/inputs/KapiDatePicker.js +120 -106
- package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
- package/dist/components/inputs/KapiDateRangePicker.js +146 -111
- package/dist/components/inputs/datePickerLogic.d.ts +9 -0
- package/dist/components/inputs/datePickerLogic.js +25 -25
- package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
- package/dist/components/inputs/dateRangeLogic.js +48 -22
- package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
- package/dist/components/layout/KapiContextSlot.js +108 -88
- package/dist/components/layout/KapiMasonry.d.ts +30 -0
- package/dist/components/layout/KapiMasonry.js +33 -0
- package/dist/components/layout/KapiPageHeader.js +89 -71
- package/dist/components/layout/KapiRail.d.ts +8 -2
- package/dist/components/layout/KapiRail.js +118 -67
- package/dist/components/layout/KapiShell.js +67 -37
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/masonryLogic.d.ts +40 -0
- package/dist/components/layout/masonryLogic.js +8 -0
- package/dist/components/layout/railLogic.d.ts +41 -1
- package/dist/components/layout/railLogic.js +36 -4
- package/dist/components/layout/reopenBus.d.ts +53 -0
- package/dist/components/layout/reopenBus.js +6 -0
- package/dist/components/layout/useMasonrySpans.d.ts +32 -0
- package/dist/components/layout/useMasonrySpans.js +44 -0
- package/dist/components/layout/useRailOverflow.d.ts +17 -0
- package/dist/components/layout/useRailOverflow.js +41 -0
- package/dist/components/locale/labelRegistry.d.ts +10 -1
- package/dist/components/navigation/KapiFilterChips.js +1 -1
- package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
- package/dist/components/navigation/filterChipsLogic.js +3 -3
- package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
- package/dist/components/overlays/KapiContextMenu.js +2 -1
- package/dist/components/overlays/KapiDropdown.d.ts +3 -1
- package/dist/components/overlays/KapiDropdown.js +29 -26
- package/dist/components/overlays/KapiMenuButton.js +1 -0
- package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
- package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
- package/dist/hooks/breakpointOpenLogic.js +2 -2
- package/dist/hooks/dataColorLogic.d.ts +23 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/numberFormatLogic.d.ts +7 -0
- package/dist/hooks/numberFormatLogic.js +5 -2
- package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
- package/dist/hooks/themeContrastLogic.js +1 -0
- package/dist/hooks/themeDeriveLogic.d.ts +8 -0
- package/dist/hooks/themeDeriveLogic.js +4 -2
- package/dist/hooks/useKapiTheme.js +27 -27
- package/dist/hooks/useMediaQuery.d.ts +7 -0
- package/dist/hooks/useMediaQuery.js +4 -4
- package/dist/index.js +125 -114
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- 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
|
|
5
|
-
import { DEFAULT_CALENDAR_LABELS as
|
|
6
|
-
import { KapiCalendarGrid as
|
|
7
|
-
import { useCalendarFocus as
|
|
8
|
-
import { useDatePopSide as
|
|
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
|
|
11
|
-
import { Fragment as
|
|
12
|
-
import { useEffect as
|
|
13
|
-
import { Calendar as
|
|
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
|
|
16
|
-
...
|
|
15
|
+
var h = {
|
|
16
|
+
...r,
|
|
17
17
|
pickStart: "Elige la fecha de inicio",
|
|
18
|
-
pickEnd: "Elige la fecha de fin"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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 =
|
|
32
|
+
let t = V.current;
|
|
31
33
|
if (!t || t.contains(e.target)) return;
|
|
32
34
|
let n = document.activeElement;
|
|
33
|
-
n instanceof HTMLElement &&
|
|
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
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
let e =
|
|
41
|
-
e === null ? (
|
|
42
|
-
},
|
|
43
|
-
let t =
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
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
|
-
|
|
54
|
+
D && "kapi-dp--chip",
|
|
55
|
+
xe
|
|
51
56
|
].filter(Boolean).join(" "),
|
|
52
|
-
style:
|
|
53
|
-
ref:
|
|
57
|
+
style: Se,
|
|
58
|
+
ref: V,
|
|
54
59
|
onBlur: (e) => {
|
|
55
|
-
n(e.relatedTarget, e.currentTarget) &&
|
|
60
|
+
n(e.relatedTarget, e.currentTarget) && S?.(e);
|
|
56
61
|
},
|
|
57
62
|
children: [
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
className: "kapi-dp__field",
|
|
60
|
-
ref:
|
|
61
|
-
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
107
|
+
x && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("input", {
|
|
93
108
|
type: "hidden",
|
|
94
|
-
name: `${
|
|
95
|
-
value:
|
|
96
|
-
disabled:
|
|
97
|
-
}), /* @__PURE__ */
|
|
109
|
+
name: `${x}.from`,
|
|
110
|
+
value: a(M.from, "date"),
|
|
111
|
+
disabled: b
|
|
112
|
+
}), /* @__PURE__ */ d("input", {
|
|
98
113
|
type: "hidden",
|
|
99
|
-
name: `${
|
|
100
|
-
value:
|
|
101
|
-
disabled:
|
|
114
|
+
name: `${x}.to`,
|
|
115
|
+
value: a(M.to, "date"),
|
|
116
|
+
disabled: b
|
|
102
117
|
})] }),
|
|
103
|
-
|
|
104
|
-
ref:
|
|
105
|
-
className: `kapi-dp__pop${
|
|
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(),
|
|
122
|
+
e.key === "Escape" && (e.preventDefault(), q(), G());
|
|
108
123
|
},
|
|
109
|
-
children: /* @__PURE__ */
|
|
124
|
+
children: /* @__PURE__ */ f("div", {
|
|
110
125
|
className: "kapi-dp__cal",
|
|
111
126
|
children: [
|
|
112
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ f("div", {
|
|
113
128
|
className: "kapi-dp__head",
|
|
114
129
|
children: [
|
|
115
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ d("button", {
|
|
116
131
|
type: "button",
|
|
117
132
|
className: "kapi-dp__nav",
|
|
118
|
-
"aria-label":
|
|
119
|
-
onClick: () =>
|
|
120
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
140
|
+
/* @__PURE__ */ d("span", {
|
|
126
141
|
className: "kapi-dp__title",
|
|
127
|
-
children:
|
|
142
|
+
children: ie(z, T.months)
|
|
128
143
|
}),
|
|
129
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ d("button", {
|
|
130
145
|
type: "button",
|
|
131
146
|
className: "kapi-dp__nav",
|
|
132
|
-
"aria-label":
|
|
133
|
-
onClick: () =>
|
|
134
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
142
|
-
view:
|
|
143
|
-
onViewChange:
|
|
144
|
-
labels:
|
|
145
|
-
focusTarget:
|
|
146
|
-
focusRequest:
|
|
147
|
-
isSelected: (e) =>
|
|
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 =
|
|
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:
|
|
167
|
+
onPick: Ne,
|
|
153
168
|
onDayHover: (e) => {
|
|
154
|
-
e === null ?
|
|
169
|
+
e === null ? I(null) : Q && I(e);
|
|
155
170
|
}
|
|
156
171
|
}),
|
|
157
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ f("div", {
|
|
158
173
|
className: "kapi-dp__foot",
|
|
159
|
-
children: [/* @__PURE__ */
|
|
174
|
+
children: [/* @__PURE__ */ d("button", {
|
|
160
175
|
type: "button",
|
|
161
176
|
className: "kapi-dp__link",
|
|
162
177
|
onClick: () => {
|
|
163
|
-
|
|
178
|
+
Y(o), j(!1);
|
|
164
179
|
},
|
|
165
|
-
children:
|
|
166
|
-
}), /* @__PURE__ */
|
|
180
|
+
children: T.clear
|
|
181
|
+
}), /* @__PURE__ */ d("span", {
|
|
167
182
|
className: "kapi-dp__hint",
|
|
168
183
|
"aria-live": "polite",
|
|
169
|
-
children:
|
|
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 {
|
|
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",
|
|
84
|
-
if (
|
|
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
|
|
98
|
-
},
|
|
99
|
-
let i = n ?
|
|
100
|
-
return i ? i.format(e) : `${t.weekdayNames[
|
|
101
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
111
|
-
case "ArrowLeft": return
|
|
112
|
-
case "ArrowDown": return
|
|
113
|
-
case "ArrowUp": return
|
|
114
|
-
case "Home": return
|
|
115
|
-
case "End": return
|
|
116
|
-
case "PageUp": return
|
|
117
|
-
case "PageDown": return
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
142
|
+
}, A = (e, t) => {
|
|
143
143
|
let n = (e || "").replace(/\D/g, ""), r;
|
|
144
|
-
if (
|
|
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)}`),
|
|
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
|
-
},
|
|
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 =
|
|
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,
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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()),
|
|
7
|
-
let n =
|
|
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] =
|
|
19
|
+
let [r, i] = d(e.from, n);
|
|
13
20
|
return {
|
|
14
|
-
from:
|
|
15
|
-
to:
|
|
21
|
+
from: u(r),
|
|
22
|
+
to: u(i)
|
|
16
23
|
};
|
|
17
|
-
},
|
|
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,
|
|
22
|
-
if (r(a,
|
|
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,
|
|
25
|
-
let
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
let n =
|
|
29
|
-
return
|
|
30
|
-
},
|
|
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 (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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,
|
|
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 "
|
|
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.
|