@central-ui/react 0.1.2 → 0.2.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 (279) 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 +14 -25
  5. package/dist/components/autocomplete/index.js +70 -54
  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/checkbox/index.d.ts +13 -11
  21. package/dist/components/checkbox/index.js +51 -31
  22. package/dist/components/chip/index.d.ts +1 -1
  23. package/dist/components/chip/index.js +2 -3
  24. package/dist/components/combobox/index.d.ts +18 -30
  25. package/dist/components/combobox/index.js +90 -67
  26. package/dist/components/datepicker/index.d.ts +18 -31
  27. package/dist/components/datepicker/index.js +81 -99
  28. package/dist/components/dialog/index.d.ts +14 -27
  29. package/dist/components/dialog/index.js +17 -18
  30. package/dist/components/divider/index.d.ts +0 -1
  31. package/dist/components/divider/index.js +0 -1
  32. package/dist/components/donutchart/index.d.ts +100 -0
  33. package/dist/components/donutchart/index.js +178 -0
  34. package/dist/components/drawer/index.d.ts +12 -21
  35. package/dist/components/drawer/index.js +34 -36
  36. package/dist/components/empty/index.d.ts +1 -2
  37. package/dist/components/empty/index.js +2 -4
  38. package/dist/components/fileupload/index.d.ts +4 -9
  39. package/dist/components/fileupload/index.js +26 -38
  40. package/dist/components/form/index.d.ts +0 -1
  41. package/dist/components/form/index.js +0 -1
  42. package/dist/components/horizontalbarchart/index.d.ts +120 -0
  43. package/dist/components/horizontalbarchart/index.js +193 -0
  44. package/dist/components/input/index.d.ts +22 -22
  45. package/dist/components/input/index.js +76 -105
  46. package/dist/components/linechart/index.d.ts +114 -0
  47. package/dist/components/linechart/index.js +139 -0
  48. package/dist/components/menu/index.d.ts +9 -11
  49. package/dist/components/menu/index.js +42 -39
  50. package/dist/components/metric/index.d.ts +0 -1
  51. package/dist/components/metric/index.js +0 -1
  52. package/dist/components/numberinput/index.d.ts +14 -21
  53. package/dist/components/numberinput/index.js +40 -53
  54. package/dist/components/otpinput/index.d.ts +14 -9
  55. package/dist/components/otpinput/index.js +25 -18
  56. package/dist/components/page/index.d.ts +0 -1
  57. package/dist/components/page/index.js +1 -3
  58. package/dist/components/passwordinput/index.d.ts +14 -11
  59. package/dist/components/passwordinput/index.js +36 -45
  60. package/dist/components/popover/index.d.ts +21 -19
  61. package/dist/components/popover/index.js +34 -15
  62. package/dist/components/radio/index.d.ts +13 -9
  63. package/dist/components/radio/index.js +69 -60
  64. package/dist/components/ratinginput/index.d.ts +13 -8
  65. package/dist/components/ratinginput/index.js +37 -17
  66. package/dist/components/select/index.d.ts +25 -28
  67. package/dist/components/select/index.js +67 -38
  68. package/dist/components/skeleton/index.d.ts +0 -1
  69. package/dist/components/skeleton/index.js +0 -1
  70. package/dist/components/slider/index.d.ts +14 -9
  71. package/dist/components/slider/index.js +64 -63
  72. package/dist/components/spinner/index.d.ts +1 -2
  73. package/dist/components/spinner/index.js +2 -3
  74. package/dist/components/splitter/index.d.ts +1 -2
  75. package/dist/components/splitter/index.js +5 -6
  76. package/dist/components/stepper/index.d.ts +8 -20
  77. package/dist/components/stepper/index.js +15 -16
  78. package/dist/components/switch/index.d.ts +12 -10
  79. package/dist/components/switch/index.js +46 -30
  80. package/dist/components/table/index.d.ts +3 -3
  81. package/dist/components/table/index.js +14 -13
  82. package/dist/components/tabs/index.d.ts +0 -1
  83. package/dist/components/tabs/index.js +1 -2
  84. package/dist/components/textarea/index.d.ts +14 -11
  85. package/dist/components/textarea/index.js +37 -46
  86. package/dist/components/textlink/index.d.ts +3 -1
  87. package/dist/components/textlink/index.js +4 -1
  88. package/dist/components/toast/index.d.ts +8 -14
  89. package/dist/components/toast/index.js +48 -48
  90. package/dist/components/toggle/index.d.ts +0 -1
  91. package/dist/components/toggle/index.js +17 -24
  92. package/dist/components/tooltip/index.d.ts +11 -13
  93. package/dist/components/tooltip/index.js +12 -9
  94. package/dist/components/tour/index.d.ts +154 -0
  95. package/dist/components/tour/index.js +280 -0
  96. package/dist/index.d.ts +5 -2
  97. package/dist/index.js +5 -1
  98. package/dist/types/Icon.d.ts +0 -1
  99. package/dist/types/Icon.js +0 -1
  100. package/dist/types/Style.d.ts +0 -1
  101. package/dist/types/Style.js +0 -1
  102. package/dist/types/Tone.d.ts +0 -1
  103. package/dist/types/Tone.js +0 -1
  104. package/dist/types/Validation.d.ts +12 -0
  105. package/dist/types/Validation.js +1 -0
  106. package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
  107. package/dist/utils/ArkStateToDataAttributes.js +0 -1
  108. package/dist/utils/Tone.d.ts +0 -1
  109. package/dist/utils/Tone.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 +12 -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-checkbox.css +2 -2
  128. package/src/presets/shopify-polaris/shopify-polaris-combobox.css +2 -2
  129. package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +4 -4
  130. package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
  131. package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
  132. package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
  133. package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
  134. package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
  135. package/src/presets/shopify-polaris/shopify-polaris-input.css +2 -2
  136. package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
  137. package/src/presets/shopify-polaris/shopify-polaris-menu.css +16 -0
  138. package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +2 -2
  139. package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +2 -2
  140. package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +2 -2
  141. package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
  142. package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
  143. package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
  144. package/src/presets/shopify-polaris/shopify-polaris-select.css +2 -2
  145. package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
  146. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
  147. package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
  148. package/src/presets/shopify-polaris/shopify-polaris-textarea.css +2 -2
  149. package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
  150. package/src/presets/shopify-polaris/shopify-polaris.css +4 -0
  151. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
  152. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
  153. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
  154. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
  155. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
  156. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
  157. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
  158. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -0
  159. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +1 -1
  160. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-horizontalbarchart.css +60 -0
  161. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +2 -2
  162. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-linechart.css +68 -0
  163. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +9 -0
  164. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +2 -2
  165. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +2 -2
  166. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +2 -2
  167. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +22 -0
  168. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +2 -2
  169. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +2 -2
  170. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +2 -2
  171. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +9 -0
  172. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +2 -2
  173. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +2 -2
  174. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +9 -0
  175. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +4 -0
  176. package/dist/components/accordion/index.d.ts.map +0 -1
  177. package/dist/components/accordion/index.js.map +0 -1
  178. package/dist/components/autocomplete/index.d.ts.map +0 -1
  179. package/dist/components/autocomplete/index.js.map +0 -1
  180. package/dist/components/avatar/index.d.ts.map +0 -1
  181. package/dist/components/avatar/index.js.map +0 -1
  182. package/dist/components/badge/index.d.ts.map +0 -1
  183. package/dist/components/badge/index.js.map +0 -1
  184. package/dist/components/banner/index.d.ts.map +0 -1
  185. package/dist/components/banner/index.js.map +0 -1
  186. package/dist/components/breadcrumb/index.d.ts.map +0 -1
  187. package/dist/components/breadcrumb/index.js.map +0 -1
  188. package/dist/components/button/index.d.ts.map +0 -1
  189. package/dist/components/button/index.js.map +0 -1
  190. package/dist/components/card/index.d.ts.map +0 -1
  191. package/dist/components/card/index.js.map +0 -1
  192. package/dist/components/checkbox/index.d.ts.map +0 -1
  193. package/dist/components/checkbox/index.js.map +0 -1
  194. package/dist/components/chip/index.d.ts.map +0 -1
  195. package/dist/components/chip/index.js.map +0 -1
  196. package/dist/components/combobox/index.d.ts.map +0 -1
  197. package/dist/components/combobox/index.js.map +0 -1
  198. package/dist/components/datepicker/index.d.ts.map +0 -1
  199. package/dist/components/datepicker/index.js.map +0 -1
  200. package/dist/components/dialog/index.d.ts.map +0 -1
  201. package/dist/components/dialog/index.js.map +0 -1
  202. package/dist/components/divider/index.d.ts.map +0 -1
  203. package/dist/components/divider/index.js.map +0 -1
  204. package/dist/components/drawer/index.d.ts.map +0 -1
  205. package/dist/components/drawer/index.js.map +0 -1
  206. package/dist/components/empty/index.d.ts.map +0 -1
  207. package/dist/components/empty/index.js.map +0 -1
  208. package/dist/components/fileupload/index.d.ts.map +0 -1
  209. package/dist/components/fileupload/index.js.map +0 -1
  210. package/dist/components/form/index.d.ts.map +0 -1
  211. package/dist/components/form/index.js.map +0 -1
  212. package/dist/components/input/index.d.ts.map +0 -1
  213. package/dist/components/input/index.js.map +0 -1
  214. package/dist/components/menu/index.d.ts.map +0 -1
  215. package/dist/components/menu/index.js.map +0 -1
  216. package/dist/components/metric/index.d.ts.map +0 -1
  217. package/dist/components/metric/index.js.map +0 -1
  218. package/dist/components/numberinput/index.d.ts.map +0 -1
  219. package/dist/components/numberinput/index.js.map +0 -1
  220. package/dist/components/otpinput/index.d.ts.map +0 -1
  221. package/dist/components/otpinput/index.js.map +0 -1
  222. package/dist/components/page/index.d.ts.map +0 -1
  223. package/dist/components/page/index.js.map +0 -1
  224. package/dist/components/passwordinput/index.d.ts.map +0 -1
  225. package/dist/components/passwordinput/index.js.map +0 -1
  226. package/dist/components/popover/index.d.ts.map +0 -1
  227. package/dist/components/popover/index.js.map +0 -1
  228. package/dist/components/radio/index.d.ts.map +0 -1
  229. package/dist/components/radio/index.js.map +0 -1
  230. package/dist/components/ratinginput/index.d.ts.map +0 -1
  231. package/dist/components/ratinginput/index.js.map +0 -1
  232. package/dist/components/select/index.d.ts.map +0 -1
  233. package/dist/components/select/index.js.map +0 -1
  234. package/dist/components/skeleton/index.d.ts.map +0 -1
  235. package/dist/components/skeleton/index.js.map +0 -1
  236. package/dist/components/slider/index.d.ts.map +0 -1
  237. package/dist/components/slider/index.js.map +0 -1
  238. package/dist/components/spinner/index.d.ts.map +0 -1
  239. package/dist/components/spinner/index.js.map +0 -1
  240. package/dist/components/splitter/index.d.ts.map +0 -1
  241. package/dist/components/splitter/index.js.map +0 -1
  242. package/dist/components/stepper/index.d.ts.map +0 -1
  243. package/dist/components/stepper/index.js.map +0 -1
  244. package/dist/components/switch/index.d.ts.map +0 -1
  245. package/dist/components/switch/index.js.map +0 -1
  246. package/dist/components/table/index.d.ts.map +0 -1
  247. package/dist/components/table/index.js.map +0 -1
  248. package/dist/components/tabs/index.d.ts.map +0 -1
  249. package/dist/components/tabs/index.js.map +0 -1
  250. package/dist/components/textarea/index.d.ts.map +0 -1
  251. package/dist/components/textarea/index.js.map +0 -1
  252. package/dist/components/textlink/index.d.ts.map +0 -1
  253. package/dist/components/textlink/index.js.map +0 -1
  254. package/dist/components/toast/index.d.ts.map +0 -1
  255. package/dist/components/toast/index.js.map +0 -1
  256. package/dist/components/toggle/index.d.ts.map +0 -1
  257. package/dist/components/toggle/index.js.map +0 -1
  258. package/dist/components/tooltip/index.d.ts.map +0 -1
  259. package/dist/components/tooltip/index.js.map +0 -1
  260. package/dist/index.d.ts.map +0 -1
  261. package/dist/index.js.map +0 -1
  262. package/dist/types/Icon.d.ts.map +0 -1
  263. package/dist/types/Icon.js.map +0 -1
  264. package/dist/types/Style.d.ts.map +0 -1
  265. package/dist/types/Style.js.map +0 -1
  266. package/dist/types/Tone.d.ts.map +0 -1
  267. package/dist/types/Tone.js.map +0 -1
  268. package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
  269. package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
  270. package/dist/utils/Tone.d.ts.map +0 -1
  271. package/dist/utils/Tone.js.map +0 -1
  272. package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
  273. package/dist/utils/useForwardClickToInput.js.map +0 -1
  274. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
  275. package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
  276. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
  277. package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
  278. package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
  279. package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { asChildStyleAttributes } from "../../utils/asChild.js";
