@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,52 +1,52 @@
1
1
  "use client";
2
2
  import { flattenMenuRows as e } from "./selectLogic.js";
3
3
  import { useVirtualList as t } from "../../hooks/useVirtualList.js";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
- import { memo as i, useCallback as a, useLayoutEffect as o, useMemo as s, useRef as c } from "react";
4
+ import { memo as n, useCallback as r, useLayoutEffect as i, useMemo as a, useRef as o } from "react";
5
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
6
  import { Check as l } from "lucide-react";
7
7
  import { createPortal as u } from "react-dom";
8
8
  //#region src/components/inputs/KapiSelectMenu.tsx
9
- var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, active: o, create: s, vindex: c, setSize: u, renderOption: d, query: f, onHover: p, onChoose: m }) => /* @__PURE__ */ r("li", {
10
- id: i,
9
+ var d = 38, f = 264, p = 4, m = n(({ option: e, index: t, id: n, selected: r, active: i, create: a, vindex: o, setSize: u, renderOption: d, query: f, onHover: p, onChoose: m }) => /* @__PURE__ */ c("li", {
10
+ id: n,
11
11
  role: "option",
12
- "aria-selected": a,
12
+ "aria-selected": r,
13
13
  "aria-disabled": e.disabled || void 0,
14
14
  "data-kapisel-index": t,
15
- "data-vindex": c,
16
- "aria-setsize": c === void 0 ? void 0 : u,
17
- "aria-posinset": c === void 0 ? void 0 : t + 1,
15
+ "data-vindex": o,
16
+ "aria-setsize": o === void 0 ? void 0 : u,
17
+ "aria-posinset": o === void 0 ? void 0 : t + 1,
18
18
  className: [
19
19
  "kapisel__opt",
20
- o && "kapisel__opt--active",
21
- a && "kapisel__opt--selected",
22
- s && "kapisel__opt--create",
20
+ i && "kapisel__opt--active",
21
+ r && "kapisel__opt--selected",
22
+ a && "kapisel__opt--create",
23
23
  e.disabled && "kapisel__opt--disabled"
24
24
  ].filter(Boolean).join(" "),
25
25
  onMouseMove: () => {
26
- !e.disabled && !o && p(t);
26
+ !e.disabled && !i && p(t);
27
27
  },
28
28
  onClick: (t) => m(e, t.shiftKey),
29
- children: [/* @__PURE__ */ n("span", {
29
+ children: [/* @__PURE__ */ s("span", {
30
30
  className: "kapisel__opt-body",
31
- children: d && !s ? d(e, {
32
- selected: a,
33
- active: o,
31
+ children: d && !a ? d(e, {
32
+ selected: r,
33
+ active: i,
34
34
  disabled: e.disabled === !0,
35
35
  query: f
36
36
  }) : e.label
37
- }), a && /* @__PURE__ */ n(l, {
37
+ }), r && /* @__PURE__ */ s(l, {
38
38
  className: "kapisel__check",
39
39
  size: 15,
40
40
  strokeWidth: 2.4,
41
41
  "aria-hidden": "true"
42
42
  })]
43
- })), h = ({ root: i, ref: l, side: h, hug: g, style: _, listboxId: v, optionId: y, multiple: b, "aria-label": x, rows: S, createRow: C, createIndex: w, loading: T, empty: E, message: D, active: O, values: k, renderOption: A, query: j, virtual: M, onHover: N, onChoose: P }) => {
44
- let F = c(null), I = s(() => M ? e(S, C, w) : null, [
43
+ })), h = ({ root: n, ref: l, side: h, hug: g, style: _, listboxId: v, optionId: y, multiple: b, "aria-label": x, rows: S, createRow: C, createIndex: w, loading: T, empty: E, message: D, active: O, values: k, renderOption: A, query: j, virtual: M, onHover: N, onChoose: P }) => {
44
+ let F = o(null), I = a(() => M ? e(S, C, w) : null, [
45
45
  M,
46
46
  S,
47
47
  C,
48
48
  w
49
- ]), L = s(() => I?.rows.map((e) => e.key), [I]), R = t({
49
+ ]), L = a(() => I?.rows.map((e) => e.key), [I]), R = t({
50
50
  enabled: M && !T,
51
51
  count: I?.rows.length ?? 0,
52
52
  scrollRef: F,
@@ -56,42 +56,42 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
56
56
  overscan: p,
57
57
  fallbackViewHeight: f
58
58
  }), { scrollToIndex: z } = R, B = O >= 0 ? I?.rowOf[O] : void 0;
59
- o(() => {
59
+ i(() => {
60
60
  B !== void 0 && z(B);
61
61
  }, [B, z]);
62
- let V = s(() => new Set(k), [k]), H = c({
62
+ let V = a(() => new Set(k), [k]), H = o({
63
63
  onHover: N,
64
64
  onChoose: P
65
65
  });
66
- o(() => {
66
+ i(() => {
67
67
  H.current = {
68
68
  onHover: N,
69
69
  onChoose: P
70
70
  };
71
71
  });
72
- let U = a((e) => H.current.onHover(e), []), W = a((e, t) => H.current.onChoose(e, t), []), G = w + 1, K = ({ option: e, index: t }, r) => {
73
- let i = e === C, a = A && !i ? A : void 0;
74
- return /* @__PURE__ */ n(m, {
72
+ let U = r((e) => H.current.onHover(e), []), W = r((e, t) => H.current.onChoose(e, t), []), G = w + 1, K = ({ option: e, index: t }, n) => {
73
+ let r = e === C, i = A && !r ? A : void 0;
74
+ return /* @__PURE__ */ s(m, {
75
75
  option: e,
76
76
  index: t,
77
77
  id: y(t),
78
78
  selected: V.has(e.value),
79
79
  active: t === O,
80
- create: i,
81
- vindex: r,
82
- setSize: r === void 0 ? void 0 : G,
83
- renderOption: a,
84
- query: a ? j : "",
80
+ create: r,
81
+ vindex: n,
82
+ setSize: n === void 0 ? void 0 : G,
83
+ renderOption: i,
84
+ query: i ? j : "",
85
85
  onHover: U,
86
86
  onChoose: W
87
87
  }, `${e.value}-${t}`);
88
88
  };
89
- return u(/* @__PURE__ */ r("div", {
89
+ return u(/* @__PURE__ */ c("div", {
90
90
  ref: l,
91
91
  className: `kapisel__menu kapisel__menu--${h}${g ? " kapisel__menu--hug" : ""}`,
92
92
  style: _,
93
93
  onMouseDown: (e) => e.preventDefault(),
94
- children: [/* @__PURE__ */ r("ul", {
94
+ children: [/* @__PURE__ */ c("ul", {
95
95
  id: v,
96
96
  role: "listbox",
97
97
  "aria-multiselectable": b || void 0,
@@ -101,55 +101,55 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
101
101
  ref: F,
102
102
  onScroll: M ? R.onScroll : void 0,
103
103
  children: [
104
- !T && I && ((e, t, i, a, o) => {
105
- let s = [];
106
- a > 0 && s.push(/* @__PURE__ */ n("li", {
104
+ !T && I && ((e, t, n, r, i) => {
105
+ let a = [];
106
+ r > 0 && a.push(/* @__PURE__ */ s("li", {
107
107
  role: "presentation",
108
108
  "aria-hidden": !0,
109
- style: { height: a }
109
+ style: { height: r }
110
110
  }, "pad-top"));
111
- let c = t;
112
- for (; c < i;) {
113
- let t = e[c];
111
+ let o = t;
112
+ for (; o < n;) {
113
+ let t = e[o];
114
114
  if (t.group === null) {
115
- t.kind === "option" && s.push(K(t.item, c)), c += 1;
115
+ t.kind === "option" && a.push(K(t.item, o)), o += 1;
116
116
  continue;
117
117
  }
118
- let a = t.group, o = null, l = [];
119
- for (; c < i && e[c].group?.key === a.key;) {
120
- let t = e[c];
121
- t.kind === "header" ? o = /* @__PURE__ */ n("div", {
118
+ let r = t.group, i = null, l = [];
119
+ for (; o < n && e[o].group?.key === r.key;) {
120
+ let t = e[o];
121
+ t.kind === "header" ? i = /* @__PURE__ */ s("div", {
122
122
  className: "kapisel__group-label",
123
123
  "aria-hidden": "true",
124
- "data-vindex": c,
125
- children: a.label
126
- }, "h") : l.push(K(t.item, c)), c += 1;
124
+ "data-vindex": o,
125
+ children: r.label
126
+ }, "h") : l.push(K(t.item, o)), o += 1;
127
127
  }
128
- s.push(/* @__PURE__ */ r("li", {
128
+ a.push(/* @__PURE__ */ c("li", {
129
129
  role: "presentation",
130
130
  className: "kapisel__group",
131
- children: [o, l.length > 0 && /* @__PURE__ */ n("ul", {
131
+ children: [i, l.length > 0 && /* @__PURE__ */ s("ul", {
132
132
  role: "group",
133
- "aria-label": a.label,
133
+ "aria-label": r.label,
134
134
  className: "kapisel__group-list",
135
135
  children: l
136
136
  })]
137
- }, a.key));
137
+ }, r.key));
138
138
  }
139
- return o > 0 && s.push(/* @__PURE__ */ n("li", {
139
+ return i > 0 && a.push(/* @__PURE__ */ s("li", {
140
140
  role: "presentation",
141
141
  "aria-hidden": !0,
142
- style: { height: o }
143
- }, "pad-bottom")), s;
142
+ style: { height: i }
143
+ }, "pad-bottom")), a;
144
144
  })(I.rows, R.start, R.end, R.padTop, R.padBottom),
145
- !T && !I && S.map((e) => e.kind === "option" ? K(e.item) : /* @__PURE__ */ r("li", {
145
+ !T && !I && S.map((e) => e.kind === "option" ? K(e.item) : /* @__PURE__ */ c("li", {
146
146
  role: "presentation",
147
147
  className: "kapisel__group",
148
- children: [/* @__PURE__ */ n("div", {
148
+ children: [/* @__PURE__ */ s("div", {
149
149
  className: "kapisel__group-label",
150
150
  "aria-hidden": "true",
151
151
  children: e.label
152
- }), /* @__PURE__ */ n("ul", {
152
+ }), /* @__PURE__ */ s("ul", {
153
153
  role: "group",
154
154
  "aria-label": e.label,
155
155
  className: "kapisel__group-list",
@@ -161,13 +161,13 @@ var d = 38, f = 264, p = 4, m = i(({ option: e, index: t, id: i, selected: a, ac
161
161
  index: w
162
162
  })
163
163
  ]
164
- }), D != null && D !== !1 && D !== "" && /* @__PURE__ */ n("div", {
164
+ }), D != null && D !== !1 && D !== "" && /* @__PURE__ */ s("div", {
165
165
  className: "kapisel__status",
166
166
  role: "status",
167
167
  "aria-live": "polite",
168
168
  children: D
169
169
  })]
170
- }), i);
170
+ }), n);
171
171
  };
172
172
  //#endregion
173
173
  export { h as KapiSelectMenu };
@@ -5,8 +5,8 @@ import { useOwnField as r } from "./ownField.js";
5
5
  /* empty css */
6
6
  import { useControllableState as i } from "../../hooks/useControllableState.js";
7
7
  import { clampToStep as a, percentOf as o } from "./sliderLogic.js";
8
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
8
  import "react";
9
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
10
10
  //#region src/components/inputs/KapiSlider.tsx
11
11
  var l = ({ tone: e = "primary", disabled: t = !1, readOnly: n = !1, className: r = "" } = {}) => [
12
12
  "kapi-slider",
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/checkControl.css";
3
- import { nativeFieldProps as e } from "./fieldLogic.js";
4
- import { useKapiField as t } from "./KapiField.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { nativeFieldProps as t } from "./fieldLogic.js";
5
+ import { useKapiField as n } from "./KapiField.js";
5
6
  /* empty css */
6
- import { joinClasses as n } from "../rootProps.js";
7
7
  import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
8
8
  //#region src/components/inputs/KapiSwitch.tsx
9
9
  var o = ({ label: o, className: s, ref: c, invalid: l, id: u, required: d, "aria-describedby": f, "aria-invalid": p, "aria-required": m, ...h }) => {
10
- let g = e(t(), {
10
+ let g = t(n(), {
11
11
  id: u,
12
12
  describedBy: f,
13
13
  invalid: l,
@@ -23,10 +23,10 @@ var o = ({ label: o, className: s, ref: c, invalid: l, id: u, required: d, "aria
23
23
  required: d
24
24
  }), /* @__PURE__ */ i("span", { className: "kapi-switch__track" })] });
25
25
  return o == null ? /* @__PURE__ */ i("label", {
26
- className: n("kapi-switch", s),
26
+ className: e("kapi-switch", s),
27
27
  children: _
28
28
  }) : /* @__PURE__ */ a("label", {
29
- className: n("kapi-switchfield", s),
29
+ className: e("kapi-switchfield", s),
30
30
  children: [/* @__PURE__ */ i("span", {
31
31
  className: "kapi-switch",
32
32
  children: _
@@ -1,122 +1,124 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiTagInput.css";
3
- import { assignRef as e, fieldControlProps as t, focusLeaves as n, joinIds as r, resolveReadOnly as i } from "./fieldLogic.js";
4
- import { useOwnField as ee } from "./ownField.js";
5
- import { useLabels as te } from "../locale/KapiLocaleProvider.js";
6
- import { joinClasses as a } from "../rootProps.js";
7
- import { useControllableState as o } from "../../hooks/useControllableState.js";
3
+ import { joinClasses as e } from "../rootProps.js";
4
+ import { assignRef as t, fieldControlProps as n, focusLeaves as r, joinIds as i, resolveReadOnly as a } from "./fieldLogic.js";
5
+ import { useOwnField as o } from "./ownField.js";
6
+ import { useLabels as s } from "../locale/KapiLocaleProvider.js";
7
+ import { useControllableState as ee } from "../../hooks/useControllableState.js";
8
+ import { useFormReset as te } from "../../hooks/useFormReset.js";
9
+ import { useMergedRefs as ne } from "../../hooks/mergeRefs.js";
8
10
  /* empty css */
9
- import { addTags as s, hasSeparator as c, removeTagAt as l, spliceText as ne, splitDraft as re, splitTags as u } from "./tagInputLogic.js";
11
+ import { addTags as re, hasSeparator as c, removeTagAt as l, spliceText as u, splitDraft as d, splitTags as f } from "./tagInputLogic.js";
10
12
  import { KapiTag as ie } from "../display/KapiTag.js";
11
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
12
- import { useCallback as p, useId as m, useRef as h, useState as g } from "react";
13
+ import { useCallback as ae, useId as oe, useRef as p, useState as m } from "react";
14
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
15
  //#region src/components/inputs/KapiTagInput.tsx
14
16
  var _ = {
15
17
  remove: "Quitar",
16
18
  duplicate: "Ya está en la lista:",
17
19
  max: "Llegaste al máximo de"
18
- }, v = ({ size: e = "md", invalid: t, disabled: n, readOnly: r, className: i }) => a("kapi-taginput", e !== "md" && `kapi-taginput--${e}`, t && "kapi-taginput--err", n && "kapi-taginput--disabled", r && "kapi-taginput--readonly", i);
19
- function y({ value: a, defaultValue: y = [], onChange: ae, validate: oe, maxTags: b, allowDuplicates: x, caseSensitive: S, placeholder: C, disabled: w = !1, size: T = "md", name: E, id: D, invalid: O, required: k, label: se, help: ce, fieldClassName: le, readOnly: A, "aria-label": ue, "aria-labelledby": j, "aria-describedby": M, onBlur: N, ref: P, labels: F, className: I, onClick: L, ...R }) {
20
- let z = te("tagInput", _, F), B = ee({
21
- id: D,
22
- label: se,
23
- help: ce,
24
- required: k,
25
- invalid: O,
26
- readOnly: A,
27
- fieldClassName: le
28
- }), V = B.field, H = i(A, V), U = m(), [W, G] = o(a, y, ae), [K, q] = g(""), [J, Y] = g(null), X = h(null), Z = h(null), de = p((t) => {
29
- Z.current = t, e(P, t);
30
- }, [P]), fe = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${z.duplicate} ${e.tag}` : `${z.max} ${b}`, Q = (e, t = "") => {
31
- let { values: n, rejected: r } = s(W, e, {
32
- validate: oe,
33
- maxTags: b,
34
- allowDuplicates: x,
35
- caseSensitive: S
20
+ }, v = ({ size: t = "md", invalid: n, disabled: r, readOnly: i, className: a }) => e("kapi-taginput", t !== "md" && `kapi-taginput--${t}`, n && "kapi-taginput--err", r && "kapi-taginput--disabled", i && "kapi-taginput--readonly", a);
21
+ function y({ value: e, defaultValue: y = [], onChange: b, validate: se, maxTags: x, allowDuplicates: ce, caseSensitive: le, placeholder: ue, disabled: S = !1, size: C = "md", name: w, id: T, invalid: E, required: D, label: de, help: fe, fieldClassName: pe, readOnly: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, onBlur: M, ref: N, labels: P, className: F, onClick: I, ...L }) {
22
+ let R = s("tagInput", _, P), z = o({
23
+ id: T,
24
+ label: de,
25
+ help: fe,
26
+ required: D,
27
+ invalid: E,
28
+ readOnly: O,
29
+ fieldClassName: pe
30
+ }), B = z.field, V = a(O, B), H = oe(), [U, W, , me] = ee(e, y, b), [G, K] = m(""), [q, J] = m(null), Y = p(null), he = ne(Y, te(me)), X = p(null), ge = ae((e) => {
31
+ X.current = e, t(N, e);
32
+ }, [N]), _e = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${R.duplicate} ${e.tag}` : `${R.max} ${x}`, Z = (e, t = "") => {
33
+ let { values: n, rejected: r } = re(U, e, {
34
+ validate: se,
35
+ maxTags: x,
36
+ allowDuplicates: ce,
37
+ caseSensitive: le
36
38
  });
37
- n.length !== W.length && G(n), Y(r[0] ? fe(r[0]) : null), q([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
38
- }, pe = (e) => {
39
+ n.length !== U.length && W(n), J(r[0] ? _e(r[0]) : null), K([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
40
+ }, Q = (e) => {
39
41
  let t = e.target.value;
40
- if (Y(null), !c(t)) {
41
- q(t);
42
+ if (J(null), !c(t)) {
43
+ K(t);
42
44
  return;
43
45
  }
44
- let { complete: n, tail: r } = re(t);
45
- Q(n, r);
46
- }, me = (e) => {
47
- w || H || (e.key === "Enter" && K.trim() ? (e.preventDefault(), Q(u(K))) : e.key === "Backspace" && K === "" && W.length > 0 && (e.preventDefault(), Y(null), G(l(W, W.length - 1))));
48
- }, he = (e) => {
49
- if (H) return;
46
+ let { complete: n, tail: r } = d(t);
47
+ Z(n, r);
48
+ }, ve = (e) => {
49
+ S || V || (e.key === "Enter" && G.trim() ? (e.preventDefault(), Z(f(G))) : e.key === "Backspace" && G === "" && U.length > 0 && (e.preventDefault(), J(null), W(l(U, U.length - 1))));
50
+ }, ye = (e) => {
51
+ if (V) return;
50
52
  let t = e.clipboardData.getData("text");
51
53
  if (!c(t)) return;
52
54
  e.preventDefault();
53
- let n = e.currentTarget, r = ne(K, n.selectionStart ?? K.length, n.selectionEnd ?? K.length, t);
54
- Q(u(r));
55
- }, ge = (e) => {
56
- n(e.relatedTarget, X.current) && (K.trim() && !H && Q(u(K)), N?.(e));
57
- }, _e = (e) => {
58
- L?.(e), !(e.defaultPrevented || w) && (e.target.closest("button, input") || Z.current?.focus());
59
- }, ve = (e) => {
60
- Y(null), G(l(W, e)), Z.current?.focus();
61
- }, $ = J !== null || (O ?? V?.invalid ?? !1);
62
- return B.wrap(/* @__PURE__ */ f("div", {
63
- ...R,
64
- ref: X,
55
+ let n = e.currentTarget, r = u(G, n.selectionStart ?? G.length, n.selectionEnd ?? G.length, t);
56
+ Z(f(r));
57
+ }, be = (e) => {
58
+ r(e.relatedTarget, Y.current) && (G.trim() && !V && Z(f(G)), M?.(e));
59
+ }, xe = (e) => {
60
+ I?.(e), !(e.defaultPrevented || S) && (e.target.closest("button, input") || X.current?.focus());
61
+ }, Se = (e) => {
62
+ J(null), W(l(U, e)), X.current?.focus();
63
+ }, $ = q !== null || (E ?? B?.invalid ?? !1);
64
+ return z.wrap(/* @__PURE__ */ g("div", {
65
+ ...L,
66
+ ref: he,
65
67
  className: v({
66
- size: T,
68
+ size: C,
67
69
  invalid: $,
68
- disabled: w,
69
- readOnly: H,
70
- className: I
70
+ disabled: S,
71
+ readOnly: V,
72
+ className: F
71
73
  }),
72
- onClick: _e,
73
- onBlur: ge,
74
+ onClick: xe,
75
+ onBlur: be,
74
76
  children: [
75
- /* @__PURE__ */ f("div", {
77
+ /* @__PURE__ */ g("div", {
76
78
  className: "kapi-taginput__box",
77
- children: [W.length > 0 && /* @__PURE__ */ d("ul", {
79
+ children: [U.length > 0 && /* @__PURE__ */ h("ul", {
78
80
  className: "kapi-taginput__tags",
79
- children: W.map((e, t) => /* @__PURE__ */ d("li", {
81
+ children: U.map((e, t) => /* @__PURE__ */ h("li", {
80
82
  className: "kapi-taginput__item",
81
- children: /* @__PURE__ */ d(ie, {
83
+ children: /* @__PURE__ */ h(ie, {
82
84
  tone: "primary",
83
- size: T === "sm" ? "sm" : "md",
84
- onRemove: w || H ? void 0 : () => ve(t),
85
- removeLabel: `${z.remove} ${e}`,
85
+ size: C === "sm" ? "sm" : "md",
86
+ onRemove: S || V ? void 0 : () => Se(t),
87
+ removeLabel: `${R.remove} ${e}`,
86
88
  children: e
87
89
  })
88
90
  }, `${t}-${e}`))
89
- }), /* @__PURE__ */ d("input", {
90
- ref: de,
91
+ }), /* @__PURE__ */ h("input", {
92
+ ref: ge,
91
93
  type: "text",
92
94
  className: "kapi-taginput__input",
93
- ...t(V, {
94
- id: D,
95
- describedBy: r(J !== null && U, M),
95
+ ...n(B, {
96
+ id: T,
97
+ describedBy: i(q !== null && H, j),
96
98
  invalid: $,
97
- required: k
99
+ required: D
98
100
  }),
99
- "aria-label": ue,
100
- "aria-labelledby": j,
101
- placeholder: W.length ? void 0 : C,
102
- value: K,
103
- disabled: w,
104
- readOnly: H || void 0,
101
+ "aria-label": k,
102
+ "aria-labelledby": A,
103
+ placeholder: U.length ? void 0 : ue,
104
+ value: G,
105
+ disabled: S,
106
+ readOnly: V || void 0,
105
107
  enterKeyHint: "enter",
106
- onChange: pe,
107
- onKeyDown: me,
108
- onPaste: he
108
+ onChange: Q,
109
+ onKeyDown: ve,
110
+ onPaste: ye
109
111
  })]
110
112
  }),
111
- J !== null && /* @__PURE__ */ d("span", {
112
- id: U,
113
+ q !== null && /* @__PURE__ */ h("span", {
114
+ id: H,
113
115
  className: "kapi-taginput__error",
114
116
  role: "alert",
115
- children: J
117
+ children: q
116
118
  }),
117
- E && W.map((e, t) => /* @__PURE__ */ d("input", {
119
+ w && U.map((e, t) => /* @__PURE__ */ h("input", {
118
120
  type: "hidden",
119
- name: E,
121
+ name: w,
120
122
  value: e
121
123
  }, `${t}-${e}`))
122
124
  ]
@@ -7,8 +7,8 @@ import { inputClasses as i } from "./KapiInput.js";
7
7
  import { computedStyleOf as a } from "../../hooks/ownerDocument.js";
8
8
  import { rafThrottle as o } from "../../hooks/rafThrottle.js";
9
9
  import { autosizeHeight as s, rowsToHeight as c } from "./textareaLogic.js";
10
- import { jsx as l } from "react/jsx-runtime";
11
- import { useCallback as u, useEffect as d, useLayoutEffect as f, useRef as p } from "react";
10
+ import { useCallback as l, useEffect as u, useLayoutEffect as d, useRef as f } from "react";
11
+ import { jsx as p } from "react/jsx-runtime";
12
12
  //#region src/components/inputs/KapiTextarea.tsx
13
13
  var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
14
14
  status: e,
@@ -26,9 +26,9 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
26
26
  invalid: i,
27
27
  status: h,
28
28
  fieldClassName: y
29
- }), { controlId: j, helpId: M } = A, N = p(null), P = u((e) => {
29
+ }), { controlId: j, helpId: M } = A, N = f(null), P = l((e) => {
30
30
  N.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
31
- }, [E]), F = p(null), I = u(() => {
31
+ }, [E]), F = f(null), I = l(() => {
32
32
  let e = N.current;
33
33
  if (!e || !b) return;
34
34
  let t = a(e), n = (e) => parseFloat(e) || 0;
@@ -45,11 +45,11 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
45
45
  x,
46
46
  w
47
47
  ]), L = D.value;
48
- f(() => {
48
+ d(() => {
49
49
  I();
50
50
  }, [I, L]);
51
- let R = p(I);
52
- R.current = I, d(() => {
51
+ let R = f(I);
52
+ R.current = I, u(() => {
53
53
  let e = N.current;
54
54
  if (!e || !b || typeof ResizeObserver > "u") return;
55
55
  let t = null, n = o(() => R.current()), r = new ResizeObserver((e) => {
@@ -66,7 +66,7 @@ var m = ({ status: e, autosize: t = !1, className: n = "" } = {}) => i({
66
66
  }, [b]);
67
67
  let z = (e) => {
68
68
  I(), T?.(e);
69
- }, B = /* @__PURE__ */ l("textarea", {
69
+ }, B = /* @__PURE__ */ p("textarea", {
70
70
  ...D,
71
71
  ref: P,
72
72
  ...e(A.outer, {
@@ -0,0 +1,37 @@
1
+ /** El primer valor repetido de la lista, envuelto para distinguirlo de «no hay». */
2
+ export declare const firstDuplicate: (values: readonly unknown[]) => {
3
+ value: unknown;
4
+ } | null;
5
+ /**
6
+ * Aviso: dos opciones con el mismo valor.
7
+ *
8
+ * Medido en `KapiSelect` con dos opciones de valor `"x"`: las DOS quedan con `aria-selected="true"`,
9
+ * así que un lector de pantalla anuncia dos opciones elegidas a la vez y elegir una no distingue
10
+ * cuál. Nada más lo señalaba.
11
+ *
12
+ * Recibe los valores ya calculados (y memoizados por el componente) en vez de la lista y un
13
+ * `valueOf`: así la dependencia del efecto es estable y no hay que desactivar `exhaustive-deps`.
14
+ */
15
+ export declare const useDuplicateValueWarning: (name: string, values: readonly unknown[]) => void;
16
+ /** Lo que mira el aviso de control mudo. */
17
+ export type MutedControl = {
18
+ /** `value` llegó definido: el estado es del consumidor. */
19
+ controlled: boolean;
20
+ /** Llegó un `onChange` (o el `onXChange` que corresponda). */
21
+ hasOnChange: boolean;
22
+ /** Pedir sólo lectura es explícito: ahí no se avisa. */
23
+ readOnly?: boolean | undefined;
24
+ /** Deshabilitado también es explícito. */
25
+ disabled?: boolean | undefined;
26
+ };
27
+ /** `true` si el control quedó mudo sin que nadie lo haya pedido. */
28
+ export declare const isMuted: ({ controlled, hasOnChange, readOnly, disabled }: MutedControl) => boolean;
29
+ /**
30
+ * Aviso: `value` sin `onChange` deja el control mudo.
31
+ *
32
+ * Con `value` el estado es del consumidor, así que el componente no guarda nada: sin `onChange`
33
+ * nadie se entera de lo que la persona elige y el control parece roto. Es la forma más común de
34
+ * escribir mal un componente controlado, y no decía nada. `readOnly` y `disabled` son maneras
35
+ * explícitas de pedir justamente eso, así que ahí no avisa.
36
+ */
37
+ export declare const useMutedControlWarning: (name: string, control: MutedControl) => void;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { useEffect as e, useRef as t } from "react";
3
+ //#region src/components/inputs/misuseWarnings.ts
4
+ var n = (e) => {
5
+ let t = /* @__PURE__ */ new Set();
6
+ for (let n of e) {
7
+ if (t.has(n)) return { value: n };
8
+ t.add(n);
9
+ }
10
+ return null;
11
+ }, r = (r, i) => {
12
+ let a = t(!1);
13
+ e(() => {
14
+ if (process.env.NODE_ENV === "production" || a.current) return;
15
+ let e = n(i);
16
+ e && (a.current = !0, console.warn(`${r}: hay dos opciones con el mismo valor (${JSON.stringify(e.value)}). Las dos quedan marcadas como elegidas y no se puede distinguir cuál se eligió. Dales un valor propio.`));
17
+ }, [r, i]);
18
+ }, i = ({ controlled: e, hasOnChange: t, readOnly: n, disabled: r }) => e && !t && !n && !r, a = (n, r) => {
19
+ let a = t(!1), { controlled: o, hasOnChange: s, readOnly: c, disabled: l } = r;
20
+ e(() => {
21
+ process.env.NODE_ENV === "production" || a.current || i({
22
+ controlled: o,
23
+ hasOnChange: s,
24
+ readOnly: c,
25
+ disabled: l
26
+ }) && (a.current = !0, console.warn(`${n}: tiene \`value\` pero no \`onChange\`, así que no responde a lo que la persona elige. Pasa \`onChange\` para quedarte con el valor, \`defaultValue\` para que lo guarde el componente, o \`readOnly\` si de verdad querés que no se pueda cambiar.`));
27
+ }, [
28
+ n,
29
+ o,
30
+ s,
31
+ c,
32
+ l
33
+ ]);
34
+ };
35
+ //#endregion
36
+ export { n as firstDuplicate, i as isMuted, r as useDuplicateValueWarning, a as useMutedControlWarning };
@@ -3,6 +3,16 @@ export type StepBounds = {
3
3
  max?: number | undefined;
4
4
  step?: number | undefined;
5
5
  };
6
+ /** El texto como número decimal finito, o `null` si no lo es. La coma vale como separador. */
7
+ export declare const parseTypedNumber: (text: string) => number | null;
8
+ /**
9
+ * Ajusta al escalón más cercano, contando desde `min` (o desde 0 si no hay).
10
+ *
11
+ * Los botones y las flechas siempre caen en la grilla; lo tipeado no caía, así que con `step={1}`
12
+ * un `2.5` escrito a mano se quedaba en 2.5 y el contador mostraba un valor que sus propios
13
+ * botones no podían producir. Un `step` que no sea un número finito positivo no ajusta nada.
14
+ */
15
+ export declare const snapToStep: (value: number, { min, step }?: StepBounds) => number;
6
16
  /** Clamp to optional bounds. */
7
17
  export declare const clampNumber: (value: number, { min, max }?: StepBounds) => number;
8
18
  /**