@central-ui/react 0.1.1 → 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 (281) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +1 -1
  3. package/dist/components/accordion/index.d.ts +7 -6
  4. package/dist/components/accordion/index.js +13 -10
  5. package/dist/components/autocomplete/index.d.ts +22 -33
  6. package/dist/components/autocomplete/index.js +90 -73
  7. package/dist/components/avatar/index.d.ts +1 -2
  8. package/dist/components/avatar/index.js +6 -6
  9. package/dist/components/badge/index.d.ts +0 -1
  10. package/dist/components/badge/index.js +2 -2
  11. package/dist/components/banner/index.d.ts +1 -1
  12. package/dist/components/banner/index.js +24 -26
  13. package/dist/components/barchart/index.d.ts +106 -0
  14. package/dist/components/barchart/index.js +122 -0
  15. package/dist/components/breadcrumb/index.d.ts +0 -1
  16. package/dist/components/breadcrumb/index.js +6 -7
  17. package/dist/components/button/index.d.ts +3 -4
  18. package/dist/components/button/index.js +11 -12
  19. package/dist/components/card/index.d.ts +0 -1
  20. package/dist/components/card/index.js +0 -1
  21. package/dist/components/checkbox/index.d.ts +13 -11
  22. package/dist/components/checkbox/index.js +59 -39
  23. package/dist/components/chip/index.d.ts +1 -1
  24. package/dist/components/chip/index.js +2 -3
  25. package/dist/components/combobox/index.d.ts +32 -44
  26. package/dist/components/combobox/index.js +112 -88
  27. package/dist/components/datepicker/index.d.ts +54 -55
  28. package/dist/components/datepicker/index.js +105 -100
  29. package/dist/components/dialog/index.d.ts +17 -30
  30. package/dist/components/dialog/index.js +25 -26
  31. package/dist/components/divider/index.d.ts +0 -1
  32. package/dist/components/divider/index.js +0 -1
  33. package/dist/components/donutchart/index.d.ts +100 -0
  34. package/dist/components/donutchart/index.js +178 -0
  35. package/dist/components/drawer/index.d.ts +15 -24
  36. package/dist/components/drawer/index.js +45 -47
  37. package/dist/components/empty/index.d.ts +1 -2
  38. package/dist/components/empty/index.js +2 -4
  39. package/dist/components/fileupload/index.d.ts +4 -9
  40. package/dist/components/fileupload/index.js +27 -39
  41. package/dist/components/form/index.d.ts +0 -1
  42. package/dist/components/form/index.js +0 -1
  43. package/dist/components/horizontalbarchart/index.d.ts +120 -0
  44. package/dist/components/horizontalbarchart/index.js +193 -0
  45. package/dist/components/input/index.d.ts +23 -23
  46. package/dist/components/input/index.js +86 -115
  47. package/dist/components/linechart/index.d.ts +114 -0
  48. package/dist/components/linechart/index.js +139 -0
  49. package/dist/components/menu/index.d.ts +14 -16
  50. package/dist/components/menu/index.js +56 -53
  51. package/dist/components/metric/index.d.ts +0 -1
  52. package/dist/components/metric/index.js +0 -1
  53. package/dist/components/numberinput/index.d.ts +16 -23
  54. package/dist/components/numberinput/index.js +55 -68
  55. package/dist/components/otpinput/index.d.ts +14 -9
  56. package/dist/components/otpinput/index.js +32 -25
  57. package/dist/components/page/index.d.ts +0 -1
  58. package/dist/components/page/index.js +2 -4
  59. package/dist/components/passwordinput/index.d.ts +16 -13
  60. package/dist/components/passwordinput/index.js +47 -56
  61. package/dist/components/popover/index.d.ts +21 -19
  62. package/dist/components/popover/index.js +40 -21
  63. package/dist/components/radio/index.d.ts +13 -9
  64. package/dist/components/radio/index.js +80 -71
  65. package/dist/components/ratinginput/index.d.ts +15 -10
  66. package/dist/components/ratinginput/index.js +38 -18
  67. package/dist/components/select/index.d.ts +29 -32
  68. package/dist/components/select/index.js +79 -50
  69. package/dist/components/skeleton/index.d.ts +0 -1
  70. package/dist/components/skeleton/index.js +0 -1
  71. package/dist/components/slider/index.d.ts +14 -9
  72. package/dist/components/slider/index.js +75 -74
  73. package/dist/components/spinner/index.d.ts +2 -3
  74. package/dist/components/spinner/index.js +2 -3
  75. package/dist/components/splitter/index.d.ts +1 -2
  76. package/dist/components/splitter/index.js +6 -7
  77. package/dist/components/stepper/index.d.ts +8 -20
  78. package/dist/components/stepper/index.js +15 -16
  79. package/dist/components/switch/index.d.ts +12 -10
  80. package/dist/components/switch/index.js +52 -36
  81. package/dist/components/table/index.d.ts +3 -3
  82. package/dist/components/table/index.js +17 -16
  83. package/dist/components/tabs/index.d.ts +3 -4
  84. package/dist/components/tabs/index.js +6 -7
  85. package/dist/components/textarea/index.d.ts +16 -13
  86. package/dist/components/textarea/index.js +46 -55
  87. package/dist/components/textlink/index.d.ts +3 -1
  88. package/dist/components/textlink/index.js +4 -1
  89. package/dist/components/toast/index.d.ts +8 -14
  90. package/dist/components/toast/index.js +54 -54
  91. package/dist/components/toggle/index.d.ts +5 -6
  92. package/dist/components/toggle/index.js +19 -26
  93. package/dist/components/tooltip/index.d.ts +11 -13
  94. package/dist/components/tooltip/index.js +14 -11
  95. package/dist/components/tour/index.d.ts +154 -0
  96. package/dist/components/tour/index.js +280 -0
  97. package/dist/index.d.ts +5 -2
  98. package/dist/index.js +5 -1
  99. package/dist/types/Icon.d.ts +10 -0
  100. package/dist/types/Icon.js +1 -0
  101. package/dist/types/Style.d.ts +0 -1
  102. package/dist/types/Style.js +0 -1
  103. package/dist/types/Tone.d.ts +0 -1
  104. package/dist/types/Tone.js +0 -1
  105. package/dist/types/Validation.d.ts +12 -0
  106. package/dist/types/Validation.js +1 -0
  107. package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
  108. package/dist/utils/ArkStateToDataAttributes.js +3 -2
  109. package/dist/utils/Tone.d.ts +0 -1
  110. package/dist/utils/Tone.js +1 -2
  111. package/dist/utils/Validation.d.ts +14 -0
  112. package/dist/utils/Validation.js +23 -0
  113. package/dist/utils/asChild.d.ts +41 -0
  114. package/dist/utils/asChild.js +15 -0
  115. package/dist/utils/icons.d.ts +24 -0
  116. package/dist/utils/icons.js +160 -0
  117. package/dist/utils/useForwardClickToInput.d.ts +0 -1
  118. package/dist/utils/useForwardClickToInput.js +4 -3
  119. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +0 -1
  120. package/dist/utils/virtualization/useVirtualizedAutocomplete.js +0 -1
  121. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +0 -1
  122. package/dist/utils/virtualization/useVirtualizedCombobox.js +0 -1
  123. package/dist/utils/virtualization/useVirtualizedTable.d.ts +0 -1
  124. package/dist/utils/virtualization/useVirtualizedTable.js +0 -1
  125. package/package.json +12 -11
  126. package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +15 -6
  127. package/src/presets/shopify-polaris/shopify-polaris-badge.css +1 -1
  128. package/src/presets/shopify-polaris/shopify-polaris-barchart.css +64 -0
  129. package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +2 -2
  130. package/src/presets/shopify-polaris/shopify-polaris-chip.css +3 -3
  131. package/src/presets/shopify-polaris/shopify-polaris-combobox.css +19 -10
  132. package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +20 -11
  133. package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
  134. package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
  135. package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
  136. package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
  137. package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
  138. package/src/presets/shopify-polaris/shopify-polaris-input.css +14 -5
  139. package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
  140. package/src/presets/shopify-polaris/shopify-polaris-menu.css +47 -6
  141. package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +16 -7
  142. package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +3 -3
  143. package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +14 -5
  144. package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
  145. package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
  146. package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
  147. package/src/presets/shopify-polaris/shopify-polaris-select.css +15 -6
  148. package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
  149. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
  150. package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
  151. package/src/presets/shopify-polaris/shopify-polaris-textarea.css +13 -4
  152. package/src/presets/shopify-polaris/shopify-polaris-toast.css +43 -0
  153. package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
  154. package/src/presets/shopify-polaris/shopify-polaris.css +5 -0
  155. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
  156. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
  157. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
  158. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
  159. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
  160. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
  161. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
  162. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -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 +4 -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/Style.d.ts.map +0 -1
  267. package/dist/types/Style.js.map +0 -1
  268. package/dist/types/Tone.d.ts.map +0 -1
  269. package/dist/types/Tone.js.map +0 -1
  270. package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
  271. package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
  272. package/dist/utils/Tone.d.ts.map +0 -1
  273. package/dist/utils/Tone.js.map +0 -1
  274. package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
  275. package/dist/utils/useForwardClickToInput.js.map +0 -1
  276. package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
  277. package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
  278. package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
  279. package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
  280. package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
  281. package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
