@kapiuara/ui 0.14.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 +234 -1
- 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/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 +53 -53
- 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 +31 -31
- package/dist/components/feedback/KapiOfflineBanner.js +8 -8
- package/dist/components/feedback/KapiToastContainer.js +21 -21
- package/dist/components/feedback/KapiTour.d.ts +2 -1
- package/dist/components/feedback/KapiTour.js +32 -32
- 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 +28 -28
- package/dist/components/inputs/KapiDateRangePicker.js +27 -27
- package/dist/components/inputs/KapiFacetedSearch.js +24 -24
- 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.js +22 -22
- package/dist/components/inputs/KapiNumberStepper.js +12 -12
- package/dist/components/inputs/KapiRating.js +1 -1
- package/dist/components/inputs/KapiSearchChip.js +8 -8
- package/dist/components/inputs/KapiSegmented.js +27 -27
- package/dist/components/inputs/KapiSelect.js +166 -166
- 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 +22 -22
- package/dist/components/inputs/KapiTextarea.js +8 -8
- package/dist/components/inputs/ownField.js +4 -4
- package/dist/components/layout/KapiAccountMenu.d.ts +2 -1
- package/dist/components/layout/KapiAccountMenu.js +51 -51
- 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/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 +18 -17
- package/dist/components/navigation/KapiTree.js +72 -72
- 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 +15 -15
- package/dist/components/overlays/KapiDialogHost.js +22 -22
- package/dist/components/overlays/KapiLoading.js +16 -16
- package/dist/components/overlays/KapiMenuButton.js +12 -12
- 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 +14 -14
- package/dist/components/overlays/KapiPopover.d.ts +2 -1
- package/dist/components/overlays/KapiPopover.js +7 -7
- package/dist/components/overlays/KapiShapeSheet.js +17 -17
- package/dist/components/overlays/KapiSplitModal.js +29 -29
- package/dist/components/overlays/KapiTooltip.js +20 -20
- 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/hooks/portalRoot.js +6 -6
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -7,12 +7,12 @@ import { useDismiss as r } from "../../hooks/useDismiss.js";
|
|
|
7
7
|
import { KapiOverlayPortal as i } from "./overlayPortal.js";
|
|
8
8
|
import { useExitPresence as a } from "./useExitPresence.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
11
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/overlays/KapiPopover.tsx
|
|
13
13
|
function u({ open: u, anchorRef: d, onClose: f, side: p = "bottom", align: m = "start", offset: h = 6, margin: g = 8, matchAnchorWidth: _ = !1, role: v = "dialog", "aria-label": y, id: b, className: x = "", style: S, ref: C, closeOnEscape: w = !0, closeOnOutside: T = !0, restoreFocus: E = !0, children: D }) {
|
|
14
|
-
let O =
|
|
15
|
-
|
|
14
|
+
let O = s(null), k = n(O, C), [A, j] = c(null), { present: M, closing: N } = a(u, O);
|
|
15
|
+
o(() => {
|
|
16
16
|
j(M ? e(d.current) : null);
|
|
17
17
|
}, [M, d]);
|
|
18
18
|
let { placement: P, style: F } = t({
|
|
@@ -30,12 +30,12 @@ function u({ open: u, anchorRef: d, onClose: f, side: p = "bottom", align: m = "
|
|
|
30
30
|
escape: w,
|
|
31
31
|
outside: T,
|
|
32
32
|
onDismiss: (e) => {
|
|
33
|
-
f?.(), e === "escape" && E && d.current?.focus();
|
|
33
|
+
f?.(e), e === "escape" && E && d.current?.focus();
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
return M ? /* @__PURE__ */
|
|
36
|
+
return M ? /* @__PURE__ */ l(i, {
|
|
37
37
|
root: A,
|
|
38
|
-
children: /* @__PURE__ */
|
|
38
|
+
children: /* @__PURE__ */ l("div", {
|
|
39
39
|
ref: k,
|
|
40
40
|
id: b,
|
|
41
41
|
role: v,
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/overlays.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 { useControllableState as n } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
|
|
7
7
|
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
8
8
|
/* empty css */
|
|
9
9
|
import { focusableWithin as a } from "../../hooks/focusLogic.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useEffect as o, useId as s, useRef as c } from "react";
|
|
11
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
12
12
|
import { Minus as d, Plus as f } from "lucide-react";
|
|
13
13
|
//#region src/components/overlays/KapiShapeSheet.tsx
|
|
14
14
|
var p = {
|
|
15
15
|
close: "Cerrar",
|
|
16
16
|
open: "Abrir"
|
|
17
17
|
}, m = ({ title: m, children: h, width: g = 300, height: _ = 250, label: v, labels: y, className: b, style: x, id: S, ref: C, open: w, defaultOpen: T = !1, onOpenChange: E }) => {
|
|
18
|
-
let D =
|
|
18
|
+
let D = t("shapeSheet", p, y), O = c(null), k = r(O, C), A = c(null), j = c(null), M = c(null), N = s(), [P, F] = n(w, T, E), I = c(P);
|
|
19
19
|
I.current = P;
|
|
20
20
|
let L = (e) => {
|
|
21
21
|
e !== I.current && F(e);
|
|
22
|
-
}, R =
|
|
22
|
+
}, R = c(!1), z = () => {
|
|
23
23
|
R.current = !0, L(!1);
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
o(() => {
|
|
26
26
|
P ? (a(M.current)[0] ?? j.current)?.focus() : R.current && (R.current = !1, A.current?.focus());
|
|
27
27
|
}, [P]);
|
|
28
28
|
let B = i(P, {
|
|
@@ -31,17 +31,17 @@ var p = {
|
|
|
31
31
|
e === "escape" && (R.current = !0), L(!1);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ u("div", {
|
|
35
35
|
ref: k,
|
|
36
36
|
id: S,
|
|
37
|
-
className:
|
|
37
|
+
className: e("kapi-shape", P && "kapi-shape--open", b),
|
|
38
38
|
style: P ? {
|
|
39
39
|
...x,
|
|
40
40
|
width: g,
|
|
41
41
|
height: _
|
|
42
42
|
} : x,
|
|
43
43
|
onKeyDown: B,
|
|
44
|
-
children: [/* @__PURE__ */
|
|
44
|
+
children: [/* @__PURE__ */ l("button", {
|
|
45
45
|
ref: A,
|
|
46
46
|
type: "button",
|
|
47
47
|
className: "kapi-shape__fab",
|
|
@@ -49,34 +49,34 @@ var p = {
|
|
|
49
49
|
onClick: () => L(!0),
|
|
50
50
|
"aria-expanded": P,
|
|
51
51
|
"aria-label": v ?? D.open,
|
|
52
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ l(f, {
|
|
53
53
|
size: 22,
|
|
54
54
|
strokeWidth: 2.4
|
|
55
55
|
})
|
|
56
|
-
}), /* @__PURE__ */
|
|
56
|
+
}), /* @__PURE__ */ u("div", {
|
|
57
57
|
ref: j,
|
|
58
58
|
className: "kapi-shape__sheet",
|
|
59
59
|
inert: !P,
|
|
60
60
|
role: "dialog",
|
|
61
61
|
"aria-labelledby": N,
|
|
62
62
|
tabIndex: -1,
|
|
63
|
-
children: [/* @__PURE__ */
|
|
63
|
+
children: [/* @__PURE__ */ u("div", {
|
|
64
64
|
className: "kapi-shape__head",
|
|
65
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ l("span", {
|
|
66
66
|
className: "kapi-shape__title",
|
|
67
67
|
id: N,
|
|
68
68
|
children: m
|
|
69
|
-
}), /* @__PURE__ */
|
|
69
|
+
}), /* @__PURE__ */ l("button", {
|
|
70
70
|
type: "button",
|
|
71
71
|
className: "kapi-shape__close",
|
|
72
72
|
onClick: z,
|
|
73
73
|
"aria-label": D.close,
|
|
74
|
-
children: /* @__PURE__ */
|
|
74
|
+
children: /* @__PURE__ */ l(d, {
|
|
75
75
|
size: 16,
|
|
76
76
|
strokeWidth: 2.4
|
|
77
77
|
})
|
|
78
78
|
})]
|
|
79
|
-
}), /* @__PURE__ */
|
|
79
|
+
}), /* @__PURE__ */ l("div", {
|
|
80
80
|
className: "kapi-shape__body",
|
|
81
81
|
ref: M,
|
|
82
82
|
children: h
|
|
@@ -8,8 +8,8 @@ import { useBackdropClose as a, useNativeDialog as o, usePortalRoot as s, useTra
|
|
|
8
8
|
/* empty css */
|
|
9
9
|
import { resolveAsideWidth as l, resolvePanelOrder as u, splitModalClasses as d } from "./splitModalLayout.js";
|
|
10
10
|
/* empty css */
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { useId as f, useRef as p } from "react";
|
|
12
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
13
|
import { X as g } from "lucide-react";
|
|
14
14
|
import { createPortal as _ } from "react-dom";
|
|
15
15
|
//#region src/components/overlays/KapiSplitModal.tsx
|
|
@@ -17,99 +17,99 @@ var v = {
|
|
|
17
17
|
close: "Cerrar",
|
|
18
18
|
closePanel: "Cerrar panel"
|
|
19
19
|
}, y = ({ open: e, ...t }) => {
|
|
20
|
-
let n =
|
|
21
|
-
return r ? /* @__PURE__ */
|
|
20
|
+
let n = p(null), { present: r, closing: a } = i(e, n);
|
|
21
|
+
return r ? /* @__PURE__ */ m(x, {
|
|
22
22
|
...t,
|
|
23
23
|
dialogRef: n,
|
|
24
24
|
closing: a
|
|
25
25
|
}) : null;
|
|
26
|
-
}, b = () => {}, x = ({ title: i, subtitle:
|
|
27
|
-
let z = R ? b : y, B =
|
|
26
|
+
}, b = () => {}, x = ({ title: i, subtitle: p, onClose: y, children: x, footer: S, size: C = "md", hideHeader: w = !1, className: T = "", style: E, id: D, ref: O, closeOnBackdrop: ee, closeOnEscape: k, closeButton: A, dismissible: j, closeLabel: M, labels: N, "aria-label": P, "aria-labelledby": F, aside: I, dialogRef: L, closing: R }) => {
|
|
27
|
+
let z = R ? b : y, B = f(), V = f(), H = r({
|
|
28
28
|
dismissible: j,
|
|
29
29
|
closeOnEscape: k,
|
|
30
30
|
closeOnBackdrop: ee,
|
|
31
31
|
closeButton: A
|
|
32
|
-
}), { closeOnEscape: U, closeOnBackdrop: W, closeButton: G } = H, { ref: K, dialogProps: q } = o({ onRequestClose: U ? z : void 0 }), J = a(W ? z : void 0);
|
|
32
|
+
}), { closeOnEscape: U, closeOnBackdrop: W, closeButton: G } = H, { ref: K, dialogProps: q } = o({ onRequestClose: U ? () => z("escape") : void 0 }), J = a(W ? () => z("backdrop") : void 0);
|
|
33
33
|
c("KapiSplitModal", H, K);
|
|
34
34
|
let Y = e("splitModal", v, N), X = M ?? Y.close, Z = s();
|
|
35
35
|
if (!Z) return null;
|
|
36
|
-
let Q = I?.open === !0, $ = I?.side ?? "left", te = /* @__PURE__ */
|
|
36
|
+
let Q = I?.open === !0, $ = I?.side ?? "left", te = /* @__PURE__ */ h("div", {
|
|
37
37
|
ref: O,
|
|
38
38
|
id: D,
|
|
39
39
|
className: n(C, T),
|
|
40
40
|
style: E,
|
|
41
41
|
children: [
|
|
42
|
-
w ? G && /* @__PURE__ */
|
|
42
|
+
w ? G && /* @__PURE__ */ m("button", {
|
|
43
43
|
type: "button",
|
|
44
44
|
className: "kapi-modal__x kapi-modal__x--float",
|
|
45
|
-
onClick: z,
|
|
45
|
+
onClick: () => z("close-button"),
|
|
46
46
|
"aria-label": X,
|
|
47
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ m(g, {
|
|
48
48
|
size: 17,
|
|
49
49
|
strokeWidth: 2.2
|
|
50
50
|
})
|
|
51
|
-
}) : /* @__PURE__ */
|
|
51
|
+
}) : /* @__PURE__ */ h("div", {
|
|
52
52
|
className: "kapi-modal__head",
|
|
53
|
-
children: [/* @__PURE__ */
|
|
53
|
+
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("div", {
|
|
54
54
|
id: B,
|
|
55
55
|
className: "kapi-modal__title",
|
|
56
56
|
children: i
|
|
57
|
-
}),
|
|
57
|
+
}), p && /* @__PURE__ */ m("div", {
|
|
58
58
|
className: "kapi-modal__sub",
|
|
59
|
-
children:
|
|
60
|
-
})] }), G && /* @__PURE__ */
|
|
59
|
+
children: p
|
|
60
|
+
})] }), G && /* @__PURE__ */ m("button", {
|
|
61
61
|
type: "button",
|
|
62
62
|
className: "kapi-modal__x",
|
|
63
|
-
onClick: z,
|
|
63
|
+
onClick: () => z("close-button"),
|
|
64
64
|
"aria-label": X,
|
|
65
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ m(g, {
|
|
66
66
|
size: 17,
|
|
67
67
|
strokeWidth: 2.2
|
|
68
68
|
})
|
|
69
69
|
})]
|
|
70
70
|
}),
|
|
71
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ m("div", {
|
|
72
72
|
className: "kapi-modal__body",
|
|
73
73
|
children: x
|
|
74
74
|
}),
|
|
75
|
-
S && /* @__PURE__ */
|
|
75
|
+
S && /* @__PURE__ */ m("div", {
|
|
76
76
|
className: "kapi-modal__foot",
|
|
77
77
|
children: S
|
|
78
78
|
})
|
|
79
79
|
]
|
|
80
|
-
}, "main"), ne = I && Q ? /* @__PURE__ */
|
|
80
|
+
}, "main"), ne = I && Q ? /* @__PURE__ */ h("aside", {
|
|
81
81
|
className: "kapi-splitmodal__aside",
|
|
82
82
|
style: { "--kapi-split-aside-w": l(I.width) },
|
|
83
83
|
"aria-labelledby": I.title ? V : void 0,
|
|
84
84
|
children: [
|
|
85
|
-
(I.title || I.onClose) && /* @__PURE__ */
|
|
85
|
+
(I.title || I.onClose) && /* @__PURE__ */ h("div", {
|
|
86
86
|
className: "kapi-modal__head",
|
|
87
|
-
children: [/* @__PURE__ */
|
|
87
|
+
children: [/* @__PURE__ */ m("div", {
|
|
88
88
|
id: V,
|
|
89
89
|
className: "kapi-modal__title",
|
|
90
90
|
children: I.title
|
|
91
|
-
}), I.onClose && /* @__PURE__ */
|
|
91
|
+
}), I.onClose && /* @__PURE__ */ m("button", {
|
|
92
92
|
type: "button",
|
|
93
93
|
className: "kapi-modal__x",
|
|
94
94
|
onClick: I.onClose,
|
|
95
95
|
"aria-label": I.closeLabel ?? Y.closePanel,
|
|
96
|
-
children: /* @__PURE__ */
|
|
96
|
+
children: /* @__PURE__ */ m(g, {
|
|
97
97
|
size: 17,
|
|
98
98
|
strokeWidth: 2.2
|
|
99
99
|
})
|
|
100
100
|
})]
|
|
101
101
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ m("div", {
|
|
103
103
|
className: "kapi-modal__body",
|
|
104
104
|
children: I.children
|
|
105
105
|
}),
|
|
106
|
-
I.footer && /* @__PURE__ */
|
|
106
|
+
I.footer && /* @__PURE__ */ m("div", {
|
|
107
107
|
className: "kapi-modal__foot",
|
|
108
108
|
children: I.footer
|
|
109
109
|
})
|
|
110
110
|
]
|
|
111
111
|
}, "aside") : null, re = u($).map((e) => e === "main" ? te : ne).filter((e) => e !== null);
|
|
112
|
-
return _(/* @__PURE__ */
|
|
112
|
+
return _(/* @__PURE__ */ m("dialog", {
|
|
113
113
|
ref: (e) => {
|
|
114
114
|
K.current = e, L.current = e;
|
|
115
115
|
},
|
|
@@ -125,7 +125,7 @@ var v = {
|
|
|
125
125
|
}),
|
|
126
126
|
...q,
|
|
127
127
|
...J,
|
|
128
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ m("div", {
|
|
129
129
|
className: Q ? d($) : "kapi-splitmodal kapi-splitmodal--single",
|
|
130
130
|
children: re
|
|
131
131
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/overlays.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { joinIds as t } from "../inputs/fieldLogic.js";
|
|
5
|
+
import { useKapiDir as n } from "../locale/KapiLocaleProvider.js";
|
|
6
6
|
import { winOf as r } from "../../hooks/ownerDocument.js";
|
|
7
7
|
import { placePopover as i } from "./popoverLogic.js";
|
|
8
8
|
import { onViewportChange as a } from "../../hooks/rafThrottle.js";
|
|
@@ -10,8 +10,8 @@ import { placementViewport as o } from "../../hooks/viewportInsetLogic.js";
|
|
|
10
10
|
import { resolveDirection as s } from "../../hooks/directionLogic.js";
|
|
11
11
|
import { useMergedRefs as c } from "../../hooks/mergeRefs.js";
|
|
12
12
|
/* empty css */
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { cloneElement as l, isValidElement as u, useEffect as d, useId as f, useLayoutEffect as p, useRef as m, useState as h } from "react";
|
|
14
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/overlays/KapiTooltip.tsx
|
|
16
16
|
var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "rtl" ? "left" : "right" : e === "start" ? t === "rtl" ? "right" : "left" : e, w = (e) => Math.min(v, String(e).length * y + b), T = (e, t, n, r, a = Infinity) => {
|
|
17
17
|
let o = t.bottom ?? t.top, s = t.left ?? t.right, c = {
|
|
@@ -68,20 +68,20 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
|
|
|
68
68
|
} catch {
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
|
-
}, j = (
|
|
72
|
-
let w =
|
|
71
|
+
}, j = (e, n) => t(typeof e == "string" ? e : void 0, n), M = ({ label: t, children: i, prefer: v = "end", className: y, style: b, id: x, ref: S }) => {
|
|
72
|
+
let w = f(), E = m(null), D = c(E, S), O = n(), [M, N] = h(() => C(v, s(null, O))), [P, F] = h(!1), [I, L] = h(!1), R = m({
|
|
73
73
|
hover: !1,
|
|
74
74
|
focus: !1
|
|
75
75
|
}), z = () => {
|
|
76
|
-
let
|
|
77
|
-
if (!
|
|
78
|
-
let n =
|
|
79
|
-
|
|
80
|
-
}, B =
|
|
81
|
-
|
|
76
|
+
let e = E.current;
|
|
77
|
+
if (!e) return;
|
|
78
|
+
let n = e.getBoundingClientRect(), r = o(e), i = T(C(v, s(e, O)), n, t, r.width, r.height), { x: a, y: c } = k(i, n);
|
|
79
|
+
e.style.setProperty("--kapi-tip-x", `${Math.round(a)}px`), e.style.setProperty("--kapi-tip-y", `${Math.round(c)}px`), N(i);
|
|
80
|
+
}, B = m(z);
|
|
81
|
+
p(() => {
|
|
82
82
|
B.current = z;
|
|
83
83
|
});
|
|
84
|
-
let V =
|
|
84
|
+
let V = m(null), H = m(!1), U = (e) => {
|
|
85
85
|
let t = V.current;
|
|
86
86
|
if (!t || typeof t.showPopover != "function") return;
|
|
87
87
|
let n = A(t, ":popover-open") ?? H.current;
|
|
@@ -91,17 +91,17 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
|
|
|
91
91
|
}, G = (e) => {
|
|
92
92
|
R.current[e] = !1, !(R.current.hover || R.current.focus) && (F(!1), L(!1), U(!1));
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
d(() => {
|
|
95
95
|
if (!I) return;
|
|
96
96
|
let e = r(E.current);
|
|
97
97
|
return a(() => B.current(), e ? { target: e } : {});
|
|
98
98
|
}, [I]);
|
|
99
99
|
let K = (e) => {
|
|
100
100
|
e.key === "Escape" && !P && F(!0);
|
|
101
|
-
}, q =
|
|
102
|
-
return /* @__PURE__ */
|
|
101
|
+
}, q = u(i) ? i : null, J = q ? l(q, { "aria-describedby": j(q.props["aria-describedby"], w) }) : i;
|
|
102
|
+
return /* @__PURE__ */ _("span", {
|
|
103
103
|
id: x,
|
|
104
|
-
className:
|
|
104
|
+
className: e("kapi-tip", y),
|
|
105
105
|
style: b,
|
|
106
106
|
ref: D,
|
|
107
107
|
"data-side": M,
|
|
@@ -114,13 +114,13 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
|
|
|
114
114
|
onMouseLeave: () => G("hover"),
|
|
115
115
|
onBlur: () => G("focus"),
|
|
116
116
|
onKeyDown: K,
|
|
117
|
-
children: [J, /* @__PURE__ */
|
|
117
|
+
children: [J, /* @__PURE__ */ g("span", {
|
|
118
118
|
ref: V,
|
|
119
119
|
className: "kapi-tip__bubble",
|
|
120
120
|
role: "tooltip",
|
|
121
121
|
id: w,
|
|
122
122
|
popover: "manual",
|
|
123
|
-
children:
|
|
123
|
+
children: t
|
|
124
124
|
})]
|
|
125
125
|
});
|
|
126
126
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
+
import { resolveMenuItemTone as t } from "../tone.js";
|
|
4
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
5
5
|
import { initialMenuFocus as r, isTypeaheadKey as i, menuKeyIntent as a, nextEnabledIndex as o } from "./menuKeyboardLogic.js";
|
|
6
6
|
import { activeElementOf as s } from "../../hooks/ownerDocument.js";
|
|
7
7
|
import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
|
|
@@ -9,8 +9,8 @@ import { usePlacement as l } from "../../hooks/usePlacement.js";
|
|
|
9
9
|
import { useTypeahead as u } from "../../hooks/useTypeahead.js";
|
|
10
10
|
import { actionableIndexes as d, isActionMenuItem as f, matchMenuTypeahead as p, menuItemRole as m, submenuKeyAction as h } from "./menuButtonLogic.js";
|
|
11
11
|
import { DEFAULT_LINK_LABELS as g } from "../locale/linkLabels.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useEffect as _, useId as v, useRef as y, useState as b } from "react";
|
|
13
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
14
14
|
import { Check as w, ChevronRight as T, Circle as E } from "lucide-react";
|
|
15
15
|
var D = {
|
|
16
16
|
side: "right",
|
|
@@ -18,9 +18,9 @@ var D = {
|
|
|
18
18
|
offset: 4,
|
|
19
19
|
flip: "auto",
|
|
20
20
|
shift: !0
|
|
21
|
-
}, O = (
|
|
22
|
-
let t =
|
|
23
|
-
|
|
21
|
+
}, O = (n) => e("kapi-ctxmenu__item", t(n.tone, n.danger) === "danger" && "is-danger", n.disabled && "is-disabled", n.current && "is-current"), k = (e) => {
|
|
22
|
+
let t = y([]), n = y(null), r = y(void 0), [i, a] = b(null);
|
|
23
|
+
_(() => () => clearTimeout(r.current), []);
|
|
24
24
|
let o = (e) => t.current[e]?.focus(), c = (e, t) => a((n) => ({
|
|
25
25
|
index: e,
|
|
26
26
|
focus: t ? (n?.focus ?? 0) + 1 : n?.index === e ? n.focus : 0
|
|
@@ -56,15 +56,15 @@ var D = {
|
|
|
56
56
|
onLeave: p
|
|
57
57
|
})
|
|
58
58
|
};
|
|
59
|
-
}, A = ({ items: e, onActivate:
|
|
60
|
-
let E =
|
|
61
|
-
return
|
|
59
|
+
}, A = ({ items: e, onActivate: t, onClose: l, focusRequest: f, onBack: m, onKeyDown: v, ref: y, id: b, className: x, style: C, "aria-label": w, "aria-labelledby": T }) => {
|
|
60
|
+
let E = n("link", g), D = u(500), O = k(e), { itemEls: A, focusItem: M, openSub: N, hasSubmenu: P } = O, F = d(e), I = m !== void 0;
|
|
61
|
+
return _(() => {
|
|
62
62
|
f > 0 && M(r(F));
|
|
63
|
-
}, [f]), /* @__PURE__ */
|
|
63
|
+
}, [f]), /* @__PURE__ */ S("div", {
|
|
64
64
|
ref: y,
|
|
65
|
-
id:
|
|
65
|
+
id: b,
|
|
66
66
|
role: "menu",
|
|
67
|
-
className:
|
|
67
|
+
className: x,
|
|
68
68
|
style: C,
|
|
69
69
|
"aria-label": w,
|
|
70
70
|
"aria-labelledby": T,
|
|
@@ -84,113 +84,113 @@ var D = {
|
|
|
84
84
|
else if (f === "back") u(), m?.();
|
|
85
85
|
else if (d.kind === "close") {
|
|
86
86
|
if (I) return;
|
|
87
|
-
if (d.returnFocus) return
|
|
87
|
+
if (d.returnFocus) return v?.(t);
|
|
88
88
|
l(!1);
|
|
89
89
|
} else if (i(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
90
90
|
let n = p(e, r, D(t.key));
|
|
91
91
|
n >= 0 && (u(), M(n));
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
children: e.map((e,
|
|
94
|
+
children: e.map((e, n) => e.sep ? /* @__PURE__ */ S("div", {
|
|
95
95
|
role: "separator",
|
|
96
96
|
className: "kapi-ctxmenu__sep"
|
|
97
|
-
}, `s${
|
|
97
|
+
}, `s${n}`) : "header" in e ? /* @__PURE__ */ S("div", {
|
|
98
98
|
role: "presentation",
|
|
99
99
|
className: "kapi-ctxmenu__header",
|
|
100
100
|
children: e.header
|
|
101
|
-
}, `h${
|
|
102
|
-
...O.entryProps(
|
|
101
|
+
}, `h${n}`) : /* @__PURE__ */ S(j, {
|
|
102
|
+
...O.entryProps(n),
|
|
103
103
|
item: e,
|
|
104
|
-
index:
|
|
104
|
+
index: n,
|
|
105
105
|
newTabLabel: E.newTab,
|
|
106
|
-
onActivate:
|
|
106
|
+
onActivate: t,
|
|
107
107
|
onClose: l
|
|
108
|
-
}, e.id ?? `m${
|
|
108
|
+
}, e.id ?? `m${n}`))
|
|
109
109
|
});
|
|
110
|
-
}, j = ({ item:
|
|
111
|
-
let h =
|
|
112
|
-
|
|
110
|
+
}, j = ({ item: t, index: n, newTabLabel: r, itemRef: i, subOpen: a, subFocus: o, subRef: s, onToggleSub: c, onBackFromSub: l, onActivate: u, onClose: d, onEnter: f, onLeave: p }) => {
|
|
111
|
+
let h = v(), g = v(), _ = y(null), b = m(t), D = b !== "menuitem", k = t.items !== void 0 && t.items.length > 0 ? t.items : null, A = t.href !== void 0 && t.target === "_blank", j = typeof t.label != "string" && t.textValue !== void 0 ? A ? `${t.textValue} ${r}` : t.textValue : void 0, N = (e) => {
|
|
112
|
+
_.current = e, i(e);
|
|
113
113
|
}, P = {
|
|
114
114
|
id: k ? h : void 0,
|
|
115
|
-
role:
|
|
115
|
+
role: b,
|
|
116
116
|
tabIndex: -1,
|
|
117
|
-
"data-menu-index":
|
|
118
|
-
"data-menu-id":
|
|
119
|
-
"aria-disabled":
|
|
120
|
-
"aria-current":
|
|
121
|
-
"aria-checked": D ?
|
|
122
|
-
"aria-keyshortcuts":
|
|
123
|
-
"aria-describedby":
|
|
117
|
+
"data-menu-index": n,
|
|
118
|
+
"data-menu-id": t.id,
|
|
119
|
+
"aria-disabled": t.disabled ? "true" : void 0,
|
|
120
|
+
"aria-current": t.current ? "true" : void 0,
|
|
121
|
+
"aria-checked": D ? t.checked === !0 : void 0,
|
|
122
|
+
"aria-keyshortcuts": t.shortcut,
|
|
123
|
+
"aria-describedby": t.description === void 0 ? void 0 : g,
|
|
124
124
|
"aria-haspopup": k ? "menu" : void 0,
|
|
125
125
|
"aria-expanded": k ? a : void 0,
|
|
126
126
|
"aria-label": j,
|
|
127
|
-
className:
|
|
128
|
-
onClick: (
|
|
129
|
-
|
|
127
|
+
className: e(O(t), D && "is-checkable", a && "is-open"),
|
|
128
|
+
onClick: (e) => {
|
|
129
|
+
t.disabled ? e.preventDefault() : k ? (e.preventDefault(), c()) : u(t, e);
|
|
130
130
|
},
|
|
131
131
|
onMouseEnter: f,
|
|
132
132
|
onMouseLeave: p
|
|
133
|
-
}, F = /* @__PURE__ */
|
|
134
|
-
D && /* @__PURE__ */
|
|
133
|
+
}, F = /* @__PURE__ */ C(x, { children: [
|
|
134
|
+
D && /* @__PURE__ */ S("span", {
|
|
135
135
|
className: "kapi-ctxmenu__check",
|
|
136
136
|
"aria-hidden": "true",
|
|
137
|
-
children:
|
|
137
|
+
children: t.checked === !0 && (b === "menuitemradio" ? /* @__PURE__ */ S(E, {
|
|
138
138
|
size: 8,
|
|
139
139
|
fill: "currentColor",
|
|
140
140
|
strokeWidth: 0
|
|
141
|
-
}) : /* @__PURE__ */
|
|
141
|
+
}) : /* @__PURE__ */ S(w, {
|
|
142
142
|
size: 15,
|
|
143
143
|
strokeWidth: 2.4
|
|
144
144
|
}))
|
|
145
145
|
}),
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
t.icon,
|
|
147
|
+
t.description === void 0 ? t.label : /* @__PURE__ */ C("span", {
|
|
148
148
|
className: "kapi-ctxmenu__text",
|
|
149
|
-
children: [/* @__PURE__ */
|
|
149
|
+
children: [/* @__PURE__ */ S("span", {
|
|
150
150
|
className: "kapi-ctxmenu__label",
|
|
151
|
-
children:
|
|
152
|
-
}), /* @__PURE__ */
|
|
151
|
+
children: t.label
|
|
152
|
+
}), /* @__PURE__ */ S("span", {
|
|
153
153
|
id: g,
|
|
154
154
|
className: "kapi-ctxmenu__desc",
|
|
155
155
|
"aria-hidden": "true",
|
|
156
|
-
children:
|
|
156
|
+
children: t.description
|
|
157
157
|
})]
|
|
158
158
|
}),
|
|
159
|
-
A && j === void 0 && /* @__PURE__ */
|
|
159
|
+
A && j === void 0 && /* @__PURE__ */ C(x, { children: [" ", /* @__PURE__ */ S("span", {
|
|
160
160
|
className: "kapi-sr-only",
|
|
161
161
|
children: r
|
|
162
162
|
})] }),
|
|
163
|
-
|
|
163
|
+
t.shortcut !== void 0 && /* @__PURE__ */ S("kbd", {
|
|
164
164
|
className: "kapi-ctxmenu__kbd",
|
|
165
165
|
"aria-hidden": "true",
|
|
166
|
-
children:
|
|
166
|
+
children: t.shortcut
|
|
167
167
|
}),
|
|
168
|
-
k && /* @__PURE__ */
|
|
168
|
+
k && /* @__PURE__ */ S(T, {
|
|
169
169
|
className: "kapi-ctxmenu__chev kapi-flip-rtl",
|
|
170
170
|
size: 15,
|
|
171
171
|
strokeWidth: 2.2,
|
|
172
172
|
"aria-hidden": "true"
|
|
173
173
|
})
|
|
174
|
-
] }), I =
|
|
174
|
+
] }), I = t.href !== void 0 && !k ? /* @__PURE__ */ S("a", {
|
|
175
175
|
ref: N,
|
|
176
176
|
...P,
|
|
177
|
-
href:
|
|
178
|
-
target:
|
|
179
|
-
rel:
|
|
180
|
-
download:
|
|
177
|
+
href: t.disabled ? void 0 : t.href,
|
|
178
|
+
target: t.target,
|
|
179
|
+
rel: t.rel ?? (A ? "noopener noreferrer" : void 0),
|
|
180
|
+
download: t.download,
|
|
181
181
|
children: F
|
|
182
|
-
}) : /* @__PURE__ */
|
|
182
|
+
}) : /* @__PURE__ */ S("button", {
|
|
183
183
|
ref: N,
|
|
184
184
|
type: "button",
|
|
185
185
|
...P,
|
|
186
186
|
children: F
|
|
187
187
|
});
|
|
188
|
-
return k ? /* @__PURE__ */
|
|
188
|
+
return k ? /* @__PURE__ */ C("div", {
|
|
189
189
|
role: "none",
|
|
190
190
|
className: "kapi-ctxmenu__subwrap",
|
|
191
|
-
children: [I, a && /* @__PURE__ */
|
|
191
|
+
children: [I, a && /* @__PURE__ */ S(M, {
|
|
192
192
|
items: k,
|
|
193
|
-
anchorRef:
|
|
193
|
+
anchorRef: _,
|
|
194
194
|
menuRef: s,
|
|
195
195
|
labelledBy: h,
|
|
196
196
|
focusRequest: o,
|
|
@@ -207,7 +207,7 @@ var D = {
|
|
|
207
207
|
...D,
|
|
208
208
|
hideUntilPlaced: !1
|
|
209
209
|
});
|
|
210
|
-
return /* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ S(A, {
|
|
211
211
|
ref: n,
|
|
212
212
|
items: e,
|
|
213
213
|
className: "kapi-ctxmenu kapi-ctxmenu--sub",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement } from "react";
|
|
2
|
+
/** Props que el componente calculó para su elemento. */
|
|
3
|
+
export type SlotProps = HTMLAttributes<HTMLElement> & Record<string, unknown>;
|
|
4
|
+
/** Encadena dos handlers: primero el del consumidor; si frena el evento, el interno no corre. */
|
|
5
|
+
export declare const chainHandlers: (delConsumidor: ((e: unknown) => void) | undefined, interno: ((e: unknown) => void) | undefined) => ((e: unknown) => void) | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Fusiona las props del componente con las del elemento que trajo el consumidor.
|
|
8
|
+
*
|
|
9
|
+
* `fijas` son las que el componente necesita para funcionar (rol, `aria-*` de estado, `type` de un
|
|
10
|
+
* botón): se aplican al final y no se pueden pisar. Sin eso, un `render` descuidado convierte un
|
|
11
|
+
* control accesible en un `<div>` mudo y nada lo avisa.
|
|
12
|
+
*/
|
|
13
|
+
export declare const mergeSlotProps: (propias: SlotProps, delConsumidor: SlotProps, fijas?: SlotProps) => SlotProps;
|
|
14
|
+
/**
|
|
15
|
+
* Lo que el consumidor puede pasar en `render`: un elemento ya armado, o una función que recibe
|
|
16
|
+
* las props calculadas y devuelve el elemento. La función sirve cuando hay que repartirlas a mano
|
|
17
|
+
* (un componente que no reenvía lo que no conoce).
|
|
18
|
+
*/
|
|
19
|
+
export type KapiRender = ReactElement | ((props: SlotProps) => ReactElement);
|
|
20
|
+
/**
|
|
21
|
+
* Produce el elemento final: el del consumidor si pasó `render`, o el que arma `propio`.
|
|
22
|
+
*
|
|
23
|
+
* Las props del componente se fusionan con las del elemento recibido por `mergeSlotProps`, así el
|
|
24
|
+
* `render` hereda exactamente las mismas reglas que el passthrough nativo y no estrena otra
|
|
25
|
+
* filosofía. `fijas` son las que el componente necesita para funcionar y no se negocian.
|
|
26
|
+
*/
|
|
27
|
+
export declare const renderSlot: (render: KapiRender | undefined, propias: SlotProps, fijas: SlotProps, propio: (props: SlotProps) => ReactElement) => ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { joinClasses as e } from "./rootProps.js";
|
|
3
|
+
import { cloneElement as t, isValidElement as n } from "react";
|
|
4
|
+
//#region src/components/renderSlot.ts
|
|
5
|
+
var r = (e, t) => typeof t == "function" && /^on[A-Z]/.test(e), i = (e, t) => e ? t ? (n) => {
|
|
6
|
+
e(n), n?.defaultPrevented || t(n);
|
|
7
|
+
} : e : t, a = (t, n, a = {}) => {
|
|
8
|
+
let o = { ...t };
|
|
9
|
+
for (let [t, a] of Object.entries(n)) {
|
|
10
|
+
let n = o[t];
|
|
11
|
+
o[t] = t === "className" ? e(String(n ?? ""), String(a ?? "")) : t === "style" ? {
|
|
12
|
+
...n,
|
|
13
|
+
...a
|
|
14
|
+
} : r(t, a) ? i(a, n) : a;
|
|
15
|
+
}
|
|
16
|
+
for (let [e, t] of Object.entries(a)) t !== void 0 && (o[e] = t);
|
|
17
|
+
return o;
|
|
18
|
+
}, o = (e, r, i, o) => {
|
|
19
|
+
let s = (e) => a(r, e, i);
|
|
20
|
+
return e === void 0 ? o(s({})) : typeof e == "function" ? e(s({})) : n(e) ? t(e, s(e.props ?? {})) : o(s({}));
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as chainHandlers, a as mergeSlotProps, o as renderSlot };
|