@kapiuara/ui 0.14.0 → 0.15.1
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/overlays/useNativeDialog.d.ts +5 -0
- package/dist/components/overlays/useNativeDialog.js +2 -2
- 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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/KapiCommandPalette.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
5
5
|
import { enabledIndexes as n, nextEnabledIndex as r } from "./menuKeyboardLogic.js";
|
|
6
6
|
import { useMergedRefs as i } from "../../hooks/mergeRefs.js";
|
|
7
7
|
import { useBackdropClose as a, useNativeDialog as o, usePortalRoot as s } from "./useNativeDialog.js";
|
|
8
8
|
import { clampActiveIndex as c, filterGroups as ee, flattenNavigable as l, nodeText as u } from "./commandPaletteLogic.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { useEffect as d, useId as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
11
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
12
12
|
import { Search as v } from "lucide-react";
|
|
13
13
|
import { createPortal as y } from "react-dom";
|
|
14
14
|
//#region src/components/overlays/KapiCommandPalette.tsx
|
|
@@ -17,7 +17,7 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
17
17
|
empty: "Sin resultados",
|
|
18
18
|
footerHint: b
|
|
19
19
|
}, S = ({ onClose: b, groups: S, placeholder: C, emptyMessage: w, emptyLabel: T, footerHint: E, labels: D, className: O, style: k, id: A, ref: j }) => {
|
|
20
|
-
let M =
|
|
20
|
+
let M = t("commandPalette", x, D), N = C ?? M.placeholder, P = w ?? T ?? M.empty, F = E === void 0 ? M.footerHint : E, I = f(), L = `${I}-listbox`, R = (e) => `${I}-opt-${e}`, z = m(null), [B, V] = h(""), [H, U] = h(0), { ref: W, dialogProps: G } = o({ onRequestClose: () => b("escape") }), K = i(W, j), q = a(() => b("backdrop")), J = p(() => {
|
|
21
21
|
let e = S.map((e) => ({
|
|
22
22
|
...e,
|
|
23
23
|
commands: e.commands.map((e) => ({
|
|
@@ -26,14 +26,14 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
26
26
|
}))
|
|
27
27
|
}));
|
|
28
28
|
return ee(e, B);
|
|
29
|
-
}, [S, B]), Y =
|
|
30
|
-
|
|
29
|
+
}, [S, B]), Y = p(() => l(J), [J]), X = c(H, Y.length), Z = X >= 0 ? Y[X] : void 0;
|
|
30
|
+
d(() => {
|
|
31
31
|
if (!Z) return;
|
|
32
32
|
let e = z.current?.querySelector(`[data-cmd-id="${CSS.escape(Z.id)}"]`);
|
|
33
33
|
e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
34
34
|
}, [Z]);
|
|
35
35
|
let Q = (e) => {
|
|
36
|
-
e.disabled || (e.onSelect(), b());
|
|
36
|
+
e.disabled || (e.onSelect(), b("item-selected"));
|
|
37
37
|
}, te = (e) => {
|
|
38
38
|
switch (e.key) {
|
|
39
39
|
case "ArrowDown":
|
|
@@ -47,24 +47,24 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
47
47
|
case "Enter": Z && !e.nativeEvent.isComposing && (e.preventDefault(), Q(Z));
|
|
48
48
|
}
|
|
49
49
|
}, $ = s();
|
|
50
|
-
return $ ? y(/* @__PURE__ */
|
|
50
|
+
return $ ? y(/* @__PURE__ */ _("dialog", {
|
|
51
51
|
ref: K,
|
|
52
52
|
id: A,
|
|
53
53
|
style: k,
|
|
54
|
-
className:
|
|
54
|
+
className: e("kapi-cmdk", O),
|
|
55
55
|
"aria-modal": "true",
|
|
56
56
|
"aria-label": N,
|
|
57
57
|
...G,
|
|
58
58
|
...q,
|
|
59
59
|
children: [
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ _("div", {
|
|
61
61
|
className: "kapi-cmdk__search",
|
|
62
|
-
children: [/* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ g(v, {
|
|
63
63
|
size: 17,
|
|
64
64
|
strokeWidth: 2.2,
|
|
65
65
|
"aria-hidden": "true",
|
|
66
66
|
className: "kapi-cmdk__search-icon"
|
|
67
|
-
}), /* @__PURE__ */
|
|
67
|
+
}), /* @__PURE__ */ g("input", {
|
|
68
68
|
"data-autofocus": !0,
|
|
69
69
|
type: "text",
|
|
70
70
|
className: "kapi-cmdk__input",
|
|
@@ -84,7 +84,7 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
84
84
|
onKeyDown: te
|
|
85
85
|
})]
|
|
86
86
|
}),
|
|
87
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ _("div", {
|
|
88
88
|
ref: z,
|
|
89
89
|
id: L,
|
|
90
90
|
role: "listbox",
|
|
@@ -92,18 +92,18 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
92
92
|
className: "kapi-cmdk__list",
|
|
93
93
|
children: [J.map((e) => {
|
|
94
94
|
let t = `${I}-grp-${e.id}`;
|
|
95
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ _("div", {
|
|
96
96
|
role: "group",
|
|
97
97
|
className: "kapi-cmdk__group",
|
|
98
98
|
"aria-labelledby": e.label == null ? void 0 : t,
|
|
99
|
-
children: [e.label != null && /* @__PURE__ */
|
|
99
|
+
children: [e.label != null && /* @__PURE__ */ g("div", {
|
|
100
100
|
id: t,
|
|
101
101
|
className: "kapi-cmdk__group-label",
|
|
102
102
|
role: "presentation",
|
|
103
103
|
children: e.label
|
|
104
104
|
}), e.commands.map((e) => {
|
|
105
105
|
let t = Z?.id === e.id;
|
|
106
|
-
return /* @__PURE__ */
|
|
106
|
+
return /* @__PURE__ */ _("div", {
|
|
107
107
|
id: R(e.id),
|
|
108
108
|
"data-cmd-id": e.id,
|
|
109
109
|
role: "option",
|
|
@@ -121,16 +121,16 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
121
121
|
},
|
|
122
122
|
onClick: () => Q(e),
|
|
123
123
|
children: [
|
|
124
|
-
e.icon && /* @__PURE__ */
|
|
124
|
+
e.icon && /* @__PURE__ */ g("span", {
|
|
125
125
|
className: "kapi-cmdk__icon",
|
|
126
126
|
"aria-hidden": "true",
|
|
127
127
|
children: e.icon
|
|
128
128
|
}),
|
|
129
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ g("span", {
|
|
130
130
|
className: "kapi-cmdk__label",
|
|
131
131
|
children: e.label
|
|
132
132
|
}),
|
|
133
|
-
e.trailing && /* @__PURE__ */
|
|
133
|
+
e.trailing && /* @__PURE__ */ g("span", {
|
|
134
134
|
className: "kapi-cmdk__trailing",
|
|
135
135
|
children: e.trailing
|
|
136
136
|
})
|
|
@@ -138,18 +138,18 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
138
138
|
}, e.id);
|
|
139
139
|
})]
|
|
140
140
|
}, e.id);
|
|
141
|
-
}), J.length === 0 && /* @__PURE__ */
|
|
141
|
+
}), J.length === 0 && /* @__PURE__ */ g("div", {
|
|
142
142
|
className: "kapi-cmdk__empty",
|
|
143
143
|
role: "status",
|
|
144
144
|
children: P
|
|
145
145
|
})]
|
|
146
146
|
}),
|
|
147
|
-
F && /* @__PURE__ */
|
|
147
|
+
F && /* @__PURE__ */ g("div", {
|
|
148
148
|
className: "kapi-cmdk__foot",
|
|
149
149
|
children: F
|
|
150
150
|
})
|
|
151
151
|
]
|
|
152
152
|
}), $) : null;
|
|
153
|
-
}, C = ({ open: e, ...t }) => e ? /* @__PURE__ */
|
|
153
|
+
}, C = ({ open: e, ...t }) => e ? /* @__PURE__ */ g(S, { ...t }) : null;
|
|
154
154
|
//#endregion
|
|
155
155
|
export { x as DEFAULT_COMMAND_PALETTE_LABELS, b as DEFAULT_FOOTER_HINT, C as KapiCommandPalette };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import type { KapiRootProps } from "../rootProps.js";
|
|
3
4
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
4
5
|
import { type KapiTone } from "../tone.js";
|
|
@@ -54,7 +55,7 @@ export type KapiConfirmProps = KapiRootProps<HTMLDivElement> & {
|
|
|
54
55
|
/** Click en el botón de confirmar. */
|
|
55
56
|
onConfirm: () => void;
|
|
56
57
|
/** Pedido de cierre: Cancelar, X, Escape o click en el fondo. El padre pone `open={false}`. */
|
|
57
|
-
onClose: () => void;
|
|
58
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
58
59
|
};
|
|
59
60
|
/**
|
|
60
61
|
* Confirmación (envuelve a KapiModal `sm` sin header). Controlada:
|
|
@@ -5,8 +5,8 @@ import { KapiButton as t } from "../inputs/KapiButton.js";
|
|
|
5
5
|
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
6
|
import { KapiModal as r } from "./KapiModal.js";
|
|
7
7
|
/* empty css */
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useId as i } from "react";
|
|
9
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
10
10
|
import { AlertTriangle as c, CheckCircle2 as l, CircleHelp as u, Info as d, Trash2 as f } from "lucide-react";
|
|
11
11
|
//#region src/components/overlays/KapiConfirm.tsx
|
|
12
12
|
var p = {
|
|
@@ -39,8 +39,8 @@ var p = {
|
|
|
39
39
|
question: "Sí",
|
|
40
40
|
error: "No se pudo completar la acción"
|
|
41
41
|
}, h = ({ open: c, tone: l, variant: u, title: d, message: f, confirmLabel: h, cancelLabel: g, labels: _, loading: v = !1, error: y, onConfirm: b, onClose: x, className: S, style: C, id: w, ref: T }) => {
|
|
42
|
-
let E =
|
|
43
|
-
return /* @__PURE__ */
|
|
42
|
+
let E = i(), D = n("confirm", m, _), O = e(l, u, "question"), k = O in p ? O : "question", { Icon: A, button: j } = p[k];
|
|
43
|
+
return /* @__PURE__ */ s(r, {
|
|
44
44
|
ref: T,
|
|
45
45
|
className: S,
|
|
46
46
|
style: C,
|
|
@@ -52,35 +52,35 @@ var p = {
|
|
|
52
52
|
onClose: v ? () => {} : x,
|
|
53
53
|
closeOnEscape: !v,
|
|
54
54
|
closeOnBackdrop: !v,
|
|
55
|
-
footer: /* @__PURE__ */
|
|
55
|
+
footer: /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(t, {
|
|
56
56
|
"data-autofocus": !0,
|
|
57
57
|
disabled: v,
|
|
58
|
-
onClick: x,
|
|
58
|
+
onClick: () => x("cancel"),
|
|
59
59
|
children: g ?? D.cancel
|
|
60
|
-
}), /* @__PURE__ */
|
|
60
|
+
}), /* @__PURE__ */ o(t, {
|
|
61
61
|
tone: j,
|
|
62
62
|
loading: v,
|
|
63
63
|
onClick: b,
|
|
64
64
|
children: h ?? D[k]
|
|
65
65
|
})] }),
|
|
66
66
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ o("div", {
|
|
68
68
|
className: `kapi-confirm__icon kapi-confirm__icon--${k}`,
|
|
69
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ o(A, {
|
|
70
70
|
size: 28,
|
|
71
71
|
strokeWidth: 2
|
|
72
72
|
})
|
|
73
73
|
}),
|
|
74
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ o("div", {
|
|
75
75
|
id: E,
|
|
76
76
|
className: "kapi-confirm__title",
|
|
77
77
|
children: d
|
|
78
78
|
}),
|
|
79
|
-
f && /* @__PURE__ */
|
|
79
|
+
f && /* @__PURE__ */ o("div", {
|
|
80
80
|
className: "kapi-confirm__msg",
|
|
81
81
|
children: f
|
|
82
82
|
}),
|
|
83
|
-
y != null && y !== !1 && /* @__PURE__ */
|
|
83
|
+
y != null && y !== !1 && /* @__PURE__ */ o("div", {
|
|
84
84
|
className: "kapi-confirm__error",
|
|
85
85
|
role: "alert",
|
|
86
86
|
children: y
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributeAnchorTarget, type MouseEvent, type ReactNode } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
2
3
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
4
|
import { type KapiRootProps } from "../rootProps.js";
|
|
4
5
|
import type { KapiMenuItemTone } from "../tone.js";
|
|
@@ -97,7 +98,7 @@ export type KapiContextMenuProps = KapiRootProps<HTMLDivElement> & {
|
|
|
97
98
|
/** Ítems del menú, en orden (acciones y separadores). */
|
|
98
99
|
items: readonly KapiMenuItem[];
|
|
99
100
|
/** Pedido de cierre (Escape, click afuera o tras elegir un ítem). El padre pone `open={false}`. */
|
|
100
|
-
onClose: () => void;
|
|
101
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
101
102
|
/** Nombre accesible del menú (`aria-label`). Sin la prop usa `labels.menu`. */
|
|
102
103
|
"aria-label"?: string | undefined;
|
|
103
104
|
/** Textos fijos (clave `contextMenu`). */
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { usePlacement as n } from "../../hooks/usePlacement.js";
|
|
6
6
|
import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
|
|
7
7
|
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
@@ -10,11 +10,11 @@ import { POINT_MENU_PLACEMENT as a } from "../../hooks/rightClick.js";
|
|
|
10
10
|
import { estimateMenuHeight as o } from "./menuButtonLogic.js";
|
|
11
11
|
import { MenuList as s } from "./menuList.js";
|
|
12
12
|
import { useFocusReturn as c } from "../../hooks/useFocusReturn.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { useLayoutEffect as l, useRef as u } from "react";
|
|
14
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/overlays/KapiContextMenu.tsx
|
|
16
|
-
var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /* @__PURE__ */
|
|
17
|
-
let E =
|
|
16
|
+
var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /* @__PURE__ */ f(_, { ...t }) : null, _ = ({ x: g, y: _, items: v, onClose: y, className: b, style: x, id: S, ref: C, labels: w, "aria-label": T }) => {
|
|
17
|
+
let E = t("contextMenu", m, w), D = u(null), O = r(D, C);
|
|
18
18
|
c(!0, {
|
|
19
19
|
container: D,
|
|
20
20
|
restoreOnDeactivate: "if-lost"
|
|
@@ -22,7 +22,7 @@ var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /*
|
|
|
22
22
|
let k = i(!0, {
|
|
23
23
|
zones: [D],
|
|
24
24
|
outside: !1,
|
|
25
|
-
onDismiss: () => y()
|
|
25
|
+
onDismiss: (e) => y(e)
|
|
26
26
|
}), { placement: A, update: j } = n({
|
|
27
27
|
open: !0,
|
|
28
28
|
anchor: () => ({
|
|
@@ -37,7 +37,7 @@ var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /*
|
|
|
37
37
|
...a,
|
|
38
38
|
hideUntilPlaced: !1
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
l(() => {
|
|
41
41
|
j();
|
|
42
42
|
}, [
|
|
43
43
|
g,
|
|
@@ -46,16 +46,16 @@ var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /*
|
|
|
46
46
|
j
|
|
47
47
|
]);
|
|
48
48
|
let M = A?.left ?? g, N = A?.top ?? _;
|
|
49
|
-
return /* @__PURE__ */ d
|
|
49
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
50
50
|
className: "kapi-ctxmenu__backdrop",
|
|
51
|
-
onMouseDown: y,
|
|
51
|
+
onMouseDown: () => y("outside"),
|
|
52
52
|
onContextMenu: (e) => {
|
|
53
|
-
e.preventDefault(), y();
|
|
53
|
+
e.preventDefault(), y("outside");
|
|
54
54
|
}
|
|
55
|
-
}), /* @__PURE__ */
|
|
55
|
+
}), /* @__PURE__ */ f(s, {
|
|
56
56
|
ref: O,
|
|
57
57
|
id: S,
|
|
58
|
-
className:
|
|
58
|
+
className: e("kapi-ctxmenu", b),
|
|
59
59
|
style: {
|
|
60
60
|
...x,
|
|
61
61
|
left: M,
|
|
@@ -66,9 +66,9 @@ var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /*
|
|
|
66
66
|
items: v,
|
|
67
67
|
focusRequest: 1,
|
|
68
68
|
onKeyDown: k,
|
|
69
|
-
onClose: () => y(),
|
|
69
|
+
onClose: () => y("outside"),
|
|
70
70
|
onActivate: (e, t) => {
|
|
71
|
-
e.onClick?.(t), e.keepOpen || y();
|
|
71
|
+
e.onClick?.(t), e.keepOpen || y("item-selected");
|
|
72
72
|
}
|
|
73
73
|
})] });
|
|
74
74
|
};
|
|
@@ -10,8 +10,8 @@ import { KapiModal as a } from "./KapiModal.js";
|
|
|
10
10
|
/* empty css */
|
|
11
11
|
import { DEFAULT_CONFIRM_LABELS as o, KapiConfirm as s } from "./KapiConfirm.js";
|
|
12
12
|
import { confirmErrorMessage as c, dialogStore as l } from "./dialogStore.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { useId as u, useRef as d, useState as f, useSyncExternalStore as p } from "react";
|
|
14
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
15
|
import { AlertTriangle as _, CheckCircle2 as v, Info as y, XCircle as b } from "lucide-react";
|
|
16
16
|
import { createPortal as x } from "react-dom";
|
|
17
17
|
//#region src/components/overlays/KapiDialogHost.tsx
|
|
@@ -24,44 +24,44 @@ var S = {
|
|
|
24
24
|
info: y,
|
|
25
25
|
warning: _
|
|
26
26
|
}, w = ({ options: n, acceptLabel: r, onClose: i }) => {
|
|
27
|
-
let o =
|
|
28
|
-
return /* @__PURE__ */
|
|
27
|
+
let o = u(), s = e(n.tone, n.variant, "info"), c = s in C ? s : "info", l = C[c];
|
|
28
|
+
return /* @__PURE__ */ g(a, {
|
|
29
29
|
size: "sm",
|
|
30
30
|
hideHeader: !0,
|
|
31
31
|
"aria-labelledby": o,
|
|
32
32
|
open: !0,
|
|
33
33
|
onClose: i,
|
|
34
|
-
footer: /* @__PURE__ */
|
|
34
|
+
footer: /* @__PURE__ */ h(t, {
|
|
35
35
|
"data-autofocus": !0,
|
|
36
36
|
tone: "primary",
|
|
37
37
|
onClick: i,
|
|
38
38
|
children: n.acceptLabel ?? r
|
|
39
39
|
}),
|
|
40
40
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ h("div", {
|
|
42
42
|
className: `kapi-confirm__icon kapi-confirm__icon--${c}`,
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ h(l, {
|
|
44
44
|
size: 28,
|
|
45
45
|
strokeWidth: 2
|
|
46
46
|
})
|
|
47
47
|
}),
|
|
48
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ h("div", {
|
|
49
49
|
id: o,
|
|
50
50
|
className: "kapi-confirm__title",
|
|
51
51
|
children: n.title
|
|
52
52
|
}),
|
|
53
|
-
n.message && /* @__PURE__ */
|
|
53
|
+
n.message && /* @__PURE__ */ h("div", {
|
|
54
54
|
className: "kapi-confirm__msg",
|
|
55
55
|
children: n.message
|
|
56
56
|
})
|
|
57
57
|
]
|
|
58
58
|
});
|
|
59
59
|
}, T = ({ options: e, onSettle: t }) => {
|
|
60
|
-
let r = n("confirm", o), [i, a] =
|
|
60
|
+
let r = n("confirm", o), [i, a] = f({
|
|
61
61
|
busy: !1,
|
|
62
62
|
error: null
|
|
63
|
-
}), l =
|
|
64
|
-
return /* @__PURE__ */
|
|
63
|
+
}), l = d(!1);
|
|
64
|
+
return /* @__PURE__ */ h(s, {
|
|
65
65
|
open: !0,
|
|
66
66
|
title: e.title,
|
|
67
67
|
message: e.message,
|
|
@@ -88,8 +88,8 @@ var S = {
|
|
|
88
88
|
onClose: () => t(!1)
|
|
89
89
|
});
|
|
90
90
|
}, E = ({ message: e, root: t }) => {
|
|
91
|
-
let n =
|
|
92
|
-
return x(/* @__PURE__ */
|
|
91
|
+
let n = u(), { ref: i, dialogProps: a } = r();
|
|
92
|
+
return x(/* @__PURE__ */ h("dialog", {
|
|
93
93
|
ref: i,
|
|
94
94
|
className: "kapi-loading-overlay kapi-loading-dialog",
|
|
95
95
|
"aria-modal": "true",
|
|
@@ -97,12 +97,12 @@ var S = {
|
|
|
97
97
|
"aria-labelledby": n,
|
|
98
98
|
tabIndex: -1,
|
|
99
99
|
...a,
|
|
100
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ g("div", {
|
|
101
101
|
className: "kapi-loading",
|
|
102
|
-
children: [/* @__PURE__ */
|
|
102
|
+
children: [/* @__PURE__ */ h("span", {
|
|
103
103
|
className: "kapi-spinner",
|
|
104
104
|
"aria-hidden": "true"
|
|
105
|
-
}), /* @__PURE__ */
|
|
105
|
+
}), /* @__PURE__ */ h("span", {
|
|
106
106
|
id: n,
|
|
107
107
|
className: "kapi-loading__msg",
|
|
108
108
|
role: "status",
|
|
@@ -111,18 +111,18 @@ var S = {
|
|
|
111
111
|
})
|
|
112
112
|
}), t);
|
|
113
113
|
}, D = ({ labels: e, store: t = l }) => {
|
|
114
|
-
let r = n("dialog", S, e), { dialog: a, loading: o } =
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
a?.kind === "confirm" && /* @__PURE__ */
|
|
114
|
+
let r = n("dialog", S, e), { dialog: a, loading: o } = p(t.subscribe, t.getSnapshot, t.getSnapshot), s = i(), c = o && !a ? s : null;
|
|
115
|
+
return /* @__PURE__ */ g(m, { children: [
|
|
116
|
+
a?.kind === "confirm" && /* @__PURE__ */ h(T, {
|
|
117
117
|
options: a.options,
|
|
118
118
|
onSettle: (e) => t.settle(a.id, e)
|
|
119
119
|
}, a.id),
|
|
120
|
-
a?.kind === "alert" && /* @__PURE__ */
|
|
120
|
+
a?.kind === "alert" && /* @__PURE__ */ h(w, {
|
|
121
121
|
options: a.options,
|
|
122
122
|
acceptLabel: r.accept,
|
|
123
123
|
onClose: () => t.settle(a.id, !1)
|
|
124
124
|
}, a.id),
|
|
125
|
-
!a && o && c && /* @__PURE__ */
|
|
125
|
+
!a && o && c && /* @__PURE__ */ h(E, {
|
|
126
126
|
message: o.message ?? r.loading,
|
|
127
127
|
root: c
|
|
128
128
|
})
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/KapiModal.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 { useNativeDialog as n, usePortalRoot as r } from "./useNativeDialog.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useId as i } from "react";
|
|
8
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
9
9
|
import { createPortal as s } from "react-dom";
|
|
10
10
|
//#region src/components/overlays/KapiLoading.tsx
|
|
11
|
-
var c = { message: "Cargando…" }, l = ({ message:
|
|
12
|
-
let f =
|
|
13
|
-
return s(/* @__PURE__ */
|
|
11
|
+
var c = { message: "Cargando…" }, l = ({ message: t, root: r, className: c, style: l, id: u, ref: d }) => {
|
|
12
|
+
let f = i(), { ref: p, dialogProps: m } = n();
|
|
13
|
+
return s(/* @__PURE__ */ a("dialog", {
|
|
14
14
|
ref: p,
|
|
15
15
|
className: "kapi-loading-overlay kapi-loading-dialog",
|
|
16
16
|
role: "alertdialog",
|
|
@@ -19,25 +19,25 @@ var c = { message: "Cargando…" }, l = ({ message: e, root: r, className: c, st
|
|
|
19
19
|
"aria-labelledby": f,
|
|
20
20
|
tabIndex: -1,
|
|
21
21
|
...m,
|
|
22
|
-
children: /* @__PURE__ */
|
|
22
|
+
children: /* @__PURE__ */ o("div", {
|
|
23
23
|
ref: d,
|
|
24
24
|
id: u,
|
|
25
|
-
className:
|
|
25
|
+
className: e("kapi-loading", c),
|
|
26
26
|
style: l,
|
|
27
|
-
children: [/* @__PURE__ */
|
|
27
|
+
children: [/* @__PURE__ */ a("span", {
|
|
28
28
|
className: "kapi-spinner",
|
|
29
29
|
"aria-hidden": "true"
|
|
30
|
-
}), /* @__PURE__ */
|
|
30
|
+
}), /* @__PURE__ */ a("span", {
|
|
31
31
|
id: f,
|
|
32
32
|
className: "kapi-loading__msg",
|
|
33
|
-
children:
|
|
33
|
+
children: t
|
|
34
34
|
})]
|
|
35
35
|
})
|
|
36
36
|
}), r);
|
|
37
|
-
}, u = ({ open:
|
|
38
|
-
let o =
|
|
39
|
-
return u ? /* @__PURE__ */
|
|
40
|
-
...
|
|
37
|
+
}, u = ({ open: e, message: n, ...i }) => {
|
|
38
|
+
let o = t("loading", c), s = r(), u = e ? s : null;
|
|
39
|
+
return u ? /* @__PURE__ */ a(l, {
|
|
40
|
+
...i,
|
|
41
41
|
message: n ?? o.message,
|
|
42
42
|
root: u
|
|
43
43
|
}) : null;
|
|
@@ -1,7 +1,7 @@
|
|
|
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";
|
|
@@ -11,16 +11,16 @@ import { useDismiss as o } from "../../hooks/useDismiss.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,7 +31,7 @@ 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,
|
|
@@ -44,13 +44,13 @@ var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, dis
|
|
|
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). */
|