@rinzai/zen 0.10.3 → 0.13.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 (299) hide show
  1. package/README.md +38 -8
  2. package/dist/accordion/index.d.ts +41 -0
  3. package/dist/accordion/index.d.ts.map +1 -0
  4. package/dist/accordion/index.js +81 -0
  5. package/dist/animated-number/index.d.ts +3 -2
  6. package/dist/animated-number/index.d.ts.map +1 -1
  7. package/dist/animated-number/index.js +40 -38
  8. package/dist/avatar/index.d.ts +8 -3
  9. package/dist/avatar/index.d.ts.map +1 -1
  10. package/dist/avatar/index.js +29 -21
  11. package/dist/backdrop/index.d.ts +4 -4
  12. package/dist/backdrop/index.d.ts.map +1 -1
  13. package/dist/backdrop/index.js +41 -39
  14. package/dist/badge/index.d.ts +4 -2
  15. package/dist/badge/index.d.ts.map +1 -1
  16. package/dist/badge/index.js +20 -11
  17. package/dist/base.css +4 -0
  18. package/dist/breadcrumbs/index.d.ts +1 -1
  19. package/dist/breadcrumbs/index.d.ts.map +1 -1
  20. package/dist/breadcrumbs/index.js +25 -24
  21. package/dist/button/index.d.ts +3 -3
  22. package/dist/button/index.d.ts.map +1 -1
  23. package/dist/button/index.js +16 -11
  24. package/dist/button-group/index.d.ts +13 -0
  25. package/dist/button-group/index.d.ts.map +1 -0
  26. package/dist/button-group/index.js +14 -0
  27. package/dist/calendar/index.d.ts +15 -8
  28. package/dist/calendar/index.d.ts.map +1 -1
  29. package/dist/calendar/index.js +97 -91
  30. package/dist/calendar-heatmap/index.d.ts +7 -5
  31. package/dist/calendar-heatmap/index.d.ts.map +1 -1
  32. package/dist/calendar-heatmap/index.js +32 -30
  33. package/dist/canvas/geometry.d.ts +51 -0
  34. package/dist/canvas/geometry.d.ts.map +1 -0
  35. package/dist/canvas/geometry.js +90 -0
  36. package/dist/canvas/index.d.ts +59 -0
  37. package/dist/canvas/index.d.ts.map +1 -0
  38. package/dist/canvas/index.js +305 -0
  39. package/dist/carousel/index.d.ts +27 -0
  40. package/dist/carousel/index.d.ts.map +1 -0
  41. package/dist/carousel/index.js +162 -0
  42. package/dist/chart/index.d.ts +5 -4
  43. package/dist/chart/index.d.ts.map +1 -1
  44. package/dist/chart/index.js +137 -135
  45. package/dist/chart/palette.js +0 -1
  46. package/dist/checkbox/index.d.ts +3 -3
  47. package/dist/checkbox/index.d.ts.map +1 -1
  48. package/dist/checkbox/index.js +33 -30
  49. package/dist/chip/index.js +1 -1
  50. package/dist/code-block/index.d.ts.map +1 -1
  51. package/dist/code-block/index.js +27 -32
  52. package/dist/code-input/index.d.ts.map +1 -1
  53. package/dist/code-input/index.js +30 -24
  54. package/dist/collapse/index.d.ts +4 -3
  55. package/dist/collapse/index.d.ts.map +1 -1
  56. package/dist/collapse/index.js +42 -39
  57. package/dist/color-picker/index.d.ts +43 -0
  58. package/dist/color-picker/index.d.ts.map +1 -0
  59. package/dist/color-picker/index.js +221 -0
  60. package/dist/combobox/index.d.ts +14 -6
  61. package/dist/combobox/index.d.ts.map +1 -1
  62. package/dist/combobox/index.js +151 -139
  63. package/dist/command-palette/index.d.ts +4 -3
  64. package/dist/command-palette/index.d.ts.map +1 -1
  65. package/dist/command-palette/index.js +60 -57
  66. package/dist/confirm-dialog/index.d.ts +6 -7
  67. package/dist/confirm-dialog/index.d.ts.map +1 -1
  68. package/dist/confirm-dialog/index.js +20 -16
  69. package/dist/date-picker/index.d.ts +23 -14
  70. package/dist/date-picker/index.d.ts.map +1 -1
  71. package/dist/date-picker/index.js +109 -93
  72. package/dist/dialog/index.d.ts +3 -4
  73. package/dist/dialog/index.d.ts.map +1 -1
  74. package/dist/dialog/index.js +58 -55
  75. package/dist/disclosure/index.d.ts +8 -0
  76. package/dist/disclosure/index.d.ts.map +1 -1
  77. package/dist/disclosure/index.js +31 -32
  78. package/dist/editable-cell/index.d.ts +4 -5
  79. package/dist/editable-cell/index.d.ts.map +1 -1
  80. package/dist/editable-cell/index.js +23 -22
  81. package/dist/field/index.d.ts +8 -8
  82. package/dist/field/index.d.ts.map +1 -1
  83. package/dist/field/index.js +20 -18
  84. package/dist/filter-bar/index.d.ts +2 -2
  85. package/dist/filter-bar/index.d.ts.map +1 -1
  86. package/dist/filter-bar/index.js +38 -36
  87. package/dist/header/index.d.ts +1 -1
  88. package/dist/header/index.d.ts.map +1 -1
  89. package/dist/header/index.js +13 -11
  90. package/dist/hover-card/index.d.ts +32 -0
  91. package/dist/hover-card/index.d.ts.map +1 -0
  92. package/dist/hover-card/index.js +84 -0
  93. package/dist/icon-picker/index.d.ts +16 -5
  94. package/dist/icon-picker/index.d.ts.map +1 -1
  95. package/dist/icon-picker/index.js +42 -47
  96. package/dist/icons/micro/plus.d.ts +3 -0
  97. package/dist/icons/micro/plus.d.ts.map +1 -0
  98. package/dist/icons/micro/plus.js +17 -0
  99. package/dist/index.d.ts +41 -24
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/input/index.d.ts +5 -1
  102. package/dist/input/index.d.ts.map +1 -1
  103. package/dist/input/index.js +10 -10
  104. package/dist/input-group/index.d.ts +4 -1
  105. package/dist/input-group/index.d.ts.map +1 -1
  106. package/dist/input-group/index.js +17 -17
  107. package/dist/keypad/index.d.ts +9 -7
  108. package/dist/keypad/index.d.ts.map +1 -1
  109. package/dist/keypad/index.js +22 -19
  110. package/dist/lib.js +112 -93
  111. package/dist/load-more/index.d.ts +4 -2
  112. package/dist/load-more/index.d.ts.map +1 -1
  113. package/dist/load-more/index.js +26 -23
  114. package/dist/locale-provider/index.d.ts +23 -0
  115. package/dist/locale-provider/index.d.ts.map +1 -0
  116. package/dist/locale-provider/index.js +35 -0
  117. package/dist/menu/index.d.ts +62 -9
  118. package/dist/menu/index.d.ts.map +1 -1
  119. package/dist/menu/index.js +371 -128
  120. package/dist/meter/index.d.ts +2 -2
  121. package/dist/meter/index.d.ts.map +1 -1
  122. package/dist/meter/index.js +4 -4
  123. package/dist/money-input/index.d.ts +20 -10
  124. package/dist/money-input/index.d.ts.map +1 -1
  125. package/dist/money-input/index.js +199 -190
  126. package/dist/month-picker/index.d.ts +17 -10
  127. package/dist/month-picker/index.d.ts.map +1 -1
  128. package/dist/month-picker/index.js +97 -86
  129. package/dist/navigation-menu/index.d.ts +42 -0
  130. package/dist/navigation-menu/index.d.ts.map +1 -0
  131. package/dist/navigation-menu/index.js +144 -0
  132. package/dist/number-field/index.d.ts +34 -0
  133. package/dist/number-field/index.d.ts.map +1 -0
  134. package/dist/number-field/index.js +119 -0
  135. package/dist/page-header/index.d.ts +4 -3
  136. package/dist/page-header/index.d.ts.map +1 -1
  137. package/dist/page-header/index.js +2 -1
  138. package/dist/pagination/index.d.ts +1 -1
  139. package/dist/pagination/index.d.ts.map +1 -1
  140. package/dist/pagination/index.js +35 -33
  141. package/dist/progress-ring/index.d.ts +4 -3
  142. package/dist/progress-ring/index.d.ts.map +1 -1
  143. package/dist/progress-ring/index.js +11 -10
  144. package/dist/radio-cards/index.d.ts +9 -5
  145. package/dist/radio-cards/index.d.ts.map +1 -1
  146. package/dist/radio-cards/index.js +26 -24
  147. package/dist/radio-group/index.d.ts +9 -8
  148. package/dist/radio-group/index.d.ts.map +1 -1
  149. package/dist/radio-group/index.js +35 -34
  150. package/dist/range-slider/index.d.ts +10 -4
  151. package/dist/range-slider/index.d.ts.map +1 -1
  152. package/dist/range-slider/index.js +43 -31
  153. package/dist/repeat-picker/index.d.ts +13 -6
  154. package/dist/repeat-picker/index.d.ts.map +1 -1
  155. package/dist/repeat-picker/index.js +74 -62
  156. package/dist/resizable/index.d.ts +29 -0
  157. package/dist/resizable/index.d.ts.map +1 -0
  158. package/dist/resizable/index.js +135 -0
  159. package/dist/segmented/index.d.ts +8 -5
  160. package/dist/segmented/index.d.ts.map +1 -1
  161. package/dist/segmented/index.js +36 -34
  162. package/dist/select/index.d.ts +9 -3
  163. package/dist/select/index.d.ts.map +1 -1
  164. package/dist/select/index.js +94 -91
  165. package/dist/separator/index.d.ts +14 -0
  166. package/dist/separator/index.d.ts.map +1 -0
  167. package/dist/separator/index.js +15 -0
  168. package/dist/side-nav/index.js +1 -1
  169. package/dist/skeleton/index.d.ts +4 -4
  170. package/dist/skeleton/index.d.ts.map +1 -1
  171. package/dist/skeleton/index.js +4 -3
  172. package/dist/slider/index.d.ts +6 -3
  173. package/dist/slider/index.d.ts.map +1 -1
  174. package/dist/slider/index.js +29 -23
  175. package/dist/sortable/index.d.ts +10 -20
  176. package/dist/sortable/index.d.ts.map +1 -1
  177. package/dist/sortable/index.js +72 -134
  178. package/dist/sortable/shared.d.ts +56 -0
  179. package/dist/sortable/shared.d.ts.map +1 -0
  180. package/dist/sortable/shared.js +104 -0
  181. package/dist/sortable/tree-model.d.ts +46 -0
  182. package/dist/sortable/tree-model.d.ts.map +1 -0
  183. package/dist/sortable/tree-model.js +87 -0
  184. package/dist/sortable/tree.d.ts +31 -0
  185. package/dist/sortable/tree.d.ts.map +1 -0
  186. package/dist/sortable/tree.js +150 -0
  187. package/dist/sparkline/index.d.ts +1 -1
  188. package/dist/sparkline/index.d.ts.map +1 -1
  189. package/dist/sparkline/index.js +26 -25
  190. package/dist/spinner/index.d.ts +4 -3
  191. package/dist/spinner/index.d.ts.map +1 -1
  192. package/dist/spinner/index.js +2 -1
  193. package/dist/status-pill/index.d.ts.map +1 -1
  194. package/dist/status-pill/index.js +1 -1
  195. package/dist/stepper/index.d.ts +1 -1
  196. package/dist/stepper/index.d.ts.map +1 -1
  197. package/dist/stepper/index.js +31 -30
  198. package/dist/tab-bar/index.js +1 -1
  199. package/dist/table/index.d.ts +5 -5
  200. package/dist/table/index.d.ts.map +1 -1
  201. package/dist/table/index.js +66 -64
  202. package/dist/table/selection.d.ts +2 -2
  203. package/dist/table/selection.d.ts.map +1 -1
  204. package/dist/table/selection.js +41 -38
  205. package/dist/table/swipe.d.ts +1 -1
  206. package/dist/table/swipe.d.ts.map +1 -1
  207. package/dist/table/swipe.js +1 -1
  208. package/dist/table-of-contents/index.d.ts +4 -2
  209. package/dist/table-of-contents/index.d.ts.map +1 -1
  210. package/dist/table-of-contents/index.js +27 -25
  211. package/dist/tabs/index.d.ts.map +1 -1
  212. package/dist/tabs/index.js +90 -88
  213. package/dist/tag-input/index.d.ts +3 -1
  214. package/dist/tag-input/index.d.ts.map +1 -1
  215. package/dist/tag-input/index.js +61 -52
  216. package/dist/textarea/index.js +4 -4
  217. package/dist/theme-toggle/index.d.ts +9 -8
  218. package/dist/theme-toggle/index.d.ts.map +1 -1
  219. package/dist/theme-toggle/index.js +30 -28
  220. package/dist/theme.css +90 -12
  221. package/dist/time-field/index.d.ts +31 -0
  222. package/dist/time-field/index.d.ts.map +1 -0
  223. package/dist/time-field/index.js +175 -0
  224. package/dist/timeline/index.js +1 -1
  225. package/dist/toast/index.d.ts +1 -1
  226. package/dist/toast/index.d.ts.map +1 -1
  227. package/dist/toast/index.js +127 -125
  228. package/dist/toggle/index.d.ts +2 -2
  229. package/dist/toggle/index.d.ts.map +1 -1
  230. package/dist/toggle/index.js +8 -6
  231. package/dist/toggle-group/index.d.ts +35 -0
  232. package/dist/toggle-group/index.d.ts.map +1 -0
  233. package/dist/toggle-group/index.js +53 -0
  234. package/dist/toolbar/index.d.ts +19 -0
  235. package/dist/toolbar/index.d.ts.map +1 -0
  236. package/dist/toolbar/index.js +36 -0
  237. package/dist/tooltip/index.d.ts.map +1 -1
  238. package/dist/tooltip/index.js +40 -74
  239. package/dist/tree/index.d.ts.map +1 -1
  240. package/dist/tree/index.js +105 -102
  241. package/dist/trend/index.d.ts +2 -2
  242. package/dist/trend/index.d.ts.map +1 -1
  243. package/dist/trend/index.js +20 -19
  244. package/dist/utils/color.d.ts +35 -0
  245. package/dist/utils/color.d.ts.map +1 -0
  246. package/dist/utils/color.js +65 -0
  247. package/dist/utils/cva.js +0 -1
  248. package/dist/utils/cx.js +0 -1
  249. package/dist/utils/date.d.ts +6 -0
  250. package/dist/utils/date.d.ts.map +1 -1
  251. package/dist/utils/date.js +1 -2
  252. package/dist/utils/direction.d.ts +7 -0
  253. package/dist/utils/direction.d.ts.map +1 -0
  254. package/dist/utils/direction.js +6 -0
  255. package/dist/utils/form-value.d.ts +15 -0
  256. package/dist/utils/form-value.d.ts.map +1 -0
  257. package/dist/utils/form-value.js +29 -0
  258. package/dist/utils/fx.js +0 -1
  259. package/dist/utils/merge.js +0 -1
  260. package/dist/utils/messages.d.ts +137 -0
  261. package/dist/utils/messages.d.ts.map +1 -0
  262. package/dist/utils/messages.js +133 -0
  263. package/dist/utils/money.js +0 -1
  264. package/dist/utils/month.js +0 -1
  265. package/dist/utils/motion.js +0 -1
  266. package/dist/utils/refs.d.ts +6 -0
  267. package/dist/utils/refs.d.ts.map +1 -0
  268. package/dist/utils/refs.js +13 -0
  269. package/dist/utils/repeat.d.ts +3 -1
  270. package/dist/utils/repeat.d.ts.map +1 -1
  271. package/dist/utils/repeat.js +28 -25
  272. package/dist/utils/roving.d.ts +17 -0
  273. package/dist/utils/roving.d.ts.map +1 -0
  274. package/dist/utils/roving.js +35 -0
  275. package/dist/utils/section-link.js +0 -1
  276. package/dist/utils/slot.d.ts.map +1 -1
  277. package/dist/utils/slot.js +7 -11
  278. package/dist/utils/status-icons.js +7 -7
  279. package/dist/utils/styles.d.ts +9 -2
  280. package/dist/utils/styles.d.ts.map +1 -1
  281. package/dist/utils/styles.js +6 -3
  282. package/dist/utils/theme-wave.d.ts.map +1 -1
  283. package/dist/utils/theme-wave.js +70 -70
  284. package/dist/utils/theme.d.ts.map +1 -1
  285. package/dist/utils/theme.js +56 -60
  286. package/dist/utils/useAnchoredPopup.d.ts +7 -4
  287. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  288. package/dist/utils/useAnchoredPopup.js +18 -11
  289. package/dist/utils/useControllable.d.ts +9 -0
  290. package/dist/utils/useControllable.d.ts.map +1 -0
  291. package/dist/utils/useControllable.js +15 -0
  292. package/dist/utils/useCopyToClipboard.d.ts +13 -0
  293. package/dist/utils/useCopyToClipboard.d.ts.map +1 -0
  294. package/dist/utils/useCopyToClipboard.js +26 -0
  295. package/dist/utils/useHoverPopup.d.ts +39 -0
  296. package/dist/utils/useHoverPopup.d.ts.map +1 -0
  297. package/dist/utils/useHoverPopup.js +64 -0
  298. package/dist/zen.css +1 -1
  299. package/package.json +1 -1
