@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,6 +1,8 @@
1
- import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
2
1
  import type { SVGIconProps } from '../../types/Icon.ts';
2
+ import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
3
+ import type { ValidationProps } from '../../types/Validation.ts';
3
4
  import type { ComponentProps, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
5
+ import type { ValidationMessageChildren } from '../../utils/Validation.ts';
4
6
  type StyleProps = {
5
7
  /**
6
8
  * Disables preset styling for this element.
@@ -34,7 +36,7 @@ export type GroupType<T extends readonly GroupShape[]> = T[number];
34
36
  export type ItemType<T extends readonly GroupShape[]> = GroupType<T>['items'][number];
35
37
  /** Manually type a ChipsList callback argument with ChipsType<typeof rootItems>, using the exact items variable passed to Root. Also useful for multiple-selection state. */
36
38
  export type ChipsType<T extends readonly GroupShape[]> = ItemType<T>[];
37
- export type RootProps<T extends readonly GroupShape[], Multiple extends boolean | undefined = false> = Omit<BaseCombobox.Root.Props<ItemType<T>, Multiple>, 'items' | 'filteredItems' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue' | 'id'> & {
39
+ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean | undefined = false> = Omit<BaseCombobox.Root.Props<ItemType<T>, Multiple>, 'items' | 'filteredItems' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue' | 'id'> & ValidationProps & {
38
40
  /** Input id, also used automatically by Label. Omit to generate a stable id. */
39
41
  id?: BaseCombobox.Root.Props<ItemType<T>, Multiple>['id'];
40
42
  /**
@@ -50,8 +52,6 @@ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean
50
52
  * performs filtering itself, such as filtering results on a server.
51
53
  */
52
54
  filteredItems?: readonly GroupType<T>[];
53
- /** Visual validation tone only; does not validate or change selection. @default 'neutral' */
54
- tone?: 'neutral' | 'valid' | 'invalid';
55
55
  };
56
56
  /**
57
57
  * Searchable selection using Base UI's built-in filtering and keyboard handling.
@@ -206,7 +206,7 @@ export type RootProps<T extends readonly GroupShape[], Multiple extends boolean
206
206
  * <Combobox.AddonOpenButtonIcon />
207
207
  * </Combobox.AddonOpenButton>
208
208
  */
209
- export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, id, tone, open, defaultOpen, onOpenChange, onItemHighlighted, ...props }: RootProps<T, Multiple>): import("react").JSX.Element;
209
+ export declare function Root<T extends readonly GroupShape[], Multiple extends boolean | undefined = false>({ children, id, validation, defaultOpen, onOpenChange, ...props }: RootProps<T, Multiple>): import("react").JSX.Element;
210
210
  /** Use for the standard stacked layout, or omit when supplying your own layout. */
211
211
  export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
212
212
  /** Labels the input automatically using Root's id. Supply the visible label as children; no htmlFor needed. */
@@ -271,7 +271,7 @@ export type GroupsListProps<Group extends GroupShape = GroupShape> = Omit<Compon
271
271
  children: ReactNode | ((group: Group, index: number) => ReactNode);
272
272
  } & StyleProps;
273
273
  /** Required groups container inside ScrollArea. A children callback receives each automatically filtered group; do not filter or map the original groups again. Manually annotate group with Combobox.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
274
- export declare function GroupsList<Group extends GroupShape = GroupShape>({ disableStyle, children, className, style, ...props }: GroupsListProps<Group>): import("react").JSX.Element;
274
+ export declare function GroupsList<Group extends GroupShape = GroupShape>({ disableStyle, children, className, ...props }: GroupsListProps<Group>): import("react").JSX.Element;
275
275
  export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<'div'>, 'children' | 'className'> & {
276
276
  className?: string;
277
277
  /**
@@ -283,21 +283,21 @@ export type ItemsListProps<Item extends ItemShape = ItemShape> = Omit<ComponentP
283
283
  children?: ReactNode | ((item: Item, index: number) => ReactNode);
284
284
  } & StyleProps;
285
285
  /** Required items container inside Group. A children callback receives the filtered items belonging to that Group; do not repeat filtering yourself. Manually annotate item with Combobox.ItemType<typeof rootItems>, using the exact items variable passed to Root. */
286
- export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className, style, ...props }: ItemsListProps<Item>): import("react").JSX.Element;
286
+ export declare function ItemsList<Item extends ItemShape = ItemShape>({ disableStyle, children, className, ...props }: ItemsListProps<Item>): import("react").JSX.Element;
287
287
  export type GroupProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseCombobox.Group>, 'items' | 'className'> & {
288
288
  className?: string;
289
289
  /** Items for this group; pass group.items from GroupsList. Required even for a flat list. */
290
290
  items: readonly Item[];
291
291
  } & StyleProps;
