@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
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/navigation/navigation.css";
3
- import { useKapiFormatLocale as e } from "../locale/KapiLocaleProvider.js";
4
- import { joinClasses as t } from "../rootProps.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { useKapiFormatLocale as t } from "../locale/KapiLocaleProvider.js";
5
5
  import { useControllableState as n } from "../../hooks/useControllableState.js";
6
6
  import { logicalKeyOf as r } from "../../hooks/directionLogic.js";
7
7
  import { useDuplicateValueWarning as i, useMutedControlWarning as a } from "../inputs/misuseWarnings.js";
@@ -11,12 +11,12 @@ import { formatCount as c } from "../../hooks/numberFormatLogic.js";
11
11
  import { useScrollEdges as l } from "../../hooks/useScrollEdges.js";
12
12
  /* empty css */
13
13
  import { nextTabId as u, tabClasses as d, tabId as f, tabPanelId as p } from "./tabsLogic.js";
14
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
15
- import { useCallback as _, useId as v, useLayoutEffect as y, useMemo as b, useRef as x } from "react";
14
+ import { useCallback as m, useId as h, useLayoutEffect as g, useMemo as _, useRef as v } from "react";
15
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
16
16
  //#region src/components/navigation/KapiTabs.tsx
17
17
  var S = [];
