@react-md/core 6.5.1 → 7.0.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 (648) hide show
  1. package/dist/_utils.scss +3 -0
  2. package/dist/app-bar/AppBar.d.ts +3 -2
  3. package/dist/app-bar/AppBar.js +3 -4
  4. package/dist/app-bar/AppBar.js.map +1 -1
  5. package/dist/app-bar/AppBarTitle.d.ts +3 -1
  6. package/dist/app-bar/AppBarTitle.js +3 -4
  7. package/dist/app-bar/AppBarTitle.js.map +1 -1
  8. package/dist/autocomplete/AutocompleteChip.d.ts +2 -1
  9. package/dist/autocomplete/AutocompleteChip.js +3 -4
  10. package/dist/autocomplete/AutocompleteChip.js.map +1 -1
  11. package/dist/autocomplete/types.d.ts +1 -0
  12. package/dist/autocomplete/types.js.map +1 -1
  13. package/dist/autocomplete/utils.d.ts +4 -4
  14. package/dist/autocomplete/utils.js.map +1 -1
  15. package/dist/avatar/Avatar.d.ts +3 -2
  16. package/dist/avatar/Avatar.js +3 -4
  17. package/dist/avatar/Avatar.js.map +1 -1
  18. package/dist/badge/Badge.d.ts +3 -2
  19. package/dist/badge/Badge.js +3 -4
  20. package/dist/badge/Badge.js.map +1 -1
  21. package/dist/box/Box.d.ts +3 -2
  22. package/dist/box/Box.js +3 -4
  23. package/dist/box/Box.js.map +1 -1
  24. package/dist/button/AsyncButton.d.ts +3 -2
  25. package/dist/button/AsyncButton.js +3 -4
  26. package/dist/button/AsyncButton.js.map +1 -1
  27. package/dist/button/Button.d.ts +3 -2
  28. package/dist/button/Button.js +3 -4
  29. package/dist/button/Button.js.map +1 -1
  30. package/dist/button/ButtonUnstyled.d.ts +5 -3
  31. package/dist/button/ButtonUnstyled.js +3 -4
  32. package/dist/button/ButtonUnstyled.js.map +1 -1
  33. package/dist/button/FloatingActionButton.d.ts +3 -2
  34. package/dist/button/FloatingActionButton.js +3 -4
  35. package/dist/button/FloatingActionButton.js.map +1 -1
  36. package/dist/button/TooltippedButton.d.ts +3 -2
  37. package/dist/button/TooltippedButton.js +3 -4
  38. package/dist/button/TooltippedButton.js.map +1 -1
  39. package/dist/card/Card.d.ts +3 -2
  40. package/dist/card/Card.js +3 -4
  41. package/dist/card/Card.js.map +1 -1
  42. package/dist/card/CardContent.d.ts +3 -2
  43. package/dist/card/CardContent.js +3 -4
  44. package/dist/card/CardContent.js.map +1 -1
  45. package/dist/card/CardFooter.d.ts +3 -1
  46. package/dist/card/CardFooter.js +3 -4
  47. package/dist/card/CardFooter.js.map +1 -1
  48. package/dist/card/CardHeader.d.ts +3 -2
  49. package/dist/card/CardHeader.js +3 -4
  50. package/dist/card/CardHeader.js.map +1 -1
  51. package/dist/card/CardSubtitle.d.ts +3 -1
  52. package/dist/card/CardSubtitle.js +3 -4
  53. package/dist/card/CardSubtitle.js.map +1 -1
  54. package/dist/card/CardTitle.d.ts +3 -1
  55. package/dist/card/CardTitle.js +3 -4
  56. package/dist/card/CardTitle.js.map +1 -1
  57. package/dist/card/ClickableCard.d.ts +3 -2
  58. package/dist/card/ClickableCard.js +3 -4
  59. package/dist/card/ClickableCard.js.map +1 -1
  60. package/dist/chip/Chip.d.ts +4 -2
  61. package/dist/chip/Chip.js +4 -4
  62. package/dist/chip/Chip.js.map +1 -1
  63. package/dist/datetime/NativeDateField.d.ts +3 -1
  64. package/dist/datetime/NativeDateField.js +3 -4
  65. package/dist/datetime/NativeDateField.js.map +1 -1
  66. package/dist/datetime/NativeTimeField.d.ts +3 -1
  67. package/dist/datetime/NativeTimeField.js +3 -4
  68. package/dist/datetime/NativeTimeField.js.map +1 -1
  69. package/dist/dialog/Dialog.d.ts +3 -2
  70. package/dist/dialog/Dialog.js +4 -4
  71. package/dist/dialog/Dialog.js.map +1 -1
  72. package/dist/dialog/DialogContainer.d.ts +3 -2
  73. package/dist/dialog/DialogContainer.js +3 -4
  74. package/dist/dialog/DialogContainer.js.map +1 -1
  75. package/dist/dialog/DialogContent.d.ts +3 -2
  76. package/dist/dialog/DialogContent.js +3 -4
  77. package/dist/dialog/DialogContent.js.map +1 -1
  78. package/dist/dialog/DialogFooter.d.ts +3 -2
  79. package/dist/dialog/DialogFooter.js +3 -4
  80. package/dist/dialog/DialogFooter.js.map +1 -1
  81. package/dist/dialog/DialogHeader.d.ts +3 -1
  82. package/dist/dialog/DialogHeader.js +3 -4
  83. package/dist/dialog/DialogHeader.js.map +1 -1
  84. package/dist/dialog/DialogTitle.d.ts +3 -1
  85. package/dist/dialog/DialogTitle.js +3 -4
  86. package/dist/dialog/DialogTitle.js.map +1 -1
  87. package/dist/dialog/FixedDialog.d.ts +4 -3
  88. package/dist/dialog/FixedDialog.js +4 -4
  89. package/dist/dialog/FixedDialog.js.map +1 -1
  90. package/dist/divider/Divider.d.ts +3 -2
  91. package/dist/divider/Divider.js +3 -4
  92. package/dist/divider/Divider.js.map +1 -1
  93. package/dist/draggable/useDraggable.d.ts +3 -3
  94. package/dist/draggable/useDraggable.js.map +1 -1
  95. package/dist/draggable/utils.d.ts +1 -1
  96. package/dist/draggable/utils.js.map +1 -1
  97. package/dist/expansion-panel/ExpansionList.d.ts +3 -2
  98. package/dist/expansion-panel/ExpansionList.js +3 -4
  99. package/dist/expansion-panel/ExpansionList.js.map +1 -1
  100. package/dist/expansion-panel/ExpansionPanel.d.ts +3 -2
  101. package/dist/expansion-panel/ExpansionPanel.js +3 -4
  102. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  103. package/dist/expansion-panel/ExpansionPanelHeader.d.ts +3 -2
  104. package/dist/expansion-panel/ExpansionPanelHeader.js +3 -4
  105. package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
  106. package/dist/files/FileInput.d.ts +3 -2
  107. package/dist/files/FileInput.js +3 -4
  108. package/dist/files/FileInput.js.map +1 -1
  109. package/dist/focus/useFocusContainer.d.ts +1 -1
  110. package/dist/focus/useFocusContainer.js.map +1 -1
  111. package/dist/form/Checkbox.d.ts +2 -1
  112. package/dist/form/Checkbox.js +4 -4
  113. package/dist/form/Checkbox.js.map +1 -1
  114. package/dist/form/Fieldset.d.ts +3 -2
  115. package/dist/form/Fieldset.js +3 -4
  116. package/dist/form/Fieldset.js.map +1 -1
  117. package/dist/form/Form.d.ts +3 -2
  118. package/dist/form/Form.js +3 -4
  119. package/dist/form/Form.js.map +1 -1
  120. package/dist/form/FormMessage.d.ts +8 -2
  121. package/dist/form/FormMessage.js +3 -4
  122. package/dist/form/FormMessage.js.map +1 -1
  123. package/dist/form/FormMessageContainer.d.ts +5 -4
  124. package/dist/form/FormMessageContainer.js +3 -4
  125. package/dist/form/FormMessageContainer.js.map +1 -1
  126. package/dist/form/FormMessageCounter.d.ts +3 -2
  127. package/dist/form/FormMessageCounter.js +3 -4
  128. package/dist/form/FormMessageCounter.js.map +1 -1
  129. package/dist/form/InputToggle.d.ts +3 -2
  130. package/dist/form/InputToggle.js +3 -4
  131. package/dist/form/InputToggle.js.map +1 -1
  132. package/dist/form/InputToggleIcon.d.ts +3 -2
  133. package/dist/form/InputToggleIcon.js +3 -4
  134. package/dist/form/InputToggleIcon.js.map +1 -1
  135. package/dist/form/Label.d.ts +2 -1
  136. package/dist/form/Label.js +3 -4
  137. package/dist/form/Label.js.map +1 -1
  138. package/dist/form/Legend.d.ts +3 -1
  139. package/dist/form/Legend.js +3 -4
  140. package/dist/form/Legend.js.map +1 -1
  141. package/dist/form/NativeSelect.d.ts +3 -2
  142. package/dist/form/NativeSelect.js +3 -4
  143. package/dist/form/NativeSelect.js.map +1 -1
  144. package/dist/form/OptGroup.d.ts +3 -2
  145. package/dist/form/OptGroup.js +3 -4
  146. package/dist/form/OptGroup.js.map +1 -1
  147. package/dist/form/Option.d.ts +3 -2
  148. package/dist/form/Option.js +4 -4
  149. package/dist/form/Option.js.map +1 -1
  150. package/dist/form/Password.d.ts +2 -2
  151. package/dist/form/Password.js +3 -4
  152. package/dist/form/Password.js.map +1 -1
  153. package/dist/form/Radio.d.ts +2 -1
  154. package/dist/form/Radio.js +4 -4
  155. package/dist/form/Radio.js.map +1 -1
  156. package/dist/form/ResizingTextAreaWrapper.d.ts +3 -2
  157. package/dist/form/ResizingTextAreaWrapper.js +3 -4
  158. package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
  159. package/dist/form/SliderContainer.d.ts +3 -2
  160. package/dist/form/SliderContainer.js +3 -4
  161. package/dist/form/SliderContainer.js.map +1 -1
  162. package/dist/form/SliderThumb.d.ts +3 -2
  163. package/dist/form/SliderThumb.js +4 -4
  164. package/dist/form/SliderThumb.js.map +1 -1
  165. package/dist/form/SliderTrack.d.ts +3 -2
  166. package/dist/form/SliderTrack.js +3 -4
  167. package/dist/form/SliderTrack.js.map +1 -1
  168. package/dist/form/Switch.d.ts +3 -2
  169. package/dist/form/Switch.js +3 -4
  170. package/dist/form/Switch.js.map +1 -1
  171. package/dist/form/SwitchTrack.d.ts +3 -2
  172. package/dist/form/SwitchTrack.js +3 -4
  173. package/dist/form/SwitchTrack.js.map +1 -1
  174. package/dist/form/TextArea.d.ts +3 -2
  175. package/dist/form/TextArea.js +3 -4
  176. package/dist/form/TextArea.js.map +1 -1
  177. package/dist/form/TextField.d.ts +3 -2
  178. package/dist/form/TextField.js +3 -4
  179. package/dist/form/TextField.js.map +1 -1
  180. package/dist/form/TextFieldAddon.d.ts +2 -1
  181. package/dist/form/TextFieldAddon.js +3 -4
  182. package/dist/form/TextFieldAddon.js.map +1 -1
  183. package/dist/form/TextFieldContainer.d.ts +3 -2
  184. package/dist/form/TextFieldContainer.js +3 -4
  185. package/dist/form/TextFieldContainer.js.map +1 -1
  186. package/dist/form/sliderUtils.d.ts +1 -1
  187. package/dist/form/sliderUtils.js.map +1 -1
  188. package/dist/form/types.d.ts +11 -5
  189. package/dist/form/types.js.map +1 -1
  190. package/dist/form/useCombobox.d.ts +6 -6
  191. package/dist/form/useCombobox.js.map +1 -1
  192. package/dist/form/useFormReset.d.ts +1 -1
  193. package/dist/form/useFormReset.js.map +1 -1
  194. package/dist/form/useTextField.d.ts +4 -4
  195. package/dist/form/useTextField.js.map +1 -1
  196. package/dist/hoverMode/useHoverMode.js +1 -1
  197. package/dist/hoverMode/useHoverMode.js.map +1 -1
  198. package/dist/hoverMode/useHoverModeProvider.d.ts +5 -5
  199. package/dist/hoverMode/useHoverModeProvider.js +1 -1
  200. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  201. package/dist/icon/FontIcon.d.ts +3 -2
  202. package/dist/icon/FontIcon.js +3 -4
  203. package/dist/icon/FontIcon.js.map +1 -1
  204. package/dist/icon/IconRotator.d.ts +3 -2
  205. package/dist/icon/IconRotator.js +4 -4
  206. package/dist/icon/IconRotator.js.map +1 -1
  207. package/dist/icon/MaterialIcon.d.ts +3 -2
  208. package/dist/icon/MaterialIcon.js +3 -4
  209. package/dist/icon/MaterialIcon.js.map +1 -1
  210. package/dist/icon/MaterialSymbol.d.ts +3 -2
  211. package/dist/icon/MaterialSymbol.js +3 -4
  212. package/dist/icon/MaterialSymbol.js.map +1 -1
  213. package/dist/icon/SVGIcon.d.ts +3 -2
  214. package/dist/icon/SVGIcon.js +3 -4
  215. package/dist/icon/SVGIcon.js.map +1 -1
  216. package/dist/layout/LayoutAppBar.d.ts +3 -1
  217. package/dist/layout/LayoutAppBar.js +3 -4
  218. package/dist/layout/LayoutAppBar.js.map +1 -1
  219. package/dist/layout/LayoutNav.d.ts +3 -2
  220. package/dist/layout/LayoutNav.js +3 -4
  221. package/dist/layout/LayoutNav.js.map +1 -1
  222. package/dist/layout/LayoutWindowSplitter.d.ts +4 -2
  223. package/dist/layout/LayoutWindowSplitter.js +4 -4
  224. package/dist/layout/LayoutWindowSplitter.js.map +1 -1
  225. package/dist/layout/Main.d.ts +4 -3
  226. package/dist/layout/Main.js +3 -4
  227. package/dist/layout/Main.js.map +1 -1
  228. package/dist/link/Link.d.ts +10 -2
  229. package/dist/link/Link.js +4 -4
  230. package/dist/link/Link.js.map +1 -1
  231. package/dist/link/SkipToMainContent.d.ts +3 -2
  232. package/dist/link/SkipToMainContent.js +4 -4
  233. package/dist/link/SkipToMainContent.js.map +1 -1
  234. package/dist/list/List.d.ts +3 -2
  235. package/dist/list/List.js +3 -4
  236. package/dist/list/List.js.map +1 -1
  237. package/dist/list/ListItem.d.ts +3 -2
  238. package/dist/list/ListItem.js +3 -4
  239. package/dist/list/ListItem.js.map +1 -1
  240. package/dist/list/ListItemLink.d.ts +3 -2
  241. package/dist/list/ListItemLink.js +3 -4
  242. package/dist/list/ListItemLink.js.map +1 -1
  243. package/dist/list/ListItemText.d.ts +3 -2
  244. package/dist/list/ListItemText.js +3 -4
  245. package/dist/list/ListItemText.js.map +1 -1
  246. package/dist/list/ListSubheader.d.ts +3 -2
  247. package/dist/list/ListSubheader.js +3 -4
  248. package/dist/list/ListSubheader.js.map +1 -1
  249. package/dist/menu/DropdownMenu.js.map +1 -1
  250. package/dist/menu/Menu.d.ts +4 -2
  251. package/dist/menu/Menu.js +5 -4
  252. package/dist/menu/Menu.js.map +1 -1
  253. package/dist/menu/MenuBar.d.ts +3 -1
  254. package/dist/menu/MenuBar.js +3 -4
  255. package/dist/menu/MenuBar.js.map +1 -1
  256. package/dist/menu/MenuButton.d.ts +2 -1
  257. package/dist/menu/MenuButton.js +3 -4
  258. package/dist/menu/MenuButton.js.map +1 -1
  259. package/dist/menu/MenuItem.d.ts +3 -1
  260. package/dist/menu/MenuItem.js +3 -4
  261. package/dist/menu/MenuItem.js.map +1 -1
  262. package/dist/menu/MenuItemButton.d.ts +2 -1
  263. package/dist/menu/MenuItemButton.js +4 -4
  264. package/dist/menu/MenuItemButton.js.map +1 -1
  265. package/dist/menu/MenuItemCheckbox.d.ts +2 -1
  266. package/dist/menu/MenuItemCheckbox.js +4 -4
  267. package/dist/menu/MenuItemCheckbox.js.map +1 -1
  268. package/dist/menu/MenuItemCircularProgress.d.ts +3 -2
  269. package/dist/menu/MenuItemCircularProgress.js +3 -4
  270. package/dist/menu/MenuItemCircularProgress.js.map +1 -1
  271. package/dist/menu/MenuItemFileInput.d.ts +2 -2
  272. package/dist/menu/MenuItemFileInput.js +3 -4
  273. package/dist/menu/MenuItemFileInput.js.map +1 -1
  274. package/dist/menu/MenuItemGroup.d.ts +3 -3
  275. package/dist/menu/MenuItemGroup.js +4 -4
  276. package/dist/menu/MenuItemGroup.js.map +1 -1
  277. package/dist/menu/MenuItemInputToggle.d.ts +3 -2
  278. package/dist/menu/MenuItemInputToggle.js +3 -4
  279. package/dist/menu/MenuItemInputToggle.js.map +1 -1
  280. package/dist/menu/MenuItemRadio.d.ts +3 -1
  281. package/dist/menu/MenuItemRadio.js +4 -4
  282. package/dist/menu/MenuItemRadio.js.map +1 -1
  283. package/dist/menu/MenuItemSeparator.d.ts +3 -2
  284. package/dist/menu/MenuItemSeparator.js +3 -4
  285. package/dist/menu/MenuItemSeparator.js.map +1 -1
  286. package/dist/menu/MenuItemSwitch.d.ts +2 -1
  287. package/dist/menu/MenuItemSwitch.js +4 -4
  288. package/dist/menu/MenuItemSwitch.js.map +1 -1
  289. package/dist/menu/MenuItemTextField.d.ts +2 -2
  290. package/dist/menu/MenuItemTextField.js +3 -4
  291. package/dist/menu/MenuItemTextField.js.map +1 -1
  292. package/dist/menu/MenuVisibilityProvider.d.ts +3 -3
  293. package/dist/menu/MenuVisibilityProvider.js.map +1 -1
  294. package/dist/menu/MenuWidget.d.ts +4 -4
  295. package/dist/menu/MenuWidget.js +4 -4
  296. package/dist/menu/MenuWidget.js.map +1 -1
  297. package/dist/menu/useContextMenu.d.ts +4 -4
  298. package/dist/menu/useContextMenu.js.map +1 -1
  299. package/dist/movement/types.d.ts +5 -5
  300. package/dist/movement/types.js.map +1 -1
  301. package/dist/navigation/CollapsibleNavGroup.d.ts +2 -2
  302. package/dist/navigation/CollapsibleNavGroup.js +3 -4
  303. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  304. package/dist/navigation/NavGroup.d.ts +3 -2
  305. package/dist/navigation/NavGroup.js +3 -4
  306. package/dist/navigation/NavGroup.js.map +1 -1
  307. package/dist/navigation/NavItem.d.ts +3 -2
  308. package/dist/navigation/NavItem.js +3 -4
  309. package/dist/navigation/NavItem.js.map +1 -1
  310. package/dist/navigation/NavItemButton.d.ts +2 -2
  311. package/dist/navigation/NavItemButton.js +3 -4
  312. package/dist/navigation/NavItemButton.js.map +1 -1
  313. package/dist/navigation/NavItemLink.d.ts +3 -2
  314. package/dist/navigation/NavItemLink.js +4 -4
  315. package/dist/navigation/NavItemLink.js.map +1 -1
  316. package/dist/navigation/NavSubheader.d.ts +2 -1
  317. package/dist/navigation/NavSubheader.js +3 -4
  318. package/dist/navigation/NavSubheader.js.map +1 -1
  319. package/dist/navigation/Navigation.d.ts +1 -1
  320. package/dist/navigation/Navigation.js +1 -1
  321. package/dist/navigation/Navigation.js.map +1 -1
  322. package/dist/navigation/types.d.ts +5 -2
  323. package/dist/navigation/types.js.map +1 -1
  324. package/dist/navigation/useActiveHeadingId.js +1 -1
  325. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  326. package/dist/overlay/Overlay.d.ts +3 -2
  327. package/dist/overlay/Overlay.js +3 -4
  328. package/dist/overlay/Overlay.js.map +1 -1
  329. package/dist/positioning/useFixedPositioning.d.ts +1 -1
  330. package/dist/positioning/useFixedPositioning.js.map +1 -1
  331. package/dist/progress/CircularProgress.d.ts +2 -2
  332. package/dist/progress/CircularProgress.js +4 -4
  333. package/dist/progress/CircularProgress.js.map +1 -1
  334. package/dist/progress/LinearProgress.d.ts +2 -2
  335. package/dist/progress/LinearProgress.js +4 -4
  336. package/dist/progress/LinearProgress.js.map +1 -1
  337. package/dist/progress/types.d.ts +2 -0
  338. package/dist/progress/types.js.map +1 -1
  339. package/dist/responsive-item/ResponsiveItem.d.ts +3 -2
  340. package/dist/responsive-item/ResponsiveItem.js +3 -4
  341. package/dist/responsive-item/ResponsiveItem.js.map +1 -1
  342. package/dist/responsive-item/ResponsiveItemOverlay.d.ts +3 -2
  343. package/dist/responsive-item/ResponsiveItemOverlay.js +3 -4
  344. package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
  345. package/dist/segmented-button/SegmentedButton.d.ts +3 -2
  346. package/dist/segmented-button/SegmentedButton.js +3 -4
  347. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  348. package/dist/segmented-button/SegmentedButtonContainer.d.ts +4 -3
  349. package/dist/segmented-button/SegmentedButtonContainer.js +4 -5
  350. package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
  351. package/dist/sheet/Sheet.d.ts +2 -1
  352. package/dist/sheet/Sheet.js +3 -4
  353. package/dist/sheet/Sheet.js.map +1 -1
  354. package/dist/snackbar/Snackbar.d.ts +3 -2
  355. package/dist/snackbar/Snackbar.js +3 -4
  356. package/dist/snackbar/Snackbar.js.map +1 -1
  357. package/dist/snackbar/Toast.d.ts +3 -2
  358. package/dist/snackbar/Toast.js +4 -4
  359. package/dist/snackbar/Toast.js.map +1 -1
  360. package/dist/snackbar/ToastActionButton.d.ts +2 -1
  361. package/dist/snackbar/ToastActionButton.js +3 -4
  362. package/dist/snackbar/ToastActionButton.js.map +1 -1
  363. package/dist/snackbar/ToastCloseButton.d.ts +2 -1
  364. package/dist/snackbar/ToastCloseButton.js +3 -4
  365. package/dist/snackbar/ToastCloseButton.js.map +1 -1
  366. package/dist/snackbar/ToastContent.d.ts +3 -2
  367. package/dist/snackbar/ToastContent.js +4 -4
  368. package/dist/snackbar/ToastContent.js.map +1 -1
  369. package/dist/spinbutton/SpinButton.d.ts +4 -3
  370. package/dist/spinbutton/SpinButton.js +3 -4
  371. package/dist/spinbutton/SpinButton.js.map +1 -1
  372. package/dist/spinbutton/types.d.ts +1 -1
  373. package/dist/spinbutton/types.js.map +1 -1
  374. package/dist/table/StickyTableSection.d.ts +3 -2
  375. package/dist/table/StickyTableSection.js +3 -4
  376. package/dist/table/StickyTableSection.js.map +1 -1
  377. package/dist/table/Table.d.ts +3 -2
  378. package/dist/table/Table.js +4 -4
  379. package/dist/table/Table.js.map +1 -1
  380. package/dist/table/TableBody.d.ts +3 -2
  381. package/dist/table/TableBody.js +4 -4
  382. package/dist/table/TableBody.js.map +1 -1
  383. package/dist/table/TableCell.d.ts +3 -2
  384. package/dist/table/TableCell.js +3 -4
  385. package/dist/table/TableCell.js.map +1 -1
  386. package/dist/table/TableCellContent.d.ts +3 -2
  387. package/dist/table/TableCellContent.js +3 -4
  388. package/dist/table/TableCellContent.js.map +1 -1
  389. package/dist/table/TableCheckbox.d.ts +3 -2
  390. package/dist/table/TableCheckbox.js +3 -4
  391. package/dist/table/TableCheckbox.js.map +1 -1
  392. package/dist/table/TableContainer.d.ts +5 -3
  393. package/dist/table/TableContainer.js +4 -4
  394. package/dist/table/TableContainer.js.map +1 -1
  395. package/dist/table/TableContainerProvider.d.ts +1 -1
  396. package/dist/table/TableContainerProvider.js.map +1 -1
  397. package/dist/table/TableFooter.d.ts +3 -2
  398. package/dist/table/TableFooter.js +4 -5
  399. package/dist/table/TableFooter.js.map +1 -1
  400. package/dist/table/TableHeader.d.ts +3 -2
  401. package/dist/table/TableHeader.js +4 -5
  402. package/dist/table/TableHeader.js.map +1 -1
  403. package/dist/table/TableRadio.d.ts +3 -2
  404. package/dist/table/TableRadio.js +3 -4
  405. package/dist/table/TableRadio.js.map +1 -1
  406. package/dist/table/TableRow.d.ts +3 -2
  407. package/dist/table/TableRow.js +3 -4
  408. package/dist/table/TableRow.js.map +1 -1
  409. package/dist/tabs/SimpleTabPanel.d.ts +3 -2
  410. package/dist/tabs/SimpleTabPanel.js +3 -4
  411. package/dist/tabs/SimpleTabPanel.js.map +1 -1
  412. package/dist/tabs/SimpleTabPanels.d.ts +3 -2
  413. package/dist/tabs/SimpleTabPanels.js +3 -4
  414. package/dist/tabs/SimpleTabPanels.js.map +1 -1
  415. package/dist/tabs/TabList.d.ts +3 -2
  416. package/dist/tabs/TabList.js +4 -4
  417. package/dist/tabs/TabList.js.map +1 -1
  418. package/dist/tabs/TabListScrollButton.d.ts +3 -2
  419. package/dist/tabs/TabListScrollButton.js +4 -4
  420. package/dist/tabs/TabListScrollButton.js.map +1 -1
  421. package/dist/tabs/useTabList.d.ts +2 -2
  422. package/dist/tabs/useTabList.js.map +1 -1
  423. package/dist/theme/useCSSVariables.d.ts +1 -1
  424. package/dist/theme/useCSSVariables.js.map +1 -1
  425. package/dist/tooltip/Tooltip.d.ts +3 -2
  426. package/dist/tooltip/Tooltip.js +3 -4
  427. package/dist/tooltip/Tooltip.js.map +1 -1
  428. package/dist/tooltip/useTooltip.d.ts +3 -3
  429. package/dist/tooltip/useTooltip.js.map +1 -1
  430. package/dist/transition/SkeletonPlaceholder.d.ts +3 -2
  431. package/dist/transition/SkeletonPlaceholder.js +3 -4
  432. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  433. package/dist/transition/Slide.d.ts +3 -2
  434. package/dist/transition/Slide.js +3 -4
  435. package/dist/transition/Slide.js.map +1 -1
  436. package/dist/transition/SlideContainer.d.ts +3 -2
  437. package/dist/transition/SlideContainer.js +3 -4
  438. package/dist/transition/SlideContainer.js.map +1 -1
  439. package/dist/tree/TreeGroup.d.ts +2 -2
  440. package/dist/tree/TreeGroup.js +3 -4
  441. package/dist/tree/TreeGroup.js.map +1 -1
  442. package/dist/tree/TreeProvider.d.ts +2 -3
  443. package/dist/tree/TreeProvider.js.map +1 -1
  444. package/dist/tree/useTreeMovement.d.ts +6 -7
  445. package/dist/tree/useTreeMovement.js.map +1 -1
  446. package/dist/types.d.ts +1 -15
  447. package/dist/types.js.map +1 -1
  448. package/dist/typography/Mark.d.ts +3 -2
  449. package/dist/typography/Mark.js +3 -4
  450. package/dist/typography/Mark.js.map +1 -1
  451. package/dist/typography/SrOnly.d.ts +3 -2
  452. package/dist/typography/SrOnly.js +3 -4
  453. package/dist/typography/SrOnly.js.map +1 -1
  454. package/dist/typography/TextContainer.d.ts +3 -2
  455. package/dist/typography/TextContainer.js +3 -4
  456. package/dist/typography/TextContainer.js.map +1 -1
  457. package/dist/typography/Typography.d.ts +3 -2
  458. package/dist/typography/Typography.js +3 -4
  459. package/dist/typography/Typography.js.map +1 -1
  460. package/dist/useAsyncFunction.d.ts +3 -2
  461. package/dist/useAsyncFunction.js.map +1 -1
  462. package/dist/useDebouncedFunction.js +1 -1
  463. package/dist/useDebouncedFunction.js.map +1 -1
  464. package/dist/useDropzone.js +1 -1
  465. package/dist/useDropzone.js.map +1 -1
  466. package/dist/useEnsuredRef.d.ts +3 -3
  467. package/dist/useEnsuredRef.js +1 -1
  468. package/dist/useEnsuredRef.js.map +1 -1
  469. package/dist/useThrottledFunction.js +3 -3
  470. package/dist/useThrottledFunction.js.map +1 -1
  471. package/dist/useUnmounted.d.ts +2 -2
  472. package/dist/useUnmounted.js.map +1 -1
  473. package/dist/utils/applyRef.d.ts +1 -1
  474. package/dist/utils/applyRef.js.map +1 -1
  475. package/dist/window-splitter/WindowSplitter.d.ts +3 -2
  476. package/dist/window-splitter/WindowSplitter.js +3 -4
  477. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  478. package/package.json +9 -9
  479. package/src/app-bar/AppBar.tsx +54 -54
  480. package/src/app-bar/AppBarTitle.tsx +29 -27
  481. package/src/autocomplete/AutocompleteChip.tsx +4 -6
  482. package/src/autocomplete/types.ts +2 -0
  483. package/src/autocomplete/utils.ts +4 -4
  484. package/src/avatar/Avatar.tsx +47 -45
  485. package/src/badge/Badge.tsx +17 -11
  486. package/src/box/Box.tsx +51 -50
  487. package/src/button/AsyncButton.tsx +125 -119
  488. package/src/button/Button.tsx +74 -73
  489. package/src/button/ButtonUnstyled.tsx +9 -9
  490. package/src/button/FloatingActionButton.tsx +9 -7
  491. package/src/button/TooltippedButton.tsx +6 -6
  492. package/src/card/Card.tsx +36 -35
  493. package/src/card/CardContent.tsx +31 -28
  494. package/src/card/CardFooter.tsx +22 -16
  495. package/src/card/CardHeader.tsx +36 -30
  496. package/src/card/CardSubtitle.tsx +8 -6
  497. package/src/card/CardTitle.tsx +26 -25
  498. package/src/card/ClickableCard.tsx +57 -54
  499. package/src/chip/Chip.tsx +122 -120
  500. package/src/datetime/NativeDateField.tsx +7 -7
  501. package/src/datetime/NativeTimeField.tsx +7 -7
  502. package/src/dialog/Dialog.tsx +156 -150
  503. package/src/dialog/DialogContainer.tsx +35 -29
  504. package/src/dialog/DialogContent.tsx +26 -19
  505. package/src/dialog/DialogFooter.tsx +22 -19
  506. package/src/dialog/DialogHeader.tsx +24 -23
  507. package/src/dialog/DialogTitle.tsx +27 -26
  508. package/src/dialog/FixedDialog.tsx +70 -69
  509. package/src/divider/Divider.tsx +32 -26
  510. package/src/draggable/useDraggable.ts +3 -6
  511. package/src/draggable/utils.ts +1 -1
  512. package/src/expansion-panel/ExpansionList.tsx +24 -19
  513. package/src/expansion-panel/ExpansionPanel.tsx +11 -6
  514. package/src/expansion-panel/ExpansionPanelHeader.tsx +9 -6
  515. package/src/files/FileInput.tsx +79 -79
  516. package/src/focus/useFocusContainer.ts +1 -1
  517. package/src/form/Checkbox.tsx +6 -6
  518. package/src/form/Fieldset.tsx +33 -28
  519. package/src/form/Form.tsx +26 -25
  520. package/src/form/FormMessage.tsx +13 -7
  521. package/src/form/FormMessageContainer.tsx +12 -9
  522. package/src/form/FormMessageCounter.tsx +8 -7
  523. package/src/form/InputToggle.tsx +105 -107
  524. package/src/form/InputToggleIcon.tsx +12 -6
  525. package/src/form/Label.tsx +40 -41
  526. package/src/form/Legend.tsx +44 -43
  527. package/src/form/NativeSelect.tsx +116 -114
  528. package/src/form/OptGroup.tsx +15 -15
  529. package/src/form/Option.tsx +123 -122
  530. package/src/form/Password.tsx +66 -67
  531. package/src/form/Radio.tsx +6 -6
  532. package/src/form/ResizingTextAreaWrapper.tsx +7 -6
  533. package/src/form/SliderContainer.tsx +35 -29
  534. package/src/form/SliderThumb.tsx +8 -6
  535. package/src/form/SliderTrack.tsx +80 -80
  536. package/src/form/Switch.tsx +80 -79
  537. package/src/form/SwitchTrack.tsx +35 -34
  538. package/src/form/TextArea.tsx +167 -165
  539. package/src/form/TextField.tsx +106 -104
  540. package/src/form/TextFieldAddon.tsx +33 -32
  541. package/src/form/TextFieldContainer.tsx +8 -6
  542. package/src/form/sliderUtils.ts +1 -1
  543. package/src/form/types.ts +15 -5
  544. package/src/form/useCombobox.ts +6 -10
  545. package/src/form/useFormReset.ts +1 -1
  546. package/src/form/useTextField.ts +4 -4
  547. package/src/hoverMode/useHoverMode.ts +1 -1
  548. package/src/hoverMode/useHoverModeProvider.ts +13 -8
  549. package/src/icon/FontIcon.tsx +32 -30
  550. package/src/icon/IconRotator.tsx +30 -28
  551. package/src/icon/MaterialIcon.tsx +36 -30
  552. package/src/icon/MaterialSymbol.tsx +50 -44
  553. package/src/icon/SVGIcon.tsx +47 -41
  554. package/src/layout/LayoutAppBar.tsx +23 -28
  555. package/src/layout/LayoutNav.tsx +68 -62
  556. package/src/layout/LayoutWindowSplitter.tsx +9 -7
  557. package/src/layout/Main.tsx +30 -29
  558. package/src/link/Link.tsx +16 -11
  559. package/src/link/SkipToMainContent.tsx +6 -6
  560. package/src/list/List.tsx +31 -29
  561. package/src/list/ListItem.tsx +126 -125
  562. package/src/list/ListItemLink.tsx +128 -126
  563. package/src/list/ListItemText.tsx +42 -37
  564. package/src/list/ListSubheader.tsx +27 -26
  565. package/src/menu/DropdownMenu.tsx +2 -2
  566. package/src/menu/Menu.tsx +327 -326
  567. package/src/menu/MenuBar.tsx +51 -50
  568. package/src/menu/MenuButton.tsx +69 -70
  569. package/src/menu/MenuItem.tsx +37 -37
  570. package/src/menu/MenuItemButton.tsx +132 -133
  571. package/src/menu/MenuItemCheckbox.tsx +6 -7
  572. package/src/menu/MenuItemCircularProgress.tsx +13 -6
  573. package/src/menu/MenuItemFileInput.tsx +4 -6
  574. package/src/menu/MenuItemGroup.tsx +18 -18
  575. package/src/menu/MenuItemInputToggle.tsx +8 -6
  576. package/src/menu/MenuItemRadio.tsx +6 -6
  577. package/src/menu/MenuItemSeparator.tsx +7 -7
  578. package/src/menu/MenuItemSwitch.tsx +6 -6
  579. package/src/menu/MenuItemTextField.tsx +5 -7
  580. package/src/menu/MenuVisibilityProvider.tsx +3 -2
  581. package/src/menu/MenuWidget.tsx +123 -119
  582. package/src/menu/useContextMenu.ts +7 -4
  583. package/src/movement/types.ts +5 -9
  584. package/src/navigation/CollapsibleNavGroup.tsx +10 -6
  585. package/src/navigation/NavGroup.tsx +18 -19
  586. package/src/navigation/NavItem.tsx +16 -11
  587. package/src/navigation/NavItemButton.tsx +69 -66
  588. package/src/navigation/NavItemLink.tsx +102 -100
  589. package/src/navigation/NavSubheader.tsx +14 -16
  590. package/src/navigation/Navigation.tsx +1 -1
  591. package/src/navigation/types.ts +13 -4
  592. package/src/navigation/useActiveHeadingId.ts +1 -1
  593. package/src/overlay/Overlay.tsx +66 -65
  594. package/src/positioning/useFixedPositioning.ts +1 -1
  595. package/src/progress/CircularProgress.tsx +6 -6
  596. package/src/progress/LinearProgress.tsx +6 -6
  597. package/src/progress/types.ts +4 -0
  598. package/src/responsive-item/ResponsiveItem.tsx +29 -28
  599. package/src/responsive-item/ResponsiveItemOverlay.tsx +9 -8
  600. package/src/segmented-button/SegmentedButton.tsx +11 -6
  601. package/src/segmented-button/SegmentedButtonContainer.tsx +14 -8
  602. package/src/sheet/Sheet.tsx +42 -43
  603. package/src/snackbar/Snackbar.tsx +44 -38
  604. package/src/snackbar/Toast.tsx +110 -109
  605. package/src/snackbar/ToastActionButton.tsx +6 -6
  606. package/src/snackbar/ToastCloseButton.tsx +4 -6
  607. package/src/snackbar/ToastContent.tsx +56 -49
  608. package/src/spinbutton/SpinButton.tsx +9 -8
  609. package/src/spinbutton/types.ts +1 -1
  610. package/src/table/StickyTableSection.tsx +8 -6
  611. package/src/table/Table.tsx +47 -41
  612. package/src/table/TableBody.tsx +46 -42
  613. package/src/table/TableCell.tsx +83 -81
  614. package/src/table/TableCellContent.tsx +11 -6
  615. package/src/table/TableCheckbox.tsx +6 -6
  616. package/src/table/TableContainer.tsx +31 -26
  617. package/src/table/TableContainerProvider.ts +1 -1
  618. package/src/table/TableFooter.tsx +7 -12
  619. package/src/table/TableHeader.tsx +15 -9
  620. package/src/table/TableRadio.tsx +59 -58
  621. package/src/table/TableRow.tsx +34 -33
  622. package/src/tabs/SimpleTabPanel.tsx +18 -13
  623. package/src/tabs/SimpleTabPanels.tsx +11 -7
  624. package/src/tabs/TabList.tsx +106 -105
  625. package/src/tabs/TabListScrollButton.tsx +9 -6
  626. package/src/tabs/useTabList.ts +2 -2
  627. package/src/theme/useCSSVariables.ts +1 -1
  628. package/src/tooltip/Tooltip.tsx +61 -61
  629. package/src/tooltip/useTooltip.ts +2 -3
  630. package/src/transition/SkeletonPlaceholder.tsx +8 -6
  631. package/src/transition/Slide.tsx +54 -48
  632. package/src/transition/SlideContainer.tsx +16 -16
  633. package/src/tree/TreeGroup.tsx +54 -55
  634. package/src/tree/TreeProvider.tsx +2 -2
  635. package/src/tree/useTreeMovement.ts +6 -6
  636. package/src/types.ts +1 -16
  637. package/src/typography/Mark.tsx +16 -11
  638. package/src/typography/SrOnly.tsx +41 -35
  639. package/src/typography/TextContainer.tsx +12 -12
  640. package/src/typography/Typography.tsx +42 -41
  641. package/src/useAsyncFunction.ts +3 -3
  642. package/src/useDebouncedFunction.ts +1 -1
  643. package/src/useDropzone.ts +1 -1
  644. package/src/useEnsuredRef.ts +3 -3
  645. package/src/useThrottledFunction.ts +3 -3
  646. package/src/useUnmounted.ts +2 -4
  647. package/src/utils/applyRef.ts +2 -2
  648. package/src/window-splitter/WindowSplitter.tsx +6 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/TextField.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { Label } from \"./Label.js\";\nimport { TextFieldContainer } from \"./TextFieldContainer.js\";\nimport { textField } from \"./textFieldStyles.js\";\nimport {\n type FormFieldOptions,\n type UserAgentAutocompleteProps,\n} from \"./types.js\";\n\n/**\n * These are all the \"supported\" input types for react-md so that they at least\n * render reasonably well by default. There is no built-in validation or\n * anything adding onto existing browser functionality for these types.\n *\n * @since 2.5.0 - `\"search\"` was added\n * @since 6.0.0 Dropped support for `\"week\"` and `\"month\"` input types since\n * they are not available in Firefox and Safari at this time.\n */\nexport type SupportedInputTypes =\n | \"text\"\n | \"password\"\n | \"number\"\n | \"tel\"\n | \"email\"\n | \"date\"\n | \"time\"\n | \"datetime-local\"\n | \"url\"\n | \"color\"\n | \"search\";\n\n/**\n * @since 6.0.0 Renamed from `TextFieldAttributes` to\n * `TextFieldInputAttributes`\n */\nexport type TextFieldInputAttributes = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\"\n>;\n\n/**\n * @since 6.0.0 Removed the `containerRef` prop.\n */\nexport interface TextFieldProps\n extends\n TextFieldInputAttributes,\n UserAgentAutocompleteProps,\n FormFieldOptions {\n /**\n * @defaultValue `\"text-field-\" + useId()`\n */\n id?: string;\n\n /**\n * Optional placeholder text to display in the text field.\n *\n * @defaultValue `label ? \" \" : \"\"`\n */\n placeholder?: string;\n\n /**\n * Any optional inline styles to set on the input.\n */\n inputStyle?: CSSProperties;\n\n /**\n * An optional `className` to add to the input.\n */\n inputClassName?: string;\n\n /**\n * The text field type.\n *\n * @defaultValue `\"text\"`\n */\n type?: SupportedInputTypes;\n\n /**\n * Optional props to provide to the {@link TextFieldContainer} component.\n * There probably isn't any real use for this prop other than if you need to\n * add a `ref` for some DOM behavior.\n */\n containerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n}\n\n/**\n * The structure for this component is:\n * @example Component Structure\n * ```tsx\n * <FormMessageContainer {...messageContainerProps}>\n * <TextFieldContainer {...containerProps}>\n * <input {...props} />\n * <Label {...labelProps} />\n * </TextFieldContainer>\n * </FormMessageContainer>\n * ```\n *\n * @example Simple Example\n * ```tsx\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <TextField\n * label=\"Name\"\n * placeholder=\"Bob\"\n * defaultValue=\"\"\n * />\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/textfield | TextField Demos}\n */\nexport const TextField = forwardRef<HTMLInputElement, TextFieldProps>(\n function TextField(props, ref) {\n const {\n id: propId,\n style,\n className,\n type = \"text\",\n label,\n labelProps,\n labelStyle,\n labelClassName,\n autoCompleteValue,\n autoComplete = autoCompleteValue,\n name = autoCompleteValue,\n dense,\n error,\n active,\n inline,\n leftAddon,\n leftAddonProps,\n rightAddon,\n rightAddonProps,\n disableLeftAddonStyles,\n disableRightAddonStyles,\n inputStyle,\n inputClassName,\n theme,\n underlineDirection,\n messageProps,\n messageContainerProps,\n containerProps,\n ...remaining\n } = props;\n const { disabled, readOnly } = props;\n const id = useEnsuredId(propId, \"text-field\");\n\n let { placeholder = \"\" } = props;\n if (label && !placeholder) {\n // See the placeholder type definition comments for information\n placeholder = \" \";\n }\n\n return (\n <FormMessageContainer\n inline={inline}\n {...messageContainerProps}\n messageProps={\n messageProps && {\n error,\n theme,\n ...messageProps,\n }\n }\n >\n <TextFieldContainer\n {...containerProps}\n style={style}\n className={className}\n theme={theme}\n label={!!label}\n error={error}\n dense={dense}\n inline={inline}\n active={active}\n readOnly={readOnly}\n disabled={disabled}\n leftAddon={leftAddon}\n leftAddonProps={leftAddonProps}\n rightAddon={rightAddon}\n rightAddonProps={rightAddonProps}\n underlineDirection={underlineDirection}\n disableLeftAddonStyles={disableLeftAddonStyles}\n disableRightAddonStyles={disableRightAddonStyles}\n >\n <input\n {...remaining}\n id={id}\n ref={ref}\n type={type}\n name={name}\n disabled={disabled}\n placeholder={placeholder}\n autoComplete={autoComplete}\n style={inputStyle}\n className={textField({\n className: inputClassName,\n placeholderHidden: !!label && !active,\n })}\n />\n {label && (\n <Label\n floating\n dense={dense}\n error={error}\n active={active}\n disabled={disabled}\n {...labelProps}\n htmlFor={id}\n style={labelProps?.style ?? labelStyle}\n className={labelProps?.className ?? labelClassName}\n >\n {label}\n </Label>\n )}\n </TextFieldContainer>\n </FormMessageContainer>\n );\n }\n);\n"],"names":["forwardRef","useEnsuredId","FormMessageContainer","Label","TextFieldContainer","textField","TextField","props","ref","id","propId","style","className","type","label","labelProps","labelStyle","labelClassName","autoCompleteValue","autoComplete","name","dense","error","active","inline","leftAddon","leftAddonProps","rightAddon","rightAddonProps","disableLeftAddonStyles","disableRightAddonStyles","inputStyle","inputClassName","theme","underlineDirection","messageProps","messageContainerProps","containerProps","remaining","disabled","readOnly","placeholder","input","placeholderHidden","floating","htmlFor"],"mappings":";AAAA,SAIEA,UAAU,QACL,QAAQ;AAGf,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,SAAS,QAAQ,uBAAuB;AAkFjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMC,0BAAYN,WACvB,SAASM,UAAUC,KAAK,EAAEC,GAAG;IAC3B,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,SAAS,EACTC,OAAO,MAAM,EACbC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,eAAeD,iBAAiB,EAChCE,OAAOF,iBAAiB,EACxBG,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,eAAe,EACfC,sBAAsB,EACtBC,uBAAuB,EACvBC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,kBAAkB,EAClBC,YAAY,EACZC,qBAAqB,EACrBC,cAAc,EACd,GAAGC,WACJ,GAAG/B;IACJ,MAAM,EAAEgC,QAAQ,EAAEC,QAAQ,EAAE,GAAGjC;IAC/B,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,IAAI,EAAE+B,cAAc,EAAE,EAAE,GAAGlC;IAC3B,IAAIO,SAAS,CAAC2B,aAAa;QACzB,+DAA+D;QAC/DA,cAAc;IAChB;IAEA,qBACE,KAACvC;QACCsB,QAAQA;QACP,GAAGY,qBAAqB;QACzBD,cACEA,gBAAgB;YACdb;YACAW;YACA,GAAGE,YAAY;QACjB;kBAGF,cAAA,MAAC/B;YACE,GAAGiC,cAAc;YAClB1B,OAAOA;YACPC,WAAWA;YACXqB,OAAOA;YACPnB,OAAO,CAAC,CAACA;YACTQ,OAAOA;YACPD,OAAOA;YACPG,QAAQA;YACRD,QAAQA;YACRiB,UAAUA;YACVD,UAAUA;YACVd,WAAWA;YACXC,gBAAgBA;YAChBC,YAAYA;YACZC,iBAAiBA;YACjBM,oBAAoBA;YACpBL,wBAAwBA;YACxBC,yBAAyBA;;8BAEzB,KAACY;oBACE,GAAGJ,SAAS;oBACb7B,IAAIA;oBACJD,KAAKA;oBACLK,MAAMA;oBACNO,MAAMA;oBACNmB,UAAUA;oBACVE,aAAaA;oBACbtB,cAAcA;oBACdR,OAAOoB;oBACPnB,WAAWP,UAAU;wBACnBO,WAAWoB;wBACXW,mBAAmB,CAAC,CAAC7B,SAAS,CAACS;oBACjC;;gBAEDT,uBACC,KAACX;oBACCyC,QAAQ;oBACRvB,OAAOA;oBACPC,OAAOA;oBACPC,QAAQA;oBACRgB,UAAUA;oBACT,GAAGxB,UAAU;oBACd8B,SAASpC;oBACTE,OAAOI,YAAYJ,SAASK;oBAC5BJ,WAAWG,YAAYH,aAAaK;8BAEnCH;;;;;AAMb,GACA"}
