@kapiuara/ui 0.16.0 → 0.17.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 (181) hide show
  1. package/README.md +171 -11
  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/KapiSparkline.d.ts +2 -1
  6. package/dist/components/data/KapiSparkline.js +29 -26
  7. package/dist/components/data/KapiTableFilter.js +6 -6
  8. package/dist/components/data/tableCells.d.ts +12 -1
  9. package/dist/components/data/tableCells.js +49 -51
  10. package/dist/components/data/useTableSelection.js +3 -3
  11. package/dist/components/display/KapiAnnotation.js +68 -63
  12. package/dist/components/display/KapiAvatar.d.ts +6 -4
  13. package/dist/components/display/KapiAvatar.js +33 -28
  14. package/dist/components/display/KapiCodeBlock.d.ts +48 -0
  15. package/dist/components/display/KapiCodeBlock.js +44 -0
  16. package/dist/components/display/KapiCommentComposer.js +6 -6
  17. package/dist/components/display/KapiDiff.d.ts +62 -0
  18. package/dist/components/display/KapiDiff.js +118 -0
  19. package/dist/components/display/KapiHighlight.d.ts +27 -0
  20. package/dist/components/display/KapiHighlight.js +21 -0
  21. package/dist/components/display/KapiIconTile.d.ts +2 -1
  22. package/dist/components/display/KapiIconTile.js +23 -21
  23. package/dist/components/display/KapiStat.d.ts +3 -2
  24. package/dist/components/display/KapiStat.js +32 -26
  25. package/dist/components/display/KapiTag.d.ts +4 -3
  26. package/dist/components/display/KapiTag.js +29 -24
  27. package/dist/components/display/KapiTimeline.d.ts +5 -2
  28. package/dist/components/display/KapiTimeline.js +31 -23
  29. package/dist/components/display/annotationLogic.d.ts +2 -1
  30. package/dist/components/display/annotationLogic.js +7 -6
  31. package/dist/components/display/codeBlockSlots.d.ts +10 -0
  32. package/dist/components/display/codeBlockSlots.js +13 -0
  33. package/dist/components/display/diffLogic.d.ts +58 -0
  34. package/dist/components/display/diffLogic.js +96 -0
  35. package/dist/components/display/diffSlots.d.ts +14 -0
  36. package/dist/components/display/diffSlots.js +17 -0
  37. package/dist/components/display/highlightLogic.d.ts +18 -0
  38. package/dist/components/display/highlightLogic.js +26 -0
  39. package/dist/components/display/highlightSlots.d.ts +5 -0
  40. package/dist/components/display/highlightSlots.js +8 -0
  41. package/dist/components/display/iconTileLogic.d.ts +2 -2
  42. package/dist/components/display/iconTileLogic.js +7 -6
  43. package/dist/components/display/index.d.ts +8 -0
  44. package/dist/components/display/statLogic.d.ts +2 -1
  45. package/dist/components/display/statLogic.js +7 -6
  46. package/dist/components/display/tagLogic.d.ts +2 -1
  47. package/dist/components/display/tagLogic.js +7 -6
  48. package/dist/components/display/timelineLogic.d.ts +20 -2
  49. package/dist/components/display/timelineLogic.js +10 -2
  50. package/dist/components/feedback/KapiFab.js +108 -108
  51. package/dist/components/feedback/KapiProgress.js +63 -54
  52. package/dist/components/feedback/KapiToastContainer.js +9 -9
  53. package/dist/components/feedback/KapiTour.js +12 -12
  54. package/dist/components/feedback/progressLogic.d.ts +2 -1
  55. package/dist/components/feedback/progressLogic.js +9 -8
  56. package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
  57. package/dist/components/inputs/KapiAutocomplete.js +86 -85
  58. package/dist/components/inputs/KapiChecklist.d.ts +7 -1
  59. package/dist/components/inputs/KapiChecklist.js +53 -52
  60. package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
  61. package/dist/components/inputs/KapiCopyButton.js +35 -0
  62. package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
  63. package/dist/components/inputs/KapiDatePicker.js +118 -116
  64. package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
  65. package/dist/components/inputs/KapiDateRangePicker.js +136 -135
  66. package/dist/components/inputs/KapiFacetedSearch.js +5 -5
  67. package/dist/components/inputs/KapiField.d.ts +9 -1
  68. package/dist/components/inputs/KapiField.js +43 -42
  69. package/dist/components/inputs/KapiFileUpload.js +6 -6
  70. package/dist/components/inputs/KapiInput.d.ts +29 -1
  71. package/dist/components/inputs/KapiInput.js +74 -51
  72. package/dist/components/inputs/KapiMaskedInput.js +26 -26
  73. package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
  74. package/dist/components/inputs/KapiNumberStepper.js +24 -23
  75. package/dist/components/inputs/KapiPinInput.d.ts +72 -0
  76. package/dist/components/inputs/KapiPinInput.js +75 -0
  77. package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
  78. package/dist/components/inputs/KapiPropsForm.js +78 -0
  79. package/dist/components/inputs/KapiRating.d.ts +7 -1
  80. package/dist/components/inputs/KapiRating.js +39 -38
  81. package/dist/components/inputs/KapiSearchChip.js +5 -5
  82. package/dist/components/inputs/KapiSegmented.d.ts +13 -5
  83. package/dist/components/inputs/KapiSegmented.js +81 -77
  84. package/dist/components/inputs/KapiSelect.d.ts +9 -1
  85. package/dist/components/inputs/KapiSelect.js +236 -233
  86. package/dist/components/inputs/KapiSlider.d.ts +10 -3
  87. package/dist/components/inputs/KapiSlider.js +67 -63
  88. package/dist/components/inputs/KapiTagInput.d.ts +7 -1
  89. package/dist/components/inputs/KapiTagInput.js +70 -69
  90. package/dist/components/inputs/KapiTextarea.d.ts +7 -1
  91. package/dist/components/inputs/KapiTextarea.js +51 -50
  92. package/dist/components/inputs/copyLogic.d.ts +1 -0
  93. package/dist/components/inputs/copyLogic.js +12 -0
  94. package/dist/components/inputs/fieldLogic.d.ts +23 -3
  95. package/dist/components/inputs/fieldLogic.js +18 -11
  96. package/dist/components/inputs/index.d.ts +8 -0
  97. package/dist/components/inputs/inputLogic.d.ts +16 -1
  98. package/dist/components/inputs/inputLogic.js +3 -3
  99. package/dist/components/inputs/ownField.d.ts +3 -1
  100. package/dist/components/inputs/ownField.js +28 -27
  101. package/dist/components/inputs/pinInputLogic.d.ts +34 -0
  102. package/dist/components/inputs/pinInputLogic.js +37 -0
  103. package/dist/components/inputs/propsFormLogic.d.ts +53 -0
  104. package/dist/components/inputs/propsFormLogic.js +11 -0
  105. package/dist/components/inputs/segmentedLogic.d.ts +7 -0
  106. package/dist/components/inputs/segmentedLogic.js +2 -2
  107. package/dist/components/layout/KapiAccessCard.d.ts +5 -1
  108. package/dist/components/layout/KapiAccessCard.js +43 -39
  109. package/dist/components/layout/KapiAccountMenu.js +7 -7
  110. package/dist/components/layout/KapiCollapse.d.ts +39 -0
  111. package/dist/components/layout/KapiCollapse.js +20 -0
  112. package/dist/components/layout/KapiContextSlot.js +4 -4
  113. package/dist/components/layout/KapiDivider.d.ts +11 -2
  114. package/dist/components/layout/KapiDivider.js +30 -24
  115. package/dist/components/layout/KapiGrid.js +2 -2
  116. package/dist/components/layout/KapiNotificationBell.js +10 -10
  117. package/dist/components/layout/KapiPageHeader.js +22 -22
  118. package/dist/components/layout/KapiRail.js +4 -4
  119. package/dist/components/layout/KapiRoot.d.ts +22 -2
  120. package/dist/components/layout/KapiRoot.js +33 -29
  121. package/dist/components/layout/KapiShell.d.ts +9 -1
  122. package/dist/components/layout/KapiShell.js +28 -27
  123. package/dist/components/layout/accessCardLogic.d.ts +8 -1
  124. package/dist/components/layout/accessCardLogic.js +11 -7
  125. package/dist/components/layout/index.d.ts +2 -0
  126. package/dist/components/locale/labelRegistry.d.ts +10 -0
  127. package/dist/components/navigation/KapiAccordion.js +9 -9
  128. package/dist/components/navigation/KapiContextPanel.js +12 -12
  129. package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
  130. package/dist/components/navigation/KapiNavBadge.js +26 -22
  131. package/dist/components/navigation/KapiTabs.js +9 -9
  132. package/dist/components/navigation/KapiToc.d.ts +48 -0
  133. package/dist/components/navigation/KapiToc.js +66 -0
  134. package/dist/components/navigation/KapiTree.js +10 -10
  135. package/dist/components/navigation/index.d.ts +3 -0
  136. package/dist/components/navigation/tocLogic.d.ts +35 -0
  137. package/dist/components/navigation/tocLogic.js +11 -0
  138. package/dist/components/navigation/tocSlots.d.ts +8 -0
  139. package/dist/components/navigation/tocSlots.js +11 -0
  140. package/dist/components/overlays/KapiCommandPalette.js +6 -6
  141. package/dist/components/overlays/KapiContextMenu.js +5 -5
  142. package/dist/components/overlays/KapiMenuButton.js +7 -7
  143. package/dist/components/overlays/KapiModal.js +3 -3
  144. package/dist/components/overlays/KapiOffcanvas.js +24 -24
  145. package/dist/components/overlays/KapiPhotoView.js +10 -10
  146. package/dist/components/overlays/KapiPopover.js +6 -6
  147. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  148. package/dist/components/overlays/KapiTooltip.js +18 -18
  149. package/dist/components/overlays/menuList.js +22 -22
  150. package/dist/components/slotCatalog.d.ts +33 -0
  151. package/dist/components/slotCatalog.js +18 -10
  152. package/dist/css/base.css +1 -1
  153. package/dist/css/components/display/KapiAnnotation.css +1 -1
  154. package/dist/css/components/display/KapiCodeBlock.css +1 -0
  155. package/dist/css/components/display/KapiDiff.css +1 -0
  156. package/dist/css/components/display/display.css +1 -1
  157. package/dist/css/components/feedback/feedback.css +1 -1
  158. package/dist/css/components/inputs/KapiPinInput.css +1 -0
  159. package/dist/css/components/inputs/KapiSelect.css +1 -1
  160. package/dist/css/components/inputs/inputsExtra.css +1 -1
  161. package/dist/css/components/layout/KapiAccessCard.css +1 -1
  162. package/dist/css/components/layout/KapiCollapse.css +1 -0
  163. package/dist/css/components/layout/KapiDivider.css +1 -1
  164. package/dist/css/components/navigation/KapiToc.css +1 -0
  165. package/dist/hooks/asyncResourceLogic.d.ts +11 -0
  166. package/dist/hooks/asyncResourceLogic.js +4 -0
  167. package/dist/hooks/index.d.ts +3 -0
  168. package/dist/hooks/toneFamilyLogic.d.ts +26 -2
  169. package/dist/hooks/toneFamilyLogic.js +19 -6
  170. package/dist/hooks/useAsyncResource.d.ts +45 -0
  171. package/dist/hooks/useAsyncResource.js +24 -0
  172. package/dist/hooks/useKapiTheme.d.ts +8 -1
  173. package/dist/hooks/useKapiTheme.js +57 -57
  174. package/dist/hooks/useToneFamilies.d.ts +14 -4
  175. package/dist/hooks/useToneFamilies.js +27 -23
  176. package/dist/index.js +221 -207
  177. package/dist/kapi.css +1 -1
  178. package/dist/kapi.layered.css +1 -1
  179. package/dist/logic.d.ts +41 -0
  180. package/dist/logic.js +42 -0
  181. package/package.json +13 -2
