@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,15 +1,15 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/inputsExtra.css";
3
- import { fieldControlProps as e, joinIds as t, resolveFieldClassName as n, resolveReadOnly as r, resolveValidation as i } from "./fieldLogic.js";
4
- import { useOwnField as a } from "./ownField.js";
5
- import { useLabels as o } from "../locale/KapiLocaleProvider.js";
3
+ import { fieldControlProps as e, joinIds as t, resolveFieldClassName as n, resolveReadOnly as ee, resolveValidation as r } from "./fieldLogic.js";
4
+ import { useOwnField as i } from "./ownField.js";
5
+ import { useLabels as a } from "../locale/KapiLocaleProvider.js";
6
6
  /* empty css */
7
- import { inputClasses as s } from "./KapiInput.js";
8
- import { useControllableState as c } from "../../hooks/useControllableState.js";
9
- import { canDecrement as l, canIncrement as u, clampNumber as d, stepValue as f } from "./numberStepLogic.js";
10
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
11
- import { useEffect as h, useState as ee } from "react";
12
- import { Minus as te, Plus as g } from "lucide-react";
7
+ import { inputClasses as o } from "./KapiInput.js";
8
+ import { useControllableState as s } from "../../hooks/useControllableState.js";
9
+ import { canDecrement as te, canIncrement as c, clampNumber as l, parseTypedNumber as u, snapToStep as d, stepValue as f } from "./numberStepLogic.js";
10
+ import { useEffect as ne, useState as p } from "react";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { Minus as g, Plus as re } from "lucide-react";
13
13
  //#region src/components/inputs/KapiNumberStepper.tsx