1
+ {"version":3,"sources":["../../src/form/TextField.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type ReactElement,\n type Ref,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { Label } from \"./Label.js\";\nimport { TextFieldContainer } from \"./TextFieldContainer.js\";\nimport { textField } from \"./textFieldStyles.js\";\nimport {\n type FormFieldOptions,\n type UserAgentAutocompleteProps,\n} from \"./types.js\";\n\n/**\n * These are all the \"supported\" input types for react-md so that they at least\n * render reasonably well by default. There is no built-in validation or\n * anything adding onto existing browser functionality for these types.\n *\n * @since 2.5.0 - `\"search\"` was added\n * @since 6.0.0 Dropped support for `\"week\"` and `\"month\"` input types since\n * they are not available in Firefox and Safari at this time.\n */\nexport type SupportedInputTypes =\n | \"text\"\n | \"password\"\n | \"number\"\n | \"tel\"\n | \"email\"\n | \"date\"\n | \"time\"\n | \"datetime-local\"\n | \"url\"\n | \"color\"\n | \"search\";\n\n/**\n * @since 6.0.0 Renamed from `TextFieldAttributes` to\n * `TextFieldInputAttributes`\n */\nexport type TextFieldInputAttributes = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\"\n>;\n\n/**\n * @since 6.0.0 Removed the `containerRef` prop.\n */\nexport interface TextFieldProps\n extends\n TextFieldInputAttributes,\n UserAgentAutocompleteProps,\n FormFieldOptions {\n ref?: Ref<HTMLInputElement>;\n\n /**\n * @defaultValue `\"text-field-\" + useId()`\n */\n id?: string;\n\n /**\n * Optional placeholder text to display in the text field.\n *\n * @defaultValue `label ? \" \" : \"\"`\n */\n placeholder?: string;\n\n /**\n * Any optional inline styles to set on the input.\n */\n inputStyle?: CSSProperties;\n\n /**\n * An optional `className` to add to the input.\n */\n inputClassName?: string;\n\n /**\n * The text field type.\n *\n * @defaultValue `\"text\"`\n */\n type?: SupportedInputTypes;\n\n /**\n * Optional props to provide to the {@link TextFieldContainer} component.\n * There probably isn't any real use for this prop other than if you need to\n * add a `ref` for some DOM behavior.\n */\n containerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n}\n\n/**\n * The structure for this component is:\n * @example Component Structure\n * ```tsx\n * <FormMessageContainer {...messageContainerProps}>\n * <TextFieldContainer {...containerProps}>\n * <input {...props} />\n * <Label {...labelProps} />\n * </TextFieldContainer>\n * </FormMessageContainer>\n * ```\n *\n * @example Simple Example\n * ```tsx\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <TextField\n * label=\"Name\"\n * placeholder=\"Bob\"\n * defaultValue=\"\"\n * />\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/textfield | TextField Demos}\n */\nexport function TextField(props: TextFieldProps): ReactElement {\n const {\n ref,\n id: propId,\n style,\n className,\n type = \"text\",\n label,\n labelProps,\n labelStyle,\n labelClassName,\n autoCompleteValue,\n autoComplete = autoCompleteValue,\n name = autoCompleteValue,\n dense,\n error,\n active,\n inline,\n leftAddon,\n leftAddonProps,\n rightAddon,\n rightAddonProps,\n disableLeftAddonStyles,\n disableRightAddonStyles,\n inputStyle,\n inputClassName,\n theme,\n underlineDirection,\n messageProps,\n messageContainerProps,\n containerProps,\n ...remaining\n } = props;\n const { disabled, readOnly } = props;\n const id = useEnsuredId(propId, \"text-field\");\n\n let { placeholder = \"\" } = props;\n if (label && !placeholder) {\n // See the placeholder type definition comments for information\n placeholder = \" \";\n }\n\n return (\n <FormMessageContainer\n inline={inline}\n {...messageContainerProps}\n messageProps={\n messageProps && {\n error,\n theme,\n ...messageProps,\n }\n }\n >\n <TextFieldContainer\n {...containerProps}\n style={style}\n className={className}\n theme={theme}\n label={!!label}\n error={error}\n dense={dense}\n inline={inline}\n active={active}\n readOnly={readOnly}\n disabled={disabled}\n leftAddon={leftAddon}\n leftAddonProps={leftAddonProps}\n rightAddon={rightAddon}\n rightAddonProps={rightAddonProps}\n underlineDirection={underlineDirection}\n disableLeftAddonStyles={disableLeftAddonStyles}\n disableRightAddonStyles={disableRightAddonStyles}\n >\n <input\n {...remaining}\n id={id}\n ref={ref}\n type={type}\n name={name}\n disabled={disabled}\n placeholder={placeholder}\n autoComplete={autoComplete}\n style={inputStyle}\n className={textField({\n className: inputClassName,\n placeholderHidden: !!label && !active,\n })}\n />\n {label && (\n <Label\n floating\n dense={dense}\n error={error}\n active={active}\n disabled={disabled}\n {...labelProps}\n htmlFor={id}\n style={labelProps?.style ?? labelStyle}\n className={labelProps?.className ?? labelClassName}\n >\n {label}\n </Label>\n )}\n </TextFieldContainer>\n </FormMessageContainer>\n );\n}\n"],"names":["useEnsuredId","FormMessageContainer","Label","TextFieldContainer","textField","TextField","props","ref","id","propId","style","className","type","label","labelProps","labelStyle","labelClassName","autoCompleteValue","autoComplete","name","dense","error","active","inline","leftAddon","leftAddonProps","rightAddon","rightAddonProps","disableLeftAddonStyles","disableRightAddonStyles","inputStyle","inputClassName","theme","underlineDirection","messageProps","messageContainerProps","containerProps","remaining","disabled","readOnly","placeholder","input","placeholderHidden","floating","htmlFor"],"mappings":";AASA,SAASA,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,SAAS,QAAQ,uBAAuB;AAoFjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,SAASC,UAAUC,KAAqB;IAC7C,MAAM,EACJC,GAAG,EACHC,IAAIC,MAAM,EACVC,KAAK,EACLC,SAAS,EACTC,OAAO,MAAM,EACbC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,eAAeD,iBAAiB,EAChCE,OAAOF,iBAAiB,EACxBG,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,eAAe,EACfC,sBAAsB,EACtBC,uBAAuB,EACvBC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,kBAAkB,EAClBC,YAAY,EACZC,qBAAqB,EACrBC,cAAc,EACd,GAAGC,WACJ,GAAG/B;IACJ,MAAM,EAAEgC,QAAQ,EAAEC,QAAQ,EAAE,GAAGjC;IAC/B,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,IAAI,EAAE+B,cAAc,EAAE,EAAE,GAAGlC;IAC3B,IAAIO,SAAS,CAAC2B,aAAa;QACzB,+DAA+D;QAC/DA,cAAc;IAChB;IAEA,qBACE,KAACvC;QACCsB,QAAQA;QACP,GAAGY,qBAAqB;QACzBD,cACEA,gBAAgB;YACdb;YACAW;YACA,GAAGE,YAAY;QACjB;kBAGF,cAAA,MAAC/B;YACE,GAAGiC,cAAc;YAClB1B,OAAOA;YACPC,WAAWA;YACXqB,OAAOA;YACPnB,OAAO,CAAC,CAACA;YACTQ,OAAOA;YACPD,OAAOA;YACPG,QAAQA;YACRD,QAAQA;YACRiB,UAAUA;YACVD,UAAUA;YACVd,WAAWA;YACXC,gBAAgBA;YAChBC,YAAYA;YACZC,iBAAiBA;YACjBM,oBAAoBA;YACpBL,wBAAwBA;YACxBC,yBAAyBA;;8BAEzB,KAACY;oBACE,GAAGJ,SAAS;oBACb7B,IAAIA;oBACJD,KAAKA;oBACLK,MAAMA;oBACNO,MAAMA;oBACNmB,UAAUA;oBACVE,aAAaA;oBACbtB,cAAcA;oBACdR,OAAOoB;oBACPnB,WAAWP,UAAU;wBACnBO,WAAWoB;wBACXW,mBAAmB,CAAC,CAAC7B,SAAS,CAACS;oBACjC;;gBAEDT,uBACC,KAACX;oBACCyC,QAAQ;oBACRvB,OAAOA;oBACPC,OAAOA;oBACPC,QAAQA;oBACRgB,UAAUA;oBACT,GAAGxB,UAAU;oBACd8B,SAASpC;oBACTE,OAAOI,YAAYJ,SAASK;oBAC5BJ,WAAWG,YAAYH,aAAaK;8BAEnCH;;;;;AAMb"}
@@ -1,6 +1,7 @@
1
+ import { type ReactElement } from "react";
1
2
  import { type TextFieldAddonProps } from "./types.js";