@@ -0,0 +1,100 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import { PieChart as RechartsPieChart } from 'recharts';
3
+ import type { TooltipProps as RechartsTooltipProps } from 'recharts';
4
+ import type { StyleProps } from '../../types/Style.ts';
5
+ /** Every record needs a unique `label` (the slice name) and a numeric `value` (its share). Extra fields are kept for the tooltip and legend. */
6
+ type Datum = {
7
+ label: string;
8
+ value: number;
9
+ };
10
+ export type RootProps<Data extends Datum = Datum> = Pick<ComponentProps<typeof RechartsPieChart>, 'accessibilityLayer' | 'desc'> & {
11
+ /** Slices are drawn clockwise from 12 o'clock in this order, so sort the records first (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 body, the legend, and the tooltip, so all read the same.
18
+ * @default (label) => label
19
+ */
20
+ labelToString?: (label: string) => string;
21
+ /**
22
+ * Converts a record's `value` (and the total) into display text.
23
+ * Used by the body, the legend, and the tooltip, so all read the same.
24
+ * Use it for currency, percentages, or units (e.g. `74678.2` → `'$74.6K'`).
25
+ * @default (value) => value.toLocaleString()
26
+ */
27
+ valueToString?: (value: number) => string;
28
+ };
29
+ /** Provides the chart data, formatting, and accessibility settings to its parts. Renders no element. */
30
+ export declare function Root<Data extends Datum>({ children, labelToString, valueToString, ...chart }: RootProps<Data>): import("react").JSX.Element;
31
+ export type ContainerProps = Pick<ComponentProps<typeof RechartsPieChart>, 'children' | 'height' | 'className' | 'style' | 'id' | 'ref' | 'tabIndex'>;
32
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
33
+ export declare function Container({ height, className, style, children, ...props }: ContainerProps): import("react").JSX.Element;
34
+ export type TrackProps = {
35
+ /** Classes for the full ring behind the slices, e.g. `fill-neutral-100`. */
36
+ className?: string;
37
+ };
38
+ /** Optional full ring behind the slices. It keeps the donut visible when every value is 0. */
39
+ export declare function Track({ className }: TrackProps): import("react").JSX.Element;
40
+ export type SlicesProps = {
41
+ /**
42
+ * Classes for every slice. Colors come only from here or from a preset; there is no built-in color.
43
+ * Target one slice with `data-[index=0]:`, the hovered one with `data-active:`, and the others with `data-inactive:`
44
+ * (e.g. `data-[index=0]:fill-sky-500 data-[index=1]:fill-violet-200 data-inactive:opacity-40`).
45
+ */
46
+ className?: string;
47
+ /**
48
+ * Degrees of empty space between slices.
49
+ * @default 2
50
+ */
51
+ gap?: number;
52
+ };
53
+ export declare function Slices({ className, gap }: SlicesProps): import("react").JSX.Element;
54
+ /**
55
+ * HTML laid over the donut's hole, so its content is ordinary JSX: Tailwind, fonts, and truncation all work.
56
+ * Rendered through an SVG foreignObject, which keeps it inside the chart and its hover state.
57
+ */
58
+ export declare function Body({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element | null;
59
+ /**
60
+ * Shows the hovered slice's label, formatted by `labelToString` on Root.
61
+ * While nothing is hovered it shows its children: name the measure the total stands for, e.g. `Total sales`.
62
+ */
63
+ export declare function BodyTitle({ disableStyle, className, children, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
64
+ /** Shows the hovered slice's value, or the sum of every value while nothing is hovered. */
65
+ export declare function BodyValue({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
66
+ export type LegendListProps<Data extends Datum = Datum> = Omit<ComponentProps<'ul'>, 'children'> & StyleProps & {
67
+ /** Receives each record with its position in data, and returns its row, like Combobox.List. */
68
+ children: (datum: Data, index: number) => ReactNode;
69
+ /**
70
+ * Where the legend sits.
71
+ * - `'right'`: beside the donut, vertically centered. The usual choice in cards with room to spare.
72
+ * - `'bottom'`: under the donut. Use it in narrow cards.
73
+ * @default 'right'
74
+ */
75
+ position?: 'right' | 'bottom';
76
+ };
77
+ /** The legend's list of rows. Recharts' native Legend places and sizes it; its content slot renders this list. */
78
+ export declare function LegendList<Data extends Datum = Datum>({ children, position, className, disableStyle, ...props }: LegendListProps<Data>): import("react").JSX.Element;
79
+ /** One legend row. Dims along with its slice while another slice is hovered. */
80
+ export declare function LegendItem({ disableStyle, className, ...props }: ComponentProps<'li'> & StyleProps): import("react").JSX.Element;
81
+ export declare function LegendColorIndicator({ disableStyle, className, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
82
+ /** Shows the row's label, formatted by `labelToString` on Root. */
83
+ export declare function LegendLabel({ disableStyle, className, ...props }: Omit<ComponentProps<'span'>, 'children'> & StyleProps): import("react").JSX.Element;
84
+ /** Shows the row's value, formatted by `valueToString` on Root. */
85
+ export declare function LegendValue({ disableStyle, className, ...props }: Omit<ComponentProps<'span'>, 'children'> & StyleProps): import("react").JSX.Element;
86
+ export type TooltipProps<Data extends Datum = Datum> = Pick<RechartsTooltipProps<number, string>, 'offset' | 'allowEscapeViewBox' | 'portal'> & {
87
+ /** Receives the hovered record and returns the popup. */
88
+ children: (datum: Data) => ReactNode;
89
+ };
90
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
91
+ export declare function Tooltip<Data extends Datum = Datum>({ children, offset, allowEscapeViewBox, portal, }: TooltipProps<Data>): null;
92
+ export declare function TooltipPopup({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
93
+ export declare function TooltipTitle({ disableStyle, className, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
94
+ /** Shows the hovered slice's label, formatted by `labelToString` on Root. */
95
+ export declare function TooltipLabel({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
96
+ /** Shows the hovered slice's value, formatted by `valueToString` on Root. */
97
+ export declare function TooltipValue({ disableStyle, className, ...props }: Omit<ComponentProps<'p'>, 'children'> & StyleProps): import("react").JSX.Element;
98
+ /** Carries the hovered slice's `data-index`, so it can match that slice's color. */
99
+ export declare function TooltipColorIndicator({ disableStyle, className, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
100
+ export {};
@@ -0,0 +1,178 @@
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 { Legend as RechartsLegend, Pie as RechartsPie, PieChart as RechartsPieChart, Sector as RechartsSector, Tooltip as RechartsTooltip, useActiveTooltipDataPoints, usePlotArea, } from 'recharts';
5
+ /** Inner radius as a share of the outer one: the ring is 16% of the radius thick. */
6
+ const INNER_RADIUS = 0.84;
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(), ...chart }) {
10
+ return (_jsx(ChartContext.Provider, { value: { ...chart, labelToString, valueToString }, children: children }));
11
+ }
12
+ function useChart(part) {
13
+ const chart = useContext(ChartContext);
14
+ if (!chart)
15
+ throw new Error(`DonutChart.${part} must be inside DonutChart.Root`);
16
+ return chart;
17
+ }
18
+ /** The hovered slice's record and position in data, read from Recharts' own hover state. */
19
+ function useActiveSlice(part) {
20
+ const chart = useChart(part);
21
+ const [point] = useActiveTooltipDataPoints() ?? [];
22
+ const index = point
23
+ ? chart.data.findIndex((datum) => datum.label === point.label)
24
+ : -1;
25
+ return index < 0 ? null : { datum: chart.data[index], index };
26
+ }
27
+ /** Lets a Tooltip part hand its content to the Container, which owns the single Recharts tooltip. */
28
+ const TooltipSlotContext = /* @__PURE__ */ createContext(null);
29
+ /** Recharts supplies its own responsive container, so no extra wrapper is needed. */
30
+ export function Container({ height = 240, className, style, children, ...props }) {
31
+ const chart = useChart('Container');
32
+ const [tooltip, setTooltip] = useState(null);
33
+ return (_jsxs(RechartsPieChart, { margin: { top: 0, right: 0, 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, children: [_jsx(TooltipSlotContext.Provider, { value: setTooltip, children: children }), _jsx(RechartsTooltip, { offset: 12, ...tooltip?.props, animationDuration: 200, animationEasing: "ease-out", content: (state) => {
34
+ if (!tooltip || !state.active || !state.payload.length)
35
+ return null;
36
+ // Recharts types the payload as unknown; payload[0] is always the hovered record.
37
+ const datum = state.payload[0].payload;
38
+ return (_jsx(TooltipContext.Provider, { value: datum, children: tooltip.render(datum) }));
39
+ } })] }));
40
+ }
41
+ /** Shared ring geometry, so the track and the slices always line up. */
42
+ const ring = {
43
+ cx: '50%',
44
+ cy: '50%',
45
+ innerRadius: `${INNER_RADIUS * 100}%`,
46
+ outerRadius: '100%',
47
+ startAngle: 90,
48
+ endAngle: -270,
49
+ stroke: 'none',
50
+ isAnimationActive: false,
51
+ };
52
+ /** Optional full ring behind the slices. It keeps the donut visible when every value is 0. */
53
+ export function Track({ className }) {
54
+ return (_jsx(RechartsPie, { ...ring, data: [{ value: 1 }], dataKey: "value", tooltipType: "none", legendType: "none",
55
+ // The track is a backdrop: it never takes the pointer from the slices.
56
+ pointerEvents: "none", shape: (sector) => (_jsx(RechartsSector, { ...sector, className: className, "data-component": "donutchart-track" })) }));
57
+ }
58
+ export function Slices({ className, gap = 2 }) {
59
+ const chart = useChart('Slices');
60
+ return (_jsx(RechartsPie, { ...ring, data: chart.data, dataKey: "value", nameKey: "label", paddingAngle: gap,
61
+ // Recharts' native shape slot renders each slice ourselves, so className and data attributes land on the drawn element.
62
+ shape: (sector) => (_jsx(Slice, { ...sector, className: className })) }));
63
+ }
64
+ function Slice({ className, ...sector }) {
65
+ const active = useActiveSlice('Slices');
66
+ return (_jsx(RechartsSector, { ...sector, className: className, "data-component": "donutchart-slice", "data-index": sector.index, "data-active": active?.index === sector.index ? '' : undefined, "data-inactive": active && active.index !== sector.index ? '' : undefined }));
67
+ }
68
+ /**
69
+ * HTML laid over the donut's hole, so its content is ordinary JSX: Tailwind, fonts, and truncation all work.
70
+ * Rendered through an SVG foreignObject, which keeps it inside the chart and its hover state.
71
+ */
72
+ export function Body({ disableStyle, className, ...props }) {
73
+ const plotArea = usePlotArea();
74
+ const active = useActiveSlice('Body');
75
+ if (!plotArea)
76
+ return null;
77
+ const radius = (Math.min(plotArea.width, plotArea.height) / 2) * INNER_RADIUS;
78
+ // The largest square that fits in the hole.
79
+ const side = radius * Math.SQRT2;
80
+ return (_jsx("foreignObject", { x: plotArea.x + plotArea.width / 2 - side / 2, y: plotArea.y + plotArea.height / 2 - side / 2, width: side, height: side,
81
+ // The hole stays transparent to the pointer, so hovering it never blocks a slice.
82
+ pointerEvents: "none", children: _jsx("div", { ...props, "data-component": "donutchart-body", "data-active": active ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
83
+ }
84
+ /**
85
+ * Shows the hovered slice's label, formatted by `labelToString` on Root.
86
+ * While nothing is hovered it shows its children: name the measure the total stands for, e.g. `Total sales`.
87
+ */
88
+ export function BodyTitle({ disableStyle, className, children, ...props }) {
89
+ const chart = useChart('BodyTitle');
90
+ const active = useActiveSlice('BodyTitle');
91
+ return (_jsx("p", { ...props, "data-component": "donutchart-bodytitle", "data-index": active?.index, "data-active": active ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: active ? chart.labelToString(active.datum.label) : children }));
92
+ }
93
+ /** Shows the hovered slice's value, or the sum of every value while nothing is hovered. */
94
+ export function BodyValue({ disableStyle, className, ...props }) {
95
+ const chart = useChart('BodyValue');
96
+ const active = useActiveSlice('BodyValue');
97
+ const total = chart.data.reduce((sum, datum) => sum + datum.value, 0);
98
+ return (_jsx("p", { ...props, "data-component": "donutchart-bodyvalue", "data-index": active?.index, "data-active": active ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.valueToString(active ? active.datum.value : total) }));
99
+ }
100
+ /** The legend's list of rows. Recharts' native Legend places and sizes it; its content slot renders this list. */
101
+ export function LegendList({ children, position = 'right', className, disableStyle, ...props }) {
102
+ const chart = useChart('LegendList');
103
+ return (_jsx(RechartsLegend, { layout: "vertical", align: position === 'right' ? 'right' : 'center', verticalAlign: position === 'right' ? 'middle' : 'bottom', content: () => (_jsx("ul", { ...props, "data-component": "donutchart-legendlist", "data-position": position, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.data.map((datum, index) => (_jsx(LegendContext.Provider, { value: { datum, index }, children: children(datum, index) }, datum.label))) })) }));
104
+ }
105
+ const LegendContext = /* @__PURE__ */ createContext(null);
106
+ function useLegendRow(part) {
107
+ const row = useContext(LegendContext);
108
+ if (!row)
109
+ throw new Error(`DonutChart.${part} must be inside DonutChart.LegendList`);
110
+ return row;
111
+ }
112
+ /** One legend row. Dims along with its slice while another slice is hovered. */
113
+ export function LegendItem({ disableStyle, className, ...props }) {
114
+ const row = useLegendRow('LegendItem');
115
+ const active = useActiveSlice('LegendItem');
116
+ return (_jsx("li", { ...props, "data-component": "donutchart-legenditem", "data-index": row.index, "data-active": active?.index === row.index ? '' : undefined, "data-inactive": active && active.index !== row.index ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className }));
117
+ }
118
+ export function LegendColorIndicator({ disableStyle, className, ...props }) {
119
+ const row = useLegendRow('LegendColorIndicator');
120
+ return (_jsx("span", { "aria-hidden": "true", ...props, "data-component": "donutchart-legendcolorindicator", "data-index": row.index, "data-style-disabled": disableStyle ? '' : undefined, className: className }));
121
+ }
122
+ /** Shows the row's label, formatted by `labelToString` on Root. */
123
+ export function LegendLabel({ disableStyle, className, ...props }) {
124
+ const chart = useChart('LegendLabel');
125
+ const row = useLegendRow('LegendLabel');
126
+ return (_jsx("span", { ...props, "data-component": "donutchart-legendlabel", "data-index": row.index, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.labelToString(row.datum.label) }));
127
+ }
128
+ /** Shows the row's value, formatted by `valueToString` on Root. */
129
+ export function LegendValue({ disableStyle, className, ...props }) {
130
+ const chart = useChart('LegendValue');
131
+ const row = useLegendRow('LegendValue');
132
+ return (_jsx("span", { ...props, "data-component": "donutchart-legendvalue", "data-index": row.index, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.valueToString(row.datum.value) }));
133
+ }
134
+ const TooltipContext = /* @__PURE__ */ createContext(null);
135
+ /** Renders no element: hands its popup to the Container. For extra fields, specify the record type: Tooltip<(typeof data)[number]>. */
136
+ export function Tooltip({ children, offset, allowEscapeViewBox, portal, }) {
137
+ const setTooltip = useContext(TooltipSlotContext);
138
+ if (!setTooltip)
139
+ throw new Error('DonutChart.Tooltip must be inside DonutChart.Container');
140
+ useLayoutEffect(() => {
141
+ setTooltip({
142
+ render: children,
143
+ props: { offset, allowEscapeViewBox, portal },
144
+ });
145
+ return () => setTooltip(null);
146
+ }, [setTooltip, children, offset, allowEscapeViewBox, portal]);
147
+ return null;
148
+ }
149
+ function useTooltipDatum(part) {
150
+ const datum = useContext(TooltipContext);
151
+ if (!datum)
152
+ throw new Error(`DonutChart.${part} must be inside DonutChart.Tooltip`);
153
+ return datum;
154
+ }
155
+ export function TooltipPopup({ disableStyle, className, ...props }) {
156
+ return (_jsx("div", { ...props, "data-component": "donutchart-tooltip", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
157
+ }
158
+ export function TooltipTitle({ disableStyle, className, ...props }) {
159
+ return (_jsx("p", { ...props, "data-component": "donutchart-tooltiptitle", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
160
+ }
161
+ /** Shows the hovered slice's label, formatted by `labelToString` on Root. */
162
+ export function TooltipLabel({ disableStyle, className, ...props }) {
163
+ const chart = useChart('TooltipLabel');
164
+ const datum = useTooltipDatum('TooltipLabel');
165
+ return (_jsx("p", { ...props, "data-component": "donutchart-tooltiplabel", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.labelToString(datum.label) }));
166
+ }
167
+ /** Shows the hovered slice's value, formatted by `valueToString` on Root. */
168
+ export function TooltipValue({ disableStyle, className, ...props }) {
169
+ const chart = useChart('TooltipValue');
170
+ const datum = useTooltipDatum('TooltipValue');
171
+ return (_jsx("p", { ...props, "data-component": "donutchart-tooltipvalue", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: chart.valueToString(datum.value) }));
172
+ }
173
+ /** Carries the hovered slice's `data-index`, so it can match that slice's color. */
174
+ export function TooltipColorIndicator({ disableStyle, className, ...props }) {
175
+ const chart = useChart('TooltipColorIndicator');
176
+ const datum = useTooltipDatum('TooltipColorIndicator');
177
+ return (_jsx("span", { "aria-hidden": "true", ...props, "data-component": "donutchart-tooltipcolorindicator", "data-index": chart.data.findIndex((item) => item.label === datum.label), "data-style-disabled": disableStyle ? '' : undefined, className: className }));
178
+ }
@@ -1,7 +1,8 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
+ import type { AsChildProps } from '../../utils/asChild.ts';
2
3
  import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
3
4
  import type { ReactElement } from 'react';
4
- import type { LucideProps } from 'lucide-react';
5
+ import type { SVGIconProps } from '../../types/Icon.ts';
5
6
  /**
6
7
  * Choose swipeDirection on Root and keep trigger and Popup in that Root. Popup already includes its portal. Provider and Indent parts are for an optional indented-background composition, not required for a basic drawer.
7
8
  *
@@ -11,9 +12,9 @@ import type { LucideProps } from 'lucide-react';
11
12
  * function Example() {
12
13
  * return (
13
14
  * <Drawer.Root swipeDirection="right">
14
- * <Drawer.OpenHandler>
15
+ * <Drawer.OpenButton asChild>
15
16
  * <Button.default variant="secondary">Open account</Button.default>
16
- * </Drawer.OpenHandler>
17
+ * </Drawer.OpenButton>
17
18
  * <Drawer.Backdrop />
18
19
  * <Drawer.Popup>
19
20
  * <Drawer.Header>
@@ -25,9 +26,9 @@ import type { LucideProps } from 'lucide-react';
25
26
  * </Drawer.Header>
26
27
  * <Drawer.Body>Account information goes here.</Drawer.Body>
27
28
  * <Drawer.Footer>
28
- * <Drawer.CloseHandler>
29
+ * <Drawer.CloseButton asChild>
29
30
  * <Button.default variant="primary">Done</Button.default>
30
- * </Drawer.CloseHandler>
31
+ * </Drawer.CloseButton>
31
32
  * </Drawer.Footer>
32
33
  * </Drawer.Popup>
33
34
  * </Drawer.Root>
@@ -57,25 +58,15 @@ export declare const Indent: import("react").ForwardRefExoticComponent<Omit<Omit
57
58
  export declare const SwipeArea: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerSwipeAreaProps, "className"> & {
58
59
  className?: string;
59
60
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
60
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
61
- export declare const OpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<BaseDrawer.Trigger.Props<unknown>, "children" | "className" | "render"> & {
62
- className?: string;
63
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
64
- children: ReactElement;
65
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
66
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
67
- export declare const CloseHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerCloseProps, "children" | "className" | "render"> & {
61
+ /** Opens the drawer. Pass asChild to give this behavior to your own element, like your app's Button. */
62
+ export declare const OpenButton: import("react").ForwardRefExoticComponent<Omit<Omit<BaseDrawer.Trigger.Props<unknown>, "className" | "render"> & {
68
63
  className?: string;
69
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
70
- children: ReactElement;
71
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
64
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
72
65
  export type PopupProps = Omit<BaseDrawer.Popup.Props, 'className'> & {
73
66
  className?: string;
74
67
  } & Pick<BaseDrawer.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
75
68
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
76
- export declare const Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerPopupProps, "className"> & {
77
- className?: string;
78
- } & Pick<import("@base-ui/react").DrawerPortalProps, "keepMounted" | "container"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
69
+ export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
79
70
  export declare const Backdrop: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerBackdropProps, "className"> & {
80
71
  className?: string;
81
72
  } & Pick<import("@base-ui/react").DrawerPortalProps, "keepMounted" | "container"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -88,12 +79,12 @@ export declare const Title: import("react").ForwardRefExoticComponent<Omit<Omit<
88
79
  export declare const Description: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerDescriptionProps, "className"> & {
89
80
  className?: string;
90
81
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
91
- export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerCloseProps, "className"> & {
82
+ /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Close drawer". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
83
+ export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerCloseProps, "className" | "render"> & {
92
84
  className?: string;
93
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
85
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
94
86
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
95
- export declare const CloseButtonIcon: import("react").ForwardRefExoticComponent<Omit<LucideProps & {
87
+ export declare const CloseButtonIcon: import("react").ForwardRefExoticComponent<Omit<SVGIconProps & {
96
88
  /** Omit for the supplied default icon; pass a child only to replace it. */
97
- children?: ReactElement<LucideProps>;
89
+ children?: ReactElement<SVGIconProps>;
98
90
  } & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
99
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { asChildRendering } from "../../utils/asChild.js";
2
3
  import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
3
4
  import { cloneElement, forwardRef } from 'react';
4
5
  import { twMerge } from 'tailwind-merge';
5
- import { X } from 'lucide-react';
6
+ import { X } from "../../utils/icons.js";
6
7
  /**
7
8
  * Choose swipeDirection on Root and keep trigger and Popup in that Root. Popup already includes its portal. Provider and Indent parts are for an optional indented-background composition, not required for a basic drawer.
8
9
  *
@@ -12,9 +13,9 @@ import { X } from 'lucide-react';
12
13
  * function Example() {
13
14
  * return (
14
15
  * <Drawer.Root swipeDirection="right">
15
- * <Drawer.OpenHandler>
16
+ * <Drawer.OpenButton asChild>
16
17
  * <Button.default variant="secondary">Open account</Button.default>
17
- * </Drawer.OpenHandler>
18
+ * </Drawer.OpenButton>
18
19
  * <Drawer.Backdrop />
19
20
  * <Drawer.Popup>
20
21
  * <Drawer.Header>
@@ -26,9 +27,9 @@ import { X } from 'lucide-react';
26
27
  * </Drawer.Header>
27
28
  * <Drawer.Body>Account information goes here.</Drawer.Body>
28
29
  * <Drawer.Footer>
29
- * <Drawer.CloseHandler>
30
+ * <Drawer.CloseButton asChild>
30
31
  * <Button.default variant="primary">Done</Button.default>
31
- * </Drawer.CloseHandler>
32
+ * </Drawer.CloseButton>
32
33
  * </Drawer.Footer>
33
34
  * </Drawer.Popup>
34
35
  * </Drawer.Root>
@@ -49,80 +50,78 @@ export function Root({ swipeDirection = 'right', ...props }) {
49
50
  /** Optional: use around IndentBackground, Indent and drawers when app indentation is needed. */
50
51
  export const Provider = BaseDrawer.Provider;
51
52
  /** Optional: background layer for app indentation; use with Indent inside Provider. */
52
- export const IndentBackground = forwardRef(function IndentBackground({ disableStyle, className, ...props }, ref) {
53
+ export const IndentBackground = /* @__PURE__ */ forwardRef(function IndentBackground({ disableStyle, className, ...props }, ref) {
53
54
  return (_jsx(BaseDrawer.IndentBackground, { ...props, ref: ref, "data-component": "drawer-indentbackground", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
54
55
  });
55
56
  /** Optional: wraps the app content when indentation is needed; use inside Provider. */
56
- export const Indent = forwardRef(function Indent({ disableStyle, className, ...props }, ref) {
57
+ export const Indent = /* @__PURE__ */ forwardRef(function Indent({ disableStyle, className, ...props }, ref) {
57
58
  return (_jsx(BaseDrawer.Indent, { ...props, ref: ref, "data-component": "drawer-indent", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
58
59
  });
59
60
  /** Optional: a custom swipe-to-open area outside Popup but inside Root. Unpainted by default; style its size and position at the call site. */
60
- export const SwipeArea = forwardRef(function SwipeArea({ disableStyle, className, ...props }, ref) {
61
+ export const SwipeArea = /* @__PURE__ */ forwardRef(function SwipeArea({ disableStyle, className, ...props }, ref) {
61
62
  return (_jsx(BaseDrawer.SwipeArea, { ...props, ref: ref, "data-component": "drawer-swipearea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
62
63
  });
63
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
64
- export const OpenHandler = forwardRef(function OpenHandler({ children, ...props }, ref) {
65
- return _jsx(BaseDrawer.Trigger, { ...props, ref: ref, render: children });
66
- });
67
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
68
- export const CloseHandler = forwardRef(function CloseHandler({ children, ...props }, ref) {
69
- return _jsx(BaseDrawer.Close, { ...props, ref: ref, render: children });
64
+ /** Opens the drawer. Pass asChild to give this behavior to your own element, like your app's Button. */
65
+ export const OpenButton = /* @__PURE__ */ forwardRef(function OpenButton({ asChild, disableStyle, children, ...props }, ref) {
66
+ const rendering = asChildRendering({ asChild, children, component: 'drawer-openbutton', disableStyle });
67
+ return _jsx(BaseDrawer.Trigger, { ...props, ref: ref, ...rendering });
70
68
  });
71
69
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
72
- export const Popup = forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
70
+ export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
73
71
  return (_jsx(BaseDrawer.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDrawer.Viewport, { children: _jsx(BaseDrawer.Popup, { ...props, ref: ref, "data-component": "drawer-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className, style: (state) => {
74
- const offset = state.swipeDirection === 'left' || state.swipeDirection === 'up'
75
- ? '-100%'
76
- : '100%';
77
72
  const vertical = state.swipeDirection === 'up' || state.swipeDirection === 'down';
78
- const transitioning = state.transitionStatus === 'starting' ||
79
- state.transitionStatus === 'ending';
80
- const baseStyle = {
73
+ // Sliding in and out from the side it swipes towards, otherwise following the finger (and the snap point, vertically)
74
+ const transform = (() => {
75
+ const offset = state.swipeDirection === 'left' || state.swipeDirection === 'up' ? '-100%' : '100%';
76
+ if (state.transitionStatus === 'starting' || state.transitionStatus === 'ending')
77
+ return vertical ? 'translateY(' + offset + ')' : 'translateX(' + offset + ')';
78
+ if (vertical)
79
+ return 'translateY(calc(var(--drawer-snap-point-offset, 0px) + var(--drawer-swipe-movement-y, 0px)))';
80
+ return 'translateX(var(--drawer-swipe-movement-x, 0px))';
81
+ })();
82
+ // No transition while the finger drags it, and a faster close after a strong swipe
83
+ const transitionDuration = (() => {
84
+ if (state.swiping)
85
+ return '0ms';
86
+ if (state.transitionStatus === 'ending')
87
+ return 'calc(var(--drawer-swipe-strength, 1) * 300ms)';
88
+ return '300ms';
89
+ })();
90
+ return {
81
91
  zIndex: 40,
82
- transform: transitioning
83
- ? vertical
84
- ? 'translateY(' + offset + ')'
85
- : 'translateX(' + offset + ')'
86
- : vertical
87
- ? 'translateY(calc(var(--drawer-snap-point-offset, 0px) + var(--drawer-swipe-movement-y, 0px)))'
88
- : 'translateX(var(--drawer-swipe-movement-x, 0px))',
92
+ transform,
89
93
  transitionProperty: 'transform',
90
- transitionDuration: state.swiping
91
- ? '0ms'
92
- : state.transitionStatus === 'ending'
93
- ? 'calc(var(--drawer-swipe-strength, 1) * 300ms)'
94
- : '300ms',
94
+ transitionDuration,
95
95
  transitionTimingFunction: 'ease-out',
96
- };
97
- return {
98
- ...baseStyle,
99
96
  ...(typeof style === 'function' ? style(state) : style),
100
97
  };
101
98
  } }) }) }));
102
99
  });
103
- export const Backdrop = forwardRef(function Backdrop({ disableStyle, container, keepMounted, className, ...props }, ref) {
100
+ export const Backdrop = /* @__PURE__ */ forwardRef(function Backdrop({ disableStyle, container, keepMounted, className, ...props }, ref) {
104
101
  return (_jsx(BaseDrawer.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDrawer.Backdrop, { ...props, ref: ref, "data-component": "drawer-backdrop", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
105
102
  });
106
- export const Header = forwardRef(function Header({ disableStyle, className, ...props }, ref) {
103
+ export const Header = /* @__PURE__ */ forwardRef(function Header({ disableStyle, className, ...props }, ref) {
107
104
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
108
105
  });
109
- export const Body = forwardRef(function Body({ disableStyle, className, ...props }, ref) {
106
+ export const Body = /* @__PURE__ */ forwardRef(function Body({ disableStyle, className, ...props }, ref) {
110
107
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
111
108
  });
112
- export const Footer = forwardRef(function Footer({ disableStyle, className, ...props }, ref) {
109
+ export const Footer = /* @__PURE__ */ forwardRef(function Footer({ disableStyle, className, ...props }, ref) {
113
110
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-footer", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
114
111
  });
115
- export const Title = forwardRef(function Title({ disableStyle, className, ...props }, ref) {
112
+ export const Title = /* @__PURE__ */ forwardRef(function Title({ disableStyle, className, ...props }, ref) {
116
113
  return (_jsx(BaseDrawer.Title, { ...props, ref: ref, "data-component": "drawer-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
117
114
  });
118
- export const Description = forwardRef(function Description({ disableStyle, className, ...props }, ref) {
115
+ export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
119
116
  return (_jsx(BaseDrawer.Description, { ...props, ref: ref, "data-component": "drawer-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
120
117
  });
121
- export const CloseButton = forwardRef(function CloseButton({ disableStyle, className, ...props }, ref) {
122
- return (_jsx(BaseDrawer.Close, { ...props, ref: ref, "data-component": "drawer-closebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
118
+ /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Close drawer". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
119
+ export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ asChild, disableStyle, children, ...props }, ref) {
120
+ const rendering = asChildRendering({ asChild, children, component: 'drawer-closebutton', disableStyle });
121
+ return _jsx(BaseDrawer.Close, { ...props, ref: ref, ...rendering });
123
122
  });
124
123
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
125
- export const CloseButtonIcon = forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
124
+ export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
126
125
  return cloneElement(children ?? _jsx(X, {}), {
127
126
  ...props,
128
127
  ref,
@@ -134,4 +133,3 @@ export const CloseButtonIcon = forwardRef(function CloseButtonIcon({ disableStyl
134
133
  className: twMerge(children?.props.className, className),
135
134
  });
136
135
  });
137
- //# sourceMappingURL=index.js.map
@@ -26,7 +26,7 @@ import type { ComponentProps, HTMLAttributes, ImgHTMLAttributes, ReactElement }
26
26
  * )
27
27
  * }
28
28
  */
29
- export declare function Surface({ disableStyle, className, children, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
29
+ export declare function Surface({ disableStyle, className, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
30
30
  export declare function Body({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
31
31
  export declare function Title({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
32
32
  export declare function Description({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
@@ -37,4 +37,3 @@ export declare function Icon({ disableStyle, children, className, ...props }: (O
37
37
  children: ReactElement<ComponentProps<'svg'>>;
38
38
  }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
39
39
  export declare function ActionsList({ disableStyle, className, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
40
- //# sourceMappingURL=index.d.ts.map
@@ -27,8 +27,8 @@ import { twMerge } from 'tailwind-merge';
27
27
  * )
28
28
  * }
29
29
  */
30
- export function Surface({ disableStyle, className, children, ...props }) {
31
- return (_jsx("div", { "data-component": "empty-surface", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props, children: children }));
30
+ export function Surface({ disableStyle, className, ...props }) {
31
+ return (_jsx("div", { "data-component": "empty-surface", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
32
32
  }
33
33
  export function Body({ disableStyle, className, ...props }) {
34
34
  return (_jsx("div", { ...props, "data-component": "empty-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
@@ -45,7 +45,6 @@ export function Image({ disableStyle, className, ...props }) {
45
45
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
46
46
  export function Icon({ disableStyle, children, className, ...props }) {
47
47
  return cloneElement(children, {
48
- ...children.props,
49
48
  ...props,
50
49
  ...{
51
50
  'data-component': 'empty-icon',
@@ -58,4 +57,3 @@ export function Icon({ disableStyle, children, className, ...props }) {
58
57
  export function ActionsList({ disableStyle, className, ...props }) {
59
58
  return (_jsx("div", { "data-component": "empty-actionslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
60
59
  }
61
- //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@ import type { StyleProps } from '../../types/Style.ts';
2
2
  import { FileUpload as ArkFileUpload, type FileUploadFileRejection } from '@ark-ui/react/file-upload';
3
3
  import type { ComponentProps, ReactElement, ReactNode } from 'react';
4
4
  /**
5
- * 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.
5
+ * 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.
6
6
  *
7
7
  * @example Complete composition
8
8
  * import { FileUpload } from '@central-ui/react'
@@ -16,7 +16,7 @@ import type { ComponentProps, ReactElement, ReactNode } from 'react';
16
16
  * <FileUpload.UploadIcon />
17
17
  * <FileUpload.Title>Drop an image here</FileUpload.Title>
18
18
  * <FileUpload.Description>PNG or JPG up to 10 MB.</FileUpload.Description>
19
- * <FileUpload.FilePickerOpenButton>Browse image</FileUpload.FilePickerOpenButton>
19
+ * <FileUpload.PickerButton>Browse image</FileUpload.PickerButton>
20
20
  * <FileUpload.FileList>
21
21
  * {({ file, status }) => (
22
22
  * <FileUpload.File file={file} status={status}>
@@ -50,7 +50,8 @@ export declare function Root({ children, ...props }: Omit<ArkFileUpload.RootProp
50
50
  export declare function Container({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
51
51
  export declare function Label({ disableStyle, className, ...props }: ArkFileUpload.LabelProps & StyleProps): import("react").JSX.Element;
52
52
  export declare function Dropzone({ disableStyle, children, className, ...props }: ArkFileUpload.DropzoneProps & StyleProps): import("react").JSX.Element;
53
- export declare function FilePickerOpenButton({ disableStyle, className, ...props }: ArkFileUpload.TriggerProps & StyleProps): import("react").JSX.Element;
53
+ /** 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. */
54
+ export declare function PickerButton({ asChild, disableStyle, ...props }: ArkFileUpload.TriggerProps & StyleProps): import("react").JSX.Element;
54
55
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
55
56
  export declare function UploadIcon({ disableStyle, children, className, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
56
57
  /** Omit for the supplied default icon; pass a child only to replace it. */
@@ -90,11 +91,6 @@ export declare function FileThumbnailIcon({ disableStyle, children, className, .
90
91
  export declare function FileName({ disableStyle, className, ...props }: ArkFileUpload.ItemNameProps & StyleProps): import("react").JSX.Element;
91
92
  /** Reads the surrounding File automatically. Omit children to keep the supplied text; override only for custom presentation. */
92
93
  export declare function FileSize({ disableStyle, className, ...props }: ArkFileUpload.ItemSizeTextProps & StyleProps): import("react").JSX.Element;
93
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
94
- export declare function FileRemoveHandler({ children, ...props }: Omit<ArkFileUpload.ItemDeleteTriggerProps, 'asChild' | 'children'> & {
95
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
96
- children: ReactElement;
97
- }): import("react").JSX.Element;
98
94
  /** Removes the surrounding file automatically, including rejected entries. No extra removal click handler needed. */
99
95
  export declare function FileRemoveButton({ disableStyle, children, className, ...props }: (Omit<ArkFileUpload.ItemDeleteTriggerProps, 'asChild' | 'children'> & {
100
96
  children?: ReactNode;
@@ -104,4 +100,3 @@ export declare function FileRemoveButtonIcon({ disableStyle, children, className
104
100
  /** Omit for the supplied default icon; pass a child only to replace it. */
105
101
  children?: ReactElement<ComponentProps<'svg'>>;
106
102
  }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
107
- //# sourceMappingURL=index.d.ts.map