@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
@@ -1,17 +1,40 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { DatePicker as AriaDatePicker, DateRangePicker as AriaDateRangePicker, RangeCalendar as AriaRangeCalendar, DateRangePickerStateContext, RangeCalendarStateContext, Label as AriaLabel, Group as AriaGroup, DateInput as AriaDateInput, DateSegment as AriaDateSegment, Button as AriaButton, Popover as AriaPopover, Calendar as AriaCalendar, Heading, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, CalendarCell, ListBox, ListBoxItem, SelectionIndicatorContext, useSlottedContext, Text, FieldError, I18nProvider, DatePickerStateContext, CalendarStateContext, DateFieldStateContext, DialogContext, useContextProps, } from 'react-aria-components';
2
+ import { asChildStyleAttributes } from "../../utils/asChild.js";
3
+ import { DatePicker as AriaDatePicker, DatePickerStateContext, } from 'react-aria-components/DatePicker';
4
+ import { DateRangePicker as AriaDateRangePicker, DateRangePickerStateContext, } from 'react-aria-components/DateRangePicker';
5
+ import { RangeCalendar as AriaRangeCalendar, RangeCalendarStateContext, } from 'react-aria-components/RangeCalendar';
6
+ import { Label as AriaLabel } from 'react-aria-components/Label';
7
+ import { Group as AriaGroup } from 'react-aria-components/Group';
8
+ import { DateInput as AriaDateInput, DateSegment as AriaDateSegment, DateFieldStateContext, } from 'react-aria-components/DateField';
9
+ import { Button as AriaButton } from 'react-aria-components/Button';
10
+ import { Popover as AriaPopover } from 'react-aria-components/Popover';
11
+ import { Calendar as AriaCalendar, CalendarGrid, CalendarGridHeader, CalendarHeaderCell, CalendarGridBody, CalendarCell, CalendarStateContext, } from 'react-aria-components/Calendar';
12
+ import { Heading } from 'react-aria-components/Heading';
13
+ import { ListBox, ListBoxItem } from 'react-aria-components/ListBox';
14
+ import { SelectionIndicatorContext } from 'react-aria-components/SelectionIndicator';
15
+ import { useSlottedContext, useContextProps } from 'react-aria-components/slots';
16
+ import { Text } from 'react-aria-components/Text';
17
+ import { FieldError } from 'react-aria-components/FieldError';
18
+ import { I18nProvider } from 'react-aria-components/I18nProvider';
19
+ import { DialogContext } from 'react-aria-components/Dialog';
3
20
  import { parseDate, toCalendarDate, toCalendar, GregorianCalendar, } from '@internationalized/date';
4
- import { useLocale, useDateFormatter, mergeProps } from 'react-aria';
21
+ import { useLocale } from 'react-aria/I18nProvider';
22
+ import { useDateFormatter } from 'react-aria/useDateFormatter';
23
+ import { mergeProps } from 'react-aria/mergeProps';
5
24
  import { cloneElement, createContext, forwardRef, useContext, Fragment, useState, useMemo, } from 'react';
6
- import { CalendarDays, Check, ChevronLeft, ChevronRight, LoaderCircle, } from 'lucide-react';
25
+ import { CalendarDays, Check, ChevronLeft, ChevronRight, LoaderCircle, } from "../../utils/icons.js";
7
26
  import { twMerge } from 'tailwind-merge';
8
- import { ToneProvider, useToneContext } from "../../utils/Tone.js";
9
- const SinglePicker = forwardRef(function SinglePicker({ mode, locale, tone, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, invalid, open, isDateUnavailable, ...props }, ref) {
10
- 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 &&
11
32
  ((date) => isDateUnavailable(toGregorianDateString(date))) }));
12
33
  });
