@kapiuara/ui 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +171 -11
  2. package/dist/components/chat/KapiChatThread.js +4 -4
  3. package/dist/components/chat/KapiComposer.js +8 -8
  4. package/dist/components/data/KapiDataTable.js +4 -4
  5. package/dist/components/data/KapiSparkline.d.ts +2 -1
  6. package/dist/components/data/KapiSparkline.js +29 -26
  7. package/dist/components/data/KapiTableFilter.js +6 -6
  8. package/dist/components/data/tableCells.d.ts +12 -1
  9. package/dist/components/data/tableCells.js +49 -51
  10. package/dist/components/data/useTableSelection.js +3 -3
  11. package/dist/components/display/KapiAnnotation.js +68 -63
  12. package/dist/components/display/KapiAvatar.d.ts +6 -4
  13. package/dist/components/display/KapiAvatar.js +33 -28
  14. package/dist/components/display/KapiCodeBlock.d.ts +48 -0
  15. package/dist/components/display/KapiCodeBlock.js +44 -0
  16. package/dist/components/display/KapiCommentComposer.js +6 -6
  17. package/dist/components/display/KapiDiff.d.ts +62 -0
  18. package/dist/components/display/KapiDiff.js +118 -0
  19. package/dist/components/display/KapiHighlight.d.ts +27 -0
  20. package/dist/components/display/KapiHighlight.js +21 -0
  21. package/dist/components/display/KapiIconTile.d.ts +2 -1
  22. package/dist/components/display/KapiIconTile.js +23 -21
  23. package/dist/components/display/KapiStat.d.ts +3 -2
  24. package/dist/components/display/KapiStat.js +32 -26
  25. package/dist/components/display/KapiTag.d.ts +4 -3
  26. package/dist/components/display/KapiTag.js +29 -24
  27. package/dist/components/display/KapiTimeline.d.ts +5 -2
  28. package/dist/components/display/KapiTimeline.js +31 -23
  29. package/dist/components/display/annotationLogic.d.ts +2 -1
  30. package/dist/components/display/annotationLogic.js +7 -6
  31. package/dist/components/display/codeBlockSlots.d.ts +10 -0
  32. package/dist/components/display/codeBlockSlots.js +13 -0
  33. package/dist/components/display/diffLogic.d.ts +58 -0
  34. package/dist/components/display/diffLogic.js +96 -0
  35. package/dist/components/display/diffSlots.d.ts +14 -0
  36. package/dist/components/display/diffSlots.js +17 -0
  37. package/dist/components/display/highlightLogic.d.ts +18 -0
  38. package/dist/components/display/highlightLogic.js +26 -0
  39. package/dist/components/display/highlightSlots.d.ts +5 -0
  40. package/dist/components/display/highlightSlots.js +8 -0
  41. package/dist/components/display/iconTileLogic.d.ts +2 -2
  42. package/dist/components/display/iconTileLogic.js +7 -6
  43. package/dist/components/display/index.d.ts +8 -0
  44. package/dist/components/display/statLogic.d.ts +2 -1
  45. package/dist/components/display/statLogic.js +7 -6
  46. package/dist/components/display/tagLogic.d.ts +2 -1
  47. package/dist/components/display/tagLogic.js +7 -6
  48. package/dist/components/display/timelineLogic.d.ts +20 -2
  49. package/dist/components/display/timelineLogic.js +10 -2
  50. package/dist/components/feedback/KapiFab.js +108 -108
  51. package/dist/components/feedback/KapiProgress.js +63 -54
  52. package/dist/components/feedback/KapiToastContainer.js +9 -9
  53. package/dist/components/feedback/KapiTour.js +12 -12
  54. package/dist/components/feedback/progressLogic.d.ts +2 -1
  55. package/dist/components/feedback/progressLogic.js +9 -8
  56. package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
  57. package/dist/components/inputs/KapiAutocomplete.js +86 -85
  58. package/dist/components/inputs/KapiChecklist.d.ts +7 -1
  59. package/dist/components/inputs/KapiChecklist.js +53 -52
  60. package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
  61. package/dist/components/inputs/KapiCopyButton.js +35 -0
  62. package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
  63. package/dist/components/inputs/KapiDatePicker.js +118 -116
  64. package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
  65. package/dist/components/inputs/KapiDateRangePicker.js +136 -135
  66. package/dist/components/inputs/KapiFacetedSearch.js +5 -5
  67. package/dist/components/inputs/KapiField.d.ts +9 -1
  68. package/dist/components/inputs/KapiField.js +43 -42
  69. package/dist/components/inputs/KapiFileUpload.js +6 -6
  70. package/dist/components/inputs/KapiInput.d.ts +29 -1
  71. package/dist/components/inputs/KapiInput.js +74 -51
  72. package/dist/components/inputs/KapiMaskedInput.js +26 -26
  73. package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
  74. package/dist/components/inputs/KapiNumberStepper.js +24 -23
  75. package/dist/components/inputs/KapiPinInput.d.ts +72 -0
  76. package/dist/components/inputs/KapiPinInput.js +75 -0
  77. package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
  78. package/dist/components/inputs/KapiPropsForm.js +78 -0
  79. package/dist/components/inputs/KapiRating.d.ts +7 -1
  80. package/dist/components/inputs/KapiRating.js +39 -38
  81. package/dist/components/inputs/KapiSearchChip.js +5 -5
  82. package/dist/components/inputs/KapiSegmented.d.ts +13 -5
  83. package/dist/components/inputs/KapiSegmented.js +81 -77
  84. package/dist/components/inputs/KapiSelect.d.ts +9 -1
  85. package/dist/components/inputs/KapiSelect.js +236 -233
  86. package/dist/components/inputs/KapiSlider.d.ts +10 -3
  87. package/dist/components/inputs/KapiSlider.js +67 -63
  88. package/dist/components/inputs/KapiTagInput.d.ts +7 -1
  89. package/dist/components/inputs/KapiTagInput.js +70 -69
  90. package/dist/components/inputs/KapiTextarea.d.ts +7 -1
  91. package/dist/components/inputs/KapiTextarea.js +51 -50
  92. package/dist/components/inputs/copyLogic.d.ts +1 -0
  93. package/dist/components/inputs/copyLogic.js +12 -0
  94. package/dist/components/inputs/fieldLogic.d.ts +23 -3
  95. package/dist/components/inputs/fieldLogic.js +18 -11
  96. package/dist/components/inputs/index.d.ts +8 -0
  97. package/dist/components/inputs/inputLogic.d.ts +16 -1
  98. package/dist/components/inputs/inputLogic.js +3 -3
  99. package/dist/components/inputs/ownField.d.ts +3 -1
  100. package/dist/components/inputs/ownField.js +28 -27
  101. package/dist/components/inputs/pinInputLogic.d.ts +34 -0
  102. package/dist/components/inputs/pinInputLogic.js +37 -0
  103. package/dist/components/inputs/propsFormLogic.d.ts +53 -0
  104. package/dist/components/inputs/propsFormLogic.js +11 -0
  105. package/dist/components/inputs/segmentedLogic.d.ts +7 -0
  106. package/dist/components/inputs/segmentedLogic.js +2 -2
  107. package/dist/components/layout/KapiAccessCard.d.ts +5 -1
  108. package/dist/components/layout/KapiAccessCard.js +43 -39
  109. package/dist/components/layout/KapiAccountMenu.js +7 -7
  110. package/dist/components/layout/KapiCollapse.d.ts +39 -0
  111. package/dist/components/layout/KapiCollapse.js +20 -0
  112. package/dist/components/layout/KapiContextSlot.js +4 -4
  113. package/dist/components/layout/KapiDivider.d.ts +11 -2
  114. package/dist/components/layout/KapiDivider.js +30 -24
  115. package/dist/components/layout/KapiGrid.js +2 -2
  116. package/dist/components/layout/KapiNotificationBell.js +10 -10
  117. package/dist/components/layout/KapiPageHeader.js +22 -22
  118. package/dist/components/layout/KapiRail.js +4 -4
  119. package/dist/components/layout/KapiRoot.d.ts +22 -2
  120. package/dist/components/layout/KapiRoot.js +33 -29
  121. package/dist/components/layout/KapiShell.d.ts +9 -1
  122. package/dist/components/layout/KapiShell.js +28 -27
  123. package/dist/components/layout/accessCardLogic.d.ts +8 -1
  124. package/dist/components/layout/accessCardLogic.js +11 -7
  125. package/dist/components/layout/index.d.ts +2 -0
  126. package/dist/components/locale/labelRegistry.d.ts +10 -0
  127. package/dist/components/navigation/KapiAccordion.js +9 -9
  128. package/dist/components/navigation/KapiContextPanel.js +12 -12
  129. package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
  130. package/dist/components/navigation/KapiNavBadge.js +26 -22
  131. package/dist/components/navigation/KapiTabs.js +9 -9
  132. package/dist/components/navigation/KapiToc.d.ts +48 -0
  133. package/dist/components/navigation/KapiToc.js +66 -0
  134. package/dist/components/navigation/KapiTree.js +10 -10
  135. package/dist/components/navigation/index.d.ts +3 -0
  136. package/dist/components/navigation/tocLogic.d.ts +35 -0
  137. package/dist/components/navigation/tocLogic.js +11 -0
  138. package/dist/components/navigation/tocSlots.d.ts +8 -0
  139. package/dist/components/navigation/tocSlots.js +11 -0
  140. package/dist/components/overlays/KapiCommandPalette.js +6 -6
  141. package/dist/components/overlays/KapiContextMenu.js +5 -5
  142. package/dist/components/overlays/KapiMenuButton.js +7 -7
  143. package/dist/components/overlays/KapiModal.js +3 -3
  144. package/dist/components/overlays/KapiOffcanvas.js +24 -24
  145. package/dist/components/overlays/KapiPhotoView.js +10 -10
  146. package/dist/components/overlays/KapiPopover.js +6 -6
  147. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  148. package/dist/components/overlays/KapiTooltip.js +18 -18
  149. package/dist/components/overlays/menuList.js +22 -22
  150. package/dist/components/slotCatalog.d.ts +33 -0
  151. package/dist/components/slotCatalog.js +18 -10
  152. package/dist/css/base.css +1 -1
  153. package/dist/css/components/display/KapiAnnotation.css +1 -1
  154. package/dist/css/components/display/KapiCodeBlock.css +1 -0
  155. package/dist/css/components/display/KapiDiff.css +1 -0
  156. package/dist/css/components/display/display.css +1 -1
  157. package/dist/css/components/feedback/feedback.css +1 -1
  158. package/dist/css/components/inputs/KapiPinInput.css +1 -0
  159. package/dist/css/components/inputs/KapiSelect.css +1 -1
  160. package/dist/css/components/inputs/inputsExtra.css +1 -1
  161. package/dist/css/components/layout/KapiAccessCard.css +1 -1
  162. package/dist/css/components/layout/KapiCollapse.css +1 -0
  163. package/dist/css/components/layout/KapiDivider.css +1 -1
  164. package/dist/css/components/navigation/KapiToc.css +1 -0
  165. package/dist/hooks/asyncResourceLogic.d.ts +11 -0
  166. package/dist/hooks/asyncResourceLogic.js +4 -0
  167. package/dist/hooks/index.d.ts +3 -0
  168. package/dist/hooks/toneFamilyLogic.d.ts +26 -2
  169. package/dist/hooks/toneFamilyLogic.js +19 -6
  170. package/dist/hooks/useAsyncResource.d.ts +45 -0
  171. package/dist/hooks/useAsyncResource.js +24 -0
  172. package/dist/hooks/useKapiTheme.d.ts +8 -1
  173. package/dist/hooks/useKapiTheme.js +57 -57
  174. package/dist/hooks/useToneFamilies.d.ts +14 -4
  175. package/dist/hooks/useToneFamilies.js +27 -23
  176. package/dist/index.js +221 -207
  177. package/dist/kapi.css +1 -1
  178. package/dist/kapi.layered.css +1 -1
  179. package/dist/logic.d.ts +41 -0
  180. package/dist/logic.js +42 -0
  181. package/package.json +13 -2
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiAutocomplete.css";
3
- import { assignRef as e, fieldControlProps as t, joinIds as n, resolveReadOnly as r, resolveValidation as ee } from "./fieldLogic.js";
4
- import { useOwnField as te } from "./ownField.js";
5
- import { useLabels as ne } from "../locale/KapiLocaleProvider.js";
3
+ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
+ import { assignRef as t, fieldControlProps as n, joinIds as r, resolveFieldMessage as ee, resolveReadOnly as te } from "./fieldLogic.js";
5
+ import { useOwnField as ne } from "./ownField.js";
6
6
  import { inputClasses as re } from "./KapiInput.js";