@@ -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;
@@ -1,116 +1,120 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/inputsExtra.css";
3
- import { joinClasses as e } from "../rootProps.js";
4
- import { resolveTone as t } from "../tone.js";
5
- import { assignRef as n, fieldControlProps as r, resolveReadOnly as i } from "./fieldLogic.js";
6
- import { useOwnField as a } from "./ownField.js";
7
- import { useKapiFormatLocale as o } from "../locale/KapiLocaleProvider.js";
3
+ import { useToneLookResolver as e } from "../../hooks/useToneFamilies.js";
4
+ import { joinClasses as t } from "../rootProps.js";
5
+ import { resolveTone as n } from "../tone.js";
6
+ import { useKapiFormatLocale as r } from "../locale/KapiLocaleProvider.js";
7
+ import { assignRef as i, fieldControlProps as a, resolveReadOnly as o } from "./fieldLogic.js";
8
+ import { useOwnField as s } from "./ownField.js";
8
9
  /* empty css */
9
- import { useControllableState as s } from "../../hooks/useControllableState.js";
10
+ import { useControllableState as ee } from "../../hooks/useControllableState.js";
10
11
  import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
11
- import { useDuplicateValueWarning as l, useMutedControlWarning as ee } from "./misuseWarnings.js";
12
- import { useFormReset as u } from "../../hooks/useFormReset.js";
13
- import { useSlidingIndicator as d } from "../../hooks/useSlidingIndicator.js";
14
- import { formatCount as f } from "../../hooks/numberFormatLogic.js";
15
- import { KapiTooltip as p } from "../overlays/KapiTooltip.js";
16
- import { nextRadioIndex as m } from "./segmentedLogic.js";
17
- import { useMemo as h } from "react";
18
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ import { useDuplicateValueWarning as l, useMutedControlWarning as te } from "./misuseWarnings.js";
13
+ import { useFormReset as ne } from "../../hooks/useFormReset.js";
14
+ import { useSlidingIndicator as u } from "../../hooks/useSlidingIndicator.js";
15
+ import { formatCount as d } from "../../hooks/numberFormatLogic.js";
16
+ import { KapiTooltip as f } from "../overlays/KapiTooltip.js";
17
+ import { nextRadioIndex as p, segmentedToneAttr as m } from "./segmentedLogic.js";
18
+ import { useMemo as re } from "react";
19
+ import { Fragment as ie, jsx as h, jsxs as g } from "react/jsx-runtime";
19
20
  //#region src/components/inputs/KapiSegmented.tsx
