@kapiuara/ui 0.16.0 → 0.18.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 (243) hide show
  1. package/README.md +430 -20
  2. package/dist/components/chat/KapiChatThread.js +4 -4
  3. package/dist/components/chat/KapiComposer.js +8 -8
  4. package/dist/components/data/KapiDataTable.js +4 -4
  5. package/dist/components/data/KapiScatterChart.d.ts +56 -0
  6. package/dist/components/data/KapiScatterChart.js +90 -0
  7. package/dist/components/data/KapiSparkline.d.ts +2 -1
  8. package/dist/components/data/KapiSparkline.js +29 -26
  9. package/dist/components/data/KapiTableFilter.js +6 -6
  10. package/dist/components/data/chartFrame.d.ts +20 -2
  11. package/dist/components/data/chartFrame.js +33 -24
  12. package/dist/components/data/index.d.ts +4 -0
  13. package/dist/components/data/scatterLogic.d.ts +56 -0
  14. package/dist/components/data/scatterLogic.js +43 -0
  15. package/dist/components/data/tableCells.d.ts +12 -1
  16. package/dist/components/data/tableCells.js +49 -51
  17. package/dist/components/data/useTableSelection.js +3 -3
  18. package/dist/components/display/KapiAnnotation.js +68 -63
  19. package/dist/components/display/KapiAvatar.d.ts +6 -4
  20. package/dist/components/display/KapiAvatar.js +33 -28
  21. package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
  22. package/dist/components/display/KapiAvatarGroup.js +25 -23
  23. package/dist/components/display/KapiCodeBlock.d.ts +48 -0
  24. package/dist/components/display/KapiCodeBlock.js +44 -0
  25. package/dist/components/display/KapiCommentComposer.js +6 -6
  26. package/dist/components/display/KapiDiff.d.ts +62 -0
  27. package/dist/components/display/KapiDiff.js +118 -0
  28. package/dist/components/display/KapiHighlight.d.ts +27 -0
  29. package/dist/components/display/KapiHighlight.js +21 -0
  30. package/dist/components/display/KapiIconTile.d.ts +2 -1
  31. package/dist/components/display/KapiIconTile.js +23 -21
  32. package/dist/components/display/KapiStat.d.ts +3 -2
  33. package/dist/components/display/KapiStat.js +32 -26
  34. package/dist/components/display/KapiTag.d.ts +4 -3
  35. package/dist/components/display/KapiTag.js +29 -24
  36. package/dist/components/display/KapiTimeline.d.ts +19 -2
  37. package/dist/components/display/KapiTimeline.js +38 -23
  38. package/dist/components/display/annotationLogic.d.ts +2 -1
  39. package/dist/components/display/annotationLogic.js +7 -6
  40. package/dist/components/display/avatarGroupSlots.d.ts +6 -0
  41. package/dist/components/display/avatarGroupSlots.js +9 -0
  42. package/dist/components/display/codeBlockSlots.d.ts +10 -0
  43. package/dist/components/display/codeBlockSlots.js +13 -0
  44. package/dist/components/display/diffLogic.d.ts +58 -0
  45. package/dist/components/display/diffLogic.js +96 -0
  46. package/dist/components/display/diffSlots.d.ts +14 -0
  47. package/dist/components/display/diffSlots.js +17 -0
  48. package/dist/components/display/highlightLogic.d.ts +18 -0
  49. package/dist/components/display/highlightLogic.js +26 -0
  50. package/dist/components/display/highlightSlots.d.ts +5 -0
  51. package/dist/components/display/highlightSlots.js +8 -0
  52. package/dist/components/display/iconTileLogic.d.ts +2 -2
  53. package/dist/components/display/iconTileLogic.js +7 -6
  54. package/dist/components/display/index.d.ts +9 -1
  55. package/dist/components/display/statLogic.d.ts +2 -1
  56. package/dist/components/display/statLogic.js +7 -6
  57. package/dist/components/display/tagLogic.d.ts +2 -1
  58. package/dist/components/display/tagLogic.js +7 -6
  59. package/dist/components/display/timelineLogic.d.ts +20 -2
  60. package/dist/components/display/timelineLogic.js +10 -2
  61. package/dist/components/feedback/KapiAlert.d.ts +6 -1
  62. package/dist/components/feedback/KapiAlert.js +45 -44
  63. package/dist/components/feedback/KapiCountdown.d.ts +12 -1
  64. package/dist/components/feedback/KapiCountdown.js +34 -31
  65. package/dist/components/feedback/KapiEmpty.d.ts +6 -1
  66. package/dist/components/feedback/KapiEmpty.js +20 -18
  67. package/dist/components/feedback/KapiFab.js +108 -108
  68. package/dist/components/feedback/KapiProgress.js +63 -54
  69. package/dist/components/feedback/KapiSpinner.d.ts +48 -0
  70. package/dist/components/feedback/KapiSpinner.js +27 -0
  71. package/dist/components/feedback/KapiToastContainer.js +10 -10
  72. package/dist/components/feedback/KapiTour.js +13 -13
  73. package/dist/components/feedback/alertSlots.d.ts +9 -0
  74. package/dist/components/feedback/alertSlots.js +12 -0
  75. package/dist/components/feedback/countdownSlots.d.ts +6 -0
  76. package/dist/components/feedback/countdownSlots.js +9 -0
  77. package/dist/components/feedback/emptySlots.d.ts +8 -0
  78. package/dist/components/feedback/emptySlots.js +11 -0
  79. package/dist/components/feedback/index.d.ts +5 -3
  80. package/dist/components/feedback/progressLogic.d.ts +2 -1
  81. package/dist/components/feedback/progressLogic.js +9 -8
  82. package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
  83. package/dist/components/inputs/KapiAutocomplete.js +86 -85
  84. package/dist/components/inputs/KapiChecklist.d.ts +7 -1
  85. package/dist/components/inputs/KapiChecklist.js +53 -52
  86. package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
  87. package/dist/components/inputs/KapiCopyButton.js +35 -0
  88. package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
  89. package/dist/components/inputs/KapiDatePicker.js +118 -116
  90. package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
  91. package/dist/components/inputs/KapiDateRangePicker.js +136 -135
  92. package/dist/components/inputs/KapiFacetedSearch.js +5 -5
  93. package/dist/components/inputs/KapiField.d.ts +9 -1
  94. package/dist/components/inputs/KapiField.js +43 -42
  95. package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
  96. package/dist/components/inputs/KapiFileUpload.js +83 -70
  97. package/dist/components/inputs/KapiInput.d.ts +29 -1
  98. package/dist/components/inputs/KapiInput.js +74 -51
  99. package/dist/components/inputs/KapiMaskedInput.js +26 -26
  100. package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
  101. package/dist/components/inputs/KapiNumberStepper.js +24 -23
  102. package/dist/components/inputs/KapiPinInput.d.ts +72 -0
  103. package/dist/components/inputs/KapiPinInput.js +75 -0
  104. package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
  105. package/dist/components/inputs/KapiPropsForm.js +78 -0
  106. package/dist/components/inputs/KapiRating.d.ts +7 -1
  107. package/dist/components/inputs/KapiRating.js +39 -38
  108. package/dist/components/inputs/KapiSearchChip.js +5 -5
  109. package/dist/components/inputs/KapiSegmented.d.ts +13 -5
  110. package/dist/components/inputs/KapiSegmented.js +81 -77
  111. package/dist/components/inputs/KapiSelect.d.ts +9 -1
  112. package/dist/components/inputs/KapiSelect.js +236 -233
  113. package/dist/components/inputs/KapiSlider.d.ts +10 -3
  114. package/dist/components/inputs/KapiSlider.js +67 -63
  115. package/dist/components/inputs/KapiTagInput.d.ts +7 -1
  116. package/dist/components/inputs/KapiTagInput.js +70 -69
  117. package/dist/components/inputs/KapiTextarea.d.ts +7 -1
  118. package/dist/components/inputs/KapiTextarea.js +51 -50
  119. package/dist/components/inputs/copyLogic.d.ts +1 -0
  120. package/dist/components/inputs/copyLogic.js +12 -0
  121. package/dist/components/inputs/fieldLogic.d.ts +23 -3
  122. package/dist/components/inputs/fieldLogic.js +18 -11
  123. package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
  124. package/dist/components/inputs/formBridgeLogic.js +25 -0
  125. package/dist/components/inputs/index.d.ts +10 -0
  126. package/dist/components/inputs/inputLogic.d.ts +16 -1
  127. package/dist/components/inputs/inputLogic.js +3 -3
  128. package/dist/components/inputs/ownField.d.ts +3 -1
  129. package/dist/components/inputs/ownField.js +28 -27
  130. package/dist/components/inputs/pinInputLogic.d.ts +34 -0
  131. package/dist/components/inputs/pinInputLogic.js +37 -0
  132. package/dist/components/inputs/propsFormLogic.d.ts +53 -0
  133. package/dist/components/inputs/propsFormLogic.js +11 -0
  134. package/dist/components/inputs/segmentedLogic.d.ts +7 -0
  135. package/dist/components/inputs/segmentedLogic.js +2 -2
  136. package/dist/components/layout/KapiAccessCard.d.ts +5 -1
  137. package/dist/components/layout/KapiAccessCard.js +43 -39
  138. package/dist/components/layout/KapiAccountMenu.js +7 -7
  139. package/dist/components/layout/KapiCollapse.d.ts +39 -0
  140. package/dist/components/layout/KapiCollapse.js +20 -0
  141. package/dist/components/layout/KapiContextSlot.js +4 -4
  142. package/dist/components/layout/KapiDivider.d.ts +11 -2
  143. package/dist/components/layout/KapiDivider.js +30 -24
  144. package/dist/components/layout/KapiGrid.js +2 -2
  145. package/dist/components/layout/KapiNotificationBell.js +10 -10
  146. package/dist/components/layout/KapiPageHeader.js +22 -22
  147. package/dist/components/layout/KapiRail.js +4 -4
  148. package/dist/components/layout/KapiRoot.d.ts +22 -2
  149. package/dist/components/layout/KapiRoot.js +33 -29
  150. package/dist/components/layout/KapiShell.d.ts +9 -1
  151. package/dist/components/layout/KapiShell.js +28 -27
  152. package/dist/components/layout/accessCardLogic.d.ts +8 -1
  153. package/dist/components/layout/accessCardLogic.js +11 -7
  154. package/dist/components/layout/index.d.ts +2 -0
  155. package/dist/components/locale/labelRegistry.d.ts +18 -0
  156. package/dist/components/navigation/KapiAccordion.js +9 -9
  157. package/dist/components/navigation/KapiContextPanel.js +12 -12
  158. package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
  159. package/dist/components/navigation/KapiNavBadge.js +26 -22
  160. package/dist/components/navigation/KapiSteps.d.ts +26 -5
  161. package/dist/components/navigation/KapiSteps.js +55 -43
  162. package/dist/components/navigation/KapiTabs.js +9 -9
  163. package/dist/components/navigation/KapiToc.d.ts +48 -0
  164. package/dist/components/navigation/KapiToc.js +66 -0
  165. package/dist/components/navigation/KapiTree.js +10 -10
  166. package/dist/components/navigation/index.d.ts +3 -0
  167. package/dist/components/navigation/tocLogic.d.ts +35 -0
  168. package/dist/components/navigation/tocLogic.js +11 -0
  169. package/dist/components/navigation/tocSlots.d.ts +8 -0
  170. package/dist/components/navigation/tocSlots.js +11 -0
  171. package/dist/components/overlays/KapiCommandPalette.js +6 -6
  172. package/dist/components/overlays/KapiContextMenu.js +5 -5
  173. package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
  174. package/dist/components/overlays/KapiImageViewer.js +106 -0
  175. package/dist/components/overlays/KapiMenuButton.js +7 -7
  176. package/dist/components/overlays/KapiModal.js +3 -3
  177. package/dist/components/overlays/KapiOffcanvas.js +24 -24
  178. package/dist/components/overlays/KapiPhotoView.js +10 -10
  179. package/dist/components/overlays/KapiPopover.js +6 -6
  180. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  181. package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
  182. package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
  183. package/dist/components/overlays/KapiTooltip.d.ts +49 -10
  184. package/dist/components/overlays/KapiTooltip.js +120 -68
  185. package/dist/components/overlays/KapiViewport.d.ts +63 -0
  186. package/dist/components/overlays/KapiViewport.js +195 -0
  187. package/dist/components/overlays/index.d.ts +8 -0
  188. package/dist/components/overlays/menuList.js +22 -22
  189. package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
  190. package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
  191. package/dist/components/overlays/viewportLogic.d.ts +73 -0
  192. package/dist/components/overlays/viewportLogic.js +54 -0
  193. package/dist/components/slotCatalog.d.ts +66 -0
  194. package/dist/components/slotCatalog.js +30 -12
  195. package/dist/css/base.css +1 -1
  196. package/dist/css/components/data/KapiScatterChart.css +1 -0
  197. package/dist/css/components/display/KapiAnnotation.css +1 -1
  198. package/dist/css/components/display/KapiCodeBlock.css +1 -0
  199. package/dist/css/components/display/KapiDiff.css +1 -0
  200. package/dist/css/components/display/display.css +1 -1
  201. package/dist/css/components/feedback/feedback.css +1 -1
  202. package/dist/css/components/inputs/KapiFileUpload.css +1 -1
  203. package/dist/css/components/inputs/KapiPinInput.css +1 -0
  204. package/dist/css/components/inputs/KapiSelect.css +1 -1
  205. package/dist/css/components/inputs/inputsExtra.css +1 -1
  206. package/dist/css/components/layout/KapiAccessCard.css +1 -1
  207. package/dist/css/components/layout/KapiCollapse.css +1 -0
  208. package/dist/css/components/layout/KapiDivider.css +1 -1
  209. package/dist/css/components/navigation/KapiSteps.css +1 -1
  210. package/dist/css/components/navigation/KapiToc.css +1 -0
  211. package/dist/css/components/overlays/KapiViewport.css +1 -0
  212. package/dist/css/components/overlays/overlays.css +1 -1
  213. package/dist/hooks/asyncResourceLogic.d.ts +11 -0
  214. package/dist/hooks/asyncResourceLogic.js +4 -0
  215. package/dist/hooks/elementSizeLogic.d.ts +15 -0
  216. package/dist/hooks/elementSizeLogic.js +7 -0
  217. package/dist/hooks/hotkeyLogic.d.ts +9 -0
  218. package/dist/hooks/hotkeyLogic.js +16 -15
  219. package/dist/hooks/hotkeyRegistry.d.ts +44 -0
  220. package/dist/hooks/hotkeyRegistry.js +32 -0
  221. package/dist/hooks/index.d.ts +13 -0
  222. package/dist/hooks/toneFamilyLogic.d.ts +26 -2
  223. package/dist/hooks/toneFamilyLogic.js +19 -6
  224. package/dist/hooks/useAsyncResource.d.ts +45 -0
  225. package/dist/hooks/useAsyncResource.js +24 -0
  226. package/dist/hooks/useDebouncedValue.d.ts +30 -0
  227. package/dist/hooks/useDebouncedValue.js +26 -0
  228. package/dist/hooks/useDisclosure.d.ts +39 -0
  229. package/dist/hooks/useDisclosure.js +35 -0
  230. package/dist/hooks/useElementSize.d.ts +27 -0
  231. package/dist/hooks/useElementSize.js +29 -0
  232. package/dist/hooks/useHotkey.d.ts +8 -0
  233. package/dist/hooks/useHotkey.js +27 -15
  234. package/dist/hooks/useKapiTheme.d.ts +8 -1
  235. package/dist/hooks/useKapiTheme.js +57 -57
  236. package/dist/hooks/useToneFamilies.d.ts +14 -4
  237. package/dist/hooks/useToneFamilies.js +27 -23
  238. package/dist/index.js +234 -207
  239. package/dist/kapi.css +1 -1
  240. package/dist/kapi.layered.css +1 -1
  241. package/dist/logic.d.ts +45 -0
  242. package/dist/logic.js +46 -0
  243. package/package.json +13 -2
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/inputsExtra.css";
3
- import { fieldControlProps as e, joinIds as t, resolveFieldClassName as n, resolveReadOnly as ee, resolveValidation as r } from "./fieldLogic.js";
4
- import { useOwnField as i } from "./ownField.js";
5
- import { useLabels as a } from "../locale/KapiLocaleProvider.js";
3
+ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
+ import { fieldControlProps as t, joinIds as n, resolveFieldClassName as r, resolveFieldMessage as i, resolveReadOnly as a } from "./fieldLogic.js";
5
+ import { useOwnField as o } from "./ownField.js";
6
6
  /* empty css */
