@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.
- package/README.md +5 -0
- package/dist/components/chat/KapiChatDivider.d.ts +7 -3
- package/dist/components/chat/KapiChatDivider.js +6 -6
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/display/KapiAnnotation.js +4 -4
- package/dist/components/feedback/KapiFab.js +4 -4
- package/dist/components/feedback/KapiToastContainer.js +5 -5
- package/dist/components/feedback/KapiTour.js +4 -4
- package/dist/components/inputs/KapiDatePicker.js +124 -122
- package/dist/components/inputs/KapiDateRangePicker.js +138 -136
- package/dist/components/inputs/KapiFacetedSearch.js +8 -8
- package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
- package/dist/components/inputs/KapiMaskedInput.js +66 -53
- package/dist/components/inputs/KapiNumberStepper.js +29 -29
- package/dist/components/inputs/KapiRating.js +61 -59
- package/dist/components/inputs/KapiSegmented.js +68 -58
- package/dist/components/inputs/KapiSelect.js +204 -194
- package/dist/components/inputs/KapiTagInput.js +82 -80
- package/dist/components/inputs/misuseWarnings.d.ts +37 -0
- package/dist/components/inputs/misuseWarnings.js +36 -0
- package/dist/components/inputs/numberStepLogic.d.ts +10 -0
- package/dist/components/inputs/numberStepLogic.js +16 -7
- package/dist/components/layout/KapiAccountMenu.js +4 -4
- package/dist/components/navigation/CtxSlidingList.js +4 -4
- package/dist/components/navigation/KapiTabs.js +58 -51
- package/dist/components/navigation/KapiTree.js +5 -5
- package/dist/components/overlays/KapiContextMenu.js +4 -4
- package/dist/components/overlays/KapiMenuButton.js +4 -4
- package/dist/components/overlays/KapiPhotoView.js +1 -1
- package/dist/components/overlays/KapiPopover.js +4 -4
- package/dist/components/overlays/KapiShapeSheet.js +4 -4
- package/dist/components/overlays/KapiTooltip.js +1 -1
- package/dist/css/components/chat/chat.css +1 -1
- package/dist/hooks/useControllableState.d.ts +6 -2
- package/dist/hooks/useControllableState.js +14 -11
- package/dist/hooks/useFormReset.d.ts +22 -0
- package/dist/hooks/useFormReset.js +17 -0
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- 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 {
|
|
10
|
-
import {
|
|
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
|
|
13
|
-
import { useCalendarFocus as
|
|
14
|
-
import { useDatePopSide as
|
|
15
|
-
import { EMPTY_RANGE as i, formatRange as a, isCompleteRange as
|
|
16
|
-
import { Fragment as
|
|
17
|
-
import { useId as
|
|
18
|
-
import { Calendar as
|
|
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
|
|
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
|
-
},
|
|
27
|
-
let
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
} :
|
|
31
|
-
variant:
|
|
32
|
-
icon:
|
|
33
|
-
chipLabel:
|
|
34
|
-
label:
|
|
35
|
-
}), { chipLabel:
|
|
36
|
-
chip:
|
|
37
|
-
chipLabel:
|
|
38
|
-
label:
|
|
39
|
-
}),
|
|
40
|
-
id:
|
|
41
|
-
label:
|
|
42
|
-
help:
|
|
43
|
-
required:
|
|
44
|
-
invalid:
|
|
45
|
-
readOnly:
|
|
46
|
-
fieldClassName:
|
|
47
|
-
}),
|
|
48
|
-
(
|
|
49
|
-
let
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
let e = se(
|
|
54
|
-
e &&
|
|
54
|
+
ue(M, [H], () => {
|
|
55
|
+
let e = se(H.current);
|
|
56
|
+
e && W.current?.contains(e) && e.blur(), J();
|
|
55
57
|
});
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
let t =
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
let e =
|
|
62
|
-
e === null ? (
|
|
63
|
-
},
|
|
64
|
-
let t =
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
return
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
E && "kapi-dp--chip",
|
|
76
|
+
A && "kapi-dp--readonly",
|
|
77
|
+
Re
|
|
76
78
|
].filter(Boolean).join(" "),
|
|
77
|
-
style:
|
|
78
|
-
ref:
|
|
79
|
+
style: ze,
|
|
80
|
+
ref: $e,
|
|
79
81
|
onBlur: (e) => {
|
|
80
|
-
ee(e.relatedTarget, e.currentTarget) &&
|
|
82
|
+
ee(e.relatedTarget, e.currentTarget) && We?.(e);
|
|
81
83
|
},
|
|
82
84
|
children: [
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
className: ["kapi-dp__field",
|
|
85
|
-
ref:
|
|
85
|
+
/* @__PURE__ */ c("div", {
|
|
86
|
+
className: ["kapi-dp__field", E && "kapi-filterchip"].filter(Boolean).join(" "),
|
|
87
|
+
ref: U,
|
|
86
88
|
children: [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
E && m,
|
|
90
|
+
D && /* @__PURE__ */ c("label", {
|
|
89
91
|
className: "kapi-dp__label",
|
|
90
|
-
htmlFor:
|
|
91
|
-
children: [
|
|
92
|
+
htmlFor: j,
|
|
93
|
+
children: [D, ":"]
|
|
92
94
|
}),
|
|
93
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ s("input", {
|
|
94
96
|
ref: (t) => {
|
|
95
|
-
|
|
97
|
+
et.current = t, e(Ue, t);
|
|
96
98
|
},
|
|
97
|
-
...t(
|
|
98
|
-
id:
|
|
99
|
-
invalid:
|
|
100
|
-
required:
|
|
99
|
+
...t(k, {
|
|
100
|
+
id: j,
|
|
101
|
+
invalid: He,
|
|
102
|
+
required: x
|
|
101
103
|
}),
|
|
102
|
-
...
|
|
104
|
+
...E ? { size: fe(w) } : {},
|
|
103
105
|
className: "kapi-input kapi-dp__input",
|
|
104
|
-
value:
|
|
105
|
-
placeholder:
|
|
106
|
-
disabled:
|
|
107
|
-
readOnly:
|
|
108
|
-
"aria-label":
|
|
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) =>
|
|
112
|
-
onFocus:
|
|
113
|
-
onBlur:
|
|
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" &&
|
|
117
|
+
e.key === "Escape" && M && (e.preventDefault(), e.stopPropagation(), J()), e.key === "ArrowDown" && !A && (e.preventDefault(), G());
|
|
116
118
|
}
|
|
117
119
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ s("button", {
|
|
119
121
|
type: "button",
|
|
120
122
|
className: "kapi-dp__toggle",
|
|
121
|
-
disabled:
|
|
122
|
-
"aria-label":
|
|
123
|
-
"aria-expanded":
|
|
124
|
-
onClick: () =>
|
|
125
|
-
children: /* @__PURE__ */
|
|
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
|
-
|
|
134
|
+
b && /* @__PURE__ */ c(De, { children: [/* @__PURE__ */ s("input", {
|
|
133
135
|
type: "hidden",
|
|
134
|
-
name: `${
|
|
135
|
-
value: r(
|
|
136
|
-
disabled:
|
|
137
|
-
}), /* @__PURE__ */
|
|
136
|
+
name: `${b}.from`,
|
|
137
|
+
value: r(P.from, "date"),
|
|
138
|
+
disabled: v
|
|
139
|
+
}), /* @__PURE__ */ s("input", {
|
|
138
140
|
type: "hidden",
|
|
139
|
-
name: `${
|
|
140
|
-
value: r(
|
|
141
|
-
disabled:
|
|
141
|
+
name: `${b}.to`,
|
|
142
|
+
value: r(P.to, "date"),
|
|
143
|
+
disabled: v
|
|
142
144
|
})] }),
|
|
143
|
-
|
|
144
|
-
ref:
|
|
145
|
-
className: `kapi-dp__pop${
|
|
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(),
|
|
149
|
+
e.key === "Escape" && (e.preventDefault(), J(), K());
|
|
148
150
|
},
|
|
149
|
-
children: /* @__PURE__ */
|
|
151
|
+
children: /* @__PURE__ */ c("div", {
|
|
150
152
|
className: "kapi-dp__cal",
|
|
151
153
|
children: [
|
|
152
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ c("div", {
|
|
153
155
|
className: "kapi-dp__head",
|
|
154
156
|
children: [
|
|
155
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ s("button", {
|
|
156
158
|
type: "button",
|
|
157
159
|
className: "kapi-dp__nav",
|
|
158
|
-
"aria-label":
|
|
159
|
-
onClick: () =>
|
|
160
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
168
|
+
/* @__PURE__ */ s("span", {
|
|
167
169
|
className: "kapi-dp__title",
|
|
168
|
-
children:
|
|
170
|
+
children: me(B, T.months)
|
|
169
171
|
}),
|
|
170
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ s("button", {
|
|
171
173
|
type: "button",
|
|
172
174
|
className: "kapi-dp__nav",
|
|
173
|
-
"aria-label":
|
|
174
|
-
onClick: () =>
|
|
175
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
184
|
-
weekStartsOn:
|
|
185
|
-
view:
|
|
186
|
-
onViewChange:
|
|
187
|
-
labels:
|
|
188
|
-
focusTarget:
|
|
189
|
-
focusRequest:
|
|
190
|
-
isSelected: (e) => o(e,
|
|
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,
|
|
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:
|
|
197
|
+
onPick: ct,
|
|
196
198
|
onDayHover: (e) => {
|
|
197
|
-
e === null ?
|
|
199
|
+
e === null ? L(null) : Q && L(e);
|
|
198
200
|
}
|
|
199
201
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ c("div", {
|
|
201
203
|
className: "kapi-dp__foot",
|
|
202
|
-
children: [/* @__PURE__ */
|
|
204
|
+
children: [/* @__PURE__ */ s("button", {
|
|
203
205
|
type: "button",
|
|
204
206
|
className: "kapi-dp__link",
|
|
205
207
|
onClick: () => {
|
|
206
|
-
|
|
208
|
+
Y(i), N(!1);
|
|
207
209
|
},
|
|
208
|
-
children:
|
|
209
|
-
}), /* @__PURE__ */
|
|
210
|
+
children: T.clear
|
|
211
|
+
}), /* @__PURE__ */ s("span", {
|
|
210
212
|
className: "kapi-dp__hint",
|
|
211
213
|
"aria-live": "polite",
|
|
212
|
-
children: Q ?
|
|
214
|
+
children: Q ? T.pickEnd : T.pickStart
|
|
213
215
|
})]
|
|
214
216
|
}),
|
|
215
|
-
$ && /* @__PURE__ */
|
|
217
|
+
$ && /* @__PURE__ */ c("div", {
|
|
216
218
|
className: "kapi-dp__open",
|
|
217
|
-
children: [/* @__PURE__ */
|
|
219
|
+
children: [/* @__PURE__ */ s("button", {
|
|
218
220
|
type: "button",
|
|
219
221
|
className: "kapi-dp__link",
|
|
220
|
-
onClick: () =>
|
|
222
|
+
onClick: () => X({
|
|
221
223
|
from: $,
|
|
222
224
|
to: null
|
|
223
225
|
}),
|
|
224
|
-
children:
|
|
225
|
-
}), /* @__PURE__ */
|
|
226
|
+
children: T.openEnd
|
|
227
|
+
}), /* @__PURE__ */ s("button", {
|
|
226
228
|
type: "button",
|
|
227
229
|
className: "kapi-dp__link",
|
|
228
|
-
onClick: () =>
|
|
230
|
+
onClick: () => X({
|
|
229
231
|
from: null,
|
|
230
232
|
to: $
|
|
231
233
|
}),
|
|
232
|
-
children:
|
|
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 {
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
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 {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
|
12
|
-
|
|
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
|
|
15
|
-
if (r !== void 0 &&
|
|
16
|
-
let e = Math.max(0, c - (
|
|
17
|
-
return
|
|
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 =
|
|
20
|
-
if (
|
|
21
|
-
let e =
|
|
22
|
-
|
|
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
|
-
}),
|
|
27
|
-
let [
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
...
|
|
30
|
-
ref:
|
|
31
|
-
|
|
32
|
-
|
|
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 =
|
|
37
|
-
t !==
|
|
45
|
+
let t = p(w(e, u(b)));
|
|
46
|
+
t !== b && v(t), o?.(e);
|
|
38
47
|
}
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
let
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
...
|
|
44
|
-
ref:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 =
|
|
55
|
-
t !==
|
|
64
|
+
let t = p(L(e, c(j)));
|
|
65
|
+
t !== j && k(t), s?.(e);
|
|
56
66
|
}
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
let [
|
|
60
|
-
e !== void 0 && e !==
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 =
|
|
71
|
-
|
|
72
|
-
let n =
|
|
73
|
-
n !==
|
|
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
|
-
|
|
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 {
|
|
94
|
+
export { w as DEFAULT_CUIT_INPUT_LABELS, T as KapiCuitInput, E as KapiCurrencyInput, C as KapiDniInput };
|