@kapiuara/ui 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +239 -1
  2. package/dist/components/chat/KapiChatDivider.d.ts +7 -3
  3. package/dist/components/chat/KapiChatDivider.js +6 -6
  4. package/dist/components/chat/KapiChatList.js +19 -19
  5. package/dist/components/chat/KapiChatThread.js +23 -23
  6. package/dist/components/chat/KapiComposer.js +19 -19
  7. package/dist/components/chat/KapiMessageBubble.js +4 -4
  8. package/dist/components/chat/KapiTypingIndicator.js +4 -4
  9. package/dist/components/chat/index.d.ts +1 -1
  10. package/dist/components/closeReason.d.ts +34 -0
  11. package/dist/components/data/KapiBarChart.js +1 -1
  12. package/dist/components/data/KapiDataTable.js +31 -31
  13. package/dist/components/data/KapiEventCalendar.js +78 -78
  14. package/dist/components/data/KapiHeatmap.js +23 -23
  15. package/dist/components/data/KapiLineChart.js +1 -1
  16. package/dist/components/data/KapiPagination.js +4 -4
  17. package/dist/components/data/KapiSparkline.js +1 -1
  18. package/dist/components/data/KapiTable.js +122 -122
  19. package/dist/components/data/KapiTableFilter.js +18 -18
  20. package/dist/components/data/KapiTableRow.js +24 -24
  21. package/dist/components/data/KapiTableToolbar.js +49 -49
  22. package/dist/components/data/chartFrame.js +21 -21
  23. package/dist/components/data/useColumnResize.js +8 -8
  24. package/dist/components/data/useTableSelection.js +8 -8
  25. package/dist/components/display/KapiAnnotation.js +55 -55
  26. package/dist/components/display/KapiComment.js +4 -4
  27. package/dist/components/display/KapiCommentComposer.js +16 -16
  28. package/dist/components/display/KapiFileItem.js +6 -6
  29. package/dist/components/display/KapiFileViewer.js +9 -9
  30. package/dist/components/display/KapiTruncate.js +7 -7
  31. package/dist/components/feedback/KapiAlert.d.ts +2 -1
  32. package/dist/components/feedback/KapiAlert.js +8 -8
  33. package/dist/components/feedback/KapiCountdown.js +8 -8
  34. package/dist/components/feedback/KapiFab.js +30 -30
  35. package/dist/components/feedback/KapiOfflineBanner.js +8 -8
  36. package/dist/components/feedback/KapiToastContainer.js +25 -25
  37. package/dist/components/feedback/KapiTour.d.ts +2 -1
  38. package/dist/components/feedback/KapiTour.js +35 -35
  39. package/dist/components/inputs/KapiAutocomplete.js +14 -14
  40. package/dist/components/inputs/KapiButton.d.ts +17 -1
  41. package/dist/components/inputs/KapiButton.js +41 -25
  42. package/dist/components/inputs/KapiCalendar.js +5 -5
  43. package/dist/components/inputs/KapiCalendarGrid.js +10 -10
  44. package/dist/components/inputs/KapiChecklist.js +71 -71
  45. package/dist/components/inputs/KapiDatePicker.js +124 -122
  46. package/dist/components/inputs/KapiDateRangePicker.js +138 -136
  47. package/dist/components/inputs/KapiFacetedSearch.js +29 -29
  48. package/dist/components/inputs/KapiField.js +14 -14
  49. package/dist/components/inputs/KapiFileUpload.js +27 -27
  50. package/dist/components/inputs/KapiIconButton.d.ts +9 -1
  51. package/dist/components/inputs/KapiIconButton.js +27 -10
  52. package/dist/components/inputs/KapiInput.js +21 -21
  53. package/dist/components/inputs/KapiInputGroup.js +8 -8
  54. package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
  55. package/dist/components/inputs/KapiMaskedInput.js +64 -51
  56. package/dist/components/inputs/KapiNumberStepper.js +29 -29
  57. package/dist/components/inputs/KapiRating.js +61 -59
  58. package/dist/components/inputs/KapiSearchChip.js +8 -8
  59. package/dist/components/inputs/KapiSegmented.js +74 -64
  60. package/dist/components/inputs/KapiSelect.js +232 -222
  61. package/dist/components/inputs/KapiSelectMenu.js +60 -60
  62. package/dist/components/inputs/KapiSlider.js +1 -1
  63. package/dist/components/inputs/KapiSwitch.js +6 -6
  64. package/dist/components/inputs/KapiTagInput.js +83 -81
  65. package/dist/components/inputs/KapiTextarea.js +8 -8
  66. package/dist/components/inputs/misuseWarnings.d.ts +37 -0
  67. package/dist/components/inputs/misuseWarnings.js +36 -0
  68. package/dist/components/inputs/numberStepLogic.d.ts +10 -0
  69. package/dist/components/inputs/numberStepLogic.js +16 -7
  70. package/dist/components/inputs/ownField.js +4 -4
  71. package/dist/components/layout/KapiAccountMenu.d.ts +2 -1
  72. package/dist/components/layout/KapiAccountMenu.js +53 -53
  73. package/dist/components/layout/KapiContextSlot.js +35 -35
  74. package/dist/components/layout/KapiMasonry.js +6 -6
  75. package/dist/components/layout/KapiNotificationBell.js +60 -60
  76. package/dist/components/layout/KapiPageHeader.js +19 -19
  77. package/dist/components/layout/KapiRail.js +60 -60
  78. package/dist/components/layout/KapiRailAccount.js +9 -9
  79. package/dist/components/layout/KapiRoot.js +21 -21
  80. package/dist/components/layout/KapiScrollArea.js +11 -11
  81. package/dist/components/layout/KapiShell.js +12 -12
  82. package/dist/components/locale/KapiLocaleProvider.js +13 -13
  83. package/dist/components/navigation/CtxSlidingList.js +4 -4
  84. package/dist/components/navigation/KapiAccordion.js +12 -12
  85. package/dist/components/navigation/KapiBreadcrumb.js +11 -11
  86. package/dist/components/navigation/KapiCollapsiblePanel.js +23 -23
  87. package/dist/components/navigation/KapiContextPanel.js +76 -76
  88. package/dist/components/navigation/KapiFilterChips.js +9 -9
  89. package/dist/components/navigation/KapiNavBadge.d.ts +4 -2
  90. package/dist/components/navigation/KapiNavBadge.js +11 -10
  91. package/dist/components/navigation/KapiPanelGroup.js +25 -25
  92. package/dist/components/navigation/KapiSteps.js +4 -4
  93. package/dist/components/navigation/KapiTabs.d.ts +4 -1
  94. package/dist/components/navigation/KapiTabs.js +63 -55
  95. package/dist/components/navigation/KapiTree.js +75 -75
  96. package/dist/components/navigation/KapiWizard.d.ts +2 -1
  97. package/dist/components/navigation/KapiWizard.js +30 -30
  98. package/dist/components/overlays/KapiCanvasForm.d.ts +6 -2
  99. package/dist/components/overlays/KapiCanvasForm.js +12 -12
  100. package/dist/components/overlays/KapiCommandPalette.d.ts +2 -1
  101. package/dist/components/overlays/KapiCommandPalette.js +23 -23
  102. package/dist/components/overlays/KapiConfirm.d.ts +2 -1
  103. package/dist/components/overlays/KapiConfirm.js +12 -12
  104. package/dist/components/overlays/KapiContextMenu.d.ts +2 -1
  105. package/dist/components/overlays/KapiContextMenu.js +18 -18
  106. package/dist/components/overlays/KapiDialogHost.js +22 -22
  107. package/dist/components/overlays/KapiLoading.js +16 -16
  108. package/dist/components/overlays/KapiMenuButton.js +15 -15
  109. package/dist/components/overlays/KapiModal.d.ts +2 -1
  110. package/dist/components/overlays/KapiModal.js +28 -28
  111. package/dist/components/overlays/KapiOffcanvas.d.ts +3 -2
  112. package/dist/components/overlays/KapiOffcanvas.js +63 -63
  113. package/dist/components/overlays/KapiOffcanvasStack.js +38 -38
  114. package/dist/components/overlays/KapiPhotoView.js +15 -15
  115. package/dist/components/overlays/KapiPopover.d.ts +2 -1
  116. package/dist/components/overlays/KapiPopover.js +10 -10
  117. package/dist/components/overlays/KapiShapeSheet.js +20 -20
  118. package/dist/components/overlays/KapiSplitModal.js +29 -29
  119. package/dist/components/overlays/KapiTooltip.js +21 -21
  120. package/dist/components/overlays/menuList.js +60 -60
  121. package/dist/components/renderSlot.d.ts +27 -0
  122. package/dist/components/renderSlot.js +23 -0
  123. package/dist/css/components/chat/chat.css +1 -1
  124. package/dist/hooks/portalRoot.js +6 -6
  125. package/dist/hooks/useControllableState.d.ts +6 -2
  126. package/dist/hooks/useControllableState.js +14 -11
  127. package/dist/hooks/useFormReset.d.ts +22 -0
  128. package/dist/hooks/useFormReset.js +17 -0
  129. package/dist/index.d.ts +2 -0
  130. package/dist/kapi.css +1 -1
  131. package/dist/kapi.layered.css +1 -1
  132. package/package.json +5 -2
