@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.
Files changed (145) hide show
  1. package/LICENSE +19 -15
  2. package/README.md +338 -6
  3. package/dist/components/data/KapiDataTable.d.ts +1 -1
  4. package/dist/components/data/KapiDataTable.js +22 -22
  5. package/dist/components/data/KapiPaginationFooter.js +1 -1
  6. package/dist/components/data/KapiSheet.d.ts +105 -0
  7. package/dist/components/data/KapiSheet.js +75 -0
  8. package/dist/components/data/KapiTable.d.ts +2 -2
  9. package/dist/components/data/KapiTable.js +347 -329
  10. package/dist/components/data/KapiTableFooter.d.ts +22 -0
  11. package/dist/components/data/KapiTableFooter.js +55 -0
  12. package/dist/components/data/KapiTableRow.js +53 -52
  13. package/dist/components/data/KapiTableToolbar.d.ts +4 -2
  14. package/dist/components/data/KapiTableToolbar.js +71 -69
  15. package/dist/components/data/index.d.ts +3 -1
  16. package/dist/components/data/tableCells.d.ts +5 -4
  17. package/dist/components/data/tableCells.js +48 -43
  18. package/dist/components/data/tableLogic.d.ts +2 -0
  19. package/dist/components/data/tableLogic.js +66 -66
  20. package/dist/components/data/tableSlots.d.ts +9 -0
  21. package/dist/components/data/tableSlots.js +12 -0
  22. package/dist/components/data/tableSpanLogic.d.ts +35 -0
  23. package/dist/components/data/tableSpanLogic.js +47 -0
  24. package/dist/components/data/tableTypes.d.ts +66 -1
  25. package/dist/components/data/useTableSelection.d.ts +4 -2
  26. package/dist/components/data/useTableSelection.js +27 -23
  27. package/dist/components/display/KapiAnchor.d.ts +36 -0
  28. package/dist/components/display/KapiAnchor.js +36 -0
  29. package/dist/components/display/KapiBadge.d.ts +6 -5
  30. package/dist/components/display/KapiBadge.js +25 -19
  31. package/dist/components/display/KapiText.d.ts +43 -0
  32. package/dist/components/display/KapiText.js +33 -0
  33. package/dist/components/display/KapiTitle.d.ts +33 -0
  34. package/dist/components/display/KapiTitle.js +29 -0
  35. package/dist/components/display/index.d.ts +7 -0
  36. package/dist/components/display/textLogic.d.ts +32 -0
  37. package/dist/components/display/textLogic.js +19 -0
  38. package/dist/components/feedback/KapiAlert.d.ts +8 -4
  39. package/dist/components/feedback/KapiAlert.js +39 -34
  40. package/dist/components/inputs/KapiButton.d.ts +7 -4
  41. package/dist/components/inputs/KapiButton.js +47 -42
  42. package/dist/components/inputs/KapiSelect.d.ts +12 -0
  43. package/dist/components/inputs/KapiSelect.js +215 -212
  44. package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
  45. package/dist/components/inputs/KapiSelectMenu.js +131 -133
  46. package/dist/components/inputs/fieldLogic.d.ts +2 -2
  47. package/dist/components/inputs/index.d.ts +1 -1
  48. package/dist/components/inputs/selectSlots.d.ts +24 -0
  49. package/dist/components/inputs/selectSlots.js +27 -0
  50. package/dist/components/layout/KapiBox.d.ts +31 -0
  51. package/dist/components/layout/KapiBox.js +26 -0
  52. package/dist/components/layout/KapiCard.d.ts +16 -4
  53. package/dist/components/layout/KapiCard.js +46 -34
  54. package/dist/components/layout/KapiCenter.d.ts +13 -0
  55. package/dist/components/layout/KapiCenter.js +23 -0
  56. package/dist/components/layout/KapiCol.d.ts +22 -0
  57. package/dist/components/layout/KapiCol.js +23 -0
  58. package/dist/components/layout/KapiGrid.d.ts +29 -3
  59. package/dist/components/layout/KapiGrid.js +39 -17
  60. package/dist/components/layout/KapiPageHeader.d.ts +10 -1
  61. package/dist/components/layout/KapiPageHeader.js +82 -80
  62. package/dist/components/layout/KapiPanelParts.d.ts +11 -2
  63. package/dist/components/layout/KapiPanelParts.js +73 -56
  64. package/dist/components/layout/KapiRail.d.ts +10 -1
  65. package/dist/components/layout/KapiRail.js +123 -120
  66. package/dist/components/layout/KapiRoot.d.ts +35 -5
  67. package/dist/components/layout/KapiRoot.js +54 -39
  68. package/dist/components/layout/KapiShell.d.ts +36 -3
  69. package/dist/components/layout/KapiShell.js +53 -50
  70. package/dist/components/layout/cardSlots.d.ts +9 -0
  71. package/dist/components/layout/cardSlots.js +12 -0
  72. package/dist/components/layout/gridSpanLogic.d.ts +46 -0
  73. package/dist/components/layout/gridSpanLogic.js +39 -0
  74. package/dist/components/layout/index.d.ts +11 -4
  75. package/dist/components/layout/layoutPrimitives.d.ts +11 -0
  76. package/dist/components/layout/layoutPrimitives.js +12 -1
  77. package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
  78. package/dist/components/layout/pageHeaderSlots.js +15 -0
  79. package/dist/components/layout/railLogic.d.ts +16 -3
  80. package/dist/components/layout/railSlots.d.ts +12 -0
  81. package/dist/components/layout/railSlots.js +15 -0
  82. package/dist/components/layout/shellSlots.d.ts +6 -0
  83. package/dist/components/layout/shellSlots.js +9 -0
  84. package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
  85. package/dist/components/layout/useGridBreakpoint.js +35 -0
  86. package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
  87. package/dist/components/navigation/KapiBreadcrumb.js +23 -16
  88. package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
  89. package/dist/components/navigation/KapiContextPanel.js +151 -135
  90. package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
  91. package/dist/components/navigation/KapiPanelGroup.js +66 -65
  92. package/dist/components/navigation/KapiTabs.d.ts +12 -0
  93. package/dist/components/navigation/KapiTabs.js +87 -71
  94. package/dist/components/navigation/MiniNavItem.d.ts +7 -2
  95. package/dist/components/navigation/MiniNavItem.js +41 -36
  96. package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
  97. package/dist/components/navigation/breadcrumbLogic.js +1 -1
  98. package/dist/components/navigation/navLink.d.ts +21 -0
  99. package/dist/components/navigation/navLink.js +26 -0
  100. package/dist/components/navigation/navLinkLogic.d.ts +18 -0
  101. package/dist/components/navigation/navLinkLogic.js +22 -0
  102. package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
  103. package/dist/components/overlays/KapiModal.d.ts +9 -0
  104. package/dist/components/overlays/KapiModal.js +77 -75
  105. package/dist/components/overlays/index.d.ts +1 -1
  106. package/dist/components/overlays/menuList.js +123 -113
  107. package/dist/components/overlays/modalSlots.d.ts +11 -0
  108. package/dist/components/overlays/modalSlots.js +14 -0
  109. package/dist/components/slotCatalog.d.ts +90 -0
  110. package/dist/components/slotCatalog.js +19 -0
  111. package/dist/components/slotsLogic.d.ts +34 -0
  112. package/dist/components/slotsLogic.js +18 -0
  113. package/dist/components/tone.d.ts +26 -0
  114. package/dist/components/tone.js +15 -14
  115. package/dist/css/base.css +1 -1
  116. package/dist/css/components/data/KapiEventCalendar.css +1 -1
  117. package/dist/css/components/data/KapiTable.css +1 -1
  118. package/dist/css/components/display/display.css +1 -1
  119. package/dist/css/components/display/typography.css +1 -0
  120. package/dist/css/components/feedback/feedback.css +1 -1
  121. package/dist/css/components/inputs/KapiButton.css +1 -1
  122. package/dist/css/components/inputs/KapiDatePicker.css +1 -1
  123. package/dist/css/components/layout/KapiBox.css +1 -0
  124. package/dist/css/components/layout/KapiRail.css +1 -1
  125. package/dist/css/components/layout/gridSpan.css +1 -0
  126. package/dist/css/components/navigation/navigation.css +1 -1
  127. package/dist/hooks/densityLogic.d.ts +15 -0
  128. package/dist/hooks/densityLogic.js +4 -0
  129. package/dist/hooks/index.d.ts +4 -0
  130. package/dist/hooks/themeColorsLogic.d.ts +19 -0
  131. package/dist/hooks/themeColorsLogic.js +4 -2
  132. package/dist/hooks/themeDeriveLogic.d.ts +16 -0
  133. package/dist/hooks/themeDeriveLogic.js +27 -17
  134. package/dist/hooks/toneFamilyLogic.d.ts +122 -0
  135. package/dist/hooks/toneFamilyLogic.js +151 -0
  136. package/dist/hooks/useKapiTheme.d.ts +8 -2
  137. package/dist/hooks/useKapiTheme.js +116 -103
  138. package/dist/hooks/useToneFamilies.d.ts +30 -0
  139. package/dist/hooks/useToneFamilies.js +46 -0
  140. package/dist/index.d.ts +3 -1
  141. package/dist/index.js +213 -204
  142. package/dist/kapi.css +1 -1
  143. package/dist/kapi.layered.css +1 -1
  144. package/dist/styles/rawHeights.d.ts +8 -0
  145. 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 { prefersReducedMotion as n } from "../../hooks/reducedMotion.js";
