@zj-dynamics/components 0.0.0-stage → 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 (674) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.react-is +21 -0
  3. package/NOTICE.tabbable +22 -0
  4. package/README.md +31 -2
  5. package/compatibility.css +2 -0
  6. package/dist/Button.d.ts +90 -0
  7. package/dist/Button.js +58 -0
  8. package/dist/ButtonDismiss.d.ts +6 -0
  9. package/dist/ButtonDismiss.js +5 -0
  10. package/dist/Dialog.d.ts +75 -0
  11. package/dist/Dialog.js +59 -0
  12. package/dist/Icon.d.ts +20 -0
  13. package/dist/Icon.js +11 -0
  14. package/dist/InputText.d.ts +26 -0
  15. package/dist/InputText.js +63 -0
  16. package/dist/Switch.d.ts +8 -0
  17. package/dist/Switch.js +19 -0
  18. package/dist/Toast.d.ts +21 -0
  19. package/dist/Toast.js +58 -0
  20. package/dist/browserFocus.d.ts +11 -0
  21. package/dist/browserFocus.js +85 -0
  22. package/dist/browserHooks.d.ts +5 -0
  23. package/dist/browserHooks.js +4 -0
  24. package/dist/index.d.ts +100 -0
  25. package/dist/index.js +91 -0
  26. package/dist/legacyModalPortal.d.ts +1 -0
  27. package/dist/legacyModalPortal.js +2 -0
  28. package/dist/mockViewportWidth.d.ts +5 -0
  29. package/dist/mockViewportWidth.js +58 -0
  30. package/dist/slotChildren.d.ts +2 -0
  31. package/dist/slotChildren.js +6 -0
  32. package/dist/theme.d.ts +26 -0
  33. package/dist/theme.js +65 -0
  34. package/dist/unstyledPrimitives.d.ts +12 -0
  35. package/dist/unstyledPrimitives.js +12 -0
  36. package/dist/useBreakpoints.d.ts +3 -0
  37. package/dist/useBreakpoints.js +2 -0
  38. package/dist/useFocusTrap.d.ts +1 -0
  39. package/dist/useFocusTrap.js +1 -0
  40. package/dist/useInView.d.ts +1 -0
  41. package/dist/useInView.js +1 -0
  42. package/dist/useIsSmallScreen.d.ts +1 -0
  43. package/dist/useIsSmallScreen.js +1 -0
  44. package/dist/useLiveAnnounce.d.ts +1 -0
  45. package/dist/useLiveAnnounce.js +1 -0
  46. package/dist/useOnKeyDown.d.ts +1 -0
  47. package/dist/useOnKeyDown.js +1 -0
  48. package/dist/useRefocusOnActivator.d.ts +1 -0
  49. package/dist/useRefocusOnActivator.js +1 -0
  50. package/dist/useResizeObserver.d.ts +22 -0
  51. package/dist/useResizeObserver.js +47 -0
  52. package/dist/useWindowDimensions.d.ts +2 -0
  53. package/dist/useWindowDimensions.js +1 -0
  54. package/dist/viewport.d.ts +46 -0
  55. package/dist/viewport.js +141 -0
  56. package/foundation/ActivityIndicator/ActivityIndicator.d.ts +38 -0
  57. package/foundation/ActivityIndicator/index.d.mts +2 -0
  58. package/foundation/ActivityIndicator/index.mjs +6 -0
  59. package/foundation/ActivityIndicator-es.js +30 -0
  60. package/foundation/Autocomplete/Autocomplete.d.ts +8 -0
  61. package/foundation/Autocomplete/Autocomplete.types.d.ts +401 -0
  62. package/foundation/Autocomplete/hooks/useAutocompleteListNav.d.ts +30 -0
  63. package/foundation/Autocomplete/index.d.mts +3 -0
  64. package/foundation/Autocomplete/index.mjs +39 -0
  65. package/foundation/Autocomplete/utils/interactionUtils.d.ts +14 -0
  66. package/foundation/Autocomplete-es.js +1322 -0
  67. package/foundation/Avatar/Avatar.d.ts +77 -0
  68. package/foundation/Avatar/index.d.mts +1 -0
  69. package/foundation/Avatar/index.mjs +6 -0
  70. package/foundation/Avatar-es.js +80 -0
  71. package/foundation/Banner/Banner.d.ts +10 -0
  72. package/foundation/Banner/Banner.types.d.ts +165 -0
  73. package/foundation/Banner/index.d.mts +2 -0
  74. package/foundation/Banner/index.mjs +14 -0
  75. package/foundation/Banner-es.js +134 -0
  76. package/foundation/Body-es.js +45 -0
  77. package/foundation/BottomSheet-es.js +110 -0
  78. package/foundation/Box/Box.d.ts +3 -0
  79. package/foundation/Box/Box.types.d.ts +40 -0
  80. package/foundation/Box/index.d.mts +1 -0
  81. package/foundation/Box/index.mjs +4 -0
  82. package/foundation/Box-es.js +130 -0
  83. package/foundation/Button/Button.d.ts +17 -0
  84. package/foundation/Button/Button.types.d.ts +112 -0
  85. package/foundation/Button/ButtonInternals.d.ts +11 -0
  86. package/foundation/Button/ButtonProvider.d.ts +11 -0
  87. package/foundation/Button/index.d.mts +4 -0
  88. package/foundation/Button/useButtonStyles.d.ts +17 -0
  89. package/foundation/Button-es.js +122 -0
  90. package/foundation/ButtonDismiss/ButtonDismiss.d.ts +6 -0
  91. package/foundation/ButtonDismiss/index.d.mts +1 -0
  92. package/foundation/ButtonDismiss-es.js +9 -0
  93. package/foundation/Card/Card.d.ts +78 -0
  94. package/foundation/Card/cardcolors.module.d.ts +90 -0
  95. package/foundation/Card/index.d.mts +1 -0
  96. package/foundation/Card/index.mjs +37 -0
  97. package/foundation/Card/types.d.ts +63 -0
  98. package/foundation/Card-es.js +138 -0
  99. package/foundation/Checkbox/Checkbox.d.ts +7 -0
  100. package/foundation/Checkbox/Checkbox.types.d.ts +51 -0
  101. package/foundation/Checkbox/index.d.mts +2 -0
  102. package/foundation/Checkbox/index.mjs +8 -0
  103. package/foundation/Checkbox-es.js +57 -0
  104. package/foundation/Chip/Chip.d.ts +14 -0
  105. package/foundation/Chip/Chip.types.d.ts +70 -0
  106. package/foundation/Chip/components/ChipDismissible/ChipDismissible.d.ts +3 -0
  107. package/foundation/Chip/components/ChipPrefix/Chip.Prefix.d.ts +3 -0
  108. package/foundation/Chip/components/ChipSelectable/ChipSelectable.d.ts +3 -0
  109. package/foundation/Chip/components/ChipSuffix/Chip.Suffix.d.ts +9 -0
  110. package/foundation/Chip/index.d.mts +4 -0
  111. package/foundation/Chip/index.mjs +19 -0
  112. package/foundation/Chip-es.js +165 -0
  113. package/foundation/ChipDismissible-es.js +19 -0
  114. package/foundation/Chips/Chip.d.ts +9 -0
  115. package/foundation/Chips/ChipDismissible.d.ts +11 -0
  116. package/foundation/Chips/ChipTypes.d.ts +59 -0
  117. package/foundation/Chips/Chips.d.ts +8 -0
  118. package/foundation/Chips/ChipsTypes.d.ts +106 -0
  119. package/foundation/Chips/InternalChipButton.d.ts +11 -0
  120. package/foundation/Chips/index.d.mts +3 -0
  121. package/foundation/Chips/index.mjs +56 -0
  122. package/foundation/Chips-es.js +114 -0
  123. package/foundation/Cluster/Cluster.d.ts +3 -0
  124. package/foundation/Cluster/index.d.mts +2 -0
  125. package/foundation/Cluster/index.mjs +4 -0
  126. package/foundation/Cluster/types.d.ts +47 -0
  127. package/foundation/Cluster-es.js +12 -0
  128. package/foundation/Combobox/Combobox.d.ts +71 -0
  129. package/foundation/Combobox/Combobox.footer.d.ts +7 -0
  130. package/foundation/Combobox/Combobox.items.d.ts +25 -0
  131. package/foundation/Combobox/Combobox.selectAll.d.ts +4 -0
  132. package/foundation/Combobox/Combobox.slotFactory.d.ts +7 -0
  133. package/foundation/Combobox/Combobox.types.d.ts +168 -0
  134. package/foundation/Combobox/index.d.mts +2 -0
  135. package/foundation/Combobox/index.mjs +28 -0
  136. package/foundation/Combobox-es.js +782 -0
  137. package/foundation/ComboboxPrimitive-es.js +187 -0
  138. package/foundation/ComboboxSeparator-es.js +3541 -0
  139. package/foundation/ComponentSettingsContext/ComponentSettingsContext.d.ts +41 -0
  140. package/foundation/ComponentSettingsContext/index.d.mts +4 -0
  141. package/foundation/ComponentSettingsContext/index.mjs +5 -0
  142. package/foundation/ComponentSettingsContext-es.js +18 -0
  143. package/foundation/ConfirmationModal/ConfirmationModal.d.ts +79 -0
  144. package/foundation/ConfirmationModal/index.d.mts +1 -0
  145. package/foundation/ConfirmationModal/index.mjs +37 -0
  146. package/foundation/ConfirmationModal-es.js +111 -0
  147. package/foundation/Container/Container.d.ts +6 -0
  148. package/foundation/Container/index.d.mts +1 -0
  149. package/foundation/Container/index.mjs +3 -0
  150. package/foundation/Container/types.d.ts +22 -0
  151. package/foundation/Container-es.js +16 -0
  152. package/foundation/Content/Content.d.ts +22 -0
  153. package/foundation/Content/Spacing.module.d.ts +14 -0
  154. package/foundation/Content/index.d.mts +1 -0
  155. package/foundation/Content/index.mjs +3 -0
  156. package/foundation/Content-es.js +13 -0
  157. package/foundation/ContentBlock/ContentBlock.d.ts +3 -0
  158. package/foundation/ContentBlock/index.d.mts +2 -0
  159. package/foundation/ContentBlock/index.mjs +4 -0
  160. package/foundation/ContentBlock/types.d.ts +37 -0
  161. package/foundation/ContentBlock-es.js +29 -0
  162. package/foundation/Countdown/Countdown.d.ts +30 -0
  163. package/foundation/Countdown/index.d.mts +1 -0
  164. package/foundation/Countdown/index.mjs +4 -0
  165. package/foundation/Countdown-es.js +649 -0
  166. package/foundation/Cover/Cover.d.ts +6 -0
  167. package/foundation/Cover/index.d.mts +2 -0
  168. package/foundation/Cover/index.mjs +4 -0
  169. package/foundation/Cover/types.d.ts +34 -0
  170. package/foundation/Cover-es.js +14 -0
  171. package/foundation/DataDump/DataDump.d.ts +21 -0
  172. package/foundation/DataDump/index.d.mts +1 -0
  173. package/foundation/DataDump/index.mjs +40 -0
  174. package/foundation/DataDump-es.js +26 -0
  175. package/foundation/DataList/DataList.const.d.ts +22 -0
  176. package/foundation/DataList/DataList.d.ts +28 -0
  177. package/foundation/DataList/DataList.types.d.ts +323 -0
  178. package/foundation/DataList/components/DataListAction/DataListAction.d.ts +3 -0
  179. package/foundation/DataList/components/DataListAction/index.d.mts +1 -0
  180. package/foundation/DataList/components/DataListBulkActions/DataListBulkActions.d.ts +4 -0
  181. package/foundation/DataList/components/DataListBulkActions/index.d.mts +1 -0
  182. package/foundation/DataList/components/DataListEmptyState/DataListEmptyState.d.ts +4 -0
  183. package/foundation/DataList/components/DataListEmptyState/index.d.mts +1 -0
  184. package/foundation/DataList/components/DataListFilters/DataListFilters.d.ts +11 -0
  185. package/foundation/DataList/components/DataListFilters/index.d.mts +1 -0
  186. package/foundation/DataList/components/DataListItemActions/DataListItemActions.d.ts +9 -0
  187. package/foundation/DataList/components/DataListItemActions/index.d.mts +1 -0
  188. package/foundation/DataList/components/DataListLayout/DataListLayout.d.ts +3 -0
  189. package/foundation/DataList/components/DataListLayout/index.d.mts +1 -0
  190. package/foundation/DataList/components/DataListLayoutActions/DataListLayoutActions.d.ts +2 -0
  191. package/foundation/DataList/components/DataListLayoutActions/index.d.mts +1 -0
  192. package/foundation/DataList/components/DataListSearch/DataListSearch.d.ts +8 -0
  193. package/foundation/DataList/components/DataListSearch/index.d.mts +1 -0
  194. package/foundation/DataList/components/DataListStatusBar/DataListStatusBar.d.ts +11 -0
  195. package/foundation/DataList/components/DataListStatusBar/index.d.mts +1 -0
  196. package/foundation/DataList/index.d.mts +2 -0
  197. package/foundation/DataList/index.mjs +96 -0
  198. package/foundation/DataList-es.js +141 -0
  199. package/foundation/DataList.const-es.js +26 -0
  200. package/foundation/DataList.module-es.js +3 -0
  201. package/foundation/DataList.utils-es.js +167 -0
  202. package/foundation/DataListAction-es.js +43 -0
  203. package/foundation/DataListActions-es.js +53 -0
  204. package/foundation/DataListActionsMenu-es.js +52 -0
  205. package/foundation/DataListBulkActions-es.js +28 -0
  206. package/foundation/DataListContext-es.js +26 -0
  207. package/foundation/DataListEmptyState-es.js +54 -0
  208. package/foundation/DataListFilters-es.js +43 -0
  209. package/foundation/DataListHeader-es.js +130 -0
  210. package/foundation/DataListHeaderTile-es.js +86 -0
  211. package/foundation/DataListItem-es.js +118 -0
  212. package/foundation/DataListItemActions-es.js +29 -0
  213. package/foundation/DataListItemActionsOverflow-es.js +34 -0
  214. package/foundation/DataListItemClickable-es.js +45 -0
  215. package/foundation/DataListItems-es.js +19 -0
  216. package/foundation/DataListLayout-es.js +19 -0
  217. package/foundation/DataListLayoutActions-es.js +36 -0
  218. package/foundation/DataListLayoutContext-es.js +14 -0
  219. package/foundation/DataListLayoutContext-es2.js +8 -0
  220. package/foundation/DataListLoadMore-es.js +32 -0
  221. package/foundation/DataListLoadingState-es.js +22 -0
  222. package/foundation/DataListOverflowFade-es.js +22 -0
  223. package/foundation/DataListSearch-es.js +84 -0
  224. package/foundation/DataListSort-es.js +74 -0
  225. package/foundation/DataListSortingOptions-es.js +34 -0
  226. package/foundation/DataListStatusBar-es.js +22 -0
  227. package/foundation/DataListStickyHeader-es.js +23 -0
  228. package/foundation/DataListTags-es.js +62 -0
  229. package/foundation/DataListTotalCount-es.js +38 -0
  230. package/foundation/DataTable/DataTable.d.ts +74 -0
  231. package/foundation/DataTable/SortIcon.d.ts +11 -0
  232. package/foundation/DataTable/components/DataTableActions.d.ts +2 -0
  233. package/foundation/DataTable/components/DataTableBody.d.ts +2 -0
  234. package/foundation/DataTable/components/DataTableCell.d.ts +2 -0
  235. package/foundation/DataTable/components/DataTableContainer.d.ts +2 -0
  236. package/foundation/DataTable/components/DataTableFooter.d.ts +5 -0
  237. package/foundation/DataTable/components/DataTableHeader.d.ts +2 -0
  238. package/foundation/DataTable/components/DataTableHeaderCell.d.ts +5 -0
  239. package/foundation/DataTable/components/DataTablePagination.d.ts +5 -0
  240. package/foundation/DataTable/components/DataTablePaginationButton.d.ts +21 -0
  241. package/foundation/DataTable/components/DataTableRow.d.ts +2 -0
  242. package/foundation/DataTable/components/DataTableRowActions.d.ts +4 -0
  243. package/foundation/DataTable/components/DataTableSortableHeader.d.ts +24 -0
  244. package/foundation/DataTable/components/DataTableTable.d.ts +11 -0
  245. package/foundation/DataTable/components/index.d.mts +13 -0
  246. package/foundation/DataTable/index.d.mts +6 -0
  247. package/foundation/DataTable/index.mjs +29 -0
  248. package/foundation/DataTable/test-utilities/helpers.d.ts +1 -0
  249. package/foundation/DataTable/types.d.ts +83 -0
  250. package/foundation/DataTable-es.js +262 -0
  251. package/foundation/DataTableTable-es.js +117 -0
  252. package/foundation/DatePicker/DatePicker.d.ts +74 -0
  253. package/foundation/DatePicker/DatePickerActivator.d.ts +18 -0
  254. package/foundation/DatePicker/index.d.mts +1 -0
  255. package/foundation/DatePicker/index.mjs +26 -0
  256. package/foundation/DatePicker-es.js +13627 -0
  257. package/foundation/Dialog/dialogReturnFocus.d.ts +43 -0
  258. package/foundation/Disclosure/Disclosure.d.ts +68 -0
  259. package/foundation/Disclosure/index.d.mts +1 -0
  260. package/foundation/Disclosure/index.mjs +7 -0
  261. package/foundation/Disclosure-es.js +46 -0
  262. package/foundation/Divider/Divider.d.ts +39 -0
  263. package/foundation/Divider/DividerDirections.module.d.ts +6 -0
  264. package/foundation/Divider/DividerSizes.module.d.ts +8 -0
  265. package/foundation/Divider/index.d.mts +1 -0
  266. package/foundation/Divider/index.mjs +3 -0
  267. package/foundation/Divider-es.js +15 -0
  268. package/foundation/Drawer/Drawer.d.ts +14 -0
  269. package/foundation/Drawer/DrawerGrid.d.ts +7 -0
  270. package/foundation/Drawer/index.d.mts +2 -0
  271. package/foundation/Drawer/index.mjs +13 -0
  272. package/foundation/DrawerGrid-es.js +39 -0
  273. package/foundation/DrawerTitle-es.js +90 -0
  274. package/foundation/Emphasis/Emphasis.d.ts +12 -0
  275. package/foundation/Emphasis/index.d.mts +1 -0
  276. package/foundation/Emphasis/index.mjs +4 -0
  277. package/foundation/Emphasis-es.js +13 -0
  278. package/foundation/FeatureSwitch/FeatureSwitch.d.ts +52 -0
  279. package/foundation/FeatureSwitch/index.d.mts +1 -0
  280. package/foundation/FeatureSwitch/index.mjs +20 -0
  281. package/foundation/FeatureSwitch-es.js +66 -0
  282. package/foundation/FieldDescription-es.js +859 -0
  283. package/foundation/FilterPicker/FilterPicker.d.ts +11 -0
  284. package/foundation/FilterPicker/FilterPicker.types.d.ts +282 -0
  285. package/foundation/FilterPicker/FilterPickerProvider.d.ts +18 -0
  286. package/foundation/FilterPicker/components/FilterPickerAction/FilterPickerAction.d.ts +3 -0
  287. package/foundation/FilterPicker/components/FilterPickerAction/index.d.mts +1 -0
  288. package/foundation/FilterPicker/components/FilterPickerActivator/FilterPickerActivator.d.ts +3 -0
  289. package/foundation/FilterPicker/components/FilterPickerActivator/index.d.mts +1 -0
  290. package/foundation/FilterPicker/components/FilterPickerOption/FilterPickerOption.d.ts +3 -0
  291. package/foundation/FilterPicker/index.d.mts +3 -0
  292. package/foundation/FilterPicker/index.mjs +49 -0
  293. package/foundation/FilterPicker-es.js +110 -0
  294. package/foundation/FilterPicker.messages-es.js +56 -0
  295. package/foundation/FilterPickerAction-es.js +30 -0
  296. package/foundation/FilterPickerActivator-es.js +36 -0
  297. package/foundation/FilterPickerContent-es.js +180 -0
  298. package/foundation/FilterPickerContentHeader-es.js +23 -0
  299. package/foundation/FilterPickerContentList-es.js +74 -0
  300. package/foundation/FilterPickerContentSearch-es.js +35 -0
  301. package/foundation/FilterPickerLoadMore-es.js +14 -0
  302. package/foundation/FilterPickerOption-es.js +29 -0
  303. package/foundation/FilterPickerProvider-es.js +10 -0
  304. package/foundation/FilterPickerTrigger-es.js +19 -0
  305. package/foundation/Flex/Flex.d.ts +33 -0
  306. package/foundation/Flex/Flex.types.d.ts +6 -0
  307. package/foundation/Flex/index.d.mts +1 -0
  308. package/foundation/Flex/index.mjs +3 -0
  309. package/foundation/Flex-es.js +28 -0
  310. package/foundation/FormField/FormFieldAffix.d.ts +19 -0
  311. package/foundation/FormField/FormFieldTypes.d.ts +185 -0
  312. package/foundation/FormField/FormFieldWrapper.d.ts +57 -0
  313. package/foundation/FormField/hooks/useFormFieldName.d.ts +6 -0
  314. package/foundation/FormField/hooks/useFormFieldWrapperStyles.d.ts +35 -0
  315. package/foundation/FormField/index.d.mts +5 -0
  316. package/foundation/FormField/index.mjs +17 -0
  317. package/foundation/FormFieldPostFix-es.js +13 -0
  318. package/foundation/FormFieldWrapper-es.js +233 -0
  319. package/foundation/FormatFile/FormatFile.d.ts +42 -0
  320. package/foundation/FormatFile/index.d.mts +4 -0
  321. package/foundation/FormatFile/index.mjs +42 -0
  322. package/foundation/FormatFile/types.d.ts +27 -0
  323. package/foundation/FormatFile/useFormatFile.d.ts +5 -0
  324. package/foundation/FormatFile/useFormatFileStyles.d.ts +10 -0
  325. package/foundation/FormatFile-es.js +137 -0
  326. package/foundation/Frame/Frame.d.ts +3 -0
  327. package/foundation/Frame/index.d.mts +2 -0
  328. package/foundation/Frame/index.mjs +3 -0
  329. package/foundation/Frame/types.d.ts +24 -0
  330. package/foundation/Frame-es.js +10 -0
  331. package/foundation/Gallery/Gallery.d.ts +3 -0
  332. package/foundation/Gallery/GalleryTypes.d.ts +36 -0
  333. package/foundation/Gallery/index.d.mts +3 -0
  334. package/foundation/Gallery/index.mjs +64 -0
  335. package/foundation/Gallery-es.js +88 -0
  336. package/foundation/Glimmer/Glimmer.d.ts +71 -0
  337. package/foundation/Glimmer/index.d.mts +1 -0
  338. package/foundation/Glimmer/index.mjs +5 -0
  339. package/foundation/Glimmer/style/Shape.module.d.ts +9 -0
  340. package/foundation/Glimmer/style/Sizes.module.d.ts +10 -0
  341. package/foundation/Glimmer/style/Timing.module.d.ts +6 -0
  342. package/foundation/Glimmer-es.js +53 -0
  343. package/foundation/Grid/Grid.d.ts +32 -0
  344. package/foundation/Grid/GridAlign.module.d.ts +8 -0
  345. package/foundation/Grid/GridCell/GridCell.d.ts +23 -0
  346. package/foundation/Grid/GridCell/index.d.mts +1 -0
  347. package/foundation/Grid/index.d.mts +1 -0
  348. package/foundation/Grid/index.mjs +5 -0
  349. package/foundation/Grid-es.js +30 -0
  350. package/foundation/GridCell-es.js +34 -0
  351. package/foundation/Heading/Heading.d.ts +41 -0
  352. package/foundation/Heading/index.d.mts +2 -0
  353. package/foundation/Heading/index.mjs +4 -0
  354. package/foundation/Heading-es.js +55 -0
  355. package/foundation/HelperText-es.js +19 -0
  356. package/foundation/Icon/Icon.d.ts +47 -0
  357. package/foundation/Icon/index.d.mts +1 -0
  358. package/foundation/Icon-es.js +22 -0
  359. package/foundation/InlineLabel/InlineLabel.d.ts +18 -0
  360. package/foundation/InlineLabel/index.d.mts +1 -0
  361. package/foundation/InlineLabel/index.mjs +4 -0
  362. package/foundation/InlineLabel-es.js +19 -0
  363. package/foundation/InputAvatar/InputAvatar.d.ts +23 -0
  364. package/foundation/InputAvatar/index.d.mts +1 -0
  365. package/foundation/InputAvatar/index.mjs +22 -0
  366. package/foundation/InputAvatar-es.js +64 -0
  367. package/foundation/InputDate/InputDate.d.ts +3 -0
  368. package/foundation/InputDate/InputDate.types.d.ts +36 -0
  369. package/foundation/InputDate/index.d.mts +2 -0
  370. package/foundation/InputDate/index.mjs +39 -0
  371. package/foundation/InputDate-es.js +104 -0
  372. package/foundation/InputEmail/InputEmail.d.ts +3 -0
  373. package/foundation/InputEmail/InputEmail.types.d.ts +16 -0
  374. package/foundation/InputEmail/index.d.mts +2 -0
  375. package/foundation/InputEmail/index.mjs +22 -0
  376. package/foundation/InputEmail-es.js +105 -0
  377. package/foundation/InputFile/FileTypes.d.ts +17 -0
  378. package/foundation/InputFile/InputFile.d.ts +187 -0
  379. package/foundation/InputFile/InputFileButton.d.ts +6 -0
  380. package/foundation/InputFile/InputFileContentContext.d.ts +12 -0
  381. package/foundation/InputFile/InputFileDescription.d.ts +4 -0
  382. package/foundation/InputFile/InputFileDropzoneWrapper.d.ts +4 -0
  383. package/foundation/InputFile/InputFileHintText.d.ts +4 -0
  384. package/foundation/InputFile/index.d.mts +3 -0
  385. package/foundation/InputFile/index.mjs +16 -0
  386. package/foundation/InputFile-es.js +1780 -0
  387. package/foundation/InputGroup/InputGroup.d.ts +12 -0
  388. package/foundation/InputGroup/index.d.mts +1 -0
  389. package/foundation/InputGroup/index.mjs +3 -0
  390. package/foundation/InputGroup-es.js +26 -0
  391. package/foundation/InputNumber/InputNumber.d.ts +77 -0
  392. package/foundation/InputNumber/index.d.mts +2 -0
  393. package/foundation/InputNumber/index.mjs +33 -0
  394. package/foundation/InputNumber/types.d.ts +197 -0
  395. package/foundation/InputNumber-es.js +348 -0
  396. package/foundation/InputPhoneNumber/InputPhoneNumber.d.ts +3 -0
  397. package/foundation/InputPhoneNumber/InputPhoneNumber.types.d.ts +24 -0
  398. package/foundation/InputPhoneNumber/index.d.mts +2 -0
  399. package/foundation/InputPhoneNumber/index.mjs +22 -0
  400. package/foundation/InputPhoneNumber-es.js +188 -0
  401. package/foundation/InputText/InputText.d.ts +3 -0
  402. package/foundation/InputText/InputText.types.d.ts +58 -0
  403. package/foundation/InputText/index.d.mts +2 -0
  404. package/foundation/InputText/index.mjs +23 -0
  405. package/foundation/InputText-es.js +196 -0
  406. package/foundation/InputTime/InputTime.d.ts +3 -0
  407. package/foundation/InputTime/InputTime.types.d.ts +34 -0
  408. package/foundation/InputTime/index.d.mts +2 -0
  409. package/foundation/InputTime/index.mjs +23 -0
  410. package/foundation/InputTime-es.js +297 -0
  411. package/foundation/InputValidation/InputValidation.d.ts +10 -0
  412. package/foundation/InputValidation/index.d.mts +1 -0
  413. package/foundation/InputValidation/index.mjs +8 -0
  414. package/foundation/InputValidation-es.js +22 -0
  415. package/foundation/InternalChipDismissible-es.js +68 -0
  416. package/foundation/LICENSE +21 -0
  417. package/foundation/LegacySelect/LegacySelect.d.ts +7 -0
  418. package/foundation/LegacySelect/LegacySelect.types.d.ts +18 -0
  419. package/foundation/LegacySelect/Option.d.ts +18 -0
  420. package/foundation/LegacySelect/OptionGroup.d.ts +29 -0
  421. package/foundation/LegacySelect/index.d.mts +3 -0
  422. package/foundation/LegacySelect/index.mjs +23 -0
  423. package/foundation/LegacySelect-es.js +76 -0
  424. package/foundation/LegacyThemeContext/LegacyThemeContext.d.ts +5 -0
  425. package/foundation/LegacyThemeContext/index.d.mts +3 -0
  426. package/foundation/LegacyThemeContext/index.mjs +12 -0
  427. package/foundation/LegacyThemeContext/types.d.ts +59 -0
  428. package/foundation/LegacyThemeContext/updateTheme.d.ts +7 -0
  429. package/foundation/LegacyThemeContext-es.js +457 -0
  430. package/foundation/LightBox/LightBox.d.ts +165 -0
  431. package/foundation/LightBox/LightBox.types.d.ts +153 -0
  432. package/foundation/LightBox/LightBoxContext.d.ts +5 -0
  433. package/foundation/LightBox/index.d.mts +3 -0
  434. package/foundation/LightBox/index.mjs +50 -0
  435. package/foundation/LightBox-es.js +454 -0
  436. package/foundation/Link/Link.d.ts +9 -0
  437. package/foundation/Link/index.d.mts +2 -0
  438. package/foundation/Link/index.mjs +2 -0
  439. package/foundation/Link-es.js +12 -0
  440. package/foundation/List/List.d.ts +41 -0
  441. package/foundation/List/ListItem.d.ts +59 -0
  442. package/foundation/List/index.d.mts +2 -0
  443. package/foundation/List/index.mjs +22 -0
  444. package/foundation/List-es.js +199 -0
  445. package/foundation/Markdown/Markdown.d.ts +24 -0
  446. package/foundation/Markdown/index.d.mts +1 -0
  447. package/foundation/Markdown/index.mjs +10 -0
  448. package/foundation/Markdown-es.js +20558 -0
  449. package/foundation/Menu/Menu.d.ts +89 -0
  450. package/foundation/Menu/Menu.types.d.ts +105 -0
  451. package/foundation/Menu/index.d.mts +2 -0
  452. package/foundation/Menu/index.mjs +35 -0
  453. package/foundation/Menu/menuComposableTypes.d.ts +103 -0
  454. package/foundation/Menu-es.js +1033 -0
  455. package/foundation/MenuSubmenuTrigger-es.js +3088 -0
  456. package/foundation/Modal/Modal.rebuilt.d.ts +16 -0
  457. package/foundation/Modal/Modal.types.d.ts +138 -0
  458. package/foundation/Modal/ModalContext.rebuilt.d.ts +19 -0
  459. package/foundation/Modal/ModalSizes.module.d.ts +7 -0
  460. package/foundation/Modal/index.d.mts +17 -0
  461. package/foundation/Modal/index.mjs +302 -0
  462. package/foundation/Modal/useModalStyles.d.ts +12 -0
  463. package/foundation/MultiSelect/MultiSelect.d.ts +30 -0
  464. package/foundation/MultiSelect/index.d.mts +1 -0
  465. package/foundation/MultiSelect/index.mjs +9 -0
  466. package/foundation/MultiSelect/types.d.ts +13 -0
  467. package/foundation/MultiSelect-es.js +172 -0
  468. package/foundation/OverlaySeparator-es.js +13 -0
  469. package/foundation/Page/Page.d.ts +74 -0
  470. package/foundation/Page/index.d.mts +2 -0
  471. package/foundation/Page/index.mjs +42 -0
  472. package/foundation/Page/types.d.ts +123 -0
  473. package/foundation/Page-es.js +196 -0
  474. package/foundation/Popover/Popover.d.ts +9 -0
  475. package/foundation/Popover/Popover.types.d.ts +109 -0
  476. package/foundation/Popover/PopoverContext.d.ts +18 -0
  477. package/foundation/Popover/index.d.mts +4 -0
  478. package/foundation/Popover/index.mjs +27 -0
  479. package/foundation/Popover/usePopoverStyles.d.ts +5 -0
  480. package/foundation/Popover-es.js +166 -0
  481. package/foundation/ProgressBar/ProgressBar.d.ts +41 -0
  482. package/foundation/ProgressBar/ProgressBarSizes.module.d.ts +7 -0
  483. package/foundation/ProgressBar/index.d.mts +1 -0
  484. package/foundation/ProgressBar/index.mjs +5 -0
  485. package/foundation/ProgressBar-es.js +48 -0
  486. package/foundation/ProgressIndicator/ProgressIndicator.d.ts +60 -0
  487. package/foundation/ProgressIndicator/index.d.mts +1 -0
  488. package/foundation/ProgressIndicator/index.mjs +3 -0
  489. package/foundation/ProgressIndicator-es.js +41 -0
  490. package/foundation/RadioGroup/RadioGroup.d.ts +33 -0
  491. package/foundation/RadioGroup/RadioOption.d.ts +48 -0
  492. package/foundation/RadioGroup/index.d.mts +2 -0
  493. package/foundation/RadioGroup/index.mjs +5 -0
  494. package/foundation/RadioGroup-es.js +42 -0
  495. package/foundation/ResponsiveSwitcher/ResponsiveSwitcher.d.ts +3 -0
  496. package/foundation/ResponsiveSwitcher/index.d.mts +2 -0
  497. package/foundation/ResponsiveSwitcher/index.mjs +4 -0
  498. package/foundation/ResponsiveSwitcher/types.d.ts +26 -0
  499. package/foundation/ResponsiveSwitcher-es.js +11 -0
  500. package/foundation/RulnarPortalContent-es.js +1 -0
  501. package/foundation/ScrollAreaViewport-es.js +3959 -0
  502. package/foundation/SegmentedControl/SegmentedControl.d.ts +39 -0
  503. package/foundation/SegmentedControl/SegmentedControlBase.d.ts +7 -0
  504. package/foundation/SegmentedControl/SegmentedControlOption.d.ts +15 -0
  505. package/foundation/SegmentedControl/SegmentedControlProvider.d.ts +17 -0
  506. package/foundation/SegmentedControl/index.d.mts +2 -0
  507. package/foundation/SegmentedControl/index.mjs +3 -0
  508. package/foundation/SegmentedControl-es.js +64 -0
  509. package/foundation/Select/Select.d.ts +31 -0
  510. package/foundation/Select/Select.types.d.ts +145 -0
  511. package/foundation/Select/index.d.mts +2 -0
  512. package/foundation/Select/index.mjs +29 -0
  513. package/foundation/Select-es.js +227 -0
  514. package/foundation/SelectGroupLabel-es.js +1763 -0
  515. package/foundation/SelectPrimitive-es.js +126 -0
  516. package/foundation/Separator-es.js +33 -0
  517. package/foundation/SideDrawer/SideDrawer.d.ts +56 -0
  518. package/foundation/SideDrawer/SideDrawerActions.d.ts +3 -0
  519. package/foundation/SideDrawer/SideDrawerBackButton.d.ts +3 -0
  520. package/foundation/SideDrawer/SideDrawerFooter.d.ts +3 -0
  521. package/foundation/SideDrawer/SideDrawerTitle.d.ts +3 -0
  522. package/foundation/SideDrawer/SideDrawerToolbar.d.ts +2 -0
  523. package/foundation/SideDrawer/index.d.mts +1 -0
  524. package/foundation/SideDrawer/index.mjs +16 -0
  525. package/foundation/SideDrawer-es.js +198 -0
  526. package/foundation/SideKick/SideKick.d.ts +3 -0
  527. package/foundation/SideKick/index.d.mts +2 -0
  528. package/foundation/SideKick/index.mjs +4 -0
  529. package/foundation/SideKick/types.d.ts +35 -0
  530. package/foundation/SideKick-es.js +15 -0
  531. package/foundation/Spinner/Spinner.d.ts +22 -0
  532. package/foundation/Spinner/index.d.mts +1 -0
  533. package/foundation/Spinner/index.mjs +6 -0
  534. package/foundation/Spinner-es.js +21 -0
  535. package/foundation/Stack/Stack.d.ts +3 -0
  536. package/foundation/Stack/index.d.mts +2 -0
  537. package/foundation/Stack/index.mjs +4 -0
  538. package/foundation/Stack/types.d.ts +32 -0
  539. package/foundation/Stack-es.js +13 -0
  540. package/foundation/StatusIndicator/StatusIndicator.d.ts +7 -0
  541. package/foundation/StatusIndicator/StatusIndicator.type.d.ts +1 -0
  542. package/foundation/StatusIndicator/index.d.mts +2 -0
  543. package/foundation/StatusIndicator/index.mjs +2 -0
  544. package/foundation/StatusIndicator-es.js +9 -0
  545. package/foundation/StatusLabel/StatusLabel.d.ts +26 -0
  546. package/foundation/StatusLabel/index.d.mts +1 -0
  547. package/foundation/StatusLabel/index.mjs +5 -0
  548. package/foundation/StatusLabel-es.js +16 -0
  549. package/foundation/Table/Body.d.ts +7 -0
  550. package/foundation/Table/Cells/Cell.d.ts +8 -0
  551. package/foundation/Table/Cells/CellCurrency.d.ts +9 -0
  552. package/foundation/Table/Cells/CellNumeric.d.ts +5 -0
  553. package/foundation/Table/Footer.d.ts +7 -0
  554. package/foundation/Table/Header.d.ts +7 -0
  555. package/foundation/Table/Row.d.ts +7 -0
  556. package/foundation/Table/Table.d.ts +7 -0
  557. package/foundation/Table/index.d.mts +8 -0
  558. package/foundation/Table/index.mjs +4 -0
  559. package/foundation/Tabs/Tabs.d.ts +38 -0
  560. package/foundation/Tabs/index.d.mts +1 -0
  561. package/foundation/Tabs/index.mjs +8 -0
  562. package/foundation/Tabs-es.js +227 -0
  563. package/foundation/Text/Text.d.ts +29 -0
  564. package/foundation/Text/index.d.mts +2 -0
  565. package/foundation/Text/index.mjs +4 -0
  566. package/foundation/Text-es.js +25 -0
  567. package/foundation/Thumbnail/Thumbnail.d.ts +25 -0
  568. package/foundation/Thumbnail/index.d.mts +1 -0
  569. package/foundation/Thumbnail/index.mjs +9 -0
  570. package/foundation/Thumbnail-es.js +119 -0
  571. package/foundation/Tiles/Tiles.d.ts +3 -0
  572. package/foundation/Tiles/index.d.mts +2 -0
  573. package/foundation/Tiles/index.mjs +4 -0
  574. package/foundation/Tiles/types.d.ts +34 -0
  575. package/foundation/Tiles-es.js +11 -0
  576. package/foundation/Tooltip/Tooltip.d.ts +18 -0
  577. package/foundation/Tooltip/Tooltip.types.d.ts +1 -0
  578. package/foundation/Tooltip/index.d.mts +1 -0
  579. package/foundation/Tooltip/index.mjs +8 -0
  580. package/foundation/Tooltip-es.js +137 -0
  581. package/foundation/Typography/Typography.d.ts +64 -0
  582. package/foundation/Typography/css/Emphasis.module.d.ts +6 -0
  583. package/foundation/Typography/css/FontFamilies.module.d.ts +6 -0
  584. package/foundation/Typography/css/FontSizes.module.d.ts +12 -0
  585. package/foundation/Typography/css/FontWeights.module.d.ts +10 -0
  586. package/foundation/Typography/css/TextAlignment.module.d.ts +7 -0
  587. package/foundation/Typography/css/TextCases.module.d.ts +8 -0
  588. package/foundation/Typography/css/TextColors.module.d.ts +69 -0
  589. package/foundation/Typography/index.d.mts +1 -0
  590. package/foundation/Typography/index.mjs +3 -0
  591. package/foundation/Typography/types.d.ts +7 -0
  592. package/foundation/Typography-es.js +53 -0
  593. package/foundation/_baseAssignValue-es.js +29 -0
  594. package/foundation/_baseEach-es.js +1028 -0
  595. package/foundation/_baseFlatten-es.js +65 -0
  596. package/foundation/_baseFor-es.js +45 -0
  597. package/foundation/_commonjsHelpers-es.js +7 -0
  598. package/foundation/_getAllKeys-es.js +506 -0
  599. package/foundation/_getTag-es.js +133 -0
  600. package/foundation/_isIterateeCall-es.js +55 -0
  601. package/foundation/_setToString-es.js +168 -0
  602. package/foundation/buttonRenderAdapter-es.js +52 -0
  603. package/foundation/buttonStyles.d.mts +1 -0
  604. package/foundation/buttonStyles.mjs +1 -0
  605. package/foundation/clearable.d.ts +1 -0
  606. package/foundation/common.messages-es.js +18 -0
  607. package/foundation/compatHooks.mjs +2 -0
  608. package/foundation/constants-es.js +3 -0
  609. package/foundation/dateLocale-es.js +1142 -0
  610. package/foundation/debounce-es.js +329 -0
  611. package/foundation/dialogFocus.d.mts +1 -0
  612. package/foundation/dialogFocus.mjs +66 -0
  613. package/foundation/filterDataAttributes-es.js +24 -0
  614. package/foundation/floating-ui.react-es.js +6174 -0
  615. package/foundation/getMappedSpaceToken-es.js +18 -0
  616. package/foundation/helpers-es.js +15 -0
  617. package/foundation/identity-es.js +809 -0
  618. package/foundation/imageTypes.d.mts +1 -0
  619. package/foundation/imageTypes.mjs +1 -0
  620. package/foundation/index-es.js +1186 -0
  621. package/foundation/isObjectLike-es.js +190 -0
  622. package/foundation/isSymbol-es.js +33 -0
  623. package/foundation/isTypedArray-es.js +589 -0
  624. package/foundation/keysIn-es.js +385 -0
  625. package/foundation/linkEvents.d.mts +1 -0
  626. package/foundation/linkEvents.mjs +9 -0
  627. package/foundation/maxHeight-es.js +22 -0
  628. package/foundation/mergeClassName-es.js +10 -0
  629. package/foundation/mergeRefs-es.js +18 -0
  630. package/foundation/nestedEscape-es.js +91 -0
  631. package/foundation/noop-es.js +24 -0
  632. package/foundation/primitives/BottomSheet/BottomSheet.d.ts +37 -0
  633. package/foundation/primitives/BottomSheet/BottomSheet.types.d.ts +36 -0
  634. package/foundation/primitives/BottomSheet/index.d.mts +2 -0
  635. package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.d.ts +32 -0
  636. package/foundation/primitives/ComboboxPrimitive/ComboboxPrimitive.types.d.ts +30 -0
  637. package/foundation/primitives/ComboboxPrimitive/index.d.mts +2 -0
  638. package/foundation/primitives/HelperText/HelperText.d.ts +25 -0
  639. package/foundation/primitives/HelperText/index.d.mts +1 -0
  640. package/foundation/primitives/OverlaySeparator/OverlaySeparator.d.ts +6 -0
  641. package/foundation/primitives/OverlaySeparator/index.d.mts +1 -0
  642. package/foundation/primitives/SelectPrimitive/SelectPrimitive.d.ts +74 -0
  643. package/foundation/primitives/SelectPrimitive/index.d.mts +2 -0
  644. package/foundation/primitives/SelectPrimitive/types.d.ts +31 -0
  645. package/foundation/primitives/index.d.mts +12 -0
  646. package/foundation/primitives/index.mjs +29 -0
  647. package/foundation/routerLink.d.mts +3 -0
  648. package/foundation/routerLink.mjs +1 -0
  649. package/foundation/scrollEdges-es.js +64 -0
  650. package/foundation/scrollable-es.js +54 -0
  651. package/foundation/sharedHelpers/getMappedBreakpointWidth.d.ts +8 -0
  652. package/foundation/sharedHelpers/types.d.ts +254 -0
  653. package/foundation/stringifyLocale-es.js +11 -0
  654. package/foundation/styles.css +16646 -0
  655. package/foundation/tslib.es6-es.js +97 -0
  656. package/foundation/unstyledPrimitives/index.d.mts +22 -0
  657. package/foundation/useActiveLayout-es.js +14 -0
  658. package/foundation/useBatchSelect-es.js +36 -0
  659. package/foundation/useChildComponent-es.js +15 -0
  660. package/foundation/useComponentMessages-es.js +86 -0
  661. package/foundation/useCompositeListItem-es.js +3955 -0
  662. package/foundation/useFormFieldFocus-es.js +37 -0
  663. package/foundation/useFormFieldName-es.js +11 -0
  664. package/foundation/useLabel-es.js +81 -0
  665. package/foundation/useRenderElement-es.js +628 -0
  666. package/foundation/useResponsiveSizing-es.js +8 -0
  667. package/foundation/useScrollLock-es.js +5746 -0
  668. package/foundation/useScrollToActive-es.js +581 -0
  669. package/foundation/utils/isNormalClick.d.ts +6 -0
  670. package/foundation/utils/isPreviewableImage.d.ts +1 -0
  671. package/foundation/utils/meta/meta.json +298 -0
  672. package/foundation.css +67 -0
  673. package/package.json +540 -4
  674. package/src/styles.css +181 -0