@@ -3,18 +3,18 @@ import { KapiButton as e } from "../inputs/KapiButton.js";
3
3
  import { useLabels as t } from "../locale/KapiLocaleProvider.js";
4
4
  import { KapiOffcanvas as n } from "./KapiOffcanvas.js";
5
5
  import { runSubmit as r } from "./canvasFormLogic.js";
6
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import { useCallback as s, useEffect as c, useId as l, useRef as u, useState as d } from "react";
6
+ import { useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
7
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
8
  //#region src/components/overlays/KapiCanvasForm.tsx
9
9
  var f = {
10
10
  submit: "Guardar",
11
11
  cancel: "Cancelar"
12
12
  }, p = ({ onClose: p, children: m, onSubmit: h, onError: g, submitLabel: _, cancelLabel: v, submitDisabled: y = !1, formId: b, closeOnBackdrop: x, closeOnEscape: S, ...C }) => {
13
- let w = t("canvasForm", f), T = l(), E = b ?? `canvas-form-${T}`, [D, O] = d(!1), k = u(!1), A = u(!0);
14
- c(() => (A.current = !0, () => {
13
+ let w = t("canvasForm", f), T = o(), E = b ?? `canvas-form-${T}`, [D, O] = c(!1), k = s(!1), A = s(!0);
14
+ a(() => (A.current = !0, () => {
15
15
  A.current = !1;
16
16
  }), []);
17
- let j = s((e) => {
17
+ let j = i((e) => {
18
18
  e.preventDefault(), !k.current && r(() => h(e), {
19
19
  onStart: () => {
20
20
  k.current = !0, O(!0);
@@ -24,13 +24,13 @@ var f = {
24
24
  },
25
25
  onError: g
26
26
  });
27
- }, [h, g]), M = () => {
28
- k.current || p();
29
- }, N = /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a(e, {
30
- onClick: M,
27
+ }, [h, g]), M = (e) => {
28
+ k.current || p(e);
29
+ }, N = /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(e, {
30
+ onClick: () => M("cancel"),
31
31
  disabled: D,
32
32
  children: v ?? w.cancel
33
- }), /* @__PURE__ */ a(e, {
33
+ }), /* @__PURE__ */ u(e, {
34
34
  tone: "primary",
35
35
  type: "submit",
36
36
  form: E,
@@ -38,13 +38,13 @@ var f = {
38
38
  disabled: y,
39
39
  children: _ ?? w.submit
40
40
  })] });
41
- return /* @__PURE__ */ a(n, {
41
+ return /* @__PURE__ */ u(n, {
42
42
  ...C,
43
43
  onClose: M,
44
44
  closeOnBackdrop: !D && x,
45
45
  closeOnEscape: !D && S,
46
46
  footer: N,
47
- children: /* @__PURE__ */ a("form", {
47
+ children: /* @__PURE__ */ u("form", {
48
48
  id: E,
49
49
  className: "kapi-stack",
50
50
  onSubmit: j,
@@ -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
  export type KapiCommand = {
@@ -25,7 +26,7 @@ export type KapiCommandPaletteProps = KapiRootProps<HTMLDialogElement> & {
25
26
  /** Controlado. */
26
27
  open: boolean;
27
28
  /** Pedido de cierre (Esc, click afuera, o después de elegir un comando). */
28
- onClose: () => void;
29
+ onClose: (reason: KapiCloseReason) => void;
29
30
  /** Secciones de comandos, en orden; la búsqueda filtra dentro de cada una. */
30
31
  groups: readonly KapiCommandGroup[];
31
32
  /** Gana sobre `labels.placeholder` ("Buscar o ir a…"). */
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/overlays/KapiCommandPalette.css";
3
- import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as t } from "../rootProps.js";
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 { jsx as d, jsxs as f } from "react/jsx-runtime";
11
- import { useEffect as p, useId as m, useMemo as h, useRef as g, useState as _ } from "react";
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 = e("commandPalette", x, D), N = C ?? M.placeholder, P = w ?? T ?? M.empty, F = E === void 0 ? M.footerHint : E, I = m(), L = `${I}-listbox`, R = (e) => `${I}-opt-${e}`, z = g(null), [B, V] = _(""), [H, U] = _(0), { ref: W, dialogProps: G } = o({ onRequestClose: b }), K = i(W, j), q = a(b), J = h(() => {
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 = h(() => l(J), [J]), X = c(H, Y.length), Z = X >= 0 ? Y[X] : void 0;
30
- p(() => {
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__ */ f("dialog", {
50
+ return $ ? y(/* @__PURE__ */ _("dialog", {
51
51
  ref: K,
52
52
  id: A,
53
53
  style: k,
54
- className: t("kapi-cmdk", O),
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__ */ f("div", {
60
+ /* @__PURE__ */ _("div", {
61
61
  className: "kapi-cmdk__search",
62
- children: [/* @__PURE__ */ d(v, {
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__ */ d("input", {
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__ */ f("div", {
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__ */ f("div", {
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__ */ d("div", {
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__ */ f("div", {
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__ */ d("span", {
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__ */ d("span", {
129
+ /* @__PURE__ */ g("span", {
130
130
  className: "kapi-cmdk__label",
131
131
  children: e.label
132
132
  }),
133
- e.trailing && /* @__PURE__ */ d("span", {
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__ */ d("div", {
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__ */ d("div", {
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__ */ d(S, { ...t }) : null;
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 { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
9
- import { useId as s } from "react";
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 = s(), D = n("confirm", m, _), O = e(l, u, "question"), k = O in p ? O : "question", { Icon: A, button: j } = p[k];
43
- return /* @__PURE__ */ o(r, {
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__ */ o(i, { children: [/* @__PURE__ */ a(t, {
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__ */ a(t, {
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__ */ a("div", {
67
+ /* @__PURE__ */ o("div", {
68
68
  className: `kapi-confirm__icon kapi-confirm__icon--${k}`,
69
- children: /* @__PURE__ */ a(A, {
69
+ children: /* @__PURE__ */ o(A, {
70
70
  size: 28,
71
71
  strokeWidth: 2
72
72
  })
73
73
  }),
74
- /* @__PURE__ */ a("div", {
74
+ /* @__PURE__ */ o("div", {
75
75
  id: E,
76
76
  className: "kapi-confirm__title",
77
77
  children: d
78
78
  }),
79
- f && /* @__PURE__ */ a("div", {
79
+ f && /* @__PURE__ */ o("div", {
80
80
  className: "kapi-confirm__msg",
81
81
  children: f
82
82
  }),
83
- y != null && y !== !1 && /* @__PURE__ */ a("div", {
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,28 +1,28 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/overlays/overlays.css";
3
- import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as t } from "../rootProps.js";
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
- import { useDismiss as r } from "../../hooks/useDismiss.js";
6
+ import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
7
+ import { useDismiss as i } from "../../hooks/useDismiss.js";
7
8
  /* empty css */
8
- import { useMergedRefs as i } from "../../hooks/mergeRefs.js";
9
9
  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 { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
14
- import { useLayoutEffect as f, useRef as p } from "react";
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__ */ u(_, { ...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 = e("contextMenu", m, w), D = p(null), O = i(D, C);
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"
21
21
  });
22
- let k = r(!0, {
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
- f(() => {
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(l, { children: [/* @__PURE__ */ u("div", {
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__ */ u(s, {
55
+ }), /* @__PURE__ */ f(s, {
56
56
  ref: O,
57
57
  id: S,
58
- className: t("kapi-ctxmenu", b),
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 { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
14
- import { useId as p, useRef as m, useState as h, useSyncExternalStore as g } from "react";
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 = p(), s = e(n.tone, n.variant, "info"), c = s in C ? s : "info", l = C[c];
28
- return /* @__PURE__ */ f(a, {
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__ */ d(t, {
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__ */ d("div", {
41
+ /* @__PURE__ */ h("div", {
42
42
  className: `kapi-confirm__icon kapi-confirm__icon--${c}`,
43
- children: /* @__PURE__ */ d(l, {
43
+ children: /* @__PURE__ */ h(l, {
44
44
  size: 28,
45
45
  strokeWidth: 2
46
46
  })
47
47
  }),
48
- /* @__PURE__ */ d("div", {
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__ */ d("div", {
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] = h({
60
+ let r = n("confirm", o), [i, a] = f({
61
61
  busy: !1,
62
62
  error: null
63
- }), l = m(!1);
64
- return /* @__PURE__ */ d(s, {
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 = p(), { ref: i, dialogProps: a } = r();
92
- return x(/* @__PURE__ */ d("dialog", {
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__ */ f("div", {
100
+ children: /* @__PURE__ */ g("div", {
101
101
  className: "kapi-loading",
102
- children: [/* @__PURE__ */ d("span", {
102
+ children: [/* @__PURE__ */ h("span", {
103
103
  className: "kapi-spinner",
104
104
  "aria-hidden": "true"
105
- }), /* @__PURE__ */ d("span", {
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 } = g(t.subscribe, t.getSnapshot, t.getSnapshot), s = i(), c = o && !a ? s : null;
115
- return /* @__PURE__ */ f(u, { children: [
116
- a?.kind === "confirm" && /* @__PURE__ */ d(T, {
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__ */ d(w, {
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__ */ d(E, {
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 { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as t } from "../rootProps.js";
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 { jsx as i, jsxs as a } from "react/jsx-runtime";
8
- import { useId as o } from "react";
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: e, root: r, className: c, style: l, id: u, ref: d }) => {
12
- let f = o(), { ref: p, dialogProps: m } = n();
13
- return s(/* @__PURE__ */ i("dialog", {
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__ */ a("div", {
22
+ children: /* @__PURE__ */ o("div", {
23
23
  ref: d,
24
24
  id: u,
25
- className: t("kapi-loading", c),
25
+ className: e("kapi-loading", c),
26
26
  style: l,
27
- children: [/* @__PURE__ */ i("span", {
27
+ children: [/* @__PURE__ */ a("span", {
28
28
  className: "kapi-spinner",
29
29
  "aria-hidden": "true"
30
- }), /* @__PURE__ */ i("span", {
30
+ }), /* @__PURE__ */ a("span", {
31
31
  id: f,
32
32
  className: "kapi-loading__msg",
33
- children: e
33
+ children: t
34
34
  })]
35
35
  })
36
36
  }), r);
37
- }, u = ({ open: t, message: n, ...a }) => {
38
- let o = e("loading", c), s = r(), u = t ? s : null;
39
- return u ? /* @__PURE__ */ i(l, {
40
- ...a,
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;