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

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 (665) hide show
  1. package/dist/_box-shadows.scss +76 -0
  2. package/dist/_colors.scss +279 -277
  3. package/dist/_core.scss +107 -16
  4. package/dist/_object-fit.scss +86 -0
  5. package/dist/_utils.scss +246 -72
  6. package/dist/app-bar/AppBar.d.ts +1 -90
  7. package/dist/app-bar/AppBar.js +1 -40
  8. package/dist/app-bar/AppBar.js.map +1 -1
  9. package/dist/app-bar/AppBarTitle.d.ts +1 -27
  10. package/dist/app-bar/AppBarTitle.js +1 -15
  11. package/dist/app-bar/AppBarTitle.js.map +1 -1
  12. package/dist/app-bar/_app-bar.scss +156 -25
  13. package/dist/app-bar/styles.d.ts +117 -0
  14. package/dist/app-bar/styles.js +55 -0
  15. package/dist/app-bar/styles.js.map +1 -0
  16. package/dist/autocomplete/Autocomplete.d.ts +8 -79
  17. package/dist/autocomplete/Autocomplete.js +112 -83
  18. package/dist/autocomplete/Autocomplete.js.map +1 -1
  19. package/dist/autocomplete/AutocompleteChip.d.ts +8 -0
  20. package/dist/autocomplete/AutocompleteChip.js +34 -0
  21. package/dist/autocomplete/AutocompleteChip.js.map +1 -0
  22. package/dist/autocomplete/AutocompleteCircularProgress.d.ts +5 -11
  23. package/dist/autocomplete/AutocompleteCircularProgress.js +4 -0
  24. package/dist/autocomplete/AutocompleteCircularProgress.js.map +1 -1
  25. package/dist/autocomplete/AutocompleteClearButton.d.ts +9 -0
  26. package/dist/autocomplete/AutocompleteClearButton.js +29 -0
  27. package/dist/autocomplete/AutocompleteClearButton.js.map +1 -0
  28. package/dist/autocomplete/AutocompleteDropdownButton.d.ts +4 -26
  29. package/dist/autocomplete/AutocompleteDropdownButton.js +5 -1
  30. package/dist/autocomplete/AutocompleteDropdownButton.js.map +1 -1
  31. package/dist/autocomplete/AutocompleteListboxChildren.d.ts +22 -0
  32. package/dist/autocomplete/AutocompleteListboxChildren.js +37 -0
  33. package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -0
  34. package/dist/autocomplete/_autocomplete.scss +362 -34
  35. package/dist/autocomplete/autocompleteStyles.d.ts +22 -0
  36. package/dist/autocomplete/autocompleteStyles.js +17 -8
  37. package/dist/autocomplete/autocompleteStyles.js.map +1 -1
  38. package/dist/autocomplete/defaults.d.ts +9 -9
  39. package/dist/autocomplete/defaults.js +13 -13
  40. package/dist/autocomplete/defaults.js.map +1 -1
  41. package/dist/autocomplete/types.d.ts +554 -56
  42. package/dist/autocomplete/types.js.map +1 -1
  43. package/dist/autocomplete/useAutocomplete.d.ts +22 -0
  44. package/dist/autocomplete/useAutocomplete.js +281 -0
  45. package/dist/autocomplete/useAutocomplete.js.map +1 -0
  46. package/dist/autocomplete/utils.d.ts +81 -0
  47. package/dist/autocomplete/utils.js +108 -0
  48. package/dist/autocomplete/utils.js.map +1 -0
  49. package/dist/avatar/_avatar.scss +93 -2
  50. package/dist/badge/Badge.d.ts +1 -20
  51. package/dist/badge/Badge.js +1 -14
  52. package/dist/badge/Badge.js.map +1 -1
  53. package/dist/badge/_badge.scss +90 -3
  54. package/dist/badge/styles.d.ts +26 -0
  55. package/dist/badge/styles.js +18 -0
  56. package/dist/badge/styles.js.map +1 -0
  57. package/dist/box/Box.js +2 -1
  58. package/dist/box/Box.js.map +1 -1
  59. package/dist/box/_box.scss +130 -17
  60. package/dist/box/styles.d.ts +6 -0
  61. package/dist/box/styles.js +2 -1
  62. package/dist/box/styles.js.map +1 -1
  63. package/dist/button/AsyncButton.d.ts +1 -1
  64. package/dist/button/AsyncButton.js.map +1 -1
  65. package/dist/button/Button.d.ts +2 -1
  66. package/dist/button/Button.js +2 -1
  67. package/dist/button/Button.js.map +1 -1
  68. package/dist/button/_button.scss +157 -25
  69. package/dist/card/Card.d.ts +16 -0
  70. package/dist/card/Card.js +11 -3
  71. package/dist/card/Card.js.map +1 -1
  72. package/dist/card/ClickableCard.d.ts +2 -1
  73. package/dist/card/ClickableCard.js +5 -2
  74. package/dist/card/ClickableCard.js.map +1 -1
  75. package/dist/card/_card.scss +90 -19
  76. package/dist/card/styles.d.ts +0 -7
  77. package/dist/card/styles.js +2 -3
  78. package/dist/card/styles.js.map +1 -1
  79. package/dist/chip/Chip.d.ts +2 -1
  80. package/dist/chip/Chip.js +2 -1
  81. package/dist/chip/Chip.js.map +1 -1
  82. package/dist/chip/_chip.scss +45 -22
  83. package/dist/chip/styles.d.ts +12 -10
  84. package/dist/chip/styles.js.map +1 -1
  85. package/dist/cssUtils.js.map +1 -1
  86. package/dist/delegateEvent.d.ts +2 -2
  87. package/dist/delegateEvent.js.map +1 -1
  88. package/dist/dialog/Dialog.d.ts +8 -21
  89. package/dist/dialog/Dialog.js +27 -27
  90. package/dist/dialog/Dialog.js.map +1 -1
  91. package/dist/dialog/FixedDialog.d.ts +1 -3
  92. package/dist/dialog/FixedDialog.js +0 -8
  93. package/dist/dialog/FixedDialog.js.map +1 -1
  94. package/dist/dialog/_dialog.scss +67 -13
  95. package/dist/dialog/styles.d.ts +56 -0
  96. package/dist/dialog/styles.js +29 -2
  97. package/dist/dialog/styles.js.map +1 -1
  98. package/dist/divider/Divider.d.ts +0 -11
  99. package/dist/divider/Divider.js.map +1 -1
  100. package/dist/divider/_divider.scss +7 -1
  101. package/dist/divider/styles.d.ts +11 -0
  102. package/dist/divider/styles.js.map +1 -1
  103. package/dist/draggable/useDraggable.d.ts +6 -6
  104. package/dist/draggable/useDraggable.js.map +1 -1
  105. package/dist/draggable/utils.d.ts +3 -3
  106. package/dist/draggable/utils.js.map +1 -1
  107. package/dist/expansion-panel/ExpansionPanel.d.ts +1 -1
  108. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  109. package/dist/expansion-panel/_expansion-panel.scss +5 -1
  110. package/dist/expansion-panel/useExpansionPanels.js +12 -24
  111. package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
  112. package/dist/{form → files}/FileInput.d.ts +3 -6
  113. package/dist/{form → files}/FileInput.js +3 -6
  114. package/dist/files/FileInput.js.map +1 -0
  115. package/dist/files/_files.scss +22 -0
  116. package/dist/files/styles.d.ts +5 -0
  117. package/dist/files/styles.js +7 -0
  118. package/dist/files/styles.js.map +1 -0
  119. package/dist/{form → files}/useFileUpload.d.ts +7 -9
  120. package/dist/{form → files}/useFileUpload.js +5 -7
  121. package/dist/files/useFileUpload.js.map +1 -0
  122. package/dist/files/utils.d.ts +169 -0
  123. package/dist/files/utils.js +114 -0
  124. package/dist/files/utils.js.map +1 -0
  125. package/dist/{form/fileUtils.d.ts → files/validation.d.ts} +11 -176
  126. package/dist/{form/fileUtils.js → files/validation.js} +10 -135
  127. package/dist/files/validation.js.map +1 -0
  128. package/dist/focus/useFocusContainer.d.ts +2 -2
  129. package/dist/focus/useFocusContainer.js.map +1 -1
  130. package/dist/focus/utils.js.map +1 -1
  131. package/dist/form/FormMessage.js.map +1 -1
  132. package/dist/form/FormMessageContainer.js +4 -2
  133. package/dist/form/FormMessageContainer.js.map +1 -1
  134. package/dist/form/InputToggle.d.ts +2 -1
  135. package/dist/form/InputToggle.js +2 -1
  136. package/dist/form/InputToggle.js.map +1 -1
  137. package/dist/form/InputToggleIcon.js.map +1 -1
  138. package/dist/form/Label.js +2 -2
  139. package/dist/form/Label.js.map +1 -1
  140. package/dist/form/Listbox.d.ts +24 -0
  141. package/dist/form/Listbox.js +46 -0
  142. package/dist/form/Listbox.js.map +1 -0
  143. package/dist/form/ListboxProvider.d.ts +21 -0
  144. package/dist/form/{useListboxProvider.js → ListboxProvider.js} +1 -1
  145. package/dist/form/ListboxProvider.js.map +1 -0
  146. package/dist/form/MenuItemTextField.js +1 -2
  147. package/dist/form/MenuItemTextField.js.map +1 -1
  148. package/dist/form/NativeSelect.js +7 -4
  149. package/dist/form/NativeSelect.js.map +1 -1
  150. package/dist/form/Option.d.ts +49 -10
  151. package/dist/form/Option.js +11 -9
  152. package/dist/form/Option.js.map +1 -1
  153. package/dist/form/Password.js.map +1 -1
  154. package/dist/form/Select.d.ts +2 -2
  155. package/dist/form/Select.js +81 -85
  156. package/dist/form/Select.js.map +1 -1
  157. package/dist/form/SelectedOption.js +2 -1
  158. package/dist/form/SelectedOption.js.map +1 -1
  159. package/dist/form/Slider.d.ts +4 -4
  160. package/dist/form/Slider.js +6 -2
  161. package/dist/form/Slider.js.map +1 -1
  162. package/dist/form/SliderThumb.d.ts +3 -3
  163. package/dist/form/SliderThumb.js.map +1 -1
  164. package/dist/form/SliderValueMarks.d.ts +2 -2
  165. package/dist/form/SliderValueMarks.js.map +1 -1
  166. package/dist/form/SliderValueTooltip.js.map +1 -1
  167. package/dist/form/TextArea.js +1 -2
  168. package/dist/form/TextArea.js.map +1 -1
  169. package/dist/form/TextField.js +1 -2
  170. package/dist/form/TextField.js.map +1 -1
  171. package/dist/form/TextFieldContainer.js +1 -2
  172. package/dist/form/TextFieldContainer.js.map +1 -1
  173. package/dist/form/_form.scss +193 -124
  174. package/dist/form/formMessageContainerStyles.d.ts +10 -0
  175. package/dist/form/formMessageContainerStyles.js +11 -0
  176. package/dist/form/formMessageContainerStyles.js.map +1 -0
  177. package/dist/form/inputToggleStyles.js.map +1 -1
  178. package/dist/form/optionStyles.d.ts +1 -0
  179. package/dist/form/optionStyles.js +2 -2
  180. package/dist/form/optionStyles.js.map +1 -1
  181. package/dist/form/selectUtils.js.map +1 -1
  182. package/dist/form/sliderUtils.d.ts +1 -1
  183. package/dist/form/sliderUtils.js.map +1 -1
  184. package/dist/form/textFieldContainerStyles.d.ts +0 -2
  185. package/dist/form/textFieldContainerStyles.js +1 -2
  186. package/dist/form/textFieldContainerStyles.js.map +1 -1
  187. package/dist/form/types.d.ts +3 -10
  188. package/dist/form/types.js.map +1 -1
  189. package/dist/form/useCheckboxGroup.d.ts +17 -17
  190. package/dist/form/useCheckboxGroup.js +9 -17
  191. package/dist/form/useCheckboxGroup.js.map +1 -1
  192. package/dist/form/useCombobox.d.ts +56 -21
  193. package/dist/form/useCombobox.js +19 -4
  194. package/dist/form/useCombobox.js.map +1 -1
  195. package/dist/form/useEditableCombobox.d.ts +24 -4
  196. package/dist/form/useEditableCombobox.js +5 -0
  197. package/dist/form/useEditableCombobox.js.map +1 -1
  198. package/dist/form/useNumberField.js.map +1 -1
  199. package/dist/form/useRadioGroup.d.ts +6 -6
  200. package/dist/form/useRadioGroup.js.map +1 -1
  201. package/dist/form/useResizingTextArea.js.map +1 -1
  202. package/dist/form/useSelectCombobox.d.ts +3 -4
  203. package/dist/form/useSelectCombobox.js.map +1 -1
  204. package/dist/form/useTextField.d.ts +1 -1
  205. package/dist/form/useTextField.js.map +1 -1
  206. package/dist/form/useTextFieldContainerAddons.js.map +1 -1
  207. package/dist/hoverMode/useHoverMode.d.ts +3 -3
  208. package/dist/hoverMode/useHoverMode.js.map +1 -1
  209. package/dist/hoverMode/useHoverModeProvider.d.ts +4 -4
  210. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  211. package/dist/icon/FontIcon.d.ts +4 -2
  212. package/dist/icon/FontIcon.js.map +1 -1
  213. package/dist/icon/TextIconSpacing.d.ts +3 -1
  214. package/dist/icon/TextIconSpacing.js.map +1 -1
  215. package/dist/icon/_icon.scss +151 -2
  216. package/dist/icon/iconConfig.d.ts +10 -0
  217. package/dist/icon/iconConfig.js +7 -0
  218. package/dist/icon/iconConfig.js.map +1 -1
  219. package/dist/icon/materialConfig.js.map +1 -1
  220. package/dist/icon/styles.js.map +1 -1
  221. package/dist/interaction/UserInteractionModeProvider.d.ts +5 -5
  222. package/dist/interaction/UserInteractionModeProvider.js +12 -8
  223. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  224. package/dist/interaction/types.d.ts +20 -2
  225. package/dist/interaction/types.js.map +1 -1
  226. package/dist/interaction/useElementInteraction.d.ts +7 -1
  227. package/dist/interaction/useElementInteraction.js +1 -2
  228. package/dist/interaction/useElementInteraction.js.map +1 -1
  229. package/dist/interaction/utils.d.ts +2 -2
  230. package/dist/interaction/utils.js +2 -2
  231. package/dist/interaction/utils.js.map +1 -1
  232. package/dist/layout/LayoutWindowSplitter.js.map +1 -1
  233. package/dist/layout/_layout.scss +23 -10
  234. package/dist/layout/useExpandableLayout.d.ts +3 -3
  235. package/dist/layout/useExpandableLayout.js.map +1 -1
  236. package/dist/layout/useLayoutAppBarHeight.d.ts +2 -3
  237. package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
  238. package/dist/layout/useTemporaryLayout.d.ts +2 -2
  239. package/dist/layout/useTemporaryLayout.js.map +1 -1
  240. package/dist/link/SkipToMainContent.js.map +1 -1
  241. package/dist/list/ListItem.d.ts +2 -1
  242. package/dist/list/ListItem.js +2 -1
  243. package/dist/list/ListItem.js.map +1 -1
  244. package/dist/list/ListItemChildren.js.map +1 -1
  245. package/dist/list/ListItemLink.d.ts +2 -1
  246. package/dist/list/ListItemLink.js +2 -1
  247. package/dist/list/ListItemLink.js.map +1 -1
  248. package/dist/list/_list.scss +6 -5
  249. package/dist/media-queries/_media-queries.scss +12 -0
  250. package/dist/media-queries/appSize.js.map +1 -1
  251. package/dist/media-queries/useMediaQuery.js +3 -1
  252. package/dist/media-queries/useMediaQuery.js.map +1 -1
  253. package/dist/menu/DropdownMenu.js.map +1 -1
  254. package/dist/menu/Menu.d.ts +8 -3
  255. package/dist/menu/Menu.js +2 -1
  256. package/dist/menu/Menu.js.map +1 -1
  257. package/dist/menu/MenuItemButton.js +6 -2
  258. package/dist/menu/MenuItemButton.js.map +1 -1
  259. package/dist/menu/useContextMenu.d.ts +3 -3
  260. package/dist/menu/useContextMenu.js.map +1 -1
  261. package/dist/movement/types.d.ts +5 -5
  262. package/dist/movement/types.js.map +1 -1
  263. package/dist/navigation/CollapsibleNavGroup.d.ts +5 -3
  264. package/dist/navigation/CollapsibleNavGroup.js +3 -4
  265. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  266. package/dist/navigation/DefaultNavigationRenderer.d.ts +1 -2
  267. package/dist/navigation/DefaultNavigationRenderer.js +6 -2
  268. package/dist/navigation/DefaultNavigationRenderer.js.map +1 -1
  269. package/dist/navigation/NavItemButton.d.ts +1 -1
  270. package/dist/navigation/NavItemButton.js +1 -0
  271. package/dist/navigation/NavItemButton.js.map +1 -1
  272. package/dist/navigation/NavItemLink.d.ts +3 -2
  273. package/dist/navigation/NavItemLink.js +6 -2
  274. package/dist/navigation/NavItemLink.js.map +1 -1
  275. package/dist/navigation/NavSubheader.d.ts +2 -3
  276. package/dist/navigation/NavSubheader.js.map +1 -1
  277. package/dist/navigation/Navigation.d.ts +1 -1
  278. package/dist/navigation/Navigation.js.map +1 -1
  279. package/dist/navigation/_navigation.scss +6 -5
  280. package/dist/navigation/types.d.ts +54 -6
  281. package/dist/navigation/types.js.map +1 -1
  282. package/dist/navigation/useActiveHeadingId.d.ts +1 -1
  283. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  284. package/dist/navigation/useNavigationExpansion.d.ts +104 -0
  285. package/dist/navigation/useNavigationExpansion.js +77 -0
  286. package/dist/navigation/useNavigationExpansion.js.map +1 -0
  287. package/dist/navigation/utils.d.ts +13 -0
  288. package/dist/navigation/utils.js +36 -0
  289. package/dist/navigation/utils.js.map +1 -0
  290. package/dist/objectFit.d.ts +69 -0
  291. package/dist/objectFit.js +52 -0
  292. package/dist/objectFit.js.map +1 -0
  293. package/dist/overlay/_overlay.scss +2 -1
  294. package/dist/positioning/useFixedPositioning.d.ts +17 -4
  295. package/dist/positioning/useFixedPositioning.js +10 -5
  296. package/dist/positioning/useFixedPositioning.js.map +1 -1
  297. package/dist/positioning/utils.js.map +1 -1
  298. package/dist/progress/LinearProgress.js.map +1 -1
  299. package/dist/progress/_progress.scss +20 -14
  300. package/dist/responsive-item/ResponsiveItem.d.ts +64 -0
  301. package/dist/responsive-item/ResponsiveItem.js +68 -0
  302. package/dist/responsive-item/ResponsiveItem.js.map +1 -0
  303. package/dist/responsive-item/ResponsiveItemOverlay.d.ts +1 -19
  304. package/dist/responsive-item/ResponsiveItemOverlay.js +1 -12
  305. package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
  306. package/dist/responsive-item/_responsive-item.scss +110 -133
  307. package/dist/responsive-item/responsiveItemOverlayStyles.d.ts +19 -0
  308. package/dist/responsive-item/responsiveItemOverlayStyles.js +14 -0
  309. package/dist/responsive-item/responsiveItemOverlayStyles.js.map +1 -0
  310. package/dist/responsive-item/responsiveItemStyles.d.ts +52 -0
  311. package/dist/responsive-item/responsiveItemStyles.js +15 -0
  312. package/dist/responsive-item/responsiveItemStyles.js.map +1 -0
  313. package/dist/scroll/useScrollLock.d.ts +5 -0
  314. package/dist/scroll/useScrollLock.js.map +1 -1
  315. package/dist/searching/utils.d.ts +2 -2
  316. package/dist/searching/utils.js.map +1 -1
  317. package/dist/segmented-button/SegmentedButton.d.ts +2 -1
  318. package/dist/segmented-button/SegmentedButton.js +2 -1
  319. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  320. package/dist/segmented-button/_segmented-button.scss +6 -6
  321. package/dist/sheet/_sheet.scss +18 -6
  322. package/dist/snackbar/ToastManager.js +15 -5
  323. package/dist/snackbar/ToastManager.js.map +1 -1
  324. package/dist/snackbar/_snackbar.scss +30 -17
  325. package/dist/snackbar/useCurrentToastActions.d.ts +5 -5
  326. package/dist/snackbar/useCurrentToastActions.js.map +1 -1
  327. package/dist/table/_table.scss +15 -3
  328. package/dist/table/tableCellStyles.d.ts +7 -3
  329. package/dist/table/tableCellStyles.js +2 -2
  330. package/dist/table/tableCellStyles.js.map +1 -1
  331. package/dist/tabs/Tab.d.ts +2 -1
  332. package/dist/tabs/Tab.js +2 -1
  333. package/dist/tabs/Tab.js.map +1 -1
  334. package/dist/tabs/TabList.d.ts +2 -2
  335. package/dist/tabs/TabList.js.map +1 -1
  336. package/dist/tabs/TabListScrollButton.d.ts +1 -1
  337. package/dist/tabs/TabListScrollButton.js +1 -1
  338. package/dist/tabs/TabListScrollButton.js.map +1 -1
  339. package/dist/tabs/_tabs.scss +30 -9
  340. package/dist/tabs/getTabListScrollToOptions.d.ts +18 -0
  341. package/dist/tabs/getTabListScrollToOptions.js +19 -0
  342. package/dist/tabs/getTabListScrollToOptions.js.map +1 -0
  343. package/dist/tabs/tabStyles.d.ts +3 -0
  344. package/dist/tabs/tabStyles.js.map +1 -1
  345. package/dist/tabs/useTabList.d.ts +1 -8
  346. package/dist/tabs/useTabList.js +1 -0
  347. package/dist/tabs/useTabList.js.map +1 -1
  348. package/dist/tabs/useTabs.d.ts +6 -6
  349. package/dist/tabs/useTabs.js.map +1 -1
  350. package/dist/tabs/utils.d.ts +0 -18
  351. package/dist/tabs/utils.js +0 -15
  352. package/dist/tabs/utils.js.map +1 -1
  353. package/dist/test-utils/ResizeObserver.d.ts +11 -12
  354. package/dist/test-utils/ResizeObserver.js +11 -12
  355. package/dist/test-utils/ResizeObserver.js.map +1 -1
  356. package/dist/test-utils/matchMedia.d.ts +3 -3
  357. package/dist/test-utils/matchMedia.js +6 -6
  358. package/dist/test-utils/matchMedia.js.map +1 -1
  359. package/dist/test-utils/polyfills/TextDecoder.js +0 -1
  360. package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
  361. package/dist/test-utils/timers.d.ts +9 -5
  362. package/dist/test-utils/timers.js +5 -5
  363. package/dist/test-utils/timers.js.map +1 -1
  364. package/dist/theme/LocalStorageColorSchemeProvider.d.ts +1 -1
  365. package/dist/theme/LocalStorageColorSchemeProvider.js +2 -1
  366. package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
  367. package/dist/theme/ThemeProvider.js +3 -1
  368. package/dist/theme/ThemeProvider.js.map +1 -1
  369. package/dist/theme/_a11y.scss +86 -13
  370. package/dist/theme/_colors.scss +279 -277
  371. package/dist/theme/_theme.scss +308 -37
  372. package/dist/theme/isColorScheme.d.ts +16 -0
  373. package/dist/theme/isColorScheme.js +19 -0
  374. package/dist/theme/isColorScheme.js.map +1 -0
  375. package/dist/theme/types.d.ts +53 -1
  376. package/dist/theme/types.js +1 -23
  377. package/dist/theme/types.js.map +1 -1
  378. package/dist/theme/useCSSVariables.d.ts +2 -19
  379. package/dist/theme/useCSSVariables.js.map +1 -1
  380. package/dist/theme/useColorScheme.d.ts +1 -35
  381. package/dist/theme/useColorScheme.js.map +1 -1
  382. package/dist/theme/useColorSchemeMetaTag.d.ts +1 -1
  383. package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
  384. package/dist/theme/useColorSchemeProvider.d.ts +1 -1
  385. package/dist/theme/useColorSchemeProvider.js +1 -1
  386. package/dist/theme/useColorSchemeProvider.js.map +1 -1
  387. package/dist/theme/{usePrefersColorScheme.js → usePrefersDarkScheme.js} +1 -1
  388. package/dist/theme/usePrefersDarkScheme.js.map +1 -0
  389. package/dist/theme/utils.js.map +1 -1
  390. package/dist/tooltip/useTooltip.d.ts +14 -9
  391. package/dist/tooltip/useTooltip.js +2 -1
  392. package/dist/tooltip/useTooltip.js.map +1 -1
  393. package/dist/transition/_transition.scss +16 -9
  394. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  395. package/dist/transition/types.d.ts +1 -1
  396. package/dist/transition/types.js.map +1 -1
  397. package/dist/transition/useCarousel.d.ts +3 -3
  398. package/dist/transition/useCarousel.js.map +1 -1
  399. package/dist/transition/useCollapseTransition.js.map +1 -1
  400. package/dist/transition/useTransition.js +1 -0
  401. package/dist/transition/useTransition.js.map +1 -1
  402. package/dist/transition/utils.js.map +1 -1
  403. package/dist/tree/TreeItem.d.ts +2 -1
  404. package/dist/tree/TreeItem.js +4 -3
  405. package/dist/tree/TreeItem.js.map +1 -1
  406. package/dist/tree/TreeItemExpander.js.map +1 -1
  407. package/dist/tree/_tree.scss +8 -6
  408. package/dist/tree/useTreeExpansion.d.ts +1 -1
  409. package/dist/tree/useTreeExpansion.js +6 -18
  410. package/dist/tree/useTreeExpansion.js.map +1 -1
  411. package/dist/tree/useTreeSelection.d.ts +1 -1
  412. package/dist/tree/useTreeSelection.js +7 -25
  413. package/dist/tree/useTreeSelection.js.map +1 -1
  414. package/dist/tree/utils.d.ts +1 -1
  415. package/dist/tree/utils.js.map +1 -1
  416. package/dist/types.d.ts +12 -4
  417. package/dist/types.js.map +1 -1
  418. package/dist/typography/WritingDirectionProvider.d.ts +1 -1
  419. package/dist/typography/WritingDirectionProvider.js.map +1 -1
  420. package/dist/typography/_typography.scss +94 -37
  421. package/dist/typography/typographyStyles.js.map +1 -1
  422. package/dist/useDebouncedFunction.d.ts +1 -5
  423. package/dist/useDebouncedFunction.js +3 -1
  424. package/dist/useDebouncedFunction.js.map +1 -1
  425. package/dist/useDropzone.d.ts +4 -4
  426. package/dist/useDropzone.js.map +1 -1
  427. package/dist/useEnsuredId.js.map +1 -1
  428. package/dist/useIntersectionObserver.d.ts +5 -5
  429. package/dist/useIntersectionObserver.js.map +1 -1
  430. package/dist/useLocalStorage.d.ts +3 -3
  431. package/dist/useLocalStorage.js +1 -1
  432. package/dist/useLocalStorage.js.map +1 -1
  433. package/dist/useMutationObserver.d.ts +1 -1
  434. package/dist/useMutationObserver.js.map +1 -1
  435. package/dist/useOrientation.js +3 -1
  436. package/dist/useOrientation.js.map +1 -1
  437. package/dist/usePageInactive.d.ts +2 -2
  438. package/dist/usePageInactive.js.map +1 -1
  439. package/dist/useReadonlySet.d.ts +76 -0
  440. package/dist/useReadonlySet.js +72 -0
  441. package/dist/useReadonlySet.js.map +1 -0
  442. package/dist/useResizeListener.d.ts +1 -1
  443. package/dist/useResizeListener.js.map +1 -1
  444. package/dist/useResizeObserver.d.ts +19 -0
  445. package/dist/useResizeObserver.js +19 -0
  446. package/dist/useResizeObserver.js.map +1 -1
  447. package/dist/useThrottledFunction.d.ts +1 -5
  448. package/dist/useThrottledFunction.js +3 -1
  449. package/dist/useThrottledFunction.js.map +1 -1
  450. package/dist/useToggle.d.ts +3 -3
  451. package/dist/useToggle.js.map +1 -1
  452. package/dist/utils/RenderRecursively.d.ts +2 -2
  453. package/dist/utils/RenderRecursively.js.map +1 -1
  454. package/dist/utils/alphaNumericSort.d.ts +5 -5
  455. package/dist/utils/alphaNumericSort.js.map +1 -1
  456. package/dist/utils/bem.d.ts +1 -1
  457. package/dist/utils/bem.js +1 -1
  458. package/dist/utils/bem.js.map +1 -1
  459. package/dist/utils/debounce.d.ts +5 -0
  460. package/dist/utils/debounce.js +17 -0
  461. package/dist/utils/debounce.js.map +1 -0
  462. package/dist/utils/nearest.js.map +1 -1
  463. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  464. package/dist/utils/throttle.d.ts +5 -0
  465. package/dist/utils/throttle.js +30 -0
  466. package/dist/utils/throttle.js.map +1 -0
  467. package/dist/utils/wait.js +3 -1
  468. package/dist/utils/wait.js.map +1 -1
  469. package/dist/window-splitter/WindowSplitter.d.ts +37 -15
  470. package/dist/window-splitter/WindowSplitter.js +38 -17
  471. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  472. package/dist/window-splitter/_window-splitter.scss +32 -14
  473. package/dist/window-splitter/styles.d.ts +14 -0
  474. package/dist/window-splitter/styles.js +18 -0
  475. package/dist/window-splitter/styles.js.map +1 -0
  476. package/package.json +25 -24
  477. package/src/app-bar/AppBar.tsx +1 -170
  478. package/src/app-bar/AppBarTitle.tsx +1 -44
  479. package/src/app-bar/styles.ts +206 -0
  480. package/src/autocomplete/Autocomplete.tsx +194 -211
  481. package/src/autocomplete/AutocompleteChip.tsx +48 -0
  482. package/src/autocomplete/AutocompleteCircularProgress.tsx +6 -17
  483. package/src/autocomplete/AutocompleteClearButton.tsx +44 -0
  484. package/src/autocomplete/AutocompleteDropdownButton.tsx +16 -37
  485. package/src/autocomplete/AutocompleteListboxChildren.tsx +68 -0
  486. package/src/autocomplete/autocompleteStyles.ts +48 -9
  487. package/src/autocomplete/defaults.ts +26 -17
  488. package/src/autocomplete/types.ts +744 -61
  489. package/src/autocomplete/useAutocomplete.ts +428 -0
  490. package/src/autocomplete/utils.ts +211 -0
  491. package/src/badge/Badge.tsx +1 -39
  492. package/src/badge/styles.ts +45 -0
  493. package/src/box/Box.tsx +11 -9
  494. package/src/box/styles.ts +14 -5
  495. package/src/button/AsyncButton.tsx +1 -1
  496. package/src/button/Button.tsx +5 -1
  497. package/src/card/Card.tsx +35 -4
  498. package/src/card/ClickableCard.tsx +9 -2
  499. package/src/card/styles.ts +1 -10
  500. package/src/chip/Chip.tsx +6 -1
  501. package/src/chip/styles.ts +12 -10
  502. package/src/delegateEvent.ts +5 -5
  503. package/src/dialog/Dialog.tsx +48 -61
  504. package/src/dialog/FixedDialog.tsx +1 -11
  505. package/src/dialog/styles.ts +97 -0
  506. package/src/divider/Divider.tsx +0 -12
  507. package/src/divider/styles.ts +12 -0
  508. package/src/draggable/useDraggable.ts +17 -10
  509. package/src/draggable/utils.ts +3 -3
  510. package/src/expansion-panel/ExpansionPanel.tsx +1 -1
  511. package/src/expansion-panel/useExpansionPanels.ts +18 -27
  512. package/src/{form → files}/FileInput.tsx +7 -15
  513. package/src/files/styles.ts +10 -0
  514. package/src/{form → files}/useFileUpload.ts +30 -34
  515. package/src/files/utils.ts +234 -0
  516. package/src/{form/fileUtils.ts → files/validation.ts} +15 -244
  517. package/src/focus/useFocusContainer.ts +16 -8
  518. package/src/form/FormMessageContainer.tsx +2 -2
  519. package/src/form/InputToggle.tsx +5 -1
  520. package/src/form/Label.tsx +18 -18
  521. package/src/form/Listbox.tsx +87 -0
  522. package/src/form/ListboxProvider.ts +37 -0
  523. package/src/form/MenuItemTextField.tsx +1 -2
  524. package/src/form/NativeSelect.tsx +14 -10
  525. package/src/form/Option.tsx +74 -22
  526. package/src/form/Select.tsx +89 -85
  527. package/src/form/SelectedOption.tsx +2 -0
  528. package/src/form/Slider.tsx +14 -11
  529. package/src/form/SliderThumb.tsx +4 -4
  530. package/src/form/SliderValueMarks.tsx +4 -4
  531. package/src/form/TextArea.tsx +6 -8
  532. package/src/form/TextField.tsx +0 -2
  533. package/src/form/TextFieldContainer.tsx +9 -11
  534. package/src/form/formMessageContainerStyles.ts +22 -0
  535. package/src/form/optionStyles.ts +7 -2
  536. package/src/form/sliderUtils.ts +1 -1
  537. package/src/form/textFieldContainerStyles.ts +9 -14
  538. package/src/form/types.ts +3 -11
  539. package/src/form/useCheckboxGroup.ts +28 -36
  540. package/src/form/useCombobox.ts +86 -38
  541. package/src/form/useEditableCombobox.ts +43 -8
  542. package/src/form/useRadioGroup.ts +6 -6
  543. package/src/form/useSelectCombobox.ts +4 -4
  544. package/src/form/useTextField.ts +1 -1
  545. package/src/hoverMode/useHoverMode.ts +3 -3
  546. package/src/hoverMode/useHoverModeProvider.ts +4 -4
  547. package/src/icon/FontIcon.tsx +4 -2
  548. package/src/icon/TextIconSpacing.tsx +1 -1
  549. package/src/icon/iconConfig.tsx +12 -0
  550. package/src/interaction/UserInteractionModeProvider.tsx +12 -8
  551. package/src/interaction/types.ts +21 -2
  552. package/src/interaction/useElementInteraction.tsx +9 -2
  553. package/src/interaction/utils.ts +7 -7
  554. package/src/layout/useExpandableLayout.ts +3 -3
  555. package/src/layout/useLayoutAppBarHeight.ts +3 -4
  556. package/src/layout/useTemporaryLayout.ts +2 -2
  557. package/src/list/ListItem.tsx +5 -1
  558. package/src/list/ListItemLink.tsx +5 -1
  559. package/src/media-queries/useMediaQuery.ts +2 -1
  560. package/src/menu/Menu.tsx +11 -3
  561. package/src/menu/MenuItemButton.tsx +7 -1
  562. package/src/menu/useContextMenu.ts +3 -3
  563. package/src/movement/types.ts +5 -5
  564. package/src/navigation/CollapsibleNavGroup.tsx +16 -8
  565. package/src/navigation/DefaultNavigationRenderer.tsx +8 -6
  566. package/src/navigation/NavItemButton.tsx +2 -1
  567. package/src/navigation/NavItemLink.tsx +11 -3
  568. package/src/navigation/NavSubheader.tsx +1 -1
  569. package/src/navigation/Navigation.tsx +1 -1
  570. package/src/navigation/types.ts +60 -10
  571. package/src/navigation/useActiveHeadingId.ts +1 -1
  572. package/src/navigation/useNavigationExpansion.ts +170 -0
  573. package/src/navigation/utils.ts +47 -0
  574. package/src/objectFit.ts +88 -0
  575. package/src/positioning/useFixedPositioning.ts +34 -11
  576. package/src/responsive-item/ResponsiveItem.tsx +96 -0
  577. package/src/responsive-item/ResponsiveItemOverlay.tsx +6 -46
  578. package/src/responsive-item/responsiveItemOverlayStyles.ts +46 -0
  579. package/src/responsive-item/responsiveItemStyles.ts +81 -0
  580. package/src/scroll/useScrollLock.ts +6 -0
  581. package/src/searching/utils.ts +3 -3
  582. package/src/segmented-button/SegmentedButton.tsx +5 -1
  583. package/src/snackbar/ToastManager.tsx +16 -5
  584. package/src/snackbar/useCurrentToastActions.ts +5 -5
  585. package/src/table/tableCellStyles.ts +10 -6
  586. package/src/tabs/Tab.tsx +4 -1
  587. package/src/tabs/TabList.tsx +2 -2
  588. package/src/tabs/TabListScrollButton.tsx +4 -4
  589. package/src/tabs/getTabListScrollToOptions.ts +37 -0
  590. package/src/tabs/tabStyles.ts +4 -0
  591. package/src/tabs/useTabList.ts +2 -9
  592. package/src/tabs/useTabs.ts +6 -6
  593. package/src/tabs/utils.ts +0 -38
  594. package/src/test-utils/ResizeObserver.ts +11 -12
  595. package/src/test-utils/matchMedia.ts +7 -7
  596. package/src/test-utils/polyfills/TextDecoder.ts +0 -1
  597. package/src/test-utils/timers.ts +10 -7
  598. package/src/theme/LocalStorageColorSchemeProvider.tsx +4 -4
  599. package/src/theme/ThemeProvider.tsx +3 -3
  600. package/src/theme/isColorScheme.ts +22 -0
  601. package/src/theme/types.ts +67 -1
  602. package/src/theme/useCSSVariables.ts +7 -30
  603. package/src/theme/useColorScheme.ts +1 -40
  604. package/src/theme/useColorSchemeMetaTag.ts +1 -1
  605. package/src/theme/useColorSchemeProvider.ts +2 -2
  606. package/src/tooltip/useTooltip.ts +17 -9
  607. package/src/transition/types.ts +1 -1
  608. package/src/transition/useCarousel.ts +3 -3
  609. package/src/transition/useTransition.ts +1 -0
  610. package/src/tree/TreeItem.tsx +7 -1
  611. package/src/tree/TreeItemExpander.tsx +1 -1
  612. package/src/tree/useTreeExpansion.ts +7 -25
  613. package/src/tree/useTreeSelection.ts +8 -32
  614. package/src/tree/utils.ts +6 -2
  615. package/src/types.ts +20 -4
  616. package/src/typography/WritingDirectionProvider.tsx +1 -1
  617. package/src/useDebouncedFunction.ts +4 -9
  618. package/src/useDropzone.ts +4 -4
  619. package/src/useIntersectionObserver.ts +5 -5
  620. package/src/useLocalStorage.ts +6 -6
  621. package/src/useMutationObserver.ts +1 -1
  622. package/src/useOrientation.ts +3 -1
  623. package/src/usePageInactive.ts +2 -2
  624. package/src/useReadonlySet.ts +122 -0
  625. package/src/useResizeListener.ts +1 -1
  626. package/src/useResizeObserver.ts +19 -0
  627. package/src/useThrottledFunction.ts +6 -9
  628. package/src/useToggle.ts +3 -3
  629. package/src/utils/RenderRecursively.tsx +2 -2
  630. package/src/utils/alphaNumericSort.ts +5 -5
  631. package/src/utils/bem.ts +1 -1
  632. package/src/utils/debounce.ts +22 -0
  633. package/src/utils/throttle.ts +38 -0
  634. package/src/utils/wait.ts +5 -1
  635. package/src/window-splitter/WindowSplitter.tsx +38 -43
  636. package/src/window-splitter/styles.ts +42 -0
  637. package/dist/autocomplete/FilterAutocompleteOptions.d.ts +0 -8
  638. package/dist/autocomplete/FilterAutocompleteOptions.js +0 -57
  639. package/dist/autocomplete/FilterAutocompleteOptions.js.map +0 -1
  640. package/dist/dialog/DialogContainer.d.ts +0 -14
  641. package/dist/dialog/DialogContainer.js +0 -20
  642. package/dist/dialog/DialogContainer.js.map +0 -1
  643. package/dist/form/FileInput.js.map +0 -1
  644. package/dist/form/fileUtils.js.map +0 -1
  645. package/dist/form/useFileUpload.js.map +0 -1
  646. package/dist/form/useListboxProvider.d.ts +0 -31
  647. package/dist/form/useListboxProvider.js.map +0 -1
  648. package/dist/navigation/getHrefFromParents.d.ts +0 -5
  649. package/dist/navigation/getHrefFromParents.js +0 -13
  650. package/dist/navigation/getHrefFromParents.js.map +0 -1
  651. package/dist/responsive-item/ResponsiveItemContainer.d.ts +0 -115
  652. package/dist/responsive-item/ResponsiveItemContainer.js +0 -80
  653. package/dist/responsive-item/ResponsiveItemContainer.js.map +0 -1
  654. package/dist/responsive-item/styles.d.ts +0 -34
  655. package/dist/responsive-item/styles.js +0 -17
  656. package/dist/responsive-item/styles.js.map +0 -1
  657. package/dist/theme/usePrefersColorScheme.js.map +0 -1
  658. package/src/autocomplete/FilterAutocompleteOptions.tsx +0 -86
  659. package/src/dialog/DialogContainer.tsx +0 -28
  660. package/src/form/useListboxProvider.ts +0 -45
  661. package/src/navigation/getHrefFromParents.ts +0 -15
  662. package/src/responsive-item/ResponsiveItemContainer.tsx +0 -174
  663. package/src/responsive-item/styles.ts +0 -58
  664. /package/dist/theme/{usePrefersColorScheme.d.ts → usePrefersDarkScheme.d.ts} +0 -0
  665. /package/src/theme/{usePrefersColorScheme.ts → usePrefersDarkScheme.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/useTreeExpansion.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { type TreeDefaultIds, type TreeItemIdSet } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed from `TreeItemExpansion` and uses a Set\n * instead of a list to increase performance. Also renamed `onItemExpansion` to\n * `toggleTreeItemExpansion` and `onMultiItemExpansion` to\n * `expandMultipleTreeItems`.\n */\nexport interface TreeExpansion {\n expandedIds: TreeItemIdSet;\n toggleTreeItemExpansion(itemId: string): void;\n expandMultipleTreeItems: UseStateSetter<TreeItemIdSet>;\n}\n\n/**\n * @since 6.0.0 Renamed from `useTreeItemExpansion` and uses a Set\n * instead of a list to increase performance.\n */\nexport function useTreeExpansion(\n defaultExpandedIds?: TreeDefaultIds\n): TreeExpansion {\n const [expandedIds, setExpandedIds] = useState<TreeItemIdSet>(() => {\n const defaultIds =\n typeof defaultExpandedIds === \"function\"\n ? defaultExpandedIds()\n : defaultExpandedIds;\n\n return new Set(defaultIds);\n });\n\n const toggleTreeItemExpansion = useCallback((itemId: string) => {\n setExpandedIds((prevExpandedIds) => {\n const expandedIds = new Set(prevExpandedIds);\n if (expandedIds.has(itemId)) {\n expandedIds.delete(itemId);\n } else {\n expandedIds.add(itemId);\n }\n\n return expandedIds;\n });\n }, []);\n\n return {\n expandedIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems: setExpandedIds,\n };\n}\n"],"names":["useCallback","useState","useTreeExpansion","defaultExpandedIds","expandedIds","setExpandedIds","defaultIds","Set","toggleTreeItemExpansion","itemId","prevExpandedIds","has","delete","add","expandMultipleTreeItems"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAgB9C;;;CAGC,GACD,OAAO,SAASC,iBACdC,kBAAmC;IAEnC,MAAM,CAACC,aAAaC,eAAe,GAAGJ,SAAwB;QAC5D,MAAMK,aACJ,OAAOH,uBAAuB,aAC1BA,uBACAA;QAEN,OAAO,IAAII,IAAID;IACjB;IAEA,MAAME,0BAA0BR,YAAY,CAACS;QAC3CJ,eAAe,CAACK;YACd,MAAMN,cAAc,IAAIG,IAAIG;YAC5B,IAAIN,YAAYO,GAAG,CAACF,SAAS;gBAC3BL,YAAYQ,MAAM,CAACH;YACrB,OAAO;gBACLL,YAAYS,GAAG,CAACJ;YAClB;YAEA,OAAOL;QACT;IACF,GAAG,EAAE;IAEL,OAAO;QACLA;QACAI;QACAM,yBAAyBT;IAC3B;AACF"}
1
+ {"version":3,"sources":["../../src/tree/useTreeExpansion.ts"],"sourcesContent":["\"use client\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useReadonlySet } from \"../useReadonlySet.js\";\nimport { type TreeDefaultIds, type TreeItemIdSet } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed from `TreeItemExpansion` and uses a Set\n * instead of a list to increase performance. Also renamed `onItemExpansion` to\n * `toggleTreeItemExpansion` and `onMultiItemExpansion` to\n * `expandMultipleTreeItems`.\n */\nexport interface TreeExpansion {\n expandedIds: TreeItemIdSet;\n toggleTreeItemExpansion: (itemId: string) => void;\n expandMultipleTreeItems: UseStateSetter<TreeItemIdSet>;\n}\n\n/**\n * @since 6.0.0 Renamed from `useTreeItemExpansion` and uses a Set\n * instead of a list to increase performance.\n */\nexport function useTreeExpansion(\n defaultExpandedIds?: TreeDefaultIds\n): TreeExpansion {\n const { value, setValue, toggleValue } = useReadonlySet({\n defaultValue: defaultExpandedIds,\n });\n\n return {\n expandedIds: value,\n toggleTreeItemExpansion: toggleValue,\n expandMultipleTreeItems: setValue,\n };\n}\n"],"names":["useReadonlySet","useTreeExpansion","defaultExpandedIds","value","setValue","toggleValue","defaultValue","expandedIds","toggleTreeItemExpansion","expandMultipleTreeItems"],"mappings":"AAAA;AAEA,SAASA,cAAc,QAAQ,uBAAuB;AAetD;;;CAGC,GACD,OAAO,SAASC,iBACdC,kBAAmC;IAEnC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGL,eAAe;QACtDM,cAAcJ;IAChB;IAEA,OAAO;QACLK,aAAaJ;QACbK,yBAAyBH;QACzBI,yBAAyBL;IAC3B;AACF"}
@@ -10,7 +10,7 @@ export interface TreeSelection {
10
10
  /** @defaultValue `false` */
11
11
  multiSelect?: boolean;
12
12
  selectedIds: ReadonlySet<string>;
13
- toggleTreeItemSelection(itemId: string): void;
13
+ toggleTreeItemSelection: (itemId: string) => void;
14
14
  selectMultipleTreeItems: UseStateSetter<TreeItemIdSet>;
15
15
  }
16
16
  /**
@@ -1,36 +1,18 @@
1
1
  "use client";
2
- import { useCallback, useState } from "react";
2
+ import { useReadonlySet } from "../useReadonlySet.js";
3
3
  /**
4
4
  * @since 6.0.0 Renamed from `useTreeItemSelection` and uses a Set
5
5
  * instead of a list to increase performance.
6
6
  */ export function useTreeSelection(defaultSelectedIds, multiSelect = false) {
7
- const [selectedIds, setSelectedIds] = useState(()=>{
8
- const defaultIds = typeof defaultSelectedIds === "function" ? defaultSelectedIds() : defaultSelectedIds;
9
- return new Set(defaultIds);
7
+ const { value, setValue, toggleValue } = useReadonlySet({
8
+ toggleType: multiSelect ? "multiple" : "single-select",
9
+ defaultValue: defaultSelectedIds
10
10
  });
11
- const toggleTreeItemSelection = useCallback((itemId)=>{
12
- setSelectedIds((selectedIds)=>{
13
- if (!multiSelect) {
14
- return selectedIds.has(itemId) ? selectedIds : new Set([
15
- itemId
16
- ]);
17
- }
18
- const nextSelectedIds = new Set(selectedIds);
19
- if (selectedIds.has(itemId)) {
20
- nextSelectedIds.delete(itemId);
21
- } else {
22
- nextSelectedIds.add(itemId);
23
- }
24
- return nextSelectedIds;
25
- });
26
- }, [
27
- multiSelect
28
- ]);
29
11
  return {
30
- selectedIds,
31
12
  multiSelect,
32
- toggleTreeItemSelection,
33
- selectMultipleTreeItems: setSelectedIds
13
+ selectedIds: value,
14
+ toggleTreeItemSelection: toggleValue,
15
+ selectMultipleTreeItems: setValue
34
16
  };
35
17
  }
36
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/useTreeSelection.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { type TreeDefaultIds, type TreeItemIdSet } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed from `TreeItemSelection` and uses a Set\n * instead of a list to increase performance. Also renamed `onItemSelect` to\n * `toggleTreeItemSelection` and `onMultiItemSelect` to\n * `selectMultipleTreeItems`.\n */\nexport interface TreeSelection {\n /** @defaultValue `false` */\n multiSelect?: boolean;\n selectedIds: ReadonlySet<string>;\n toggleTreeItemSelection(itemId: string): void;\n selectMultipleTreeItems: UseStateSetter<TreeItemIdSet>;\n}\n\n/**\n * @since 6.0.0 Renamed from `useTreeItemSelection` and uses a Set\n * instead of a list to increase performance.\n */\nexport function useTreeSelection(\n defaultSelectedIds?: TreeDefaultIds,\n multiSelect = false\n): Required<TreeSelection> {\n const [selectedIds, setSelectedIds] = useState<TreeItemIdSet>(() => {\n const defaultIds =\n typeof defaultSelectedIds === \"function\"\n ? defaultSelectedIds()\n : defaultSelectedIds;\n\n return new Set(defaultIds);\n });\n\n const toggleTreeItemSelection = useCallback(\n (itemId: string) => {\n setSelectedIds((selectedIds) => {\n if (!multiSelect) {\n return selectedIds.has(itemId) ? selectedIds : new Set([itemId]);\n }\n\n const nextSelectedIds = new Set(selectedIds);\n if (selectedIds.has(itemId)) {\n nextSelectedIds.delete(itemId);\n } else {\n nextSelectedIds.add(itemId);\n }\n\n return nextSelectedIds;\n });\n },\n [multiSelect]\n );\n\n return {\n selectedIds,\n multiSelect,\n toggleTreeItemSelection,\n selectMultipleTreeItems: setSelectedIds,\n };\n}\n"],"names":["useCallback","useState","useTreeSelection","defaultSelectedIds","multiSelect","selectedIds","setSelectedIds","defaultIds","Set","toggleTreeItemSelection","itemId","has","nextSelectedIds","delete","add","selectMultipleTreeItems"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAkB9C;;;CAGC,GACD,OAAO,SAASC,iBACdC,kBAAmC,EACnCC,cAAc,KAAK;IAEnB,MAAM,CAACC,aAAaC,eAAe,GAAGL,SAAwB;QAC5D,MAAMM,aACJ,OAAOJ,uBAAuB,aAC1BA,uBACAA;QAEN,OAAO,IAAIK,IAAID;IACjB;IAEA,MAAME,0BAA0BT,YAC9B,CAACU;QACCJ,eAAe,CAACD;YACd,IAAI,CAACD,aAAa;gBAChB,OAAOC,YAAYM,GAAG,CAACD,UAAUL,cAAc,IAAIG,IAAI;oBAACE;iBAAO;YACjE;YAEA,MAAME,kBAAkB,IAAIJ,IAAIH;YAChC,IAAIA,YAAYM,GAAG,CAACD,SAAS;gBAC3BE,gBAAgBC,MAAM,CAACH;YACzB,OAAO;gBACLE,gBAAgBE,GAAG,CAACJ;YACtB;YAEA,OAAOE;QACT;IACF,GACA;QAACR;KAAY;IAGf,OAAO;QACLC;QACAD;QACAK;QACAM,yBAAyBT;IAC3B;AACF"}
1
+ {"version":3,"sources":["../../src/tree/useTreeSelection.ts"],"sourcesContent":["\"use client\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useReadonlySet } from \"../useReadonlySet.js\";\nimport { type TreeDefaultIds, type TreeItemIdSet } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed from `TreeItemSelection` and uses a Set\n * instead of a list to increase performance. Also renamed `onItemSelect` to\n * `toggleTreeItemSelection` and `onMultiItemSelect` to\n * `selectMultipleTreeItems`.\n */\nexport interface TreeSelection {\n /** @defaultValue `false` */\n multiSelect?: boolean;\n selectedIds: ReadonlySet<string>;\n toggleTreeItemSelection: (itemId: string) => void;\n selectMultipleTreeItems: UseStateSetter<TreeItemIdSet>;\n}\n\n/**\n * @since 6.0.0 Renamed from `useTreeItemSelection` and uses a Set\n * instead of a list to increase performance.\n */\nexport function useTreeSelection(\n defaultSelectedIds?: TreeDefaultIds,\n multiSelect = false\n): Required<TreeSelection> {\n const { value, setValue, toggleValue } = useReadonlySet({\n toggleType: multiSelect ? \"multiple\" : \"single-select\",\n defaultValue: defaultSelectedIds,\n });\n\n return {\n multiSelect,\n selectedIds: value,\n toggleTreeItemSelection: toggleValue,\n selectMultipleTreeItems: setValue,\n };\n}\n"],"names":["useReadonlySet","useTreeSelection","defaultSelectedIds","multiSelect","value","setValue","toggleValue","toggleType","defaultValue","selectedIds","toggleTreeItemSelection","selectMultipleTreeItems"],"mappings":"AAAA;AAEA,SAASA,cAAc,QAAQ,uBAAuB;AAiBtD;;;CAGC,GACD,OAAO,SAASC,iBACdC,kBAAmC,EACnCC,cAAc,KAAK;IAEnB,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGN,eAAe;QACtDO,YAAYJ,cAAc,aAAa;QACvCK,cAAcN;IAChB;IAEA,OAAO;QACLC;QACAM,aAAaL;QACbM,yBAAyBJ;QACzBK,yBAAyBN;IAC3B;AACF"}
@@ -1,4 +1,4 @@
1
- import type { TreeItemNode, TreeData, DefaultTreeItemNode } from "./types.js";
1
+ import { type DefaultTreeItemNode, type TreeData, type TreeItemNode } from "./types.js";
2
2
  /**
3
3
  * This will get all the items from the provided itemId up to the root of the
4
4
  * tree that can be used for drag and drop behavior or building a breadcrumb
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/utils.ts"],"sourcesContent":["import type { TreeItemNode, TreeData, DefaultTreeItemNode } from \"./types.js\";\n\n/**\n * This will get all the items from the provided itemId up to the root of the\n * tree that can be used for drag and drop behavior or building a breadcrumb\n * list.\n *\n * @param data - The flattened tree data to navigate.\n * @param itemId - The item id to start the search at.\n * @returns an ordered list of the current item followed by all the direct\n * parents of that item.\n * @since 6.0.0 Renamed from `getItemsFrom` to `getTreeItemsFrom`.\n */\nexport function getTreeItemsFrom<T extends TreeItemNode = DefaultTreeItemNode>(\n data: TreeData<T>,\n itemId: string | null\n): readonly T[] {\n const items: T[] = [];\n let currentId = itemId;\n while (currentId) {\n const item = data[currentId];\n currentId = item?.parentId ?? null;\n if (item) {\n items.push(item);\n }\n }\n\n return items;\n}\n\n/**\n * Gets all the child items for a specific parent item id. If the `recursive`\n * argument is enabled, all children of the items will also be returned instead\n * of only the top level items.\n *\n * @param data - Either the flattened tree data or a list of all the tree data\n * to iterate over\n * @param parentId - The parent id to get children of\n * @param recursive - Boolean if the children's children should also be returned\n * @returns a list of all the items for a specific parent item id. Note: if the\n * recursive param is enabled, the list will be ordered so that the children of\n * a item will appear before the next item at the same level. So you either need\n * to sort by `parentId` or something else if you want a specific order.\n * @since 6.0.0 Renamed from `getChildItems` to `getChildTreeItems`.\n */\nexport function getChildTreeItems<T extends TreeItemNode = DefaultTreeItemNode>(\n data: TreeData<T> | readonly T[],\n parentId: string | null,\n recursive = false\n): readonly T[] {\n const items = Array.isArray(data) ? data : Object.values(data);\n\n return items.reduce<T[]>((list, item) => {\n if (parentId !== item.parentId) {\n return list;\n }\n\n return [\n ...list,\n item,\n ...(recursive ? getChildTreeItems(items, item.itemId, recursive) : []),\n ];\n }, []);\n}\n"],"names":["getTreeItemsFrom","data","itemId","items","currentId","item","parentId","push","getChildTreeItems","recursive","Array","isArray","Object","values","reduce","list"],"mappings":"AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASA,iBACdC,IAAiB,EACjBC,MAAqB;IAErB,MAAMC,QAAa,EAAE;IACrB,IAAIC,YAAYF;IAChB,MAAOE,UAAW;QAChB,MAAMC,OAAOJ,IAAI,CAACG,UAAU;QAC5BA,YAAYC,MAAMC,YAAY;QAC9B,IAAID,MAAM;YACRF,MAAMI,IAAI,CAACF;QACb;IACF;IAEA,OAAOF;AACT;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASK,kBACdP,IAAgC,EAChCK,QAAuB,EACvBG,YAAY,KAAK;IAEjB,MAAMN,QAAQO,MAAMC,OAAO,CAACV,QAAQA,OAAOW,OAAOC,MAAM,CAACZ;IAEzD,OAAOE,MAAMW,MAAM,CAAM,CAACC,MAAMV;QAC9B,IAAIC,aAAaD,KAAKC,QAAQ,EAAE;YAC9B,OAAOS;QACT;QAEA,OAAO;eACFA;YACHV;eACII,YAAYD,kBAAkBL,OAAOE,KAAKH,MAAM,EAAEO,aAAa,EAAE;SACtE;IACH,GAAG,EAAE;AACP"}
1
+ {"version":3,"sources":["../../src/tree/utils.ts"],"sourcesContent":["import {\n type DefaultTreeItemNode,\n type TreeData,\n type TreeItemNode,\n} from \"./types.js\";\n\n/**\n * This will get all the items from the provided itemId up to the root of the\n * tree that can be used for drag and drop behavior or building a breadcrumb\n * list.\n *\n * @param data - The flattened tree data to navigate.\n * @param itemId - The item id to start the search at.\n * @returns an ordered list of the current item followed by all the direct\n * parents of that item.\n * @since 6.0.0 Renamed from `getItemsFrom` to `getTreeItemsFrom`.\n */\nexport function getTreeItemsFrom<T extends TreeItemNode = DefaultTreeItemNode>(\n data: TreeData<T>,\n itemId: string | null\n): readonly T[] {\n const items: T[] = [];\n let currentId = itemId;\n while (currentId) {\n const item = data[currentId];\n currentId = item?.parentId ?? null;\n if (item) {\n items.push(item);\n }\n }\n\n return items;\n}\n\n/**\n * Gets all the child items for a specific parent item id. If the `recursive`\n * argument is enabled, all children of the items will also be returned instead\n * of only the top level items.\n *\n * @param data - Either the flattened tree data or a list of all the tree data\n * to iterate over\n * @param parentId - The parent id to get children of\n * @param recursive - Boolean if the children's children should also be returned\n * @returns a list of all the items for a specific parent item id. Note: if the\n * recursive param is enabled, the list will be ordered so that the children of\n * a item will appear before the next item at the same level. So you either need\n * to sort by `parentId` or something else if you want a specific order.\n * @since 6.0.0 Renamed from `getChildItems` to `getChildTreeItems`.\n */\nexport function getChildTreeItems<T extends TreeItemNode = DefaultTreeItemNode>(\n data: TreeData<T> | readonly T[],\n parentId: string | null,\n recursive = false\n): readonly T[] {\n const items: readonly T[] = Array.isArray(data) ? data : Object.values(data);\n\n return items.reduce<T[]>((list, item) => {\n if (parentId !== item.parentId) {\n return list;\n }\n\n return [\n ...list,\n item,\n ...(recursive ? getChildTreeItems(items, item.itemId, recursive) : []),\n ];\n }, []);\n}\n"],"names":["getTreeItemsFrom","data","itemId","items","currentId","item","parentId","push","getChildTreeItems","recursive","Array","isArray","Object","values","reduce","list"],"mappings":"AAMA;;;;;;;;;;CAUC,GACD,OAAO,SAASA,iBACdC,IAAiB,EACjBC,MAAqB;IAErB,MAAMC,QAAa,EAAE;IACrB,IAAIC,YAAYF;IAChB,MAAOE,UAAW;QAChB,MAAMC,OAAOJ,IAAI,CAACG,UAAU;QAC5BA,YAAYC,MAAMC,YAAY;QAC9B,IAAID,MAAM;YACRF,MAAMI,IAAI,CAACF;QACb;IACF;IAEA,OAAOF;AACT;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASK,kBACdP,IAAgC,EAChCK,QAAuB,EACvBG,YAAY,KAAK;IAEjB,MAAMN,QAAsBO,MAAMC,OAAO,CAACV,QAAQA,OAAOW,OAAOC,MAAM,CAACZ;IAEvE,OAAOE,MAAMW,MAAM,CAAM,CAACC,MAAMV;QAC9B,IAAIC,aAAaD,KAAKC,QAAQ,EAAE;YAC9B,OAAOS;QACT;QAEA,OAAO;eACFA;YACHV;eACII,YAAYD,kBAAkBL,OAAOE,KAAKH,MAAM,EAAEO,aAAa,EAAE;SACtE;IACH,GAAG,EAAE;AACP"}
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { Dispatch, ReactElement, Ref, SetStateAction } from "react";
3
3
  * A helper type that allows an optional `ref` to also be applied with a props
4
4
  * object even though a `ref` isn't a real prop.
5
5
  */
6
- export type PropsWithRef<Props extends {}, Element extends HTMLElement> = Props & {
6
+ export type PropsWithRef<Props extends object, Element extends HTMLElement> = Props & {
7
7
  /**
8
8
  * An optional ref that can be applied.
9
9
  */
@@ -13,7 +13,7 @@ export type PropsWithRef<Props extends {}, Element extends HTMLElement> = Props
13
13
  * A simple type that can be used for different components that clone a
14
14
  * `className` into a child component.
15
15
  */
16
- export type ClassNameCloneableChild<T = {}> = ReactElement<T & {
16
+ export type ClassNameCloneableChild<T = object> = ReactElement<T & {
17
17
  className?: string;
18
18
  }>;
19
19
  /**
@@ -145,13 +145,21 @@ export type CssPosition = "fixed" | "sticky" | "static";
145
145
  /**
146
146
  * @since 6.0.0
147
147
  */
148
- export type AnyFunction = (...args: any[]) => any | void;
148
+ export type AnyFunction = (...args: any[]) => any;
149
149
  /**
150
150
  * @since 6.0.0
151
151
  */
152
152
  export type CancelableFunction<F extends AnyFunction> = F & {
153
- cancel(): void;
153
+ cancel: () => void;
154
154
  };
155
+ /**
156
+ * @since 6.0.0
157
+ */
158
+ export type DebouncedFunction<F extends AnyFunction> = CancelableFunction<(...args: Parameters<F>) => void>;
159
+ /**
160
+ * @since 6.0.0
161
+ */
162
+ export type ThrottledFunction<F extends AnyFunction> = CancelableFunction<(...args: Parameters<F>) => ReturnType<F>>;
155
163
  /**
156
164
  * @since 6.0.0
157
165
  */
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Dispatch, ReactElement, Ref, SetStateAction } from \"react\";\n\n/**\n * A helper type that allows an optional `ref` to also be applied with a props\n * object even though a `ref` isn't a real prop.\n */\nexport type PropsWithRef<\n Props extends {},\n Element extends HTMLElement,\n> = Props & {\n /**\n * An optional ref that can be applied.\n */\n ref?: Ref<Element>;\n};\n\n/**\n * A simple type that can be used for different components that clone a\n * `className` into a child component.\n */\nexport type ClassNameCloneableChild<T = {}> = ReactElement<\n T & { className?: string }\n>;\n\n/**\n * This type allows you to require at least one of the provided keys. This is\n * super helpful for things like `aria-label` or `aria-labelledby` when it's\n * required for a11y.\n *\n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198\n */\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport interface LabelA11y {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n}\n\n/**\n * A small accessibility helper to ensure that either `aria-label` or\n * `aria-labelledby` have been provided to a component.\n *\n * @example Simple Example\n * ```ts\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import type { LabelRequiredForA11y } from \"@react-md/core\";\n *\n * type Props = LabelRequiredForA11y<HTMLAttributes<HTMLDivElement>>;\n *\n * function Component(props: Props): ReactElement {\n * return <div {...props} />;\n * }\n *\n * const test1 = <Component />\n * // ^ type error\n * const test2 = <Component aria-label=\"Label\" />\n * const test3 = <Component aria-labelledby=\"some-other-id\" />\n * ```\n */\nexport type LabelRequiredForA11y<Props extends LabelA11y> = RequireAtLeastOne<\n Props,\n keyof LabelA11y\n>;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport interface NonNullRef<T> {\n readonly current: T;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface NonNullMutableRef<T> {\n current: T;\n}\n\n/** @since 6.0.0 */\nexport type HtmlTagName = keyof JSX.IntrinsicElements;\n\n/**\n * A function to get a string from a generic item.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * name: string;\n * }\n *\n * const items: Item[] = [{ name: 'Hello' }, { name: 'World' }];\n *\n * const extractor: TextExtractor<Item> = (item) => item.name;\n * ```\n * @since 6.0.0\n */\nexport type TextExtractor<T> = (item: T) => string;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateSetter<T> = Dispatch<SetStateAction<T>>;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateInitializer<T> = T | (() => T);\n\n/**\n * @example\n * ```ts\n * type Visibility = UseStateObject<\"visible\", boolean>;\n * // type Visibility = {\n * // visible: boolean;\n * // setVisible: UseStateSetter<boolean>\n * // }\n *\n * type AnotherOne = UseStateObject<\"renderAsSheet\", RenderMenuAsSheet>;\n * // type AnotherOne = {\n * // renderAsSheet: RenderMenuAsSheet;\n * // setRenderAsSheet: UseStateSetter<RenderMenuAsSheet>;\n * // }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport type UseStateObject<Name extends string, Value> = {\n [key in Name]: Value;\n} & {\n [key in `set${Capitalize<Name>}`]: UseStateSetter<Value>;\n};\n\n/**\n * @example\n * ```ts\n * interface Example {\n * value: number;\n * setValue: UseStateSetter<number>;\n * }\n *\n * type WithPrefix = RenameKeysWithPrefix<Example, \"thumb1\">;\n * // type WithPrefix = {\n * // thumb1Value: number;\n * // thumb1SetValue: UseStateSetter<number>;\n * // }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport type RenameKeysWithPrefix<T, Prefix extends string> = {\n [Key in keyof T & string as `${Prefix}${Capitalize<Key>}`]: T[Key];\n};\n\n/**\n * @since 6.0.0\n */\nexport type CssPosition = \"fixed\" | \"sticky\" | \"static\";\n\n/**\n * @since 6.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any | void;\n\n/**\n * @since 6.0.0\n */\nexport type CancelableFunction<F extends AnyFunction> = F & { cancel(): void };\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSize {\n height: number;\n width: number;\n}\n"],"names":[],"mappings":"AAoLA;;CAEC,GACD,WAGC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Dispatch, ReactElement, Ref, SetStateAction } from \"react\";\n\n/**\n * A helper type that allows an optional `ref` to also be applied with a props\n * object even though a `ref` isn't a real prop.\n */\nexport type PropsWithRef<\n Props extends object,\n Element extends HTMLElement,\n> = Props & {\n /**\n * An optional ref that can be applied.\n */\n ref?: Ref<Element>;\n};\n\n/**\n * A simple type that can be used for different components that clone a\n * `className` into a child component.\n */\nexport type ClassNameCloneableChild<T = object> = ReactElement<\n T & { className?: string }\n>;\n\n/**\n * This type allows you to require at least one of the provided keys. This is\n * super helpful for things like `aria-label` or `aria-labelledby` when it's\n * required for a11y.\n *\n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198\n */\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport interface LabelA11y {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n}\n\n/**\n * A small accessibility helper to ensure that either `aria-label` or\n * `aria-labelledby` have been provided to a component.\n *\n * @example Simple Example\n * ```ts\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import type { LabelRequiredForA11y } from \"@react-md/core\";\n *\n * type Props = LabelRequiredForA11y<HTMLAttributes<HTMLDivElement>>;\n *\n * function Component(props: Props): ReactElement {\n * return <div {...props} />;\n * }\n *\n * const test1 = <Component />\n * // ^ type error\n * const test2 = <Component aria-label=\"Label\" />\n * const test3 = <Component aria-labelledby=\"some-other-id\" />\n * ```\n */\nexport type LabelRequiredForA11y<Props extends LabelA11y> = RequireAtLeastOne<\n Props,\n keyof LabelA11y\n>;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport interface NonNullRef<T> {\n readonly current: T;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface NonNullMutableRef<T> {\n current: T;\n}\n\n/** @since 6.0.0 */\nexport type HtmlTagName = keyof JSX.IntrinsicElements;\n\n/**\n * A function to get a string from a generic item.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * name: string;\n * }\n *\n * const items: Item[] = [{ name: 'Hello' }, { name: 'World' }];\n *\n * const extractor: TextExtractor<Item> = (item) => item.name;\n * ```\n * @since 6.0.0\n */\nexport type TextExtractor<T> = (item: T) => string;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateSetter<T> = Dispatch<SetStateAction<T>>;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateInitializer<T> = T | (() => T);\n\n/**\n * @example\n * ```ts\n * type Visibility = UseStateObject<\"visible\", boolean>;\n * // type Visibility = {\n * // visible: boolean;\n * // setVisible: UseStateSetter<boolean>\n * // }\n *\n * type AnotherOne = UseStateObject<\"renderAsSheet\", RenderMenuAsSheet>;\n * // type AnotherOne = {\n * // renderAsSheet: RenderMenuAsSheet;\n * // setRenderAsSheet: UseStateSetter<RenderMenuAsSheet>;\n * // }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport type UseStateObject<Name extends string, Value> = {\n [key in Name]: Value;\n} & {\n [key in `set${Capitalize<Name>}`]: UseStateSetter<Value>;\n};\n\n/**\n * @example\n * ```ts\n * interface Example {\n * value: number;\n * setValue: UseStateSetter<number>;\n * }\n *\n * type WithPrefix = RenameKeysWithPrefix<Example, \"thumb1\">;\n * // type WithPrefix = {\n * // thumb1Value: number;\n * // thumb1SetValue: UseStateSetter<number>;\n * // }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport type RenameKeysWithPrefix<T, Prefix extends string> = {\n [Key in keyof T & string as `${Prefix}${Capitalize<Key>}`]: T[Key];\n};\n\n/**\n * @since 6.0.0\n */\nexport type CssPosition = \"fixed\" | \"sticky\" | \"static\";\n\n/**\n * @since 6.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any;\n\n/**\n * @since 6.0.0\n */\nexport type CancelableFunction<F extends AnyFunction> = F & {\n cancel: () => void;\n};\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\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 * @since 6.0.0\n */\nexport interface ElementSize {\n height: number;\n width: number;\n}\n"],"names":[],"mappings":"AAoMA;;CAEC,GACD,WAGC"}
@@ -17,7 +17,7 @@ export interface WritingDirectionContext {
17
17
  /**
18
18
  * Toggles the current writing direction for the first parent `Dir` component.
19
19
  */
20
- toggleDir(): void;
20
+ toggleDir: () => void;
21
21
  }
22
22
  /**
23
23
  * Gets the writing direction context which provides access to the current `dir`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/WritingDirectionProvider.tsx"],"sourcesContent":["\"use client\";\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { type UseStateInitializer } from \"../types.js\";\n\n/**\n * Note: unlike the `dir` DOM attribute, the `\"auto\"` value is not supported.\n *\n * @since 6.0.0\n */\nexport type Dir = \"ltr\" | \"rtl\";\n\n/** @since 6.0.0 */\nexport type DefaultDir = UseStateInitializer<Dir>;\n\n/** @since 2.3.0 */\nexport interface WritingDirectionContext {\n /**\n * The current writing direction that is being inherited.\n */\n dir: Dir;\n\n /**\n * Toggles the current writing direction for the first parent `Dir` component.\n */\n toggleDir(): void;\n}\n\n/** @internal */\ninterface InheritableContext extends WritingDirectionContext {\n root: boolean;\n}\n\nconst context = createContext<InheritableContext>({\n root: true,\n dir: \"ltr\",\n toggleDir: () => {\n if (process.env.NODE_ENV !== \"production\") {\n throw new Error(\n \"Tried to toggle the current writing direction without initializing the `Dir` component.\"\n );\n }\n },\n});\ncontext.displayName = \"WritingDirection\";\nconst { Provider } = context;\n\n/**\n * Gets the writing direction context which provides access to the current `dir`\n * and a `toggleDir` function.\n *\n * @example Manually Changing the Writing Direction\n * ```tsx\n * import { useDir } from \"@react-md/core\";\n *\n * function Example() {\n * const { dir, toggleDir } = useDir();\n *\n * return (\n * <>\n * <p>{`The current dir is: \"${dir}\"`}</p>\n * <button type=\"button\" onClick={toggleDir}>Toggle</button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useDir(): Readonly<WritingDirectionContext> {\n const { root: _root, ...current } = useContext(context);\n return current;\n}\n\n/** @since 6.0.0 */\nexport interface WritingDirectionProviderProps {\n /**\n * A single ReactElement child. If the `WritingDirection` has a parent\n * `WritingDirection`, the child will have the `dir` prop cloned into this\n * element.\n */\n children: ReactElement<{ dir?: Dir }> | ReactNode;\n\n /**\n * The default writing direction for your app or a subtree. To change the\n * current writing direction, use the `useDir` hook to get access to the\n * current `dir` and the `toggleDir` function.\n *\n * @defaultValue `\"ltr\"`\n * @see {@link DEFAULT_WRITING_DIRECTION}\n */\n defaultDir?: DefaultDir;\n}\n\n/**\n * In the browser, this will default to the `<html>`'s `dir` value if one\n * exists. If the `dir` attribute does not exist, it will default to `\"ltr\"`.\n *\n * In node environments, this will default to `\"ltr\"`.\n *\n * @since 6.0.0 Renamed from `DEFAULT_DIR`\n */\nexport const DEFAULT_WRITING_DIRECTION = (): Dir => {\n let dir: Dir = \"ltr\";\n if (typeof document !== \"undefined\") {\n const rootDir = document.documentElement.getAttribute(\"dir\");\n dir = rootDir === \"rtl\" ? \"rtl\" : \"ltr\";\n }\n\n return dir;\n};\n\n/**\n * **Client Component**\n *\n * The `WritingDirection` component is used to handle the current writing\n * direction within your app as well as conditionally updating the writing\n * direction for small sections in your app. When this component is used for the\n * first time near the root of your React component tree, the current direction\n * will be applied to the root `<html>` element. Otherwise the current dir will\n * be cloned into the child element so it can be passed as a prop.\n *\n * Note: Since the `dir` is cloned into the child element, you need to make sure\n * that the child is either a DOM element or the `dir` prop is passed from your\n * custom component.\n *\n * @example Root Setup\n * ```tsx\n * import { createRoot } from \"react-dom/client\";\n * import { WritingDirection } from \"@react-md/core\";\n * import App from \"./App.js\":\n *\n * const container = document.getElementById(\"root\");\n * const root = createRoot(container);\n *\n * root.render(\n * <WritingDirection>\n * <App />\n * </WritingDirection>\n * );\n * ```\n *\n * @example Supporting RTL Languages\n * ```tsx\n * import { createRoot } from \"react-dom/client\";\n * import { WritingDirection } from \"@react-md/core\";\n * import type { Dir } from \"@react-md/core\";\n * import App from \"./App.js\":\n *\n * const container = document.getElementById(\"root\");\n * const root = createRoot(container);\n *\n * // see https://meta.wikimedia.org/wiki/Template:List_of_language_names_ordered_by_code\n * const SUPPORTED_RTL_LANGUAGES = [\n * \"ar\",\n * \"arc\",\n * \"ckb\",\n * \"dv\",\n * \"fa\",\n * \"ha\",\n * \"he\",\n * \"khw\",\n * \"ks\",\n * \"ps\",\n * \"sd\",\n * \"ur\",\n * \"uz_AF\",\n * \"ti\",\n * ];\n *\n * const defaultDir = (): Dir => {\n * if (SUPPORTED_RTL_LANGUAGES.includes(navigator.language)) {\n * return \"rtl\"\n * }\n *\n * return \"ltr\";\n * }\n *\n * root.render(\n * <WritingDirection defaultDir={defaultDir}>\n * <App />\n * </WritingDirection>\n * );\n * ```\n *\n * @since 6.0.0 Renamed from `Dir`\n */\nexport function WritingDirectionProvider(\n props: WritingDirectionProviderProps\n): ReactElement {\n const { children, defaultDir = DEFAULT_WRITING_DIRECTION } = props;\n const { root } = useContext(context);\n const [dir, setDir] = useState(defaultDir);\n useEffect(() => {\n if (!root || typeof document === \"undefined\") {\n return;\n }\n\n document.documentElement.setAttribute(\"dir\", dir);\n\n return () => {\n document.documentElement.removeAttribute(\"dir\");\n };\n }, [dir, root]);\n\n const toggleDir = useCallback(() => {\n setDir((prevDir) => (prevDir === \"ltr\" ? \"rtl\" : \"ltr\"));\n }, []);\n\n const value = useMemo<InheritableContext>(\n () => ({ root: false, dir, toggleDir }),\n [dir, toggleDir]\n );\n let child = Children.only(children);\n if (!root && isValidElement<{ dir: Dir }>(child)) {\n child = cloneElement(child, { dir });\n }\n\n return <Provider value={value}>{child}</Provider>;\n}\n"],"names":["Children","cloneElement","createContext","isValidElement","useCallback","useContext","useEffect","useMemo","useState","context","root","dir","toggleDir","process","env","NODE_ENV","Error","displayName","Provider","useDir","_root","current","DEFAULT_WRITING_DIRECTION","document","rootDir","documentElement","getAttribute","WritingDirectionProvider","props","children","defaultDir","setDir","setAttribute","removeAttribute","prevDir","value","child","only"],"mappings":"AAAA;;AACA,SACEA,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QAGH,QAAQ;AA+Bf,MAAMC,wBAAUP,cAAkC;IAChDQ,MAAM;IACNC,KAAK;IACLC,WAAW;QACT,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MACR;QAEJ;IACF;AACF;AACAP,QAAQQ,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGT;AAErB;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASU;IACd,MAAM,EAAET,MAAMU,KAAK,EAAE,GAAGC,SAAS,GAAGhB,WAAWI;IAC/C,OAAOY;AACT;AAsBA;;;;;;;CAOC,GACD,OAAO,MAAMC,4BAA4B;IACvC,IAAIX,MAAW;IACf,IAAI,OAAOY,aAAa,aAAa;QACnC,MAAMC,UAAUD,SAASE,eAAe,CAACC,YAAY,CAAC;QACtDf,MAAMa,YAAY,QAAQ,QAAQ;IACpC;IAEA,OAAOb;AACT,EAAE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EC,GACD,OAAO,SAASgB,yBACdC,KAAoC;IAEpC,MAAM,EAAEC,QAAQ,EAAEC,aAAaR,yBAAyB,EAAE,GAAGM;IAC7D,MAAM,EAAElB,IAAI,EAAE,GAAGL,WAAWI;IAC5B,MAAM,CAACE,KAAKoB,OAAO,GAAGvB,SAASsB;IAC/BxB,UAAU;QACR,IAAI,CAACI,QAAQ,OAAOa,aAAa,aAAa;YAC5C;QACF;QAEAA,SAASE,eAAe,CAACO,YAAY,CAAC,OAAOrB;QAE7C,OAAO;YACLY,SAASE,eAAe,CAACQ,eAAe,CAAC;QAC3C;IACF,GAAG;QAACtB;QAAKD;KAAK;IAEd,MAAME,YAAYR,YAAY;QAC5B2B,OAAO,CAACG,UAAaA,YAAY,QAAQ,QAAQ;IACnD,GAAG,EAAE;IAEL,MAAMC,QAAQ5B,QACZ,IAAO,CAAA;YAAEG,MAAM;YAAOC;YAAKC;QAAU,CAAA,GACrC;QAACD;QAAKC;KAAU;IAElB,IAAIwB,QAAQpC,SAASqC,IAAI,CAACR;IAC1B,IAAI,CAACnB,sBAAQP,eAA6BiC,QAAQ;QAChDA,sBAAQnC,aAAamC,OAAO;YAAEzB;QAAI;IACpC;IAEA,qBAAO,KAACO;QAASiB,OAAOA;kBAAQC;;AAClC"}
1
+ {"version":3,"sources":["../../src/typography/WritingDirectionProvider.tsx"],"sourcesContent":["\"use client\";\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { type UseStateInitializer } from \"../types.js\";\n\n/**\n * Note: unlike the `dir` DOM attribute, the `\"auto\"` value is not supported.\n *\n * @since 6.0.0\n */\nexport type Dir = \"ltr\" | \"rtl\";\n\n/** @since 6.0.0 */\nexport type DefaultDir = UseStateInitializer<Dir>;\n\n/** @since 2.3.0 */\nexport interface WritingDirectionContext {\n /**\n * The current writing direction that is being inherited.\n */\n dir: Dir;\n\n /**\n * Toggles the current writing direction for the first parent `Dir` component.\n */\n toggleDir: () => void;\n}\n\n/** @internal */\ninterface InheritableContext extends WritingDirectionContext {\n root: boolean;\n}\n\nconst context = createContext<InheritableContext>({\n root: true,\n dir: \"ltr\",\n toggleDir: () => {\n if (process.env.NODE_ENV !== \"production\") {\n throw new Error(\n \"Tried to toggle the current writing direction without initializing the `Dir` component.\"\n );\n }\n },\n});\ncontext.displayName = \"WritingDirection\";\nconst { Provider } = context;\n\n/**\n * Gets the writing direction context which provides access to the current `dir`\n * and a `toggleDir` function.\n *\n * @example Manually Changing the Writing Direction\n * ```tsx\n * import { useDir } from \"@react-md/core\";\n *\n * function Example() {\n * const { dir, toggleDir } = useDir();\n *\n * return (\n * <>\n * <p>{`The current dir is: \"${dir}\"`}</p>\n * <button type=\"button\" onClick={toggleDir}>Toggle</button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useDir(): Readonly<WritingDirectionContext> {\n const { root: _root, ...current } = useContext(context);\n return current;\n}\n\n/** @since 6.0.0 */\nexport interface WritingDirectionProviderProps {\n /**\n * A single ReactElement child. If the `WritingDirection` has a parent\n * `WritingDirection`, the child will have the `dir` prop cloned into this\n * element.\n */\n children: ReactElement<{ dir?: Dir }> | ReactNode;\n\n /**\n * The default writing direction for your app or a subtree. To change the\n * current writing direction, use the `useDir` hook to get access to the\n * current `dir` and the `toggleDir` function.\n *\n * @defaultValue `\"ltr\"`\n * @see {@link DEFAULT_WRITING_DIRECTION}\n */\n defaultDir?: DefaultDir;\n}\n\n/**\n * In the browser, this will default to the `<html>`'s `dir` value if one\n * exists. If the `dir` attribute does not exist, it will default to `\"ltr\"`.\n *\n * In node environments, this will default to `\"ltr\"`.\n *\n * @since 6.0.0 Renamed from `DEFAULT_DIR`\n */\nexport const DEFAULT_WRITING_DIRECTION = (): Dir => {\n let dir: Dir = \"ltr\";\n if (typeof document !== \"undefined\") {\n const rootDir = document.documentElement.getAttribute(\"dir\");\n dir = rootDir === \"rtl\" ? \"rtl\" : \"ltr\";\n }\n\n return dir;\n};\n\n/**\n * **Client Component**\n *\n * The `WritingDirection` component is used to handle the current writing\n * direction within your app as well as conditionally updating the writing\n * direction for small sections in your app. When this component is used for the\n * first time near the root of your React component tree, the current direction\n * will be applied to the root `<html>` element. Otherwise the current dir will\n * be cloned into the child element so it can be passed as a prop.\n *\n * Note: Since the `dir` is cloned into the child element, you need to make sure\n * that the child is either a DOM element or the `dir` prop is passed from your\n * custom component.\n *\n * @example Root Setup\n * ```tsx\n * import { createRoot } from \"react-dom/client\";\n * import { WritingDirection } from \"@react-md/core\";\n * import App from \"./App.js\":\n *\n * const container = document.getElementById(\"root\");\n * const root = createRoot(container);\n *\n * root.render(\n * <WritingDirection>\n * <App />\n * </WritingDirection>\n * );\n * ```\n *\n * @example Supporting RTL Languages\n * ```tsx\n * import { createRoot } from \"react-dom/client\";\n * import { WritingDirection } from \"@react-md/core\";\n * import type { Dir } from \"@react-md/core\";\n * import App from \"./App.js\":\n *\n * const container = document.getElementById(\"root\");\n * const root = createRoot(container);\n *\n * // see https://meta.wikimedia.org/wiki/Template:List_of_language_names_ordered_by_code\n * const SUPPORTED_RTL_LANGUAGES = [\n * \"ar\",\n * \"arc\",\n * \"ckb\",\n * \"dv\",\n * \"fa\",\n * \"ha\",\n * \"he\",\n * \"khw\",\n * \"ks\",\n * \"ps\",\n * \"sd\",\n * \"ur\",\n * \"uz_AF\",\n * \"ti\",\n * ];\n *\n * const defaultDir = (): Dir => {\n * if (SUPPORTED_RTL_LANGUAGES.includes(navigator.language)) {\n * return \"rtl\"\n * }\n *\n * return \"ltr\";\n * }\n *\n * root.render(\n * <WritingDirection defaultDir={defaultDir}>\n * <App />\n * </WritingDirection>\n * );\n * ```\n *\n * @since 6.0.0 Renamed from `Dir`\n */\nexport function WritingDirectionProvider(\n props: WritingDirectionProviderProps\n): ReactElement {\n const { children, defaultDir = DEFAULT_WRITING_DIRECTION } = props;\n const { root } = useContext(context);\n const [dir, setDir] = useState(defaultDir);\n useEffect(() => {\n if (!root || typeof document === \"undefined\") {\n return;\n }\n\n document.documentElement.setAttribute(\"dir\", dir);\n\n return () => {\n document.documentElement.removeAttribute(\"dir\");\n };\n }, [dir, root]);\n\n const toggleDir = useCallback(() => {\n setDir((prevDir) => (prevDir === \"ltr\" ? \"rtl\" : \"ltr\"));\n }, []);\n\n const value = useMemo<InheritableContext>(\n () => ({ root: false, dir, toggleDir }),\n [dir, toggleDir]\n );\n let child = Children.only(children);\n if (!root && isValidElement<{ dir: Dir }>(child)) {\n child = cloneElement(child, { dir });\n }\n\n return <Provider value={value}>{child}</Provider>;\n}\n"],"names":["Children","cloneElement","createContext","isValidElement","useCallback","useContext","useEffect","useMemo","useState","context","root","dir","toggleDir","process","env","NODE_ENV","Error","displayName","Provider","useDir","_root","current","DEFAULT_WRITING_DIRECTION","document","rootDir","documentElement","getAttribute","WritingDirectionProvider","props","children","defaultDir","setDir","setAttribute","removeAttribute","prevDir","value","child","only"],"mappings":"AAAA;;AACA,SACEA,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QAGH,QAAQ;AA+Bf,MAAMC,wBAAUP,cAAkC;IAChDQ,MAAM;IACNC,KAAK;IACLC,WAAW;QACT,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MACR;QAEJ;IACF;AACF;AACAP,QAAQQ,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGT;AAErB;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASU;IACd,MAAM,EAAET,MAAMU,KAAK,EAAE,GAAGC,SAAS,GAAGhB,WAAWI;IAC/C,OAAOY;AACT;AAsBA;;;;;;;CAOC,GACD,OAAO,MAAMC,4BAA4B;IACvC,IAAIX,MAAW;IACf,IAAI,OAAOY,aAAa,aAAa;QACnC,MAAMC,UAAUD,SAASE,eAAe,CAACC,YAAY,CAAC;QACtDf,MAAMa,YAAY,QAAQ,QAAQ;IACpC;IAEA,OAAOb;AACT,EAAE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EC,GACD,OAAO,SAASgB,yBACdC,KAAoC;IAEpC,MAAM,EAAEC,QAAQ,EAAEC,aAAaR,yBAAyB,EAAE,GAAGM;IAC7D,MAAM,EAAElB,IAAI,EAAE,GAAGL,WAAWI;IAC5B,MAAM,CAACE,KAAKoB,OAAO,GAAGvB,SAASsB;IAC/BxB,UAAU;QACR,IAAI,CAACI,QAAQ,OAAOa,aAAa,aAAa;YAC5C;QACF;QAEAA,SAASE,eAAe,CAACO,YAAY,CAAC,OAAOrB;QAE7C,OAAO;YACLY,SAASE,eAAe,CAACQ,eAAe,CAAC;QAC3C;IACF,GAAG;QAACtB;QAAKD;KAAK;IAEd,MAAME,YAAYR,YAAY;QAC5B2B,OAAO,CAACG,UAAaA,YAAY,QAAQ,QAAQ;IACnD,GAAG,EAAE;IAEL,MAAMC,QAAQ5B,QACZ,IAAO,CAAA;YAAEG,MAAM;YAAOC;YAAKC;QAAU,CAAA,GACrC;QAACD;QAAKC;KAAU;IAElB,IAAIwB,QAAQpC,SAASqC,IAAI,CAACR;IAC1B,IAAI,CAACnB,sBAAQP,eAA6BiC,QAAQ;QAChDA,sBAAQnC,aAAamC,OAAO;YAAEzB;QAAI;IACpC;IAEA,qBAAO,KAACO;QAASiB,OAAOA;kBAAQC;;AAClC"}
@@ -3,43 +3,56 @@
3
3
  @use "../media-queries/media-queries";
4
4
  @use "../utils";
5
5
 
6
+ // Set this to `true` to disable the styles for the `TextContainer` component
6
7
  $disable-text-container: false !default;
8
+
9
+ // Set this to `true` to disable the `headline-1` typography styles
7
10
  $disable-headline-1: false !default;
11
+
12
+ // Set this to `true` to disable the `headline-2` typography styles
8
13
  $disable-headline-2: false !default;
14
+
15
+ // Set this to `true` to disable the `headline-3` typography styles
9
16
  $disable-headline-3: false !default;
17
+
18
+ // Set this to `true` to disable the `headline-4` typography styles
10
19
  $disable-headline-4: false !default;
20
+
21
+ // Set this to `true` to disable the `headline-5` typography styles
11
22
  $disable-headline-5: false !default;
23
+
24
+ // Set this to `true` to disable the `headline-6` typography styles
12
25
  $disable-headline-6: false !default;
26
+
27
+ // Set this to `true` to disable the `subtitle-1` typography styles
13
28
  $disable-subtitle-1: false !default;
29
+
30
+ // Set this to `true` to disable the `subtitle-2` typography styles
14
31
  $disable-subtitle-2: false !default;
32
+
33
+ // Set this to `true` to disable the `body-1` typography styles
15
34
  $disable-body-1: false !default;
35
+
36
+ // Set this to `true` to disable the `body-2` typography styles
16
37
  $disable-body-2: false !default;
38
+
39
+ // Set this to `true` to disable the `caption` typography styles
17
40
  $disable-caption: false !default;
41
+
42
+ // Set this to `true` to disable the `overline` typography styles
18
43
  $disable-overline: false !default;
19
44
 
20
- /// A small utility function to get the letter spacing based on tracking and
21
- /// font-size
22
- ///
23
- /// @access private
24
- /// @param {Number} tracking - The tracking to use
25
- /// @param {Number} font-size - The font size to use
26
- /// @return {Number} the letter spacing value in em
45
+ // A small utility function to get the letter spacing based on tracking and
46
+ // font-size
47
+ //
48
+ // @internal
49
+ // @param {number} tracking - The tracking to use
50
+ // @param {number} font-size - The font size to use
51
+ // @returns {number} the letter spacing value in em
27
52
  @function get-letter-spacing($tracking, $font-size) {
28
53
  @return math.div($tracking, $font-size * 16) * 1em;
29
54
  }
30
55
 
31
- /// The font family to use throughout the entire application.
32
- ///
33
- /// @example scss - Changing the Font
34
- /// @use "react-md" with (
35
- /// $font-family: string.unquote("'Open Sans', Koulen, 'Roboto Flex', sans-serif")
36
- /// ):
37
- ///
38
- /// @include react-md.typography;
39
- ///
40
- /// @type String
41
- $font-family: Roboto, sans-serif !default;
42
-
43
56
  $font-weight-thin: 100 !default;
44
57
  $font-weight-light: 300 !default;
45
58
  $font-weight-regular: 400 !default;
@@ -48,19 +61,19 @@ $font-weight-bold: 700 !default;
48
61
  $font-weight-semi-bold: 800 !default;
49
62
  $font-weight-black: 900 !default;
50
63
 
51
- /// A Map of all the font weights.
52
- ///
53
- /// @type Map
54
- /// @prop {Number} thin [$font-weight-thin] - The thin font weight value.
55
- /// @prop {Number} light [$font-weight-light] - The light font weight value.
56
- /// @prop {Number} regular [$font-weight-regular] - The regular font weight
57
- /// value.
58
- /// @prop {Number} medium [$font-weight-medium] - The medium font weight
59
- /// value.
60
- /// @prop {Number} bold [$font-weight-bold] - The bold font weight value.
61
- /// @prop {Number} semi-bold [$font-weight-semi-bold] - The semi-bold font
62
- /// weight value.
63
- /// @prop {Number} black [$font-weight-black] - The black font weight value.
64
+ // A Map of all the font weights.
65
+ //
66
+ // @type Map
67
+ // @prop {number} thin [$font-weight-thin] - The thin font weight value.
68
+ // @prop {number} light [$font-weight-light] - The light font weight value.
69
+ // @prop {number} regular [$font-weight-regular] - The regular font weight
70
+ // value.
71
+ // @prop {number} medium [$font-weight-medium] - The medium font weight
72
+ // value.
73
+ // @prop {number} bold [$font-weight-bold] - The bold font weight value.
74
+ // @prop {number} semi-bold [$font-weight-semi-bold] - The semi-bold font
75
+ // weight value.
76
+ // @prop {number} black [$font-weight-black] - The black font weight value.
64
77
  $font-weights: (
65
78
  thin: $font-weight-thin,
66
79
  light: $font-weight-light,
@@ -68,7 +81,7 @@ $font-weights: (
68
81
  medium: $font-weight-medium,
69
82
  bold: $font-weight-bold,
70
83
  semi-bold: $font-weight-semi-bold,
71
- black: $font-weight-black,
84
+ "black": $font-weight-black,
72
85
  ) !default;
73
86
 
74
87
  $text-alignments: left center right !default;
@@ -76,10 +89,27 @@ $text-decorations: underline overline line-through none !default;
76
89
  $text-transforms: capitalize uppercase lowercase !default;
77
90
  $font-styles: normal italic oblique !default;
78
91
 
79
- /// The base styles for typography.
80
- /// @type Map
92
+ // The font family to use throughout the entire application.
93
+ //
94
+ // @example Changing the Font
95
+ // ```scss
96
+ // @use "react-md" with (
97
+ // $font-family: string.unquote("'Open Sans', Koulen, 'Roboto Flex', sans-serif")
98
+ // ):
99
+ //
100
+ // @include react-md.typography;
101
+ // ```
102
+ //
103
+ // @type string
104
+ $font-family: Roboto, sans-serif !default;
105
+ $font-size: 1rem !default;
106
+ $font-weight: $font-weight-regular !default;
107
+ $line-height: 1.5rem !default;
108
+
109
+ // The base styles for typography.
110
+ // @type Map
81
111
  $base-recommended-font-styles: (
82
- font-family: $font-family,
112
+ font-family: var(--rmd-font-family),
83
113
  overflow: inherit,
84
114
  overflow-wrap: break-word,
85
115
  text-overflow: inherit,
@@ -248,7 +278,14 @@ $text-container-padding: 1rem !default;
248
278
  // characters + left and right padding so the text is _really_ 65ch
249
279
  $text-line-length: calc(65ch + $text-container-padding * 2) !default;
250
280
 
251
- $typography-variables: (line-length, text-container-padding);
281
+ $typography-variables: (
282
+ line-length,
283
+ text-container-padding,
284
+ font-size,
285
+ font-family,
286
+ font-weight,
287
+ line-height
288
+ );
252
289
 
253
290
  @function typography-get-var($name, $fallback: null) {
254
291
  $var: utils.get-var-name($typography-variables, $name, "typography");
@@ -382,6 +419,19 @@ $typography-variables: (line-length, text-container-padding);
382
419
  }
383
420
 
384
421
  @mixin typography-variables {
422
+ @include typography-set-var(font-family, $font-family);
423
+ @if $font-size {
424
+ @include typography-set-var(font-size, $font-size);
425
+ }
426
+
427
+ @if $font-weight {
428
+ @include typography-set-var(font-weight, $font-weight);
429
+ }
430
+
431
+ @if $line-height {
432
+ @include typography-set-var(line-height, $line-height);
433
+ }
434
+
385
435
  @if not $disable-text-container {
386
436
  @include typography-set-var(line-length, $text-line-length);
387
437
  @include typography-set-var(
@@ -391,6 +441,13 @@ $typography-variables: (line-length, text-container-padding);
391
441
  }
392
442
  }
393
443
 
444
+ @mixin typography-html-body-styles {
445
+ @include typography-use-var(font-family);
446
+ @include typography-use-var(font-size);
447
+ @include typography-use-var(font-weight);
448
+ @include typography-use-var(line-height);
449
+ }
450
+
394
451
  @mixin typography-styles($disable-layer: false) {
395
452
  @include utils.optional-layer(typography, $disable-layer) {
396
453
  @include typography-text-container-styles($disable-layer: true);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/typographyStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { cssUtils, type TextCssUtilsOptions } from \"../cssUtils.js\";\n\n/**\n * A union of all the material design provided typography styles. When used with\n * the Typography component, this will generate the correct typography className\n * to apply and determine what component to be rendered as if none was provided.\n *\n * @since 4.0.0\n */\nexport type TypographyType =\n | \"headline-1\"\n | \"headline-2\"\n | \"headline-3\"\n | \"headline-4\"\n | \"headline-5\"\n | \"headline-6\"\n | \"subtitle-1\"\n | \"subtitle-2\"\n | \"body-1\"\n | \"body-2\"\n | \"caption\"\n | \"overline\";\n\n/** @since 6.0.0 */\nexport interface TypographyClassNameOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType;\n}\n\n/** @since 6.0.0 */\nexport type NullableTypographyClassNameOptions = Omit<\n TypographyClassNameOptions,\n \"type\"\n> & {\n /**\n * When using the {@link typography} class name utility, the `type` can be set\n * to `null` to inherit font.\n *\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType | null;\n};\n\n/**\n * Get a typography class name based on different typography options. This is\n * only useful if you are unable to use the {@link Typography} component for\n * some reason.\n *\n * @example Simple Example\n * ```ts\n * import { typography } from \"@react-md/core\";\n *\n * function Example() {\n * return (\n * <>\n * <h1 className={typography({ type: \"headline-1\" })} />\n * <h2 className={typography({ type: \"headline-2\" })} />\n * <h3 className={typography({ type: \"headline-3\" })} />\n * <h4 className={typography({ type: \"headline-4\" })} />\n * <h5 className={typography({ type: \"headline-5\" })} />\n * <h6 className={typography({ type: \"headline-6\" })} />\n * <h5 className={typography({ type: \"subtitle-1\" })} />\n * <h6 className={typography({ type: \"subtitle-2\" })} />\n * <p className={typography()} />\n * <p className={typography({ type \"body-1\" })} />\n * <p className={typography({ type \"body-1\" })} />\n * <caption className={typography({ type: \"caption\" })} />\n * <span className={typography({ type: \"overline\" })} />\n * </>\n * );\n * }\n * ```\n *\n * @example Applying Additional Styles\n * ```ts\n * import { typography } from \"@react-md/core\";\n *\n * function Example() {\n * return (\n * <>\n * <h1\n * // only maintain the default margin-bottom\n * className={typography({\n * type: \"headline-1\",\n * margin: \"bottom\",\n * })}\n * />\n *\n * <h2\n * // remove all default margin\n * className={typography({\n * type: \"headline-2\",\n * margin: \"none\",\n * })}\n * />\n *\n * <h3\n * // only maintain the default margin-top\n * className={typography({\n * type: \"headline-3\",\n * margin: \"top\",\n * })}\n * />\n *\n * <p\n * // center the text, set to bold, and only maintain default margin-bottom\n * className={typography({\n * type \"subtitle-1\",\n * align: \"center\",\n * margin: \"bottom\",\n * })}\n * />\n * </>\n * );\n * }\n * ```\n *\n * @see {@link Typography}\n * @param options - An optional object of options used to create the typography\n * class name.\n * @returns a typography class name string\n * @since 6.0.0\n */\nexport function typography(\n options: NullableTypographyClassNameOptions = {}\n): string {\n const { type = \"body-1\" } = options;\n\n // using `&&` instead of `bem` since the latest version of typescript does not\n // support setting the same object key (empty string)\n return cnb(\n \"rmd-typography\",\n type && `rmd-typography--${type}`,\n cssUtils(options)\n );\n}\n"],"names":["cnb","cssUtils","typography","options","type"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,QAAkC,iBAAiB;AAiDpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EC,GACD,OAAO,SAASC,WACdC,UAA8C,CAAC,CAAC;IAEhD,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGD;IAE5B,8EAA8E;IAC9E,qDAAqD;IACrD,OAAOH,IACL,kBACAI,QAAQ,CAAC,gBAAgB,EAAEA,KAAK,CAAC,EACjCH,SAASE;AAEb"}
1
+ {"version":3,"sources":["../../src/typography/typographyStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { cssUtils, type TextCssUtilsOptions } from \"../cssUtils.js\";\n\n/**\n * A union of all the material design provided typography styles. When used with\n * the Typography component, this will generate the correct typography className\n * to apply and determine what component to be rendered as if none was provided.\n *\n * @since 4.0.0\n */\nexport type TypographyType =\n | \"headline-1\"\n | \"headline-2\"\n | \"headline-3\"\n | \"headline-4\"\n | \"headline-5\"\n | \"headline-6\"\n | \"subtitle-1\"\n | \"subtitle-2\"\n | \"body-1\"\n | \"body-2\"\n | \"caption\"\n | \"overline\";\n\n/** @since 6.0.0 */\nexport interface TypographyClassNameOptions extends TextCssUtilsOptions {\n className?: string;\n\n /**\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType;\n}\n\n/** @since 6.0.0 */\nexport type NullableTypographyClassNameOptions = Omit<\n TypographyClassNameOptions,\n \"type\"\n> & {\n /**\n * When using the {@link typography} class name utility, the `type` can be set\n * to `null` to inherit font.\n *\n * @see {@link TypographyType}\n * @defaultValue `\"body-1\"`\n */\n type?: TypographyType | null;\n};\n\n/**\n * Get a typography class name based on different typography options. This is\n * only useful if you are unable to use the {@link Typography} component for\n * some reason.\n *\n * @example Simple Example\n * ```ts\n * import { typography } from \"@react-md/core\";\n *\n * function Example() {\n * return (\n * <>\n * <h1 className={typography({ type: \"headline-1\" })} />\n * <h2 className={typography({ type: \"headline-2\" })} />\n * <h3 className={typography({ type: \"headline-3\" })} />\n * <h4 className={typography({ type: \"headline-4\" })} />\n * <h5 className={typography({ type: \"headline-5\" })} />\n * <h6 className={typography({ type: \"headline-6\" })} />\n * <h5 className={typography({ type: \"subtitle-1\" })} />\n * <h6 className={typography({ type: \"subtitle-2\" })} />\n * <p className={typography()} />\n * <p className={typography({ type \"body-1\" })} />\n * <p className={typography({ type \"body-1\" })} />\n * <caption className={typography({ type: \"caption\" })} />\n * <span className={typography({ type: \"overline\" })} />\n * </>\n * );\n * }\n * ```\n *\n * @example Applying Additional Styles\n * ```ts\n * import { typography } from \"@react-md/core\";\n *\n * function Example() {\n * return (\n * <>\n * <h1\n * // only maintain the default margin-bottom\n * className={typography({\n * type: \"headline-1\",\n * margin: \"bottom\",\n * })}\n * />\n *\n * <h2\n * // remove all default margin\n * className={typography({\n * type: \"headline-2\",\n * margin: \"none\",\n * })}\n * />\n *\n * <h3\n * // only maintain the default margin-top\n * className={typography({\n * type: \"headline-3\",\n * margin: \"top\",\n * })}\n * />\n *\n * <p\n * // center the text, set to bold, and only maintain default margin-bottom\n * className={typography({\n * type \"subtitle-1\",\n * align: \"center\",\n * margin: \"bottom\",\n * })}\n * />\n * </>\n * );\n * }\n * ```\n *\n * @see {@link Typography}\n * @param options - An optional object of options used to create the typography\n * class name.\n * @returns a typography class name string\n * @since 6.0.0\n */\nexport function typography(\n options: NullableTypographyClassNameOptions = {}\n): string {\n const { type = \"body-1\" } = options;\n\n // using `&&` instead of `bem` since the latest version of typescript does not\n // support setting the same object key (empty string)\n return cnb(\n \"rmd-typography\",\n type && `rmd-typography--${type}`,\n cssUtils(options)\n );\n}\n"],"names":["cnb","cssUtils","typography","options","type"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,QAAkC,iBAAiB;AAiDpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EC,GACD,OAAO,SAASC,WACdC,UAA8C,CAAC,CAAC;IAEhD,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGD;IAE5B,8EAA8E;IAC9E,qDAAqD;IACrD,OAAOH,IACL,kBACAI,QAAQ,CAAC,gBAAgB,EAAEA,MAAM,EACjCH,SAASE;AAEb"}
@@ -1,8 +1,4 @@
1
- import { type CancelableFunction, type AnyFunction } from "./types.js";
2
- /**
3
- * @since 6.0.0
4
- */
5
- export type DebouncedFunction<F extends AnyFunction> = CancelableFunction<(...args: Parameters<F>) => void>;
1
+ import { type AnyFunction, type DebouncedFunction } from "./types.js";
6
2
  /**
7
3
  * Creates a function that will only be called if it has not been called again
8
4
  * for X milliseconds.
@@ -94,7 +94,9 @@ import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
94
94
  funcRef.current(...args);
95
95
  }, wait);
96
96
  };
97
- debounced.cancel = ()=>window.clearTimeout(timeout.current);
97
+ debounced.cancel = ()=>{
98
+ window.clearTimeout(timeout.current);
99
+ };
98
100
  return debounced;
99
101
  }, [
100
102
  wait
@@ -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"],"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 AnyFunction, type DebouncedFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\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 = () => {\n window.clearTimeout(timeout.current);\n };\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;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;YACjBL,OAAOC,YAAY,CAACJ,QAAQE,OAAO;QACrC;QAEA,OAAOG;IACT,GAAG;QAACN;KAAK;AACX"}
@@ -5,10 +5,10 @@ import type { DragEvent } from "react";
5
5
  * instead of the `DropzoneHandlers` type.
6
6
  */
7
7
  export interface DropzoneHandlers {
8
- onDrop<E extends HTMLElement>(event: DragEvent<E>): void;
9
- onDragEnter?<E extends HTMLElement>(event: DragEvent<E>): void;
10
- onDragOver?<E extends HTMLElement>(event: DragEvent<E>): void;
11
- onDragLeave?<E extends HTMLElement>(event: DragEvent<E>): void;
8
+ onDrop: <E extends HTMLElement>(event: DragEvent<E>) => void;
9
+ onDragEnter?: <E extends HTMLElement>(event: DragEvent<E>) => void;
10
+ onDragOver?: <E extends HTMLElement>(event: DragEvent<E>) => void;
11
+ onDragLeave?: <E extends HTMLElement>(event: DragEvent<E>) => void;
12
12
  }
13
13
  /**
14
14
  * @since 6.0.0
@@ -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"],"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/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
+ {"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,GAAGC,OAAO,CAAC,EAAEC,IAAI;AACpC"}