18
18
  function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, className: O, idBase: k, disabled: A = !1, size: j = "md", onKeyDown: M, ref: N, ...P }) {
19
- let F = e(), I = C ?? w ?? S, L = v(), R = k ?? L, z = x({}), [B, V] = n(T, () => E ?? I[0]?.id, D), H = b(() => I.map((e) => e.id), [I]);
19
+ let F = t(), I = C ?? w ?? S, L = h(), R = k ?? L, z = v({}), [B, V] = n(T, () => E ?? I[0]?.id, D), H = _(() => I.map((e) => e.id), [I]);
20
20
  i("KapiTabs", H), a("KapiTabs", {
21
21
  controlled: T !== void 0,
22
22
  hasOnChange: !!D,
@@ -26,10 +26,10 @@ function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, classNam
26
26
  active: B ?? null,
27
27
  deps: [I],
28
28
  findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
29
- }), { ref: G, edges: K, reveal: q } = l({ axis: "x" }), J = _((e) => {
29
+ }), { ref: G, edges: K, reveal: q } = l({ axis: "x" }), J = m((e) => {
30
30
  U.current = e, G.current = e;
31
- }, [U, G]), Y = o(J, N), X = x(!1);
32
- y(() => {
31
+ }, [U, G]), Y = o(J, N), X = v(!1);
32
+ g(() => {
33
33
  let e = U.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
34
34
  e && q(e, { instant: !X.current }), X.current = !0;
35
35
  }, [
@@ -42,22 +42,22 @@ function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, classNam
42
42
  let t = u(I.map((e) => e.id), B, r(e), Z);
43
43
  t !== void 0 && (e.preventDefault(), V(t), z.current[t]?.focus());
44
44
  };
45
- return /* @__PURE__ */ g("div", {
45
+ return /* @__PURE__ */ x("div", {
46
46
  ...P,
47
47
  ref: Y,
48
- className: t("kapi-tabs", "kapi-fade-x", j === "sm" && "kapi-tabs--sm", O),
48
+ className: e("kapi-tabs", "kapi-fade-x", j === "sm" && "kapi-tabs--sm", O),
49
49
  "data-edge-start": K.start ? "" : void 0,
50
50
  "data-edge-end": K.end ? "" : void 0,
51
51
  role: "tablist",
52
52
  "aria-disabled": A || void 0,
53
53
  onKeyDown: $,
54
- children: [/* @__PURE__ */ h("span", {
54
+ children: [/* @__PURE__ */ b("span", {
55
55
  ref: W,
56
56
  className: "kapi-tabs__indicator",
57
57
  "aria-hidden": "true"
58
58
  }), I.map((e) => {
59
59
  let t = e.id === B;
60
- return /* @__PURE__ */ g("button", {
60
+ return /* @__PURE__ */ x("button", {
61
61
  ref: (t) => {
62
62
  z.current[e.id] = t;
63
63
  },
@@ -73,7 +73,7 @@ function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, classNam
73
73
  children: [
74
74
  e.icon,
75
75
  e.label,
76
- e.count !== void 0 && /* @__PURE__ */ g(m, { children: [" ", /* @__PURE__ */ h("span", {
76
+ e.count !== void 0 && /* @__PURE__ */ x(y, { children: [" ", /* @__PURE__ */ b("span", {
77
77
  className: "kapi-tabs__count",
78
78
  children: c(e.count, F)
79
79
  })] })
@@ -82,16 +82,17 @@ function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, classNam
82
82
  })]
83
83
  });
84
84
  }
85
- function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: a, ref: o }) {
86
- return /* @__PURE__ */ h("div", {
87
- ref: o,
85
+ function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, style: a, children: o, ref: s }) {
86
+ return /* @__PURE__ */ b("div", {
87
+ ref: s,
88
+ style: a,
88
89
  id: p(e, t),
89
90
  role: "tabpanel",
90
91
  "aria-labelledby": f(e, t),
91
92
  tabIndex: 0,
92
93
  hidden: !n,
93
94
  className: i,
94
- children: n || r ? a : null
95
+ children: n || r ? o : null
95
96
  });
96
97
  }
97
98
  //#endregion
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/navigation/navigation.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 { isTypeaheadKey as n } from "../overlays/menuKeyboardLogic.js";
6
6
  import { useControllableState as r } from "../../hooks/useControllableState.js";
7
7
  import { logicalKeyOf as i } from "../../hooks/directionLogic.js";
@@ -10,51 +10,51 @@ import { useTypeahead as o } from "../../hooks/useTypeahead.js";
10
10
  import { useVirtualList as s } from "../../hooks/useVirtualList.js";
11
11
  /* empty css */
12
12
  import { TREE_KEYS as c, flattenVisible as l, isExpandable as u, matchTypeahead as ee, needsChildren as te, resolveTabStop as ne, toggleSelectedId as re, treeKeyAction as d } from "./treeLogic.js";
13
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
14
- import { useId as ie, useLayoutEffect as ae, useMemo as h, useRef as g, useState as oe } from "react";
15
- import { ChevronRight as se } from "lucide-react";
13
+ import { useId as ie, useLayoutEffect as ae, useMemo as f, useRef as p, useState as oe } from "react";
14
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
15
+ import { ChevronRight as _ } from "lucide-react";
16
16
  //#region src/components/navigation/KapiTree.tsx
17
- var _ = { loading: "Cargando…" }, ce = 37, v = 400;
18
- function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsChange: b, expanded: x, defaultExpanded: S, onExpandedChange: de, onExpand: fe, selectedIds: pe, defaultSelectedIds: me, onSelectedIdsChange: he, selected: ge, defaultSelected: _e, onSelectedChange: ve, multiple: C = !1, renderLabel: w, labels: ye, virtual: T = !1, maxHeight: E = v, className: D, style: O, ref: k, onKeyDown: A, onFocus: j, ...M }) {
19
- let N = e("tree", _, ye), P = ie(), [F, be] = r(le ?? x, () => ue ?? S ?? [], b ?? de), [I, xe] = r(pe ?? ge, () => me ?? _e ?? []), Se = he ?? ve, [Ce, L] = oe(null), R = g(/* @__PURE__ */ new Map()), z = o(500), B = h(() => l(y, F), [y, F]), V = ne(y, B, Ce, I), H = h(() => new Map(B.map((e, t) => [e.node.id, {
17
+ var v = { loading: "Cargando…" }, se = 37, y = 400;
18
+ function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsChange: x, expanded: S, defaultExpanded: C, onExpandedChange: ue, onExpand: de, selectedIds: fe, defaultSelectedIds: pe, onSelectedIdsChange: me, selected: he, defaultSelected: ge, onSelectedChange: _e, multiple: w = !1, renderLabel: T, labels: ve, virtual: E = !1, maxHeight: D = y, className: O, style: k, ref: A, onKeyDown: j, onFocus: M, ...N }) {
19
+ let P = t("tree", v, ve), F = ie(), [I, ye] = r(ce ?? S, () => le ?? C ?? [], x ?? ue), [L, be] = r(fe ?? he, () => pe ?? ge ?? []), xe = me ?? _e, [Se, R] = oe(null), z = p(/* @__PURE__ */ new Map()), Ce = o(500), B = f(() => l(b, I), [b, I]), V = ne(b, B, Se, L), H = f(() => new Map(B.map((e, t) => [e.node.id, {
20
20
  ...e,
21
21
  node: e.node,
22
22
  index: t
23
23
  }])), [B]), U = (e, t) => {
24
- be(e), t.filter(te).forEach((e) => fe?.(e));
24
+ ye(e), t.filter(te).forEach((e) => de?.(e));
25
25
  }, W = (e) => !e.disabled && u(e), G = (e) => {
26
- W(e) && !F.includes(e.id) && U([...F, e.id], [e]);
26
+ W(e) && !I.includes(e.id) && U([...I, e.id], [e]);
27
27
  }, K = (e) => {
28
- W(e) && F.includes(e.id) && U(F.filter((t) => t !== e.id), []);
28
+ W(e) && I.includes(e.id) && U(I.filter((t) => t !== e.id), []);
29
29
  }, we = (e) => {
30
- F.includes(e.id) ? K(e) : G(e);
30
+ I.includes(e.id) ? K(e) : G(e);
31
31
  }, q = (e) => {
32
32
  if (e.disabled) return;
33
- let t = re(I, e.id, C);
34
- xe(t), Se?.(t, e);
35
- }, J = g(null), Te = a(k, J), Ee = h(() => T ? B.map((e) => e.node.id) : void 0, [T, B]), Y = s({
36
- enabled: T,
33
+ let t = re(L, e.id, w);
34
+ be(t), xe?.(t, e);
35
+ }, J = p(null), Te = a(A, J), Ee = f(() => E ? B.map((e) => e.node.id) : void 0, [E, B]), Y = s({
36
+ enabled: E,
37
37
  count: B.length,
38
38
  scrollRef: J,
39
- estimate: ce,
39
+ estimate: se,
40
40
  measure: !0,
41
41
  keys: Ee,
42
- fallbackViewHeight: v
43
- }), X = g(null);
42
+ fallbackViewHeight: y
43
+ }), X = p(null);
44
44
  ae(() => {
45
- let e = X.current, t = e === null ? void 0 : R.current.get(e);
45
+ let e = X.current, t = e === null ? void 0 : z.current.get(e);
46
46
  t && (X.current = null, t.focus());
47
47
  });
48
48
  let Z = (e) => {
49
- L(e);
50
- let t = R.current.get(e);
51
- if (T) {
49
+ R(e);
50
+ let t = z.current.get(e);
51
+ if (E) {
52
52
  let t = H.get(e)?.index;
53
53
  t !== void 0 && Y.scrollToIndex(t);
54
54
  }
55
55
  t ? t.focus() : X.current = e;
56
56
  }, De = (e) => {
57
- if (A?.(e), e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
57
+ if (j?.(e), e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
58
58
  let t = V;
59
59
  if (t === null) return;
60
60
  let r = e.target.getAttribute("role") === "treeitem", a = e.key === "Enter" || e.key === " ";
@@ -63,10 +63,10 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
63
63
  e.preventDefault();
64
64
  let n = d({
65
65
  key: i(e),
66
- nodes: y,
66
+ nodes: b,
67
67
  visible: B,
68
68
  focusId: t,
69
- expanded: F
69
+ expanded: I
70
70
  });
71
71
  if (!n) return;
72
72
  switch (n.type) {
@@ -89,8 +89,8 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
89
89
  break;
90
90
  }
91
91
  case "expandMany": {
92
- let e = n.ids.filter((e) => !F.includes(e)), t = e.flatMap((e) => H.get(e)?.node ?? []);
93
- U([...F, ...e], t);
92
+ let e = n.ids.filter((e) => !I.includes(e)), t = e.flatMap((e) => H.get(e)?.node ?? []);
93
+ U([...I, ...e], t);
94
94
  break;
95
95
  }
96
96
  }
@@ -99,27 +99,27 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
99
99
  if (!n(e.key)) return;
100
100
  let o = H.get(t)?.index;
101
101
  if (o === void 0) return;
102
- let s = ee(B, o, z(e.key));
102
+ let s = ee(B, o, Ce(e.key));
103
103
  s && (e.preventDefault(), Z(s));
104
104
  }, Oe = (e) => {
105
- if (j?.(e), T && e.target === e.currentTarget && V !== null) {
105
+ if (M?.(e), E && e.target === e.currentTarget && V !== null) {
106
106
  Z(V);
107
107
  return;
108
108
  }
109
109
  let t = e.target.dataset.treeId;
110
- t !== void 0 && L(t);
111
- }, Q = (e, n) => {
112
- let r = H.get(e.id);
110
+ t !== void 0 && R(t);
111
+ }, Q = (t, n) => {
112
+ let r = H.get(t.id);
113
113
  if (!r) return null;
114
- let i = u(e), a = i && F.includes(e.id), o = I.includes(e.id), s = i && e.loading === !0, c = `${P}-l-${r.index}`, l = `${P}-w-${r.index}`;
115
- return /* @__PURE__ */ m("li", {
116
- ref: (t) => {
117
- t ? R.current.set(e.id, t) : R.current.delete(e.id);
114
+ let i = u(t), a = i && I.includes(t.id), o = L.includes(t.id), s = i && t.loading === !0, c = `${F}-l-${r.index}`, l = `${F}-w-${r.index}`;
115
+ return /* @__PURE__ */ g("li", {
116
+ ref: (e) => {
117
+ e ? z.current.set(t.id, e) : z.current.delete(t.id);
118
118
  },
119
119
  role: "treeitem",
120
- "data-tree-id": e.id,
120
+ "data-tree-id": t.id,
121
121
  "data-vindex": n,
122
- className: t("kapi-tree__item", o && "kapi-tree__item--selected", a && "kapi-tree__item--open"),
122
+ className: e("kapi-tree__item", o && "kapi-tree__item--selected", a && "kapi-tree__item--open"),
123
123
  "aria-labelledby": c,
124
124
  "aria-describedby": s ? l : void 0,
125
125
  "aria-level": r.level,
@@ -127,83 +127,83 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
127
127
  "aria-posinset": r.posInSet,
128
128
  "aria-expanded": i ? a : void 0,
129
129
  "aria-selected": o,
130
- "aria-disabled": e.disabled || void 0,
130
+ "aria-disabled": t.disabled || void 0,
131
131
  "aria-busy": s || void 0,
132
- tabIndex: V === e.id ? 0 : -1,
133
- children: [/* @__PURE__ */ m("div", {
132
+ tabIndex: V === t.id ? 0 : -1,
133
+ children: [/* @__PURE__ */ g("div", {
134
134
  className: "kapi-tree__row",
135
135
  style: { "--kapi-tree-level": r.level },
136
- onClick: () => q(e),
136
+ onClick: () => q(t),
137
137
  children: [
138
- i ? /* @__PURE__ */ p("span", {
138
+ i ? /* @__PURE__ */ h("span", {
139
139
  className: "kapi-tree__toggle",
140
140
  "aria-hidden": "true",
141
- onClick: (t) => {
142
- t.stopPropagation(), we(e);
141
+ onClick: (e) => {
142
+ e.stopPropagation(), we(t);
143
143
  },
144
- children: /* @__PURE__ */ p(se, {
144
+ children: /* @__PURE__ */ h(_, {
145
145
  className: "kapi-tree__chevron kapi-flip-rtl",
146
146
  size: 16,
147
147
  strokeWidth: 2.2
148
148
  })
149
- }) : /* @__PURE__ */ p("span", {
149
+ }) : /* @__PURE__ */ h("span", {
150
150
  className: "kapi-tree__toggle kapi-tree__toggle--leaf",
151
151
  "aria-hidden": "true"
152
152
  }),
153
- /* @__PURE__ */ p("span", {
153
+ /* @__PURE__ */ h("span", {
154
154
  id: c,
155
155
  className: "kapi-tree__label",
156
- children: w ? w(e) : e.label
156
+ children: T ? T(t) : t.label
157
157
  }),
158
- s && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", {
158
+ s && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
159
159
  className: "kapi-tree__spinner kapi-spinner kapi-spinner--sm",
160
160
  "aria-hidden": "true"
161
- }), /* @__PURE__ */ p("span", {
161
+ }), /* @__PURE__ */ h("span", {
162
162
  id: l,
163
163
  className: "kapi-tree__sr",
164
- children: N.loading
164
+ children: P.loading
165
165
  })] })
166
166
  ]
167
- }), n === void 0 && a && e.children?.length ? /* @__PURE__ */ p("ul", {
167
+ }), n === void 0 && a && t.children?.length ? /* @__PURE__ */ h("ul", {
168
168
  role: "group",
169
169
  className: "kapi-tree__group",
170
- children: $(e.children)
170
+ children: $(t.children)
171
171
  }) : null]
172
- }, e.id);
173
- }, $ = (e) => e.map((e) => Q(e)), ke = () => /* @__PURE__ */ m(f, { children: [
174
- Y.padTop > 0 && /* @__PURE__ */ p("li", {
172
+ }, t.id);
173
+ }, $ = (e) => e.map((e) => Q(e)), ke = () => /* @__PURE__ */ g(m, { children: [
174
+ Y.padTop > 0 && /* @__PURE__ */ h("li", {
175
175
  role: "none",
176
176
  "aria-hidden": !0,
177
177
  className: "kapi-tree__pad",
178
178
  style: { height: Y.padTop }
179
179
  }),
180
180
  B.slice(Y.start, Y.end).map((e, t) => Q(e.node, Y.start + t)),
181
- Y.padBottom > 0 && /* @__PURE__ */ p("li", {
181
+ Y.padBottom > 0 && /* @__PURE__ */ h("li", {
182
182
  role: "none",
183
183
  "aria-hidden": !0,
184
184
  className: "kapi-tree__pad",
185
185
  style: { height: Y.padBottom }
186
186
  })
187
- ] }), Ae = !T || (() => {
187
+ ] }), Ae = !E || (() => {
188
188
  let e = V === null ? void 0 : H.get(V)?.index;
189
189
  return e === void 0 || e >= Y.start && e < Y.end;
190
190
  })();
191
- return /* @__PURE__ */ p("ul", {
192
- ...M,
191
+ return /* @__PURE__ */ h("ul", {
192
+ ...N,
193
193
  role: "tree",
194
- "aria-multiselectable": C || void 0,
195
- ref: T ? Te : k,
196
- className: t("kapi-tree", T && "kapi-tree--virtual", D),
197
- style: T ? {
198
- maxHeight: E,
199
- ...O
200
- } : O,
194
+ "aria-multiselectable": w || void 0,
195
+ ref: E ? Te : A,
196
+ className: e("kapi-tree", E && "kapi-tree--virtual", O),
197
+ style: E ? {
198
+ maxHeight: D,
199
+ ...k
200
+ } : k,
201
201
  ...Ae ? {} : { tabIndex: 0 },
202
202
  onKeyDown: De,
203
203
  onFocus: Oe,
204
- onScroll: T ? Y.onScroll : void 0,
205
- children: T ? ke() : $(y)
204
+ onScroll: E ? Y.onScroll : void 0,
205
+ children: E ? ke() : $(b)
206
206
  });
207
207
  }
208
208
  //#endregion
209
- export { _ as DEFAULT_TREE_LABELS, y as KapiTree };
209
+ export { v as DEFAULT_TREE_LABELS, b as KapiTree };
@@ -1,4 +1,5 @@
1
1
  import { type HTMLAttributes, type ReactNode, type Ref } from "react";
2
+ import type { KapiCloseReason } from "../closeReason.js";
2
3
  import type { KapiLabelsOverride } from "../labelsLogic.js";
3
4
  export type KapiWizardStep = {
4
5
  title: string;
@@ -36,7 +37,7 @@ export type KapiWizardProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
36
37
  * Se dispara con «Cancelar» (el botón del primer paso): el consumidor cierra el flujo (p. ej. el modal
37
38
  * que lo contiene), igual que el `onClose` de los overlays.
38
39
  */
39
- onClose?: (() => void) | undefined;
40
+ onClose?: ((reason: KapiCloseReason) => void) | undefined;
40
41
  /**
41
42
  * Nombre anterior de `onClose`; si llegan los dos, solo se llama a `onClose`.
42
43
  * @deprecated Usar `onClose` (la convención no usa `onCancel`).
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { KapiButton as e } from "../inputs/KapiButton.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 { KapiButton as t } from "../inputs/KapiButton.js";
4
+ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
5
5
  import { useControllableState as r } from "../../hooks/useControllableState.js";
6
6
  import { canJumpTo as i, clampStep as a, isThenable as o, resolveAdvance as s } from "./wizardLogic.js";
7
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
8
- import { useRef as d, useState as f } from "react";
7
+ import { useRef as c, useState as l } from "react";
8
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
9
  import { Check as p, ChevronLeft as m, ChevronRight as h } from "lucide-react";
10
10
  //#region src/components/navigation/KapiWizard.tsx
11
11
  var g = {
@@ -18,7 +18,7 @@ var g = {
18
18
  size: 15,
19
19
  strokeWidth: 2.2
20
20
  }, v = (e, t) => e === void 0 ? t : e, y = ({ steps: y, orientation: b = "horizontal", onFinish: x, onClose: S, onCancel: C, finishLabel: w, cancelLabel: T, backLabel: E, nextLabel: D, labels: O, step: k, defaultStep: A = 0, onStepChange: j, className: M, ...N }) => {
21
- let P = t("wizard", g, O), [F, I] = r(k, A, j), [L, R] = f(!1), z = d(0), B = d(0), V = a(F, y.length);
21
+ let P = n("wizard", g, O), [F, I] = r(k, A, j), [L, R] = l(!1), z = c(0), B = c(0), V = a(F, y.length);
22
22
  B.current = V;
23
23
  let H = y[V];
24
24
  if (!H) return null;
@@ -41,78 +41,78 @@ var g = {
41
41
  }
42
42
  let t = z.current += 1, n = V;
43
43
  R(!0), e.then((e) => q(t, n, !!e), () => q(t, n, !1));
44
- }, Y = /* @__PURE__ */ u("div", {
44
+ }, Y = /* @__PURE__ */ f("div", {
45
45
  className: "kapi-wz__nav",
46
- children: [/* @__PURE__ */ l(e, {
47
- onClick: V === 0 ? S ?? C : () => W(V - 1),
46
+ children: [/* @__PURE__ */ d(t, {
47
+ onClick: V === 0 ? () => S ? S("cancel") : C?.() : () => W(V - 1),
48
48
  disabled: L,
49
- children: V === 0 ? v(T, P.cancel) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(m, {
49
+ children: V === 0 ? v(T, P.cancel) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(m, {
50
50
  className: "kapi-flip-rtl",
51
51
  ..._
52
52
  }), v(E, P.back)] })
53
- }), /* @__PURE__ */ l(e, {
53
+ }), /* @__PURE__ */ d(t, {
54
54
  tone: "primary",
55
55
  onClick: J,
56
56
  disabled: L,
57
57
  "aria-busy": L || void 0,
58
- children: L ? P.validating : U ? v(w, P.finish) : /* @__PURE__ */ u(c, { children: [v(D, P.next), /* @__PURE__ */ l(h, {
58
+ children: L ? P.validating : U ? v(w, P.finish) : /* @__PURE__ */ f(u, { children: [v(D, P.next), /* @__PURE__ */ d(h, {
59
59
  className: "kapi-flip-rtl",
60
60
  ..._
61
61
  })] })
62
62
  })]
63
- }), X = /* @__PURE__ */ l("div", {
63
+ }), X = /* @__PURE__ */ d("div", {
64
64
  className: "kapi-wz__pane",
65
65
  children: H.content
66
66
  }, V);
67
- return b === "vertical" ? /* @__PURE__ */ u("div", {
67
+ return b === "vertical" ? /* @__PURE__ */ f("div", {
68
68
  ...N,
69
- className: n("kapi-wz kapi-wz--v", M),
70
- children: [/* @__PURE__ */ l("div", {
69
+ className: e("kapi-wz kapi-wz--v", M),
70
+ children: [/* @__PURE__ */ d("div", {
71
71
  className: "kapi-wz__rail",
72
- children: y.map((e, t) => /* @__PURE__ */ u("button", {
72
+ children: y.map((e, t) => /* @__PURE__ */ f("button", {
73
73
  type: "button",
74
74
  className: `kapi-wz__vstep${t === V ? " is-on" : ""}`,
75
75
  "aria-current": t === V ? "step" : void 0,
76
76
  onClick: () => G(t),
77
- children: [/* @__PURE__ */ l("span", {
77
+ children: [/* @__PURE__ */ d("span", {
78
78
  className: `kapi-step__dot${t < V ? " kapi-step__dot--done" : ""}${t === V ? " kapi-step__dot--on" : ""}`,
79
- children: t < V ? /* @__PURE__ */ l(p, {
79
+ children: t < V ? /* @__PURE__ */ d(p, {
80
80
  size: 13,
81
81
  strokeWidth: 3
82
82
  }) : t + 1
83
- }), /* @__PURE__ */ u("span", {
83
+ }), /* @__PURE__ */ f("span", {
84
84
  className: "kapi-wz__vlabel",
85
- children: [/* @__PURE__ */ l("b", { children: e.title }), e.desc && /* @__PURE__ */ l("span", { children: e.desc })]
85
+ children: [/* @__PURE__ */ d("b", { children: e.title }), e.desc && /* @__PURE__ */ d("span", { children: e.desc })]
86
86
  })]
87
87
  }, `${t}-${e.title}`))
88
- }), /* @__PURE__ */ u("div", {
88
+ }), /* @__PURE__ */ f("div", {
89
89
  className: "kapi-wz__main",
90
90
  children: [X, Y]
91
91
  })]
92
- }) : /* @__PURE__ */ u("div", {
92
+ }) : /* @__PURE__ */ f("div", {
93
93
  ...N,
94
- className: n("kapi-wz", M),
94
+ className: e("kapi-wz", M),
95
95
  children: [
96
- /* @__PURE__ */ l("div", {
96
+ /* @__PURE__ */ d("div", {
97
97
  className: "kapi-wz__steps",
98
- children: y.map((e, t) => /* @__PURE__ */ u("button", {
98
+ children: y.map((e, t) => /* @__PURE__ */ f("button", {
99
99
  type: "button",
100
100
  className: `kapi-wz__step${t === V ? " is-on" : ""}${t < V ? " is-done" : ""}`,
101
101
  "aria-current": t === V ? "step" : void 0,
102
102
  onClick: () => G(t),
103
103
  children: [
104
- /* @__PURE__ */ l("span", {
104
+ /* @__PURE__ */ d("span", {
105
105
  className: "kapi-wz__num",
106
- children: t < V ? /* @__PURE__ */ l(p, {
106
+ children: t < V ? /* @__PURE__ */ d(p, {
107
107
  size: 16,
108
108
  strokeWidth: 3
109
109
  }) : t + 1
110
110
  }),
111
- /* @__PURE__ */ l("span", {
111
+ /* @__PURE__ */ d("span", {
112
112
  className: "kapi-wz__st",
113
113
  children: e.title
114
114
  }),
115
- e.desc && /* @__PURE__ */ l("span", {
115
+ e.desc && /* @__PURE__ */ d("span", {
116
116
  className: "kapi-wz__ss",
117
117
  children: e.desc
118
118
  })
@@ -1,4 +1,5 @@
1
1
  import { type SubmitEvent, type ReactNode } from "react";
2
+ import type { KapiCloseReason } from "../closeReason.js";
2
3
  import { type KapiOffcanvasProps } from "./KapiOffcanvas.js";
3
4
  /**
4
5
  * Textos de los botones (clave `canvasForm` del provider). No hay prop `labels` propia: `labels` es la
@@ -10,8 +11,11 @@ export type KapiCanvasFormLabels = {
10
11
  };
11
12
  export declare const DEFAULT_CANVAS_FORM_LABELS: KapiCanvasFormLabels;
12
13
  export type KapiCanvasFormProps = Omit<KapiOffcanvasProps, "footer" | "children" | "onClose"> & {
13
- /** Pedido de cierre (X, fondo, Escape, Cancelar). Se ignora mientras se está guardando. */
14
- onClose: () => void;
14
+ /**
15
+ * Pedido de cierre, con la razón: `close-button` la X, `backdrop` el fondo, `escape` la tecla y
16
+ * `cancel` el botón Cancelar del pie. Se ignora mientras se está guardando.
17
+ */
18
+ onClose: (reason: KapiCloseReason) => void;
15
19
  /** Los campos del formulario. */
16
20
  children?: ReactNode;
17
21
  /**
@@ -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…"). */