292
292
  /** Required wrapper around ItemsList, even for a visually flat list. Pass group.items. A GroupLabel is optional; omit it when the group has an empty label. */
293
- export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, className, style, ...props }: GroupProps<Item>): import("react").JSX.Element;
293
+ export declare function Group<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: GroupProps<Item>): import("react").JSX.Element;
294
294
  export type ItemProps<Item extends ItemShape = ItemShape> = Omit<ComponentPropsWithRef<typeof BaseCombobox.Item>, 'value' | 'className'> & {
295
295
  className?: string;
296
296
  /** Pass the item supplied by ItemsList so selection can match it by item.value. */
297
297
  value: Item;
298
298
  } & StyleProps;
299
299
  /** Required selectable row inside ItemsList. Pass the complete item object as value, with ItemText and ItemIndicator inside. Selection, highlighting, and keyboard behavior are built in. */
300
- export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className, style, ...props }: ItemProps<Item>): import("react").JSX.Element;
300
+ export declare function Item<Item extends ItemShape = ItemShape>({ disableStyle, className, ...props }: ItemProps<Item>): import("react").JSX.Element;
301
301
  export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseCombobox.Popup>, 'className'> & {
302
302
  className?: string;
303
303
  } & Pick<BaseCombobox.Portal.Props, 'container' | 'keepMounted'> & Pick<BaseCombobox.Positioner.Props, 'anchor' | 'positionMethod' | 'alignOffset' | 'collisionBoundary' | 'collisionPadding' | 'sticky' | 'arrowPadding' | 'disableAnchorTracking' | 'collisionAvoidance'> & {
@@ -312,20 +312,6 @@ export type PopupProps = Omit<ComponentPropsWithRef<typeof BaseCombobox.Popup>,
312
312
  export declare function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }: PopupProps): import("react").JSX.Element;
313
313
  /** Optional decorative popup arrow. Place inside Popup; the SVG and direction handling are supplied. No children needed. */
314
314
  export declare const Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").SVGProps<SVGSVGElement>, "children" | "dangerouslySetInnerHTML"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
