@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,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { asChildStyleAttributes } from "../../utils/asChild.js";
2
3
  import { DatePicker as AriaDatePicker, DatePickerStateContext, } from 'react-aria-components/DatePicker';
3
4
  import { DateRangePicker as AriaDateRangePicker, DateRangePickerStateContext, } from 'react-aria-components/DateRangePicker';
4
5
  import { RangeCalendar as AriaRangeCalendar, RangeCalendarStateContext, } from 'react-aria-components/RangeCalendar';
@@ -21,15 +22,19 @@ import { useLocale } from 'react-aria/I18nProvider';
21
22
  import { useDateFormatter } from 'react-aria/useDateFormatter';
22
23
  import { mergeProps } from 'react-aria/mergeProps';
23
24
  import { cloneElement, createContext, forwardRef, useContext, Fragment, useState, useMemo, } from 'react';
24
- import { CalendarDays, Check, ChevronLeft, ChevronRight, LoaderCircle, } from 'lucide-react';
25
+ import { CalendarDays, Check, ChevronLeft, ChevronRight, LoaderCircle, } from "../../utils/icons.js";
25
26
  import { twMerge } from 'tailwind-merge';
26
- import { ToneProvider, useToneContext } from "../../utils/Tone.js";
27
- const SinglePicker = /* @__PURE__ */ forwardRef(function SinglePicker({ mode, locale, tone, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, invalid, open, isDateUnavailable, ...props }, ref) {
28
- return (_jsx(AriaDatePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateString(value), defaultValue: parseDateString(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (date) => onValueChange?.(date ? toGregorianDateString(date) : null), isDateUnavailable: isDateUnavailable &&
27
+ import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
28
+ const SinglePicker = /* @__PURE__ */ forwardRef(function SinglePicker({ mode, locale, validation, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, open, isDateUnavailable, ...props }, ref) {
29
+ return (_jsx(AriaDatePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required,
30
+ // An error validation marks it invalid; otherwise Aria keeps running its own validation
31
+ isInvalid: readValidation(validation).state === 'error' || undefined, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateString(value), defaultValue: parseDateString(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (date) => onValueChange?.(date ? toGregorianDateString(date) : null), isDateUnavailable: isDateUnavailable &&
29
32
  ((date) => isDateUnavailable(toGregorianDateString(date))) }));
30
33
  });
31
- const RangePicker = /* @__PURE__ */ forwardRef(function RangePicker({ mode, locale, tone, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, invalid, open, isDateUnavailable, ...props }, ref) {
32
- return (_jsx(AriaDateRangePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required, isInvalid: invalid, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateRange(value), defaultValue: parseDateRange(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (range) => onValueChange?.(range
34
+ const RangePicker = /* @__PURE__ */ forwardRef(function RangePicker({ mode, locale, validation, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, open, isDateUnavailable, ...props }, ref) {
35
+ return (_jsx(AriaDateRangePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required,
36
+ // An error validation marks it invalid; otherwise Aria keeps running its own validation
37
+ isInvalid: readValidation(validation).state === 'error' || undefined, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateRange(value), defaultValue: parseDateRange(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (range) => onValueChange?.(range
33
38
  ? {
34
39
  start: toGregorianDateString(range.start),
35
40
  end: toGregorianDateString(range.end),
@@ -121,14 +126,15 @@ function Picker({ pickerRef, ...props }) {
121
126
  export const Root = /* @__PURE__ */ forwardRef(function Root(props, ref) {
122
127
  const [buttonAnchor, setButtonAnchor] = useState(null);
123
128
  const buttonAnchorRef = useMemo(() => ({ current: buttonAnchor }), [buttonAnchor]);
124
- return (_jsx(I18nProvider, { locale: props.locale ?? 'en-US', children: _jsx(ToneProvider, { value: props.tone ?? 'neutral', children: _jsx(ConfigurationContext.Provider, { value: {
125
- mode: props.mode ?? 'single',
126
- presets: props.presets ?? [],
127
- buttonAnchorRef,
128
- setButtonAnchor,
129
- disabled: props.disabled ?? false,
130
- readOnly: props.readOnly ?? false,
131
- }, children: _jsx(Picker, { ...props, pickerRef: ref }) }) }) }));
129
+ return (_jsx(I18nProvider, { locale: props.locale ?? 'en-US', children: _jsx(ConfigurationContext.Provider, { value: {
130
+ mode: props.mode ?? 'single',
131
+ presets: props.presets ?? [],
132
+ buttonAnchorRef,
133
+ setButtonAnchor,
134
+ disabled: props.disabled ?? false,
135
+ readOnly: props.readOnly ?? false,
136
+ validation: readValidation(props.validation),
137
+ }, children: _jsx(Picker, { ...props, pickerRef: ref }) }) }));
132
138
  });
133
139
  export function Container({ disableStyle, className, ...props }) {
134
140
  return (_jsx("div", { ...props, ...usePartAttributes(), "data-component": "datepicker-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
@@ -148,7 +154,6 @@ export function AddonText({ disableStyle, className, ...props }) {
148
154
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
149
155
  export function AddonIcon({ disableStyle, children, className, ...props }) {
150
156
  return cloneElement(children, {
151
- ...children.props,
152
157
  ...props,
153
158
  ...usePartAttributes(),
154
159
  'aria-hidden': true,
@@ -163,7 +168,6 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
163
168
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
164
169
  export function AddonLoadingIcon({ disableStyle, children = _jsx(LoaderCircle, {}), className, ...props }) {
165
170
  return cloneElement(children, {
166
- ...children.props,
167
171
  ...props,
168
172
  ...usePartAttributes(),
169
173
  'aria-hidden': true,
@@ -213,7 +217,6 @@ export function AddonOpenButton({ disableStyle, className, isDisabled, ...props
213
217
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
214
218
  export function AddonOpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {}), className, ...props }) {
215
219
  return cloneElement(children, {
216
- ...children.props,
217
220
  ...props,
218
221
  ...usePartAttributes(),
219
222
  'aria-hidden': true,
@@ -225,57 +228,40 @@ export function AddonOpenButtonIcon({ disableStyle, children = _jsx(CalendarDays
225
228
  strokeWidth: props.strokeWidth ?? children.props.strokeWidth ?? 2,
226
229
  });
227
230
  }
228
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
229
- export function AddonOpenHandler({ children, isDisabled, ...props }) {
230
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, render: (buttonProps) => renderButtonChild(children, buttonProps) }));
231
- }
232
- export function OpenButton({ disableStyle, className, isDisabled, ...props }) {
233
- const { setButtonAnchor } = useContext(ConfigurationContext);
234
- return (_jsx(AriaGroup, { style: { display: 'contents' }, children: _jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, ref: setButtonAnchor, ...usePartAttributes(), "data-component": "datepicker-openbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
235
- }
236
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
237
- export function OpenHandler({ children, isDisabled, ...props }) {
238
- const { setButtonAnchor } = useContext(ConfigurationContext);
239
- return (_jsx(AriaGroup, { style: { display: 'contents' }, children: _jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, ref: setButtonAnchor, render: (buttonProps) => renderButtonChild(children, buttonProps) }) }));
231
+ /** Opens the calendar popup. Pass asChild to give this behavior to your own button, like a "Choose appointment" Button; it keeps the state data attributes but none of this part's styling. */
232
+ export function OpenButton({ asChild, disableStyle, isDisabled, children, ...props }) {
233
+ const context = useContext(ConfigurationContext);
234
+ const partAttributes = usePartAttributes();
235
+ // Deciding what renders: the consumer's child as the element when asChild, otherwise this part's own button
236
+ const rendering = asChild
237
+ ? { render: (buttonProps) => renderButtonChild(children, buttonProps) }
238
+ : { children };
239
+ return (_jsx(AriaGroup, { style: { display: 'contents' }, children: _jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, ref: context.setButtonAnchor, ...partAttributes, ...asChildStyleAttributes({ asChild, component: 'datepicker-openbutton', disableStyle }), ...rendering }) }));
240
240
  }
241
241
  /** Formats the selected date or range automatically. Omit children for the usual display; supply children only to replace it. Placeholder appears before selection. */
242
242
  export function OpenButtonValue({ disableStyle, children, placeholder = 'Select date', className, ...props }) {
243
243
  const single = useContext(DatePickerStateContext);
244
244
  const range = useContext(DateRangePickerStateContext);
245
- const { mode } = useContext(ConfigurationContext);
246
- const { locale } = useLocale();
247
- return (_jsx("span", { ...props, ...usePartAttributes(), "data-component": "datepicker-openbuttonvalue", "data-placeholder": children == null &&
248
- (mode === 'range'
249
- ? !range?.value.start || !range.value.end
250
- : !single?.value)
251
- ? ''
252
- : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children ??
245
+ const context = useContext(ConfigurationContext);
246
+ const i18n = useLocale();
247
+ // Whether no full date is selected yet, so the placeholder shows
248
+ const empty = context.mode === 'range' ? !range?.value.start || !range.value.end : !single?.value;
249
+ return (_jsx("span", { ...props, ...usePartAttributes(), "data-component": "datepicker-openbuttonvalue", "data-placeholder": children == null && empty ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children ??
253
250
  (() => {
254
- if (mode === 'range') {
255
- if (!range?.value.start || !range.value.end)
251
+ if (empty)
252
+ return placeholder;
253
+ if (context.mode === 'range') {
254
+ const formatted = range.formatValue(i18n.locale, { day: 'numeric', month: 'long', year: 'numeric' });
255
+ if (!formatted)
256
256
  return placeholder;
257
- const formatted = range.formatValue(locale, {
258
- day: 'numeric',
259
- month: 'long',
260
- year: 'numeric',
261
- });
262
- return formatted
263
- ? formatted.start + ' — ' + formatted.end
264
- : placeholder;
257
+ return formatted.start + ' — ' + formatted.end;
265
258
  }
266
- return single?.value
267
- ? single.formatValue(locale, {
268
- day: 'numeric',
269
- month: 'long',
270
- year: 'numeric',
271
- })
272
- : placeholder;
259
+ return single.formatValue(i18n.locale, { day: 'numeric', month: 'long', year: 'numeric' });
273
260
  })() }));
274
261
  }
275
262
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
276
263
  export function OpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {}), className, ...props }) {
277
264
  return cloneElement(children, {
278
- ...children.props,
279
265
  ...props,
280
266
  'aria-hidden': true,
281
267
  ...{
@@ -290,10 +276,10 @@ export function OpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {})
290
276
  export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, ...props }, ref) {
291
277
  // The Popover supplies dialog semantics itself. Merge DatePicker's generated dialog
292
278
  // id/labeling onto that same element instead of adding another Dialog wrapper.
293
- const { buttonAnchorRef } = useContext(ConfigurationContext);
279
+ const context = useContext(ConfigurationContext);
294
280
  const [mergedProps, mergedRef] = useContextProps(props, ref, DialogContext);
295
281
  const { className, style, placement = 'bottom end', offset = 5, ...rest } = mergedProps;
296
- return (_jsx(AriaPopover, { ...(buttonAnchorRef?.current ? { triggerRef: buttonAnchorRef } : {}), ...rest, ref: mergedRef, placement: placement, offset: offset, style: { minWidth: 'var(--trigger-width)', ...style }, "data-component": "datepicker-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
282
+ return (_jsx(AriaPopover, { ...(context.buttonAnchorRef?.current ? { triggerRef: context.buttonAnchorRef } : {}), ...rest, ref: mergedRef, placement: placement, offset: offset, style: { minWidth: 'var(--trigger-width)', ...style }, "data-component": "datepicker-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
297
283
  });
298
284
  function SingleCalendar({ disableStyle, className, focusedValue, defaultFocusedValue, onFocusChange, ...props }) {
299
285
  return (_jsx(AriaCalendar, { ...props, firstDayOfWeek: "mon", pageBehavior: "single", focusedValue: parseDateString(focusedValue), defaultFocusedValue: parseDateString(defaultFocusedValue), onFocusChange: onFocusChange && ((date) => onFocusChange(toGregorianDateString(date))), "data-component": "datepicker-calendar", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
@@ -303,32 +289,33 @@ function RangeCalendar({ disableStyle, className, focusedValue, defaultFocusedVa
303
289
  }
304
290
  /** Chooses the single-date or range calendar from Root mode automatically. Keep Actions and TablesList inside; do not render separate calendars for each mode. */
305
291
  export function Calendar(props) {
306
- const { mode } = useContext(ConfigurationContext);
307
- if (mode === 'range')
292
+ const context = useContext(ConfigurationContext);
293
+ if (context.mode === 'range')
308
294
  return _jsx(RangeCalendar, { ...props });
309
295
  return _jsx(SingleCalendar, { ...props });
310
296
  }
311
297
  /** Optional shortcut list. Its children callback receives all presets from Root once; map them to Item. Item handles applying the chosen value. */
312
298
  export function PresetsList({ disableStyle, className, children, ...props }) {
313
- const { presets, mode } = useContext(ConfigurationContext);
299
+ const context = useContext(ConfigurationContext);
314
300
  const single = useContext(DatePickerStateContext);
315
301
  const range = useContext(DateRangePickerStateContext);
316
- const selectedValue = mode === 'range'
317
- ? range?.value.start && range.value.end
318
- ? {
319
- start: toGregorianDateString(range.value.start),
320
- end: toGregorianDateString(range.value.end),
321
- }
322
- : null
323
- : single?.value
324
- ? toGregorianDateString(single.value)
325
- : null;
326
- const selectedPreset = presets.find((preset) => samePresetValue(preset.value, selectedValue));
302
+ // The current selection as a preset value, to highlight the preset matching it
303
+ const selectedValue = (() => {
304
+ if (context.mode === 'range') {
305
+ if (!range?.value.start || !range.value.end)
306
+ return null;
307
+ return { start: toGregorianDateString(range.value.start), end: toGregorianDateString(range.value.end) };
308
+ }
309
+ if (!single?.value)
310
+ return null;
311
+ return toGregorianDateString(single.value);
312
+ })();
313
+ const selectedPreset = context.presets.find((preset) => samePresetValue(preset.value, selectedValue));
327
314
  return (_jsx(ListBox, { "aria-label": "Presets", ...props, selectionMode: "single", disallowEmptySelection: true, selectedKeys: selectedPreset ? [selectedPreset.label] : [], onSelectionChange: (keys) => {
328
315
  if (keys === 'all')
329
316
  return;
330
317
  const key = keys.values().next().value;
331
- const preset = presets.find((preset) => preset.label === key);
318
+ const preset = context.presets.find((preset) => preset.label === key);
332
319
  if (!preset)
333
320
  return;
334
321
  if (typeof preset.value === 'string') {
@@ -337,18 +324,18 @@ export function PresetsList({ disableStyle, className, children, ...props }) {
337
324
  else {
338
325
  range.setDateRange(parseDateRange(preset.value));
339
326
  }
340
- }, "data-component": "datepicker-presetslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children(presets) }));
327
+ }, "data-component": "datepicker-presetslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: children(context.presets) }));
341
328
  }
342
329
  export function Item({ disableStyle, value, className, textValue, ...props }) {
343
330
  const calendar = useActiveCalendarState();
344
- const { presets } = useContext(ConfigurationContext);
331
+ const context = useContext(ConfigurationContext);
345
332
  const dates = typeof value === 'string'
346
333
  ? [parseDateString(value)]
347
334
  : [parseDateString(value.start), parseDateString(value.end)];
348
335
  // Distinct presets may resolve to the same date (e.g. Today and First of this week).
349
336
  // Their labels identify options; their date values still control the actual picker.
350
337
  const label = textValue ??
351
- presets.find((preset) => samePresetValue(preset.value, value))?.label;
338
+ context.presets.find((preset) => samePresetValue(preset.value, value))?.label;
352
339
  return (_jsx(ListBoxItem, { ...props, id: label ??
353
340
  (typeof value === 'string' ? value : value.start + '/' + value.end), textValue: label, isDisabled: calendar.isDisabled ||
354
341
  calendar.isReadOnly ||
@@ -397,19 +384,10 @@ export function PreviousButton({ disableStyle, className, isDisabled, ...props }
397
384
  export function NextButton({ disableStyle, className, isDisabled, ...props }) {
398
385
  return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "next", "data-component": "datepicker-nextbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
399
386
  }
400
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
401
- export function PreviousHandler({ children, isDisabled, ...props }) {
402
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "previous", render: (buttonProps) => renderButtonChild(children, buttonProps) }));
403
- }
404
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
405
- export function NextHandler({ children, isDisabled, ...props }) {
406
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "next", render: (buttonProps) => renderButtonChild(children, buttonProps) }));
407
- }
408
387
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
409
388
  export function PreviousButtonIcon({ disableStyle, children = _jsx(ChevronLeft, {}), className, ...props }) {
410
389
  const calendar = useActiveCalendarState();
411
390
  return cloneElement(children, {
412
- ...children.props,
413
391
  ...props,
414
392
  'aria-hidden': true,
415
393
  ...{
@@ -429,7 +407,6 @@ export function PreviousButtonIcon({ disableStyle, children = _jsx(ChevronLeft,
429
407
  export function NextButtonIcon({ disableStyle, children = _jsx(ChevronRight, {}), className, ...props }) {
430
408
  const calendar = useActiveCalendarState();
431
409
  return cloneElement(children, {
432
- ...children.props,
433
410
  ...props,
434
411
  'aria-hidden': true,
435
412
  ...{
@@ -452,29 +429,35 @@ export function TablesList({ disableStyle, className, children, ...props }) {
452
429
  }
453
430
  /** Renders weekday headings and day cells automatically. Pass the index from TablesList; do not map individual dates yourself. */
454
431
  export function Table({ disableStyle, index = 0, className, ...props }) {
455
- const { mode } = useContext(ConfigurationContext);
456
- return (_jsxs(CalendarGrid, { ...props, offset: { months: index }, "data-component": "datepicker-table", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx(CalendarGridHeader, { children: (day) => (_jsx(CalendarHeaderCell, { "data-component": "datepicker-table-1", children: day })) }), _jsx(CalendarGridBody, { children: (date) => (_jsx(CalendarCell, { date: date, "data-mode": mode, "data-component": "datepicker-table-2" })) })] }));
432
+ const context = useContext(ConfigurationContext);
433
+ return (_jsxs(CalendarGrid, { ...props, offset: { months: index }, "data-component": "datepicker-table", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx(CalendarGridHeader, { children: (day) => (_jsx(CalendarHeaderCell, { "data-component": "datepicker-table-1", children: day })) }), _jsx(CalendarGridBody, { children: (date) => (_jsx(CalendarCell, { date: date, "data-mode": context.mode, "data-component": "datepicker-table-2" })) })] }));
457
434
  }
458
435
  export function Description({ disableStyle, className, ...props }) {
459
436
  return (_jsx(Text, { ...props, ...usePartAttributes(), slot: "description", "data-component": "datepicker-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
460
437
  }
461
- /** Keep mounted to let the picker render its validation error automatically. Omit children for the native error text; override only for a custom message. */
462
- export function Error({ disableStyle, className, ...props }) {
463
- return (_jsx(FieldError, { ...props, ...usePartAttributes(), "data-component": "datepicker-error", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
438
+ /** Keep mounted: it shows while the picker is invalid. With no children it shows Root's message from `['error', message]`, or else the picker's own validation text, like a required or out-of-range date. A function children formats Root's message, and other children replace it. */
439
+ export function Error({ disableStyle, className, children, ...props }) {
440
+ const configuration = useContext(ConfigurationContext);
441
+ // Undefined lets FieldError show Aria's own validation text
442
+ const content = validationMessageContent(configuration.validation, 'error', children);
443
+ return (_jsx(FieldError, { ...props, ...usePartAttributes(), "data-component": "datepicker-error", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: content }));
464
444
  }
465
- /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
466
- export function Success({ disableStyle, className, ...props }) {
467
- return (_jsx(Text, { role: "status", ...props, ...usePartAttributes(), slot: "description", "data-component": "datepicker-success", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
445
+ /** 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. */
446
+ export function Success({ disableStyle, className, children, ...props }) {
447
+ const configuration = useContext(ConfigurationContext);
448
+ const content = validationMessageContent(configuration.validation, 'success', children);
449
+ if (content === undefined)
450
+ return null;
451
+ return (_jsx(Text, { role: "status", ...props, ...usePartAttributes(), slot: "description", "data-component": "datepicker-success", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: content }));
468
452
  }
469
- const ConfigurationContext = /* @__PURE__ */ createContext({ mode: 'single', presets: [], disabled: false, readOnly: false });
453
+ const ConfigurationContext = /* @__PURE__ */ createContext({ mode: 'single', presets: [], disabled: false, readOnly: false, validation: readValidation() });
470
454
  function usePartAttributes() {
471
455
  const single = useContext(DatePickerStateContext);
472
456
  const range = useContext(DateRangePickerStateContext);
473
457
  const configuration = useContext(ConfigurationContext);
474
- const tone = useToneContext();
475
458
  const state = configuration.mode === 'range' ? range : single;
476
459
  return {
477
- 'data-tone': tone,
460
+ ...validationAttributes(configuration.validation),
478
461
  'data-disabled': configuration.disabled || undefined,
479
462
  'data-readonly': configuration.readOnly || undefined,
480
463
  'data-open': state.isOpen || undefined,
@@ -508,8 +491,8 @@ function renderButtonChild(child, buttonProps) {
508
491
  function useActiveCalendarState() {
509
492
  const single = useContext(CalendarStateContext);
510
493
  const range = useContext(RangeCalendarStateContext);
511
- const { mode } = useContext(ConfigurationContext);
512
- return mode === 'range' ? range : single;
494
+ const context = useContext(ConfigurationContext);
495
+ return context.mode === 'range' ? range : single;
513
496
  }
514
497
  function samePresetValue(a, b) {
515
498
  if (typeof a === 'string')
@@ -527,4 +510,3 @@ function parseDateRange(value) {
527
510
  end: parseDateString(value.end),
528
511
  };
529
512
  }
530
- //# sourceMappingURL=index.js.map
@@ -2,8 +2,9 @@ import type { StyleProps } from '../../types/Style.ts';
2
2
  import { Dialog as BaseDialog } from '@base-ui/react/dialog';
3
3
  import type { ReactElement } from 'react';
4
4
  import type { SVGIconProps } from '../../types/Icon.ts';
5
+ import type { AsChildProps } from '../../utils/asChild.ts';
5
6
  /**
6
- * OpenHandler and CloseHandler give behavior to your button children. Popup already includes its portal; do not add one. Use Title to name the dialog and Description when supporting text is needed. Header, Body, and Footer organize content.
7
+ * OpenButton and CloseButton render their own buttons; pass asChild to give their behavior to your own button instead. Popup already includes its portal; do not add one. Use Title to name the dialog and Description when supporting text is needed. Header, Body, and Footer organize content.
7
8
  *
8
9
  * @example Complete composition
9
10
  * import { Button, Dialog } from '@central-ui/react'
@@ -11,9 +12,7 @@ import type { SVGIconProps } from '../../types/Icon.ts';
11
12
  * function Example() {
12
13
  * return (
13
14
  * <Dialog.Root>
14
- * <Dialog.OpenHandler>
15
- * <Button.default variant="secondary">Account details</Button.default>
16
- * </Dialog.OpenHandler>
15
+ * <Dialog.OpenButton>Account details</Dialog.OpenButton>
17
16
  * <Dialog.Backdrop />
18
17
  * <Dialog.Popup>
19
18
  * <Dialog.Header>
@@ -25,9 +24,9 @@ import type { SVGIconProps } from '../../types/Icon.ts';
25
24
  * </Dialog.Header>
26
25
  * <Dialog.Body>Your account is ready to use.</Dialog.Body>
27
26
  * <Dialog.Footer>
28
- * <Dialog.CloseHandler>
27
+ * <Dialog.CloseButton asChild>
29
28
  * <Button.default variant="primary">Done</Button.default>
30
- * </Dialog.CloseHandler>
29
+ * </Dialog.CloseButton>
31
30
  * </Dialog.Footer>
32
31
  * </Dialog.Popup>
33
32
  * </Dialog.Root>
@@ -42,32 +41,20 @@ import type { SVGIconProps } from '../../types/Icon.ts';
42
41
  * }
43
42
  * </Dialog.Root>
44
43
  */
45
- export declare const Root: <Payload>(props: BaseDialog.Root.Props<Payload>) => React.JSX.Element;
46
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
47
- export declare const OpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<BaseDialog.Trigger.Props<unknown>, "children" | "className" | "render"> & {
48
- className?: string;
49
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
50
- children: ReactElement;
51
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
52
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
53
- export declare const CloseHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogCloseProps, "children" | "className" | "render"> & {
44
+ export declare function Root<Payload = unknown>(props: BaseDialog.Root.Props<Payload>): import("react").JSX.Element;
45
+ /** Opens the dialog. Pass asChild to give this behavior to your own button, like your app's Button. */
46
+ export declare const OpenButton: import("react").ForwardRefExoticComponent<Omit<Omit<BaseDialog.Trigger.Props<unknown>, "className" | "render"> & {
54
47
  className?: string;
55
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
56
- children: ReactElement;
57
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
48
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
58
49
  export type PopupProps = Omit<BaseDialog.Popup.Props, 'className'> & {
59
50
  className?: string;
60
51
  } & Pick<BaseDialog.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
61
52
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
62
- export declare const Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogPopupProps, "className"> & {
63
- className?: string;
64
- } & Pick<import("@base-ui/react").AlertDialogPortalProps, "keepMounted" | "container"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
53
+ export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
65
54
  export type BackdropProps = Omit<BaseDialog.Backdrop.Props, 'className'> & {
66
55
  className?: string;
67
56
  } & Pick<BaseDialog.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
68
- export declare const Backdrop: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogBackdropProps, "className"> & {
69
- className?: string;
70
- } & Pick<import("@base-ui/react").AlertDialogPortalProps, "keepMounted" | "container"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
57
+ export declare const Backdrop: import("react").ForwardRefExoticComponent<Omit<BackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
71
58
  export declare const Header: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
72
59
  export declare const Body: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
73
60
  export declare const Footer: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -77,12 +64,12 @@ export declare const Title: import("react").ForwardRefExoticComponent<Omit<Omit<
77
64
  export declare const Description: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogDescriptionProps, "className"> & {
78
65
  className?: string;
79
66
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
80
- export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogCloseProps, "className"> & {
67
+ /** 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". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
68
+ export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogCloseProps, "className" | "render"> & {
81
69
  className?: string;
82
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
70
+ } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
83
71
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
84
72
  export declare const CloseButtonIcon: import("react").ForwardRefExoticComponent<Omit<SVGIconProps & {
85
73
  /** Omit for the supplied default icon; pass a child only to replace it. */
86
74
  children?: ReactElement<SVGIconProps>;
87
75
  } & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
88
- //# sourceMappingURL=index.d.ts.map
@@ -2,9 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Dialog as BaseDialog } from '@base-ui/react/dialog';
3
3
  import { cloneElement, forwardRef } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
- import { X } from 'lucide-react';
5
+ import { X } from "../../utils/icons.js";
6
+ import { asChildRendering } from "../../utils/asChild.js";
6
7
  /**
7
- * OpenHandler and CloseHandler give behavior to your button children. Popup already includes its portal; do not add one. Use Title to name the dialog and Description when supporting text is needed. Header, Body, and Footer organize content.
8
+ * OpenButton and CloseButton render their own buttons; pass asChild to give their behavior to your own button instead. Popup already includes its portal; do not add one. Use Title to name the dialog and Description when supporting text is needed. Header, Body, and Footer organize content.
8
9
  *
9
10
  * @example Complete composition
10
11
  * import { Button, Dialog } from '@central-ui/react'
@@ -12,9 +13,7 @@ import { X } from 'lucide-react';
12
13
  * function Example() {
13
14
  * return (
14
15
  * <Dialog.Root>
15
- * <Dialog.OpenHandler>
16
- * <Button.default variant="secondary">Account details</Button.default>
17
- * </Dialog.OpenHandler>
16
+ * <Dialog.OpenButton>Account details</Dialog.OpenButton>
18
17
  * <Dialog.Backdrop />
19
18
  * <Dialog.Popup>
20
19
  * <Dialog.Header>
@@ -26,9 +25,9 @@ import { X } from 'lucide-react';
26
25
  * </Dialog.Header>
27
26
  * <Dialog.Body>Your account is ready to use.</Dialog.Body>
28
27
  * <Dialog.Footer>
29
- * <Dialog.CloseHandler>
28
+ * <Dialog.CloseButton asChild>
30
29
  * <Button.default variant="primary">Done</Button.default>
31
- * </Dialog.CloseHandler>
30
+ * </Dialog.CloseButton>
32
31
  * </Dialog.Footer>
33
32
  * </Dialog.Popup>
34
33
  * </Dialog.Root>
@@ -43,14 +42,13 @@ import { X } from 'lucide-react';
43
42
  * }
44
43
  * </Dialog.Root>
45
44
  */
46
- export const Root = BaseDialog.Root;
47
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
48
- export const OpenHandler = /* @__PURE__ */ forwardRef(function OpenHandler({ children, ...props }, ref) {
49
- return _jsx(BaseDialog.Trigger, { ...props, ref: ref, render: children });
50
- });
51
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
52
- export const CloseHandler = /* @__PURE__ */ forwardRef(function CloseHandler({ children, ...props }, ref) {
53
- return _jsx(BaseDialog.Close, { ...props, ref: ref, render: children });
45
+ export function Root(props) {
46
+ return _jsx(BaseDialog.Root, { ...props });
47
+ }
48
+ /** Opens the dialog. Pass asChild to give this behavior to your own button, like your app's Button. */
49
+ export const OpenButton = /* @__PURE__ */ forwardRef(function OpenButton({ asChild, disableStyle, children, ...props }, ref) {
50
+ const rendering = asChildRendering({ asChild, children, component: 'dialog-openbutton', disableStyle });
51
+ return _jsx(BaseDialog.Trigger, { ...props, ref: ref, ...rendering });
54
52
  });
55
53
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
56
54
  export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
@@ -83,8 +81,10 @@ export const Title = /* @__PURE__ */ forwardRef(function Title({ disableStyle, c
83
81
  export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
84
82
  return (_jsx(BaseDialog.Description, { ...props, ref: ref, "data-component": "dialog-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
85
83
  });
86
- export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ disableStyle, className, ...props }, ref) {
87
- return (_jsx(BaseDialog.Close, { ...props, ref: ref, "data-component": "dialog-closebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
84
+ /** 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". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
85
+ export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ asChild, disableStyle, children, ...props }, ref) {
86
+ const rendering = asChildRendering({ asChild, children, component: 'dialog-closebutton', disableStyle });
87
+ return _jsx(BaseDialog.Close, { ...props, ref: ref, ...rendering });
88
88
  });
89
89
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
90
90
  export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
@@ -99,4 +99,3 @@ export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIc
99
99
  className: twMerge(children?.props.className, className),
100
100
  });
101
101
  });
102
- //# sourceMappingURL=index.js.map
@@ -18,4 +18,3 @@ import type { HTMLAttributes } from 'react';
18
18
  */
19
19
  export default function Divider({ disableStyle, className, ...props }: HTMLAttributes<HTMLHRElement> & StyleProps): import("react").JSX.Element;
20
20
  export declare function Text({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
21
- //# sourceMappingURL=index.d.ts.map
@@ -21,4 +21,3 @@ export default function Divider({ disableStyle, className, ...props }) {
21
21
  export function Text({ disableStyle, className, ...props }) {
22
22
  return (_jsx("p", { "data-component": "divider-text", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
23
23
  }
24
- //# sourceMappingURL=index.js.map