@kapiuara/ui 0.5.0 → 0.7.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 (74) hide show
  1. package/README.md +123 -5
  2. package/dist/components/chat/KapiChatDivider.d.ts +15 -0
  3. package/dist/components/chat/KapiChatDivider.js +17 -0
  4. package/dist/components/chat/KapiChatList.d.ts +57 -0
  5. package/dist/components/chat/KapiChatList.js +71 -0
  6. package/dist/components/chat/KapiChatThread.d.ts +35 -0
  7. package/dist/components/chat/KapiChatThread.js +85 -0
  8. package/dist/components/chat/KapiComposer.d.ts +60 -0
  9. package/dist/components/chat/KapiComposer.js +91 -0
  10. package/dist/components/chat/KapiMessageBubble.d.ts +43 -0
  11. package/dist/components/chat/KapiMessageBubble.js +67 -0
  12. package/dist/components/chat/KapiTypingIndicator.d.ts +27 -0
  13. package/dist/components/chat/KapiTypingIndicator.js +34 -0
  14. package/dist/components/chat/chatLogic.d.ts +76 -0
  15. package/dist/components/chat/chatLogic.js +34 -0
  16. package/dist/components/chat/index.d.ts +14 -0
  17. package/dist/components/data/KapiTable.d.ts +25 -1
  18. package/dist/components/data/KapiTable.js +408 -390
  19. package/dist/components/data/index.d.ts +1 -1
  20. package/dist/components/data/tableLogic.d.ts +7 -0
  21. package/dist/components/data/tableLogic.js +21 -16
  22. package/dist/components/display/KapiCommentComposer.d.ts +4 -0
  23. package/dist/components/display/KapiCommentComposer.js +43 -46
  24. package/dist/components/display/commentLogic.d.ts +9 -2
  25. package/dist/components/display/commentLogic.js +1 -1
  26. package/dist/components/display/index.d.ts +1 -0
  27. package/dist/components/inputs/KapiButton.d.ts +9 -2
  28. package/dist/components/inputs/KapiButton.js +25 -15
  29. package/dist/components/inputs/KapiFacetedSearch.d.ts +29 -5
  30. package/dist/components/inputs/KapiFacetedSearch.js +161 -119
  31. package/dist/components/inputs/KapiSegmented.d.ts +2 -1
  32. package/dist/components/inputs/KapiSegmented.js +45 -44
  33. package/dist/components/inputs/facetedSearchLogic.d.ts +40 -9
  34. package/dist/components/inputs/facetedSearchLogic.js +38 -20
  35. package/dist/components/inputs/index.d.ts +2 -2
  36. package/dist/components/layout/KapiPanelParts.js +9 -9
  37. package/dist/components/layout/KapiRail.d.ts +1 -1
  38. package/dist/components/layout/KapiRail.js +60 -53
  39. package/dist/components/layout/KapiShell.d.ts +9 -2
  40. package/dist/components/layout/KapiShell.js +22 -22
  41. package/dist/components/locale/labelRegistry.d.ts +10 -0
  42. package/dist/components/navigation/KapiContextPanel.js +86 -86
  43. package/dist/components/navigation/KapiPanelGroup.js +18 -18
  44. package/dist/components/navigation/KapiTabs.d.ts +3 -1
  45. package/dist/components/navigation/KapiTabs.js +47 -46
  46. package/dist/components/navigation/MiniNavItem.js +1 -1
  47. package/dist/components/overlays/KapiCanvasForm.js +2 -6
  48. package/dist/components/overlays/KapiConfirm.js +1 -6
  49. package/dist/hooks/colorLogic.d.ts +26 -0
  50. package/dist/hooks/colorLogic.js +53 -0
  51. package/dist/hooks/dateFormat.d.ts +7 -0
  52. package/dist/hooks/dateFormat.js +16 -2
  53. package/dist/hooks/index.d.ts +7 -1
  54. package/dist/hooks/numberFormatLogic.d.ts +6 -0
  55. package/dist/hooks/numberFormatLogic.js +7 -0
  56. package/dist/hooks/rightClick.d.ts +10 -0
  57. package/dist/hooks/rightClick.js +10 -4
  58. package/dist/hooks/themeColorsLogic.d.ts +11 -0
  59. package/dist/hooks/themeColorsLogic.js +37 -0
  60. package/dist/hooks/themeContrastLogic.d.ts +23 -0
  61. package/dist/hooks/themeContrastLogic.js +46 -0
  62. package/dist/hooks/themeDeriveLogic.d.ts +52 -0
  63. package/dist/hooks/themeDeriveLogic.js +103 -0
  64. package/dist/hooks/useDragScroll.js +26 -23
  65. package/dist/hooks/useGlobalRightClick.js +28 -25
  66. package/dist/hooks/useKapiTheme.d.ts +28 -4
  67. package/dist/hooks/useKapiTheme.js +82 -50
  68. package/dist/hooks/useSubmitDraft.d.ts +34 -0
  69. package/dist/hooks/useSubmitDraft.js +28 -0
  70. package/dist/index.d.ts +1 -0
  71. package/dist/index.js +129 -119
  72. package/dist/kapi.css +1 -1
  73. package/dist/kapi.layered.css +1 -1
  74. package/package.json +3 -3