2
3
  /**
3
4
  * This component is used to add an icon before or after the text field with
4
5
  * correct styling.
5
6
  */
6
- export declare const TextFieldAddon: import("react").ForwardRefExoticComponent<TextFieldAddonProps & import("react").RefAttributes<HTMLSpanElement>>;
7
+ export declare function TextFieldAddon(props: TextFieldAddonProps): ReactElement | null;
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
2
  import { textFieldAddon } from "./textFieldAddonStyles.js";
4
3
  /**
5
4
  * This component is used to add an icon before or after the text field with
6
5
  * correct styling.
7
- */ export const TextFieldAddon = /*#__PURE__*/ forwardRef(function TextFieldAddon(props, ref) {
8
- const { after, disabled, pointerEvents, children, className, ...remaining } = props;
6
+ */ export function TextFieldAddon(props) {
7
+ const { ref, after, disabled, pointerEvents, children, className, ...remaining } = props;
9
8
  if (!children) {
10
9
  return null;
11
10
  }
@@ -24,6 +23,6 @@ import { textFieldAddon } from "./textFieldAddonStyles.js";
24
23
  }),
25
24
  children: children
26
25
  });
27
- });
26
+ }
28
27
 
29
28
  //# sourceMappingURL=TextFieldAddon.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/TextFieldAddon.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport { textFieldAddon } from \"./textFieldAddonStyles.js\";\nimport { type TextFieldAddonProps } from \"./types.js\";\n\n/**\n * This component is used to add an icon before or after the text field with\n * correct styling.\n */\nexport const TextFieldAddon = forwardRef<HTMLSpanElement, TextFieldAddonProps>(\n function TextFieldAddon(props, ref) {\n const {\n after,\n disabled,\n pointerEvents,\n children,\n className,\n ...remaining\n } = props;\n\n if (!children) {\n return null;\n }\n\n if (disabled) {\n return <>{children}</>;\n }\n\n return (\n <span\n {...remaining}\n ref={ref}\n className={textFieldAddon({\n after,\n presentational: !pointerEvents,\n className,\n })}\n >\n {children}\n </span>\n );\n }\n);\n"],"names":["forwardRef","textFieldAddon","TextFieldAddon","props","ref","after","disabled","pointerEvents","children","className","remaining","span","presentational"],"mappings":";AAAA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,cAAc,QAAQ,4BAA4B;AAG3D;;;CAGC,GACD,OAAO,MAAMC,+BAAiBF,WAC5B,SAASE,eAAeC,KAAK,EAAEC,GAAG;IAChC,MAAM,EACJC,KAAK,EACLC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACRC,SAAS,EACT,GAAGC,WACJ,GAAGP;IAEJ,IAAI,CAACK,UAAU;QACb,OAAO;IACT;IAEA,IAAIF,UAAU;QACZ,qBAAO;sBAAGE;;IACZ;IAEA,qBACE,KAACG;QACE,GAAGD,SAAS;QACbN,KAAKA;QACLK,WAAWR,eAAe;YACxBI;YACAO,gBAAgB,CAACL;YACjBE;QACF;kBAECD;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/form/TextFieldAddon.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\n\nimport { textFieldAddon } from \"./textFieldAddonStyles.js\";\nimport { type TextFieldAddonProps } from \"./types.js\";\n\n/**\n * This component is used to add an icon before or after the text field with\n * correct styling.\n */\nexport function TextFieldAddon(\n props: TextFieldAddonProps\n): ReactElement | null {\n const {\n ref,\n after,\n disabled,\n pointerEvents,\n children,\n className,\n ...remaining\n } = props;\n\n if (!children) {\n return null;\n }\n\n if (disabled) {\n return <>{children}</>;\n }\n\n return (\n <span\n {...remaining}\n ref={ref}\n className={textFieldAddon({\n after,\n presentational: !pointerEvents,\n className,\n })}\n >\n {children}\n </span>\n );\n}\n"],"names":["textFieldAddon","TextFieldAddon","props","ref","after","disabled","pointerEvents","children","className","remaining","span","presentational"],"mappings":";AAEA,SAASA,cAAc,QAAQ,4BAA4B;AAG3D;;;CAGC,GACD,OAAO,SAASC,eACdC,KAA0B;IAE1B,MAAM,EACJC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACRC,SAAS,EACT,GAAGC,WACJ,GAAGP;IAEJ,IAAI,CAACK,UAAU;QACb,OAAO;IACT;IAEA,IAAIF,UAAU;QACZ,qBAAO;sBAAGE;;IACZ;IAEA,qBACE,KAACG;QACE,GAAGD,SAAS;QACbN,KAAKA;QACLK,WAAWR,eAAe;YACxBI;YACAO,gBAAgB,CAACL;YACjBE;QACF;kBAECD;;AAGP"}
@@ -1,6 +1,7 @@
1
- import { type HTMLAttributes } from "react";
1
+ import { type HTMLAttributes, type ReactElement, type Ref } from "react";
2
2
  import { type TextFieldContainerOptions } from "./types.js";
3
3
  export interface TextFieldContainerProps extends HTMLAttributes<HTMLDivElement>, TextFieldContainerOptions {
4
+ ref?: Ref<HTMLDivElement>;
4
5
  /**
5
6
  * Set this to `true` if there is a floating label with the `TextField` or
6
7
  * `TextArea`.
@@ -18,4 +19,4 @@ export interface TextFieldContainerProps extends HTMLAttributes<HTMLDivElement>,
18
19
  *
19
20
  * @internal
20
21
  */
21
- export declare const TextFieldContainer: import("react").ForwardRefExoticComponent<TextFieldContainerProps & import("react").RefAttributes<HTMLDivElement>>;
22
+ export declare function TextFieldContainer(props: TextFieldContainerProps): ReactElement;
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
3
  import { TextFieldAddon } from "./TextFieldAddon.js";
5
4
  import { getFormConfig } from "./formConfig.js";
6
5
  import { textFieldContainer } from "./textFieldContainerStyles.js";
@@ -12,8 +11,8 @@ import { textFieldContainer } from "./textFieldContainerStyles.js";
12
11
  * `Select` theme styles.
13
12
  *
14
13
  * @internal
15
- */ export const TextFieldContainer = /*#__PURE__*/ forwardRef(function TextFieldContainer(props, ref) {
16
- const { children, className, dense, error, label, active, inline, readOnly, disabled, leftAddon, leftAddonProps, disableLeftAddonStyles, rightAddon, rightAddonProps, disableRightAddonStyles, theme: propTheme, underlineDirection: propUnderlineDirection, ...remaining } = props;
14
+ */ export function TextFieldContainer(props) {
15
+ const { ref, children, className, dense, error, label, active, inline, readOnly, disabled, leftAddon, leftAddonProps, disableLeftAddonStyles, rightAddon, rightAddonProps, disableRightAddonStyles, theme: propTheme, underlineDirection: propUnderlineDirection, ...remaining } = props;
17
16
  const theme = getFormConfig("theme", propTheme);
18
17
  const underlineDirection = getFormConfig("underlineDirection", propUnderlineDirection);
19
18
  return /*#__PURE__*/ _jsxs("div", {
@@ -48,6 +47,6 @@ import { textFieldContainer } from "./textFieldContainerStyles.js";
48
47
  })
49
48
  ]
50
49
  });
51
- });
50
+ }
52
51
 
