@kapiuara/ui 0.13.0 → 0.15.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 +239 -1
- package/dist/components/chat/KapiChatDivider.d.ts +7 -3
- package/dist/components/chat/KapiChatDivider.js +6 -6
- package/dist/components/chat/KapiChatList.js +19 -19
- package/dist/components/chat/KapiChatThread.js +23 -23
- package/dist/components/chat/KapiComposer.js +19 -19
- package/dist/components/chat/KapiMessageBubble.js +4 -4
- package/dist/components/chat/KapiTypingIndicator.js +4 -4
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/closeReason.d.ts +34 -0
- package/dist/components/data/KapiBarChart.js +1 -1
- package/dist/components/data/KapiDataTable.js +31 -31
- package/dist/components/data/KapiEventCalendar.js +78 -78
- package/dist/components/data/KapiHeatmap.js +23 -23
- package/dist/components/data/KapiLineChart.js +1 -1
- package/dist/components/data/KapiPagination.js +4 -4
- package/dist/components/data/KapiSparkline.js +1 -1
- package/dist/components/data/KapiTable.js +122 -122
- package/dist/components/data/KapiTableFilter.js +18 -18
- package/dist/components/data/KapiTableRow.js +24 -24
- package/dist/components/data/KapiTableToolbar.js +49 -49
- package/dist/components/data/chartFrame.js +21 -21
- package/dist/components/data/useColumnResize.js +8 -8
- package/dist/components/data/useTableSelection.js +8 -8
- package/dist/components/display/KapiAnnotation.js +55 -55
- package/dist/components/display/KapiComment.js +4 -4
- package/dist/components/display/KapiCommentComposer.js +16 -16
- package/dist/components/display/KapiFileItem.js +6 -6
- package/dist/components/display/KapiFileViewer.js +9 -9
- package/dist/components/display/KapiTruncate.js +7 -7
- package/dist/components/feedback/KapiAlert.d.ts +2 -1
- package/dist/components/feedback/KapiAlert.js +8 -8
- package/dist/components/feedback/KapiCountdown.js +8 -8
- package/dist/components/feedback/KapiFab.js +30 -30
- package/dist/components/feedback/KapiOfflineBanner.js +8 -8
- package/dist/components/feedback/KapiToastContainer.js +25 -25
- package/dist/components/feedback/KapiTour.d.ts +2 -1
- package/dist/components/feedback/KapiTour.js +35 -35
- package/dist/components/inputs/KapiAutocomplete.js +14 -14
- package/dist/components/inputs/KapiButton.d.ts +17 -1
- package/dist/components/inputs/KapiButton.js +41 -25
- package/dist/components/inputs/KapiCalendar.js +5 -5
- package/dist/components/inputs/KapiCalendarGrid.js +10 -10
- package/dist/components/inputs/KapiChecklist.js +71 -71
- package/dist/components/inputs/KapiDatePicker.js +124 -122
- package/dist/components/inputs/KapiDateRangePicker.js +138 -136
- package/dist/components/inputs/KapiFacetedSearch.js +29 -29
- package/dist/components/inputs/KapiField.js +14 -14
- package/dist/components/inputs/KapiFileUpload.js +27 -27
- package/dist/components/inputs/KapiIconButton.d.ts +9 -1
- package/dist/components/inputs/KapiIconButton.js +27 -10
- package/dist/components/inputs/KapiInput.js +21 -21
- package/dist/components/inputs/KapiInputGroup.js +8 -8
- package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
- package/dist/components/inputs/KapiMaskedInput.js +64 -51
- package/dist/components/inputs/KapiNumberStepper.js +29 -29
- package/dist/components/inputs/KapiRating.js +61 -59
- package/dist/components/inputs/KapiSearchChip.js +8 -8
- package/dist/components/inputs/KapiSegmented.js +74 -64
- package/dist/components/inputs/KapiSelect.js +232 -222
- package/dist/components/inputs/KapiSelectMenu.js +60 -60
- package/dist/components/inputs/KapiSlider.js +1 -1
- package/dist/components/inputs/KapiSwitch.js +6 -6
- package/dist/components/inputs/KapiTagInput.js +83 -81
- package/dist/components/inputs/KapiTextarea.js +8 -8
- 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/inputs/ownField.js +4 -4
- package/dist/components/layout/KapiAccountMenu.d.ts +2 -1
- package/dist/components/layout/KapiAccountMenu.js +53 -53
- package/dist/components/layout/KapiContextSlot.js +35 -35
- package/dist/components/layout/KapiMasonry.js +6 -6
- package/dist/components/layout/KapiNotificationBell.js +60 -60
- package/dist/components/layout/KapiPageHeader.js +19 -19
- package/dist/components/layout/KapiRail.js +60 -60
- package/dist/components/layout/KapiRailAccount.js +9 -9
- package/dist/components/layout/KapiRoot.js +21 -21
- package/dist/components/layout/KapiScrollArea.js +11 -11
- package/dist/components/layout/KapiShell.js +12 -12
- package/dist/components/locale/KapiLocaleProvider.js +13 -13
- package/dist/components/navigation/CtxSlidingList.js +4 -4
- package/dist/components/navigation/KapiAccordion.js +12 -12
- package/dist/components/navigation/KapiBreadcrumb.js +11 -11
- package/dist/components/navigation/KapiCollapsiblePanel.js +23 -23
- package/dist/components/navigation/KapiContextPanel.js +76 -76
- package/dist/components/navigation/KapiFilterChips.js +9 -9
- package/dist/components/navigation/KapiNavBadge.d.ts +4 -2
- package/dist/components/navigation/KapiNavBadge.js +11 -10
- package/dist/components/navigation/KapiPanelGroup.js +25 -25
- package/dist/components/navigation/KapiSteps.js +4 -4
- package/dist/components/navigation/KapiTabs.d.ts +4 -1
- package/dist/components/navigation/KapiTabs.js +63 -55
- package/dist/components/navigation/KapiTree.js +75 -75
- package/dist/components/navigation/KapiWizard.d.ts +2 -1
- package/dist/components/navigation/KapiWizard.js +30 -30
- package/dist/components/overlays/KapiCanvasForm.d.ts +6 -2
- package/dist/components/overlays/KapiCanvasForm.js +12 -12
- package/dist/components/overlays/KapiCommandPalette.d.ts +2 -1
- package/dist/components/overlays/KapiCommandPalette.js +23 -23
- package/dist/components/overlays/KapiConfirm.d.ts +2 -1
- package/dist/components/overlays/KapiConfirm.js +12 -12
- package/dist/components/overlays/KapiContextMenu.d.ts +2 -1
- package/dist/components/overlays/KapiContextMenu.js +18 -18
- package/dist/components/overlays/KapiDialogHost.js +22 -22
- package/dist/components/overlays/KapiLoading.js +16 -16
- package/dist/components/overlays/KapiMenuButton.js +15 -15
- package/dist/components/overlays/KapiModal.d.ts +2 -1
- package/dist/components/overlays/KapiModal.js +28 -28
- package/dist/components/overlays/KapiOffcanvas.d.ts +3 -2
- package/dist/components/overlays/KapiOffcanvas.js +63 -63
- package/dist/components/overlays/KapiOffcanvasStack.js +38 -38
- package/dist/components/overlays/KapiPhotoView.js +15 -15
- package/dist/components/overlays/KapiPopover.d.ts +2 -1
- package/dist/components/overlays/KapiPopover.js +10 -10
- package/dist/components/overlays/KapiShapeSheet.js +20 -20
- package/dist/components/overlays/KapiSplitModal.js +29 -29
- package/dist/components/overlays/KapiTooltip.js +21 -21
- package/dist/components/overlays/menuList.js +60 -60
- package/dist/components/renderSlot.d.ts +27 -0
- package/dist/components/renderSlot.js +23 -0
- package/dist/css/components/chat/chat.css +1 -1
- package/dist/hooks/portalRoot.js +6 -6
- 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/index.d.ts +2 -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 {
|
|
17
|
-
import {
|
|
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 { useId as De, useMemo as s, useRef as c, useState as l } from "react";
|
|
19
|
+
import { Fragment as Oe, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
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 = s(() => pe(S), [S]), w = Pe ?? we(C), Ke = s(() => 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 = De(), j = y ?? k?.controlId ?? (E ? Je : void 0), [M, N] = l(!1), Ye = n !== void 0, [P, Xe, , Ze] = oe(n === void 0 ? void 0 : Ee(n), Ee(p ?? i), Ne), [F, I] = l(P), [Qe, L] = l(null), [R, z] = l(() => a(P, C)), [B, V] = l(() => P.from ?? /* @__PURE__ */ new Date()), H = c(null), $e = le(H, ce(Ze)), U = c(null), W = c(null), { inputRef: et, focusRequest: tt, openFromKeyboard: G, openFromFocus: nt, returnFocus: K } = _e(N), q = Me(P), [rt, it] = l(q), [at, ot] = l(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__ */ d("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__ */ d("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__ */ d("label", {
|
|
89
91
|
className: "kapi-dp__label",
|
|
90
|
-
htmlFor:
|
|
91
|
-
children: [
|
|
92
|
+
htmlFor: j,
|
|
93
|
+
children: [D, ":"]
|
|
92
94
|
}),
|
|
93
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ u("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__ */ u("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__ */ u(ke, {
|
|
126
128
|
size: 16,
|
|
127
129
|
strokeWidth: 1.9
|
|
128
130
|
})
|
|
129
131
|
})
|
|
130
132
|
]
|
|
131
133
|
}),
|
|
132
|
-
|
|
134
|
+
b && /* @__PURE__ */ d(Oe, { children: [/* @__PURE__ */ u("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__ */ u("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__ */ u("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__ */ d("div", {
|
|
150
152
|
className: "kapi-dp__cal",
|
|
151
153
|
children: [
|
|
152
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ d("div", {
|
|
153
155
|
className: "kapi-dp__head",
|
|
154
156
|
children: [
|
|
155
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ u("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__ */ u(Ae, {
|
|
161
163
|
className: "kapi-flip-rtl",
|
|
162
164
|
size: 15,
|
|
163
165
|
strokeWidth: 2.2
|
|
164
166
|
})
|
|
165
167
|
}),
|
|
166
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ u("span", {
|
|
167
169
|
className: "kapi-dp__title",
|
|
168
|
-
children:
|
|
170
|
+
children: me(B, T.months)
|
|
169
171
|
}),
|
|
170
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ u("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__ */ u(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__ */ u(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__ */ d("div", {
|
|
201
203
|
className: "kapi-dp__foot",
|
|
202
|
-
children: [/* @__PURE__ */
|
|
204
|
+
children: [/* @__PURE__ */ u("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__ */ u("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__ */ d("div", {
|
|
216
218
|
className: "kapi-dp__open",
|
|
217
|
-
children: [/* @__PURE__ */
|
|
219
|
+
children: [/* @__PURE__ */ u("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__ */ u("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 };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiFacetedSearch.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.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";
|
|
13
13
|
/* empty css */
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { useId as s, useRef as c, useState as l } from "react";
|
|
15
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
16
16
|
import { Search as de } from "lucide-react";
|
|
17
17
|
//#region src/components/inputs/KapiFacetedSearch.tsx
|
|
18
18
|
var p = {
|
|
@@ -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 =
|
|
43
|
+
let y = t("facetedSearch", p, he), b = s(), x = `${b}-list`, S = c(null), ye = r(S, ve), C = c(null), w = c(null), [T, E] = l(""), [D, O] = l(null), [k, A] = l(null), [j, M] = l(!1), [N, P] = l(-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,
|
|
@@ -113,22 +113,22 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
113
113
|
let t = e.target.value === "";
|
|
114
114
|
e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), q(), K()) : e.key === "Backspace" && t && (e.preventDefault(), X());
|
|
115
115
|
}, $ = (e) => `${b}-opt-${e}`;
|
|
116
|
-
return /* @__PURE__ */
|
|
116
|
+
return /* @__PURE__ */ f("div", {
|
|
117
117
|
...v,
|
|
118
118
|
ref: ye,
|
|
119
|
-
className:
|
|
119
|
+
className: e("kapi-facets", ge),
|
|
120
120
|
role: "search",
|
|
121
121
|
"aria-label": _ ?? y.region,
|
|
122
122
|
onMouseDown: (e) => {
|
|
123
123
|
_e?.(e), !e.defaultPrevented && e.target === e.currentTarget && (e.preventDefault(), C.current?.focus(), M(!0));
|
|
124
124
|
},
|
|
125
125
|
children: [
|
|
126
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ d(de, {
|
|
127
127
|
className: "kapi-facets__icon",
|
|
128
128
|
size: 15,
|
|
129
129
|
"aria-hidden": !0
|
|
130
130
|
}),
|
|
131
|
-
h.map((e) => /* @__PURE__ */
|
|
131
|
+
h.map((e) => /* @__PURE__ */ d(i, {
|
|
132
132
|
size: "sm",
|
|
133
133
|
onRemove: () => {
|
|
134
134
|
e.onRemove(), K();
|
|
@@ -136,7 +136,7 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
136
136
|
removeLabel: `${y.remove} ${B(e)}`,
|
|
137
137
|
children: B(e)
|
|
138
138
|
}, e.key)),
|
|
139
|
-
D && /* @__PURE__ */
|
|
139
|
+
D && /* @__PURE__ */ f(i, {
|
|
140
140
|
size: "sm",
|
|
141
141
|
tone: "primary",
|
|
142
142
|
className: "kapi-facets__pending",
|
|
@@ -146,23 +146,23 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
146
146
|
":"
|
|
147
147
|
]
|
|
148
148
|
}),
|
|
149
|
-
V && D ? /* @__PURE__ */
|
|
149
|
+
V && D ? /* @__PURE__ */ d("span", {
|
|
150
150
|
className: "kapi-facets__date",
|
|
151
151
|
onKeyDownCapture: Se,
|
|
152
|
-
children: D.kind === "dateRange" ? /* @__PURE__ */
|
|
152
|
+
children: D.kind === "dateRange" ? /* @__PURE__ */ d(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__ */
|
|
158
|
+
}) : /* @__PURE__ */ d(ne, {
|
|
159
159
|
ref: w,
|
|
160
160
|
"aria-label": `${y.valuePrefix} ${D.label}`,
|
|
161
161
|
onChange: (e) => {
|
|
162
162
|
e && (D.apply(ue(e), k ?? "eq"), J());
|
|
163
163
|
}
|
|
164
164
|
})
|
|
165
|
-
}) : /* @__PURE__ */
|
|
165
|
+
}) : /* @__PURE__ */ d("input", {
|
|
166
166
|
ref: C,
|
|
167
167
|
className: "kapi-facets__input",
|
|
168
168
|
type: "text",
|
|
@@ -186,7 +186,7 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
186
186
|
},
|
|
187
187
|
onKeyDown: xe
|
|
188
188
|
}),
|
|
189
|
-
g && h.length > 0 && /* @__PURE__ */
|
|
189
|
+
g && h.length > 0 && /* @__PURE__ */ d("button", {
|
|
190
190
|
type: "button",
|
|
191
191
|
className: "kapi-facets__clear",
|
|
192
192
|
onClick: () => {
|
|
@@ -194,7 +194,7 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
194
194
|
},
|
|
195
195
|
children: y.clearAll
|
|
196
196
|
}),
|
|
197
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ f(ie, {
|
|
198
198
|
open: G,
|
|
199
199
|
anchorRef: S,
|
|
200
200
|
onClose: () => M(!1),
|
|
@@ -206,19 +206,19 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
206
206
|
restoreFocus: !1,
|
|
207
207
|
className: "kapi-facets__menu",
|
|
208
208
|
children: [
|
|
209
|
-
U && /* @__PURE__ */
|
|
209
|
+
U && /* @__PURE__ */ d("div", {
|
|
210
210
|
className: "kapi-facets__empty",
|
|
211
211
|
children: y.loading
|
|
212
212
|
}),
|
|
213
|
-
!U && H?.error && /* @__PURE__ */
|
|
213
|
+
!U && H?.error && /* @__PURE__ */ d("div", {
|
|
214
214
|
className: "kapi-facets__empty kapi-facets__empty--err",
|
|
215
215
|
children: y.loadError
|
|
216
216
|
}),
|
|
217
|
-
!U && !H?.error && W.length === 0 && /* @__PURE__ */
|
|
217
|
+
!U && !H?.error && W.length === 0 && /* @__PURE__ */ d("div", {
|
|
218
218
|
className: "kapi-facets__empty",
|
|
219
219
|
children: y.empty
|
|
220
220
|
}),
|
|
221
|
-
!U && !H?.error && W.map((e, t) => /* @__PURE__ */
|
|
221
|
+
!U && !H?.error && W.map((e, t) => /* @__PURE__ */ d("div", {
|
|
222
222
|
id: $(t),
|
|
223
223
|
role: "option",
|
|
224
224
|
"aria-selected": t === N,
|
|
@@ -227,19 +227,19 @@ function m({ facets: m, chips: h, onText: fe, onClearAll: g, loadDelay: pe = 300
|
|
|
227
227
|
onMouseDown: (e) => e.preventDefault(),
|
|
228
228
|
onMouseEnter: () => P(t),
|
|
229
229
|
onClick: () => Q(e),
|
|
230
|
-
children: e.type === "text" ? /* @__PURE__ */
|
|
230
|
+
children: e.type === "text" ? /* @__PURE__ */ f("span", { children: [
|
|
231
231
|
y.searchFor,
|
|
232
232
|
" “",
|
|
233
233
|
e.text,
|
|
234
234
|
"”"
|
|
235
|
-
] }) : e.type === "operator" ? /* @__PURE__ */
|
|
235
|
+
] }) : e.type === "operator" ? /* @__PURE__ */ d("span", { children: z[e.operator] }) : e.type === "option" ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: e.option.label }), e.option.count !== void 0 && /* @__PURE__ */ d("span", {
|
|
236
236
|
className: "kapi-facets__count",
|
|
237
237
|
"aria-hidden": "true",
|
|
238
238
|
children: e.option.count
|
|
239
|
-
})] }) : /* @__PURE__ */
|
|
239
|
+
})] }) : /* @__PURE__ */ f("span", { children: [/* @__PURE__ */ d("span", {
|
|
240
240
|
className: "kapi-facets__facet",
|
|
241
241
|
children: e.facet.label
|
|
242
|
-
}), e.facet.kind !== "flag" && /* @__PURE__ */
|
|
242
|
+
}), e.facet.kind !== "flag" && /* @__PURE__ */ f("span", {
|
|
243
243
|
className: "kapi-facets__hint",
|
|
244
244
|
children: [
|
|
245
245
|
" ",
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { fieldContextValue as e, fieldIds as t, resolveValidation as n } from "./fieldLogic.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createContext as r, useContext as i, useId as a, useMemo as o } from "react";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
5
|
import { AlertTriangle as l, CheckCircle2 as u, LoaderCircle as d } from "lucide-react";
|
|
6
6
|
//#region src/components/inputs/KapiField.tsx
|
|
7
|
-
var f =
|
|
8
|
-
let w =
|
|
9
|
-
htmlFor:
|
|
7
|
+
var f = r(null), p = () => i(f), m = (e = "") => ["kapi-field", e].filter(Boolean).join(" "), h = (e) => ["kapi-help", e && `kapi-help--${e}`].filter(Boolean).join(" "), g = ({ label: r, htmlFor: i, required: p = !1, help: g, helpId: _, invalid: v, status: y, readOnly: b, className: x, children: S, ...C }) => {
|
|
8
|
+
let w = a(), T = !!g, { controlId: E, labelId: D, helpId: O } = t({
|
|
9
|
+
htmlFor: i,
|
|
10
10
|
autoId: w,
|
|
11
11
|
helpId: _,
|
|
12
12
|
hasHelp: T
|
|
13
|
-
}), { status: k } = n(v, y), A =
|
|
13
|
+
}), { status: k } = n(v, y), A = r != null, j = o(() => e({
|
|
14
14
|
controlId: E,
|
|
15
15
|
labelId: A ? D : void 0,
|
|
16
16
|
helpId: O,
|
|
@@ -26,33 +26,33 @@ var f = a(null), p = () => o(f), m = (e = "") => ["kapi-field", e].filter(Boolea
|
|
|
26
26
|
k,
|
|
27
27
|
b
|
|
28
28
|
]);
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ s(f.Provider, {
|
|
30
30
|
value: j,
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ c("div", {
|
|
32
32
|
...C,
|
|
33
33
|
className: m(x),
|
|
34
34
|
children: [
|
|
35
|
-
|
|
35
|
+
r != null && /* @__PURE__ */ c("label", {
|
|
36
36
|
id: D,
|
|
37
37
|
htmlFor: E,
|
|
38
|
-
children: [
|
|
38
|
+
children: [r, p && " *"]
|
|
39
39
|
}),
|
|
40
40
|
S,
|
|
41
|
-
T ? /* @__PURE__ */
|
|
41
|
+
T ? /* @__PURE__ */ c("span", {
|
|
42
42
|
id: O,
|
|
43
43
|
className: h(k),
|
|
44
44
|
role: k === "err" ? "alert" : void 0,
|
|
45
45
|
"aria-live": k === "pending" ? "polite" : void 0,
|
|
46
46
|
children: [
|
|
47
|
-
k === "ok" && /* @__PURE__ */
|
|
47
|
+
k === "ok" && /* @__PURE__ */ s(u, {
|
|
48
48
|
size: 13,
|
|
49
49
|
strokeWidth: 2.2
|
|
50
50
|
}),
|
|
51
|
-
k === "err" && /* @__PURE__ */
|
|
51
|
+
k === "err" && /* @__PURE__ */ s(l, {
|
|
52
52
|
size: 13,
|
|
53
53
|
strokeWidth: 2.2
|
|
54
54
|
}),
|
|
55
|
-
k === "pending" && /* @__PURE__ */
|
|
55
|
+
k === "pending" && /* @__PURE__ */ s(d, {
|
|
56
56
|
size: 13,
|
|
57
57
|
strokeWidth: 2.2,
|
|
58
58
|
className: "kapi-spinner"
|