@kapiuara/ui 0.13.0 → 0.14.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 (40) hide show
  1. package/README.md +5 -0
  2. package/dist/components/chat/KapiChatDivider.d.ts +7 -3
  3. package/dist/components/chat/KapiChatDivider.js +6 -6
  4. package/dist/components/chat/index.d.ts +1 -1
  5. package/dist/components/display/KapiAnnotation.js +4 -4
  6. package/dist/components/feedback/KapiFab.js +4 -4
  7. package/dist/components/feedback/KapiToastContainer.js +5 -5
  8. package/dist/components/feedback/KapiTour.js +4 -4
  9. package/dist/components/inputs/KapiDatePicker.js +124 -122
  10. package/dist/components/inputs/KapiDateRangePicker.js +138 -136
  11. package/dist/components/inputs/KapiFacetedSearch.js +8 -8
  12. package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
  13. package/dist/components/inputs/KapiMaskedInput.js +66 -53
  14. package/dist/components/inputs/KapiNumberStepper.js +29 -29
  15. package/dist/components/inputs/KapiRating.js +61 -59
  16. package/dist/components/inputs/KapiSegmented.js +68 -58
  17. package/dist/components/inputs/KapiSelect.js +204 -194
  18. package/dist/components/inputs/KapiTagInput.js +82 -80
  19. package/dist/components/inputs/misuseWarnings.d.ts +37 -0
  20. package/dist/components/inputs/misuseWarnings.js +36 -0
  21. package/dist/components/inputs/numberStepLogic.d.ts +10 -0
  22. package/dist/components/inputs/numberStepLogic.js +16 -7
  23. package/dist/components/layout/KapiAccountMenu.js +4 -4
  24. package/dist/components/navigation/CtxSlidingList.js +4 -4
  25. package/dist/components/navigation/KapiTabs.js +58 -51
  26. package/dist/components/navigation/KapiTree.js +5 -5
  27. package/dist/components/overlays/KapiContextMenu.js +4 -4
  28. package/dist/components/overlays/KapiMenuButton.js +4 -4
  29. package/dist/components/overlays/KapiPhotoView.js +1 -1
  30. package/dist/components/overlays/KapiPopover.js +4 -4
  31. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  32. package/dist/components/overlays/KapiTooltip.js +1 -1
  33. package/dist/css/components/chat/chat.css +1 -1
  34. package/dist/hooks/useControllableState.d.ts +6 -2
  35. package/dist/hooks/useControllableState.js +14 -11
  36. package/dist/hooks/useFormReset.d.ts +22 -0
  37. package/dist/hooks/useFormReset.js +17 -0
  38. package/dist/kapi.css +1 -1
  39. package/dist/kapi.layered.css +1 -1
  40. package/package.json +5 -2
@@ -6,173 +6,175 @@ import { useKapiLocale as re, useLabels as ie } from "../locale/KapiLocaleProvid
6
6
  import { resolveChipLabel as ae } from "./selectLogic.js";
7
7
  import { useControllableState as oe } from "../../hooks/useControllableState.js";
8
8
  import { activeHTMLElementOf as se } from "../../hooks/ownerDocument.js";
9
- import { useOutsidePress as ce } from "../../hooks/useOutsidePress.js";
10
- import { DEFAULT_CALENDAR_LABELS as n, calendarNames as le, chipFieldSize as ue, datePatternFor as de, formDateValue as r, monthTitle as fe, pickerIsChip as pe } from "./datePickerLogic.js";
9
+ import { useFormReset as ce } from "../../hooks/useFormReset.js";
10
+ import { useMergedRefs as le } from "../../hooks/mergeRefs.js";
11
+ import { useOutsidePress as ue } from "../../hooks/useOutsidePress.js";
12
+ import { DEFAULT_CALENDAR_LABELS as n, calendarNames as de, chipFieldSize as fe, datePatternFor as pe, formDateValue as r, monthTitle as me, pickerIsChip as he } from "./datePickerLogic.js";
11
13
  /* empty css */
12
- import { KapiCalendarGrid as me } from "./KapiCalendarGrid.js";
13
- import { useCalendarFocus as he } from "./useCalendarFocus.js";
14
- import { useDatePopSide as ge } from "./useDatePopSide.js";
15
- import { EMPTY_RANGE as i, formatRange as a, isCompleteRange as _e, maskRangeInput as ve, openEndedDay as ye, parseRangeText as be, pickRangeDay as xe, rangeDayState as o, rangePlaceholder as Se, sameRange as Ce, validRange as s } from "./dateRangeLogic.js";
16
- import { Fragment as we, jsx as c, jsxs as l } from "react/jsx-runtime";
17
- import { useId as Te, useMemo as u, useRef as d, useState as f } from "react";
18
- import { Calendar as Ee, ChevronLeft as De, ChevronRight as Oe } from "lucide-react";
14
+ import { KapiCalendarGrid as ge } from "./KapiCalendarGrid.js";
15
+ import { useCalendarFocus as _e } from "./useCalendarFocus.js";
16
+ import { useDatePopSide as ve } from "./useDatePopSide.js";
17
+ import { EMPTY_RANGE as i, formatRange as a, isCompleteRange as ye, maskRangeInput as be, openEndedDay as xe, parseRangeText as Se, pickRangeDay as Ce, rangeDayState as o, rangePlaceholder as we, sameRange as Te, validRange as Ee } from "./dateRangeLogic.js";
18
+ import { Fragment as De, jsx as s, jsxs as c } from "react/jsx-runtime";
19
+ import { useId as Oe, useMemo as l, useRef as u, useState as d } from "react";
20
+ import { Calendar as ke, ChevronLeft as Ae, ChevronRight as je } from "lucide-react";
19
21
  //#region src/components/inputs/KapiDateRangePicker.tsx
