@central-ui/react 0.1.2 → 0.3.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 (287) hide show
  1. package/LICENSE +49 -0
  2. package/dist/components/accordion/index.d.ts +4 -3
  3. package/dist/components/accordion/index.js +7 -4
  4. package/dist/components/autocomplete/index.d.ts +23 -30
  5. package/dist/components/autocomplete/index.js +81 -56
  6. package/dist/components/avatar/index.d.ts +1 -2
  7. package/dist/components/avatar/index.js +0 -1
  8. package/dist/components/badge/index.d.ts +0 -1
  9. package/dist/components/badge/index.js +2 -2
  10. package/dist/components/banner/index.d.ts +1 -1
  11. package/dist/components/banner/index.js +23 -25
  12. package/dist/components/barchart/index.d.ts +106 -0
  13. package/dist/components/barchart/index.js +122 -0
  14. package/dist/components/breadcrumb/index.d.ts +0 -1
  15. package/dist/components/breadcrumb/index.js +6 -7
  16. package/dist/components/button/index.d.ts +2 -3
  17. package/dist/components/button/index.js +11 -12
  18. package/dist/components/card/index.d.ts +0 -1
  19. package/dist/components/card/index.js +0 -1
  20. package/dist/components/carousel/index.d.ts +169 -0
  21. package/dist/components/carousel/index.js +299 -0
  22. package/dist/components/checkbox/index.d.ts +13 -11
  23. package/dist/components/checkbox/index.js +51 -31
  24. package/dist/components/chip/index.d.ts +1 -1
  25. package/dist/components/chip/index.js +2 -3
  26. package/dist/components/combobox/index.d.ts +33 -49
  27. package/dist/components/combobox/index.js +102 -70
  28. package/dist/components/datepicker/index.d.ts +18 -31
  29. package/dist/components/datepicker/index.js +81 -99
  30. package/dist/components/dialog/index.d.ts +14 -27
  31. package/dist/components/dialog/index.js +17 -18
  32. package/dist/components/divider/index.d.ts +0 -1
  33. package/dist/components/divider/index.js +0 -1
  34. package/dist/components/donutchart/index.d.ts +100 -0
  35. package/dist/components/donutchart/index.js +178 -0
  36. package/dist/components/drawer/index.d.ts +12 -21
  37. package/dist/components/drawer/index.js +34 -36
  38. package/dist/components/empty/index.d.ts +3 -3
  39. package/dist/components/empty/index.js +4 -5
  40. package/dist/components/exception/index.d.ts +86 -0
  41. package/dist/components/exception/index.js +116 -0
  42. package/dist/components/fileupload/index.d.ts +4 -9
  43. package/dist/components/fileupload/index.js +26 -38
  44. package/dist/components/form/index.d.ts +0 -1
  45. package/dist/components/form/index.js +0 -1
  46. package/dist/components/horizontalbarchart/index.d.ts +120 -0
  47. package/dist/components/horizontalbarchart/index.js +193 -0
  48. package/dist/components/input/index.d.ts +22 -22
  49. package/dist/components/input/index.js +76 -105
  50. package/dist/components/linechart/index.d.ts +114 -0
  51. package/dist/components/linechart/index.js +139 -0
  52. package/dist/components/menu/index.d.ts +9 -11
  53. package/dist/components/menu/index.js +42 -39
  54. package/dist/components/metric/index.d.ts +0 -1
  55. package/dist/components/metric/index.js +0 -1
  56. package/dist/components/numberinput/index.d.ts +14 -21
  57. package/dist/components/numberinput/index.js +40 -53
  58. package/dist/components/otpinput/index.d.ts +14 -9
  59. package/dist/components/otpinput/index.js +25 -18
  60. package/dist/components/page/index.d.ts +0 -1
  61. package/dist/components/page/index.js +1 -3
  62. package/dist/components/passwordinput/index.d.ts +14 -11
  63. package/dist/components/passwordinput/index.js +36 -45
  64. package/dist/components/popover/index.d.ts +21 -19
  65. package/dist/components/popover/index.js +34 -15
  66. package/dist/components/radio/index.d.ts +13 -9
  67. package/dist/components/radio/index.js +69 -60
  68. package/dist/components/ratinginput/index.d.ts +13 -8
  69. package/dist/components/ratinginput/index.js +37 -17
  70. package/dist/components/select/index.d.ts +30 -30
  71. package/dist/components/select/index.js +80 -41
  72. package/dist/components/skeleton/index.d.ts +0 -1
  73. package/dist/components/skeleton/index.js +0 -1
  74. package/dist/components/slider/index.d.ts +14 -9
  75. package/dist/components/slider/index.js +64 -63
  76. package/dist/components/spinner/index.d.ts +1 -2
  77. package/dist/components/spinner/index.js +2 -3
  78. package/dist/components/splitter/index.d.ts +1 -2
  79. package/dist/components/splitter/index.js +5 -6
  80. package/dist/components/stepper/index.d.ts +8 -20
  81. package/dist/components/stepper/index.js +15 -16
  82. package/dist/components/switch/index.d.ts +12 -10
  83. package/dist/components/switch/index.js +46 -30
  84. package/dist/components/table/index.d.ts +3 -3
  85. package/dist/components/table/index.js +14 -13
  86. package/dist/components/tabs/index.d.ts +0 -1
  87. package/dist/components/tabs/index.js +1 -2
  88. package/dist/components/textarea/index.d.ts +14 -11
  89. package/dist/components/textarea/index.js +37 -46
  90. package/dist/components/textlink/index.d.ts +3 -1
  91. package/dist/components/textlink/index.js +4 -1
  92. package/dist/components/toast/index.d.ts +8 -14
  93. package/dist/components/toast/index.js +48 -48
  94. package/dist/components/toggle/index.d.ts +0 -1
  95. package/dist/components/toggle/index.js +17 -24
  96. package/dist/components/tooltip/index.d.ts +11 -13
  97. package/dist/components/tooltip/index.js +12 -9
  98. package/dist/components/tour/index.d.ts +154 -0
  99. package/dist/components/tour/index.js +280 -0
  100. package/dist/index.d.ts +7 -2
  101. package/dist/index.js +7 -1
  102. package/dist/types/Icon.d.ts +0 -1
  103. package/dist/types/Icon.js +0 -1
  104. package/dist/types/Style.d.ts +0 -1
  105. package/dist/types/Style.js +0 -1
  106. package/dist/types/Validation.d.ts +12 -0
  107. package/dist/types/Validation.js +1 -0
  108. package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
  109. package/dist/utils/ArkStateToDataAttributes.js +0 -1
  110. package/dist/utils/Validation.d.ts +14 -0
  111. package/dist/utils/Validation.js +23 -0
  112. package/dist/utils/asChild.d.ts +41 -0
  113. package/dist/utils/asChild.js +15 -0
  114. package/dist/utils/icons.d.ts +24 -0
  115. package/dist/utils/icons.js +160 -0
  116. package/dist/utils/useForwardClickToInput.d.ts +0 -1
  117. package/dist/utils/useForwardClickToInput.js +0 -1
  118. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +0 -1
  119. package/dist/utils/virtualization/useVirtualizedAutocomplete.js +0 -1
  120. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +0 -1
  121. package/dist/utils/virtualization/useVirtualizedCombobox.js +0 -1
  122. package/dist/utils/virtualization/useVirtualizedTable.d.ts +0 -1
  123. package/dist/utils/virtualization/useVirtualizedTable.js +0 -1
  124. package/package.json +14 -11
  125. package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +2 -2
  126. package/src/presets/shopify-polaris/shopify-polaris-barchart.css +64 -0
  127. package/src/presets/shopify-polaris/shopify-polaris-carousel.css +62 -0
  128. package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +2 -2
  129. package/src/presets/shopify-polaris/shopify-polaris-combobox.css +2 -2
  130. package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +4 -4
  131. package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
  132. package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
  133. package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
  134. package/src/presets/shopify-polaris/shopify-polaris-exception.css +40 -0
  135. package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
  136. package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
  137. package/src/presets/shopify-polaris/shopify-polaris-input.css +2 -2
  138. package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
  139. package/src/presets/shopify-polaris/shopify-polaris-menu.css +16 -0
  140. package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +2 -2
  141. package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +2 -2
  142. package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +2 -2
  143. package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
  144. package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
  145. package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
  146. package/src/presets/shopify-polaris/shopify-polaris-select.css +2 -2
  147. package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
  148. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
  149. package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
  150. package/src/presets/shopify-polaris/shopify-polaris-textarea.css +2 -2
  151. package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
  152. package/src/presets/shopify-polaris/shopify-polaris.css +6 -0
  153. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
  154. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
  155. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-carousel.css +55 -0
  156. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
  157. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
  158. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
  159. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
  160. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
  161. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -0
  162. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-exception.css +40 -0
  163. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +1 -1
  164. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-horizontalbarchart.css +60 -0
  165. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +2 -2
  166. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-linechart.css +68 -0
  167. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +9 -0
  168. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +2 -2
  169. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +2 -2
  170. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +2 -2
  171. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +22 -0
  172. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +2 -2
  173. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +2 -2
  174. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +2 -2
  175. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +9 -0
  176. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +2 -2
  177. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +2 -2
  178. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +9 -0
  179. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +6 -0
  180. package/dist/components/accordion/index.d.ts.map +0 -1
  181. package/dist/components/accordion/index.js.map +0 -1
  182. package/dist/components/autocomplete/index.d.ts.map +0 -1
  183. package/dist/components/autocomplete/index.js.map +0 -1
  184. package/dist/components/avatar/index.d.ts.map +0 -1
  185. package/dist/components/avatar/index.js.map +0 -1
  186. package/dist/components/badge/index.d.ts.map +0 -1
  187. package/dist/components/badge/index.js.map +0 -1
  188. package/dist/components/banner/index.d.ts.map +0 -1
  189. package/dist/components/banner/index.js.map +0 -1
  190. package/dist/components/breadcrumb/index.d.ts.map +0 -1
  191. package/dist/components/breadcrumb/index.js.map +0 -1
  192. package/dist/components/button/index.d.ts.map +0 -1
  193. package/dist/components/button/index.js.map +0 -1
  194. package/dist/components/card/index.d.ts.map +0 -1
  195. package/dist/components/card/index.js.map +0 -1
  196. package/dist/components/checkbox/index.d.ts.map +0 -1
  197. package/dist/components/checkbox/index.js.map +0 -1
  198. package/dist/components/chip/index.d.ts.map +0 -1
  199. package/dist/components/chip/index.js.map +0 -1
  200. package/dist/components/combobox/index.d.ts.map +0 -1
  201. package/dist/components/combobox/index.js.map +0 -1
  202. package/dist/components/datepicker/index.d.ts.map +0 -1
  203. package/dist/components/datepicker/index.js.map +0 -1
  204. package/dist/components/dialog/index.d.ts.map +0 -1
  205. package/dist/components/dialog/index.js.map +0 -1
  206. package/dist/components/divider/index.d.ts.map +0 -1
  207. package/dist/components/divider/index.js.map +0 -1
  208. package/dist/components/drawer/index.d.ts.map +0 -1
  209. package/dist/components/drawer/index.js.map +0 -1
  210. package/dist/components/empty/index.d.ts.map +0 -1
  211. package/dist/components/empty/index.js.map +0 -1
  212. package/dist/components/fileupload/index.d.ts.map +0 -1
  213. package/dist/components/fileupload/index.js.map +0 -1
  214. package/dist/components/form/index.d.ts.map +0 -1
  215. package/dist/components/form/index.js.map +0 -1
  216. package/dist/components/input/index.d.ts.map +0 -1
  217. package/dist/components/input/index.js.map +0 -1
  218. package/dist/components/menu/index.d.ts.map +0 -1
  219. package/dist/components/menu/index.js.map +0 -1
  220. package/dist/components/metric/index.d.ts.map +0 -1
  221. package/dist/components/metric/index.js.map +0 -1
  222. package/dist/components/numberinput/index.d.ts.map +0 -1
  223. package/dist/components/numberinput/index.js.map +0 -1
  224. package/dist/components/otpinput/index.d.ts.map +0 -1
  225. package/dist/components/otpinput/index.js.map +0 -1
  226. package/dist/components/page/index.d.ts.map +0 -1
  227. package/dist/components/page/index.js.map +0 -1
  228. package/dist/components/passwordinput/index.d.ts.map +0 -1
  229. package/dist/components/passwordinput/index.js.map +0 -1
  230. package/dist/components/popover/index.d.ts.map +0 -1
  231. package/dist/components/popover/index.js.map +0 -1
  232. package/dist/components/radio/index.d.ts.map +0 -1
  233. package/dist/components/radio/index.js.map +0 -1
  234. package/dist/components/ratinginput/index.d.ts.map +0 -1
  235. package/dist/components/ratinginput/index.js.map +0 -1
  236. package/dist/components/select/index.d.ts.map +0 -1
  237. package/dist/components/select/index.js.map +0 -1
  238. package/dist/components/skeleton/index.d.ts.map +0 -1
  239. package/dist/components/skeleton/index.js.map +0 -1
  240. package/dist/components/slider/index.d.ts.map +0 -1
  241. package/dist/components/slider/index.js.map +0 -1
  242. package/dist/components/spinner/index.d.ts.map +0 -1
  243. package/dist/components/spinner/index.js.map +0 -1
  244. package/dist/components/splitter/index.d.ts.map +0 -1
  245. package/dist/components/splitter/index.js.map +0 -1
  246. package/dist/components/stepper/index.d.ts.map +0 -1
  247. package/dist/components/stepper/index.js.map +0 -1
  248. package/dist/components/switch/index.d.ts.map +0 -1
  249. package/dist/components/switch/index.js.map +0 -1
  250. package/dist/components/table/index.d.ts.map +0 -1
  251. package/dist/components/table/index.js.map +0 -1
  252. package/dist/components/tabs/index.d.ts.map +0 -1
  253. package/dist/components/tabs/index.js.map +0 -1
  254. package/dist/components/textarea/index.d.ts.map +0 -1
  255. package/dist/components/textarea/index.js.map +0 -1
  256. package/dist/components/textlink/index.d.ts.map +0 -1
  257. package/dist/components/textlink/index.js.map +0 -1
  258. package/dist/components/toast/index.d.ts.map +0 -1
  259. package/dist/components/toast/index.js.map +0 -1
  260. package/dist/components/toggle/index.d.ts.map +0 -1
  261. package/dist/components/toggle/index.js.map +0 -1
  262. package/dist/components/tooltip/index.d.ts.map +0 -1
  263. package/dist/components/tooltip/index.js.map +0 -1
  264. package/dist/index.d.ts.map +0 -1
  265. package/dist/index.js.map +0 -1
  266. package/dist/types/Icon.d.ts.map +0 -1
  267. package/dist/types/Icon.js.map +0 -1
  268. package/dist/types/Style.d.ts.map +0 -1
  269. package/dist/types/Style.js.map +0 -1
  270. package/dist/types/Tone.d.ts +0 -4
  271. package/dist/types/Tone.d.ts.map +0 -1
  272. package/dist/types/Tone.js +0 -2
  273. package/dist/types/Tone.js.map +0 -1
  274. package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
  275. package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
  276. package/dist/utils/Tone.d.ts +0 -3
  277. package/dist/utils/Tone.d.ts.map +0 -1
  278. package/dist/utils/Tone.js +0 -7
  279. package/dist/utils/Tone.js.map +0 -1
  280. package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
  281. package/dist/utils/useForwardClickToInput.js.map +0 -1
  282. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
  283. package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
  284. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
  285. package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
  286. package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
  287. package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CircleAlert, CircleCheck, Info, Text, TriangleAlert, X, } from 'lucide-react';