2
3
  import { FileUpload as ArkFileUpload, useFileUpload, useFileUploadContext, } from '@ark-ui/react/file-upload';
3
- import { File as FileIcon, Upload, X } from 'lucide-react';
4
- import { cloneElement, createContext, useContext, Fragment } from 'react';
4
+ import { File as FileIcon, Upload, X } from "../../utils/icons.js";
5
+ import { cloneElement, createContext, useContext } from 'react';
5
6
  import { twMerge } from 'tailwind-merge';
6
7
  import { arkStateToDataAttributes } from "../../utils/ArkStateToDataAttributes.js";
7
8
  /**
8
- * Root manages accepted/rejected files, validation, and picker behavior. Dropzone/FilePickerOpenButton open the picker; do not add a second file input. FileList supplies entries; pass each entry file and status to File. FileThumbnail chooses image preview versus fallback automatically.
9
+ * Root manages accepted/rejected files, validation, and picker behavior. Dropzone/PickerButton open the picker; do not add a second file input. FileList supplies entries; pass each entry file and status to File. FileThumbnail chooses image preview versus fallback automatically.
9
10
  *
10
11
  * @example Complete composition
11
12
  * import { FileUpload } from '@central-ui/react'
@@ -19,7 +20,7 @@ import { arkStateToDataAttributes } from "../../utils/ArkStateToDataAttributes.j
19
20
  * <FileUpload.UploadIcon />
20
21
  * <FileUpload.Title>Drop an image here</FileUpload.Title>
21
22
  * <FileUpload.Description>PNG or JPG up to 10 MB.</FileUpload.Description>
22
- * <FileUpload.FilePickerOpenButton>Browse image</FileUpload.FilePickerOpenButton>
23
+ * <FileUpload.PickerButton>Browse image</FileUpload.PickerButton>
23
24
  * <FileUpload.FileList>
24
25
  * {({ file, status }) => (
25
26
  * <FileUpload.File file={file} status={status}>
@@ -50,8 +51,8 @@ import { arkStateToDataAttributes } from "../../utils/ArkStateToDataAttributes.j
50
51
  * </FileUpload.Root>
51
52
  */
