@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,91 +1,99 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/navigation/navigation.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { useKapiFormatLocale as t } from "../locale/KapiLocaleProvider.js";
|
|
5
5
|
import { useControllableState as n } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { logicalKeyOf as r } from "../../hooks/directionLogic.js";
|
|
7
|
-
import {
|
|
8
|
-
import { formatCount as a } from "../../hooks/numberFormatLogic.js";
|
|
7
|
+
import { useDuplicateValueWarning as i, useMutedControlWarning as a } from "../inputs/misuseWarnings.js";
|
|
9
8
|
import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
|
|
10
|
-
import {
|
|
9
|
+
import { useSlidingIndicator as s } from "../../hooks/useSlidingIndicator.js";
|
|
10
|
+
import { formatCount as c } from "../../hooks/numberFormatLogic.js";
|
|
11
|
+
import { useScrollEdges as l } from "../../hooks/useScrollEdges.js";
|
|
11
12
|
/* empty css */
|
|
12
|
-
import { nextTabId as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { nextTabId as u, tabClasses as d, tabId as f, tabPanelId as p } from "./tabsLogic.js";
|
|
14
|
+
import { useCallback as m, useId as h, useLayoutEffect as g, useMemo as _, useRef as v } from "react";
|
|
15
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
15
16
|
//#region src/components/navigation/KapiTabs.tsx
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
var S = [];
|
|
18
|
+
function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, className: O, idBase: k, disabled: A = !1, size: j = "md", onKeyDown: M, ref: N, ...P }) {
|
|
19
|
+
let F = t(), I = C ?? w ?? S, L = h(), R = k ?? L, z = v({}), [B, V] = n(T, () => E ?? I[0]?.id, D), H = _(() => I.map((e) => e.id), [I]);
|
|
20
|
+
i("KapiTabs", H), a("KapiTabs", {
|
|
21
|
+
controlled: T !== void 0,
|
|
22
|
+
hasOnChange: !!D,
|
|
23
|
+
disabled: A
|
|
24
|
+
});
|
|
25
|
+
let { containerRef: U, indicatorRef: W } = s({
|
|
26
|
+
active: B ?? null,
|
|
27
|
+
deps: [I],
|
|
21
28
|
findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
|
|
22
|
-
}), { ref:
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
let e =
|
|
27
|
-
e &&
|
|
29
|
+
}), { ref: G, edges: K, reveal: q } = l({ axis: "x" }), J = m((e) => {
|
|
30
|
+
U.current = e, G.current = e;
|
|
31
|
+
}, [U, G]), Y = o(J, N), X = v(!1);
|
|
32
|
+
g(() => {
|
|
33
|
+
let e = U.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
|
|
34
|
+
e && q(e, { instant: !X.current }), X.current = !0;
|
|
28
35
|
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
B,
|
|
37
|
+
U,
|
|
38
|
+
q
|
|
32
39
|
]);
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
let t =
|
|
36
|
-
t !== void 0 && (e.preventDefault(),
|
|
40
|
+
let Z = (e) => A || I.some((t) => t.id === e && t.disabled === !0), Q = B !== void 0 && I.some((e) => e.id === B) && !Z(B) ? B : I.find((e) => !Z(e.id))?.id, $ = (e) => {
|
|
41
|
+
if (M?.(e), e.defaultPrevented || B === void 0) return;
|
|
42
|
+
let t = u(I.map((e) => e.id), B, r(e), Z);
|
|
43
|
+
t !== void 0 && (e.preventDefault(), V(t), z.current[t]?.focus());
|
|
37
44
|
};
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
-
...
|
|
40
|
-
ref:
|
|
41
|
-
className:
|
|
42
|
-
"data-edge-start":
|
|
43
|
-
"data-edge-end":
|
|
45
|
+
return /* @__PURE__ */ x("div", {
|
|
46
|
+
...P,
|
|
47
|
+
ref: Y,
|
|
48
|
+
className: e("kapi-tabs", "kapi-fade-x", j === "sm" && "kapi-tabs--sm", O),
|
|
49
|
+
"data-edge-start": K.start ? "" : void 0,
|
|
50
|
+
"data-edge-end": K.end ? "" : void 0,
|
|
44
51
|
role: "tablist",
|
|
45
|
-
"aria-disabled":
|
|
46
|
-
onKeyDown:
|
|
47
|
-
children: [/* @__PURE__ */
|
|
48
|
-
ref:
|
|
52
|
+
"aria-disabled": A || void 0,
|
|
53
|
+
onKeyDown: $,
|
|
54
|
+
children: [/* @__PURE__ */ b("span", {
|
|
55
|
+
ref: W,
|
|
49
56
|
className: "kapi-tabs__indicator",
|
|
50
57
|
"aria-hidden": "true"
|
|
51
|
-
}),
|
|
52
|
-
let t = e.id ===
|
|
53
|
-
return /* @__PURE__ */
|
|
58
|
+
}), I.map((e) => {
|
|
59
|
+
let t = e.id === B;
|
|
60
|
+
return /* @__PURE__ */ x("button", {
|
|
54
61
|
ref: (t) => {
|
|
55
|
-
|
|
62
|
+
z.current[e.id] = t;
|
|
56
63
|
},
|
|
57
64
|
type: "button",
|
|
58
|
-
id:
|
|
65
|
+
id: f(R, e.id),
|
|
59
66
|
role: "tab",
|
|
60
|
-
"aria-controls":
|
|
67
|
+
"aria-controls": k ? p(k, e.id) : void 0,
|
|
61
68
|
"aria-selected": t,
|
|
62
|
-
tabIndex: e.id ===
|
|
63
|
-
disabled:
|
|
64
|
-
className:
|
|
65
|
-
onClick: () =>
|
|
69
|
+
tabIndex: e.id === Q ? 0 : -1,
|
|
70
|
+
disabled: Z(e.id) || void 0,
|
|
71
|
+
className: d(t),
|
|
72
|
+
onClick: () => V(e.id),
|
|
66
73
|
children: [
|
|
67
74
|
e.icon,
|
|
68
75
|
e.label,
|
|
69
|
-
e.count !== void 0 && /* @__PURE__ */
|
|
76
|
+
e.count !== void 0 && /* @__PURE__ */ x(y, { children: [" ", /* @__PURE__ */ b("span", {
|
|
70
77
|
className: "kapi-tabs__count",
|
|
71
|
-
children:
|
|
78
|
+
children: c(e.count, F)
|
|
72
79
|
})] })
|
|
73
80
|
]
|
|
74
81
|
}, e.id);
|
|
75
82
|
})]
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
|
-
function
|
|
79
|
-
return /* @__PURE__ */
|
|
80
|
-
ref:
|
|
81
|
-
|
|
85
|
+
function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, style: a, children: o, ref: s }) {
|
|
86
|
+
return /* @__PURE__ */ b("div", {
|
|
87
|
+
ref: s,
|
|
88
|
+
style: a,
|
|
89
|
+
id: p(e, t),
|
|
82
90
|
role: "tabpanel",
|
|
83
|
-
"aria-labelledby":
|
|
91
|
+
"aria-labelledby": f(e, t),
|
|
84
92
|
tabIndex: 0,
|
|
85
93
|
hidden: !n,
|
|
86
94
|
className: i,
|
|
87
|
-
children: n || r ?
|
|
95
|
+
children: n || r ? o : null
|
|
88
96
|
});
|
|
89
97
|
}
|
|
90
98
|
//#endregion
|
|
91
|
-
export {
|
|
99
|
+
export { w as KapiTabPanel, C as KapiTabs };
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/navigation/navigation.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 { isTypeaheadKey as n } from "../overlays/menuKeyboardLogic.js";
|
|
6
6
|
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
7
7
|
import { logicalKeyOf as i } from "../../hooks/directionLogic.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
|
|
9
|
+
import { useTypeahead as o } from "../../hooks/useTypeahead.js";
|
|
10
|
+
import { useVirtualList as s } from "../../hooks/useVirtualList.js";
|
|
11
11
|
/* empty css */
|
|
12
12
|
import { TREE_KEYS as c, flattenVisible as l, isExpandable as u, matchTypeahead as ee, needsChildren as te, resolveTabStop as ne, toggleSelectedId as re, treeKeyAction as d } from "./treeLogic.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { ChevronRight as
|
|
13
|
+
import { useId as ie, useLayoutEffect as ae, useMemo as f, useRef as p, useState as oe } from "react";
|
|
14
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
|
+
import { ChevronRight as _ } from "lucide-react";
|
|
16
16
|
//#region src/components/navigation/KapiTree.tsx
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let
|
|
17
|
+
var v = { loading: "Cargando…" }, se = 37, y = 400;
|
|
18
|
+
function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsChange: x, expanded: S, defaultExpanded: C, onExpandedChange: ue, onExpand: de, selectedIds: fe, defaultSelectedIds: pe, onSelectedIdsChange: me, selected: he, defaultSelected: ge, onSelectedChange: _e, multiple: w = !1, renderLabel: T, labels: ve, virtual: E = !1, maxHeight: D = y, className: O, style: k, ref: A, onKeyDown: j, onFocus: M, ...N }) {
|
|
19
|
+
let P = t("tree", v, ve), F = ie(), [I, ye] = r(ce ?? S, () => le ?? C ?? [], x ?? ue), [L, be] = r(fe ?? he, () => pe ?? ge ?? []), xe = me ?? _e, [Se, R] = oe(null), z = p(/* @__PURE__ */ new Map()), Ce = o(500), B = f(() => l(b, I), [b, I]), V = ne(b, B, Se, L), H = f(() => new Map(B.map((e, t) => [e.node.id, {
|
|
20
20
|
...e,
|
|
21
21
|
node: e.node,
|
|
22
22
|
index: t
|
|
23
23
|
}])), [B]), U = (e, t) => {
|
|
24
|
-
|
|
24
|
+
ye(e), t.filter(te).forEach((e) => de?.(e));
|
|
25
25
|
}, W = (e) => !e.disabled && u(e), G = (e) => {
|
|
26
|
-
W(e) && !
|
|
26
|
+
W(e) && !I.includes(e.id) && U([...I, e.id], [e]);
|
|
27
27
|
}, K = (e) => {
|
|
28
|
-
W(e) &&
|
|
28
|
+
W(e) && I.includes(e.id) && U(I.filter((t) => t !== e.id), []);
|
|
29
29
|
}, we = (e) => {
|
|
30
|
-
|
|
30
|
+
I.includes(e.id) ? K(e) : G(e);
|
|
31
31
|
}, q = (e) => {
|
|
32
32
|
if (e.disabled) return;
|
|
33
|
-
let t = re(
|
|
34
|
-
|
|
35
|
-
}, J =
|
|
36
|
-
enabled:
|
|
33
|
+
let t = re(L, e.id, w);
|
|
34
|
+
be(t), xe?.(t, e);
|
|
35
|
+
}, J = p(null), Te = a(A, J), Ee = f(() => E ? B.map((e) => e.node.id) : void 0, [E, B]), Y = s({
|
|
36
|
+
enabled: E,
|
|
37
37
|
count: B.length,
|
|
38
38
|
scrollRef: J,
|
|
39
|
-
estimate:
|
|
39
|
+
estimate: se,
|
|
40
40
|
measure: !0,
|
|
41
41
|
keys: Ee,
|
|
42
|
-
fallbackViewHeight:
|
|
43
|
-
}), X =
|
|
42
|
+
fallbackViewHeight: y
|
|
43
|
+
}), X = p(null);
|
|
44
44
|
ae(() => {
|
|
45
|
-
let e = X.current, t = e === null ? void 0 :
|
|
45
|
+
let e = X.current, t = e === null ? void 0 : z.current.get(e);
|
|
46
46
|
t && (X.current = null, t.focus());
|
|
47
47
|
});
|
|
48
48
|
let Z = (e) => {
|
|
49
|
-
|
|
50
|
-
let t =
|
|
51
|
-
if (
|
|
49
|
+
R(e);
|
|
50
|
+
let t = z.current.get(e);
|
|
51
|
+
if (E) {
|
|
52
52
|
let t = H.get(e)?.index;
|
|
53
53
|
t !== void 0 && Y.scrollToIndex(t);
|
|
54
54
|
}
|
|
55
55
|
t ? t.focus() : X.current = e;
|
|
56
56
|
}, De = (e) => {
|
|
57
|
-
if (
|
|
57
|
+
if (j?.(e), e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
58
58
|
let t = V;
|
|
59
59
|
if (t === null) return;
|
|
60
60
|
let r = e.target.getAttribute("role") === "treeitem", a = e.key === "Enter" || e.key === " ";
|
|
@@ -63,10 +63,10 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
|
|
|
63
63
|
e.preventDefault();
|
|
64
64
|
let n = d({
|
|
65
65
|
key: i(e),
|
|
66
|
-
nodes:
|
|
66
|
+
nodes: b,
|
|
67
67
|
visible: B,
|
|
68
68
|
focusId: t,
|
|
69
|
-
expanded:
|
|
69
|
+
expanded: I
|
|
70
70
|
});
|
|
71
71
|
if (!n) return;
|
|
72
72
|
switch (n.type) {
|
|
@@ -89,8 +89,8 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
|
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
case "expandMany": {
|
|
92
|
-
let e = n.ids.filter((e) => !
|
|
93
|
-
U([...
|
|
92
|
+
let e = n.ids.filter((e) => !I.includes(e)), t = e.flatMap((e) => H.get(e)?.node ?? []);
|
|
93
|
+
U([...I, ...e], t);
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -99,27 +99,27 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
|
|
|
99
99
|
if (!n(e.key)) return;
|
|
100
100
|
let o = H.get(t)?.index;
|
|
101
101
|
if (o === void 0) return;
|
|
102
|
-
let s = ee(B, o,
|
|
102
|
+
let s = ee(B, o, Ce(e.key));
|
|
103
103
|
s && (e.preventDefault(), Z(s));
|
|
104
104
|
}, Oe = (e) => {
|
|
105
|
-
if (
|
|
105
|
+
if (M?.(e), E && e.target === e.currentTarget && V !== null) {
|
|
106
106
|
Z(V);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
let t = e.target.dataset.treeId;
|
|
110
|
-
t !== void 0 &&
|
|
111
|
-
}, Q = (
|
|
112
|
-
let r = H.get(
|
|
110
|
+
t !== void 0 && R(t);
|
|
111
|
+
}, Q = (t, n) => {
|
|
112
|
+
let r = H.get(t.id);
|
|
113
113
|
if (!r) return null;
|
|
114
|
-
let i = u(
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
ref: (
|
|
117
|
-
|
|
114
|
+
let i = u(t), a = i && I.includes(t.id), o = L.includes(t.id), s = i && t.loading === !0, c = `${F}-l-${r.index}`, l = `${F}-w-${r.index}`;
|
|
115
|
+
return /* @__PURE__ */ g("li", {
|
|
116
|
+
ref: (e) => {
|
|
117
|
+
e ? z.current.set(t.id, e) : z.current.delete(t.id);
|
|
118
118
|
},
|
|
119
119
|
role: "treeitem",
|
|
120
|
-
"data-tree-id":
|
|
120
|
+
"data-tree-id": t.id,
|
|
121
121
|
"data-vindex": n,
|
|
122
|
-
className:
|
|
122
|
+
className: e("kapi-tree__item", o && "kapi-tree__item--selected", a && "kapi-tree__item--open"),
|
|
123
123
|
"aria-labelledby": c,
|
|
124
124
|
"aria-describedby": s ? l : void 0,
|
|
125
125
|
"aria-level": r.level,
|
|
@@ -127,83 +127,83 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
|
|
|
127
127
|
"aria-posinset": r.posInSet,
|
|
128
128
|
"aria-expanded": i ? a : void 0,
|
|
129
129
|
"aria-selected": o,
|
|
130
|
-
"aria-disabled":
|
|
130
|
+
"aria-disabled": t.disabled || void 0,
|
|
131
131
|
"aria-busy": s || void 0,
|
|
132
|
-
tabIndex: V ===
|
|
133
|
-
children: [/* @__PURE__ */
|
|
132
|
+
tabIndex: V === t.id ? 0 : -1,
|
|
133
|
+
children: [/* @__PURE__ */ g("div", {
|
|
134
134
|
className: "kapi-tree__row",
|
|
135
135
|
style: { "--kapi-tree-level": r.level },
|
|
136
|
-
onClick: () => q(
|
|
136
|
+
onClick: () => q(t),
|
|
137
137
|
children: [
|
|
138
|
-
i ? /* @__PURE__ */
|
|
138
|
+
i ? /* @__PURE__ */ h("span", {
|
|
139
139
|
className: "kapi-tree__toggle",
|
|
140
140
|
"aria-hidden": "true",
|
|
141
|
-
onClick: (
|
|
142
|
-
|
|
141
|
+
onClick: (e) => {
|
|
142
|
+
e.stopPropagation(), we(t);
|
|
143
143
|
},
|
|
144
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ h(_, {
|
|
145
145
|
className: "kapi-tree__chevron kapi-flip-rtl",
|
|
146
146
|
size: 16,
|
|
147
147
|
strokeWidth: 2.2
|
|
148
148
|
})
|
|
149
|
-
}) : /* @__PURE__ */
|
|
149
|
+
}) : /* @__PURE__ */ h("span", {
|
|
150
150
|
className: "kapi-tree__toggle kapi-tree__toggle--leaf",
|
|
151
151
|
"aria-hidden": "true"
|
|
152
152
|
}),
|
|
153
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ h("span", {
|
|
154
154
|
id: c,
|
|
155
155
|
className: "kapi-tree__label",
|
|
156
|
-
children:
|
|
156
|
+
children: T ? T(t) : t.label
|
|
157
157
|
}),
|
|
158
|
-
s && /* @__PURE__ */ m
|
|
158
|
+
s && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
159
159
|
className: "kapi-tree__spinner kapi-spinner kapi-spinner--sm",
|
|
160
160
|
"aria-hidden": "true"
|
|
161
|
-
}), /* @__PURE__ */
|
|
161
|
+
}), /* @__PURE__ */ h("span", {
|
|
162
162
|
id: l,
|
|
163
163
|
className: "kapi-tree__sr",
|
|
164
|
-
children:
|
|
164
|
+
children: P.loading
|
|
165
165
|
})] })
|
|
166
166
|
]
|
|
167
|
-
}), n === void 0 && a &&
|
|
167
|
+
}), n === void 0 && a && t.children?.length ? /* @__PURE__ */ h("ul", {
|
|
168
168
|
role: "group",
|
|
169
169
|
className: "kapi-tree__group",
|
|
170
|
-
children: $(
|
|
170
|
+
children: $(t.children)
|
|
171
171
|
}) : null]
|
|
172
|
-
},
|
|
173
|
-
}, $ = (e) => e.map((e) => Q(e)), ke = () => /* @__PURE__ */ m
|
|
174
|
-
Y.padTop > 0 && /* @__PURE__ */
|
|
172
|
+
}, t.id);
|
|
173
|
+
}, $ = (e) => e.map((e) => Q(e)), ke = () => /* @__PURE__ */ g(m, { children: [
|
|
174
|
+
Y.padTop > 0 && /* @__PURE__ */ h("li", {
|
|
175
175
|
role: "none",
|
|
176
176
|
"aria-hidden": !0,
|
|
177
177
|
className: "kapi-tree__pad",
|
|
178
178
|
style: { height: Y.padTop }
|
|
179
179
|
}),
|
|
180
180
|
B.slice(Y.start, Y.end).map((e, t) => Q(e.node, Y.start + t)),
|
|
181
|
-
Y.padBottom > 0 && /* @__PURE__ */
|
|
181
|
+
Y.padBottom > 0 && /* @__PURE__ */ h("li", {
|
|
182
182
|
role: "none",
|
|
183
183
|
"aria-hidden": !0,
|
|
184
184
|
className: "kapi-tree__pad",
|
|
185
185
|
style: { height: Y.padBottom }
|
|
186
186
|
})
|
|
187
|
-
] }), Ae = !
|
|
187
|
+
] }), Ae = !E || (() => {
|
|
188
188
|
let e = V === null ? void 0 : H.get(V)?.index;
|
|
189
189
|
return e === void 0 || e >= Y.start && e < Y.end;
|
|
190
190
|
})();
|
|
191
|
-
return /* @__PURE__ */
|
|
192
|
-
...
|
|
191
|
+
return /* @__PURE__ */ h("ul", {
|
|
192
|
+
...N,
|
|
193
193
|
role: "tree",
|
|
194
|
-
"aria-multiselectable":
|
|
195
|
-
ref:
|
|
196
|
-
className:
|
|
197
|
-
style:
|
|
198
|
-
maxHeight:
|
|
199
|
-
...
|
|
200
|
-
} :
|
|
194
|
+
"aria-multiselectable": w || void 0,
|
|
195
|
+
ref: E ? Te : A,
|
|
196
|
+
className: e("kapi-tree", E && "kapi-tree--virtual", O),
|
|
197
|
+
style: E ? {
|
|
198
|
+
maxHeight: D,
|
|
199
|
+
...k
|
|
200
|
+
} : k,
|
|
201
201
|
...Ae ? {} : { tabIndex: 0 },
|
|
202
202
|
onKeyDown: De,
|
|
203
203
|
onFocus: Oe,
|
|
204
|
-
onScroll:
|
|
205
|
-
children:
|
|
204
|
+
onScroll: E ? Y.onScroll : void 0,
|
|
205
|
+
children: E ? ke() : $(b)
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
//#endregion
|
|
209
|
-
export {
|
|
209
|
+
export { v as DEFAULT_TREE_LABELS, b as KapiTree };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
4
|
export type KapiWizardStep = {
|
|
4
5
|
title: string;
|
|
@@ -36,7 +37,7 @@ export type KapiWizardProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
36
37
|
* Se dispara con «Cancelar» (el botón del primer paso): el consumidor cierra el flujo (p. ej. el modal
|
|
37
38
|
* que lo contiene), igual que el `onClose` de los overlays.
|
|
38
39
|
*/
|
|
39
|
-
onClose?: (() => void) | undefined;
|
|
40
|
+
onClose?: ((reason: KapiCloseReason) => void) | undefined;
|
|
40
41
|
/**
|
|
41
42
|
* Nombre anterior de `onClose`; si llegan los dos, solo se llama a `onClose`.
|
|
42
43
|
* @deprecated Usar `onClose` (la convención no usa `onCancel`).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
+
import { KapiButton as t } from "../inputs/KapiButton.js";
|
|
4
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
5
5
|
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { canJumpTo as i, clampStep as a, isThenable as o, resolveAdvance as s } from "./wizardLogic.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useRef as c, useState as l } from "react";
|
|
8
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
9
|
import { Check as p, ChevronLeft as m, ChevronRight as h } from "lucide-react";
|
|
10
10
|
//#region src/components/navigation/KapiWizard.tsx
|
|
11
11
|
var g = {
|
|
@@ -18,7 +18,7 @@ var g = {
|
|
|
18
18
|
size: 15,
|
|
19
19
|
strokeWidth: 2.2
|
|
20
20
|
}, v = (e, t) => e === void 0 ? t : e, y = ({ steps: y, orientation: b = "horizontal", onFinish: x, onClose: S, onCancel: C, finishLabel: w, cancelLabel: T, backLabel: E, nextLabel: D, labels: O, step: k, defaultStep: A = 0, onStepChange: j, className: M, ...N }) => {
|
|
21
|
-
let P =
|
|
21
|
+
let P = n("wizard", g, O), [F, I] = r(k, A, j), [L, R] = l(!1), z = c(0), B = c(0), V = a(F, y.length);
|
|
22
22
|
B.current = V;
|
|
23
23
|
let H = y[V];
|
|
24
24
|
if (!H) return null;
|
|
@@ -41,78 +41,78 @@ var g = {
|
|
|
41
41
|
}
|
|
42
42
|
let t = z.current += 1, n = V;
|
|
43
43
|
R(!0), e.then((e) => q(t, n, !!e), () => q(t, n, !1));
|
|
44
|
-
}, Y = /* @__PURE__ */
|
|
44
|
+
}, Y = /* @__PURE__ */ f("div", {
|
|
45
45
|
className: "kapi-wz__nav",
|
|
46
|
-
children: [/* @__PURE__ */
|
|
47
|
-
onClick: V === 0 ? S
|
|
46
|
+
children: [/* @__PURE__ */ d(t, {
|
|
47
|
+
onClick: V === 0 ? () => S ? S("cancel") : C?.() : () => W(V - 1),
|
|
48
48
|
disabled: L,
|
|
49
|
-
children: V === 0 ? v(T, P.cancel) : /* @__PURE__ */ u
|
|
49
|
+
children: V === 0 ? v(T, P.cancel) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(m, {
|
|
50
50
|
className: "kapi-flip-rtl",
|
|
51
51
|
..._
|
|
52
52
|
}), v(E, P.back)] })
|
|
53
|
-
}), /* @__PURE__ */
|
|
53
|
+
}), /* @__PURE__ */ d(t, {
|
|
54
54
|
tone: "primary",
|
|
55
55
|
onClick: J,
|
|
56
56
|
disabled: L,
|
|
57
57
|
"aria-busy": L || void 0,
|
|
58
|
-
children: L ? P.validating : U ? v(w, P.finish) : /* @__PURE__ */ u
|
|
58
|
+
children: L ? P.validating : U ? v(w, P.finish) : /* @__PURE__ */ f(u, { children: [v(D, P.next), /* @__PURE__ */ d(h, {
|
|
59
59
|
className: "kapi-flip-rtl",
|
|
60
60
|
..._
|
|
61
61
|
})] })
|
|
62
62
|
})]
|
|
63
|
-
}), X = /* @__PURE__ */
|
|
63
|
+
}), X = /* @__PURE__ */ d("div", {
|
|
64
64
|
className: "kapi-wz__pane",
|
|
65
65
|
children: H.content
|
|
66
66
|
}, V);
|
|
67
|
-
return b === "vertical" ? /* @__PURE__ */
|
|
67
|
+
return b === "vertical" ? /* @__PURE__ */ f("div", {
|
|
68
68
|
...N,
|
|
69
|
-
className:
|
|
70
|
-
children: [/* @__PURE__ */
|
|
69
|
+
className: e("kapi-wz kapi-wz--v", M),
|
|
70
|
+
children: [/* @__PURE__ */ d("div", {
|
|
71
71
|
className: "kapi-wz__rail",
|
|
72
|
-
children: y.map((e, t) => /* @__PURE__ */
|
|
72
|
+
children: y.map((e, t) => /* @__PURE__ */ f("button", {
|
|
73
73
|
type: "button",
|
|
74
74
|
className: `kapi-wz__vstep${t === V ? " is-on" : ""}`,
|
|
75
75
|
"aria-current": t === V ? "step" : void 0,
|
|
76
76
|
onClick: () => G(t),
|
|
77
|
-
children: [/* @__PURE__ */
|
|
77
|
+
children: [/* @__PURE__ */ d("span", {
|
|
78
78
|
className: `kapi-step__dot${t < V ? " kapi-step__dot--done" : ""}${t === V ? " kapi-step__dot--on" : ""}`,
|
|
79
|
-
children: t < V ? /* @__PURE__ */
|
|
79
|
+
children: t < V ? /* @__PURE__ */ d(p, {
|
|
80
80
|
size: 13,
|
|
81
81
|
strokeWidth: 3
|
|
82
82
|
}) : t + 1
|
|
83
|
-
}), /* @__PURE__ */
|
|
83
|
+
}), /* @__PURE__ */ f("span", {
|
|
84
84
|
className: "kapi-wz__vlabel",
|
|
85
|
-
children: [/* @__PURE__ */
|
|
85
|
+
children: [/* @__PURE__ */ d("b", { children: e.title }), e.desc && /* @__PURE__ */ d("span", { children: e.desc })]
|
|
86
86
|
})]
|
|
87
87
|
}, `${t}-${e.title}`))
|
|
88
|
-
}), /* @__PURE__ */
|
|
88
|
+
}), /* @__PURE__ */ f("div", {
|
|
89
89
|
className: "kapi-wz__main",
|
|
90
90
|
children: [X, Y]
|
|
91
91
|
})]
|
|
92
|
-
}) : /* @__PURE__ */
|
|
92
|
+
}) : /* @__PURE__ */ f("div", {
|
|
93
93
|
...N,
|
|
94
|
-
className:
|
|
94
|
+
className: e("kapi-wz", M),
|
|
95
95
|
children: [
|
|
96
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ d("div", {
|
|
97
97
|
className: "kapi-wz__steps",
|
|
98
|
-
children: y.map((e, t) => /* @__PURE__ */
|
|
98
|
+
children: y.map((e, t) => /* @__PURE__ */ f("button", {
|
|
99
99
|
type: "button",
|
|
100
100
|
className: `kapi-wz__step${t === V ? " is-on" : ""}${t < V ? " is-done" : ""}`,
|
|
101
101
|
"aria-current": t === V ? "step" : void 0,
|
|
102
102
|
onClick: () => G(t),
|
|
103
103
|
children: [
|
|
104
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ d("span", {
|
|
105
105
|
className: "kapi-wz__num",
|
|
106
|
-
children: t < V ? /* @__PURE__ */
|
|
106
|
+
children: t < V ? /* @__PURE__ */ d(p, {
|
|
107
107
|
size: 16,
|
|
108
108
|
strokeWidth: 3
|
|
109
109
|
}) : t + 1
|
|
110
110
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ d("span", {
|
|
112
112
|
className: "kapi-wz__st",
|
|
113
113
|
children: e.title
|
|
114
114
|
}),
|
|
115
|
-
e.desc && /* @__PURE__ */
|
|
115
|
+
e.desc && /* @__PURE__ */ d("span", {
|
|
116
116
|
className: "kapi-wz__ss",
|
|
117
117
|
children: e.desc
|
|
118
118
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type SubmitEvent, type ReactNode } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import { type KapiOffcanvasProps } from "./KapiOffcanvas.js";
|
|
3
4
|
/**
|
|
4
5
|
* Textos de los botones (clave `canvasForm` del provider). No hay prop `labels` propia: `labels` es la
|
|
@@ -10,8 +11,11 @@ export type KapiCanvasFormLabels = {
|
|
|
10
11
|
};
|
|
11
12
|
export declare const DEFAULT_CANVAS_FORM_LABELS: KapiCanvasFormLabels;
|
|
12
13
|
export type KapiCanvasFormProps = Omit<KapiOffcanvasProps, "footer" | "children" | "onClose"> & {
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Pedido de cierre, con la razón: `close-button` la X, `backdrop` el fondo, `escape` la tecla y
|
|
16
|
+
* `cancel` el botón Cancelar del pie. Se ignora mientras se está guardando.
|
|
17
|
+
*/
|
|
18
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
15
19
|
/** Los campos del formulario. */
|
|
16
20
|
children?: ReactNode;
|
|
17
21
|
/**
|