@kapiuara/ui 0.14.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 (116) hide show
  1. package/README.md +234 -1
  2. package/dist/components/chat/KapiChatList.js +19 -19
  3. package/dist/components/chat/KapiChatThread.js +23 -23
  4. package/dist/components/chat/KapiComposer.js +19 -19
  5. package/dist/components/chat/KapiMessageBubble.js +4 -4
  6. package/dist/components/chat/KapiTypingIndicator.js +4 -4
  7. package/dist/components/closeReason.d.ts +34 -0
  8. package/dist/components/data/KapiBarChart.js +1 -1
  9. package/dist/components/data/KapiDataTable.js +31 -31
  10. package/dist/components/data/KapiEventCalendar.js +78 -78
  11. package/dist/components/data/KapiHeatmap.js +23 -23
  12. package/dist/components/data/KapiLineChart.js +1 -1
  13. package/dist/components/data/KapiPagination.js +4 -4
  14. package/dist/components/data/KapiSparkline.js +1 -1
  15. package/dist/components/data/KapiTable.js +122 -122
  16. package/dist/components/data/KapiTableFilter.js +18 -18
  17. package/dist/components/data/KapiTableRow.js +24 -24
  18. package/dist/components/data/KapiTableToolbar.js +49 -49
  19. package/dist/components/data/chartFrame.js +21 -21
  20. package/dist/components/data/useColumnResize.js +8 -8
  21. package/dist/components/data/useTableSelection.js +8 -8
  22. package/dist/components/display/KapiAnnotation.js +53 -53
  23. package/dist/components/display/KapiComment.js +4 -4
  24. package/dist/components/display/KapiCommentComposer.js +16 -16
  25. package/dist/components/display/KapiFileItem.js +6 -6
  26. package/dist/components/display/KapiFileViewer.js +9 -9
  27. package/dist/components/display/KapiTruncate.js +7 -7
  28. package/dist/components/feedback/KapiAlert.d.ts +2 -1
  29. package/dist/components/feedback/KapiAlert.js +8 -8
  30. package/dist/components/feedback/KapiCountdown.js +8 -8
  31. package/dist/components/feedback/KapiFab.js +31 -31
  32. package/dist/components/feedback/KapiOfflineBanner.js +8 -8
  33. package/dist/components/feedback/KapiToastContainer.js +21 -21
  34. package/dist/components/feedback/KapiTour.d.ts +2 -1
  35. package/dist/components/feedback/KapiTour.js +32 -32
  36. package/dist/components/inputs/KapiAutocomplete.js +14 -14
  37. package/dist/components/inputs/KapiButton.d.ts +17 -1
  38. package/dist/components/inputs/KapiButton.js +41 -25
  39. package/dist/components/inputs/KapiCalendar.js +5 -5
  40. package/dist/components/inputs/KapiCalendarGrid.js +10 -10
  41. package/dist/components/inputs/KapiChecklist.js +71 -71
  42. package/dist/components/inputs/KapiDatePicker.js +28 -28
  43. package/dist/components/inputs/KapiDateRangePicker.js +27 -27
  44. package/dist/components/inputs/KapiFacetedSearch.js +24 -24
  45. package/dist/components/inputs/KapiField.js +14 -14
  46. package/dist/components/inputs/KapiFileUpload.js +27 -27
  47. package/dist/components/inputs/KapiIconButton.d.ts +9 -1
  48. package/dist/components/inputs/KapiIconButton.js +27 -10
  49. package/dist/components/inputs/KapiInput.js +21 -21
  50. package/dist/components/inputs/KapiInputGroup.js +8 -8
  51. package/dist/components/inputs/KapiMaskedInput.js +22 -22
  52. package/dist/components/inputs/KapiNumberStepper.js +12 -12
  53. package/dist/components/inputs/KapiRating.js +1 -1
  54. package/dist/components/inputs/KapiSearchChip.js +8 -8
  55. package/dist/components/inputs/KapiSegmented.js +27 -27
  56. package/dist/components/inputs/KapiSelect.js +166 -166
  57. package/dist/components/inputs/KapiSelectMenu.js +60 -60
  58. package/dist/components/inputs/KapiSlider.js +1 -1
  59. package/dist/components/inputs/KapiSwitch.js +6 -6
  60. package/dist/components/inputs/KapiTagInput.js +22 -22
  61. package/dist/components/inputs/KapiTextarea.js +8 -8
  62. package/dist/components/inputs/ownField.js +4 -4
  63. package/dist/components/layout/KapiAccountMenu.d.ts +2 -1
  64. package/dist/components/layout/KapiAccountMenu.js +51 -51
  65. package/dist/components/layout/KapiContextSlot.js +35 -35
  66. package/dist/components/layout/KapiMasonry.js +6 -6
  67. package/dist/components/layout/KapiNotificationBell.js +60 -60
  68. package/dist/components/layout/KapiPageHeader.js +19 -19
  69. package/dist/components/layout/KapiRail.js +60 -60
  70. package/dist/components/layout/KapiRailAccount.js +9 -9
  71. package/dist/components/layout/KapiRoot.js +21 -21
  72. package/dist/components/layout/KapiScrollArea.js +11 -11
  73. package/dist/components/layout/KapiShell.js +12 -12
  74. package/dist/components/locale/KapiLocaleProvider.js +13 -13
  75. package/dist/components/navigation/KapiAccordion.js +12 -12
  76. package/dist/components/navigation/KapiBreadcrumb.js +11 -11
  77. package/dist/components/navigation/KapiCollapsiblePanel.js +23 -23
  78. package/dist/components/navigation/KapiContextPanel.js +76 -76
  79. package/dist/components/navigation/KapiFilterChips.js +9 -9
  80. package/dist/components/navigation/KapiNavBadge.d.ts +4 -2
  81. package/dist/components/navigation/KapiNavBadge.js +11 -10
  82. package/dist/components/navigation/KapiPanelGroup.js +25 -25
  83. package/dist/components/navigation/KapiSteps.js +4 -4
  84. package/dist/components/navigation/KapiTabs.d.ts +4 -1
  85. package/dist/components/navigation/KapiTabs.js +18 -17
  86. package/dist/components/navigation/KapiTree.js +72 -72
  87. package/dist/components/navigation/KapiWizard.d.ts +2 -1
  88. package/dist/components/navigation/KapiWizard.js +30 -30
  89. package/dist/components/overlays/KapiCanvasForm.d.ts +6 -2
  90. package/dist/components/overlays/KapiCanvasForm.js +12 -12
  91. package/dist/components/overlays/KapiCommandPalette.d.ts +2 -1
  92. package/dist/components/overlays/KapiCommandPalette.js +23 -23
  93. package/dist/components/overlays/KapiConfirm.d.ts +2 -1
  94. package/dist/components/overlays/KapiConfirm.js +12 -12
  95. package/dist/components/overlays/KapiContextMenu.d.ts +2 -1
  96. package/dist/components/overlays/KapiContextMenu.js +15 -15
  97. package/dist/components/overlays/KapiDialogHost.js +22 -22
  98. package/dist/components/overlays/KapiLoading.js +16 -16
  99. package/dist/components/overlays/KapiMenuButton.js +12 -12
  100. package/dist/components/overlays/KapiModal.d.ts +2 -1
  101. package/dist/components/overlays/KapiModal.js +28 -28
  102. package/dist/components/overlays/KapiOffcanvas.d.ts +3 -2
  103. package/dist/components/overlays/KapiOffcanvas.js +63 -63
  104. package/dist/components/overlays/KapiOffcanvasStack.js +38 -38
  105. package/dist/components/overlays/KapiPhotoView.js +14 -14
  106. package/dist/components/overlays/KapiPopover.d.ts +2 -1
  107. package/dist/components/overlays/KapiPopover.js +7 -7
  108. package/dist/components/overlays/KapiShapeSheet.js +17 -17
  109. package/dist/components/overlays/KapiSplitModal.js +29 -29
  110. package/dist/components/overlays/KapiTooltip.js +20 -20
  111. package/dist/components/overlays/menuList.js +60 -60
  112. package/dist/components/renderSlot.d.ts +27 -0
  113. package/dist/components/renderSlot.js +23 -0
  114. package/dist/hooks/portalRoot.js +6 -6
  115. package/dist/index.d.ts +2 -0
  116. package/package.json +1 -1