7
- import { inputClasses as o } from "./KapiInput.js";
8
- import { useControllableState as s } from "../../hooks/useControllableState.js";
9
- import { canDecrement as te, canIncrement as c, clampNumber as l, parseTypedNumber as u, snapToStep as d, stepValue as f } from "./numberStepLogic.js";
10
- import { useEffect as ne, useState as p } from "react";
7
+ import { inputClasses as s } from "./KapiInput.js";
8
+ import { useControllableState as ee } from "../../hooks/useControllableState.js";
9
+ import { canDecrement as c, canIncrement as te, clampNumber as l, parseTypedNumber as u, snapToStep as d, stepValue as ne } from "./numberStepLogic.js";
10
+ import { useEffect as f, useState as p } from "react";
11
11
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
12
  import { Minus as g, Plus as re } from "lucide-react";
13
13
  //#region src/components/inputs/KapiNumberStepper.tsx
@@ -18,25 +18,26 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
18
18
  ].filter(Boolean).join(" "), v = {
19
19
  decrease: "Disminuir",
20
20
  increase: "Aumentar"
21
- }, y = ({ value: y, defaultValue: b, onChange: x, min: S, max: C, step: w = 1, size: T = "md", invalid: E, status: D, required: O, label: k, help: A, fieldClassName: j, wrapperClassName: M, labels: N, className: P, disabled: F, readOnly: I, id: L, ...R }) => {
22
- let z = a("numberStepper", v, N), [B, V] = s(y, () => l(b ?? 0, {
21
+ }, y = ({ value: y, defaultValue: b, onChange: x, min: S, max: C, step: w = 1, size: T = "md", invalid: E, status: D, required: O, label: ie, help: k, error: A, fieldClassName: j, wrapperClassName: M, labels: N, className: P, disabled: F, readOnly: I, id: L, ...R }) => {
22
+ let z = e("numberStepper", v, N), [B, V] = ee(y, () => l(b ?? 0, {
23
23
  min: S,
24
24
  max: C,
25
25
  step: w
26
- }), x), { invalid: H, status: U } = r(E, D), W = i({
26
+ }), x), { invalid: H, status: U } = i(A, k, E, D), W = o({
27
27
  id: L,
28
- label: k,
29
- help: A,
28
+ label: ie,
29
+ help: k,
30
+ error: A,
30
31
  required: O,
31
32
  invalid: E,
32
33
  status: D,
33
34
  readOnly: I
34
- }), G = W.controlId ?? W.autoId, { helpId: K } = W, q = ee(I, W.field), J = {
35
+ }), G = W.controlId ?? W.autoId, { helpId: K } = W, q = a(I, W.field), J = {
35
36
  min: S,
36
37
  max: C,
37
38
  step: w
38
39
  }, [Y, X] = p(null);
39
- ne(() => X(null), [B]);
40
+ f(() => X(null), [B]);
40
41
  let Z = (e) => {
41
42
  let t = l(e, J);
42
43
  t !== B && V(t), X(null);
@@ -47,11 +48,11 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
47
48
  }, $ = (e) => {
48
49
  if (q) return;
49
50
  let t = Y === null ? null : u(Y), n = t === null ? B : d(t, J);
50
- Z(f(n, e, J));
51
- }, ie = /* @__PURE__ */ h("div", {
51
+ Z(ne(n, e, J));
52
+ }, ae = /* @__PURE__ */ h("div", {
52
53
  className: _({
53
54
  size: T,
54
- className: n(j, M)
55
+ className: r(j, M)
55
56
  }),
56
57
  children: [
57
58
  /* @__PURE__ */ m("button", {
@@ -59,7 +60,7 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
59
60
  className: "kapi-stepper__btn",
60
61
  "aria-label": z.decrease,
61
62
  tabIndex: -1,
62
- disabled: F || q || !te(B, J),
63
+ disabled: F || q || !c(B, J),
63
64
  onClick: () => $(-1),
64
65
  children: /* @__PURE__ */ m(g, {
65
66
  size: 15,
@@ -68,9 +69,9 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
68
69
  }),
69
70
  /* @__PURE__ */ m("input", {
70
71
  ...R,
71
- ...e(W.outer, {
72
+ ...t(W.outer, {
72
73
  id: G,
73
- describedBy: t(K, R["aria-describedby"]),
74
+ describedBy: n(K, R["aria-describedby"]),
74
75
  invalid: H
75
76
  }),
76
77
  required: O,
@@ -81,7 +82,7 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
81
82
  "aria-valuenow": B,
82
83
  "aria-valuemin": S,
83
84
  "aria-valuemax": C,
84
- className: o({
85
+ className: s({
85
86
  size: T,
86
87
  status: U,
87
88
  num: !0,
@@ -100,7 +101,7 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
100
101
  className: "kapi-stepper__btn",
101
102
  "aria-label": z.increase,
102
103
  tabIndex: -1,
103
- disabled: F || q || !c(B, J),
104
+ disabled: F || q || !te(B, J),
104
105
  onClick: () => $(1),
105
106
  children: /* @__PURE__ */ m(re, {
106
107
  size: 15,
@@ -109,7 +110,7 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
109
110
  })
110
111
  ]
111
112
  });
112
- return W.wrap(ie);
113
+ return W.wrap(ae);
113
114
  };
114
115
  //#endregion
115
116
  export { v as DEFAULT_NUMBER_STEPPER_LABELS, y as KapiNumberStepper, _ as stepperClasses };
@@ -0,0 +1,72 @@
1
+ import { type FocusEvent, type HTMLAttributes, type ReactNode, type Ref } from "react";
2
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
3
+ import { type KapiFieldStatus } from "./fieldLogic.js";
4
+ import { type KapiPinInputType } from "./pinInputLogic.js";
5
+ export type KapiPinInputLabels = {
6
+ /** Nombre de cada caja. `{n}` es el número de caja y `{total}`, cuántas hay. */
7
+ digit: string;
8
+ };
9
+ export declare const DEFAULT_PIN_INPUT_LABELS: KapiPinInputLabels;
10
+ export type KapiPinInputProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "onBlur" | "defaultValue" | "children"> & {
11
+ /** `ref` a la PRIMERA caja, que es la que enfoca el campo. */
12
+ ref?: Ref<HTMLInputElement> | undefined;
13
+ /** Cuántas cajas. @default 6 */
14
+ length?: number | undefined;
15
+ /** Qué acepta cada caja. @default "numeric" */
16
+ type?: KapiPinInputType | undefined;
17
+ /** El código. Controlado. */
18
+ value?: string | undefined;
19
+ /** El código inicial, sin controlar. */
20
+ defaultValue?: string | undefined;
21
+ /** Avisa el código completo (las cajas unidas, sin los huecos). */
22
+ onChange?: ((value: string) => void) | undefined;
23
+ /** Avisa cuando se llenaron todas las cajas: el momento de enviar sin que aprieten un botón. */
24
+ onComplete?: ((value: string) => void) | undefined;
25
+ /**
26
+ * Oculta los caracteres, como una contraseña. Para un código que llega por SMS no va: verlo es
27
+ * parte de poder tipearlo bien.
28
+ */
29
+ mask?: boolean | undefined;
30
+ /**
31
+ * Deja que el teléfono ofrezca el código del SMS (`autocomplete="one-time-code"`). Va en la
32
+ * PRIMERA caja nada más, que es como lo espera el navegador; el reparto a las demás lo hace solo.
33
+ * @default true
34
+ */
35
+ oneTimeCode?: boolean | undefined;
36
+ /** Etiqueta del grupo. Con `label` o `help` se envuelve solo en un `KapiField`. */
37
+ label?: ReactNode | undefined;
38
+ /** Pista bajo las cajas. */
39
+ help?: ReactNode | undefined;
40
+ /** El motivo por el que está mal: reemplaza a `help` y lo marca inválido. Ver `KapiFieldProps`. */
41
+ error?: ReactNode | undefined;
42
+ /** Marca el grupo inválido. Sin esto, lo toma del `KapiField` que lo envuelve. */
43
+ invalid?: boolean | undefined;
44
+ /** Validación que no es error: `ok` o `pending`. */
45
+ status?: KapiFieldStatus | undefined;
46
+ /** Obligatorio. */
47
+ required?: boolean | undefined;
48
+ /** No se edita, pero se lee y se copia. */
49
+ readOnly?: boolean | undefined;
50
+ /** Deshabilitado. */
51
+ disabled?: boolean | undefined;
52
+ /** Enfoca la primera caja al montar. */
53
+ autoFocus?: boolean | undefined;
54
+ /** Para el envío nativo del `<form>`: emite un `<input type="hidden">` con el código. */
55
+ name?: string | undefined;
56
+ /** Se llama cuando el foco sale del grupo entero (moverse entre cajas no cuenta). */
57
+ onBlur?: ((event: FocusEvent<HTMLDivElement>) => void) | undefined;
58
+ /** Clase del contenedor del campo. */
59
+ fieldClassName?: string | undefined;
60
+ /** Textos propios. */
61
+ labels?: KapiLabelsOverride<KapiPinInputLabels> | undefined;
62
+ };
63
+ /**
64
+ * Un código en cajas, una por carácter: el segundo factor, el código del SMS, un PIN.
65
+ *
66
+ * NOMBRA CADA CAJA, y es el motivo por el que existe en vez de componerse a mano: seis `<input>`
67
+ * seguidos se anuncian como seis campos idénticos, así que cada uno lleva «Dígito 3 de 6» y el
68
+ * grupo entero lleva la etiqueta. Eso, el pegado desde cualquier caja y el Backspace que retrocede
69
+ * son justamente lo que cada app termina reescribiendo —y a veces olvidando— cuando compone esto
70
+ * con inputs sueltos.
71
+ */
72
+ export declare function KapiPinInput({ ref, length, type, value: valueProp, defaultValue, onChange, onComplete, mask, oneTimeCode, label, help, error, invalid, status, required, readOnly, disabled, autoFocus, name, onBlur, fieldClassName, className, id, labels, ...rest }: KapiPinInputProps): ReactNode;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import "#kapi-css/components/inputs/KapiPinInput.css";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
5
+ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
6
+ import { fieldControlProps as r } from "./fieldLogic.js";
7
+ import { useOwnField as i } from "./ownField.js";
8
+ import { useControllableState as a } from "../../hooks/useControllableState.js";
9
+ import { joinPin as o, pinAfterBackspace as s, pinAfterInput as c, pinAfterPaste as l, splitPin as u } from "./pinInputLogic.js";
10
+ /* empty css */
11
+ import { useRef as d } from "react";
12
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
13
+ //#region src/components/inputs/KapiPinInput.tsx
14
+ var m = { digit: "Dígito {n} de {total}" };
15
+ function h({ ref: h, length: g = 6, type: _ = "numeric", value: v, defaultValue: y, onChange: b, onComplete: x, mask: S, oneTimeCode: C = !0, label: w, help: T, error: E, invalid: D, status: O, required: k, readOnly: A, disabled: j, autoFocus: M, name: N, onBlur: P, fieldClassName: F, className: I, id: L, labels: R, ...z }) {
16
+ let B = n("pinInput", m, R), V = i({
17
+ id: L,
18
+ label: w,
19
+ help: T,
20
+ error: E,
21
+ required: k,
22
+ invalid: D,
23
+ status: O,
24
+ readOnly: A,
25
+ fieldClassName: F
26
+ }), [H, U] = a(v, y ?? "", b), W = d([]), G = t(h, (e) => {
27
+ W.current[0] = e;
28
+ }), K = u(H, g), q = ({ boxes: e, focus: t }) => {
29
+ let n = o(e);
30
+ U(n), W.current[t]?.focus(), W.current[t]?.select(), n.length === g && x?.(n);
31
+ }, J = (e) => (t) => {
32
+ A || j || (t.key === "Backspace" ? (t.preventDefault(), q(s(K, e))) : t.key === "ArrowLeft" && e > 0 ? (t.preventDefault(), W.current[e - 1]?.focus()) : t.key === "ArrowRight" && e < g - 1 && (t.preventDefault(), W.current[e + 1]?.focus()));
33
+ }, Y = (e) => (t) => {
34
+ A || j || (t.preventDefault(), q(l(K, e, t.clipboardData.getData("text"), _)));
35
+ }, X = r(V.field, {
36
+ id: L,
37
+ required: k,
38
+ invalid: D,
39
+ labelable: !1
40
+ });
41
+ return V.wrap(/* @__PURE__ */ p("div", {
42
+ ...z,
43
+ className: e("kapi-pin", I),
44
+ role: "group",
45
+ onBlur: (e) => {
46
+ e.currentTarget.contains(e.relatedTarget) || P?.(e);
47
+ },
48
+ ...X,
49
+ children: [K.map((e, t) => /* @__PURE__ */ f("input", {
50
+ ref: t === 0 ? G : (e) => {
51
+ W.current[t] = e;
52
+ },
53
+ className: "kapi-pin__box",
54
+ type: S ? "password" : "text",
55
+ inputMode: _ === "numeric" ? "numeric" : "text",
56
+ autoComplete: C && t === 0 ? "one-time-code" : "off",
57
+ "aria-label": B.digit.replace("{n}", String(t + 1)).replace("{total}", String(g)),
58
+ "aria-invalid": X["aria-invalid"],
59
+ value: e,
60
+ readOnly: A,
61
+ disabled: j,
62
+ autoFocus: M && t === 0,
63
+ onPaste: Y(t),
64
+ onKeyDown: J(t),
65
+ onChange: (e) => q(c(K, t, e.target.value, _)),
66
+ onFocus: (e) => e.currentTarget.select()
67
+ }, t)), N && /* @__PURE__ */ f("input", {
68
+ type: "hidden",
69
+ name: N,
70
+ value: j ? "" : H
71
+ })]
72
+ }));
73
+ }
74
+ //#endregion
75
+ export { m as DEFAULT_PIN_INPUT_LABELS, h as KapiPinInput };
@@ -0,0 +1,34 @@
1
+ import type { HTMLAttributes, Ref } from "react";
2
+ import { type KapiPropsFormField, type KapiPropsFormValues } from "./propsFormLogic.js";
3
+ export type { KapiPropsFormField, KapiPropsFormValue, KapiPropsFormValues } from "./propsFormLogic.js";
4
+ /** Atributos nativos (`id`, `style`, `data-*`…) van al `<div>` raíz. */
5
+ export type KapiPropsFormProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & {
6
+ /** Ref al `<div>` raíz. */
7
+ ref?: Ref<HTMLDivElement> | undefined;
8
+ /** El esquema: qué campos hay y de qué tipo. Puede cambiar en vivo. */
9
+ fields: readonly KapiPropsFormField[];
10
+ /** Valores controlados, por nombre de campo. */
11
+ values?: KapiPropsFormValues | undefined;
12
+ /** Valores iniciales cuando el componente los maneja solo. */
13
+ defaultValues?: KapiPropsFormValues | undefined;
14
+ /** Avisa con TODOS los valores cada vez que uno cambia. */
15
+ onChange?: ((values: KapiPropsFormValues) => void) | undefined;
16
+ /** Marca en rojo los obligatorios vacíos. La app decide cuándo (al intentar guardar). */
17
+ showErrors?: boolean | undefined;
18
+ /** Deshabilita el formulario entero. @default false */
19
+ disabled?: boolean | undefined;
20
+ /** Ancho mínimo de cada campo, en px: debajo de eso la grilla pasa a una columna. @default 220 */
21
+ min?: number | undefined;
22
+ };
23
+ /**
24
+ * Formulario generado desde un esquema: el diálogo de "insertar bloque" de una wiki, la pantalla
25
+ * de configuración de un plugin, cualquier formulario que no se conoce al compilar.
26
+ *
27
+ * **El esquema puede cambiar en vivo** —viene del servidor, o de un tipo de bloque elegido en un
28
+ * menú— y los valores se acomodan solos: los campos que el esquema nuevo no declara se descartan y
29
+ * los que agrega entran con su inicial. Sin eso, cambiar de bloque manda campos del anterior.
30
+ *
31
+ * **`required` no valida: marca.** Quién decide si se puede guardar es la app, con
32
+ * `missingPropsFormFields`. La librería no tiene motor de validación y esto no lo cambia.
33
+ */
34
+ export declare function KapiPropsForm({ fields, values, defaultValues, onChange, showErrors, disabled, min, className, ...rest }: KapiPropsFormProps): import("react").JSX.Element;
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { KapiInput as e } from "./KapiInput.js";
3
+ import { useControllableState as t } from "../../hooks/useControllableState.js";
4
+ import { KapiSwitch as n } from "./KapiSwitch.js";
5
+ import { KapiSelect as r } from "./KapiSelect.js";
6
+ import { KapiTextarea as i } from "./KapiTextarea.js";
7
+ import { KapiNumberStepper as a } from "./KapiNumberStepper.js";
8
+ import { KapiGrid as o } from "../layout/KapiGrid.js";
9
+ import { missingPropsFormFields as s, reconcilePropsFormValues as c } from "./propsFormLogic.js";
10
+ import { useMemo as l } from "react";
11
+ import { jsx as u } from "react/jsx-runtime";
12
+ //#region src/components/inputs/KapiPropsForm.tsx
13
+ function d({ fields: d, values: f, defaultValues: p, onChange: m, showErrors: h = !1, disabled: g = !1, min: _ = 220, className: v, ...y }) {
14
+ let [b, x] = t(f, () => c(d, p ?? {}), m), S = l(() => c(d, b), [d, b]), C = l(() => h ? new Set(s(d, S)) : /* @__PURE__ */ new Set(), [
15
+ h,
16
+ d,
17
+ S
18
+ ]), w = (e, t) => x({
19
+ ...S,
20
+ [e]: t
21
+ });
22
+ return /* @__PURE__ */ u("div", {
23
+ ...y,
24
+ className: ["kapi-propsform", v].filter(Boolean).join(" "),
25
+ children: /* @__PURE__ */ u(o, {
26
+ min: _,
27
+ gap: 4,
28
+ children: d.map((t) => {
29
+ let o = {
30
+ label: t.label,
31
+ name: t.name,
32
+ disabled: g || t.disabled === !0,
33
+ required: t.required === !0,
34
+ invalid: C.has(t.name),
35
+ ...t.hint === void 0 ? {} : { help: t.hint }
36
+ }, s = S[t.name] ?? null;
37
+ if (t.kind === "boolean") return /* @__PURE__ */ u(n, {
38
+ ...o,
39
+ checked: s === !0,
40
+ onChange: (e) => w(t.name, e.currentTarget.checked)
41
+ }, t.name);
42
+ if (t.kind === "number") return /* @__PURE__ */ u(a, {
43
+ ...o,
44
+ ...typeof s == "number" ? { value: s } : {},
45
+ onChange: (e) => w(t.name, e),
46
+ ...t.min === void 0 ? {} : { min: t.min },
47
+ ...t.max === void 0 ? {} : { max: t.max }
48
+ }, t.name);
49
+ if (t.kind === "select") return /* @__PURE__ */ u(r, {
50
+ ...o,
51
+ options: (t.options ?? []).map((e) => ({
52
+ value: e.value,
53
+ label: e.label
54
+ })),
55
+ value: typeof s == "string" ? s : null,
56
+ onChange: (e) => w(t.name, e),
57
+ clearable: !0,
58
+ ...t.placeholder === void 0 ? {} : { placeholder: t.placeholder }
59
+ }, t.name);
60
+ let c = typeof s == "string" ? s : "", l = t.placeholder === void 0 ? {} : { placeholder: t.placeholder };
61
+ return t.kind === "textarea" ? /* @__PURE__ */ u(i, {
62
+ ...o,
63
+ ...l,
64
+ rows: 3,
65
+ value: c,
66
+ onChange: (e) => w(t.name, e.currentTarget.value)
67
+ }, t.name) : /* @__PURE__ */ u(e, {
68
+ ...o,
69
+ ...l,
70
+ value: c,
71
+ onChange: (e) => w(t.name, e.currentTarget.value)
72
+ }, t.name);
73
+ })
74
+ })
75
+ });
76
+ }
77
+ //#endregion
78
+ export { d as KapiPropsForm };
@@ -43,6 +43,12 @@ export type KapiRatingProps = Omit<HTMLAttributes<HTMLDivElement>, "children" |
43
43
  label?: ReactNode | undefined;
44
44
  /** Ayuda / mensaje de error bajo la calificación (la envuelve en un `KapiField`). */
45
45
  help?: ReactNode | undefined;
46
+ /**
47
+ * El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
48
+ * `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
49
+ * Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
50
+ */
51
+ error?: ReactNode | undefined;
46
52
  /** Clase del `KapiField` propio (con `label` o `help`). `className` va a la raíz. */
47
53
  fieldClassName?: string | undefined;
48
54
  /**
@@ -69,4 +75,4 @@ export declare const ratingClasses: ({ size, interactive, disabled, readOnly, cl
69
75
  * Inside a `KapiField` the interactive slider takes the field id, name (`aria-labelledby`), help,
70
76
  * `aria-invalid` and `aria-required`.
71
77
  */
72
- export declare const KapiRating: ({ value: valueProp, defaultValue, onChange, max, size, disabled, allowHalf, className, labels, "aria-label": ariaLabelProp, name, invalid, required, label, help, fieldClassName, readOnly: readOnlyProp, id, "aria-describedby": describedBy, ref, ...rest }: KapiRatingProps) => ReactNode;
78
+ export declare const KapiRating: ({ value: valueProp, defaultValue, onChange, max, size, disabled, allowHalf, className, labels, "aria-label": ariaLabelProp, name, invalid, required, label, help, error, fieldClassName, readOnly: readOnlyProp, id, "aria-describedby": describedBy, ref, ...rest }: KapiRatingProps) => ReactNode;
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/inputsExtra.css";
3
- import { fieldControlProps as e, resolveReadOnly as t } from "./fieldLogic.js";
4
- import { useOwnField as n } from "./ownField.js";
5
- import { useLabels as r } from "../locale/KapiLocaleProvider.js";
3
+ import { useMergedRefs as e } from "../../hooks/mergeRefs.js";
4
+ import { useLabels as t } from "../locale/KapiLocaleProvider.js";
5
+ import { fieldControlProps as n, resolveReadOnly as r } from "./fieldLogic.js";
6
+ import { useOwnField as i } from "./ownField.js";
6
7
  /* empty css */
7
- import { useControllableState as i } from "../../hooks/useControllableState.js";
8
- import { directionOf as ee, logicalKeyOf as te } from "../../hooks/directionLogic.js";
9
- import { useFormReset as ne } from "../../hooks/useFormReset.js";
10
- import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
11
- import { normalizeRating as o, ratingFromKey as s, ratingFromPointer as c, starFills as re } from "./ratingLogic.js";
8
+ import { useControllableState as a } from "../../hooks/useControllableState.js";
9
+ import { directionOf as o, logicalKeyOf as s } from "../../hooks/directionLogic.js";
10
+ import { useFormReset as ee } from "../../hooks/useFormReset.js";
11
+ import { normalizeRating as te, ratingFromKey as c, ratingFromPointer as ne, starFills as re } from "./ratingLogic.js";
12
12
  import { useState as ie } from "react";
13
13
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
14
14
  import { Star as d } from "lucide-react";
@@ -16,46 +16,47 @@ import { Star as d } from "lucide-react";
16
16
  var f = {
17
17
  rating: "Calificación",
18
18
  of: "de"
19
- }, p = {
19
+ }, ae = {
20
20
  sm: 16,
21
21
  md: 22,
22
22
  lg: 30
23
- }, m = ({ size: e = "md", interactive: t = !1, disabled: n = !1, readOnly: r = !1, className: i = "" } = {}) => [
23
+ }, p = ({ size: e = "md", interactive: t = !1, disabled: n = !1, readOnly: r = !1, className: i = "" } = {}) => [
24
24
  "kapi-rating",
25
25
  e !== "md" && `kapi-rating--${e}`,
26
26
  t && "kapi-rating--interactive",
27
27
  n && "kapi-rating--disabled",
28
28
  r && "kapi-rating--readonly",
29
29
  i
30
- ].filter(Boolean).join(" "), h = ({ value: h, defaultValue: g, onChange: _, max: v = 5, size: y = "md", disabled: b = !1, allowHalf: x = !1, className: ae, labels: S, "aria-label": C, name: w, invalid: T, required: E, label: D, help: O, fieldClassName: k, readOnly: A, id: j, "aria-describedby": M, ref: oe, ...N }) => {
31
- let P = r("rating", f, S), F = n({
30
+ ].filter(Boolean).join(" "), m = ({ value: m, defaultValue: h, onChange: g, max: _ = 5, size: v = "md", disabled: y = !1, allowHalf: b = !1, className: x, labels: oe, "aria-label": S, name: C, invalid: w, required: T, label: E, help: D, error: O, fieldClassName: k, readOnly: A, id: j, "aria-describedby": M, ref: se, ...N }) => {
31
+ let P = t("rating", f, oe), F = i({
32
32
  id: j,
33
- label: D,
34
- help: O,
35
- required: E,
36
- invalid: T,
33
+ label: E,
34
+ help: D,
35
+ error: O,
36
+ required: T,
37
+ invalid: w,
37
38
  readOnly: A,
38
39
  fieldClassName: k
39
- }), I = F.field, L = t(A, I), [R, z] = ie(null), [B, V, , H] = i(h, g ?? 0, _), U = a(oe, ne(H)), W = (_ !== void 0 || h === void 0 && g !== void 0) && !b, G = W && !L, K = e(W ? I : null, {
40
+ }), I = F.field, L = r(A, I), [R, z] = ie(null), [B, V, , H] = a(m, h ?? 0, g), U = e(se, ee(H)), W = (g !== void 0 || m === void 0 && h !== void 0) && !y, G = W && !L, K = n(W ? I : null, {
40
41
  id: j,
41
42
  describedBy: M,
42
- invalid: T,
43
- required: E,
43
+ invalid: w,
44
+ required: T,
44
45
  labelable: !1,
45
- ariaLabel: C
46
- }), q = C ?? P.rating, J = o(B, v, x), Y = w ? /* @__PURE__ */ l("input", {
46
+ ariaLabel: S
47
+ }), q = S ?? P.rating, J = te(B, _, b), Y = C ? /* @__PURE__ */ l("input", {
47
48
  type: "hidden",
48
- name: w,
49
+ name: C,
49
50
  value: J,
50
- disabled: b
51
- }) : null, se = re(G && R !== null ? R : J, v, x), X = p[y], Z = (e, t) => {
52
- let n = e.currentTarget.getBoundingClientRect(), r = ee(e.currentTarget) === "rtl" ? n.right - e.clientX : e.clientX - n.left, i = n.width > 0 ? r / n.width : 1;
53
- return c(t, i, x);
54
- }, ce = (e) => {
51
+ disabled: y
52
+ }) : null, ce = re(G && R !== null ? R : J, _, b), X = ae[v], Z = (e, t) => {
53
+ let n = e.currentTarget.getBoundingClientRect(), r = o(e.currentTarget) === "rtl" ? n.right - e.clientX : e.clientX - n.left, i = n.width > 0 ? r / n.width : 1;
54
+ return ne(t, i, b);
55
+ }, le = (e) => {
55
56
  if (!G) return;
56
- let t = s(te(e), J, v, x);
57
+ let t = c(s(e), J, _, b);
57
58
  t !== null && (e.preventDefault(), t !== J && V(t));
58
- }, Q = se.map((e, t) => /* @__PURE__ */ u("span", {
59
+ }, Q = ce.map((e, t) => /* @__PURE__ */ u("span", {
59
60
  className: "kapi-rating__star",
60
61
  "data-fill": e,
61
62
  onMouseMove: G ? (e) => z(Z(e, t)) : void 0,
@@ -78,12 +79,12 @@ var f = {
78
79
  "aria-hidden": "true"
79
80
  })
80
81
  })]
81
- }, t)), $ = m({
82
- size: y,
82
+ }, t)), $ = p({
83
+ size: v,
83
84
  interactive: W,
84
- disabled: b,
85
+ disabled: y,
85
86
  readOnly: W && L,
86
- className: ae
87
+ className: x
87
88
  });
88
89
  return W ? F.wrap(/* @__PURE__ */ u("div", {
89
90
  ...N,
@@ -94,11 +95,11 @@ var f = {
94
95
  tabIndex: 0,
95
96
  "aria-label": K["aria-labelledby"] ? void 0 : q,
96
97
  "aria-valuemin": 0,
97
- "aria-valuemax": v,
98
+ "aria-valuemax": _,
98
99
  "aria-valuenow": J,
99
- "aria-valuetext": `${J} ${P.of} ${v}`,
100
+ "aria-valuetext": `${J} ${P.of} ${_}`,
100
101
  "aria-readonly": L || void 0,
101
- onKeyDown: ce,
102
+ onKeyDown: le,
102
103
  onMouseLeave: () => z(null),
103
104
  children: [Q, Y]
104
105
  })) : F.wrap(/* @__PURE__ */ u("div", {
@@ -108,9 +109,9 @@ var f = {
108
109
  "aria-describedby": M,
109
110
  className: $,
110
111
  role: "img",
111
- "aria-label": `${q}: ${J} ${P.of} ${v}`,
112
+ "aria-label": `${q}: ${J} ${P.of} ${_}`,
112
113
  children: [Q, Y]
113
114
  }));
114
115
  };
115
116
  //#endregion
116
- export { f as DEFAULT_RATING_LABELS, h as KapiRating, m as ratingClasses };
117
+ export { f as DEFAULT_RATING_LABELS, m as KapiRating, p as ratingClasses };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiSearchChip.css";
3
- import { assignRef as e } from "./fieldLogic.js";
4
- import { useLabels as t } from "../locale/KapiLocaleProvider.js";
3
+ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
+ import { assignRef as t } from "./fieldLogic.js";
5
5
  import { useControllableState as n } from "../../hooks/useControllableState.js";
6
6
  import { searchChipClasses as r, searchChipName as i } from "./searchChipLogic.js";
7
7
  /* empty css */
@@ -16,12 +16,12 @@ var u = {
16
16
  }, d = (e) => {
17
17
  Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 }));
18
18
  }, f = ({ value: f, defaultValue: p, onChange: m, onSubmit: h, disabled: g = !1, placeholder: _, "aria-label": v, labels: y, className: b, style: x, ref: S, onKeyDown: C, ...w }) => {
19
- let T = t("searchChip", u, y), E = a(null), [D, O] = n(f, p ?? ""), k = _ ?? T.placeholder, A = i({
19
+ let T = e("searchChip", u, y), E = a(null), [D, O] = n(f, p ?? ""), k = _ ?? T.placeholder, A = i({
20
20
  ariaLabel: v,
21
21
  placeholder: k,
22
22
  fallback: T.search
23
- }), j = D !== "" && !g && !w.readOnly, M = (t) => {
24
- E.current = t, e(S, t);
23
+ }), j = D !== "" && !g && !w.readOnly, M = (e) => {
24
+ E.current = e, t(S, e);
25
25
  }, N = () => {
26
26
  let e = E.current;
27
27
  e && (d(e), e.focus());
@@ -1,10 +1,12 @@
1
1
  import type { FocusEvent, HTMLAttributes, ReactNode, Ref } from "react";
2
- import { type KapiTone } from "../tone.js";
2
+ import { type KapiFamilyTone, type KapiTone } from "../tone.js";
3
3
  export type KapiSegmentedVariant = "text" | "icon" | "both";
4
4
  /** Escala del segmentado: `sm` para barras compactas (filtros de tabla), `md` el de siempre. */
5
5
  export type KapiSegmentedSize = "sm" | "md";
6
6
  /** Tonos de un ítem de `KapiSegmented` (subconjunto de `KapiTone`). */
7
7
  export type KapiSegmentedTone = Extract<KapiTone, "success" | "warning" | "danger" | "info">;
8
+ /** Tono de un ítem: uno del subconjunto, o una familia propia de la app (`toneFamilies`). */
9
+ export type KapiSegmentedToneName = KapiSegmentedTone | KapiFamilyTone;
8
10
  /** @deprecated Usar `KapiSegmentedTone`. */
9
11
  export type KapiSegmentedColor = KapiSegmentedTone;
10
12
  export type KapiSegmentedItem<Id extends string | number = string> = {
@@ -19,15 +21,15 @@ export type KapiSegmentedItem<Id extends string | number = string> = {
19
21
  */
20
22
  count?: number | undefined;
21
23
  /** Tono del ítem cuando está activo (en vez del primario); sin activar no se ve. */
22
- activeTone?: KapiSegmentedTone | undefined;
24
+ activeTone?: KapiSegmentedToneName | undefined;
23
25
  /** Nombre anterior de `activeTone`, deprecado. @deprecated Usar `activeTone` (mismos valores). */
24
- color?: KapiSegmentedTone | undefined;
26
+ color?: KapiSegmentedToneName | undefined;
25
27
  /**
26
28
  * Estado permanente del ítem: tiñe el label y el contador **siempre**, sin tocar el fondo, para que una
27
29
  * opción que necesita atención («Demorados 41») se vea sin tener que elegirla. Si además está activa, el
28
30
  * tratamiento de `activeTone` gana.
29
31
  */
30
- tone?: KapiSegmentedTone | undefined;
32
+ tone?: KapiSegmentedToneName | undefined;
31
33
  /** Opción no elegible: se ve atenuada y el teclado la saltea. */
32
34
  disabled?: boolean | undefined;
33
35
  };
@@ -58,6 +60,12 @@ export type KapiSegmentedProps<Id extends string | number = string> = Omit<HTMLA
58
60
  label?: ReactNode | undefined;
59
61
  /** Ayuda / mensaje de error bajo el grupo (lo envuelve en un `KapiField`). */
60
62
  help?: ReactNode | undefined;
63
+ /**
64
+ * El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
65
+ * `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
66
+ * Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
67
+ */
68
+ error?: ReactNode | undefined;
61
69
  /** Clase del `KapiField` propio (con `label` o `help`). `className` va al `radiogroup`. */
62
70
  fieldClassName?: string | undefined;
63
71
  /** Deshabilita el grupo entero (cada opción también acepta `disabled`). */
@@ -78,4 +86,4 @@ export type KapiSegmentedProps<Id extends string | number = string> = Omit<HTMLA
78
86
  * En variante `icon` cada tab muestra su label en un tooltip al hover.
79
87
  * Dentro de un `KapiField` toma id, nombre (`aria-labelledby`), ayuda, `aria-invalid` y `aria-required`.
80
88
  */
81
- export declare const KapiSegmented: <Id extends string | number = string>({ items, value: valueProp, defaultValue, onChange, variant, "aria-label": ariaLabel, className, name, onBlur, invalid, required, label, help, fieldClassName, disabled, readOnly: readOnlyProp, size, id, "aria-describedby": describedBy, ref, ...rest }: KapiSegmentedProps<Id>) => ReactNode;
89
+ export declare const KapiSegmented: <Id extends string | number = string>({ items, value: valueProp, defaultValue, onChange, variant, "aria-label": ariaLabel, className, name, onBlur, invalid, required, label, help, error, fieldClassName, disabled, readOnly: readOnlyProp, size, id, "aria-describedby": describedBy, ref, ...rest }: KapiSegmentedProps<Id>) => ReactNode;