13
- const RangePicker = forwardRef(function RangePicker({ mode, locale, tone, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, invalid, open, isDateUnavailable, ...props }, ref) {
14
- 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
15
38
  ? {
16
39
  start: toGregorianDateString(range.start),
17
40
  end: toGregorianDateString(range.end),
@@ -100,17 +123,18 @@ function Picker({ pickerRef, ...props }) {
100
123
  * }
101
124
  * </DatePicker.PresetsList>
102
125
  */
103
- export const Root = forwardRef(function Root(props, ref) {
126
+ export const Root = /* @__PURE__ */ forwardRef(function Root(props, ref) {
104
127
  const [buttonAnchor, setButtonAnchor] = useState(null);
105
128
  const buttonAnchorRef = useMemo(() => ({ current: buttonAnchor }), [buttonAnchor]);
106
- return (_jsx(I18nProvider, { locale: props.locale ?? 'en-US', children: _jsx(ToneProvider, { value: props.tone ?? 'neutral', children: _jsx(ConfigurationContext.Provider, { value: {
107
- mode: props.mode ?? 'single',
108
- presets: props.presets ?? [],
109
- buttonAnchorRef,
110
- setButtonAnchor,
111
- disabled: props.disabled ?? false,
112
- readOnly: props.readOnly ?? false,
113
- }, 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 }) }) }));
114
138
  });
115
139
  export function Container({ disableStyle, className, ...props }) {
116
140
  return (_jsx("div", { ...props, ...usePartAttributes(), "data-component": "datepicker-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
@@ -130,7 +154,6 @@ export function AddonText({ disableStyle, className, ...props }) {
130
154
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
131
155
  export function AddonIcon({ disableStyle, children, className, ...props }) {
132
156
  return cloneElement(children, {
133
- ...children.props,
134
157
  ...props,
135
158
  ...usePartAttributes(),
136
159
  'aria-hidden': true,
@@ -145,7 +168,6 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
145
168
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
146
169
  export function AddonLoadingIcon({ disableStyle, children = _jsx(LoaderCircle, {}), className, ...props }) {
147
170
  return cloneElement(children, {
148
- ...children.props,
149
171
  ...props,
150
172
  ...usePartAttributes(),
151
173
  'aria-hidden': true,
@@ -195,7 +217,6 @@ export function AddonOpenButton({ disableStyle, className, isDisabled, ...props
195
217
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
196
218
  export function AddonOpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {}), className, ...props }) {
197
219
  return cloneElement(children, {
198
- ...children.props,
199
220
  ...props,
200
221
  ...usePartAttributes(),
201
222
  'aria-hidden': true,
@@ -207,52 +228,40 @@ export function AddonOpenButtonIcon({ disableStyle, children = _jsx(CalendarDays
207
228
  strokeWidth: props.strokeWidth ?? children.props.strokeWidth ?? 2,
208
229
  });
209
230
  }
210
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
211
- export function AddonOpenHandler({ children, isDisabled, ...props }) {
212
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, render: (buttonProps) => renderButtonChild(children, buttonProps) }));
213
- }
214
- export function OpenButton({ disableStyle, className, isDisabled, ...props }) {
215
- const { setButtonAnchor } = useContext(ConfigurationContext);
216
- 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 }) }));
217
- }
218
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
219
- export function OpenHandler({ children, isDisabled, ...props }) {
220
- const { setButtonAnchor } = useContext(ConfigurationContext);
221
- 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 }) }));
222
240
  }
223
241
  /** Formats the selected date or range automatically. Omit children for the usual display; supply children only to replace it. Placeholder appears before selection. */
224
242
  export function OpenButtonValue({ disableStyle, children, placeholder = 'Select date', className, ...props }) {
225
243
  const single = useContext(DatePickerStateContext);
226
244
  const range = useContext(DateRangePickerStateContext);
227
- const { mode } = useContext(ConfigurationContext);
228
- const { locale } = useLocale();
229
- return (_jsx("span", { ...props, ...usePartAttributes(), "data-component": "datepicker-openbuttonvalue", "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 ??
230
250
  (() => {
231
- if (mode === 'range') {
232
- 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)
233
256
  return placeholder;
234
- const formatted = range.formatValue(locale, {
235
- day: 'numeric',
236
- month: 'long',
237
- year: 'numeric',
238
- });
239
- return formatted
240
- ? formatted.start + ' — ' + formatted.end
241
- : placeholder;
257
+ return formatted.start + ' — ' + formatted.end;
242
258
  }
243
- return single?.value
244
- ? single.formatValue(locale, {
245
- day: 'numeric',
246
- month: 'long',
247
- year: 'numeric',
248
- })
249
- : placeholder;
259
+ return single.formatValue(i18n.locale, { day: 'numeric', month: 'long', year: 'numeric' });
250
260
  })() }));
251
261
  }
252
262
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
253
263
  export function OpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {}), className, ...props }) {
254
264
  return cloneElement(children, {
255
- ...children.props,
256
265
  ...props,
257
266
  'aria-hidden': true,
258
267
  ...{
@@ -264,13 +273,13 @@ export function OpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {})
264
273
  });
265
274
  }
266
275
  /** Use the same calendar composition for both trigger choices. Opening and focus management are handled by the picker; do not add your own popup visibility condition. */
267
- export const Popup = forwardRef(function Popup({ disableStyle, ...props }, ref) {
276
+ export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, ...props }, ref) {
268
277
  // The Popover supplies dialog semantics itself. Merge DatePicker's generated dialog
269
278
  // id/labeling onto that same element instead of adding another Dialog wrapper.
270
- const { buttonAnchorRef } = useContext(ConfigurationContext);
279
+ const context = useContext(ConfigurationContext);
271
280
  const [mergedProps, mergedRef] = useContextProps(props, ref, DialogContext);
272
281
  const { className, style, placement = 'bottom end', offset = 5, ...rest } = mergedProps;
273
- 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 }));
274
283
  });