@@ -6,28 +6,28 @@ import { prefersReducedMotion as n } from "../../hooks/reducedMotion.js";
6
6
  import { dialogNameProps as r, modalClasses as i, resolveDismiss as a } from "./dialogUtils.js";
7
7
  import { useExitPresence as o } from "./useExitPresence.js";
8
8
  import { originWithinCard as s } from "../../hooks/growOriginLogic.js";
9
- import { useBackdropClose as c, useNativeDialog as l, usePortalRoot as u, useTrappedDialogWarning as d } from "./useNativeDialog.js";
9
+ import { useBackdropClose as ee, useNativeDialog as c, usePortalRoot as l, useTrappedDialogWarning as u } from "./useNativeDialog.js";
10
10
  /* empty css */
11
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
- import { useId as m, useLayoutEffect as h, useRef as g, useState as _ } from "react";
13
- import { X as v } from "lucide-react";
14
- import { createPortal as y } from "react-dom";
11
+ import { useId as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
12
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
+ import { X as _ } from "lucide-react";
14
+ import { createPortal as v } from "react-dom";
15
15
  //#region src/components/overlays/KapiModal.tsx
16
- var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
17
- let n = g(null), { present: r, closing: i } = o(e, n);
18
- return r ? /* @__PURE__ */ f(S, {
16
+ var y = { close: "Cerrar" }, b = ({ open: e, ...t }) => {
17
+ let n = p(null), { present: r, closing: i } = o(e, n);
18
+ return r ? /* @__PURE__ */ h(S, {
19
19
  ...t,
20
20
  dialogRef: n,
21
21
  closing: i
22
22
  }) : null;
23
- }, ee = () => {}, S = ({ title: o, subtitle: x, 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 ? ee : S, H = m(), U = e("modal", b, F), W = P ?? U.close, G = g(null), K = t(G, k), [q, J] = _(null), Y = a({
23
+ }, x = () => {}, S = ({ title: o, subtitle: b, onClose: S, children: C, footer: w, size: T = "md", hideHeader: E = !1, className: te = "", style: D, id: O, ref: k, closeOnBackdrop: A, closeOnEscape: j, closeButton: M, dismissible: N, closeLabel: P, labels: F, "aria-label": I, "aria-labelledby": L, growFrom: R, dialogRef: z, closing: B }) => {
24
+ let V = B ? x : S, H = d(), U = e("modal", y, F), W = P ?? U.close, G = p(null), K = t(G, k), [q, J] = m(null), Y = a({
25
25
  dismissible: N,
26
26
  closeOnEscape: j,
27
27
  closeOnBackdrop: A,
28
28
  closeButton: M
29
- }), { closeOnEscape: X, closeOnBackdrop: Z, closeButton: Q } = Y, { ref: ne, dialogProps: re } = l({ onRequestClose: X ? V : void 0 }), ie = c(Z ? V : void 0);
30
- d("KapiModal", Y, G), h(() => {
29
+ }), { closeOnEscape: X, closeOnBackdrop: Z, closeButton: Q } = Y, { ref: ne, dialogProps: re } = c({ onRequestClose: X ? () => V("escape") : void 0 }), ie = ee(Z ? () => V("backdrop") : void 0);
30
+ u("KapiModal", Y, G), f(() => {
31
31
  let e = G.current;
32
32
  if (!R || !e || n(e)) {
33
33
  J(null);
@@ -41,8 +41,8 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
41
41
  height: i
42
42
  }));
43
43
  }, [R]);
44
- let $ = u();
45
- return $ ? y(/* @__PURE__ */ f("dialog", {
44
+ let $ = l();
45
+ return $ ? v(/* @__PURE__ */ h("dialog", {
46
46
  ref: (e) => {
47
47
  ne.current = e, z.current = e;
48
48
  },
@@ -58,7 +58,7 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
58
58
  }),
59
59
  ...re,
60
60
  ...ie,
61
- children: /* @__PURE__ */ p("div", {
61
+ children: /* @__PURE__ */ g("div", {
62
62
  ref: K,
63
63
  id: O,
64
64
  className: `${i(T, te)}${q ? " kapi-modal--grow" : ""}`,
@@ -68,40 +68,40 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
68
68
  "--kapi-grow-y": `${q.y}px`
69
69
  } : D,
70
70
  children: [
71
- E ? Q && /* @__PURE__ */ f("button", {
71
+ E ? Q && /* @__PURE__ */ h("button", {
72
72
  type: "button",
73
73
  className: "kapi-modal__x kapi-modal__x--float",
74
- onClick: V,
74
+ onClick: () => V("close-button"),
75
75
  "aria-label": W,
76
- children: /* @__PURE__ */ f(v, {
76
+ children: /* @__PURE__ */ h(_, {
77
77
  size: 17,
78
78
  strokeWidth: 2.2
79
79
  })
80
- }) : /* @__PURE__ */ p("div", {
80
+ }) : /* @__PURE__ */ g("div", {
81
81
  className: "kapi-modal__head",
82
- children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("div", {
82
+ children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("div", {
83
83
  id: H,
84
84
  className: "kapi-modal__title",
85
85
  children: o
86
- }), x && /* @__PURE__ */ f("div", {
86
+ }), b && /* @__PURE__ */ h("div", {
87
87
  className: "kapi-modal__sub",
88
- children: x
89
- })] }), Q && /* @__PURE__ */ f("button", {
88
+ children: b
89
+ })] }), Q && /* @__PURE__ */ h("button", {
90
90
  type: "button",
91
91
  className: "kapi-modal__x",
92
- onClick: V,
92
+ onClick: () => V("close-button"),
93
93
  "aria-label": W,
94
- children: /* @__PURE__ */ f(v, {
94
+ children: /* @__PURE__ */ h(_, {
95
95
  size: 17,
96
96
  strokeWidth: 2.2
97
97
  })
98
98
  })]
99
99
  }),
100
- /* @__PURE__ */ f("div", {
100
+ /* @__PURE__ */ h("div", {
101
101
  className: "kapi-modal__body",
102
102
  children: C
103
103
  }),
104
- w && /* @__PURE__ */ f("div", {
104
+ w && /* @__PURE__ */ h("div", {
105
105
  className: "kapi-modal__foot",
106
106
  children: w
107
107
  })
@@ -110,4 +110,4 @@ var b = { close: "Cerrar" }, x = ({ open: e, ...t }) => {
110
110
  }), $) : null;
111
111
  };
112
112
  //#endregion
113
- export { b as DEFAULT_MODAL_LABELS, x as KapiModal };
113
+ export { y as DEFAULT_MODAL_LABELS, b as KapiModal };
@@ -1,4 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
+ import type { KapiCloseReason } from "../closeReason.js";
2
3
  import { type KapiOffcanvasSide } from "./offcanvasSide.js";
3
4
  import { type KapiRootProps } from "../rootProps.js";
4
5
  import type { KapiLabelsOverride } from "../labelsLogic.js";
@@ -31,8 +32,8 @@ export declare const DEFAULT_OFFCANVAS_LABELS: KapiOffcanvasLabels;
31
32
  export type KapiOffcanvasProps = KapiRootProps<HTMLDialogElement> & {
32
33
  /** Controlado. Al pasar a false corre la animación de salida y recién después se desmonta. */
33
34
  open: boolean;
34
- /** Pedido de cierre (X, click en el fondo, Escape). El padre pone `open={false}`. */
35
- onClose: () => void;
35
+ /** Pedido de cierre: `reason` dice si fue la X, el fondo o Escape. El padre pone `open={false}`. */
36
+ onClose: (reason: KapiCloseReason) => void;
36
37
  /** Título del header del panel (también nombra al diálogo). */
37
38
  title: ReactNode;
38
39
  /** Texto secundario bajo el título. */
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/overlays/KapiOffcanvas.css";
3
- import { useKapiDir as e, useLabels as t } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as n } from "../rootProps.js";
5
- import { computedStyleOf as ee, winOf as r } from "../../hooks/ownerDocument.js";
6
- import { resolveDirection as i } from "../../hooks/directionLogic.js";
7
- import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
8
- import { maxTransitionMs as o, resolveDismiss as s } from "./dialogUtils.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { useKapiDir as t, useLabels as n } from "../locale/KapiLocaleProvider.js";
5
+ import { computedStyleOf as r, winOf as i } from "../../hooks/ownerDocument.js";
6
+ import { resolveDirection as a } from "../../hooks/directionLogic.js";
7
+ import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
8
+ import { maxTransitionMs as ee, resolveDismiss as s } from "./dialogUtils.js";
9
9
  import { useExitPresence as c } from "./useExitPresence.js";
10
10
  import { useBackdropClose as l, useNativeDialog as u, usePortalRoot as d, useTrappedDialogWarning as f } from "./useNativeDialog.js";
11
11
  import { DEFAULT_PUSH_RATIO as te, depthOf as ne, levelOf as re, offcanvasStackStore as p, phaseReducer as m, pushTransform as ie } from "./offcanvasStack.js";
@@ -13,16 +13,16 @@ import { normalizeSide as ae, pushForSide as oe, resolveOffcanvasSide as h, side
13
13
  import { companionDockClasses as le, isCompanionActive as ue, resolveCompanionOrder as de, resolveCompanionWidth as fe, supportsCompanion as pe } from "./offcanvasCompanion.js";
14
14
  import { resolveInitialWidth as me, resolveMaxWidth as g, stepOffcanvasWidth as he, widthFromDrag as ge } from "./offcanvasResize.js";
15
15
  /* empty css */
16
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
17
- import { useEffect as _e, useId as y, useLayoutEffect as b, useReducer as x, useRef as S, useState as ve, useSyncExternalStore as ye } from "react";
16
+ import { useEffect as _e, useId as _, useLayoutEffect as v, useReducer as ve, useRef as y, useState as b, useSyncExternalStore as ye } from "react";
17
+ import { jsx as x, jsxs as S } from "react/jsx-runtime";
18
18
  import { X as C } from "lucide-react";
19
19
  import { createPortal as w } from "react-dom";
20
20
  var be = 120, T = {
21
21
  resize: "Redimensionar panel",
22
22
  close: "Cerrar",
23
23
  closePanel: "Cerrar panel"
24
- }, E = ({ textDir: e, stackId: i, phase: d, onEntered: m, onExited: h, onClose: x, title: w, subtitle: E, children: D, footer: O, side: xe, width: k = 520, height: Se, pushRatio: Ce = te, pushOffset: we = 16, closeOnBackdrop: Te, closeOnEscape: Ee, closeButton: De, dismissible: Oe, closeLabel: ke, labels: Ae, className: je, style: Me, id: Ne, ref: Pe, companion: A, resizable: Fe = !1, minWidth: j = 320, maxWidth: M, onResize: Ie }) => {
25
- let N = t("offcanvas", T, Ae), Le = ke ?? N.close, P = y(), F = y(), I = ae(xe), L = S(null), R = ye(p.subscribe, p.getSnapshot, p.getServerSnapshot), z = ne(R, i), Re = Math.max(0, re(R, i)), { scale: ze, translateX: Be } = oe(I, ie(z, Ce, we)), [B, Ve] = ve(() => me(k, 520)), [He, V] = ve(!1), H = S(null), U = S(Ie);
24
+ }, E = ({ textDir: t, stackId: a, phase: d, onEntered: m, onExited: h, onClose: ve, title: w, subtitle: E, children: D, footer: O, side: xe, width: k = 520, height: Se, pushRatio: Ce = te, pushOffset: we = 16, closeOnBackdrop: Te, closeOnEscape: Ee, closeButton: De, dismissible: Oe, closeLabel: ke, labels: Ae, className: je, style: Me, id: Ne, ref: Pe, companion: A, resizable: Fe = !1, minWidth: j = 320, maxWidth: M, onResize: Ie }) => {
25
+ let N = n("offcanvas", T, Ae), Le = ke ?? N.close, P = _(), F = _(), I = ae(xe), L = y(null), R = ye(p.subscribe, p.getSnapshot, p.getServerSnapshot), z = ne(R, a), Re = Math.max(0, re(R, a)), { scale: ze, translateX: Be } = oe(I, ie(z, Ce, we)), [B, Ve] = b(() => me(k, 520)), [He, V] = b(!1), H = y(null), U = y(Ie);
26
26
  U.current = Ie;
27
27
  let W = (e) => {
28
28
  Ve(e), e !== B && U.current?.(e);
@@ -36,31 +36,31 @@ var be = 120, T = {
36
36
  }, We = (e) => {
37
37
  let t = H.current;
38
38
  if (!t) return;
39
- let n = g(M, (r(L.current) ?? window).innerWidth);
39
+ let n = g(M, (i(L.current) ?? window).innerWidth);
40
40
  W(ge(I, t.startWidth, t.startX, e.clientX, j, n));
41
41
  }, G = (e) => {
42
42
  H.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), V(!1);
43
43
  }, Ge = (e) => {
44
- let t = g(M, (r(L.current) ?? window).innerWidth), n = he(I, B, e.key, j, t);
44
+ let t = g(M, (i(L.current) ?? window).innerWidth), n = he(I, B, e.key, j, t);
45
45
  n !== null && (e.preventDefault(), e.stopPropagation(), W(n));
46
- }, K = d === "open" ? x : void 0, q = s({
46
+ }, K = d === "open" ? ve : void 0, q = s({
47
47
  dismissible: Oe,
48
48
  closeOnEscape: Ee,
49
49
  closeOnBackdrop: Te,
50
50
  closeButton: De
51
- }), { closeOnEscape: Ke, closeOnBackdrop: qe, closeButton: Je } = q, { ref: J, dialogProps: Ye } = u({ onRequestClose: Ke ? K : void 0 }), Xe = a(J, Pe), Ze = l(qe ? K : void 0);
52
- f("KapiOffcanvas", q, J), b(() => (p.dispatch({
51
+ }), { closeOnEscape: Ke, closeOnBackdrop: qe, closeButton: Je } = q, { ref: J, dialogProps: Ye } = u({ onRequestClose: Ke ? () => K?.("escape") : void 0 }), Xe = o(J, Pe), Ze = l(qe ? () => K?.("backdrop") : void 0);
52
+ f("KapiOffcanvas", q, J), v(() => (p.dispatch({
53
53
  type: "add",
54
- id: i
54
+ id: a
55
55
  }), () => p.dispatch({
56
56
  type: "remove",
57
- id: i
58
- })), [i]);
59
- let Y = S(m);
60
- Y.current = m, b(() => {
57
+ id: a
58
+ })), [a]);
59
+ let Y = y(m);
60
+ Y.current = m, v(() => {
61
61
  L.current?.getBoundingClientRect(), Y.current();
62
62
  }, []);
63
- let X = S(h);
63
+ let X = y(h);
64
64
  X.current = h, _e(() => {
65
65
  if (d !== "exit") return;
66
66
  let e = L.current;
@@ -68,20 +68,20 @@ var be = 120, T = {
68
68
  X.current();
69
69
  return;
70
70
  }
71
- let t = ee(e), n = o(t.transitionDuration, t.transitionDelay);
71
+ let t = r(e), n = ee(t.transitionDuration, t.transitionDelay);
72
72
  if (n <= 0) {
73
73
  X.current();
74
74
  return;
75
75
  }
76
- let r = !1, i = () => {
77
- r || (r = !0, X.current());
78
- }, a = (t) => {
79
- t.target === e && t.propertyName === "transform" && i();
76
+ let i = !1, a = () => {
77
+ i || (i = !0, X.current());
78
+ }, o = (t) => {
79
+ t.target === e && t.propertyName === "transform" && a();
80
80
  };
81
- e.addEventListener("transitionend", a);
82
- let s = window.setTimeout(i, n + be);
81
+ e.addEventListener("transitionend", o);
82
+ let s = window.setTimeout(a, n + be);
83
83
  return () => {
84
- r = !0, e.removeEventListener("transitionend", a), window.clearTimeout(s);
84
+ i = !0, e.removeEventListener("transitionend", o), window.clearTimeout(s);
85
85
  };
86
86
  }, [d]);
87
87
  let Z = Fe && (I === "left" || I === "right"), Q = ce(I, k, Se, "520px");
@@ -91,14 +91,14 @@ var be = 120, T = {
91
91
  [Q.name]: Q.value,
92
92
  "--kapi-offc-push-x": `${Be}px`,
93
93
  "--kapi-offc-push-s": ze
94
- }, $e = ue(I, A), et = S(null), { present: tt, closing: nt } = c($e, et), rt = S(A);
94
+ }, $e = ue(I, A), et = y(null), { present: tt, closing: nt } = c($e, et), rt = y(A);
95
95
  A && (rt.current = A);
96
- let $ = A ?? rt.current, it = tt && pe(I) && $ !== void 0, at = e === "rtl", ot = at ? { dir: "rtl" } : {}, st = /* @__PURE__ */ v("div", {
96
+ let $ = A ?? rt.current, it = tt && pe(I) && $ !== void 0, at = t === "rtl", ot = at ? { dir: "rtl" } : {}, st = /* @__PURE__ */ S("div", {
97
97
  ref: L,
98
98
  className: "kapi-offc__panel",
99
99
  ...ot,
100
100
  children: [
101
- Z && /* @__PURE__ */ _("div", {
101
+ Z && /* @__PURE__ */ x("div", {
102
102
  className: "kapi-offc__resize",
103
103
  role: "separator",
104
104
  "aria-orientation": "vertical",
@@ -113,36 +113,36 @@ var be = 120, T = {
113
113
  onPointerCancel: G,
114
114
  onKeyDown: Ge
115
115
  }),
116
- /* @__PURE__ */ v("div", {
116
+ /* @__PURE__ */ S("div", {
117
117
  className: "kapi-offc__head",
118
- children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("div", {
118
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
119
119
  id: P,
120
120
  className: "kapi-modal__title",
121
121
  children: w
122
- }), E && /* @__PURE__ */ _("div", {
122
+ }), E && /* @__PURE__ */ x("div", {
123
123
  className: "kapi-modal__sub",
124
124
  children: E
125
- })] }), Je && /* @__PURE__ */ _("button", {
125
+ })] }), Je && /* @__PURE__ */ x("button", {
126
126
  type: "button",
127
127
  className: "kapi-modal__x",
128
- onClick: K,
128
+ onClick: () => K?.("close-button"),
129
129
  "aria-label": Le,
130
- children: /* @__PURE__ */ _(C, {
130
+ children: /* @__PURE__ */ x(C, {
131
131
  size: 17,
132
132
  strokeWidth: 2.2
133
133
  })
134
134
  })]
135
135
  }),
136
- /* @__PURE__ */ _("div", {
136
+ /* @__PURE__ */ x("div", {
137
137
  className: "kapi-offc__body",
138
138
  children: D
139
139
  }),
140
- O && /* @__PURE__ */ _("div", {
140
+ O && /* @__PURE__ */ x("div", {
141
141
  className: "kapi-offc__foot",
142
142
  children: O
143
143
  })
144
144
  ]
145
- }, "main"), ct = $ && it ? /* @__PURE__ */ v("div", {
145
+ }, "main"), ct = $ && it ? /* @__PURE__ */ S("div", {
146
146
  ref: et,
147
147
  "data-closing": nt || void 0,
148
148
  inert: nt || void 0,
@@ -152,40 +152,40 @@ var be = 120, T = {
152
152
  "aria-labelledby": $.title ? F : void 0,
153
153
  style: { "--kapi-offc-companion-w": fe($.width) },
154
154
  children: [
155
- ($.title || $.onClose) && /* @__PURE__ */ v("div", {
155
+ ($.title || $.onClose) && /* @__PURE__ */ S("div", {
156
156
  className: "kapi-offc__head",
157
- children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("div", {
157
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
158
158
  id: F,
159
159
  className: "kapi-modal__title",
160
160
  children: $.title
161
- }), $.subtitle && /* @__PURE__ */ _("div", {
161
+ }), $.subtitle && /* @__PURE__ */ x("div", {
162
162
  className: "kapi-modal__sub",
163
163
  children: $.subtitle
164
- })] }), $.onClose && /* @__PURE__ */ _("button", {
164
+ })] }), $.onClose && /* @__PURE__ */ x("button", {
165
165
  type: "button",
166
166
  className: "kapi-modal__x",
167
167
  onClick: $.onClose,
168
168
  "aria-label": $.closeLabel ?? N.closePanel,
169
- children: /* @__PURE__ */ _(C, {
169
+ children: /* @__PURE__ */ x(C, {
170
170
  size: 17,
171
171
  strokeWidth: 2.2
172
172
  })
173
173
  })]
174
174
  }),
175
- /* @__PURE__ */ _("div", {
175
+ /* @__PURE__ */ x("div", {
176
176
  className: "kapi-offc__body",
177
177
  children: $.children
178
178
  }),
179
- $.footer && /* @__PURE__ */ _("div", {
179
+ $.footer && /* @__PURE__ */ x("div", {
180
180
  className: "kapi-offc__foot",
181
181
  children: $.footer
182
182
  })
183
183
  ]
184
184
  }, "companion") : null, lt = de(I).map((e) => e === "main" ? st : ct).filter((e) => e !== null);
185
- return /* @__PURE__ */ _("dialog", {
185
+ return /* @__PURE__ */ x("dialog", {
186
186
  ref: Xe,
187
187
  id: Ne,
188
- className: n("kapi-offc", He && "is-resizing", je),
188
+ className: e("kapi-offc", He && "is-resizing", je),
189
189
  "data-side": se(I),
190
190
  "data-state": d === "open" ? "open" : "closed",
191
191
  "data-level": Re,
@@ -196,30 +196,30 @@ var be = 120, T = {
196
196
  style: Qe,
197
197
  ...Ye,
198
198
  ...Ze,
199
- children: /* @__PURE__ */ _("div", {
199
+ children: /* @__PURE__ */ x("div", {
200
200
  className: le(it),
201
201
  children: lt
202
202
  })
203
203
  });
204
- }, D = ({ open: t, onExited: n, side: ee, ...r }) => {
205
- let a = y(), o = e(), [s, c] = x(m, "unmounted"), l = S(n);
206
- l.current = n, b(() => {
207
- c(t ? "open" : "close");
208
- }, [t]), b(() => {
204
+ }, D = ({ open: e, onExited: n, side: r, ...i }) => {
205
+ let o = _(), ee = t(), [s, c] = ve(m, "unmounted"), l = y(n);
206
+ l.current = n, v(() => {
207
+ c(e ? "open" : "close");
208
+ }, [e]), v(() => {
209
209
  (s === "exit" || s === "open") && p.dispatch({
210
210
  type: "mark",
211
- id: a,
211
+ id: o,
212
212
  state: s === "exit" ? "closing" : "open"
213
213
  });
214
- }, [s, a]);
214
+ }, [s, o]);
215
215
  let u = d();
216
216
  if (s === "unmounted" || !u) return null;
217
- let f = i(u, o);
218
- return w(/* @__PURE__ */ _(E, {
219
- ...r,
217
+ let f = a(u, ee);
218
+ return w(/* @__PURE__ */ x(E, {
219
+ ...i,
220
220
  textDir: f,
221
- side: h(ee, f),
222
- stackId: a,
221
+ side: h(r, f),
222
+ stackId: o,
223
223
  phase: s,
224
224
  onEntered: () => c("entered"),
225
225
  onExited: () => {
@@ -1,65 +1,65 @@
1
1
  "use client";
2
2
  import { panelsReducer as e, topOpenId as t } from "./offcanvasStack.js";
3
3
  import { KapiOffcanvas as n } from "./KapiOffcanvas.js";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
- import { createContext as a, useCallback as o, useContext as s, useLayoutEffect as c, useMemo as l, useReducer as u, useRef as d } from "react";
4
+ import { createContext as r, useCallback as i, useContext as a, useLayoutEffect as o, useMemo as s, useReducer as c, useRef as l } from "react";
5
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
6
6
  //#region src/components/overlays/KapiOffcanvasStack.tsx
7
- var f = a(null), p = a(null), m = (t, n) => e(t, n), h = ({ entry: e, level: t, close: i, push: a, dispatch: o }) => {
8
- let { id: s } = e, c = l(() => ({
9
- id: s,
7
+ var f = r(null), p = r(null), m = (t, n) => e(t, n), h = ({ entry: e, level: t, close: r, push: i, dispatch: a }) => {
8
+ let { id: o } = e, c = s(() => ({
9
+ id: o,
10
10
  level: t,
11
- close: () => i(s),
12
- push: a
11
+ close: () => r(o),
12
+ push: i
13
13
  }), [
14
- s,
14
+ o,
15
15
  t,
16
- i,
17
- a
18
- ]), { content: u, beforeClose: d, onClose: f, onExited: m, ...h } = e.config;
19
- return /* @__PURE__ */ r(p.Provider, {
16
+ r,
17
+ i
18
+ ]), { content: l, beforeClose: d, onClose: f, onExited: m, ...h } = e.config;
19
+ return /* @__PURE__ */ u(p.Provider, {
20
20
  value: c,
21
- children: /* @__PURE__ */ r(n, {
21
+ children: /* @__PURE__ */ u(n, {
22
22
  ...h,
23
23
  open: e.open,
24
24
  onClose: c.close,
25
25
  onExited: () => {
26
- o({
26
+ a({
27
27
  type: "remove",
28
- id: s
28
+ id: o
29
29
  }), m?.();
30
30
  },
31
- children: typeof u == "function" ? u(c) : u
31
+ children: typeof l == "function" ? l(c) : l
32
32
  })
33
33
  });
34
34
  }, g = ({ children: e }) => {
35
- let [n, a] = u(m, []), s = d(n);
36
- c(() => {
37
- s.current = n;
35
+ let [n, r] = c(m, []), a = l(n);
36
+ o(() => {
37
+ a.current = n;
38
38
  });
39
- let p = d(0), g = o((e) => {
39
+ let p = l(0), g = i((e) => {
40
40
  p.current += 1;
41
41
  let t = `kapi-offc-${p.current}`;
42
- return a({
42
+ return r({
43
43
  type: "push",
44
44
  id: t,
45
45
  config: e
46
46
  }), t;
47
- }, []), _ = o((e) => {
48
- let n = s.current, r = e ?? t(n), i = n.findIndex((e) => e.id === r);
49
- if (i < 0 || !n[i]?.open) return;
50
- let o = n.filter((e, t) => t >= i && e.open);
51
- for (let e = o.length - 1; e >= 0; --e) if (o[e]?.config.beforeClose?.() === !1) return;
52
- a({
47
+ }, []), _ = i((e) => {
48
+ let n = a.current, i = e ?? t(n), o = n.findIndex((e) => e.id === i);
49
+ if (o < 0 || !n[o]?.open) return;
50
+ let s = n.filter((e, t) => t >= o && e.open);
51
+ for (let e = s.length - 1; e >= 0; --e) if (s[e]?.config.beforeClose?.() === !1) return;
52
+ r({
53
53
  type: "close",
54
- id: n[i].id
55
- }), o.forEach((e) => e.config.onClose?.());
56
- }, []), v = o(() => {
57
- let e = s.current.filter((e) => e.open);
54
+ id: n[o].id
55
+ }), s.forEach((e) => e.config.onClose?.());
56
+ }, []), v = i(() => {
57
+ let e = a.current.filter((e) => e.open);
58
58
  if (e.length !== 0) {
59
59
  for (let t = e.length - 1; t >= 0; --t) if (e[t]?.config.beforeClose?.() === !1) return;
60
- a({ type: "closeAll" }), e.forEach((e) => e.config.onClose?.());
60
+ r({ type: "closeAll" }), e.forEach((e) => e.config.onClose?.());
61
61
  }
62
- }, []), y = o(() => _(), [_]), b = n.filter((e) => e.open).length, x = l(() => ({
62
+ }, []), y = i(() => _(), [_]), b = n.filter((e) => e.open).length, x = s(() => ({
63
63
  push: g,
64
64
  close: _,
65
65
  pop: y,
@@ -72,22 +72,22 @@ var f = a(null), p = a(null), m = (t, n) => e(t, n), h = ({ entry: e, level: t,
72
72
  v,
73
73
  b
74
74
  ]);
75
- return /* @__PURE__ */ i(f.Provider, {
75
+ return /* @__PURE__ */ d(f.Provider, {
76
76
  value: x,
77
- children: [e, n.map((e, t) => /* @__PURE__ */ r(h, {
77
+ children: [e, n.map((e, t) => /* @__PURE__ */ u(h, {
78
78
  entry: e,
79
79
  level: t,
80
80
  close: _,
81
81
  push: g,
82
- dispatch: a
82
+ dispatch: r
83
83
  }, e.id))]
84
84
  });
85
85
  }, _ = () => {
86
- let e = s(f);
86
+ let e = a(f);
87
87
  if (!e) throw Error("useKapiOffcanvasStack: falta <KapiOffcanvasStack> más arriba en el árbol.");
88
88
  return e;
89
89
  }, v = () => {
90
- let e = s(p);
90
+ let e = a(p);
91
91
  if (!e) throw Error("useKapiOffcanvasPanel: sólo se puede usar dentro del contenido de un panel del stack.");
92
92
  return e;
93
93
  };
@@ -1,7 +1,7 @@
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 { computedStyleOf as n } from "../../hooks/ownerDocument.js";
6
6
  import { resolveKapiRoot as r } from "../../hooks/kapiRoot.js";
7
7
  import { onViewportChange as i } from "../../hooks/rafThrottle.js";
@@ -10,8 +10,8 @@ import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
10
10
  import { KapiOverlayPortal as o } from "./overlayPortal.js";
11
11
  import { prefersReducedMotion as s } from "../../hooks/reducedMotion.js";
12
12
  import { trapTabKey as c } from "../../hooks/focusLogic.js";
13
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
14
- import { useEffect as f, useLayoutEffect as p, useReducer as m, useRef as h, useState as g } from "react";
13
+ import { useEffect as l, useLayoutEffect as u, useReducer as d, useRef as f, useState as p } from "react";
14
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
15
15
  //#region src/components/overlays/KapiPhotoView.tsx
16
16
  var _ = { viewer: "Foto ampliada" }, v = 92, y = 24, b = .42, x = (e, t) => {
17
17
  switch (t) {
@@ -44,7 +44,7 @@ var _ = { viewer: "Foto ampliada" }, v = 92, y = 24, b = .42, x = (e, t) => {
44
44
  fontSize: t.height * b
45
45
  } : {};
46
46
  }, E = ({ children: v, content: y, bg: b = "var(--kapi-primary-soft)", ink: E = "var(--kapi-primary-ink)", label: D, labels: O, className: k, style: A, id: j, ref: M }) => {
47
- let N = e("photoView", _, O), P = h(null), F = a(P, M), I = h(null), L = h(!1), [R, z] = m(x, "closed"), [B, V] = g(null), [H, U] = g(999), [W, G] = g(null), K = (e) => {
47
+ let N = t("photoView", _, O), P = f(null), F = a(P, M), I = f(null), L = f(!1), [R, z] = d(x, "closed"), [B, V] = p(null), [H, U] = p(999), [W, G] = p(null), K = (e) => {
48
48
  e.stopPropagation();
49
49
  let t = P.current;
50
50
  if (!t) return;
@@ -55,24 +55,24 @@ var _ = { viewer: "Foto ampliada" }, v = 92, y = 24, b = .42, x = (e, t) => {
55
55
  }, q = (e) => {
56
56
  e.stopPropagation(), z("close");
57
57
  };
58
- p(() => {
58
+ u(() => {
59
59
  if (R !== "opening") return;
60
60
  let e = requestAnimationFrame(() => z("ready"));
61
61
  return () => cancelAnimationFrame(e);
62
62
  }, [R]);
63
63
  let J = R === "closed";
64
- f(() => {
64
+ l(() => {
65
65
  if (!J) return i(() => {
66
66
  let e = P.current;
67
67
  if (!e) return;
68
68
  let t = e.getBoundingClientRect();
69
69
  V((e) => w(e, t) ? e : t);
70
70
  });
71
- }, [J]), f(() => {
71
+ }, [J]), l(() => {
72
72
  if (R !== "closing") return;
73
73
  let e = window.setTimeout(() => z("end"), S(s(P.current)));
74
74
  return () => window.clearTimeout(e);
75
- }, [R]), p(() => {
75
+ }, [R]), u(() => {
76
76
  R === "closed" ? (V(null), G(null), L.current && P.current?.focus(), L.current = !1) : R === "opening" && (L.current = !0, I.current?.focus());
77
77
  }, [R]);
78
78
  let Y = T(R, B, typeof window > "u" ? {
@@ -82,19 +82,19 @@ var _ = { viewer: "Foto ampliada" }, v = 92, y = 24, b = .42, x = (e, t) => {
82
82
  width: window.innerWidth,
83
83
  height: window.innerHeight
84
84
  }, H);
85
- return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("button", {
85
+ return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("button", {
86
86
  ref: F,
87
87
  type: "button",
88
88
  onClick: K,
89
89
  id: j,
90
- className: t("kapi-photo-thumb", k),
90
+ className: e("kapi-photo-thumb", k),
91
91
  style: A,
92
92
  "aria-label": D,
93
93
  "aria-haspopup": "dialog",
94
94
  children: v
95
- }), R !== "closed" && /* @__PURE__ */ u(o, {
95
+ }), R !== "closed" && /* @__PURE__ */ h(o, {
96
96
  root: W,
97
- children: /* @__PURE__ */ u("div", {
97
+ children: /* @__PURE__ */ h("div", {
98
98
  ref: I,
99
99
  className: `kapi-photo-overlay${R === "open" ? " is-open" : ""}`,
100
100
  role: "dialog",
@@ -105,7 +105,7 @@ var _ = { viewer: "Foto ampliada" }, v = 92, y = 24, b = .42, x = (e, t) => {
105
105
  onKeyDown: (e) => {
106
106
  e.key === "Escape" ? (e.preventDefault(), q(e)) : c(e, I.current);
107
107
  },
108
- children: /* @__PURE__ */ u("div", {
108
+ children: /* @__PURE__ */ h("div", {
109
109
  className: "kapi-photo-fly",
110
110
  style: {
111
111
  ...Y,
@@ -1,4 +1,5 @@
1
1
  import { type CSSProperties, type ReactNode, type Ref, type RefObject } from "react";
2
+ import type { KapiCloseReason } from "../closeReason.js";
2
3
  import type { KapiPopoverAlign, KapiPopoverSide } from "./popoverLogic.js";
3
4
  export type KapiPopoverProps = {
4
5
  /** Muestra u oculta el popover (controlado). */
@@ -6,7 +7,7 @@ export type KapiPopoverProps = {
6
7
  /** Elemento al que se ancla. */
7
8
  anchorRef: RefObject<HTMLElement | null>;
8
9
  /** Pedido de cierre: Escape o click afuera (si están habilitados). El padre pone `open={false}`. */
9
- onClose: () => void;
10
+ onClose: (reason: KapiCloseReason) => void;
10
11
  /** Lado preferido; da vuelta solo si no entra. Default `"bottom"`. */
11
12
  side?: KapiPopoverSide | undefined;
12
13
  /** Default `"start"`. */