14
14
  var _ = ({ size: e = "md", className: t = "" } = {}) => [
15
15
  "kapi-stepper",
@@ -19,11 +19,11 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
19
19
  decrease: "Disminuir",
20
20
  increase: "Aumentar"
21
21
  }, y = ({ value: y, defaultValue: b, onChange: x, min: S, max: C, step: w = 1, size: T = "md", invalid: E, status: D, required: O, label: k, help: A, fieldClassName: j, wrapperClassName: M, labels: N, className: P, disabled: F, readOnly: I, id: L, ...R }) => {
22
- let z = o("numberStepper", v, N), [B, V] = c(y, () => d(b ?? 0, {
22
+ let z = a("numberStepper", v, N), [B, V] = s(y, () => l(b ?? 0, {
23
23
  min: S,
24
24
  max: C,
25
25
  step: w
26
- }), x), { invalid: H, status: U } = i(E, D), W = a({
26
+ }), x), { invalid: H, status: U } = r(E, D), W = i({
27
27
  id: L,
28
28
  label: k,
29
29
  help: A,
@@ -31,42 +31,42 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
31
31
  invalid: E,
32
32
  status: D,
33
33
  readOnly: I
34
- }), G = W.controlId ?? W.autoId, { helpId: K } = W, q = r(I, W.field), J = {
34
+ }), G = W.controlId ?? W.autoId, { helpId: K } = W, q = ee(I, W.field), J = {
35
35
  min: S,
36
36
  max: C,
37
37
  step: w
38
- }, [Y, X] = ee(null);
39
- h(() => X(null), [B]);
38
+ }, [Y, X] = p(null);
39
+ ne(() => X(null), [B]);
40
40
  let Z = (e) => {
41
- let t = d(e, J);
41
+ let t = l(e, J);
42
42
  t !== B && V(t), X(null);
43
43
  }, Q = () => {
44
44
  if (Y === null) return;
45
- let e = Number(Y.replace(",", "."));
46
- Z(Y.trim() === "" || Number.isNaN(e) ? B : e);
45
+ let e = u(Y);
46
+ Z(e === null ? B : d(e, J));
47
47
  }, $ = (e) => {
48
48
  if (q) return;
49
- let t = Y === null || Y.trim() === "" ? NaN : Number(Y.replace(",", "."));
50
- Z(f(Number.isNaN(t) ? B : t, e, J));
51
- }, ne = /* @__PURE__ */ m("div", {
49
+ let t = Y === null ? null : u(Y), n = t === null ? B : d(t, J);
50
+ Z(f(n, e, J));
51
+ }, ie = /* @__PURE__ */ h("div", {
52
52
  className: _({
53
53
  size: T,
54
54
  className: n(j, M)
55
55
  }),
56
56
  children: [
57
- /* @__PURE__ */ p("button", {
57
+ /* @__PURE__ */ m("button", {
58
58
  type: "button",
59
59
  className: "kapi-stepper__btn",
60
60
  "aria-label": z.decrease,
61
61
  tabIndex: -1,
62
- disabled: F || q || !l(B, J),
62
+ disabled: F || q || !te(B, J),
63
63
  onClick: () => $(-1),
64
- children: /* @__PURE__ */ p(te, {
64
+ children: /* @__PURE__ */ m(g, {
65
65
  size: 15,
66
66
  strokeWidth: 2.4
67
67
  })
68
68
  }),
69
- /* @__PURE__ */ p("input", {
69
+ /* @__PURE__ */ m("input", {
70
70
  ...R,
71
71
  ...e(W.outer, {
72
72
  id: G,
@@ -81,7 +81,7 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
81
81
  "aria-valuenow": B,
82
82
  "aria-valuemin": S,
83
83
  "aria-valuemax": C,
84
- className: s({
84
+ className: o({
85
85
  size: T,
86
86
  status: U,
87
87
  num: !0,
@@ -95,21 +95,21 @@ var _ = ({ size: e = "md", className: t = "" } = {}) => [
95
95
  e.key === "ArrowUp" ? (e.preventDefault(), $(1)) : e.key === "ArrowDown" ? (e.preventDefault(), $(-1)) : e.key === "Enter" && Q();
96
96
  }
97
97
  }),
98
- /* @__PURE__ */ p("button", {
98
+ /* @__PURE__ */ m("button", {
99
99
  type: "button",
100
100
  className: "kapi-stepper__btn",
101
101
  "aria-label": z.increase,
102
102
  tabIndex: -1,
103
- disabled: F || q || !u(B, J),
103
+ disabled: F || q || !c(B, J),
104
104
  onClick: () => $(1),
105
- children: /* @__PURE__ */ p(g, {
105
+ children: /* @__PURE__ */ m(re, {
106
106
  size: 15,
107
107
  strokeWidth: 2.4
108
108
  })
109
109
  })
110
110
  ]
111
111
  });
112
- return W.wrap(ne);
112
+ return W.wrap(ie);
113
113
  };
114
114
  //#endregion
115
115
  export { v as DEFAULT_NUMBER_STEPPER_LABELS, y as KapiNumberStepper, _ as stepperClasses };
@@ -5,110 +5,112 @@ import { useOwnField as n } from "./ownField.js";
5
5
  import { useLabels as r } from "../locale/KapiLocaleProvider.js";
6
6
  /* empty css */
7
7
  import { useControllableState as i } from "../../hooks/useControllableState.js";
8
- import { directionOf as a, logicalKeyOf as ee } from "../../hooks/directionLogic.js";
9
- import { normalizeRating as o, ratingFromKey as s, ratingFromPointer as c, starFills as l } from "./ratingLogic.js";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
- import { useState as te } from "react";
12
- import { Star as f } from "lucide-react";
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";
12
+ import { useState as ie } from "react";
13
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
14
+ import { Star as d } from "lucide-react";
13
15
  //#region src/components/inputs/KapiRating.tsx
14
- var p = {
16
+ var f = {
15
17
  rating: "Calificación",
16
18
  of: "de"
17
- }, m = {
19
+ }, p = {
18
20
  sm: 16,
19
21
  md: 22,
20
22
  lg: 30
21
- }, h = ({ size: e = "md", interactive: t = !1, disabled: n = !1, readOnly: r = !1, className: i = "" } = {}) => [
23
+ }, m = ({ size: e = "md", interactive: t = !1, disabled: n = !1, readOnly: r = !1, className: i = "" } = {}) => [
22
24
  "kapi-rating",
23
25
  e !== "md" && `kapi-rating--${e}`,
24
26
  t && "kapi-rating--interactive",
25
27
  n && "kapi-rating--disabled",
26
28
  r && "kapi-rating--readonly",
27
29
  i
28
- ].filter(Boolean).join(" "), g = ({ value: g, defaultValue: _, onChange: v, max: y = 5, size: b = "md", disabled: x = !1, allowHalf: S = !1, className: ne, labels: C, "aria-label": w, name: T, invalid: E, required: D, label: re, help: O, fieldClassName: k, readOnly: A, id: j, "aria-describedby": M, ref: N, ...P }) => {
29
- let F = r("rating", p, C), I = n({
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
32
  id: j,
31
- label: re,
33
+ label: D,
32
34
  help: O,
33
- required: D,
34
- invalid: E,
35
+ required: E,
36
+ invalid: T,
35
37
  readOnly: A,
36
38
  fieldClassName: k
37
- }), L = I.field, R = t(A, L), [z, B] = te(null), [V, H] = i(g, _ ?? 0, v), U = (v !== void 0 || g === void 0 && _ !== void 0) && !x, W = U && !R, G = e(U ? L : null, {
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, {
38
40
  id: j,
39
41
  describedBy: M,
40
- invalid: E,
41
- required: D,
42
+ invalid: T,
43
+ required: E,
42
44
  labelable: !1,
43
- ariaLabel: w
44
- }), K = w ?? F.rating, q = o(V, y, S), J = T ? /* @__PURE__ */ u("input", {
45
+ ariaLabel: C
46
+ }), q = C ?? P.rating, J = o(B, v, x), Y = w ? /* @__PURE__ */ l("input", {
45
47
  type: "hidden",
46
- name: T,
47
- value: q,
48
- disabled: x
49
- }) : null, Y = l(W && z !== null ? z : q, y, S), X = m[b], Z = (e, t) => {
50
- let n = e.currentTarget.getBoundingClientRect(), r = a(e.currentTarget) === "rtl" ? n.right - e.clientX : e.clientX - n.left, i = n.width > 0 ? r / n.width : 1;
51
- return c(t, i, S);
52
- }, ie = (e) => {
53
- if (!W) return;
54
- let t = s(ee(e), q, y, S);
55
- t !== null && (e.preventDefault(), t !== q && H(t));
56
- }, Q = Y.map((e, t) => /* @__PURE__ */ d("span", {
48
+ name: w,
49
+ 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) => {
55
+ if (!G) return;
56
+ let t = s(te(e), J, v, x);
57
+ t !== null && (e.preventDefault(), t !== J && V(t));
58
+ }, Q = se.map((e, t) => /* @__PURE__ */ u("span", {
57
59
  className: "kapi-rating__star",
58
60
  "data-fill": e,
59
- onMouseMove: W ? (e) => B(Z(e, t)) : void 0,
60
- onClick: W ? (e) => {
61
+ onMouseMove: G ? (e) => z(Z(e, t)) : void 0,
62
+ onClick: G ? (e) => {
61
63
  let n = Z(e, t);
62
- H(n === q ? 0 : n);
64
+ V(n === J ? 0 : n);
63
65
  } : void 0,
64
- children: [/* @__PURE__ */ u(f, {
66
+ children: [/* @__PURE__ */ l(d, {
65
67
  size: X,
66
68
  strokeWidth: 2,
67
69
  className: "kapi-rating__base",
68
70
  "aria-hidden": "true"
69
- }), e !== "empty" && /* @__PURE__ */ u("span", {
71
+ }), e !== "empty" && /* @__PURE__ */ l("span", {
70
72
  className: "kapi-rating__fill",
71
73
  style: { width: e === "half" ? "50%" : "100%" },
72
- children: /* @__PURE__ */ u(f, {
74
+ children: /* @__PURE__ */ l(d, {
73
75
  size: X,
74
76
  strokeWidth: 2,
75
77
  fill: "currentColor",
76
78
  "aria-hidden": "true"
77
79
  })
78
80
  })]
79
- }, t)), $ = h({
80
- size: b,
81
- interactive: U,
82
- disabled: x,
83
- readOnly: U && R,
84
- className: ne
81
+ }, t)), $ = m({
82
+ size: y,
83
+ interactive: W,
84
+ disabled: b,
85
+ readOnly: W && L,
86
+ className: ae
85
87
  });
86
- return U ? I.wrap(/* @__PURE__ */ d("div", {
87
- ...P,
88
- ...G,
89
- ref: N,
88
+ return W ? F.wrap(/* @__PURE__ */ u("div", {
89
+ ...N,
90
+ ...K,
91
+ ref: U,
90
92
  className: $,
91
93
  role: "slider",
92
94
  tabIndex: 0,
93
- "aria-label": G["aria-labelledby"] ? void 0 : K,
95
+ "aria-label": K["aria-labelledby"] ? void 0 : q,
94
96
  "aria-valuemin": 0,
95
- "aria-valuemax": y,
96
- "aria-valuenow": q,
97
- "aria-valuetext": `${q} ${F.of} ${y}`,
98
- "aria-readonly": R || void 0,
99
- onKeyDown: ie,
100
- onMouseLeave: () => B(null),
101
- children: [Q, J]
102
- })) : I.wrap(/* @__PURE__ */ d("div", {
103
- ...P,
104
- ref: N,
97
+ "aria-valuemax": v,
98
+ "aria-valuenow": J,
99
+ "aria-valuetext": `${J} ${P.of} ${v}`,
100
+ "aria-readonly": L || void 0,
101
+ onKeyDown: ce,
102
+ onMouseLeave: () => z(null),
103
+ children: [Q, Y]
104
+ })) : F.wrap(/* @__PURE__ */ u("div", {
105
+ ...N,
106
+ ref: U,
105
107
  id: j,
106
108
  "aria-describedby": M,
107
109
  className: $,
108
110
  role: "img",
109
- "aria-label": `${K}: ${q} ${F.of} ${y}`,
110
- children: [Q, J]
111
+ "aria-label": `${q}: ${J} ${P.of} ${v}`,
112
+ children: [Q, Y]
111
113
  }));
112
114
  };
113
115
  //#endregion
114
- export { p as DEFAULT_RATING_LABELS, g as KapiRating, h as ratingClasses };
116
+ export { f as DEFAULT_RATING_LABELS, h as KapiRating, m as ratingClasses };
@@ -5,8 +5,8 @@ import { useLabels as t } from "../locale/KapiLocaleProvider.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 */
8
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
9
- import { useRef as s } from "react";
8
+ import { useRef as a } from "react";
9
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
10
10
  import { Search as c, X as l } from "lucide-react";
11
11
  //#region src/components/inputs/KapiSearchChip.tsx
12
12
  var u = {
@@ -16,7 +16,7 @@ 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 = s(null), [D, O] = n(f, p ?? ""), k = _ ?? T.placeholder, A = i({
19
+ let T = t("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
@@ -30,7 +30,7 @@ var u = {
30
30
  }, F = (e) => {
31
31
  C?.(e), !e.defaultPrevented && e.key === "Enter" && h && (e.preventDefault(), h(e.currentTarget.value));
32
32
  };
33
- return /* @__PURE__ */ o("div", {
33
+ return /* @__PURE__ */ s("div", {
34
34
  className: r({
35
35
  disabled: g,
36
36
  className: b
@@ -38,13 +38,13 @@ var u = {
38
38
  style: x,
39
39
  onMouseDown: P,
40
40
  children: [
41
- /* @__PURE__ */ a(c, {
41
+ /* @__PURE__ */ o(c, {
42
42
  className: "kapi-searchchip__icon",
43
43
  size: 15,
44
44
  strokeWidth: 1.9,
45
45
  "aria-hidden": "true"
46
46
  }),
47
- /* @__PURE__ */ a("input", {
47
+ /* @__PURE__ */ o("input", {
48
48
  ...w,
49
49
  ref: M,
50
50
  type: "search",
@@ -59,12 +59,12 @@ var u = {
59
59
  },
60
60
  onKeyDown: F
61
61
  }),
62
- j && /* @__PURE__ */ a("button", {
62
+ j && /* @__PURE__ */ o("button", {
63
63
  type: "button",
64
64
  className: "kapi-searchchip__clear",
65
65
  "aria-label": T.clear,
66
66
  onClick: N,
67
- children: /* @__PURE__ */ a(l, {
67
+ children: /* @__PURE__ */ o(l, {
68
68
  size: 14,
69
69
  strokeWidth: 2.2,
70
70
  "aria-hidden": "true"
@@ -1,106 +1,116 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/inputsExtra.css";
3
- import { resolveTone as e } from "../tone.js";
4
- import { assignRef as t, fieldControlProps as n, resolveReadOnly as r } from "./fieldLogic.js";
5
- import { useOwnField as i } from "./ownField.js";
6
- import { useKapiFormatLocale as a } from "../locale/KapiLocaleProvider.js";
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";
7
8
  /* empty css */
8
- import { joinClasses as o } from "../rootProps.js";
9
9
  import { useControllableState as s } from "../../hooks/useControllableState.js";
10
10
  import { logicalKeyOf as c } from "../../hooks/directionLogic.js";
11
- import { useSlidingIndicator as l } from "../../hooks/useSlidingIndicator.js";
12
- import { formatCount as u } from "../../hooks/numberFormatLogic.js";
13
- import { KapiTooltip as d } from "../overlays/KapiTooltip.js";
14
- import { nextRadioIndex as f } from "./segmentedLogic.js";
15
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
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";
16
19
  //#region src/components/inputs/KapiSegmented.tsx
17
- var g = (t) => e(t.activeTone, t.color, void 0), _ = ({ items: e, value: _, defaultValue: v, onChange: y, variant: b = "text", "aria-label": x, className: S, name: C, onBlur: w, invalid: T, required: E, label: D, help: O, fieldClassName: k, disabled: A = !1, readOnly: j, size: M = "md", id: N, "aria-describedby": P, ref: F, ...I }) => {
18
- let L = a(), R = i({
19
- id: N,
20
- label: D,
21
- help: O,
22
- required: E,
23
- invalid: T,
24
- readOnly: j,
25
- fieldClassName: k
26
- }), z = r(j, R.field), B = (t) => A || e[t]?.disabled === !0, V = n(R.field, {
27
- id: N,
28
- describedBy: P,
29
- invalid: T,
30
- required: E,
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,
31
34
  labelable: !1,
32
- ariaLabel: x
33
- }), [H, U] = s(_, () => v ?? e[0]?.id, y), W = e.find((e) => e.id === H), { containerRef: G, indicatorRef: K } = l({
34
- active: H ?? null,
35
- deps: [e, b],
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
42
+ });
43
+ let X = t.find((e) => e.id === G), { containerRef: Z, indicatorRef: Q } = d({
44
+ active: G ?? null,
45
+ deps: [t, C],
36
46
  findActive: (e) => e.querySelector("[role=\"radio\"][aria-checked=\"true\"]")
37
- }), q = e.findIndex((e) => e.id === H), J = q >= 0 && !B(q) ? q : e.findIndex((e, t) => !B(t)), Y = (t) => {
38
- if (z) return;
39
- let n = f(e.length, q, c(t), B), r = n === void 0 ? void 0 : e[n];
40
- n !== void 0 && r && (t.preventDefault(), U(r.id), G.current?.querySelectorAll("[role=\"radio\"]")[n]?.focus());
41
- }, X = (e) => {
42
- e.currentTarget.contains(e.relatedTarget) || w?.(e);
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);
43
53
  };
44
- return R.wrap(/* @__PURE__ */ h("div", {
45
- ...I,
46
- ...V,
54
+ return V.wrap(/* @__PURE__ */ v("div", {
55
+ ...z,
56
+ ...W,
47
57
  ref: (e) => {
48
- G.current = e, t(F, e);
58
+ Z.current = e, J(e), n(R, e);
49
59
  },
50
- className: o("kapi-seg", M === "sm" && "kapi-seg--sm", z && "kapi-seg--readonly", S),
60
+ className: e("kapi-seg", F === "sm" && "kapi-seg--sm", H && "kapi-seg--readonly", T),
51
61
  role: "radiogroup",
52
- "aria-label": x,
53
- "aria-disabled": A || void 0,
54
- "aria-readonly": z || void 0,
55
- onKeyDown: Y,
56
- onBlur: X,
62
+ "aria-label": w,
63
+ "aria-disabled": N || void 0,
64
+ "aria-readonly": H || void 0,
65
+ onKeyDown: ne,
66
+ onBlur: re,
57
67
  children: [
58
- /* @__PURE__ */ m("span", {
59
- ref: K,
68
+ /* @__PURE__ */ _("span", {
69
+ ref: Q,
60
70
  className: "kapi-seg__indicator",
61
- "data-color": W ? g(W) : void 0,
71
+ "data-color": X ? y(X) : void 0,
62
72
  "aria-hidden": "true"
63
73
  }),
64
- e.map((e, t) => {
65
- let n = H === e.id, r = /* @__PURE__ */ h("button", {
74
+ t.map((e, t) => {
75
+ let n = G === e.id, r = /* @__PURE__ */ v("button", {
66
76
  type: "button",
67
77
  role: "radio",
68
78
  "aria-checked": n,
69
- tabIndex: t === J ? 0 : -1,
70
- "aria-label": b === "icon" ? e.label : void 0,
79
+ tabIndex: t === te ? 0 : -1,
80
+ "aria-label": C === "icon" ? e.label : void 0,
71
81
  className: `kapi-seg__btn${n ? " is-on" : ""}`,
72
- "data-color": n ? g(e) : void 0,
82
+ "data-color": n ? y(e) : void 0,
73
83
  "data-tone": e.tone,
74
- disabled: B(t) || void 0,
84
+ disabled: U(t) || void 0,
75
85
  onClick: () => {
76
- z || U(e.id);
86
+ H || K(e.id);
77
87
  },
78
88
  children: [
79
- (b === "icon" || b === "both") && e.icon && /* @__PURE__ */ m("span", {
89
+ (C === "icon" || C === "both") && e.icon && /* @__PURE__ */ _("span", {
80
90
  className: "kapi-seg__ico",
81
91
  children: e.icon
82
92
  }),
83
- b !== "icon" && /* @__PURE__ */ m("span", { children: e.label }),
84
- e.count != null && /* @__PURE__ */ h(p, { children: [" ", /* @__PURE__ */ m("span", {
93
+ C !== "icon" && /* @__PURE__ */ _("span", { children: e.label }),
94
+ e.count != null && /* @__PURE__ */ v(g, { children: [" ", /* @__PURE__ */ _("span", {
85
95
  className: "kapi-seg__n",
86
- children: u(e.count, L)
96
+ children: f(e.count, B)
87
97
  })] })
88
98
  ]
89
99
  }, e.id);
90
- return b === "icon" && e.label ? /* @__PURE__ */ m(d, {
100
+ return C === "icon" && e.label ? /* @__PURE__ */ _(p, {
91
101
  label: e.label,
92
102
  prefer: "top",
93
103
  children: r
94
104
  }, e.id) : r;
95
105
  }),
96
- C && /* @__PURE__ */ m("input", {
106
+ E && /* @__PURE__ */ _("input", {
97
107
  type: "hidden",
98
- name: C,
99
- value: H === void 0 ? "" : String(H),
100
- disabled: A || void 0
108
+ name: E,
109
+ value: G === void 0 ? "" : String(G),
110
+ disabled: N || void 0
101
111
  })
102
112
  ]
103
113
  }));
104
114
  };
105
115
  //#endregion
106
- export { _ as KapiSegmented };
116
+ export { b as KapiSegmented };