@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
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { flattenMenuRows as e } from "./selectLogic.js";
|
|
3
3
|
import { useVirtualList as t } from "../../hooks/useVirtualList.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { memo as n, useCallback as r, useLayoutEffect as i, useMemo as a, useRef as o } from "react";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
6
|
import { Check as l } from "lucide-react";
|
|
7
7
|
import { createPortal as u } from "react-dom";
|
|
8
8
|
//#region src/components/inputs/KapiSelectMenu.tsx
|
|
9
|
-
var d = 38, f = 264, p = 4, m =
|
|
10
|
-
id:
|
|
9
|
+
var d = 38, f = 264, p = 4, m = n(({ option: e, index: t, id: n, selected: r, active: i, create: a, vindex: o, setSize: u, renderOption: d, query: f, onHover: p, onChoose: m }) => /* @__PURE__ */ c("li", {
|
|
10
|
+
id: n,
|
|
11
11
|
role: "option",
|
|
12
|
-
"aria-selected":
|
|
12
|
+
"aria-selected": r,
|
|
13
13
|
"aria-disabled": e.disabled || void 0,
|
|
14
14
|
"data-kapisel-index": t,
|
|
15
|
-
"data-vindex":
|
|
16
|
-
"aria-setsize":
|
|
17
|
-
"aria-posinset":
|
|
15
|
+
"data-vindex": o,
|
|
16
|
+
"aria-setsize": o === void 0 ? void 0 : u,
|
|
17
|
+
"aria-posinset": o === void 0 ? void 0 : t + 1,
|
|
18
18
|
className: [
|
|
19
19
|
"kapisel__opt",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
i && "kapisel__opt--active",
|
|
21
|
+
r && "kapisel__opt--selected",
|
|
22
|
+
a && "kapisel__opt--create",
|
|
23
23
|
e.disabled && "kapisel__opt--disabled"
|
|
24
24
|
].filter(Boolean).join(" "),
|
|
25
25
|
onMouseMove: () => {
|
|
26
|
-
!e.disabled && !
|
|
26
|
+
!e.disabled && !i && p(t);
|
|
27
27
|
},
|
|
28
28
|
onClick: (t) => m(e, t.shiftKey),
|
|
29
|
-
children: [/* @__PURE__ */
|
|
29
|
+
children: [/* @__PURE__ */ s("span", {
|
|
30
30
|
className: "kapisel__opt-body",
|
|
31
|
-
children: d && !
|
|
32
|
-
selected:
|
|
33
|
-
active:
|
|
31
|
+
children: d && !a ? d(e, {
|
|
32
|
+
selected: r,
|
|
33
|
+
active: i,
|
|
34
34
|
disabled: e.disabled === !0,
|
|
35
35
|
query: f
|
|
36
36
|
}) : e.label
|
|
37
|
-
}),
|
|
37
|
+
}), r && /* @__PURE__ */ s(l, {
|
|
38
38
|
className: "kapisel__check",
|
|
39
39
|
size: 15,
|
|
40
40
|
strokeWidth: 2.4,
|
|
41
41
|
"aria-hidden": "true"
|
|
42
42
|
})]
|
|
43
|
-
})), h = ({ root:
|
|
44
|
-
let F =
|
|
43
|
+
})), h = ({ root: n, ref: l, side: h, hug: g, style: _, listboxId: v, optionId: y, multiple: b, "aria-label": x, rows: S, createRow: C, createIndex: w, loading: T, empty: E, message: D, active: O, values: k, renderOption: A, query: j, virtual: M, onHover: N, onChoose: P }) => {
|
|
44
|
+
let F = o(null), I = a(() => M ? e(S, C, w) : null, [
|
|
45
45
|
M,
|
|
46
46
|
S,
|
|
47
47
|
C,
|
|
48
48
|
w
|
|
49
|
-
]), L =
|
|
49
|
+
]), L = a(() => I?.rows.map((e) => e.key), [I]), R = t({
|
|
50
50
|
enabled: M && !T,
|
|
51
51
|
count: I?.rows.length ?? 0,
|
|
52
52
|
scrollRef: F,
|
|
@@ -56,42 +56,42 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
|
|
|
56
56
|
overscan: p,
|
|
57
57
|
fallbackViewHeight: f
|
|
58
58
|
}), { scrollToIndex: z } = R, B = O >= 0 ? I?.rowOf[O] : void 0;
|
|
59
|
-
|
|
59
|
+
i(() => {
|
|
60
60
|
B !== void 0 && z(B);
|
|
61
61
|
}, [B, z]);
|
|
62
|
-
let V =
|
|
62
|
+
let V = a(() => new Set(k), [k]), H = o({
|
|
63
63
|
onHover: N,
|
|
64
64
|
onChoose: P
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
i(() => {
|
|
67
67
|
H.current = {
|
|
68
68
|
onHover: N,
|
|
69
69
|
onChoose: P
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
|
-
let U =
|
|
73
|
-
let
|
|
74
|
-
return /* @__PURE__ */
|
|
72
|
+
let U = r((e) => H.current.onHover(e), []), W = r((e, t) => H.current.onChoose(e, t), []), G = w + 1, K = ({ option: e, index: t }, n) => {
|
|
73
|
+
let r = e === C, i = A && !r ? A : void 0;
|
|
74
|
+
return /* @__PURE__ */ s(m, {
|
|
75
75
|
option: e,
|
|
76
76
|
index: t,
|
|
77
77
|
id: y(t),
|
|
78
78
|
selected: V.has(e.value),
|
|
79
79
|
active: t === O,
|
|
80
|
-
create:
|
|
81
|
-
vindex:
|
|
82
|
-
setSize:
|
|
83
|
-
renderOption:
|
|
84
|
-
query:
|
|
80
|
+
create: r,
|
|
81
|
+
vindex: n,
|
|
82
|
+
setSize: n === void 0 ? void 0 : G,
|
|
83
|
+
renderOption: i,
|
|
84
|
+
query: i ? j : "",
|
|
85
85
|
onHover: U,
|
|
86
86
|
onChoose: W
|
|
87
87
|
}, `${e.value}-${t}`);
|
|
88
88
|
};
|
|
89
|
-
return u(/* @__PURE__ */
|
|
89
|
+
return u(/* @__PURE__ */ c("div", {
|
|
90
90
|
ref: l,
|
|
91
91
|
className: `kapisel__menu kapisel__menu--${h}${g ? " kapisel__menu--hug" : ""}`,
|
|
92
92
|
style: _,
|
|
93
93
|
onMouseDown: (e) => e.preventDefault(),
|
|
94
|
-
children: [/* @__PURE__ */
|
|
94
|
+
children: [/* @__PURE__ */ c("ul", {
|
|
95
95
|
id: v,
|
|
96
96
|
role: "listbox",
|
|
97
97
|
"aria-multiselectable": b || void 0,
|
|
@@ -101,55 +101,55 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
|
|
|
101
101
|
ref: F,
|
|
102
102
|
onScroll: M ? R.onScroll : void 0,
|
|
103
103
|
children: [
|
|
104
|
-
!T && I && ((e, t,
|
|
105
|
-
let
|
|
106
|
-
|
|
104
|
+
!T && I && ((e, t, n, r, i) => {
|
|
105
|
+
let a = [];
|
|
106
|
+
r > 0 && a.push(/* @__PURE__ */ s("li", {
|
|
107
107
|
role: "presentation",
|
|
108
108
|
"aria-hidden": !0,
|
|
109
|
-
style: { height:
|
|
109
|
+
style: { height: r }
|
|
110
110
|
}, "pad-top"));
|
|
111
|
-
let
|
|
112
|
-
for (;
|
|
113
|
-
let t = e[
|
|
111
|
+
let o = t;
|
|
112
|
+
for (; o < n;) {
|
|
113
|
+
let t = e[o];
|
|
114
114
|
if (t.group === null) {
|
|
115
|
-
t.kind === "option" &&
|
|
115
|
+
t.kind === "option" && a.push(K(t.item, o)), o += 1;
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
-
let
|
|
119
|
-
for (;
|
|
120
|
-
let t = e[
|
|
121
|
-
t.kind === "header" ?
|
|
118
|
+
let r = t.group, i = null, l = [];
|
|
119
|
+
for (; o < n && e[o].group?.key === r.key;) {
|
|
120
|
+
let t = e[o];
|
|
121
|
+
t.kind === "header" ? i = /* @__PURE__ */ s("div", {
|
|
122
122
|
className: "kapisel__group-label",
|
|
123
123
|
"aria-hidden": "true",
|
|
124
|
-
"data-vindex":
|
|
125
|
-
children:
|
|
126
|
-
}, "h") : l.push(K(t.item,
|
|
124
|
+
"data-vindex": o,
|
|
125
|
+
children: r.label
|
|
126
|
+
}, "h") : l.push(K(t.item, o)), o += 1;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
a.push(/* @__PURE__ */ c("li", {
|
|
129
129
|
role: "presentation",
|
|
130
130
|
className: "kapisel__group",
|
|
131
|
-
children: [
|
|
131
|
+
children: [i, l.length > 0 && /* @__PURE__ */ s("ul", {
|
|
132
132
|
role: "group",
|
|
133
|
-
"aria-label":
|
|
133
|
+
"aria-label": r.label,
|
|
134
134
|
className: "kapisel__group-list",
|
|
135
135
|
children: l
|
|
136
136
|
})]
|
|
137
|
-
},
|
|
137
|
+
}, r.key));
|
|
138
138
|
}
|
|
139
|
-
return
|
|
139
|
+
return i > 0 && a.push(/* @__PURE__ */ s("li", {
|
|
140
140
|
role: "presentation",
|
|
141
141
|
"aria-hidden": !0,
|
|
142
|
-
style: { height:
|
|
143
|
-
}, "pad-bottom")),
|
|
142
|
+
style: { height: i }
|
|
143
|
+
}, "pad-bottom")), a;
|
|
144
144
|
})(I.rows, R.start, R.end, R.padTop, R.padBottom),
|
|
145
|
-
!T && !I && S.map((e) => e.kind === "option" ? K(e.item) : /* @__PURE__ */
|
|
145
|
+
!T && !I && S.map((e) => e.kind === "option" ? K(e.item) : /* @__PURE__ */ c("li", {
|
|
146
146
|
role: "presentation",
|
|
147
147
|
className: "kapisel__group",
|
|
148
|
-
children: [/* @__PURE__ */
|
|
148
|
+
children: [/* @__PURE__ */ s("div", {
|
|
149
149
|
className: "kapisel__group-label",
|
|
150
150
|
"aria-hidden": "true",
|
|
151
151
|
children: e.label
|
|
152
|
-
}), /* @__PURE__ */
|
|
152
|
+
}), /* @__PURE__ */ s("ul", {
|
|
153
153
|
role: "group",
|
|
154
154
|
"aria-label": e.label,
|
|
155
155
|
className: "kapisel__group-list",
|
|
@@ -161,13 +161,13 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
|
|
|
161
161
|
index: w
|
|
162
162
|
})
|
|
163
163
|
]
|
|
164
|
-
}), D != null && D !== !1 && D !== "" && /* @__PURE__ */
|
|
164
|
+
}), D != null && D !== !1 && D !== "" && /* @__PURE__ */ s("div", {
|
|
165
165
|
className: "kapisel__status",
|
|
166
166
|
role: "status",
|
|
167
167
|
"aria-live": "polite",
|
|
168
168
|
children: D
|
|
169
169
|
})]
|
|
170
|
-
}),
|
|
170
|
+
}), n);
|
|
171
171
|
};
|
|
172
172
|
//#endregion
|
|
173
173
|
export { h as KapiSelectMenu };
|
|
@@ -5,8 +5,8 @@ import { useOwnField as r } from "./ownField.js";
|
|
|
5
5
|
/* empty css */
|
|
6
6
|
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
7
7
|
import { clampToStep as a, percentOf as o } from "./sliderLogic.js";
|
|
8
|
-
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
9
8
|
import "react";
|
|
9
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
10
10
|
//#region src/components/inputs/KapiSlider.tsx
|
|
11
11
|
var l = ({ tone: e = "primary", disabled: t = !1, readOnly: n = !1, className: r = "" } = {}) => [
|
|
12
12
|
"kapi-slider",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/checkControl.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { nativeFieldProps as t } from "./fieldLogic.js";
|
|
5
|
+
import { useKapiField as n } from "./KapiField.js";
|
|
5
6
|
/* empty css */
|
|
6
|
-
import { joinClasses as n } from "../rootProps.js";
|
|
7
7
|
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/inputs/KapiSwitch.tsx
|
|
9
9
|
var o = ({ label: o, className: s, ref: c, invalid: l, id: u, required: d, "aria-describedby": f, "aria-invalid": p, "aria-required": m, ...h }) => {
|
|
10
|
-
let g =
|
|
10
|
+
let g = t(n(), {
|
|
11
11
|
id: u,
|
|
12
12
|
describedBy: f,
|
|
13
13
|
invalid: l,
|
|
@@ -23,10 +23,10 @@ var o = ({ label: o, className: s, ref: c, invalid: l, id: u, required: d, "aria
|
|
|
23
23
|
required: d
|
|
24
24
|
}), /* @__PURE__ */ i("span", { className: "kapi-switch__track" })] });
|
|
25
25
|
return o == null ? /* @__PURE__ */ i("label", {
|
|
26
|
-
className:
|
|
26
|
+
className: e("kapi-switch", s),
|
|
27
27
|
children: _
|
|
28
28
|
}) : /* @__PURE__ */ a("label", {
|
|
29
|
-
className:
|
|
29
|
+
className: e("kapi-switchfield", s),
|
|
30
30
|
children: [/* @__PURE__ */ i("span", {
|
|
31
31
|
className: "kapi-switch",
|
|
32
32
|
children: _
|
|
@@ -1,122 +1,124 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/inputs/KapiTagInput.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useControllableState as
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { assignRef as t, fieldControlProps as n, focusLeaves as r, joinIds as i, resolveReadOnly as a } from "./fieldLogic.js";
|
|
5
|
+
import { useOwnField as o } from "./ownField.js";
|
|
6
|
+
import { useLabels as s } from "../locale/KapiLocaleProvider.js";
|
|
7
|
+
import { useControllableState as ee } from "../../hooks/useControllableState.js";
|
|
8
|
+
import { useFormReset as te } from "../../hooks/useFormReset.js";
|
|
9
|
+
import { useMergedRefs as ne } from "../../hooks/mergeRefs.js";
|
|
8
10
|
/* empty css */
|
|
9
|
-
import { addTags as
|
|
11
|
+
import { addTags as re, hasSeparator as c, removeTagAt as l, spliceText as u, splitDraft as d, splitTags as f } from "./tagInputLogic.js";
|
|
10
12
|
import { KapiTag as ie } from "../display/KapiTag.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { useCallback as ae, useId as oe, useRef as p, useState as m } from "react";
|
|
14
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
15
|
//#region src/components/inputs/KapiTagInput.tsx
|
|
14
16
|
var _ = {
|
|
15
17
|
remove: "Quitar",
|
|
16
18
|
duplicate: "Ya está en la lista:",
|
|
17
19
|
max: "Llegaste al máximo de"
|
|
18
|
-
}, v = ({ size:
|
|
19
|
-
function y({ value:
|
|
20
|
-
let
|
|
21
|
-
id:
|
|
22
|
-
label:
|
|
23
|
-
help:
|
|
24
|
-
required:
|
|
25
|
-
invalid:
|
|
26
|
-
readOnly:
|
|
27
|
-
fieldClassName:
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
let { values: n, rejected: r } =
|
|
32
|
-
validate:
|
|
33
|
-
maxTags:
|
|
34
|
-
allowDuplicates:
|
|
35
|
-
caseSensitive:
|
|
20
|
+
}, v = ({ size: t = "md", invalid: n, disabled: r, readOnly: i, className: a }) => e("kapi-taginput", t !== "md" && `kapi-taginput--${t}`, n && "kapi-taginput--err", r && "kapi-taginput--disabled", i && "kapi-taginput--readonly", a);
|
|
21
|
+
function y({ value: e, defaultValue: y = [], onChange: b, validate: se, maxTags: x, allowDuplicates: ce, caseSensitive: le, placeholder: ue, disabled: S = !1, size: C = "md", name: w, id: T, invalid: E, required: D, label: de, help: fe, fieldClassName: pe, readOnly: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, onBlur: M, ref: N, labels: P, className: F, onClick: I, ...L }) {
|
|
22
|
+
let R = s("tagInput", _, P), z = o({
|
|
23
|
+
id: T,
|
|
24
|
+
label: de,
|
|
25
|
+
help: fe,
|
|
26
|
+
required: D,
|
|
27
|
+
invalid: E,
|
|
28
|
+
readOnly: O,
|
|
29
|
+
fieldClassName: pe
|
|
30
|
+
}), B = z.field, V = a(O, B), H = oe(), [U, W, , me] = ee(e, y, b), [G, K] = m(""), [q, J] = m(null), Y = p(null), he = ne(Y, te(me)), X = p(null), ge = ae((e) => {
|
|
31
|
+
X.current = e, t(N, e);
|
|
32
|
+
}, [N]), _e = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${R.duplicate} ${e.tag}` : `${R.max} ${x}`, Z = (e, t = "") => {
|
|
33
|
+
let { values: n, rejected: r } = re(U, e, {
|
|
34
|
+
validate: se,
|
|
35
|
+
maxTags: x,
|
|
36
|
+
allowDuplicates: ce,
|
|
37
|
+
caseSensitive: le
|
|
36
38
|
});
|
|
37
|
-
n.length !==
|
|
38
|
-
},
|
|
39
|
+
n.length !== U.length && W(n), J(r[0] ? _e(r[0]) : null), K([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
|
|
40
|
+
}, Q = (e) => {
|
|
39
41
|
let t = e.target.value;
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
+
if (J(null), !c(t)) {
|
|
43
|
+
K(t);
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
let { complete: n, tail: r } =
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
if (
|
|
46
|
+
let { complete: n, tail: r } = d(t);
|
|
47
|
+
Z(n, r);
|
|
48
|
+
}, ve = (e) => {
|
|
49
|
+
S || V || (e.key === "Enter" && G.trim() ? (e.preventDefault(), Z(f(G))) : e.key === "Backspace" && G === "" && U.length > 0 && (e.preventDefault(), J(null), W(l(U, U.length - 1))));
|
|
50
|
+
}, ye = (e) => {
|
|
51
|
+
if (V) return;
|
|
50
52
|
let t = e.clipboardData.getData("text");
|
|
51
53
|
if (!c(t)) return;
|
|
52
54
|
e.preventDefault();
|
|
53
|
-
let n = e.currentTarget, r =
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
}, $ =
|
|
62
|
-
return
|
|
63
|
-
...
|
|
64
|
-
ref:
|
|
55
|
+
let n = e.currentTarget, r = u(G, n.selectionStart ?? G.length, n.selectionEnd ?? G.length, t);
|
|
56
|
+
Z(f(r));
|
|
57
|
+
}, be = (e) => {
|
|
58
|
+
r(e.relatedTarget, Y.current) && (G.trim() && !V && Z(f(G)), M?.(e));
|
|
59
|
+
}, xe = (e) => {
|
|
60
|
+
I?.(e), !(e.defaultPrevented || S) && (e.target.closest("button, input") || X.current?.focus());
|
|
61
|
+
}, Se = (e) => {
|
|
62
|
+
J(null), W(l(U, e)), X.current?.focus();
|
|
63
|
+
}, $ = q !== null || (E ?? B?.invalid ?? !1);
|
|
64
|
+
return z.wrap(/* @__PURE__ */ g("div", {
|
|
65
|
+
...L,
|
|
66
|
+
ref: he,
|
|
65
67
|
className: v({
|
|
66
|
-
size:
|
|
68
|
+
size: C,
|
|
67
69
|
invalid: $,
|
|
68
|
-
disabled:
|
|
69
|
-
readOnly:
|
|
70
|
-
className:
|
|
70
|
+
disabled: S,
|
|
71
|
+
readOnly: V,
|
|
72
|
+
className: F
|
|
71
73
|
}),
|
|
72
|
-
onClick:
|
|
73
|
-
onBlur:
|
|
74
|
+
onClick: xe,
|
|
75
|
+
onBlur: be,
|
|
74
76
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ g("div", {
|
|
76
78
|
className: "kapi-taginput__box",
|
|
77
|
-
children: [
|
|
79
|
+
children: [U.length > 0 && /* @__PURE__ */ h("ul", {
|
|
78
80
|
className: "kapi-taginput__tags",
|
|
79
|
-
children:
|
|
81
|
+
children: U.map((e, t) => /* @__PURE__ */ h("li", {
|
|
80
82
|
className: "kapi-taginput__item",
|
|
81
|
-
children: /* @__PURE__ */
|
|
83
|
+
children: /* @__PURE__ */ h(ie, {
|
|
82
84
|
tone: "primary",
|
|
83
|
-
size:
|
|
84
|
-
onRemove:
|
|
85
|
-
removeLabel: `${
|
|
85
|
+
size: C === "sm" ? "sm" : "md",
|
|
86
|
+
onRemove: S || V ? void 0 : () => Se(t),
|
|
87
|
+
removeLabel: `${R.remove} ${e}`,
|
|
86
88
|
children: e
|
|
87
89
|
})
|
|
88
90
|
}, `${t}-${e}`))
|
|
89
|
-
}), /* @__PURE__ */
|
|
90
|
-
ref:
|
|
91
|
+
}), /* @__PURE__ */ h("input", {
|
|
92
|
+
ref: ge,
|
|
91
93
|
type: "text",
|
|
92
94
|
className: "kapi-taginput__input",
|
|
93
|
-
...
|
|
94
|
-
id:
|
|
95
|
-
describedBy:
|
|
95
|
+
...n(B, {
|
|
96
|
+
id: T,
|
|
97
|
+
describedBy: i(q !== null && H, j),
|
|
96
98
|
invalid: $,
|
|
97
|
-
required:
|
|
99
|
+
required: D
|
|
98
100
|
}),
|
|
99
|
-
"aria-label":
|
|
100
|
-
"aria-labelledby":
|
|
101
|
-
placeholder:
|
|
102
|
-
value:
|
|
103
|
-
disabled:
|
|
104
|
-
readOnly:
|
|
101
|
+
"aria-label": k,
|
|
102
|
+
"aria-labelledby": A,
|
|
103
|
+
placeholder: U.length ? void 0 : ue,
|
|
104
|
+
value: G,
|
|
105
|
+
disabled: S,
|
|
106
|
+
readOnly: V || void 0,
|
|
105
107
|
enterKeyHint: "enter",
|
|
106
|
-
onChange:
|
|
107
|
-
onKeyDown:
|
|
108
|
-
onPaste:
|
|
108
|
+
onChange: Q,
|
|
109
|
+
onKeyDown: ve,
|
|
110
|
+
onPaste: ye
|
|
109
111
|
})]
|
|
110
112
|
}),
|
|
111
|
-
|
|
112
|
-
id:
|
|
113
|
+
q !== null && /* @__PURE__ */ h("span", {
|
|
114
|
+
id: H,
|
|
113
115
|
className: "kapi-taginput__error",
|
|
114
116
|
role: "alert",
|
|
115
|
-
children:
|
|
117
|
+
children: q
|
|
116
118
|
}),
|
|
117
|
-
|
|
119
|
+
w && U.map((e, t) => /* @__PURE__ */ h("input", {
|
|
118
120
|
type: "hidden",
|
|
119
|
-
name:
|
|
121
|
+
name: w,
|
|
120
122
|
value: e
|
|
121
123
|
}, `${t}-${e}`))
|
|
122
124
|
]
|
|
@@ -7,8 +7,8 @@ import { inputClasses as i } from "./KapiInput.js";
|
|
|
7
7
|
import { computedStyleOf as a } from "../../hooks/ownerDocument.js";
|
|
8
8
|
import { rafThrottle as o } from "../../hooks/rafThrottle.js";
|
|
9
9
|
import { autosizeHeight as s, rowsToHeight as c } from "./textareaLogic.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useCallback as l, useEffect as u, useLayoutEffect as d, useRef as f } from "react";
|
|
11
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/inputs/KapiTextarea.tsx
|
|
13
13
|
var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
|
|
14
14
|
status: e,
|
|
@@ -26,9 +26,9 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
|
|
|
26
26
|
invalid: i,
|
|
27
27
|
status: h,
|
|
28
28
|
fieldClassName: y
|
|
29
|
-
}), { controlId: j, helpId: M } = A, N =
|
|
29
|
+
}), { controlId: j, helpId: M } = A, N = f(null), P = l((e) => {
|
|
30
30
|
N.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
|
|
31
|
-
}, [E]), F =
|
|
31
|
+
}, [E]), F = f(null), I = l(() => {
|
|
32
32
|
let e = N.current;
|
|
33
33
|
if (!e || !b) return;
|
|
34
34
|
let t = a(e), n = (e) => parseFloat(e) || 0;
|
|
@@ -45,11 +45,11 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
|
|
|
45
45
|
x,
|
|
46
46
|
w
|
|
47
47
|
]), L = D.value;
|
|
48
|
-
|
|
48
|
+
d(() => {
|
|
49
49
|
I();
|
|
50
50
|
}, [I, L]);
|
|
51
|
-
let R =
|
|
52
|
-
R.current = I,
|
|
51
|
+
let R = f(I);
|
|
52
|
+
R.current = I, u(() => {
|
|
53
53
|
let e = N.current;
|
|
54
54
|
if (!e || !b || typeof ResizeObserver > "u") return;
|
|
55
55
|
let t = null, n = o(() => R.current()), r = new ResizeObserver((e) => {
|
|
@@ -66,7 +66,7 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
|
|
|
66
66
|
}, [b]);
|
|
67
67
|
let z = (e) => {
|
|
68
68
|
I(), T?.(e);
|
|
69
|
-
}, B = /* @__PURE__ */
|
|
69
|
+
}, B = /* @__PURE__ */ p("textarea", {
|
|
70
70
|
...D,
|
|
71
71
|
ref: P,
|
|
72
72
|
...e(A.outer, {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** El primer valor repetido de la lista, envuelto para distinguirlo de «no hay». */
|
|
2
|
+
export declare const firstDuplicate: (values: readonly unknown[]) => {
|
|
3
|
+
value: unknown;
|
|
4
|
+
} | null;
|
|
5
|
+
/**
|
|
6
|
+
* Aviso: dos opciones con el mismo valor.
|
|
7
|
+
*
|
|
8
|
+
* Medido en `KapiSelect` con dos opciones de valor `"x"`: las DOS quedan con `aria-selected="true"`,
|
|
9
|
+
* así que un lector de pantalla anuncia dos opciones elegidas a la vez y elegir una no distingue
|
|
10
|
+
* cuál. Nada más lo señalaba.
|
|
11
|
+
*
|
|
12
|
+
* Recibe los valores ya calculados (y memoizados por el componente) en vez de la lista y un
|
|
13
|
+
* `valueOf`: así la dependencia del efecto es estable y no hay que desactivar `exhaustive-deps`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useDuplicateValueWarning: (name: string, values: readonly unknown[]) => void;
|
|
16
|
+
/** Lo que mira el aviso de control mudo. */
|
|
17
|
+
export type MutedControl = {
|
|
18
|
+
/** `value` llegó definido: el estado es del consumidor. */
|
|
19
|
+
controlled: boolean;
|
|
20
|
+
/** Llegó un `onChange` (o el `onXChange` que corresponda). */
|
|
21
|
+
hasOnChange: boolean;
|
|
22
|
+
/** Pedir sólo lectura es explícito: ahí no se avisa. */
|
|
23
|
+
readOnly?: boolean | undefined;
|
|
24
|
+
/** Deshabilitado también es explícito. */
|
|
25
|
+
disabled?: boolean | undefined;
|
|
26
|
+
};
|
|
27
|
+
/** `true` si el control quedó mudo sin que nadie lo haya pedido. */
|
|
28
|
+
export declare const isMuted: ({ controlled, hasOnChange, readOnly, disabled }: MutedControl) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Aviso: `value` sin `onChange` deja el control mudo.
|
|
31
|
+
*
|
|
32
|
+
* Con `value` el estado es del consumidor, así que el componente no guarda nada: sin `onChange`
|
|
33
|
+
* nadie se entera de lo que la persona elige y el control parece roto. Es la forma más común de
|
|
34
|
+
* escribir mal un componente controlado, y no decía nada. `readOnly` y `disabled` son maneras
|
|
35
|
+
* explícitas de pedir justamente eso, así que ahí no avisa.
|
|
36
|
+
*/
|
|
37
|
+
export declare const useMutedControlWarning: (name: string, control: MutedControl) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as e, useRef as t } from "react";
|
|
3
|
+
//#region src/components/inputs/misuseWarnings.ts
|
|
4
|
+
var n = (e) => {
|
|
5
|
+
let t = /* @__PURE__ */ new Set();
|
|
6
|
+
for (let n of e) {
|
|
7
|
+
if (t.has(n)) return { value: n };
|
|
8
|
+
t.add(n);
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}, r = (r, i) => {
|
|
12
|
+
let a = t(!1);
|
|
13
|
+
e(() => {
|
|
14
|
+
if (process.env.NODE_ENV === "production" || a.current) return;
|
|
15
|
+
let e = n(i);
|
|
16
|
+
e && (a.current = !0, console.warn(`${r}: hay dos opciones con el mismo valor (${JSON.stringify(e.value)}). Las dos quedan marcadas como elegidas y no se puede distinguir cuál se eligió. Dales un valor propio.`));
|
|
17
|
+
}, [r, i]);
|
|
18
|
+
}, i = ({ controlled: e, hasOnChange: t, readOnly: n, disabled: r }) => e && !t && !n && !r, a = (n, r) => {
|
|
19
|
+
let a = t(!1), { controlled: o, hasOnChange: s, readOnly: c, disabled: l } = r;
|
|
20
|
+
e(() => {
|
|
21
|
+
process.env.NODE_ENV === "production" || a.current || i({
|
|
22
|
+
controlled: o,
|
|
23
|
+
hasOnChange: s,
|
|
24
|
+
readOnly: c,
|
|
25
|
+
disabled: l
|
|
26
|
+
}) && (a.current = !0, console.warn(`${n}: tiene \`value\` pero no \`onChange\`, así que no responde a lo que la persona elige. Pasa \`onChange\` para quedarte con el valor, \`defaultValue\` para que lo guarde el componente, o \`readOnly\` si de verdad querés que no se pueda cambiar.`));
|
|
27
|
+
}, [
|
|
28
|
+
n,
|
|
29
|
+
o,
|
|
30
|
+
s,
|
|
31
|
+
c,
|
|
32
|
+
l
|
|
33
|
+
]);
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { n as firstDuplicate, i as isMuted, r as useDuplicateValueWarning, a as useMutedControlWarning };
|
|
@@ -3,6 +3,16 @@ export type StepBounds = {
|
|
|
3
3
|
max?: number | undefined;
|
|
4
4
|
step?: number | undefined;
|
|
5
5
|
};
|
|
6
|
+
/** El texto como número decimal finito, o `null` si no lo es. La coma vale como separador. */
|
|
7
|
+
export declare const parseTypedNumber: (text: string) => number | null;
|
|
8
|
+
/**
|
|
9
|
+
* Ajusta al escalón más cercano, contando desde `min` (o desde 0 si no hay).
|
|
10
|
+
*
|
|
11
|
+
* Los botones y las flechas siempre caen en la grilla; lo tipeado no caía, así que con `step={1}`
|
|
12
|
+
* un `2.5` escrito a mano se quedaba en 2.5 y el contador mostraba un valor que sus propios
|
|
13
|
+
* botones no podían producir. Un `step` que no sea un número finito positivo no ajusta nada.
|
|
14
|
+
*/
|
|
15
|
+
export declare const snapToStep: (value: number, { min, step }?: StepBounds) => number;
|
|
6
16
|
/** Clamp to optional bounds. */
|
|
7
17
|
export declare const clampNumber: (value: number, { min, max }?: StepBounds) => number;
|
|
8
18
|
/**
|