6
- import { dialogNameProps as r, modalClasses as i, resolveDismiss as a } from "./dialogUtils.js";
7
- import { useExitPresence as o } from "./useExitPresence.js";
8
- import { originWithinCard as s } from "../../hooks/growOriginLogic.js";
9
- import { useBackdropClose as ee, useNativeDialog as c, usePortalRoot as l, useTrappedDialogWarning as u } from "./useNativeDialog.js";
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 { 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";
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 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, {
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
- }, 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
- dismissible: N,
26
- closeOnEscape: j,
27
- closeOnBackdrop: A,
28
- closeButton: M
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
- let e = G.current;
32
- if (!R || !e || n(e)) {
33
- J(null);
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(), r = e.offsetWidth, i = e.offsetHeight, a = t.left + t.width / 2, o = t.top + t.height / 2;
37
- J(s(R, {
38
- left: a - r / 2,
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: r,
42
+ width: n,
41
43
  height: i
42
44
  }));
43
- }, [R]);
45
+ }, [B]);
44
46
  let $ = l();
45
- return $ ? v(/* @__PURE__ */ h("dialog", {
47
+ return $ ? y(/* @__PURE__ */ g("dialog", {
46
48
  ref: (e) => {
47
- ne.current = e, z.current = e;
49
+ ae.current = e, V.current = e;
48
50
  },
49
- className: "kapi-modal-overlay kapi-modal-dialog",
50
- "data-closing": B || void 0,
51
+ ...n(d, "overlay", O, "kapi-modal-dialog"),
52
+ "data-closing": H || void 0,
51
53
  "aria-modal": "true",
52
- ...r({
53
- titleId: H,
54
- title: o,
55
- hideHeader: E,
56
- "aria-label": I,
57
- "aria-labelledby": L
54
+ ...i({
55
+ titleId: W,
56
+ title: s,
57
+ hideHeader: D,
58
+ "aria-label": R,
59
+ "aria-labelledby": z
58
60
  }),
59
- ...re,
60
- ...ie,
61
- children: /* @__PURE__ */ g("div", {
62
- ref: K,
63
- id: O,
64
- className: `${i(T, te)}${q ? " kapi-modal--grow" : ""}`,
65
- style: q ? {
66
- ...D,
67
- "--kapi-grow-x": `${q.x}px`,
68
- "--kapi-grow-y": `${q.y}px`
69
- } : D,
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
- E ? Q && /* @__PURE__ */ h("button", {
73
+ D ? Q && /* @__PURE__ */ g("button", {
72
74
  type: "button",
73
- className: "kapi-modal__x kapi-modal__x--float",
74
- onClick: () => V("close-button"),
75
- "aria-label": W,
76
- children: /* @__PURE__ */ h(_, {
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__ */ g("div", {
81
- className: "kapi-modal__head",
82
- children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("div", {
83
- id: H,
84
- className: "kapi-modal__title",
85
- children: o
86
- }), b && /* @__PURE__ */ h("div", {
87
- className: "kapi-modal__sub",
88
- children: b
89
- })] }), Q && /* @__PURE__ */ h("button", {
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
- className: "kapi-modal__x",
92
- onClick: () => V("close-button"),
93
- "aria-label": W,
94
- children: /* @__PURE__ */ h(_, {
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__ */ h("div", {
101
- className: "kapi-modal__body",
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 { y as DEFAULT_MODAL_LABELS, b as KapiModal };
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 { resolveMenuItemTone as t } from "../tone.js";
4
- import { useLabels as n } from "../locale/KapiLocaleProvider.js";
5
- import { initialMenuFocus as r, isTypeaheadKey as i, menuKeyIntent as a, nextEnabledIndex as o } from "./menuKeyboardLogic.js";
6
- import { activeElementOf as s } from "../../hooks/ownerDocument.js";
7
- import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
8
- import { usePlacement as l } from "../../hooks/usePlacement.js";
9
- import { useTypeahead as u } from "../../hooks/useTypeahead.js";
10
- import { actionableIndexes as d, isActionMenuItem as f, matchMenuTypeahead as p, menuItemRole as m, submenuKeyAction as h } from "./menuButtonLogic.js";
11
- import { DEFAULT_LINK_LABELS as g } from "../locale/linkLabels.js";
12
- import { useEffect as _, useId as v, useRef as y, useState as b } from "react";
13
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
14
- import { Check as w, ChevronRight as T, Circle as E } from "lucide-react";
15
- var D = {
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
- }, O = (n) => e("kapi-ctxmenu__item", t(n.tone, n.danger) === "danger" && "is-danger", n.disabled && "is-disabled", n.current && "is-current"), k = (e) => {
22
- let t = y([]), n = y(null), r = y(void 0), [i, a] = b(null);
23
- _(() => () => clearTimeout(r.current), []);
24
- let o = (e) => t.current[e]?.focus(), c = (e, t) => a((n) => ({
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(s(n.current)) && o(i.index), a(null));
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 && f(n) && !n.disabled && (n.items?.length ?? 0) > 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) ? c(e, !1) : l();
35
+ u(e) ? s(e, !1) : l();
35
36
  }, 200));
36
- }, p = () => clearTimeout(r.current);
37
+ }, f = () => clearTimeout(r.current);
37
38
  return {
38
39
  itemEls: t,
39
40
  focusItem: o,
40
41
  sub: i,
41
- openSub: c,
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() : c(e, !0),
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: p
57
+ onLeave: f
57
58
  })
58
59
  };
59
- }, A = ({ items: e, onActivate: t, onClose: l, focusRequest: f, onBack: m, onKeyDown: v, ref: y, id: b, className: x, style: C, "aria-label": w, "aria-labelledby": T }) => {
60
- let E = n("link", g), D = u(500), O = k(e), { itemEls: A, focusItem: M, openSub: N, hasSubmenu: P } = O, F = d(e), I = m !== void 0;
61
- return _(() => {
62
- f > 0 && M(r(F));
63
- }, [f]), /* @__PURE__ */ S("div", {
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: C,
69
+ style: S,
69
70
  "aria-label": w,
70
71
  "aria-labelledby": T,
71
72
  onKeyDown: (t) => {
72
- let n = s(t.currentTarget), r = A.current.findIndex((e) => e !== null && e === n), u = () => {
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 = a(t.key);
75
+ }, d = o(t.key);
75
76
  if (d.kind === "move") {
76
- u(), M(o(r, d.dir, F));
77
+ u(), j(s(i, d.dir, F));
77
78
  return;
78
79
  }
79
- let f = h(c(t), {
80
- hasSubmenu: r >= 0 && P(r),
80
+ let f = g(l(t), {
81
+ hasSubmenu: i >= 0 && P(i),
81
82
  nested: I
82
83
  });
83
- if (f === "open") u(), N(r, !0);
84
- else if (f === "back") u(), m?.();
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 v?.(t);
88
- l(!1);
89
- } else if (i(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
90
- let n = p(e, r, D(t.key));
91
- n >= 0 && (u(), M(n));
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, n) => e.sep ? /* @__PURE__ */ S("div", {
95
+ children: e.map((e, r) => e.sep ? /* @__PURE__ */ C("div", {
95
96
  role: "separator",
96
97
  className: "kapi-ctxmenu__sep"
97
- }, `s${n}`) : "header" in e ? /* @__PURE__ */ S("div", {
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${n}`) : /* @__PURE__ */ S(j, {
102
- ...O.entryProps(n),
102
+ }, `h${r}`) : /* @__PURE__ */ C(M, {
103
+ ...O.entryProps(r),
103
104
  item: e,
104
- index: n,
105
+ index: r,
105
106
  newTabLabel: E.newTab,
106
107
  onActivate: t,
107
- onClose: l
108
- }, e.id ?? `m${n}`))
108
+ onClose: n
109
+ }, e.id ?? `m${r}`))
109
110
  });
110
- }, j = ({ item: t, index: n, newTabLabel: r, itemRef: i, subOpen: a, subFocus: o, subRef: s, onToggleSub: c, onBackFromSub: l, onActivate: u, onClose: d, onEnter: f, onLeave: p }) => {
111
- let h = v(), g = v(), _ = y(null), b = m(t), D = b !== "menuitem", k = t.items !== void 0 && t.items.length > 0 ? t.items : null, A = t.href !== void 0 && t.target === "_blank", j = typeof t.label != "string" && t.textValue !== void 0 ? A ? `${t.textValue} ${r}` : t.textValue : void 0, N = (e) => {
112
- _.current = e, i(e);
113
- }, P = {
114
- id: k ? h : void 0,
115
- role: b,
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": n,
118
- "data-menu-id": t.id,
119
- "aria-disabled": t.disabled ? "true" : void 0,
120
- "aria-current": t.current ? "true" : void 0,
121
- "aria-checked": D ? t.checked === !0 : void 0,
122
- "aria-keyshortcuts": t.shortcut,
123
- "aria-describedby": t.description === void 0 ? void 0 : g,
124
- "aria-haspopup": k ? "menu" : void 0,
125
- "aria-expanded": k ? a : void 0,
126
- "aria-label": j,
127
- className: e(O(t), D && "is-checkable", a && "is-open"),
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
- t.disabled ? e.preventDefault() : k ? (e.preventDefault(), c()) : u(t, e);
130
+ n.disabled ? e.preventDefault() : A ? (e.preventDefault(), l()) : d(n, e);
130
131
  },
131
- onMouseEnter: f,
132
- onMouseLeave: p
133
- }, F = /* @__PURE__ */ C(x, { children: [
134
- D && /* @__PURE__ */ S("span", {
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: t.checked === !0 && (b === "menuitemradio" ? /* @__PURE__ */ S(E, {
138
+ children: n.checked === !0 && (x === "menuitemradio" ? /* @__PURE__ */ C(D, {
138
139
  size: 8,
139
140
  fill: "currentColor",
140
141
  strokeWidth: 0
141
- }) : /* @__PURE__ */ S(w, {
142
+ }) : /* @__PURE__ */ C(T, {
142
143
  size: 15,
143
144
  strokeWidth: 2.4
144
145
  }))
145
146
  }),
146
- t.icon,
147
- t.description === void 0 ? t.label : /* @__PURE__ */ C("span", {
147
+ n.icon,
148
+ n.description === void 0 ? n.label : /* @__PURE__ */ w("span", {
148
149
  className: "kapi-ctxmenu__text",
149
- children: [/* @__PURE__ */ S("span", {
150
+ children: [/* @__PURE__ */ C("span", {
150
151
  className: "kapi-ctxmenu__label",
151
- children: t.label
152
- }), /* @__PURE__ */ S("span", {
153
- id: g,
152
+ children: n.label
153
+ }), /* @__PURE__ */ C("span", {
154
+ id: _,
154
155
  className: "kapi-ctxmenu__desc",
155
156
  "aria-hidden": "true",
156
- children: t.description
157
+ children: n.description
157
158
  })]
158
159
  }),
159
- A && j === void 0 && /* @__PURE__ */ C(x, { children: [" ", /* @__PURE__ */ S("span", {
160
+ j && M === void 0 && /* @__PURE__ */ w(S, { children: [" ", /* @__PURE__ */ C("span", {
160
161
  className: "kapi-sr-only",
161
- children: r
162
+ children: i
162
163
  })] }),
163
- t.shortcut !== void 0 && /* @__PURE__ */ S("kbd", {
164
+ n.shortcut !== void 0 && /* @__PURE__ */ C("kbd", {
164
165
  className: "kapi-ctxmenu__kbd",
165
166
  "aria-hidden": "true",
166
- children: t.shortcut
167
+ children: n.shortcut
167
168
  }),
168
- k && /* @__PURE__ */ S(T, {
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
- ] }), I = t.href !== void 0 && !k ? /* @__PURE__ */ S("a", {
175
- ref: N,
176
- ...P,
177
- href: t.disabled ? void 0 : t.href,
178
- target: t.target,
179
- rel: t.rel ?? (A ? "noopener noreferrer" : void 0),
180
- download: t.download,
181
- children: F
182
- }) : /* @__PURE__ */ S("button", {
183
- ref: N,
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
- ...P,
186
- children: F
195
+ ...F,
196
+ children: I
187
197
  });
188
- return k ? /* @__PURE__ */ C("div", {
198
+ return A ? /* @__PURE__ */ w("div", {
189
199
  role: "none",
190
200
  className: "kapi-ctxmenu__subwrap",
191
- children: [I, a && /* @__PURE__ */ S(M, {
192
- items: k,
193
- anchorRef: _,
194
- menuRef: s,
195
- labelledBy: h,
196
- focusRequest: o,
197
- onBack: l,
198
- onActivate: u,
199
- onClose: d
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
- }) : I;
202
- }, M = ({ items: e, anchorRef: t, menuRef: n, labelledBy: r, focusRequest: i, onBack: a, onActivate: o, onClose: s }) => {
203
- let { style: c } = l({
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
- ...D,
217
+ ...O,
208
218
  hideUntilPlaced: !1
209
219
  });
210
- return /* @__PURE__ */ S(A, {
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 { j as MenuEntry, A as MenuList, O as menuItemClass, k as useMenuSubmenus };
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
+ }>;