@@ -1,22 +1,22 @@
1
1
  "use client";
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
3
  import { joinClasses as t } from "../rootProps.js";
4
- import { canCollapse as n, clampCtxPanelWidth as r, ctxPanelClasses as i, ctxPanelWidthFromDrag as a, resolveCollapsed as o, stepCtxPanelWidth as s } from "./contextPanelLogic.js";
5
- import { activeIdIn as c } from "./activeItemLogic.js";
6
- import { CtxSlidingList as l } from "./CtxSlidingList.js";
7
- /* empty css */
8
- import { DEFAULT_LINK_LABELS as u } from "../locale/linkLabels.js";
9
4
  import "./navBadgeLogic.js";
10
- import { KapiNavBadge as d } from "./KapiNavBadge.js";
5
+ import { KapiNavBadge as n } from "./KapiNavBadge.js";
6
+ import { canCollapse as r, clampCtxPanelWidth as i, ctxPanelClasses as a, ctxPanelWidthFromDrag as o, resolveCollapsed as s, stepCtxPanelWidth as c } from "./contextPanelLogic.js";
7
+ import { activeIdIn as l } from "./activeItemLogic.js";
8
+ import { CtxSlidingList as u } from "./CtxSlidingList.js";
9
+ /* empty css */
10
+ import { DEFAULT_LINK_LABELS as d } from "../locale/linkLabels.js";
11
11
  import { KapiPanelMiniContext as f, useKapiPanelMini as p } from "./panelMini.js";
12
12
  import { MiniNavItem as m } from "./MiniNavItem.js";
13
13
  import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
14
- import { useLayoutEffect as ee, useRef as v, useState as y } from "react";
15
- import { ChevronsLeft as b, ChevronsRight as x, ExternalLink as S } from "lucide-react";
14
+ import { useLayoutEffect as v, useRef as y, useState as b } from "react";
15
+ import { ChevronsLeft as x, ChevronsRight as S, ExternalLink as C } from "lucide-react";
16
16
  //#region src/components/navigation/KapiContextPanel.tsx
