@react-md/core 1.0.0-next.14 → 1.0.0-next.16

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 (1165) hide show
  1. package/dist/CoreProviders.js.map +1 -1
  2. package/dist/NoSsr.js.map +1 -1
  3. package/dist/RootHtml.d.ts +0 -2
  4. package/dist/RootHtml.js +0 -2
  5. package/dist/RootHtml.js.map +1 -1
  6. package/dist/SsrProvider.js.map +1 -1
  7. package/dist/app-bar/AppBar.d.ts +0 -2
  8. package/dist/app-bar/AppBar.js +0 -2
  9. package/dist/app-bar/AppBar.js.map +1 -1
  10. package/dist/app-bar/AppBarTitle.d.ts +8 -7
  11. package/dist/app-bar/AppBarTitle.js +3 -4
  12. package/dist/app-bar/AppBarTitle.js.map +1 -1
  13. package/dist/autocomplete/Autocomplete.js.map +1 -1
  14. package/dist/autocomplete/AutocompleteCircularProgress.js.map +1 -1
  15. package/dist/autocomplete/AutocompleteDropdownButton.js.map +1 -1
  16. package/dist/autocomplete/FilterAutocompleteOptions.js.map +1 -1
  17. package/dist/autocomplete/autocompleteStyles.js.map +1 -1
  18. package/dist/autocomplete/defaults.d.ts +2 -2
  19. package/dist/autocomplete/defaults.js +3 -3
  20. package/dist/autocomplete/defaults.js.map +1 -1
  21. package/dist/autocomplete/types.js.map +1 -1
  22. package/dist/avatar/Avatar.d.ts +1 -4
  23. package/dist/avatar/Avatar.js +1 -4
  24. package/dist/avatar/Avatar.js.map +1 -1
  25. package/dist/avatar/styles.js.map +1 -1
  26. package/dist/badge/Badge.d.ts +1 -3
  27. package/dist/badge/Badge.js +0 -2
  28. package/dist/badge/Badge.js.map +1 -1
  29. package/dist/box/Box.d.ts +0 -2
  30. package/dist/box/Box.js +0 -2
  31. package/dist/box/Box.js.map +1 -1
  32. package/dist/box/styles.js.map +1 -1
  33. package/dist/button/AsyncButton.js.map +1 -1
  34. package/dist/button/Button.js.map +1 -1
  35. package/dist/button/ButtonUnstyled.d.ts +0 -2
  36. package/dist/button/ButtonUnstyled.js +0 -2
  37. package/dist/button/ButtonUnstyled.js.map +1 -1
  38. package/dist/button/FloatingActionButton.js.map +1 -1
  39. package/dist/button/TooltippedButton.js.map +1 -1
  40. package/dist/button/buttonStyles.js.map +1 -1
  41. package/dist/button/buttonUnstyledStyles.js.map +1 -1
  42. package/dist/card/Card.d.ts +2 -3
  43. package/dist/card/Card.js +0 -2
  44. package/dist/card/Card.js.map +1 -1
  45. package/dist/card/CardContent.d.ts +0 -2
  46. package/dist/card/CardContent.js +0 -2
  47. package/dist/card/CardContent.js.map +1 -1
  48. package/dist/card/CardFooter.d.ts +0 -3
  49. package/dist/card/CardFooter.js +0 -2
  50. package/dist/card/CardFooter.js.map +1 -1
  51. package/dist/card/CardHeader.d.ts +0 -2
  52. package/dist/card/CardHeader.js +0 -2
  53. package/dist/card/CardHeader.js.map +1 -1
  54. package/dist/card/CardSubtitle.d.ts +6 -3
  55. package/dist/card/CardSubtitle.js +2 -3
  56. package/dist/card/CardSubtitle.js.map +1 -1
  57. package/dist/card/CardTitle.d.ts +0 -3
  58. package/dist/card/CardTitle.js +0 -2
  59. package/dist/card/CardTitle.js.map +1 -1
  60. package/dist/card/ClickableCard.js.map +1 -1
  61. package/dist/card/styles.js +2 -4
  62. package/dist/card/styles.js.map +1 -1
  63. package/dist/chip/Chip.d.ts +0 -2
  64. package/dist/chip/Chip.js +0 -2
  65. package/dist/chip/Chip.js.map +1 -1
  66. package/dist/chip/styles.js.map +1 -1
  67. package/dist/cssUtils.d.ts +1 -1
  68. package/dist/cssUtils.js.map +1 -1
  69. package/dist/delegateEvent.js.map +1 -1
  70. package/dist/dialog/Dialog.js.map +1 -1
  71. package/dist/dialog/DialogContainer.d.ts +0 -2
  72. package/dist/dialog/DialogContainer.js +0 -2
  73. package/dist/dialog/DialogContainer.js.map +1 -1
  74. package/dist/dialog/DialogContent.d.ts +3 -3
  75. package/dist/dialog/DialogContent.js +3 -3
  76. package/dist/dialog/DialogContent.js.map +1 -1
  77. package/dist/dialog/DialogFooter.d.ts +2 -3
  78. package/dist/dialog/DialogFooter.js +2 -3
  79. package/dist/dialog/DialogFooter.js.map +1 -1
  80. package/dist/dialog/DialogHeader.d.ts +3 -3
  81. package/dist/dialog/DialogHeader.js +3 -3
  82. package/dist/dialog/DialogHeader.js.map +1 -1
  83. package/dist/dialog/DialogTitle.d.ts +3 -4
  84. package/dist/dialog/DialogTitle.js +3 -3
  85. package/dist/dialog/DialogTitle.js.map +1 -1
  86. package/dist/dialog/FixedDialog.js.map +1 -1
  87. package/dist/dialog/NestedDialogProvider.d.ts +0 -1
  88. package/dist/dialog/NestedDialogProvider.js.map +1 -1
  89. package/dist/dialog/styles.js.map +1 -1
  90. package/dist/divider/Divider.d.ts +0 -2
  91. package/dist/divider/Divider.js +0 -2
  92. package/dist/divider/Divider.js.map +1 -1
  93. package/dist/divider/styles.js.map +1 -1
  94. package/dist/draggable/useDraggable.js.map +1 -1
  95. package/dist/draggable/utils.js.map +1 -1
  96. package/dist/expansion-panel/ExpansionList.d.ts +1 -1
  97. package/dist/expansion-panel/ExpansionList.js +1 -1
  98. package/dist/expansion-panel/ExpansionList.js.map +1 -1
  99. package/dist/expansion-panel/ExpansionPanel.d.ts +8 -24
  100. package/dist/expansion-panel/ExpansionPanel.js +1 -12
  101. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  102. package/dist/expansion-panel/ExpansionPanelHeader.d.ts +0 -1
  103. package/dist/expansion-panel/ExpansionPanelHeader.js +0 -1
  104. package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
  105. package/dist/expansion-panel/expansionPanelStyles.d.ts +19 -0
  106. package/dist/expansion-panel/expansionPanelStyles.js +14 -0
  107. package/dist/expansion-panel/expansionPanelStyles.js.map +1 -0
  108. package/dist/expansion-panel/useExpansionList.js.map +1 -1
  109. package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
  110. package/dist/focus/useFocusContainer.js.map +1 -1
  111. package/dist/focus/utils.js.map +1 -1
  112. package/dist/form/Checkbox.d.ts +0 -1
  113. package/dist/form/Checkbox.js.map +1 -1
  114. package/dist/form/Fieldset.d.ts +0 -2
  115. package/dist/form/Fieldset.js.map +1 -1
  116. package/dist/form/FileInput.js.map +1 -1
  117. package/dist/form/Form.js.map +1 -1
  118. package/dist/form/FormMessage.d.ts +0 -3
  119. package/dist/form/FormMessage.js +0 -2
  120. package/dist/form/FormMessage.js.map +1 -1
  121. package/dist/form/FormMessageContainer.d.ts +0 -1
  122. package/dist/form/FormMessageContainer.js +0 -1
  123. package/dist/form/FormMessageContainer.js.map +1 -1
  124. package/dist/form/FormMessageCounter.d.ts +0 -2
  125. package/dist/form/FormMessageCounter.js +0 -2
  126. package/dist/form/FormMessageCounter.js.map +1 -1
  127. package/dist/form/InputToggle.js.map +1 -1
  128. package/dist/form/InputToggleIcon.d.ts +0 -2
  129. package/dist/form/InputToggleIcon.js +0 -2
  130. package/dist/form/InputToggleIcon.js.map +1 -1
  131. package/dist/form/Label.d.ts +0 -3
  132. package/dist/form/Label.js +0 -2
  133. package/dist/form/Label.js.map +1 -1
  134. package/dist/form/Legend.d.ts +0 -3
  135. package/dist/form/Legend.js +0 -2
  136. package/dist/form/Legend.js.map +1 -1
  137. package/dist/form/MenuItemCheckbox.d.ts +0 -1
  138. package/dist/form/MenuItemCheckbox.js.map +1 -1
  139. package/dist/form/MenuItemFileInput.js.map +1 -1
  140. package/dist/form/MenuItemInputToggle.js.map +1 -1
  141. package/dist/form/MenuItemRadio.d.ts +0 -1
  142. package/dist/form/MenuItemRadio.js.map +1 -1
  143. package/dist/form/MenuItemSwitch.d.ts +0 -1
  144. package/dist/form/MenuItemSwitch.js.map +1 -1
  145. package/dist/form/MenuItemTextField.js.map +1 -1
  146. package/dist/form/NativeSelect.d.ts +0 -2
  147. package/dist/form/NativeSelect.js +0 -2
  148. package/dist/form/NativeSelect.js.map +1 -1
  149. package/dist/form/OptGroup.js.map +1 -1
  150. package/dist/form/Option.js.map +1 -1
  151. package/dist/form/Password.js.map +1 -1
  152. package/dist/form/Radio.d.ts +0 -1
  153. package/dist/form/Radio.js.map +1 -1
  154. package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
  155. package/dist/form/Select.js.map +1 -1
  156. package/dist/form/SelectedOption.d.ts +0 -2
  157. package/dist/form/SelectedOption.js +0 -2
  158. package/dist/form/SelectedOption.js.map +1 -1
  159. package/dist/form/Slider.js.map +1 -1
  160. package/dist/form/SliderContainer.d.ts +0 -2
  161. package/dist/form/SliderContainer.js +0 -2
  162. package/dist/form/SliderContainer.js.map +1 -1
  163. package/dist/form/SliderMark.d.ts +0 -2
  164. package/dist/form/SliderMark.js +0 -2
  165. package/dist/form/SliderMark.js.map +1 -1
  166. package/dist/form/SliderMarkLabel.d.ts +0 -2
  167. package/dist/form/SliderMarkLabel.js +0 -2
  168. package/dist/form/SliderMarkLabel.js.map +1 -1
  169. package/dist/form/SliderThumb.js.map +1 -1
  170. package/dist/form/SliderTrack.d.ts +0 -2
  171. package/dist/form/SliderTrack.js +0 -2
  172. package/dist/form/SliderTrack.js.map +1 -1
  173. package/dist/form/SliderValueMarks.d.ts +0 -2
  174. package/dist/form/SliderValueMarks.js +0 -2
  175. package/dist/form/SliderValueMarks.js.map +1 -1
  176. package/dist/form/SliderValueTooltip.js.map +1 -1
  177. package/dist/form/Switch.d.ts +0 -2
  178. package/dist/form/Switch.js +0 -2
  179. package/dist/form/Switch.js.map +1 -1
  180. package/dist/form/SwitchTrack.d.ts +2 -1
  181. package/dist/form/SwitchTrack.js +2 -1
  182. package/dist/form/SwitchTrack.js.map +1 -1
  183. package/dist/form/TextArea.js.map +1 -1
  184. package/dist/form/TextField.d.ts +0 -2
  185. package/dist/form/TextField.js +0 -2
  186. package/dist/form/TextField.js.map +1 -1
  187. package/dist/form/TextFieldAddon.d.ts +1 -4
  188. package/dist/form/TextFieldAddon.js +1 -3
  189. package/dist/form/TextFieldAddon.js.map +1 -1
  190. package/dist/form/TextFieldContainer.js.map +1 -1
  191. package/dist/form/fileUtils.js.map +1 -1
  192. package/dist/form/formConfig.js.map +1 -1
  193. package/dist/form/formMessageStyles.js.map +1 -1
  194. package/dist/form/inputToggleStyles.js.map +1 -1
  195. package/dist/form/menuItemInputToggleStyles.js.map +1 -1
  196. package/dist/form/nativeSelectStyles.js.map +1 -1
  197. package/dist/form/optionStyles.js.map +1 -1
  198. package/dist/form/passwordStyles.js.map +1 -1
  199. package/dist/form/selectStyles.js.map +1 -1
  200. package/dist/form/selectUtils.js.map +1 -1
  201. package/dist/form/sliderUtils.js.map +1 -1
  202. package/dist/form/switchStyles.js.map +1 -1
  203. package/dist/form/textAreaStyles.js.map +1 -1
  204. package/dist/form/textFieldContainerStyles.js.map +1 -1
  205. package/dist/form/textFieldStyles.js.map +1 -1
  206. package/dist/form/types.js.map +1 -1
  207. package/dist/form/useCheckboxGroup.js.map +1 -1
  208. package/dist/form/useCombobox.js.map +1 -1
  209. package/dist/form/useEditableCombobox.js.map +1 -1
  210. package/dist/form/useFileUpload.js.map +1 -1
  211. package/dist/form/useFormReset.js.map +1 -1
  212. package/dist/form/useListboxProvider.js.map +1 -1
  213. package/dist/form/useNumberField.js.map +1 -1
  214. package/dist/form/useRadioGroup.js.map +1 -1
  215. package/dist/form/useRangeSlider.js.map +1 -1
  216. package/dist/form/useResizingTextArea.js.map +1 -1
  217. package/dist/form/useSelectCombobox.js.map +1 -1
  218. package/dist/form/useSlider.js.map +1 -1
  219. package/dist/form/useTextField.js.map +1 -1
  220. package/dist/form/useTextFieldContainerAddons.js.map +1 -1
  221. package/dist/form/utils.js.map +1 -1
  222. package/dist/form/validation.js.map +1 -1
  223. package/dist/hoverMode/useHoverMode.js.map +1 -1
  224. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  225. package/dist/icon/FontIcon.d.ts +10 -8
  226. package/dist/icon/FontIcon.js +1 -7
  227. package/dist/icon/FontIcon.js.map +1 -1
  228. package/dist/icon/IconRotator.d.ts +0 -2
  229. package/dist/icon/IconRotator.js +0 -2
  230. package/dist/icon/IconRotator.js.map +1 -1
  231. package/dist/icon/MaterialIcon.d.ts +18 -3
  232. package/dist/icon/MaterialIcon.js +13 -3
  233. package/dist/icon/MaterialIcon.js.map +1 -1
  234. package/dist/icon/MaterialSymbol.d.ts +0 -1
  235. package/dist/icon/MaterialSymbol.js +0 -1
  236. package/dist/icon/MaterialSymbol.js.map +1 -1
  237. package/dist/icon/SVGIcon.d.ts +3 -2
  238. package/dist/icon/SVGIcon.js +0 -2
  239. package/dist/icon/SVGIcon.js.map +1 -1
  240. package/dist/icon/TextIconSpacing.d.ts +0 -2
  241. package/dist/icon/TextIconSpacing.js +0 -2
  242. package/dist/icon/TextIconSpacing.js.map +1 -1
  243. package/dist/icon/_icon.scss +2 -2
  244. package/dist/icon/iconConfig.d.ts +1 -0
  245. package/dist/icon/iconConfig.js +1 -0
  246. package/dist/icon/iconConfig.js.map +1 -1
  247. package/dist/icon/material.d.ts +1 -1
  248. package/dist/icon/material.js.map +1 -1
  249. package/dist/icon/materialConfig.js.map +1 -1
  250. package/dist/icon/styles.js +1 -1
  251. package/dist/icon/styles.js.map +1 -1
  252. package/dist/interaction/Ripple.js.map +1 -1
  253. package/dist/interaction/RippleContainer.d.ts +0 -2
  254. package/dist/interaction/RippleContainer.js +0 -2
  255. package/dist/interaction/RippleContainer.js.map +1 -1
  256. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  257. package/dist/interaction/config.js.map +1 -1
  258. package/dist/interaction/types.js.map +1 -1
  259. package/dist/interaction/useElementInteraction.js.map +1 -1
  260. package/dist/interaction/useHigherContrastChildren.js.map +1 -1
  261. package/dist/interaction/utils.js.map +1 -1
  262. package/dist/layout/LayoutAppBar.d.ts +0 -1
  263. package/dist/layout/LayoutAppBar.js.map +1 -1
  264. package/dist/layout/LayoutNav.js +1 -2
  265. package/dist/layout/LayoutNav.js.map +1 -1
  266. package/dist/layout/LayoutWindowSplitter.d.ts +0 -1
  267. package/dist/layout/LayoutWindowSplitter.js.map +1 -1
  268. package/dist/layout/Main.js.map +1 -1
  269. package/dist/layout/layoutNavStyles.js.map +1 -1
  270. package/dist/layout/layoutWindowSplitterStyles.js.map +1 -1
  271. package/dist/layout/mainStyles.js.map +1 -1
  272. package/dist/layout/useExpandableLayout.js.map +1 -1
  273. package/dist/layout/useHorizontalLayoutTransition.js +1 -1
  274. package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
  275. package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
  276. package/dist/layout/useLayoutTree.d.ts +2 -2
  277. package/dist/layout/useLayoutTree.js.map +1 -1
  278. package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
  279. package/dist/layout/useMainTabIndex.js.map +1 -1
  280. package/dist/layout/useResizableLayout.js.map +1 -1
  281. package/dist/layout/useTemporaryLayout.js.map +1 -1
  282. package/dist/link/Link.d.ts +2 -6
  283. package/dist/link/Link.js +1 -4
  284. package/dist/link/Link.js.map +1 -1
  285. package/dist/link/SkipToMainContent.d.ts +10 -3
  286. package/dist/link/SkipToMainContent.js +4 -1
  287. package/dist/link/SkipToMainContent.js.map +1 -1
  288. package/dist/link/styles.d.ts +2 -2
  289. package/dist/link/styles.js.map +1 -1
  290. package/dist/list/List.d.ts +0 -20
  291. package/dist/list/List.js +1 -14
  292. package/dist/list/List.js.map +1 -1
  293. package/dist/list/ListItem.d.ts +0 -16
  294. package/dist/list/ListItem.js.map +1 -1
  295. package/dist/list/ListItemAddon.d.ts +0 -2
  296. package/dist/list/ListItemAddon.js +0 -2
  297. package/dist/list/ListItemAddon.js.map +1 -1
  298. package/dist/list/ListItemChildren.d.ts +0 -2
  299. package/dist/list/ListItemChildren.js +0 -2
  300. package/dist/list/ListItemChildren.js.map +1 -1
  301. package/dist/list/ListItemLink.js.map +1 -1
  302. package/dist/list/ListItemText.d.ts +0 -2
  303. package/dist/list/ListItemText.js +0 -2
  304. package/dist/list/ListItemText.js.map +1 -1
  305. package/dist/list/ListSubheader.d.ts +3 -2
  306. package/dist/list/ListSubheader.js +0 -2
  307. package/dist/list/ListSubheader.js.map +1 -1
  308. package/dist/list/getListItemHeight.d.ts +2 -2
  309. package/dist/list/getListItemHeight.js +2 -2
  310. package/dist/list/getListItemHeight.js.map +1 -1
  311. package/dist/list/listItemStyles.d.ts +17 -1
  312. package/dist/list/listItemStyles.js.map +1 -1
  313. package/dist/list/listStyles.d.ts +18 -0
  314. package/dist/list/listStyles.js +14 -0
  315. package/dist/list/listStyles.js.map +1 -0
  316. package/dist/list/types.d.ts +9 -3
  317. package/dist/list/types.js +6 -1
  318. package/dist/list/types.js.map +1 -1
  319. package/dist/media-queries/AppSizeProvider.d.ts +8 -0
  320. package/dist/media-queries/AppSizeProvider.js +2 -0
  321. package/dist/media-queries/AppSizeProvider.js.map +1 -1
  322. package/dist/media-queries/appSize.d.ts +5 -5
  323. package/dist/media-queries/appSize.js.map +1 -1
  324. package/dist/media-queries/useMediaQuery.d.ts +1 -1
  325. package/dist/media-queries/useMediaQuery.js +1 -1
  326. package/dist/media-queries/useMediaQuery.js.map +1 -1
  327. package/dist/menu/DropdownMenu.js.map +1 -1
  328. package/dist/menu/Menu.js.map +1 -1
  329. package/dist/menu/MenuBar.d.ts +0 -1
  330. package/dist/menu/MenuBar.js.map +1 -1
  331. package/dist/menu/MenuButton.d.ts +0 -1
  332. package/dist/menu/MenuButton.js.map +1 -1
  333. package/dist/menu/MenuConfigurationProvider.js.map +1 -1
  334. package/dist/menu/MenuItem.d.ts +0 -1
  335. package/dist/menu/MenuItem.js.map +1 -1
  336. package/dist/menu/MenuItemButton.d.ts +0 -1
  337. package/dist/menu/MenuItemButton.js.map +1 -1
  338. package/dist/menu/MenuItemCircularProgress.js.map +1 -1
  339. package/dist/menu/MenuItemGroup.js.map +1 -1
  340. package/dist/menu/MenuItemSeparator.js.map +1 -1
  341. package/dist/menu/MenuSheet.js.map +1 -1
  342. package/dist/menu/MenuVisibilityProvider.js.map +1 -1
  343. package/dist/menu/MenuWidget.js.map +1 -1
  344. package/dist/menu/MenuWidgetKeyboardProvider.js.map +1 -1
  345. package/dist/menu/useContextMenu.js.map +1 -1
  346. package/dist/menu/useMenuBarProvider.d.ts +0 -1
  347. package/dist/menu/useMenuBarProvider.js.map +1 -1
  348. package/dist/menu/utils.js.map +1 -1
  349. package/dist/movement/constants.js.map +1 -1
  350. package/dist/movement/findMatchIndex.js.map +1 -1
  351. package/dist/movement/types.js.map +1 -1
  352. package/dist/movement/useKeyboardMovementProvider.d.ts +0 -1
  353. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  354. package/dist/movement/utils.js.map +1 -1
  355. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  356. package/dist/navigation/DefaultNavigationRenderer.js.map +1 -1
  357. package/dist/navigation/NavGroup.d.ts +0 -2
  358. package/dist/navigation/NavGroup.js +0 -2
  359. package/dist/navigation/NavGroup.js.map +1 -1
  360. package/dist/navigation/NavItem.d.ts +0 -2
  361. package/dist/navigation/NavItem.js +0 -2
  362. package/dist/navigation/NavItem.js.map +1 -1
  363. package/dist/navigation/NavItemButton.js.map +1 -1
  364. package/dist/navigation/NavItemLink.js.map +1 -1
  365. package/dist/navigation/NavSubheader.d.ts +0 -3
  366. package/dist/navigation/NavSubheader.js +0 -2
  367. package/dist/navigation/NavSubheader.js.map +1 -1
  368. package/dist/navigation/Navigation.js.map +1 -1
  369. package/dist/navigation/getHrefFromParents.js.map +1 -1
  370. package/dist/navigation/navGroupStyles.js.map +1 -1
  371. package/dist/navigation/navItemStyles.js.map +1 -1
  372. package/dist/navigation/types.js.map +1 -1
  373. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  374. package/dist/overlay/Overlay.d.ts +1 -0
  375. package/dist/overlay/Overlay.js.map +1 -1
  376. package/dist/overlay/overlayStyles.js.map +1 -1
  377. package/dist/portal/Portal.d.ts +4 -0
  378. package/dist/portal/Portal.js.map +1 -1
  379. package/dist/portal/PortalContainerProvider.d.ts +8 -3
  380. package/dist/portal/PortalContainerProvider.js +1 -0
  381. package/dist/portal/PortalContainerProvider.js.map +1 -1
  382. package/dist/positioning/constants.js.map +1 -1
  383. package/dist/positioning/createHorizontalPosition.js.map +1 -1
  384. package/dist/positioning/createVerticalPosition.js.map +1 -1
  385. package/dist/positioning/getFixedPosition.js.map +1 -1
  386. package/dist/positioning/types.js.map +1 -1
  387. package/dist/positioning/useFixedPositioning.js.map +1 -1
  388. package/dist/positioning/utils.js.map +1 -1
  389. package/dist/progress/CircularProgress.d.ts +5 -6
  390. package/dist/progress/CircularProgress.js +0 -2
  391. package/dist/progress/CircularProgress.js.map +1 -1
  392. package/dist/progress/LinearProgress.d.ts +0 -2
  393. package/dist/progress/LinearProgress.js +0 -2
  394. package/dist/progress/LinearProgress.js.map +1 -1
  395. package/dist/progress/getProgressA11y.js.map +1 -1
  396. package/dist/progress/types.js.map +1 -1
  397. package/dist/responsive-item/ResponsiveItemContainer.d.ts +0 -2
  398. package/dist/responsive-item/ResponsiveItemContainer.js +0 -2
  399. package/dist/responsive-item/ResponsiveItemContainer.js.map +1 -1
  400. package/dist/responsive-item/ResponsiveItemOverlay.d.ts +0 -2
  401. package/dist/responsive-item/ResponsiveItemOverlay.js +0 -2
  402. package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
  403. package/dist/responsive-item/styles.js.map +1 -1
  404. package/dist/scroll/ScrollLock.js.map +1 -1
  405. package/dist/scroll/getScrollbarWidth.js.map +1 -1
  406. package/dist/scroll/useScrollLock.js.map +1 -1
  407. package/dist/searching/caseInsensitive.js.map +1 -1
  408. package/dist/searching/fuzzy.js.map +1 -1
  409. package/dist/searching/toSearchQuery.js.map +1 -1
  410. package/dist/searching/types.js.map +1 -1
  411. package/dist/searching/useFuzzyMatch.js.map +1 -1
  412. package/dist/searching/utils.js.map +1 -1
  413. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  414. package/dist/segmented-button/SegmentedButtonContainer.d.ts +0 -2
  415. package/dist/segmented-button/SegmentedButtonContainer.js +0 -2
  416. package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
  417. package/dist/segmented-button/segmentedButtonContainerStyles.js.map +1 -1
  418. package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
  419. package/dist/sheet/Sheet.d.ts +30 -16
  420. package/dist/sheet/Sheet.js +24 -14
  421. package/dist/sheet/Sheet.js.map +1 -1
  422. package/dist/sheet/styles.d.ts +29 -0
  423. package/dist/sheet/styles.js +13 -0
  424. package/dist/sheet/styles.js.map +1 -1
  425. package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
  426. package/dist/snackbar/Snackbar.js.map +1 -1
  427. package/dist/snackbar/Toast.js.map +1 -1
  428. package/dist/snackbar/ToastActionButton.d.ts +0 -1
  429. package/dist/snackbar/ToastActionButton.js.map +1 -1
  430. package/dist/snackbar/ToastCloseButton.d.ts +0 -1
  431. package/dist/snackbar/ToastCloseButton.js.map +1 -1
  432. package/dist/snackbar/ToastContent.js.map +1 -1
  433. package/dist/snackbar/ToastManager.js.map +1 -1
  434. package/dist/snackbar/ToastManagerProvider.js.map +1 -1
  435. package/dist/snackbar/snackbarStyles.js.map +1 -1
  436. package/dist/snackbar/toastContentStyles.js.map +1 -1
  437. package/dist/snackbar/toastStyles.js.map +1 -1
  438. package/dist/snackbar/useCurrentToastActions.d.ts +0 -1
  439. package/dist/snackbar/useCurrentToastActions.js.map +1 -1
  440. package/dist/suspense/CircularProgressSuspense.d.ts +0 -2
  441. package/dist/suspense/CircularProgressSuspense.js +0 -2
  442. package/dist/suspense/CircularProgressSuspense.js.map +1 -1
  443. package/dist/suspense/NullSuspense.d.ts +0 -2
  444. package/dist/suspense/NullSuspense.js +0 -2
  445. package/dist/suspense/NullSuspense.js.map +1 -1
  446. package/dist/table/StickyTableSection.d.ts +23 -0
  447. package/dist/table/StickyTableSection.js +56 -0
  448. package/dist/table/StickyTableSection.js.map +1 -0
  449. package/dist/table/Table.d.ts +1 -1
  450. package/dist/table/Table.js.map +1 -1
  451. package/dist/table/TableBody.d.ts +1 -1
  452. package/dist/table/TableBody.js.map +1 -1
  453. package/dist/table/TableCell.d.ts +3 -2
  454. package/dist/table/TableCell.js.map +1 -1
  455. package/dist/table/TableCellContent.d.ts +1 -5
  456. package/dist/table/TableCellContent.js +0 -3
  457. package/dist/table/TableCellContent.js.map +1 -1
  458. package/dist/table/TableCheckbox.js.map +1 -1
  459. package/dist/table/TableConfigurationProvider.d.ts +1 -74
  460. package/dist/table/TableConfigurationProvider.js.map +1 -1
  461. package/dist/table/TableContainer.js.map +1 -1
  462. package/dist/table/TableContainerProvider.js.map +1 -1
  463. package/dist/table/TableFooter.d.ts +8 -17
  464. package/dist/table/TableFooter.js +17 -80
  465. package/dist/table/TableFooter.js.map +1 -1
  466. package/dist/table/TableHeader.d.ts +8 -17
  467. package/dist/table/TableHeader.js +20 -87
  468. package/dist/table/TableHeader.js.map +1 -1
  469. package/dist/table/TableRadio.js.map +1 -1
  470. package/dist/table/TableRow.d.ts +1 -1
  471. package/dist/table/TableRow.js.map +1 -1
  472. package/dist/table/tableCellStyles.d.ts +1 -1
  473. package/dist/table/tableCellStyles.js.map +1 -1
  474. package/dist/table/tableContainerStyles.js.map +1 -1
  475. package/dist/table/tableFooterStyles.js.map +1 -1
  476. package/dist/table/tableHeaderStyles.js.map +1 -1
  477. package/dist/table/tableRowStyles.js.map +1 -1
  478. package/dist/table/tableStyles.js.map +1 -1
  479. package/dist/table/types.d.ts +89 -9
  480. package/dist/table/types.js.map +1 -1
  481. package/dist/table/useStickyTableSection.d.ts +27 -0
  482. package/dist/table/useStickyTableSection.js +84 -0
  483. package/dist/table/useStickyTableSection.js.map +1 -0
  484. package/dist/table/useTableSectionConfig.d.ts +13 -0
  485. package/dist/table/useTableSectionConfig.js +33 -0
  486. package/dist/table/useTableSectionConfig.js.map +1 -0
  487. package/dist/tabs/Tab.d.ts +3 -0
  488. package/dist/tabs/Tab.js.map +1 -1
  489. package/dist/tabs/TabList.js.map +1 -1
  490. package/dist/tabs/TabListScrollButton.js +5 -1
  491. package/dist/tabs/TabListScrollButton.js.map +1 -1
  492. package/dist/tabs/_tabs.scss +21 -3
  493. package/dist/tabs/tabIndicatorStyles.js.map +1 -1
  494. package/dist/tabs/tabListScrollButtonStyles.d.ts +2 -0
  495. package/dist/tabs/tabListScrollButtonStyles.js +9 -5
  496. package/dist/tabs/tabListScrollButtonStyles.js.map +1 -1
  497. package/dist/tabs/tabListStyles.js.map +1 -1
  498. package/dist/tabs/tabStyles.js.map +1 -1
  499. package/dist/tabs/useTabList.d.ts +2 -0
  500. package/dist/tabs/useTabList.js +4 -2
  501. package/dist/tabs/useTabList.js.map +1 -1
  502. package/dist/tabs/useTabs.d.ts +33 -11
  503. package/dist/tabs/useTabs.js +9 -3
  504. package/dist/tabs/useTabs.js.map +1 -1
  505. package/dist/tabs/utils.js.map +1 -1
  506. package/dist/test-utils/IntersectionObserver.js.map +1 -1
  507. package/dist/test-utils/ResizeObserver.js.map +1 -1
  508. package/dist/test-utils/data-testid.d.ts +0 -1
  509. package/dist/test-utils/data-testid.js.map +1 -1
  510. package/dist/test-utils/index.js.map +1 -1
  511. package/dist/test-utils/jest-setup.js.map +1 -1
  512. package/dist/test-utils/matchMedia.js.map +1 -1
  513. package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
  514. package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
  515. package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
  516. package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
  517. package/dist/test-utils/polyfills/index.js.map +1 -1
  518. package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
  519. package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
  520. package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
  521. package/dist/test-utils/render.js.map +1 -1
  522. package/dist/test-utils/timers.js.map +1 -1
  523. package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
  524. package/dist/theme/ThemeProvider.js.map +1 -1
  525. package/dist/theme/_theme.scss +2 -1
  526. package/dist/theme/colors.js.map +1 -1
  527. package/dist/theme/cssVars.js.map +1 -1
  528. package/dist/theme/types.js.map +1 -1
  529. package/dist/theme/useCSSVariables.js.map +1 -1
  530. package/dist/theme/useColorScheme.d.ts +0 -1
  531. package/dist/theme/useColorScheme.js.map +1 -1
  532. package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
  533. package/dist/theme/useColorSchemeProvider.js.map +1 -1
  534. package/dist/theme/usePrefersColorScheme.js.map +1 -1
  535. package/dist/theme/utils.js.map +1 -1
  536. package/dist/tooltip/Tooltip.d.ts +20 -9
  537. package/dist/tooltip/Tooltip.js.map +1 -1
  538. package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
  539. package/dist/tooltip/constants.js.map +1 -1
  540. package/dist/tooltip/tooltipStyles.js.map +1 -1
  541. package/dist/tooltip/useTooltip.d.ts +30 -16
  542. package/dist/tooltip/useTooltip.js.map +1 -1
  543. package/dist/tooltip/useTooltipPosition.d.ts +2 -4
  544. package/dist/tooltip/useTooltipPosition.js.map +1 -1
  545. package/dist/tooltip/utils.js.map +1 -1
  546. package/dist/transition/CSSTransition.js.map +1 -1
  547. package/dist/transition/Collapse.js.map +1 -1
  548. package/dist/transition/CrossFade.js.map +1 -1
  549. package/dist/transition/ScaleTransition.js.map +1 -1
  550. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  551. package/dist/transition/Slide.js.map +1 -1
  552. package/dist/transition/SlideContainer.d.ts +2 -48
  553. package/dist/transition/SlideContainer.js +2 -48
  554. package/dist/transition/SlideContainer.js.map +1 -1
  555. package/dist/transition/collapseStyles.js.map +1 -1
  556. package/dist/transition/config.js.map +1 -1
  557. package/dist/transition/maxWidthTransition.js.map +1 -1
  558. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  559. package/dist/transition/types.d.ts +19 -24
  560. package/dist/transition/types.js.map +1 -1
  561. package/dist/transition/useCSSTransition.js.map +1 -1
  562. package/dist/transition/useCarousel.js.map +1 -1
  563. package/dist/transition/useCollapseTransition.js.map +1 -1
  564. package/dist/transition/useCrossFadeTransition.js.map +1 -1
  565. package/dist/transition/useMaxWidthTransition.js.map +1 -1
  566. package/dist/transition/useScaleTransition.js.map +1 -1
  567. package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
  568. package/dist/transition/useSlideTransition.js.map +1 -1
  569. package/dist/transition/useTransition.d.ts +1 -0
  570. package/dist/transition/useTransition.js +1 -0
  571. package/dist/transition/useTransition.js.map +1 -1
  572. package/dist/transition/utils.js.map +1 -1
  573. package/dist/tree/DefaultTreeItemRenderer.d.ts +2 -3
  574. package/dist/tree/DefaultTreeItemRenderer.js +1 -1
  575. package/dist/tree/DefaultTreeItemRenderer.js.map +1 -1
  576. package/dist/tree/Tree.d.ts +3 -4
  577. package/dist/tree/Tree.js.map +1 -1
  578. package/dist/tree/TreeGroup.js.map +1 -1
  579. package/dist/tree/TreeItem.d.ts +10 -3
  580. package/dist/tree/TreeItem.js +5 -2
  581. package/dist/tree/TreeItem.js.map +1 -1
  582. package/dist/tree/TreeItemExpander.js.map +1 -1
  583. package/dist/tree/TreeProvider.js.map +1 -1
  584. package/dist/tree/styles.js.map +1 -1
  585. package/dist/tree/types.d.ts +11 -6
  586. package/dist/tree/types.js +1 -26
  587. package/dist/tree/types.js.map +1 -1
  588. package/dist/tree/useTree.d.ts +5 -5
  589. package/dist/tree/useTree.js.map +1 -1
  590. package/dist/tree/useTreeExpansion.d.ts +3 -3
  591. package/dist/tree/useTreeExpansion.js.map +1 -1
  592. package/dist/tree/useTreeItems.js.map +1 -1
  593. package/dist/tree/useTreeMovement.js.map +1 -1
  594. package/dist/tree/useTreeSelection.d.ts +3 -3
  595. package/dist/tree/useTreeSelection.js.map +1 -1
  596. package/dist/tree/utils.js.map +1 -1
  597. package/dist/types.js.map +1 -1
  598. package/dist/typography/SrOnly.d.ts +2 -1
  599. package/dist/typography/SrOnly.js +2 -1
  600. package/dist/typography/SrOnly.js.map +1 -1
  601. package/dist/typography/TextContainer.d.ts +4 -2
  602. package/dist/typography/TextContainer.js +2 -2
  603. package/dist/typography/TextContainer.js.map +1 -1
  604. package/dist/typography/Typography.d.ts +10 -2
  605. package/dist/typography/Typography.js +3 -2
  606. package/dist/typography/Typography.js.map +1 -1
  607. package/dist/typography/WritingDirectionProvider.d.ts +2 -2
  608. package/dist/typography/WritingDirectionProvider.js +2 -2
  609. package/dist/typography/WritingDirectionProvider.js.map +1 -1
  610. package/dist/typography/textContainerStyles.js.map +1 -1
  611. package/dist/typography/typographyStyles.js.map +1 -1
  612. package/dist/useAsyncFunction.js.map +1 -1
  613. package/dist/useDebouncedFunction.js.map +1 -1
  614. package/dist/useDropzone.js.map +1 -1
  615. package/dist/useElementSize.js.map +1 -1
  616. package/dist/useEnsuredId.js.map +1 -1
  617. package/dist/useEnsuredRef.js.map +1 -1
  618. package/dist/useEnsuredState.js.map +1 -1
  619. package/dist/useHtmlClassName.js.map +1 -1
  620. package/dist/useIntersectionObserver.js.map +1 -1
  621. package/dist/useIsomorphicLayoutEffect.js.map +1 -1
  622. package/dist/useLocalStorage.js.map +1 -1
  623. package/dist/useMutationObserver.js.map +1 -1
  624. package/dist/useOrientation.js.map +1 -1
  625. package/dist/usePageInactive.js.map +1 -1
  626. package/dist/useResizeListener.d.ts +7 -1
  627. package/dist/useResizeListener.js.map +1 -1
  628. package/dist/useResizeObserver.d.ts +3 -3
  629. package/dist/useResizeObserver.js.map +1 -1
  630. package/dist/useThrottledFunction.js.map +1 -1
  631. package/dist/useToggle.d.ts +4 -4
  632. package/dist/useToggle.js +1 -1
  633. package/dist/useToggle.js.map +1 -1
  634. package/dist/useUnmounted.js.map +1 -1
  635. package/dist/useWindowSize.js.map +1 -1
  636. package/dist/utils/RenderRecursively.js.map +1 -1
  637. package/dist/utils/alphaNumericSort.js.map +1 -1
  638. package/dist/utils/applyRef.js.map +1 -1
  639. package/dist/utils/bem.js.map +1 -1
  640. package/dist/utils/getClientPosition.js.map +1 -1
  641. package/dist/utils/getMiddleOfRange.js.map +1 -1
  642. package/dist/utils/getPercentage.js.map +1 -1
  643. package/dist/utils/getRangeDefaultValue.js.map +1 -1
  644. package/dist/utils/getRangeSteps.js.map +1 -1
  645. package/dist/utils/identity.js.map +1 -1
  646. package/dist/utils/isElementVisible.js.map +1 -1
  647. package/dist/utils/loop.js.map +1 -1
  648. package/dist/utils/nearest.js.map +1 -1
  649. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  650. package/dist/utils/randomInt.js.map +1 -1
  651. package/dist/utils/wait.js.map +1 -1
  652. package/dist/utils/withinRange.js.map +1 -1
  653. package/dist/window-splitter/WindowSplitter.d.ts +2 -2
  654. package/dist/window-splitter/WindowSplitter.js +2 -2
  655. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  656. package/dist/window-splitter/useWindowSplitter.js.map +1 -1
  657. package/package.json +25 -24
  658. package/src/RootHtml.tsx +0 -2
  659. package/src/app-bar/AppBar.tsx +0 -2
  660. package/src/app-bar/AppBarTitle.tsx +8 -6
  661. package/src/autocomplete/defaults.ts +3 -3
  662. package/src/avatar/Avatar.tsx +1 -4
  663. package/src/badge/Badge.tsx +1 -3
  664. package/src/box/Box.tsx +0 -2
  665. package/src/button/ButtonUnstyled.tsx +0 -2
  666. package/src/card/Card.tsx +2 -3
  667. package/src/card/CardContent.tsx +0 -2
  668. package/src/card/CardFooter.tsx +0 -2
  669. package/src/card/CardHeader.tsx +0 -2
  670. package/src/card/CardSubtitle.tsx +9 -2
  671. package/src/card/CardTitle.tsx +0 -2
  672. package/src/card/styles.ts +2 -6
  673. package/src/chip/Chip.tsx +0 -2
  674. package/src/cssUtils.ts +1 -1
  675. package/src/dialog/DialogContainer.tsx +0 -2
  676. package/src/dialog/DialogContent.tsx +3 -3
  677. package/src/dialog/DialogFooter.tsx +2 -3
  678. package/src/dialog/DialogHeader.tsx +3 -3
  679. package/src/dialog/DialogTitle.tsx +3 -3
  680. package/src/divider/Divider.tsx +0 -2
  681. package/src/expansion-panel/ExpansionList.tsx +1 -1
  682. package/src/expansion-panel/ExpansionPanel.tsx +9 -38
  683. package/src/expansion-panel/ExpansionPanelHeader.tsx +0 -1
  684. package/src/expansion-panel/expansionPanelStyles.ts +33 -0
  685. package/src/form/Fieldset.tsx +0 -2
  686. package/src/form/FormMessage.tsx +0 -2
  687. package/src/form/FormMessageContainer.tsx +0 -1
  688. package/src/form/FormMessageCounter.tsx +0 -2
  689. package/src/form/InputToggle.tsx +1 -1
  690. package/src/form/InputToggleIcon.tsx +0 -2
  691. package/src/form/Label.tsx +0 -2
  692. package/src/form/Legend.tsx +0 -2
  693. package/src/form/NativeSelect.tsx +0 -2
  694. package/src/form/Option.tsx +1 -1
  695. package/src/form/SelectedOption.tsx +0 -2
  696. package/src/form/SliderContainer.tsx +0 -2
  697. package/src/form/SliderMark.tsx +0 -2
  698. package/src/form/SliderMarkLabel.tsx +0 -2
  699. package/src/form/SliderTrack.tsx +0 -2
  700. package/src/form/SliderValueMarks.tsx +0 -2
  701. package/src/form/Switch.tsx +0 -2
  702. package/src/form/SwitchTrack.tsx +2 -1
  703. package/src/form/TextField.tsx +0 -2
  704. package/src/form/TextFieldAddon.tsx +1 -3
  705. package/src/icon/FontIcon.tsx +19 -11
  706. package/src/icon/IconRotator.tsx +0 -2
  707. package/src/icon/MaterialIcon.tsx +22 -5
  708. package/src/icon/MaterialSymbol.tsx +0 -1
  709. package/src/icon/SVGIcon.tsx +3 -2
  710. package/src/icon/TextIconSpacing.tsx +0 -2
  711. package/src/icon/iconConfig.tsx +1 -0
  712. package/src/icon/material.ts +276 -19
  713. package/src/icon/styles.ts +1 -1
  714. package/src/interaction/RippleContainer.tsx +0 -2
  715. package/src/layout/LayoutNav.tsx +3 -2
  716. package/src/layout/useHorizontalLayoutTransition.ts +1 -1
  717. package/src/layout/useLayoutTree.ts +2 -2
  718. package/src/link/Link.tsx +2 -6
  719. package/src/link/SkipToMainContent.tsx +11 -4
  720. package/src/link/styles.ts +2 -2
  721. package/src/list/List.tsx +1 -33
  722. package/src/list/ListItem.tsx +0 -17
  723. package/src/list/ListItemAddon.tsx +0 -2
  724. package/src/list/ListItemChildren.tsx +0 -2
  725. package/src/list/ListItemText.tsx +0 -2
  726. package/src/list/ListSubheader.tsx +3 -2
  727. package/src/list/getListItemHeight.ts +2 -2
  728. package/src/list/listItemStyles.ts +21 -4
  729. package/src/list/listStyles.ts +31 -0
  730. package/src/list/types.ts +9 -3
  731. package/src/media-queries/AppSizeProvider.tsx +8 -0
  732. package/src/media-queries/useMediaQuery.ts +1 -1
  733. package/src/menu/MenuConfigurationProvider.tsx +2 -2
  734. package/src/navigation/NavGroup.tsx +0 -2
  735. package/src/navigation/NavItem.tsx +0 -2
  736. package/src/navigation/NavSubheader.tsx +0 -2
  737. package/src/overlay/Overlay.tsx +1 -0
  738. package/src/portal/Portal.tsx +5 -0
  739. package/src/portal/PortalContainerProvider.tsx +16 -7
  740. package/src/progress/CircularProgress.tsx +5 -6
  741. package/src/progress/LinearProgress.tsx +0 -2
  742. package/src/responsive-item/ResponsiveItemContainer.tsx +0 -2
  743. package/src/responsive-item/ResponsiveItemOverlay.tsx +0 -2
  744. package/src/segmented-button/SegmentedButtonContainer.tsx +0 -2
  745. package/src/sheet/Sheet.tsx +36 -33
  746. package/src/sheet/styles.ts +50 -0
  747. package/src/suspense/CircularProgressSuspense.tsx +0 -2
  748. package/src/suspense/NullSuspense.tsx +0 -2
  749. package/src/table/StickyTableSection.tsx +91 -0
  750. package/src/table/Table.tsx +2 -5
  751. package/src/table/TableBody.tsx +1 -2
  752. package/src/table/TableCell.tsx +3 -5
  753. package/src/table/TableCellContent.tsx +1 -6
  754. package/src/table/TableConfigurationProvider.tsx +1 -86
  755. package/src/table/TableFooter.tsx +19 -116
  756. package/src/table/TableHeader.tsx +20 -118
  757. package/src/table/TableRow.tsx +2 -4
  758. package/src/table/tableCellStyles.ts +1 -1
  759. package/src/table/types.ts +105 -10
  760. package/src/table/useStickyTableSection.tsx +126 -0
  761. package/src/table/useTableSectionConfig.ts +45 -0
  762. package/src/tabs/Tab.tsx +3 -0
  763. package/src/tabs/TabListScrollButton.tsx +9 -2
  764. package/src/tabs/tabListScrollButtonStyles.ts +9 -5
  765. package/src/tabs/useTabList.ts +4 -0
  766. package/src/tabs/useTabs.ts +61 -14
  767. package/src/test-utils/IntersectionObserver.ts +1 -1
  768. package/src/tooltip/Tooltip.tsx +24 -8
  769. package/src/tooltip/useTooltip.ts +52 -27
  770. package/src/tooltip/useTooltipPosition.ts +2 -4
  771. package/src/transition/SlideContainer.tsx +2 -48
  772. package/src/transition/types.ts +23 -27
  773. package/src/transition/useTransition.ts +1 -0
  774. package/src/tree/DefaultTreeItemRenderer.tsx +3 -4
  775. package/src/tree/Tree.tsx +4 -6
  776. package/src/tree/TreeItem.tsx +11 -4
  777. package/src/tree/types.ts +16 -6
  778. package/src/tree/useTree.ts +5 -7
  779. package/src/tree/useTreeExpansion.ts +3 -3
  780. package/src/tree/useTreeSelection.ts +3 -3
  781. package/src/typography/SrOnly.tsx +2 -1
  782. package/src/typography/TextContainer.tsx +4 -2
  783. package/src/typography/Typography.tsx +10 -2
  784. package/src/typography/WritingDirectionProvider.tsx +2 -2
  785. package/src/useResizeListener.ts +8 -2
  786. package/src/useResizeObserver.ts +3 -3
  787. package/src/useToggle.ts +4 -4
  788. package/src/window-splitter/WindowSplitter.tsx +2 -2
  789. package/.eslintrc.cjs +0 -26
  790. package/.stylelintrc.json +0 -14
  791. package/.swcrc +0 -17
  792. package/.turbo/turbo-build.log +0 -22
  793. package/.turbo/turbo-lint.log +0 -12
  794. package/.turbo/turbo-test.log +0 -5498
  795. package/.turbo/turbo-typecheck.log +0 -26
  796. package/CHANGELOG.md +0 -310
  797. package/coverage/clover.xml +0 -775
  798. package/coverage/coverage-final.json +0 -5
  799. package/coverage/lcov-report/autocomplete/Autocomplete.tsx.html +0 -967
  800. package/coverage/lcov-report/autocomplete/index.html +0 -116
  801. package/coverage/lcov-report/base.css +0 -224
  802. package/coverage/lcov-report/block-navigation.js +0 -87
  803. package/coverage/lcov-report/button/Button.tsx.html +0 -676
  804. package/coverage/lcov-report/button/index.html +0 -116
  805. package/coverage/lcov-report/createHorizontalPosition.ts.html +0 -1075
  806. package/coverage/lcov-report/createVerticalPosition.ts.html +0 -997
  807. package/coverage/lcov-report/favicon.png +0 -0
  808. package/coverage/lcov-report/index.html +0 -161
  809. package/coverage/lcov-report/prettify.css +0 -1
  810. package/coverage/lcov-report/prettify.js +0 -2
  811. package/coverage/lcov-report/searching/fuzzy.ts.html +0 -607
  812. package/coverage/lcov-report/searching/index.html +0 -116
  813. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  814. package/coverage/lcov-report/sorter.js +0 -196
  815. package/coverage/lcov-report/typography/SrOnly.tsx.html +0 -325
  816. package/coverage/lcov-report/typography/index.html +0 -116
  817. package/coverage/lcov-report/utils.ts.html +0 -1225
  818. package/coverage/lcov.info +0 -836
  819. package/jest.config.ts +0 -68
  820. package/jest.setup.ts +0 -3
  821. package/scripts/copySassFiles.ts +0 -70
  822. package/scripts/tsconfig.json +0 -18
  823. package/src/__tests__/NoSsr.node.tsx +0 -26
  824. package/src/__tests__/NoSsr.tsx +0 -89
  825. package/src/__tests__/RootHtml.node.tsx +0 -46
  826. package/src/__tests__/__snapshots__/RootHtml.node.tsx.snap +0 -19
  827. package/src/__tests__/useAsyncFunction.tsx +0 -124
  828. package/src/__tests__/useDebouncedFunction.tsx +0 -108
  829. package/src/__tests__/useDropzone.tsx +0 -131
  830. package/src/__tests__/useElementSize.tsx +0 -181
  831. package/src/__tests__/useEnsuredId.tsx +0 -25
  832. package/src/__tests__/useEnsuredState.tsx +0 -74
  833. package/src/__tests__/useHtmlClassName.tsx +0 -54
  834. package/src/__tests__/useLocalStorage.tsx +0 -377
  835. package/src/__tests__/useOrientation.node.tsx +0 -20
  836. package/src/__tests__/useOrientation.tsx +0 -63
  837. package/src/__tests__/useResizeObserver.tsx +0 -258
  838. package/src/__tests__/useThrottledFunction.tsx +0 -226
  839. package/src/__tests__/useToggle.tsx +0 -78
  840. package/src/__tests__/useWindowSize.node.tsx +0 -56
  841. package/src/__tests__/useWindowSize.tsx +0 -155
  842. package/src/_box-shadows.scss +0 -219
  843. package/src/_core.scss +0 -432
  844. package/src/_utils.scss +0 -348
  845. package/src/app-bar/__tests__/AppBar.tsx +0 -121
  846. package/src/app-bar/__tests__/AppBarTitle.tsx +0 -39
  847. package/src/app-bar/__tests__/__snapshots__/AppBar.tsx.snap +0 -186
  848. package/src/app-bar/__tests__/__snapshots__/AppBarTitle.tsx.snap +0 -47
  849. package/src/app-bar/_app-bar.scss +0 -248
  850. package/src/autocomplete/__tests__/Autocomplete.tsx +0 -458
  851. package/src/autocomplete/__tests__/__snapshots__/Autocomplete.tsx.snap +0 -144
  852. package/src/autocomplete/_autocomplete.scss +0 -75
  853. package/src/avatar/__tests__/Avatar.tsx +0 -75
  854. package/src/avatar/__tests__/__snapshots__/Avatar.tsx.snap +0 -73
  855. package/src/avatar/_avatar.scss +0 -157
  856. package/src/badge/__tests__/Badge.tsx +0 -42
  857. package/src/badge/__tests__/__snapshots__/Badge.tsx.snap +0 -54
  858. package/src/badge/_badge.scss +0 -145
  859. package/src/box/__tests__/Box.tsx +0 -158
  860. package/src/box/__tests__/__snapshots__/Box.tsx.snap +0 -544
  861. package/src/box/_box.scss +0 -168
  862. package/src/button/__tests__/AsyncButton.tsx +0 -211
  863. package/src/button/__tests__/Button.tsx +0 -198
  864. package/src/button/__tests__/ButtonUnstyled.tsx +0 -37
  865. package/src/button/__tests__/TooltippedButton.tsx +0 -60
  866. package/src/button/__tests__/__snapshots__/AsyncButton.tsx.snap +0 -418
  867. package/src/button/__tests__/__snapshots__/Button.tsx.snap +0 -573
  868. package/src/button/__tests__/__snapshots__/ButtonUnstyled.tsx.snap +0 -22
  869. package/src/button/__tests__/__snapshots__/TooltippedButton.tsx.snap +0 -26
  870. package/src/button/__tests__/__snapshots__/buttonStyles.ts.snap +0 -11
  871. package/src/button/__tests__/buttonStyles.ts +0 -15
  872. package/src/button/_button.scss +0 -330
  873. package/src/card/__tests__/Card.tsx +0 -37
  874. package/src/card/__tests__/CardContent.tsx +0 -40
  875. package/src/card/__tests__/CardFooter.tsx +0 -34
  876. package/src/card/__tests__/CardHeader.tsx +0 -66
  877. package/src/card/__tests__/CardSubtitle.tsx +0 -30
  878. package/src/card/__tests__/CardTitle.tsx +0 -30
  879. package/src/card/__tests__/ClickableCard.tsx +0 -66
  880. package/src/card/__tests__/__snapshots__/Card.tsx.snap +0 -40
  881. package/src/card/__tests__/__snapshots__/CardContent.tsx.snap +0 -50
  882. package/src/card/__tests__/__snapshots__/CardFooter.tsx.snap +0 -30
  883. package/src/card/__tests__/__snapshots__/CardHeader.tsx.snap +0 -74
  884. package/src/card/__tests__/__snapshots__/CardSubtitle.tsx.snap +0 -18
  885. package/src/card/__tests__/__snapshots__/CardTitle.tsx.snap +0 -18
  886. package/src/card/__tests__/__snapshots__/ClickableCard.tsx.snap +0 -20
  887. package/src/card/__tests__/__snapshots__/styles.ts.snap +0 -13
  888. package/src/card/__tests__/styles.ts +0 -45
  889. package/src/card/_card.scss +0 -189
  890. package/src/chip/__tests__/Chip.tsx +0 -327
  891. package/src/chip/__tests__/__snapshots__/Chip.tsx.snap +0 -597
  892. package/src/chip/__tests__/__snapshots__/styles.ts.snap +0 -5
  893. package/src/chip/__tests__/styles.ts +0 -14
  894. package/src/chip/_chip.scss +0 -324
  895. package/src/dialog/__tests__/Dialog.tsx +0 -316
  896. package/src/dialog/__tests__/DialogContent.tsx +0 -53
  897. package/src/dialog/__tests__/DialogFooter.tsx +0 -70
  898. package/src/dialog/__tests__/DialogHeader.tsx +0 -37
  899. package/src/dialog/__tests__/DialogTitle.tsx +0 -41
  900. package/src/dialog/__tests__/__snapshots__/Dialog.tsx.snap +0 -84
  901. package/src/dialog/__tests__/__snapshots__/DialogContent.tsx.snap +0 -36
  902. package/src/dialog/__tests__/__snapshots__/DialogFooter.tsx.snap +0 -186
  903. package/src/dialog/__tests__/__snapshots__/DialogHeader.tsx.snap +0 -18
  904. package/src/dialog/__tests__/__snapshots__/DialogTitle.tsx.snap +0 -26
  905. package/src/dialog/_dialog.scss +0 -273
  906. package/src/divider/__tests__/Divider.tsx +0 -36
  907. package/src/divider/__tests__/__snapshots__/Divider.tsx.snap +0 -26
  908. package/src/divider/_divider.scss +0 -124
  909. package/src/draggable/__tests__/__snapshots__/useDraggable.tsx.snap +0 -49
  910. package/src/draggable/__tests__/useDraggable.tsx +0 -540
  911. package/src/draggable/_draggable.scss +0 -29
  912. package/src/expansion-panel/__tests__/ExpansionPanel.tsx +0 -290
  913. package/src/expansion-panel/__tests__/__snapshots__/ExpansionPanel.tsx.snap +0 -197
  914. package/src/expansion-panel/_expansion-panel.scss +0 -107
  915. package/src/focus/__tests__/useFocusContainer.tsx +0 -280
  916. package/src/form/__tests__/Checkbox.tsx +0 -42
  917. package/src/form/__tests__/Fieldset.tsx +0 -44
  918. package/src/form/__tests__/FileInput.tsx +0 -120
  919. package/src/form/__tests__/Label.tsx +0 -69
  920. package/src/form/__tests__/Legend.tsx +0 -34
  921. package/src/form/__tests__/MenuItemCheckbox.tsx +0 -53
  922. package/src/form/__tests__/MenuItemRadio.tsx +0 -53
  923. package/src/form/__tests__/Radio.tsx +0 -35
  924. package/src/form/__tests__/Select.tsx +0 -439
  925. package/src/form/__tests__/Switch.tsx +0 -152
  926. package/src/form/__tests__/TextArea.tsx +0 -433
  927. package/src/form/__tests__/TextField.tsx +0 -195
  928. package/src/form/__tests__/__snapshots__/Checkbox.tsx.snap +0 -99
  929. package/src/form/__tests__/__snapshots__/Fieldset.tsx.snap +0 -58
  930. package/src/form/__tests__/__snapshots__/FileInput.tsx.snap +0 -612
  931. package/src/form/__tests__/__snapshots__/Label.tsx.snap +0 -140
  932. package/src/form/__tests__/__snapshots__/Legend.tsx.snap +0 -30
  933. package/src/form/__tests__/__snapshots__/MenuItemCheckbox.tsx.snap +0 -96
  934. package/src/form/__tests__/__snapshots__/MenuItemRadio.tsx.snap +0 -96
  935. package/src/form/__tests__/__snapshots__/Radio.tsx.snap +0 -99
  936. package/src/form/__tests__/__snapshots__/Select.tsx.snap +0 -492
  937. package/src/form/__tests__/__snapshots__/Switch.tsx.snap +0 -428
  938. package/src/form/__tests__/__snapshots__/TextArea.tsx.snap +0 -548
  939. package/src/form/__tests__/__snapshots__/TextField.tsx.snap +0 -279
  940. package/src/form/__tests__/__snapshots__/useCheckboxGroup.tsx.snap +0 -481
  941. package/src/form/__tests__/__snapshots__/useRadioGroup.tsx.snap +0 -704
  942. package/src/form/__tests__/useCheckboxGroup.tsx +0 -292
  943. package/src/form/__tests__/useFileUpload.tsx +0 -289
  944. package/src/form/__tests__/useFormReset.tsx +0 -194
  945. package/src/form/__tests__/useRadioGroup.tsx +0 -227
  946. package/src/form/__tests__/utils.ts +0 -247
  947. package/src/form/_form.scss +0 -2190
  948. package/src/icon/__tests__/FontIcon.tsx +0 -45
  949. package/src/icon/__tests__/IconRotator.tsx +0 -120
  950. package/src/icon/__tests__/MaterialIcon.tsx +0 -79
  951. package/src/icon/__tests__/MaterialSymbol.tsx +0 -100
  952. package/src/icon/__tests__/SVGIcon.tsx +0 -40
  953. package/src/icon/__tests__/TextIconSpacing.tsx +0 -108
  954. package/src/icon/__tests__/__snapshots__/FontIcon.tsx.snap +0 -35
  955. package/src/icon/__tests__/__snapshots__/IconRotator.tsx.snap +0 -165
  956. package/src/icon/__tests__/__snapshots__/MaterialIcon.tsx.snap +0 -82
  957. package/src/icon/__tests__/__snapshots__/MaterialSymbol.tsx.snap +0 -42
  958. package/src/icon/__tests__/__snapshots__/SVGIcon.tsx.snap +0 -47
  959. package/src/icon/__tests__/__snapshots__/TextIconSpacing.tsx.snap +0 -101
  960. package/src/icon/__tests__/__snapshots__/styles.ts.snap +0 -29
  961. package/src/icon/__tests__/styles.ts +0 -28
  962. package/src/icon/_icon.scss +0 -213
  963. package/src/interaction/__tests__/UserInteractionModeProvider.tsx +0 -121
  964. package/src/interaction/__tests__/__snapshots__/useHigherContrastChildren.tsx.snap +0 -79
  965. package/src/interaction/__tests__/useHigherContrastChildren.tsx +0 -97
  966. package/src/interaction/_interaction.scss +0 -436
  967. package/src/layout/__tests__/LayoutAppBar.tsx +0 -117
  968. package/src/layout/__tests__/LayoutNav.tsx +0 -78
  969. package/src/layout/__tests__/LayoutWindowSplitter.tsx +0 -63
  970. package/src/layout/__tests__/Main.tsx +0 -51
  971. package/src/layout/__tests__/__snapshots__/LayoutAppBar.tsx.snap +0 -78
  972. package/src/layout/__tests__/__snapshots__/LayoutNav.tsx.snap +0 -31
  973. package/src/layout/__tests__/__snapshots__/LayoutWindowSplitter.tsx.snap +0 -60
  974. package/src/layout/__tests__/__snapshots__/Main.tsx.snap +0 -32
  975. package/src/layout/__tests__/__snapshots__/useExpandableLayout.tsx.snap +0 -116
  976. package/src/layout/__tests__/__snapshots__/useLayoutTree.tsx.snap +0 -676
  977. package/src/layout/__tests__/__snapshots__/useResizableLayout.tsx.snap +0 -95
  978. package/src/layout/__tests__/__snapshots__/useTemporaryLayout.tsx.snap +0 -141
  979. package/src/layout/__tests__/useExpandableLayout.tsx +0 -279
  980. package/src/layout/__tests__/useLayoutTree.tsx +0 -212
  981. package/src/layout/__tests__/useResizableLayout.tsx +0 -170
  982. package/src/layout/__tests__/useTemporaryLayout.tsx +0 -109
  983. package/src/layout/_layout.scss +0 -163
  984. package/src/link/__tests__/Link.tsx +0 -31
  985. package/src/link/__tests__/SkipToMainContent.tsx +0 -125
  986. package/src/link/__tests__/__snapshots__/Link.tsx.snap +0 -20
  987. package/src/link/__tests__/__snapshots__/SkipToMainContent.tsx.snap +0 -22
  988. package/src/link/_link.scss +0 -149
  989. package/src/list/__tests__/List.tsx +0 -58
  990. package/src/list/__tests__/ListItem.tsx +0 -280
  991. package/src/list/__tests__/ListItemLink.tsx +0 -89
  992. package/src/list/__tests__/ListSubheader.tsx +0 -81
  993. package/src/list/__tests__/__snapshots__/List.tsx.snap +0 -41
  994. package/src/list/__tests__/__snapshots__/ListItem.tsx.snap +0 -414
  995. package/src/list/__tests__/__snapshots__/ListItemLink.tsx.snap +0 -73
  996. package/src/list/__tests__/__snapshots__/ListSubheader.tsx.snap +0 -99
  997. package/src/list/__tests__/getListItemHeight.ts +0 -176
  998. package/src/list/_list.scss +0 -322
  999. package/src/media-queries/__tests__/AppSizeProvider.node.tsx +0 -37
  1000. package/src/media-queries/__tests__/AppSizeProvider.tsx +0 -119
  1001. package/src/media-queries/__tests__/useMediaQuery.node.tsx +0 -20
  1002. package/src/media-queries/__tests__/useMediaQuery.tsx +0 -59
  1003. package/src/media-queries/_media-queries.scss +0 -63
  1004. package/src/menu/__tests__/DropdownMenu.tsx +0 -627
  1005. package/src/menu/__tests__/MenuBar.tsx +0 -354
  1006. package/src/menu/__tests__/MenuItemCircularProgress.tsx +0 -39
  1007. package/src/menu/__tests__/MenuVisibilityProvider.tsx +0 -34
  1008. package/src/menu/__tests__/__snapshots__/DropdownMenu.tsx.snap +0 -292
  1009. package/src/menu/__tests__/__snapshots__/MenuBar.tsx.snap +0 -87
  1010. package/src/menu/__tests__/__snapshots__/MenuItemCircularProgress.tsx.snap +0 -68
  1011. package/src/menu/__tests__/__snapshots__/useContextMenu.tsx.snap +0 -54
  1012. package/src/menu/__tests__/useContextMenu.tsx +0 -41
  1013. package/src/menu/__tests__/utils.ts +0 -121
  1014. package/src/menu/_menu.scss +0 -116
  1015. package/src/movement/__tests__/findMatchIndex.ts +0 -244
  1016. package/src/movement/__tests__/utils.ts +0 -710
  1017. package/src/navigation/__tests__/Navigation.tsx +0 -97
  1018. package/src/navigation/__tests__/__snapshots__/Navigation.tsx.snap +0 -165
  1019. package/src/navigation/_navigation.scss +0 -99
  1020. package/src/overlay/__tests__/Overlay.tsx +0 -198
  1021. package/src/overlay/__tests__/__snapshots__/Overlay.tsx.snap +0 -77
  1022. package/src/overlay/_overlay.scss +0 -74
  1023. package/src/portal/__tests__/PortalContainerProvider.node.tsx +0 -26
  1024. package/src/portal/__tests__/PortalContainerProvider.tsx +0 -84
  1025. package/src/positioning/__tests__/__snapshots__/useFixedPositioning.tsx.snap +0 -87
  1026. package/src/positioning/__tests__/createHorizontalPosition.ts +0 -777
  1027. package/src/positioning/__tests__/createVerticalPosition.ts +0 -464
  1028. package/src/positioning/__tests__/useFixedPositioning.tsx +0 -205
  1029. package/src/positioning/__tests__/utils.ts +0 -1311
  1030. package/src/progress/__tests__/CircularProgress.tsx +0 -153
  1031. package/src/progress/__tests__/LinearProgress.tsx +0 -131
  1032. package/src/progress/__tests__/__snapshots__/CircularProgress.tsx.snap +0 -499
  1033. package/src/progress/__tests__/__snapshots__/LinearProgress.tsx.snap +0 -321
  1034. package/src/progress/__tests__/getProgressA11y.ts +0 -16
  1035. package/src/progress/_progress.scss +0 -577
  1036. package/src/responsive-item/__tests__/ResponsiveItemContainer.tsx +0 -56
  1037. package/src/responsive-item/__tests__/ResponsiveItemOverlay.tsx +0 -66
  1038. package/src/responsive-item/__tests__/__snapshots__/ResponsiveItemContainer.tsx.snap +0 -85
  1039. package/src/responsive-item/__tests__/__snapshots__/ResponsiveItemOverlay.tsx.snap +0 -151
  1040. package/src/responsive-item/__tests__/__snapshots__/styles.ts.snap +0 -9
  1041. package/src/responsive-item/__tests__/styles.ts +0 -32
  1042. package/src/responsive-item/_responsive-item.scss +0 -199
  1043. package/src/searching/__tests__/caseInsensitive.ts +0 -165
  1044. package/src/searching/__tests__/fuzzy.ts +0 -169
  1045. package/src/searching/__tests__/toSearchQuery.ts +0 -21
  1046. package/src/searching/__tests__/useFuzzyMatch.tsx +0 -200
  1047. package/src/segmented-button/__tests__/SegmentedButton.tsx +0 -61
  1048. package/src/segmented-button/__tests__/SegmentedButtonContainer.tsx +0 -38
  1049. package/src/segmented-button/__tests__/__snapshots__/SegmentedButton.tsx.snap +0 -116
  1050. package/src/segmented-button/__tests__/__snapshots__/SegmentedButtonContainer.tsx.snap +0 -22
  1051. package/src/segmented-button/_segmented-button.scss +0 -208
  1052. package/src/sheet/_sheet.scss +0 -189
  1053. package/src/snackbar/__tests__/Snackbar.tsx +0 -85
  1054. package/src/snackbar/__tests__/Toast.tsx +0 -105
  1055. package/src/snackbar/__tests__/ToastActionButton.tsx +0 -112
  1056. package/src/snackbar/__tests__/ToastCloseButton.tsx +0 -140
  1057. package/src/snackbar/__tests__/ToastContent.tsx +0 -88
  1058. package/src/snackbar/__tests__/ToastManagerProvider.tsx +0 -852
  1059. package/src/snackbar/__tests__/__snapshots__/Snackbar.tsx.snap +0 -176
  1060. package/src/snackbar/__tests__/__snapshots__/Toast.tsx.snap +0 -52
  1061. package/src/snackbar/__tests__/__snapshots__/ToastActionButton.tsx.snap +0 -36
  1062. package/src/snackbar/__tests__/__snapshots__/ToastCloseButton.tsx.snap +0 -104
  1063. package/src/snackbar/__tests__/__snapshots__/ToastContent.tsx.snap +0 -26
  1064. package/src/snackbar/__tests__/__snapshots__/ToastManagerProvider.tsx.snap +0 -290
  1065. package/src/snackbar/_snackbar.scss +0 -266
  1066. package/src/suspense/__tests__/CircularProgressSuspense.tsx +0 -90
  1067. package/src/suspense/__tests__/NullSuspense.tsx +0 -46
  1068. package/src/suspense/__tests__/__snapshots__/CircularProgressSuspense.tsx.snap +0 -24
  1069. package/src/table/__tests__/Table.tsx +0 -314
  1070. package/src/table/__tests__/TableBody.tsx +0 -52
  1071. package/src/table/__tests__/TableCheckbox.tsx +0 -89
  1072. package/src/table/__tests__/TableContainer.tsx +0 -31
  1073. package/src/table/__tests__/TableRadio.tsx +0 -112
  1074. package/src/table/__tests__/TableRow.tsx +0 -63
  1075. package/src/table/__tests__/__snapshots__/Table.tsx.snap +0 -2426
  1076. package/src/table/__tests__/__snapshots__/TableBody.tsx.snap +0 -54
  1077. package/src/table/__tests__/__snapshots__/TableCheckbox.tsx.snap +0 -142
  1078. package/src/table/__tests__/__snapshots__/TableContainer.tsx.snap +0 -16
  1079. package/src/table/__tests__/__snapshots__/TableRadio.tsx.snap +0 -138
  1080. package/src/table/__tests__/__snapshots__/TableRow.tsx.snap +0 -56
  1081. package/src/table/__tests__/__snapshots__/tableContainerStyles.ts.snap +0 -3
  1082. package/src/table/__tests__/__snapshots__/tableRowStyles.ts.snap +0 -3
  1083. package/src/table/__tests__/__snapshots__/tableStyles.ts.snap +0 -3
  1084. package/src/table/__tests__/tableContainerStyles.ts +0 -8
  1085. package/src/table/__tests__/tableRowStyles.ts +0 -8
  1086. package/src/table/__tests__/tableStyles.ts +0 -8
  1087. package/src/table/_table.scss +0 -447
  1088. package/src/tabs/__tests__/Tab.tsx +0 -51
  1089. package/src/tabs/__tests__/TabList.tsx +0 -640
  1090. package/src/tabs/__tests__/__snapshots__/Tab.tsx.snap +0 -85
  1091. package/src/tabs/__tests__/__snapshots__/TabList.tsx.snap +0 -51
  1092. package/src/tabs/__tests__/useTabs.tsx +0 -212
  1093. package/src/tabs/_tabs.scss +0 -273
  1094. package/src/test-utils/__tests__/ResizeObserver.ts +0 -171
  1095. package/src/theme/__tests__/LocalStorageColorSchemeProvider.tsx +0 -162
  1096. package/src/theme/__tests__/ThemeProvider.tsx +0 -90
  1097. package/src/theme/__tests__/__snapshots__/useCSSVariables.tsx.snap +0 -27
  1098. package/src/theme/__tests__/__snapshots__/useColorSchemeMetaTag.tsx.snap +0 -15
  1099. package/src/theme/__tests__/useCSSVariables.tsx +0 -177
  1100. package/src/theme/__tests__/useColorSchemeMetaTag.tsx +0 -36
  1101. package/src/theme/__tests__/utils.ts +0 -67
  1102. package/src/theme/_a11y.scss +0 -114
  1103. package/src/theme/_colors.scss +0 -1057
  1104. package/src/theme/_theme.scss +0 -519
  1105. package/src/tooltip/__tests__/Tooltip.tsx +0 -501
  1106. package/src/tooltip/__tests__/TooltipHoverModeProvider.tsx +0 -94
  1107. package/src/tooltip/__tests__/__snapshots__/Tooltip.tsx.snap +0 -34
  1108. package/src/tooltip/__tests__/utils.ts +0 -94
  1109. package/src/tooltip/_tooltip.scss +0 -155
  1110. package/src/transition/__tests__/CSSTransition.tsx +0 -182
  1111. package/src/transition/__tests__/Collapse.tsx +0 -209
  1112. package/src/transition/__tests__/CrossFade.tsx +0 -227
  1113. package/src/transition/__tests__/ScaleTransition.tsx +0 -204
  1114. package/src/transition/__tests__/SkeletonPlaceholder.tsx +0 -72
  1115. package/src/transition/__tests__/__snapshots__/CSSTransition.tsx.snap +0 -145
  1116. package/src/transition/__tests__/__snapshots__/Collapse.tsx.snap +0 -224
  1117. package/src/transition/__tests__/__snapshots__/CrossFade.tsx.snap +0 -240
  1118. package/src/transition/__tests__/__snapshots__/ScaleTransition.tsx.snap +0 -239
  1119. package/src/transition/__tests__/__snapshots__/SkeletonPlaceholder.tsx.snap +0 -24
  1120. package/src/transition/__tests__/__snapshots__/useCollapseTransition.tsx.snap +0 -361
  1121. package/src/transition/__tests__/__snapshots__/useCrossFadeTransition.tsx.snap +0 -258
  1122. package/src/transition/__tests__/__snapshots__/useMaxWidthTransition.tsx.snap +0 -68
  1123. package/src/transition/__tests__/__snapshots__/useScaleTransition.tsx.snap +0 -209
  1124. package/src/transition/__tests__/useCSSTransition.tsx +0 -190
  1125. package/src/transition/__tests__/useCollapseTransition.tsx +0 -316
  1126. package/src/transition/__tests__/useCrossFadeTransition.tsx +0 -229
  1127. package/src/transition/__tests__/useMaxWidthTransition.tsx +0 -123
  1128. package/src/transition/__tests__/useScaleTransition.tsx +0 -212
  1129. package/src/transition/__tests__/useTransition.tsx +0 -569
  1130. package/src/transition/__tests__/utils.ts +0 -620
  1131. package/src/transition/_transition.scss +0 -365
  1132. package/src/tree/__tests__/Tree.tsx +0 -735
  1133. package/src/tree/__tests__/TreeGroup.tsx +0 -76
  1134. package/src/tree/__tests__/TreeItemExpander.tsx +0 -74
  1135. package/src/tree/__tests__/__snapshots__/Tree.tsx.snap +0 -3618
  1136. package/src/tree/__tests__/__snapshots__/TreeItemExpander.tsx.snap +0 -11
  1137. package/src/tree/__tests__/utils.ts +0 -98
  1138. package/src/tree/_tree.scss +0 -176
  1139. package/src/typography/__tests__/SrOnly.tsx +0 -43
  1140. package/src/typography/__tests__/TextContainer.tsx +0 -45
  1141. package/src/typography/__tests__/Typography.tsx +0 -87
  1142. package/src/typography/__tests__/WritingDirectionProvider.node.tsx +0 -27
  1143. package/src/typography/__tests__/WritingDirectionProvider.tsx +0 -119
  1144. package/src/typography/__tests__/__snapshots__/SrOnly.tsx.snap +0 -56
  1145. package/src/typography/__tests__/__snapshots__/TextContainer.tsx.snap +0 -29
  1146. package/src/typography/__tests__/__snapshots__/Typography.tsx.snap +0 -112
  1147. package/src/typography/_typography.scss +0 -399
  1148. package/src/utils/__tests__/RenderRecursively.tsx +0 -87
  1149. package/src/utils/__tests__/__snapshots__/RenderRecursively.tsx.snap +0 -80
  1150. package/src/utils/__tests__/applyRef.ts +0 -30
  1151. package/src/utils/__tests__/bem.ts +0 -54
  1152. package/src/utils/__tests__/getMiddleOfRange.ts +0 -12
  1153. package/src/utils/__tests__/getPercentage.ts +0 -104
  1154. package/src/utils/__tests__/getRangeDefaultValue.ts +0 -47
  1155. package/src/utils/__tests__/getRangeSteps.ts +0 -14
  1156. package/src/utils/__tests__/loop.ts +0 -50
  1157. package/src/utils/__tests__/nearest.ts +0 -83
  1158. package/src/utils/__tests__/parseCssLengthUnit.node.ts +0 -28
  1159. package/src/utils/__tests__/parseCssLengthUnit.ts +0 -47
  1160. package/src/utils/__tests__/wait.ts +0 -12
  1161. package/src/utils/__tests__/withinRange.ts +0 -24
  1162. package/src/window-splitter/_window-splitter.scss +0 -143
  1163. package/tsconfig.json +0 -19
  1164. package/tsconfig.types.json +0 -12
  1165. package/tsdoc.json +0 -14
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useDebouncedFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type CancelableFunction, type AnyFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\n\n/**\n * Creates a function that will only be called if it has not been called again\n * for X milliseconds.\n *\n * @example Debounced Search API Requests\n * ```tsx\n * import { TextField, useDebouncedFunction, useUnmounted } from \"@react-md/core\";\n * import { useState } from \"react\";\n * import type { ReactElement } from \"react\";\n *\n * interface State {\n * error?: unknown\n * loading: boolean;\n * results?: {\n * // pretend some search results\n * id: string;\n * name: string;\n * }[];\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * loading: false,\n * });\n * // this is only required for async actions\n * const unmounted = useUnmounted();\n *\n * // A new search request will be fired once every 500ms as the user types.\n * // can't use the event here since React uses synthetic events\n * const search = useDebouncedFunction(async (q: string) => {\n * setState({\n * loading: true,\n * error: undefined,\n * results: undefined,\n * });\n *\n * try {\n * const response = await fetch('/search', {\n * method: 'POST',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({ q }),\n * });\n * const json = await response.json();\n *\n * if (!unmounted.current) {\n * setState({\n * loading: false,\n * results: json,\n * });\n * }\n * } catch (error) {\n * if (!unmounted.current) {\n * setState({\n * error,\n * loading: false,\n * });\n * }\n * }\n * }, 500);\n *\n * return (\n * <TextField\n * type=\"search\"\n * label=\"Search\"\n * onChange={(event) => search(event.currentTarget.value)}\n * />\n * );\n * }\n * ```\n *\n * @see `useThrottledFunction` for throttle behavior instead. (Call a\n * function at most once every X milliseconds).\n * @since 6.0.0\n */\nexport function useDebouncedFunction<F extends AnyFunction>(\n func: F,\n wait: number\n): DebouncedFunction<F> {\n const timeout = useRef<number | undefined>();\n const funcRef = useRef(func);\n useIsomorphicLayoutEffect(() => {\n funcRef.current = func;\n });\n\n useEffect(() => {\n return () => {\n window.clearTimeout(timeout.current);\n };\n }, []);\n\n return useMemo(() => {\n const debounced: DebouncedFunction<F> = (...args) => {\n window.clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n funcRef.current(...args);\n }, wait);\n };\n debounced.cancel = () => window.clearTimeout(timeout.current);\n\n return debounced;\n }, [wait]);\n}\n"],"names":["useEffect","useMemo","useRef","useIsomorphicLayoutEffect","useDebouncedFunction","func","wait","timeout","funcRef","current","window","clearTimeout","debounced","args","setTimeout","cancel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,yBAAyB,QAAQ,iCAAiC;AAS3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EC,GACD,OAAO,SAASC,qBACdC,IAAO,EACPC,IAAY;IAEZ,MAAMC,UAAUL;IAChB,MAAMM,UAAUN,OAAOG;IACvBF,0BAA0B;QACxBK,QAAQC,OAAO,GAAGJ;IACpB;IAEAL,UAAU;QACR,OAAO;YACLU,OAAOC,YAAY,CAACJ,QAAQE,OAAO;QACrC;IACF,GAAG,EAAE;IAEL,OAAOR,QAAQ;QACb,MAAMW,YAAkC,CAAC,GAAGC;YAC1CH,OAAOC,YAAY,CAACJ,QAAQE,OAAO;YACnCF,QAAQE,OAAO,GAAGC,OAAOI,UAAU,CAAC;gBAClCN,QAAQC,OAAO,IAAII;YACrB,GAAGP;QACL;QACAM,UAAUG,MAAM,GAAG,IAAML,OAAOC,YAAY,CAACJ,QAAQE,OAAO;QAE5D,OAAOG;IACT,GAAG;QAACN;KAAK;AACX"}
1
+ {"version":3,"sources":["../src/useDebouncedFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type CancelableFunction, type AnyFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\n\n/**\n * Creates a function that will only be called if it has not been called again\n * for X milliseconds.\n *\n * @example Debounced Search API Requests\n * ```tsx\n * import { TextField, useDebouncedFunction, useUnmounted } from \"@react-md/core\";\n * import { useState } from \"react\";\n * import type { ReactElement } from \"react\";\n *\n * interface State {\n * error?: unknown\n * loading: boolean;\n * results?: {\n * // pretend some search results\n * id: string;\n * name: string;\n * }[];\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * loading: false,\n * });\n * // this is only required for async actions\n * const unmounted = useUnmounted();\n *\n * // A new search request will be fired once every 500ms as the user types.\n * // can't use the event here since React uses synthetic events\n * const search = useDebouncedFunction(async (q: string) => {\n * setState({\n * loading: true,\n * error: undefined,\n * results: undefined,\n * });\n *\n * try {\n * const response = await fetch('/search', {\n * method: 'POST',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({ q }),\n * });\n * const json = await response.json();\n *\n * if (!unmounted.current) {\n * setState({\n * loading: false,\n * results: json,\n * });\n * }\n * } catch (error) {\n * if (!unmounted.current) {\n * setState({\n * error,\n * loading: false,\n * });\n * }\n * }\n * }, 500);\n *\n * return (\n * <TextField\n * type=\"search\"\n * label=\"Search\"\n * onChange={(event) => search(event.currentTarget.value)}\n * />\n * );\n * }\n * ```\n *\n * @see `useThrottledFunction` for throttle behavior instead. (Call a\n * function at most once every X milliseconds).\n * @since 6.0.0\n */\nexport function useDebouncedFunction<F extends AnyFunction>(\n func: F,\n wait: number\n): DebouncedFunction<F> {\n const timeout = useRef<number | undefined>();\n const funcRef = useRef(func);\n useIsomorphicLayoutEffect(() => {\n funcRef.current = func;\n });\n\n useEffect(() => {\n return () => {\n window.clearTimeout(timeout.current);\n };\n }, []);\n\n return useMemo(() => {\n const debounced: DebouncedFunction<F> = (...args) => {\n window.clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n funcRef.current(...args);\n }, wait);\n };\n debounced.cancel = () => window.clearTimeout(timeout.current);\n\n return debounced;\n }, [wait]);\n}\n"],"names":["useEffect","useMemo","useRef","useIsomorphicLayoutEffect","useDebouncedFunction","func","wait","timeout","funcRef","current","window","clearTimeout","debounced","args","setTimeout","cancel"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,yBAAyB,QAAQ,iCAAiC;AAS3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EC,GACD,OAAO,SAASC,qBACdC,IAAO,EACPC,IAAY;IAEZ,MAAMC,UAAUL;IAChB,MAAMM,UAAUN,OAAOG;IACvBF,0BAA0B;QACxBK,QAAQC,OAAO,GAAGJ;IACpB;IAEAL,UAAU;QACR,OAAO;YACLU,OAAOC,YAAY,CAACJ,QAAQE,OAAO;QACrC;IACF,GAAG,EAAE;IAEL,OAAOR,QAAQ;QACb,MAAMW,YAAkC,CAAC,GAAGC;YAC1CH,OAAOC,YAAY,CAACJ,QAAQE,OAAO;YACnCF,QAAQE,OAAO,GAAGC,OAAOI,UAAU,CAAC;gBAClCN,QAAQC,OAAO,IAAII;YACrB,GAAGP;QACL;QACAM,UAAUG,MAAM,GAAG,IAAML,OAAOC,YAAY,CAACJ,QAAQE,OAAO;QAE5D,OAAOG;IACT,GAAG;QAACN;KAAK;AACX"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useDropzone.ts"],"sourcesContent":["\"use client\";\nimport type { DragEvent } from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 5.1.3\n * @since 6.0.0 The element type is dynamically inferred on each handler\n * instead of the `DropzoneHandlers` type.\n */\nexport interface DropzoneHandlers {\n onDrop<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragEnter?<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragOver?<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragLeave?<E extends HTMLElement>(event: DragEvent<E>): void;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface DropzoneOptions extends DropzoneHandlers {\n /**\n * Set this to `true` if you do not need to capture drag events from outside\n * the window. i.e. Dragging files into the dropzone.\n *\n * @defaultValue `false`\n * @see {@link DropzoneHookReturnValue.isDragging}\n */\n disableDragging?: boolean;\n}\n\n/**\n * @since 2.9.0\n * @since 6.0.0 Returns an object instead of an ordered array of\n * `[isOver: boolean, dropzoneHandlers: DropzoneHandlers]`. Also returns a new\n * `isDragging` state.\n */\nexport interface DropzoneHookReturnValue {\n /**\n * This will be `true` when the user is dragging something over the dropzone\n * target.\n */\n isOver: boolean;\n\n /**\n * This will be `true` when the user is dragging anything within the document.\n * The main use case for this is detecting when a user is dragging a file into\n * the document so you can help highlight the dropzone area.\n *\n * This will always be `false` if {@link DropzoneOptions.disableDragging} is\n * `true`.\n */\n isDragging: boolean;\n\n /**\n * The event handlers that should be passed to the dropzone target.\n */\n dropzoneHandlers: Required<DropzoneHandlers>;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useDropzone, useFileUpload } from \"@react-md/core\"\n * import type { CSSProperties, ReactElement } from \"react\";\n *\n * const style: CSSProperties = {\n * border: '1px solid blue',\n * };\n *\n * function Example(): ReactElement {\n * const { onDrop } = useFileUpload()\n * const { isOver, dropzoneHandlers } = useDropzone({\n * onDrop(event) {\n * // normally use the `onDrop` behavior from `useFileUpload` to upload\n * // files:\n * // onDrop(event);\n * },\n * disableDragging: true,\n * });\n *\n * return (\n * <div {...dropzoneHandlers} style={isOver ? style : {}}>\n * Drag and drop some files!\n * {isOver && <UploadSVGIcon />}\n * </div>\n * );\n * }\n * ```\n *\n * @example Dragging Example\n * ```tsx\n * import { useDropzone, useFileUpload } from \"@react-md/core\"\n * import type { CSSProperties, ReactElement } from \"react\";\n *\n * const draggingStyle: CSSProperties = {\n * backgroundColor: \"orange\",\n * };\n * const overStyle: CSSProperties = {\n * border: '1px solid blue',\n * };\n *\n * function Example(): ReactElement {\n * const { onDrop } = useFileUpload()\n * const { isOver, isDragging, dropzoneHandlers } = useDropzone({\n * onDrop(event) {\n * // normally use the `onDrop` behavior from `useFileUpload` to upload\n * // files:\n * // onDrop(event);\n * },\n * });\n *\n * return (\n * <div\n * {...dropzoneHandlers}\n * style={{\n * ...(isDragging && draggingStyle),\n * ...(isOver && overStyle),\n * }}\n * >\n * Drag and drop some files!\n * {isOver && <UploadSVGIcon />}\n * </div>\n * );\n * }\n * ```\n *\n * @since 2.9.0\n * @since 6.0.0 Supports document-level dragging flag;\n */\nexport function useDropzone(options: DropzoneOptions): DropzoneHookReturnValue {\n const {\n onDrop,\n onDragOver = noop,\n onDragEnter = noop,\n onDragLeave = noop,\n disableDragging = false,\n } = options;\n\n const [isOver, setOver] = useState(false);\n const [isDragging, setDragging] = useState(false);\n const draggingTimeout = useRef<number | undefined>();\n\n useEffect(() => {\n if (disableDragging) {\n return;\n }\n\n const startDragging = (): void => {\n setDragging(true);\n };\n\n // Browsers sometimes don't trigger a dragleave event for the entire\n // document, so we have to work around that by using the `dragover` event\n // instead. The `dragover` event will continually fire within the window\n // until the user drops the file or moves the file outside of the window.\n //\n // So we can consider the\n const handler = (): void => {\n window.clearTimeout(draggingTimeout.current);\n draggingTimeout.current = window.setTimeout(() => {\n setDragging(false);\n }, 100);\n };\n\n window.addEventListener(\"dragenter\", startDragging);\n window.addEventListener(\"dragover\", handler);\n return () => {\n window.clearTimeout(draggingTimeout.current);\n window.removeEventListener(\"dragenter\", startDragging);\n window.removeEventListener(\"dragover\", handler);\n };\n }, [disableDragging]);\n\n return {\n isOver,\n isDragging,\n dropzoneHandlers: {\n // Note: need to call `event.stopPropagation()` and\n // `event.preventDefault())` for each of these handlers to prevent the\n // default browser behavior when dropping. Only calling within `onDrop`\n // does not work.\n //\n // i.e. dropping an image would preview that image in the current\n // window/tab instead of triggering the drop event.\n onDrop(event) {\n event.preventDefault();\n event.stopPropagation();\n\n window.clearTimeout(draggingTimeout.current);\n onDrop(event);\n setOver(false);\n setDragging(false);\n },\n onDragOver(event) {\n event.preventDefault();\n event.stopPropagation();\n\n window.clearTimeout(draggingTimeout.current);\n onDragOver(event);\n setOver(true);\n },\n onDragEnter(event) {\n event.preventDefault();\n event.stopPropagation();\n\n onDragEnter(event);\n setOver(true);\n },\n onDragLeave(event) {\n event.preventDefault();\n event.stopPropagation();\n\n onDragLeave(event);\n setOver(false);\n },\n },\n };\n}\n"],"names":["useEffect","useRef","useState","noop","useDropzone","options","onDrop","onDragOver","onDragEnter","onDragLeave","disableDragging","isOver","setOver","isDragging","setDragging","draggingTimeout","startDragging","handler","window","clearTimeout","current","setTimeout","addEventListener","removeEventListener","dropzoneHandlers","event","preventDefault","stopPropagation"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,MAAMC,OAAO;AACX,aAAa;AACf;AAyDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EACJC,MAAM,EACNC,aAAaJ,IAAI,EACjBK,cAAcL,IAAI,EAClBM,cAAcN,IAAI,EAClBO,kBAAkB,KAAK,EACxB,GAAGL;IAEJ,MAAM,CAACM,QAAQC,QAAQ,GAAGV,SAAS;IACnC,MAAM,CAACW,YAAYC,YAAY,GAAGZ,SAAS;IAC3C,MAAMa,kBAAkBd;IAExBD,UAAU;QACR,IAAIU,iBAAiB;YACnB;QACF;QAEA,MAAMM,gBAAgB;YACpBF,YAAY;QACd;QAEA,oEAAoE;QACpE,yEAAyE;QACzE,wEAAwE;QACxE,yEAAyE;QACzE,EAAE;QACF,yBAAyB;QACzB,MAAMG,UAAU;YACdC,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;YAC3CL,gBAAgBK,OAAO,GAAGF,OAAOG,UAAU,CAAC;gBAC1CP,YAAY;YACd,GAAG;QACL;QAEAI,OAAOI,gBAAgB,CAAC,aAAaN;QACrCE,OAAOI,gBAAgB,CAAC,YAAYL;QACpC,OAAO;YACLC,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;YAC3CF,OAAOK,mBAAmB,CAAC,aAAaP;YACxCE,OAAOK,mBAAmB,CAAC,YAAYN;QACzC;IACF,GAAG;QAACP;KAAgB;IAEpB,OAAO;QACLC;QACAE;QACAW,kBAAkB;YAChB,mDAAmD;YACnD,sEAAsE;YACtE,uEAAuE;YACvE,iBAAiB;YACjB,EAAE;YACF,iEAAiE;YACjE,mDAAmD;YACnDlB,QAAOmB,KAAK;gBACVA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBT,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;gBAC3Cd,OAAOmB;gBACPb,QAAQ;gBACRE,YAAY;YACd;YACAP,YAAWkB,KAAK;gBACdA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBT,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;gBAC3Cb,WAAWkB;gBACXb,QAAQ;YACV;YACAJ,aAAYiB,KAAK;gBACfA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBnB,YAAYiB;gBACZb,QAAQ;YACV;YACAH,aAAYgB,KAAK;gBACfA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBlB,YAAYgB;gBACZb,QAAQ;YACV;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/useDropzone.ts"],"sourcesContent":["\"use client\";\nimport type { DragEvent } from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 5.1.3\n * @since 6.0.0 The element type is dynamically inferred on each handler\n * instead of the `DropzoneHandlers` type.\n */\nexport interface DropzoneHandlers {\n onDrop<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragEnter?<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragOver?<E extends HTMLElement>(event: DragEvent<E>): void;\n onDragLeave?<E extends HTMLElement>(event: DragEvent<E>): void;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface DropzoneOptions extends DropzoneHandlers {\n /**\n * Set this to `true` if you do not need to capture drag events from outside\n * the window. i.e. Dragging files into the dropzone.\n *\n * @defaultValue `false`\n * @see {@link DropzoneHookReturnValue.isDragging}\n */\n disableDragging?: boolean;\n}\n\n/**\n * @since 2.9.0\n * @since 6.0.0 Returns an object instead of an ordered array of\n * `[isOver: boolean, dropzoneHandlers: DropzoneHandlers]`. Also returns a new\n * `isDragging` state.\n */\nexport interface DropzoneHookReturnValue {\n /**\n * This will be `true` when the user is dragging something over the dropzone\n * target.\n */\n isOver: boolean;\n\n /**\n * This will be `true` when the user is dragging anything within the document.\n * The main use case for this is detecting when a user is dragging a file into\n * the document so you can help highlight the dropzone area.\n *\n * This will always be `false` if {@link DropzoneOptions.disableDragging} is\n * `true`.\n */\n isDragging: boolean;\n\n /**\n * The event handlers that should be passed to the dropzone target.\n */\n dropzoneHandlers: Required<DropzoneHandlers>;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useDropzone, useFileUpload } from \"@react-md/core\"\n * import type { CSSProperties, ReactElement } from \"react\";\n *\n * const style: CSSProperties = {\n * border: '1px solid blue',\n * };\n *\n * function Example(): ReactElement {\n * const { onDrop } = useFileUpload()\n * const { isOver, dropzoneHandlers } = useDropzone({\n * onDrop(event) {\n * // normally use the `onDrop` behavior from `useFileUpload` to upload\n * // files:\n * // onDrop(event);\n * },\n * disableDragging: true,\n * });\n *\n * return (\n * <div {...dropzoneHandlers} style={isOver ? style : {}}>\n * Drag and drop some files!\n * {isOver && <UploadSVGIcon />}\n * </div>\n * );\n * }\n * ```\n *\n * @example Dragging Example\n * ```tsx\n * import { useDropzone, useFileUpload } from \"@react-md/core\"\n * import type { CSSProperties, ReactElement } from \"react\";\n *\n * const draggingStyle: CSSProperties = {\n * backgroundColor: \"orange\",\n * };\n * const overStyle: CSSProperties = {\n * border: '1px solid blue',\n * };\n *\n * function Example(): ReactElement {\n * const { onDrop } = useFileUpload()\n * const { isOver, isDragging, dropzoneHandlers } = useDropzone({\n * onDrop(event) {\n * // normally use the `onDrop` behavior from `useFileUpload` to upload\n * // files:\n * // onDrop(event);\n * },\n * });\n *\n * return (\n * <div\n * {...dropzoneHandlers}\n * style={{\n * ...(isDragging && draggingStyle),\n * ...(isOver && overStyle),\n * }}\n * >\n * Drag and drop some files!\n * {isOver && <UploadSVGIcon />}\n * </div>\n * );\n * }\n * ```\n *\n * @since 2.9.0\n * @since 6.0.0 Supports document-level dragging flag;\n */\nexport function useDropzone(options: DropzoneOptions): DropzoneHookReturnValue {\n const {\n onDrop,\n onDragOver = noop,\n onDragEnter = noop,\n onDragLeave = noop,\n disableDragging = false,\n } = options;\n\n const [isOver, setOver] = useState(false);\n const [isDragging, setDragging] = useState(false);\n const draggingTimeout = useRef<number | undefined>();\n\n useEffect(() => {\n if (disableDragging) {\n return;\n }\n\n const startDragging = (): void => {\n setDragging(true);\n };\n\n // Browsers sometimes don't trigger a dragleave event for the entire\n // document, so we have to work around that by using the `dragover` event\n // instead. The `dragover` event will continually fire within the window\n // until the user drops the file or moves the file outside of the window.\n //\n // So we can consider the\n const handler = (): void => {\n window.clearTimeout(draggingTimeout.current);\n draggingTimeout.current = window.setTimeout(() => {\n setDragging(false);\n }, 100);\n };\n\n window.addEventListener(\"dragenter\", startDragging);\n window.addEventListener(\"dragover\", handler);\n return () => {\n window.clearTimeout(draggingTimeout.current);\n window.removeEventListener(\"dragenter\", startDragging);\n window.removeEventListener(\"dragover\", handler);\n };\n }, [disableDragging]);\n\n return {\n isOver,\n isDragging,\n dropzoneHandlers: {\n // Note: need to call `event.stopPropagation()` and\n // `event.preventDefault())` for each of these handlers to prevent the\n // default browser behavior when dropping. Only calling within `onDrop`\n // does not work.\n //\n // i.e. dropping an image would preview that image in the current\n // window/tab instead of triggering the drop event.\n onDrop(event) {\n event.preventDefault();\n event.stopPropagation();\n\n window.clearTimeout(draggingTimeout.current);\n onDrop(event);\n setOver(false);\n setDragging(false);\n },\n onDragOver(event) {\n event.preventDefault();\n event.stopPropagation();\n\n window.clearTimeout(draggingTimeout.current);\n onDragOver(event);\n setOver(true);\n },\n onDragEnter(event) {\n event.preventDefault();\n event.stopPropagation();\n\n onDragEnter(event);\n setOver(true);\n },\n onDragLeave(event) {\n event.preventDefault();\n event.stopPropagation();\n\n onDragLeave(event);\n setOver(false);\n },\n },\n };\n}\n"],"names":["useEffect","useRef","useState","noop","useDropzone","options","onDrop","onDragOver","onDragEnter","onDragLeave","disableDragging","isOver","setOver","isDragging","setDragging","draggingTimeout","startDragging","handler","window","clearTimeout","current","setTimeout","addEventListener","removeEventListener","dropzoneHandlers","event","preventDefault","stopPropagation"],"mappings":"AAAA;AAEA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,MAAMC,OAAO;AACX,aAAa;AACf;AAyDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EACJC,MAAM,EACNC,aAAaJ,IAAI,EACjBK,cAAcL,IAAI,EAClBM,cAAcN,IAAI,EAClBO,kBAAkB,KAAK,EACxB,GAAGL;IAEJ,MAAM,CAACM,QAAQC,QAAQ,GAAGV,SAAS;IACnC,MAAM,CAACW,YAAYC,YAAY,GAAGZ,SAAS;IAC3C,MAAMa,kBAAkBd;IAExBD,UAAU;QACR,IAAIU,iBAAiB;YACnB;QACF;QAEA,MAAMM,gBAAgB;YACpBF,YAAY;QACd;QAEA,oEAAoE;QACpE,yEAAyE;QACzE,wEAAwE;QACxE,yEAAyE;QACzE,EAAE;QACF,yBAAyB;QACzB,MAAMG,UAAU;YACdC,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;YAC3CL,gBAAgBK,OAAO,GAAGF,OAAOG,UAAU,CAAC;gBAC1CP,YAAY;YACd,GAAG;QACL;QAEAI,OAAOI,gBAAgB,CAAC,aAAaN;QACrCE,OAAOI,gBAAgB,CAAC,YAAYL;QACpC,OAAO;YACLC,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;YAC3CF,OAAOK,mBAAmB,CAAC,aAAaP;YACxCE,OAAOK,mBAAmB,CAAC,YAAYN;QACzC;IACF,GAAG;QAACP;KAAgB;IAEpB,OAAO;QACLC;QACAE;QACAW,kBAAkB;YAChB,mDAAmD;YACnD,sEAAsE;YACtE,uEAAuE;YACvE,iBAAiB;YACjB,EAAE;YACF,iEAAiE;YACjE,mDAAmD;YACnDlB,QAAOmB,KAAK;gBACVA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBT,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;gBAC3Cd,OAAOmB;gBACPb,QAAQ;gBACRE,YAAY;YACd;YACAP,YAAWkB,KAAK;gBACdA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBT,OAAOC,YAAY,CAACJ,gBAAgBK,OAAO;gBAC3Cb,WAAWkB;gBACXb,QAAQ;YACV;YACAJ,aAAYiB,KAAK;gBACfA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBnB,YAAYiB;gBACZb,QAAQ;YACV;YACAH,aAAYgB,KAAK;gBACfA,MAAMC,cAAc;gBACpBD,MAAME,eAAe;gBAErBlB,YAAYgB;gBACZb,QAAQ;YACV;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useElementSize.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef, useState, type RefCallback } from \"react\";\nimport { type ElementSize, type UseStateInitializer } from \"./types.js\";\nimport {\n useResizeObserver,\n type ResizeObserverHookOptions,\n} from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeOptions<E extends HTMLElement>\n extends Omit<ResizeObserverHookOptions<E>, \"onUpdate\"> {\n /** @defaultValue `{ height: 0, width: 0 }` */\n defaultValue?: UseStateInitializer<ElementSize>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeImplementation<E extends HTMLElement>\n extends ElementSize {\n elementRef: RefCallback<E>;\n\n /**\n * This will be `true` once the resize observer's callback is triggered at\n * least once.\n *\n * This was added so that generating custom properties that have a reasonable\n * default value set in css don't cause major layout shifts when a default\n * value cannot be provided.\n *\n * @example\n * ```tsx\n * const { height, width, observedOnce }` = useElementSize();\n * useCSSVariables(useMemo(() => {\n * if (!observedOnce) {\n * return []\n * }\n *\n * // something that uses the element's height, width, or both\n * return [{ var: \"--something\", value: height / width * 0.5 }];\n * }, [height, width, observedOnce]))\n * ```\n */\n observedOnce: boolean;\n}\n\n/**\n * A small wrapper around the {@link useResizeObserver} hook to calculate the\n * element's size.\n *\n * @example Simple Example\n * ```tsx\n * import { useElementSize } from \"@react-md/core\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width, elementRef } = useElementSize();\n *\n * return (\n * <div ref={elementRef}>\n * {`height: ${height}, width: ${width}`}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useElementSize<E extends HTMLElement>(\n options: ElementSizeOptions<E> = {}\n): ElementSizeImplementation<E> {\n const { defaultValue } = options;\n\n const observedOnce = useRef(false);\n const [size, setSize] = useState<ElementSize>(() => {\n if (typeof defaultValue === \"function\") {\n return defaultValue();\n }\n\n return (\n defaultValue ?? {\n height: 0,\n width: 0,\n }\n );\n });\n\n const elementRef = useResizeObserver({\n ...options,\n onUpdate: useCallback((entry) => {\n observedOnce.current = true;\n const size = entry.borderBoxSize[0];\n\n setSize({\n height: size.blockSize,\n width: size.inlineSize,\n });\n }, []),\n });\n\n return {\n ...size,\n elementRef,\n observedOnce: observedOnce.current,\n };\n}\n"],"names":["useCallback","useRef","useState","useResizeObserver","useElementSize","options","defaultValue","observedOnce","size","setSize","height","width","elementRef","onUpdate","entry","current","borderBoxSize","blockSize","inlineSize"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAA0B,QAAQ;AAExE,SACEC,iBAAiB,QAEZ,yBAAyB;AA0ChC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,eACdC,UAAiC,CAAC,CAAC;IAEnC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IAEzB,MAAME,eAAeN,OAAO;IAC5B,MAAM,CAACO,MAAMC,QAAQ,GAAGP,SAAsB;QAC5C,IAAI,OAAOI,iBAAiB,YAAY;YACtC,OAAOA;QACT;QAEA,OACEA,gBAAgB;YACdI,QAAQ;YACRC,OAAO;QACT;IAEJ;IAEA,MAAMC,aAAaT,kBAAkB;QACnC,GAAGE,OAAO;QACVQ,UAAUb,YAAY,CAACc;YACrBP,aAAaQ,OAAO,GAAG;YACvB,MAAMP,OAAOM,MAAME,aAAa,CAAC,EAAE;YAEnCP,QAAQ;gBACNC,QAAQF,KAAKS,SAAS;gBACtBN,OAAOH,KAAKU,UAAU;YACxB;QACF,GAAG,EAAE;IACP;IAEA,OAAO;QACL,GAAGV,IAAI;QACPI;QACAL,cAAcA,aAAaQ,OAAO;IACpC;AACF"}
1
+ {"version":3,"sources":["../src/useElementSize.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef, useState, type RefCallback } from \"react\";\nimport { type ElementSize, type UseStateInitializer } from \"./types.js\";\nimport {\n useResizeObserver,\n type ResizeObserverHookOptions,\n} from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeOptions<E extends HTMLElement>\n extends Omit<ResizeObserverHookOptions<E>, \"onUpdate\"> {\n /** @defaultValue `{ height: 0, width: 0 }` */\n defaultValue?: UseStateInitializer<ElementSize>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeImplementation<E extends HTMLElement>\n extends ElementSize {\n elementRef: RefCallback<E>;\n\n /**\n * This will be `true` once the resize observer's callback is triggered at\n * least once.\n *\n * This was added so that generating custom properties that have a reasonable\n * default value set in css don't cause major layout shifts when a default\n * value cannot be provided.\n *\n * @example\n * ```tsx\n * const { height, width, observedOnce }` = useElementSize();\n * useCSSVariables(useMemo(() => {\n * if (!observedOnce) {\n * return []\n * }\n *\n * // something that uses the element's height, width, or both\n * return [{ var: \"--something\", value: height / width * 0.5 }];\n * }, [height, width, observedOnce]))\n * ```\n */\n observedOnce: boolean;\n}\n\n/**\n * A small wrapper around the {@link useResizeObserver} hook to calculate the\n * element's size.\n *\n * @example Simple Example\n * ```tsx\n * import { useElementSize } from \"@react-md/core\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width, elementRef } = useElementSize();\n *\n * return (\n * <div ref={elementRef}>\n * {`height: ${height}, width: ${width}`}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useElementSize<E extends HTMLElement>(\n options: ElementSizeOptions<E> = {}\n): ElementSizeImplementation<E> {\n const { defaultValue } = options;\n\n const observedOnce = useRef(false);\n const [size, setSize] = useState<ElementSize>(() => {\n if (typeof defaultValue === \"function\") {\n return defaultValue();\n }\n\n return (\n defaultValue ?? {\n height: 0,\n width: 0,\n }\n );\n });\n\n const elementRef = useResizeObserver({\n ...options,\n onUpdate: useCallback((entry) => {\n observedOnce.current = true;\n const size = entry.borderBoxSize[0];\n\n setSize({\n height: size.blockSize,\n width: size.inlineSize,\n });\n }, []),\n });\n\n return {\n ...size,\n elementRef,\n observedOnce: observedOnce.current,\n };\n}\n"],"names":["useCallback","useRef","useState","useResizeObserver","useElementSize","options","defaultValue","observedOnce","size","setSize","height","width","elementRef","onUpdate","entry","current","borderBoxSize","blockSize","inlineSize"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAA0B,QAAQ;AAExE,SACEC,iBAAiB,QAEZ,yBAAyB;AA0ChC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,eACdC,UAAiC,CAAC,CAAC;IAEnC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IAEzB,MAAME,eAAeN,OAAO;IAC5B,MAAM,CAACO,MAAMC,QAAQ,GAAGP,SAAsB;QAC5C,IAAI,OAAOI,iBAAiB,YAAY;YACtC,OAAOA;QACT;QAEA,OACEA,gBAAgB;YACdI,QAAQ;YACRC,OAAO;QACT;IAEJ;IAEA,MAAMC,aAAaT,kBAAkB;QACnC,GAAGE,OAAO;QACVQ,UAAUb,YAAY,CAACc;YACrBP,aAAaQ,OAAO,GAAG;YACvB,MAAMP,OAAOM,MAAME,aAAa,CAAC,EAAE;YAEnCP,QAAQ;gBACNC,QAAQF,KAAKS,SAAS;gBACtBN,OAAOH,KAAKU,UAAU;YACxB;QACF,GAAG,EAAE;IACP;IAEA,OAAO;QACL,GAAGV,IAAI;QACPI;QACAL,cAAcA,aAAaQ,OAAO;IACpC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useEnsuredId.ts"],"sourcesContent":["import { useId } from \"react\";\n\n/**\n * This hook is used to ensure that an `id` has been provided to a component\n * either through props or use the `useId` hook.\n *\n * @example Simple Example\n * ```tsx\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import { useEnsuredId } from \"@react-md/core\";\n *\n * export function MaterialDesignComponent(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const id = useEnsuredId(props.id, \"component-name\");\n *\n * return <div {...props} id={id} />;\n * }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport function useEnsuredId(\n propId: string | undefined,\n prefix: string\n): string {\n const id = useId();\n\n return propId ?? `${prefix}-${id}`;\n}\n"],"names":["useId","useEnsuredId","propId","prefix","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,KAAK,QAAQ,QAAQ;AAE9B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aACdC,MAA0B,EAC1BC,MAAc;IAEd,MAAMC,KAAKJ;IAEX,OAAOE,UAAU,CAAC,EAAEC,OAAO,CAAC,EAAEC,GAAG,CAAC;AACpC"}
1
+ {"version":3,"sources":["../src/useEnsuredId.ts"],"sourcesContent":["import { useId } from \"react\";\n\n/**\n * This hook is used to ensure that an `id` has been provided to a component\n * either through props or use the `useId` hook.\n *\n * @example Simple Example\n * ```tsx\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import { useEnsuredId } from \"@react-md/core\";\n *\n * export function MaterialDesignComponent(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const id = useEnsuredId(props.id, \"component-name\");\n *\n * return <div {...props} id={id} />;\n * }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport function useEnsuredId(\n propId: string | undefined,\n prefix: string\n): string {\n const id = useId();\n\n return propId ?? `${prefix}-${id}`;\n}\n"],"names":["useId","useEnsuredId","propId","prefix","id"],"mappings":"AAAA,SAASA,KAAK,QAAQ,QAAQ;AAE9B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aACdC,MAA0B,EAC1BC,MAAc;IAEd,MAAMC,KAAKJ;IAEX,OAAOE,UAAU,CAAC,EAAEC,OAAO,CAAC,EAAEC,GAAG,CAAC;AACpC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useEnsuredRef.ts"],"sourcesContent":["\"use client\";\nimport type { MutableRefObject, Ref, RefCallback } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { applyRef } from \"./utils/applyRef.js\";\n\n/**\n * @since 2.3.0\n * @internal\n */\nexport type EnsuredRefs<E extends HTMLElement> = readonly [\n MutableRefObject<E | null>,\n RefCallback<E | null>,\n];\n\n/**\n * This is mostly an internal hook that allows for an optional ref (normally\n * from props or hook options) to be merged with a hook's required `ref`. This\n * will return a MutableRefObject used for DOM manipulation in a custom hook\n * followed by a ref callback function that should be passed to the DOM node\n * that will ensure that both the optional `propRef` and hook ref are updated.\n *\n * @example Simple Example\n * ```tsx\n * import { HTMLAttributes, forwardRef } from \"react\";\n * import { useEnsuredRef } from \"@react-md/core\";\n *\n * export type ExampleProps = HTMLAttributes<HTMLDivElement>;\n *\n * export const Example = forwardRef<HTMLDivElement, ExampleProps>(function Example(props, ref) {\n * const [nodeRef, refHandler] = useEnsuredRef(ref);\n * useEffect(() => {\n * // do something with nodeRef.current\n * }, [nodeRef])\n *\n * return <div ref={refHandler} />;\n * });\n * ```\n *\n * @since 2.3.0\n * @internal\n */\nexport function useEnsuredRef<E extends HTMLElement>(\n propRef?: Ref<E | null>\n): EnsuredRefs<E> {\n const ref = useRef<E | null>(null);\n const refHandler = useCallback(\n (instance: E | null) => {\n applyRef(instance, propRef);\n ref.current = instance;\n },\n [propRef]\n );\n\n return [ref, refHandler];\n}\n"],"names":["useCallback","useRef","applyRef","useEnsuredRef","propRef","ref","refHandler","instance","current"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAC5C,SAASC,QAAQ,QAAQ,sBAAsB;AAW/C;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,cACdC,OAAuB;IAEvB,MAAMC,MAAMJ,OAAiB;IAC7B,MAAMK,aAAaN,YACjB,CAACO;QACCL,SAASK,UAAUH;QACnBC,IAAIG,OAAO,GAAGD;IAChB,GACA;QAACH;KAAQ;IAGX,OAAO;QAACC;QAAKC;KAAW;AAC1B"}
1
+ {"version":3,"sources":["../src/useEnsuredRef.ts"],"sourcesContent":["\"use client\";\nimport type { MutableRefObject, Ref, RefCallback } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { applyRef } from \"./utils/applyRef.js\";\n\n/**\n * @since 2.3.0\n * @internal\n */\nexport type EnsuredRefs<E extends HTMLElement> = readonly [\n MutableRefObject<E | null>,\n RefCallback<E | null>,\n];\n\n/**\n * This is mostly an internal hook that allows for an optional ref (normally\n * from props or hook options) to be merged with a hook's required `ref`. This\n * will return a MutableRefObject used for DOM manipulation in a custom hook\n * followed by a ref callback function that should be passed to the DOM node\n * that will ensure that both the optional `propRef` and hook ref are updated.\n *\n * @example Simple Example\n * ```tsx\n * import { HTMLAttributes, forwardRef } from \"react\";\n * import { useEnsuredRef } from \"@react-md/core\";\n *\n * export type ExampleProps = HTMLAttributes<HTMLDivElement>;\n *\n * export const Example = forwardRef<HTMLDivElement, ExampleProps>(function Example(props, ref) {\n * const [nodeRef, refHandler] = useEnsuredRef(ref);\n * useEffect(() => {\n * // do something with nodeRef.current\n * }, [nodeRef])\n *\n * return <div ref={refHandler} />;\n * });\n * ```\n *\n * @since 2.3.0\n * @internal\n */\nexport function useEnsuredRef<E extends HTMLElement>(\n propRef?: Ref<E | null>\n): EnsuredRefs<E> {\n const ref = useRef<E | null>(null);\n const refHandler = useCallback(\n (instance: E | null) => {\n applyRef(instance, propRef);\n ref.current = instance;\n },\n [propRef]\n );\n\n return [ref, refHandler];\n}\n"],"names":["useCallback","useRef","applyRef","useEnsuredRef","propRef","ref","refHandler","instance","current"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAC5C,SAASC,QAAQ,QAAQ,sBAAsB;AAW/C;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,SAASC,cACdC,OAAuB;IAEvB,MAAMC,MAAMJ,OAAiB;IAC7B,MAAMK,aAAaN,YACjB,CAACO;QACCL,SAASK,UAAUH;QACnBC,IAAIG,OAAO,GAAGD;IAChB,GACA;QAACH;KAAQ;IAGX,OAAO;QAACC;QAAKC;KAAW;AAC1B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useEnsuredState.ts"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { Dispatch } from \"react\";\nimport { useState } from \"react\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface EnsuredStateOptions<\n V,\n Setter extends Dispatch<V> | UseStateSetter<V> = UseStateSetter<V>,\n> {\n value?: V;\n setValue?: Setter;\n defaultValue?: UseStateInitializer<V>;\n}\n\n/**\n * This is used to dynamically allow controlling hooks by providing a `value` +\n * `setValue` or defaulting to uncontrolled behavior with local state.\n *\n * @internal\n * @since 6.0.0\n */\nexport function useEnsuredState<\n V,\n Setter extends Dispatch<V> | UseStateSetter<V>,\n>(\n options: EnsuredStateOptions<V, Setter>\n): readonly [value: V, setValue: Setter] {\n const { value, setValue, defaultValue } = options;\n if (typeof value !== \"undefined\" && typeof setValue !== \"undefined\") {\n return [value, setValue];\n }\n\n if (typeof value !== \"undefined\" || typeof setValue !== \"undefined\") {\n throw new Error(\n \"Both a `value` and `setValue` must be defined for controlled components.\"\n );\n }\n\n if (typeof defaultValue === \"undefined\") {\n throw new Error(\n \"A `defaultValue` must be defined for uncontrolled components.\"\n );\n }\n\n return useState(defaultValue) as [value: V, setValue: Setter];\n}\n"],"names":["useState","useEnsuredState","options","value","setValue","defaultValue","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,6CAA6C,GAE7C,SAASA,QAAQ,QAAQ,QAAQ;AAgBjC;;;;;;CAMC,GACD,OAAO,SAASC,gBAIdC,OAAuC;IAEvC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IAC1C,IAAI,OAAOC,UAAU,eAAe,OAAOC,aAAa,aAAa;QACnE,OAAO;YAACD;YAAOC;SAAS;IAC1B;IAEA,IAAI,OAAOD,UAAU,eAAe,OAAOC,aAAa,aAAa;QACnE,MAAM,IAAIE,MACR;IAEJ;IAEA,IAAI,OAAOD,iBAAiB,aAAa;QACvC,MAAM,IAAIC,MACR;IAEJ;IAEA,OAAON,SAASK;AAClB"}
1
+ {"version":3,"sources":["../src/useEnsuredState.ts"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { Dispatch } from \"react\";\nimport { useState } from \"react\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface EnsuredStateOptions<\n V,\n Setter extends Dispatch<V> | UseStateSetter<V> = UseStateSetter<V>,\n> {\n value?: V;\n setValue?: Setter;\n defaultValue?: UseStateInitializer<V>;\n}\n\n/**\n * This is used to dynamically allow controlling hooks by providing a `value` +\n * `setValue` or defaulting to uncontrolled behavior with local state.\n *\n * @internal\n * @since 6.0.0\n */\nexport function useEnsuredState<\n V,\n Setter extends Dispatch<V> | UseStateSetter<V>,\n>(\n options: EnsuredStateOptions<V, Setter>\n): readonly [value: V, setValue: Setter] {\n const { value, setValue, defaultValue } = options;\n if (typeof value !== \"undefined\" && typeof setValue !== \"undefined\") {\n return [value, setValue];\n }\n\n if (typeof value !== \"undefined\" || typeof setValue !== \"undefined\") {\n throw new Error(\n \"Both a `value` and `setValue` must be defined for controlled components.\"\n );\n }\n\n if (typeof defaultValue === \"undefined\") {\n throw new Error(\n \"A `defaultValue` must be defined for uncontrolled components.\"\n );\n }\n\n return useState(defaultValue) as [value: V, setValue: Setter];\n}\n"],"names":["useState","useEnsuredState","options","value","setValue","defaultValue","Error"],"mappings":"AAAA,6CAA6C,GAE7C,SAASA,QAAQ,QAAQ,QAAQ;AAgBjC;;;;;;CAMC,GACD,OAAO,SAASC,gBAIdC,OAAuC;IAEvC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IAC1C,IAAI,OAAOC,UAAU,eAAe,OAAOC,aAAa,aAAa;QACnE,OAAO;YAACD;YAAOC;SAAS;IAC1B;IAEA,IAAI,OAAOD,UAAU,eAAe,OAAOC,aAAa,aAAa;QACnE,MAAM,IAAIE,MACR;IAEJ;IAEA,IAAI,OAAOD,iBAAiB,aAAa;QACvC,MAAM,IAAIC,MACR;IAEJ;IAEA,OAAON,SAASK;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useHtmlClassName.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\n/**\n * @since 6.0.0\n */\nexport function useHtmlClassName(className: string): void {\n useEffect(() => {\n if (!className) {\n return;\n }\n\n const html = document.documentElement;\n html.classList.add(className);\n return () => {\n html.classList.remove(className);\n };\n }, [className]);\n}\n"],"names":["useEffect","useHtmlClassName","className","html","document","documentElement","classList","add","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAElC;;CAEC,GACD,OAAO,SAASC,iBAAiBC,SAAiB;IAChDF,UAAU;QACR,IAAI,CAACE,WAAW;YACd;QACF;QAEA,MAAMC,OAAOC,SAASC,eAAe;QACrCF,KAAKG,SAAS,CAACC,GAAG,CAACL;QACnB,OAAO;YACLC,KAAKG,SAAS,CAACE,MAAM,CAACN;QACxB;IACF,GAAG;QAACA;KAAU;AAChB"}
1
+ {"version":3,"sources":["../src/useHtmlClassName.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\n/**\n * @since 6.0.0\n */\nexport function useHtmlClassName(className: string): void {\n useEffect(() => {\n if (!className) {\n return;\n }\n\n const html = document.documentElement;\n html.classList.add(className);\n return () => {\n html.classList.remove(className);\n };\n }, [className]);\n}\n"],"names":["useEffect","useHtmlClassName","className","html","document","documentElement","classList","add","remove"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAElC;;CAEC,GACD,OAAO,SAASC,iBAAiBC,SAAiB;IAChDF,UAAU;QACR,IAAI,CAACE,WAAW;YACd;QACF;QAEA,MAAMC,OAAOC,SAASC,eAAe;QACrCF,KAAKG,SAAS,CAACC,GAAG,CAACL;QACnB,OAAO;YACLC,KAAKG,SAAS,CAACE,MAAM,CAACN;QACxB;IACF,GAAG;QAACA;KAAU;AAChB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useIntersectionObserver.ts"],"sourcesContent":["\"use client\";\nimport type { Ref, RefCallback, RefObject } from \"react\";\nimport { useEffect } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/** @since 6.0.0 */\nexport type IntersectionObserverRoot = IntersectionObserverInit[\"root\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverThreshold =\n IntersectionObserverInit[\"threshold\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverRootMargin =\n IntersectionObserverInit[\"rootMargin\"];\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface BaseIntersectionObserverHookOptions {\n /**\n * This is the same as the normal `root` for an IntersectionObserverInit, but\n * also supports refs.\n */\n root?: RefObject<IntersectionObserverRoot> | IntersectionObserverRoot;\n\n /**\n * Set this to `true` if the intersection observer behavior should be\n * disabled.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * **When using a list of thresholds, they must either be defined outside of\n * the component or wrapped in a `useMemo` to prevent the IntersectionObserver\n * from being re-created each render.**\n *\n * @example Moving Out of Render\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example() {\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * })\n * }\n * ```\n *\n * @example Wrapping in useMemo\n * ```tsx\n * interface ExampleProps {\n * min: number;\n * max: number;\n * }\n *\n * function Example({ min, max }: ExampleProps): ReactElement {\n * const targetRef = useIntersectionObserver({\n * threshold: useMemo(() => [min, max], [min, max]),\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * });\n * }\n * ```\n *\n * @see {@link getThreshold}\n */\n threshold?: IntersectionObserverThreshold;\n\n /** @see {@link getRootMargin} */\n rootMargin?: IntersectionObserverRootMargin;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link threshold} which is\n * generally useful if you need access to the DOM or do some expensive\n * computation.\n *\n * @example Simple Example\n * ```tsx\n * const targetRef = useIntersectionObserver({\n * getThreshold: useCallback(() => {\n * // pretend some expensive computation\n * return [0, 0.25, 0.5, 0.75, 1];\n * }, []),\n * OnUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * If this option is provided, {@link threshold}'s value will be ignored.\n */\n getThreshold?(): IntersectionObserverThreshold;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link rootMargin} which is\n * generally useful if you need access to the DOM.\n *\n * @example Simple Example\n * ```tsx\n * const nodeRef = useRef<HTMLElement>();\n * const targetRef = useIntersectionObserver({\n * getRootMargin: useCallback(() => {\n * return `-${nodeRef.current.offsetHeight - 1}px 0px 0px`;\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * Note: If this option is provided, {@link rootMargin} will be ignored.\n */\n getRootMargin?(): IntersectionObserverRootMargin;\n}\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface IntersectionObserverHookOptions<E extends HTMLElement>\n extends BaseIntersectionObserverHookOptions {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * @example Simple Example\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example(): ReactElement {\n * const [intersecting, setIntersecting] = useState(false);\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) {\n * setIntersecting(entry.isIntersecting);\n * }, []),\n * });\n *\n * // implementation\n * }\n * ```\n */\n onUpdate(entries: readonly IntersectionObserverEntry[]): void;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * If this is defined, the {@link ref} will be ignored along with the returned\n * ref.\n *\n * @example Watching Queried Elements\n * ```tsx\n * function Example(): ReactElement {\n * useIntersectionObserver({\n * onUpdate: useCallback((entries) => {\n * entries.forEach((entry) => {\n * // do stuff\n * });\n *\n * setIntersectingIds(intersecting);\n * }, []),\n * getTargets: useCallback(() => {\n * return document.querySelectorAll('h1, h2, h3, h4, h5, h6');\n * }, []),\n * }),\n *\n * return <div {...props} />;\n * }\n * ```\n */\n getTargets?(): readonly Element[];\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#a_simple_example\n *\n * import { useIntersectionObserver } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * import styles from \"./Example.module.scss\";\n *\n * const numSteps = 20;\n * const thresholds = Array.from({ length: numSteps }, (_, i) => i / numSteps);\n * thresholds.push(0);\n *\n * const INCREASING = \"rgba(40, 40, 190, ratio)\";\n * const DECREASING = \"rgba(190, 40, 40, ratio)\";\n *\n * export default function Example(): ReactElement {\n * const [{ ratio, increasing }, setState] = useState({\n * ratio: 0.0,\n * increasing: true,\n * });\n *\n * const targetRef = useIntersectionObserver({\n * threshold: thresholds,\n * rootMargin: \"0px\",\n * onUpdate: useCallback(([entry]) => {\n * const { intersectionRatio } = entry;\n * setState((prevState) => {\n * return {\n * ratio: intersectionRatio,\n * increasing: intersectionRatio > prevState.ratio,\n * };\n * });\n * }, []),\n * });\n *\n * return (\n * <div\n * ref={targetRef}\n * className={styles.box}\n * style={{\n * backgroundColor: (increasing ? INCREASING : DECREASING).replace(\n * \"ratio\",\n * `${ratio}`\n * ),\n * }}\n * >\n * <div className={styles.vertical}>\n * Welcome to <strong>The Box!</strong>\n * </div>\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n */\nexport function useIntersectionObserver<E extends HTMLElement>(\n options: IntersectionObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n root,\n disabled = false,\n onUpdate,\n threshold,\n rootMargin,\n getTargets,\n getThreshold,\n getRootMargin,\n } = options;\n\n const [targetNodeRef, targetRef] = useEnsuredRef(ref);\n\n useEffect(() => {\n const element = targetNodeRef.current;\n let targets: readonly Element[] = [];\n if (getTargets) {\n targets = getTargets();\n } else if (element) {\n targets = [element];\n }\n\n if (disabled || !targets.length) {\n return;\n }\n\n let resolvedRoot: IntersectionObserverRoot;\n if (root && \"current\" in root) {\n resolvedRoot = root.current;\n } else {\n resolvedRoot = root;\n }\n\n const options: IntersectionObserverInit = {\n root: resolvedRoot,\n threshold: (getThreshold || (() => threshold))(),\n rootMargin: (getRootMargin || (() => rootMargin))(),\n };\n\n // Just like the ResizeObserver, you can see performance improvements by\n // sharing a single intersection observer but I don't think it's worth the\n // effort to implement here since I'd need to:\n // - check if there is an observer with the same options\n // - if there is, add the callback to that existing observer\n // - if there isn't, create a new observer\n // - when cleaning up, check if there are any other existing callbacks\n // - disconnect and remove the observer if there are none left\n const observer = new IntersectionObserver(onUpdate, options);\n targets.forEach((target) => {\n observer.observe(target);\n });\n\n return () => {\n observer.disconnect();\n };\n }, [\n disabled,\n getRootMargin,\n getTargets,\n getThreshold,\n onUpdate,\n root,\n rootMargin,\n targetNodeRef,\n threshold,\n ]);\n\n return targetRef;\n}\n"],"names":["useEffect","useEnsuredRef","useIntersectionObserver","options","ref","root","disabled","onUpdate","threshold","rootMargin","getTargets","getThreshold","getRootMargin","targetNodeRef","targetRef","element","current","targets","length","resolvedRoot","observer","IntersectionObserver","forEach","target","observe","disconnect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,qBAAqB;AA2LnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DC,GACD,OAAO,SAASC,wBACdC,OAA2C;IAE3C,MAAM,EACJC,GAAG,EACHC,IAAI,EACJC,WAAW,KAAK,EAChBC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAM,CAACU,eAAeC,UAAU,GAAGb,cAAcG;IAEjDJ,UAAU;QACR,MAAMe,UAAUF,cAAcG,OAAO;QACrC,IAAIC,UAA8B,EAAE;QACpC,IAAIP,YAAY;YACdO,UAAUP;QACZ,OAAO,IAAIK,SAAS;YAClBE,UAAU;gBAACF;aAAQ;QACrB;QAEA,IAAIT,YAAY,CAACW,QAAQC,MAAM,EAAE;YAC/B;QACF;QAEA,IAAIC;QACJ,IAAId,QAAQ,aAAaA,MAAM;YAC7Bc,eAAed,KAAKW,OAAO;QAC7B,OAAO;YACLG,eAAed;QACjB;QAEA,MAAMF,UAAoC;YACxCE,MAAMc;YACNX,WAAW,AAACG,CAAAA,gBAAiB,CAAA,IAAMH,SAAQ,CAAC;YAC5CC,YAAY,AAACG,CAAAA,iBAAkB,CAAA,IAAMH,UAAS,CAAC;QACjD;QAEA,wEAAwE;QACxE,0EAA0E;QAC1E,8CAA8C;QAC9C,wDAAwD;QACxD,8DAA8D;QAC9D,4CAA4C;QAC5C,sEAAsE;QACtE,gEAAgE;QAChE,MAAMW,WAAW,IAAIC,qBAAqBd,UAAUJ;QACpDc,QAAQK,OAAO,CAAC,CAACC;YACfH,SAASI,OAAO,CAACD;QACnB;QAEA,OAAO;YACLH,SAASK,UAAU;QACrB;IACF,GAAG;QACDnB;QACAM;QACAF;QACAC;QACAJ;QACAF;QACAI;QACAI;QACAL;KACD;IAED,OAAOM;AACT"}
1
+ {"version":3,"sources":["../src/useIntersectionObserver.ts"],"sourcesContent":["\"use client\";\nimport type { Ref, RefCallback, RefObject } from \"react\";\nimport { useEffect } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/** @since 6.0.0 */\nexport type IntersectionObserverRoot = IntersectionObserverInit[\"root\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverThreshold =\n IntersectionObserverInit[\"threshold\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverRootMargin =\n IntersectionObserverInit[\"rootMargin\"];\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface BaseIntersectionObserverHookOptions {\n /**\n * This is the same as the normal `root` for an IntersectionObserverInit, but\n * also supports refs.\n */\n root?: RefObject<IntersectionObserverRoot> | IntersectionObserverRoot;\n\n /**\n * Set this to `true` if the intersection observer behavior should be\n * disabled.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * **When using a list of thresholds, they must either be defined outside of\n * the component or wrapped in a `useMemo` to prevent the IntersectionObserver\n * from being re-created each render.**\n *\n * @example Moving Out of Render\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example() {\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * })\n * }\n * ```\n *\n * @example Wrapping in useMemo\n * ```tsx\n * interface ExampleProps {\n * min: number;\n * max: number;\n * }\n *\n * function Example({ min, max }: ExampleProps): ReactElement {\n * const targetRef = useIntersectionObserver({\n * threshold: useMemo(() => [min, max], [min, max]),\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * });\n * }\n * ```\n *\n * @see {@link getThreshold}\n */\n threshold?: IntersectionObserverThreshold;\n\n /** @see {@link getRootMargin} */\n rootMargin?: IntersectionObserverRootMargin;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link threshold} which is\n * generally useful if you need access to the DOM or do some expensive\n * computation.\n *\n * @example Simple Example\n * ```tsx\n * const targetRef = useIntersectionObserver({\n * getThreshold: useCallback(() => {\n * // pretend some expensive computation\n * return [0, 0.25, 0.5, 0.75, 1];\n * }, []),\n * OnUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * If this option is provided, {@link threshold}'s value will be ignored.\n */\n getThreshold?(): IntersectionObserverThreshold;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link rootMargin} which is\n * generally useful if you need access to the DOM.\n *\n * @example Simple Example\n * ```tsx\n * const nodeRef = useRef<HTMLElement>();\n * const targetRef = useIntersectionObserver({\n * getRootMargin: useCallback(() => {\n * return `-${nodeRef.current.offsetHeight - 1}px 0px 0px`;\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * Note: If this option is provided, {@link rootMargin} will be ignored.\n */\n getRootMargin?(): IntersectionObserverRootMargin;\n}\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface IntersectionObserverHookOptions<E extends HTMLElement>\n extends BaseIntersectionObserverHookOptions {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * @example Simple Example\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example(): ReactElement {\n * const [intersecting, setIntersecting] = useState(false);\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) {\n * setIntersecting(entry.isIntersecting);\n * }, []),\n * });\n *\n * // implementation\n * }\n * ```\n */\n onUpdate(entries: readonly IntersectionObserverEntry[]): void;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * If this is defined, the {@link ref} will be ignored along with the returned\n * ref.\n *\n * @example Watching Queried Elements\n * ```tsx\n * function Example(): ReactElement {\n * useIntersectionObserver({\n * onUpdate: useCallback((entries) => {\n * entries.forEach((entry) => {\n * // do stuff\n * });\n *\n * setIntersectingIds(intersecting);\n * }, []),\n * getTargets: useCallback(() => {\n * return document.querySelectorAll('h1, h2, h3, h4, h5, h6');\n * }, []),\n * }),\n *\n * return <div {...props} />;\n * }\n * ```\n */\n getTargets?(): readonly Element[];\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#a_simple_example\n *\n * import { useIntersectionObserver } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * import styles from \"./Example.module.scss\";\n *\n * const numSteps = 20;\n * const thresholds = Array.from({ length: numSteps }, (_, i) => i / numSteps);\n * thresholds.push(0);\n *\n * const INCREASING = \"rgba(40, 40, 190, ratio)\";\n * const DECREASING = \"rgba(190, 40, 40, ratio)\";\n *\n * export default function Example(): ReactElement {\n * const [{ ratio, increasing }, setState] = useState({\n * ratio: 0.0,\n * increasing: true,\n * });\n *\n * const targetRef = useIntersectionObserver({\n * threshold: thresholds,\n * rootMargin: \"0px\",\n * onUpdate: useCallback(([entry]) => {\n * const { intersectionRatio } = entry;\n * setState((prevState) => {\n * return {\n * ratio: intersectionRatio,\n * increasing: intersectionRatio > prevState.ratio,\n * };\n * });\n * }, []),\n * });\n *\n * return (\n * <div\n * ref={targetRef}\n * className={styles.box}\n * style={{\n * backgroundColor: (increasing ? INCREASING : DECREASING).replace(\n * \"ratio\",\n * `${ratio}`\n * ),\n * }}\n * >\n * <div className={styles.vertical}>\n * Welcome to <strong>The Box!</strong>\n * </div>\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n */\nexport function useIntersectionObserver<E extends HTMLElement>(\n options: IntersectionObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n root,\n disabled = false,\n onUpdate,\n threshold,\n rootMargin,\n getTargets,\n getThreshold,\n getRootMargin,\n } = options;\n\n const [targetNodeRef, targetRef] = useEnsuredRef(ref);\n\n useEffect(() => {\n const element = targetNodeRef.current;\n let targets: readonly Element[] = [];\n if (getTargets) {\n targets = getTargets();\n } else if (element) {\n targets = [element];\n }\n\n if (disabled || !targets.length) {\n return;\n }\n\n let resolvedRoot: IntersectionObserverRoot;\n if (root && \"current\" in root) {\n resolvedRoot = root.current;\n } else {\n resolvedRoot = root;\n }\n\n const options: IntersectionObserverInit = {\n root: resolvedRoot,\n threshold: (getThreshold || (() => threshold))(),\n rootMargin: (getRootMargin || (() => rootMargin))(),\n };\n\n // Just like the ResizeObserver, you can see performance improvements by\n // sharing a single intersection observer but I don't think it's worth the\n // effort to implement here since I'd need to:\n // - check if there is an observer with the same options\n // - if there is, add the callback to that existing observer\n // - if there isn't, create a new observer\n // - when cleaning up, check if there are any other existing callbacks\n // - disconnect and remove the observer if there are none left\n const observer = new IntersectionObserver(onUpdate, options);\n targets.forEach((target) => {\n observer.observe(target);\n });\n\n return () => {\n observer.disconnect();\n };\n }, [\n disabled,\n getRootMargin,\n getTargets,\n getThreshold,\n onUpdate,\n root,\n rootMargin,\n targetNodeRef,\n threshold,\n ]);\n\n return targetRef;\n}\n"],"names":["useEffect","useEnsuredRef","useIntersectionObserver","options","ref","root","disabled","onUpdate","threshold","rootMargin","getTargets","getThreshold","getRootMargin","targetNodeRef","targetRef","element","current","targets","length","resolvedRoot","observer","IntersectionObserver","forEach","target","observe","disconnect"],"mappings":"AAAA;AAEA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,qBAAqB;AA2LnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DC,GACD,OAAO,SAASC,wBACdC,OAA2C;IAE3C,MAAM,EACJC,GAAG,EACHC,IAAI,EACJC,WAAW,KAAK,EAChBC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAM,CAACU,eAAeC,UAAU,GAAGb,cAAcG;IAEjDJ,UAAU;QACR,MAAMe,UAAUF,cAAcG,OAAO;QACrC,IAAIC,UAA8B,EAAE;QACpC,IAAIP,YAAY;YACdO,UAAUP;QACZ,OAAO,IAAIK,SAAS;YAClBE,UAAU;gBAACF;aAAQ;QACrB;QAEA,IAAIT,YAAY,CAACW,QAAQC,MAAM,EAAE;YAC/B;QACF;QAEA,IAAIC;QACJ,IAAId,QAAQ,aAAaA,MAAM;YAC7Bc,eAAed,KAAKW,OAAO;QAC7B,OAAO;YACLG,eAAed;QACjB;QAEA,MAAMF,UAAoC;YACxCE,MAAMc;YACNX,WAAW,AAACG,CAAAA,gBAAiB,CAAA,IAAMH,SAAQ,CAAC;YAC5CC,YAAY,AAACG,CAAAA,iBAAkB,CAAA,IAAMH,UAAS,CAAC;QACjD;QAEA,wEAAwE;QACxE,0EAA0E;QAC1E,8CAA8C;QAC9C,wDAAwD;QACxD,8DAA8D;QAC9D,4CAA4C;QAC5C,sEAAsE;QACtE,gEAAgE;QAChE,MAAMW,WAAW,IAAIC,qBAAqBd,UAAUJ;QACpDc,QAAQK,OAAO,CAAC,CAACC;YACfH,SAASI,OAAO,CAACD;QACnB;QAEA,OAAO;YACLH,SAASK,UAAU;QACrB;IACF,GAAG;QACDnB;QACAM;QACAF;QACAC;QACAJ;QACAF;QACAI;QACAI;QACAL;KACD;IAED,OAAOM;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useIsomorphicLayoutEffect.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useLayoutEffect } from \"react\";\n\n/**\n * This is copy/pasted from react-redux which has some more information about\n * this and how to fix \"invalid\" warnings while running tests.\n *\n * @see {@link https://github.com/reduxjs/react-redux/blob/4c907c0870c6b9a136dd69be294c17d1dc63c8f5/src/utils/useIsomorphicLayoutEffect.js}\n */\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\" &&\n typeof window.document.createElement !== \"undefined\"\n ? useLayoutEffect\n : useEffect;\n"],"names":["useEffect","useLayoutEffect","useIsomorphicLayoutEffect","window","document","createElement"],"rangeMappings":";;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,eAAe,QAAQ,QAAQ;AAEnD;;;;;CAKC,GACD,OAAO,MAAMC,4BACX,OAAOC,WAAW,eAClB,OAAOA,OAAOC,QAAQ,KAAK,eAC3B,OAAOD,OAAOC,QAAQ,CAACC,aAAa,KAAK,cACrCJ,kBACAD,UAAU"}
1
+ {"version":3,"sources":["../src/useIsomorphicLayoutEffect.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useLayoutEffect } from \"react\";\n\n/**\n * This is copy/pasted from react-redux which has some more information about\n * this and how to fix \"invalid\" warnings while running tests.\n *\n * @see {@link https://github.com/reduxjs/react-redux/blob/4c907c0870c6b9a136dd69be294c17d1dc63c8f5/src/utils/useIsomorphicLayoutEffect.js}\n */\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\" &&\n typeof window.document.createElement !== \"undefined\"\n ? useLayoutEffect\n : useEffect;\n"],"names":["useEffect","useLayoutEffect","useIsomorphicLayoutEffect","window","document","createElement"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,eAAe,QAAQ,QAAQ;AAEnD;;;;;CAKC,GACD,OAAO,MAAMC,4BACX,OAAOC,WAAW,eAClB,OAAOA,OAAOC,QAAQ,KAAK,eAC3B,OAAOD,OAAOC,QAAQ,CAACC,aAAa,KAAK,cACrCJ,kBACAD,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useLocalStorage.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nimport { identity } from \"./utils/identity.js\";\n\n/** @since 6.0.0 */\nexport type LocalStorageSerializer<T> = (value: T) => string;\n/** @since 6.0.0 */\nexport type LocalStorageDeserializer<T> = (item: string) => T;\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookOptions<T> {\n /**\n * The local storage key name to use.\n *\n * This can be set to an empty string for internal usage of conditionally\n * saving items to local storage.\n */\n key: string;\n\n /**\n * The default value to use if an item does not exist in local storage.\n */\n defaultValue: UseStateInitializer<T>;\n\n /**\n * Set this to `true` if the `value` should not persist to local storage\n * immediately whenever it changes. You will manually need to call\n * {@link LocalStorageHookReturnValue.persist} instead.\n *\n * @see {@link LocalStorageHookReturnValue.persist} for an example.\n * @defaultValue `false`\n */\n manual?: boolean;\n\n /**\n * Set this to `true` to update:\n *\n * - the default {@link serializer} to be:\n * ```\n * typeof value === \"string\" ? value : `${value}`\n * ```\n * - the default {@link deserializer} to not call `JSON.parse` if the\n * {@link defaultValue} is a string.\n *\n * @defaultValue `typeof defaultValue === 'string'`\n */\n raw?: boolean;\n\n /**\n * An optional function to serialize the `value` before storing it in local\n * storage.\n *\n * @defaultValue `JSON.stringify`\n */\n serializer?: LocalStorageSerializer<T>;\n\n /**\n * An optional function to deserialize the `value` if the item existed in\n * local storage.\n *\n * @defaultValue `JSON.parse`\n */\n deserializer?: LocalStorageDeserializer<T>;\n}\n\n/**\n * @since 6.0.0\n */\nexport const defaultLocalStorageSerializer = <T>(value: T): string =>\n typeof value === \"string\" ? value : `${value}`;\n\n/** @since 6.0.0 */\nexport interface GetItemFromStorageOptions<T> {\n /**\n * The storage key to use\n */\n key: string;\n\n /**\n * A value to use when the {@link key} does not exist in storage or there is\n * an error deserializing the value.\n */\n fallback: T;\n\n /** @see {@link LocalStorageHookOptions.deserializer} */\n deserializer?: LocalStorageDeserializer<T>;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * const item1 = getItemFromStorage({\n * key: \"testKey\",\n * fallback: values[0],\n * deserializer(item) {\n * if (!values.includes(item)) {\n * return values[0]\n * }\n *\n * return item;\n * },\n * });\n *\n * const item2 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * });\n *\n * const item3 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const getItemFromStorage = <T>(\n options: GetItemFromStorageOptions<T>\n): T => {\n const {\n key,\n fallback,\n storage = localStorage,\n deserializer = JSON.parse,\n } = options;\n if (!key) {\n return fallback;\n }\n\n try {\n const value = storage.getItem(key);\n return !value ? fallback : deserializer(value);\n } catch (e) {\n return fallback;\n }\n};\n\n/** @since 6.0.0 */\nexport interface SetItemInStorageOptions<T> {\n key: string;\n value: T;\n /** @defaultValue `localStorage` */\n storage?: Storage;\n\n /** @see {@link LocalStorageHookOptions.serializer} */\n serializer?: LocalStorageSerializer<T>;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { identity, getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * setItemInStorage({\n * key: \"testKey\",\n * value: values[0],\n * // store string value as-is\n * serializer: identity,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const setItemInStorage = <T>(\n options: SetItemInStorageOptions<T>\n): void => {\n const {\n key,\n value,\n storage = localStorage,\n serializer = JSON.stringify,\n } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.setItem(key, serializer(value));\n } catch {\n //\n }\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface RemoveItemFromStorageOptions {\n key: string;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const removeItemFromStorage = (\n options: RemoveItemFromStorageOptions\n): void => {\n const { key, storage = localStorage } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.removeItem(key);\n } catch {\n // do nothing\n }\n};\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookReturnValue<T> {\n value: T;\n\n /**\n * Updates the {@link value} in state. When the\n * {@link LocalStorageHookOptions.manual} option is `false`, the value will\n * also be updated in local storage immediately.\n */\n setValue: UseStateSetter<T>;\n\n /**\n * Remove the item from local storage.\n */\n remove(): void;\n\n /**\n * Manually persist the current {@link value} into local storage. This is only\n * useful if the {@link LocalStorageHookOptions.manual} option is `true`.\n *\n * @example Manual Persisting\n * ```tsx\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: \"\",\n * });\n *\n * return (\n * <>\n * <Button onClick={closeDialog}>\n * Cancel\n * </Button>\n * <Button\n * onClick={async () => {\n * await saveToDatabase(value);\n * persist();\n * closeDialog();\n * }}\n * >\n * Confirm\n * </Button>\n * </>\n * );\n * }\n * ```\n */\n persist(): void;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { TextField, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage({\n * key: \"savedSearch\",\n * defaultValue: \"\",\n * });\n *\n * return (\n * <TextField\n * label=\"Search\"\n * placeholder=\"Search...\"\n * type=\"search\"\n * value={value}\n * onChange={(event) => {\n * setValue(event.currentTarget.value)\n * }}\n * />\n * );\n * }\n * ```\n *\n * @example Type-safe Objects\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { useLocalStorage } from \"@react-md/core\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage<ExpectedSchema | null>({\n * key: \"someKey\",\n * defaultValue: null,\n *\n * // this is optional: you can create a custom deserializer to validate\n * // the stored value to prevent people manually updating local storage in\n * // the dev tools\n * deserializer(item) {\n * const parsed = JSON.parse(item):\n * const { label, value } = parsed;\n * if (typeof label !== 'string' || typeof value !== 'string') {\n * return null;\n * }\n *\n * return { label, value };\n * }\n * });\n *\n * // do something\n * // value will be `ExpectedSchema | null`\n * }\n * ```\n *\n * @example Manual Persistence\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { Button, Checkbox, Form, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: false,\n * });\n *\n * return (\n * <Form\n * onSubmit={() => {\n * // current value will be saved into local storage\n * persist();\n * }}\n * onReset={() => {\n * // \"someKey\" will be removed from local storage\n * remove();\n * }}\n * >\n * <Checkbox\n * label=\"Allow cookies\"\n * checked={value}\n * onChange={(event) =>\n * setValue(event.currentTarget.checked);\n * }\n * />\n * <Button type=\"reset\">Decline</Button>\n * <Button type=\"submit\">Save</Button>\n * </Form>\n * );\n * }\n * ```\n *\n * Note: Using the same local storage key in multiple parts in your app will not\n * update all instances with that value. The value will only be updated if it\n * was updated in a separate tab with the `\"storage\"` event. You must setup your\n * own context to share values or another state manager solution.\n *\n * @example Shared Value\n * ```tsx\n * const context = createContext(null);\n * const { Provider } = context;\n *\n * export function useSomeValue(): string {\n * const value = useContext(context);\n * if (!value) {\n * throw new Error()\n * }\n *\n * return value;\n * }\n *\n * function Example({ children }: { children: ReactNode }) {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * defaultValue: \"\",\n *\n * // optional\n * manual: true,\n * });\n *\n * return (\n * <Provider\n * value={useMemo(() => ({\n * value,\n * setValue,\n *\n * // remove and persist are optional\n * remove,\n * persist,\n * }), [value, setValue, remove, persist])}\n * >\n * {children}\n * </Provider>\n * );\n * }\n *\n * function SomeChildComponent() {\n * const { value, setValue } = useSomeValue();\n * // do stuff\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useLocalStorage<T>(\n options: LocalStorageHookOptions<T>\n): LocalStorageHookReturnValue<T> {\n const { key, defaultValue, manual = false } = options;\n\n const [initialValue] = useState(defaultValue);\n // this allows for strings to automatically be stored as-is instead of adding\n // additional quotes around then with JSON.stringify\n const raw = options.raw ?? typeof initialValue === \"string\";\n const serializer =\n options.serializer ??\n (raw ? defaultLocalStorageSerializer : JSON.stringify);\n const deserializer =\n options.deserializer ??\n (raw && typeof initialValue === \"string\" ? identity : JSON.parse);\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n const value = getItemFromStorage({\n key,\n fallback: initialValue,\n deserializer,\n });\n if (!manual) {\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }\n\n return value;\n });\n const config = useRef({\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, serializer } = config.current;\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual) {\n setItemInStorage({\n key,\n value: nextValue,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage({\n key: config.current.key,\n });\n }, []);\n\n const persist = useCallback(() => {\n const { key, value, serializer } = config.current;\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }, []);\n\n useEffect(() => {\n const { defaultValue, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n setValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr, setValue]);\n\n // update the value if another tab changed the local storage value\n useEffect(() => {\n if (!key) {\n return;\n }\n\n const callback = (event: StorageEvent): void => {\n const { defaultValue, deserializer } = config.current;\n if (event.key === key) {\n setStoredValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }\n };\n\n window.addEventListener(\"storage\", callback);\n return () => {\n window.removeEventListener(\"storage\", callback);\n };\n }, [key]);\n\n return {\n value,\n setValue,\n remove,\n persist,\n };\n}\n"],"names":["useCallback","useEffect","useRef","useState","useSsr","useIsomorphicLayoutEffect","identity","defaultLocalStorageSerializer","value","getItemFromStorage","options","key","fallback","storage","localStorage","deserializer","JSON","parse","getItem","e","setItemInStorage","serializer","stringify","setItem","removeItemFromStorage","removeItem","useLocalStorage","defaultValue","manual","initialValue","raw","ssr","setStoredValue","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","window","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
1
+ {"version":3,"sources":["../src/useLocalStorage.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nimport { identity } from \"./utils/identity.js\";\n\n/** @since 6.0.0 */\nexport type LocalStorageSerializer<T> = (value: T) => string;\n/** @since 6.0.0 */\nexport type LocalStorageDeserializer<T> = (item: string) => T;\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookOptions<T> {\n /**\n * The local storage key name to use.\n *\n * This can be set to an empty string for internal usage of conditionally\n * saving items to local storage.\n */\n key: string;\n\n /**\n * The default value to use if an item does not exist in local storage.\n */\n defaultValue: UseStateInitializer<T>;\n\n /**\n * Set this to `true` if the `value` should not persist to local storage\n * immediately whenever it changes. You will manually need to call\n * {@link LocalStorageHookReturnValue.persist} instead.\n *\n * @see {@link LocalStorageHookReturnValue.persist} for an example.\n * @defaultValue `false`\n */\n manual?: boolean;\n\n /**\n * Set this to `true` to update:\n *\n * - the default {@link serializer} to be:\n * ```\n * typeof value === \"string\" ? value : `${value}`\n * ```\n * - the default {@link deserializer} to not call `JSON.parse` if the\n * {@link defaultValue} is a string.\n *\n * @defaultValue `typeof defaultValue === 'string'`\n */\n raw?: boolean;\n\n /**\n * An optional function to serialize the `value` before storing it in local\n * storage.\n *\n * @defaultValue `JSON.stringify`\n */\n serializer?: LocalStorageSerializer<T>;\n\n /**\n * An optional function to deserialize the `value` if the item existed in\n * local storage.\n *\n * @defaultValue `JSON.parse`\n */\n deserializer?: LocalStorageDeserializer<T>;\n}\n\n/**\n * @since 6.0.0\n */\nexport const defaultLocalStorageSerializer = <T>(value: T): string =>\n typeof value === \"string\" ? value : `${value}`;\n\n/** @since 6.0.0 */\nexport interface GetItemFromStorageOptions<T> {\n /**\n * The storage key to use\n */\n key: string;\n\n /**\n * A value to use when the {@link key} does not exist in storage or there is\n * an error deserializing the value.\n */\n fallback: T;\n\n /** @see {@link LocalStorageHookOptions.deserializer} */\n deserializer?: LocalStorageDeserializer<T>;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * const item1 = getItemFromStorage({\n * key: \"testKey\",\n * fallback: values[0],\n * deserializer(item) {\n * if (!values.includes(item)) {\n * return values[0]\n * }\n *\n * return item;\n * },\n * });\n *\n * const item2 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * });\n *\n * const item3 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const getItemFromStorage = <T>(\n options: GetItemFromStorageOptions<T>\n): T => {\n const {\n key,\n fallback,\n storage = localStorage,\n deserializer = JSON.parse,\n } = options;\n if (!key) {\n return fallback;\n }\n\n try {\n const value = storage.getItem(key);\n return !value ? fallback : deserializer(value);\n } catch (e) {\n return fallback;\n }\n};\n\n/** @since 6.0.0 */\nexport interface SetItemInStorageOptions<T> {\n key: string;\n value: T;\n /** @defaultValue `localStorage` */\n storage?: Storage;\n\n /** @see {@link LocalStorageHookOptions.serializer} */\n serializer?: LocalStorageSerializer<T>;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { identity, getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * setItemInStorage({\n * key: \"testKey\",\n * value: values[0],\n * // store string value as-is\n * serializer: identity,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const setItemInStorage = <T>(\n options: SetItemInStorageOptions<T>\n): void => {\n const {\n key,\n value,\n storage = localStorage,\n serializer = JSON.stringify,\n } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.setItem(key, serializer(value));\n } catch {\n //\n }\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface RemoveItemFromStorageOptions {\n key: string;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const removeItemFromStorage = (\n options: RemoveItemFromStorageOptions\n): void => {\n const { key, storage = localStorage } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.removeItem(key);\n } catch {\n // do nothing\n }\n};\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookReturnValue<T> {\n value: T;\n\n /**\n * Updates the {@link value} in state. When the\n * {@link LocalStorageHookOptions.manual} option is `false`, the value will\n * also be updated in local storage immediately.\n */\n setValue: UseStateSetter<T>;\n\n /**\n * Remove the item from local storage.\n */\n remove(): void;\n\n /**\n * Manually persist the current {@link value} into local storage. This is only\n * useful if the {@link LocalStorageHookOptions.manual} option is `true`.\n *\n * @example Manual Persisting\n * ```tsx\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: \"\",\n * });\n *\n * return (\n * <>\n * <Button onClick={closeDialog}>\n * Cancel\n * </Button>\n * <Button\n * onClick={async () => {\n * await saveToDatabase(value);\n * persist();\n * closeDialog();\n * }}\n * >\n * Confirm\n * </Button>\n * </>\n * );\n * }\n * ```\n */\n persist(): void;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { TextField, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage({\n * key: \"savedSearch\",\n * defaultValue: \"\",\n * });\n *\n * return (\n * <TextField\n * label=\"Search\"\n * placeholder=\"Search...\"\n * type=\"search\"\n * value={value}\n * onChange={(event) => {\n * setValue(event.currentTarget.value)\n * }}\n * />\n * );\n * }\n * ```\n *\n * @example Type-safe Objects\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { useLocalStorage } from \"@react-md/core\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage<ExpectedSchema | null>({\n * key: \"someKey\",\n * defaultValue: null,\n *\n * // this is optional: you can create a custom deserializer to validate\n * // the stored value to prevent people manually updating local storage in\n * // the dev tools\n * deserializer(item) {\n * const parsed = JSON.parse(item):\n * const { label, value } = parsed;\n * if (typeof label !== 'string' || typeof value !== 'string') {\n * return null;\n * }\n *\n * return { label, value };\n * }\n * });\n *\n * // do something\n * // value will be `ExpectedSchema | null`\n * }\n * ```\n *\n * @example Manual Persistence\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { Button, Checkbox, Form, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: false,\n * });\n *\n * return (\n * <Form\n * onSubmit={() => {\n * // current value will be saved into local storage\n * persist();\n * }}\n * onReset={() => {\n * // \"someKey\" will be removed from local storage\n * remove();\n * }}\n * >\n * <Checkbox\n * label=\"Allow cookies\"\n * checked={value}\n * onChange={(event) =>\n * setValue(event.currentTarget.checked);\n * }\n * />\n * <Button type=\"reset\">Decline</Button>\n * <Button type=\"submit\">Save</Button>\n * </Form>\n * );\n * }\n * ```\n *\n * Note: Using the same local storage key in multiple parts in your app will not\n * update all instances with that value. The value will only be updated if it\n * was updated in a separate tab with the `\"storage\"` event. You must setup your\n * own context to share values or another state manager solution.\n *\n * @example Shared Value\n * ```tsx\n * const context = createContext(null);\n * const { Provider } = context;\n *\n * export function useSomeValue(): string {\n * const value = useContext(context);\n * if (!value) {\n * throw new Error()\n * }\n *\n * return value;\n * }\n *\n * function Example({ children }: { children: ReactNode }) {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * defaultValue: \"\",\n *\n * // optional\n * manual: true,\n * });\n *\n * return (\n * <Provider\n * value={useMemo(() => ({\n * value,\n * setValue,\n *\n * // remove and persist are optional\n * remove,\n * persist,\n * }), [value, setValue, remove, persist])}\n * >\n * {children}\n * </Provider>\n * );\n * }\n *\n * function SomeChildComponent() {\n * const { value, setValue } = useSomeValue();\n * // do stuff\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useLocalStorage<T>(\n options: LocalStorageHookOptions<T>\n): LocalStorageHookReturnValue<T> {\n const { key, defaultValue, manual = false } = options;\n\n const [initialValue] = useState(defaultValue);\n // this allows for strings to automatically be stored as-is instead of adding\n // additional quotes around then with JSON.stringify\n const raw = options.raw ?? typeof initialValue === \"string\";\n const serializer =\n options.serializer ??\n (raw ? defaultLocalStorageSerializer : JSON.stringify);\n const deserializer =\n options.deserializer ??\n (raw && typeof initialValue === \"string\" ? identity : JSON.parse);\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n const value = getItemFromStorage({\n key,\n fallback: initialValue,\n deserializer,\n });\n if (!manual) {\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }\n\n return value;\n });\n const config = useRef({\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, serializer } = config.current;\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual) {\n setItemInStorage({\n key,\n value: nextValue,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage({\n key: config.current.key,\n });\n }, []);\n\n const persist = useCallback(() => {\n const { key, value, serializer } = config.current;\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }, []);\n\n useEffect(() => {\n const { defaultValue, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n setValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr, setValue]);\n\n // update the value if another tab changed the local storage value\n useEffect(() => {\n if (!key) {\n return;\n }\n\n const callback = (event: StorageEvent): void => {\n const { defaultValue, deserializer } = config.current;\n if (event.key === key) {\n setStoredValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }\n };\n\n window.addEventListener(\"storage\", callback);\n return () => {\n window.removeEventListener(\"storage\", callback);\n };\n }, [key]);\n\n return {\n value,\n setValue,\n remove,\n persist,\n };\n}\n"],"names":["useCallback","useEffect","useRef","useState","useSsr","useIsomorphicLayoutEffect","identity","defaultLocalStorageSerializer","value","getItemFromStorage","options","key","fallback","storage","localStorage","deserializer","JSON","parse","getItem","e","setItemInStorage","serializer","stringify","setItem","removeItemFromStorage","removeItem","useLocalStorage","defaultValue","manual","initialValue","raw","ssr","setStoredValue","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","window","addEventListener","removeEventListener"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useMutationObserver.ts"],"sourcesContent":["import { useEffect, type RefCallback, type Ref } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MutationObserverHookOptions<E extends HTMLElement>\n extends MutationObserverInit {\n ref?: Ref<E>;\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options\n * @defaultValue `!childList && !attributes && !characterData`\n */\n disabled?: boolean;\n\n onObserved(mutation: MutationRecord): void;\n}\n\n/**\n * The mutation observer is used to track the changes made to the DOM tree.\n *\n * @example Simple Example\n * ```tsx\n * import { useMutationObserver } from \"@react-md/core\";\n * import { useCallback, type HTMLAttributes, type ReactElement } from \"react\";\n *\n * function Example(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const { children, ...remaining } = props;\n *\n * const targetRef = useMutationObserver({\n * subtree: true,\n * attributes: true,\n * childList: true,\n * onUpdate: useCallback((mutation) => {\n * switch (mutation.type) {\n * case \"childList\":\n * console.log(\"A child node has been added or removed\");\n * break;\n * case \"attributes\":\n * console.log(`The ${mutation.attributeName} attribute was modified`);\n * break\n * }\n *\n * }, []),\n * });\n *\n * return (\n * <div {...remaining} ref={targetRef}>\n * {children}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useMutationObserver<E extends HTMLElement>(\n options: MutationObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onObserved,\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n disabled = !childList && !attributes && !characterData,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const observerTarget = targetNodeRef.current;\n if (!observerTarget) {\n return;\n }\n\n const observer = new MutationObserver((records) => {\n const [entry] = records;\n if (entry) {\n onObserved(entry);\n }\n });\n\n observer.observe(observerTarget, {\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n });\n return () => {\n observer.disconnect();\n };\n }, [\n attributeFilter,\n attributeOldValue,\n attributes,\n characterData,\n characterDataOldValue,\n childList,\n disabled,\n onObserved,\n subtree,\n targetNodeRef,\n ]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","useMutationObserver","options","ref","onObserved","attributes","attributeFilter","attributeOldValue","subtree","childList","characterData","characterDataOldValue","disabled","targetNodeRef","refCallback","observerTarget","current","observer","MutationObserver","records","entry","observe","disconnect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAoC,QAAQ;AAC9D,SAASC,aAAa,QAAQ,qBAAqB;AAkBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GACD,OAAO,SAASC,oBACdC,OAAuC;IAEvC,MAAM,EACJC,GAAG,EACHC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,qBAAqB,EACrBC,WAAW,CAACH,aAAa,CAACJ,cAAc,CAACK,aAAa,EACvD,GAAGR;IAEJ,MAAM,CAACW,eAAeC,YAAY,GAAGd,cAAcG;IACnDJ,UAAU;QACR,IAAIa,UAAU;YACZ;QACF;QAEA,MAAMG,iBAAiBF,cAAcG,OAAO;QAC5C,IAAI,CAACD,gBAAgB;YACnB;QACF;QAEA,MAAME,WAAW,IAAIC,iBAAiB,CAACC;YACrC,MAAM,CAACC,MAAM,GAAGD;YAChB,IAAIC,OAAO;gBACThB,WAAWgB;YACb;QACF;QAEAH,SAASI,OAAO,CAACN,gBAAgB;YAC/BV;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACA,OAAO;YACLM,SAASK,UAAU;QACrB;IACF,GAAG;QACDhB;QACAC;QACAF;QACAK;QACAC;QACAF;QACAG;QACAR;QACAI;QACAK;KACD;IAED,OAAOC;AACT"}
1
+ {"version":3,"sources":["../src/useMutationObserver.ts"],"sourcesContent":["import { useEffect, type RefCallback, type Ref } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MutationObserverHookOptions<E extends HTMLElement>\n extends MutationObserverInit {\n ref?: Ref<E>;\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options\n * @defaultValue `!childList && !attributes && !characterData`\n */\n disabled?: boolean;\n\n onObserved(mutation: MutationRecord): void;\n}\n\n/**\n * The mutation observer is used to track the changes made to the DOM tree.\n *\n * @example Simple Example\n * ```tsx\n * import { useMutationObserver } from \"@react-md/core\";\n * import { useCallback, type HTMLAttributes, type ReactElement } from \"react\";\n *\n * function Example(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const { children, ...remaining } = props;\n *\n * const targetRef = useMutationObserver({\n * subtree: true,\n * attributes: true,\n * childList: true,\n * onUpdate: useCallback((mutation) => {\n * switch (mutation.type) {\n * case \"childList\":\n * console.log(\"A child node has been added or removed\");\n * break;\n * case \"attributes\":\n * console.log(`The ${mutation.attributeName} attribute was modified`);\n * break\n * }\n *\n * }, []),\n * });\n *\n * return (\n * <div {...remaining} ref={targetRef}>\n * {children}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useMutationObserver<E extends HTMLElement>(\n options: MutationObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onObserved,\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n disabled = !childList && !attributes && !characterData,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const observerTarget = targetNodeRef.current;\n if (!observerTarget) {\n return;\n }\n\n const observer = new MutationObserver((records) => {\n const [entry] = records;\n if (entry) {\n onObserved(entry);\n }\n });\n\n observer.observe(observerTarget, {\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n });\n return () => {\n observer.disconnect();\n };\n }, [\n attributeFilter,\n attributeOldValue,\n attributes,\n characterData,\n characterDataOldValue,\n childList,\n disabled,\n onObserved,\n subtree,\n targetNodeRef,\n ]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","useMutationObserver","options","ref","onObserved","attributes","attributeFilter","attributeOldValue","subtree","childList","characterData","characterDataOldValue","disabled","targetNodeRef","refCallback","observerTarget","current","observer","MutationObserver","records","entry","observe","disconnect"],"mappings":"AAAA,SAASA,SAAS,QAAoC,QAAQ;AAC9D,SAASC,aAAa,QAAQ,qBAAqB;AAkBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GACD,OAAO,SAASC,oBACdC,OAAuC;IAEvC,MAAM,EACJC,GAAG,EACHC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,qBAAqB,EACrBC,WAAW,CAACH,aAAa,CAACJ,cAAc,CAACK,aAAa,EACvD,GAAGR;IAEJ,MAAM,CAACW,eAAeC,YAAY,GAAGd,cAAcG;IACnDJ,UAAU;QACR,IAAIa,UAAU;YACZ;QACF;QAEA,MAAMG,iBAAiBF,cAAcG,OAAO;QAC5C,IAAI,CAACD,gBAAgB;YACnB;QACF;QAEA,MAAME,WAAW,IAAIC,iBAAiB,CAACC;YACrC,MAAM,CAACC,MAAM,GAAGD;YAChB,IAAIC,OAAO;gBACThB,WAAWgB;YACb;QACF;QAEAH,SAASI,OAAO,CAACN,gBAAgB;YAC/BV;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACA,OAAO;YACLM,SAASK,UAAU;QACrB;IACF,GAAG;QACDhB;QACAC;QACAF;QACAK;QACAC;QACAF;QACAG;QACAR;QACAI;QACAK;KACD;IAED,OAAOC;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useOrientation.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * An extremely simple \"polyfill\" for the `window.screen.orientation` just for\n * the `type` value that is required for the `useOrientation` hook.\n *\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the orientation type either from the `window.screen.orientation` or\n * by comparing the `availHeight` and `availWidth` on the `window.screen`\n * @internal\n */\nexport const getOrientationType = (): OrientationType => {\n if (typeof window === \"undefined\") {\n return \"landscape-primary\";\n }\n\n // Note: at the time of writing this, it looks like only Safari does not\n // support it from my list of browsers\n const screenOrientation = window.screen.orientation?.type;\n if (typeof screenOrientation === \"string\") {\n return screenOrientation;\n }\n\n const { availHeight, availWidth } = window.screen;\n\n return availHeight > availWidth ? \"portrait-primary\" : \"landscape-primary\";\n};\n\n/**\n * This hook uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation} API\n * to determine if the screen is landscape or portrait. For browsers that do not\n * support this API yet, it will polyfill that behavior using a resize handler\n * instead.\n *\n * @internal\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the current orientation type\n */\nexport function useOrientation(): OrientationType {\n const [orientation, setOrientation] = useState(getOrientationType);\n useEffect(() => {\n const handler = (): void => setOrientation(getOrientationType());\n\n const { orientation } = window.screen;\n if (orientation) {\n orientation.addEventListener(\"change\", handler);\n } else {\n window.addEventListener(\"resize\", handler);\n }\n\n return () => {\n if (orientation) {\n orientation.removeEventListener(\"change\", handler);\n } else {\n window.removeEventListener(\"resize\", handler);\n }\n };\n }, []);\n\n return orientation;\n}\n"],"names":["useEffect","useState","getOrientationType","window","screenOrientation","screen","orientation","type","availHeight","availWidth","useOrientation","setOrientation","handler","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB;IAChC,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,wEAAwE;IACxE,sCAAsC;IACtC,MAAMC,oBAAoBD,OAAOE,MAAM,CAACC,WAAW,EAAEC;IACrD,IAAI,OAAOH,sBAAsB,UAAU;QACzC,OAAOA;IACT;IAEA,MAAM,EAAEI,WAAW,EAAEC,UAAU,EAAE,GAAGN,OAAOE,MAAM;IAEjD,OAAOG,cAAcC,aAAa,qBAAqB;AACzD,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASC;IACd,MAAM,CAACJ,aAAaK,eAAe,GAAGV,SAASC;IAC/CF,UAAU;QACR,MAAMY,UAAU,IAAYD,eAAeT;QAE3C,MAAM,EAAEI,WAAW,EAAE,GAAGH,OAAOE,MAAM;QACrC,IAAIC,aAAa;YACfA,YAAYO,gBAAgB,CAAC,UAAUD;QACzC,OAAO;YACLT,OAAOU,gBAAgB,CAAC,UAAUD;QACpC;QAEA,OAAO;YACL,IAAIN,aAAa;gBACfA,YAAYQ,mBAAmB,CAAC,UAAUF;YAC5C,OAAO;gBACLT,OAAOW,mBAAmB,CAAC,UAAUF;YACvC;QACF;IACF,GAAG,EAAE;IAEL,OAAON;AACT"}
1
+ {"version":3,"sources":["../src/useOrientation.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * An extremely simple \"polyfill\" for the `window.screen.orientation` just for\n * the `type` value that is required for the `useOrientation` hook.\n *\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the orientation type either from the `window.screen.orientation` or\n * by comparing the `availHeight` and `availWidth` on the `window.screen`\n * @internal\n */\nexport const getOrientationType = (): OrientationType => {\n if (typeof window === \"undefined\") {\n return \"landscape-primary\";\n }\n\n // Note: at the time of writing this, it looks like only Safari does not\n // support it from my list of browsers\n const screenOrientation = window.screen.orientation?.type;\n if (typeof screenOrientation === \"string\") {\n return screenOrientation;\n }\n\n const { availHeight, availWidth } = window.screen;\n\n return availHeight > availWidth ? \"portrait-primary\" : \"landscape-primary\";\n};\n\n/**\n * This hook uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation} API\n * to determine if the screen is landscape or portrait. For browsers that do not\n * support this API yet, it will polyfill that behavior using a resize handler\n * instead.\n *\n * @internal\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the current orientation type\n */\nexport function useOrientation(): OrientationType {\n const [orientation, setOrientation] = useState(getOrientationType);\n useEffect(() => {\n const handler = (): void => setOrientation(getOrientationType());\n\n const { orientation } = window.screen;\n if (orientation) {\n orientation.addEventListener(\"change\", handler);\n } else {\n window.addEventListener(\"resize\", handler);\n }\n\n return () => {\n if (orientation) {\n orientation.removeEventListener(\"change\", handler);\n } else {\n window.removeEventListener(\"resize\", handler);\n }\n };\n }, []);\n\n return orientation;\n}\n"],"names":["useEffect","useState","getOrientationType","window","screenOrientation","screen","orientation","type","availHeight","availWidth","useOrientation","setOrientation","handler","addEventListener","removeEventListener"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB;IAChC,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,wEAAwE;IACxE,sCAAsC;IACtC,MAAMC,oBAAoBD,OAAOE,MAAM,CAACC,WAAW,EAAEC;IACrD,IAAI,OAAOH,sBAAsB,UAAU;QACzC,OAAOA;IACT;IAEA,MAAM,EAAEI,WAAW,EAAEC,UAAU,EAAE,GAAGN,OAAOE,MAAM;IAEjD,OAAOG,cAAcC,aAAa,qBAAqB;AACzD,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASC;IACd,MAAM,CAACJ,aAAaK,eAAe,GAAGV,SAASC;IAC/CF,UAAU;QACR,MAAMY,UAAU,IAAYD,eAAeT;QAE3C,MAAM,EAAEI,WAAW,EAAE,GAAGH,OAAOE,MAAM;QACrC,IAAIC,aAAa;YACfA,YAAYO,gBAAgB,CAAC,UAAUD;QACzC,OAAO;YACLT,OAAOU,gBAAgB,CAAC,UAAUD;QACpC;QAEA,OAAO;YACL,IAAIN,aAAa;gBACfA,YAAYQ,mBAAmB,CAAC,UAAUF;YAC5C,OAAO;gBACLT,OAAOW,mBAAmB,CAAC,UAAUF;YACvC;QACF;IACF,GAAG,EAAE;IAEL,OAAON;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/usePageInactive.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * When this is set to `\"focus\"`, the change handler will be fired whenever the\n * window gains or loses focus.\n *\n * When this is set to `visibility`, the change handler will be fired when the\n * browser is no longer partially visible or becomes partially visible.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState\n * @since 6.0.0\n */\nexport type PageInactiveType = \"focus\" | \"visibility\";\n\n/**\n * @since 6.0.0\n */\nexport interface PageInactiveOptions {\n /**\n * @see {@link PageInactiveType}\n * @defaultValue `\"focus\"`\n */\n type?: PageInactiveType;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This will be called whenever the page activity changes based on the\n * {@link PageInactiveType}.\n */\n onChange(active: boolean): void;\n\n /**\n * This will be fired whenever the {@link disabled} state is `true` which can\n * be useful for clearing pending timers or resetting state.\n *\n * Since this is passed to a `useEffect` as a dependency, you might have to\n * wrap this in a `useCallback` if unexpected re-rendering or errors occurs.\n *\n * @defaultValue `() => {}`\n */\n onDisabledCleanup?(): void;\n}\n\n/**\n * @example\n * ```ts\n * import { usePageInactive } from \"@react-md/core\";\n * import { useCallback, useEffect, useRef, useState } from \"react\";\n *\n * function Example(): null {\n * const [visible, setVisible] = useState(false);\n * const timeout = useRef<number | undefined>();\n * const startTimeout = useCallback(() => {\n * timeout.current = window.setTimeout(() => {\n * setVisible(false);\n * }, 10000);\n * }, []);\n *\n * usePageInactive({\n * onChange(active) {\n * if (!active) {\n * window.clearTimeout(timeout.current);\n * setVisible(false);\n * } else {\n * startTimeout();\n * }\n * }\n * });\n *\n * // pretend implementation\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function usePageInactive(options: PageInactiveOptions): void {\n const {\n type = \"focus\",\n disabled,\n onChange,\n onDisabledCleanup = noop,\n } = options;\n useEffect(() => {\n if (disabled) {\n onDisabledCleanup();\n return;\n }\n\n const callback = (event: Event): void => {\n let active = document.visibilityState === \"visible\";\n if (event.type === \"blur\") {\n active = false;\n } else if (event.type === \"focus\") {\n active = true;\n }\n\n onChange(active);\n };\n\n document.addEventListener(\"visibilitychange\", callback);\n if (type === \"focus\") {\n window.addEventListener(\"blur\", callback);\n window.addEventListener(\"focus\", callback);\n }\n\n return () => {\n document.removeEventListener(\"visibilitychange\", callback);\n window.removeEventListener(\"blur\", callback);\n window.removeEventListener(\"focus\", callback);\n };\n }, [disabled, onChange, onDisabledCleanup, type]);\n}\n"],"names":["useEffect","noop","usePageInactive","options","type","disabled","onChange","onDisabledCleanup","callback","event","active","document","visibilityState","addEventListener","window","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAElC,MAAMC,OAAO;AACX,aAAa;AACf;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,SAASC,gBAAgBC,OAA4B;IAC1D,MAAM,EACJC,OAAO,OAAO,EACdC,QAAQ,EACRC,QAAQ,EACRC,oBAAoBN,IAAI,EACzB,GAAGE;IACJH,UAAU;QACR,IAAIK,UAAU;YACZE;YACA;QACF;QAEA,MAAMC,WAAW,CAACC;YAChB,IAAIC,SAASC,SAASC,eAAe,KAAK;YAC1C,IAAIH,MAAML,IAAI,KAAK,QAAQ;gBACzBM,SAAS;YACX,OAAO,IAAID,MAAML,IAAI,KAAK,SAAS;gBACjCM,SAAS;YACX;YAEAJ,SAASI;QACX;QAEAC,SAASE,gBAAgB,CAAC,oBAAoBL;QAC9C,IAAIJ,SAAS,SAAS;YACpBU,OAAOD,gBAAgB,CAAC,QAAQL;YAChCM,OAAOD,gBAAgB,CAAC,SAASL;QACnC;QAEA,OAAO;YACLG,SAASI,mBAAmB,CAAC,oBAAoBP;YACjDM,OAAOC,mBAAmB,CAAC,QAAQP;YACnCM,OAAOC,mBAAmB,CAAC,SAASP;QACtC;IACF,GAAG;QAACH;QAAUC;QAAUC;QAAmBH;KAAK;AAClD"}
1
+ {"version":3,"sources":["../src/usePageInactive.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * When this is set to `\"focus\"`, the change handler will be fired whenever the\n * window gains or loses focus.\n *\n * When this is set to `visibility`, the change handler will be fired when the\n * browser is no longer partially visible or becomes partially visible.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState\n * @since 6.0.0\n */\nexport type PageInactiveType = \"focus\" | \"visibility\";\n\n/**\n * @since 6.0.0\n */\nexport interface PageInactiveOptions {\n /**\n * @see {@link PageInactiveType}\n * @defaultValue `\"focus\"`\n */\n type?: PageInactiveType;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This will be called whenever the page activity changes based on the\n * {@link PageInactiveType}.\n */\n onChange(active: boolean): void;\n\n /**\n * This will be fired whenever the {@link disabled} state is `true` which can\n * be useful for clearing pending timers or resetting state.\n *\n * Since this is passed to a `useEffect` as a dependency, you might have to\n * wrap this in a `useCallback` if unexpected re-rendering or errors occurs.\n *\n * @defaultValue `() => {}`\n */\n onDisabledCleanup?(): void;\n}\n\n/**\n * @example\n * ```ts\n * import { usePageInactive } from \"@react-md/core\";\n * import { useCallback, useEffect, useRef, useState } from \"react\";\n *\n * function Example(): null {\n * const [visible, setVisible] = useState(false);\n * const timeout = useRef<number | undefined>();\n * const startTimeout = useCallback(() => {\n * timeout.current = window.setTimeout(() => {\n * setVisible(false);\n * }, 10000);\n * }, []);\n *\n * usePageInactive({\n * onChange(active) {\n * if (!active) {\n * window.clearTimeout(timeout.current);\n * setVisible(false);\n * } else {\n * startTimeout();\n * }\n * }\n * });\n *\n * // pretend implementation\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function usePageInactive(options: PageInactiveOptions): void {\n const {\n type = \"focus\",\n disabled,\n onChange,\n onDisabledCleanup = noop,\n } = options;\n useEffect(() => {\n if (disabled) {\n onDisabledCleanup();\n return;\n }\n\n const callback = (event: Event): void => {\n let active = document.visibilityState === \"visible\";\n if (event.type === \"blur\") {\n active = false;\n } else if (event.type === \"focus\") {\n active = true;\n }\n\n onChange(active);\n };\n\n document.addEventListener(\"visibilitychange\", callback);\n if (type === \"focus\") {\n window.addEventListener(\"blur\", callback);\n window.addEventListener(\"focus\", callback);\n }\n\n return () => {\n document.removeEventListener(\"visibilitychange\", callback);\n window.removeEventListener(\"blur\", callback);\n window.removeEventListener(\"focus\", callback);\n };\n }, [disabled, onChange, onDisabledCleanup, type]);\n}\n"],"names":["useEffect","noop","usePageInactive","options","type","disabled","onChange","onDisabledCleanup","callback","event","active","document","visibilityState","addEventListener","window","removeEventListener"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAElC,MAAMC,OAAO;AACX,aAAa;AACf;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,SAASC,gBAAgBC,OAA4B;IAC1D,MAAM,EACJC,OAAO,OAAO,EACdC,QAAQ,EACRC,QAAQ,EACRC,oBAAoBN,IAAI,EACzB,GAAGE;IACJH,UAAU;QACR,IAAIK,UAAU;YACZE;YACA;QACF;QAEA,MAAMC,WAAW,CAACC;YAChB,IAAIC,SAASC,SAASC,eAAe,KAAK;YAC1C,IAAIH,MAAML,IAAI,KAAK,QAAQ;gBACzBM,SAAS;YACX,OAAO,IAAID,MAAML,IAAI,KAAK,SAAS;gBACjCM,SAAS;YACX;YAEAJ,SAASI;QACX;QAEAC,SAASE,gBAAgB,CAAC,oBAAoBL;QAC9C,IAAIJ,SAAS,SAAS;YACpBU,OAAOD,gBAAgB,CAAC,QAAQL;YAChCM,OAAOD,gBAAgB,CAAC,SAASL;QACnC;QAEA,OAAO;YACLG,SAASI,mBAAmB,CAAC,oBAAoBP;YACjDM,OAAOC,mBAAmB,CAAC,QAAQP;YACnCM,OAAOC,mBAAmB,CAAC,SAASP;QACtC;IACF,GAAG;QAACH;QAAUC;QAAUC;QAAmBH;KAAK;AAClD"}
@@ -1,5 +1,10 @@
1
1
  /**
2
- * @since 6.0.0 Updated the API
2
+ * @since 6.0.0 Removed the `immediate` option to force the resize handler to be
3
+ * called immediately.
4
+ * @since 6.0.0 Renamed to a new API so that there is no longer an `options`
5
+ * property and instead the `AddEventListenerOptions` are part of the hook
6
+ * options.
7
+ * @since 6.0.0 Renamed `onResize` to `onUpdate` and `enabled` to `disabled`.
3
8
  */
4
9
  export interface ResizeListenerOptions extends AddEventListenerOptions {
5
10
  /**
@@ -7,6 +12,7 @@ export interface ResizeListenerOptions extends AddEventListenerOptions {
7
12
  * `window.requestAnimationFrame`.
8
13
  *
9
14
  * @defaultValue `true`
15
+ * @since 6.0.0
10
16
  */
11
17
  throttle?: boolean;
12
18
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useResizeListener.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\nimport { delegateEvent } from \"./delegateEvent.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { useResizeObserver } from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0 Updated the API\n */\nexport interface ResizeListenerOptions extends AddEventListenerOptions {\n /**\n * Set this to `false` to disable throttling with\n * `window.requestAnimationFrame`.\n *\n * @defaultValue `true`\n */\n throttle?: boolean;\n\n /**\n * Set this to `true` to disable attaching the resize event handler.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This function will be called whenever the resize event is fired on the\n * `window`. This should be wrapped in `useCallback`.\n */\n onUpdate(event: Event): void;\n}\n\n/**\n * This hook can be used to listen to the entire window resizing. If you need to\n * observe specific elements resizing, check out the {@link useResizeObserver}\n * hook instead.\n *\n * @example Simple Example\n * ```tsx\n * import { useResizeListener } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [size, setSize] = useState({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * }):\n *\n * useResizeListener({\n * onUpdate(event) {\n * setSize({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * });\n * },\n * });\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0 Updated the API to match the `useResizeObserver` and\n * `useIntersectionObserver` hooks by having an `onUpdate` callback and include\n * the `AddEventListenerOptions` as part of the hook options.\n */\nexport function useResizeListener(options: ResizeListenerOptions): void {\n const {\n once,\n signal,\n capture,\n passive,\n throttle = true,\n disabled = false,\n onUpdate,\n } = options;\n\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const eventHandler = delegateEvent(\"resize\", window, throttle, {\n once,\n signal,\n capture,\n passive,\n });\n eventHandler.add(onUpdate);\n\n window.dispatchEvent(new Event(\"resize\"));\n return () => {\n eventHandler.remove(onUpdate);\n };\n }, [capture, disabled, onUpdate, once, passive, signal, throttle]);\n}\n"],"names":["useEffect","delegateEvent","useResizeListener","options","once","signal","capture","passive","throttle","disabled","onUpdate","eventHandler","window","add","dispatchEvent","Event","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,qBAAqB;AA8BnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC,kBAAkBC,OAA8B;IAC9D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,WAAW,IAAI,EACfC,WAAW,KAAK,EAChBC,QAAQ,EACT,GAAGP;IAEJH,UAAU;QACR,IAAIS,UAAU;YACZ;QACF;QAEA,MAAME,eAAeV,cAAc,UAAUW,QAAQJ,UAAU;YAC7DJ;YACAC;YACAC;YACAC;QACF;QACAI,aAAaE,GAAG,CAACH;QAEjBE,OAAOE,aAAa,CAAC,IAAIC,MAAM;QAC/B,OAAO;YACLJ,aAAaK,MAAM,CAACN;QACtB;IACF,GAAG;QAACJ;QAASG;QAAUC;QAAUN;QAAMG;QAASF;QAAQG;KAAS;AACnE"}
1
+ {"version":3,"sources":["../src/useResizeListener.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\nimport { delegateEvent } from \"./delegateEvent.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useResizeObserver } from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0 Removed the `immediate` option to force the resize handler to be\n * called immediately.\n * @since 6.0.0 Renamed to a new API so that there is no longer an `options`\n * property and instead the `AddEventListenerOptions` are part of the hook\n * options.\n * @since 6.0.0 Renamed `onResize` to `onUpdate` and `enabled` to `disabled`.\n */\nexport interface ResizeListenerOptions extends AddEventListenerOptions {\n /**\n * Set this to `false` to disable throttling with\n * `window.requestAnimationFrame`.\n *\n * @defaultValue `true`\n * @since 6.0.0\n */\n throttle?: boolean;\n\n /**\n * Set this to `true` to disable attaching the resize event handler.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This function will be called whenever the resize event is fired on the\n * `window`. This should be wrapped in `useCallback`.\n */\n onUpdate(event: Event): void;\n}\n\n/**\n * This hook can be used to listen to the entire window resizing. If you need to\n * observe specific elements resizing, check out the {@link useResizeObserver}\n * hook instead.\n *\n * @example Simple Example\n * ```tsx\n * import { useResizeListener } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [size, setSize] = useState({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * }):\n *\n * useResizeListener({\n * onUpdate(event) {\n * setSize({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * });\n * },\n * });\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0 Updated the API to match the `useResizeObserver` and\n * `useIntersectionObserver` hooks by having an `onUpdate` callback and include\n * the `AddEventListenerOptions` as part of the hook options.\n */\nexport function useResizeListener(options: ResizeListenerOptions): void {\n const {\n once,\n signal,\n capture,\n passive,\n throttle = true,\n disabled = false,\n onUpdate,\n } = options;\n\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const eventHandler = delegateEvent(\"resize\", window, throttle, {\n once,\n signal,\n capture,\n passive,\n });\n eventHandler.add(onUpdate);\n\n window.dispatchEvent(new Event(\"resize\"));\n return () => {\n eventHandler.remove(onUpdate);\n };\n }, [capture, disabled, onUpdate, once, passive, signal, throttle]);\n}\n"],"names":["useEffect","delegateEvent","useResizeListener","options","once","signal","capture","passive","throttle","disabled","onUpdate","eventHandler","window","add","dispatchEvent","Event","remove"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,qBAAqB;AAoCnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC,kBAAkBC,OAA8B;IAC9D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,WAAW,IAAI,EACfC,WAAW,KAAK,EAChBC,QAAQ,EACT,GAAGP;IAEJH,UAAU;QACR,IAAIS,UAAU;YACZ;QACF;QAEA,MAAME,eAAeV,cAAc,UAAUW,QAAQJ,UAAU;YAC7DJ;YACAC;YACAC;YACAC;QACF;QACAI,aAAaE,GAAG,CAACH;QAEjBE,OAAOE,aAAa,CAAC,IAAIC,MAAM;QAC/B,OAAO;YACLJ,aAAaK,MAAM,CAACN;QACtB;IACF,GAAG;QAACJ;QAASG;QAAUC;QAAUN;QAAMG;QAASF;QAAQG;KAAS;AACnE"}
@@ -14,9 +14,9 @@ interface TargetSize {
14
14
  }
15
15
  /** @internal */
16
16
  interface TargetSubscription {
17
- readonly onUpdate: ResizeObserverEntryCallback;
18
- readonly disableHeight: boolean;
19
- readonly disableWidth: boolean;
17
+ onUpdate: ResizeObserverEntryCallback;
18
+ disableHeight: boolean;
19
+ disableWidth: boolean;
20
20
  size?: TargetSize;
21
21
  }
22
22
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, type Ref, type RefCallback } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;\n\n/** @internal */\ntype Unsubscribe = () => void;\n\n/** @internal */\ninterface TargetSize {\n height: number;\n width: number;\n scrollHeight: number;\n scrollWidth: number;\n}\n\n/** @internal */\ninterface TargetSubscription {\n readonly onUpdate: ResizeObserverEntryCallback;\n readonly disableHeight: boolean;\n readonly disableWidth: boolean;\n\n size?: TargetSize;\n}\n\n/** @internal */\ninterface SubscribeOptions {\n element: Element;\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0 This was added to help with testing. The\n * `subscriptions` and `sharedObserver` used to be module-level variables but\n * moving to a class makes it easier to mock. Checkout the\n * `src/tests-utils/ResizeObserver.ts`\n */\nexport class ResizeObserverManager {\n frame: number;\n subscriptions: Map<Element, Set<TargetSubscription>>;\n\n /**\n * Why is there a single shared observer instead of multiple and a\n * \"subscription\" model?\n *\n * Note: Probably a bit of a premature optimization right now...\n *\n * @see https://github.com/WICG/resize-observer/issues/59\n * @internal\n */\n sharedObserver: ResizeObserver | undefined;\n\n constructor() {\n this.frame = 0;\n this.subscriptions = new Map();\n }\n\n subscribe = (options: SubscribeOptions): Unsubscribe => {\n const { element, onUpdate, disableHeight, disableWidth } = options;\n\n // lazy initialize the observer\n const observer =\n this.sharedObserver ||\n new ResizeObserver((entries) => {\n // this prevents the `ResizeObserver loop limit exceeded`\n window.cancelAnimationFrame(this.frame);\n this.frame = window.requestAnimationFrame(() => {\n this.handleResizeEntries(entries);\n });\n });\n this.sharedObserver = observer;\n\n const updates = this.subscriptions.get(element) || new Set();\n const subscription: TargetSubscription = {\n onUpdate,\n disableHeight,\n disableWidth,\n };\n updates.add(subscription);\n if (!this.subscriptions.has(element)) {\n this.subscriptions.set(element, updates);\n }\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n updates.delete(subscription);\n };\n };\n\n handleResizeEntries = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n const targetSubscriptions = this.subscriptions.get(entry.target);\n // shouldn't really happen\n /* c8 ignore start */\n if (!targetSubscriptions) {\n continue;\n }\n /* c8 ignore stop */\n\n const entries = targetSubscriptions.values();\n for (const subscription of entries) {\n const { height, width } = entry.contentRect;\n const { scrollHeight, scrollWidth } = entry.target;\n const { onUpdate, size, disableHeight, disableWidth } = subscription;\n const isHeightChange =\n !disableHeight &&\n (!size ||\n size.height !== height ||\n size.scrollHeight !== scrollHeight);\n const isWidthChange =\n !disableWidth &&\n (!size || size.width !== width || size.scrollWidth !== scrollWidth);\n\n subscription.size = {\n height,\n width,\n scrollHeight,\n scrollWidth,\n };\n if (isHeightChange || isWidthChange) {\n onUpdate(entry);\n }\n }\n }\n };\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const resizeObserverManager = new ResizeObserverManager();\n\n/**\n * @since 2.3.0\n * @since 6.0.0 Renamed from `UseResizeObserverOptions` and added\n * `onUpdate`/`disabled` options.\n */\nexport interface ResizeObserverHookOptions<E extends HTMLElement> {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * ResizeObserver each render.**\n *\n * This function will be called whenever the target element resizes.\n *\n * @see {@link useResizeObserver} for an example.\n */\n onUpdate: ResizeObserverEntryCallback;\n\n /**\n * Set this to `true` to prevent observing the element's size changes. This is\n * equivalent to not attaching the returned ref to any element.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for height\n * changes.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for width\n * changes.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * The resize observer is used to track the size changes of a specific element.\n * For most cases you can use the {@link useElementSize} instead, but this hook\n * can be used for more complex behavior with the {@link ResizeObserverEntry}.\n *\n * @since 2.3.0\n * @since 6.0.0 The API was updated to match the `useIntersectionObserver`\n * implementation -- accepts only a single object parameter and returns a\n * {@link RefCallback} instead of `[nodeRef, refCallback]`\n */\nexport function useResizeObserver<E extends HTMLElement>(\n options: ResizeObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n disabled,\n disableHeight = false,\n disableWidth = false,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n const element = targetNodeRef.current;\n if (disabled || (disableHeight && disableWidth) || !element) {\n return;\n }\n\n const unsubscribe = resizeObserverManager.subscribe({\n element,\n onUpdate,\n disableHeight,\n disableWidth,\n });\n\n return () => {\n unsubscribe();\n };\n }, [disableHeight, disableWidth, disabled, onUpdate, targetNodeRef]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","ResizeObserverManager","constructor","frame","subscriptions","sharedObserver","subscribe","options","element","onUpdate","disableHeight","disableWidth","observer","ResizeObserver","entries","window","cancelAnimationFrame","requestAnimationFrame","handleResizeEntries","updates","get","Set","subscription","add","has","set","observe","unobserve","delete","entry","targetSubscriptions","target","values","height","width","contentRect","scrollHeight","scrollWidth","size","isHeightChange","isWidthChange","Map","resizeObserverManager","useResizeObserver","ref","disabled","targetNodeRef","refCallback","current","unsubscribe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
1
+ {"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, type Ref, type RefCallback } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;\n\n/** @internal */\ntype Unsubscribe = () => void;\n\n/** @internal */\ninterface TargetSize {\n height: number;\n width: number;\n scrollHeight: number;\n scrollWidth: number;\n}\n\n/** @internal */\ninterface TargetSubscription {\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n\n size?: TargetSize;\n}\n\n/** @internal */\ninterface SubscribeOptions {\n element: Element;\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0 This was added to help with testing. The\n * `subscriptions` and `sharedObserver` used to be module-level variables but\n * moving to a class makes it easier to mock. Checkout the\n * `src/tests-utils/ResizeObserver.ts`\n */\nexport class ResizeObserverManager {\n frame: number;\n subscriptions: Map<Element, Set<TargetSubscription>>;\n\n /**\n * Why is there a single shared observer instead of multiple and a\n * \"subscription\" model?\n *\n * Note: Probably a bit of a premature optimization right now...\n *\n * @see https://github.com/WICG/resize-observer/issues/59\n * @internal\n */\n sharedObserver: ResizeObserver | undefined;\n\n constructor() {\n this.frame = 0;\n this.subscriptions = new Map();\n }\n\n subscribe = (options: SubscribeOptions): Unsubscribe => {\n const { element, onUpdate, disableHeight, disableWidth } = options;\n\n // lazy initialize the observer\n const observer =\n this.sharedObserver ||\n new ResizeObserver((entries) => {\n // this prevents the `ResizeObserver loop limit exceeded`\n window.cancelAnimationFrame(this.frame);\n this.frame = window.requestAnimationFrame(() => {\n this.handleResizeEntries(entries);\n });\n });\n this.sharedObserver = observer;\n\n const updates = this.subscriptions.get(element) || new Set();\n const subscription: TargetSubscription = {\n onUpdate,\n disableHeight,\n disableWidth,\n };\n updates.add(subscription);\n if (!this.subscriptions.has(element)) {\n this.subscriptions.set(element, updates);\n }\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n updates.delete(subscription);\n };\n };\n\n handleResizeEntries = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n const targetSubscriptions = this.subscriptions.get(entry.target);\n // shouldn't really happen\n /* c8 ignore start */\n if (!targetSubscriptions) {\n continue;\n }\n /* c8 ignore stop */\n\n const entries = targetSubscriptions.values();\n for (const subscription of entries) {\n const { height, width } = entry.contentRect;\n const { scrollHeight, scrollWidth } = entry.target;\n const { onUpdate, size, disableHeight, disableWidth } = subscription;\n const isHeightChange =\n !disableHeight &&\n (!size ||\n size.height !== height ||\n size.scrollHeight !== scrollHeight);\n const isWidthChange =\n !disableWidth &&\n (!size || size.width !== width || size.scrollWidth !== scrollWidth);\n\n subscription.size = {\n height,\n width,\n scrollHeight,\n scrollWidth,\n };\n if (isHeightChange || isWidthChange) {\n onUpdate(entry);\n }\n }\n }\n };\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const resizeObserverManager = new ResizeObserverManager();\n\n/**\n * @since 2.3.0\n * @since 6.0.0 Renamed from `UseResizeObserverOptions` and added\n * `onUpdate`/`disabled` options.\n */\nexport interface ResizeObserverHookOptions<E extends HTMLElement> {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * ResizeObserver each render.**\n *\n * This function will be called whenever the target element resizes.\n *\n * @see {@link useResizeObserver} for an example.\n */\n onUpdate: ResizeObserverEntryCallback;\n\n /**\n * Set this to `true` to prevent observing the element's size changes. This is\n * equivalent to not attaching the returned ref to any element.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for height\n * changes.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for width\n * changes.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * The resize observer is used to track the size changes of a specific element.\n * For most cases you can use the {@link useElementSize} instead, but this hook\n * can be used for more complex behavior with the {@link ResizeObserverEntry}.\n *\n * @since 2.3.0\n * @since 6.0.0 The API was updated to match the `useIntersectionObserver`\n * implementation -- accepts only a single object parameter and returns a\n * {@link RefCallback} instead of `[nodeRef, refCallback]`\n */\nexport function useResizeObserver<E extends HTMLElement>(\n options: ResizeObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n disabled,\n disableHeight = false,\n disableWidth = false,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n const element = targetNodeRef.current;\n if (disabled || (disableHeight && disableWidth) || !element) {\n return;\n }\n\n const unsubscribe = resizeObserverManager.subscribe({\n element,\n onUpdate,\n disableHeight,\n disableWidth,\n });\n\n return () => {\n unsubscribe();\n };\n }, [disableHeight, disableWidth, disabled, onUpdate, targetNodeRef]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","ResizeObserverManager","constructor","frame","subscriptions","sharedObserver","subscribe","options","element","onUpdate","disableHeight","disableWidth","observer","ResizeObserver","entries","window","cancelAnimationFrame","requestAnimationFrame","handleResizeEntries","updates","get","Set","subscription","add","has","set","observe","unobserve","delete","entry","targetSubscriptions","target","values","height","width","contentRect","scrollHeight","scrollWidth","size","isHeightChange","isWidthChange","Map","resizeObserverManager","useResizeObserver","ref","disabled","targetNodeRef","refCallback","current","unsubscribe"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useThrottledFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type AnyFunction, type CancelableFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * Creates a function that will only be called once every X milliseconds.\n *\n * @example Throttling Search API Requests\n * ```tsx\n * import { TextField, useThrottledFunction, useUnmounted } from \"@react-md/core\";\n * import { useState } from \"react\";\n * import type { ReactElement } from \"react\";\n *\n * interface State {\n * error?: unknown\n * loading: boolean;\n * results?: {\n * // pretend some search results\n * id: string;\n * name: string;\n * }[];\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * loading: false,\n * });\n * // this is only required for async actions\n * const unmounted = useUnmounted();\n *\n * // A new search request will be fired once every 500ms as the user types.\n * // can't use the event here since React uses synthetic events\n * const search = useThrottledFunction(async (q: string) => {\n * setState({\n * loading: true,\n * error: undefined,\n * results: undefined,\n * });\n *\n * try {\n * const response = await fetch('/search', {\n * method: 'POST',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({ q }),\n * });\n * const json = await response.json();\n *\n * if (!unmounted.current) {\n * setState({\n * loading: false,\n * results: json,\n * });\n * }\n * } catch (error) {\n * if (!unmounted.current) {\n * setState({\n * error,\n * loading: false,\n * });\n * }\n * }\n * }, 500);\n *\n * return (\n * <TextField\n * type=\"search\"\n * label=\"Search\"\n * onChange={(event) => search(event.currentTarget.value)}\n * />\n * );\n * }\n * ```\n *\n * @see `useDebouncedFunction` for debounce behavior instead. (Call a\n * function only if it has not been called again for X milliseconds).\n * @since 6.0.0\n */\nexport function useThrottledFunction<F extends AnyFunction>(\n func: F,\n wait: number\n): ThrottledFunction<F> {\n const args = useRef<Parameters<F>>();\n const result = useRef<ReturnType<F>>();\n const timeout = useRef<number | undefined>();\n const funcRef = useRef(func);\n const lastCalledTime = useRef(0);\n\n useIsomorphicLayoutEffect(() => {\n funcRef.current = func;\n });\n\n useEffect(() => {\n return () => {\n window.clearTimeout(timeout.current);\n };\n }, []);\n\n return useMemo(() => {\n const throttled: ThrottledFunction<F> = (...nextArgs) => {\n args.current = nextArgs;\n\n const now = Date.now();\n const remaining = wait - (now - lastCalledTime.current);\n if (remaining <= 0 || remaining > wait) {\n lastCalledTime.current = now;\n result.current = funcRef.current(...args.current);\n } else if (!timeout.current) {\n timeout.current = window.setTimeout(() => {\n lastCalledTime.current = Date.now();\n timeout.current = undefined;\n // should exist by this time\n result.current = funcRef.current(...(args.current as Parameters<F>));\n }, remaining);\n }\n\n return result.current as ReturnType<F>;\n };\n throttled.cancel = () => window.clearTimeout(timeout.current);\n\n return throttled;\n }, [wait]);\n}\n"],"names":["useEffect","useMemo","useRef","useIsomorphicLayoutEffect","useThrottledFunction","func","wait","args","result","timeout","funcRef","lastCalledTime","current","window","clearTimeout","throttled","nextArgs","now","Date","remaining","setTimeout","undefined","cancel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,yBAAyB,QAAQ,iCAAiC;AAS3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EC,GACD,OAAO,SAASC,qBACdC,IAAO,EACPC,IAAY;IAEZ,MAAMC,OAAOL;IACb,MAAMM,SAASN;IACf,MAAMO,UAAUP;IAChB,MAAMQ,UAAUR,OAAOG;IACvB,MAAMM,iBAAiBT,OAAO;IAE9BC,0BAA0B;QACxBO,QAAQE,OAAO,GAAGP;IACpB;IAEAL,UAAU;QACR,OAAO;YACLa,OAAOC,YAAY,CAACL,QAAQG,OAAO;QACrC;IACF,GAAG,EAAE;IAEL,OAAOX,QAAQ;QACb,MAAMc,YAAkC,CAAC,GAAGC;YAC1CT,KAAKK,OAAO,GAAGI;YAEf,MAAMC,MAAMC,KAAKD,GAAG;YACpB,MAAME,YAAYb,OAAQW,CAAAA,MAAMN,eAAeC,OAAO,AAAD;YACrD,IAAIO,aAAa,KAAKA,YAAYb,MAAM;gBACtCK,eAAeC,OAAO,GAAGK;gBACzBT,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAIL,KAAKK,OAAO;YAClD,OAAO,IAAI,CAACH,QAAQG,OAAO,EAAE;gBAC3BH,QAAQG,OAAO,GAAGC,OAAOO,UAAU,CAAC;oBAClCT,eAAeC,OAAO,GAAGM,KAAKD,GAAG;oBACjCR,QAAQG,OAAO,GAAGS;oBAClB,4BAA4B;oBAC5Bb,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAKL,KAAKK,OAAO;gBACnD,GAAGO;YACL;YAEA,OAAOX,OAAOI,OAAO;QACvB;QACAG,UAAUO,MAAM,GAAG,IAAMT,OAAOC,YAAY,CAACL,QAAQG,OAAO;QAE5D,OAAOG;IACT,GAAG;QAACT;KAAK;AACX"}
1
+ {"version":3,"sources":["../src/useThrottledFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type AnyFunction, type CancelableFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * Creates a function that will only be called once every X milliseconds.\n *\n * @example Throttling Search API Requests\n * ```tsx\n * import { TextField, useThrottledFunction, useUnmounted } from \"@react-md/core\";\n * import { useState } from \"react\";\n * import type { ReactElement } from \"react\";\n *\n * interface State {\n * error?: unknown\n * loading: boolean;\n * results?: {\n * // pretend some search results\n * id: string;\n * name: string;\n * }[];\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * loading: false,\n * });\n * // this is only required for async actions\n * const unmounted = useUnmounted();\n *\n * // A new search request will be fired once every 500ms as the user types.\n * // can't use the event here since React uses synthetic events\n * const search = useThrottledFunction(async (q: string) => {\n * setState({\n * loading: true,\n * error: undefined,\n * results: undefined,\n * });\n *\n * try {\n * const response = await fetch('/search', {\n * method: 'POST',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({ q }),\n * });\n * const json = await response.json();\n *\n * if (!unmounted.current) {\n * setState({\n * loading: false,\n * results: json,\n * });\n * }\n * } catch (error) {\n * if (!unmounted.current) {\n * setState({\n * error,\n * loading: false,\n * });\n * }\n * }\n * }, 500);\n *\n * return (\n * <TextField\n * type=\"search\"\n * label=\"Search\"\n * onChange={(event) => search(event.currentTarget.value)}\n * />\n * );\n * }\n * ```\n *\n * @see `useDebouncedFunction` for debounce behavior instead. (Call a\n * function only if it has not been called again for X milliseconds).\n * @since 6.0.0\n */\nexport function useThrottledFunction<F extends AnyFunction>(\n func: F,\n wait: number\n): ThrottledFunction<F> {\n const args = useRef<Parameters<F>>();\n const result = useRef<ReturnType<F>>();\n const timeout = useRef<number | undefined>();\n const funcRef = useRef(func);\n const lastCalledTime = useRef(0);\n\n useIsomorphicLayoutEffect(() => {\n funcRef.current = func;\n });\n\n useEffect(() => {\n return () => {\n window.clearTimeout(timeout.current);\n };\n }, []);\n\n return useMemo(() => {\n const throttled: ThrottledFunction<F> = (...nextArgs) => {\n args.current = nextArgs;\n\n const now = Date.now();\n const remaining = wait - (now - lastCalledTime.current);\n if (remaining <= 0 || remaining > wait) {\n lastCalledTime.current = now;\n result.current = funcRef.current(...args.current);\n } else if (!timeout.current) {\n timeout.current = window.setTimeout(() => {\n lastCalledTime.current = Date.now();\n timeout.current = undefined;\n // should exist by this time\n result.current = funcRef.current(...(args.current as Parameters<F>));\n }, remaining);\n }\n\n return result.current as ReturnType<F>;\n };\n throttled.cancel = () => window.clearTimeout(timeout.current);\n\n return throttled;\n }, [wait]);\n}\n"],"names":["useEffect","useMemo","useRef","useIsomorphicLayoutEffect","useThrottledFunction","func","wait","args","result","timeout","funcRef","lastCalledTime","current","window","clearTimeout","throttled","nextArgs","now","Date","remaining","setTimeout","undefined","cancel"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,yBAAyB,QAAQ,iCAAiC;AAS3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EC,GACD,OAAO,SAASC,qBACdC,IAAO,EACPC,IAAY;IAEZ,MAAMC,OAAOL;IACb,MAAMM,SAASN;IACf,MAAMO,UAAUP;IAChB,MAAMQ,UAAUR,OAAOG;IACvB,MAAMM,iBAAiBT,OAAO;IAE9BC,0BAA0B;QACxBO,QAAQE,OAAO,GAAGP;IACpB;IAEAL,UAAU;QACR,OAAO;YACLa,OAAOC,YAAY,CAACL,QAAQG,OAAO;QACrC;IACF,GAAG,EAAE;IAEL,OAAOX,QAAQ;QACb,MAAMc,YAAkC,CAAC,GAAGC;YAC1CT,KAAKK,OAAO,GAAGI;YAEf,MAAMC,MAAMC,KAAKD,GAAG;YACpB,MAAME,YAAYb,OAAQW,CAAAA,MAAMN,eAAeC,OAAO,AAAD;YACrD,IAAIO,aAAa,KAAKA,YAAYb,MAAM;gBACtCK,eAAeC,OAAO,GAAGK;gBACzBT,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAIL,KAAKK,OAAO;YAClD,OAAO,IAAI,CAACH,QAAQG,OAAO,EAAE;gBAC3BH,QAAQG,OAAO,GAAGC,OAAOO,UAAU,CAAC;oBAClCT,eAAeC,OAAO,GAAGM,KAAKD,GAAG;oBACjCR,QAAQG,OAAO,GAAGS;oBAClB,4BAA4B;oBAC5Bb,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAKL,KAAKK,OAAO;gBACnD,GAAGO;YACL;YAEA,OAAOX,OAAOI,OAAO;QACvB;QACAG,UAAUO,MAAM,GAAG,IAAMT,OAAOC,YAAY,CAACL,QAAQG,OAAO;QAE5D,OAAOG;IACT,GAAG;QAACT;KAAK;AACX"}
@@ -1,8 +1,8 @@
1
- import type { UseStateInitializer, UseStateSetter } from "./types.js";
1
+ import { type UseStateInitializer, type UseStateSetter } from "./types.js";
2
2
  /**
3
3
  * @since 6.0.0
4
4
  */
5
- export interface ToggleHookReturnValue {
5
+ export interface ToggleImplementation {
6
6
  toggled: boolean;
7
7
  setToggled: UseStateSetter<boolean>;
8
8
  toggle(): void;
@@ -21,7 +21,7 @@ export interface ToggleHookReturnValue {
21
21
  *
22
22
  * return (
23
23
  * <>
24
- * <Button onClick=[toggle]>Toggle</Button>
24
+ * <Button onClick={toggle}>Toggle</Button>
25
25
  * {`Toggled: ${toggled}`}
26
26
  * </>
27
27
  * );
@@ -30,4 +30,4 @@ export interface ToggleHookReturnValue {
30
30
  *
31
31
  * @param defaultValue - `false`
32
32
  */
33
- export declare function useToggle(defaultValue?: UseStateInitializer<boolean>): Readonly<ToggleHookReturnValue>;
33
+ export declare function useToggle(defaultValue?: UseStateInitializer<boolean>): ToggleImplementation;
package/dist/useToggle.js CHANGED
@@ -12,7 +12,7 @@ import { useCallback, useState } from "react";
12
12
  *
13
13
  * return (
14
14
  * <>
15
- * <Button onClick=[toggle]>Toggle</Button>
15
+ * <Button onClick={toggle}>Toggle</Button>
16
16
  * {`Toggled: ${toggled}`}
17
17
  * </>
18
18
  * );
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useToggle.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToggleHookReturnValue {\n toggled: boolean;\n setToggled: UseStateSetter<boolean>;\n toggle(): void;\n enable(): void;\n disable(): void;\n}\n\n/**\n *\n * @example Simple Example\n * ```tsx\n * import { Button, useToggle } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { toggled, toggle } = useToggle();\n *\n * return (\n * <>\n * <Button onClick=[toggle]>Toggle</Button>\n * {`Toggled: ${toggled}`}\n * </>\n * );\n * }\n * ```\n *\n * @param defaultValue - `false`\n */\nexport function useToggle(\n defaultValue: UseStateInitializer<boolean> = false\n): Readonly<ToggleHookReturnValue> {\n const [toggled, setToggled] = useState(defaultValue);\n\n return {\n toggled,\n setToggled,\n toggle: useCallback(() => {\n setToggled((prevToggled) => !prevToggled);\n }, []),\n enable: useCallback(() => {\n setToggled(true);\n }, []),\n disable: useCallback(() => {\n setToggled(false);\n }, []),\n };\n}\n"],"names":["useCallback","useState","useToggle","defaultValue","toggled","setToggled","toggle","prevToggled","enable","disable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAc9C;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,UACdC,eAA6C,KAAK;IAElD,MAAM,CAACC,SAASC,WAAW,GAAGJ,SAASE;IAEvC,OAAO;QACLC;QACAC;QACAC,QAAQN,YAAY;YAClBK,WAAW,CAACE,cAAgB,CAACA;QAC/B,GAAG,EAAE;QACLC,QAAQR,YAAY;YAClBK,WAAW;QACb,GAAG,EAAE;QACLI,SAAST,YAAY;YACnBK,WAAW;QACb,GAAG,EAAE;IACP;AACF"}
1
+ {"version":3,"sources":["../src/useToggle.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { type UseStateInitializer, type UseStateSetter } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToggleImplementation {\n toggled: boolean;\n setToggled: UseStateSetter<boolean>;\n toggle(): void;\n enable(): void;\n disable(): void;\n}\n\n/**\n *\n * @example Simple Example\n * ```tsx\n * import { Button, useToggle } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { toggled, toggle } = useToggle();\n *\n * return (\n * <>\n * <Button onClick={toggle}>Toggle</Button>\n * {`Toggled: ${toggled}`}\n * </>\n * );\n * }\n * ```\n *\n * @param defaultValue - `false`\n */\nexport function useToggle(\n defaultValue: UseStateInitializer<boolean> = false\n): ToggleImplementation {\n const [toggled, setToggled] = useState(defaultValue);\n\n return {\n toggled,\n setToggled,\n toggle: useCallback(() => {\n setToggled((prevToggled) => !prevToggled);\n }, []),\n enable: useCallback(() => {\n setToggled(true);\n }, []),\n disable: useCallback(() => {\n setToggled(false);\n }, []),\n };\n}\n"],"names":["useCallback","useState","useToggle","defaultValue","toggled","setToggled","toggle","prevToggled","enable","disable"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAc9C;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,UACdC,eAA6C,KAAK;IAElD,MAAM,CAACC,SAASC,WAAW,GAAGJ,SAASE;IAEvC,OAAO;QACLC;QACAC;QACAC,QAAQN,YAAY;YAClBK,WAAW,CAACE,cAAgB,CAACA;QAC/B,GAAG,EAAE;QACLC,QAAQR,YAAY;YAClBK,WAAW;QACb,GAAG,EAAE;QACLI,SAAST,YAAY;YACnBK,WAAW;QACb,GAAG,EAAE;IACP;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useUnmounted.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { NonNullRef } from \"./types.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useUnmounted } from \"@react-md/core\";\n * import { useEffect, useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState({ loading: false });\n * const unmounted = useUnmounted();\n *\n * useEffect(() => {\n * async function load(): void {\n * const result = await fetch('/some-api');\n * const json = await response.json();\n * if (!unmounted.current) {\n * setState({ loading: false, result: json });\n * }\n * }\n *\n * setState({ loading: true });\n * load();\n * }, [unmounted]);\n *\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function useUnmounted(): NonNullRef<boolean> {\n const unmounted = useRef(false);\n useEffect(() => {\n unmounted.current = false;\n return () => {\n unmounted.current = true;\n };\n }, []);\n\n return unmounted;\n}\n"],"names":["useEffect","useRef","useUnmounted","unmounted","current"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,QAAQ;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,SAASC;IACd,MAAMC,YAAYF,OAAO;IACzBD,UAAU;QACRG,UAAUC,OAAO,GAAG;QACpB,OAAO;YACLD,UAAUC,OAAO,GAAG;QACtB;IACF,GAAG,EAAE;IAEL,OAAOD;AACT"}
1
+ {"version":3,"sources":["../src/useUnmounted.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { NonNullRef } from \"./types.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useUnmounted } from \"@react-md/core\";\n * import { useEffect, useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState({ loading: false });\n * const unmounted = useUnmounted();\n *\n * useEffect(() => {\n * async function load(): void {\n * const result = await fetch('/some-api');\n * const json = await response.json();\n * if (!unmounted.current) {\n * setState({ loading: false, result: json });\n * }\n * }\n *\n * setState({ loading: true });\n * load();\n * }, [unmounted]);\n *\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function useUnmounted(): NonNullRef<boolean> {\n const unmounted = useRef(false);\n useEffect(() => {\n unmounted.current = false;\n return () => {\n unmounted.current = true;\n };\n }, []);\n\n return unmounted;\n}\n"],"names":["useEffect","useRef","useUnmounted","unmounted","current"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,QAAQ;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,SAASC;IACd,MAAMC,YAAYF,OAAO;IACzBD,UAAU;QACRG,UAAUC,OAAO,GAAG;QACpB,OAAO;YACLD,UAAUC,OAAO,GAAG;QACtB;IACF,GAAG,EAAE;IAEL,OAAOD;AACT"}