@kapiuara/ui 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) 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/overlays/useNativeDialog.d.ts +5 -0
  113. package/dist/components/overlays/useNativeDialog.js +2 -2
  114. package/dist/components/renderSlot.d.ts +27 -0
  115. package/dist/components/renderSlot.js +23 -0
  116. package/dist/hooks/portalRoot.js +6 -6
  117. package/dist/index.d.ts +2 -0
  118. package/package.json +1 -1
@@ -7,12 +7,12 @@ import { useDismiss as r } from "../../hooks/useDismiss.js";
7
7
  import { KapiOverlayPortal as i } from "./overlayPortal.js";
8
8
  import { useExitPresence as a } from "./useExitPresence.js";
9
9
  /* empty css */
10
- import { jsx as o } from "react/jsx-runtime";
11
- import { useLayoutEffect as s, useRef as c, useState as l } from "react";
10
+ import { useLayoutEffect as o, useRef as s, useState as c } from "react";
11
+ import { jsx as l } from "react/jsx-runtime";
12
12
  //#region src/components/overlays/KapiPopover.tsx
13
13
  function u({ open: u, anchorRef: d, onClose: f, side: p = "bottom", align: m = "start", offset: h = 6, margin: g = 8, matchAnchorWidth: _ = !1, role: v = "dialog", "aria-label": y, id: b, className: x = "", style: S, ref: C, closeOnEscape: w = !0, closeOnOutside: T = !0, restoreFocus: E = !0, children: D }) {
14
- let O = c(null), k = n(O, C), [A, j] = l(null), { present: M, closing: N } = a(u, O);
15
- s(() => {
14
+ let O = s(null), k = n(O, C), [A, j] = c(null), { present: M, closing: N } = a(u, O);
15
+ o(() => {
16
16
  j(M ? e(d.current) : null);
17
17
  }, [M, d]);
18
18
  let { placement: P, style: F } = t({
@@ -30,12 +30,12 @@ function u({ open: u, anchorRef: d, onClose: f, side: p = "bottom", align: m = "
30
30
  escape: w,
31
31
  outside: T,
32
32
  onDismiss: (e) => {
33
- f?.(), e === "escape" && E && d.current?.focus();
33
+ f?.(e), e === "escape" && E && d.current?.focus();
34
34
  }
35
35
  });
36
- return M ? /* @__PURE__ */ o(i, {
36
+ return M ? /* @__PURE__ */ l(i, {
37
37
  root: A,
38
- children: /* @__PURE__ */ o("div", {
38
+ children: /* @__PURE__ */ l("div", {
39
39
  ref: k,
40
40
  id: b,
41
41
  role: v,
@@ -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 { useControllableState as n } from "../../hooks/useControllableState.js";
6
6
  import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
7
7
  import { useDismiss as i } from "../../hooks/useDismiss.js";
8
8
  /* empty css */
9
9
  import { focusableWithin as a } from "../../hooks/focusLogic.js";
10
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
11
- import { useEffect as c, useId as l, useRef as u } from "react";
10
+ import { useEffect as o, useId as s, useRef as c } from "react";
11
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
12
12
  import { Minus as d, Plus as f } from "lucide-react";
13
13
  //#region src/components/overlays/KapiShapeSheet.tsx
14
14
  var p = {
15
15
  close: "Cerrar",
16
16
  open: "Abrir"
17
17
  }, m = ({ title: m, children: h, width: g = 300, height: _ = 250, label: v, labels: y, className: b, style: x, id: S, ref: C, open: w, defaultOpen: T = !1, onOpenChange: E }) => {
18
- let D = e("shapeSheet", p, y), O = u(null), k = r(O, C), A = u(null), j = u(null), M = u(null), N = l(), [P, F] = n(w, T, E), I = u(P);
18
+ let D = t("shapeSheet", p, y), O = c(null), k = r(O, C), A = c(null), j = c(null), M = c(null), N = s(), [P, F] = n(w, T, E), I = c(P);
19
19
  I.current = P;
20
20
  let L = (e) => {
21
21
  e !== I.current && F(e);
22
- }, R = u(!1), z = () => {
22
+ }, R = c(!1), z = () => {
23
23
  R.current = !0, L(!1);
24
24
  };
25
- c(() => {
25
+ o(() => {
26
26
  P ? (a(M.current)[0] ?? j.current)?.focus() : R.current && (R.current = !1, A.current?.focus());
27
27
  }, [P]);
28
28
  let B = i(P, {
@@ -31,17 +31,17 @@ var p = {
31
31
  e === "escape" && (R.current = !0), L(!1);
32
32
  }
33
33
  });
34
- return /* @__PURE__ */ s("div", {
34
+ return /* @__PURE__ */ u("div", {
35
35
  ref: k,
36
36
  id: S,
37
- className: t("kapi-shape", P && "kapi-shape--open", b),
37
+ className: e("kapi-shape", P && "kapi-shape--open", b),
38
38
  style: P ? {
39
39
  ...x,
40
40
  width: g,
41
41
  height: _
42
42
  } : x,
43
43
  onKeyDown: B,
44
- children: [/* @__PURE__ */ o("button", {
44
+ children: [/* @__PURE__ */ l("button", {
45
45
  ref: A,
46
46
  type: "button",
47
47
  className: "kapi-shape__fab",
@@ -49,34 +49,34 @@ var p = {
49
49
  onClick: () => L(!0),
50
50
  "aria-expanded": P,
51
51
  "aria-label": v ?? D.open,
52
- children: /* @__PURE__ */ o(f, {
52
+ children: /* @__PURE__ */ l(f, {
53
53
  size: 22,
54
54
  strokeWidth: 2.4
55
55
  })
56
- }), /* @__PURE__ */ s("div", {
56
+ }), /* @__PURE__ */ u("div", {
57
57
  ref: j,
58
58
  className: "kapi-shape__sheet",
59
59
  inert: !P,
60
60
  role: "dialog",
61
61
  "aria-labelledby": N,
62
62
  tabIndex: -1,
63
- children: [/* @__PURE__ */ s("div", {
63
+ children: [/* @__PURE__ */ u("div", {
64
64
  className: "kapi-shape__head",
65
- children: [/* @__PURE__ */ o("span", {
65
+ children: [/* @__PURE__ */ l("span", {
66
66
  className: "kapi-shape__title",
67
67
  id: N,
68
68
  children: m
69
- }), /* @__PURE__ */ o("button", {
69
+ }), /* @__PURE__ */ l("button", {
70
70
  type: "button",
71
71
  className: "kapi-shape__close",
72
72
  onClick: z,
73
73
  "aria-label": D.close,
74
- children: /* @__PURE__ */ o(d, {
74
+ children: /* @__PURE__ */ l(d, {
75
75
  size: 16,
76
76
  strokeWidth: 2.4
77
77
  })
78
78
  })]
79
- }), /* @__PURE__ */ o("div", {
79
+ }), /* @__PURE__ */ l("div", {
80
80
  className: "kapi-shape__body",
81
81
  ref: M,
82
82
  children: h
@@ -8,8 +8,8 @@ import { useBackdropClose as a, useNativeDialog as o, usePortalRoot as s, useTra
8
8
  /* empty css */
9
9
  import { resolveAsideWidth as l, resolvePanelOrder as u, splitModalClasses as d } from "./splitModalLayout.js";
10
10
  /* empty css */
11
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
- import { useId as m, useRef as h } from "react";
11
+ import { useId as f, useRef as p } from "react";
12
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
13
13
  import { X as g } from "lucide-react";
14
14
  import { createPortal as _ } from "react-dom";
15
15
  //#region src/components/overlays/KapiSplitModal.tsx
@@ -17,99 +17,99 @@ var v = {
17
17
  close: "Cerrar",
18
18
  closePanel: "Cerrar panel"
19
19
  }, y = ({ open: e, ...t }) => {
20
- let n = h(null), { present: r, closing: a } = i(e, n);
21
- return r ? /* @__PURE__ */ f(x, {
20
+ let n = p(null), { present: r, closing: a } = i(e, n);
21
+ return r ? /* @__PURE__ */ m(x, {
22
22
  ...t,
23
23
  dialogRef: n,
24
24
  closing: a
25
25
  }) : null;
26
- }, b = () => {}, x = ({ title: i, subtitle: h, onClose: y, children: x, footer: S, size: C = "md", hideHeader: w = !1, className: T = "", style: E, id: D, ref: O, closeOnBackdrop: ee, closeOnEscape: k, closeButton: A, dismissible: j, closeLabel: M, labels: N, "aria-label": P, "aria-labelledby": F, aside: I, dialogRef: L, closing: R }) => {
27
- let z = R ? b : y, B = m(), V = m(), H = r({
26
+ }, b = () => {}, x = ({ title: i, subtitle: p, onClose: y, children: x, footer: S, size: C = "md", hideHeader: w = !1, className: T = "", style: E, id: D, ref: O, closeOnBackdrop: ee, closeOnEscape: k, closeButton: A, dismissible: j, closeLabel: M, labels: N, "aria-label": P, "aria-labelledby": F, aside: I, dialogRef: L, closing: R }) => {
27
+ let z = R ? b : y, B = f(), V = f(), H = r({
28
28
  dismissible: j,
29
29
  closeOnEscape: k,
30
30
  closeOnBackdrop: ee,
31
31
  closeButton: A
32
- }), { closeOnEscape: U, closeOnBackdrop: W, closeButton: G } = H, { ref: K, dialogProps: q } = o({ onRequestClose: U ? z : void 0 }), J = a(W ? z : void 0);
32
+ }), { closeOnEscape: U, closeOnBackdrop: W, closeButton: G } = H, { ref: K, dialogProps: q } = o({ onRequestClose: U ? () => z("escape") : void 0 }), J = a(W ? () => z("backdrop") : void 0);
33
33
  c("KapiSplitModal", H, K);
34
34
  let Y = e("splitModal", v, N), X = M ?? Y.close, Z = s();
35
35
  if (!Z) return null;
36
- let Q = I?.open === !0, $ = I?.side ?? "left", te = /* @__PURE__ */ p("div", {
36
+ let Q = I?.open === !0, $ = I?.side ?? "left", te = /* @__PURE__ */ h("div", {
37
37
  ref: O,
38
38
  id: D,
39
39
  className: n(C, T),
40
40
  style: E,
41
41
  children: [
42
- w ? G && /* @__PURE__ */ f("button", {
42
+ w ? G && /* @__PURE__ */ m("button", {
43
43
  type: "button",
44
44
  className: "kapi-modal__x kapi-modal__x--float",
45
- onClick: z,
45
+ onClick: () => z("close-button"),
46
46
  "aria-label": X,
47
- children: /* @__PURE__ */ f(g, {
47
+ children: /* @__PURE__ */ m(g, {
48
48
  size: 17,
49
49
  strokeWidth: 2.2
50
50
  })
51
- }) : /* @__PURE__ */ p("div", {
51
+ }) : /* @__PURE__ */ h("div", {
52
52
  className: "kapi-modal__head",
53
- children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("div", {
53
+ children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("div", {
54
54
  id: B,
55
55
  className: "kapi-modal__title",
56
56
  children: i
57
- }), h && /* @__PURE__ */ f("div", {
57
+ }), p && /* @__PURE__ */ m("div", {
58
58
  className: "kapi-modal__sub",
59
- children: h
60
- })] }), G && /* @__PURE__ */ f("button", {
59
+ children: p
60
+ })] }), G && /* @__PURE__ */ m("button", {
61
61
  type: "button",
62
62
  className: "kapi-modal__x",
63
- onClick: z,
63
+ onClick: () => z("close-button"),
64
64
  "aria-label": X,
65
- children: /* @__PURE__ */ f(g, {
65
+ children: /* @__PURE__ */ m(g, {
66
66
  size: 17,
67
67
  strokeWidth: 2.2
68
68
  })
69
69
  })]
70
70
  }),
71
- /* @__PURE__ */ f("div", {
71
+ /* @__PURE__ */ m("div", {
72
72
  className: "kapi-modal__body",
73
73
  children: x
74
74
  }),
75
- S && /* @__PURE__ */ f("div", {
75
+ S && /* @__PURE__ */ m("div", {
76
76
  className: "kapi-modal__foot",
77
77
  children: S
78
78
  })
79
79
  ]
80
- }, "main"), ne = I && Q ? /* @__PURE__ */ p("aside", {
80
+ }, "main"), ne = I && Q ? /* @__PURE__ */ h("aside", {
81
81
  className: "kapi-splitmodal__aside",
82
82
  style: { "--kapi-split-aside-w": l(I.width) },
83
83
  "aria-labelledby": I.title ? V : void 0,
84
84
  children: [
85
- (I.title || I.onClose) && /* @__PURE__ */ p("div", {
85
+ (I.title || I.onClose) && /* @__PURE__ */ h("div", {
86
86
  className: "kapi-modal__head",
87
- children: [/* @__PURE__ */ f("div", {
87
+ children: [/* @__PURE__ */ m("div", {
88
88
  id: V,
89
89
  className: "kapi-modal__title",
90
90
  children: I.title
91
- }), I.onClose && /* @__PURE__ */ f("button", {
91
+ }), I.onClose && /* @__PURE__ */ m("button", {
92
92
  type: "button",
93
93
  className: "kapi-modal__x",
94
94
  onClick: I.onClose,
95
95
  "aria-label": I.closeLabel ?? Y.closePanel,
96
- children: /* @__PURE__ */ f(g, {
96
+ children: /* @__PURE__ */ m(g, {
97
97
  size: 17,
98
98
  strokeWidth: 2.2
99
99
  })
100
100
  })]
101
101
  }),
102
- /* @__PURE__ */ f("div", {
102
+ /* @__PURE__ */ m("div", {
103
103
  className: "kapi-modal__body",
104
104
  children: I.children
105
105
  }),
106
- I.footer && /* @__PURE__ */ f("div", {
106
+ I.footer && /* @__PURE__ */ m("div", {
107
107
  className: "kapi-modal__foot",
108
108
  children: I.footer
109
109
  })
110
110
  ]
111
111
  }, "aside") : null, re = u($).map((e) => e === "main" ? te : ne).filter((e) => e !== null);
112
- return _(/* @__PURE__ */ f("dialog", {
112
+ return _(/* @__PURE__ */ m("dialog", {
113
113
  ref: (e) => {
114
114
  K.current = e, L.current = e;
115
115
  },
@@ -125,7 +125,7 @@ var v = {
125
125
  }),
126
126
  ...q,
127
127
  ...J,
128
- children: /* @__PURE__ */ f("div", {
128
+ children: /* @__PURE__ */ m("div", {
129
129
  className: Q ? d($) : "kapi-splitmodal kapi-splitmodal--single",
130
130
  children: re
131
131
  })
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/overlays/overlays.css";
3
- import { joinIds as e } from "../inputs/fieldLogic.js";
4
- import { useKapiDir as t } from "../locale/KapiLocaleProvider.js";
5
- import { joinClasses as n } from "../rootProps.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { joinIds as t } from "../inputs/fieldLogic.js";
5
+ import { useKapiDir as n } from "../locale/KapiLocaleProvider.js";
6
6
  import { winOf as r } from "../../hooks/ownerDocument.js";
7
7
  import { placePopover as i } from "./popoverLogic.js";
8
8
  import { onViewportChange as a } from "../../hooks/rafThrottle.js";
@@ -10,8 +10,8 @@ import { placementViewport as o } from "../../hooks/viewportInsetLogic.js";
10
10
  import { resolveDirection as s } from "../../hooks/directionLogic.js";
11
11
  import { useMergedRefs as c } from "../../hooks/mergeRefs.js";
12
12
  /* empty css */
13
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
14
- import { cloneElement as d, isValidElement as f, useEffect as p, useId as m, useLayoutEffect as h, useRef as g, useState as _ } from "react";
13
+ import { cloneElement as l, isValidElement as u, useEffect as d, 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
15
  //#region src/components/overlays/KapiTooltip.tsx
16
16
  var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "rtl" ? "left" : "right" : e === "start" ? t === "rtl" ? "right" : "left" : e, w = (e) => Math.min(v, String(e).length * y + b), T = (e, t, n, r, a = Infinity) => {
17
17
  let o = t.bottom ?? t.top, s = t.left ?? t.right, c = {
@@ -68,20 +68,20 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
68
68
  } catch {
69
69
  return null;
70
70
  }
71
- }, j = (t, n) => e(typeof t == "string" ? t : void 0, n), M = ({ label: e, children: i, prefer: v = "end", className: y, style: b, id: x, ref: S }) => {
72
- let w = m(), E = g(null), D = c(E, S), O = t(), [M, N] = _(() => C(v, s(null, O))), [P, F] = _(!1), [I, L] = _(!1), R = g({
71
+ }, j = (e, n) => t(typeof e == "string" ? e : void 0, n), M = ({ label: t, children: i, prefer: v = "end", className: y, style: b, id: x, ref: S }) => {
72
+ let w = f(), E = m(null), D = c(E, S), O = n(), [M, N] = h(() => C(v, s(null, O))), [P, F] = h(!1), [I, L] = h(!1), R = m({
73
73
  hover: !1,
74
74
  focus: !1
75
75
  }), z = () => {
76
- let t = E.current;
77
- if (!t) return;
78
- let n = t.getBoundingClientRect(), r = o(t), i = T(C(v, s(t, O)), n, e, r.width, r.height), { x: a, y: c } = k(i, n);
79
- t.style.setProperty("--kapi-tip-x", `${Math.round(a)}px`), t.style.setProperty("--kapi-tip-y", `${Math.round(c)}px`), N(i);
80
- }, B = g(z);
81
- h(() => {
76
+ let e = E.current;
77
+ if (!e) return;
78
+ let n = e.getBoundingClientRect(), r = o(e), i = T(C(v, s(e, O)), n, t, r.width, r.height), { x: a, y: c } = k(i, n);
79
+ e.style.setProperty("--kapi-tip-x", `${Math.round(a)}px`), e.style.setProperty("--kapi-tip-y", `${Math.round(c)}px`), N(i);
80
+ }, B = m(z);
81
+ p(() => {
82
82
  B.current = z;
83
83
  });
84
- let V = g(null), H = g(!1), U = (e) => {
84
+ let V = m(null), H = m(!1), U = (e) => {
85
85
  let t = V.current;
86
86
  if (!t || typeof t.showPopover != "function") return;
87
87
  let n = A(t, ":popover-open") ?? H.current;
@@ -91,17 +91,17 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
91
91
  }, G = (e) => {
92
92
  R.current[e] = !1, !(R.current.hover || R.current.focus) && (F(!1), L(!1), U(!1));
93
93
  };
94
- p(() => {
94
+ d(() => {
95
95
  if (!I) return;
96
96
  let e = r(E.current);
97
97
  return a(() => B.current(), e ? { target: e } : {});
98
98
  }, [I]);
99
99
  let K = (e) => {
100
100
  e.key === "Escape" && !P && F(!0);
101
- }, q = f(i) ? i : null, J = q ? d(q, { "aria-describedby": j(q.props["aria-describedby"], w) }) : i;
102
- return /* @__PURE__ */ u("span", {
101
+ }, q = u(i) ? i : null, J = q ? l(q, { "aria-describedby": j(q.props["aria-describedby"], w) }) : i;
102
+ return /* @__PURE__ */ _("span", {
103
103
  id: x,
104
- className: n("kapi-tip", y),
104
+ className: e("kapi-tip", y),
105
105
  style: b,
106
106
  ref: D,
107
107
  "data-side": M,
@@ -114,13 +114,13 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
114
114
  onMouseLeave: () => G("hover"),
115
115
  onBlur: () => G("focus"),
116
116
  onKeyDown: K,
117
- children: [J, /* @__PURE__ */ l("span", {
117
+ children: [J, /* @__PURE__ */ g("span", {
118
118
  ref: V,
119
119
  className: "kapi-tip__bubble",
120
120
  role: "tooltip",
121
121
  id: w,
122
122
  popover: "manual",
123
- children: e
123
+ children: t
124
124
  })]
125
125
  });
126
126
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { resolveMenuItemTone as e } from "../tone.js";
3
- import { useLabels as t } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as n } from "../rootProps.js";
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
5
  import { initialMenuFocus as r, isTypeaheadKey as i, menuKeyIntent as a, nextEnabledIndex as o } from "./menuKeyboardLogic.js";
6
6
  import { activeElementOf as s } from "../../hooks/ownerDocument.js";
7
7
  import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
@@ -9,8 +9,8 @@ import { usePlacement as l } from "../../hooks/usePlacement.js";
9
9
  import { useTypeahead as u } from "../../hooks/useTypeahead.js";
10
10
  import { actionableIndexes as d, isActionMenuItem as f, matchMenuTypeahead as p, menuItemRole as m, submenuKeyAction as h } from "./menuButtonLogic.js";
11
11
  import { DEFAULT_LINK_LABELS as g } from "../locale/linkLabels.js";
12
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
13
- import { useEffect as b, useId as x, useRef as S, useState as C } from "react";
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
14
  import { Check as w, ChevronRight as T, Circle as E } from "lucide-react";
15
15
  var D = {
16
16
  side: "right",
@@ -18,9 +18,9 @@ var D = {
18
18
  offset: 4,
19
19
  flip: "auto",
20
20
  shift: !0
21
- }, O = (t) => n("kapi-ctxmenu__item", e(t.tone, t.danger) === "danger" && "is-danger", t.disabled && "is-disabled", t.current && "is-current"), k = (e) => {
22
- let t = S([]), n = S(null), r = S(void 0), [i, a] = C(null);
23
- b(() => () => clearTimeout(r.current), []);
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
24
  let o = (e) => t.current[e]?.focus(), c = (e, t) => a((n) => ({
25
25
  index: e,
26
26
  focus: t ? (n?.focus ?? 0) + 1 : n?.index === e ? n.focus : 0
@@ -56,15 +56,15 @@ var D = {
56
56
  onLeave: p
57
57
  })
58
58
  };
59
- }, A = ({ items: e, onActivate: n, onClose: l, focusRequest: f, onBack: m, onKeyDown: _, ref: y, id: x, className: S, style: C, "aria-label": w, "aria-labelledby": T }) => {
60
- let E = t("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 b(() => {
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
62
  f > 0 && M(r(F));
63
- }, [f]), /* @__PURE__ */ v("div", {
63
+ }, [f]), /* @__PURE__ */ S("div", {
64
64
  ref: y,
65
- id: x,
65
+ id: b,
66
66
  role: "menu",
67
- className: S,
67
+ className: x,
68
68
  style: C,
69
69
  "aria-label": w,
70
70
  "aria-labelledby": T,
@@ -84,113 +84,113 @@ var D = {
84
84
  else if (f === "back") u(), m?.();
85
85
  else if (d.kind === "close") {
86
86
  if (I) return;
87
- if (d.returnFocus) return _?.(t);
87
+ if (d.returnFocus) return v?.(t);
88
88
  l(!1);
89
89
  } else if (i(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
90
90
  let n = p(e, r, D(t.key));
91
91
  n >= 0 && (u(), M(n));
92
92
  }
93
93
  },
94
- children: e.map((e, t) => e.sep ? /* @__PURE__ */ v("div", {
94
+ children: e.map((e, n) => e.sep ? /* @__PURE__ */ S("div", {
95
95
  role: "separator",
96
96
  className: "kapi-ctxmenu__sep"
97
- }, `s${t}`) : "header" in e ? /* @__PURE__ */ v("div", {
97
+ }, `s${n}`) : "header" in e ? /* @__PURE__ */ S("div", {
98
98
  role: "presentation",
99
99
  className: "kapi-ctxmenu__header",
100
100
  children: e.header
101
- }, `h${t}`) : /* @__PURE__ */ v(j, {
102
- ...O.entryProps(t),
101
+ }, `h${n}`) : /* @__PURE__ */ S(j, {
102
+ ...O.entryProps(n),
103
103
  item: e,
104
- index: t,
104
+ index: n,
105
105
  newTabLabel: E.newTab,
106
- onActivate: n,
106
+ onActivate: t,
107
107
  onClose: l
108
- }, e.id ?? `m${t}`))
108
+ }, e.id ?? `m${n}`))
109
109
  });
110
- }, j = ({ item: e, index: t, 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 = x(), g = x(), b = S(null), C = m(e), D = C !== "menuitem", k = e.items !== void 0 && e.items.length > 0 ? e.items : null, A = e.href !== void 0 && e.target === "_blank", j = typeof e.label != "string" && e.textValue !== void 0 ? A ? `${e.textValue} ${r}` : e.textValue : void 0, N = (e) => {
112
- b.current = e, i(e);
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
113
  }, P = {
114
114
  id: k ? h : void 0,
115
- role: C,
115
+ role: b,
116
116
  tabIndex: -1,
117
- "data-menu-index": t,
118
- "data-menu-id": e.id,
119
- "aria-disabled": e.disabled ? "true" : void 0,
120
- "aria-current": e.current ? "true" : void 0,
121
- "aria-checked": D ? e.checked === !0 : void 0,
122
- "aria-keyshortcuts": e.shortcut,
123
- "aria-describedby": e.description === void 0 ? void 0 : g,
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
124
  "aria-haspopup": k ? "menu" : void 0,
125
125
  "aria-expanded": k ? a : void 0,
126
126
  "aria-label": j,
127
- className: n(O(e), D && "is-checkable", a && "is-open"),
128
- onClick: (t) => {
129
- e.disabled ? t.preventDefault() : k ? (t.preventDefault(), c()) : u(e, t);
127
+ className: e(O(t), D && "is-checkable", a && "is-open"),
128
+ onClick: (e) => {
129
+ t.disabled ? e.preventDefault() : k ? (e.preventDefault(), c()) : u(t, e);
130
130
  },
131
131
  onMouseEnter: f,
132
132
  onMouseLeave: p
133
- }, F = /* @__PURE__ */ y(_, { children: [
134
- D && /* @__PURE__ */ v("span", {
133
+ }, F = /* @__PURE__ */ C(x, { children: [
134
+ D && /* @__PURE__ */ S("span", {
135
135
  className: "kapi-ctxmenu__check",
136
136
  "aria-hidden": "true",
137
- children: e.checked === !0 && (C === "menuitemradio" ? /* @__PURE__ */ v(E, {
137
+ children: t.checked === !0 && (b === "menuitemradio" ? /* @__PURE__ */ S(E, {
138
138
  size: 8,
139
139
  fill: "currentColor",
140
140
  strokeWidth: 0
141
- }) : /* @__PURE__ */ v(w, {
141
+ }) : /* @__PURE__ */ S(w, {
142
142
  size: 15,
143
143
  strokeWidth: 2.4
144
144
  }))
145
145
  }),
146
- e.icon,
147
- e.description === void 0 ? e.label : /* @__PURE__ */ y("span", {
146
+ t.icon,
147
+ t.description === void 0 ? t.label : /* @__PURE__ */ C("span", {
148
148
  className: "kapi-ctxmenu__text",
149
- children: [/* @__PURE__ */ v("span", {
149
+ children: [/* @__PURE__ */ S("span", {
150
150
  className: "kapi-ctxmenu__label",
151
- children: e.label
152
- }), /* @__PURE__ */ v("span", {
151
+ children: t.label
152
+ }), /* @__PURE__ */ S("span", {
153
153
  id: g,
154
154
  className: "kapi-ctxmenu__desc",
155
155
  "aria-hidden": "true",
156
- children: e.description
156
+ children: t.description
157
157
  })]
158
158
  }),
159
- A && j === void 0 && /* @__PURE__ */ y(_, { children: [" ", /* @__PURE__ */ v("span", {
159
+ A && j === void 0 && /* @__PURE__ */ C(x, { children: [" ", /* @__PURE__ */ S("span", {
160
160
  className: "kapi-sr-only",
161
161
  children: r
162
162
  })] }),
163
- e.shortcut !== void 0 && /* @__PURE__ */ v("kbd", {
163
+ t.shortcut !== void 0 && /* @__PURE__ */ S("kbd", {
164
164
  className: "kapi-ctxmenu__kbd",
165
165
  "aria-hidden": "true",
166
- children: e.shortcut
166
+ children: t.shortcut
167
167
  }),
168
- k && /* @__PURE__ */ v(T, {
168
+ k && /* @__PURE__ */ S(T, {
169
169
  className: "kapi-ctxmenu__chev kapi-flip-rtl",
170
170
  size: 15,
171
171
  strokeWidth: 2.2,
172
172
  "aria-hidden": "true"
173
173
  })
174
- ] }), I = e.href !== void 0 && !k ? /* @__PURE__ */ v("a", {
174
+ ] }), I = t.href !== void 0 && !k ? /* @__PURE__ */ S("a", {
175
175
  ref: N,
176
176
  ...P,
177
- href: e.disabled ? void 0 : e.href,
178
- target: e.target,
179
- rel: e.rel ?? (A ? "noopener noreferrer" : void 0),
180
- download: e.download,
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
181
  children: F
182
- }) : /* @__PURE__ */ v("button", {
182
+ }) : /* @__PURE__ */ S("button", {
183
183
  ref: N,
184
184
  type: "button",
185
185
  ...P,
186
186
  children: F
187
187
  });
188
- return k ? /* @__PURE__ */ y("div", {
188
+ return k ? /* @__PURE__ */ C("div", {
189
189
  role: "none",
190
190
  className: "kapi-ctxmenu__subwrap",
191
- children: [I, a && /* @__PURE__ */ v(M, {
191
+ children: [I, a && /* @__PURE__ */ S(M, {
192
192
  items: k,
193
- anchorRef: b,
193
+ anchorRef: _,
194
194
  menuRef: s,
195
195
  labelledBy: h,
196
196
  focusRequest: o,
@@ -207,7 +207,7 @@ var D = {
207
207
  ...D,
208
208
  hideUntilPlaced: !1
209
209
  });
210
- return /* @__PURE__ */ v(A, {
210
+ return /* @__PURE__ */ S(A, {
211
211
  ref: n,
212
212
  items: e,
213
213
  className: "kapi-ctxmenu kapi-ctxmenu--sub",
@@ -7,6 +7,11 @@ export declare const getPortalRoot: () => HTMLElement | null;
7
7
  * sin provider, `getPortalRoot()`.
8
8
  */
9
9
  export declare const usePortalRoot: () => HTMLElement | null;
10
+ /**
11
+ * Abre el diálogo como modal. Exportada para testearla sola: el camino que importa no se puede
12
+ * reproducir montando componentes (ver el comentario de abajo).
13
+ */
14
+ export declare const openModal: (el: HTMLDialogElement) => void;
10
15
  export type UseNativeDialogOptions = {
11
16
  /**
12
17
  * Se llama cuando el usuario pide cerrar (Escape o cierre nativo). Si es
@@ -17,7 +17,7 @@ var f = () => n(), p = () => t() ?? f(), m = /* @__PURE__ */ new WeakMap(), h =
17
17
  })
18
18
  }), m.set(t, n)), n;
19
19
  }, g = (e) => {
20
- e.open || (typeof e.showModal == "function" ? e.showModal() : e.setAttribute("open", ""));
20
+ e.open || e.isConnected && (typeof e.showModal == "function" ? e.showModal() : e.setAttribute("open", ""));
21
21
  }, _ = (e) => {
22
22
  typeof e.close == "function" ? e.open && e.close() : e.removeAttribute("open");
23
23
  }, v = ({ onRequestClose: e, lockScroll: t = !0 } = {}) => {
@@ -72,4 +72,4 @@ var f = () => n(), p = () => t() ?? f(), m = /* @__PURE__ */ new WeakMap(), h =
72
72
  }, [r]);
73
73
  };
74
74
  //#endregion
75
- export { f as getPortalRoot, y as useBackdropClose, v as useNativeDialog, p as usePortalRoot, b as useTrappedDialogWarning };
75
+ export { f as getPortalRoot, g as openModal, y as useBackdropClose, v as useNativeDialog, p as usePortalRoot, b as useTrappedDialogWarning };