275
284
  function SingleCalendar({ disableStyle, className, focusedValue, defaultFocusedValue, onFocusChange, ...props }) {
276
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 }));
@@ -280,32 +289,33 @@ function RangeCalendar({ disableStyle, className, focusedValue, defaultFocusedVa
280
289
  }
281
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. */
282
291
  export function Calendar(props) {
283
- const { mode } = useContext(ConfigurationContext);
284
- if (mode === 'range')
292
+ const context = useContext(ConfigurationContext);
293
+ if (context.mode === 'range')
285
294
  return _jsx(RangeCalendar, { ...props });
286
295
  return _jsx(SingleCalendar, { ...props });
287
296
  }
288
297
  /** Optional shortcut list. Its children callback receives all presets from Root once; map them to Item. Item handles applying the chosen value. */
289
298
  export function PresetsList({ disableStyle, className, children, ...props }) {
290
- const { presets, mode } = useContext(ConfigurationContext);
299
+ const context = useContext(ConfigurationContext);
291
300
  const single = useContext(DatePickerStateContext);
292
301
  const range = useContext(DateRangePickerStateContext);
293
- const selectedValue = mode === 'range'
294
- ? range?.value.start && range.value.end
295
- ? {
296
- start: toGregorianDateString(range.value.start),
297
- end: toGregorianDateString(range.value.end),
298
- }
299
- : null
300
- : single?.value
301
- ? toGregorianDateString(single.value)
302
- : null;
303
- 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));
304
314
  return (_jsx(ListBox, { "aria-label": "Presets", ...props, selectionMode: "single", disallowEmptySelection: true, selectedKeys: selectedPreset ? [selectedPreset.label] : [], onSelectionChange: (keys) => {
305
315
  if (keys === 'all')
306
316
  return;
307
317
  const key = keys.values().next().value;
308
- const preset = presets.find((preset) => preset.label === key);
318
+ const preset = context.presets.find((preset) => preset.label === key);
309
319
  if (!preset)
310
320
  return;
311
321
  if (typeof preset.value === 'string') {
@@ -314,28 +324,28 @@ export function PresetsList({ disableStyle, className, children, ...props }) {
314
324
  else {
315
325
  range.setDateRange(parseDateRange(preset.value));
316
326
  }
317
- }, "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) }));
318
328
  }
319
329
  export function Item({ disableStyle, value, className, textValue, ...props }) {
320
330
  const calendar = useActiveCalendarState();
321
- const { presets } = useContext(ConfigurationContext);
331
+ const context = useContext(ConfigurationContext);
322
332
  const dates = typeof value === 'string'
323
333
  ? [parseDateString(value)]
324
334
  : [parseDateString(value.start), parseDateString(value.end)];
325
335
  // Distinct presets may resolve to the same date (e.g. Today and First of this week).
326
336
  // Their labels identify options; their date values still control the actual picker.
327
337
  const label = textValue ??
328
- presets.find((preset) => samePresetValue(preset.value, value))?.label;
338
+ context.presets.find((preset) => samePresetValue(preset.value, value))?.label;
329
339
  return (_jsx(ListBoxItem, { ...props, id: label ??
330
340
  (typeof value === 'string' ? value : value.start + '/' + value.end), textValue: label, isDisabled: calendar.isDisabled ||
331
341
  calendar.isReadOnly ||
332
342
  dates.some((date) => calendar.isInvalid(date) || calendar.isCellUnavailable(date)), "data-component": "datepicker-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
333
343
  }
334
- export const ItemText = forwardRef(function ItemText({ disableStyle, className, ...props }, ref) {
344
+ export const ItemText = /* @__PURE__ */ forwardRef(function ItemText({ disableStyle, className, ...props }, ref) {
335
345
  return (_jsx(Text, { ...props, ref: ref, slot: "label", "data-component": "datepicker-itemtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
336
346
  });
337
347
  /** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
338
- export const ItemIndicator = forwardRef(function ItemIndicator({ disableStyle, children, ...props }, ref) {
348
+ export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({ disableStyle, children, ...props }, ref) {
339
349
  // ListBoxItem supplies this public Aria context, including for controlled selection.
340
350
  // Read visibility directly so no measured div or shared-element animation is needed.
341
351
  const selection = useSlottedContext(SelectionIndicatorContext);
@@ -374,19 +384,10 @@ export function PreviousButton({ disableStyle, className, isDisabled, ...props }
374
384
  export function NextButton({ disableStyle, className, isDisabled, ...props }) {
375
385
  return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "next", "data-component": "datepicker-nextbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
376
386
  }
377
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
378
- export function PreviousHandler({ children, isDisabled, ...props }) {
379
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "previous", render: (buttonProps) => renderButtonChild(children, buttonProps) }));
380
- }
381
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
382
- export function NextHandler({ children, isDisabled, ...props }) {
383
- return (_jsx(AriaButton, { isDisabled: isDisabled || undefined, ...props, slot: "next", render: (buttonProps) => renderButtonChild(children, buttonProps) }));
384
- }
385
387
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
386
388
  export function PreviousButtonIcon({ disableStyle, children = _jsx(ChevronLeft, {}), className, ...props }) {
387
389
  const calendar = useActiveCalendarState();
388
390
  return cloneElement(children, {
389
- ...children.props,
390
391
  ...props,
391
392
  'aria-hidden': true,
392
393
  ...{
@@ -406,7 +407,6 @@ export function PreviousButtonIcon({ disableStyle, children = _jsx(ChevronLeft,
406
407
  export function NextButtonIcon({ disableStyle, children = _jsx(ChevronRight, {}), className, ...props }) {
407
408
  const calendar = useActiveCalendarState();
408
409
  return cloneElement(children, {
409
- ...children.props,
410
410
  ...props,
411
411
  'aria-hidden': true,
412
412
  ...{
@@ -429,29 +429,35 @@ export function TablesList({ disableStyle, className, children, ...props }) {
429
429
  }
430
430
  /** Renders weekday headings and day cells automatically. Pass the index from TablesList; do not map individual dates yourself. */
431
431
  export function Table({ disableStyle, index = 0, className, ...props }) {
432
- const { mode } = 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": 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" })) })] }));
434
434
  }
435
435
  export function Description({ disableStyle, className, ...props }) {
436
436
  return (_jsx(Text, { ...props, ...usePartAttributes(), slot: "description", "data-component": "datepicker-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
437
437
  }
438
- /** Keep mounted to let the picker render its validation error automatically. Omit children for the native error text; override only for a custom message. */
439
- export function Error({ disableStyle, className, ...props }) {
440
- 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 }));
441
444
  }
442
- /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
443
- export function Success({ disableStyle, className, ...props }) {
444
- 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 }));
445
452
  }