20
- var y = (e) => t(e.activeTone, e.color, void 0), b = ({ items: t, value: b, defaultValue: x, onChange: S, variant: C = "text", "aria-label": w, className: T, name: E, onBlur: D, invalid: O, required: k, label: A, help: j, fieldClassName: M, disabled: N = !1, readOnly: P, size: F = "md", id: I, "aria-describedby": L, ref: R, ...z }) => {
21
- let B = o(), V = a({
22
- id: I,
23
- label: A,
24
- help: j,
25
- required: k,
26
- invalid: O,
27
- readOnly: P,
28
- fieldClassName: M
29
- }), H = i(P, V.field), U = (e) => N || t[e]?.disabled === !0, W = r(V.field, {
30
- id: I,
31
- describedBy: L,
32
- invalid: O,
33
- required: k,
21
+ var _ = (e) => n(e.activeTone, e.color, void 0), v = ({ items: n, value: v, defaultValue: y, onChange: b, variant: x = "text", "aria-label": S, className: C, name: w, onBlur: T, invalid: E, required: D, label: O, help: k, error: A, fieldClassName: j, disabled: M = !1, readOnly: N, size: P = "md", id: F, "aria-describedby": I, ref: L, ...R }) => {
22
+ let z = r(), B = s({
23
+ id: F,
24
+ label: O,
25
+ help: k,
26
+ error: A,
27
+ required: D,
28
+ invalid: E,
29
+ readOnly: N,
30
+ fieldClassName: j
31
+ }), V = o(N, B.field), H = (e) => M || n[e]?.disabled === !0, U = a(B.field, {
32
+ id: F,
33
+ describedBy: I,
34
+ invalid: E,
35
+ required: D,
34
36
  labelable: !1,
35
- ariaLabel: w
36
- }), [G, K, , q] = s(b, () => x ?? t[0]?.id, S), J = u(q), Y = h(() => t.map((e) => e.id), [t]);
37
- l("KapiSegmented", Y), ee("KapiSegmented", {
38
- controlled: b !== void 0,
39
- hasOnChange: !!S,
40
- readOnly: H,
41
- disabled: N
37
+ ariaLabel: S
38
+ }), [W, G, , K] = ee(v, () => y ?? n[0]?.id, b), q = ne(K), J = re(() => n.map((e) => e.id), [n]);
39
+ l("KapiSegmented", J), te("KapiSegmented", {
40
+ controlled: v !== void 0,
41
+ hasOnChange: !!b,
42
+ readOnly: V,
43
+ disabled: M
42
44
  });
43
- let X = t.find((e) => e.id === G), { containerRef: Z, indicatorRef: Q } = d({
44
- active: G ?? null,
45
- deps: [t, C],
45
+ let Y = n.find((e) => e.id === W), X = e("KapiSegmented"), Z = X(Y ? _(Y) : void 0), { containerRef: Q, indicatorRef: ae } = u({
46
+ active: W ?? null,
47
+ deps: [n, x],
46
48
  findActive: (e) => e.querySelector("[role=\"radio\"][aria-checked=\"true\"]")
47
- }), $ = t.findIndex((e) => e.id === G), te = $ >= 0 && !U($) ? $ : t.findIndex((e, t) => !U(t)), ne = (e) => {
48
- if (H) return;
49
- let n = m(t.length, $, c(e), U), r = n === void 0 ? void 0 : t[n];
50
- n !== void 0 && r && (e.preventDefault(), K(r.id), Z.current?.querySelectorAll("[role=\"radio\"]")[n]?.focus());
51
- }, re = (e) => {
52
- e.currentTarget.contains(e.relatedTarget) || D?.(e);
49
+ }), $ = n.findIndex((e) => e.id === W), oe = $ >= 0 && !H($) ? $ : n.findIndex((e, t) => !H(t)), se = (e) => {
50
+ if (V) return;
51
+ let t = p(n.length, $, c(e), H), r = t === void 0 ? void 0 : n[t];
52
+ t !== void 0 && r && (e.preventDefault(), G(r.id), Q.current?.querySelectorAll("[role=\"radio\"]")[t]?.focus());
53
+ }, ce = (e) => {
54
+ e.currentTarget.contains(e.relatedTarget) || T?.(e);
53
55
  };
54
- return V.wrap(/* @__PURE__ */ v("div", {
55
- ...z,
56
- ...W,
56
+ return B.wrap(/* @__PURE__ */ g("div", {
57
+ ...R,
58
+ ...U,
57
59
  ref: (e) => {
58
- Z.current = e, J(e), n(R, e);
60
+ Q.current = e, q(e), i(L, e);
59
61
  },
60
- className: e("kapi-seg", F === "sm" && "kapi-seg--sm", H && "kapi-seg--readonly", T),
62
+ className: t("kapi-seg", P === "sm" && "kapi-seg--sm", V && "kapi-seg--readonly", C),
61
63
  role: "radiogroup",
62
- "aria-label": w,
63
- "aria-disabled": N || void 0,
64
- "aria-readonly": H || void 0,
65
- onKeyDown: ne,
66
- onBlur: re,
64
+ "aria-label": S,
65
+ "aria-disabled": M || void 0,
66
+ "aria-readonly": V || void 0,
67
+ onKeyDown: se,
68
+ onBlur: ce,
67
69
  children: [
68
- /* @__PURE__ */ _("span", {
69
- ref: Q,
70
+ /* @__PURE__ */ h("span", {
71
+ ref: ae,
70
72
  className: "kapi-seg__indicator",
71
- "data-color": X ? y(X) : void 0,
73
+ "data-color": m(Z.tone, Z.style !== void 0),
74
+ style: Z.style,
72
75
  "aria-hidden": "true"
73
76
  }),
74
- t.map((e, t) => {
75
- let n = G === e.id, r = /* @__PURE__ */ v("button", {
77
+ n.map((e, t) => {
78
+ let n = W === e.id, r = t === oe, i = X(e.tone), a = X(_(e)), o = n && a.style || i.style, s = /* @__PURE__ */ g("button", {
76
79
  type: "button",
77
80
  role: "radio",
78
81
  "aria-checked": n,
79
- tabIndex: t === te ? 0 : -1,
80
- "aria-label": C === "icon" ? e.label : void 0,
82
+ tabIndex: r ? 0 : -1,
83
+ "aria-label": x === "icon" ? e.label : void 0,
81
84
  className: `kapi-seg__btn${n ? " is-on" : ""}`,
82
- "data-color": n ? y(e) : void 0,
83
- "data-tone": e.tone,
84
- disabled: U(t) || void 0,
85
+ "data-color": n ? m(a.tone, a.style !== void 0) : void 0,
86
+ "data-tone": m(i.tone, i.style !== void 0),
87
+ style: o,
88
+ disabled: H(t) || void 0,
85
89
  onClick: () => {
86
- H || K(e.id);
90
+ V || G(e.id);
87
91
  },
88
92
  children: [
89
- (C === "icon" || C === "both") && e.icon && /* @__PURE__ */ _("span", {
93
+ (x === "icon" || x === "both") && e.icon && /* @__PURE__ */ h("span", {
90
94
  className: "kapi-seg__ico",
91
95
  children: e.icon
92
96
  }),
93
- C !== "icon" && /* @__PURE__ */ _("span", { children: e.label }),
94
- e.count != null && /* @__PURE__ */ v(g, { children: [" ", /* @__PURE__ */ _("span", {
97
+ x !== "icon" && /* @__PURE__ */ h("span", { children: e.label }),
98
+ e.count != null && /* @__PURE__ */ g(ie, { children: [" ", /* @__PURE__ */ h("span", {
95
99
  className: "kapi-seg__n",
96
- children: f(e.count, B)
100
+ children: d(e.count, z)
97
101
  })] })
98
102
  ]
99
103
  }, e.id);
100
- return C === "icon" && e.label ? /* @__PURE__ */ _(p, {
104
+ return x === "icon" && e.label ? /* @__PURE__ */ h(f, {
101
105
  label: e.label,
102
106
  prefer: "top",
103
- children: r
104
- }, e.id) : r;
107
+ children: s
108
+ }, e.id) : s;
105
109
  }),
106
- E && /* @__PURE__ */ _("input", {
110
+ w && /* @__PURE__ */ h("input", {
107
111
  type: "hidden",
108
- name: E,
109
- value: G === void 0 ? "" : String(G),
110
- disabled: N || void 0
112
+ name: w,
113
+ value: W === void 0 ? "" : String(W),
114
+ disabled: M || void 0
111
115
  })
112
116
  ]
113
117
  }));
114
118
  };
115
119
  //#endregion
116
- export { b as KapiSegmented };
120
+ export { v as KapiSegmented };
@@ -101,6 +101,12 @@ export interface KapiSelectBaseProps<T = unknown> {
101
101
  chipLabel?: string | undefined;
102
102
  /** Ayuda / mensaje de error bajo el control (envuelve el select en un `KapiField`). */
103
103
  help?: ReactNode | undefined;
104
+ /**
105
+ * El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
106
+ * `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
107
+ * Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
108
+ */
109
+ error?: ReactNode | undefined;
104
110
  /** Clase del `KapiField` propio (con `label` o `help`). `className` va al select. */
105
111
  fieldClassName?: string | undefined;
106
112
  /**
@@ -163,13 +169,15 @@ export interface KapiSelectBaseProps<T = unknown> {
163
169
  onBlur?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
164
170
  }
165
171
  /** Clases del contenedor. Pura y exportada para testear. */
166
- export declare const selectClasses: ({ size, open, disabled, readOnly, multi, chip, className }: {
172
+ export declare const selectClasses: ({ size, open, disabled, readOnly, multi, chip, invalid, className }: {
167
173
  size?: KapiSelectSize | undefined;
168
174
  open?: boolean | undefined;
169
175
  disabled?: boolean | undefined;
170
176
  readOnly?: boolean | undefined;
171
177
  multi?: boolean | undefined;
172
178
  chip?: boolean | undefined;
179
+ /** Pinta la caja en rojo, como ya hacían el input, el textarea y el stepper. */
180
+ invalid?: boolean | undefined;
173
181
  className?: string | undefined;
174
182
  }) => string;
175
183
  /**