315
- /** Behavior only: turns its single child element into the popup trigger. Adds no preset styling and has no disableStyle prop. Use an accessible button child; pass className to the child for its appearance. */
316
- export declare const PopupOpenHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxTriggerProps, "children" | "className" | "render"> & {
317
- /** Additional classes forwarded to the trigger element. This handler has no preset styles. */
318
- className?: string;
319
- /** Single element to receive the behavior. Use a button with an accessible name. */
320
- children: ReactElement;
321
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
322
- /** Behavior only: turns its single child element into a removal control for the surrounding Chip. Adds no preset styling and has no disableStyle prop. Use an accessible button child. */
323
- export declare const ChipRemoveHandler: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxChipRemoveProps, "children" | "className" | "render"> & {
324
- /** Additional classes forwarded to the removal element. This handler has no preset styles. */
325
- className?: string;
326
- /** Single element to receive the behavior. Use a button with an accessible name. */
327
- children: ReactElement;
328
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
329
315
  /** Optional input adornment container inside InputGroup. Wraps icons, text, or buttons without adding trigger behavior. */
330
316
  export declare const Addon: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
331
317
  /** Preset adornment appearance. Does not add button behavior. @default 'normal' */
@@ -346,7 +332,7 @@ export declare const AddonButton: import("react").ForwardRefExoticComponent<Omit
346
332
  /** Disables this button. Root disabled or readOnly also disables it automatically. */
347
333
  disabled?: ComponentProps<"button">["disabled"];
348
334
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
349
- /** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root tone controls its preset validation border. */
335
+ /** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root validation controls its preset validation border. */
350
336
  export declare const InputGroup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ComboboxInputGroupProps, "className"> & {
351
337
  className?: string;
352
338
  } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -384,12 +370,15 @@ export declare const ItemText: import("react").ForwardRefExoticComponent<Omit<im
384
370
  export declare const AddonText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
385
371
  /** Text content inside Empty. Supply your empty-result message; Empty handles its visibility automatically. */
386
372
  export declare const EmptyText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
387
- /** Optional supporting text. Supply its content; it does not connect itself to the input with aria-describedby. Use matching id and Input aria-describedby when needed. */
373
+ /** Optional supporting text. Supply its content; it describes the input to screen readers automatically. */
388
374
  export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
389
- /** Optional alert message. You control when it is rendered and its contents; tone does not validate or show this message automatically. */
390
- export declare const Error: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
391
- /** Optional success status. You control when it is rendered and its contents; tone does not show this message automatically. */
392
- export declare const Success: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
375
+ type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
376
+ children?: ValidationMessageChildren;
377
+ };
378
+ /** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
379
+ export declare const Error: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
380
+ /** 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. */
381
+ export declare const Success: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
393
382
  /** Built-in decorative open-button icon. Place inside AddonOpenButton; no children needed. Defaults to strokeWidth 1.5. */
394
383
  export declare const AddonOpenButtonIcon: import("react").ForwardRefExoticComponent<Omit<Omit<SVGIconProps, "strokeWidth"> & {
395
384
  /** @default 1.5 */
@@ -424,4 +413,3 @@ export declare const LoadingText: import("react").ForwardRefExoticComponent<Omit
424
413
  /** Built-in decorative spinner for Loading. No children needed; you control when it is rendered. */
425
414
  export declare const LoadingIcon: import("react").ForwardRefExoticComponent<Omit<SVGIconProps & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
426
415
  export {};
427
- //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
3
- import { Check, ChevronsUpDown, LoaderCircle, X } from 'lucide-react';
4
- import { cloneElement, createContext, forwardRef, useContext, useId, useState, } from 'react';
3
+ import { Check, ChevronsUpDown, LoaderCircle, X } from "../../utils/icons.js";
4
+ import { cloneElement, createContext, forwardRef, useContext, useEffect, useId, useState } from 'react';
5
5
  import { twMerge } from 'tailwind-merge';
6
- import { ToneProvider, useToneContext } from "../../utils/Tone.js";
6
+ import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
7
7
  /**
8
8
  * Searchable selection using Base UI's built-in filtering and keyboard handling.
9
9
  * Does not render an element. Keep all parts inside Root.
@@ -157,21 +157,28 @@ import { ToneProvider, useToneContext } from "../../utils/Tone.js";
157
157
  * <Combobox.AddonOpenButtonIcon />
158
158
  * </Combobox.AddonOpenButton>
159
159
  */
160
- export function Root({ children, id, tone = 'neutral', open, defaultOpen = false, onOpenChange, onItemHighlighted, ...props }) {
160
+ export function Root({ children, id, validation, defaultOpen = false, onOpenChange, ...props }) {
161
+ //1. Tracking the open state even when uncontrolled, so parts can carry data-open
162
+ const [openInternalState, setOpenInternalState] = useState(defaultOpen);
163
+ //2. Holding the ids of Description, Error and Success, so Input announces them to screen readers through aria-describedby
164
+ const [describedByIds, setDescribedByIds] = useState([]);
165
+ //3. Sharing everything with the parts
161
166
  const generatedId = useId();
162
167
  const inputId = id ?? generatedId;
163
- const [openInternalState, setOpenInternalState] = useState(defaultOpen);
164
- return (_jsx(BaseCombobox.Root, { ...props, id: inputId, open: open, defaultOpen: defaultOpen, onItemHighlighted: onItemHighlighted, isItemEqualToValue: (item, selected) => item.value === selected.value, onOpenChange: (nextOpen, details) => {
168
+ return (_jsx(BaseCombobox.Root, { ...props, id: inputId, defaultOpen: defaultOpen, isItemEqualToValue: (item, selected) => item.value === selected.value, onOpenChange: (nextOpen, details) => {
165
169
  onOpenChange?.(nextOpen, details);
166
170
  if (!details.isCanceled)
167
171
  setOpenInternalState(nextOpen);
168
172
  }, children: _jsx(ComboboxContext.Provider, { value: {
169
173
  inputId,
170
- open: open ?? openInternalState,
174
+ open: props.open ?? openInternalState,
171
175
  disabled: props.disabled ?? false,
172
176
  readOnly: props.readOnly ?? false,
173
177
  required: props.required ?? false,
174
- }, children: _jsx(ToneProvider, { value: tone, children: children }) }) }));
178
+ validation: readValidation(validation),
179
+ describedByIds,
180
+ setDescribedByIds,
181
+ }, children: children }) }));
175
182
  }
176
183
  /** Use for the standard stacked layout, or omit when supplying your own layout. */
177
184
  export const Container = /* @__PURE__ */ forwardRef(function Container({ disableStyle, className, ...props }, ref) {
@@ -179,15 +186,15 @@ export const Container = /* @__PURE__ */ forwardRef(function Container({ disable
179
186
  });
180
187
  /** Labels the input automatically using Root's id. Supply the visible label as children; no htmlFor needed. */
181
188
  export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, className, ...props }, ref) {
182
- const { inputId } = useComboboxContext();
189
+ const context = useComboboxContext();
183
190
  const attributes = usePartAttributes();
184
- return (_jsx("label", { ...attributes, ...props, ref: ref, htmlFor: inputId, "data-component": "combobox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
191
+ return (_jsx("label", { ...attributes, ...props, ref: ref, htmlFor: context.inputId, "data-component": "combobox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
185
192
  });
186
193
  /** Search input with built-in filtering and selected-label display. Its id is managed by Root. Inside ChipsList, the preset automatically uses the compact chip-input sizing. */
187
- export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, ...props }, ref) {
188
- const { inputId } = useComboboxContext();
194
+ export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, 'aria-describedby': describedBy, ...props }, ref) {
195
+ const context = useComboboxContext();
189
196
  const inChips = useContext(ChipsContext);
190
- return (_jsx(BaseCombobox.Input, { ...props, ref: ref, id: inputId, "data-component": "combobox-input", "data-style-disabled": disableStyle ? '' : undefined, "data-in-chips": inChips ? '' : undefined, className: className }));
197
+ return (_jsx(BaseCombobox.Input, { "aria-invalid": context.validation.state === 'error' || undefined, "aria-describedby": [describedBy, ...context.describedByIds].filter(Boolean).join(' ') || undefined, ...props, ref: ref, id: context.inputId, "data-component": "combobox-input", "data-style-disabled": disableStyle ? '' : undefined, "data-in-chips": inChips ? '' : undefined, className: className }));
191
198
  });
192
199
  function ChipsListInner({ disableStyle, children, className, ...props }, ref) {
193
200
  return (_jsx(BaseCombobox.Value, { children: (selected) => (_jsx(ChipsContext.Provider, { value: true, children: _jsx(BaseCombobox.Chips, { ...props, ref: ref, "data-slot": "chips-list", "data-component": "combobox-chipslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? children(selected) : children }) })) }));
@@ -222,24 +229,24 @@ export const ChipsList = /* @__PURE__ */ forwardRef(ChipsListInner);
222
229
  /** Reads Base UI selection without rendering its own element. Use its children callback only when you need a custom selection display; Input already displays the selected label automatically. */
223
230
  export const Value = BaseCombobox.Value;
224
231
  /** Required listbox and scroll viewport inside Popup. Place GroupsList inside it. Owns keyboard/listbox semantics; do not nest another listbox primitive. */
225
- export const ScrollArea = /* @__PURE__ */ forwardRef(function ScrollArea({ disableStyle, className, style, ...props }, ref) {
226
- return (_jsx(BaseCombobox.List, { ...props, ref: ref, style: style, "data-component": "combobox-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
232
+ export const ScrollArea = /* @__PURE__ */ forwardRef(function ScrollArea({ disableStyle, className, ...props }, ref) {
233
+ return (_jsx(BaseCombobox.List, { ...props, ref: ref, "data-component": "combobox-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
227
234
  });
228
235
  /** Required groups container inside ScrollArea. A children callback receives each automatically filtered group; do not filter or map the original groups again. Manually annotate group with Combobox.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
229
- export function GroupsList({ disableStyle, children, className, style, ...props }) {
230
- return (_jsx("div", { ...props, style: style, "data-component": "combobox-groupslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
236
+ export function GroupsList({ disableStyle, children, className, ...props }) {
237
+ return (_jsx("div", { ...props, "data-component": "combobox-groupslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
231
238
  }
232
239
  /** Required items container inside Group. A children callback receives the filtered items belonging to that Group; do not repeat filtering yourself. Manually annotate item with Combobox.ItemType<typeof rootItems>, using the exact items variable passed to Root. */
233
- export function ItemsList({ disableStyle, children, className, style, ...props }) {
234
- return (_jsx("div", { ...props, style: style, "data-component": "combobox-itemslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
240
+ export function ItemsList({ disableStyle, children, className, ...props }) {
241
+ return (_jsx("div", { ...props, "data-component": "combobox-itemslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
235
242
  }
236
243
  /** Required wrapper around ItemsList, even for a visually flat list. Pass group.items. A GroupLabel is optional; omit it when the group has an empty label. */
237
- export function Group({ disableStyle, className, style, ...props }) {
238
- return (_jsx(BaseCombobox.Group, { ...props, style: style, "data-component": "combobox-group", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
244
+ export function Group({ disableStyle, className, ...props }) {
245
+ return (_jsx(BaseCombobox.Group, { ...props, "data-component": "combobox-group", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
239
246
  }
240
247
  /** Required selectable row inside ItemsList. Pass the complete item object as value, with ItemText and ItemIndicator inside. Selection, highlighting, and keyboard behavior are built in. */
241
- export function Item({ disableStyle, className, style, ...props }) {
242
- return (_jsx(BaseCombobox.Item, { ...props, style: style, "data-component": "combobox-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
248
+ export function Item({ disableStyle, className, ...props }) {
249
+ return (_jsx(BaseCombobox.Item, { ...props, "data-component": "combobox-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
243
250
  }
244
251
  /** Popup containing Empty, an optional Loading message, and ScrollArea, in that order. Already includes the portal and positioner: do not add either yourself. Defaults to bottom/start with a 5px gap. Core available-space and anchor-width inline styles stay active when preset styling is disabled. */
245
252
  export function Popup({ disableStyle, container, keepMounted, anchor, positionMethod, side = 'bottom', sideOffset = 5, align = 'start', alignOffset, collisionBoundary, collisionPadding, sticky, arrowPadding, disableAnchorTracking, collisionAvoidance, className, style, ...props }) {
@@ -255,14 +262,6 @@ export function Popup({ disableStyle, container, keepMounted, anchor, positionMe
255
262
  export const Arrow = /* @__PURE__ */ forwardRef(function Arrow({ disableStyle, className, style, ...props }, ref) {
256
263
  return (_jsxs(BaseCombobox.Arrow, { style: style, render: _jsx("svg", { ...props, ref: ref, "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10" }), "data-component": "combobox-arrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "combobox-arrow-1" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "combobox-arrow-2" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "combobox-arrow-3" })] }));
257
264
  });
258
- /** Behavior only: turns its single child element into the popup trigger. Adds no preset styling and has no disableStyle prop. Use an accessible button child; pass className to the child for its appearance. */
259
- export const PopupOpenHandler = /* @__PURE__ */ forwardRef(function PopupOpenHandler({ children, ...props }, ref) {
260
- return _jsx(BaseCombobox.Trigger, { ...props, ref: ref, render: children });
261
- });
262
- /** Behavior only: turns its single child element into a removal control for the surrounding Chip. Adds no preset styling and has no disableStyle prop. Use an accessible button child. */
263
- export const ChipRemoveHandler = /* @__PURE__ */ forwardRef(function ChipRemoveHandler({ children, ...props }, ref) {
264
- return _jsx(BaseCombobox.ChipRemove, { ...props, ref: ref, render: children });
265
- });
266
265
  /** Optional input adornment container inside InputGroup. Wraps icons, text, or buttons without adding trigger behavior. */
267
266
  export const Addon = /* @__PURE__ */ forwardRef(function Addon({ disableStyle, variant = 'normal', className, ...props }, ref) {
268
267
  return (_jsx("div", { ...props, ref: ref, "data-variant": variant, "data-component": "combobox-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
@@ -287,10 +286,10 @@ export const AddonButton = /* @__PURE__ */ forwardRef(function AddonButton({ dis
287
286
  const attributes = usePartAttributes();
288
287
  return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "combobox-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
289
288
  });
290
- /** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root tone controls its preset validation border. */
289
+ /** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root validation controls its preset validation border. */
291
290
  export const InputGroup = /* @__PURE__ */ forwardRef(function InputGroup({ disableStyle, className, ...props }, ref) {
292
- const tone = useToneContext();
293
- return (_jsx(BaseCombobox.InputGroup, { "data-tone": tone, ...props, ref: ref, "data-component": "combobox-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
291
+ const attributes = usePartAttributes();
292
+ return (_jsx(BaseCombobox.InputGroup, { "data-validation": attributes['data-validation'], ...props, ref: ref, "data-component": "combobox-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
294
293
  });
295
294
  /** Displays one selected item inside ChipsList. Keep chips in selected-item order so Base UI can remove the matching item. Supply the item label and an optional removal control. */
296
295
  export const Chip = /* @__PURE__ */ forwardRef(function Chip({ disableStyle, className, ...props }, ref) {
@@ -335,40 +334,54 @@ export const EmptyText = /* @__PURE__ */ forwardRef(function EmptyText({ disable
335
334
  const attributes = usePartAttributes();
336
335
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "combobox-emptytext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
337
336
  });
338
- /** Optional supporting text. Supply its content; it does not connect itself to the input with aria-describedby. Use matching id and Input aria-describedby when needed. */
339
- export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
337
+ /** Optional supporting text. Supply its content; it describes the input to screen readers automatically. */
338
+ export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, id, ...props }, ref) {
339
+ const describedById = useDescribedById(id);
340
340
  const attributes = usePartAttributes();
341
- return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "combobox-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
341
+ return (_jsx("div", { ...attributes, ...props, id: describedById, ref: ref, "data-component": "combobox-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
342
342
  });
343
- /** Optional alert message. You control when it is rendered and its contents; tone does not validate or show this message automatically. */
344
- export const Error = /* @__PURE__ */ forwardRef(function Error({ disableStyle, className, ...props }, ref) {
345
- const attributes = usePartAttributes();
346
- return (_jsx("div", { role: "alert", "aria-atomic": "true", ...attributes, ...props, ref: ref, "data-component": "combobox-error", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
343
+ /** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
344
+ export const Error = /* @__PURE__ */ forwardRef(function Error({ children, ...props }, ref) {
345
+ const context = useComboboxContext();
346
+ const content = validationMessageContent(context.validation, 'error', children);
347
+ if (content === undefined)
348
+ return null;
349
+ return _jsx(Message, { ...props, ref: ref, role: "alert", component: "combobox-error", children: content });
347
350
  });
348
- /** Optional success status. You control when it is rendered and its contents; tone does not show this message automatically. */
349
- export const Success = /* @__PURE__ */ forwardRef(function Success({ disableStyle, className, ...props }, ref) {
351
+ /** 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. */
352
+ export const Success = /* @__PURE__ */ forwardRef(function Success({ children, ...props }, ref) {
353
+ const context = useComboboxContext();
354
+ const content = validationMessageContent(context.validation, 'success', children);
355
+ if (content === undefined)
356
+ return null;
357
+ return _jsx(Message, { ...props, ref: ref, role: "status", component: "combobox-success", children: content });
358
+ });
359
+ // The shared body of Error and Success, mounted only while they show, so only visible messages describe the input
360
+ const Message = /* @__PURE__ */ forwardRef(function Message({ disableStyle, className, id, component, ...props }, ref) {
361
+ const describedById = useDescribedById(id);
350
362
  const attributes = usePartAttributes();
351
- return (_jsx("div", { role: "status", "aria-atomic": "true", ...attributes, ...props, ref: ref, "data-component": "combobox-success", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
363
+ return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: describedById, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
352
364
  });
353
365
  /** Built-in decorative open-button icon. Place inside AddonOpenButton; no children needed. Defaults to strokeWidth 1.5. */
354
- export const AddonOpenButtonIcon = /* @__PURE__ */ forwardRef(function AddonOpenButtonIcon({ disableStyle, className, strokeWidth = 1.5, ...props }, ref) {
355
- const attributes = usePartAttributes();
356
- return (_jsx(ChevronsUpDown, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-addonopenbuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
366
+ export const AddonOpenButtonIcon = /* @__PURE__ */ forwardRef(function AddonOpenButtonIcon(props, ref) {
367
+ return _jsx(BuiltInIcon, { ...props, ref: ref, icon: ChevronsUpDown, component: "combobox-addonopenbuttonicon" });
357
368
  });
358
369
  /** Built-in decorative clear icon. Place inside AddonClearButton; no children needed. Defaults to strokeWidth 1.5. */
359
- export const AddonClearButtonIcon = /* @__PURE__ */ forwardRef(function AddonClearButtonIcon({ disableStyle, className, strokeWidth = 1.5, ...props }, ref) {
360
- const attributes = usePartAttributes();
361
- return (_jsx(X, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-addonclearbuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
370
+ export const AddonClearButtonIcon = /* @__PURE__ */ forwardRef(function AddonClearButtonIcon(props, ref) {
371
+ return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-addonclearbuttonicon" });
362
372
  });
363
373
  /** Built-in decorative removal icon. Place inside ChipRemoveButton; no children needed. Defaults to strokeWidth 1.5. */
364
- export const ChipRemoveButtonIcon = /* @__PURE__ */ forwardRef(function ChipRemoveButtonIcon({ disableStyle, className, strokeWidth = 1.5, ...props }, ref) {
365
- const attributes = usePartAttributes();
366
- return (_jsx(X, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-chipremovebuttonicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
374
+ export const ChipRemoveButtonIcon = /* @__PURE__ */ forwardRef(function ChipRemoveButtonIcon(props, ref) {
375
+ return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-chipremovebuttonicon" });
367
376
  });
368
377
  /** Optional spinner inside Addon. Does not detect requests: you decide when to render it. Defaults to strokeWidth 1.5. */
369
- export const AddonLoadingIcon = /* @__PURE__ */ forwardRef(function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ...props }, ref) {
378
+ export const AddonLoadingIcon = /* @__PURE__ */ forwardRef(function AddonLoadingIcon(props, ref) {
379
+ return _jsx(BuiltInIcon, { ...props, ref: ref, icon: LoaderCircle, component: "combobox-addonloadingicon" });
380
+ });
381
+ // The shared body of the built-in decorative icons above, which only differ by their icon and component name
382
+ const BuiltInIcon = /* @__PURE__ */ forwardRef(function BuiltInIcon({ disableStyle, className, strokeWidth = 1.5, icon: Icon, component, ...props }, ref) {
370
383
  const attributes = usePartAttributes();
371
- return (_jsx(LoaderCircle, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-addonloadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
384
+ return _jsx(Icon, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
372
385
  });
373
386
  /** Required selection indicator inside Item. Visibility is automatic and a checkmark is supplied: no children or selection condition needed. Pass children only to replace the built-in checkmark. */
374
387
  export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({ disableStyle, children, keepMounted, ...props }, ref) {
@@ -391,11 +404,11 @@ export const LoadingText = /* @__PURE__ */ forwardRef(function LoadingText({ dis
391
404
  return (_jsx("div", { ...props, ref: ref, "data-component": "combobox-loadingtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
392
405
  });
393
406
  /** Built-in decorative spinner for Loading. No children needed; you control when it is rendered. */
394
- export const LoadingIcon = /* @__PURE__ */ forwardRef(function LoadingIcon({ disableStyle, className, ...props }, ref) {
395
- return (_jsx(LoaderCircle, { "aria-hidden": true, strokeWidth: undefined, ...props, ref: ref, "data-component": "combobox-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
407
+ export const LoadingIcon = /* @__PURE__ */ forwardRef(function LoadingIcon({ disableStyle, className, strokeWidth = 2, ...props }, ref) {
408
+ return (_jsx(LoaderCircle, { "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
396
409
  });
397
- const ComboboxContext =
398
- /* @__PURE__ */ createContext(null);
410
+ const ComboboxContext = /* @__PURE__ */ createContext(null);
411
+ // Telling Input it sits inside ChipsList, so the preset uses the compact chip-input sizing
399
412
  const ChipsContext = /* @__PURE__ */ createContext(false);
400
413
  function useComboboxContext() {
401
414
  const context = useContext(ComboboxContext);
@@ -403,15 +416,25 @@ function useComboboxContext() {
403
416
  throw new globalThis.Error('Combobox parts must be inside Combobox.Root');
404
417
  return context;
405
418
  }
419
+ // The state attributes every part carries, so presets can style any part from Root's state
406
420
  function usePartAttributes() {
407
- const { open, disabled, readOnly, required } = useComboboxContext();
408
- const tone = useToneContext();
421
+ const context = useComboboxContext();
409
422
  return {
410
- 'data-open': open ? '' : undefined,
411
- 'data-disabled': disabled ? '' : undefined,
412
- 'data-readonly': readOnly ? '' : undefined,
413
- 'data-required': required ? '' : undefined,
414
- 'data-tone': tone,
423
+ 'data-open': context.open ? '' : undefined,
424
+ 'data-disabled': context.disabled ? '' : undefined,
425
+ 'data-readonly': context.readOnly ? '' : undefined,
426
+ 'data-required': context.required ? '' : undefined,
427
+ ...validationAttributes(context.validation),
415
428
  };
416
429
  }
417
- //# sourceMappingURL=index.js.map
430
+ // Registering a part's id in Input's aria-describedby while the part is mounted
431
+ function useDescribedById(id) {
432
+ const context = useComboboxContext();
433
+ const generatedId = useId();
434
+ const describedById = id ?? generatedId;
435
+ useEffect(() => {
436
+ context.setDescribedByIds((current) => [...current, describedById]);
437
+ return () => context.setDescribedByIds((current) => current.filter((currentId) => currentId !== describedById));
438
+ }, [describedById, context.setDescribedByIds]);
439
+ return describedById;
440
+ }
@@ -1,4 +1,5 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
+ import type { AsChildProps } from '../../utils/asChild.ts';
2
3
  import type { DatePickerProps } from 'react-aria-components/DatePicker';
3
4
  import type { DateRangePickerProps } from 'react-aria-components/DateRangePicker';
4
5
  import { Label as AriaLabel } from 'react-aria-components/Label';
@@ -16,6 +17,8 @@ import { FieldError } from 'react-aria-components/FieldError';
16
17
  import type { CalendarDate } from '@internationalized/date';
17
18
  import type { ComponentProps, ReactElement, ReactNode } from 'react';
18
19
  import type { SVGIconProps } from '../../types/Icon.ts';
20
+ import type { Validation } from '../../types/Validation.ts';
21
+ import type { ValidationMessageChildren } from '../../utils/Validation.ts';
19
22
  type DateRange = {
20
23
  start: string;
21
24
  end: string;
@@ -35,8 +38,6 @@ type SharedRootProps = {
35
38
  readOnly?: DatePickerProps<CalendarDate>['isReadOnly'];
36
39
  /** Require a date when validating a surrounding form. */
37
40
  required?: DatePickerProps<CalendarDate>['isRequired'];
38
- /** Mark the picker invalid for accessibility and validation; use tone for a separate visual tone. */
39
- invalid?: DatePickerProps<CalendarDate>['isInvalid'];
40
41
  /** Control the popup from application state. Omit to let trigger interactions manage it. */
41
42
  open?: DatePickerProps<CalendarDate>['isOpen'];
42
43
  /** Prevent selection before this ISO calendar date (YYYY-MM-DD). Omit for no lower limit. */
@@ -47,8 +48,11 @@ type SharedRootProps = {
47
48
  placeholderValue?: string | null;
48
49
  /** Choose date formatting and language. Omit to use the inherited application locale. */
49
50
  locale?: string;
50
- /** Choose the visual tone. This does not validate data or show/hide feedback messages. */
51
- tone?: 'neutral' | 'valid' | 'invalid';
51
+ /**
52
+ * The picker's validation state, with an optional message: `'error'` marks it invalid, `['error', 'Pick a later date']` also shows that message in Error. Same for `'success'` and Success.
53
+ * Omit it to keep only the picker's own validation, like a required or out-of-range date.
54
+ */
55
+ validation?: Validation;
52
56
  };
53
57
  type SingleRootProps = Pick<DatePickerProps<CalendarDate>, CoreKeys | 'name' | 'autoComplete'> & SharedRootProps & {
54
58
  /** Use range for a start/end selection; single is the default. Choose the corresponding field composition. */
@@ -200,17 +204,8 @@ export declare function AddonOpenButtonIcon({ disableStyle, children, className,
200
204
  /** Omit for the supplied default icon; pass a child only to replace it. */
201
205
  children?: ReactElement<SVGIconProps>;
202
206
  }) & StyleProps): ReactElement<SVGIconProps, string | import("react").JSXElementConstructor<any>>;
203
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
204
- export declare function AddonOpenHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
205
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
206
- children: ReactElement<ComponentProps<'button'>>;
207
- }): import("react").JSX.Element;
208
- export declare function OpenButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
209
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
210
- export declare function OpenHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
211
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
212
- children: ReactElement<ComponentProps<'button'>>;
213
- }): import("react").JSX.Element;
207
+ /** 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. */
208
+ export declare function OpenButton({ asChild, disableStyle, isDisabled, children, ...props }: StyledButtonProps & AsChildProps & StyleProps): import("react").JSX.Element;
214
209
  /** Formats the selected date or range automatically. Omit children for the usual display; supply children only to replace it. Placeholder appears before selection. */
215
210
  export declare function OpenButtonValue({ disableStyle, children, placeholder, className, ...props }: (ComponentProps<'span'> & {
216
211
  /** Shown before a date is selected. Omit children to keep the automatic formatted date display. */
@@ -226,7 +221,7 @@ export type PopupProps = Omit<PopoverProps, 'className' | 'style' | 'render' | '
226
221
  style?: ComponentProps<'div'>['style'];
227
222
  } & StyleProps;
228
223
  /** 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. */
229
- export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "slot" | "style" | "className" | "render" | "onOpenChange" | "defaultOpen" | "isOpen" | "trigger"> & {
224
+ export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "className" | "slot" | "style" | "render" | "onOpenChange" | "defaultOpen" | "isOpen" | "trigger"> & {
230
225
  className?: string;
231
226
  style?: ComponentProps<"div">["style"];
232
227
  } & StyleProps & import("react").RefAttributes<HTMLElement>>;
@@ -268,16 +263,6 @@ export declare function Actions({ disableStyle, className, ...props }: Component
268
263
  export declare function ViewDateValue({ disableStyle, className, level, ...props }: (Omit<ComponentProps<'h2'>, 'children'> & Pick<ComponentProps<typeof Heading>, 'level'>) & StyleProps): import("react").JSX.Element;
269
264
  export declare function PreviousButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
270
265
  export declare function NextButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
271
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
272
- export declare function PreviousHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
273
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
274
- children: ReactElement<ComponentProps<'button'>>;
275
- }): import("react").JSX.Element;
276
- /** Behavior only: give your child control this action. Style the child itself; this wrapper has no preset appearance or disableStyle prop. */
277
- export declare function NextHandler({ children, isDisabled, ...props }: Omit<StyledButtonProps, 'children' | 'render'> & {
278
- /** Supply your own accessible control. It receives the behavior; its own className owns the appearance. */
279
- children: ReactElement<ComponentProps<'button'>>;
280
- }): import("react").JSX.Element;
281
266
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
282
267
  export declare function PreviousButtonIcon({ disableStyle, children, className, ...props }: (Omit<SVGIconProps, 'children'> & {
283
268
  /** Omit for the supplied default icon; pass a child only to replace it. */
@@ -299,11 +284,13 @@ export declare function Table({ disableStyle, index, className, ...props }: (Omi
299
284
  index?: number;
300
285
  }) & StyleProps): import("react").JSX.Element;
301
286
  export declare function Description({ disableStyle, className, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render'> & StyleProps): import("react").JSX.Element;
302
- /** Keep mounted to let the picker render its validation error automatically. Omit children for the native error text; override only for a custom message. */
303
- export declare function Error({ disableStyle, className, ...props }: (Omit<ComponentProps<typeof FieldError>, 'className' | 'render'> & {
287
+ /** 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. */
288
+ export declare function Error({ disableStyle, className, children, ...props }: (Omit<ComponentProps<typeof FieldError>, 'className' | 'render' | 'children'> & {
304
289
  className?: string;
290
+ children?: ValidationMessageChildren;
305
291
  }) & StyleProps): import("react").JSX.Element;
306
- /** You decide when to show this feedback. Changing tone does not validate data or render the message for you. */
307
- export declare function Success({ disableStyle, className, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render'> & StyleProps): import("react").JSX.Element;
292
+ /** 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. */
293
+ export declare function Success({ disableStyle, className, children, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render' | 'children'> & {
294
+ children?: ValidationMessageChildren;
295
+ } & StyleProps): import("react").JSX.Element | null;
308
296
  export {};
309
- //# sourceMappingURL=index.d.ts.map