20
- var p = {
22
+ var f = {
21
23
  ...n,
22
24
  pickStart: "Elige la fecha de inicio",
23
25
  pickEnd: "Elige la fecha de fin",
24
26
  openEnd: "Desde esta fecha",
25
27
  openStart: "Hasta esta fecha"
26
- }, ke = (e) => `${e.from?.getTime() ?? ""}-${e.to?.getTime() ?? ""}`, m = ({ value: n, defaultValue: m, onChange: Ae, placeholder: je, variant: Me, icon: h, chipLabel: g, label: _, help: Ne, fieldClassName: Pe, readOnly: v, disabled: y = !1, id: b, name: x, className: Fe, style: Ie, "aria-label": Le, labels: Re, invalid: S, required: C, ref: ze, onBlur: Be, weekStartsOn: Ve }) => {
27
- let w = re(), T = u(() => de(w), [w]), E = je ?? Se(T), He = u(() => w ? {
28
- ...p,
29
- ...le(w)
30
- } : p, [w]), D = ie("calendar", He, Re), O = pe({
31
- variant: Me,
32
- icon: h,
33
- chipLabel: g,
34
- label: _
35
- }), { chipLabel: k, fieldLabel: Ue } = ae({
36
- chip: O,
37
- chipLabel: g,
38
- label: _
39
- }), A = ne({
40
- id: b,
41
- label: Ue,
42
- help: Ne,
43
- required: C,
44
- invalid: S,
45
- readOnly: v,
46
- fieldClassName: Pe
47
- }), j = A.field, M = te(v, j), We = Te(), N = b ?? j?.controlId ?? (O ? We : void 0), [P, F] = f(!1), Ge = n !== void 0, [I, Ke] = oe(n === void 0 ? void 0 : s(n), s(m ?? i), Ae), [L, R] = f(I), [qe, z] = f(null), [B, V] = f(() => a(I, T)), [H, U] = f(() => I.from ?? /* @__PURE__ */ new Date()), W = d(null), G = d(null), K = d(null), { inputRef: Je, focusRequest: Ye, openFromKeyboard: q, openFromFocus: Xe, returnFocus: J } = he(F), Y = ke(I), [Ze, Qe] = f(Y), [$e, et] = f(T);
48
- (Ze !== Y || $e !== T) && (Qe(Y), et(T), R(I), V(a(I, T)), I.from && U(I.from));
49
- let X = () => {
50
- F(!1), R(I), z(null);
28
+ }, Me = (e) => `${e.from?.getTime() ?? ""}-${e.to?.getTime() ?? ""}`, p = ({ value: n, defaultValue: p, onChange: Ne, placeholder: Pe, variant: Fe, icon: m, chipLabel: h, label: g, help: Ie, fieldClassName: Le, readOnly: _, disabled: v = !1, id: y, name: b, className: Re, style: ze, "aria-label": Be, labels: Ve, invalid: He, required: x, ref: Ue, onBlur: We, weekStartsOn: Ge }) => {
29
+ let S = re(), C = l(() => pe(S), [S]), w = Pe ?? we(C), Ke = l(() => S ? {
30
+ ...f,
31
+ ...de(S)
32
+ } : f, [S]), T = ie("calendar", Ke, Ve), E = he({
33
+ variant: Fe,
34
+ icon: m,
35
+ chipLabel: h,
36
+ label: g
37
+ }), { chipLabel: D, fieldLabel: qe } = ae({
38
+ chip: E,
39
+ chipLabel: h,
40
+ label: g
41
+ }), O = ne({
42
+ id: y,
43
+ label: qe,
44
+ help: Ie,
45
+ required: x,
46
+ invalid: He,
47
+ readOnly: _,
48
+ fieldClassName: Le
49
+ }), k = O.field, A = te(_, k), Je = Oe(), j = y ?? k?.controlId ?? (E ? Je : void 0), [M, N] = d(!1), Ye = n !== void 0, [P, Xe, , Ze] = oe(n === void 0 ? void 0 : Ee(n), Ee(p ?? i), Ne), [F, I] = d(P), [Qe, L] = d(null), [R, z] = d(() => a(P, C)), [B, V] = d(() => P.from ?? /* @__PURE__ */ new Date()), H = u(null), $e = le(H, ce(Ze)), U = u(null), W = u(null), { inputRef: et, focusRequest: tt, openFromKeyboard: G, openFromFocus: nt, returnFocus: K } = _e(N), q = Me(P), [rt, it] = d(q), [at, ot] = d(C);
50
+ (rt !== q || at !== C) && (it(q), ot(C), I(P), z(a(P, C)), P.from && V(P.from));
51
+ let J = () => {
52
+ N(!1), I(P), L(null);
51
53
  };
52
- ce(P, [W], () => {
53
- let e = se(W.current);
54
- e && K.current?.contains(e) && e.blur(), X();
54
+ ue(M, [H], () => {
55
+ let e = se(H.current);
56
+ e && W.current?.contains(e) && e.blur(), J();
55
57
  });
56
- let Z = (e) => {
57
- Ke(e);
58
- let t = Ge ? I : e;
59
- R(t), V(a(t, T));
60
- }, tt = () => {
61
- let e = be(B, T);
62
- e === null ? (I.from || I.to) && Z(i) : e === void 0 ? V(a(I, T)) : (Ce(e, I) ? V(a(e, T)) : Z(e), e.from && U(e.from));
63
- }, nt = (e) => {
64
- let t = xe(L, e);
65
- z(null), _e(t) ? (Z(t), J()) : R(t);
66
- }, rt = (e) => {
67
- z(null), Z(e), J();
68
- }, it = (e) => U(new Date(H.getFullYear(), H.getMonth() + e, 1)), Q = !!L.from && !L.to, $ = ye(L), at = ge(P && !y && !M, G, K);
69
- return A.wrap(/* @__PURE__ */ l("div", {
58
+ let Y = (e) => {
59
+ Xe(e);
60
+ let t = Ye ? P : e;
61
+ I(t), z(a(t, C));
62
+ }, st = () => {
63
+ let e = Se(R, C);
64
+ e === null ? (P.from || P.to) && Y(i) : e === void 0 ? z(a(P, C)) : (Te(e, P) ? z(a(e, C)) : Y(e), e.from && V(e.from));
65
+ }, ct = (e) => {
66
+ let t = Ce(F, e);
67
+ L(null), ye(t) ? (Y(t), K()) : I(t);
68
+ }, X = (e) => {
69
+ L(null), Y(e), K();
70
+ }, Z = (e) => V(new Date(B.getFullYear(), B.getMonth() + e, 1)), Q = !!F.from && !F.to, $ = xe(F), lt = ve(M && !v && !A, U, W);
71
+ return O.wrap(/* @__PURE__ */ c("div", {
70
72
  className: [
71
73
  "kapi-dp",
72
74
  "kapi-dp--range",
73
- O && "kapi-dp--chip",
74
- M && "kapi-dp--readonly",
75
- Fe
75
+ E && "kapi-dp--chip",
76
+ A && "kapi-dp--readonly",
77
+ Re
76
78
  ].filter(Boolean).join(" "),
77
- style: Ie,
78
- ref: W,
79
+ style: ze,
80
+ ref: $e,
79
81
  onBlur: (e) => {
80
- ee(e.relatedTarget, e.currentTarget) && Be?.(e);
82
+ ee(e.relatedTarget, e.currentTarget) && We?.(e);
81
83
  },
82
84
  children: [
83
- /* @__PURE__ */ l("div", {
84
- className: ["kapi-dp__field", O && "kapi-filterchip"].filter(Boolean).join(" "),
85
- ref: G,
85
+ /* @__PURE__ */ c("div", {
86
+ className: ["kapi-dp__field", E && "kapi-filterchip"].filter(Boolean).join(" "),
87
+ ref: U,
86
88
  children: [
87
- O && h,
88
- k && /* @__PURE__ */ l("label", {
89
+ E && m,
90
+ D && /* @__PURE__ */ c("label", {
89
91
  className: "kapi-dp__label",
90
- htmlFor: N,
91
- children: [k, ":"]
92
+ htmlFor: j,
93
+ children: [D, ":"]
92
94
  }),
93
- /* @__PURE__ */ c("input", {
95
+ /* @__PURE__ */ s("input", {
94
96
  ref: (t) => {
95
- Je.current = t, e(ze, t);
97
+ et.current = t, e(Ue, t);
96
98
  },
97
- ...t(j, {
98
- id: N,
99
- invalid: S,
100
- required: C
99
+ ...t(k, {
100
+ id: j,
101
+ invalid: He,
102
+ required: x
101
103
  }),
102
- ...O ? { size: ue(E) } : {},
104
+ ...E ? { size: fe(w) } : {},
103
105
  className: "kapi-input kapi-dp__input",
104
- value: B,
105
- placeholder: E,
106
- disabled: y,
107
- readOnly: M || void 0,
108
- "aria-label": Le,
106
+ value: R,
107
+ placeholder: w,
108
+ disabled: v,
109
+ readOnly: A || void 0,
110
+ "aria-label": Be,
109
111
  autoComplete: "off",
110
112
  inputMode: "numeric",
111
- onChange: (e) => V(ve(e.target.value, T)),
112
- onFocus: M ? void 0 : Xe,
113
- onBlur: tt,
113
+ onChange: (e) => z(be(e.target.value, C)),
114
+ onFocus: A ? void 0 : nt,
115
+ onBlur: st,
114
116
  onKeyDown: (e) => {
115
- e.key === "Escape" && P && (e.preventDefault(), e.stopPropagation(), X()), e.key === "ArrowDown" && !M && (e.preventDefault(), q());
117
+ e.key === "Escape" && M && (e.preventDefault(), e.stopPropagation(), J()), e.key === "ArrowDown" && !A && (e.preventDefault(), G());
116
118
  }
117
119
  }),
118
- /* @__PURE__ */ c("button", {
120
+ /* @__PURE__ */ s("button", {
119
121
  type: "button",
120
122
  className: "kapi-dp__toggle",
121
- disabled: y || M,
122
- "aria-label": D.openPicker,
123
- "aria-expanded": P,
124
- onClick: () => P ? X() : q(),
125
- children: /* @__PURE__ */ c(Ee, {
123
+ disabled: v || A,
124
+ "aria-label": T.openPicker,
125
+ "aria-expanded": M,
126
+ onClick: () => M ? J() : G(),
127
+ children: /* @__PURE__ */ s(ke, {
126
128
  size: 16,
127
129
  strokeWidth: 1.9
128
130
  })
129
131
  })
130
132
  ]
131
133
  }),
132
- x && /* @__PURE__ */ l(we, { children: [/* @__PURE__ */ c("input", {
134
+ b && /* @__PURE__ */ c(De, { children: [/* @__PURE__ */ s("input", {
133
135
  type: "hidden",
134
- name: `${x}.from`,
135
- value: r(I.from, "date"),
136
- disabled: y
137
- }), /* @__PURE__ */ c("input", {
136
+ name: `${b}.from`,
137
+ value: r(P.from, "date"),
138
+ disabled: v
139
+ }), /* @__PURE__ */ s("input", {
138
140
  type: "hidden",
139
- name: `${x}.to`,
140
- value: r(I.to, "date"),
141
- disabled: y
141
+ name: `${b}.to`,
142
+ value: r(P.to, "date"),
143
+ disabled: v
142
144
  })] }),
143
- P && !y && !M && /* @__PURE__ */ c("div", {
144
- ref: K,
145
- className: `kapi-dp__pop${at === "top" ? " kapi-dp__pop--up" : ""}`,
145
+ M && !v && !A && /* @__PURE__ */ s("div", {
146
+ ref: W,
147
+ className: `kapi-dp__pop${lt === "top" ? " kapi-dp__pop--up" : ""}`,
146
148
  onKeyDown: (e) => {
147
- e.key === "Escape" && (e.preventDefault(), X(), J());
149
+ e.key === "Escape" && (e.preventDefault(), J(), K());
148
150
  },
149
- children: /* @__PURE__ */ l("div", {
151
+ children: /* @__PURE__ */ c("div", {
150
152
  className: "kapi-dp__cal",
151
153
  children: [
152
- /* @__PURE__ */ l("div", {
154
+ /* @__PURE__ */ c("div", {
153
155
  className: "kapi-dp__head",
154
156
  children: [
155
- /* @__PURE__ */ c("button", {
157
+ /* @__PURE__ */ s("button", {
156
158
  type: "button",
157
159
  className: "kapi-dp__nav",
158
- "aria-label": D.prevMonth,
159
- onClick: () => it(-1),
160
- children: /* @__PURE__ */ c(De, {
160
+ "aria-label": T.prevMonth,
161
+ onClick: () => Z(-1),
162
+ children: /* @__PURE__ */ s(Ae, {
161
163
  className: "kapi-flip-rtl",
162
164
  size: 15,
163
165
  strokeWidth: 2.2
164
166
  })
165
167
  }),
166
- /* @__PURE__ */ c("span", {
168
+ /* @__PURE__ */ s("span", {
167
169
  className: "kapi-dp__title",
168
- children: fe(H, D.months)
170
+ children: me(B, T.months)
169
171
  }),
170
- /* @__PURE__ */ c("button", {
172
+ /* @__PURE__ */ s("button", {
171
173
  type: "button",
172
174
  className: "kapi-dp__nav",
173
- "aria-label": D.nextMonth,
174
- onClick: () => it(1),
175
- children: /* @__PURE__ */ c(Oe, {
175
+ "aria-label": T.nextMonth,
176
+ onClick: () => Z(1),
177
+ children: /* @__PURE__ */ s(je, {
176
178
  className: "kapi-flip-rtl",
177
179
  size: 15,
178
180
  strokeWidth: 2.2
@@ -180,56 +182,56 @@ var p = {
180
182
  })
181
183
  ]
182
184
  }),
183
- /* @__PURE__ */ c(me, {
184
- weekStartsOn: Ve,
185
- view: H,
186
- onViewChange: U,
187
- labels: D,
188
- focusTarget: L.from,
189
- focusRequest: Ye,
190
- isSelected: (e) => o(e, L, null) !== null,
185
+ /* @__PURE__ */ s(ge, {
186
+ weekStartsOn: Ge,
187
+ view: B,
188
+ onViewChange: V,
189
+ labels: T,
190
+ focusTarget: F.from,
191
+ focusRequest: tt,
192
+ isSelected: (e) => o(e, F, null) !== null,
191
193
  dayClassName: (e) => {
192
- let t = o(e, L, Q ? qe : null);
194
+ let t = o(e, F, Q ? Qe : null);
193
195
  return [(t === "start" || t === "end" || t === "single") && "kapi-dp__day--sel", t && `kapi-dp__day--${t}`].filter(Boolean).join(" ");
194
196
  },
195
- onPick: nt,
197
+ onPick: ct,
196
198
  onDayHover: (e) => {
197
- e === null ? z(null) : Q && z(e);
199
+ e === null ? L(null) : Q && L(e);
198
200
  }
199
201
  }),
200
- /* @__PURE__ */ l("div", {
202
+ /* @__PURE__ */ c("div", {
201
203
  className: "kapi-dp__foot",
202
- children: [/* @__PURE__ */ c("button", {
204
+ children: [/* @__PURE__ */ s("button", {
203
205
  type: "button",
204
206
  className: "kapi-dp__link",
205
207
  onClick: () => {
206
- Z(i), F(!1);
208
+ Y(i), N(!1);
207
209
  },
208
- children: D.clear
209
- }), /* @__PURE__ */ c("span", {
210
+ children: T.clear
211
+ }), /* @__PURE__ */ s("span", {
210
212
  className: "kapi-dp__hint",
211
213
  "aria-live": "polite",
212
- children: Q ? D.pickEnd : D.pickStart
214
+ children: Q ? T.pickEnd : T.pickStart
213
215
  })]
214
216
  }),
215
- $ && /* @__PURE__ */ l("div", {
217
+ $ && /* @__PURE__ */ c("div", {
216
218
  className: "kapi-dp__open",
217
- children: [/* @__PURE__ */ c("button", {
219
+ children: [/* @__PURE__ */ s("button", {
218
220
  type: "button",
219
221
  className: "kapi-dp__link",
220
- onClick: () => rt({
222
+ onClick: () => X({
221
223
  from: $,
222
224
  to: null
223
225
  }),
224
- children: D.openEnd
225
- }), /* @__PURE__ */ c("button", {
226
+ children: T.openEnd
227
+ }), /* @__PURE__ */ s("button", {
226
228
  type: "button",
227
229
  className: "kapi-dp__link",
228
- onClick: () => rt({
230
+ onClick: () => X({
229
231
  from: null,
230
232
  to: $
231
233
  }),
232
- children: D.openStart
234
+ children: T.openStart
233
235
  })]
234
236
  })
235
237
  ]
@@ -239,4 +241,4 @@ var p = {
239
241
  }));
240
242
  };
241
243
  //#endregion
242
- export { p as DEFAULT_DATE_RANGE_LABELS, m as KapiDateRangePicker };
244
+ export { f as DEFAULT_DATE_RANGE_LABELS, p as KapiDateRangePicker };
@@ -3,10 +3,10 @@ import "#kapi-css/components/inputs/KapiFacetedSearch.css";
3
3
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
4
  import { joinClasses as t } from "../rootProps.js";
5
5
  import { enabledIndexes as ee, nextEnabledIndex as n } from "../overlays/menuKeyboardLogic.js";
6
- import { useAsyncLoader as r } from "../../hooks/useAsyncLoader.js";
7
- import { KapiDatePicker as te } from "./KapiDatePicker.js";
8
- import { KapiDateRangePicker as ne } from "./KapiDateRangePicker.js";
9
- import { useMergedRefs as re } from "../../hooks/mergeRefs.js";
6
+ import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
7
+ import { useAsyncLoader as te } from "../../hooks/useAsyncLoader.js";
8
+ import { KapiDatePicker as ne } from "./KapiDatePicker.js";
9
+ import { KapiDateRangePicker as re } from "./KapiDateRangePicker.js";
10
10
  import { KapiTag as i } from "../display/KapiTag.js";
11
11
  import { KapiPopover as ie } from "../overlays/KapiPopover.js";
12
12
  import { facetChipText as ae, facetKeyAction as oe, facetMenuItems as se, facetOperators as a, facetOptionName as ce, isDateFacet as o, toDateRangeValue as le, toDateValue as ue } from "./facetedSearchLogic.js";
@@ -40,7 +40,7 @@ var p = {
40
40
  operatorLte: "menor o igual que"
41
41
  };
42
42
  function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300, reloadKey: me, labels: he, className: ge, onMouseDown: _e, "aria-label": _, ref: ve, ...v }) {
43
- let y = e("facetedSearch", p, he), b = u(), x = `${b}-list`, S = d(null), ye = re(S, ve), C = d(null), w = d(null), [T, E] = f(""), [D, O] = f(null), [k, A] = f(null), [j, M] = f(!1), [N, P] = f(-1), F = T.trim(), I = !!D && a(D).length >= 2 && k === null, L = D?.kind === "text" && !I, R = typeof D?.loadOptions == "function" && D.kind !== "text" && !I, z = {
43
+ let y = e("facetedSearch", p, he), b = u(), x = `${b}-list`, S = d(null), ye = r(S, ve), C = d(null), w = d(null), [T, E] = f(""), [D, O] = f(null), [k, A] = f(null), [j, M] = f(!1), [N, P] = f(-1), F = T.trim(), I = !!D && a(D).length >= 2 && k === null, L = D?.kind === "text" && !I, R = typeof D?.loadOptions == "function" && D.kind !== "text" && !I, z = {
44
44
  eq: y.operatorEq,
45
45
  ne: y.operatorNe,
46
46
  contains: y.operatorContains,
@@ -50,7 +50,7 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
50
50
  gte: y.operatorGte,
51
51
  lt: y.operatorLt,
52
52
  lte: y.operatorLte
53
- }, B = (e) => ae(e, e.operator ? z[e.operator] : void 0), V = o(D) && !I, be = r({
53
+ }, B = (e) => ae(e, e.operator ? z[e.operator] : void 0), V = o(D) && !I, be = te({
54
54
  query: F,
55
55
  key: `${D?.key ?? ""}\u0000${F}`,
56
56
  enabled: R && j && !V,
@@ -149,13 +149,13 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
149
149
  V && D ? /* @__PURE__ */ c("span", {
150
150
  className: "kapi-facets__date",
151
151
  onKeyDownCapture: Se,
152
- children: D.kind === "dateRange" ? /* @__PURE__ */ c(ne, {
152
+ children: D.kind === "dateRange" ? /* @__PURE__ */ c(re, {
153
153
  ref: w,
154
154
  "aria-label": `${y.valuePrefix} ${D.label}`,
155
155
  onChange: ({ from: e, to: t }) => {
156
156
  e && t && (D.apply(le(e, t), k ?? "eq"), J());
157
157
  }
158
- }) : /* @__PURE__ */ c(te, {
158
+ }) : /* @__PURE__ */ c(ne, {
159
159
  ref: w,
160
160
  "aria-label": `${y.valuePrefix} ${D.label}`,
161
161
  onChange: (e) => {
@@ -4,6 +4,11 @@ import { type KapiInputProps } from "./KapiInput.js";
4
4
  type MaskedBaseProps = Omit<KapiInputProps, "value" | "defaultValue" | "multiline" | "type"> & {
5
5
  /** Ref al `<input>`. */
6
6
  ref?: Ref<HTMLInputElement> | undefined;
7
+ /**
8
+ * Nombre para formularios nativos: un `<input type="hidden">` con el valor CRUDO (los dígitos, o
9
+ * el número en el caso del importe). El campo de texto no lleva `name`.
10
+ */
11
+ name?: string | undefined;
7
12
  };
8
13
  export type KapiDniInputProps = MaskedBaseProps & {
9
14
  /** Dígitos del DNI (sin puntos). Controlado si viene definido. */
@@ -14,7 +19,7 @@ export type KapiDniInputProps = MaskedBaseProps & {
14
19
  onValueChange?: ((digits: string) => void) | undefined;
15
20
  };
16
21
  /** DNI argentino con máscara `12.345.678` (7 u 8 dígitos). El valor son sólo los dígitos. */
17
- export declare const KapiDniInput: ({ value, defaultValue, onValueChange, onChange, ref, placeholder, ...rest }: KapiDniInputProps) => import("react").JSX.Element;
22
+ export declare const KapiDniInput: ({ value, defaultValue, onValueChange, onChange, ref, name, disabled, placeholder, ...rest }: KapiDniInputProps) => import("react").JSX.Element;
18
23
  export type KapiCuitInputProps = MaskedBaseProps & {
19
24
  /** Dígitos del CUIT/CUIL (sin guiones). Controlado si viene definido. */
20
25
  value?: string | undefined;
@@ -35,7 +40,7 @@ export declare const DEFAULT_CUIT_INPUT_LABELS: KapiCuitInputLabels;
35
40
  * rojo y `aria-invalid` (salvo que `invalid` o `status` vengan de afuera); si el campo tiene label o ayuda, muestra
36
41
  * `invalidMessage`.
37
42
  */
38
- export declare const KapiCuitInput: ({ value, defaultValue, onValueChange, onChange, invalidMessage, invalid: invalidProp, status, help, label, ref, placeholder, ...rest }: KapiCuitInputProps) => import("react").JSX.Element;
43
+ export declare const KapiCuitInput: ({ value, defaultValue, onValueChange, onChange, invalidMessage, invalid: invalidProp, status, help, label, ref, name, disabled, placeholder, ...rest }: KapiCuitInputProps) => import("react").JSX.Element;
39
44
  export type KapiCurrencyInputProps = MaskedBaseProps & {
40
45
  /** Importe. Controlado si viene definido (`null` = vacío). */
41
46
  value?: number | null | undefined;
@@ -48,5 +53,5 @@ export type KapiCurrencyInputProps = MaskedBaseProps & {
48
53
  * Importe en pesos con formato es-AR (`$ 1.234,56`): puntos de miles automáticos y coma decimal
49
54
  * mientras se tipea; al salir del campo completa los dos decimales. El valor es un `number`.
50
55
  */
51
- export declare const KapiCurrencyInput: ({ value, defaultValue, onValueChange, onChange, onBlur, ref, placeholder, ...rest }: KapiCurrencyInputProps) => import("react").JSX.Element;
56
+ export declare const KapiCurrencyInput: ({ value, defaultValue, onValueChange, onChange, onBlur, ref, name, disabled, placeholder, ...rest }: KapiCurrencyInputProps) => import("react").JSX.Element;
52
57
  export {};
@@ -4,78 +4,91 @@ import { useLabels as t } from "../locale/KapiLocaleProvider.js";
4
4
  import { KapiInput as n } from "./KapiInput.js";
5
5
  import { useControllableState as r } from "../../hooks/useControllableState.js";
6
6
  import { activeElementOf as i } from "../../hooks/ownerDocument.js";
7
- import { caretForSignificant as a, countSignificant as o, formatCuit as s, formatCurrency as c, formatDni as l, isValidCuit as u, maskCurrencyInput as d, onlyDigits as f, parseCurrency as p } from "./maskLogic.js";
8
- import { jsx as m } from "react/jsx-runtime";
9
- import { useCallback as h, useRef as g, useState as _ } from "react";
7
+ import { useFormReset as a } from "../../hooks/useFormReset.js";
8
+ import { caretForSignificant as o, countSignificant as s, formatCuit as c, formatCurrency as l, formatDni as u, isValidCuit as d, maskCurrencyInput as f, onlyDigits as p, parseCurrency as m } from "./maskLogic.js";
9
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
10
+ import { useCallback as v, useRef as y, useState as b } from "react";
10
11
  //#region src/components/inputs/KapiMaskedInput.tsx
11
- var v = (t, n, r) => ({
12
- setRef: h((t) => e(n, t), [n]),
12
+ var x = (e, t, n) => e ? /* @__PURE__ */ g("input", {
13
+ type: "hidden",
14
+ name: e,
15
+ value: t,
16
+ disabled: n
17
+ }) : null, S = (t, n, r, a) => ({
18
+ setRef: v((t) => {
19
+ e(n, t), a?.(t);
20
+ }, [n, a]),
13
21
  apply: (e, n) => {
14
- let s = e.target, c = s.selectionStart ?? s.value.length;
15
- if (r !== void 0 && f(s.value).length > r) {
16
- let e = Math.max(0, c - (s.value.length - n.length));
17
- return s.value = n, s.setSelectionRange(e, e), n;
22
+ let a = e.target, c = a.selectionStart ?? a.value.length;
23
+ if (r !== void 0 && p(a.value).length > r) {
24
+ let e = Math.max(0, c - (a.value.length - n.length));
25
+ return a.value = n, a.setSelectionRange(e, e), n;
18
26
  }
19
- let l = o(s.value, c), u = t(s.value);
20
- if (s.value = u, i(s) === s) {
21
- let e = a(u, l);
22
- s.setSelectionRange(e, e);
27
+ let l = s(a.value, c), u = t(a.value);
28
+ if (a.value = u, i(a) === a) {
29
+ let e = o(u, l);
30
+ a.setSelectionRange(e, e);
23
31
  }
24
32
  return u;
25
33
  }
26
- }), y = ({ value: e, defaultValue: t = "", onValueChange: i, onChange: a, ref: o, placeholder: s = "12.345.678", ...c }) => {
27
- let [u, d] = r(e, () => f(t, 8), i), p = f(u, 8), { setRef: h, apply: g } = v(l, o, 8);
28
- return /* @__PURE__ */ m(n, {
29
- ...c,
30
- ref: h,
31
- value: l(p),
32
- placeholder: s,
34
+ }), C = ({ value: e, defaultValue: t = "", onValueChange: i, onChange: o, ref: s, name: c, disabled: l, placeholder: d = "12.345.678", ...f }) => {
35
+ let [m, v, , y] = r(e, () => p(t, 8), i), b = p(m, 8), { setRef: C, apply: w } = S(u, s, 8, a(y));
36
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(n, {
37
+ ...f,
38
+ ref: C,
39
+ disabled: l,
40
+ value: u(b),
41
+ placeholder: d,
33
42
  inputMode: "numeric",
34
43
  autoComplete: "off",
35
44
  onChange: (e) => {
36
- let t = f(g(e, l(p)));
37
- t !== p && d(t), a?.(e);
45
+ let t = p(w(e, u(b)));
46
+ t !== b && v(t), o?.(e);
38
47
  }
39
- });
40
- }, b = { invalid: "CUIT inválido: revisa el dígito verificador" }, x = ({ value: e, defaultValue: i = "", onValueChange: a, onChange: o, invalidMessage: c, invalid: l, status: d, help: p, label: h, ref: g, placeholder: _ = "20-12345678-9", ...y }) => {
41
- let x = t("cuitInput", b), [S, C] = r(e, () => f(i, 11), a && ((e) => a(e, u(e)))), w = f(S, 11), T = w.length === 11 && !u(w), E = l !== void 0 || d !== void 0, D = h != null || !!p, { setRef: O, apply: k } = v(s, g, 11);
42
- return /* @__PURE__ */ m(n, {
43
- ...y,
44
- ref: O,
45
- label: h,
46
- help: D && T ? c ?? x.invalid : p,
47
- status: d,
48
- invalid: E ? l : T || void 0,
49
- value: s(w),
50
- placeholder: _,
48
+ }), x(c, b, l)] });
49
+ }, w = { invalid: "CUIT inválido: revisa el dígito verificador" }, T = ({ value: e, defaultValue: i = "", onValueChange: o, onChange: s, invalidMessage: l, invalid: u, status: f, help: m, label: v, ref: y, name: b, disabled: C, placeholder: T = "20-12345678-9", ...E }) => {
50
+ let D = t("cuitInput", w), [O, k, , A] = r(e, () => p(i, 11), o && ((e) => o(e, d(e)))), j = p(O, 11), M = a(A), N = j.length === 11 && !d(j), P = u !== void 0 || f !== void 0, F = v != null || !!m, { setRef: I, apply: L } = S(c, y, 11, M);
51
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(n, {
52
+ ...E,
53
+ ref: I,
54
+ disabled: C,
55
+ label: v,
56
+ help: F && N ? l ?? D.invalid : m,
57
+ status: f,
58
+ invalid: P ? u : N || void 0,
59
+ value: c(j),
60
+ placeholder: T,
51
61
  inputMode: "numeric",
52
62
  autoComplete: "off",
53
63
  onChange: (e) => {
54
- let t = f(k(e, s(w)));
55
- t !== w && C(t), o?.(e);
64
+ let t = p(L(e, c(j)));
65
+ t !== j && k(t), s?.(e);
56
66
  }
57
- });
58
- }, S = ({ value: e, defaultValue: t = null, onValueChange: r, onChange: i, onBlur: a, ref: o, placeholder: s = "$ 0,00", ...l }) => {
59
- let [u, f] = _(() => c(e === void 0 ? t : e)), h = g(p(u)), [y, b] = _(e);
60
- e !== void 0 && e !== y && (b(e), e !== p(u) && (f(c(e)), h.current = e));
61
- let { setRef: x, apply: S } = v(d, o);
62
- return /* @__PURE__ */ m(n, {
63
- ...l,
64
- ref: x,
65
- value: u,
66
- placeholder: s,
67
+ }), x(b, j, C)] });
68
+ }, E = ({ value: e, defaultValue: t = null, onValueChange: r, onChange: i, onBlur: o, ref: s, name: c, disabled: u, placeholder: d = "$ 0,00", ...p }) => {
69
+ let [v, C] = b(() => l(e === void 0 ? t : e)), w = y(m(v)), T = y(v), [E, D] = b(e);
70
+ e !== void 0 && e !== E && (D(e), e !== m(v) && (C(l(e)), w.current = e));
71
+ let O = a(() => {
72
+ e === void 0 && (C(T.current), w.current = m(T.current));
73
+ }), { setRef: k, apply: A } = S(f, s, void 0, O), j = m(v);
74
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(n, {
75
+ ...p,
76
+ ref: k,
77
+ disabled: u,
78
+ value: v,
79
+ placeholder: d,
67
80
  inputMode: "decimal",
68
81
  autoComplete: "off",
69
82
  onChange: (e) => {
70
- let t = S(e, u);
71
- f(t);
72
- let n = p(t);
73
- n !== h.current && (h.current = n, r?.(n)), i?.(e);
83
+ let t = A(e, v);
84
+ C(t);
85
+ let n = m(t);
86
+ n !== w.current && (w.current = n, r?.(n)), i?.(e);
74
87
  },
75
88
  onBlur: (e) => {
76
- f(c(p(u))), a?.(e);
89
+ C(l(m(v))), o?.(e);
77
90
  }
78
- });
91
+ }), x(c, j === null ? "" : String(j), u)] });
79
92
  };
80
93
  //#endregion
81
- export { b as DEFAULT_CUIT_INPUT_LABELS, x as KapiCuitInput, S as KapiCurrencyInput, y as KapiDniInput };
94
+ export { w as DEFAULT_CUIT_INPUT_LABELS, T as KapiCuitInput, E as KapiCurrencyInput, C as KapiDniInput };