53
52
  //# sourceMappingURL=TextFieldContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/TextFieldContainer.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { TextFieldAddon } from \"./TextFieldAddon.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { textFieldContainer } from \"./textFieldContainerStyles.js\";\nimport { type TextFieldContainerOptions } from \"./types.js\";\n\nexport interface TextFieldContainerProps\n extends HTMLAttributes<HTMLDivElement>, TextFieldContainerOptions {\n /**\n * Set this to `true` if there is a floating label with the `TextField` or\n * `TextArea`.\n *\n * @defaultValue `false`\n */\n label?: boolean;\n}\n\n/**\n * **Client Component**\n * This might be able to become a server component if I remove the useFormTheme hook\n *\n * This component is used to add the additional `TextField`, `TextArea`, and\n * `Select` theme styles.\n *\n * @internal\n */\nexport const TextFieldContainer = forwardRef<\n HTMLDivElement,\n TextFieldContainerProps\n>(function TextFieldContainer(props, ref) {\n const {\n children,\n className,\n dense,\n error,\n label,\n active,\n inline,\n readOnly,\n disabled,\n leftAddon,\n leftAddonProps,\n disableLeftAddonStyles,\n rightAddon,\n rightAddonProps,\n disableRightAddonStyles,\n theme: propTheme,\n underlineDirection: propUnderlineDirection,\n ...remaining\n } = props;\n const theme = getFormConfig(\"theme\", propTheme);\n const underlineDirection = getFormConfig(\n \"underlineDirection\",\n propUnderlineDirection\n );\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={textFieldContainer({\n theme,\n dense,\n error,\n label,\n inline,\n active,\n readOnly,\n disabled,\n className,\n leftAddon: !!leftAddon && !disableLeftAddonStyles,\n rightAddon: !!rightAddon && !disableRightAddonStyles,\n underlineDirection,\n })}\n >\n <TextFieldAddon {...leftAddonProps} disabled={disableLeftAddonStyles}>\n {leftAddon}\n </TextFieldAddon>\n {children}\n <TextFieldAddon\n {...rightAddonProps}\n disabled={disableRightAddonStyles}\n after\n >\n {rightAddon}\n </TextFieldAddon>\n </div>\n );\n});\n"],"names":["forwardRef","TextFieldAddon","getFormConfig","textFieldContainer","TextFieldContainer","props","ref","children","className","dense","error","label","active","inline","readOnly","disabled","leftAddon","leftAddonProps","disableLeftAddonStyles","rightAddon","rightAddonProps","disableRightAddonStyles","theme","propTheme","underlineDirection","propUnderlineDirection","remaining","div","after"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,kBAAkB,QAAQ,gCAAgC;AAcnE;;;;;;;;CAQC,GACD,OAAO,MAAMC,mCAAqBJ,WAGhC,SAASI,mBAAmBC,KAAK,EAAEC,GAAG;IACtC,MAAM,EACJC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,EACVC,eAAe,EACfC,uBAAuB,EACvBC,OAAOC,SAAS,EAChBC,oBAAoBC,sBAAsB,EAC1C,GAAGC,WACJ,GAAGrB;IACJ,MAAMiB,QAAQpB,cAAc,SAASqB;IACrC,MAAMC,qBAAqBtB,cACzB,sBACAuB;IAGF,qBACE,MAACE;QACE,GAAGD,SAAS;QACbpB,KAAKA;QACLE,WAAWL,mBAAmB;YAC5BmB;YACAb;YACAC;YACAC;YACAE;YACAD;YACAE;YACAC;YACAP;YACAQ,WAAW,CAAC,CAACA,aAAa,CAACE;YAC3BC,YAAY,CAAC,CAACA,cAAc,CAACE;YAC7BG;QACF;;0BAEA,KAACvB;gBAAgB,GAAGgB,cAAc;gBAAEF,UAAUG;0BAC3CF;;YAEFT;0BACD,KAACN;gBACE,GAAGmB,eAAe;gBACnBL,UAAUM;gBACVO,KAAK;0BAEJT;;;;AAIT,GAAG"}
1
+ {"version":3,"sources":["../../src/form/TextFieldContainer.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, type ReactElement, type Ref } from \"react\";\n\nimport { TextFieldAddon } from \"./TextFieldAddon.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { textFieldContainer } from \"./textFieldContainerStyles.js\";\nimport { type TextFieldContainerOptions } from \"./types.js\";\n\nexport interface TextFieldContainerProps\n extends HTMLAttributes<HTMLDivElement>, TextFieldContainerOptions {\n ref?: Ref<HTMLDivElement>;\n\n /**\n * Set this to `true` if there is a floating label with the `TextField` or\n * `TextArea`.\n *\n * @defaultValue `false`\n */\n label?: boolean;\n}\n\n/**\n * **Client Component**\n * This might be able to become a server component if I remove the useFormTheme hook\n *\n * This component is used to add the additional `TextField`, `TextArea`, and\n * `Select` theme styles.\n *\n * @internal\n */\nexport function TextFieldContainer(\n props: TextFieldContainerProps\n): ReactElement {\n const {\n ref,\n children,\n className,\n dense,\n error,\n label,\n active,\n inline,\n readOnly,\n disabled,\n leftAddon,\n leftAddonProps,\n disableLeftAddonStyles,\n rightAddon,\n rightAddonProps,\n disableRightAddonStyles,\n theme: propTheme,\n underlineDirection: propUnderlineDirection,\n ...remaining\n } = props;\n const theme = getFormConfig(\"theme\", propTheme);\n const underlineDirection = getFormConfig(\n \"underlineDirection\",\n propUnderlineDirection\n );\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={textFieldContainer({\n theme,\n dense,\n error,\n label,\n inline,\n active,\n readOnly,\n disabled,\n className,\n leftAddon: !!leftAddon && !disableLeftAddonStyles,\n rightAddon: !!rightAddon && !disableRightAddonStyles,\n underlineDirection,\n })}\n >\n <TextFieldAddon {...leftAddonProps} disabled={disableLeftAddonStyles}>\n {leftAddon}\n </TextFieldAddon>\n {children}\n <TextFieldAddon\n {...rightAddonProps}\n disabled={disableRightAddonStyles}\n after\n >\n {rightAddon}\n </TextFieldAddon>\n </div>\n );\n}\n"],"names":["TextFieldAddon","getFormConfig","textFieldContainer","TextFieldContainer","props","ref","children","className","dense","error","label","active","inline","readOnly","disabled","leftAddon","leftAddonProps","disableLeftAddonStyles","rightAddon","rightAddonProps","disableRightAddonStyles","theme","propTheme","underlineDirection","propUnderlineDirection","remaining","div","after"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,sBAAsB;AACrD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,kBAAkB,QAAQ,gCAAgC;AAgBnE;;;;;;;;CAQC,GACD,OAAO,SAASC,mBACdC,KAA8B;IAE9B,MAAM,EACJC,GAAG,EACHC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,EACVC,eAAe,EACfC,uBAAuB,EACvBC,OAAOC,SAAS,EAChBC,oBAAoBC,sBAAsB,EAC1C,GAAGC,WACJ,GAAGrB;IACJ,MAAMiB,QAAQpB,cAAc,SAASqB;IACrC,MAAMC,qBAAqBtB,cACzB,sBACAuB;IAGF,qBACE,MAACE;QACE,GAAGD,SAAS;QACbpB,KAAKA;QACLE,WAAWL,mBAAmB;YAC5BmB;YACAb;YACAC;YACAC;YACAE;YACAD;YACAE;YACAC;YACAP;YACAQ,WAAW,CAAC,CAACA,aAAa,CAACE;YAC3BC,YAAY,CAAC,CAACA,cAAc,CAACE;YAC7BG;QACF;;0BAEA,KAACvB;gBAAgB,GAAGgB,cAAc;gBAAEF,UAAUG;0BAC3CF;;YAEFT;0BACD,KAACN;gBACE,GAAGmB,eAAe;gBACnBL,UAAUM;gBACVO,KAAK;0BAEJT;;;;AAIT"}
@@ -19,7 +19,7 @@ export declare const getJumpValue: (options: JumpOptions) => number;
19
19
  * @internal
20
20
  */
21
21
  export type RequiredThumbProps = Pick<DraggableImplementation, "dragging" | keyof DraggableMouseEventHandlers<HTMLElement> | keyof DraggableTouchEventHandlers<HTMLElement>> & {
22
- ref: RefObject<HTMLSpanElement>;
22
+ ref: RefObject<HTMLSpanElement | null>;
23
23
  };
24
24
  /**
25
25
  * @since 6.0.0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/sliderUtils.ts"],"sourcesContent":["import { type RefObject } from \"react\";\n\nimport {\n type DraggableEventHandlers,\n type DraggableImplementation,\n type DraggableMouseEventHandlers,\n type DraggableTouchEventHandlers,\n} from \"../draggable/useDraggable.js\";\nimport { type MinMaxRange, type RenameKeysWithPrefix } from \"../types.js\";\nimport {\n type ClientPositionEvent,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface JumpOptions extends MinMaxRange {\n step: number;\n jump: number | undefined;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const getJumpValue = (options: JumpOptions): number => {\n const { min, max, step, jump } = options;\n\n const steps = getRangeSteps({ min, max, step });\n const value = jump ?? (steps / 10) * step;\n if (Number.isInteger(step)) {\n return Math.max(step, Math.ceil(value));\n }\n\n return value;\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type RequiredThumbProps = Pick<\n DraggableImplementation,\n | \"dragging\"\n | keyof DraggableMouseEventHandlers<HTMLElement>\n | keyof DraggableTouchEventHandlers<HTMLElement>\n> & { ref: RefObject<HTMLSpanElement> };\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type ClosestThumbEventHandlersOptions = RenameKeysWithPrefix<\n RequiredThumbProps,\n \"thumb1\"\n> &\n RenameKeysWithPrefix<RequiredThumbProps, \"thumb2\"> & {\n vertical: boolean;\n isRangeSlider: boolean;\n };\n\n/**\n * NOTE: I do not need the mousemove events for this one to work.\n *\n * @since 6.0.0\n * @internal\n */\nexport const getClosestThumbEventHandlers = (\n options: ClosestThumbEventHandlersOptions\n): DraggableEventHandlers<HTMLElement> => {\n const {\n thumb1Ref,\n thumb1Dragging,\n thumb1OnMouseUp,\n thumb1OnMouseDown,\n thumb1OnTouchStart,\n thumb1OnTouchMove,\n thumb2Ref,\n thumb2Dragging,\n thumb2OnMouseUp,\n thumb2OnMouseDown,\n thumb2OnTouchStart,\n thumb2OnTouchMove,\n isRangeSlider,\n vertical,\n } = options;\n\n if (!isRangeSlider) {\n return {\n onMouseDown: thumb1OnMouseDown,\n onMouseUp: thumb1OnMouseUp,\n onTouchStart: thumb1OnTouchStart,\n onTouchMove: thumb1OnTouchMove,\n };\n }\n\n const isThumbOneClosest = (event: ClientPositionEvent): boolean => {\n if (thumb2Dragging) {\n return false;\n }\n\n const thumb1 = thumb1Ref.current;\n const thumb2 = thumb2Ref.current;\n if (!thumb1Dragging && thumb1 && thumb2) {\n const clientPosition = getClientPosition({ event, vertical });\n const thumb1Rect = thumb1.getBoundingClientRect();\n const thumb2Rect = thumb2.getBoundingClientRect();\n const thumb1Position = vertical ? thumb1Rect.y : thumb1Rect.x;\n const thumb2Position = vertical ? thumb2Rect.y : thumb2Rect.x;\n\n return (\n Math.abs(clientPosition - thumb1Position) <=\n Math.abs(clientPosition - thumb2Position)\n );\n }\n\n return true;\n };\n\n return {\n onMouseDown(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnMouseDown(event);\n } else {\n thumb2OnMouseDown(event);\n }\n },\n onMouseUp(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnMouseUp(event);\n } else {\n thumb2OnMouseUp(event);\n }\n },\n onTouchStart(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnTouchStart(event);\n } else {\n thumb2OnTouchStart(event);\n }\n },\n onTouchMove(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnTouchMove(event);\n } else {\n thumb2OnTouchMove(event);\n }\n },\n };\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nfunction getThumbOffset(\n offset: number | undefined,\n fallback: number\n): string | undefined {\n if (typeof offset !== \"number\") {\n return;\n }\n\n // the `offset` will be NaN when there are no possible steps to take because\n // the first thumb is at the maximum value or the second thumb is at the\n // minimum value\n const value = Number.isNaN(offset) ? fallback : offset;\n return `${value * 100}%`;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ThumbOffsetsOptions extends MinMaxRange {\n thumb1Value: number;\n thumb1Dragging: boolean;\n thumb1DragPercentage: number;\n thumb2Value: number;\n thumb2Dragging: boolean;\n thumb2DragPercentage: number;\n isRangeSlider: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface ThumbOffsets {\n \"--rmd-slider-offset-1\"?: string;\n \"--rmd-slider-offset-2\"?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function getThumbOffsets(options: ThumbOffsetsOptions): ThumbOffsets {\n const {\n min,\n max,\n thumb1Value,\n thumb1Dragging,\n thumb1DragPercentage,\n thumb2Value,\n thumb2Dragging,\n thumb2DragPercentage,\n isRangeSlider,\n } = options;\n let thumb1Percentage = thumb1Dragging\n ? thumb1DragPercentage\n : getPercentage({ min, max, value: thumb1Value });\n\n let thumb2Percentage: number | undefined;\n if (isRangeSlider) {\n const percentage = getPercentage({ min, max, value: thumb2Value });\n\n thumb1Percentage = Math.min(thumb1Percentage, percentage);\n thumb2Percentage = thumb2Dragging\n ? Math.max(thumb1Percentage, thumb2DragPercentage)\n : percentage;\n }\n\n return {\n \"--rmd-slider-offset-1\": getThumbOffset(thumb1Percentage, 0),\n \"--rmd-slider-offset-2\": getThumbOffset(thumb2Percentage, 1),\n };\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface ThumbNames {\n thumb1Name?: string;\n thumb2Name?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function getSliderInputName(\n name: string | undefined,\n isRangeSlider: boolean\n): ThumbNames {\n let thumb1Name = name;\n let thumb2Name = name;\n if (name && isRangeSlider && !name.includes(\"[]\")) {\n thumb1Name = `min${name}`;\n thumb2Name = `max${name}`;\n }\n\n return { thumb1Name, thumb2Name };\n}\n"],"names":["getClientPosition","getPercentage","getRangeSteps","getJumpValue","options","min","max","step","jump","steps","value","Number","isInteger","Math","ceil","getClosestThumbEventHandlers","thumb1Ref","thumb1Dragging","thumb1OnMouseUp","thumb1OnMouseDown","thumb1OnTouchStart","thumb1OnTouchMove","thumb2Ref","thumb2Dragging","thumb2OnMouseUp","thumb2OnMouseDown","thumb2OnTouchStart","thumb2OnTouchMove","isRangeSlider","vertical","onMouseDown","onMouseUp","onTouchStart","onTouchMove","isThumbOneClosest","event","thumb1","current","thumb2","clientPosition","thumb1Rect","getBoundingClientRect","thumb2Rect","thumb1Position","y","x","thumb2Position","abs","getThumbOffset","offset","fallback","isNaN","getThumbOffsets","thumb1Value","thumb1DragPercentage","thumb2Value","thumb2DragPercentage","thumb1Percentage","thumb2Percentage","percentage","getSliderInputName","name","thumb1Name","thumb2Name","includes"],"mappings":"AASA,SAEEA,iBAAiB,QACZ,gCAAgC;AACvC,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,aAAa,QAAQ,4BAA4B;AAW1D;;;CAGC,GACD,OAAO,MAAMC,eAAe,CAACC;IAC3B,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGJ;IAEjC,MAAMK,QAAQP,cAAc;QAAEG;QAAKC;QAAKC;IAAK;IAC7C,MAAMG,QAAQF,QAAQ,AAACC,QAAQ,KAAMF;IACrC,IAAII,OAAOC,SAAS,CAACL,OAAO;QAC1B,OAAOM,KAAKP,GAAG,CAACC,MAAMM,KAAKC,IAAI,CAACJ;IAClC;IAEA,OAAOA;AACT,EAAE;AA0BF;;;;;CAKC,GACD,OAAO,MAAMK,+BAA+B,CAC1CX;IAEA,MAAM,EACJY,SAAS,EACTC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,SAAS,EACTC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,aAAa,EACbC,QAAQ,EACT,GAAGzB;IAEJ,IAAI,CAACwB,eAAe;QAClB,OAAO;YACLE,aAAaX;YACbY,WAAWb;YACXc,cAAcZ;YACda,aAAaZ;QACf;IACF;IAEA,MAAMa,oBAAoB,CAACC;QACzB,IAAIZ,gBAAgB;YAClB,OAAO;QACT;QAEA,MAAMa,SAASpB,UAAUqB,OAAO;QAChC,MAAMC,SAAShB,UAAUe,OAAO;QAChC,IAAI,CAACpB,kBAAkBmB,UAAUE,QAAQ;YACvC,MAAMC,iBAAiBvC,kBAAkB;gBAAEmC;gBAAON;YAAS;YAC3D,MAAMW,aAAaJ,OAAOK,qBAAqB;YAC/C,MAAMC,aAAaJ,OAAOG,qBAAqB;YAC/C,MAAME,iBAAiBd,WAAWW,WAAWI,CAAC,GAAGJ,WAAWK,CAAC;YAC7D,MAAMC,iBAAiBjB,WAAWa,WAAWE,CAAC,GAAGF,WAAWG,CAAC;YAE7D,OACEhC,KAAKkC,GAAG,CAACR,iBAAiBI,mBAC1B9B,KAAKkC,GAAG,CAACR,iBAAiBO;QAE9B;QAEA,OAAO;IACT;IAEA,OAAO;QACLhB,aAAYK,KAAK;YACf,IAAID,kBAAkBC,QAAQ;gBAC5BhB,kBAAkBgB;YACpB,OAAO;gBACLV,kBAAkBU;YACpB;QACF;QACAJ,WAAUI,KAAK;YACb,IAAID,kBAAkBC,QAAQ;gBAC5BjB,gBAAgBiB;YAClB,OAAO;gBACLX,gBAAgBW;YAClB;QACF;QACAH,cAAaG,KAAK;YAChB,IAAID,kBAAkBC,QAAQ;gBAC5Bf,mBAAmBe;YACrB,OAAO;gBACLT,mBAAmBS;YACrB;QACF;QACAF,aAAYE,KAAK;YACf,IAAID,kBAAkBC,QAAQ;gBAC5Bd,kBAAkBc;YACpB,OAAO;gBACLR,kBAAkBQ;YACpB;QACF;IACF;AACF,EAAE;AAEF;;;CAGC,GACD,SAASa,eACPC,MAA0B,EAC1BC,QAAgB;IAEhB,IAAI,OAAOD,WAAW,UAAU;QAC9B;IACF;IAEA,4EAA4E;IAC5E,wEAAwE;IACxE,gBAAgB;IAChB,MAAMvC,QAAQC,OAAOwC,KAAK,CAACF,UAAUC,WAAWD;IAChD,OAAO,GAAGvC,QAAQ,IAAI,CAAC,CAAC;AAC1B;AAyBA;;;CAGC,GACD,OAAO,SAAS0C,gBAAgBhD,OAA4B;IAC1D,MAAM,EACJC,GAAG,EACHC,GAAG,EACH+C,WAAW,EACXpC,cAAc,EACdqC,oBAAoB,EACpBC,WAAW,EACXhC,cAAc,EACdiC,oBAAoB,EACpB5B,aAAa,EACd,GAAGxB;IACJ,IAAIqD,mBAAmBxC,iBACnBqC,uBACArD,cAAc;QAAEI;QAAKC;QAAKI,OAAO2C;IAAY;IAEjD,IAAIK;IACJ,IAAI9B,eAAe;QACjB,MAAM+B,aAAa1D,cAAc;YAAEI;YAAKC;YAAKI,OAAO6C;QAAY;QAEhEE,mBAAmB5C,KAAKR,GAAG,CAACoD,kBAAkBE;QAC9CD,mBAAmBnC,iBACfV,KAAKP,GAAG,CAACmD,kBAAkBD,wBAC3BG;IACN;IAEA,OAAO;QACL,yBAAyBX,eAAeS,kBAAkB;QAC1D,yBAAyBT,eAAeU,kBAAkB;IAC5D;AACF;AAWA;;;CAGC,GACD,OAAO,SAASE,mBACdC,IAAwB,EACxBjC,aAAsB;IAEtB,IAAIkC,aAAaD;IACjB,IAAIE,aAAaF;IACjB,IAAIA,QAAQjC,iBAAiB,CAACiC,KAAKG,QAAQ,CAAC,OAAO;QACjDF,aAAa,CAAC,GAAG,EAAED,MAAM;QACzBE,aAAa,CAAC,GAAG,EAAEF,MAAM;IAC3B;IAEA,OAAO;QAAEC;QAAYC;IAAW;AAClC"}