@@ -4,107 +4,73 @@ import { useGraphicsMode as t } from "../utils/graphics.js";
4
4
  import { Slot as n } from "../utils/slot.js";
5
5
  import { anchorFor as r, anchoredStyle as i, useAnchorFallback as a } from "../utils/useAnchoredPopup.js";
6
6
  import { POPUP as o } from "../utils/styles.js";
7
- import { createContext as s, useCallback as c, useContext as l, useEffect as u, useId as d, useMemo as f, useRef as p } from "react";
8
- import { jsx as m } from "react/jsx-runtime";
7
+ import { useHoverPopup as s } from "../utils/useHoverPopup.js";
8
+ import { createContext as c, useContext as l, useRef as u } from "react";
9
+ import { jsx as d } from "react/jsx-runtime";
9
10
  //#region packages/tooltip/index.tsx
10
- var h = s(null);
11
- function g(e) {
12
- let t = l(h);
11
+ var f = c(null);
12
+ function p(e) {
13
+ let t = l(f);
13
14
  if (!t) throw Error(`<${e}> must be inside <Tooltip>`);
14
15
  return t;
15
16
  }
16
- function _({ children: e }) {
17
+ function m({ children: e }) {
17
18
  t();
18
- let n = `zen__tooltip-${d().replace(/[^\w-]/g, "")}`, r = p(null), i = p(0), o = c(() => {
19
- clearTimeout(i.current);
20
- try {
21
- r.current?.showPopover?.();
22
- } catch {}
23
- }, []), s = c(() => {
24
- clearTimeout(i.current);
25
- try {
26
- r.current?.hidePopover?.();
27
- } catch {}
28
- }, []), l = c(() => {
29
- clearTimeout(i.current), i.current = window.setTimeout(s, 100);
30
- }, [s]);
31
- u(() => () => clearTimeout(i.current), []), a(r);
32
- let g = f(() => ({
33
- id: n,
34
- ref: r,
35
- show: o,
36
- hide: s,
37
- hideSoon: l
38
- }), [
39
- n,
40
- o,
41
- s,
42
- l
43
- ]);
44
- return /* @__PURE__ */ m(h.Provider, {
45
- value: g,
19
+ let n = s("zen__tooltip");
20
+ return /* @__PURE__ */ d(f.Provider, {
21
+ value: n,
46
22
  children: e
47
23
  });
48
24
  }
49
- function v({ asChild: e, style: t, onPointerEnter: i, onPointerLeave: a, onFocus: o, onBlur: s, onKeyDown: c, children: l, ...u }) {
50
- let d = g("TooltipTrigger"), f = {
51
- "aria-describedby": d.id,
25
+ function h({ asChild: e, style: t, onPointerEnter: i, onPointerLeave: a, onFocus: o, onBlur: s, onKeyDown: c, children: l, ...u }) {
26
+ let f = p("TooltipTrigger"), m = {
27
+ "aria-describedby": f.id,
52
28
  ...u,
53
- ...r(d.id),
29
+ ...r(f.id),
54
30
  style: {
55
- ...r(d.id).style,
31
+ ...r(f.id).style,
56
32
  ...t
57
33
  },
58
- onPointerEnter: (e) => {
59
- i?.(e), e.pointerType === "mouse" && d.show();
60
- },
61
- onPointerLeave: (e) => {
62
- a?.(e), d.hideSoon();
63
- },
64
- onFocus: (e) => {
65
- o?.(e), e.currentTarget.matches(":focus-visible") && d.show();
66
- },
67
- onBlur: (e) => {
68
- s?.(e), d.hide();
69
- },
70
- onKeyDown: (e) => {
71
- c?.(e), e.key === "Escape" && d.hide();
72
- }
34
+ ...f.triggerProps({
35
+ onPointerEnter: i,
36
+ onPointerLeave: a,
37
+ onFocus: o,
38
+ onBlur: s,
39
+ onKeyDown: c
40
+ })
73
41
  };
74
- return e ? /* @__PURE__ */ m(n, {
75
- ...f,
42
+ return e ? /* @__PURE__ */ d(n, {
43
+ ...m,
76
44
  children: l
77
- }) : /* @__PURE__ */ m("button", {
45
+ }) : /* @__PURE__ */ d("button", {
78
46
  type: "button",
79
- ...f,
47
+ ...m,
80
48
  children: l
81
49
  });
82
50
  }
83
- function y({ align: t = "center", offset: n = 5, className: r, style: a, onPointerEnter: s, onPointerLeave: c, children: l, ...u }) {
84
- let d = g("TooltipContent");
85
- return /* @__PURE__ */ m("div", {
86
- ...u,
87
- ref: d.ref,
88
- id: d.id,
51
+ function g({ align: t = "center", offset: n = 5, className: r, style: s, onPointerEnter: c, onPointerLeave: l, children: f, ...m }) {
52
+ let h = p("TooltipContent"), g = u(null);
53
+ return a(g), /* @__PURE__ */ d("div", {
54
+ ...m,
55
+ ref: g,
56
+ id: h.id,
89
57
  role: "tooltip",
90
58
  popover: "manual",
91
- onPointerEnter: (e) => {
92
- s?.(e), d.show();
93
- },
94
- onPointerLeave: (e) => {
95
- c?.(e), d.hideSoon();
96
- },
59
+ ...h.contentProps({
60
+ onPointerEnter: c,
61
+ onPointerLeave: l
62
+ }),
97
63
  style: {
98
- ...i(d.id, {
64
+ ...i(h.id, {
99
65
  align: t,
100
66
  offset: n,
101
67
  width: "at-least"
102
68
  }),
103
- ...a
69
+ ...s
104
70
  },
105
71
  className: e("zen__popover fixed z-50 overflow-visible p-0", o, r),
106
- children: l
72
+ children: f
107
73
  });
108
74
  }
109
75
  //#endregion
110
- export { y as TooltipContent, v as TooltipTrigger, _ as default };
76
+ export { g as TooltipContent, h as TooltipTrigger, m as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tree/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,cAAc,EAAY,MAAM,YAAY,CAAC;AAGjE,OAAO,EACH,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EAKZ,MAAM,OAAO,CAAC;AAEf,iCAAiC;AACjC,MAAM,WAAW,WAAW,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,MAAM,CAAC;IACZ,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAA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AAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe,+BAsBrF;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC;IACnD,+BAA+B;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,IAAI,CAAC;IACzD,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/E,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB"}
@@ -1,156 +1,159 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { reducedMotion as t } from "../utils/motion.js";
4
- import { TableCell as n, TableRow as r } from "../table/index.js";
5
- import i from "../icons/micro/chevron-right.js";
6
- import { useCallback as a, useMemo as o, useRef as s, useState as c } from "react";
7
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
2
+ import e from "../icons/micro/chevron-right.js";
3
+ import { cx as t } from "../utils/cx.js";
4
+ import { readingKey as n } from "../utils/direction.js";
5
+ import { useMessages as r } from "../locale-provider/index.js";
6
+ import { reducedMotion as i } from "../utils/motion.js";
7
+ import { TableCell as a, TableRow as o } from "../table/index.js";
8
+ import { useCallback as s, useMemo as c, useRef as l, useState as u } from "react";
9
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
10
  //#region packages/tree/index.tsx
9
- function d({ items: n, getKey: r, getChildren: i, defaultExpanded: l = !0, rowHeight: u = 36 }) {
10
- let [d, f] = c(() => /* @__PURE__ */ new Set()), [p, m] = c(null), [h, g] = c(null), _ = s(null), v = a((e) => d.has(e) !== l, [d, l]), y = o(() => {
11
- let e = [], t = (n, a, o) => {
12
- n.forEach((s, c) => {
13
- let l = r(s), u = i(s), d = !!u?.length, f = d && v(l);
14
- e.push({
11
+ function p({ items: e, getKey: r, getChildren: a, defaultExpanded: o = !0, rowHeight: d = 36 }) {
12
+ let [f, p] = u(() => /* @__PURE__ */ new Set()), [m, h] = u(null), [g, _] = u(null), v = l(null), y = s((e) => f.has(e) !== o, [f, o]), b = c(() => {
13
+ let t = [], n = (e, i, o) => {
14
+ e.forEach((s, c) => {
15
+ let l = r(s), u = a(s), d = !!u?.length, f = d && y(l);
16
+ t.push({
15
17
  item: s,
16
18
  key: l,
17
- depth: a,
19
+ depth: i,
18
20
  parentKey: o,
19
21
  hasChildren: d,
20
22
  expanded: f,
21
23
  position: c + 1,
22
- siblings: n.length
23
- }), f && t(u, a + 1, l);
24
+ siblings: e.length
25
+ }), f && n(u, i + 1, l);
24
26
  });
25
27
  };
26
- return t(n, 0, null), e;
28
+ return n(e, 0, null), t;
27
29
  }, [
28
- n,
30
+ e,
29
31
  r,
30
- i,
31
- v
32
- ]), b = () => {
33
- let e = [], t = (n) => {
34
- for (let a of n) {
35
- let n = i(a);
36
- n?.length && (e.push(r(a)), t(n));
32
+ a,
33
+ y
34
+ ]), x = () => {
35
+ let t = [], n = (e) => {
36
+ for (let i of e) {
37
+ let e = a(i);
38
+ e?.length && (t.push(r(i)), n(e));
37
39
  }
38
40
  };
39
- return t(n), e;
40
- }, x = a((e, t) => f((n) => {
41
+ return n(e), t;
42
+ }, S = s((e, t) => p((n) => {
41
43
  let r = new Set(n);
42
- return t === l ? r.delete(e) : r.add(e), r;
43
- }), [l]), S = (e) => {
44
- let n = () => {
44
+ return t === o ? r.delete(e) : r.add(e), r;
45
+ }), [o]), C = (e) => {
46
+ let t = () => {
45
47
  let t = Date.now();
46
- m({
48
+ h({
47
49
  key: e,
48
50
  at: t
49
- }), setTimeout(() => m((e) => e?.at === t ? null : e), 320);
51
+ }), setTimeout(() => h((e) => e?.at === t ? null : e), 320);
50
52
  };
51
- if (h === e) _.current = null, g(null), n();
52
- else if (!v(e)) n(), x(e, !0);
53
- else if (t()) x(e, !1);
53
+ if (g === e) v.current = null, _(null), t();
54
+ else if (!y(e)) t(), S(e, !0);
55
+ else if (i()) S(e, !1);
54
56
  else {
55
- g(e);
57
+ _(e);
56
58
  let t = () => {
57
- _.current === t && (x(e, !1), g((t) => t === e ? null : t), _.current = null);
59
+ v.current === t && (S(e, !1), _((t) => t === e ? null : t), v.current = null);
58
60
  };
59
- _.current = t, setTimeout(t, 500);
61
+ v.current = t, setTimeout(t, 500);
60
62
  }
61
- }, [C, w] = c(null), T = y.some((e) => e.key === C) ? C : y[0]?.key ?? null, E = (e) => e.expanded && h !== e.key, D = (e, t) => {
63
+ }, [w, T] = u(null), E = b.some((e) => e.key === w) ? w : b[0]?.key ?? null, D = (e) => e.expanded && g !== e.key, O = (e, t) => {
62
64
  if (t.target !== t.currentTarget) return;
63
- let n = y.indexOf(e), r;
64
- if (t.key === "ArrowDown") r = y[n + 1];
65
- else if (t.key === "ArrowUp") r = y[n - 1];
66
- else if (t.key === "Home") r = y[0];
67
- else if (t.key === "End") r = y.at(-1);
68
- else if (t.key === "ArrowRight" && e.hasChildren) E(e) ? r = y[n + 1] : S(e.key);
69
- else if (t.key === "ArrowLeft") E(e) ? S(e.key) : r = y.find((t) => t.key === e.parentKey);
65
+ let r = b.indexOf(e), i, a = n(t.key, t.currentTarget);
66
+ if (a === "ArrowDown") i = b[r + 1];
67
+ else if (a === "ArrowUp") i = b[r - 1];
68
+ else if (a === "Home") i = b[0];
69
+ else if (a === "End") i = b.at(-1);
70
+ else if (a === "ArrowRight" && e.hasChildren) D(e) ? i = b[r + 1] : C(e.key);
71
+ else if (a === "ArrowLeft") D(e) ? C(e.key) : i = b.find((t) => t.key === e.parentKey);
70
72
  else return;
71
- t.preventDefault(), r && t.currentTarget.closest("[role=\"treegrid\"], table")?.querySelector(`[data-tree-key="${CSS.escape(r.key)}"]`)?.focus();
73
+ t.preventDefault(), i && t.currentTarget.closest("[role=\"treegrid\"], table")?.querySelector(`[data-tree-key="${CSS.escape(i.key)}"]`)?.focus();
72
74
  };
73
75
  return {
74
- rows: y,
75
- toggle: S,
76
- isExpanded: v,
77
- expand: (e) => x(e, !0),
78
- collapse: (e) => x(e, !1),
79
- expandAll: () => f(l ? /* @__PURE__ */ new Set() : new Set(b())),
80
- collapseAll: () => f(l ? new Set(b()) : /* @__PURE__ */ new Set()),
76
+ rows: b,
77
+ toggle: C,
78
+ isExpanded: y,
79
+ expand: (e) => S(e, !0),
80
+ collapse: (e) => S(e, !1),
81
+ expandAll: () => p(o ? /* @__PURE__ */ new Set() : new Set(x())),
82
+ collapseAll: () => p(o ? new Set(x()) : /* @__PURE__ */ new Set()),
81
83
  tableProps: { role: "treegrid" },
82
- rowProps: (t) => ({
83
- "aria-level": t.depth + 1,
84
- "aria-expanded": t.hasChildren ? E(t) : void 0,
85
- "aria-posinset": t.position,
86
- "aria-setsize": t.siblings,
87
- "data-depth": t.depth,
88
- "data-tree-key": t.key,
89
- tabIndex: t.key === T ? 0 : -1,
90
- onFocus: (e) => {
91
- e.target === e.currentTarget && w(t.key);
84
+ rowProps: (e) => ({
85
+ "aria-level": e.depth + 1,
86
+ "aria-expanded": e.hasChildren ? D(e) : void 0,
87
+ "aria-posinset": e.position,
88
+ "aria-setsize": e.siblings,
89
+ "data-depth": e.depth,
90
+ "data-tree-key": e.key,
91
+ tabIndex: e.key === E ? 0 : -1,
92
+ onFocus: (t) => {
93
+ t.target === t.currentTarget && T(e.key);
92
94
  },
93
- onKeyDown: (e) => D(t, e),
94
- className: e("outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring/60", p && t.parentKey === p.key && "zen__tree-row-enter", h && t.parentKey === h && "zen__tree-row-exit"),
95
- style: { "--row-h": `${u - 1}px` },
96
- onAnimationEnd: (e) => {
97
- e.animationName === "zen-row-close" && h && t.parentKey === h && _.current?.();
95
+ onKeyDown: (t) => O(e, t),
96
+ className: t("outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring/60", m && e.parentKey === m.key && "zen__tree-row-enter", g && e.parentKey === g && "zen__tree-row-exit"),
97
+ style: { "--row-h": `${d - 1}px` },
98
+ onAnimationEnd: (t) => {
99
+ t.animationName === "zen-row-close" && g && e.parentKey === g && v.current?.();
98
100
  }
99
101
  }),
100
102
  toggleProps: (e) => ({
101
- expanded: E(e),
102
- onToggle: () => S(e.key),
103
+ expanded: D(e),
104
+ onToggle: () => C(e.key),
103
105
  tabIndex: -1
104
106
  }),
105
- rowHeight: u
107
+ rowHeight: d
106
108
  };
107
109
  }
108
- function f({ row: t, tree: n, className: i, style: a, onFocus: o, onKeyDown: s, ...c }) {
109
- let u = n.rowProps(t);
110
- return /* @__PURE__ */ l(r, {
110
+ function m({ row: e, tree: n, className: r, style: i, onFocus: a, onKeyDown: s, ...c }) {
111
+ let l = n.rowProps(e);
112
+ return /* @__PURE__ */ d(o, {
111
113
  ...c,
112
- ...u,
114
+ ...l,
113
115
  onFocus: (e) => {
114
- o?.(e), u.onFocus(e);
116
+ a?.(e), l.onFocus(e);
115
117
  },
116
118
  onKeyDown: (e) => {
117
- s?.(e), e.defaultPrevented || u.onKeyDown(e);
119
+ s?.(e), e.defaultPrevented || l.onKeyDown(e);
118
120
  },
119
- className: e(u.className, i),
121
+ className: t(l.className, r),
120
122
  style: {
121
- ...u.style,
122
- ...a
123
+ ...l.style,
124
+ ...i
123
125
  }
124
126
  });
125
127
  }
126
- function p({ numeric: t, className: r, children: i, ...a }) {
127
- return /* @__PURE__ */ l(n, {
128
- numeric: t,
129
- className: e("py-0 whitespace-nowrap", r),
130
- ...a,
131
- children: /* @__PURE__ */ l("div", {
132
- className: e("zen__tree-cell flex h-[var(--row-h)] items-center", t && "justify-end"),
133
- children: i
128
+ function h({ numeric: e, className: n, children: r, ...i }) {
129
+ return /* @__PURE__ */ d(a, {
130
+ numeric: e,
131
+ className: t("py-0 whitespace-nowrap", n),
132
+ ...i,
133
+ children: /* @__PURE__ */ d("div", {
134
+ className: t("zen__tree-cell flex h-[var(--row-h)] items-center", e && "justify-end"),
135
+ children: r
134
136
  })
135
137
  });
136
138
  }
137
- function m({ row: t, tree: n, indent: r = 20, children: i, className: a }) {
138
- return /* @__PURE__ */ u("div", {
139
- className: e("flex min-w-0 flex-1 items-center gap-1", a),
140
- style: { paddingLeft: t.depth * r },
141
- children: [t.hasChildren ? /* @__PURE__ */ l(h, { ...n.toggleProps(t) }) : /* @__PURE__ */ l("span", { className: "-ml-1 w-6 shrink-0" }), i]
139
+ function g({ row: e, tree: n, indent: r = 20, children: i, className: a }) {
140
+ return /* @__PURE__ */ f("div", {
141
+ className: t("flex min-w-0 flex-1 items-center gap-1", a),
142
+ style: { paddingLeft: e.depth * r },
143
+ children: [e.hasChildren ? /* @__PURE__ */ d(_, { ...n.toggleProps(e) }) : /* @__PURE__ */ d("span", { className: "-ms-1 w-6 shrink-0" }), i]
142
144
  });
143
145
  }
144
- function h({ expanded: t, onToggle: n, className: r, ...a }) {
145
- return /* @__PURE__ */ l("button", {
146
+ function _({ expanded: n, onToggle: i, className: a, ...o }) {
147
+ let s = r();
148
+ return /* @__PURE__ */ d("button", {
146
149
  type: "button",
147
- onClick: n,
148
- "aria-label": t ? "Collapse" : "Expand",
149
- "aria-expanded": t,
150
- className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 cursor-pointer place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2", r),
151
- ...a,
152
- children: /* @__PURE__ */ l(i, { className: e("zen__tree-chevron size-4 transition-transform duration-200 ease-out", t && "rotate-90") })
150
+ onClick: i,
151
+ "aria-label": n ? s.collapse : s.expand,
152
+ "aria-expanded": n,
153
+ className: t("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground -ms-1 grid size-6 shrink-0 cursor-pointer place-items-center rounded-md outline-hidden transition-colors focus-ring", a),
154
+ ...o,
155
+ children: /* @__PURE__ */ d(e, { className: t("zen__tree-chevron size-4 transition-transform duration-200 ease-out rtl:-scale-x-100", n && "rotate-90 rtl:-rotate-90") })
153
156
  });
154
157
  }
155
158
  //#endregion
156
- export { p as TreeCell, m as TreeLabel, f as TreeRow, h as TreeToggle, d as useTree };
159
+ export { h as TreeCell, g as TreeLabel, m as TreeRow, _ as TreeToggle, p as useTree };
@@ -5,13 +5,13 @@ import { ComponentProps } from 'react';
5
5
  * the change as a fraction (0.12 for 12%); children follow it, muted, e.g.
6
6
  * "vs last month".
7
7
  */
8
- export default function Trend({ value, good, locale, format, className, children, ...rest }: TrendProps): import('react').JSX.Element;
8
+ export default function Trend({ value, good, locale: localeProp, format: formatProp, className, children, ...rest }: TrendProps): import('react').JSX.Element;
9
9
  export interface TrendProps extends ComponentProps<'span'> {
10
10
  /** The change as a fraction: 0.12 is 12% up, -0.05 is 5% down. */
11
11
  value: number;
12
12
  /** Which way is good news (default `up`); spending would be `down`. */
13
13
  good?: 'up' | 'down';
14
- /** For the default percent format. */
14
+ /** For the default percent format. Defaults to the LocaleProvider's. */
15
15
  locale?: string;
16
16
  /** How the change reads, e.g. as money instead of a percent. */
17
17
  format?: (value: number) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/trend/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC1B,KAAK,EACL,IAAW,EACX,MAAM,EACN,MAGK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,UAAU,+BAsBZ;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,MAAM,CAAC;IACtD,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACrB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/trend/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC1B,KAAK,EACL,IAAW,EACX,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,EAClB,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,UAAU,+BA+BZ;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,MAAM,CAAC;IACtD,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACrB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC"}
@@ -1,27 +1,28 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import t from "../icons/micro/arrow-trending-down.js";
4
- import n from "../icons/micro/arrow-trending-up.js";
5
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { useLocale as t } from "../locale-provider/index.js";
4
+ import n from "../icons/micro/arrow-trending-down.js";
5
+ import r from "../icons/micro/arrow-trending-up.js";
6
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
7
  //#region packages/trend/index.tsx
7
- function a({ value: a, good: o = "up", locale: s, format: c = (e) => new Intl.NumberFormat(s, {
8
- style: "percent",
9
- maximumFractionDigits: 1,
10
- signDisplay: "exceptZero"
11
- }).format(e), className: l, children: u, ...d }) {
12
- let f = a > 0 ? "up" : a < 0 ? "down" : "flat", p = f === "up" ? n : f === "down" ? t : null;
13
- return /* @__PURE__ */ i("span", {
14
- className: e("zen__trend inline-flex items-center gap-1.5 text-xs", l),
15
- ...d,
16
- children: [/* @__PURE__ */ i("span", {
17
- "data-direction": f,
18
- className: e("inline-flex items-center gap-0.5 rounded-md border px-1.5 py-0.5 font-medium whitespace-nowrap tabular-nums", f === "flat" ? "border-tint/10 bg-tint/[0.06] text-muted-foreground" : f === o ? "border-glow/30 bg-glow/10 text-primary" : "border-destructive/40 bg-destructive/10 text-destructive"),
19
- children: [p && /* @__PURE__ */ r(p, { className: "size-3.5" }), c(a)]
20
- }), u && /* @__PURE__ */ r("span", {
8
+ function o({ value: o, good: s = "up", locale: c, format: l, className: u, children: d, ...f }) {
9
+ let p = t(c), m = l ?? ((e) => new Intl.NumberFormat(p, {
10
+ style: "percent",
11
+ maximumFractionDigits: 1,
12
+ signDisplay: "exceptZero"
13
+ }).format(e)), h = o > 0 ? "up" : o < 0 ? "down" : "flat", g = h === "up" ? r : h === "down" ? n : null;
14
+ return /* @__PURE__ */ a("span", {
15
+ className: e("zen__trend inline-flex items-center gap-1.5 text-xs", u),
16
+ ...f,
17
+ children: [/* @__PURE__ */ a("span", {
18
+ "data-direction": h,
19
+ className: e("inline-flex items-center gap-0.5 rounded-md border px-1.5 py-0.5 font-medium whitespace-nowrap tabular-nums", h === "flat" ? "border-tint/10 bg-tint/[0.06] text-muted-foreground" : h === s ? "border-glow/30 bg-glow/10 text-primary" : "border-destructive/40 bg-destructive/10 text-destructive"),
20
+ children: [g && /* @__PURE__ */ i(g, { className: "size-3.5" }), m(o)]
21
+ }), d && /* @__PURE__ */ i("span", {
21
22
  className: "text-muted-foreground",
22
- children: u
23
+ children: d
23
24
  })]
24
25
  });
25
26
  }
26
27
  //#endregion
27
- export { a as default };
28
+ export { o as default };
@@ -0,0 +1,35 @@
1
+ /** A colour in OKLCH: lightness 0–1, chroma, hue in degrees, and alpha 0–1. */
2
+ export interface Oklch {
3
+ l: number;
4
+ c: number;
5
+ h: number;
6
+ alpha: number;
7
+ }
8
+ /** Hue in degrees, saturation and value 0–1, alpha 0–1. */
9
+ export interface Hsv {
10
+ h: number;
11
+ s: number;
12
+ v: number;
13
+ a: number;
14
+ }
15
+ type Rgba = [number, number, number, number];
16
+ /** "#rgb", "#rgba", "#rrggbb" or "#rrggbbaa" → sRGB and alpha, 0–1; null if it isn't one. */
17
+ export declare function parseHex(hex: string): Rgba | null;
18
+ /** sRGB and alpha, 0–1 → "#rrggbb", or "#rrggbbaa" when not opaque. */
19
+ export declare function formatHex([r, g, b, a]: readonly number[]): string;
20
+ export declare function hexToHsv(hex: string): Hsv | null;
21
+ export declare function hsvToHex({ h, s, v, a }: Hsv): string;
22
+ /** sRGB 0–1 → linear light. */
23
+ export declare const srgbToLinear: (c: number) => number;
24
+ /** Linear light → sRGB 0–1. */
25
+ export declare const linearToSrgb: (c: number) => number;
26
+ /** OKLCH → linear sRGB, clamped to gamut. */
27
+ export declare function oklchToLinear(l: number, c: number, h: number): [number, number, number];
28
+ /** A hex colour in OKLCH, e.g. to give its hue and chroma to the theme engine; null if it isn't one. */
29
+ export declare function hexToOklch(hex: string): Oklch | null;
30
+ /** OKLCH as hex; colours outside sRGB are clamped to it. */
31
+ export declare function oklchToHex({ l, c, h, alpha }: Omit<Oklch, 'alpha'> & {
32
+ alpha?: number;
33
+ }): string;
34
+ export {};
35
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../packages/utils/color.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,WAAW,KAAK;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,2DAA2D;AAC3D,MAAM,WAAW,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAED,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAI7C,6FAA6F;AAC7F,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAOjD;AAED,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAMrE;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAahD;AAED,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAMpD;AAED,+BAA+B;AAC/B,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,WAA8D,CAAC;AACrG,+BAA+B;AAC/B,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,WAAkE,CAAC;AAEzG,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAWvF;AAED,wGAAwG;AACxG,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAcpD;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAS,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEpG"}
@@ -0,0 +1,65 @@
1
+ //#region packages/utils/color.ts
2
+ var e = (e) => Math.min(1, Math.max(0, e));
3
+ function t(e) {
4
+ let t = /^#?([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.exec(e.trim());
5
+ if (!t) return null;
6
+ let n = t[1];
7
+ return n.length <= 4 && (n = n.replace(/./g, "$&$&")), n.length === 6 && (n += "ff"), [
8
+ 0,
9
+ 2,
10
+ 4,
11
+ 6
12
+ ].map((e) => parseInt(n.slice(e, e + 2), 16) / 255);
13
+ }
14
+ function n([t, n, r, i = 1]) {
15
+ let a = (t) => Math.round(e(t) * 255).toString(16).padStart(2, "0");
16
+ return `#${a(t)}${a(n)}${a(r)}${i < 1 ? a(i) : ""}`;
17
+ }
18
+ function r(e) {
19
+ let n = t(e);
20
+ if (!n) return null;
21
+ let [r, i, a, o] = n, s = Math.max(r, i, a), c = s - Math.min(r, i, a), l = 0;
22
+ return c && (l = s === r ? (i - a) / c % 6 : s === i ? (a - r) / c + 2 : (r - i) / c + 4), {
23
+ h: (l * 60 + 360) % 360,
24
+ s: s ? c / s : 0,
25
+ v: s,
26
+ a: o
27
+ };
28
+ }
29
+ function i({ h: e, s: t, v: r, a: i }) {
30
+ let a = (n) => {
31
+ let i = (n + e / 60) % 6;
32
+ return r - r * t * Math.max(0, Math.min(i, 4 - i, 1));
33
+ };
34
+ return n([
35
+ a(5),
36
+ a(3),
37
+ a(1),
38
+ i
39
+ ]);
40
+ }
41
+ var a = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, o = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
42
+ function s(t, n, r) {
43
+ let i = n * Math.cos(r * Math.PI / 180), a = n * Math.sin(r * Math.PI / 180), o = (t + .3963377774 * i + .2158037573 * a) ** 3, s = (t - .1055613458 * i - .0638541728 * a) ** 3, c = (t - .0894841775 * i - 1.291485548 * a) ** 3;
44
+ return [
45
+ e(4.0767416621 * o - 3.3077115913 * s + .2309699292 * c),
46
+ e(-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c),
47
+ e(-.0041960863 * o - .7034186147 * s + 1.707614701 * c)
48
+ ];
49
+ }
50
+ function c(e) {
51
+ let n = t(e);
52
+ if (!n) return null;
53
+ let [r, i, o] = n.slice(0, 3).map(a), s = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * o), c = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * o), l = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * o), u = .2104542553 * s + .793617785 * c - .0040720468 * l, d = 1.9779984951 * s - 2.428592205 * c + .4505937099 * l, f = .0259040371 * s + .7827717662 * c - .808675766 * l, p = Math.hypot(d, f);
54
+ return {
55
+ l: u,
56
+ c: p,
57
+ h: p < 1e-4 ? 0 : (Math.atan2(f, d) * 180 / Math.PI + 360) % 360,
58
+ alpha: n[3]
59
+ };
60
+ }
61
+ function l({ l: e, c: t, h: r, alpha: i = 1 }) {
62
+ return n([...s(e, t, r).map(o), i]);
63
+ }
64
+ //#endregion
65
+ export { n as formatHex, r as hexToHsv, c as hexToOklch, i as hsvToHex, o as linearToSrgb, l as oklchToHex, s as oklchToLinear, t as parseHex, a as srgbToLinear };
package/dist/utils/cva.js CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { cx as e } from "./cx.js";
3
2
  //#region packages/utils/cva.ts
4
3
  var t = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, n = (n, r) => (i) => {
package/dist/utils/cx.js CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { mergeClasses as e } from "./merge.js";
3
2
  //#region packages/utils/cx.ts
4
3
  var t = (...t) => e(n(t)), n = (e) => e.reduce((e, t) => t == null || t === !1 ? e : typeof t == "string" || typeof t == "number" ? e + " " + t : Array.isArray(t) ? e + " " + n(t) : typeof t == "object" ? e + " " + Object.entries(t).reduce((e, [t, n]) => n == null || n === !1 ? e : typeof n == "string" || typeof n == "number" ? e + " " + t + "-" + n : typeof n == "boolean" && n ? e + " " + t : e, "") : e, "");
@@ -70,4 +70,10 @@ export declare function weekdayNames(locale: string, style?: 'narrow' | 'short'
70
70
  export declare function weekStart(locale: string): number;
71
71
  /** "Sep 3 – 10, 2026" (or the locale's equivalent), sharing what the two dates have in common. */
72
72
  export declare function formatDateRange(start: DateString, end: DateString, locale: string, style?: Exclude<DateStyle, 'full'>): string;
73
+ /**
74
+ * Engines' ICU versions differ in thin and narrow no-break spaces (Node 24
75
+ * writes "5\u2009–\u200912 Oct", Chrome "5 – 12 Oct"). Plain spaces make text
76
+ * rendered on the server match the browser's, so hydration doesn't fail.
77
+ */
78
+ export declare const plainSpaces: (text: string) => string;
73
79
  //# sourceMappingURL=date.d.ts.map