@kapiuara/ui 0.15.2 → 0.16.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/LICENSE +19 -15
- package/README.md +338 -6
- package/dist/components/data/KapiDataTable.d.ts +1 -1
- package/dist/components/data/KapiDataTable.js +22 -22
- package/dist/components/data/KapiPaginationFooter.js +1 -1
- package/dist/components/data/KapiSheet.d.ts +105 -0
- package/dist/components/data/KapiSheet.js +75 -0
- package/dist/components/data/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +347 -329
- package/dist/components/data/KapiTableFooter.d.ts +22 -0
- package/dist/components/data/KapiTableFooter.js +55 -0
- package/dist/components/data/KapiTableRow.js +53 -52
- package/dist/components/data/KapiTableToolbar.d.ts +4 -2
- package/dist/components/data/KapiTableToolbar.js +71 -69
- package/dist/components/data/index.d.ts +3 -1
- package/dist/components/data/tableCells.d.ts +5 -4
- package/dist/components/data/tableCells.js +48 -43
- package/dist/components/data/tableLogic.d.ts +2 -0
- package/dist/components/data/tableLogic.js +66 -66
- package/dist/components/data/tableSlots.d.ts +9 -0
- package/dist/components/data/tableSlots.js +12 -0
- package/dist/components/data/tableSpanLogic.d.ts +35 -0
- package/dist/components/data/tableSpanLogic.js +47 -0
- package/dist/components/data/tableTypes.d.ts +66 -1
- package/dist/components/data/useTableSelection.d.ts +4 -2
- package/dist/components/data/useTableSelection.js +27 -23
- package/dist/components/display/KapiAnchor.d.ts +36 -0
- package/dist/components/display/KapiAnchor.js +36 -0
- package/dist/components/display/KapiBadge.d.ts +6 -5
- package/dist/components/display/KapiBadge.js +25 -19
- package/dist/components/display/KapiText.d.ts +43 -0
- package/dist/components/display/KapiText.js +33 -0
- package/dist/components/display/KapiTitle.d.ts +33 -0
- package/dist/components/display/KapiTitle.js +29 -0
- package/dist/components/display/index.d.ts +7 -0
- package/dist/components/display/textLogic.d.ts +32 -0
- package/dist/components/display/textLogic.js +19 -0
- package/dist/components/feedback/KapiAlert.d.ts +8 -4
- package/dist/components/feedback/KapiAlert.js +39 -34
- package/dist/components/inputs/KapiButton.d.ts +7 -4
- package/dist/components/inputs/KapiButton.js +47 -42
- package/dist/components/inputs/KapiSelect.d.ts +12 -0
- package/dist/components/inputs/KapiSelect.js +215 -212
- package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
- package/dist/components/inputs/KapiSelectMenu.js +131 -133
- package/dist/components/inputs/fieldLogic.d.ts +2 -2
- package/dist/components/inputs/index.d.ts +1 -1
- package/dist/components/inputs/selectSlots.d.ts +24 -0
- package/dist/components/inputs/selectSlots.js +27 -0
- package/dist/components/layout/KapiBox.d.ts +31 -0
- package/dist/components/layout/KapiBox.js +26 -0
- package/dist/components/layout/KapiCard.d.ts +16 -4
- package/dist/components/layout/KapiCard.js +46 -34
- package/dist/components/layout/KapiCenter.d.ts +13 -0
- package/dist/components/layout/KapiCenter.js +23 -0
- package/dist/components/layout/KapiCol.d.ts +22 -0
- package/dist/components/layout/KapiCol.js +23 -0
- package/dist/components/layout/KapiGrid.d.ts +29 -3
- package/dist/components/layout/KapiGrid.js +39 -17
- package/dist/components/layout/KapiPageHeader.d.ts +10 -1
- package/dist/components/layout/KapiPageHeader.js +82 -80
- package/dist/components/layout/KapiPanelParts.d.ts +11 -2
- package/dist/components/layout/KapiPanelParts.js +73 -56
- package/dist/components/layout/KapiRail.d.ts +10 -1
- package/dist/components/layout/KapiRail.js +123 -120
- package/dist/components/layout/KapiRoot.d.ts +35 -5
- package/dist/components/layout/KapiRoot.js +54 -39
- package/dist/components/layout/KapiShell.d.ts +36 -3
- package/dist/components/layout/KapiShell.js +53 -50
- package/dist/components/layout/cardSlots.d.ts +9 -0
- package/dist/components/layout/cardSlots.js +12 -0
- package/dist/components/layout/gridSpanLogic.d.ts +46 -0
- package/dist/components/layout/gridSpanLogic.js +39 -0
- package/dist/components/layout/index.d.ts +11 -4
- package/dist/components/layout/layoutPrimitives.d.ts +11 -0
- package/dist/components/layout/layoutPrimitives.js +12 -1
- package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
- package/dist/components/layout/pageHeaderSlots.js +15 -0
- package/dist/components/layout/railLogic.d.ts +16 -3
- package/dist/components/layout/railSlots.d.ts +12 -0
- package/dist/components/layout/railSlots.js +15 -0
- package/dist/components/layout/shellSlots.d.ts +6 -0
- package/dist/components/layout/shellSlots.js +9 -0
- package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
- package/dist/components/layout/useGridBreakpoint.js +35 -0
- package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
- package/dist/components/navigation/KapiBreadcrumb.js +23 -16
- package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
- package/dist/components/navigation/KapiContextPanel.js +151 -135
- package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
- package/dist/components/navigation/KapiPanelGroup.js +66 -65
- package/dist/components/navigation/KapiTabs.d.ts +12 -0
- package/dist/components/navigation/KapiTabs.js +87 -71
- package/dist/components/navigation/MiniNavItem.d.ts +7 -2
- package/dist/components/navigation/MiniNavItem.js +41 -36
- package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
- package/dist/components/navigation/breadcrumbLogic.js +1 -1
- package/dist/components/navigation/navLink.d.ts +21 -0
- package/dist/components/navigation/navLink.js +26 -0
- package/dist/components/navigation/navLinkLogic.d.ts +18 -0
- package/dist/components/navigation/navLinkLogic.js +22 -0
- package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
- package/dist/components/overlays/KapiModal.d.ts +9 -0
- package/dist/components/overlays/KapiModal.js +77 -75
- package/dist/components/overlays/index.d.ts +1 -1
- package/dist/components/overlays/menuList.js +123 -113
- package/dist/components/overlays/modalSlots.d.ts +11 -0
- package/dist/components/overlays/modalSlots.js +14 -0
- package/dist/components/slotCatalog.d.ts +90 -0
- package/dist/components/slotCatalog.js +19 -0
- package/dist/components/slotsLogic.d.ts +34 -0
- package/dist/components/slotsLogic.js +18 -0
- package/dist/components/tone.d.ts +26 -0
- package/dist/components/tone.js +15 -14
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiEventCalendar.css +1 -1
- package/dist/css/components/data/KapiTable.css +1 -1
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/display/typography.css +1 -0
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiButton.css +1 -1
- package/dist/css/components/inputs/KapiDatePicker.css +1 -1
- package/dist/css/components/layout/KapiBox.css +1 -0
- package/dist/css/components/layout/KapiRail.css +1 -1
- package/dist/css/components/layout/gridSpan.css +1 -0
- package/dist/css/components/navigation/navigation.css +1 -1
- package/dist/hooks/densityLogic.d.ts +15 -0
- package/dist/hooks/densityLogic.js +4 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/themeColorsLogic.d.ts +19 -0
- package/dist/hooks/themeColorsLogic.js +4 -2
- package/dist/hooks/themeDeriveLogic.d.ts +16 -0
- package/dist/hooks/themeDeriveLogic.js +27 -17
- package/dist/hooks/toneFamilyLogic.d.ts +122 -0
- package/dist/hooks/toneFamilyLogic.js +151 -0
- package/dist/hooks/useKapiTheme.d.ts +8 -2
- package/dist/hooks/useKapiTheme.js +116 -103
- package/dist/hooks/useToneFamilies.d.ts +30 -0
- package/dist/hooks/useToneFamilies.js +46 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +213 -204
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/styles/rawHeights.d.ts +8 -0
- package/package.json +4 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/components/navigation/navLinkLogic.ts
|
|
2
|
+
var e = (e) => e.preventDefault(), t = ({ render: t, href: n, newTab: r = !1, disabled: i = !1, active: a = !1 }) => {
|
|
3
|
+
let o = t !== void 0;
|
|
4
|
+
return {
|
|
5
|
+
propias: o ? {} : {
|
|
6
|
+
href: i ? void 0 : n,
|
|
7
|
+
rel: "noopener noreferrer",
|
|
8
|
+
target: r ? "_blank" : void 0
|
|
9
|
+
},
|
|
10
|
+
fijas: {
|
|
11
|
+
"aria-current": a ? "page" : void 0,
|
|
12
|
+
"aria-disabled": i || void 0,
|
|
13
|
+
...o && i ? { onClick: e } : {},
|
|
14
|
+
...o && r ? {
|
|
15
|
+
target: "_blank",
|
|
16
|
+
rel: "noopener noreferrer"
|
|
17
|
+
} : {}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { t as navLinkProps };
|
|
@@ -3,6 +3,7 @@ import type { KapiCloseReason } from "../closeReason.js";
|
|
|
3
3
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
4
4
|
import { type KapiRootProps } from "../rootProps.js";
|
|
5
5
|
import type { KapiMenuItemTone } from "../tone.js";
|
|
6
|
+
import type { KapiRender } from "../renderSlot.js";
|
|
6
7
|
export { menuItemClass } from "./menuList.js";
|
|
7
8
|
/**
|
|
8
9
|
* Ítem de un menú de acciones (KapiContextMenu, KapiMenuButton, menús de KapiTable y KapiShell): un
|
|
@@ -57,6 +58,13 @@ export type KapiMenuItem = {
|
|
|
57
58
|
rel?: string | undefined;
|
|
58
59
|
/** `download` del enlace (solo con `href`): `true` o el nombre sugerido del archivo. */
|
|
59
60
|
download?: boolean | string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* El elemento que dibuja el ítem: el `<Link>` de tu router, para navegar sin recargar la página. El
|
|
63
|
+
* ítem conserva `role="menuitem"` y el resto del contrato de teclado; las clases se unen, los estilos
|
|
64
|
+
* se funden y los handlers corren los dos (primero el tuyo). La librería no le pone `href`, y `href`
|
|
65
|
+
* se ignora si hay `render`. `onClick` se llama igual (después del tuyo) y el menú se cierra.
|
|
66
|
+
*/
|
|
67
|
+
render?: KapiRender | undefined;
|
|
60
68
|
/**
|
|
61
69
|
* Atajo de teclado que se muestra a la derecha como pista y se anuncia con `aria-keyshortcuts`
|
|
62
70
|
* (usa los nombres de tecla de ARIA: `Control+S`, `Shift+Delete`). Solo informa: no registra el
|
|
@@ -3,7 +3,10 @@ import type { KapiCloseReason } from "../closeReason.js";
|
|
|
3
3
|
import { type GrowOrigin } from "../../hooks/growOriginLogic.js";
|
|
4
4
|
import { type KapiModalSize } from "./dialogUtils.js";
|
|
5
5
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
6
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
6
7
|
export type { KapiModalSize } from "./dialogUtils.js";
|
|
8
|
+
/** Partes de `KapiModal` que acepta `classNames`: `overlay`, `root` (la tarjeta), `header`, `title`, `subtitle`, `close`, `body`, `footer`. */
|
|
9
|
+
export type KapiModalClassNames = KapiClassNames<"modal">;
|
|
7
10
|
export type KapiModalLabels = {
|
|
8
11
|
close: string;
|
|
9
12
|
};
|
|
@@ -27,6 +30,12 @@ export type KapiModalProps = {
|
|
|
27
30
|
hideHeader?: boolean | undefined;
|
|
28
31
|
/** Clase de la tarjeta del modal. */
|
|
29
32
|
className?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Clases por parte: `classNames={{ header: "mi-header", footer: "mi-pie" }}`. Se suman a las propias,
|
|
35
|
+
* sin reemplazarlas. `root` es la tarjeta (lo mismo que `className`) y `overlay` el `<dialog>` con el
|
|
36
|
+
* fondo. Cada parte además lleva `data-slot="modal-<parte>"`.
|
|
37
|
+
*/
|
|
38
|
+
classNames?: KapiModalClassNames | undefined;
|
|
30
39
|
/** Estilo de la tarjeta del modal. */
|
|
31
40
|
style?: CSSProperties | undefined;
|
|
32
41
|
/** id de la tarjeta del modal. */
|
|
@@ -2,112 +2,114 @@
|
|
|
2
2
|
import "#kapi-css/components/overlays/KapiModal.css";
|
|
3
3
|
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
4
4
|
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { slot as n } from "../slotsLogic.js";
|
|
6
|
+
import { prefersReducedMotion as r } from "../../hooks/reducedMotion.js";
|
|
7
|
+
import { dialogNameProps as i, modalClasses as a, resolveDismiss as o } from "./dialogUtils.js";
|
|
8
|
+
import { useExitPresence as s } from "./useExitPresence.js";
|
|
9
|
+
import { originWithinCard as ee } from "../../hooks/growOriginLogic.js";
|
|
10
|
+
import { useBackdropClose as te, useNativeDialog as c, usePortalRoot as l, useTrappedDialogWarning as u } from "./useNativeDialog.js";
|
|
10
11
|
/* empty css */
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { MODAL_SLOTS as d } from "./modalSlots.js";
|
|
13
|
+
import { 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
|
+
import { X as v } from "lucide-react";
|
|
16
|
+
import { createPortal as y } from "react-dom";
|
|
15
17
|
//#region src/components/overlays/KapiModal.tsx
|
|
16
|
-
var
|
|
17
|
-
let n =
|
|
18
|
-
return r ? /* @__PURE__ */
|
|
18
|
+
var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
|
|
19
|
+
let n = m(null), { present: r, closing: i } = s(e, n);
|
|
20
|
+
return r ? /* @__PURE__ */ g(C, {
|
|
19
21
|
...t,
|
|
20
22
|
dialogRef: n,
|
|
21
23
|
closing: i
|
|
22
24
|
}) : null;
|
|
23
|
-
},
|
|
24
|
-
let
|
|
25
|
-
dismissible:
|
|
26
|
-
closeOnEscape:
|
|
27
|
-
closeOnBackdrop:
|
|
28
|
-
closeButton:
|
|
29
|
-
}), { closeOnEscape:
|
|
30
|
-
u("KapiModal",
|
|
31
|
-
let e =
|
|
32
|
-
if (!
|
|
33
|
-
|
|
25
|
+
}, S = () => {}, C = ({ title: s, subtitle: x, onClose: C, children: w, footer: T, size: E = "md", hideHeader: D = !1, className: ne = "", classNames: O, style: k, id: A, ref: j, closeOnBackdrop: M, closeOnEscape: N, closeButton: P, dismissible: F, closeLabel: I, labels: L, "aria-label": R, "aria-labelledby": z, growFrom: B, dialogRef: V, closing: H }) => {
|
|
26
|
+
let U = H ? S : C, W = f(), G = e("modal", b, L), K = I ?? G.close, q = m(null), J = t(q, j), [Y, X] = h(null), Z = o({
|
|
27
|
+
dismissible: F,
|
|
28
|
+
closeOnEscape: N,
|
|
29
|
+
closeOnBackdrop: M,
|
|
30
|
+
closeButton: P
|
|
31
|
+
}), { closeOnEscape: re, closeOnBackdrop: ie, closeButton: Q } = Z, { ref: ae, dialogProps: oe } = c({ onRequestClose: re ? () => U("escape") : void 0 }), se = te(ie ? () => U("backdrop") : void 0);
|
|
32
|
+
u("KapiModal", Z, q), p(() => {
|
|
33
|
+
let e = q.current;
|
|
34
|
+
if (!B || !e || r(e)) {
|
|
35
|
+
X(null);
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
|
-
let t = e.getBoundingClientRect(),
|
|
37
|
-
|
|
38
|
-
left: a -
|
|
38
|
+
let t = e.getBoundingClientRect(), n = e.offsetWidth, i = e.offsetHeight, a = t.left + t.width / 2, o = t.top + t.height / 2;
|
|
39
|
+
X(ee(B, {
|
|
40
|
+
left: a - n / 2,
|
|
39
41
|
top: o - i / 2,
|
|
40
|
-
width:
|
|
42
|
+
width: n,
|
|
41
43
|
height: i
|
|
42
44
|
}));
|
|
43
|
-
}, [
|
|
45
|
+
}, [B]);
|
|
44
46
|
let $ = l();
|
|
45
|
-
return $ ?
|
|
47
|
+
return $ ? y(/* @__PURE__ */ g("dialog", {
|
|
46
48
|
ref: (e) => {
|
|
47
|
-
|
|
49
|
+
ae.current = e, V.current = e;
|
|
48
50
|
},
|
|
49
|
-
|
|
50
|
-
"data-closing":
|
|
51
|
+
...n(d, "overlay", O, "kapi-modal-dialog"),
|
|
52
|
+
"data-closing": H || void 0,
|
|
51
53
|
"aria-modal": "true",
|
|
52
|
-
...
|
|
53
|
-
titleId:
|
|
54
|
-
title:
|
|
55
|
-
hideHeader:
|
|
56
|
-
"aria-label":
|
|
57
|
-
"aria-labelledby":
|
|
54
|
+
...i({
|
|
55
|
+
titleId: W,
|
|
56
|
+
title: s,
|
|
57
|
+
hideHeader: D,
|
|
58
|
+
"aria-label": R,
|
|
59
|
+
"aria-labelledby": z
|
|
58
60
|
}),
|
|
59
|
-
...
|
|
60
|
-
...
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
-
ref:
|
|
63
|
-
id:
|
|
64
|
-
|
|
65
|
-
style:
|
|
66
|
-
...
|
|
67
|
-
"--kapi-grow-x": `${
|
|
68
|
-
"--kapi-grow-y": `${
|
|
69
|
-
} :
|
|
61
|
+
...oe,
|
|
62
|
+
...se,
|
|
63
|
+
children: /* @__PURE__ */ _("div", {
|
|
64
|
+
ref: J,
|
|
65
|
+
id: A,
|
|
66
|
+
...n(d, "root", O, `${a(E, ne)}${Y ? " kapi-modal--grow" : ""}`),
|
|
67
|
+
style: Y ? {
|
|
68
|
+
...k,
|
|
69
|
+
"--kapi-grow-x": `${Y.x}px`,
|
|
70
|
+
"--kapi-grow-y": `${Y.y}px`
|
|
71
|
+
} : k,
|
|
70
72
|
children: [
|
|
71
|
-
|
|
73
|
+
D ? Q && /* @__PURE__ */ g("button", {
|
|
72
74
|
type: "button",
|
|
73
|
-
|
|
74
|
-
onClick: () =>
|
|
75
|
-
"aria-label":
|
|
76
|
-
children: /* @__PURE__ */
|
|
75
|
+
...n(d, "close", O, "kapi-modal__x--float"),
|
|
76
|
+
onClick: () => U("close-button"),
|
|
77
|
+
"aria-label": K,
|
|
78
|
+
children: /* @__PURE__ */ g(v, {
|
|
77
79
|
size: 17,
|
|
78
80
|
strokeWidth: 2.2
|
|
79
81
|
})
|
|
80
|
-
}) : /* @__PURE__ */
|
|
81
|
-
|
|
82
|
-
children: [/* @__PURE__ */
|
|
83
|
-
id:
|
|
84
|
-
|
|
85
|
-
children:
|
|
86
|
-
}),
|
|
87
|
-
|
|
88
|
-
children:
|
|
89
|
-
})] }), Q && /* @__PURE__ */
|
|
82
|
+
}) : /* @__PURE__ */ _("div", {
|
|
83
|
+
...n(d, "header", O),
|
|
84
|
+
children: [/* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("div", {
|
|
85
|
+
id: W,
|
|
86
|
+
...n(d, "title", O),
|
|
87
|
+
children: s
|
|
88
|
+
}), x && /* @__PURE__ */ g("div", {
|
|
89
|
+
...n(d, "subtitle", O),
|
|
90
|
+
children: x
|
|
91
|
+
})] }), Q && /* @__PURE__ */ g("button", {
|
|
90
92
|
type: "button",
|
|
91
|
-
|
|
92
|
-
onClick: () =>
|
|
93
|
-
"aria-label":
|
|
94
|
-
children: /* @__PURE__ */
|
|
93
|
+
...n(d, "close", O),
|
|
94
|
+
onClick: () => U("close-button"),
|
|
95
|
+
"aria-label": K,
|
|
96
|
+
children: /* @__PURE__ */ g(v, {
|
|
95
97
|
size: 17,
|
|
96
98
|
strokeWidth: 2.2
|
|
97
99
|
})
|
|
98
100
|
})]
|
|
99
101
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
102
|
-
children: C
|
|
103
|
-
}),
|
|
104
|
-
w && /* @__PURE__ */ h("div", {
|
|
105
|
-
className: "kapi-modal__foot",
|
|
102
|
+
/* @__PURE__ */ g("div", {
|
|
103
|
+
...n(d, "body", O),
|
|
106
104
|
children: w
|
|
105
|
+
}),
|
|
106
|
+
T && /* @__PURE__ */ g("div", {
|
|
107
|
+
...n(d, "footer", O),
|
|
108
|
+
children: T
|
|
107
109
|
})
|
|
108
110
|
]
|
|
109
111
|
})
|
|
110
112
|
}), $) : null;
|
|
111
113
|
};
|
|
112
114
|
//#endregion
|
|
113
|
-
export {
|
|
115
|
+
export { b as DEFAULT_MODAL_LABELS, x as KapiModal };
|
|
@@ -12,7 +12,7 @@ export type { KapiPhotoViewLabels, KapiPhotoViewProps } from "./KapiPhotoView.js
|
|
|
12
12
|
export { KapiShapeSheet, DEFAULT_SHAPE_SHEET_LABELS } from "./KapiShapeSheet.js";
|
|
13
13
|
export type { KapiShapeSheetProps, KapiShapeSheetLabels } from "./KapiShapeSheet.js";
|
|
14
14
|
export { KapiModal, DEFAULT_MODAL_LABELS } from "./KapiModal.js";
|
|
15
|
-
export type { KapiModalLabels, KapiModalProps, KapiModalSize } from "./KapiModal.js";
|
|
15
|
+
export type { KapiModalClassNames, KapiModalLabels, KapiModalProps, KapiModalSize } from "./KapiModal.js";
|
|
16
16
|
export { KapiSplitModal, DEFAULT_SPLIT_MODAL_LABELS } from "./KapiSplitModal.js";
|
|
17
17
|
export type { KapiSplitModalAside, KapiSplitModalProps, KapiSplitModalLabels } from "./KapiSplitModal.js";
|
|
18
18
|
export { KapiConfirm, DEFAULT_CONFIRM_LABELS } from "./KapiConfirm.js";
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
3
|
+
import { renderSlot as t } from "../renderSlot.js";
|
|
4
|
+
import { resolveMenuItemTone as n } from "../tone.js";
|
|
5
|
+
import { useLabels as r } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { initialMenuFocus as i, isTypeaheadKey as a, menuKeyIntent as o, nextEnabledIndex as s } from "./menuKeyboardLogic.js";
|
|
7
|
+
import { activeElementOf as c } from "../../hooks/ownerDocument.js";
|
|
8
|
+
import { logicalKeyOf as l } from "../../hooks/directionLogic.js";
|
|
9
|
+
import { usePlacement as u } from "../../hooks/usePlacement.js";
|
|
10
|
+
import { useTypeahead as d } from "../../hooks/useTypeahead.js";
|
|
11
|
+
import { actionableIndexes as f, isActionMenuItem as p, matchMenuTypeahead as m, menuItemRole as h, submenuKeyAction as g } from "./menuButtonLogic.js";
|
|
12
|
+
import { DEFAULT_LINK_LABELS as _ } from "../locale/linkLabels.js";
|
|
13
|
+
import { useEffect as v, useId as y, useRef as b, useState as x } from "react";
|
|
14
|
+
import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
15
|
+
import { Check as T, ChevronRight as E, Circle as D } from "lucide-react";
|
|
16
|
+
var O = {
|
|
16
17
|
side: "right",
|
|
17
18
|
align: "start",
|
|
18
19
|
offset: 4,
|
|
19
20
|
flip: "auto",
|
|
20
21
|
shift: !0
|
|
21
|
-
},
|
|
22
|
-
let t =
|
|
23
|
-
|
|
24
|
-
let o = (e) => t.current[e]?.focus(),
|
|
22
|
+
}, k = (t) => e("kapi-ctxmenu__item", n(t.tone, t.danger) === "danger" && "is-danger", t.disabled && "is-disabled", t.current && "is-current"), A = (e) => {
|
|
23
|
+
let t = b([]), n = b(null), r = b(void 0), [i, a] = x(null);
|
|
24
|
+
v(() => () => clearTimeout(r.current), []);
|
|
25
|
+
let o = (e) => t.current[e]?.focus(), s = (e, t) => a((n) => ({
|
|
25
26
|
index: e,
|
|
26
27
|
focus: t ? (n?.focus ?? 0) + 1 : n?.index === e ? n.focus : 0
|
|
27
28
|
})), l = () => {
|
|
28
|
-
i !== null && (n.current?.contains(
|
|
29
|
+
i !== null && (n.current?.contains(c(n.current)) && o(i.index), a(null));
|
|
29
30
|
}, u = (t) => {
|
|
30
31
|
let n = e[t];
|
|
31
|
-
return n !== void 0 &&
|
|
32
|
+
return n !== void 0 && p(n) && !n.disabled && (n.items?.length ?? 0) > 0;
|
|
32
33
|
}, d = (e) => {
|
|
33
34
|
clearTimeout(r.current), i?.index !== e && (r.current = setTimeout(() => {
|
|
34
|
-
u(e) ?
|
|
35
|
+
u(e) ? s(e, !1) : l();
|
|
35
36
|
}, 200));
|
|
36
|
-
},
|
|
37
|
+
}, f = () => clearTimeout(r.current);
|
|
37
38
|
return {
|
|
38
39
|
itemEls: t,
|
|
39
40
|
focusItem: o,
|
|
40
41
|
sub: i,
|
|
41
|
-
openSub:
|
|
42
|
+
openSub: s,
|
|
42
43
|
closeSub: l,
|
|
43
44
|
hasSubmenu: u,
|
|
44
45
|
entryProps: (e) => ({
|
|
@@ -48,166 +49,175 @@ var D = {
|
|
|
48
49
|
subOpen: i?.index === e && u(e),
|
|
49
50
|
subFocus: i?.index === e ? i.focus : 0,
|
|
50
51
|
subRef: n,
|
|
51
|
-
onToggleSub: () => i?.index === e ? l() :
|
|
52
|
+
onToggleSub: () => i?.index === e ? l() : s(e, !0),
|
|
52
53
|
onBackFromSub: () => {
|
|
53
54
|
a(null), o(e);
|
|
54
55
|
},
|
|
55
56
|
onEnter: () => d(e),
|
|
56
|
-
onLeave:
|
|
57
|
+
onLeave: f
|
|
57
58
|
})
|
|
58
59
|
};
|
|
59
|
-
},
|
|
60
|
-
let E =
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
}, [
|
|
60
|
+
}, j = ({ items: e, onActivate: t, onClose: n, focusRequest: u, onBack: p, onKeyDown: h, ref: y, id: b, className: x, style: S, "aria-label": w, "aria-labelledby": T }) => {
|
|
61
|
+
let E = r("link", _), D = d(500), O = A(e), { itemEls: k, focusItem: j, openSub: N, hasSubmenu: P } = O, F = f(e), I = p !== void 0;
|
|
62
|
+
return v(() => {
|
|
63
|
+
u > 0 && j(i(F));
|
|
64
|
+
}, [u]), /* @__PURE__ */ C("div", {
|
|
64
65
|
ref: y,
|
|
65
66
|
id: b,
|
|
66
67
|
role: "menu",
|
|
67
68
|
className: x,
|
|
68
|
-
style:
|
|
69
|
+
style: S,
|
|
69
70
|
"aria-label": w,
|
|
70
71
|
"aria-labelledby": T,
|
|
71
72
|
onKeyDown: (t) => {
|
|
72
|
-
let
|
|
73
|
+
let r = c(t.currentTarget), i = k.current.findIndex((e) => e !== null && e === r), u = () => {
|
|
73
74
|
t.preventDefault(), I && t.stopPropagation();
|
|
74
|
-
}, d =
|
|
75
|
+
}, d = o(t.key);
|
|
75
76
|
if (d.kind === "move") {
|
|
76
|
-
u(),
|
|
77
|
+
u(), j(s(i, d.dir, F));
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
|
-
let f =
|
|
80
|
-
hasSubmenu:
|
|
80
|
+
let f = g(l(t), {
|
|
81
|
+
hasSubmenu: i >= 0 && P(i),
|
|
81
82
|
nested: I
|
|
82
83
|
});
|
|
83
|
-
if (f === "open") u(), N(
|
|
84
|
-
else if (f === "back") u(),
|
|
84
|
+
if (f === "open") u(), N(i, !0);
|
|
85
|
+
else if (f === "back") u(), p?.();
|
|
85
86
|
else if (d.kind === "close") {
|
|
86
87
|
if (I) return;
|
|
87
|
-
if (d.returnFocus) return
|
|
88
|
-
|
|
89
|
-
} else if (
|
|
90
|
-
let n =
|
|
91
|
-
n >= 0 && (u(),
|
|
88
|
+
if (d.returnFocus) return h?.(t);
|
|
89
|
+
n(!1);
|
|
90
|
+
} else if (a(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
91
|
+
let n = m(e, i, D(t.key));
|
|
92
|
+
n >= 0 && (u(), j(n));
|
|
92
93
|
}
|
|
93
94
|
},
|
|
94
|
-
children: e.map((e,
|
|
95
|
+
children: e.map((e, r) => e.sep ? /* @__PURE__ */ C("div", {
|
|
95
96
|
role: "separator",
|
|
96
97
|
className: "kapi-ctxmenu__sep"
|
|
97
|
-
}, `s${
|
|
98
|
+
}, `s${r}`) : "header" in e ? /* @__PURE__ */ C("div", {
|
|
98
99
|
role: "presentation",
|
|
99
100
|
className: "kapi-ctxmenu__header",
|
|
100
101
|
children: e.header
|
|
101
|
-
}, `h${
|
|
102
|
-
...O.entryProps(
|
|
102
|
+
}, `h${r}`) : /* @__PURE__ */ C(M, {
|
|
103
|
+
...O.entryProps(r),
|
|
103
104
|
item: e,
|
|
104
|
-
index:
|
|
105
|
+
index: r,
|
|
105
106
|
newTabLabel: E.newTab,
|
|
106
107
|
onActivate: t,
|
|
107
|
-
onClose:
|
|
108
|
-
}, e.id ?? `m${
|
|
108
|
+
onClose: n
|
|
109
|
+
}, e.id ?? `m${r}`))
|
|
109
110
|
});
|
|
110
|
-
},
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
id:
|
|
115
|
-
role:
|
|
111
|
+
}, M = ({ item: n, index: r, newTabLabel: i, itemRef: a, subOpen: o, subFocus: s, subRef: c, onToggleSub: l, onBackFromSub: u, onActivate: d, onClose: f, onEnter: p, onLeave: m }) => {
|
|
112
|
+
let g = y(), _ = y(), v = b(null), x = h(n), O = x !== "menuitem", A = n.items !== void 0 && n.items.length > 0 ? n.items : null, j = n.href !== void 0 && n.target === "_blank", M = typeof n.label != "string" && n.textValue !== void 0 ? j ? `${n.textValue} ${i}` : n.textValue : void 0, P = (e) => {
|
|
113
|
+
v.current = e, a(e);
|
|
114
|
+
}, F = {
|
|
115
|
+
id: A ? g : void 0,
|
|
116
|
+
role: x,
|
|
116
117
|
tabIndex: -1,
|
|
117
|
-
"data-menu-index":
|
|
118
|
-
"data-menu-id":
|
|
119
|
-
"aria-disabled":
|
|
120
|
-
"aria-current":
|
|
121
|
-
"aria-checked":
|
|
122
|
-
"aria-keyshortcuts":
|
|
123
|
-
"aria-describedby":
|
|
124
|
-
"aria-haspopup":
|
|
125
|
-
"aria-expanded":
|
|
126
|
-
"aria-label":
|
|
127
|
-
className: e(
|
|
118
|
+
"data-menu-index": r,
|
|
119
|
+
"data-menu-id": n.id,
|
|
120
|
+
"aria-disabled": n.disabled ? "true" : void 0,
|
|
121
|
+
"aria-current": n.current ? "true" : void 0,
|
|
122
|
+
"aria-checked": O ? n.checked === !0 : void 0,
|
|
123
|
+
"aria-keyshortcuts": n.shortcut,
|
|
124
|
+
"aria-describedby": n.description === void 0 ? void 0 : _,
|
|
125
|
+
"aria-haspopup": A ? "menu" : void 0,
|
|
126
|
+
"aria-expanded": A ? o : void 0,
|
|
127
|
+
"aria-label": M,
|
|
128
|
+
className: e(k(n), O && "is-checkable", o && "is-open"),
|
|
128
129
|
onClick: (e) => {
|
|
129
|
-
|
|
130
|
+
n.disabled ? e.preventDefault() : A ? (e.preventDefault(), l()) : d(n, e);
|
|
130
131
|
},
|
|
131
|
-
onMouseEnter:
|
|
132
|
-
onMouseLeave:
|
|
133
|
-
},
|
|
134
|
-
|
|
132
|
+
onMouseEnter: p,
|
|
133
|
+
onMouseLeave: m
|
|
134
|
+
}, I = /* @__PURE__ */ w(S, { children: [
|
|
135
|
+
O && /* @__PURE__ */ C("span", {
|
|
135
136
|
className: "kapi-ctxmenu__check",
|
|
136
137
|
"aria-hidden": "true",
|
|
137
|
-
children:
|
|
138
|
+
children: n.checked === !0 && (x === "menuitemradio" ? /* @__PURE__ */ C(D, {
|
|
138
139
|
size: 8,
|
|
139
140
|
fill: "currentColor",
|
|
140
141
|
strokeWidth: 0
|
|
141
|
-
}) : /* @__PURE__ */
|
|
142
|
+
}) : /* @__PURE__ */ C(T, {
|
|
142
143
|
size: 15,
|
|
143
144
|
strokeWidth: 2.4
|
|
144
145
|
}))
|
|
145
146
|
}),
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
n.icon,
|
|
148
|
+
n.description === void 0 ? n.label : /* @__PURE__ */ w("span", {
|
|
148
149
|
className: "kapi-ctxmenu__text",
|
|
149
|
-
children: [/* @__PURE__ */
|
|
150
|
+
children: [/* @__PURE__ */ C("span", {
|
|
150
151
|
className: "kapi-ctxmenu__label",
|
|
151
|
-
children:
|
|
152
|
-
}), /* @__PURE__ */
|
|
153
|
-
id:
|
|
152
|
+
children: n.label
|
|
153
|
+
}), /* @__PURE__ */ C("span", {
|
|
154
|
+
id: _,
|
|
154
155
|
className: "kapi-ctxmenu__desc",
|
|
155
156
|
"aria-hidden": "true",
|
|
156
|
-
children:
|
|
157
|
+
children: n.description
|
|
157
158
|
})]
|
|
158
159
|
}),
|
|
159
|
-
|
|
160
|
+
j && M === void 0 && /* @__PURE__ */ w(S, { children: [" ", /* @__PURE__ */ C("span", {
|
|
160
161
|
className: "kapi-sr-only",
|
|
161
|
-
children:
|
|
162
|
+
children: i
|
|
162
163
|
})] }),
|
|
163
|
-
|
|
164
|
+
n.shortcut !== void 0 && /* @__PURE__ */ C("kbd", {
|
|
164
165
|
className: "kapi-ctxmenu__kbd",
|
|
165
166
|
"aria-hidden": "true",
|
|
166
|
-
children:
|
|
167
|
+
children: n.shortcut
|
|
167
168
|
}),
|
|
168
|
-
|
|
169
|
+
A && /* @__PURE__ */ C(E, {
|
|
169
170
|
className: "kapi-ctxmenu__chev kapi-flip-rtl",
|
|
170
171
|
size: 15,
|
|
171
172
|
strokeWidth: 2.2,
|
|
172
173
|
"aria-hidden": "true"
|
|
173
174
|
})
|
|
174
|
-
] }),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
] }), { className: L, onClick: R, onMouseEnter: z, onMouseLeave: B, ...V } = F, H = n.render !== void 0 && !A ? t(n.render, {
|
|
176
|
+
className: L,
|
|
177
|
+
onClick: R,
|
|
178
|
+
onMouseEnter: z,
|
|
179
|
+
onMouseLeave: B
|
|
180
|
+
}, {
|
|
181
|
+
...V,
|
|
182
|
+
ref: P,
|
|
183
|
+
children: I
|
|
184
|
+
}, (e) => /* @__PURE__ */ C("a", { ...e })) : n.href !== void 0 && !A ? /* @__PURE__ */ C("a", {
|
|
185
|
+
ref: P,
|
|
186
|
+
...F,
|
|
187
|
+
href: n.disabled ? void 0 : n.href,
|
|
188
|
+
target: n.target,
|
|
189
|
+
rel: n.rel ?? (j ? "noopener noreferrer" : void 0),
|
|
190
|
+
download: n.download,
|
|
191
|
+
children: I
|
|
192
|
+
}) : /* @__PURE__ */ C("button", {
|
|
193
|
+
ref: P,
|
|
184
194
|
type: "button",
|
|
185
|
-
...
|
|
186
|
-
children:
|
|
195
|
+
...F,
|
|
196
|
+
children: I
|
|
187
197
|
});
|
|
188
|
-
return
|
|
198
|
+
return A ? /* @__PURE__ */ w("div", {
|
|
189
199
|
role: "none",
|
|
190
200
|
className: "kapi-ctxmenu__subwrap",
|
|
191
|
-
children: [
|
|
192
|
-
items:
|
|
193
|
-
anchorRef:
|
|
194
|
-
menuRef:
|
|
195
|
-
labelledBy:
|
|
196
|
-
focusRequest:
|
|
197
|
-
onBack:
|
|
198
|
-
onActivate:
|
|
199
|
-
onClose:
|
|
201
|
+
children: [H, o && /* @__PURE__ */ C(N, {
|
|
202
|
+
items: A,
|
|
203
|
+
anchorRef: v,
|
|
204
|
+
menuRef: c,
|
|
205
|
+
labelledBy: g,
|
|
206
|
+
focusRequest: s,
|
|
207
|
+
onBack: u,
|
|
208
|
+
onActivate: d,
|
|
209
|
+
onClose: f
|
|
200
210
|
})]
|
|
201
|
-
}) :
|
|
202
|
-
},
|
|
203
|
-
let { style: c } =
|
|
211
|
+
}) : H;
|
|
212
|
+
}, N = ({ items: e, anchorRef: t, menuRef: n, labelledBy: r, focusRequest: i, onBack: a, onActivate: o, onClose: s }) => {
|
|
213
|
+
let { style: c } = u({
|
|
204
214
|
open: !0,
|
|
205
215
|
anchor: t,
|
|
206
216
|
floatingRef: n,
|
|
207
|
-
...
|
|
217
|
+
...O,
|
|
208
218
|
hideUntilPlaced: !1
|
|
209
219
|
});
|
|
210
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ C(j, {
|
|
211
221
|
ref: n,
|
|
212
222
|
items: e,
|
|
213
223
|
className: "kapi-ctxmenu kapi-ctxmenu--sub",
|
|
@@ -220,4 +230,4 @@ var D = {
|
|
|
220
230
|
});
|
|
221
231
|
};
|
|
222
232
|
//#endregion
|
|
223
|
-
export {
|
|
233
|
+
export { M as MenuEntry, j as MenuList, k as menuItemClass, A as useMenuSubmenus };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Partes de `modal` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
|
|
2
|
+
export declare const MODAL_SLOTS: import("../slotsLogic.js").SlotTable<"modal", {
|
|
3
|
+
readonly overlay: "kapi-modal-overlay";
|
|
4
|
+
readonly root: "kapi-modal";
|
|
5
|
+
readonly header: "kapi-modal__head";
|
|
6
|
+
readonly title: "kapi-modal__title";
|
|
7
|
+
readonly subtitle: "kapi-modal__sub";
|
|
8
|
+
readonly close: "kapi-modal__x";
|
|
9
|
+
readonly body: "kapi-modal__body";
|
|
10
|
+
readonly footer: "kapi-modal__foot";
|
|
11
|
+
}>;
|