1
+ {"version":3,"sources":["../../src/form/sliderUtils.ts"],"sourcesContent":["import { type RefObject } from \"react\";\n\nimport {\n type DraggableEventHandlers,\n type DraggableImplementation,\n type DraggableMouseEventHandlers,\n type DraggableTouchEventHandlers,\n} from \"../draggable/useDraggable.js\";\nimport { type MinMaxRange, type RenameKeysWithPrefix } from \"../types.js\";\nimport {\n type ClientPositionEvent,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface JumpOptions extends MinMaxRange {\n step: number;\n jump: number | undefined;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const getJumpValue = (options: JumpOptions): number => {\n const { min, max, step, jump } = options;\n\n const steps = getRangeSteps({ min, max, step });\n const value = jump ?? (steps / 10) * step;\n if (Number.isInteger(step)) {\n return Math.max(step, Math.ceil(value));\n }\n\n return value;\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type RequiredThumbProps = Pick<\n DraggableImplementation,\n | \"dragging\"\n | keyof DraggableMouseEventHandlers<HTMLElement>\n | keyof DraggableTouchEventHandlers<HTMLElement>\n> & { ref: RefObject<HTMLSpanElement | null> };\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type ClosestThumbEventHandlersOptions = RenameKeysWithPrefix<\n RequiredThumbProps,\n \"thumb1\"\n> &\n RenameKeysWithPrefix<RequiredThumbProps, \"thumb2\"> & {\n vertical: boolean;\n isRangeSlider: boolean;\n };\n\n/**\n * NOTE: I do not need the mousemove events for this one to work.\n *\n * @since 6.0.0\n * @internal\n */\nexport const getClosestThumbEventHandlers = (\n options: ClosestThumbEventHandlersOptions\n): DraggableEventHandlers<HTMLElement> => {\n const {\n thumb1Ref,\n thumb1Dragging,\n thumb1OnMouseUp,\n thumb1OnMouseDown,\n thumb1OnTouchStart,\n thumb1OnTouchMove,\n thumb2Ref,\n thumb2Dragging,\n thumb2OnMouseUp,\n thumb2OnMouseDown,\n thumb2OnTouchStart,\n thumb2OnTouchMove,\n isRangeSlider,\n vertical,\n } = options;\n\n if (!isRangeSlider) {\n return {\n onMouseDown: thumb1OnMouseDown,\n onMouseUp: thumb1OnMouseUp,\n onTouchStart: thumb1OnTouchStart,\n onTouchMove: thumb1OnTouchMove,\n };\n }\n\n const isThumbOneClosest = (event: ClientPositionEvent): boolean => {\n if (thumb2Dragging) {\n return false;\n }\n\n const thumb1 = thumb1Ref.current;\n const thumb2 = thumb2Ref.current;\n if (!thumb1Dragging && thumb1 && thumb2) {\n const clientPosition = getClientPosition({ event, vertical });\n const thumb1Rect = thumb1.getBoundingClientRect();\n const thumb2Rect = thumb2.getBoundingClientRect();\n const thumb1Position = vertical ? thumb1Rect.y : thumb1Rect.x;\n const thumb2Position = vertical ? thumb2Rect.y : thumb2Rect.x;\n\n return (\n Math.abs(clientPosition - thumb1Position) <=\n Math.abs(clientPosition - thumb2Position)\n );\n }\n\n return true;\n };\n\n return {\n onMouseDown(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnMouseDown(event);\n } else {\n thumb2OnMouseDown(event);\n }\n },\n onMouseUp(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnMouseUp(event);\n } else {\n thumb2OnMouseUp(event);\n }\n },\n onTouchStart(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnTouchStart(event);\n } else {\n thumb2OnTouchStart(event);\n }\n },\n onTouchMove(event) {\n if (isThumbOneClosest(event)) {\n thumb1OnTouchMove(event);\n } else {\n thumb2OnTouchMove(event);\n }\n },\n };\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nfunction getThumbOffset(\n offset: number | undefined,\n fallback: number\n): string | undefined {\n if (typeof offset !== \"number\") {\n return;\n }\n\n // the `offset` will be NaN when there are no possible steps to take because\n // the first thumb is at the maximum value or the second thumb is at the\n // minimum value\n const value = Number.isNaN(offset) ? fallback : offset;\n return `${value * 100}%`;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ThumbOffsetsOptions extends MinMaxRange {\n thumb1Value: number;\n thumb1Dragging: boolean;\n thumb1DragPercentage: number;\n thumb2Value: number;\n thumb2Dragging: boolean;\n thumb2DragPercentage: number;\n isRangeSlider: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface ThumbOffsets {\n \"--rmd-slider-offset-1\"?: string;\n \"--rmd-slider-offset-2\"?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function getThumbOffsets(options: ThumbOffsetsOptions): ThumbOffsets {\n const {\n min,\n max,\n thumb1Value,\n thumb1Dragging,\n thumb1DragPercentage,\n thumb2Value,\n thumb2Dragging,\n thumb2DragPercentage,\n isRangeSlider,\n } = options;\n let thumb1Percentage = thumb1Dragging\n ? thumb1DragPercentage\n : getPercentage({ min, max, value: thumb1Value });\n\n let thumb2Percentage: number | undefined;\n if (isRangeSlider) {\n const percentage = getPercentage({ min, max, value: thumb2Value });\n\n thumb1Percentage = Math.min(thumb1Percentage, percentage);\n thumb2Percentage = thumb2Dragging\n ? Math.max(thumb1Percentage, thumb2DragPercentage)\n : percentage;\n }\n\n return {\n \"--rmd-slider-offset-1\": getThumbOffset(thumb1Percentage, 0),\n \"--rmd-slider-offset-2\": getThumbOffset(thumb2Percentage, 1),\n };\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface ThumbNames {\n thumb1Name?: string;\n thumb2Name?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function getSliderInputName(\n name: string | undefined,\n isRangeSlider: boolean\n): ThumbNames {\n let thumb1Name = name;\n let thumb2Name = name;\n if (name && isRangeSlider && !name.includes(\"[]\")) {\n thumb1Name = `min${name}`;\n thumb2Name = `max${name}`;\n }\n\n return { thumb1Name, thumb2Name };\n}\n"],"names":["getClientPosition","getPercentage","getRangeSteps","getJumpValue","options","min","max","step","jump","steps","value","Number","isInteger","Math","ceil","getClosestThumbEventHandlers","thumb1Ref","thumb1Dragging","thumb1OnMouseUp","thumb1OnMouseDown","thumb1OnTouchStart","thumb1OnTouchMove","thumb2Ref","thumb2Dragging","thumb2OnMouseUp","thumb2OnMouseDown","thumb2OnTouchStart","thumb2OnTouchMove","isRangeSlider","vertical","onMouseDown","onMouseUp","onTouchStart","onTouchMove","isThumbOneClosest","event","thumb1","current","thumb2","clientPosition","thumb1Rect","getBoundingClientRect","thumb2Rect","thumb1Position","y","x","thumb2Position","abs","getThumbOffset","offset","fallback","isNaN","getThumbOffsets","thumb1Value","thumb1DragPercentage","thumb2Value","thumb2DragPercentage","thumb1Percentage","thumb2Percentage","percentage","getSliderInputName","name","thumb1Name","thumb2Name","includes"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type HTMLAttributes, type InputHTMLAttributes, type LabelHTMLAttributes, type ReactNode } from "react";
1
+ import { type CSSProperties, type HTMLAttributes, type InputHTMLAttributes, type LabelHTMLAttributes, type ReactNode, type Ref } from "react";
2
2
  import { type PropsWithRef } from "../types.js";
3
3
  declare module "react" {
4
4
  interface CSSProperties {
@@ -188,7 +188,11 @@ export interface FormMessageClassNameOptions {
188
188
  */
189
189
  theme?: FormTheme;
190
190
  }
191
- export interface FormMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, "minLength" | "maxLength">, FormMessageClassNameOptions {
191
+ /**
192
+ * @since 7.0.0 Renamed from `FormMessageProps` to `ConfigurableFormMessageProps`
193
+ */
194
+ export interface ConfigurableFormMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, "minLength" | "maxLength">, FormMessageClassNameOptions {
195
+ ref?: Ref<HTMLDivElement>;
192
196
  /**
193
197
  * If this component is acting as a form-level error message handler, the role
194
198
  * should be updated to be `"alert"` for additional accessibility.
@@ -280,12 +284,12 @@ export interface FormMessageInputLengthCounterProps {
280
284
  */
281
285
  counterClassName?: string;
282
286
  }
283
- export interface FormMessageWithCounterProps extends FormMessageProps, FormMessageInputLengthCounterProps {
287
+ export interface FormMessageWithCounterProps extends ConfigurableFormMessageProps, FormMessageInputLengthCounterProps {
284
288
  }
285
289
  /**
286
290
  * @since 6.0.0
287
291
  */
288
- export interface FormMessageWithoutCounterProps extends FormMessageProps {
292
+ export interface FormMessageWithoutCounterProps extends ConfigurableFormMessageProps {
289
293
  length?: never;
290
294
  maxLength?: never;
291
295
  counterStyle?: never;
@@ -297,7 +301,7 @@ export interface FormMessageContainerExtension {
297
301
  * component, these props are optional. It kind of eliminates the whole
298
302
  * purpose of this component though.
299
303
  */
300
- messageProps?: PropsWithRef<FormMessageProps & Partial<FormMessageInputLengthCounterProps>>;
304
+ messageProps?: PropsWithRef<ConfigurableFormMessageProps & Partial<FormMessageInputLengthCounterProps>>;
301
305
  /**
302
306
  * Any props (and an optional ref) to provide to the `<div>` surrounding the
303
307
  * children and `FormMessage` component.
@@ -381,6 +385,7 @@ export interface LabelClassNameOptions {
381
385
  inactive?: boolean;
382
386
  }
383
387
  export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement>, LabelClassNameOptions {
388
+ ref?: Ref<HTMLLabelElement>;
384
389
  }
385
390
  /**
386
391
  * @since 6.0.0
@@ -398,6 +403,7 @@ export interface ConfigurableTextFieldAddonProps extends HTMLAttributes<HTMLSpan
398
403
  * @since 6.0.0 Split props into `ConfigurableTextFieldAddonProps`
399
404
  */
400
405
  export interface TextFieldAddonProps extends ConfigurableTextFieldAddonProps {
406
+ ref?: Ref<HTMLSpanElement>;
401
407
  /**
402
408
  * @defaultValue `false`
403
409
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/types.ts"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-form-active-color\"?: string;\n \"--rmd-form-focus-color\"?: string;\n\n // NOTE: The label properties are in this file since all label types are\n // in this file. If they are able to be moved to labelStyles or Label and\n // the compiled `.d.ts` includes the types from those files, this can be\n // moved.\n \"--rmd-label-floating-x\"?: string | number;\n \"--rmd-label-floating-y\"?: string | number;\n \"--rmd-label-floating-active-x\"?: string | number;\n \"--rmd-label-floating-active-y\"?: string | number;\n \"--rmd-label-active-padding\"?: string | number;\n \"--rmd-label-active-background-color\"?: string;\n\n // NOTE: The text field properties are in this file since there are no\n // typedefs included from `TextFieldContainer` or\n // `textFieldContainerStyles`.\n \"--rmd-text-field-addon-top\"?: string | number;\n \"--rmd-text-field-addon-spacing\"?: string | number;\n \"--rmd-text-field-addon-margin-top\"?: string | number;\n \"--rmd-text-field-addon-left-offset\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-base-height\"?: string | number;\n \"--rmd-text-field-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-dense-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-label-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-dense-label-height\"?: string | number;\n \"--rmd-text-field-padding-left\"?: string | number;\n \"--rmd-text-field-padding-right\"?: string | number;\n \"--rmd-text-field-padding-top\"?: string | number;\n \"--rmd-text-field-border-color\"?: string;\n /** @since 6.4.0 */\n \"--rmd-text-field-border-radius\"?: string | number;\n \"--rmd-text-field-hover-border-color\"?: string;\n \"--rmd-text-field-filled-color\"?: string;\n \"--rmd-text-field-filled-padding\"?: string | number;\n \"--rmd-text-field-outlined-padding\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-outlined-border-radius\"?: string | number;\n \"--rmd-text-field-underlined-padding\"?: string | number;\n }\n}\n\n/**\n * The supported themes for the `TextField`, `TextArea`, and `Select`\n * components.\n *\n * - \"none\" - display as an unstyled text field without any border or background\n * colors.\n * - \"underline\" - display with only an underline that gains the form active\n * color and animates from the left or right to the other side when the field\n * is focused.\n * - \"filled\" - an extension of the `\"underline\"` state that will also have a\n * slightly dark background applied.\n * - \"outline\" - outlines the entire text field in a border and applies the\n * active color as box shadow when the field is focused.\n */\nexport type FormTheme = \"none\" | \"underline\" | \"filled\" | \"outline\";\n\n/**\n * The direction that the underline should appear from when the theme is\n * `\"underline\"` or `\"filled\"`.\n */\nexport type FormUnderlineDirection = \"left\" | \"center\" | \"right\";\n\nexport interface FormThemeOptions {\n /**\n * The current theme type.\n *\n * @defaultValue `\"outline\"`\n */\n theme?: FormTheme;\n\n /**\n * The current underline direction.\n *\n * @defaultValue `\"left\"`\n */\n underlineDirection?: FormUnderlineDirection;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FormConfiguration extends Required<FormThemeOptions> {\n /**\n * Set this to `false` if the `$disable-uncontrolled-input-toggles` variable\n * is set to `true` in the Sass configuration.\n *\n * Since the `checked` state only changes for the radio that has been clicked,\n * the previously checked radio would also be shown as checked with no way of\n * fixing it without controlling the radio component. When this flag is\n * enabled, the checked icons and state are handled through css instead of\n * `useState`.\n *\n * @defaultValue `true`\n */\n uncontrolledToggles: boolean;\n}\n\n/**\n * @since 6.4.0\n */\nexport interface InteractableFormComponentStates {\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /** @defaultValue `false` */\n readOnly?: boolean;\n}\n\n/**\n * @since 6.4.0\n */\nexport interface EditableFormComponentStates extends InteractableFormComponentStates {\n /** @defaultValue `false` */\n error?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FormComponentStates extends EditableFormComponentStates {\n /** @defaultValue `false` */\n active?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @see https://html.spec.whatwg.org/multipage/forms.html#autofill\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values\n */\nexport type AutocompleteAttributeValue =\n | \"off\"\n | \"on\"\n | \"name\"\n | \"honorific-prefix\"\n | \"given-name\"\n | \"additional-name\"\n | \"family-name\"\n | \"honorific-suffix\"\n | \"nickname\"\n | \"email\"\n | \"username\"\n | \"new-password\"\n | \"current-password\"\n | \"one-time-code\"\n | \"organization-title\"\n | \"organization\"\n | \"street-address\"\n | \"address-line1\"\n | \"address-line2\"\n | \"address-line3\"\n | \"address-level1\"\n | \"address-level2\"\n | \"address-level3\"\n | \"address-level4\"\n | \"country\"\n | \"country-name\"\n | \"postal-code\"\n | \"cc-name\"\n | \"cc-given-name\"\n | \"cc-additional-name\"\n | \"cc-family-name\"\n | \"cc-number\"\n | \"cc-exp\"\n | \"cc-exp-month\"\n | \"cc-exp-year\"\n | \"cc-csc\"\n | \"cc-type\"\n | \"transaction-currency\"\n | \"transaction-amount\"\n | \"language\"\n | \"bday\"\n | \"bday-day\"\n | \"bday-month\"\n | \"bday-year\"\n | \"sex\"\n | \"tel\"\n | \"tel-country-code\"\n | \"tel-national\"\n | \"tek-area-code\"\n | \"tel-local\"\n | \"tel-extension\"\n | \"impp\"\n | \"url\"\n | \"photo\";\n\n/**\n * @since 6.0.0\n */\nexport interface UserAgentAutocompleteProps {\n /**\n * Set this to enable additional autocompletion suggestions for a user for\n * different form fields. Using this prop will update the\n * {@link UserAgentAutocompleteProps.name} and {@link autoComplete} to default to\n * this value.\n *\n * @example\n * ```tsx\n * <Form>\n * <TextField\n * label=\"Enter your credit card number\"\n * autoCompleteValue=\"cc-number\"\n * {...creditCardProps}\n * inputMode=\"number\"\n * />\n * <TextField\n * label=\"Name on card\"\n * autoCompleteValue=\"cc-name\"\n * {...creditCardNameProps}\n * />\n * <TextField\n * label=\"Security code\"\n * autoCompleteValue=\"cc-csc\"\n * {...securityCodeProps}\n * inputMode=\"number\"\n * />\n * <Button type=\"submit\">Submit</Button>\n * </Form>\n * ```\n *\n * @see https://html.spec.whatwg.org/multipage/forms.html#autofill\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values\n * @see {@link AutocompleteAttributeValue}\n * @see {@link autoComplete}\n * @see {@link UserAgentAutocompleteProps.name}\n */\n autoCompleteValue?: AutocompleteAttributeValue;\n\n /**\n * @see {@link autoCompleteValue}\n * @defaultValue `autoCompleteValue`\n */\n autoComplete?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n\n /**\n * @see {@link autoCompleteValue}\n * @defaultValue `autoCompleteValue`\n */\n name?: string;\n}\n\nexport interface FormMessageClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the message should gain the error state which changes the text\n * color to `red` by default.\n *\n * @defaultValue `false`\n */\n error?: boolean;\n\n /**\n * The current theme for the related text field. This is really only used to\n * match the current horizontal padding of the text field.\n *\n * @defaultValue `\"outline\"`\n */\n theme?: FormTheme;\n}\n\nexport interface FormMessageProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, \"minLength\" | \"maxLength\">,\n FormMessageClassNameOptions {\n /**\n * If this component is acting as a form-level error message handler, the role\n * should be updated to be `\"alert\"` for additional accessibility.\n *\n * Note: when creating a form-level error message handler, the messages should\n * no longer appear as the user types and instead once the user tries to\n * submit the form. Having an alert role disrupts normal screen reader\n * behavior by immediately reading changes in this element.\n *\n * @defaultValue `undefined`\n */\n role?: \"alert\";\n\n /**\n * Boolean if the children should no longer be wrapped in a `<p>` tag. This\n * should normally only be disabled if using a custom error message wrapper or\n * the counter behavior is not being used. To get correct alignments of the\n * message and counter, the `children` must be wrapped in some element and\n * cannot be plain test.\n *\n * Note: this will always be considered `true` if the `role` is set to\n * `\"alert\"`.\n *\n * @defaultValue `false`\n */\n disableWrap?: boolean;\n\n /**\n * Optional props to provide to inline counter.\n *\n * @since 6.3.0\n */\n counterProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Optional props to apply to the `<p>` tag that surrounds the `children`.\n * This will not be used if `role=\"alert\"` or `disableWrap={true}`.\n *\n * @since 6.3.0\n */\n messageProps?: PropsWithRef<HTMLAttributes<HTMLParagraphElement>>;\n\n /**\n * An optional style to apply to the `<p>` tag that surrounds the `children`.\n * This will not be used if `role=\"alert\"` or `disableWrap={true}`.\n */\n messageStyle?: CSSProperties;\n\n /**\n * An optional className to apply to the `<p>` tag that surrounds the\n * `children`. This will not be used if `role=\"alert\"` or\n * `disableWrap={true}`.\n */\n messageClassName?: string;\n}\n\n/**\n * Props that are used to automatically add a counter for the remaining letters\n * available for the text field. The counter will always be created to the right\n * of the optional message.\n *\n * The counter is really a simple string of: `${length} / ${maxLength}`.\n *\n * If you need additional customization, it is recommended to create your own\n * implementation such as:\n *\n * ```tsx\n * <FormMessage>\n * {errorMessage}\n * <MyCounter {...props} />\n * </FormMessage>\n * ```\n *\n * Note: this should not be used alongside form-level messages.\n *\n * @since 2.9.0 Renamed from `FormMessageCounterProps` to\n * `FormMessageInputLengthCounterProps` since a `FormMessageCounter` component\n * was added\n */\nexport interface FormMessageInputLengthCounterProps {\n /**\n * The current length of the value in the related text field.\n */\n length: number;\n\n /**\n * The max length allowed for the value in the related text field.\n */\n maxLength: number;\n\n /**\n * An optional style to apply to the counter wrapper element.\n */\n counterStyle?: CSSProperties;\n\n /**\n * An optional className to apply to the counter wrapper element.\n */\n counterClassName?: string;\n}\n\nexport interface FormMessageWithCounterProps\n extends FormMessageProps, FormMessageInputLengthCounterProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface FormMessageWithoutCounterProps extends FormMessageProps {\n length?: never;\n maxLength?: never;\n counterStyle?: never;\n counterClassName?: never;\n}\n\nexport interface FormMessageContainerExtension {\n /**\n * If the extension doesn't actually want to render the `FormMessage`\n * component, these props are optional. It kind of eliminates the whole\n * purpose of this component though.\n */\n messageProps?: PropsWithRef<\n FormMessageProps & Partial<FormMessageInputLengthCounterProps>\n >;\n\n /**\n * Any props (and an optional ref) to provide to the `<div>` surrounding the\n * children and `FormMessage` component.\n *\n * Note: This will not be used if the `messageProps` are not provided since\n * only the `children` will be returned without the container.\n */\n messageContainerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n}\n\n/** @since 6.0.0 */\nexport interface LabelClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` to remove the `gap` style from the label.\n *\n * @see `$label-gap`\n * @defaultValue `false`\n */\n gap?: boolean;\n\n /**\n * Set this to `true` when the parent `TextFieldContainer` has the `dense`\n * spec enabled. This updates the floating styles to match the smaller height.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * Set this to `true` to update the label's color to the error color.\n *\n * @see `$error-color`\n * @defaultValue `false`\n */\n error?: boolean;\n\n /**\n * Set this to `true` to update the label's color to the active color.\n *\n * @see `$active-color`\n * @defaultValue `false`\n */\n active?: boolean;\n\n /**\n * Set this to `true` if the label should gain `flex-direction: column`\n * styling.\n *\n * @defaultValue `false`\n */\n stacked?: boolean;\n\n /**\n * Set this to `true` to update the label's color to be the disabled color.\n *\n * @see `$disabled-color`\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to true when label can floating above an input, textarea, or\n * select inside of a `TextFieldContainer`.\n *\n * @defaultValue `false`\n */\n floating?: boolean;\n\n /**\n * Set this to true when label is currently floating above an input,\n * textarea, or selected inside of a `TextFieldContainer`.\n *\n * @see {@link active}\n * @defaultValue `active`\n */\n floatingActive?: boolean;\n\n /**\n * Set this to `true` to gain `flex-direction: row-reversed` styling. If the\n * {@link stacked} prop is also `true`, `flex-direction: column-reversed` will\n * be applied.\n *\n * @defaultValue `false`\n */\n reversed?: boolean;\n\n /**\n * @defaultValue `false`\n */\n inactive?: boolean;\n}\n\nexport interface LabelProps\n extends LabelHTMLAttributes<HTMLLabelElement>, LabelClassNameOptions {}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableTextFieldAddonProps extends HTMLAttributes<HTMLSpanElement> {\n /**\n * Boolean if the addon should be presentational only and prevent pointer\n * events.\n *\n * @defaultValue `false`\n */\n pointerEvents?: boolean;\n}\n\n/**\n * @since 6.0.0 Split props into `ConfigurableTextFieldAddonProps`\n */\nexport interface TextFieldAddonProps extends ConfigurableTextFieldAddonProps {\n /**\n * @defaultValue `false`\n */\n after?: boolean;\n\n /**\n * Set this to `true` if the addon should not be wrapped in a `<span>` with some\n * additional styles.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n}\n\n/**\n * @since 6.0.0 Renamed the `leftChildren` / `rightChildren` props to\n * `leftAddon` / `rightAddon`. Renamed `isLeftAddon` / `isRightAddon` to\n * `disableLeftAddonStyles` / `disableRightAddonStyles`. Added\n * `leftAddonProps` / `rightAddonProps`. Removed `stretch`\n */\nexport interface TextFieldContainerOptions\n extends FormThemeOptions, FormComponentStates {\n /**\n * Set this to `true` to enable the dense spec which reduces the height.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * Set this to `true` to change the style from `display: flex` to\n * `display: inline-flex`.\n *\n * @defaultValue `false`\n */\n inline?: boolean;\n\n /**\n * This should generally be an icon or a button that will be placed before the\n * `TextField` or `TextArea`.\n */\n leftAddon?: ReactNode;\n\n /**\n * Any additional props to pass to the `<span>` surrounding the {@link leftAddon}.\n *\n * @since 6.0.0\n */\n leftAddonProps?: PropsWithRef<ConfigurableTextFieldAddonProps>;\n\n /**\n * @see {@link TextFieldAddonProps.disabled}\n *\n * @defaultValue `false`\n */\n disableLeftAddonStyles?: boolean;\n\n /**\n * This should generally be an icon or a button that will be placed after the\n * `TextField` or `TextArea`.\n */\n rightAddon?: ReactNode;\n\n /**\n * Any additional props to pass to the `<span>` surrounding the {@link rightAddon}.\n *\n * @since 6.0.0\n */\n rightAddonProps?: PropsWithRef<ConfigurableTextFieldAddonProps>;\n\n /**\n * @see {@link TextFieldAddonProps.disabled}\n *\n * @defaultValue `false`\n */\n disableRightAddonStyles?: boolean;\n}\n\nexport interface FormFieldOptions\n extends TextFieldContainerOptions, FormMessageContainerExtension {\n /**\n * An optional floating label to use with the text field. A label is generally\n * recommended for accessibility, but can be omitted if an `aria-label` or\n * `aria-labelledby` is provided.\n */\n label?: ReactNode;\n\n /**\n * Any additional props and/or ref that should be passed to the `<label>`\n * element when a {@link label} is provided.\n *\n * @example\n * ```tsx\n * labelProps={{\n * ref: labelRef,\n * style: {},\n * className: \"some-custom-class-name\",\n * onClick: (event) => {\n * // do something\n * }\n * }}\n * ```\n */\n labelProps?: PropsWithRef<LabelProps>;\n\n /**\n * A convenience prop to apply a custom style to a label. This is equivalent\n * to:\n *\n * ```ts\n * labelProps={{\n * style: // some style here\n * }}\n * ```\n */\n labelStyle?: CSSProperties;\n\n /**\n * A convenience prop to apply a custom className to a label. This is\n * equivalent to:\n *\n * ```ts\n * labelProps={{\n * className: \"some-class-name\",\n * }}\n * ```\n */\n labelClassName?: string;\n}\n"],"names":[],"mappings":"AAslBA,WAkDC"}
1
+ {"version":3,"sources":["../../src/form/types.ts"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-form-active-color\"?: string;\n \"--rmd-form-focus-color\"?: string;\n\n // NOTE: The label properties are in this file since all label types are\n // in this file. If they are able to be moved to labelStyles or Label and\n // the compiled `.d.ts` includes the types from those files, this can be\n // moved.\n \"--rmd-label-floating-x\"?: string | number;\n \"--rmd-label-floating-y\"?: string | number;\n \"--rmd-label-floating-active-x\"?: string | number;\n \"--rmd-label-floating-active-y\"?: string | number;\n \"--rmd-label-active-padding\"?: string | number;\n \"--rmd-label-active-background-color\"?: string;\n\n // NOTE: The text field properties are in this file since there are no\n // typedefs included from `TextFieldContainer` or\n // `textFieldContainerStyles`.\n \"--rmd-text-field-addon-top\"?: string | number;\n \"--rmd-text-field-addon-spacing\"?: string | number;\n \"--rmd-text-field-addon-margin-top\"?: string | number;\n \"--rmd-text-field-addon-left-offset\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-base-height\"?: string | number;\n \"--rmd-text-field-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-dense-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-label-height\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-dense-label-height\"?: string | number;\n \"--rmd-text-field-padding-left\"?: string | number;\n \"--rmd-text-field-padding-right\"?: string | number;\n \"--rmd-text-field-padding-top\"?: string | number;\n \"--rmd-text-field-border-color\"?: string;\n /** @since 6.4.0 */\n \"--rmd-text-field-border-radius\"?: string | number;\n \"--rmd-text-field-hover-border-color\"?: string;\n \"--rmd-text-field-filled-color\"?: string;\n \"--rmd-text-field-filled-padding\"?: string | number;\n \"--rmd-text-field-outlined-padding\"?: string | number;\n /** @since 6.4.0 */\n \"--rmd-text-field-outlined-border-radius\"?: string | number;\n \"--rmd-text-field-underlined-padding\"?: string | number;\n }\n}\n\n/**\n * The supported themes for the `TextField`, `TextArea`, and `Select`\n * components.\n *\n * - \"none\" - display as an unstyled text field without any border or background\n * colors.\n * - \"underline\" - display with only an underline that gains the form active\n * color and animates from the left or right to the other side when the field\n * is focused.\n * - \"filled\" - an extension of the `\"underline\"` state that will also have a\n * slightly dark background applied.\n * - \"outline\" - outlines the entire text field in a border and applies the\n * active color as box shadow when the field is focused.\n */\nexport type FormTheme = \"none\" | \"underline\" | \"filled\" | \"outline\";\n\n/**\n * The direction that the underline should appear from when the theme is\n * `\"underline\"` or `\"filled\"`.\n */\nexport type FormUnderlineDirection = \"left\" | \"center\" | \"right\";\n\nexport interface FormThemeOptions {\n /**\n * The current theme type.\n *\n * @defaultValue `\"outline\"`\n */\n theme?: FormTheme;\n\n /**\n * The current underline direction.\n *\n * @defaultValue `\"left\"`\n */\n underlineDirection?: FormUnderlineDirection;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FormConfiguration extends Required<FormThemeOptions> {\n /**\n * Set this to `false` if the `$disable-uncontrolled-input-toggles` variable\n * is set to `true` in the Sass configuration.\n *\n * Since the `checked` state only changes for the radio that has been clicked,\n * the previously checked radio would also be shown as checked with no way of\n * fixing it without controlling the radio component. When this flag is\n * enabled, the checked icons and state are handled through css instead of\n * `useState`.\n *\n * @defaultValue `true`\n */\n uncontrolledToggles: boolean;\n}\n\n/**\n * @since 6.4.0\n */\nexport interface InteractableFormComponentStates {\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /** @defaultValue `false` */\n readOnly?: boolean;\n}\n\n/**\n * @since 6.4.0\n */\nexport interface EditableFormComponentStates extends InteractableFormComponentStates {\n /** @defaultValue `false` */\n error?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FormComponentStates extends EditableFormComponentStates {\n /** @defaultValue `false` */\n active?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @see https://html.spec.whatwg.org/multipage/forms.html#autofill\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values\n */\nexport type AutocompleteAttributeValue =\n | \"off\"\n | \"on\"\n | \"name\"\n | \"honorific-prefix\"\n | \"given-name\"\n | \"additional-name\"\n | \"family-name\"\n | \"honorific-suffix\"\n | \"nickname\"\n | \"email\"\n | \"username\"\n | \"new-password\"\n | \"current-password\"\n | \"one-time-code\"\n | \"organization-title\"\n | \"organization\"\n | \"street-address\"\n | \"address-line1\"\n | \"address-line2\"\n | \"address-line3\"\n | \"address-level1\"\n | \"address-level2\"\n | \"address-level3\"\n | \"address-level4\"\n | \"country\"\n | \"country-name\"\n | \"postal-code\"\n | \"cc-name\"\n | \"cc-given-name\"\n | \"cc-additional-name\"\n | \"cc-family-name\"\n | \"cc-number\"\n | \"cc-exp\"\n | \"cc-exp-month\"\n | \"cc-exp-year\"\n | \"cc-csc\"\n | \"cc-type\"\n | \"transaction-currency\"\n | \"transaction-amount\"\n | \"language\"\n | \"bday\"\n | \"bday-day\"\n | \"bday-month\"\n | \"bday-year\"\n | \"sex\"\n | \"tel\"\n | \"tel-country-code\"\n | \"tel-national\"\n | \"tek-area-code\"\n | \"tel-local\"\n | \"tel-extension\"\n | \"impp\"\n | \"url\"\n | \"photo\";\n\n/**\n * @since 6.0.0\n */\nexport interface UserAgentAutocompleteProps {\n /**\n * Set this to enable additional autocompletion suggestions for a user for\n * different form fields. Using this prop will update the\n * {@link UserAgentAutocompleteProps.name} and {@link autoComplete} to default to\n * this value.\n *\n * @example\n * ```tsx\n * <Form>\n * <TextField\n * label=\"Enter your credit card number\"\n * autoCompleteValue=\"cc-number\"\n * {...creditCardProps}\n * inputMode=\"number\"\n * />\n * <TextField\n * label=\"Name on card\"\n * autoCompleteValue=\"cc-name\"\n * {...creditCardNameProps}\n * />\n * <TextField\n * label=\"Security code\"\n * autoCompleteValue=\"cc-csc\"\n * {...securityCodeProps}\n * inputMode=\"number\"\n * />\n * <Button type=\"submit\">Submit</Button>\n * </Form>\n * ```\n *\n * @see https://html.spec.whatwg.org/multipage/forms.html#autofill\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values\n * @see {@link AutocompleteAttributeValue}\n * @see {@link autoComplete}\n * @see {@link UserAgentAutocompleteProps.name}\n */\n autoCompleteValue?: AutocompleteAttributeValue;\n\n /**\n * @see {@link autoCompleteValue}\n * @defaultValue `autoCompleteValue`\n */\n autoComplete?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n\n /**\n * @see {@link autoCompleteValue}\n * @defaultValue `autoCompleteValue`\n */\n name?: string;\n}\n\nexport interface FormMessageClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the message should gain the error state which changes the text\n * color to `red` by default.\n *\n * @defaultValue `false`\n */\n error?: boolean;\n\n /**\n * The current theme for the related text field. This is really only used to\n * match the current horizontal padding of the text field.\n *\n * @defaultValue `\"outline\"`\n */\n theme?: FormTheme;\n}\n\n/**\n * @since 7.0.0 Renamed from `FormMessageProps` to `ConfigurableFormMessageProps`\n */\nexport interface ConfigurableFormMessageProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, \"minLength\" | \"maxLength\">,\n FormMessageClassNameOptions {\n ref?: Ref<HTMLDivElement>;\n\n /**\n * If this component is acting as a form-level error message handler, the role\n * should be updated to be `\"alert\"` for additional accessibility.\n *\n * Note: when creating a form-level error message handler, the messages should\n * no longer appear as the user types and instead once the user tries to\n * submit the form. Having an alert role disrupts normal screen reader\n * behavior by immediately reading changes in this element.\n *\n * @defaultValue `undefined`\n */\n role?: \"alert\";\n\n /**\n * Boolean if the children should no longer be wrapped in a `<p>` tag. This\n * should normally only be disabled if using a custom error message wrapper or\n * the counter behavior is not being used. To get correct alignments of the\n * message and counter, the `children` must be wrapped in some element and\n * cannot be plain test.\n *\n * Note: this will always be considered `true` if the `role` is set to\n * `\"alert\"`.\n *\n * @defaultValue `false`\n */\n disableWrap?: boolean;\n\n /**\n * Optional props to provide to inline counter.\n *\n * @since 6.3.0\n */\n counterProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Optional props to apply to the `<p>` tag that surrounds the `children`.\n * This will not be used if `role=\"alert\"` or `disableWrap={true}`.\n *\n * @since 6.3.0\n */\n messageProps?: PropsWithRef<HTMLAttributes<HTMLParagraphElement>>;\n\n /**\n * An optional style to apply to the `<p>` tag that surrounds the `children`.\n * This will not be used if `role=\"alert\"` or `disableWrap={true}`.\n */\n messageStyle?: CSSProperties;\n\n /**\n * An optional className to apply to the `<p>` tag that surrounds the\n * `children`. This will not be used if `role=\"alert\"` or\n * `disableWrap={true}`.\n */\n messageClassName?: string;\n}\n\n/**\n * Props that are used to automatically add a counter for the remaining letters\n * available for the text field. The counter will always be created to the right\n * of the optional message.\n *\n * The counter is really a simple string of: `${length} / ${maxLength}`.\n *\n * If you need additional customization, it is recommended to create your own\n * implementation such as:\n *\n * ```tsx\n * <FormMessage>\n * {errorMessage}\n * <MyCounter {...props} />\n * </FormMessage>\n * ```\n *\n * Note: this should not be used alongside form-level messages.\n *\n * @since 2.9.0 Renamed from `FormMessageCounterProps` to\n * `FormMessageInputLengthCounterProps` since a `FormMessageCounter` component\n * was added\n */\nexport interface FormMessageInputLengthCounterProps {\n /**\n * The current length of the value in the related text field.\n */\n length: number;\n\n /**\n * The max length allowed for the value in the related text field.\n */\n maxLength: number;\n\n /**\n * An optional style to apply to the counter wrapper element.\n */\n counterStyle?: CSSProperties;\n\n /**\n * An optional className to apply to the counter wrapper element.\n */\n counterClassName?: string;\n}\n\nexport interface FormMessageWithCounterProps\n extends ConfigurableFormMessageProps, FormMessageInputLengthCounterProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface FormMessageWithoutCounterProps extends ConfigurableFormMessageProps {\n length?: never;\n maxLength?: never;\n counterStyle?: never;\n counterClassName?: never;\n}\n\nexport interface FormMessageContainerExtension {\n /**\n * If the extension doesn't actually want to render the `FormMessage`\n * component, these props are optional. It kind of eliminates the whole\n * purpose of this component though.\n */\n messageProps?: PropsWithRef<\n ConfigurableFormMessageProps & Partial<FormMessageInputLengthCounterProps>\n >;\n\n /**\n * Any props (and an optional ref) to provide to the `<div>` surrounding the\n * children and `FormMessage` component.\n *\n * Note: This will not be used if the `messageProps` are not provided since\n * only the `children` will be returned without the container.\n */\n messageContainerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n}\n\n/** @since 6.0.0 */\nexport interface LabelClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` to remove the `gap` style from the label.\n *\n * @see `$label-gap`\n * @defaultValue `false`\n */\n gap?: boolean;\n\n /**\n * Set this to `true` when the parent `TextFieldContainer` has the `dense`\n * spec enabled. This updates the floating styles to match the smaller height.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * Set this to `true` to update the label's color to the error color.\n *\n * @see `$error-color`\n * @defaultValue `false`\n */\n error?: boolean;\n\n /**\n * Set this to `true` to update the label's color to the active color.\n *\n * @see `$active-color`\n * @defaultValue `false`\n */\n active?: boolean;\n\n /**\n * Set this to `true` if the label should gain `flex-direction: column`\n * styling.\n *\n * @defaultValue `false`\n */\n stacked?: boolean;\n\n /**\n * Set this to `true` to update the label's color to be the disabled color.\n *\n * @see `$disabled-color`\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to true when label can floating above an input, textarea, or\n * select inside of a `TextFieldContainer`.\n *\n * @defaultValue `false`\n */\n floating?: boolean;\n\n /**\n * Set this to true when label is currently floating above an input,\n * textarea, or selected inside of a `TextFieldContainer`.\n *\n * @see {@link active}\n * @defaultValue `active`\n */\n floatingActive?: boolean;\n\n /**\n * Set this to `true` to gain `flex-direction: row-reversed` styling. If the\n * {@link stacked} prop is also `true`, `flex-direction: column-reversed` will\n * be applied.\n *\n * @defaultValue `false`\n */\n reversed?: boolean;\n\n /**\n * @defaultValue `false`\n */\n inactive?: boolean;\n}\n\nexport interface LabelProps\n extends LabelHTMLAttributes<HTMLLabelElement>, LabelClassNameOptions {\n ref?: Ref<HTMLLabelElement>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableTextFieldAddonProps extends HTMLAttributes<HTMLSpanElement> {\n /**\n * Boolean if the addon should be presentational only and prevent pointer\n * events.\n *\n * @defaultValue `false`\n */\n pointerEvents?: boolean;\n}\n\n/**\n * @since 6.0.0 Split props into `ConfigurableTextFieldAddonProps`\n */\nexport interface TextFieldAddonProps extends ConfigurableTextFieldAddonProps {\n ref?: Ref<HTMLSpanElement>;\n\n /**\n * @defaultValue `false`\n */\n after?: boolean;\n\n /**\n * Set this to `true` if the addon should not be wrapped in a `<span>` with some\n * additional styles.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n}\n\n/**\n * @since 6.0.0 Renamed the `leftChildren` / `rightChildren` props to\n * `leftAddon` / `rightAddon`. Renamed `isLeftAddon` / `isRightAddon` to\n * `disableLeftAddonStyles` / `disableRightAddonStyles`. Added\n * `leftAddonProps` / `rightAddonProps`. Removed `stretch`\n */\nexport interface TextFieldContainerOptions\n extends FormThemeOptions, FormComponentStates {\n /**\n * Set this to `true` to enable the dense spec which reduces the height.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * Set this to `true` to change the style from `display: flex` to\n * `display: inline-flex`.\n *\n * @defaultValue `false`\n */\n inline?: boolean;\n\n /**\n * This should generally be an icon or a button that will be placed before the\n * `TextField` or `TextArea`.\n */\n leftAddon?: ReactNode;\n\n /**\n * Any additional props to pass to the `<span>` surrounding the {@link leftAddon}.\n *\n * @since 6.0.0\n */\n leftAddonProps?: PropsWithRef<ConfigurableTextFieldAddonProps>;\n\n /**\n * @see {@link TextFieldAddonProps.disabled}\n *\n * @defaultValue `false`\n */\n disableLeftAddonStyles?: boolean;\n\n /**\n * This should generally be an icon or a button that will be placed after the\n * `TextField` or `TextArea`.\n */\n rightAddon?: ReactNode;\n\n /**\n * Any additional props to pass to the `<span>` surrounding the {@link rightAddon}.\n *\n * @since 6.0.0\n */\n rightAddonProps?: PropsWithRef<ConfigurableTextFieldAddonProps>;\n\n /**\n * @see {@link TextFieldAddonProps.disabled}\n *\n * @defaultValue `false`\n */\n disableRightAddonStyles?: boolean;\n}\n\nexport interface FormFieldOptions\n extends TextFieldContainerOptions, FormMessageContainerExtension {\n /**\n * An optional floating label to use with the text field. A label is generally\n * recommended for accessibility, but can be omitted if an `aria-label` or\n * `aria-labelledby` is provided.\n */\n label?: ReactNode;\n\n /**\n * Any additional props and/or ref that should be passed to the `<label>`\n * element when a {@link label} is provided.\n *\n * @example\n * ```tsx\n * labelProps={{\n * ref: labelRef,\n * style: {},\n * className: \"some-custom-class-name\",\n * onClick: (event) => {\n * // do something\n * }\n * }}\n * ```\n */\n labelProps?: PropsWithRef<LabelProps>;\n\n /**\n * A convenience prop to apply a custom style to a label. This is equivalent\n * to:\n *\n * ```ts\n * labelProps={{\n * style: // some style here\n * }}\n * ```\n */\n labelStyle?: CSSProperties;\n\n /**\n * A convenience prop to apply a custom className to a label. This is\n * equivalent to:\n *\n * ```ts\n * labelProps={{\n * className: \"some-class-name\",\n * }}\n * ```\n */\n labelClassName?: string;\n}\n"],"names":[],"mappings":"AAgmBA,WAkDC"}
@@ -4,7 +4,7 @@ import { type MenuSheetConfigurableProps } from "../menu/MenuSheet.js";
4
4
  import { type GetDefaultFocusedIndex, type GetFocusableElements, type KeyboardMovementExtensionData, type KeyboardMovementProviderImplementation, type KeyboardMovementProviderOptions } from "../movement/types.js";
5
5
  import { type PositionAnchor, type PositionWidth } from "../positioning/types.js";
6
6
  import { type TransitionCallbacks } from "../transition/types.js";
7
- import { type NonNullMutableRef, type UseStateInitializer, type UseStateSetter } from "../types.js";
7
+ import { type UseStateInitializer, type UseStateSetter } from "../types.js";
8
8
  /**
9
9
  * @since 6.0.0
10
10
  */
@@ -24,7 +24,7 @@ export interface ComboboxKeyboardMovementData<E extends HTMLElement = HTMLInputE
24
24
  * @since 6.3.0 Renamed from `focusLast` to `focusLastRef` to support the new
25
25
  * actions.
26
26
  */
27
- focusLastRef: NonNullMutableRef<boolean>;
27
+ focusLastRef: RefObject<boolean>;
28
28
  }
29
29
  /**
30
30
  * @since 6.0.0
@@ -161,7 +161,7 @@ export interface ProvidedComboboxMenuProps<PopupEl extends HTMLElement = HTMLDiv
161
161
  width: PositionWidth;
162
162
  /** @defaultValue `BELOW_CENTER_ANCHOR` */
163
163
  anchor: PositionAnchor;
164
- fixedTo: RefObject<HTMLElement>;
164
+ fixedTo: RefObject<HTMLElement | null>;
165
165
  sheetProps: MenuSheetConfigurableProps & Required<ComboboxTransitionCallbacks>;
166
166
  }
167
167
  /**
@@ -177,10 +177,10 @@ export interface ComboboxImplementation<ComboboxEl extends HTMLElement = HTMLInp
177
177
  hide: () => void;
178
178
  visible: boolean;
179
179
  setVisible: UseStateSetter<boolean>;
180
- focusLast: NonNullMutableRef<boolean>;
181
- popupRef: RefObject<PopupEl>;
180
+ focusLast: RefObject<boolean>;
181
+ popupRef: RefObject<PopupEl | null>;
182
182
  popupProps: ComboboxWidgetPopupProps<PopupEl>;
183
- comboboxRef: RefObject<ComboboxEl>;
183
+ comboboxRef: RefObject<ComboboxEl | null>;
184
184
  comboboxProps: ComboboxWidgetProps<ComboboxEl>;
185
185
  /**
186
186
  * Since the combobox usually uses the `Menu` as a popup element, this is a
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/useCombobox.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEventHandler,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEventHandler,\n type Ref,\n type RefCallback,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { type MenuProps } from \"../menu/Menu.js\";\nimport { type MenuSheetConfigurableProps } from \"../menu/MenuSheet.js\";\nimport {\n type GetDefaultFocusedIndex,\n type GetFocusableElements,\n type KeyboardMovementExtensionData,\n type KeyboardMovementProviderImplementation,\n type KeyboardMovementProviderOptions,\n} from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { BELOW_CENTER_ANCHOR } from \"../positioning/constants.js\";\nimport {\n type PositionAnchor,\n type PositionWidth,\n} from \"../positioning/types.js\";\nimport { getTransitionCallbacks } from \"../transition/getTransitionCallbacks.js\";\nimport { type TransitionCallbacks } from \"../transition/types.js\";\nimport {\n type NonNullMutableRef,\n type UseStateInitializer,\n type UseStateSetter,\n} from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport { tryToSubmitRelatedForm } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport const getNonDisabledOptions = (\n container: HTMLElement\n): readonly HTMLElement[] => [\n ...container.querySelectorAll<HTMLLIElement>(\n '[role=\"option\"]:not([aria-disabled])'\n ),\n];\n\n/**\n * @since 6.0.0\n */\nexport type SupportedComboboxPopup = \"listbox\" | \"grid\" | \"dialog\";\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxKeyboardMovementData<\n E extends HTMLElement = HTMLInputElement,\n> extends KeyboardMovementExtensionData<E> {\n show: () => void;\n hide: () => void;\n visible: boolean;\n\n /**\n * @since 6.3.0 Renamed from `focusLast` to `focusLastRef` to support the new\n * actions.\n */\n focusLastRef: NonNullMutableRef<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type ExtendComboboxKeyDown<E extends HTMLElement = HTMLInputElement> = (\n movementData: ComboboxKeyboardMovementData<E>\n) => void;\n\n/**\n * @since 6.0.0\n */\nexport type ComboboxKeyboardMovementOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n> = Pick<\n KeyboardMovementProviderOptions<ComboboxEl>,\n | \"onClick\"\n | \"onFocus\"\n | \"onKeyDown\"\n | \"disabled\"\n | \"loopable\"\n | \"searchable\"\n | \"onFocusChange\"\n | \"isNegativeOneAllowed\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxVisibilityOptions {\n /**\n * This can be used to control the popup's visibility and **must** be used\n * along with {@link setVisible}.\n */\n visible?: boolean;\n\n /**\n * Used to control the popup's visibility and should generally be a `useState`\n * setter.\n *\n * @example Controlling the Visibility\n * ```tsx\n * const [visible, setVisible] = useState(false);\n *\n * useCombobox({\n * visible,\n * setVisible,\n * });\n * ```\n */\n setVisible?: UseStateSetter<boolean>;\n\n /**\n * Set this to `true` to have the combobox's popup visible by default.\n *\n * @defaultValue `false`\n */\n defaultVisible?: UseStateInitializer<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableComboboxOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n>\n extends\n ComboboxKeyboardMovementOptions<ComboboxEl>,\n ComboboxVisibilityOptions {\n /**\n * This is the {@link InputHTMLAttributes.form} attribute and is used to\n * attempt submitting a form when the enter key is pressed.\n */\n form?: string;\n\n /**\n * @defaultValue `\"combobox-popup-\" + useId()`\n */\n popupId?: string;\n popupRef?: Ref<PopupEl>;\n\n /**\n * @defaultValue `\"combobox-\" + useId()`\n */\n comboboxId?: string;\n comboboxRef?: Ref<ComboboxEl>;\n\n /**\n * @defaultValue `\"listbox\"`\n */\n popup?: \"listbox\" | \"grid\" | \"dialog\";\n\n /**\n * @defaultValue `false`\n */\n multiselect?: boolean;\n\n extendKeyDown?: ExtendComboboxKeyDown<ComboboxEl>;\n\n /**\n * @defaultValue {@link getNonDisabledOptions}\n */\n getFocusableElements?: GetFocusableElements;\n\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxGetEnterDefaultFocusedIndexOptions {\n focusLast: boolean;\n focusables: readonly HTMLElement[];\n currentFocusIndex: number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n> extends ConfigurableComboboxOptions<ComboboxEl, PopupEl> {\n getEnterDefaultFocusedIndex: (\n options: ComboboxGetEnterDefaultFocusedIndexOptions\n ) => number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxWidgetProps<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n> {\n \"aria-controls\": string;\n \"aria-disabled\": true | undefined;\n \"aria-expanded\": boolean;\n \"aria-haspopup\": SupportedComboboxPopup;\n id: string;\n ref: RefCallback<ComboboxEl>;\n role: \"combobox\";\n onClick: MouseEventHandler<ComboboxEl>;\n onFocus: FocusEventHandler<ComboboxEl>;\n onKeyDown: KeyboardEventHandler<ComboboxEl>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxWidgetPopupProps<\n PopupEl extends HTMLElement = HTMLElement,\n> {\n \"aria-multiselectable\": true | undefined;\n id: string;\n ref: RefCallback<PopupEl>;\n role: \"listbox\" | \"dialog\" | \"grid\";\n}\n\n/**\n * @since 6.0.0\n */\nexport type ComboboxTransitionCallbacks = Pick<\n TransitionCallbacks,\n \"onEntering\" | \"onEntered\" | \"onExiting\" | \"onExited\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxTransitionOptions extends ComboboxTransitionCallbacks {\n disableTransition?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport type ConfigurableComboboxMenuProps = Partial<\n Omit<MenuProps, \"visible\" | \"onRequestClose\" | keyof ComboboxWidgetPopupProps>\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ProvidedComboboxMenuProps<\n PopupEl extends HTMLElement = HTMLDivElement,\n>\n extends\n Required<ComboboxTransitionCallbacks>,\n ComboboxWidgetPopupProps<PopupEl> {\n visible: boolean;\n onRequestClose: () => void;\n /** @defaultValue `\"min\"` */\n width: PositionWidth;\n /** @defaultValue `BELOW_CENTER_ANCHOR` */\n anchor: PositionAnchor;\n fixedTo: RefObject<HTMLElement>;\n sheetProps: MenuSheetConfigurableProps &\n Required<ComboboxTransitionCallbacks>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxMenuProps<PopupEl extends HTMLElement = HTMLDivElement>\n extends\n Omit<ConfigurableComboboxMenuProps, keyof ProvidedComboboxMenuProps>,\n ProvidedComboboxMenuProps<PopupEl> {}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxImplementation<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n> extends Omit<KeyboardMovementProviderImplementation<ComboboxEl>, \"nodeRef\"> {\n show: () => void;\n hide: () => void;\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n focusLast: NonNullMutableRef<boolean>;\n popupRef: RefObject<PopupEl>;\n popupProps: ComboboxWidgetPopupProps<PopupEl>;\n comboboxRef: RefObject<ComboboxEl>;\n comboboxProps: ComboboxWidgetProps<ComboboxEl>;\n /**\n * Since the combobox usually uses the `Menu` as a popup element, this is a\n * helper util to create the required props and merge any additional props\n * with reasonable defaults.\n */\n getMenuProps: (\n overrides?: ConfigurableComboboxMenuProps\n ) => ComboboxMenuProps<PopupEl>;\n}\n\n/**\n * @since 6.0.0\n */\nexport function useCombobox<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n>(\n options: ComboboxOptions<ComboboxEl, PopupEl>\n): ComboboxImplementation<ComboboxEl, PopupEl> {\n const {\n form,\n popup = \"listbox\",\n onClick = noop,\n onFocus,\n onKeyDown,\n searchable,\n multiselect,\n isNegativeOneAllowed,\n loopable,\n disabled,\n visible: propVisible,\n setVisible: propSetVisible,\n defaultVisible = false,\n comboboxId: propComboboxId,\n comboboxRef: propComboboxRef,\n popupId: propPopupId,\n popupRef: propPopupRef,\n onFocusChange = noop,\n extendKeyDown = noop,\n getFocusableElements = getNonDisabledOptions,\n getEnterDefaultFocusedIndex,\n getDefaultFocusedIndex,\n } = options;\n\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: defaultVisible,\n });\n const show = useCallback(() => {\n setVisible(true);\n }, [setVisible]);\n const hide = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n const popupId = useEnsuredId(propPopupId, \"combobox-popup\");\n const comboboxId = useEnsuredId(propComboboxId, \"combobox\");\n const [popupRef, popupRefCallback] = useEnsuredRef(propPopupRef);\n const focusLastRef = useRef(false);\n const {\n nodeRef: comboboxRef,\n movementProps,\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n } = useKeyboardMovementProvider<ComboboxEl>({\n ref: propComboboxRef,\n onFocus,\n onKeyDown,\n onClick(event) {\n onClick(event);\n if (disabled) {\n return;\n }\n\n show();\n },\n extendKeyDown(movementData) {\n extendKeyDown({\n ...movementData,\n show,\n hide,\n visible,\n focusLastRef,\n });\n const { event } = movementData;\n if (event.isPropagationStopped()) {\n return;\n }\n\n if (visible) {\n switch (event.key) {\n case \"Tab\":\n // do not stop propagation for tab so that shift+tab works correctly in dialogs\n hide();\n break;\n case \"Escape\":\n event.stopPropagation();\n hide();\n break;\n case \"Enter\":\n event.preventDefault();\n break;\n }\n\n // while visible, always use the default keyboard movement behavior\n return;\n }\n\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowDown\":\n event.preventDefault();\n event.stopPropagation();\n focusLastRef.current = event.key === \"ArrowUp\";\n show();\n break;\n case \"Enter\":\n tryToSubmitRelatedForm(event, form);\n break;\n }\n },\n disabled,\n loopable,\n searchable,\n onFocusChange,\n programmatic: true,\n includeDisabled: false,\n tabIndexBehavior: \"virtual\",\n getFocusableElements(container, programmatic) {\n const popup = popupRef.current;\n if (!popup) {\n return [];\n }\n\n return getFocusableElements(popup || container, programmatic);\n },\n isNegativeOneAllowed,\n getDefaultFocusedIndex,\n });\n\n const popupProps: ComboboxWidgetPopupProps<PopupEl> = {\n \"aria-multiselectable\": multiselect || undefined,\n id: popupId,\n ref: popupRefCallback,\n role: popup,\n };\n\n return {\n show,\n hide,\n visible,\n setVisible,\n focusLast: focusLastRef,\n popupRef,\n popupProps,\n comboboxRef,\n comboboxProps: {\n ...movementProps,\n \"aria-controls\": popupId,\n \"aria-disabled\": disabled || undefined,\n \"aria-expanded\": visible,\n \"aria-haspopup\": popup,\n id: comboboxId,\n role: \"combobox\",\n },\n movementProps,\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n getMenuProps(props = {}) {\n const {\n sheetProps,\n disableTransition,\n onEnter,\n onEntering,\n onEntered = noop,\n onExited,\n onExiting,\n onExit,\n } = props;\n\n // Chrome does not trigger the scrollIntoView behavior correctly while\n // using a scale transition, so need to trigger this on the entered flow\n // to really make sure the item is in view. An alternative would be to\n // implement a custom scrollIntoView behavior again like the previous\n // versions of react-md, but this is less lines of code\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const attemptScroll = (): void => {\n const activeOption = document.getElementById(activeDescendantId);\n if (activeOption) {\n activeOption.scrollIntoView({ block: \"nearest\" });\n }\n };\n const onEnterOnce = (): void => {\n const popup = popupRef.current;\n if (!popup) {\n attemptScroll();\n return;\n }\n\n const focusables = getFocusableElements(popup, true);\n const index = getEnterDefaultFocusedIndex({\n focusLast: focusLastRef.current,\n focusables,\n currentFocusIndex: currentFocusIndex.current,\n });\n focusLastRef.current = false;\n currentFocusIndex.current = index;\n\n const option = focusables[index];\n if (!option) {\n return;\n }\n\n onFocusChange({\n index,\n element: option,\n });\n\n option.scrollIntoView({ block: \"nearest\" });\n setActiveDescendantId(option.id || \"\");\n };\n\n return {\n anchor: BELOW_CENTER_ANCHOR,\n width: \"min\",\n fixedTo: comboboxRef,\n ...props,\n ...popupProps,\n visible,\n onRequestClose: hide,\n ...getTransitionCallbacks({\n disableTransition,\n onEnter,\n onEntered: (appearing) => {\n onEntered(appearing);\n attemptScroll();\n },\n onEntering,\n onEnterOnce,\n onExit,\n onExiting,\n onExited,\n onExitOnce: () => {\n // since the menu is unmounted or set to hidden while not visible, need\n // to clear the aria-activedescendant and current focus index when\n // hiding\n currentFocusIndex.current = -1;\n setActiveDescendantId(\"\");\n },\n }),\n sheetProps: {\n ...sheetProps,\n ...getTransitionCallbacks({\n ...sheetProps,\n onEnterOnce,\n disableTransition:\n sheetProps?.disableTransition ?? disableTransition,\n }),\n },\n };\n },\n };\n}\n"],"names":["useCallback","useRef","useKeyboardMovementProvider","BELOW_CENTER_ANCHOR","getTransitionCallbacks","useEnsuredId","useEnsuredRef","useEnsuredState","tryToSubmitRelatedForm","noop","getNonDisabledOptions","container","querySelectorAll","useCombobox","options","form","popup","onClick","onFocus","onKeyDown","searchable","multiselect","isNegativeOneAllowed","loopable","disabled","visible","propVisible","setVisible","propSetVisible","defaultVisible","comboboxId","propComboboxId","comboboxRef","propComboboxRef","popupId","propPopupId","popupRef","propPopupRef","onFocusChange","extendKeyDown","getFocusableElements","getEnterDefaultFocusedIndex","getDefaultFocusedIndex","name","value","setValue","defaultValue","show","hide","popupRefCallback","focusLastRef","nodeRef","movementProps","movementContext","currentFocusIndex","activeDescendantId","setActiveDescendantId","ref","event","movementData","isPropagationStopped","key","stopPropagation","preventDefault","current","programmatic","includeDisabled","tabIndexBehavior","popupProps","undefined","id","role","focusLast","comboboxProps","getMenuProps","props","sheetProps","disableTransition","onEnter","onEntering","onEntered","onExited","onExiting","onExit","attemptScroll","activeOption","document","getElementById","scrollIntoView","block","onEnterOnce","focusables","index","option","element","anchor","width","fixedTo","onRequestClose","appearing","onExitOnce"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/form/useCombobox.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEventHandler,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type InputHTMLAttributes,\n type KeyboardEventHandler,\n type MouseEventHandler,\n type Ref,\n type RefCallback,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { type MenuProps } from \"../menu/Menu.js\";\nimport { type MenuSheetConfigurableProps } from \"../menu/MenuSheet.js\";\nimport {\n type GetDefaultFocusedIndex,\n type GetFocusableElements,\n type KeyboardMovementExtensionData,\n type KeyboardMovementProviderImplementation,\n type KeyboardMovementProviderOptions,\n} from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { BELOW_CENTER_ANCHOR } from \"../positioning/constants.js\";\nimport {\n type PositionAnchor,\n type PositionWidth,\n} from \"../positioning/types.js\";\nimport { getTransitionCallbacks } from \"../transition/getTransitionCallbacks.js\";\nimport { type TransitionCallbacks } from \"../transition/types.js\";\nimport { type UseStateInitializer, type UseStateSetter } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport { tryToSubmitRelatedForm } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport const getNonDisabledOptions = (\n container: HTMLElement\n): readonly HTMLElement[] => [\n ...container.querySelectorAll<HTMLLIElement>(\n '[role=\"option\"]:not([aria-disabled])'\n ),\n];\n\n/**\n * @since 6.0.0\n */\nexport type SupportedComboboxPopup = \"listbox\" | \"grid\" | \"dialog\";\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxKeyboardMovementData<\n E extends HTMLElement = HTMLInputElement,\n> extends KeyboardMovementExtensionData<E> {\n show: () => void;\n hide: () => void;\n visible: boolean;\n\n /**\n * @since 6.3.0 Renamed from `focusLast` to `focusLastRef` to support the new\n * actions.\n */\n focusLastRef: RefObject<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type ExtendComboboxKeyDown<E extends HTMLElement = HTMLInputElement> = (\n movementData: ComboboxKeyboardMovementData<E>\n) => void;\n\n/**\n * @since 6.0.0\n */\nexport type ComboboxKeyboardMovementOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n> = Pick<\n KeyboardMovementProviderOptions<ComboboxEl>,\n | \"onClick\"\n | \"onFocus\"\n | \"onKeyDown\"\n | \"disabled\"\n | \"loopable\"\n | \"searchable\"\n | \"onFocusChange\"\n | \"isNegativeOneAllowed\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxVisibilityOptions {\n /**\n * This can be used to control the popup's visibility and **must** be used\n * along with {@link setVisible}.\n */\n visible?: boolean;\n\n /**\n * Used to control the popup's visibility and should generally be a `useState`\n * setter.\n *\n * @example Controlling the Visibility\n * ```tsx\n * const [visible, setVisible] = useState(false);\n *\n * useCombobox({\n * visible,\n * setVisible,\n * });\n * ```\n */\n setVisible?: UseStateSetter<boolean>;\n\n /**\n * Set this to `true` to have the combobox's popup visible by default.\n *\n * @defaultValue `false`\n */\n defaultVisible?: UseStateInitializer<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableComboboxOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n>\n extends\n ComboboxKeyboardMovementOptions<ComboboxEl>,\n ComboboxVisibilityOptions {\n /**\n * This is the {@link InputHTMLAttributes.form} attribute and is used to\n * attempt submitting a form when the enter key is pressed.\n */\n form?: string;\n\n /**\n * @defaultValue `\"combobox-popup-\" + useId()`\n */\n popupId?: string;\n popupRef?: Ref<PopupEl>;\n\n /**\n * @defaultValue `\"combobox-\" + useId()`\n */\n comboboxId?: string;\n comboboxRef?: Ref<ComboboxEl>;\n\n /**\n * @defaultValue `\"listbox\"`\n */\n popup?: \"listbox\" | \"grid\" | \"dialog\";\n\n /**\n * @defaultValue `false`\n */\n multiselect?: boolean;\n\n extendKeyDown?: ExtendComboboxKeyDown<ComboboxEl>;\n\n /**\n * @defaultValue {@link getNonDisabledOptions}\n */\n getFocusableElements?: GetFocusableElements;\n\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxGetEnterDefaultFocusedIndexOptions {\n focusLast: boolean;\n focusables: readonly HTMLElement[];\n currentFocusIndex: number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxOptions<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n> extends ConfigurableComboboxOptions<ComboboxEl, PopupEl> {\n getEnterDefaultFocusedIndex: (\n options: ComboboxGetEnterDefaultFocusedIndexOptions\n ) => number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxWidgetProps<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n> {\n \"aria-controls\": string;\n \"aria-disabled\": true | undefined;\n \"aria-expanded\": boolean;\n \"aria-haspopup\": SupportedComboboxPopup;\n id: string;\n ref: RefCallback<ComboboxEl>;\n role: \"combobox\";\n onClick: MouseEventHandler<ComboboxEl>;\n onFocus: FocusEventHandler<ComboboxEl>;\n onKeyDown: KeyboardEventHandler<ComboboxEl>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxWidgetPopupProps<\n PopupEl extends HTMLElement = HTMLElement,\n> {\n \"aria-multiselectable\": true | undefined;\n id: string;\n ref: RefCallback<PopupEl>;\n role: \"listbox\" | \"dialog\" | \"grid\";\n}\n\n/**\n * @since 6.0.0\n */\nexport type ComboboxTransitionCallbacks = Pick<\n TransitionCallbacks,\n \"onEntering\" | \"onEntered\" | \"onExiting\" | \"onExited\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxTransitionOptions extends ComboboxTransitionCallbacks {\n disableTransition?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport type ConfigurableComboboxMenuProps = Partial<\n Omit<MenuProps, \"visible\" | \"onRequestClose\" | keyof ComboboxWidgetPopupProps>\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ProvidedComboboxMenuProps<\n PopupEl extends HTMLElement = HTMLDivElement,\n>\n extends\n Required<ComboboxTransitionCallbacks>,\n ComboboxWidgetPopupProps<PopupEl> {\n visible: boolean;\n onRequestClose: () => void;\n /** @defaultValue `\"min\"` */\n width: PositionWidth;\n /** @defaultValue `BELOW_CENTER_ANCHOR` */\n anchor: PositionAnchor;\n fixedTo: RefObject<HTMLElement | null>;\n sheetProps: MenuSheetConfigurableProps &\n Required<ComboboxTransitionCallbacks>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxMenuProps<PopupEl extends HTMLElement = HTMLDivElement>\n extends\n Omit<ConfigurableComboboxMenuProps, keyof ProvidedComboboxMenuProps>,\n ProvidedComboboxMenuProps<PopupEl> {}\n\n/**\n * @since 6.0.0\n */\nexport interface ComboboxImplementation<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n> extends Omit<KeyboardMovementProviderImplementation<ComboboxEl>, \"nodeRef\"> {\n show: () => void;\n hide: () => void;\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n focusLast: RefObject<boolean>;\n popupRef: RefObject<PopupEl | null>;\n popupProps: ComboboxWidgetPopupProps<PopupEl>;\n comboboxRef: RefObject<ComboboxEl | null>;\n comboboxProps: ComboboxWidgetProps<ComboboxEl>;\n /**\n * Since the combobox usually uses the `Menu` as a popup element, this is a\n * helper util to create the required props and merge any additional props\n * with reasonable defaults.\n */\n getMenuProps: (\n overrides?: ConfigurableComboboxMenuProps\n ) => ComboboxMenuProps<PopupEl>;\n}\n\n/**\n * @since 6.0.0\n */\nexport function useCombobox<\n ComboboxEl extends HTMLElement = HTMLInputElement,\n PopupEl extends HTMLElement = HTMLElement,\n>(\n options: ComboboxOptions<ComboboxEl, PopupEl>\n): ComboboxImplementation<ComboboxEl, PopupEl> {\n const {\n form,\n popup = \"listbox\",\n onClick = noop,\n onFocus,\n onKeyDown,\n searchable,\n multiselect,\n isNegativeOneAllowed,\n loopable,\n disabled,\n visible: propVisible,\n setVisible: propSetVisible,\n defaultVisible = false,\n comboboxId: propComboboxId,\n comboboxRef: propComboboxRef,\n popupId: propPopupId,\n popupRef: propPopupRef,\n onFocusChange = noop,\n extendKeyDown = noop,\n getFocusableElements = getNonDisabledOptions,\n getEnterDefaultFocusedIndex,\n getDefaultFocusedIndex,\n } = options;\n\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: defaultVisible,\n });\n const show = useCallback(() => {\n setVisible(true);\n }, [setVisible]);\n const hide = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n const popupId = useEnsuredId(propPopupId, \"combobox-popup\");\n const comboboxId = useEnsuredId(propComboboxId, \"combobox\");\n const [popupRef, popupRefCallback] = useEnsuredRef(propPopupRef);\n const focusLastRef = useRef(false);\n const {\n nodeRef: comboboxRef,\n movementProps,\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n } = useKeyboardMovementProvider<ComboboxEl>({\n ref: propComboboxRef,\n onFocus,\n onKeyDown,\n onClick(event) {\n onClick(event);\n if (disabled) {\n return;\n }\n\n show();\n },\n extendKeyDown(movementData) {\n extendKeyDown({\n ...movementData,\n show,\n hide,\n visible,\n focusLastRef,\n });\n const { event } = movementData;\n if (event.isPropagationStopped()) {\n return;\n }\n\n if (visible) {\n switch (event.key) {\n case \"Tab\":\n // do not stop propagation for tab so that shift+tab works correctly in dialogs\n hide();\n break;\n case \"Escape\":\n event.stopPropagation();\n hide();\n break;\n case \"Enter\":\n event.preventDefault();\n break;\n }\n\n // while visible, always use the default keyboard movement behavior\n return;\n }\n\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowDown\":\n event.preventDefault();\n event.stopPropagation();\n focusLastRef.current = event.key === \"ArrowUp\";\n show();\n break;\n case \"Enter\":\n tryToSubmitRelatedForm(event, form);\n break;\n }\n },\n disabled,\n loopable,\n searchable,\n onFocusChange,\n programmatic: true,\n includeDisabled: false,\n tabIndexBehavior: \"virtual\",\n getFocusableElements(container, programmatic) {\n const popup = popupRef.current;\n if (!popup) {\n return [];\n }\n\n return getFocusableElements(popup || container, programmatic);\n },\n isNegativeOneAllowed,\n getDefaultFocusedIndex,\n });\n\n const popupProps: ComboboxWidgetPopupProps<PopupEl> = {\n \"aria-multiselectable\": multiselect || undefined,\n id: popupId,\n ref: popupRefCallback,\n role: popup,\n };\n\n return {\n show,\n hide,\n visible,\n setVisible,\n focusLast: focusLastRef,\n popupRef,\n popupProps,\n comboboxRef,\n comboboxProps: {\n ...movementProps,\n \"aria-controls\": popupId,\n \"aria-disabled\": disabled || undefined,\n \"aria-expanded\": visible,\n \"aria-haspopup\": popup,\n id: comboboxId,\n role: \"combobox\",\n },\n movementProps,\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n getMenuProps(props = {}) {\n const {\n sheetProps,\n disableTransition,\n onEnter,\n onEntering,\n onEntered = noop,\n onExited,\n onExiting,\n onExit,\n } = props;\n\n // Chrome does not trigger the scrollIntoView behavior correctly while\n // using a scale transition, so need to trigger this on the entered flow\n // to really make sure the item is in view. An alternative would be to\n // implement a custom scrollIntoView behavior again like the previous\n // versions of react-md, but this is less lines of code\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const attemptScroll = (): void => {\n const activeOption = document.getElementById(activeDescendantId);\n if (activeOption) {\n activeOption.scrollIntoView({ block: \"nearest\" });\n }\n };\n const onEnterOnce = (): void => {\n const popup = popupRef.current;\n if (!popup) {\n attemptScroll();\n return;\n }\n\n const focusables = getFocusableElements(popup, true);\n const index = getEnterDefaultFocusedIndex({\n focusLast: focusLastRef.current,\n focusables,\n currentFocusIndex: currentFocusIndex.current,\n });\n focusLastRef.current = false;\n currentFocusIndex.current = index;\n\n const option = focusables[index];\n if (!option) {\n return;\n }\n\n onFocusChange({\n index,\n element: option,\n });\n\n option.scrollIntoView({ block: \"nearest\" });\n setActiveDescendantId(option.id || \"\");\n };\n\n return {\n anchor: BELOW_CENTER_ANCHOR,\n width: \"min\",\n fixedTo: comboboxRef,\n ...props,\n ...popupProps,\n visible,\n onRequestClose: hide,\n ...getTransitionCallbacks({\n disableTransition,\n onEnter,\n onEntered: (appearing) => {\n onEntered(appearing);\n attemptScroll();\n },\n onEntering,\n onEnterOnce,\n onExit,\n onExiting,\n onExited,\n onExitOnce: () => {\n // since the menu is unmounted or set to hidden while not visible, need\n // to clear the aria-activedescendant and current focus index when\n // hiding\n currentFocusIndex.current = -1;\n setActiveDescendantId(\"\");\n },\n }),\n sheetProps: {\n ...sheetProps,\n ...getTransitionCallbacks({\n ...sheetProps,\n onEnterOnce,\n disableTransition:\n sheetProps?.disableTransition ?? disableTransition,\n }),\n },\n };\n },\n };\n}\n"],"names":["useCallback","useRef","useKeyboardMovementProvider","BELOW_CENTER_ANCHOR","getTransitionCallbacks","useEnsuredId","useEnsuredRef","useEnsuredState","tryToSubmitRelatedForm","noop","getNonDisabledOptions","container","querySelectorAll","useCombobox","options","form","popup","onClick","onFocus","onKeyDown","searchable","multiselect","isNegativeOneAllowed","loopable","disabled","visible","propVisible","setVisible","propSetVisible","defaultVisible","comboboxId","propComboboxId","comboboxRef","propComboboxRef","popupId","propPopupId","popupRef","propPopupRef","onFocusChange","extendKeyDown","getFocusableElements","getEnterDefaultFocusedIndex","getDefaultFocusedIndex","name","value","setValue","defaultValue","show","hide","popupRefCallback","focusLastRef","nodeRef","movementProps","movementContext","currentFocusIndex","activeDescendantId","setActiveDescendantId","ref","event","movementData","isPropagationStopped","key","stopPropagation","preventDefault","current","programmatic","includeDisabled","tabIndexBehavior","popupProps","undefined","id","role","focusLast","comboboxProps","getMenuProps","props","sheetProps","disableTransition","onEnter","onEntering","onEntered","onExited","onExiting","onExit","attemptScroll","activeOption","document","getElementById","scrollIntoView","block","onEnterOnce","focusables","index","option","element","anchor","width","fixedTo","onRequestClose","appearing","onExitOnce"],"mappings":"AAAA;AAEA,SASEA,WAAW,EACXC,MAAM,QACD,QAAQ;AAWf,SAASC,2BAA2B,QAAQ,6CAA6C;AACzF,SAASC,mBAAmB,QAAQ,8BAA8B;AAKlE,SAASC,sBAAsB,QAAQ,0CAA0C;AAGjF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,sBAAsB,QAAQ,aAAa;AAEpD,MAAMC,OAAO;AACX,aAAa;AACf;AAEA;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CACnCC,YAC2B;WACxBA,UAAUC,gBAAgB,CAC3B;KAEH,CAAC;AAiQF;;CAEC,GACD,OAAO,SAASC,YAIdC,OAA6C;IAE7C,MAAM,EACJC,IAAI,EACJC,QAAQ,SAAS,EACjBC,UAAUR,IAAI,EACdS,OAAO,EACPC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,oBAAoB,EACpBC,QAAQ,EACRC,QAAQ,EACRC,SAASC,WAAW,EACpBC,YAAYC,cAAc,EAC1BC,iBAAiB,KAAK,EACtBC,YAAYC,cAAc,EAC1BC,aAAaC,eAAe,EAC5BC,SAASC,WAAW,EACpBC,UAAUC,YAAY,EACtBC,gBAAgB7B,IAAI,EACpB8B,gBAAgB9B,IAAI,EACpB+B,uBAAuB9B,qBAAqB,EAC5C+B,2BAA2B,EAC3BC,sBAAsB,EACvB,GAAG5B;IAEJ,MAAM,CAACW,SAASE,WAAW,GAAGpB,gBAAgB;QAC5CoC,MAAM;QACNC,OAAOlB;QACPmB,UAAUjB;QACVkB,cAAcjB;IAChB;IACA,MAAMkB,OAAO/C,YAAY;QACvB2B,WAAW;IACb,GAAG;QAACA;KAAW;IACf,MAAMqB,OAAOhD,YAAY;QACvB2B,WAAW;IACb,GAAG;QAACA;KAAW;IAEf,MAAMO,UAAU7B,aAAa8B,aAAa;IAC1C,MAAML,aAAazB,aAAa0B,gBAAgB;IAChD,MAAM,CAACK,UAAUa,iBAAiB,GAAG3C,cAAc+B;IACnD,MAAMa,eAAejD,OAAO;IAC5B,MAAM,EACJkD,SAASnB,WAAW,EACpBoB,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,qBAAqB,EACtB,GAAGtD,4BAAwC;QAC1CuD,KAAKxB;QACLf;QACAC;QACAF,SAAQyC,KAAK;YACXzC,QAAQyC;YACR,IAAIlC,UAAU;gBACZ;YACF;YAEAuB;QACF;QACAR,eAAcoB,YAAY;YACxBpB,cAAc;gBACZ,GAAGoB,YAAY;gBACfZ;gBACAC;gBACAvB;gBACAyB;YACF;YACA,MAAM,EAAEQ,KAAK,EAAE,GAAGC;YAClB,IAAID,MAAME,oBAAoB,IAAI;gBAChC;YACF;YAEA,IAAInC,SAAS;gBACX,OAAQiC,MAAMG,GAAG;oBACf,KAAK;wBACH,+EAA+E;wBAC/Eb;wBACA;oBACF,KAAK;wBACHU,MAAMI,eAAe;wBACrBd;wBACA;oBACF,KAAK;wBACHU,MAAMK,cAAc;wBACpB;gBACJ;gBAEA,mEAAmE;gBACnE;YACF;YAEA,OAAQL,MAAMG,GAAG;gBACf,KAAK;gBACL,KAAK;oBACHH,MAAMK,cAAc;oBACpBL,MAAMI,eAAe;oBACrBZ,aAAac,OAAO,GAAGN,MAAMG,GAAG,KAAK;oBACrCd;oBACA;gBACF,KAAK;oBACHvC,uBAAuBkD,OAAO3C;oBAC9B;YACJ;QACF;QACAS;QACAD;QACAH;QACAkB;QACA2B,cAAc;QACdC,iBAAiB;QACjBC,kBAAkB;QAClB3B,sBAAqB7B,SAAS,EAAEsD,YAAY;YAC1C,MAAMjD,QAAQoB,SAAS4B,OAAO;YAC9B,IAAI,CAAChD,OAAO;gBACV,OAAO,EAAE;YACX;YAEA,OAAOwB,qBAAqBxB,SAASL,WAAWsD;QAClD;QACA3C;QACAoB;IACF;IAEA,MAAM0B,aAAgD;QACpD,wBAAwB/C,eAAegD;QACvCC,IAAIpC;QACJuB,KAAKR;QACLsB,MAAMvD;IACR;IAEA,OAAO;QACL+B;QACAC;QACAvB;QACAE;QACA6C,WAAWtB;QACXd;QACAgC;QACApC;QACAyC,eAAe;YACb,GAAGrB,aAAa;YAChB,iBAAiBlB;YACjB,iBAAiBV,YAAY6C;YAC7B,iBAAiB5C;YACjB,iBAAiBT;YACjBsD,IAAIxC;YACJyC,MAAM;QACR;QACAnB;QACAC;QACAC;QACAC;QACAC;QACAkB,cAAaC,QAAQ,CAAC,CAAC;YACrB,MAAM,EACJC,UAAU,EACVC,iBAAiB,EACjBC,OAAO,EACPC,UAAU,EACVC,YAAYvE,IAAI,EAChBwE,QAAQ,EACRC,SAAS,EACTC,MAAM,EACP,GAAGR;YAEJ,sEAAsE;YACtE,wEAAwE;YACxE,sEAAsE;YACtE,qEAAqE;YACrE,uDAAuD;YACvD,+DAA+D;YAC/D,MAAMS,gBAAgB;gBACpB,MAAMC,eAAeC,SAASC,cAAc,CAAChC;gBAC7C,IAAI8B,cAAc;oBAChBA,aAAaG,cAAc,CAAC;wBAAEC,OAAO;oBAAU;gBACjD;YACF;YACA,MAAMC,cAAc;gBAClB,MAAM1E,QAAQoB,SAAS4B,OAAO;gBAC9B,IAAI,CAAChD,OAAO;oBACVoE;oBACA;gBACF;gBAEA,MAAMO,aAAanD,qBAAqBxB,OAAO;gBAC/C,MAAM4E,QAAQnD,4BAA4B;oBACxC+B,WAAWtB,aAAac,OAAO;oBAC/B2B;oBACArC,mBAAmBA,kBAAkBU,OAAO;gBAC9C;gBACAd,aAAac,OAAO,GAAG;gBACvBV,kBAAkBU,OAAO,GAAG4B;gBAE5B,MAAMC,SAASF,UAAU,CAACC,MAAM;gBAChC,IAAI,CAACC,QAAQ;oBACX;gBACF;gBAEAvD,cAAc;oBACZsD;oBACAE,SAASD;gBACX;gBAEAA,OAAOL,cAAc,CAAC;oBAAEC,OAAO;gBAAU;gBACzCjC,sBAAsBqC,OAAOvB,EAAE,IAAI;YACrC;YAEA,OAAO;gBACLyB,QAAQ5F;gBACR6F,OAAO;gBACPC,SAASjE;gBACT,GAAG2C,KAAK;gBACR,GAAGP,UAAU;gBACb3C;gBACAyE,gBAAgBlD;gBAChB,GAAG5C,uBAAuB;oBACxByE;oBACAC;oBACAE,WAAW,CAACmB;wBACVnB,UAAUmB;wBACVf;oBACF;oBACAL;oBACAW;oBACAP;oBACAD;oBACAD;oBACAmB,YAAY;wBACV,uEAAuE;wBACvE,kEAAkE;wBAClE,SAAS;wBACT9C,kBAAkBU,OAAO,GAAG,CAAC;wBAC7BR,sBAAsB;oBACxB;gBACF,EAAE;gBACFoB,YAAY;oBACV,GAAGA,UAAU;oBACb,GAAGxE,uBAAuB;wBACxB,GAAGwE,UAAU;wBACbc;wBACAb,mBACED,YAAYC,qBAAqBA;oBACrC,EAAE;gBACJ;YACF;QACF;IACF;AACF"}
@@ -8,7 +8,7 @@ import { type ChangeableHTMLElement } from "./utils.js";
8
8
  */
9
9
  export interface FormResetOptions {
10
10
  form?: string;
11
- elementRef: RefObject<ChangeableHTMLElement>;
11
+ elementRef: RefObject<ChangeableHTMLElement | null>;
12
12
  onReset?: () => void;
13
13
  defaultValue?: string;
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/useFormReset.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect } from \"react\";\n\nimport {\n type ChangeableHTMLElement,\n triggerManualChangeEvent,\n} from \"./utils.js\";\n\n/**\n * @since 6.0.0\n * @since 6.3.0 Added the optional `onReset` callback and updated\n * `defaultValue` to be optional.\n * @internal\n */\nexport interface FormResetOptions {\n form?: string;\n elementRef: RefObject<ChangeableHTMLElement>;\n onReset?: () => void;\n defaultValue?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useFormReset(options: FormResetOptions): void {\n const { form, elementRef, defaultValue, onReset } = options;\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || (defaultValue === undefined && !onReset)) {\n return;\n }\n\n const formElement =\n (form && document.getElementById(form)) ||\n element.closest<HTMLFormElement>(\"form\") ||\n null;\n if (!formElement) {\n return;\n }\n\n const handleReset = (): void => {\n if (onReset) {\n onReset();\n } else if (defaultValue !== undefined) {\n triggerManualChangeEvent(element, defaultValue);\n }\n };\n\n formElement.addEventListener(\"reset\", handleReset);\n return () => {\n formElement.removeEventListener(\"reset\", handleReset);\n };\n }, [defaultValue, elementRef, form, onReset]);\n}\n"],"names":["useEffect","triggerManualChangeEvent","useFormReset","options","form","elementRef","defaultValue","onReset","element","current","undefined","formElement","document","getElementById","closest","handleReset","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAAyBA,SAAS,QAAQ,QAAQ;AAElD,SAEEC,wBAAwB,QACnB,aAAa;AAepB;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAAyB;IACpD,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,YAAY,EAAEC,OAAO,EAAE,GAAGJ;IAEpDH,UAAU;QACR,MAAMQ,UAAUH,WAAWI,OAAO;QAClC,IAAI,CAACD,WAAYF,iBAAiBI,aAAa,CAACH,SAAU;YACxD;QACF;QAEA,MAAMI,cACJ,AAACP,QAAQQ,SAASC,cAAc,CAACT,SACjCI,QAAQM,OAAO,CAAkB,WACjC;QACF,IAAI,CAACH,aAAa;YAChB;QACF;QAEA,MAAMI,cAAc;YAClB,IAAIR,SAAS;gBACXA;YACF,OAAO,IAAID,iBAAiBI,WAAW;gBACrCT,yBAAyBO,SAASF;YACpC;QACF;QAEAK,YAAYK,gBAAgB,CAAC,SAASD;QACtC,OAAO;YACLJ,YAAYM,mBAAmB,CAAC,SAASF;QAC3C;IACF,GAAG;QAACT;QAAcD;QAAYD;QAAMG;KAAQ;AAC9C"}
1
+ {"version":3,"sources":["../../src/form/useFormReset.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect } from \"react\";\n\nimport {\n type ChangeableHTMLElement,\n triggerManualChangeEvent,\n} from \"./utils.js\";\n\n/**\n * @since 6.0.0\n * @since 6.3.0 Added the optional `onReset` callback and updated\n * `defaultValue` to be optional.\n * @internal\n */\nexport interface FormResetOptions {\n form?: string;\n elementRef: RefObject<ChangeableHTMLElement | null>;\n onReset?: () => void;\n defaultValue?: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useFormReset(options: FormResetOptions): void {\n const { form, elementRef, defaultValue, onReset } = options;\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element || (defaultValue === undefined && !onReset)) {\n return;\n }\n\n const formElement =\n (form && document.getElementById(form)) ||\n element.closest<HTMLFormElement>(\"form\") ||\n null;\n if (!formElement) {\n return;\n }\n\n const handleReset = (): void => {\n if (onReset) {\n onReset();\n } else if (defaultValue !== undefined) {\n triggerManualChangeEvent(element, defaultValue);\n }\n };\n\n formElement.addEventListener(\"reset\", handleReset);\n return () => {\n formElement.removeEventListener(\"reset\", handleReset);\n };\n }, [defaultValue, elementRef, form, onReset]);\n}\n"],"names":["useEffect","triggerManualChangeEvent","useFormReset","options","form","elementRef","defaultValue","onReset","element","current","undefined","formElement","document","getElementById","closest","handleReset","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAAyBA,SAAS,QAAQ,QAAQ;AAElD,SAEEC,wBAAwB,QACnB,aAAa;AAepB;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAAyB;IACpD,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,YAAY,EAAEC,OAAO,EAAE,GAAGJ;IAEpDH,UAAU;QACR,MAAMQ,UAAUH,WAAWI,OAAO;QAClC,IAAI,CAACD,WAAYF,iBAAiBI,aAAa,CAACH,SAAU;YACxD;QACF;QAEA,MAAMI,cACJ,AAACP,QAAQQ,SAASC,cAAc,CAACT,SACjCI,QAAQM,OAAO,CAAkB,WACjC;QACF,IAAI,CAACH,aAAa;YAChB;QACF;QAEA,MAAMI,cAAc;YAClB,IAAIR,SAAS;gBACXA;YACF,OAAO,IAAID,iBAAiBI,WAAW;gBACrCT,yBAAyBO,SAASF;YACpC;QACF;QAEAK,YAAYK,gBAAgB,CAAC,SAASD;QACtC,OAAO;YACLJ,YAAYM,mBAAmB,CAAC,SAASF;QAC3C;IACF,GAAG;QAACT;QAAcD;QAAYD;QAAMG;KAAQ;AAC9C"}
@@ -1,7 +1,7 @@
1
1
  import { type HTMLAttributes, type ReactNode, type Ref, type RefCallback, type RefObject } from "react";
2
2
  import { type UseStateInitializer, type UseStateSetter } from "../types.js";
3
3
  import { type TextFieldProps } from "./TextField.js";
4
- import { type FormMessageInputLengthCounterProps, type FormMessageProps } from "./types.js";
4
+ import { type ConfigurableFormMessageProps, type FormMessageInputLengthCounterProps } from "./types.js";
5
5
  import { type GetErrorIcon, type GetErrorMessage, type IsErrored, type TextFieldValidationOptions, type TextFieldValidationType } from "./validation.js";
6
6
  /**
7
7
  * @since 2.5.0
@@ -14,7 +14,7 @@ export interface ErrorChangeHandlerOptions<E extends HTMLInputElement | HTMLText
14
14
  * A ref containing the `TextField` or `TextArea` if you need access to that
15
15
  * DOM node for error reporting.
16
16
  */
17
- ref: RefObject<E>;
17
+ ref: RefObject<E | null>;
18
18
  /**
19
19
  * The current name for the `TextField` or `TextArea`.
20
20
  */
@@ -75,7 +75,7 @@ export interface TextFieldHookState {
75
75
  *
76
76
  * @since 2.5.0
77
77
  */
78
- export interface ProvidedFormMessageProps extends Pick<FormMessageProps, "id" | "theme" | "children">, Required<Pick<TextFieldProps, "error">>, Partial<Pick<FormMessageInputLengthCounterProps, "length" | "maxLength">> {
78
+ export interface ProvidedFormMessageProps extends Pick<ConfigurableFormMessageProps, "id" | "theme" | "children">, Required<Pick<TextFieldProps, "error">>, Partial<Pick<FormMessageInputLengthCounterProps, "length" | "maxLength">> {
79
79
  }
80
80
  /**
81
81
  * All the props that will be generated and returned by the `useTextField` hook
@@ -257,7 +257,7 @@ export interface TextFieldHookOptions<E extends HTMLInputElement | HTMLTextAreaE
257
257
  }
258
258
  /** @since 6.0.0 */
259
259
  export interface TextFieldImplementation<E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> extends TextFieldHookState {
260
- fieldRef: RefObject<E>;
260
+ fieldRef: RefObject<E | null>;
261
261
  reset: () => void;
262
262
  setState: UseStateSetter<Readonly<TextFieldHookState>>;
263
263
  fieldProps: ProvidedTextFieldProps<E>;