446
- const ConfigurationContext = createContext({ mode: 'single', presets: [], disabled: false, readOnly: false });
453
+ const ConfigurationContext = /* @__PURE__ */ createContext({ mode: 'single', presets: [], disabled: false, readOnly: false, validation: readValidation() });
447
454
  function usePartAttributes() {
448
455
  const single = useContext(DatePickerStateContext);
449
456
  const range = useContext(DateRangePickerStateContext);
450
457
  const configuration = useContext(ConfigurationContext);
451
- const tone = useToneContext();
452
458
  const state = configuration.mode === 'range' ? range : single;
453
459
  return {
454
- 'data-tone': tone,
460
+ ...validationAttributes(configuration.validation),
455
461
  'data-disabled': configuration.disabled || undefined,
456
462
  'data-readonly': configuration.readOnly || undefined,
457
463
  'data-open': state.isOpen || undefined,
@@ -485,8 +491,8 @@ function renderButtonChild(child, buttonProps) {
485
491
  function useActiveCalendarState() {
486
492
  const single = useContext(CalendarStateContext);
487
493
  const range = useContext(RangeCalendarStateContext);
488
- const { mode } = useContext(ConfigurationContext);
489
- return mode === 'range' ? range : single;
494
+ const context = useContext(ConfigurationContext);
495
+ return context.mode === 'range' ? range : single;
490
496
  }
491
497
  function samePresetValue(a, b) {
492
498
  if (typeof a === 'string')
@@ -504,4 +510,3 @@ function parseDateRange(value) {
504
510
  end: parseDateString(value.end),
505
511
  };
506
512
  }
507
- //# sourceMappingURL=index.js.map
@@ -1,9 +1,10 @@
1
1
  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
- import type { LucideProps } from 'lucide-react';
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 { LucideProps } from 'lucide-react';
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 { LucideProps } from 'lucide-react';
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 { LucideProps } from 'lucide-react';
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
- export declare const CloseButtonIcon: import("react").ForwardRefExoticComponent<Omit<LucideProps & {
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
- children?: ReactElement<LucideProps>;
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,17 +42,16 @@ 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 = 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 = 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
- export const Popup = forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
54
+ export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
57
55
  const baseStyle = {
58
56
  position: 'fixed',
59
57
  top: '50%',
@@ -65,29 +63,31 @@ export const Popup = forwardRef(function Popup({ disableStyle, container, keepMo
65
63
  ? (state) => ({ ...baseStyle, ...style(state) })
66
64
  : { ...baseStyle, ...style } }) }) }));
67
65
  });