@@ -0,0 +1,859 @@
1
+ import * as React from 'react';
2
+ import { q as useTimeout, d as useStableCallback, u as useBaseUiId, c as useIsoLayoutEffect, S as SafeReact, r as error, t as transitionStatusMapping, s as useTransitionStatus, l as useOpenChangeComplete } from './useScrollLock-es.js';
3
+ import { a as useFormContext, u as useLabelableContext, D as DEFAULT_VALIDITY_STATE, L as LabelableContext, f as fieldValidityMapping, F as FieldRootContext, b as useFieldRootContext } from './useCompositeListItem-es.js';
4
+ import { a as useRefWithInit, m as mergeProps, E as EMPTY_OBJECT, f as formatErrorMessage, u as useRenderElement } from './useRenderElement-es.js';
5
+ import { jsx } from 'react/jsx-runtime';
6
+ import { u as useLabel } from './useLabel-es.js';
7
+
8
+ const FieldItemContext = /*#__PURE__*/React.createContext({
9
+ disabled: false
10
+ });
11
+ if (process.env.NODE_ENV !== "production") FieldItemContext.displayName = "FieldItemContext";
12
+ function useFieldItemContext() {
13
+ const context = React.useContext(FieldItemContext);
14
+ return context;
15
+ }
16
+
17
+ /**
18
+ * Combines the field's client-side, stateful validity data with the external invalid state to
19
+ * determine the field's true validity.
20
+ */
21
+ function getCombinedFieldValidityData(validityData, invalid) {
22
+ return {
23
+ ...validityData,
24
+ state: {
25
+ ...validityData.state,
26
+ valid: !invalid && validityData.state.valid
27
+ }
28
+ };
29
+ }
30
+
31
+ const validityKeys = Object.keys(DEFAULT_VALIDITY_STATE);
32
+ /**
33
+ * Whether an input participates in the surrounding Base UI Form. Inputs that are effectively
34
+ * disabled, or whose `form` attribute explicitly associates them with another form, are excluded.
35
+ * DOM position only matters when it associates the input with a different form. Otherwise, field
36
+ * registration is context-driven, so portaled inputs (for example inside a dialog) still belong to
37
+ * the form for both validation and values projected into `onFormSubmit`.
38
+ */
39
+ function isEligibleInput(input, formElement) {
40
+ if (input.matches(':disabled')) {
41
+ return false;
42
+ }
43
+ if (!formElement || input.form === formElement) {
44
+ return true;
45
+ }
46
+
47
+ // React context crosses portal boundaries. An unassociated portaled input still participates in
48
+ // contextual validation, unless an explicit `form` attribute opts it out of the surrounding Form.
49
+ return input.form === null && !input.hasAttribute('form');
50
+ }
51
+
52
+ /**
53
+ * Picks the input whose native validity should represent a field that owns several inputs (such as a
54
+ * checkbox or radio group). Prefers the first eligible currently-invalid input, where "first" follows
55
+ * registration order (mount order), and otherwise returns the first eligible input.
56
+ */
57
+ function findRepresentativeInput(inputs, formElement) {
58
+ let fallback = null;
59
+ for (const input of inputs.keys()) {
60
+ if (!isEligibleInput(input, formElement)) {
61
+ continue;
62
+ }
63
+ if (!input.validity.valid) {
64
+ return input;
65
+ }
66
+ fallback ??= input;
67
+ }
68
+ return fallback;
69
+ }
70
+ function clearCustomValidity(element, inputs) {
71
+ for (const input of inputs.keys()) {
72
+ input.setCustomValidity('');
73
+ }
74
+ element?.setCustomValidity('');
75
+ }
76
+ function useFieldValidation(params) {
77
+ const {
78
+ elementRef,
79
+ formRef
80
+ } = useFormContext();
81
+ const {
82
+ setValidityData,
83
+ validate,
84
+ validityData,
85
+ validationDebounceTime,
86
+ invalid,
87
+ markedDirtyRef,
88
+ state,
89
+ shouldValidateOnChange,
90
+ registeredFieldIdRef
91
+ } = params;
92
+ const {
93
+ controlId,
94
+ getDescriptionProps
95
+ } = useLabelableContext();
96
+ const timeout = useTimeout();
97
+ const inputRef = React.useRef(null);
98
+ const registeredInputs = useRefWithInit(() => new Map()).current;
99
+ const validationCommitIdRef = React.useRef(0);
100
+
101
+ // Groups register several inputs against a single field so focus, validation, and form-value
102
+ // projection can use the same live controls. This also ensures a `required` checkbox can't be
103
+ // satisfied by another input in the group, matching native per-checkbox behavior.
104
+ const registerInput = React.useCallback((element, registration) => {
105
+ registeredInputs.set(element, registration);
106
+ return () => {
107
+ registeredInputs.delete(element);
108
+ };
109
+ }, [registeredInputs]);
110
+ const getInputControl = useStableCallback(() => {
111
+ const element = findRepresentativeInput(registeredInputs, elementRef.current);
112
+ return element && registeredInputs.get(element)?.controlRef.current || null;
113
+ });
114
+ const commit = useStableCallback(async (value, revalidate = false) => {
115
+ validationCommitIdRef.current += 1;
116
+ const validationCommitId = validationCommitIdRef.current;
117
+ function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid) {
118
+ const fieldId = registeredFieldIdRef.current ?? controlId;
119
+ if (fieldId == null) {
120
+ return;
121
+ }
122
+ const currentFieldData = formRef.current.fields.get(fieldId);
123
+ if (!currentFieldData) {
124
+ return;
125
+ }
126
+ const validityDataWithFormErrors = getCombinedFieldValidityData(nextValidityData, externalInvalid);
127
+ formRef.current.fields.set(fieldId, {
128
+ ...currentFieldData,
129
+ validityData: validityDataWithFormErrors
130
+ });
131
+ }
132
+ function publishAllValid(input, externalInvalid) {
133
+ const nextValidityData = {
134
+ value,
135
+ state: {
136
+ ...DEFAULT_VALIDITY_STATE,
137
+ valid: true
138
+ },
139
+ error: '',
140
+ errors: [],
141
+ initialValue: validityData.initialValue
142
+ };
143
+ clearCustomValidity(input, registeredInputs);
144
+ updateRegisteredFieldValidity(nextValidityData, externalInvalid);
145
+ setValidityData(nextValidityData);
146
+ }
147
+
148
+ // A field can own several inputs (such as a checkbox or radio group), but only the last-mounted
149
+ // one wins the shared `inputRef`. Validate against the registry instead so every input counts;
150
+ // `inputRef` is the fallback only when no inputs are registered.
151
+ const element = registeredInputs.size > 0 ? findRepresentativeInput(registeredInputs, elementRef.current) : inputRef.current;
152
+ // A field with no eligible input has no native constraint, but its custom validator still
153
+ // applies to the logical value at the configured validation boundary.
154
+
155
+ if (revalidate) {
156
+ if (state.valid !== false || !element) {
157
+ return;
158
+ }
159
+ const currentNativeValidity = element.validity;
160
+ if (!currentNativeValidity.valueMissing) {
161
+ // The 'valueMissing' (required) condition has been resolved by the user typing.
162
+ // Temporarily mark the field as valid for this onChange event.
163
+ // Other native errors (e.g., typeMismatch) will be caught by full validation on blur or submit.
164
+ // The required value is now present; ignore stale external invalid state for this pass.
165
+ publishAllValid(element, false);
166
+ return;
167
+ }
168
+
169
+ // A stale custom error can coexist with valueMissing, but defer any other native errors.
170
+ for (const key of validityKeys) {
171
+ if (key !== 'valid' && key !== 'valueMissing' && key !== 'customError' && currentNativeValidity[key]) {
172
+ return;
173
+ }
174
+ }
175
+
176
+ // Value is still missing: publish the current native state so valueMissing and the changed
177
+ // value are observable immediately. Full custom validation still waits for its boundary.
178
+ }
179
+ function getState(el) {
180
+ const computedState = validityKeys.reduce((acc, key) => {
181
+ acc[key] = el.validity[key];
182
+ return acc;
183
+ }, {});
184
+ let hasOnlyValueMissingError = false;
185
+ for (const key of validityKeys) {
186
+ if (key === 'valid') {
187
+ continue;
188
+ }
189
+ if (key === 'valueMissing' && computedState[key]) {
190
+ hasOnlyValueMissingError = true;
191
+ } else if (computedState[key]) {
192
+ return computedState;
193
+ }
194
+ }
195
+
196
+ // Only make `valueMissing` mark the field invalid if it's been changed
197
+ // to reduce error noise.
198
+ if (hasOnlyValueMissingError && !markedDirtyRef.current) {
199
+ computedState.valid = true;
200
+ computedState.valueMissing = false;
201
+ }
202
+ return computedState;
203
+ }
204
+ timeout.clear();
205
+ let result = null;
206
+ let validationErrors = [];
207
+
208
+ // With no representative input the field carries no native constraint, so start from an
209
+ // all-valid native state and let the custom `validate` result below decide the outcome.
210
+ const nextState = element ? getState(element) : {
211
+ ...DEFAULT_VALIDITY_STATE,
212
+ valid: true
213
+ };
214
+ let defaultValidationMessage;
215
+ const isValidatingOnChange = shouldValidateOnChange();
216
+ if (element && element.validationMessage && !isValidatingOnChange) {
217
+ // not validating on change, if there is a `validationMessage` from
218
+ // native validity, set errors and skip calling the custom validate fn
219
+ defaultValidationMessage = element.validationMessage;
220
+ validationErrors = [element.validationMessage];
221
+ } else {
222
+ // call the validate function because either
223
+ // - validating on change, or
224
+ // - native constraint validations passed, custom validity check is next
225
+ const formValues = Array.from(formRef.current.fields.values()).reduce((acc, field) => {
226
+ if (field.name) {
227
+ acc[field.name] = field.getValue();
228
+ }
229
+ return acc;
230
+ }, {});
231
+ const resultOrPromise = validate(value, formValues);
232
+ if (typeof resultOrPromise === 'object' && resultOrPromise !== null && 'then' in resultOrPromise) {
233
+ result = await resultOrPromise;
234
+ if (validationCommitId !== validationCommitIdRef.current) {
235
+ return;
236
+ }
237
+ } else {
238
+ result = resultOrPromise;
239
+ }
240
+ if (result !== null) {
241
+ nextState.valid = false;
242
+ nextState.customError = true;
243
+ if (Array.isArray(result)) {
244
+ validationErrors = result;
245
+ element?.setCustomValidity(result.join('\n'));
246
+ } else if (result) {
247
+ validationErrors = [result];
248
+ element?.setCustomValidity(result);
249
+ }
250
+ } else if (isValidatingOnChange) {
251
+ // validate function returned no errors, if validating on change
252
+ // we need to clear the custom validity state
253
+ clearCustomValidity(element, registeredInputs);
254
+ nextState.customError = false;
255
+ if (element && element.validationMessage) {
256
+ defaultValidationMessage = element.validationMessage;
257
+ validationErrors = [element.validationMessage];
258
+ } else if ((!element || element.validity.valid) && !nextState.valid) {
259
+ nextState.valid = true;
260
+ }
261
+ }
262
+ }
263
+ const nextValidityData = {
264
+ value,
265
+ state: nextState,
266
+ error: defaultValidationMessage ?? (Array.isArray(result) ? result[0] : result ?? ''),
267
+ errors: validationErrors,
268
+ initialValue: validityData.initialValue
269
+ };
270
+
271
+ // Keep Form-level errors part of overall field validity for submit blocking/focus logic.
272
+ updateRegisteredFieldValidity(nextValidityData);
273
+ setValidityData(nextValidityData);
274
+ });
275
+ const change = useStableCallback(value => {
276
+ timeout.clear();
277
+ const validateOnChange = shouldValidateOnChange();
278
+ if (validateOnChange && value !== '' && validationDebounceTime) {
279
+ validationCommitIdRef.current += 1;
280
+ timeout.start(validationDebounceTime, () => {
281
+ commit(value);
282
+ });
283
+ } else {
284
+ commit(value, !validateOnChange);
285
+ }
286
+ });
287
+ const getValidationProps = React.useCallback((disabled, externalProps = {}) => mergeProps(getDescriptionProps(externalProps), state.valid === false && !state.disabled && !disabled ? {
288
+ 'aria-invalid': true
289
+ } : EMPTY_OBJECT), [getDescriptionProps, state.disabled, state.valid]);
290
+ return React.useMemo(() => ({
291
+ getValidationProps,
292
+ inputRef,
293
+ registeredInputs,
294
+ registerInput,
295
+ getInputControl,
296
+ commit,
297
+ change
298
+ }), [getValidationProps, registeredInputs, registerInput, getInputControl, commit, change]);
299
+ }
300
+
301
+ const FieldsetRootContext = /*#__PURE__*/React.createContext(undefined);
302
+ if (process.env.NODE_ENV !== "production") FieldsetRootContext.displayName = "FieldsetRootContext";
303
+ function useFieldsetRootContext(optional = false) {
304
+ const context = React.useContext(FieldsetRootContext);
305
+ if (!context && !optional) {
306
+ throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: FieldsetRootContext is missing. Fieldset parts must be placed within <Fieldset.Root>.' : formatErrorMessage(86));
307
+ }
308
+ return context;
309
+ }
310
+
311
+ const LabelableProvider = function LabelableProvider(props) {
312
+ const defaultId = useBaseUiId();
313
+ const initialControlId = props.controlId === undefined ? defaultId : props.controlId;
314
+ const [controlId, setControlIdState] = React.useState(initialControlId);
315
+ const [labelId, setLabelId] = React.useState(props.labelId);
316
+ const [messageIds, setMessageIds] = React.useState([]);
317
+ const registrationsRef = useRefWithInit(() => new Map());
318
+ const {
319
+ messageIds: parentMessageIds
320
+ } = useLabelableContext();
321
+ const registerControlId = useStableCallback((source, nextId) => {
322
+ const registrations = registrationsRef.current;
323
+ if (nextId === undefined) {
324
+ registrations.delete(source);
325
+ return;
326
+ }
327
+ registrations.set(source, nextId);
328
+
329
+ // Only flush when registering, not when unregistering.
330
+ // This prevents loops during rapid unmount/remount cycles (e.g. React Activity).
331
+ // The next registration will pick up the correct state.
332
+ setControlIdState(prev => {
333
+ if (registrations.size === 0) {
334
+ return undefined;
335
+ }
336
+ let nextControlId;
337
+ for (const id of registrations.values()) {
338
+ if (prev !== undefined && id === prev) {
339
+ return prev;
340
+ }
341
+ if (nextControlId === undefined) {
342
+ nextControlId = id;
343
+ }
344
+ }
345
+ return nextControlId;
346
+ });
347
+ });
348
+ const getDescriptionProps = React.useCallback(externalProps => {
349
+ const ids = externalProps['aria-describedby'] ? externalProps['aria-describedby'].split(' ') : [];
350
+ ids.push(...parentMessageIds, ...messageIds);
351
+ return {
352
+ ...externalProps,
353
+ 'aria-describedby': Array.from(new Set(ids)).join(' ') || undefined
354
+ };
355
+ }, [parentMessageIds, messageIds]);
356
+ const contextValue = React.useMemo(() => ({
357
+ controlId,
358
+ registerControlId,
359
+ labelId,
360
+ setLabelId,
361
+ messageIds,
362
+ setMessageIds,
363
+ getDescriptionProps
364
+ }), [controlId, registerControlId, labelId, setLabelId, messageIds, setMessageIds, getDescriptionProps]);
365
+ return /*#__PURE__*/jsx(LabelableContext.Provider, {
366
+ value: contextValue,
367
+ children: props.children
368
+ });
369
+ };
370
+ if (process.env.NODE_ENV !== "production") LabelableProvider.displayName = "LabelableProvider";
371
+
372
+ function useFieldControlRegistration(params) {
373
+ const {
374
+ commit,
375
+ invalid,
376
+ markedDirtyRef,
377
+ name,
378
+ setRegisteredFieldName,
379
+ registeredFieldIdRef,
380
+ setValidityData,
381
+ validityData
382
+ } = params;
383
+ const {
384
+ formRef
385
+ } = useFormContext();
386
+ const activeFieldControlSourceRef = React.useRef(null);
387
+ const registrationRef = React.useRef(null);
388
+ const initialValueCapturedRef = React.useRef(false);
389
+ const getValueForForm = useStableCallback(() => {
390
+ const registration = registrationRef.current;
391
+ if (!registration) {
392
+ return undefined;
393
+ }
394
+ if (registration.getValue) {
395
+ return registration.getValue();
396
+ }
397
+ return registration.value;
398
+ });
399
+ function getRegistrationValue(registration) {
400
+ return registration.value === undefined ? getValueForForm() : registration.value;
401
+ }
402
+ const validate = useStableCallback(() => {
403
+ const registration = registrationRef.current;
404
+ markedDirtyRef.current = true;
405
+ if (!registration) {
406
+ commit(validityData.value);
407
+ return;
408
+ }
409
+ commit(getRegistrationValue(registration));
410
+ });
411
+ function refreshRegistration() {
412
+ const registration = registrationRef.current;
413
+ if (!registration || !registration.id) {
414
+ return;
415
+ }
416
+ formRef.current.fields.set(registration.id, {
417
+ getValue: getValueForForm,
418
+ name: name ?? registration.name,
419
+ controlRef: registration.controlRef,
420
+ validityData: getCombinedFieldValidityData(validityData, invalid),
421
+ validate
422
+ });
423
+ }
424
+ function deleteRegistration(id = registrationRef.current?.id) {
425
+ if (id) {
426
+ formRef.current.fields.delete(id);
427
+ }
428
+ }
429
+
430
+ // The baseline belongs to the field, not to a control instance: registration re-runs on every
431
+ // value change, and a control that unmounts and remounts (or is swapped for another one) comes
432
+ // back as a brand new registration. Capturing more than once would turn whichever value the
433
+ // control happens to hold at that point into the initial value, so a modified field would read
434
+ // pristine and its real initial value would read dirty. Consumers that want a fresh baseline
435
+ // remount or key `<Field.Root>` itself.
436
+ function captureInitialValue(registration) {
437
+ if (initialValueCapturedRef.current) {
438
+ return;
439
+ }
440
+ initialValueCapturedRef.current = true;
441
+ const initialValue = getRegistrationValue(registration);
442
+ setValidityData(prev => prev.initialValue === initialValue ? prev : {
443
+ ...prev,
444
+ initialValue
445
+ });
446
+ }
447
+ useIsoLayoutEffect(() => {
448
+ const registration = registrationRef.current;
449
+ if (!registration || !registration.id) {
450
+ return;
451
+ }
452
+ setRegisteredFieldName(name ? undefined : registration.name);
453
+ formRef.current.fields.set(registration.id, {
454
+ getValue: getValueForForm,
455
+ name: name ?? registration.name,
456
+ controlRef: registration.controlRef,
457
+ validityData: getCombinedFieldValidityData(validityData, invalid),
458
+ validate
459
+ });
460
+ }, [formRef, getValueForForm, invalid, name, setRegisteredFieldName, validate, validityData]);
461
+ useIsoLayoutEffect(() => {
462
+ const fields = formRef.current.fields;
463
+ return () => {
464
+ const id = registrationRef.current?.id;
465
+ if (id) {
466
+ fields.delete(id);
467
+ }
468
+ };
469
+ }, [formRef]);
470
+ const register = useStableCallback((source, registration) => {
471
+ if (!registration) {
472
+ if (activeFieldControlSourceRef.current === source) {
473
+ activeFieldControlSourceRef.current = null;
474
+ deleteRegistration();
475
+ registrationRef.current = null;
476
+ setRegisteredFieldName(undefined);
477
+ registeredFieldIdRef.current = undefined;
478
+ }
479
+ return;
480
+ }
481
+ const previousId = registrationRef.current?.id;
482
+ activeFieldControlSourceRef.current = source;
483
+ registrationRef.current = registration;
484
+ if (!name) {
485
+ setRegisteredFieldName(registration.name);
486
+ }
487
+ registeredFieldIdRef.current = registration.id;
488
+ if (previousId && previousId !== registration.id) {
489
+ deleteRegistration(previousId);
490
+ }
491
+ captureInitialValue(registration);
492
+ refreshRegistration();
493
+ });
494
+ return [validate, register];
495
+ }
496
+
497
+ const FieldRootInner = /*#__PURE__*/React.forwardRef(function FieldRootInner(componentProps, forwardedRef) {
498
+ const {
499
+ errors,
500
+ validationMode: formValidationMode,
501
+ submitAttemptedRef
502
+ } = useFormContext();
503
+ const {
504
+ render,
505
+ className,
506
+ validate: validateProp,
507
+ validationDebounceTime = 0,
508
+ validationMode = formValidationMode,
509
+ name,
510
+ disabled: disabledProp = false,
511
+ invalid: invalidProp,
512
+ dirty: dirtyProp,
513
+ touched: touchedProp,
514
+ actionsRef,
515
+ style,
516
+ ...elementProps
517
+ } = componentProps;
518
+ const disabledFieldset = useFieldsetRootContext(true)?.disabled;
519
+ const validate = useStableCallback(validateProp || (() => null));
520
+ const disabled = disabledFieldset || disabledProp;
521
+ const [touchedState, setTouchedUnwrapped] = React.useState(false);
522
+ const [dirtyState, setDirtyUnwrapped] = React.useState(false);
523
+ const [filled, setFilled] = React.useState(false);
524
+ const [focused, setFocused] = React.useState(false);
525
+ const dirty = dirtyProp ?? dirtyState;
526
+ const touched = touchedProp ?? touchedState;
527
+ const markedDirtyRef = React.useRef(dirty);
528
+ const registeredFieldIdRef = React.useRef(undefined);
529
+ const [registeredFieldName, setRegisteredFieldName] = React.useState();
530
+ const effectiveName = name ?? registeredFieldName;
531
+ useIsoLayoutEffect(() => {
532
+ if (dirtyProp !== undefined) {
533
+ markedDirtyRef.current = dirtyProp;
534
+ }
535
+ }, [dirtyProp]);
536
+ const setDirty = useStableCallback(value => {
537
+ if (dirtyProp !== undefined) {
538
+ return;
539
+ }
540
+ if (value) {
541
+ markedDirtyRef.current = true;
542
+ }
543
+ setDirtyUnwrapped(value);
544
+ });
545
+ const setTouched = useStableCallback(value => {
546
+ if (touchedProp !== undefined) {
547
+ return;
548
+ }
549
+ setTouchedUnwrapped(value);
550
+ });
551
+ const shouldValidateOnChange = useStableCallback(() => validationMode === 'onChange' || validationMode === 'onSubmit' && submitAttemptedRef.current);
552
+ const formError = effectiveName && Object.hasOwn(errors, effectiveName) ? errors[effectiveName] : null;
553
+ const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
554
+ const invalid = invalidProp === true || hasFormError;
555
+ const [validityData, setValidityData] = React.useState({
556
+ state: DEFAULT_VALIDITY_STATE,
557
+ error: '',
558
+ errors: [],
559
+ value: null,
560
+ initialValue: null
561
+ });
562
+
563
+ // App-controlled invalidity (the `invalid` prop and `<Form>` errors) keeps the field marked
564
+ // invalid even while disabled. Only computed validity (native constraints and `validate`)
565
+ // is suppressed when disabled, matching `:disabled` not participating in constraint validation.
566
+ const valid = !invalid && (disabled ? null : validityData.state.valid);
567
+ const state = React.useMemo(() => ({
568
+ disabled,
569
+ touched,
570
+ dirty,
571
+ valid,
572
+ filled,
573
+ focused
574
+ }), [disabled, touched, dirty, valid, filled, focused]);
575
+ const validation = useFieldValidation({
576
+ setValidityData,
577
+ validate,
578
+ validityData,
579
+ validationDebounceTime,
580
+ invalid,
581
+ markedDirtyRef,
582
+ state,
583
+ shouldValidateOnChange,
584
+ registeredFieldIdRef
585
+ });
586
+ const [validateFieldControl, registerFieldControl] = useFieldControlRegistration({
587
+ commit: validation.commit,
588
+ invalid,
589
+ markedDirtyRef,
590
+ name,
591
+ setRegisteredFieldName,
592
+ registeredFieldIdRef,
593
+ setValidityData,
594
+ validityData
595
+ });
596
+ React.useImperativeHandle(actionsRef, () => ({
597
+ validate: validateFieldControl
598
+ }), [validateFieldControl]);
599
+ const contextValue = React.useMemo(() => ({
600
+ invalid,
601
+ name: effectiveName,
602
+ validityData,
603
+ setValidityData,
604
+ disabled,
605
+ setTouched,
606
+ setDirty,
607
+ setFilled,
608
+ setFocused,
609
+ validationMode,
610
+ shouldValidateOnChange,
611
+ state,
612
+ registerFieldControl,
613
+ validation
614
+ }), [invalid, effectiveName, validityData, disabled, setTouched, setDirty, setFilled, setFocused, validationMode, shouldValidateOnChange, state, registerFieldControl, validation]);
615
+ const element = useRenderElement('div', componentProps, {
616
+ ref: forwardedRef,
617
+ state,
618
+ props: elementProps,
619
+ stateAttributesMapping: fieldValidityMapping
620
+ });
621
+ return /*#__PURE__*/jsx(FieldRootContext.Provider, {
622
+ value: contextValue,
623
+ children: element
624
+ });
625
+ });
626
+
627
+ /**
628
+ * Groups all parts of the field.
629
+ * Renders a `<div>` element.
630
+ *
631
+ * Documentation: [Base UI Field](https://base-ui.com/react/components/field)
632
+ */
633
+ if (process.env.NODE_ENV !== "production") FieldRootInner.displayName = "FieldRootInner";
634
+ const FieldRoot = /*#__PURE__*/React.forwardRef(function FieldRoot(componentProps, forwardedRef) {
635
+ return /*#__PURE__*/jsx(LabelableProvider, {
636
+ children: /*#__PURE__*/jsx(FieldRootInner, {
637
+ ...componentProps,
638
+ ref: forwardedRef
639
+ })
640
+ });
641
+ });
642
+ if (process.env.NODE_ENV !== "production") FieldRoot.displayName = "FieldRoot";
643
+
644
+ /**
645
+ * An accessible label that is automatically associated with the field control.
646
+ * Renders a `<label>` element.
647
+ *
648
+ * Documentation: [Base UI Field](https://base-ui.com/react/components/field)
649
+ */
650
+ const FieldLabel = /*#__PURE__*/React.forwardRef(function FieldLabel(componentProps, forwardedRef) {
651
+ const {
652
+ render,
653
+ className,
654
+ style,
655
+ id: idProp,
656
+ nativeLabel = true,
657
+ ...elementProps
658
+ } = componentProps;
659
+ const fieldRootContext = useFieldRootContext(false);
660
+ const fieldItemContext = useFieldItemContext();
661
+ const {
662
+ labelId
663
+ } = useLabelableContext();
664
+ const state = {
665
+ ...fieldRootContext.state,
666
+ disabled: fieldRootContext.disabled || fieldItemContext.disabled
667
+ };
668
+ const labelRef = React.useRef(null);
669
+ const labelProps = useLabel({
670
+ id: labelId ?? idProp,
671
+ native: nativeLabel
672
+ });
673
+ if (process.env.NODE_ENV !== 'production') {
674
+ // eslint-disable-next-line react-hooks/rules-of-hooks
675
+ React.useEffect(() => {
676
+ if (!labelRef.current) {
677
+ return;
678
+ }
679
+ const isLabelTag = labelRef.current.tagName === 'LABEL';
680
+ if (nativeLabel) {
681
+ if (!isLabelTag) {
682
+ const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
683
+ const message = '<Field.Label> expected a <label> element because the `nativeLabel` prop is true. ' + 'Rendering a non-<label> disables native label association, so `htmlFor` will not ' + 'work. Use a real <label> in the `render` prop, or set `nativeLabel` to `false`.';
684
+ error(`${message}${ownerStackMessage}`);
685
+ }
686
+ } else if (isLabelTag) {
687
+ const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
688
+ const message = '<Field.Label> expected a non-<label> element because the `nativeLabel` prop is false. ' + 'Rendering a <label> assumes native label behavior while Base UI treats it as ' + 'non-native, which can cause unexpected pointer behavior. Use a non-<label> in the ' + '`render` prop, or set `nativeLabel` to `true`.';
689
+ error(`${message}${ownerStackMessage}`);
690
+ }
691
+ }, [nativeLabel]);
692
+ }
693
+ const element = useRenderElement('label', componentProps, {
694
+ ref: [forwardedRef, labelRef],
695
+ state,
696
+ props: [labelProps, elementProps],
697
+ stateAttributesMapping: fieldValidityMapping
698
+ });
699
+ return element;
700
+ });
701
+ if (process.env.NODE_ENV !== "production") FieldLabel.displayName = "FieldLabel";
702
+
703
+ const stateAttributesMapping = {
704
+ ...fieldValidityMapping,
705
+ ...transitionStatusMapping
706
+ };
707
+
708
+ /**
709
+ * An error message displayed if the field control fails validation.
710
+ * Renders a `<div>` element.
711
+ *
712
+ * Documentation: [Base UI Field](https://base-ui.com/react/components/field)
713
+ */
714
+ const FieldError = /*#__PURE__*/React.forwardRef(function FieldError(componentProps, forwardedRef) {
715
+ const {
716
+ render,
717
+ id: idProp,
718
+ className,
719
+ match,
720
+ style,
721
+ ...elementProps
722
+ } = componentProps;
723
+ const id = useBaseUiId(idProp);
724
+ const {
725
+ validityData,
726
+ state: fieldState,
727
+ name
728
+ } = useFieldRootContext(false);
729
+ const {
730
+ setMessageIds
731
+ } = useLabelableContext();
732
+ const {
733
+ errors
734
+ } = useFormContext();
735
+ const formError = name && Object.hasOwn(errors, name) ? errors[name] : null;
736
+ const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
737
+ const hasSpecificMatch = typeof match === 'string';
738
+ let rendered = false;
739
+ if (match === true) {
740
+ rendered = true;
741
+ } else if (fieldState.disabled) {
742
+ rendered = false;
743
+ } else if (hasSpecificMatch) {
744
+ rendered = Boolean(validityData.state[match]);
745
+ } else {
746
+ rendered = hasFormError || validityData.state.valid === false;
747
+ }
748
+ const {
749
+ mounted,
750
+ transitionStatus,
751
+ setMounted
752
+ } = useTransitionStatus(rendered);
753
+ useIsoLayoutEffect(() => {
754
+ if (!rendered || !id) {
755
+ return undefined;
756
+ }
757
+ setMessageIds(v => v.concat(id));
758
+ return () => {
759
+ setMessageIds(v => v.filter(item => item !== id));
760
+ };
761
+ }, [rendered, id, setMessageIds]);
762
+ const errorRef = React.useRef(null);
763
+ const [lastRenderedMessage, setLastRenderedMessage] = React.useState(null);
764
+ const [lastRenderedMessageKey, setLastRenderedMessageKey] = React.useState(null);
765
+ let error = validityData.error;
766
+ if (!hasSpecificMatch && hasFormError) {
767
+ error = formError;
768
+ } else if (validityData.errors.length > 1) {
769
+ error = validityData.errors;
770
+ }
771
+ let errorMessage = error;
772
+ if (Array.isArray(error)) {
773
+ errorMessage = error.length > 1 ? /*#__PURE__*/jsx("ul", {
774
+ children: error.map(message => /*#__PURE__*/jsx("li", {
775
+ children: message
776
+ }, message))
777
+ }) : error[0];
778
+ }
779
+ const errorKey = Array.isArray(error) ? JSON.stringify(error) : error;
780
+ if (rendered && errorKey !== lastRenderedMessageKey) {
781
+ setLastRenderedMessageKey(errorKey);
782
+ setLastRenderedMessage(errorMessage);
783
+ }
784
+ useOpenChangeComplete({
785
+ open: rendered,
786
+ ref: errorRef,
787
+ onComplete() {
788
+ if (!rendered) {
789
+ setMounted(false);
790
+ }
791
+ }
792
+ });
793
+ const state = {
794
+ ...fieldState,
795
+ transitionStatus
796
+ };
797
+ const element = useRenderElement('div', componentProps, {
798
+ ref: [forwardedRef, errorRef],
799
+ state,
800
+ props: [{
801
+ id,
802
+ children: rendered ? errorMessage : lastRenderedMessage
803
+ }, elementProps],
804
+ stateAttributesMapping,
805
+ enabled: mounted
806
+ });
807
+ if (!mounted) {
808
+ return null;
809
+ }
810
+ return element;
811
+ });
812
+ if (process.env.NODE_ENV !== "production") FieldError.displayName = "FieldError";
813
+
814
+ /**
815
+ * A paragraph with additional information about the field.
816
+ * Renders a `<p>` element.
817
+ *
818
+ * Documentation: [Base UI Field](https://base-ui.com/react/components/field)
819
+ */
820
+ const FieldDescription = /*#__PURE__*/React.forwardRef(function FieldDescription(componentProps, forwardedRef) {
821
+ const {
822
+ render,
823
+ id: idProp,
824
+ className,
825
+ style,
826
+ ...elementProps
827
+ } = componentProps;
828
+ const id = useBaseUiId(idProp);
829
+ const fieldRootContext = useFieldRootContext(false);
830
+ const fieldItemContext = useFieldItemContext();
831
+ const {
832
+ setMessageIds
833
+ } = useLabelableContext();
834
+ const state = {
835
+ ...fieldRootContext.state,
836
+ disabled: fieldRootContext.disabled || fieldItemContext.disabled
837
+ };
838
+ useIsoLayoutEffect(() => {
839
+ if (!id) {
840
+ return undefined;
841
+ }
842
+ setMessageIds(v => v.concat(id));
843
+ return () => {
844
+ setMessageIds(v => v.filter(item => item !== id));
845
+ };
846
+ }, [id, setMessageIds]);
847
+ const element = useRenderElement('p', componentProps, {
848
+ ref: forwardedRef,
849
+ state,
850
+ props: [{
851
+ id
852
+ }, elementProps],
853
+ stateAttributesMapping: fieldValidityMapping
854
+ });
855
+ return element;
856
+ });
857
+ if (process.env.NODE_ENV !== "production") FieldDescription.displayName = "FieldDescription";
858
+
859
+ export { FieldRoot as F, FieldLabel as a, FieldDescription as b, FieldError as c };