52
53
  export function Root({ children, ...props }) {
53
- const file_upload = useFileUpload(props);
54
- return (_jsx(ArkFileUpload.RootProvider, { value: file_upload, asChild: true, children: _jsx(_Fragment, { children: children }) }));
54
+ const fileUpload = useFileUpload(props);
55
+ return (_jsx(ArkFileUpload.RootProvider, { value: fileUpload, asChild: true, children: _jsx(_Fragment, { children: children }) }));
55
56
  }
56
57
  export function Container({ disableStyle, className, ...props }) {
57
58
  return (_jsx("div", { "data-component": "fileupload-container", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
@@ -62,16 +63,17 @@ export function Label({ disableStyle, className, ...props }) {
62
63
  export function Dropzone({ disableStyle, children, className, ...props }) {
63
64
  return (_jsxs(ArkFileUpload.Dropzone, { ...props, "data-component": "fileupload-dropzone", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [children, _jsx(ArkFileUpload.HiddenInput, {})] }));
64
65
  }
65
- export function FilePickerOpenButton({ disableStyle, className, ...props }) {
66
- return (_jsx(ArkFileUpload.Trigger, { ...props, "data-component": "fileupload-filepickeropenbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
66
+ /** Opens the file picker. Pass asChild to give this behavior to your own button, like an "Upload" Button; it keeps the state data attributes but none of this part's styling. */
67
+ export function PickerButton({ asChild, disableStyle, ...props }) {
68
+ const styleAttributes = asChildStyleAttributes({ asChild, component: 'fileupload-pickerbutton', disableStyle });
69
+ return _jsx(ArkFileUpload.Trigger, { ...props, asChild: asChild, ...styleAttributes });
67
70
  }
68
71
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
69
72
  export function UploadIcon({ disableStyle, children = _jsx(Upload, {}), className, ...props }) {
70
- const file_upload = useFileUploadContext();
73
+ const fileUpload = useFileUploadContext();
71
74
  return cloneElement(children, {
72
- ...children.props,
73
75
  ...props,
74
- ...arkStateToDataAttributes(file_upload),
76
+ ...arkStateToDataAttributes(fileUpload),
75
77
  ...useFileStatusAttributes(),
76
78
  ...{
77
79
  'data-component': 'fileupload-uploadicon',
@@ -82,26 +84,20 @@ export function UploadIcon({ disableStyle, children = _jsx(Upload, {}), classNam
82
84
  });
83
85
  }
84
86
  export function Title({ disableStyle, className, ...props }) {
85
- const file_upload = useFileUploadContext();
86
- return (_jsx("p", { ...props, ...arkStateToDataAttributes(file_upload), ...useFileStatusAttributes(), "data-component": "fileupload-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
87
+ const fileUpload = useFileUploadContext();
88
+ return (_jsx("p", { ...props, ...arkStateToDataAttributes(fileUpload), ...useFileStatusAttributes(), "data-component": "fileupload-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
87
89
  }
88
90
  export function Description({ disableStyle, className, ...props }) {
89
- const file_upload = useFileUploadContext();
90
- return (_jsx("p", { ...props, ...arkStateToDataAttributes(file_upload), ...useFileStatusAttributes(), "data-component": "fileupload-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
91
+ const fileUpload = useFileUploadContext();
92
+ return (_jsx("p", { ...props, ...arkStateToDataAttributes(fileUpload), ...useFileStatusAttributes(), "data-component": "fileupload-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
91
93
  }
92
94
  // Keep Ark's accepted and rejected arrays native; only merge their presentation.
93
95
  export function FileList({ disableStyle, children, className, style, onClick, ...props }) {
94
- const upload = useFileUploadContext();
96
+ const fileUpload = useFileUploadContext();
97
+ // One list of accepted and rejected files, each knowing its status
95
98
  const entries = [
96
- ...upload.acceptedFiles.map((file) => ({
97
- file,
98
- status: 'accepted',
99
- errors: [],
100
- })),
101
- ...upload.rejectedFiles.map((rejection) => ({
102
- ...rejection,
103
- status: 'rejected',
104
- })),
99
+ ...fileUpload.acceptedFiles.map((file) => ({ file, status: 'accepted', errors: [] })),
100
+ ...fileUpload.rejectedFiles.map((rejection) => ({ ...rejection, status: 'rejected' })),
105
101
  ];
106
102
  return (_jsx("ul", { ...props, style: { ...style, cursor: 'default' }, onClick: (event) => {
107
103
  // Clicks anywhere in the file list must not open the surrounding Dropzone.
@@ -111,7 +107,7 @@ export function FileList({ disableStyle, children, className, style, onClick, ..
111
107
  }
112
108
  export function File({ disableStyle, status, className, children, ...props }) {
113
109
  const entry = useContext(FileStatusContext);
114
- return (_jsx(ArkFileUpload.ItemGroup, { type: status, asChild: true, children: _jsx(Fragment, { children: _jsx(FileStatusContext.Provider, { value: { status, errors: entry.errors }, children: _jsx(ArkFileUpload.Item, { ...props, "data-status": status, "data-component": "fileupload-file", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children }) }) }) }));
110
+ return (_jsx(ArkFileUpload.ItemGroup, { type: status, asChild: true, children: _jsx(_Fragment, { children: _jsx(FileStatusContext.Provider, { value: { status, errors: entry.errors }, children: _jsx(ArkFileUpload.Item, { ...props, "data-status": status, "data-component": "fileupload-file", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children }) }) }) }));
115
111
  }
116
112
  /** Reads the surrounding File automatically. Omit children to keep the supplied text; override only for custom presentation. */
117
113
  export function FileErrorText({ disableStyle, children, className, ...props }) {
@@ -130,11 +126,10 @@ export function FileThumbnail({ disableStyle, children, className, ...props }) {
130
126
  }
131
127
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
132
128
  export function FileThumbnailIcon({ disableStyle, children = _jsx(FileIcon, {}), className, ...props }) {
133
- const file_upload = useFileUploadContext();
129
+ const fileUpload = useFileUploadContext();
134
130
  return cloneElement(children, {
135
- ...children.props,
136
131
  ...props,
137
- ...arkStateToDataAttributes(file_upload),
132
+ ...arkStateToDataAttributes(fileUpload),
138
133
  ...useFileStatusAttributes(),
139
134
  ...{
140
135
  'data-component': 'fileupload-filethumbnailicon',
@@ -152,22 +147,16 @@ export function FileName({ disableStyle, className, ...props }) {
152
147
  export function FileSize({ disableStyle, className, ...props }) {
153
148
  return (_jsx(ArkFileUpload.ItemSizeText, { ...props, ...useFileStatusAttributes(), "data-component": "fileupload-filesize", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
154
149
  }
155
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
156
- export function FileRemoveHandler({ children, ...props }) {
157
- const attributes = useFileStatusAttributes();
158
- return (_jsx(ArkFileUpload.ItemDeleteTrigger, { ...props, ...attributes, asChild: true, children: children }));
159
- }
160
150
  /** Removes the surrounding file automatically, including rejected entries. No extra removal click handler needed. */
161
151
  export function FileRemoveButton({ disableStyle, children, className, ...props }) {
162
152
  return (_jsx(ArkFileUpload.ItemDeleteTrigger, { ...props, ...useFileStatusAttributes(), asChild: false, "data-component": "fileupload-fileremovebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children }));
163
153
  }
164
154
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
165
155
  export function FileRemoveButtonIcon({ disableStyle, children = _jsx(X, {}), className, ...props }) {
166
- const file_upload = useFileUploadContext();
156
+ const fileUpload = useFileUploadContext();
167
157
  return cloneElement(children, {
168
- ...children.props,
169
158
  ...props,
170
- ...arkStateToDataAttributes(file_upload),
159
+ ...arkStateToDataAttributes(fileUpload),
171
160
  ...useFileStatusAttributes(),
172
161
  ...{
173
162
  'data-component': 'fileupload-fileremovebuttonicon',
@@ -182,4 +171,3 @@ const FileStatusContext = /* @__PURE__ */ createContext({ errors: [] });
182
171
  function useFileStatusAttributes() {
183
172
  return { 'data-status': useContext(FileStatusContext).status };
184
173
  }
185
- //# sourceMappingURL=index.js.map
@@ -31,4 +31,3 @@ import type { FormHTMLAttributes } from 'react';
31
31
  * }
32
32
  */
33
33
  export declare function Form({ disableStyle, className, ...props }: FormHTMLAttributes<HTMLFormElement> & StyleProps): import("react").JSX.Element;
34
- //# sourceMappingURL=index.d.ts.map
@@ -32,4 +32,3 @@ import { jsx as _jsx } from "react/jsx-runtime";
32
32
  export function Form({ disableStyle, className, ...props }) {
33
33
  return (_jsx("form", { "data-component": "form-form", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
34
34
  }
35
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,120 @@
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 } 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 length). 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
+ /** Rows are drawn top to bottom in this order, so sort the records before passing them (e.g. largest first). */
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 category names and the tooltip label, so both always read the same.
18
+ * Use it to shorten long names or to join fields (e.g. `'United States · Iowa'`).
19
+ * @default (label) => label
20
+ */
21
+ labelToString?: (label: string) => string;
22
+ /**
23
+ * Converts a record's `value` into display text.
24
+ * Used by the value at each bar's end, the X axis ticks, and the tooltip value, so all read the same.
25
+ * Use it for currency, percentages, or units (e.g. `53700` → `'$53.7K'`).
26
+ * @default (value) => value.toLocaleString()
27
+ */
28
+ valueToString?: (value: number) => string;
29
+ /**
30
+ * Whether the X axis may place ticks at fractional values. Only matters when the XAxis part is rendered.
31
+ * Keep it `false` for counts (sessions, orders) so the axis never shows `0.5 sessions`.
32
+ * Set it to `true` for continuous measures where fractions are meaningful, such as ratings.
33
+ * @default false
34
+ */
35
+ allowDecimals?: boolean;
36
+ /**
37
+ * Where each category name sits.
38
+ * - `'top'`: above its bar, left-aligned. Bars keep the full width, so long names and long bars both fit. The usual choice for dashboards.
39
+ * - `'left'`: in a column left of the bars, like a classic axis. Use it when names are short and rows should line up as a table.
40
+ * @default 'top'
41
+ */
42
+ labelPosition?: 'top' | 'left';
43
+ };
44
+ /** Provides the chart data, formatting, and accessibility settings to its parts. Renders no element. */
45
+ export declare function Root<Data extends Datum>({ children, labelToString, valueToString, allowDecimals, labelPosition, ...chart }: RootProps<Data>): import("react").JSX.Element;
46
+ export type ContainerProps = Pick<ComponentProps<typeof RechartsBarChart>, 'children' | 'height' | 'className' | 'style' | 'id' | 'margin' | 'ref' | 'tabIndex'> & {
47
+ /**
48
+ * A horizontal line through the hovered row.
49
+ * Off by default: the hovered bar already dims, so a guide adds little here.
50
+ * Turn it on for many thin rows, where it helps the eye follow a row to its value. Style it through `data-component="horizontalbarchart-hoverguide"`.
51
+ * @default false
52
+ */
53
+ hoverGuide?: LineSwitch;
54
+ };
55
+ /** On/off only: style it through its data-component in a preset, so each export keeps one className. */
56
+ type LineSwitch = boolean;
57
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
58
+ export declare function Container({ height, className, style, children, hoverGuide, ...props }: ContainerProps): import("react").JSX.Element;
59
+ export type XAxisProps = Pick<RechartsXAxisProps, 'tickSize'> & {
60
+ /** 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. */
61
+ className?: string;
62
+ /** Space between the labels and the plot area, in pixels. */
63
+ labelGap?: number;
64
+ /** The line along the axis. Hidden by default. */
65
+ axisLine?: LineSwitch;
66
+ /** The small marks at each tick. Hidden by default. */
67
+ tickLine?: LineSwitch;
68
+ };
69
+ /** Shows the value ticks along the bottom. Optional: without it the scale still exists, just unlabeled. Renders no element. */
70
+ export declare function XAxis({ className, axisLine, tickLine, tickSize, labelGap, }: XAxisProps): null;
71
+ export type GridProps = {
72
+ /** Classes for every grid line, e.g. `stroke-neutral-200 [stroke-dasharray:4_4]`. */
73
+ className?: string;
74
+ };
75
+ /** Vertical lines only, one per X value tick, marking milestones along the bars. */
76
+ export declare function Grid({ className }: GridProps): import("react").JSX.Element;
77
+ export type BarsProps = Pick<RechartsBarProps, 'radius' | 'hide' | 'name'> & {
78
+ /**
79
+ * Classes for every bar. Colors come only from here or from a preset; there is no built-in color.
80
+ * Target hover with `data-active:` (e.g. `fill-sky-500 data-active:opacity-80`).
81
+ */
82
+ className?: string;
83
+ /**
84
+ * Whether the bar under the pointer gets `data-active`. Pass false to turn the hover state off.
85
+ * @default true
86
+ */
87
+ activeBar?: boolean;
88
+ /** Optional BarLabel and BarValue parts, drawn on every bar. */
89
+ children?: ReactNode;
90
+ };
91
+ export declare function Bars({ className, activeBar, children, ...props }: BarsProps): import("react").JSX.Element;
92
+ export type BarLabelProps = {
93
+ /** Classes for the category names, e.g. `fill-neutral-500`. Target the placement with `data-[position=top]:` or `data-[position=left]:`. */
94
+ className?: string;
95
+ };
96
+ /**
97
+ * Each bar's category name, formatted by `labelToString` on Root and placed by Root's `labelPosition`.
98
+ * Recharts draws it as a LabelList inside the bar; omit it for bars without names.
99
+ */
100
+ export declare function BarLabel({ className }: BarLabelProps): import("react").JSX.Element | null;
101
+ export type BarValueProps = {
102
+ /** Classes for the value printed past each bar's end, e.g. `fill-neutral-500`. */
103
+ className?: string;
104
+ };
105
+ /** Each bar's value, formatted by `valueToString` on Root and printed past the bar's end. Recharts draws it as a LabelList inside the bar. */
106
+ export declare function BarValue({ className }: BarValueProps): import("react").JSX.Element;
107
+ export type TooltipProps<Data extends Datum = Datum> = Pick<RechartsTooltipProps<number, string>, 'offset' | 'allowEscapeViewBox' | 'portal'> & {
108
+ /** Receives the hovered record and returns the popup. */
109
+ children: (datum: Data) => ReactNode;
110
+ };
111
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
112
+ export declare function Tooltip<Data extends Datum = Datum>({ children, offset, allowEscapeViewBox, portal, }: TooltipProps<Data>): null;
113
+ export declare function TooltipPopup({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
114
+ export declare function TooltipTitle({ disableStyle, className, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
115
+ /** Shows the hovered record's label, formatted by `labelToString` on Root. */
116
+ export declare function TooltipLabel({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
117
+ /** Shows the hovered record's value, formatted by `valueToString` on Root. */
118
+ export declare function TooltipValue({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
119
+ export declare function TooltipColorIndicator({ disableStyle, className, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
120
+ export {};
@@ -0,0 +1,193 @@
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, LabelList as RechartsLabelList, Rectangle as RechartsRectangle, Text as RechartsText, Tooltip as RechartsTooltip, XAxis as RechartsXAxis, YAxis as RechartsYAxis, usePlotArea, } from 'recharts';
5
+ // Recharts measures labels at this size; colors come from className or a preset.
6
+ const textSize = { fontSize: 12 };
7
+ const ChartContext = /* @__PURE__ */ createContext(null);
8
+ /** Provides the chart data, formatting, and accessibility settings to its parts. Renders no element. */
9
+ export function Root({ children, labelToString = (label) => label, valueToString = (value) => value.toLocaleString(), allowDecimals = false, labelPosition = 'top', ...chart }) {
10
+ return (_jsx(ChartContext.Provider, { value: {
11
+ ...chart,
12
+ labelToString,
13
+ valueToString,
14
+ allowDecimals,
15
+ labelPosition,
16
+ }, children: children }));
17
+ }
18
+ function useChart(part) {
19
+ const chart = useContext(ChartContext);
20
+ if (!chart)
21
+ throw new Error(`HorizontalBarChart.${part} must be inside HorizontalBarChart.Root`);
22
+ return chart;
23
+ }
24
+ const lineProps = (line, part) =>
25
+ // Recharts forwards data attributes at runtime; its types omit them.
26
+ (line && { 'data-component': part });
27
+ /** Lets optional parts hand their settings to the Container, which owns the axes and the single Recharts tooltip. */
28
+ const SlotsContext = /* @__PURE__ */ createContext(null);
29
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
30
+ export function Container({ height = 300, className, style, children, hoverGuide = false, ...props }) {
31
+ const chart = useChart('Container');
32
+ const [tooltip, setTooltip] = useState(null);
33
+ const [xAxis, setXAxis] = useState(null);
34
+ const [label, setLabel] = useState(null);
35
+ const [slots] = useState(() => ({
36
+ setTooltip,
37
+ setXAxis,
38
+ setLabel,
39
+ }));
40
+ const labelsOnTop = chart.labelPosition === 'top';
41
+ const { className: xTickClassName, labelGap = 8, axisLine = false, tickLine = false, tickSize, } = xAxis ?? {};
42
+ return (_jsxs(RechartsBarChart
43
+ // Top room for the first name; right room for the value printed past each bar's end.
44
+ , {
45
+ // Top room for the first name; right room for the value printed past each bar's end.
46
+ margin: { top: labelsOnTop ? 20 : 12, right: 56, 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: "vertical",
47
+ // Recharts applies this gap on both sides of a bar. With names on top, 12px a side
48
+ // always leaves 24px between bars for a name, however many rows there are.
49
+ barCategoryGap: labelsOnTop ? 12 : '20%', children: [_jsx(RechartsXAxis, { height: "auto", tickSize: tickSize, axisLine: lineProps(axisLine, 'horizontalbarchart-xaxis-line'), tickLine: lineProps(tickLine, 'horizontalbarchart-xaxis-tickline'), hide: !xAxis, tickMargin: labelGap, tickFormatter: chart.valueToString, allowDecimals: chart.allowDecimals, fontSize: 12, tick: {
50
+ className: xTickClassName,
51
+ 'data-component': 'horizontalbarchart-xaxis-ticklabel',
52
+ }, dataKey: "value", type: "number", label: false, angle: 0,
53
+ // Always include zero so bars have a baseline, and never collapse the range when every value is 0.
54
+ domain: ([minimum, maximum]) => [
55
+ Math.min(0, minimum),
56
+ Math.max(Math.min(0, minimum) + 1, maximum, 0),
57
+ ], interval: "preserveStartEnd", minTickGap: 8 }), _jsx(RechartsYAxis
58
+ // Names sit on the left only when a BarLabel part is rendered.
59
+ , {
60
+ // Names sit on the left only when a BarLabel part is rendered.
61
+ hide: labelsOnTop || !label, axisLine: false, tickLine: false, width: "auto", tickMargin: 8, tickFormatter: chart.labelToString, fontSize: 12, tick: {
62
+ className: label?.className,
63
+ 'data-component': 'horizontalbarchart-label',
64
+ 'data-position': 'left',
65
+ }, dataKey: "label", type: "category", label: false, angle: 0, interval: 0 }), _jsx(SlotsContext.Provider, { value: slots, children: children }), _jsx(RechartsTooltip, { offset: 12, ...tooltip?.props,
66
+ // Native popup slide, timed to match the hover guide's transition.
67
+ animationDuration: 200, animationEasing: "ease-out", shared: true, cursor: hoverGuide && _jsx(HoverGuide, {}), content: (state) => {
68
+ if (!tooltip || !state.active || !state.payload.length)
69
+ return null;
70
+ // Recharts types the payload as unknown; payload[0] is always the hovered record.
71
+ const datum = state.payload[0].payload;
72
+ return (_jsx(TooltipContext.Provider, { value: datum, children: tooltip.render(datum) }));
73
+ } })] }));
74
+ }
75
+ function useSlots(part) {
76
+ const slots = useContext(SlotsContext);
77
+ if (!slots)
78
+ throw new Error(`HorizontalBarChart.${part} must be inside HorizontalBarChart.Container`);
79
+ return slots;
80
+ }
81
+ /** Shows the value ticks along the bottom. Optional: without it the scale still exists, just unlabeled. Renders no element. */
82
+ export function XAxis({ className, axisLine, tickLine, tickSize, labelGap, }) {
83
+ const slots = useSlots('XAxis');
84
+ useLayoutEffect(() => {
85
+ slots.setXAxis({ className, axisLine, tickLine, tickSize, labelGap });
86
+ return () => slots.setXAxis(null);
87
+ }, [slots.setXAxis, className, axisLine, tickLine, tickSize, labelGap]);
88
+ return null;
89
+ }
90
+ /** Vertical lines only, one per X value tick, marking milestones along the bars. */
91
+ export function Grid({ className }) {
92
+ return (_jsx(RechartsGrid, { horizontal: false,
93
+ // Recharts' native line slot: each line gets the class and a data-component hook.
94
+ vertical: {
95
+ className,
96
+ 'data-component': 'horizontalbarchart-gridline',
97
+ }, fill: "none" }));
98
+ }
99
+ export function Bars({ className, activeBar = true, children, ...props }) {
100
+ return (_jsx(RechartsBar, { radius: 2, ...props, activeBar: activeBar,
101
+ // Recharts' native shape slot renders each bar ourselves, so className and data attributes land on the drawn element.
102
+ shape: (bar) => (_jsx(RechartsRectangle, { ...bar, className: className, "data-component": "horizontalbarchart-bar", "data-index": bar.index, "data-active": bar.isActive ? '' : undefined })), dataKey: "value",
103
+ // Bars stretch to fill each row, but a few rows never become blocks.
104
+ maxBarSize: 80,
105
+ // Zero rows still get a thin, hoverable sliver at the baseline.
106
+ minPointSize: 2, isAnimationActive: false, children: children }));
107
+ }
108
+ /**
109
+ * Each bar's category name, formatted by `labelToString` on Root and placed by Root's `labelPosition`.
110
+ * Recharts draws it as a LabelList inside the bar; omit it for bars without names.
111
+ */
112
+ export function BarLabel({ className }) {
113
+ const chart = useChart('BarLabel');
114
+ const slots = useSlots('BarLabel');
115
+ // Names on the left are the Container's category axis, so it needs to know they exist and their classes.
116
+ useLayoutEffect(() => {
117
+ slots.setLabel({ className });
118
+ return () => slots.setLabel(null);
119
+ }, [slots.setLabel, className]);
120
+ if (chart.labelPosition !== 'top')
121
+ return null;
122
+ return (_jsx(RechartsLabelList, { dataKey: "label", content: (label) => _jsx(NameAboveBar, { ...label, className: className }) }));
123
+ }
124
+ /** Each bar's value, formatted by `valueToString` on Root and printed past the bar's end. Recharts draws it as a LabelList inside the bar. */
125
+ export function BarValue({ className }) {
126
+ const chart = useChart('BarValue');
127
+ return (_jsx(RechartsLabelList, { dataKey: "value", position: "right", offset: 8, formatter: (value) => chart.valueToString(Number(value)), className: className, ...{ 'data-component': 'horizontalbarchart-value' }, ...textSize }));
128
+ }
129
+ /**
130
+ * Recharts sizes a bar's label to the bar itself, so short bars would wrap long names.
131
+ * Through LabelList's `content` slot, the name gets the plot's full width and one line instead,
132
+ * and Recharts' Text truncates it with an ellipsis only when it reaches the chart's edge.
133
+ */
134
+ // viewBox is the bar's own rectangle, which Recharts passes to every label.
135
+ function NameAboveBar({ viewBox, value, className, }) {
136
+ const chart = useChart('Bars');
137
+ const plotArea = usePlotArea();
138
+ if (!plotArea || !viewBox || !('x' in viewBox))
139
+ return null;
140
+ return (_jsx(RechartsText
141
+ // 6px above the bar's top-left corner, whatever the bar's thickness.
142
+ , {
143
+ // 6px above the bar's top-left corner, whatever the bar's thickness.
144
+ x: viewBox.x, y: (viewBox.y ?? 0) - 6,
145
+ // Names may run past the plot into the right margin reserved for values.
146
+ width: plotArea.width + 48, maxLines: 1, textAnchor: "start", verticalAnchor: "end", className: className, "data-component": "horizontalbarchart-label", "data-position": "top", ...textSize, children: chart.labelToString(String(value ?? '')) }));
147
+ }
148
+ const TooltipContext = /* @__PURE__ */ createContext(null);
149
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
150
+ export function Tooltip({ children, offset, allowEscapeViewBox, portal, }) {
151
+ const slots = useSlots('Tooltip');
152
+ useLayoutEffect(() => {
153
+ slots.setTooltip({
154
+ render: children,
155
+ props: { offset, allowEscapeViewBox, portal },
156
+ });
157
+ return () => slots.setTooltip(null);
158
+ }, [slots.setTooltip, children, offset, allowEscapeViewBox, portal]);
159
+ return null;
160
+ }
161
+ /** Recharts gives the cursor the row's whole rectangle; only its center line is drawn. */
162
+ function HoverGuide({ x = 0, y = 0, width = 0, height = 0, }) {
163
+ return (_jsx("line", { "data-component": "horizontalbarchart-hoverguide",
164
+ // Draw at y=0 and move with a transform, so CSS can slide it between rows (Recharts' cursor has no animation of its own).
165
+ x1: x, x2: x + width, y1: 0, y2: 0,
166
+ // The slide between points is built in.
167
+ className: "transition-transform duration-200 ease-out motion-reduce:transition-none", style: { transform: `translateY(${y + height / 2}px)` }, pointerEvents: "none" }));
168
+ }
169
+ export function TooltipPopup({ disableStyle, className, ...props }) {
170
+ return (_jsx("div", { ...props, "data-component": "horizontalbarchart-tooltip", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
171
+ }
172
+ export function TooltipTitle({ disableStyle, className, ...props }) {
173
+ return (_jsx("p", { ...props, "data-component": "horizontalbarchart-tooltiptitle", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
174
+ }
175
+ /** Shows the hovered record's label, formatted by `labelToString` on Root. */
176
+ export function TooltipLabel({ disableStyle, className, ...props }) {
177
+ const chart = useChart('TooltipLabel');
178
+ const datum = useContext(TooltipContext);
179
+ if (!datum)
180
+ throw new Error('HorizontalBarChart.TooltipLabel must be inside HorizontalBarChart.Tooltip');
181
+ return (_jsx("p", { ...props, "data-component": "horizontalbarchart-tooltiplabel", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.labelToString(datum.label) }));
182
+ }
183
+ /** Shows the hovered record's value, formatted by `valueToString` on Root. */
184
+ export function TooltipValue({ disableStyle, className, ...props }) {
185
+ const chart = useChart('TooltipValue');
186
+ const datum = useContext(TooltipContext);
187
+ if (!datum)
188
+ throw new Error('HorizontalBarChart.TooltipValue must be inside HorizontalBarChart.Tooltip');
189
+ return (_jsx("p", { ...props, "data-component": "horizontalbarchart-tooltipvalue", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.valueToString(datum.value) }));
190
+ }
191
+ export function TooltipColorIndicator({ disableStyle, className, ...props }) {
192
+ return (_jsx("span", { "aria-hidden": "true", ...props, "data-component": "horizontalbarchart-tooltipcolorindicator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
193
+ }
@@ -1,15 +1,14 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
- import { Input as BaseInput } from '@base-ui/react/input';
3
2
  import type { SVGIconProps } from '../../types/Icon.ts';
3
+ import { Input as BaseInput } from '@base-ui/react/input';
4
+ import type { ValidationProps } from '../../types/Validation.ts';
4
5
  import type { ComponentProps, ReactElement, ReactNode } from 'react';
5
- export type RootProps = Pick<BaseInput.Props, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required' | 'type'> & {
6
+ import type { ValidationMessageChildren } from '../../utils/Validation.ts';
7
+ export type RootProps = Pick<BaseInput.Props, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required' | 'type'> & ValidationProps & {
6
8
  children?: ReactNode;
7
- /** Choose the visual tone. This does not validate data or show/hide feedback messages. */
8
- /** Choose the visual tone. This does not validate data or show/hide feedback messages. */
9
- tone?: 'neutral' | 'valid' | 'invalid';
10
9
  };
11
10
  /**
12
- * Keep configuration such as value, name, and validation tone on Root. Input is the editable control; InputGroup and Container organize it. Optional addon controls already have their own behavior where named, such as clearing.
11
+ * Keep configuration such as value, name and validation on Root. Input is the editable control; InputGroup and Container organize it. Optional addon controls already have their own behavior where named, such as clearing.
13
12
  *
14
13
  * @example Complete composition
15
14
  * import { Input } from '@central-ui/react'
@@ -46,40 +45,41 @@ export type RootProps = Pick<BaseInput.Props, 'id' | 'name' | 'form' | 'value' |
46
45
  * )
47
46
  * }
48
47
  */
49
- export declare function Root({ children, id, tone, value, defaultValue, onValueChange, disabled, readOnly, required, ...coreProps }: RootProps): import("react").JSX.Element;
50
- export type InputProps = Omit<BaseInput.Props, keyof Pick<RootProps, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required' | 'type'> | 'className' | 'render'> & {
48
+ export declare function Root({ children, id, validation, value, defaultValue, onValueChange, disabled, readOnly, required, ...coreProps }: RootProps): import("react").JSX.Element;
49
+ export type InputProps = Omit<BaseInput.Props, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required' | 'type' | 'className' | 'render'> & {
51
50
  className?: string;
52
51
  } & StyleProps;
53
- export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").InputProps, "form" | "className" | "defaultValue" | "id" | "name" | "type" | "disabled" | "value" | "render" | "onValueChange" | "required" | "readOnly"> & {
54
- className?: string;
55
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
52
+ export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
56
53
  export declare const InputGroup: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
57
54
  export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
58
55
  /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
59
56
  export declare const Label: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "htmlFor"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
60
57
  export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
61
- /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
62
- export declare const Error: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
63
- /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
64
- export declare const Success: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
65
- export declare const Addon: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
58
+ type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
59
+ children?: ValidationMessageChildren;
60
+ };
61
+ /** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
62
+ export declare const Error: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
63
+ /** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
64
+ export declare const Success: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
65
+ export declare const Addon: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps & {
66
66
  /** Choose the preset appearance; this does not add action behavior. */
67
67
  variant?: "normal" | "emphasized";
68
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
68
+ }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
69
69
  export declare const AddonText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
70
70
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
71
- export declare function AddonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
71
+ export declare function AddonIcon(props: Omit<ComponentProps<'svg'>, 'children'> & StyleProps & {
72
72
  /** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
73
73
  children: ReactElement<ComponentProps<'svg'>>;
74
- }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
74
+ }): import("react").JSX.Element;
75
75
  export declare const AddonButton: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
76
76
  /** Built-in icon; no children needed. Use it inside its matching control. */
77
77
  export declare const AddonLoadingIcon: import("react").ForwardRefExoticComponent<Omit<Omit<SVGIconProps, "children"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
78
78
  /** Clears the control automatically; no clearing click handler needed. Supply the clear icon and an accessible name. */
79
79
  export declare const AddonClearButton: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
80
80
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
81
- export declare function AddonClearButtonIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
81
+ export declare function AddonClearButtonIcon({ children, ...props }: Omit<ComponentProps<'svg'>, 'children'> & StyleProps & {
82
82
  /** Omit for the supplied default icon; pass a child only to replace it. */
83
83
  children?: ReactElement<ComponentProps<'svg'>>;
84
- }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
85
- //# sourceMappingURL=index.d.ts.map
84
+ }): import("react").JSX.Element;
85
+ export {};