@kapiuara/ui 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +239 -1
  2. package/dist/components/chat/KapiChatDivider.d.ts +7 -3
  3. package/dist/components/chat/KapiChatDivider.js +6 -6
  4. package/dist/components/chat/KapiChatList.js +19 -19
  5. package/dist/components/chat/KapiChatThread.js +23 -23
  6. package/dist/components/chat/KapiComposer.js +19 -19
  7. package/dist/components/chat/KapiMessageBubble.js +4 -4
  8. package/dist/components/chat/KapiTypingIndicator.js +4 -4
  9. package/dist/components/chat/index.d.ts +1 -1
  10. package/dist/components/closeReason.d.ts +34 -0
  11. package/dist/components/data/KapiBarChart.js +1 -1
  12. package/dist/components/data/KapiDataTable.js +31 -31
  13. package/dist/components/data/KapiEventCalendar.js +78 -78
  14. package/dist/components/data/KapiHeatmap.js +23 -23
  15. package/dist/components/data/KapiLineChart.js +1 -1
  16. package/dist/components/data/KapiPagination.js +4 -4
  17. package/dist/components/data/KapiSparkline.js +1 -1
  18. package/dist/components/data/KapiTable.js +122 -122
  19. package/dist/components/data/KapiTableFilter.js +18 -18
  20. package/dist/components/data/KapiTableRow.js +24 -24
  21. package/dist/components/data/KapiTableToolbar.js +49 -49
  22. package/dist/components/data/chartFrame.js +21 -21
  23. package/dist/components/data/useColumnResize.js +8 -8
  24. package/dist/components/data/useTableSelection.js +8 -8
  25. package/dist/components/display/KapiAnnotation.js +55 -55
  26. package/dist/components/display/KapiComment.js +4 -4
  27. package/dist/components/display/KapiCommentComposer.js +16 -16
  28. package/dist/components/display/KapiFileItem.js +6 -6
  29. package/dist/components/display/KapiFileViewer.js +9 -9
  30. package/dist/components/display/KapiTruncate.js +7 -7
  31. package/dist/components/feedback/KapiAlert.d.ts +2 -1
  32. package/dist/components/feedback/KapiAlert.js +8 -8
  33. package/dist/components/feedback/KapiCountdown.js +8 -8
  34. package/dist/components/feedback/KapiFab.js +30 -30
  35. package/dist/components/feedback/KapiOfflineBanner.js +8 -8
  36. package/dist/components/feedback/KapiToastContainer.js +25 -25
  37. package/dist/components/feedback/KapiTour.d.ts +2 -1
  38. package/dist/components/feedback/KapiTour.js +35 -35
  39. package/dist/components/inputs/KapiAutocomplete.js +14 -14
  40. package/dist/components/inputs/KapiButton.d.ts +17 -1
  41. package/dist/components/inputs/KapiButton.js +41 -25
  42. package/dist/components/inputs/KapiCalendar.js +5 -5
  43. package/dist/components/inputs/KapiCalendarGrid.js +10 -10
  44. package/dist/components/inputs/KapiChecklist.js +71 -71
  45. package/dist/components/inputs/KapiDatePicker.js +124 -122
  46. package/dist/components/inputs/KapiDateRangePicker.js +138 -136
  47. package/dist/components/inputs/KapiFacetedSearch.js +29 -29
  48. package/dist/components/inputs/KapiField.js +14 -14
  49. package/dist/components/inputs/KapiFileUpload.js +27 -27
  50. package/dist/components/inputs/KapiIconButton.d.ts +9 -1
  51. package/dist/components/inputs/KapiIconButton.js +27 -10
  52. package/dist/components/inputs/KapiInput.js +21 -21
  53. package/dist/components/inputs/KapiInputGroup.js +8 -8
  54. package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
  55. package/dist/components/inputs/KapiMaskedInput.js +64 -51
  56. package/dist/components/inputs/KapiNumberStepper.js +29 -29
  57. package/dist/components/inputs/KapiRating.js +61 -59
  58. package/dist/components/inputs/KapiSearchChip.js +8 -8
  59. package/dist/components/inputs/KapiSegmented.js +74 -64
  60. package/dist/components/inputs/KapiSelect.js +232 -222
  61. package/dist/components/inputs/KapiSelectMenu.js +60 -60
  62. package/dist/components/inputs/KapiSlider.js +1 -1
  63. package/dist/components/inputs/KapiSwitch.js +6 -6
  64. package/dist/components/inputs/KapiTagInput.js +83 -81
  65. package/dist/components/inputs/KapiTextarea.js +8 -8
  66. package/dist/components/inputs/misuseWarnings.d.ts +37 -0
  67. package/dist/components/inputs/misuseWarnings.js +36 -0
  68. package/dist/components/inputs/numberStepLogic.d.ts +10 -0
  69. package/dist/components/inputs/numberStepLogic.js +16 -7
  70. package/dist/components/inputs/ownField.js +4 -4
  71. package/dist/components/layout/KapiAccountMenu.d.ts +2 -1
  72. package/dist/components/layout/KapiAccountMenu.js +53 -53
  73. package/dist/components/layout/KapiContextSlot.js +35 -35
  74. package/dist/components/layout/KapiMasonry.js +6 -6
  75. package/dist/components/layout/KapiNotificationBell.js +60 -60
  76. package/dist/components/layout/KapiPageHeader.js +19 -19
  77. package/dist/components/layout/KapiRail.js +60 -60
  78. package/dist/components/layout/KapiRailAccount.js +9 -9
  79. package/dist/components/layout/KapiRoot.js +21 -21
  80. package/dist/components/layout/KapiScrollArea.js +11 -11
  81. package/dist/components/layout/KapiShell.js +12 -12
  82. package/dist/components/locale/KapiLocaleProvider.js +13 -13
  83. package/dist/components/navigation/CtxSlidingList.js +4 -4
  84. package/dist/components/navigation/KapiAccordion.js +12 -12
  85. package/dist/components/navigation/KapiBreadcrumb.js +11 -11
  86. package/dist/components/navigation/KapiCollapsiblePanel.js +23 -23
  87. package/dist/components/navigation/KapiContextPanel.js +76 -76
  88. package/dist/components/navigation/KapiFilterChips.js +9 -9
  89. package/dist/components/navigation/KapiNavBadge.d.ts +4 -2
  90. package/dist/components/navigation/KapiNavBadge.js +11 -10
  91. package/dist/components/navigation/KapiPanelGroup.js +25 -25
  92. package/dist/components/navigation/KapiSteps.js +4 -4
  93. package/dist/components/navigation/KapiTabs.d.ts +4 -1
  94. package/dist/components/navigation/KapiTabs.js +63 -55
  95. package/dist/components/navigation/KapiTree.js +75 -75
  96. package/dist/components/navigation/KapiWizard.d.ts +2 -1
  97. package/dist/components/navigation/KapiWizard.js +30 -30
  98. package/dist/components/overlays/KapiCanvasForm.d.ts +6 -2
  99. package/dist/components/overlays/KapiCanvasForm.js +12 -12
  100. package/dist/components/overlays/KapiCommandPalette.d.ts +2 -1
  101. package/dist/components/overlays/KapiCommandPalette.js +23 -23
  102. package/dist/components/overlays/KapiConfirm.d.ts +2 -1
  103. package/dist/components/overlays/KapiConfirm.js +12 -12
  104. package/dist/components/overlays/KapiContextMenu.d.ts +2 -1
  105. package/dist/components/overlays/KapiContextMenu.js +18 -18
  106. package/dist/components/overlays/KapiDialogHost.js +22 -22
  107. package/dist/components/overlays/KapiLoading.js +16 -16
  108. package/dist/components/overlays/KapiMenuButton.js +15 -15
  109. package/dist/components/overlays/KapiModal.d.ts +2 -1
  110. package/dist/components/overlays/KapiModal.js +28 -28
  111. package/dist/components/overlays/KapiOffcanvas.d.ts +3 -2
  112. package/dist/components/overlays/KapiOffcanvas.js +63 -63
  113. package/dist/components/overlays/KapiOffcanvasStack.js +38 -38
  114. package/dist/components/overlays/KapiPhotoView.js +15 -15
  115. package/dist/components/overlays/KapiPopover.d.ts +2 -1
  116. package/dist/components/overlays/KapiPopover.js +10 -10
  117. package/dist/components/overlays/KapiShapeSheet.js +20 -20
  118. package/dist/components/overlays/KapiSplitModal.js +29 -29
  119. package/dist/components/overlays/KapiTooltip.js +21 -21
  120. package/dist/components/overlays/menuList.js +60 -60
  121. package/dist/components/renderSlot.d.ts +27 -0
  122. package/dist/components/renderSlot.js +23 -0
  123. package/dist/css/components/chat/chat.css +1 -1
  124. package/dist/hooks/portalRoot.js +6 -6
  125. package/dist/hooks/useControllableState.d.ts +6 -2
  126. package/dist/hooks/useControllableState.js +14 -11
  127. package/dist/hooks/useFormReset.d.ts +22 -0
  128. package/dist/hooks/useFormReset.js +17 -0
  129. package/dist/index.d.ts +2 -0
  130. package/dist/kapi.css +1 -1
  131. package/dist/kapi.layered.css +1 -1
  132. package/package.json +5 -2
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiFileUpload.css";
3
- import { fieldControlProps as e, joinIds as t } from "./fieldLogic.js";
4
- import { useKapiField as n } from "./KapiField.js";
5
- import { useLabels as r } from "../locale/KapiLocaleProvider.js";
6
- import { joinClasses as i } from "../rootProps.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { fieldControlProps as t, joinIds as n } from "./fieldLogic.js";
5
+ import { useKapiField as r } from "./KapiField.js";
6
+ import { useLabels as i } from "../locale/KapiLocaleProvider.js";
7
7
  import { formatFileSize as a, isActivationKey as o, matchesAccept as s, mergeFiles as c, removeFileAt as l } from "./fileUploadLogic.js";