2
+ import { CircleAlert, CircleCheck, Info, Text, TriangleAlert, X, } from "../../utils/icons.js";
3
3
  import { cloneElement, createContext, useContext } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  const BannerContext = /* @__PURE__ */ createContext({
@@ -48,32 +48,31 @@ export function Root({ tone = 'neutral', onClose, children, }) {
48
48
  return (_jsx(BannerContext.Provider, { value: { tone, onClose }, children: children }));
49
49
  }
50
50
  export function Surface({ disableStyle, className, ...props }) {
51
- const { tone } = useContext(BannerContext);
52
- return (_jsx("div", { ...props, "data-tone": tone, "data-component": "banner-surface", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
51
+ const context = useContext(BannerContext);
52
+ return (_jsx("div", { ...props, "data-tone": context.tone, "data-component": "banner-surface", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
53
53
  }
54
54
  export function Header({ disableStyle, className, ...props }) {
55
- const { tone } = useContext(BannerContext);
56
- return (_jsx("div", { ...props, "data-tone": tone, "data-component": "banner-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
55
+ const context = useContext(BannerContext);
56
+ return (_jsx("div", { ...props, "data-tone": context.tone, "data-component": "banner-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
57
57
  }
58
58
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
59
59
  export function Icon({ disableStyle, children, className, ...props }) {
60
- const { tone } = useContext(BannerContext);
60
+ const context = useContext(BannerContext);
61
61
  const icon = children ??
62
62
  (() => {
63
- if (tone === 'danger')
63
+ if (context.tone === 'danger')
64
64
  return _jsx(CircleAlert, {});
65
- if (tone === 'informative')
65
+ if (context.tone === 'informative')
66
66
  return _jsx(Info, {});
67
- if (tone === 'success')
67
+ if (context.tone === 'success')
68
68
  return _jsx(CircleCheck, {});
69
- if (tone === 'caution')
69
+ if (context.tone === 'caution')
70
70
  return _jsx(TriangleAlert, {});
71
71
  return _jsx(Text, {});
72
72
  })();
73
73
  return cloneElement(icon, {
74
- ...icon.props,
75
74
  ...props,
76
- 'data-tone': tone,
75
+ 'data-tone': context.tone,
77
76
  ...{
78
77
  'data-component': 'banner-icon',
79
78
  'data-style-disabled': disableStyle ? '' : undefined,
@@ -82,24 +81,24 @@ export function Icon({ disableStyle, children, className, ...props }) {
82
81
  });
83
82
  }
84
83
  export function Title({ disableStyle, className, ...props }) {
85
- const { tone } = useContext(BannerContext);
86
- return (_jsx("h2", { ...props, "data-tone": tone, "data-component": "banner-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
84
+ const context = useContext(BannerContext);
85
+ return (_jsx("h2", { ...props, "data-tone": context.tone, "data-component": "banner-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
87
86
  }
87
+ /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Dismiss". */
88
88
  export function CloseButton({ disableStyle, type = 'button', className, onClick, ...props }) {
89
- const { tone, onClose } = useContext(BannerContext);
90
- return (_jsx("button", { ...props, type: type, "data-tone": tone, onClick: (event) => {
89
+ const context = useContext(BannerContext);
90
+ return (_jsx("button", { ...props, type: type, "data-tone": context.tone, onClick: (event) => {
91
91
  onClick?.(event);
92
92
  if (!event.defaultPrevented)
93
- onClose?.();
93
+ context.onClose?.();
94
94
  }, "data-component": "banner-closebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
95
95
  }
96
96
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
97
97
  export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), className, ...props }) {
98
- const { tone } = useContext(BannerContext);
98
+ const context = useContext(BannerContext);
99
99
  return cloneElement(children, {
100
- ...children.props,
101
100
  ...props,
102
- 'data-tone': tone,
101
+ 'data-tone': context.tone,
103
102
  ...{
104
103
  'data-component': 'banner-closebuttonicon',
105
104
  'data-style-disabled': disableStyle ? '' : undefined,
@@ -109,11 +108,10 @@ export function CloseButtonIcon({ disableStyle, children = _jsx(X, {}), classNam
109
108
  });
110
109
  }
111
110
  export function Body({ disableStyle, className, ...props }) {
112
- const { tone } = useContext(BannerContext);
113
- return (_jsx("div", { ...props, "data-tone": tone, "data-component": "banner-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
111
+ const context = useContext(BannerContext);
112
+ return (_jsx("div", { ...props, "data-tone": context.tone, "data-component": "banner-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
114
113
  }
115
114
  export function Description({ disableStyle, className, ...props }) {
116
- const { tone } = useContext(BannerContext);
117
- return (_jsx("div", { ...props, "data-tone": tone, "data-component": "banner-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
115
+ const context = useContext(BannerContext);
116
+ return (_jsx("div", { ...props, "data-tone": context.tone, "data-component": "banner-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
118
117
  }
119
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,106 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import { BarChart as RechartsBarChart } from 'recharts';
3
+ import type { BarProps as RechartsBarProps, TooltipProps as RechartsTooltipProps, XAxisProps as RechartsXAxisProps, YAxisProps as RechartsYAxisProps } from 'recharts';
4
+ import type { StyleProps } from '../../types/Style.ts';
5
+ /** Every record needs a unique `label` (the category) and a numeric `value` (the bar height). Extra fields are kept for the tooltip. */
6
+ type Datum = {
7
+ label: string;
8
+ value: number;
9
+ };
10
+ export type RootProps<Data extends Datum = Datum> = Pick<ComponentProps<typeof RechartsBarChart>, 'accessibilityLayer' | 'desc'> & {
11
+ /** Unique labels are equally spaced categories, including when they contain dates. */
12
+ data: readonly Data[];
13
+ 'aria-label': string;
14
+ children: ReactNode;
15
+ /**
16
+ * Converts a record's `label` into display text.
17
+ * Used by the X axis ticks and the tooltip label, so both always read the same.
18
+ * Use it for dates (e.g. `'2026-10-12'` → `'October 12, 2026'`) or to shorten long categories.
19
+ * @default (label) => label
20
+ */
21
+ labelToString?: (label: string) => string;
22
+ /**
23
+ * Converts a record's `value` into display text.
24
+ * Used by the Y axis ticks and the tooltip value, so both always read the same.
25
+ * Use it for currency, percentages, or units (e.g. `1240` → `'$1,240'`).
26
+ * @default (value) => value.toLocaleString()
27
+ */
28
+ valueToString?: (value: number) => string;
29
+ /**
30
+ * Whether the Y axis may place ticks at fractional values.
31
+ * Keep it `false` for counts (orders, visitors) so the axis never shows `0.5 orders`.
32
+ * Set it to `true` for continuous measures where fractions are meaningful, such as small currency amounts or ratings.
33
+ * @default false
34
+ */
35
+ allowDecimals?: boolean;
36
+ };
37
+ /** Provides the chart data, formatting, and accessibility settings to its parts. Renders no element. */
38
+ export declare function Root<Data extends Datum>({ children, labelToString, valueToString, allowDecimals, ...chart }: RootProps<Data>): import("react").JSX.Element;
39
+ export type ContainerProps = Pick<ComponentProps<typeof RechartsBarChart>, 'children' | 'height' | 'className' | 'style' | 'id' | 'margin' | 'ref' | 'tabIndex'> & {
40
+ /**
41
+ * The vertical line that follows the pointer across the chart.
42
+ * Shown by default, with or without a Tooltip, so readers can line a point up with its axis label.
43
+ * Pass `false` for static charts where hover feedback adds noise. Style it through `data-component="barchart-hoverguide"`.
44
+ * @default true
45
+ */
46
+ hoverGuide?: LineSwitch;
47
+ };
48
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
49
+ export declare function Container({ height, className, style, children, hoverGuide, ...props }: ContainerProps): import("react").JSX.Element;
50
+ /** On/off only: style it through its data-component in a preset, so each export keeps one className. */
51
+ type LineSwitch = boolean;
52
+ export type XAxisProps = Pick<RechartsXAxisProps, 'hide' | 'tickSize'> & {
53
+ /** Classes for the tick labels, e.g. `fill-neutral-500`. Keep the font size at 12px: Recharts measures labels at that size to skip overlapping ones. */
54
+ className?: string;
55
+ /** Space between the labels and the plot area, in pixels. */
56
+ labelGap?: number;
57
+ /** The line along the axis. Hidden by default. */
58
+ axisLine?: LineSwitch;
59
+ /** The small marks at each tick. Hidden by default. */
60
+ tickLine?: LineSwitch;
61
+ };
62
+ export declare function XAxis({ className, labelGap, axisLine, tickLine, ...props }: XAxisProps): import("react").JSX.Element;
63
+ export type YAxisProps = Pick<RechartsYAxisProps, 'hide' | 'tickSize' | 'width'> & {
64
+ /** Classes for the tick labels, e.g. `fill-neutral-500`. Keep the font size at 12px: Recharts measures labels at that size to skip overlapping ones. */
65
+ className?: string;
66
+ /** Space between the labels and the plot area, in pixels. */
67
+ labelGap?: number;
68
+ /** The line along the axis. Hidden by default. */
69
+ axisLine?: LineSwitch;
70
+ /** The small marks at each tick. Hidden by default. */
71
+ tickLine?: LineSwitch;
72
+ };
73
+ export declare function YAxis({ className, labelGap, axisLine, tickLine, ...props }: YAxisProps): import("react").JSX.Element;
74
+ export type GridProps = {
75
+ /** Classes for every grid line, e.g. `stroke-neutral-200 [stroke-dasharray:4_4]`. */
76
+ className?: string;
77
+ };
78
+ /** Horizontal lines only, one per Y value tick. */
79
+ export declare function Grid({ className }: GridProps): import("react").JSX.Element;
80
+ export type BarsProps = Pick<RechartsBarProps, 'radius' | 'hide' | 'name'> & {
81
+ /**
82
+ * Classes for every bar. Colors come only from here or from a preset; there is no built-in color.
83
+ * Target hover with `data-active:` (e.g. `fill-sky-500 data-active:opacity-80`).
84
+ */
85
+ className?: string;
86
+ /**
87
+ * Whether the bar under the pointer gets `data-active`. Pass false to turn the hover state off.
88
+ * @default true
89
+ */
90
+ activeBar?: boolean;
91
+ };
92
+ export declare function Bars({ className, activeBar, ...props }: BarsProps): import("react").JSX.Element;
93
+ export type TooltipProps<Data extends Datum = Datum> = Pick<RechartsTooltipProps<number, string>, 'offset' | 'allowEscapeViewBox' | 'portal'> & {
94
+ /** Receives the hovered record and returns the popup. */
95
+ children: (datum: Data) => ReactNode;
96
+ };
97
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
98
+ export declare function Tooltip<Data extends Datum = Datum>({ children, offset, allowEscapeViewBox, portal, }: TooltipProps<Data>): null;
99
+ export declare function TooltipPopup({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
100
+ export declare function TooltipTitle({ disableStyle, className, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
101
+ /** Shows the hovered record's label, formatted by `labelToString` on Root. */
102
+ export declare function TooltipLabel({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
103
+ /** Shows the hovered record's value, formatted by `valueToString` on Root. */
104
+ export declare function TooltipValue({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
105
+ export declare function TooltipColorIndicator({ disableStyle, className, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
106
+ export {};
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext, useLayoutEffect, useState } from 'react';
3
+ import { twMerge } from 'tailwind-merge';
4
+ import { Bar as RechartsBar, BarChart as RechartsBarChart, CartesianGrid as RechartsGrid, Rectangle as RechartsRectangle, Tooltip as RechartsTooltip, XAxis as RechartsXAxis, YAxis as RechartsYAxis, } from 'recharts';
5
+ const ChartContext = /* @__PURE__ */ createContext(null);
6
+ /** Provides the chart data, formatting, and accessibility settings to its parts. Renders no element. */
7
+ export function Root({ children, labelToString = (label) => label, valueToString = (value) => value.toLocaleString(), allowDecimals = false, ...chart }) {
8
+ return (_jsx(ChartContext.Provider, { value: { ...chart, labelToString, valueToString, allowDecimals }, children: children }));
9
+ }
10
+ function useChart(part) {
11
+ const chart = useContext(ChartContext);
12
+ if (!chart)
13
+ throw new Error(`BarChart.${part} must be inside BarChart.Root`);
14
+ return chart;
15
+ }
16
+ /** Lets a Tooltip part hand its content to the Container, which owns the single Recharts tooltip. */
17
+ const TooltipSlotContext = /* @__PURE__ */ createContext(null);
18
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
19
+ export function Container({ height = 300, className, style, children, hoverGuide = true, ...props }) {
20
+ const chart = useChart('Container');
21
+ const [tooltip, setTooltip] = useState(null);
22
+ return (_jsxs(RechartsBarChart, { margin: { top: 12, right: 12, bottom: 0, left: 0 }, ...props, data: chart.data, accessibilityLayer: chart.accessibilityLayer, desc: chart.desc, title: chart['aria-label'], className: twMerge('min-w-0 w-full', className), style: { ...style, background: 'transparent' }, height: height, width: "100%", responsive: true, layout: "horizontal",
23
+ // Bars nearly touch: each fills 90% of its slot.
24
+ barCategoryGap: "15%", children: [_jsx(TooltipSlotContext.Provider, { value: setTooltip, children: children }), _jsx(RechartsTooltip, { offset: 12, ...tooltip?.props,
25
+ // Native popup slide, timed to match the hover guide's transition.
26
+ animationDuration: 200, animationEasing: "ease-out", shared: true, cursor: hoverGuide && _jsx(HoverGuide, {}), content: (state) => {
27
+ if (!tooltip || !state.active || !state.payload.length)
28
+ return null;
29
+ // Recharts types the payload as unknown; payload[0] is always the hovered record.
30
+ const datum = state.payload[0].payload;
31
+ return (_jsx(TooltipContext.Provider, { value: datum, children: tooltip.render(datum) }));
32
+ } })] }));
33
+ }
34
+ const lineProps = (line, part) =>
35
+ // Recharts forwards data attributes at runtime; its types omit them.
36
+ (line && { 'data-component': part });
37
+ export function XAxis({ className, labelGap = 8, axisLine = false, tickLine = false, ...props }) {
38
+ const chart = useChart('XAxis');
39
+ return (_jsx(RechartsXAxis, { height: "auto", ...props, axisLine: lineProps(axisLine, 'barchart-xaxis-line'), tickLine: lineProps(tickLine, 'barchart-xaxis-tickline'), tick: {
40
+ className,
41
+ 'data-component': 'barchart-xaxis-ticklabel',
42
+ }, tickMargin: labelGap, tickFormatter: chart.labelToString,
43
+ // Recharts measures labels at this size when it hides overlapping ones.
44
+ fontSize: 12, dataKey: "label", type: "category", label: false, angle: 0,
45
+ // Drops labels at a steady step when they would overlap, so the remaining ones stay evenly spaced.
46
+ interval: "equidistantPreserveStart", minTickGap: 8 }));
47
+ }
48
+ export function YAxis({ className, labelGap = 8, axisLine = false, tickLine = false, ...props }) {
49
+ const chart = useChart('YAxis');
50
+ return (_jsx(RechartsYAxis, { width: "auto", ...props, axisLine: lineProps(axisLine, 'barchart-yaxis-line'), tickLine: lineProps(tickLine, 'barchart-yaxis-tickline'), tick: {
51
+ className,
52
+ 'data-component': 'barchart-yaxis-ticklabel',
53
+ }, tickMargin: labelGap, tickFormatter: chart.valueToString, allowDecimals: chart.allowDecimals, fontSize: 12, type: "number", label: false, angle: 0,
54
+ // Always include zero so bars have a baseline, and never collapse the range when every value is 0.
55
+ domain: ([minimum, maximum]) => [
56
+ Math.min(0, minimum),
57
+ Math.max(Math.min(0, minimum) + 1, maximum, 0),
58
+ ], interval: "preserveStartEnd", minTickGap: 8 }));
59
+ }
60
+ /** Horizontal lines only, one per Y value tick. */
61
+ export function Grid({ className }) {
62
+ return (_jsx(RechartsGrid
63
+ // Recharts' native line slot: each line gets the class and a data-component hook.
64
+ , {
65
+ // Recharts' native line slot: each line gets the class and a data-component hook.
66
+ horizontal: { className, 'data-component': 'barchart-gridline' }, vertical: false, fill: "none" }));
67
+ }
68
+ export function Bars({ className, activeBar = true, ...props }) {
69
+ return (_jsx(RechartsBar, { ...props, activeBar: activeBar,
70
+ // Recharts' native shape slot renders each bar ourselves, so className and data attributes land on the drawn element.
71
+ shape: (bar) => (_jsx(RechartsRectangle, { ...bar, className: className, "data-component": "barchart-bar", "data-index": bar.index, "data-active": bar.isActive ? '' : undefined })), dataKey: "value",
72
+ // Zero days still get a thin, hoverable sliver on the baseline.
73
+ minPointSize: 2, isAnimationActive: false }));
74
+ }
75
+ const TooltipContext = /* @__PURE__ */ createContext(null);
76
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
77
+ export function Tooltip({ children, offset, allowEscapeViewBox, portal, }) {
78
+ const setTooltip = useContext(TooltipSlotContext);
79
+ if (!setTooltip)
80
+ throw new Error('BarChart.Tooltip must be inside BarChart.Container');
81
+ useLayoutEffect(() => {
82
+ setTooltip({
83
+ render: children,
84
+ props: { offset, allowEscapeViewBox, portal },
85
+ });
86
+ return () => setTooltip(null);
87
+ }, [setTooltip, children, offset, allowEscapeViewBox, portal]);
88
+ return null;
89
+ }
90
+ /** Recharts gives the cursor the bar's whole rectangle; only its center line is drawn. */
91
+ function HoverGuide({ x = 0, y = 0, width = 0, height = 0, }) {
92
+ return (_jsx("line", { "data-component": "barchart-hoverguide",
93
+ // Draw at x=0 and move with a transform, so CSS can slide it between points (Recharts' cursor has no animation of its own).
94
+ x1: 0, x2: 0, y1: y, y2: y + height,
95
+ // The slide between points is built in.
96
+ className: "transition-transform duration-200 ease-out motion-reduce:transition-none", style: { transform: `translateX(${x + width / 2}px)` }, pointerEvents: "none" }));
97
+ }
98
+ export function TooltipPopup({ disableStyle, className, ...props }) {
99
+ return (_jsx("div", { ...props, "data-component": "barchart-tooltip", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
100
+ }
101
+ export function TooltipTitle({ disableStyle, className, ...props }) {
102
+ return (_jsx("p", { ...props, "data-component": "barchart-tooltiptitle", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
103
+ }
104
+ /** Shows the hovered record's label, formatted by `labelToString` on Root. */
105
+ export function TooltipLabel({ disableStyle, className, ...props }) {
106
+ const chart = useChart('TooltipLabel');
107
+ const datum = useContext(TooltipContext);
108
+ if (!datum)
109
+ throw new Error('BarChart.TooltipLabel must be inside BarChart.Tooltip');
110
+ return (_jsx("p", { ...props, "data-component": "barchart-tooltiplabel", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.labelToString(datum.label) }));
111
+ }
112
+ /** Shows the hovered record's value, formatted by `valueToString` on Root. */
113
+ export function TooltipValue({ disableStyle, className, ...props }) {
114
+ const chart = useChart('TooltipValue');
115
+ const datum = useContext(TooltipContext);
116
+ if (!datum)
117
+ throw new Error('BarChart.TooltipValue must be inside BarChart.Tooltip');
118
+ return (_jsx("p", { ...props, "data-component": "barchart-tooltipvalue", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.valueToString(datum.value) }));
119
+ }
120
+ export function TooltipColorIndicator({ disableStyle, className, ...props }) {
121
+ return (_jsx("span", { "aria-hidden": "true", ...props, "data-component": "barchart-tooltipcolorindicator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
122
+ }
@@ -28,4 +28,3 @@ export declare function Item({ disableStyle, value, type, className, ...props }:
28
28
  export declare function Separator({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
29
29
  children?: ReactElement<ComponentProps<'svg'>>;
30
30
  }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
31
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ChevronRight } from 'lucide-react';
2
+ import { ChevronRight } from "../../utils/icons.js";
3
3
  import { cloneElement, createContext, useContext } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
- const context = /* @__PURE__ */ createContext('');
5
+ // Sharing the current location's value, so each Item knows whether it's the active one
6
+ const ActiveValueContext = /* @__PURE__ */ createContext('');
6
7
  /**
7
8
  * Set active_value on the default export to match the current Item value. Use Item for each location and Separator between locations; supply actual navigation behavior where needed.
8
9
  *
@@ -20,16 +21,15 @@ const context = /* @__PURE__ */ createContext('');
20
21
  * }
21
22
  */
22
23
  export default function BreadCrumb({ disableStyle, active_value, className, children, ...props }) {
23
- return (_jsx("div", { ...props, "data-component": "breadcrumb-breadcrumb", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsx(context.Provider, { value: active_value, children: children }) }));
24
+ return (_jsx("div", { ...props, "data-component": "breadcrumb-breadcrumb", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsx(ActiveValueContext.Provider, { value: active_value, children: children }) }));
24
25
  }
25
26
  export function Item({ disableStyle, value, type = 'button', className, ...props }) {
26
- const active_value = useContext(context);
27
- return (_jsx("button", { ...props, type: type, "data-active": active_value === value || undefined, "data-component": "breadcrumb-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
27
+ const activeValue = useContext(ActiveValueContext);
28
+ return (_jsx("button", { ...props, type: type, "data-active": activeValue === value || undefined, "data-component": "breadcrumb-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
28
29
  }
29
30
  /** Omit children to use the supplied separator icon. Override only when another separator is needed. */
30
31
  export function Separator({ disableStyle, children = _jsx(ChevronRight, {}), className, ...props }) {
31
32
  return cloneElement(children, {
32
- ...children.props,
33
33
  ...props,
34
34
  ...{
35
35
  'data-component': 'breadcrumb-separator',
@@ -39,4 +39,3 @@ export function Separator({ disableStyle, children = _jsx(ChevronRight, {}), cla
39
39
  strokeWidth: props.strokeWidth ?? children.props.strokeWidth ?? 2.5,
40
40
  });
41
41
  }
42
- //# sourceMappingURL=index.js.map
@@ -32,7 +32,7 @@ export type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'variant
32
32
  * Saving
33
33
  * </Button.default>
34
34
  */
35
- export default function Button({ disableStyle, variant, tone, size, className, children, ...props }: ButtonProps & StyleProps): import("react").JSX.Element;
35
+ export default function Button({ disableStyle, variant, tone, size, className, children, ...props }: ButtonProps): import("react").JSX.Element;
36
36
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
37
37
  export declare function Icon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
38
38
  /** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
@@ -43,6 +43,5 @@ export declare function Icon({ disableStyle, children, className, ...props }: (O
43
43
  'data-tone'?: string;
44
44
  }, string | import("react").JSXElementConstructor<any>>;
45
45
  /** Built-in icon; no children needed. Use it inside its matching control. */
46
- export declare function LoadingIcon({ disableStyle, className, ...props }: SVGIconProps & StyleProps): import("react").JSX.Element;
46
+ export declare function LoadingIcon({ disableStyle, className, strokeWidth, ...props }: SVGIconProps & StyleProps): import("react").JSX.Element;
47
47
  export declare function List({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
48
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { LoaderCircle } from 'lucide-react';
2
+ import { LoaderCircle } from "../../utils/icons.js";
3
3
  import { cloneElement, createContext, useContext } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
- const context = /* @__PURE__ */ createContext({
5
+ // Sharing the button's look with its icons, so they match its size, variant and tone
6
+ const ButtonContext = /* @__PURE__ */ createContext({
6
7
  size: 'medium',
7
8
  variant: 'primary',
8
9
  tone: 'neutral',
@@ -31,17 +32,16 @@ const context = /* @__PURE__ */ createContext({
31
32
  * </Button.default>
32
33
  */
33
34
  export default function Button({ disableStyle, variant, tone = 'neutral', size = 'medium', className, children, ...props }) {
34
- return (_jsx("button", { ...props, "data-variant": variant, "data-tone": tone, "data-size": size, "data-component": "button-button", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsx(context.Provider, { value: { size, variant, tone }, children: children }) }));
35
+ return (_jsx("button", { ...props, "data-variant": variant, "data-tone": tone, "data-size": size, "data-component": "button-button", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: _jsx(ButtonContext.Provider, { value: { size, variant, tone }, children: children }) }));
35
36
  }
36
37
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
37
38
  export function Icon({ disableStyle, children, className, ...props }) {
38
- const { size, variant, tone } = useContext(context);
39
+ const context = useContext(ButtonContext);
39
40
  return cloneElement(children, {
40
- ...children.props,
41
41
  ...props,
42
- 'data-size': size,
43
- 'data-variant': variant,
44
- 'data-tone': tone,
42
+ 'data-size': context.size,
43
+ 'data-variant': context.variant,
44
+ 'data-tone': context.tone,
45
45
  ...{
46
46
  'data-component': 'button-icon',
47
47
  'data-style-disabled': disableStyle ? '' : undefined,
@@ -50,11 +50,10 @@ export function Icon({ disableStyle, children, className, ...props }) {
50
50
  });
51
51
  }
52
52
  /** Built-in icon; no children needed. Use it inside its matching control. */
53
- export function LoadingIcon({ disableStyle, className, ...props }) {
54
- const { size, variant, tone } = useContext(context);
55
- return (_jsx(LoaderCircle, { "data-component": "button-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className, strokeWidth: undefined, ...props, "data-size": size, "data-variant": variant, "data-tone": tone }));
53
+ export function LoadingIcon({ disableStyle, className, strokeWidth = 2, ...props }) {
54
+ const context = useContext(ButtonContext);
55
+ return (_jsx(LoaderCircle, { "data-component": "button-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className, strokeWidth: strokeWidth, ...props, "data-size": context.size, "data-variant": context.variant, "data-tone": context.tone }));
56
56
  }
57
57
  export function List({ disableStyle, className, ...props }) {
58
58
  return (_jsx("div", { ...props, "data-component": "button-list", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
59
59
  }
60
- //# sourceMappingURL=index.js.map
@@ -31,4 +31,3 @@ export declare function Title({ disableStyle, className, ...props }: HTMLAttribu
31
31
  export declare function Description({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
32
32
  export declare function Body({ disableStyle, className, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
33
33
  export declare function Footer({ disableStyle, className, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
34
- //# sourceMappingURL=index.d.ts.map
@@ -42,4 +42,3 @@ export function Body({ disableStyle, className, ...props }) {
42
42
  export function Footer({ disableStyle, className, ...props }) {
43
43
  return (_jsx("div", { "data-component": "card-footer", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
44
44
  }
45
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,169 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import type { SVGIconProps } from '../../types/Icon.ts';
3
+ import type { AsChildProps } from '../../utils/asChild.ts';
4
+ import type { AutoplayOptionsType } from 'embla-carousel-autoplay';
5
+ import type { ComponentProps, ReactElement, ReactNode } from 'react';
6
+ type IconProps = Omit<SVGIconProps, 'strokeWidth'> & {
7
+ /** @default 1.5 */
8
+ strokeWidth?: SVGIconProps['strokeWidth'];
9
+ };
10
+ type Orientation = 'horizontal' | 'vertical';
11
+ export type RootProps = {
12
+ /** The carousel parts, like SlidesList, the buttons and IndicatorList. */
13
+ children: ReactNode;
14
+ /**
15
+ * The direction slides move in. A vertical carousel needs a height on SlidesList.
16
+ * @default 'horizontal'
17
+ */
18
+ orientation?: Orientation;
19
+ /**
20
+ * Whether the last slide leads back to the first, and the first back to the last.
21
+ * @default false
22
+ */
23
+ loop?: boolean;
24
+ /**
25
+ * Where the selected slide sits inside SlidesList, when slides are narrower than it.
26
+ * @default 'center'
27
+ */
28
+ align?: 'start' | 'center' | 'end';
29
+ /**
30
+ * How many slides one Previous/Next press moves. 'auto' moves by as many slides as are fully visible.
31
+ * @default 1
32
+ */
33
+ slidesToScroll?: number | 'auto';
34
+ /**
35
+ * Whether a drag glides freely with momentum instead of stopping on a slide.
36
+ * @default false
37
+ */
38
+ dragFree?: boolean;
39
+ /**
40
+ * Space between slides, as a number of pixels or any CSS length. Size slides with a className on Slide, like `basis-1/3`; the gap is already subtracted from it.
41
+ * @default 0
42
+ */
43
+ gap?: number | string;
44
+ /**
45
+ * Turns off dragging and every button.
46
+ * @default false
47
+ */
48
+ disabled?: boolean;
49
+ /**
50
+ * Moves to the next slide on its own. Pass true for the defaults, or an object to change them:
51
+ * - delay: milliseconds between slides (default 4000)
52
+ * - jump: jump instead of animating (default false)
53
+ * - playOnInit: start playing as soon as the carousel mounts (default true)
54
+ * - stopOnInteraction: whether a drag, hover or focus stops it for good; set false to resume once the user lets go, moves the mouse away, or moves focus out (default true)
55
+ * - stopOnMouseEnter: stop while the mouse is over SlidesList; it resumes on mouse leave only with stopOnInteraction false (default false)
56
+ * - stopOnFocusIn: stop when focus moves inside SlidesList; it resumes on focus out only with stopOnInteraction false (default true)
57
+ * - stopOnLastSnap: stop on the last slide (default false)
58
+ * @default false
59
+ */
60
+ autoplay?: boolean | Omit<AutoplayOptionsType, 'active' | 'breakpoints' | 'rootNode'>;
61
+ /** The selected slide's position, from 0. Use with onIndexChange to control it yourself. */
62
+ index?: number;
63
+ /**
64
+ * The slide the carousel starts on, when `index` isn't controlled.
65
+ * @default 0
66
+ */
67
+ defaultIndex?: number;
68
+ /** Called with the new position whenever another slide gets selected, by a drag, a button, or autoplay. */
69
+ onIndexChange?: (index: number) => void;
70
+ };
71
+ /**
72
+ * A row of slides users swipe through, built on Embla Carousel. Root holds the carousel's state and renders no element;
73
+ * SlidesList is the visible window and Slide is one item, written by hand so each can hold different content.
74
+ * Previous/Next and Indicator buttons work on their own: no click handlers needed.
75
+ * Every part carries data-orientation, data-disabled, and data-playing (while autoplay runs), so any part can be styled by the carousel's state.
76
+ *
77
+ * @example Complete composition
78
+ * import { Carousel } from '@central-ui/react'
79
+ *
80
+ * function Example() {
81
+ * return (
82
+ * <Carousel.Root loop>
83
+ * <Carousel.SlidesList>
84
+ * {products.map((product) => (
85
+ * <Carousel.Slide key={product.id}>
86
+ * <img src={product.image} alt={product.title} />
87
+ * </Carousel.Slide>
88
+ * ))}
89
+ * </Carousel.SlidesList>
90
+ * <Carousel.PreviousButton aria-label="Previous slide">
91
+ * <Carousel.PreviousButtonIcon />
92
+ * </Carousel.PreviousButton>
93
+ * <Carousel.NextButton aria-label="Next slide">
94
+ * <Carousel.NextButtonIcon />
95
+ * </Carousel.NextButton>
96
+ * <Carousel.IndicatorList>
97
+ * {(index) => <Carousel.IndicatorButton index={index} />}
98
+ * </Carousel.IndicatorList>
99
+ * </Carousel.Root>
100
+ * )
101
+ * }
102
+ *
103
+ * @example Several slides at once
104
+ * // Size slides with Tailwind (responsive classes work); gap is subtracted from that size.
105
+ * ;<Carousel.Root gap={12} align="start" slidesToScroll="auto">
106
+ * <Carousel.SlidesList>
107
+ * <Carousel.Slide className="basis-full md:basis-1/3">…</Carousel.Slide>
108
+ * </Carousel.SlidesList>
109
+ * </Carousel.Root>
110
+ *
111
+ * @example Autoplay, pausing while hovered and resuming on mouse leave
112
+ * ;<Carousel.Root loop autoplay={{ delay: 5000, stopOnMouseEnter: true, stopOnInteraction: false }}>
113
+ *
114
+ * @example Controlled position
115
+ * const [index, setIndex] = useState(0)
116
+ * ;<Carousel.Root index={index} onIndexChange={setIndex}>
117
+ */
118
+ export declare function Root({ orientation, loop, align, slidesToScroll, dragFree, gap, disabled, autoplay, index, defaultIndex, onIndexChange, children, }: RootProps): import("react").JSX.Element;
119
+ /** The visible window the slides move inside, announced to screen readers as the carousel. Style it freely (background, border, radius); a vertical carousel needs a height here. Put only Slides inside. */
120
+ export declare const SlidesList: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
121
+ /**
122
+ * One slide; each can hold different content. Size it with a className, like `basis-1/3`; it fills SlidesList by default.
123
+ * Its padding makes the gap between slides, so put backgrounds, borders and radius on its content, not on the Slide itself.
124
+ */
125
+ export declare const Slide: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
126
+ type ButtonPartProps = ComponentProps<'button'> & AsChildProps & StyleProps;
127
+ /** Moves to the previous slide; no click handler needed. Disabled when there's no slide before (never with loop). Supply its content, normally PreviousButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
128
+ export declare const PreviousButton: import("react").ForwardRefExoticComponent<Omit<ButtonPartProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
129
+ /** Moves to the next slide; no click handler needed. Disabled when there's no slide after (never with loop). Supply its content, normally NextButtonIcon, and an accessible label. Pass asChild to give this behavior to your own button instead. */
130
+ export declare const NextButton: import("react").ForwardRefExoticComponent<Omit<ButtonPartProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
131
+ /**
132
+ * Renders one IndicatorButton per position through its children function, which receives that position's index.
133
+ * The count comes from the carousel itself: with several slides per view, it counts positions, not slides.
134
+ *
135
+ * @example Dots
136
+ * ;<Carousel.IndicatorList>
137
+ * {(index) => <Carousel.IndicatorButton index={index} />}
138
+ * </Carousel.IndicatorList>
139
+ */
140
+ export declare const IndicatorList: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & StyleProps & {
141
+ /** Called once per position with its index; return an IndicatorButton. */
142
+ children: (index: number) => ReactNode;
143
+ }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
144
+ /**
145
+ * Moves to its position when clicked, and carries data-selected while that position is shown. Shows as a dot when empty.
146
+ * Pass asChild to give this behavior to your own button instead.
147
+ *
148
+ * @example Thumbnails instead of dots
149
+ * ;<Carousel.IndicatorList>
150
+ * {(index) => (
151
+ * <Carousel.IndicatorButton index={index}>
152
+ * <img src={images[index].thumbnail} alt="" />
153
+ * </Carousel.IndicatorButton>
154
+ * )}
155
+ * </Carousel.IndicatorList>
156
+ */
157
+ export declare const IndicatorButton: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & AsChildProps & StyleProps & {
158
+ /** The position this button moves to, from IndicatorList's children function. */
159
+ index: number;
160
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
161
+ type BuiltInIconProps = Omit<IconProps, 'children'> & StyleProps & {
162
+ /** Omit for the supplied default icon; pass a child icon only to replace it. */
163
+ children?: ReactElement<SVGIconProps>;
164
+ };
165
+ /** Built-in decorative previous icon. Place inside PreviousButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
166
+ export declare const PreviousButtonIcon: import("react").ForwardRefExoticComponent<Omit<BuiltInIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
167
+ /** Built-in decorative next icon. Place inside NextButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
168
+ export declare const NextButtonIcon: import("react").ForwardRefExoticComponent<Omit<BuiltInIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
169
+ export {};