@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,26 +1,26 @@
|
|
|
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 { KapiButton as t } from "../inputs/KapiButton.js";
|
|
5
5
|
import { useControllableState as n } from "../../hooks/useControllableState.js";
|
|
6
6
|
import { resolveKapiRoot as r } from "../../hooks/kapiRoot.js";
|
|
7
7
|
import { usePlacement as i } from "../../hooks/usePlacement.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
|
|
9
|
+
import { useDismiss as o } from "../../hooks/useDismiss.js";
|
|
9
10
|
/* empty css */
|
|
10
|
-
import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
|
|
11
11
|
import { ACTION_MENU_PLACEMENT as s } from "./menuButtonLogic.js";
|
|
12
12
|
import { MenuList as c } from "./menuList.js";
|
|
13
13
|
import { useFocusReturn as l } from "../../hooks/useFocusReturn.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { useCallback as u, useId as d, useLayoutEffect as f, useRef as p } from "react";
|
|
15
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
16
16
|
import { ChevronDown as g } from "lucide-react";
|
|
17
17
|
import { createPortal as _ } from "react-dom";
|
|
18
18
|
//#region src/components/overlays/KapiMenuButton.tsx
|
|
19
19
|
var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, disabled: T = !1, open: E, defaultOpen: D = !1, onOpenChange: O, chevron: k, "aria-label": A, drop: j = "down", className: M, style: N, id: P, ref: F }) => {
|
|
20
|
-
let I =
|
|
20
|
+
let I = d(), [L, R] = n(E, D, O), z = L && !T, B = y === void 0 && x != null, V = k ?? !B, H = p(null), U = a(H, F), W = p(null), G = p(null), { restore: K } = l(z, {
|
|
21
21
|
container: G,
|
|
22
22
|
target: W
|
|
23
|
-
}), q =
|
|
23
|
+
}), q = u((e) => {
|
|
24
24
|
R(!1), e && K();
|
|
25
25
|
}, [R, K]), { placement: J, style: Y, update: X } = i({
|
|
26
26
|
open: z,
|
|
@@ -31,26 +31,26 @@ var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, dis
|
|
|
31
31
|
offset: v,
|
|
32
32
|
hideUntilPlaced: !1
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
f(() => {
|
|
35
35
|
z && X();
|
|
36
36
|
}, [
|
|
37
37
|
z,
|
|
38
38
|
b.length,
|
|
39
39
|
X
|
|
40
40
|
]);
|
|
41
|
-
let Z =
|
|
41
|
+
let Z = o(z, {
|
|
42
42
|
zones: [H, G],
|
|
43
43
|
onDismiss: (e) => q(e === "escape")
|
|
44
44
|
}), Q = (e) => {
|
|
45
45
|
(e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), R(!0));
|
|
46
46
|
}, $ = z ? r(H.current) : null;
|
|
47
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ h("span", {
|
|
48
48
|
ref: U,
|
|
49
49
|
id: P,
|
|
50
|
-
className:
|
|
50
|
+
className: e("kapi-menubtn", M),
|
|
51
51
|
style: N,
|
|
52
52
|
onKeyDown: Z,
|
|
53
|
-
children: [/* @__PURE__ */
|
|
53
|
+
children: [/* @__PURE__ */ h(t, {
|
|
54
54
|
ref: W,
|
|
55
55
|
...S !== void 0 && { tone: S },
|
|
56
56
|
...C !== void 0 && { variant: C },
|
|
@@ -64,13 +64,13 @@ var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, dis
|
|
|
64
64
|
"aria-controls": z ? I : void 0,
|
|
65
65
|
onClick: () => R(!z),
|
|
66
66
|
onKeyDown: Q,
|
|
67
|
-
children: [y, V && /* @__PURE__ */
|
|
67
|
+
children: [y, V && /* @__PURE__ */ m(g, {
|
|
68
68
|
className: "kapi-menubtn__chevron",
|
|
69
69
|
size: 15,
|
|
70
70
|
strokeWidth: 2.2,
|
|
71
71
|
"aria-hidden": "true"
|
|
72
72
|
})]
|
|
73
|
-
}), $ && _(/* @__PURE__ */
|
|
73
|
+
}), $ && _(/* @__PURE__ */ m(c, {
|
|
74
74
|
ref: G,
|
|
75
75
|
id: I,
|
|
76
76
|
className: `kapi-ctxmenu kapi-menubtn__menu kapi-menubtn__menu--${J?.side === "top" ? "top" : "bottom"} kapi-menubtn__menu--${J?.align === "end" ? "right" : "left"}`,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import { type GrowOrigin } from "../../hooks/growOriginLogic.js";
|
|
3
4
|
import { type KapiModalSize } from "./dialogUtils.js";
|
|
4
5
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
@@ -15,7 +16,7 @@ export type KapiModalProps = {
|
|
|
15
16
|
/** Texto secundario bajo el título. */
|
|
16
17
|
subtitle?: ReactNode | undefined;
|
|
17
18
|
/** Pedido de cierre (X, click en el fondo, Escape). El padre pone `open={false}`. */
|
|
18
|
-
onClose: () => void;
|
|
19
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
19
20
|
/** Contenido del cuerpo (con scroll propio). */
|
|
20
21
|
children?: ReactNode | undefined;
|
|
21
22
|
/** Zona fija inferior (botones). */
|
|
@@ -6,28 +6,28 @@ import { prefersReducedMotion as n } from "../../hooks/reducedMotion.js";
|
|
|
6
6
|
import { dialogNameProps as r, modalClasses as i, resolveDismiss as a } from "./dialogUtils.js";
|
|
7
7
|
import { useExitPresence as o } from "./useExitPresence.js";
|
|
8
8
|
import { originWithinCard as s } from "../../hooks/growOriginLogic.js";
|
|
9
|
-
import { useBackdropClose as
|
|
9
|
+
import { useBackdropClose as ee, useNativeDialog as c, usePortalRoot as l, useTrappedDialogWarning as u } from "./useNativeDialog.js";
|
|
10
10
|
/* empty css */
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { X as
|
|
14
|
-
import { createPortal as
|
|
11
|
+
import { useId as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
|
+
import { X as _ } from "lucide-react";
|
|
14
|
+
import { createPortal as v } from "react-dom";
|
|
15
15
|
//#region src/components/overlays/KapiModal.tsx
|
|
16
|
-
var
|
|
17
|
-
let n =
|
|
18
|
-
return r ? /* @__PURE__ */
|
|
16
|
+
var y = { close: "Cerrar" }, b = ({ open: e, ...t }) => {
|
|
17
|
+
let n = p(null), { present: r, closing: i } = o(e, n);
|
|
18
|
+
return r ? /* @__PURE__ */ h(S, {
|
|
19
19
|
...t,
|
|
20
20
|
dialogRef: n,
|
|
21
21
|
closing: i
|
|
22
22
|
}) : null;
|
|
23
|
-
},
|
|
24
|
-
let V = B ?
|
|
23
|
+
}, x = () => {}, S = ({ title: o, subtitle: b, onClose: S, children: C, footer: w, size: T = "md", hideHeader: E = !1, className: te = "", style: D, id: O, ref: k, closeOnBackdrop: A, closeOnEscape: j, closeButton: M, dismissible: N, closeLabel: P, labels: F, "aria-label": I, "aria-labelledby": L, growFrom: R, dialogRef: z, closing: B }) => {
|
|
24
|
+
let V = B ? x : S, H = d(), U = e("modal", y, F), W = P ?? U.close, G = p(null), K = t(G, k), [q, J] = m(null), Y = a({
|
|
25
25
|
dismissible: N,
|
|
26
26
|
closeOnEscape: j,
|
|
27
27
|
closeOnBackdrop: A,
|
|
28
28
|
closeButton: M
|
|
29
|
-
}), { closeOnEscape: X, closeOnBackdrop: Z, closeButton: Q } = Y, { ref: ne, dialogProps: re } =
|
|
30
|
-
|
|
29
|
+
}), { closeOnEscape: X, closeOnBackdrop: Z, closeButton: Q } = Y, { ref: ne, dialogProps: re } = c({ onRequestClose: X ? () => V("escape") : void 0 }), ie = ee(Z ? () => V("backdrop") : void 0);
|
|
30
|
+
u("KapiModal", Y, G), f(() => {
|
|
31
31
|
let e = G.current;
|
|
32
32
|
if (!R || !e || n(e)) {
|
|
33
33
|
J(null);
|
|
@@ -41,8 +41,8 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
|
|
|
41
41
|
height: i
|
|
42
42
|
}));
|
|
43
43
|
}, [R]);
|
|
44
|
-
let $ =
|
|
45
|
-
return $ ?
|
|
44
|
+
let $ = l();
|
|
45
|
+
return $ ? v(/* @__PURE__ */ h("dialog", {
|
|
46
46
|
ref: (e) => {
|
|
47
47
|
ne.current = e, z.current = e;
|
|
48
48
|
},
|
|
@@ -58,7 +58,7 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
|
|
|
58
58
|
}),
|
|
59
59
|
...re,
|
|
60
60
|
...ie,
|
|
61
|
-
children: /* @__PURE__ */
|
|
61
|
+
children: /* @__PURE__ */ g("div", {
|
|
62
62
|
ref: K,
|
|
63
63
|
id: O,
|
|
64
64
|
className: `${i(T, te)}${q ? " kapi-modal--grow" : ""}`,
|
|
@@ -68,40 +68,40 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
|
|
|
68
68
|
"--kapi-grow-y": `${q.y}px`
|
|
69
69
|
} : D,
|
|
70
70
|
children: [
|
|
71
|
-
E ? Q && /* @__PURE__ */
|
|
71
|
+
E ? Q && /* @__PURE__ */ h("button", {
|
|
72
72
|
type: "button",
|
|
73
73
|
className: "kapi-modal__x kapi-modal__x--float",
|
|
74
|
-
onClick: V,
|
|
74
|
+
onClick: () => V("close-button"),
|
|
75
75
|
"aria-label": W,
|
|
76
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ h(_, {
|
|
77
77
|
size: 17,
|
|
78
78
|
strokeWidth: 2.2
|
|
79
79
|
})
|
|
80
|
-
}) : /* @__PURE__ */
|
|
80
|
+
}) : /* @__PURE__ */ g("div", {
|
|
81
81
|
className: "kapi-modal__head",
|
|
82
|
-
children: [/* @__PURE__ */
|
|
82
|
+
children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("div", {
|
|
83
83
|
id: H,
|
|
84
84
|
className: "kapi-modal__title",
|
|
85
85
|
children: o
|
|
86
|
-
}),
|
|
86
|
+
}), b && /* @__PURE__ */ h("div", {
|
|
87
87
|
className: "kapi-modal__sub",
|
|
88
|
-
children:
|
|
89
|
-
})] }), Q && /* @__PURE__ */
|
|
88
|
+
children: b
|
|
89
|
+
})] }), Q && /* @__PURE__ */ h("button", {
|
|
90
90
|
type: "button",
|
|
91
91
|
className: "kapi-modal__x",
|
|
92
|
-
onClick: V,
|
|
92
|
+
onClick: () => V("close-button"),
|
|
93
93
|
"aria-label": W,
|
|
94
|
-
children: /* @__PURE__ */
|
|
94
|
+
children: /* @__PURE__ */ h(_, {
|
|
95
95
|
size: 17,
|
|
96
96
|
strokeWidth: 2.2
|
|
97
97
|
})
|
|
98
98
|
})]
|
|
99
99
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ h("div", {
|
|
101
101
|
className: "kapi-modal__body",
|
|
102
102
|
children: C
|
|
103
103
|
}),
|
|
104
|
-
w && /* @__PURE__ */
|
|
104
|
+
w && /* @__PURE__ */ h("div", {
|
|
105
105
|
className: "kapi-modal__foot",
|
|
106
106
|
children: w
|
|
107
107
|
})
|
|
@@ -110,4 +110,4 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
|
|
|
110
110
|
}), $) : null;
|
|
111
111
|
};
|
|
112
112
|
//#endregion
|
|
113
|
-
export {
|
|
113
|
+
export { y as DEFAULT_MODAL_LABELS, b as KapiModal };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import { type KapiOffcanvasSide } from "./offcanvasSide.js";
|
|
3
4
|
import { type KapiRootProps } from "../rootProps.js";
|
|
4
5
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
@@ -31,8 +32,8 @@ export declare const DEFAULT_OFFCANVAS_LABELS: KapiOffcanvasLabels;
|
|
|
31
32
|
export type KapiOffcanvasProps = KapiRootProps<HTMLDialogElement> & {
|
|
32
33
|
/** Controlado. Al pasar a false corre la animación de salida y recién después se desmonta. */
|
|
33
34
|
open: boolean;
|
|
34
|
-
/** Pedido de cierre
|
|
35
|
-
onClose: () => void;
|
|
35
|
+
/** Pedido de cierre: `reason` dice si fue la X, el fondo o Escape. El padre pone `open={false}`. */
|
|
36
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
36
37
|
/** Título del header del panel (también nombra al diálogo). */
|
|
37
38
|
title: ReactNode;
|
|
38
39
|
/** Texto secundario bajo el título. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/KapiOffcanvas.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { computedStyleOf as
|
|
6
|
-
import { resolveDirection as
|
|
7
|
-
import { useMergedRefs as
|
|
8
|
-
import { maxTransitionMs as
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { useKapiDir as t, useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { computedStyleOf as r, winOf as i } from "../../hooks/ownerDocument.js";
|
|
6
|
+
import { resolveDirection as a } from "../../hooks/directionLogic.js";
|
|
7
|
+
import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
|
|
8
|
+
import { maxTransitionMs as ee, resolveDismiss as s } from "./dialogUtils.js";
|
|
9
9
|
import { useExitPresence as c } from "./useExitPresence.js";
|
|
10
10
|
import { useBackdropClose as l, useNativeDialog as u, usePortalRoot as d, useTrappedDialogWarning as f } from "./useNativeDialog.js";
|
|
11
11
|
import { DEFAULT_PUSH_RATIO as te, depthOf as ne, levelOf as re, offcanvasStackStore as p, phaseReducer as m, pushTransform as ie } from "./offcanvasStack.js";
|
|
@@ -13,16 +13,16 @@ import { normalizeSide as ae, pushForSide as oe, resolveOffcanvasSide as h, side
|
|
|
13
13
|
import { companionDockClasses as le, isCompanionActive as ue, resolveCompanionOrder as de, resolveCompanionWidth as fe, supportsCompanion as pe } from "./offcanvasCompanion.js";
|
|
14
14
|
import { resolveInitialWidth as me, resolveMaxWidth as g, stepOffcanvasWidth as he, widthFromDrag as ge } from "./offcanvasResize.js";
|
|
15
15
|
/* empty css */
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { useEffect as _e, useId as _, useLayoutEffect as v, useReducer as ve, useRef as y, useState as b, useSyncExternalStore as ye } from "react";
|
|
17
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
18
18
|
import { X as C } from "lucide-react";
|
|
19
19
|
import { createPortal as w } from "react-dom";
|
|
20
20
|
var be = 120, T = {
|
|
21
21
|
resize: "Redimensionar panel",
|
|
22
22
|
close: "Cerrar",
|
|
23
23
|
closePanel: "Cerrar panel"
|
|
24
|
-
}, E = ({ textDir:
|
|
25
|
-
let N =
|
|
24
|
+
}, E = ({ textDir: t, stackId: a, phase: d, onEntered: m, onExited: h, onClose: ve, title: w, subtitle: E, children: D, footer: O, side: xe, width: k = 520, height: Se, pushRatio: Ce = te, pushOffset: we = 16, closeOnBackdrop: Te, closeOnEscape: Ee, closeButton: De, dismissible: Oe, closeLabel: ke, labels: Ae, className: je, style: Me, id: Ne, ref: Pe, companion: A, resizable: Fe = !1, minWidth: j = 320, maxWidth: M, onResize: Ie }) => {
|
|
25
|
+
let N = n("offcanvas", T, Ae), Le = ke ?? N.close, P = _(), F = _(), I = ae(xe), L = y(null), R = ye(p.subscribe, p.getSnapshot, p.getServerSnapshot), z = ne(R, a), Re = Math.max(0, re(R, a)), { scale: ze, translateX: Be } = oe(I, ie(z, Ce, we)), [B, Ve] = b(() => me(k, 520)), [He, V] = b(!1), H = y(null), U = y(Ie);
|
|
26
26
|
U.current = Ie;
|
|
27
27
|
let W = (e) => {
|
|
28
28
|
Ve(e), e !== B && U.current?.(e);
|
|
@@ -36,31 +36,31 @@ var be = 120, T = {
|
|
|
36
36
|
}, We = (e) => {
|
|
37
37
|
let t = H.current;
|
|
38
38
|
if (!t) return;
|
|
39
|
-
let n = g(M, (
|
|
39
|
+
let n = g(M, (i(L.current) ?? window).innerWidth);
|
|
40
40
|
W(ge(I, t.startWidth, t.startX, e.clientX, j, n));
|
|
41
41
|
}, G = (e) => {
|
|
42
42
|
H.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), V(!1);
|
|
43
43
|
}, Ge = (e) => {
|
|
44
|
-
let t = g(M, (
|
|
44
|
+
let t = g(M, (i(L.current) ?? window).innerWidth), n = he(I, B, e.key, j, t);
|
|
45
45
|
n !== null && (e.preventDefault(), e.stopPropagation(), W(n));
|
|
46
|
-
}, K = d === "open" ?
|
|
46
|
+
}, K = d === "open" ? ve : void 0, q = s({
|
|
47
47
|
dismissible: Oe,
|
|
48
48
|
closeOnEscape: Ee,
|
|
49
49
|
closeOnBackdrop: Te,
|
|
50
50
|
closeButton: De
|
|
51
|
-
}), { closeOnEscape: Ke, closeOnBackdrop: qe, closeButton: Je } = q, { ref: J, dialogProps: Ye } = u({ onRequestClose: Ke ? K : void 0 }), Xe =
|
|
52
|
-
f("KapiOffcanvas", q, J),
|
|
51
|
+
}), { closeOnEscape: Ke, closeOnBackdrop: qe, closeButton: Je } = q, { ref: J, dialogProps: Ye } = u({ onRequestClose: Ke ? () => K?.("escape") : void 0 }), Xe = o(J, Pe), Ze = l(qe ? () => K?.("backdrop") : void 0);
|
|
52
|
+
f("KapiOffcanvas", q, J), v(() => (p.dispatch({
|
|
53
53
|
type: "add",
|
|
54
|
-
id:
|
|
54
|
+
id: a
|
|
55
55
|
}), () => p.dispatch({
|
|
56
56
|
type: "remove",
|
|
57
|
-
id:
|
|
58
|
-
})), [
|
|
59
|
-
let Y =
|
|
60
|
-
Y.current = m,
|
|
57
|
+
id: a
|
|
58
|
+
})), [a]);
|
|
59
|
+
let Y = y(m);
|
|
60
|
+
Y.current = m, v(() => {
|
|
61
61
|
L.current?.getBoundingClientRect(), Y.current();
|
|
62
62
|
}, []);
|
|
63
|
-
let X =
|
|
63
|
+
let X = y(h);
|
|
64
64
|
X.current = h, _e(() => {
|
|
65
65
|
if (d !== "exit") return;
|
|
66
66
|
let e = L.current;
|
|
@@ -68,20 +68,20 @@ var be = 120, T = {
|
|
|
68
68
|
X.current();
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
let t =
|
|
71
|
+
let t = r(e), n = ee(t.transitionDuration, t.transitionDelay);
|
|
72
72
|
if (n <= 0) {
|
|
73
73
|
X.current();
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
t.target === e && t.propertyName === "transform" &&
|
|
76
|
+
let i = !1, a = () => {
|
|
77
|
+
i || (i = !0, X.current());
|
|
78
|
+
}, o = (t) => {
|
|
79
|
+
t.target === e && t.propertyName === "transform" && a();
|
|
80
80
|
};
|
|
81
|
-
e.addEventListener("transitionend",
|
|
82
|
-
let s = window.setTimeout(
|
|
81
|
+
e.addEventListener("transitionend", o);
|
|
82
|
+
let s = window.setTimeout(a, n + be);
|
|
83
83
|
return () => {
|
|
84
|
-
|
|
84
|
+
i = !0, e.removeEventListener("transitionend", o), window.clearTimeout(s);
|
|
85
85
|
};
|
|
86
86
|
}, [d]);
|
|
87
87
|
let Z = Fe && (I === "left" || I === "right"), Q = ce(I, k, Se, "520px");
|
|
@@ -91,14 +91,14 @@ var be = 120, T = {
|
|
|
91
91
|
[Q.name]: Q.value,
|
|
92
92
|
"--kapi-offc-push-x": `${Be}px`,
|
|
93
93
|
"--kapi-offc-push-s": ze
|
|
94
|
-
}, $e = ue(I, A), et =
|
|
94
|
+
}, $e = ue(I, A), et = y(null), { present: tt, closing: nt } = c($e, et), rt = y(A);
|
|
95
95
|
A && (rt.current = A);
|
|
96
|
-
let $ = A ?? rt.current, it = tt && pe(I) && $ !== void 0, at =
|
|
96
|
+
let $ = A ?? rt.current, it = tt && pe(I) && $ !== void 0, at = t === "rtl", ot = at ? { dir: "rtl" } : {}, st = /* @__PURE__ */ S("div", {
|
|
97
97
|
ref: L,
|
|
98
98
|
className: "kapi-offc__panel",
|
|
99
99
|
...ot,
|
|
100
100
|
children: [
|
|
101
|
-
Z && /* @__PURE__ */
|
|
101
|
+
Z && /* @__PURE__ */ x("div", {
|
|
102
102
|
className: "kapi-offc__resize",
|
|
103
103
|
role: "separator",
|
|
104
104
|
"aria-orientation": "vertical",
|
|
@@ -113,36 +113,36 @@ var be = 120, T = {
|
|
|
113
113
|
onPointerCancel: G,
|
|
114
114
|
onKeyDown: Ge
|
|
115
115
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ S("div", {
|
|
117
117
|
className: "kapi-offc__head",
|
|
118
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
|
|
119
119
|
id: P,
|
|
120
120
|
className: "kapi-modal__title",
|
|
121
121
|
children: w
|
|
122
|
-
}), E && /* @__PURE__ */
|
|
122
|
+
}), E && /* @__PURE__ */ x("div", {
|
|
123
123
|
className: "kapi-modal__sub",
|
|
124
124
|
children: E
|
|
125
|
-
})] }), Je && /* @__PURE__ */
|
|
125
|
+
})] }), Je && /* @__PURE__ */ x("button", {
|
|
126
126
|
type: "button",
|
|
127
127
|
className: "kapi-modal__x",
|
|
128
|
-
onClick: K,
|
|
128
|
+
onClick: () => K?.("close-button"),
|
|
129
129
|
"aria-label": Le,
|
|
130
|
-
children: /* @__PURE__ */
|
|
130
|
+
children: /* @__PURE__ */ x(C, {
|
|
131
131
|
size: 17,
|
|
132
132
|
strokeWidth: 2.2
|
|
133
133
|
})
|
|
134
134
|
})]
|
|
135
135
|
}),
|
|
136
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ x("div", {
|
|
137
137
|
className: "kapi-offc__body",
|
|
138
138
|
children: D
|
|
139
139
|
}),
|
|
140
|
-
O && /* @__PURE__ */
|
|
140
|
+
O && /* @__PURE__ */ x("div", {
|
|
141
141
|
className: "kapi-offc__foot",
|
|
142
142
|
children: O
|
|
143
143
|
})
|
|
144
144
|
]
|
|
145
|
-
}, "main"), ct = $ && it ? /* @__PURE__ */
|
|
145
|
+
}, "main"), ct = $ && it ? /* @__PURE__ */ S("div", {
|
|
146
146
|
ref: et,
|
|
147
147
|
"data-closing": nt || void 0,
|
|
148
148
|
inert: nt || void 0,
|
|
@@ -152,40 +152,40 @@ var be = 120, T = {
|
|
|
152
152
|
"aria-labelledby": $.title ? F : void 0,
|
|
153
153
|
style: { "--kapi-offc-companion-w": fe($.width) },
|
|
154
154
|
children: [
|
|
155
|
-
($.title || $.onClose) && /* @__PURE__ */
|
|
155
|
+
($.title || $.onClose) && /* @__PURE__ */ S("div", {
|
|
156
156
|
className: "kapi-offc__head",
|
|
157
|
-
children: [/* @__PURE__ */
|
|
157
|
+
children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
|
|
158
158
|
id: F,
|
|
159
159
|
className: "kapi-modal__title",
|
|
160
160
|
children: $.title
|
|
161
|
-
}), $.subtitle && /* @__PURE__ */
|
|
161
|
+
}), $.subtitle && /* @__PURE__ */ x("div", {
|
|
162
162
|
className: "kapi-modal__sub",
|
|
163
163
|
children: $.subtitle
|
|
164
|
-
})] }), $.onClose && /* @__PURE__ */
|
|
164
|
+
})] }), $.onClose && /* @__PURE__ */ x("button", {
|
|
165
165
|
type: "button",
|
|
166
166
|
className: "kapi-modal__x",
|
|
167
167
|
onClick: $.onClose,
|
|
168
168
|
"aria-label": $.closeLabel ?? N.closePanel,
|
|
169
|
-
children: /* @__PURE__ */
|
|
169
|
+
children: /* @__PURE__ */ x(C, {
|
|
170
170
|
size: 17,
|
|
171
171
|
strokeWidth: 2.2
|
|
172
172
|
})
|
|
173
173
|
})]
|
|
174
174
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ x("div", {
|
|
176
176
|
className: "kapi-offc__body",
|
|
177
177
|
children: $.children
|
|
178
178
|
}),
|
|
179
|
-
$.footer && /* @__PURE__ */
|
|
179
|
+
$.footer && /* @__PURE__ */ x("div", {
|
|
180
180
|
className: "kapi-offc__foot",
|
|
181
181
|
children: $.footer
|
|
182
182
|
})
|
|
183
183
|
]
|
|
184
184
|
}, "companion") : null, lt = de(I).map((e) => e === "main" ? st : ct).filter((e) => e !== null);
|
|
185
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ x("dialog", {
|
|
186
186
|
ref: Xe,
|
|
187
187
|
id: Ne,
|
|
188
|
-
className:
|
|
188
|
+
className: e("kapi-offc", He && "is-resizing", je),
|
|
189
189
|
"data-side": se(I),
|
|
190
190
|
"data-state": d === "open" ? "open" : "closed",
|
|
191
191
|
"data-level": Re,
|
|
@@ -196,30 +196,30 @@ var be = 120, T = {
|
|
|
196
196
|
style: Qe,
|
|
197
197
|
...Ye,
|
|
198
198
|
...Ze,
|
|
199
|
-
children: /* @__PURE__ */
|
|
199
|
+
children: /* @__PURE__ */ x("div", {
|
|
200
200
|
className: le(it),
|
|
201
201
|
children: lt
|
|
202
202
|
})
|
|
203
203
|
});
|
|
204
|
-
}, D = ({ open:
|
|
205
|
-
let
|
|
206
|
-
l.current = n,
|
|
207
|
-
c(
|
|
208
|
-
}, [
|
|
204
|
+
}, D = ({ open: e, onExited: n, side: r, ...i }) => {
|
|
205
|
+
let o = _(), ee = t(), [s, c] = ve(m, "unmounted"), l = y(n);
|
|
206
|
+
l.current = n, v(() => {
|
|
207
|
+
c(e ? "open" : "close");
|
|
208
|
+
}, [e]), v(() => {
|
|
209
209
|
(s === "exit" || s === "open") && p.dispatch({
|
|
210
210
|
type: "mark",
|
|
211
|
-
id:
|
|
211
|
+
id: o,
|
|
212
212
|
state: s === "exit" ? "closing" : "open"
|
|
213
213
|
});
|
|
214
|
-
}, [s,
|
|
214
|
+
}, [s, o]);
|
|
215
215
|
let u = d();
|
|
216
216
|
if (s === "unmounted" || !u) return null;
|
|
217
|
-
let f =
|
|
218
|
-
return w(/* @__PURE__ */
|
|
219
|
-
...
|
|
217
|
+
let f = a(u, ee);
|
|
218
|
+
return w(/* @__PURE__ */ x(E, {
|
|
219
|
+
...i,
|
|
220
220
|
textDir: f,
|
|
221
|
-
side: h(
|
|
222
|
-
stackId:
|
|
221
|
+
side: h(r, f),
|
|
222
|
+
stackId: o,
|
|
223
223
|
phase: s,
|
|
224
224
|
onEntered: () => c("entered"),
|
|
225
225
|
onExited: () => {
|
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { panelsReducer as e, topOpenId as t } from "./offcanvasStack.js";
|
|
3
3
|
import { KapiOffcanvas as n } from "./KapiOffcanvas.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { createContext as r, useCallback as i, useContext as a, useLayoutEffect as o, useMemo as s, useReducer as c, useRef as l } from "react";
|
|
5
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/overlays/KapiOffcanvasStack.tsx
|
|
7
|
-
var f =
|
|
8
|
-
let { id:
|
|
9
|
-
id:
|
|
7
|
+
var f = r(null), p = r(null), m = (t, n) => e(t, n), h = ({ entry: e, level: t, close: r, push: i, dispatch: a }) => {
|
|
8
|
+
let { id: o } = e, c = s(() => ({
|
|
9
|
+
id: o,
|
|
10
10
|
level: t,
|
|
11
|
-
close: () =>
|
|
12
|
-
push:
|
|
11
|
+
close: () => r(o),
|
|
12
|
+
push: i
|
|
13
13
|
}), [
|
|
14
|
-
|
|
14
|
+
o,
|
|
15
15
|
t,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]), { content:
|
|
19
|
-
return /* @__PURE__ */
|
|
16
|
+
r,
|
|
17
|
+
i
|
|
18
|
+
]), { content: l, beforeClose: d, onClose: f, onExited: m, ...h } = e.config;
|
|
19
|
+
return /* @__PURE__ */ u(p.Provider, {
|
|
20
20
|
value: c,
|
|
21
|
-
children: /* @__PURE__ */
|
|
21
|
+
children: /* @__PURE__ */ u(n, {
|
|
22
22
|
...h,
|
|
23
23
|
open: e.open,
|
|
24
24
|
onClose: c.close,
|
|
25
25
|
onExited: () => {
|
|
26
|
-
|
|
26
|
+
a({
|
|
27
27
|
type: "remove",
|
|
28
|
-
id:
|
|
28
|
+
id: o
|
|
29
29
|
}), m?.();
|
|
30
30
|
},
|
|
31
|
-
children: typeof
|
|
31
|
+
children: typeof l == "function" ? l(c) : l
|
|
32
32
|
})
|
|
33
33
|
});
|
|
34
34
|
}, g = ({ children: e }) => {
|
|
35
|
-
let [n,
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
let [n, r] = c(m, []), a = l(n);
|
|
36
|
+
o(() => {
|
|
37
|
+
a.current = n;
|
|
38
38
|
});
|
|
39
|
-
let p =
|
|
39
|
+
let p = l(0), g = i((e) => {
|
|
40
40
|
p.current += 1;
|
|
41
41
|
let t = `kapi-offc-${p.current}`;
|
|
42
|
-
return
|
|
42
|
+
return r({
|
|
43
43
|
type: "push",
|
|
44
44
|
id: t,
|
|
45
45
|
config: e
|
|
46
46
|
}), t;
|
|
47
|
-
}, []), _ =
|
|
48
|
-
let n =
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
51
|
-
for (let e =
|
|
52
|
-
|
|
47
|
+
}, []), _ = i((e) => {
|
|
48
|
+
let n = a.current, i = e ?? t(n), o = n.findIndex((e) => e.id === i);
|
|
49
|
+
if (o < 0 || !n[o]?.open) return;
|
|
50
|
+
let s = n.filter((e, t) => t >= o && e.open);
|
|
51
|
+
for (let e = s.length - 1; e >= 0; --e) if (s[e]?.config.beforeClose?.() === !1) return;
|
|
52
|
+
r({
|
|
53
53
|
type: "close",
|
|
54
|
-
id: n[
|
|
55
|
-
}),
|
|
56
|
-
}, []), v =
|
|
57
|
-
let e =
|
|
54
|
+
id: n[o].id
|
|
55
|
+
}), s.forEach((e) => e.config.onClose?.());
|
|
56
|
+
}, []), v = i(() => {
|
|
57
|
+
let e = a.current.filter((e) => e.open);
|
|
58
58
|
if (e.length !== 0) {
|
|
59
59
|
for (let t = e.length - 1; t >= 0; --t) if (e[t]?.config.beforeClose?.() === !1) return;
|
|
60
|
-
|
|
60
|
+
r({ type: "closeAll" }), e.forEach((e) => e.config.onClose?.());
|
|
61
61
|
}
|
|
62
|
-
}, []), y =
|
|
62
|
+
}, []), y = i(() => _(), [_]), b = n.filter((e) => e.open).length, x = s(() => ({
|
|
63
63
|
push: g,
|
|
64
64
|
close: _,
|
|
65
65
|
pop: y,
|
|
@@ -72,22 +72,22 @@ var f = a(null), p = a(null), m = (t, n) => e(t, n), h = ({ entry: e, level: t,
|
|
|
72
72
|
v,
|
|
73
73
|
b
|
|
74
74
|
]);
|
|
75
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ d(f.Provider, {
|
|
76
76
|
value: x,
|
|
77
|
-
children: [e, n.map((e, t) => /* @__PURE__ */
|
|
77
|
+
children: [e, n.map((e, t) => /* @__PURE__ */ u(h, {
|
|
78
78
|
entry: e,
|
|
79
79
|
level: t,
|
|
80
80
|
close: _,
|
|
81
81
|
push: g,
|
|
82
|
-
dispatch:
|
|
82
|
+
dispatch: r
|
|
83
83
|
}, e.id))]
|
|
84
84
|
});
|
|
85
85
|
}, _ = () => {
|
|
86
|
-
let e =
|
|
86
|
+
let e = a(f);
|
|
87
87
|
if (!e) throw Error("useKapiOffcanvasStack: falta <KapiOffcanvasStack> más arriba en el árbol.");
|
|
88
88
|
return e;
|
|
89
89
|
}, v = () => {
|
|
90
|
-
let e =
|
|
90
|
+
let e = a(p);
|
|
91
91
|
if (!e) throw Error("useKapiOffcanvasPanel: sólo se puede usar dentro del contenido de un panel del stack.");
|
|
92
92
|
return e;
|
|
93
93
|
};
|