8
8
  /* empty css */
9
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
10
- import { useEffect as f, useId as p, useRef as m, useState as h } from "react";
9
+ import { useEffect as u, useId as d, useRef as f, useState as p } from "react";
10
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
11
  import { FileText as g, UploadCloud as _, X as v } from "lucide-react";
12
12
  //#region src/components/inputs/KapiFileUpload.tsx
13
13
  var y = {
@@ -16,12 +16,12 @@ var y = {
16
16
  remove: "Quitar",
17
17
  hint: "PDF, JPG, PNG · hasta 10MB"
18
18
  }, b = ({ multiple: b = !0, accept: x, hint: S, onChange: C, disabled: w = !1, className: T, style: E, labels: D, name: O, id: k, onBlur: A, invalid: j, "aria-describedby": M, ref: N }) => {
19
- let P = r("fileUpload", y, D), F = S ?? P.hint, I = n(), [L, R] = h([]), [z, B] = h(!1), V = m(null), H = p(), U = `${H}-title`, W = `${H}-hint`, G = !!I?.labelId, K = e(I, {
19
+ let P = i("fileUpload", y, D), F = S ?? P.hint, I = r(), [L, R] = p([]), [z, B] = p(!1), V = f(null), H = d(), U = `${H}-title`, W = `${H}-hint`, G = !!I?.labelId, K = t(I, {
20
20
  id: k,
21
- describedBy: t(G && W, M),
21
+ describedBy: n(G && W, M),
22
22
  invalid: j
23
23
  });
24
- f(() => {
24
+ u(() => {
25
25
  let e = V.current;
26
26
  if (!O || !e || typeof DataTransfer > "u" || L.length === 0 && !e.files?.length) return;
27
27
  let t = new DataTransfer();
@@ -33,16 +33,16 @@ var y = {
33
33
  let t = Array.from(e ?? []);
34
34
  t.length !== 0 && q(c(L, t, b));
35
35
  }, Y = () => V.current?.click();
36
- return /* @__PURE__ */ d("div", {
37
- className: i("kapi-upload-wrap", T),
36
+ return /* @__PURE__ */ h("div", {
37
+ className: e("kapi-upload-wrap", T),
38
38
  style: E,
39
39
  children: [
40
- /* @__PURE__ */ d("div", {
40
+ /* @__PURE__ */ h("div", {
41
41
  ref: N,
42
42
  id: K.id,
43
43
  "aria-describedby": K["aria-describedby"],
44
44
  "aria-invalid": K["aria-invalid"],
45
- "aria-labelledby": G ? t(I?.labelId, U) : void 0,
45
+ "aria-labelledby": G ? n(I?.labelId, U) : void 0,
46
46
  onBlur: A,
47
47
  className: `kapi-upload${z ? " is-over" : ""}`,
48
48
  onClick: Y,
@@ -61,30 +61,30 @@ var y = {
61
61
  role: "button",
62
62
  tabIndex: w ? -1 : 0,
63
63
  "aria-disabled": w || void 0,
64
- children: [/* @__PURE__ */ u("span", {
64
+ children: [/* @__PURE__ */ m("span", {
65
65
  className: "kapi-upload__ico",
66
- children: /* @__PURE__ */ u(_, {
66
+ children: /* @__PURE__ */ m(_, {
67
67
  size: 22,
68
68
  strokeWidth: 1.9
69
69
  })
70
- }), /* @__PURE__ */ d("div", {
70
+ }), /* @__PURE__ */ h("div", {
71
71
  className: "kapi-upload__body",
72
- children: [/* @__PURE__ */ d("div", {
72
+ children: [/* @__PURE__ */ h("div", {
73
73
  id: U,
74
74
  className: "kapi-upload__t",
75
75
  children: [
76
76
  P.drop,
77
77
  " ",
78
- /* @__PURE__ */ u("b", { children: P.choose })
78
+ /* @__PURE__ */ m("b", { children: P.choose })
79
79
  ]
80
- }), /* @__PURE__ */ u("div", {
80
+ }), /* @__PURE__ */ m("div", {
81
81
  id: W,
82
82
  className: "kapi-upload__s",
83
83
  children: F
84
84
  })]
85
85
  })]
86
86
  }),
87
- /* @__PURE__ */ u("input", {
87
+ /* @__PURE__ */ m("input", {
88
88
  ref: V,
89
89
  className: "kapi-upload__input",
90
90
  type: "file",
@@ -98,29 +98,29 @@ var y = {
98
98
  J(e.target.files), e.target.value = "";
99
99
  }
100
100
  }),
101
- L.length > 0 && /* @__PURE__ */ u("div", {
101
+ L.length > 0 && /* @__PURE__ */ m("div", {
102
102
  className: "kapi-upload__list",
103
- children: L.map((e, t) => /* @__PURE__ */ d("div", {
103
+ children: L.map((e, t) => /* @__PURE__ */ h("div", {
104
104
  className: "kapi-upload__file",
105
105
  children: [
106
- /* @__PURE__ */ u(g, {
106
+ /* @__PURE__ */ m(g, {
107
107
  className: "kapi-upload__fileico",
108
108
  size: 16,
109
109
  strokeWidth: 1.9
110
110
  }),
111
- /* @__PURE__ */ u("span", {
111
+ /* @__PURE__ */ m("span", {
112
112
  className: "kapi-upload__name",
113
113
  children: e.name
114
114
  }),
115
- /* @__PURE__ */ u("span", {
115
+ /* @__PURE__ */ m("span", {
116
116
  className: "kapi-upload__size",
117
117
  children: a(e.size)
118
118
  }),
119
- /* @__PURE__ */ u("button", {
119
+ /* @__PURE__ */ m("button", {
120
120
  type: "button",
121
121
  "aria-label": `${P.remove} ${e.name}`,
122
122
  onClick: () => q(l(L, t)),
123
- children: /* @__PURE__ */ u(v, {
123
+ children: /* @__PURE__ */ m(v, {
124
124
  size: 15,
125
125
  strokeWidth: 2.2
126
126
  })
@@ -1,4 +1,5 @@
1
1
  import type { ButtonHTMLAttributes, ReactNode, Ref } from "react";
2
+ import { type KapiRender } from "../renderSlot.js";
2
3
  export type KapiIconButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "aria-label"> & {
3
4
  /** Nombre accesible (el botón no tiene texto visible). */
4
5
  "aria-label": string;
@@ -6,8 +7,15 @@ export type KapiIconButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>,
6
7
  icon?: ReactNode;
7
8
  /** Ref al `<button>` nativo. */
8
9
  ref?: Ref<HTMLButtonElement> | undefined;
10
+ /**
11
+ * Dibuja OTRO elemento con el aspecto del botón de ícono: el `<Link>` de tu router, un `<a>`.
12
+ * Mismas reglas que `KapiButton`: clases unidas, estilos fundidos, handlers encadenados con el
13
+ * tuyo primero. `type` no viaja —sólo tiene sentido en un `<button>`— y `disabled` va como
14
+ * `aria-disabled`, que es lo válido fuera de un control nativo.
15
+ */
16
+ render?: KapiRender | undefined;
9
17
  };
10
18
  /** Clases del botón. Pura y exportada para testear. */
11
19
  export declare const iconButtonClasses: (className?: string) => string;
12
20
  /** Botón cuadrado de ícono (`.kapi-btn--icon`), p. ej. el `⋯` de acciones de una fila. */
13
- export declare const KapiIconButton: ({ icon, className, type, ref, ...rest }: KapiIconButtonProps) => import("react").JSX.Element;
21
+ export declare const KapiIconButton: ({ icon, className, type, disabled, ref, render, ...rest }: KapiIconButtonProps) => import("react").JSX.Element;
@@ -1,16 +1,33 @@
1
1
  "use client";
2
- import { jsx as e } from "react/jsx-runtime";
2
+ import { renderSlot as e } from "../renderSlot.js";
3
+ import { jsx as t } from "react/jsx-runtime";
3
4
  //#region src/components/inputs/KapiIconButton.tsx
4
- var t = (e = "") => [
5
+ var n = (e = "") => [
5
6
  "kapi-btn",
6
7
  "kapi-btn--icon",
7
8
  e
8
- ].filter(Boolean).join(" "), n = ({ icon: n, className: r, type: i = "button", ref: a, ...o }) => /* @__PURE__ */ e("button", {
9
- ref: a,
10
- type: i,
11
- className: t(r),
12
- ...o,
13
- children: n ?? "⋯"
14
- });
9
+ ].filter(Boolean).join(" "), r = ({ icon: r, className: i, type: a = "button", disabled: o, ref: s, render: c, ...l }) => {
10
+ let u = r ?? "⋯", d = {
11
+ className: n(i),
12
+ ...l
13
+ };
14
+ return c === void 0 ? /* @__PURE__ */ t("button", {
15
+ ref: s,
16
+ type: a,
17
+ disabled: o,
18
+ className: n(i),
19
+ ...l,
20
+ children: u
21
+ }) : e(c, d, {
22
+ "aria-disabled": o || void 0,
23
+ onClick: o ? (e) => e.preventDefault() : void 0,
24
+ ref: s,
25
+ children: u
26
+ }, (e) => /* @__PURE__ */ t("button", {
27
+ ...e,
28
+ type: a,
29
+ children: u
30
+ }));
31
+ };
15
32
  //#endregion
16
- export { n as KapiIconButton, t as iconButtonClasses };
33
+ export { r as KapiIconButton, n as iconButtonClasses };
@@ -4,11 +4,11 @@ import { fieldControlProps as e, joinIds as t, resolveValidation as n } from "./
4
4
  import { useOwnField as r } from "./ownField.js";
5
5
  import { resolveGroupSize as i } from "./inputGroupLogic.js";
6
6
  import { useKapiInputGroup as ee } from "./KapiInputGroup.js";
7
- import { hasAdornments as te, hasValue as a, inputBoxClasses as ne, present as o } from "./inputLogic.js";
8
- import { useLabels as re } from "../locale/KapiLocaleProvider.js";
7
+ import { hasAdornments as a, hasValue as o, inputBoxClasses as te, present as s } from "./inputLogic.js";
8
+ import { useLabels as ne } from "../locale/KapiLocaleProvider.js";
9
9
  /* empty css */
10
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
11
- import { useId as l, useRef as u, useState as d } from "react";
10
+ import { useId as re, useRef as c, useState as l } from "react";
11
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
12
12
  import { X as f } from "lucide-react";
13
13
  //#region src/components/inputs/KapiInput.tsx
14
14
  var p = { clear: "Limpiar" }, m = (e) => {
@@ -20,14 +20,14 @@ var p = { clear: "Limpiar" }, m = (e) => {
20
20
  t && `kapi-input--${t}`,
21
21
  r
22
22
  ].filter(Boolean).join(" "), g = (g) => {
23
- let { size: ie, invalid: _, status: v, num: y, label: b, required: x, help: S, fieldClassName: C, className: w, multiline: T, id: ae, startIcon: E, endIcon: D, prefix: O, suffix: k, clearable: A, onClear: j, shortcut: M, labels: N, ref: P, ...F } = g, I = P, { invalid: L, status: R } = n(_, v), z = re("input", p, N), B = i(ie, ee()?.size), V = !T && te({
23
+ let { size: ie, invalid: _, status: v, num: y, label: b, required: x, help: S, fieldClassName: C, className: w, multiline: T, id: ae, startIcon: E, endIcon: D, prefix: O, suffix: k, clearable: A, onClear: j, shortcut: M, labels: N, ref: P, ...F } = g, I = P, { invalid: L, status: R } = n(_, v), z = ne("input", p, N), B = i(ie, ee()?.size), V = !T && a({
24
24
  startIcon: E,
25
25
  endIcon: D,
26
26
  prefix: O,
27
27
  suffix: k,
28
28
  clearable: A,
29
29
  shortcut: M
30
- }), H = u(null), U = F, [W, G] = d(() => a(U.defaultValue)), K = r({
30
+ }), H = c(null), U = F, [W, G] = l(() => o(U.defaultValue)), K = r({
31
31
  id: ae,
32
32
  label: b,
33
33
  help: S,
@@ -35,7 +35,7 @@ var p = { clear: "Limpiar" }, m = (e) => {
35
35
  invalid: _,
36
36
  status: v,
37
37
  fieldClassName: C
38
- }), { controlId: q, helpId: J } = K, Y = l(), X = V && o(O) ? `${Y}-prefix` : void 0, Z = V && o(k) ? `${Y}-suffix` : void 0, Q = {
38
+ }), { controlId: q, helpId: J } = K, Y = re(), X = V && s(O) ? `${Y}-prefix` : void 0, Z = V && s(k) ? `${Y}-suffix` : void 0, Q = {
39
39
  ...e(K.outer, {
40
40
  id: q,
41
41
  describedBy: t(J, F["aria-describedby"], X, Z),
@@ -50,15 +50,15 @@ var p = { clear: "Limpiar" }, m = (e) => {
50
50
  })
51
51
  }, oe = (e) => {
52
52
  H.current = e, typeof I == "function" ? I(e) : I && (I.current = e);
53
- }, $ = U.value === void 0 ? W : a(U.value), se = () => {
53
+ }, $ = U.value === void 0 ? W : o(U.value), se = () => {
54
54
  let e = H.current;
55
55
  e && (m(e), G(!1), e.focus(), j?.());
56
- }, ce = T ? /* @__PURE__ */ s("textarea", {
56
+ }, ce = T ? /* @__PURE__ */ u("textarea", {
57
57
  ref: I,
58
58
  ...F,
59
59
  ...Q
60
- }) : V ? /* @__PURE__ */ c("div", {
61
- className: ne({
60
+ }) : V ? /* @__PURE__ */ d("div", {
61
+ className: te({
62
62
  size: B,
63
63
  status: R,
64
64
  disabled: U.disabled,
@@ -68,50 +68,50 @@ var p = { clear: "Limpiar" }, m = (e) => {
68
68
  e.target === H.current || U.disabled || (e.preventDefault(), H.current?.focus());
69
69
  },
70
70
  children: [
71
- o(E) && /* @__PURE__ */ s("span", {
71
+ s(E) && /* @__PURE__ */ u("span", {
72
72
  className: "kapi-inputbox__icon",
73
73
  "aria-hidden": "true",
74
74
  children: E
75
75
  }),
76
- o(O) && /* @__PURE__ */ s("span", {
76
+ s(O) && /* @__PURE__ */ u("span", {
77
77
  id: X,
78
78
  className: "kapi-inputbox__affix",
79
79
  children: O
80
80
  }),
81
- /* @__PURE__ */ s("input", {
81
+ /* @__PURE__ */ u("input", {
82
82
  ref: oe,
83
83
  ...U,
84
84
  ...Q,
85
85
  "aria-keyshortcuts": U["aria-keyshortcuts"] ?? (M || void 0),
86
86
  onChange: (e) => {
87
- G(a(e.target.value)), U.onChange?.(e);
87
+ G(o(e.target.value)), U.onChange?.(e);
88
88
  }
89
89
  }),
90
- o(k) && /* @__PURE__ */ s("span", {
90
+ s(k) && /* @__PURE__ */ u("span", {
91
91
  id: Z,
92
92
  className: "kapi-inputbox__affix",
93
93
  children: k
94
94
  }),
95
- A && $ && !U.disabled && !U.readOnly && /* @__PURE__ */ s("button", {
95
+ A && $ && !U.disabled && !U.readOnly && /* @__PURE__ */ u("button", {
96
96
  type: "button",
97
97
  tabIndex: -1,
98
98
  className: "kapi-inputbox__clear",
99
99
  "aria-label": z.clear,
100
100
  onClick: se,
101
- children: /* @__PURE__ */ s(f, { "aria-hidden": "true" })
101
+ children: /* @__PURE__ */ u(f, { "aria-hidden": "true" })
102
102
  }),
103
- M && !$ && /* @__PURE__ */ s("kbd", {
103
+ M && !$ && /* @__PURE__ */ u("kbd", {
104
104
  className: "kapi-inputbox__kbd",
105
105
  "aria-hidden": "true",
106
106
  children: M
107
107
  }),
108
- o(D) && /* @__PURE__ */ s("span", {
108
+ s(D) && /* @__PURE__ */ u("span", {
109
109
  className: "kapi-inputbox__icon",
110
110
  "aria-hidden": "true",
111
111
  children: D
112
112
  })
113
113
  ]
114
- }) : /* @__PURE__ */ s("input", {
114
+ }) : /* @__PURE__ */ u("input", {
115
115
  ref: I,
116
116
  ...U,
117
117
  ...Q
@@ -3,18 +3,18 @@ import "#kapi-css/components/inputs/KapiInputGroup.css";
3
3
  import { resolveValidation as e } from "./fieldLogic.js";
4
4
  import { inputGroupAddonClasses as t, inputGroupClasses as n } from "./inputGroupLogic.js";
5
5
  /* empty css */
6
- import { jsx as r } from "react/jsx-runtime";
7
- import { createContext as i, useContext as a, useMemo as o } from "react";
6
+ import { createContext as r, useContext as i, useMemo as a } from "react";
7
+ import { jsx as o } from "react/jsx-runtime";
8
8
  //#region src/components/inputs/KapiInputGroup.tsx
9
- var s = i(null), c = () => a(s), l = ({ decorative: e = !1, className: n, children: i }) => /* @__PURE__ */ r("span", {
9
+ var s = r(null), c = () => i(s), l = ({ decorative: e = !1, className: n, children: r }) => /* @__PURE__ */ o("span", {
10
10
  className: t(n),
11
11
  "aria-hidden": e || void 0,
12
- children: i
13
- }), u = ({ size: t, invalid: i, status: a, className: c, children: l, ...u }) => {
14
- let { status: d } = e(i, a), f = o(() => ({ size: t }), [t]);
15
- return /* @__PURE__ */ r(s.Provider, {
12
+ children: r
13
+ }), u = ({ size: t, invalid: r, status: i, className: c, children: l, ...u }) => {
14
+ let { status: d } = e(r, i), f = a(() => ({ size: t }), [t]);
15
+ return /* @__PURE__ */ o(s.Provider, {
16
16
  value: f,
17
- children: /* @__PURE__ */ r("div", {
17
+ children: /* @__PURE__ */ o("div", {
18
18
  ...u,
19
19
  role: "group",
20
20
  className: n({
@@ -4,6 +4,11 @@ import { type KapiInputProps } from "./KapiInput.js";
4
4
  type MaskedBaseProps = Omit<KapiInputProps, "value" | "defaultValue" | "multiline" | "type"> & {
5
5
  /** Ref al `<input>`. */
6
6
  ref?: Ref<HTMLInputElement> | undefined;
7
+ /**
8
+ * Nombre para formularios nativos: un `<input type="hidden">` con el valor CRUDO (los dígitos, o
9
+ * el número en el caso del importe). El campo de texto no lleva `name`.
10
+ */
11
+ name?: string | undefined;
7
12
  };
8
13
  export type KapiDniInputProps = MaskedBaseProps & {
9
14
  /** Dígitos del DNI (sin puntos). Controlado si viene definido. */
@@ -14,7 +19,7 @@ export type KapiDniInputProps = MaskedBaseProps & {
14
19
  onValueChange?: ((digits: string) => void) | undefined;
15
20
  };
16
21
  /** DNI argentino con máscara `12.345.678` (7 u 8 dígitos). El valor son sólo los dígitos. */
17
- export declare const KapiDniInput: ({ value, defaultValue, onValueChange, onChange, ref, placeholder, ...rest }: KapiDniInputProps) => import("react").JSX.Element;
22
+ export declare const KapiDniInput: ({ value, defaultValue, onValueChange, onChange, ref, name, disabled, placeholder, ...rest }: KapiDniInputProps) => import("react").JSX.Element;
18
23
  export type KapiCuitInputProps = MaskedBaseProps & {
19
24
  /** Dígitos del CUIT/CUIL (sin guiones). Controlado si viene definido. */
20
25
  value?: string | undefined;
@@ -35,7 +40,7 @@ export declare const DEFAULT_CUIT_INPUT_LABELS: KapiCuitInputLabels;
35
40
  * rojo y `aria-invalid` (salvo que `invalid` o `status` vengan de afuera); si el campo tiene label o ayuda, muestra
36
41
  * `invalidMessage`.
37
42
  */
38
- export declare const KapiCuitInput: ({ value, defaultValue, onValueChange, onChange, invalidMessage, invalid: invalidProp, status, help, label, ref, placeholder, ...rest }: KapiCuitInputProps) => import("react").JSX.Element;
43
+ export declare const KapiCuitInput: ({ value, defaultValue, onValueChange, onChange, invalidMessage, invalid: invalidProp, status, help, label, ref, name, disabled, placeholder, ...rest }: KapiCuitInputProps) => import("react").JSX.Element;
39
44
  export type KapiCurrencyInputProps = MaskedBaseProps & {
40
45
  /** Importe. Controlado si viene definido (`null` = vacío). */
41
46
  value?: number | null | undefined;
@@ -48,5 +53,5 @@ export type KapiCurrencyInputProps = MaskedBaseProps & {
48
53
  * Importe en pesos con formato es-AR (`$ 1.234,56`): puntos de miles automáticos y coma decimal
49
54
  * mientras se tipea; al salir del campo completa los dos decimales. El valor es un `number`.
50
55
  */
51
- export declare const KapiCurrencyInput: ({ value, defaultValue, onValueChange, onChange, onBlur, ref, placeholder, ...rest }: KapiCurrencyInputProps) => import("react").JSX.Element;
56
+ export declare const KapiCurrencyInput: ({ value, defaultValue, onValueChange, onChange, onBlur, ref, name, disabled, placeholder, ...rest }: KapiCurrencyInputProps) => import("react").JSX.Element;
52
57
  export {};
@@ -4,78 +4,91 @@ import { useLabels as t } from "../locale/KapiLocaleProvider.js";
4
4
  import { KapiInput as n } from "./KapiInput.js";
5
5
  import { useControllableState as r } from "../../hooks/useControllableState.js";
6
6
  import { activeElementOf as i } from "../../hooks/ownerDocument.js";
7
- import { caretForSignificant as a, countSignificant as o, formatCuit as s, formatCurrency as c, formatDni as l, isValidCuit as u, maskCurrencyInput as d, onlyDigits as f, parseCurrency as p } from "./maskLogic.js";
8
- import { jsx as m } from "react/jsx-runtime";
7
+ import { useFormReset as a } from "../../hooks/useFormReset.js";
8
+ import { caretForSignificant as o, countSignificant as s, formatCuit as c, formatCurrency as l, formatDni as u, isValidCuit as d, maskCurrencyInput as f, onlyDigits as p, parseCurrency as m } from "./maskLogic.js";
9
9
  import { useCallback as h, useRef as g, useState as _ } from "react";
10
+ import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
10
11
  //#region src/components/inputs/KapiMaskedInput.tsx
11
- var v = (t, n, r) => ({
12
- setRef: h((t) => e(n, t), [n]),
12
+ var x = (e, t, n) => e ? /* @__PURE__ */ y("input", {
13
+ type: "hidden",
14
+ name: e,
15
+ value: t,
16
+ disabled: n
17
+ }) : null, S = (t, n, r, a) => ({
18
+ setRef: h((t) => {
19
+ e(n, t), a?.(t);
20
+ }, [n, a]),
13
21
  apply: (e, n) => {
14
- let s = e.target, c = s.selectionStart ?? s.value.length;
15
- if (r !== void 0 && f(s.value).length > r) {
16
- let e = Math.max(0, c - (s.value.length - n.length));
17
- return s.value = n, s.setSelectionRange(e, e), n;
22
+ let a = e.target, c = a.selectionStart ?? a.value.length;
23
+ if (r !== void 0 && p(a.value).length > r) {
24
+ let e = Math.max(0, c - (a.value.length - n.length));
25
+ return a.value = n, a.setSelectionRange(e, e), n;
18
26
  }
19
- let l = o(s.value, c), u = t(s.value);
20
- if (s.value = u, i(s) === s) {
21
- let e = a(u, l);
22
- s.setSelectionRange(e, e);
27
+ let l = s(a.value, c), u = t(a.value);
28
+ if (a.value = u, i(a) === a) {
29
+ let e = o(u, l);
30
+ a.setSelectionRange(e, e);
23
31
  }
24
32
  return u;
25
33
  }
26
- }), y = ({ value: e, defaultValue: t = "", onValueChange: i, onChange: a, ref: o, placeholder: s = "12.345.678", ...c }) => {
27
- let [u, d] = r(e, () => f(t, 8), i), p = f(u, 8), { setRef: h, apply: g } = v(l, o, 8);
28
- return /* @__PURE__ */ m(n, {
29
- ...c,
30
- ref: h,
31
- value: l(p),
32
- placeholder: s,
34
+ }), C = ({ value: e, defaultValue: t = "", onValueChange: i, onChange: o, ref: s, name: c, disabled: l, placeholder: d = "12.345.678", ...f }) => {
35
+ let [m, h, , g] = r(e, () => p(t, 8), i), _ = p(m, 8), { setRef: C, apply: w } = S(u, s, 8, a(g));
36
+ return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(n, {
37
+ ...f,
38
+ ref: C,
39
+ disabled: l,
40
+ value: u(_),
41
+ placeholder: d,
33
42
  inputMode: "numeric",
34
43
  autoComplete: "off",
35
44
  onChange: (e) => {
36
- let t = f(g(e, l(p)));
37
- t !== p && d(t), a?.(e);
45
+ let t = p(w(e, u(_)));
46
+ t !== _ && h(t), o?.(e);
38
47
  }
39
- });
40
- }, b = { invalid: "CUIT inválido: revisa el dígito verificador" }, x = ({ value: e, defaultValue: i = "", onValueChange: a, onChange: o, invalidMessage: c, invalid: l, status: d, help: p, label: h, ref: g, placeholder: _ = "20-12345678-9", ...y }) => {
41
- let x = t("cuitInput", b), [S, C] = r(e, () => f(i, 11), a && ((e) => a(e, u(e)))), w = f(S, 11), T = w.length === 11 && !u(w), E = l !== void 0 || d !== void 0, D = h != null || !!p, { setRef: O, apply: k } = v(s, g, 11);
42
- return /* @__PURE__ */ m(n, {
43
- ...y,
44
- ref: O,
48
+ }), x(c, _, l)] });
49
+ }, w = { invalid: "CUIT inválido: revisa el dígito verificador" }, T = ({ value: e, defaultValue: i = "", onValueChange: o, onChange: s, invalidMessage: l, invalid: u, status: f, help: m, label: h, ref: g, name: _, disabled: C, placeholder: T = "20-12345678-9", ...E }) => {
50
+ let D = t("cuitInput", w), [O, k, , A] = r(e, () => p(i, 11), o && ((e) => o(e, d(e)))), j = p(O, 11), M = a(A), N = j.length === 11 && !d(j), P = u !== void 0 || f !== void 0, F = h != null || !!m, { setRef: I, apply: L } = S(c, g, 11, M);
51
+ return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(n, {
52
+ ...E,
53
+ ref: I,
54
+ disabled: C,
45
55
  label: h,
46
- help: D && T ? c ?? x.invalid : p,
47
- status: d,
48
- invalid: E ? l : T || void 0,
49
- value: s(w),
50
- placeholder: _,
56
+ help: F && N ? l ?? D.invalid : m,
57
+ status: f,
58
+ invalid: P ? u : N || void 0,
59
+ value: c(j),
60
+ placeholder: T,
51
61
  inputMode: "numeric",
52
62
  autoComplete: "off",
53
63
  onChange: (e) => {
54
- let t = f(k(e, s(w)));
55
- t !== w && C(t), o?.(e);
64
+ let t = p(L(e, c(j)));
65
+ t !== j && k(t), s?.(e);
56
66
  }
57
- });
58
- }, S = ({ value: e, defaultValue: t = null, onValueChange: r, onChange: i, onBlur: a, ref: o, placeholder: s = "$ 0,00", ...l }) => {
59
- let [u, f] = _(() => c(e === void 0 ? t : e)), h = g(p(u)), [y, b] = _(e);
60
- e !== void 0 && e !== y && (b(e), e !== p(u) && (f(c(e)), h.current = e));
61
- let { setRef: x, apply: S } = v(d, o);
62
- return /* @__PURE__ */ m(n, {
63
- ...l,
64
- ref: x,
65
- value: u,
66
- placeholder: s,
67
+ }), x(_, j, C)] });
68
+ }, E = ({ value: e, defaultValue: t = null, onValueChange: r, onChange: i, onBlur: o, ref: s, name: c, disabled: u, placeholder: d = "$ 0,00", ...p }) => {
69
+ let [h, C] = _(() => l(e === void 0 ? t : e)), w = g(m(h)), T = g(h), [E, D] = _(e);
70
+ e !== void 0 && e !== E && (D(e), e !== m(h) && (C(l(e)), w.current = e));
71
+ let O = a(() => {
72
+ e === void 0 && (C(T.current), w.current = m(T.current));
73
+ }), { setRef: k, apply: A } = S(f, s, void 0, O), j = m(h);
74
+ return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(n, {
75
+ ...p,
76
+ ref: k,
77
+ disabled: u,
78
+ value: h,
79
+ placeholder: d,
67
80
  inputMode: "decimal",
68
81
  autoComplete: "off",
69
82
  onChange: (e) => {
70
- let t = S(e, u);
71
- f(t);
72
- let n = p(t);
73
- n !== h.current && (h.current = n, r?.(n)), i?.(e);
83
+ let t = A(e, h);
84
+ C(t);
85
+ let n = m(t);
86
+ n !== w.current && (w.current = n, r?.(n)), i?.(e);
74
87
  },
75
88
  onBlur: (e) => {
76
- f(c(p(u))), a?.(e);
89
+ C(l(m(h))), o?.(e);
77
90
  }
78
- });
91
+ }), x(c, j === null ? "" : String(j), u)] });
79
92
  };
80
93
  //#endregion
81
- export { b as DEFAULT_CUIT_INPUT_LABELS, x as KapiCuitInput, S as KapiCurrencyInput, y as KapiDniInput };
94
+ export { w as DEFAULT_CUIT_INPUT_LABELS, T as KapiCuitInput, E as KapiCurrencyInput, C as KapiDniInput };