7
- import { enabledIndexes as ie, nextEnabledIndex as ae } from "../overlays/menuKeyboardLogic.js";
8
- import { useControllableState as oe } from "../../hooks/useControllableState.js";
7
+ import { useControllableState as ie } from "../../hooks/useControllableState.js";
8
+ import { enabledIndexes as ae, nextEnabledIndex as oe } from "../overlays/menuKeyboardLogic.js";
9
9
  import { resolveKapiRoot as se } from "../../hooks/kapiRoot.js";
10
10
  import { AUTOCOMPLETE_MENU_PLACEMENT as ce, clampActiveIndex as le, defaultGetLabel as ue, filterOptions as de, highlightParts as fe, shouldOpen as pe } from "./autocompleteLogic.js";
11
11
  import { usePlacement as me } from "../../hooks/usePlacement.js";
@@ -23,165 +23,166 @@ var l = {
23
23
  data: [],
24
24
  error: !1
25
25
  }, d = (d) => {
26
- let { value: xe, defaultValue: Se, onChange: Ce, onSelect: f, getLabel: p, getKey: m, renderOption: h, fillOnSelect: g = !0, minChars: we = 0, maxResults: _ = 8, loadDelay: Te, debounceMs: Ee, emptyMessage: De, loadingMessage: Oe, noResultsText: ke, loadingText: Ae, labels: je, size: Me, invalid: v, status: y, label: Ne, required: b, help: Pe, fieldClassName: Fe, className: Ie, readOnly: x, ref: S, options: C, loadOptions: w, id: Le, onFocus: T, onBlur: Re, onKeyDown: ze, ...E } = d, D = ne("autocomplete", l, je), Be = De ?? ke ?? D.noResults, Ve = Oe ?? Ae ?? D.loading, He = Te ?? Ee ?? 250, [O, k] = oe(xe, Se ?? "", Ce), { invalid: Ue, status: We } = ee(v, y), A = te({
27
- id: Le,
26
+ let { value: xe, defaultValue: Se, onChange: Ce, onSelect: f, getLabel: p, getKey: m, renderOption: h, fillOnSelect: g = !0, minChars: we = 0, maxResults: _ = 8, loadDelay: Te, debounceMs: Ee, emptyMessage: De, loadingMessage: Oe, noResultsText: ke, loadingText: Ae, labels: je, size: Me, invalid: v, status: y, label: Ne, required: b, help: x, error: S, fieldClassName: Pe, className: Fe, readOnly: C, ref: w, options: T, loadOptions: E, id: Ie, onFocus: Le, onBlur: Re, onKeyDown: ze, ...D } = d, O = e("autocomplete", l, je), Be = De ?? ke ?? O.noResults, Ve = Oe ?? Ae ?? O.loading, He = Te ?? Ee ?? 250, [k, A] = ie(xe, Se ?? "", Ce), { invalid: Ue, status: We } = ee(S, x, v, y), j = ne({
27
+ id: Ie,
28
28
  label: Ne,
29
- help: Pe,
29
+ help: x,
30
+ error: S,
30
31
  required: b,
31
32
  invalid: v,
32
33
  status: y,
33
- readOnly: x,
34
- fieldClassName: Fe
35
- }), j = r(x, A.field), M = A.controlId ?? A.autoId, N = `${M}-listbox`, { helpId: Ge } = A, P = (e) => `${M}-opt-${e}`, F = p ?? ue, Ke = i((t) => {
36
- e(S, t);
37
- }, [S]), [qe, I] = o(!1), [Je, L] = o(!1), [Ye, R] = o(-1), z = a(null), B = a(null), V = a(null), H = w !== void 0, U = !j && pe({
34
+ readOnly: C,
35
+ fieldClassName: Pe
36
+ }), M = te(C, j.field), N = j.controlId ?? j.autoId, P = `${N}-listbox`, { helpId: Ge } = j, F = (e) => `${N}-opt-${e}`, I = p ?? ue, Ke = i((e) => {
37
+ t(w, e);
38
+ }, [w]), [qe, L] = o(!1), [Je, R] = o(!1), [Ye, z] = o(-1), B = a(null), V = a(null), H = a(null), U = E !== void 0, W = !M && pe({
38
39
  focused: qe,
39
40
  dismissed: Je,
40
- query: O,
41
+ query: k,
41
42
  minChars: we
42
- }), W = O.trim(), G = he({
43
- query: W,
44
- enabled: H && U,
45
- load: w,
43
+ }), G = k.trim(), K = he({
44
+ query: G,
45
+ enabled: U && W,
46
+ load: E,
46
47
  delay: He,
47
48
  revalidate: !0,
48
49
  initial: u
49
- }).last ?? u, K = H && U && G.key !== W, Xe = ve(() => H ? (G.data ?? []).slice(0, _ > 0 ? _ : void 0) : de(C ?? [], O, F, _), [
50
- H,
51
- G.data,
52
- C,
53
- O,
50
+ }).last ?? u, q = U && W && K.key !== G, Xe = ve(() => U ? (K.data ?? []).slice(0, _ > 0 ? _ : void 0) : de(T ?? [], k, I, _), [
51
+ U,
52
+ K.data,
53
+ T,
54
+ k,
54
55
  _
55
- ]), q = K ? [] : Xe, J = le(Ye, q.length);
56
+ ]), J = q ? [] : Xe, Y = le(Ye, J.length);
56
57
  ge(() => {
57
- if (!U || J < 0) return;
58
- let e = z.current?.children[J];
58
+ if (!W || Y < 0) return;
59
+ let e = B.current?.children[Y];
59
60
  e instanceof HTMLElement && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
60
- }, [U, J]);
61
- let Y = U && !K && q.length === 0, X = U && (K || q.length > 0 || Y), { placement: Ze, style: Qe, update: Z } = me({
62
- open: X,
63
- anchor: B,
64
- floatingRef: V,
61
+ }, [W, Y]);
62
+ let X = W && !q && J.length === 0, Z = W && (q || J.length > 0 || X), { placement: Ze, style: Qe, update: Q } = me({
63
+ open: Z,
64
+ anchor: V,
65
+ floatingRef: H,
65
66
  ...ce,
66
67
  offset: be
67
68
  });
68
69
  _e(() => {
69
- X && Z();
70
+ Z && Q();
70
71
  }, [
71
- X,
72
- q.length,
73
- K,
74
- Z
72
+ Z,
73
+ J.length,
74
+ q,
75
+ Q
75
76
  ]);
76
- let Q = i((e) => {
77
- g && k(F(e)), f?.(e), L(!0), R(-1);
77
+ let $e = i((e) => {
78
+ g && A(I(e)), f?.(e), R(!0), z(-1);
78
79
  }, [
79
80
  g,
80
- k,
81
+ A,
81
82
  f,
82
83
  p
83
- ]), $e = (e) => {
84
- k(e.target.value), L(!1), R(-1);
85
- }, et = (e) => {
84
+ ]), et = (e) => {
85
+ A(e.target.value), R(!1), z(-1);
86
+ }, tt = (e) => {
86
87
  if (ze?.(e), !e.defaultPrevented) switch (e.key) {
87
88
  case "ArrowDown":
88
89
  case "ArrowUp":
89
- if (e.preventDefault(), !U) {
90
- L(!1);
90
+ if (e.preventDefault(), !W) {
91
+ R(!1);
91
92
  return;
92
93
  }
93
- R(ae(J, e.key === "ArrowDown" ? "next" : "prev", ie(q.length)));
94
+ z(oe(Y, e.key === "ArrowDown" ? "next" : "prev", ae(J.length)));
94
95
  break;
95
96
  case "Enter":
96
- if (U && J >= 0) {
97
+ if (W && Y >= 0) {
97
98
  e.preventDefault();
98
- let t = q[J];
99
- t !== void 0 && Q(t);
99
+ let t = J[Y];
100
+ t !== void 0 && $e(t);
100
101
  }
101
102
  break;
102
- case "Escape": U && (e.preventDefault(), e.stopPropagation(), L(!0), R(-1));
103
+ case "Escape": W && (e.preventDefault(), e.stopPropagation(), R(!0), z(-1));
103
104
  }
104
- }, tt = (e) => {
105
- I(!0), L(!1), T?.(e);
106
105
  }, nt = (e) => {
107
- I(!1), R(-1), Re?.(e);
108
- }, $ = X ? se(B.current) : null, rt = /* @__PURE__ */ c("div", {
109
- ref: B,
110
- className: ["kapi-ac", K && "kapi-ac--loading"].filter(Boolean).join(" "),
106
+ L(!0), R(!1), Le?.(e);
107
+ }, rt = (e) => {
108
+ L(!1), z(-1), Re?.(e);
109
+ }, $ = Z ? se(V.current) : null, it = /* @__PURE__ */ c("div", {
110
+ ref: V,
111
+ className: ["kapi-ac", q && "kapi-ac--loading"].filter(Boolean).join(" "),
111
112
  children: [
112
113
  /* @__PURE__ */ s("input", {
113
- ...E,
114
+ ...D,
114
115
  ref: Ke,
115
116
  type: "text",
116
117
  role: "combobox",
117
118
  autoComplete: "off",
118
119
  "aria-autocomplete": "list",
119
- "aria-expanded": X,
120
- "aria-controls": N,
121
- "aria-activedescendant": X && J >= 0 ? P(J) : void 0,
122
- ...t(A.outer, {
123
- id: M,
124
- describedBy: n(Ge, E["aria-describedby"]),
125
- busy: K || void 0,
120
+ "aria-expanded": Z,
121
+ "aria-controls": P,
122
+ "aria-activedescendant": Z && Y >= 0 ? F(Y) : void 0,
123
+ ...n(j.outer, {
124
+ id: N,
125
+ describedBy: r(Ge, D["aria-describedby"]),
126
+ busy: q || void 0,
126
127
  invalid: Ue
127
128
  }),
128
129
  required: b,
129
- readOnly: j || void 0,
130
+ readOnly: M || void 0,
130
131
  className: re({
131
132
  size: Me,
132
133
  status: We,
133
- className: Ie
134
+ className: Fe
134
135
  }),
135
- value: O,
136
- onChange: $e,
137
- onKeyDown: et,
138
- onFocus: tt,
139
- onBlur: nt
136
+ value: k,
137
+ onChange: et,
138
+ onKeyDown: tt,
139
+ onFocus: nt,
140
+ onBlur: rt
140
141
  }),
141
- K && /* @__PURE__ */ s("span", {
142
+ q && /* @__PURE__ */ s("span", {
142
143
  className: "kapi-ac__spinner kapi-spinner kapi-spinner--sm",
143
144
  "aria-hidden": "true"
144
145
  }),
145
146
  $ && ye(/* @__PURE__ */ c("div", {
146
- ref: V,
147
+ ref: H,
147
148
  className: "kapi-ac__menu",
148
149
  "data-side": Ze?.side ?? "bottom",
149
150
  style: Qe,
150
151
  onMouseDown: (e) => e.preventDefault(),
151
152
  children: [/* @__PURE__ */ s("ul", {
152
- ref: z,
153
- id: N,
153
+ ref: B,
154
+ id: P,
154
155
  role: "listbox",
155
156
  className: "kapi-ac__list",
156
- hidden: q.length === 0,
157
- children: q.map((e, t) => {
158
- let n = F(e), r = t === J;
157
+ hidden: J.length === 0,
158
+ children: J.map((e, t) => {
159
+ let n = I(e), r = t === Y;
159
160
  return /* @__PURE__ */ s("li", {
160
- id: P(t),
161
+ id: F(t),
161
162
  role: "option",
162
163
  "aria-selected": r,
163
164
  className: ["kapi-ac__opt", r && "kapi-ac__opt--active"].filter(Boolean).join(" "),
164
- onMouseEnter: () => R(t),
165
- onClick: () => Q(e),
165
+ onMouseEnter: () => z(t),
166
+ onClick: () => $e(e),
166
167
  children: h ? h(e, {
167
- query: O,
168
+ query: k,
168
169
  active: r
169
- }) : fe(n, O).map((e, t) => e.match ? /* @__PURE__ */ s("mark", {
170
+ }) : fe(n, k).map((e, t) => e.match ? /* @__PURE__ */ s("mark", {
170
171
  className: "kapi-ac__mark",
171
172
  children: e.text
172
173
  }, t) : /* @__PURE__ */ s("span", { children: e.text }, t))
173
174
  }, m ? m(e) : `${n}-${t}`);
174
175
  })
175
- }), (K || Y) && /* @__PURE__ */ s("div", {
176
+ }), (q || X) && /* @__PURE__ */ s("div", {
176
177
  className: "kapi-ac__status",
177
178
  role: "status",
178
179
  "aria-live": "polite",
179
- children: K ? Ve : Be
180
+ children: q ? Ve : Be
180
181
  })]
181
182
  }), $)
182
183
  ]
183
184
  });
184
- return A.wrap(rt);
185
+ return j.wrap(it);
185
186
  };
186
187
  //#endregion
187
188
  export { l as DEFAULT_AUTOCOMPLETE_LABELS, d as KapiAutocomplete };
@@ -37,6 +37,12 @@ export type KapiChecklistProps<Id extends string = string> = Omit<HTMLAttributes
37
37
  label?: ReactNode | undefined;
38
38
  /** Ayuda / mensaje de error bajo la lista (la envuelve en un `KapiField` sin etiqueta). */
39
39
  help?: ReactNode | undefined;
40
+ /**
41
+ * El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
42
+ * `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
43
+ * Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
44
+ */
45
+ error?: ReactNode | undefined;
40
46
  /** Clase del `KapiField` propio (con `help`). `className` va a la raíz de la lista. */
41
47
  fieldClassName?: string | undefined;
42
48
  /**
@@ -74,4 +80,4 @@ export type KapiChecklistProps<Id extends string = string> = Omit<HTMLAttributes
74
80
  * desde el último alternado, Shift + flechas extienden la selección y Ctrl/Cmd + A marca o desmarca
75
81
  * todo lo visible. Tipear con la lista enfocada escribe en el buscador.
76
82
  */
77
- export declare function KapiChecklist<Id extends string = string>({ items, value, defaultValue, onChange, label, help, fieldClassName, readOnly: readOnlyProp, invalid, required, searchable, query: queryProp, defaultQuery, onQueryChange, selectAll, rangeSelect, disabled, labels, className, "aria-label": ariaLabel, ...rest }: KapiChecklistProps<Id>): ReactNode;
83
+ export declare function KapiChecklist<Id extends string = string>({ items, value, defaultValue, onChange, label, help, error, fieldClassName, readOnly: readOnlyProp, invalid, required, searchable, query: queryProp, defaultQuery, onQueryChange, selectAll, rangeSelect, disabled, labels, className, "aria-label": ariaLabel, ...rest }: KapiChecklistProps<Id>): ReactNode;
@@ -1,37 +1,38 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiChecklist.css";
3
3
  import { joinClasses as e } from "../rootProps.js";
4
- import { fieldControlProps as t, resolveReadOnly as n } from "./fieldLogic.js";
5
- import { useOwnField as r } from "./ownField.js";
6
- import { useLabels as i } from "../locale/KapiLocaleProvider.js";
4
+ import { useLabels as t } from "../locale/KapiLocaleProvider.js";
5
+ import { fieldControlProps as n, resolveReadOnly as r } from "./fieldLogic.js";
6
+ import { useOwnField as i } from "./ownField.js";
7
7
  import { KapiInput as ee } from "./KapiInput.js";
8
+ import { useControllableState as a } from "../../hooks/useControllableState.js";
8
9
  import { useRangeSelect as te } from "../../hooks/useRangeSelect.js";
9
- import { navKeyOf as ne, nextEnabledIndex as a } from "../overlays/menuKeyboardLogic.js";
10
- import { checklistBulkState as re, filterChecklistItems as o, orderedChecklistValue as s, setChecklistItems as ie } from "./checklistLogic.js";
10
+ import { navKeyOf as ne, nextEnabledIndex as o } from "../overlays/menuKeyboardLogic.js";
11
+ import { checklistBulkState as re, filterChecklistItems as ie, orderedChecklistValue as ae, setChecklistItems as oe } from "./checklistLogic.js";
11
12
  /* empty css */
12
- import { useControllableState as c } from "../../hooks/useControllableState.js";
13
- import { useEffect as ae, useId as oe, useMemo as l, useRef as u, useState as se } from "react";
14
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
15
- import { Check as ce, Search as p } from "lucide-react";
13
+ import { useEffect as se, useId as ce, useMemo as s, useRef as c, useState as l } from "react";
14
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
15
+ import { Check as f, Search as le } from "lucide-react";
16
16
  //#region src/components/inputs/KapiChecklist.tsx
17
- var m = {
17
+ var p = {
18
18
  search: "Buscar en la lista",
19
19
  searchPlaceholder: "Buscar…",
20
20
  selectAll: "Marcar todo",
21
21
  clearAll: "Desmarcar todo",
22
22
  empty: "Sin coincidencias"
23
- }, h = 7;
24
- function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help: ue, fieldClassName: de, readOnly: y, invalid: b, required: x, searchable: S, query: C, defaultQuery: w, onQueryChange: fe, selectAll: pe = !1, rangeSelect: T = !0, disabled: E = !1, labels: me, className: he, "aria-label": ge, ..._e }) {
25
- let D = i("checklist", m, me), O = r({
26
- help: ue,
27
- required: x,
28
- invalid: b,
29
- readOnly: y,
30
- fieldClassName: de
31
- }), k = O.field, A = n(y, k), j = oe(), M = `${j}-label`, N = u(null), P = u(null), [F, ve] = c(g, le ?? [], _), I = l(() => new Set(F), [F]), L = (e) => {
32
- A || ve(s(h, e));
33
- }, [R, z] = c(C, w ?? "", fe), B = S ?? h.length > 7, V = l(() => o(h, R), [h, R]), H = l(() => V.map((e) => e.id), [V]), U = l(() => E ? [] : V.flatMap((e, t) => e.disabled ? [] : [t]), [V, E]), W = (e) => !E && h.some((t) => t.id === e && !t.disabled), G = te(), [K, q] = se(null), J = K === null ? -1 : H.indexOf(K), Y = (e) => `${j}-opt-${h.findIndex((t) => t.id === e)}`;
34
- ae(() => {
23
+ }, m = 7;
24
+ function h({ items: m, value: h, defaultValue: ue, onChange: de, label: g, help: fe, error: _, fieldClassName: pe, readOnly: v, invalid: y, required: b, searchable: x, query: S, defaultQuery: C, onQueryChange: w, selectAll: me = !1, rangeSelect: T = !0, disabled: E = !1, labels: he, className: ge, "aria-label": _e, ...ve }) {
25
+ let D = t("checklist", p, he), O = i({
26
+ help: fe,
27
+ error: _,
28
+ required: b,
29
+ invalid: y,
30
+ readOnly: v,
31
+ fieldClassName: pe
32
+ }), k = O.field, A = r(v, k), j = ce(), M = `${j}-label`, N = c(null), P = c(null), [F, ye] = a(h, ue ?? [], de), I = s(() => new Set(F), [F]), L = (e) => {
33
+ A || ye(ae(m, e));
34
+ }, [R, z] = a(S, C ?? "", w), B = x ?? m.length > 7, V = s(() => ie(m, R), [m, R]), H = s(() => V.map((e) => e.id), [V]), U = s(() => E ? [] : V.flatMap((e, t) => e.disabled ? [] : [t]), [V, E]), W = (e) => !E && m.some((t) => t.id === e && !t.disabled), G = te(), [K, q] = l(null), J = K === null ? -1 : H.indexOf(K), Y = (e) => `${j}-opt-${m.findIndex((t) => t.id === e)}`;
35
+ se(() => {
35
36
  J < 0 || N.current?.querySelector(`[data-index="${J}"]`)?.scrollIntoView?.({ block: "nearest" });
36
37
  }, [J]);
37
38
  let X = (e, t) => {
@@ -43,13 +44,13 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
43
44
  isSelectable: W
44
45
  }));
45
46
  }, Z = re(V, I), Q = (e) => {
46
- E || L(ie(h, I, H, e));
47
- }, ye = (e) => {
47
+ E || L(oe(m, I, H, e));
48
+ }, be = (e) => {
48
49
  if (E) return;
49
50
  let t = ne(e.key, "vertical");
50
51
  if (t) {
51
52
  e.preventDefault();
52
- let n = a(J, t, U);
53
+ let n = o(J, t, U);
53
54
  if (n < 0) return;
54
55
  let r = t === "next" && n < J || t === "prev" && n > J;
55
56
  if (e.shiftKey && T && J >= 0) {
@@ -65,22 +66,22 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
65
66
  }
66
67
  q(H[n]);
67
68
  } else e.key === " " || e.key === "Enter" ? (e.preventDefault(), K !== null && J >= 0 && X(K, e.shiftKey)) : (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" ? (e.preventDefault(), Q(Z !== "all")) : B && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), z(R + e.key), P.current?.focus());
68
- }, be = () => {
69
+ }, xe = () => {
69
70
  J < 0 && U.length > 0 && q(H[U[0]]), N.current?.focus();
70
- }, xe = v == null ? { "aria-label": ge } : { "aria-labelledby": M }, $ = t(k, {
71
- invalid: b,
72
- required: x
71
+ }, Se = g == null ? { "aria-label": _e } : { "aria-labelledby": M }, $ = n(k, {
72
+ invalid: y,
73
+ required: b
73
74
  });
74
- return O.wrap(/* @__PURE__ */ f("div", {
75
- ..._e,
76
- className: e("kapi-checklist", E && "is-disabled", A && "is-readonly", he),
75
+ return O.wrap(/* @__PURE__ */ d("div", {
76
+ ...ve,
77
+ className: e("kapi-checklist", E && "is-disabled", A && "is-readonly", ge),
77
78
  children: [
78
- v != null && /* @__PURE__ */ d("div", {
79
+ g != null && /* @__PURE__ */ u("div", {
79
80
  id: M,
80
81
  className: "kapi-checklist__label",
81
- children: v
82
+ children: g
82
83
  }),
83
- B && /* @__PURE__ */ d(ee, {
84
+ B && /* @__PURE__ */ u(ee, {
84
85
  ref: P,
85
86
  type: "search",
86
87
  size: "sm",
@@ -88,30 +89,30 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
88
89
  "aria-label": D.search,
89
90
  placeholder: D.searchPlaceholder,
90
91
  spellCheck: !1,
91
- startIcon: /* @__PURE__ */ d(p, {}),
92
+ startIcon: /* @__PURE__ */ u(le, {}),
92
93
  clearable: !0,
93
94
  disabled: E,
94
95
  value: R,
95
96
  onChange: (e) => z(e.target.value),
96
97
  onKeyDown: (e) => {
97
- (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), be());
98
+ (e.key === "ArrowDown" || e.key === "Enter") && (e.preventDefault(), xe());
98
99
  }
99
100
  }),
100
- pe && /* @__PURE__ */ f("div", {
101
+ me && /* @__PURE__ */ d("div", {
101
102
  className: "kapi-checklist__bulk",
102
- children: [/* @__PURE__ */ d("button", {
103
+ children: [/* @__PURE__ */ u("button", {
103
104
  type: "button",
104
105
  disabled: E || A || Z === "all",
105
106
  onClick: () => Q(!0),
106
107
  children: D.selectAll
107
- }), /* @__PURE__ */ d("button", {
108
+ }), /* @__PURE__ */ u("button", {
108
109
  type: "button",
109
110
  disabled: E || A || Z === "none",
110
111
  onClick: () => Q(!1),
111
112
  children: D.clearAll
112
113
  })]
113
114
  }),
114
- V.length > 0 ? /* @__PURE__ */ d("div", {
115
+ V.length > 0 ? /* @__PURE__ */ u("div", {
115
116
  ref: N,
116
117
  role: "listbox",
117
118
  "aria-multiselectable": "true",
@@ -123,14 +124,14 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
123
124
  "aria-activedescendant": J >= 0 && K !== null ? Y(K) : void 0,
124
125
  tabIndex: E ? -1 : 0,
125
126
  className: "kapi-checklist__list",
126
- onKeyDown: ye,
127
+ onKeyDown: be,
127
128
  onFocus: (e) => {
128
129
  e.target === e.currentTarget && J < 0 && U.length > 0 && q(H[U[0]]);
129
130
  },
130
- ...xe,
131
+ ...Se,
131
132
  children: V.map((t, n) => {
132
133
  let r = I.has(t.id), i = E || t.disabled === !0;
133
- return /* @__PURE__ */ f("div", {
134
+ return /* @__PURE__ */ d("div", {
134
135
  id: Y(t.id),
135
136
  "data-index": n,
136
137
  role: "option",
@@ -144,32 +145,32 @@ function g({ items: h, value: g, defaultValue: le, onChange: _, label: v, help:
144
145
  onClick: (e) => {
145
146
  i || (q(t.id), X(t.id, e.shiftKey));
146
147
  },
147
- children: [/* @__PURE__ */ d("span", {
148
+ children: [/* @__PURE__ */ u("span", {
148
149
  className: "kapi-checklist__box",
149
150
  "aria-hidden": "true",
150
- children: r && /* @__PURE__ */ d(ce, {
151
+ children: r && /* @__PURE__ */ u(f, {
151
152
  size: 12,
152
153
  strokeWidth: 3
153
154
  })
154
- }), /* @__PURE__ */ f("span", {
155
+ }), /* @__PURE__ */ d("span", {
155
156
  className: "kapi-checklist__text",
156
- children: [/* @__PURE__ */ d("span", {
157
+ children: [/* @__PURE__ */ u("span", {
157
158
  className: "kapi-checklist__name",
158
159
  children: t.label
159
- }), t.description != null && /* @__PURE__ */ d("span", {
160
+ }), t.description != null && /* @__PURE__ */ u("span", {
160
161
  className: "kapi-checklist__desc",
161
162
  children: t.description
162
163
  })]
163
164
  })]
164
165
  }, t.id);
165
166
  })
166
- }) : /* @__PURE__ */ d("div", {
167
+ }) : /* @__PURE__ */ u("div", {
167
168
  className: "kapi-checklist__empty",
168
169
  role: "status",
169
- children: h.length > 0 ? D.empty : null
170
+ children: m.length > 0 ? D.empty : null
170
171
  })
171
172
  ]
172
173
  }));
173
174
  }
174
175
  //#endregion
175
- export { h as CHECKLIST_SEARCH_THRESHOLD, m as DEFAULT_CHECKLIST_LABELS, g as KapiChecklist };
176
+ export { m as CHECKLIST_SEARCH_THRESHOLD, p as DEFAULT_CHECKLIST_LABELS, h as KapiChecklist };
@@ -0,0 +1,40 @@
1
+ import { type ReactNode, type Ref } from "react";
2
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
3
+ import { type KapiButtonProps } from "./KapiButton.js";
4
+ export type KapiCopyButtonLabels = {
5
+ /** Nombre del botón en reposo. */
6
+ copy: string;
7
+ /** Nombre y texto mientras muestra que copió. */
8
+ copied: string;
9
+ };
10
+ export declare const DEFAULT_COPY_BUTTON_LABELS: KapiCopyButtonLabels;
11
+ /** Cuánto dura el «Copiado» antes de volver al estado normal. */
12
+ export declare const COPY_FEEDBACK_MS = 2000;
13
+ /** Lo de `KapiButton` (tono, variante, tamaño, `render`…) más lo propio. */
14
+ export type KapiCopyButtonProps = Omit<KapiButtonProps, "onClick" | "children" | "icon"> & {
15
+ /** Ref al `<button>`. */
16
+ ref?: Ref<HTMLButtonElement> | undefined;
17
+ /** Lo que se copia. */
18
+ value: string;
19
+ /** Texto del botón. Sin esto queda sólo el ícono, con el nombre del locale. */
20
+ children?: ReactNode;
21
+ /**
22
+ * Avisa el resultado REAL: `true` si el portapapeles aceptó, `false` si no había portapapeles o
23
+ * rechazó. No es un «se intentó»: con `false` el botón tampoco confirma.
24
+ */
25
+ onCopy?: ((ok: boolean) => void) | undefined;
26
+ /** Textos propios (`copy`, `copied`). */
27
+ labels?: KapiLabelsOverride<KapiCopyButtonLabels> | undefined;
28
+ };
29
+ /**
30
+ * Botón que copia un valor y **confirma sólo si copió de verdad**.
31
+ *
32
+ * Eso último es todo el componente. El portapapeles pide contexto seguro y permiso: en http sin
33
+ * TLS `navigator.clipboard` ni existe, y la promesa puede rechazar. Un botón que dice «Copiado»
34
+ * pase lo que pase es peor que uno que no dice nada, porque la persona se va creyendo que tiene el
35
+ * valor y lo descubre al pegar.
36
+ *
37
+ * La confirmación vuelve sola a los 2 s (`COPY_FEEDBACK_MS`) y el temporizador se limpia al
38
+ * desmontar.
39
+ */
40
+ export declare function KapiCopyButton({ value, children, onCopy, labels, ref, ...rest }: KapiCopyButtonProps): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { KapiButton as e } from "./KapiButton.js";
3
+ import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
4
+ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
5
+ import { copyText as r } from "./copyLogic.js";
6
+ import { present as i } from "./inputLogic.js";
7
+ import { useEffect as a, useRef as o, useState as s } from "react";
8
+ import { jsx as c } from "react/jsx-runtime";
9
+ import { Check as l, Copy as u } from "lucide-react";
10
+ //#region src/components/inputs/KapiCopyButton.tsx
11
+ var d = {
12
+ copy: "Copiar",
13
+ copied: "Copiado"
14
+ }, f = 2e3;
15
+ function p({ value: p, children: m, onCopy: h, labels: g, ref: _, ...v }) {
16
+ let y = n("copyButton", d, g), [b, x] = s(!1), S = o(null), C = o(void 0), w = o(!0), T = t(S, _);
17
+ a(() => (w.current = !0, () => {
18
+ w.current = !1, clearTimeout(C.current);
19
+ }), []);
20
+ let E = async () => {
21
+ let e = await r(p, S.current);
22
+ w.current && (h?.(e), e && (x(!0), clearTimeout(C.current), C.current = setTimeout(() => x(!1), f)));
23
+ }, D = i(m), O = b ? y.copied : y.copy;
24
+ return /* @__PURE__ */ c(e, {
25
+ ...v,
26
+ ref: T,
27
+ icon: c(b ? l : u, { "aria-hidden": "true" }),
28
+ iconOnly: !D,
29
+ "aria-label": D && !b ? void 0 : O,
30
+ onClick: () => void E(),
31
+ children: D ? b ? y.copied : m : void 0
32
+ });
33
+ }
34
+ //#endregion
35
+ export { f as COPY_FEEDBACK_MS, d as DEFAULT_COPY_BUTTON_LABELS, p as KapiCopyButton };
@@ -37,6 +37,12 @@ export type KapiDatePickerProps = {
37
37
  label?: ReactNode | undefined;
38
38
  /** Ayuda / mensaje de error bajo el campo (envuelve el picker en un `KapiField`). */
39
39
  help?: ReactNode | undefined;
40
+ /**
41
+ * El motivo por el que el campo está mal. Reemplaza a `help` y lo marca inválido (rojo, ícono y
42
+ * `role="alert"`). Es lo que entregan las librerías de formularios: un mensaje, no un booleano.
43
+ * Un error que React no pinta (`true`, `""`, `null`) no marca nada. Gana sobre `invalid` y `status`.
44
+ */
45
+ error?: ReactNode | undefined;
40
46
  /** Clase del `KapiField` propio (con `label` o `help`). `className` va al envoltorio del picker. */
41
47
  fieldClassName?: string | undefined;
42
48
  /**
@@ -87,4 +93,4 @@ export type KapiDatePickerProps = {
87
93
  * Con `label` o `icon` el campo se dibuja como el chip de `KapiDropdown` (la misma clase
88
94
  * `.kapi-filterchip`), para una fila de filtros que mezcle los dos.
89
95
  */
90
- export declare const KapiDatePicker: ({ mode, value, defaultValue, onChange, placeholder, variant, icon, chipLabel: chipLabelProp, label: labelProp, help, fieldClassName, readOnly: readOnlyProp, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, invalid, required, ref, onBlur: onBlurProp, weekStartsOn }: KapiDatePickerProps) => ReactNode;
96
+ export declare const KapiDatePicker: ({ mode, value, defaultValue, onChange, placeholder, variant, icon, chipLabel: chipLabelProp, label: labelProp, help, error, fieldClassName, readOnly: readOnlyProp, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, invalid, required, ref, onBlur: onBlurProp, weekStartsOn }: KapiDatePickerProps) => ReactNode;