68
- export const Backdrop = forwardRef(function Backdrop({ disableStyle, container, keepMounted, className, ...props }, ref) {
66
+ export const Backdrop = /* @__PURE__ */ forwardRef(function Backdrop({ disableStyle, container, keepMounted, className, ...props }, ref) {
69
67
  return (_jsx(BaseDialog.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDialog.Backdrop, { ...props, ref: ref, "data-component": "dialog-backdrop", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
70
68
  });
71
- export const Header = forwardRef(function Header({ disableStyle, className, ...props }, ref) {
69
+ export const Header = /* @__PURE__ */ forwardRef(function Header({ disableStyle, className, ...props }, ref) {
72
70
  return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
73
71
  });
74
- export const Body = forwardRef(function Body({ disableStyle, className, ...props }, ref) {
72
+ export const Body = /* @__PURE__ */ forwardRef(function Body({ disableStyle, className, ...props }, ref) {
75
73
  return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
76
74
  });
77
- export const Footer = forwardRef(function Footer({ disableStyle, className, ...props }, ref) {
75
+ export const Footer = /* @__PURE__ */ forwardRef(function Footer({ disableStyle, className, ...props }, ref) {
78
76
  return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-footer", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
79
77
  });
80
- export const Title = forwardRef(function Title({ disableStyle, className, ...props }, ref) {
78
+ export const Title = /* @__PURE__ */ forwardRef(function Title({ disableStyle, className, ...props }, ref) {
81
79
  return (_jsx(BaseDialog.Title, { ...props, ref: ref, "data-component": "dialog-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
82
80
  });
83
- export const Description = forwardRef(function Description({ disableStyle, className, ...props }, ref) {
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 = 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
- export const CloseButtonIcon = forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
90
+ export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
91
91
  return cloneElement(children ?? _jsx(X, {}), {
92
92
  ...props,
93
93
  ref,
@@ -99,4 +99,3 @@ export const CloseButtonIcon = forwardRef(function CloseButtonIcon({ disableStyl
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