17
- var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
18
- let { mini: i } = p(), a = e.detail !== void 0 || e.initials !== void 0, o = () => n?.(e.id);
19
- return i ? /* @__PURE__ */ g(m, {
17
+ var w = ({ item: e, active: t, onSelect: r, newTabLabel: i }) => {
18
+ let { mini: a } = p(), o = e.detail !== void 0 || e.initials !== void 0, s = () => r?.(e.id);
19
+ return a ? /* @__PURE__ */ g(m, {
20
20
  label: e.label,
21
21
  icon: e.icon,
22
22
  initials: e.initials,
@@ -25,17 +25,17 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
25
25
  badgeTone: e.badgeTone,
26
26
  badgeLabel: e.badgeLabel,
27
27
  disabled: e.disabled,
28
- ...!a && e.href !== void 0 ? {
28
+ ...!o && e.href !== void 0 ? {
29
29
  href: e.href,
30
30
  newTab: e.newTab,
31
- newTabLabel: r
32
- } : { onClick: o }
33
- }) : a ? /* @__PURE__ */ _("button", {
31
+ newTabLabel: i
32
+ } : { onClick: s }
33
+ }) : o ? /* @__PURE__ */ _("button", {
34
34
  type: "button",
35
35
  className: `kapi-ctxrec${t ? " kapi-ctxrec--on" : ""}`,
36
36
  "aria-current": t ? "page" : void 0,
37
37
  disabled: e.disabled,
38
- onClick: o,
38
+ onClick: s,
39
39
  children: [
40
40
  e.initials !== void 0 && /* @__PURE__ */ g("span", {
41
41
  className: "kapi-ctxrec__av kapi-ctxrec__av--tone",
@@ -51,7 +51,7 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
51
51
  children: e.detail
52
52
  })]
53
53
  }),
54
- /* @__PURE__ */ g(d, {
54
+ /* @__PURE__ */ g(n, {
55
55
  value: e.badge,
56
56
  tone: e.badgeTone,
57
57
  label: e.badgeLabel,
@@ -64,13 +64,13 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
64
64
  className: `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`,
65
65
  "aria-current": t ? "page" : void 0,
66
66
  disabled: e.disabled,
67
- onClick: o,
67
+ onClick: s,
68
68
  children: [
69
69
  /* @__PURE__ */ _("span", {
70
70
  className: "kapi-ctxitem__main",
71
71
  children: [e.icon, e.label]
72
72
  }),
73
- /* @__PURE__ */ g(d, {
73
+ /* @__PURE__ */ g(n, {
74
74
  value: e.badge,
75
75
  tone: e.badgeTone,
76
76
  label: e.badgeLabel,
@@ -90,26 +90,26 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
90
90
  className: "kapi-ctxitem__main",
91
91
  children: [e.icon, e.label]
92
92
  }),
93
- /* @__PURE__ */ g(d, {
93
+ /* @__PURE__ */ g(n, {
94
94
  value: e.badge,
95
95
  tone: e.badgeTone,
96
96
  label: e.badgeLabel,
97
97
  max: 999
98
98
  }),
99
99
  e.trailing,
100
- e.external && /* @__PURE__ */ g(S, {
100
+ e.external && /* @__PURE__ */ g(C, {
101
101
  className: "kapi-ctxitem__ext",
102
102
  size: 14,
103
103
  "aria-hidden": "true"
104
104
  }),
105
105
  e.newTab && /* @__PURE__ */ g("span", {
106
106
  className: "kapi-ctxitem__sr",
107
- children: r
107
+ children: i
108
108
  })
109
109
  ]
110
110
  });
111
- }, w = ({ sections: t, activeId: n, onSelect: r, search: i, hint: a, labels: o }) => {
112
- let s = e("link", u, o);
111
+ }, T = ({ sections: t, activeId: n, onSelect: r, search: i, hint: a, labels: o }) => {
112
+ let s = e("link", d, o);
113
113
  return /* @__PURE__ */ _(h, { children: [
114
114
  i && /* @__PURE__ */ g("input", {
115
115
  type: "search",
@@ -127,9 +127,9 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
127
127
  className: "kapi-ct",
128
128
  children: e.label
129
129
  }),
130
- /* @__PURE__ */ g(l, {
131
- active: c(e.items, n),
132
- children: e.items.map((e) => /* @__PURE__ */ g(C, {
130
+ /* @__PURE__ */ g(u, {
131
+ active: l(e.items, n),
132
+ children: e.items.map((e) => /* @__PURE__ */ g(w, {
133
133
  item: e,
134
134
  active: e.id === n,
135
135
  onSelect: r,
@@ -143,48 +143,48 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
143
143
  children: a
144
144
  })
145
145
  ] });
146
- }, T = {
146
+ }, E = {
147
147
  resize: "Redimensionar panel",
148
148
  collapse: "Plegar panel",
149
149
  expand: "Desplegar panel",
150
150
  region: "Panel contextual"
151
- }, E = ({ title: c, actions: l, collapsed: u, defaultCollapsed: d, onCollapsedChange: p, collapseLabel: m, expandLabel: h, side: S = "left", collapsedMode: C = "hidden", resizable: E = !1, minWidth: D = 200, maxWidth: O = 420, "aria-label": k, labels: A, className: j, style: M, id: N, ...P }) => {
152
- let F = e("contextPanel", T, A), I = m ?? F.collapse, L = h ?? F.expand, R = k ?? F.region, [z, B] = y(d ?? !1), [V, H] = y(null), [U, W] = y(!1), G = v(null), K = v(null), q = o(u, z), J = v(null), [Y, X] = y(null);
153
- ee(() => {
154
- Y && (q === Y.next && J.current?.focus(), X(null));
155
- }, [Y, q]);
156
- let Z = (e) => {
157
- X({ next: e }), u === void 0 && B(e), p?.(e);
158
- }, te = S === "right" ? x : b, ne = S === "right" ? b : x, Q = () => V ?? K.current?.offsetWidth ?? 258, re = (e) => {
159
- e.button === 0 && (G.current = {
151
+ }, D = ({ title: n, actions: l, collapsed: u, defaultCollapsed: d, onCollapsedChange: p, collapseLabel: m, expandLabel: h, side: C = "left", collapsedMode: w = "hidden", resizable: D = !1, minWidth: O = 200, maxWidth: k = 420, "aria-label": A, labels: j, className: M, style: N, id: P, ...F }) => {
152
+ let I = e("contextPanel", E, j), ee = m ?? I.collapse, te = h ?? I.expand, L = A ?? I.region, [R, z] = b(d ?? !1), [B, V] = b(null), [H, U] = b(!1), W = y(null), G = y(null), K = s(u, R), q = y(null), [J, Y] = b(null);
153
+ v(() => {
154
+ J && (K === J.next && q.current?.focus(), Y(null));
155
+ }, [J, K]);
156
+ let X = (e) => {
157
+ Y({ next: e }), u === void 0 && z(e), p?.(e);
158
+ }, Z = C === "right" ? S : x, ne = C === "right" ? x : S, Q = () => B ?? G.current?.offsetWidth ?? 258, re = (e) => {
159
+ e.button === 0 && (W.current = {
160
160
  startX: e.clientX,
161
161
  startWidth: Q()
162
- }, e.currentTarget.setPointerCapture(e.pointerId), W(!0), e.preventDefault());
162
+ }, e.currentTarget.setPointerCapture(e.pointerId), U(!0), e.preventDefault());
163
163
  }, ie = (e) => {
164
- let t = G.current;
165
- t && H(a(S, t.startWidth, t.startX, e.clientX, D, O));
164
+ let t = W.current;
165
+ t && V(o(C, t.startWidth, t.startX, e.clientX, O, k));
166
166
  }, $ = (e) => {
167
- G.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), W(!1);
167
+ W.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), U(!1);
168
168
  }, ae = (e) => {
169
- let t = s(S, Q(), e.key, D, O);
170
- t !== null && (e.preventDefault(), H(t));
169
+ let t = c(C, Q(), e.key, O, k);
170
+ t !== null && (e.preventDefault(), V(t));
171
171
  };
172
- if (q) {
173
- let e = C === "mini";
172
+ if (K) {
173
+ let e = w === "mini";
174
174
  return /* @__PURE__ */ _("aside", {
175
- id: N,
176
- className: t(i({
177
- side: S,
175
+ id: P,
176
+ className: t(a({
177
+ side: C,
178
178
  collapsed: !0
179
- }), e && "is-mini kapi-navmini", j),
180
- style: M,
181
- "aria-label": R,
179
+ }), e && "is-mini kapi-navmini", M),
180
+ style: N,
181
+ "aria-label": L,
182
182
  children: [/* @__PURE__ */ g("button", {
183
- ref: J,
183
+ ref: q,
184
184
  type: "button",
185
185
  className: "kapi-paneltoggle",
186
- onClick: () => Z(!1),
187
- "aria-label": L,
186
+ onClick: () => X(!1),
187
+ "aria-label": te,
188
188
  children: /* @__PURE__ */ g(ne, {
189
189
  size: 16,
190
190
  strokeWidth: 2,
@@ -193,38 +193,38 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
193
193
  }), e && /* @__PURE__ */ g(f.Provider, {
194
194
  value: {
195
195
  mini: !0,
196
- expand: () => Z(!1),
197
- tooltipSide: S === "right" ? "left" : "right"
196
+ expand: () => X(!1),
197
+ tooltipSide: C === "right" ? "left" : "right"
198
198
  },
199
- children: /* @__PURE__ */ g(w, {
200
- ...P,
201
- labels: A
199
+ children: /* @__PURE__ */ g(T, {
200
+ ...F,
201
+ labels: j
202
202
  })
203
203
  })]
204
204
  });
205
205
  }
206
206
  return /* @__PURE__ */ _("aside", {
207
- ref: K,
208
- id: N,
209
- className: t(i({
210
- side: S,
211
- resizing: U
212
- }), j),
213
- "aria-label": R,
214
- "data-resizable": E || void 0,
215
- style: E && V !== null ? {
216
- ...M,
217
- width: V
218
- } : M,
207
+ ref: G,
208
+ id: P,
209
+ className: t(a({
210
+ side: C,
211
+ resizing: H
212
+ }), M),
213
+ "aria-label": L,
214
+ "data-resizable": D || void 0,
215
+ style: D && B !== null ? {
216
+ ...N,
217
+ width: B
218
+ } : N,
219
219
  children: [
220
- E && /* @__PURE__ */ g("div", {
220
+ D && /* @__PURE__ */ g("div", {
221
221
  className: "kapi-ctxpanel__resize",
222
222
  role: "separator",
223
223
  "aria-orientation": "vertical",
224
- "aria-label": F.resize,
225
- "aria-valuemin": D,
226
- "aria-valuemax": O,
227
- "aria-valuenow": r(V ?? 258, D, O),
224
+ "aria-label": I.resize,
225
+ "aria-valuemin": O,
226
+ "aria-valuemax": k,
227
+ "aria-valuenow": i(B ?? 258, O, k),
228
228
  tabIndex: 0,
229
229
  onPointerDown: re,
230
230
  onPointerMove: ie,
@@ -234,19 +234,19 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
234
234
  }),
235
235
  /* @__PURE__ */ _("div", {
236
236
  className: "kapi-ctxpanel__head",
237
- children: [/* @__PURE__ */ g("span", { children: c }), /* @__PURE__ */ _("div", {
237
+ children: [/* @__PURE__ */ g("span", { children: n }), /* @__PURE__ */ _("div", {
238
238
  className: "kapi-ctxpanel__actions",
239
- children: [l, n({
239
+ children: [l, r({
240
240
  collapsed: u,
241
241
  defaultCollapsed: d,
242
242
  onCollapsedChange: p
243
243
  }) && /* @__PURE__ */ g("button", {
244
- ref: J,
244
+ ref: q,
245
245
  type: "button",
246
246
  className: "kapi-paneltoggle",
247
- onClick: () => Z(!0),
248
- "aria-label": I,
249
- children: /* @__PURE__ */ g(te, {
247
+ onClick: () => X(!0),
248
+ "aria-label": ee,
249
+ children: /* @__PURE__ */ g(Z, {
250
250
  size: 16,
251
251
  strokeWidth: 2,
252
252
  "aria-hidden": "true"
@@ -254,12 +254,12 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
254
254
  })]
255
255
  })]
256
256
  }),
257
- /* @__PURE__ */ g(w, {
258
- ...P,
259
- labels: A
257
+ /* @__PURE__ */ g(T, {
258
+ ...F,
259
+ labels: j
260
260
  })
261
261
  ]
262
262
  });
263
263
  };
264
264
  //#endregion
265
- export { T as DEFAULT_CONTEXT_PANEL_LABELS, E as KapiContextPanel, w as KapiContextSections };
265
+ export { E as DEFAULT_CONTEXT_PANEL_LABELS, D as KapiContextPanel, T as KapiContextSections };
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
- import { activeIdIn as t } from "./activeItemLogic.js";
4
- import { CtxSlidingList as n } from "./CtxSlidingList.js";
5
- /* empty css */
6
- import { DEFAULT_LINK_LABELS as r } from "../locale/linkLabels.js";
7
3
  import "./navBadgeLogic.js";
8
- import { KapiNavBadge as i } from "./KapiNavBadge.js";
4
+ import { KapiNavBadge as t } from "./KapiNavBadge.js";
5
+ import { activeIdIn as n } from "./activeItemLogic.js";
6
+ import { CtxSlidingList as r } from "./CtxSlidingList.js";
7
+ /* empty css */
8
+ import { DEFAULT_LINK_LABELS as i } from "../locale/linkLabels.js";
9
9
  import { useKapiPanelMini as a } from "./panelMini.js";
10
10
  import { MiniNavItem as o } from "./MiniNavItem.js";
11
11
  import { formatCount as s, panelGroupClasses as c, resolveOpen as l } from "./panelGroupLogic.js";
@@ -19,20 +19,20 @@ var g = ({ value: e }) => {
19
19
  className: "kapi-panelgroup__count",
20
20
  children: t
21
21
  });
22
- }, _ = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
23
- let a = `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`, o = /* @__PURE__ */ d("span", {
22
+ }, _ = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
23
+ let a = `kapi-ctxitem${n ? " kapi-ctxitem--on" : ""}`, o = /* @__PURE__ */ d("span", {
24
24
  className: "kapi-ctxitem__main",
25
25
  children: [e.icon, e.label]
26
26
  });
27
27
  return e.href === void 0 ? /* @__PURE__ */ d("button", {
28
28
  type: "button",
29
29
  className: a,
30
- "aria-current": t ? "page" : void 0,
30
+ "aria-current": n ? "page" : void 0,
31
31
  disabled: e.disabled,
32
- onClick: () => n?.(e.id),
32
+ onClick: () => r?.(e.id),
33
33
  children: [
34
34
  o,
35
- /* @__PURE__ */ u(i, {
35
+ /* @__PURE__ */ u(t, {
36
36
  value: e.badge,
37
37
  tone: e.badgeTone,
38
38
  label: e.badgeLabel,
@@ -45,11 +45,11 @@ var g = ({ value: e }) => {
45
45
  href: e.disabled ? void 0 : e.href,
46
46
  rel: "noopener noreferrer",
47
47
  target: e.newTab ? "_blank" : void 0,
48
- "aria-current": t ? "page" : void 0,
48
+ "aria-current": n ? "page" : void 0,
49
49
  "aria-disabled": e.disabled || void 0,
50
50
  children: [
51
51
  o,
52
- /* @__PURE__ */ u(i, {
52
+ /* @__PURE__ */ u(t, {
53
53
  value: e.badge,
54
54
  tone: e.badgeTone,
55
55
  label: e.badgeLabel,
@@ -63,13 +63,13 @@ var g = ({ value: e }) => {
63
63
  }),
64
64
  e.newTab && /* @__PURE__ */ u("span", {
65
65
  className: "kapi-ctxitem__sr",
66
- children: r
66
+ children: i
67
67
  })
68
68
  ]
69
69
  });
70
70
  };
71
71
  function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x, items: S, activeId: C, onSelect: w, open: T, defaultOpen: E = !1, onOpenChange: D, className: O, style: k, id: A, "aria-label": j, labels: M }) {
72
- let N = e("link", r, M), P = f(), F = `${P}-body`, I = `${P}-head`, [L, R] = p(E), z = l(T, L), B = (e) => {
72
+ let N = e("link", i, M), P = f(), F = `${P}-body`, I = `${P}-head`, [L, R] = p(E), z = l(T, L), B = (e) => {
73
73
  T === void 0 && R(e), D?.(e);
74
74
  }, V = () => B(!z), { mini: H, expand: U } = a();
75
75
  return H ? /* @__PURE__ */ u("div", {
@@ -82,7 +82,7 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
82
82
  children: /* @__PURE__ */ u(o, {
83
83
  label: s,
84
84
  icon: x,
85
- active: t(S, C) !== null,
85
+ active: n(S, C) !== null,
86
86
  badge: v,
87
87
  badgeTone: y,
88
88
  badgeLabel: b,
@@ -109,7 +109,7 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
109
109
  className: "kapi-panelgroup__label",
110
110
  children: [x, s]
111
111
  }),
112
- /* @__PURE__ */ u(i, {
112
+ /* @__PURE__ */ u(t, {
113
113
  value: v,
114
114
  tone: y,
115
115
  label: b,
@@ -132,8 +132,8 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
132
132
  inert: !z,
133
133
  children: /* @__PURE__ */ u("div", {
134
134
  className: "kapi-panelgroup__clip",
135
- children: /* @__PURE__ */ u(n, {
136
- active: t(S, C),
135
+ children: /* @__PURE__ */ u(r, {
136
+ active: n(S, C),
137
137
  children: S.map((e) => /* @__PURE__ */ u(_, {
138
138
  item: e,
139
139
  active: e.id === C,
@@ -8,7 +8,9 @@ export type KapiTabItem<Id extends string = string> = {
8
8
  label: ReactNode;
9
9
  /** Ícono (lucide-react) antes del label. */
10
10
  icon?: ReactNode | undefined;
11
- /** Contador en una píldora tras el label (p. ej. documentos adjuntos); `0` también se muestra. */
11
+ /** Contador en una píldora tras el label (p. ej. documentos adjuntos); `0` también se muestra. Se
12
+ * formatea con los separadores de miles del español, que agrupa desde cinco cifras
13
+ * (`14760` → «14.760»; `4760` queda «4760»). */
12
14
  count?: number | undefined;
13
15
  };
14
16
  /**
@@ -1,81 +1,82 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
3
  import { useSlidingIndicator as t } from "../../hooks/useSlidingIndicator.js";
4
+ import { formatCount as n } from "../../hooks/numberFormatLogic.js";
5
+ import { useScrollEdges as r } from "../../hooks/useScrollEdges.js";
4
6
  /* empty css */
5
- import { useScrollEdges as n } from "../../hooks/useScrollEdges.js";
6
- import { nextTabId as r, tabClasses as i, tabId as a, tabPanelId as o } from "./tabsLogic.js";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
- import { useCallback as u, useId as d, useLayoutEffect as f, useRef as p } from "react";
7
+ import { nextTabId as i, tabClasses as a, tabId as o, tabPanelId as s } from "./tabsLogic.js";
8
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
9
+ import { useCallback as d, useId as f, useLayoutEffect as p, useRef as m } from "react";
9
10
  //#region src/components/navigation/KapiTabs.tsx
10
- function m({ tabs: m, value: h, onChange: g, className: _, idBase: v, onKeyDown: y, ...b }) {
11
- let x = d(), S = v ?? x, C = p({}), { containerRef: w, indicatorRef: T } = t({
12
- active: h,
13
- deps: [m],
11
+ function h({ tabs: h, value: g, onChange: _, className: v, idBase: y, onKeyDown: b, ...x }) {
12
+ let S = f(), C = y ?? S, w = m({}), { containerRef: T, indicatorRef: E } = t({
13
+ active: g,
14
+ deps: [h],
14
15
  findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
15
- }), { ref: E, edges: D, reveal: O } = n({ axis: "x" }), k = u((e) => {
16
- w.current = e, E.current = e;
17
- }, [w, E]), A = p(!1);
18
- f(() => {
19
- let e = w.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
20
- e && O(e, { instant: !A.current }), A.current = !0;
16
+ }), { ref: D, edges: O, reveal: k } = r({ axis: "x" }), A = d((e) => {
17
+ T.current = e, D.current = e;
18
+ }, [T, D]), j = m(!1);
19
+ p(() => {
20
+ let e = T.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
21
+ e && k(e, { instant: !j.current }), j.current = !0;
21
22
  }, [
22
- h,
23
- w,
24
- O
23
+ g,
24
+ T,
25
+ k
25
26
  ]);
26
- let j = (e) => {
27
- if (y?.(e), e.defaultPrevented) return;
28
- let t = r(m.map((e) => e.id), h, e.key);
29
- t !== void 0 && (e.preventDefault(), g(t), C.current[t]?.focus());
27
+ let M = (e) => {
28
+ if (b?.(e), e.defaultPrevented) return;
29
+ let t = i(h.map((e) => e.id), g, e.key);
30
+ t !== void 0 && (e.preventDefault(), _(t), w.current[t]?.focus());
30
31
  };
31
- return /* @__PURE__ */ l("div", {
32
- ...b,
33
- ref: k,
34
- className: e("kapi-tabs", "kapi-fade-x", _),
35
- "data-edge-start": D.start ? "" : void 0,
36
- "data-edge-end": D.end ? "" : void 0,
32
+ return /* @__PURE__ */ u("div", {
33
+ ...x,
34
+ ref: A,
35
+ className: e("kapi-tabs", "kapi-fade-x", v),
36
+ "data-edge-start": O.start ? "" : void 0,
37
+ "data-edge-end": O.end ? "" : void 0,
37
38
  role: "tablist",
38
- onKeyDown: j,
39
- children: [/* @__PURE__ */ c("span", {
40
- ref: T,
39
+ onKeyDown: M,
40
+ children: [/* @__PURE__ */ l("span", {
41
+ ref: E,
41
42
  className: "kapi-tabs__indicator",
42
43
  "aria-hidden": "true"
43
- }), m.map((e) => {
44
- let t = e.id === h;
45
- return /* @__PURE__ */ l("button", {
44
+ }), h.map((e) => {
45
+ let t = e.id === g;
46
+ return /* @__PURE__ */ u("button", {
46
47
  ref: (t) => {
47
- C.current[e.id] = t;
48
+ w.current[e.id] = t;
48
49
  },
49
50
  type: "button",
50
- id: a(S, e.id),
51
+ id: o(C, e.id),
51
52
  role: "tab",
52
- "aria-controls": v ? o(v, e.id) : void 0,
53
+ "aria-controls": y ? s(y, e.id) : void 0,
53
54
  "aria-selected": t,
54
55
  tabIndex: t ? 0 : -1,
55
- className: i(t),
56
- onClick: () => g(e.id),
56
+ className: a(t),
57
+ onClick: () => _(e.id),
57
58
  children: [
58
59
  e.icon,
59
60
  e.label,
60
- e.count !== void 0 && /* @__PURE__ */ l(s, { children: [" ", /* @__PURE__ */ c("span", {
61
+ e.count !== void 0 && /* @__PURE__ */ u(c, { children: [" ", /* @__PURE__ */ l("span", {
61
62
  className: "kapi-tabs__count",
62
- children: e.count
63
+ children: n(e.count)
63
64
  })] })
64
65
  ]
65
66
  }, e.id);
66
67
  })]
67
68
  });
68
69
  }
69
- function h({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: s }) {
70
- return /* @__PURE__ */ c("div", {
71
- id: o(e, t),
70
+ function g({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: a }) {
71
+ return /* @__PURE__ */ l("div", {
72
+ id: s(e, t),
72
73
  role: "tabpanel",
73
- "aria-labelledby": a(e, t),
74
+ "aria-labelledby": o(e, t),
74
75
  tabIndex: 0,
75
76
  hidden: !n,
76
77
  className: i,
77
- children: n || r ? s : null
78
+ children: n || r ? a : null
78
79
  });
79
80
  }
80
81
  //#endregion
81
- export { h as KapiTabPanel, m as KapiTabs };
82
+ export { g as KapiTabPanel, h as KapiTabs };
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
3
  import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
4
- /* empty css */
5
4
  import { navBadgeA11yText as n } from "./navBadgeLogic.js";
6
5
  import { KapiNavBadge as r } from "./KapiNavBadge.js";
6
+ /* empty css */
7
7
  import { useKapiPanelMini as i } from "./panelMini.js";
8
8
  import { miniInitial as a, miniTooltipLabel as o, nodeText as s } from "./panelMiniLogic.js";
9
9
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
@@ -34,12 +34,8 @@ var f = {
34
34
  variant: "primary",
35
35
  type: "submit",
36
36
  form: E,
37
- disabled: D || y,
38
- "aria-busy": D,
39
- icon: D ? /* @__PURE__ */ a("span", {
40
- className: "kapi-spinner kapi-spinner--sm",
41
- "aria-hidden": "true"
42
- }) : void 0,
37
+ loading: D,
38
+ disabled: y,
43
39
  children: _ ?? w.submit
44
40
  })] });
45
41
  return /* @__PURE__ */ a(n, {
@@ -56,12 +56,7 @@ var f = {
56
56
  children: m ?? w.cancel
57
57
  }), /* @__PURE__ */ i(e, {
58
58
  variant: D,
59
- disabled: g,
60
- "aria-busy": g || void 0,
61
- icon: g ? /* @__PURE__ */ i("span", {
62
- className: "kapi-spinner kapi-confirm__spinner",
63
- "aria-hidden": "true"
64
- }) : void 0,
59
+ loading: g,
65
60
  onClick: v,
66
61
  children: d ?? w[T]
67
62
  })] }),
@@ -0,0 +1,26 @@
1
+ /** An sRGB color: channels 0-255 and alpha 0-1. */
2
+ export type KapiRgbColor = {
3
+ /** Red channel, 0-255. */
4
+ r: number;
5
+ /** Green channel, 0-255. */
6
+ g: number;
7
+ /** Blue channel, 0-255. */
8
+ b: number;
9
+ /** Alpha, 0 (transparent) to 1 (opaque). */
10
+ a: number;
11
+ };
12
+ /**
13
+ * Parses `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()` (comma or space separated, optional
14
+ * alpha as number or percentage). Returns `null` for anything else; never throws.
15
+ */
16
+ export declare const parseColor: (input: string) => KapiRgbColor | null;
17
+ /** WCAG 2.1 relative luminance, 0 (black) to 1 (white). Alpha is ignored. */
18
+ export declare const relativeLuminance: (color: KapiRgbColor) => number;
19
+ /** WCAG 2.1 contrast ratio, 1 (identical) to 21 (black on white). Symmetric in its arguments. */
20
+ export declare const contrastRatio: (a: KapiRgbColor, b: KapiRgbColor) => number;
21
+ /** Mixes two colors in sRGB; `pct` (0-100) is how much of `a` goes in. Alpha is mixed too. */
22
+ export declare const mixColors: (a: KapiRgbColor, b: KapiRgbColor, pct: number) => KapiRgbColor;
23
+ /** The candidate with the highest contrast against `background`; the first one wins a tie. */
24
+ export declare const readableForeground: (background: KapiRgbColor, candidates: readonly [KapiRgbColor, ...KapiRgbColor[]]) => KapiRgbColor;
25
+ /** Formats a color as lowercase `#rrggbb` (channels rounded; alpha dropped). */
26
+ export declare const formatHex: (color: KapiRgbColor) => string;