@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,16 +1,14 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
- import { columnAlign as t, readCell as n, stickySideOf as r } from "./tableLogic.js";
4
- import { KapiSkeleton as i } from "../feedback/KapiSkeleton.js";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
- import { ChevronDown as s, ChevronUp as c, ChevronsUpDown as l, Copy as u, Loader2 as d } from "lucide-react";
3
+ import { copyText as t } from "../inputs/copyLogic.js";
4
+ import { columnAlign as n, readCell as r, stickySideOf as i } from "./tableLogic.js";
5
+ import { KapiSkeleton as a } from "../feedback/KapiSkeleton.js";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ import { ChevronDown as c, ChevronUp as l, ChevronsUpDown as u, Copy as d, Loader2 as f } from "lucide-react";
7
8
  //#region src/components/data/tableCells.tsx
8
- var f = (e, t) => {
9
- try {
10
- navigator.clipboard?.writeText(String(e))?.catch(() => void 0);
11
- } catch {}
12
- t?.(e);
13
- }, p = (e, t, n) => {
9
+ var p = async (e, n, r) => {
10
+ await t(String(e), r) && n?.(e);
11
+ }, m = (e, t, n) => {
14
12
  let r = n[e.key];
15
13
  return r === void 0 ? t === "th" ? {
16
14
  width: e.flex ? "100%" : e.width,
@@ -24,103 +22,103 @@ var f = (e, t) => {
24
22
  minWidth: r,
25
23
  maxWidth: r
26
24
  };
27
- }, m = (e) => {
28
- let n = t(e);
29
- if (n) return `is-align-${n}${n === "start" ? " is-align-left" : n === "end" ? " is-align-right" : ""}`;
30
- }, h = (t, n, i) => {
31
- let a = r(t.sticky);
32
- return e(a && "is-sticky", a === "right" && "is-sticky-right", a === "left" && n === i.lastLeft && "is-sticky-last", a === "right" && n === i.firstRight && "is-sticky-first-right", t.flex && "is-flex", m(t.align));
33
- }, g = (e, t) => ({
25
+ }, h = (e) => {
26
+ let t = n(e);
27
+ if (t) return `is-align-${t}${t === "start" ? " is-align-left" : t === "end" ? " is-align-right" : ""}`;
28
+ }, g = (t, n, r) => {
29
+ let a = i(t.sticky);
30
+ return e(a && "is-sticky", a === "right" && "is-sticky-right", a === "left" && n === r.lastLeft && "is-sticky-last", a === "right" && n === r.firstRight && "is-sticky-first-right", t.flex && "is-flex", h(t.align));
31
+ }, _ = (e, t) => ({
34
32
  insetInlineStart: t.lefts[e],
35
33
  insetInlineEnd: t.rights[e]
36
- }), _ = (e) => `kapi-actcol${e.firstRight >= 0 ? " is-joined" : ""}`, v = (e, t, r, i) => {
37
- let s = e.render ? e.render(t) : n(t, e.key), c = e.clamp === void 0 ? s : /* @__PURE__ */ a("span", {
34
+ }), v = (e) => `kapi-actcol${e.firstRight >= 0 ? " is-joined" : ""}`, y = (e, t, n, i) => {
35
+ let a = e.render ? e.render(t) : r(t, e.key), c = e.clamp === void 0 ? a : /* @__PURE__ */ o("span", {
38
36
  className: "kapi-cell-clamp",
39
37
  style: { "--kapi-cell-lines": String(e.clamp) },
40
- children: s
38
+ children: a
41
39
  });
42
40
  if (!e.copyable) return c;
43
- let l = e.copyValue ? e.copyValue(t) : n(t, e.key);
44
- return /* @__PURE__ */ o("span", {
41
+ let l = e.copyValue ? e.copyValue(t) : r(t, e.key);
42
+ return /* @__PURE__ */ s("span", {
45
43
  className: "kapi-cell",
46
- children: [/* @__PURE__ */ a("span", {
44
+ children: [/* @__PURE__ */ o("span", {
47
45
  className: "kapi-cell__v",
48
46
  children: c
49
- }), /* @__PURE__ */ a("button", {
47
+ }), /* @__PURE__ */ o("button", {
50
48
  type: "button",
51
49
  className: "kapi-cell__copy",
52
- "aria-label": r.copy,
50
+ "aria-label": n.copy,
53
51
  onClick: (e) => {
54
- e.stopPropagation(), f(l, i);
52
+ e.stopPropagation(), p(l, i, e.currentTarget);
55
53
  },
56
- children: /* @__PURE__ */ a(u, {
54
+ children: /* @__PURE__ */ o(d, {
57
55
  size: 13,
58
56
  strokeWidth: 2
59
57
  })
60
58
  })]
61
59
  });
62
- }, y = (e) => e === "asc" ? /* @__PURE__ */ a(c, {
60
+ }, b = (e) => e === "asc" ? /* @__PURE__ */ o(l, {
63
61
  size: 13,
64
62
  strokeWidth: 2.4
65
- }) : e === "desc" ? /* @__PURE__ */ a(s, {
63
+ }) : e === "desc" ? /* @__PURE__ */ o(c, {
66
64
  size: 13,
67
65
  strokeWidth: 2.4
68
- }) : /* @__PURE__ */ a(l, {
66
+ }) : /* @__PURE__ */ o(u, {
69
67
  size: 13,
70
68
  strokeWidth: 2
71
- }), b = (e, t) => t?.key === e.key ? t.direction : "none", x = (e, t) => {
69
+ }), x = (e, t) => t?.key === e.key ? t.direction : "none", S = (e, t) => {
72
70
  if (!e.sortable) return;
73
- let n = b(e, t);
71
+ let n = x(e, t);
74
72
  return n === "none" ? "none" : n === "asc" ? "ascending" : "descending";
75
- }, S = (e, t, n, r) => {
73
+ }, C = (e, t, n, r) => {
76
74
  if (!e.sortable) return e.label;
77
- let i = b(e, t);
78
- return /* @__PURE__ */ o("button", {
75
+ let i = x(e, t);
76
+ return /* @__PURE__ */ s("button", {
79
77
  type: "button",
80
78
  className: `kapi-thsort${i === "none" ? "" : " is-active"}`,
81
79
  onClick: () => n(e.key),
82
80
  title: typeof e.label == "string" ? `${r.sortBy} ${e.label}` : void 0,
83
- children: [/* @__PURE__ */ a("span", { children: e.label }), y(i)]
81
+ children: [/* @__PURE__ */ o("span", { children: e.label }), b(i)]
84
82
  });
85
- }, C = (e, t, n = !1) => /* @__PURE__ */ a("tr", {
83
+ }, w = (e, t, n = !1) => /* @__PURE__ */ o("tr", {
86
84
  className: "kapi-table-staterow",
87
- children: /* @__PURE__ */ o("td", {
85
+ children: /* @__PURE__ */ s("td", {
88
86
  colSpan: e,
89
87
  className: "kapi-table-state",
90
- children: [n && /* @__PURE__ */ a(d, {
88
+ children: [n && /* @__PURE__ */ o(f, {
91
89
  size: 16,
92
90
  strokeWidth: 2.2,
93
91
  className: "kapi-table-spin",
94
92
  "aria-hidden": !0
95
- }), /* @__PURE__ */ a("span", { children: t })]
93
+ }), /* @__PURE__ */ o("span", { children: t })]
96
94
  })
97
- }), w = [
95
+ }), T = [
98
96
  96,
99
97
  72,
100
98
  84,
101
99
  60
102
- ], T = (e, t, n) => {
100
+ ], E = (e, t, n) => {
103
101
  let r = e.flex ? `${[
104
102
  70,
105
103
  55,
106
104
  80
107
- ][n % 3]}%` : Math.max(32, Math.min(w[(t + n) % w.length] ?? 72, (e.width ?? 120) - 36));
108
- return /* @__PURE__ */ a(i, {
105
+ ][n % 3]}%` : Math.max(32, Math.min(T[(t + n) % T.length] ?? 72, (e.width ?? 120) - 36));
106
+ return /* @__PURE__ */ o(a, {
109
107
  width: r,
110
108
  height: 14,
111
109
  radius: 6
112
110
  });
113
- }, E = (e, n, r, i, o, s, c, l) => /* @__PURE__ */ a("td", {
111
+ }, D = (e, t, r, i, a, s, c, l) => /* @__PURE__ */ o("td", {
114
112
  "data-col": e.key,
115
113
  colSpan: l !== void 0 && l > 1 ? l : void 0,
116
- className: h(e, n, i),
114
+ className: g(e, t, i),
117
115
  style: {
118
- ...g(n, i),
119
- ...p(e, "td", o),
120
- textAlign: t(e.align)
116
+ ..._(t, i),
117
+ ...m(e, "td", a),
118
+ textAlign: n(e.align)
121
119
  },
122
120
  "data-label": typeof e.label == "string" || typeof e.label == "number" ? String(e.label) : void 0,
123
- children: v(e, r, s, c)
121
+ children: y(e, r, s, c)
124
122
  }, e.key);
125
123
  //#endregion
126
- export { _ as actColClass, x as ariaSortOf, E as bodyCell, h as cellClass, t as columnAlign, p as columnBoxStyle, f as copyToClipboard, S as headerContent, v as renderCell, T as skeletonBar, b as sortDirectionOf, y as sortIcon, C as stateRow, g as stickyInset };
124
+ export { v as actColClass, S as ariaSortOf, D as bodyCell, g as cellClass, n as columnAlign, m as columnBoxStyle, p as copyToClipboard, C as headerContent, y as renderCell, E as skeletonBar, x as sortDirectionOf, b as sortIcon, w as stateRow, _ as stickyInset };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { useRangeSelect as e } from "../../hooks/useRangeSelect.js";
3
- import { useControllableState as t } from "../../hooks/useControllableState.js";
2
+ import { useControllableState as e } from "../../hooks/useControllableState.js";
3
+ import { useRangeSelect as t } from "../../hooks/useRangeSelect.js";
4
4
  import { slot as n } from "../slotsLogic.js";
5
5
  import { formatCount as r } from "../../hooks/numberFormatLogic.js";
6
6
  import { selectOnlyWithin as i, selectionState as a } from "./tableLogic.js";
@@ -11,7 +11,7 @@ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
11
11
  import { Loader2 as h } from "lucide-react";
12
12
  //#region src/components/data/useTableSelection.tsx
13
13
  var g = [], _ = ({ rows: n, keyField: o, selectable: s, selectedIds: c, defaultSelectedIds: u, onSelectedIdsChange: _, isRowSelectable: v, selectionPresets: y, rangeSelect: b, dataset: x, loadingLabel: S, locale: C }) => {
14
- let [w, T] = t(c, u ?? g, _ && ((e) => _([...e]))), E = d(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = e(), j = s && y !== void 0 && y.length > 0, M = d(() => n.filter((e) => !v || v(e)), [n, v]), N = d(() => M.map((e) => e[o]), [M, o]), P = d(() => j && y ? y.map((e) => ({
14
+ let [w, T] = e(c, u ?? g, _ && ((e) => _([...e]))), E = d(() => new Set(w), [w]), D = (e) => T([...e]), O = () => D(/* @__PURE__ */ new Set()), k = [...E], A = t(), j = s && y !== void 0 && y.length > 0, M = d(() => n.filter((e) => !v || v(e)), [n, v]), N = d(() => M.map((e) => e[o]), [M, o]), P = d(() => j && y ? y.map((e) => ({
15
15
  preset: e,
16
16
  matching: e.match === void 0 ? [] : M.filter(e.match).map((e) => e[o])
17
17
  })) : [], [
@@ -1,122 +1,127 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/display/KapiAnnotation.css";
3
- import { joinIds as e } from "../inputs/fieldLogic.js";
4
- import { resolveKapiRoot as t } from "../../hooks/kapiRoot.js";
5
- import { usePlacement as n } from "../../hooks/usePlacement.js";
6
- import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
5
+ import { joinIds as ee } from "../inputs/fieldLogic.js";
6
+ import { resolveKapiRoot as n } from "../../hooks/kapiRoot.js";
7
+ import { usePlacement as r } from "../../hooks/usePlacement.js";
7
8
  import { useDismiss as i } from "../../hooks/useDismiss.js";
8
9
  import { KapiTooltip as a } from "../overlays/KapiTooltip.js";
9
10
  import { annotationClasses as o, annotationRole as s } from "./annotationLogic.js";
10
11
  /* empty css */
11
- import { useEffect as c, useId as l, useRef as u, useState as d } from "react";
12
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
13
- import { createPortal as m } from "react-dom";
12
+ import { useEffect as c, useId as te, useRef as l, useState as u } from "react";
13
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
14
+ import { createPortal as p } from "react-dom";
14
15
  //#region src/components/display/KapiAnnotation.tsx
15
- var h = 8, g = 8, _ = 150;
16
- function v({ children: v, info: y, underline: b = "dotted", tone: x = "primary", onClick: S, popover: C, interactive: w = !1, className: T, "aria-label": E, ref: D, ...O }) {
17
- let k = l(), A = u(null), j = r(A, D), [M, N] = d(!1), [ee, P] = d(!1), F = u(null), I = u(void 0), { element: L, tabIndex: R, mode: z } = s(S, C, y), B = o({
18
- underline: b,
19
- tone: x,
20
- clickable: !!S,
21
- className: T
16
+ var m = 8, h = 8, g = 150;
17
+ function _({ children: _, info: v, underline: y = "dotted", tone: ne = "primary", onClick: b, popover: x, interactive: S = !1, className: C, "aria-label": w, ref: T, ...E }) {
18
+ let D = te(), O = l(null), k = t(O, T), [A, j] = u(!1), [M, N] = u(!1), P = l(null), F = l(void 0), { element: I, tabIndex: L, mode: R } = s(b, x, v), z = e("KapiAnnotation", ne), B = o({
19
+ underline: y,
20
+ tone: z.tone,
21
+ clickable: !!b,
22
+ className: C
22
23
  }), V = (e) => {
23
- e.key === "Escape" && (N(!1), P(!0));
24
- }, H = () => clearTimeout(I.current), U = () => {
25
- H(), P(!1), N(!0);
24
+ e.key === "Escape" && (j(!1), N(!0));
25
+ }, H = () => clearTimeout(F.current), U = () => {
26
+ H(), N(!1), j(!0);
26
27
  }, W = () => {
27
- H(), N(!1), P(!1);
28
+ H(), j(!1), N(!1);
28
29
  }, G = () => {
29
- if (!w) return W();
30
- H(), I.current = setTimeout(W, _);
30
+ if (!S) return W();
31
+ H(), F.current = setTimeout(W, g);
31
32
  }, K = (e) => {
32
33
  let t = e.relatedTarget;
33
- w && t && F.current?.contains(t) || W();
34
- }, { placement: q } = n({
35
- open: M,
36
- anchor: A,
37
- floatingRef: F,
34
+ S && t && P.current?.contains(t) || W();
35
+ }, { placement: q } = r({
36
+ open: A,
37
+ anchor: O,
38
+ floatingRef: P,
38
39
  side: "bottom",
39
40
  align: "center",
40
- offset: h,
41
- margin: g
41
+ offset: m,
42
+ margin: h
42
43
  }), J = q ? {
43
44
  top: q.top,
44
45
  left: q.centerX,
45
46
  side: q.side === "top" ? "top" : "bottom"
46
- } : null, Y = i(M && w, {
47
- zones: [A, F],
47
+ } : null, Y = i(A && S, {
48
+ zones: [O, P],
48
49
  onDismiss: (e) => {
49
50
  if (e === "outside") return W();
50
- N(!1), P(!0);
51
+ j(!1), N(!0);
51
52
  }
52
53
  });
53
- c(() => () => clearTimeout(I.current), []);
54
+ c(() => () => clearTimeout(F.current), []);
54
55
  let X = {
55
- ...O,
56
- ref: j,
56
+ ...E,
57
+ style: z.style ? {
58
+ ...z.style,
59
+ ...E.style
60
+ } : E.style,
61
+ ref: k,
57
62
  className: B,
58
63
  onKeyDown: V,
59
- onClick: S,
60
- ...E !== void 0 && { "aria-label": E },
61
- "data-dismissed": ee ? "" : void 0
64
+ onClick: b,
65
+ ...w !== void 0 && { "aria-label": w },
66
+ "data-dismissed": M ? "" : void 0
62
67
  };
63
- if (z === "tooltip") {
64
- let e = String(y), t = L === "button" ? /* @__PURE__ */ f("button", {
68
+ if (R === "tooltip") {
69
+ let e = String(v), t = I === "button" ? /* @__PURE__ */ d("button", {
65
70
  ...X,
66
71
  type: "button",
67
72
  onBlur: W,
68
- children: v
69
- }) : /* @__PURE__ */ f("span", {
73
+ children: _
74
+ }) : /* @__PURE__ */ d("span", {
70
75
  ...X,
71
- tabIndex: R,
76
+ tabIndex: L,
72
77
  onBlur: W,
73
- children: v
78
+ children: _
74
79
  });
75
- return /* @__PURE__ */ f(a, {
80
+ return /* @__PURE__ */ d(a, {
76
81
  label: e,
77
82
  prefer: "top",
78
83
  children: t
79
84
  });
80
85
  }
81
- let Z = C ?? { body: y }, Q = {
86
+ let Z = x ?? { body: v }, Q = {
82
87
  ...X,
83
- "aria-describedby": e(O["aria-describedby"], M && k),
88
+ "aria-describedby": ee(E["aria-describedby"], A && D),
84
89
  onFocus: U,
85
90
  onBlur: K
86
- }, $ = M ? t(A.current) : null;
87
- return /* @__PURE__ */ p("span", {
91
+ }, $ = A ? n(O.current) : null;
92
+ return /* @__PURE__ */ f("span", {
88
93
  className: "kapi-annotation-wrap",
89
94
  onMouseEnter: U,
90
95
  onMouseLeave: G,
91
96
  onKeyDown: Y,
92
- children: [L === "button" ? /* @__PURE__ */ f("button", {
97
+ children: [I === "button" ? /* @__PURE__ */ d("button", {
93
98
  ...Q,
94
99
  type: "button",
95
- children: v
96
- }) : /* @__PURE__ */ f("span", {
100
+ children: _
101
+ }) : /* @__PURE__ */ d("span", {
97
102
  ...Q,
98
- tabIndex: R,
99
- children: v
100
- }), $ && m(/* @__PURE__ */ p("span", {
101
- ref: F,
102
- id: k,
103
+ tabIndex: L,
104
+ children: _
105
+ }), $ && p(/* @__PURE__ */ f("span", {
106
+ ref: P,
107
+ id: D,
103
108
  role: "tooltip",
104
109
  className: "kapi-annotation__pop",
105
110
  "data-side": J?.side ?? "bottom",
106
- "data-interactive": w ? "" : void 0,
111
+ "data-interactive": S ? "" : void 0,
107
112
  style: {
108
113
  top: J?.top ?? 0,
109
114
  left: J?.left ?? 0,
110
115
  visibility: J ? void 0 : "hidden"
111
116
  },
112
- tabIndex: w ? -1 : void 0,
113
- onMouseEnter: w ? H : void 0,
114
- onMouseLeave: w ? G : void 0,
115
- onBlur: w ? K : void 0,
116
- children: [Z.title && /* @__PURE__ */ f("span", {
117
+ tabIndex: S ? -1 : void 0,
118
+ onMouseEnter: S ? H : void 0,
119
+ onMouseLeave: S ? G : void 0,
120
+ onBlur: S ? K : void 0,
121
+ children: [Z.title && /* @__PURE__ */ d("span", {
117
122
  className: "kapi-annotation__title",
118
123
  children: Z.title
119
- }), /* @__PURE__ */ f("span", {
124
+ }), /* @__PURE__ */ d("span", {
120
125
  className: "kapi-annotation__body",
121
126
  children: Z.body
122
127
  })]
@@ -124,4 +129,4 @@ function v({ children: v, info: y, underline: b = "dotted", tone: x = "primary",
124
129
  });
125
130
  }
126
131
  //#endregion
127
- export { v as KapiAnnotation };
132
+ export { _ as KapiAnnotation };
@@ -1,8 +1,8 @@
1
1
  import type { HTMLAttributes, Ref } from "react";
2
- import { type KapiTone } from "../tone.js";
2
+ import { type KapiFamilyTone, type KapiTone } from "../tone.js";
3
3
  export type KapiAvatarSize = "sm" | "md" | "lg" | number;
4
- /** Tono de un avatar: `auto` (según el nombre) o un `KapiTone`. */
5
- export type KapiAvatarTone = "auto" | KapiTone;
4
+ /** Tono de un avatar: `auto` (según el nombre), un `KapiTone` o una familia propia de la app. */
5
+ export type KapiAvatarTone = "auto" | KapiTone | KapiFamilyTone;
6
6
  /** @deprecated Usar `KapiAvatarTone`. */
7
7
  export type KapiAvatarColor = KapiAvatarTone;
8
8
  export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> & {
@@ -24,9 +24,11 @@ export type KapiAvatarProps = Omit<HTMLAttributes<HTMLSpanElement>, "children">
24
24
  /** Orden fijo de los roles para el color automático (cambiarlo cambia los colores de todos). */
25
25
  export declare const AVATAR_ROLES: ReadonlyArray<KapiTone>;
26
26
  /** Clases de un avatar. Pura y exportada. */
27
- export declare const avatarClasses: ({ size, role, className }: {
27
+ export declare const avatarClasses: ({ size, role, family, className }: {
28
28
  size?: KapiAvatarSize | undefined;
29
29
  role: KapiTone;
30
+ /** El color sale de una familia de la app: va por `--family`, que lee los slots locales. */
31
+ family?: boolean | undefined;
30
32
  className?: string | undefined;
31
33
  }) => string;
32
34
  /** Avatar circular: imagen o iniciales sobre el color subtle del rol. */
@@ -1,45 +1,50 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/display/display.css";
3
- import { resolveTone as e } from "../tone.js";
3
+ import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
+ import { isFamilyTone as t, resolveTone as n } from "../tone.js";
4
5
  /* empty css */
5
- import { colorIndexFrom as t, initialsFrom as n } from "./avatarLogic.js";
6
- import { jsx as r } from "react/jsx-runtime";
6
+ import { colorIndexFrom as r, initialsFrom as i } from "./avatarLogic.js";
7
+ import { jsx as a } from "react/jsx-runtime";
7
8
  //#region src/components/display/KapiAvatar.tsx
8
- var i = [
9
+ var o = [
9
10
  "primary",
10
11
  "success",
11
12
  "info",
12
13
  "warning",
13
14
  "danger",
14
15
  "neutral"
15
- ], a = ({ size: e = "md", role: t, className: n = "" }) => [
16
+ ], s = ({ size: e = "md", role: t, family: n = !1, className: r = "" }) => [
16
17
  "kapi-avatar",
17
- `kapi-avatar--${t}`,
18
+ n ? "kapi-avatar--family" : `kapi-avatar--${t}`,
18
19
  typeof e == "string" && e !== "md" && `kapi-avatar--${e}`,
19
- n
20
+ r
20
21
  ].filter(Boolean).join(" ");
21
- function o({ name: o = "", initials: s, src: c, size: l = "md", tone: u, color: d, className: f, style: p, ...m }) {
22
- let h = e(u, d, "auto"), g = h === "auto" ? i[t(o, i.length)] ?? "neutral" : h, _ = o || s || "", v = typeof l == "number" ? l : void 0, y = v === void 0 ? p : {
23
- width: v,
24
- height: v,
25
- fontSize: Math.round(v * .38),
26
- ...p
27
- };
28
- return /* @__PURE__ */ r("span", {
29
- className: a({
30
- size: l,
31
- role: g,
32
- className: f
22
+ function c({ name: c = "", initials: l, src: u, size: d = "md", tone: f, color: p, className: m, style: h, ...g }) {
23
+ let _ = n(f, p, "auto"), v = t(_), y = e("KapiAvatar", v ? _ : void 0), b = v || _ === "auto" ? o[r(c, o.length)] ?? "neutral" : _, x = c || l || "", S = typeof d == "number" ? d : void 0, C = S === void 0 ? h : {
24
+ width: S,
25
+ height: S,
26
+ fontSize: Math.round(S * .38),
27
+ ...h
28
+ }, w = y.style ? {
29
+ ...y.style,
30
+ ...C
31
+ } : C;
32
+ return /* @__PURE__ */ a("span", {
33
+ className: s({
34
+ size: d,
35
+ role: b,
36
+ family: y.style !== void 0,
37
+ className: m
33
38
  }),
34
- style: y,
35
- role: c || !_ ? void 0 : "img",
36
- "aria-label": c || !_ ? void 0 : _,
37
- ...m,
38
- children: c ? /* @__PURE__ */ r("img", {
39
- src: c,
40
- alt: o
41
- }) : s ?? n(o)
39
+ style: w,
40
+ role: u || !x ? void 0 : "img",
41
+ "aria-label": u || !x ? void 0 : x,
42
+ ...g,
43
+ children: u ? /* @__PURE__ */ a("img", {
44
+ src: u,
45
+ alt: c
46
+ }) : l ?? i(c)
42
47
  });
43
48
  }
44
49
  //#endregion
45
- export { i as AVATAR_ROLES, o as KapiAvatar, a as avatarClasses };
50
+ export { o as AVATAR_ROLES, c as KapiAvatar, s as avatarClasses };
@@ -0,0 +1,48 @@
1
+ import type { HTMLAttributes, ReactNode, Ref } from "react";
2
+ import type { KapiClassNames } from "../slotCatalog.js";
3
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
4
+ /** Textos de `KapiCodeBlock`; se pisan con `labels` o el `KapiLocaleProvider`. */
5
+ export type KapiCodeBlockLabels = {
6
+ /** Nombre accesible de la región, con `{lang}` = el lenguaje si se pasó. */
7
+ region: string;
8
+ };
9
+ export declare const DEFAULT_CODE_BLOCK_LABELS: KapiCodeBlockLabels;
10
+ /** Atributos nativos (`id`, `style`, `data-*`…) van al `<figure>` raíz. */
11
+ export type KapiCodeBlockProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
12
+ /** Ref al `<figure>` raíz. */
13
+ ref?: Ref<HTMLElement> | undefined;
14
+ /** El código, tal cual. Es lo que se copia, aunque `children` dibuje otra cosa. */
15
+ code: string;
16
+ /**
17
+ * El código ya resaltado. Sin esto se dibuja `code` plano.
18
+ *
19
+ * El resaltado lo inyecta la app a propósito: un highlighter adentro rompería la regla de cero
20
+ * dependencias de runtime, y además cada app ya tiene el suyo. Lo que se COPIA sigue saliendo de
21
+ * `code`, así que el resaltado nunca puede ensuciar el portapapeles.
22
+ */
23
+ children?: ReactNode;
24
+ /** Lenguaje, para el rótulo y el `data-lang`. No cambia el dibujo. */
25
+ lang?: string | undefined;
26
+ /** Título sobre el bloque (nombre de archivo, ruta). */
27
+ title?: ReactNode;
28
+ /** Oculta el botón de copiar. @default false */
29
+ noCopy?: boolean | undefined;
30
+ /** Avisa el resultado REAL de copiar: `true` sólo si el portapapeles aceptó. */
31
+ onCopy?: ((ok: boolean) => void) | undefined;
32
+ /** Numera las líneas. @default false */
33
+ lineNumbers?: boolean | undefined;
34
+ /** Textos propios; pisan los del `KapiLocaleProvider` y los defaults. */
35
+ labels?: KapiLabelsOverride<KapiCodeBlockLabels> | undefined;
36
+ /** Clases por parte (`root`, `bar`, `title`, `copy`, `pre`, `numbers`, `code`). */
37
+ classNames?: KapiClassNames<"codeBlock"> | undefined;
38
+ };
39
+ /**
40
+ * Bloque de código con botón de copiar.
41
+ *
42
+ * Dos cosas que no se deducen del markup. **Lo que se copia es `code`, no lo que se ve**: si la
43
+ * app inyecta su resaltado por `children`, el portapapeles igual recibe el texto limpio, sin los
44
+ * `<span>` del highlighter ni los números de línea. Y **el botón confirma sólo si copió de
45
+ * verdad**, porque usa `KapiCopyButton`: en http sin TLS el portapapeles no existe y un «Copiado»
46
+ * ahí sería mentira.
47
+ */
48
+ export declare function KapiCodeBlock({ code, children, lang, title, noCopy, onCopy, lineNumbers, labels, classNames, className, ...rest }: KapiCodeBlockProps): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import "#kapi-css/components/display/KapiCodeBlock.css";
3
+ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
+ import { KapiCopyButton as t } from "../inputs/KapiCopyButton.js";
5
+ import { slot as n } from "../slotsLogic.js";
6
+ import { CODE_BLOCK_SLOTS as r } from "./codeBlockSlots.js";
7
+ /* empty css */
8
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
9
+ //#region src/components/display/KapiCodeBlock.tsx
10
+ var o = { region: "Bloque de código {lang}" };
11
+ function s({ code: s, children: c, lang: l, title: u, noCopy: d = !1, onCopy: f, lineNumbers: p = !1, labels: m, classNames: h, className: g, ..._ }) {
12
+ let v = e("codeBlock", o, m), y = p ? s.split("\n") : null;
13
+ return /* @__PURE__ */ a("figure", {
14
+ ..._,
15
+ ...n(r, "root", h, g),
16
+ "data-lang": l,
17
+ "aria-label": v.region.replace("{lang}", l ?? "").trim(),
18
+ children: [(u !== void 0 || !d) && /* @__PURE__ */ a("figcaption", {
19
+ ...n(r, "bar", h),
20
+ children: [/* @__PURE__ */ i("span", {
21
+ ...n(r, "title", h),
22
+ children: u
23
+ }), !d && /* @__PURE__ */ i(t, {
24
+ value: s,
25
+ size: "sm",
26
+ variant: "ghost",
27
+ ...f ? { onCopy: f } : {},
28
+ ...n(r, "copy", h)
29
+ })]
30
+ }), /* @__PURE__ */ a("pre", {
31
+ ...n(r, "pre", h),
32
+ children: [y && /* @__PURE__ */ i("span", {
33
+ ...n(r, "numbers", h),
34
+ "aria-hidden": "true",
35
+ children: y.map((e, t) => /* @__PURE__ */ i("span", { children: t + 1 }, t))
36
+ }), /* @__PURE__ */ i("code", {
37
+ ...n(r, "code", h),
38
+ children: c ?? s
39
+ })]
40
+ })]
41
+ });
42
+ }
43
+ //#endregion
44
+ export { o as DEFAULT_CODE_BLOCK_LABELS, s as KapiCodeBlock };
@@ -2,9 +2,9 @@
2
2
  import "#kapi-css/components/display/KapiComment.css";
3
3
  import { joinClasses as e } from "../rootProps.js";
4
4
  import { KapiButton as t } from "../inputs/KapiButton.js";
5
- import { assignRef as n, joinIds as r } from "../inputs/fieldLogic.js";
6
- import { useKapiField as i } from "../inputs/KapiField.js";
7
- import { useLabels as a } from "../locale/KapiLocaleProvider.js";
5
+ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
6
+ import { assignRef as r, joinIds as i } from "../inputs/fieldLogic.js";
7
+ import { useKapiField as a } from "../inputs/KapiField.js";
8
8
  import { KapiTextarea as o } from "../inputs/KapiTextarea.js";
9
9
  /* empty css */
10
10
  import { isSubmitShortcut as s } from "./commentLogic.js";
@@ -18,7 +18,7 @@ var f = {
18
18
  submit: "Comentar",
19
19
  shortcut: "Ctrl o ⌘ + Enter para enviar"
20
20
  }, p = ({ value: p, defaultValue: m, onChange: h, onSubmit: g, loading: _ = !1, invalid: v, required: y, disabled: b, className: x, style: S, labels: C, ref: w, placeholder: T, onKeyDown: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k, ...A }) => {
21
- let j = a("commentComposer", f, C), M = i(), N = l(), { text: P, setText: F, submit: I, busy: L, canSubmit: R, boxRef: z } = c({
21
+ let j = n("commentComposer", f, C), M = a(), N = l(), { text: P, setText: F, submit: I, busy: L, canSubmit: R, boxRef: z } = c({
22
22
  value: p,
23
23
  defaultValue: m,
24
24
  onChange: h,
@@ -37,7 +37,7 @@ var f = {
37
37
  children: [/* @__PURE__ */ u(o, {
38
38
  ...A,
39
39
  ref: (e) => {
40
- z.current = e, n(w, e);
40
+ z.current = e, r(w, e);
41
41
  },
42
42
  className: "kapi-composer__input",
43
43
  autosize: !0,
@@ -48,7 +48,7 @@ var f = {
48
48
  placeholder: T ?? j.placeholder,
49
49
  "aria-label": V ? D : j.label,
50
50
  "aria-labelledby": O,
51
- "aria-describedby": r(k, N),
51
+ "aria-describedby": i(k, N),
52
52
  ...y === void 0 ? {} : { required: y },
53
53
  ...v ? { invalid: !0 } : {},
54
54
  onChange: (e) => F(e.target.value),