@react-md/core 6.3.3 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/dist/CoreProviders.d.ts +1 -0
  2. package/dist/CoreProviders.js.map +1 -1
  3. package/dist/_base.scss +3 -0
  4. package/dist/_core.scss +1 -0
  5. package/dist/_utils.scss +15 -7
  6. package/dist/app-bar/AppBar.js.map +1 -1
  7. package/dist/app-bar/AppBarTitle.js.map +1 -1
  8. package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
  9. package/dist/autocomplete/types.js.map +1 -1
  10. package/dist/autocomplete/utils.js.map +1 -1
  11. package/dist/avatar/Avatar.js.map +1 -1
  12. package/dist/box/_box.scss +20 -1
  13. package/dist/box/styles.d.ts +39 -0
  14. package/dist/box/styles.js +39 -0
  15. package/dist/box/styles.js.map +1 -1
  16. package/dist/button/Button.js.map +1 -1
  17. package/dist/button/FloatingActionButton.js.map +1 -1
  18. package/dist/card/Card.js.map +1 -1
  19. package/dist/card/CardContent.js.map +1 -1
  20. package/dist/card/ClickableCard.js.map +1 -1
  21. package/dist/chip/Chip.js.map +1 -1
  22. package/dist/datetime/NativeDateField.js.map +1 -1
  23. package/dist/datetime/NativeTimeField.js.map +1 -1
  24. package/dist/datetime/useDateField.js.map +1 -1
  25. package/dist/datetime/useTimeField.js.map +1 -1
  26. package/dist/dialog/Dialog.js.map +1 -1
  27. package/dist/dialog/DialogContainer.js.map +1 -1
  28. package/dist/dialog/DialogContent.js.map +1 -1
  29. package/dist/dialog/DialogFooter.js.map +1 -1
  30. package/dist/divider/Divider.js.map +1 -1
  31. package/dist/draggable/useDraggable.js.map +1 -1
  32. package/dist/draggable/utils.js.map +1 -1
  33. package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
  34. package/dist/files/FileInput.js.map +1 -1
  35. package/dist/files/useFileUpload.js.map +1 -1
  36. package/dist/files/validation.js.map +1 -1
  37. package/dist/focus/useFocusContainer.js.map +1 -1
  38. package/dist/form/Fieldset.d.ts +19 -0
  39. package/dist/form/Fieldset.js +22 -2
  40. package/dist/form/Fieldset.js.map +1 -1
  41. package/dist/form/FormMessageContainer.js.map +1 -1
  42. package/dist/form/FormMessageCounter.js.map +1 -1
  43. package/dist/form/InputToggle.js.map +1 -1
  44. package/dist/form/Legend.d.ts +27 -5
  45. package/dist/form/Legend.js +39 -6
  46. package/dist/form/Legend.js.map +1 -1
  47. package/dist/form/Listbox.js.map +1 -1
  48. package/dist/form/ListboxProvider.js.map +1 -1
  49. package/dist/form/NativeSelect.js.map +1 -1
  50. package/dist/form/Password.js.map +1 -1
  51. package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
  52. package/dist/form/Select.js.map +1 -1
  53. package/dist/form/Slider.js.map +1 -1
  54. package/dist/form/SliderContainer.js.map +1 -1
  55. package/dist/form/SliderThumb.js.map +1 -1
  56. package/dist/form/SliderTrack.js.map +1 -1
  57. package/dist/form/SliderValueMarks.js.map +1 -1
  58. package/dist/form/Switch.js.map +1 -1
  59. package/dist/form/TextArea.js.map +1 -1
  60. package/dist/form/TextField.js.map +1 -1
  61. package/dist/form/TextFieldContainer.js.map +1 -1
  62. package/dist/form/_fieldset.scss +7 -0
  63. package/dist/form/_legend.scss +68 -0
  64. package/dist/form/_text-field.scss +39 -4
  65. package/dist/form/fieldsetStyles.d.ts +6 -1
  66. package/dist/form/fieldsetStyles.js +3 -2
  67. package/dist/form/fieldsetStyles.js.map +1 -1
  68. package/dist/form/inputToggleStyles.js.map +1 -1
  69. package/dist/form/labelStyles.d.ts +1 -1
  70. package/dist/form/labelStyles.js +1 -1
  71. package/dist/form/labelStyles.js.map +1 -1
  72. package/dist/form/legendStyles.d.ts +83 -0
  73. package/dist/form/legendStyles.js +25 -0
  74. package/dist/form/legendStyles.js.map +1 -0
  75. package/dist/form/selectUtils.js.map +1 -1
  76. package/dist/form/textFieldContainerStyles.js.map +1 -1
  77. package/dist/form/types.d.ts +28 -6
  78. package/dist/form/types.js.map +1 -1
  79. package/dist/form/useCheckboxGroup.js.map +1 -1
  80. package/dist/form/useCombobox.js.map +1 -1
  81. package/dist/form/useNumberField.js +16 -19
  82. package/dist/form/useNumberField.js.map +1 -1
  83. package/dist/form/useRangeSlider.js.map +1 -1
  84. package/dist/form/useSlider.js.map +1 -1
  85. package/dist/form/useTextField.d.ts +1 -1
  86. package/dist/form/useTextField.js.map +1 -1
  87. package/dist/hoverMode/useHoverMode.js.map +1 -1
  88. package/dist/icon/FontIcon.js.map +1 -1
  89. package/dist/icon/IconRotator.js.map +1 -1
  90. package/dist/icon/MaterialIcon.js.map +1 -1
  91. package/dist/icon/MaterialSymbol.js.map +1 -1
  92. package/dist/icon/SVGIcon.js.map +1 -1
  93. package/dist/icon/config.d.ts +0 -1
  94. package/dist/icon/config.js +10 -7
  95. package/dist/icon/config.js.map +1 -1
  96. package/dist/icon/materialConfig.js.map +1 -1
  97. package/dist/icon/styles.js.map +1 -1
  98. package/dist/interaction/UserInteractionModeProvider.js +6 -4
  99. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  100. package/dist/interaction/types.js.map +1 -1
  101. package/dist/interaction/useElementInteraction.js.map +1 -1
  102. package/dist/layout/LayoutAppBar.d.ts +6 -6
  103. package/dist/layout/LayoutAppBar.js +6 -6
  104. package/dist/layout/LayoutAppBar.js.map +1 -1
  105. package/dist/layout/LayoutNav.js.map +1 -1
  106. package/dist/layout/LayoutWindowSplitter.js.map +1 -1
  107. package/dist/layout/Main.js.map +1 -1
  108. package/dist/layout/useExpandableLayout.js +43 -0
  109. package/dist/layout/useExpandableLayout.js.map +1 -1
  110. package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
  111. package/dist/layout/useLayoutTree.js.map +1 -1
  112. package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
  113. package/dist/layout/useResizableLayout.js.map +1 -1
  114. package/dist/link/Link.js.map +1 -1
  115. package/dist/link/SkipToMainContent.js +19 -21
  116. package/dist/link/SkipToMainContent.js.map +1 -1
  117. package/dist/list/List.js.map +1 -1
  118. package/dist/list/ListItem.js.map +1 -1
  119. package/dist/list/ListItemAddon.js.map +1 -1
  120. package/dist/list/ListItemLink.js.map +1 -1
  121. package/dist/list/ListSubheader.js.map +1 -1
  122. package/dist/list/getListItemHeight.js.map +1 -1
  123. package/dist/list/listItemStyles.js.map +1 -1
  124. package/dist/list/types.js.map +1 -1
  125. package/dist/media-queries/AppSizeProvider.d.ts +2 -0
  126. package/dist/media-queries/AppSizeProvider.js +3 -2
  127. package/dist/media-queries/AppSizeProvider.js.map +1 -1
  128. package/dist/media-queries/appSize.d.ts +3 -0
  129. package/dist/media-queries/appSize.js +3 -1
  130. package/dist/media-queries/appSize.js.map +1 -1
  131. package/dist/media-queries/config.d.ts +11 -0
  132. package/dist/media-queries/config.js +26 -0
  133. package/dist/media-queries/config.js.map +1 -0
  134. package/dist/menu/DropdownMenu.js.map +1 -1
  135. package/dist/menu/Menu.js.map +1 -1
  136. package/dist/menu/MenuItemButton.js.map +1 -1
  137. package/dist/menu/MenuItemFileInput.js.map +1 -1
  138. package/dist/menu/MenuItemInputToggle.js.map +1 -1
  139. package/dist/menu/MenuItemSeparator.js.map +1 -1
  140. package/dist/menu/MenuVisibilityProvider.js.map +1 -1
  141. package/dist/menu/MenuWidget.js.map +1 -1
  142. package/dist/menu/useContextMenu.js.map +1 -1
  143. package/dist/movement/types.d.ts +28 -3
  144. package/dist/movement/types.js.map +1 -1
  145. package/dist/movement/useKeyboardMovementProvider.js +96 -47
  146. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  147. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  148. package/dist/navigation/NavItem.js.map +1 -1
  149. package/dist/navigation/NavItemButton.js.map +1 -1
  150. package/dist/navigation/NavItemLink.js.map +1 -1
  151. package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
  152. package/dist/navigation/types.js.map +1 -1
  153. package/dist/overlay/Overlay.js.map +1 -1
  154. package/dist/positioning/createHorizontalPosition.js.map +1 -1
  155. package/dist/positioning/createVerticalPosition.js.map +1 -1
  156. package/dist/positioning/useFixedPositioning.js.map +1 -1
  157. package/dist/progress/CircularProgress.js.map +1 -1
  158. package/dist/progress/LinearProgress.js.map +1 -1
  159. package/dist/progress/linearProgressStyles.js.map +1 -1
  160. package/dist/responsive-item/ResponsiveItem.js.map +1 -1
  161. package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
  162. package/dist/searching/caseInsensitive.js.map +1 -1
  163. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  164. package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
  165. package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
  166. package/dist/sheet/Sheet.js.map +1 -1
  167. package/dist/snackbar/Toast.js.map +1 -1
  168. package/dist/spinbutton/SpinButton.d.ts +16 -0
  169. package/dist/spinbutton/SpinButton.js +55 -0
  170. package/dist/spinbutton/SpinButton.js.map +1 -0
  171. package/dist/spinbutton/SpinButtonGroupProvider.d.ts +17 -0
  172. package/dist/spinbutton/SpinButtonGroupProvider.js +19 -0
  173. package/dist/spinbutton/SpinButtonGroupProvider.js.map +1 -0
  174. package/dist/spinbutton/defaults.d.ts +9 -0
  175. package/dist/spinbutton/defaults.js +25 -0
  176. package/dist/spinbutton/defaults.js.map +1 -0
  177. package/dist/spinbutton/types.d.ts +324 -0
  178. package/dist/spinbutton/types.js +5 -0
  179. package/dist/spinbutton/types.js.map +1 -0
  180. package/dist/spinbutton/useSpinButton.d.ts +5 -0
  181. package/dist/spinbutton/useSpinButton.js +260 -0
  182. package/dist/spinbutton/useSpinButton.js.map +1 -0
  183. package/dist/spinbutton/useSpinButtonGroupProvider.d.ts +27 -0
  184. package/dist/spinbutton/useSpinButtonGroupProvider.js +49 -0
  185. package/dist/spinbutton/useSpinButtonGroupProvider.js.map +1 -0
  186. package/dist/spinbutton/utils/deselectNode.d.ts +5 -0
  187. package/dist/spinbutton/utils/deselectNode.js +17 -0
  188. package/dist/spinbutton/utils/deselectNode.js.map +1 -0
  189. package/dist/spinbutton/utils/resolveInputEvent.d.ts +30 -0
  190. package/dist/spinbutton/utils/resolveInputEvent.js +53 -0
  191. package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -0
  192. package/dist/spinbutton/utils/selectNode.d.ts +5 -0
  193. package/dist/spinbutton/utils/selectNode.js +15 -0
  194. package/dist/spinbutton/utils/selectNode.js.map +1 -0
  195. package/dist/table/StickyTableSection.js.map +1 -1
  196. package/dist/table/Table.js.map +1 -1
  197. package/dist/table/TableBody.js.map +1 -1
  198. package/dist/table/TableCellContent.js.map +1 -1
  199. package/dist/table/TableCheckbox.js.map +1 -1
  200. package/dist/table/TableFooter.js.map +1 -1
  201. package/dist/table/TableHeader.js.map +1 -1
  202. package/dist/table/TableRadio.js.map +1 -1
  203. package/dist/table/TableRow.js.map +1 -1
  204. package/dist/table/useStickyTableSection.js.map +1 -1
  205. package/dist/tabs/SimpleTabPanel.js.map +1 -1
  206. package/dist/tabs/SimpleTabPanels.js.map +1 -1
  207. package/dist/tabs/Tab.js.map +1 -1
  208. package/dist/tabs/TabList.js.map +1 -1
  209. package/dist/tabs/TabListScrollButton.js.map +1 -1
  210. package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
  211. package/dist/test-utils/data-testid.js.map +1 -1
  212. package/dist/test-utils/mocks/match-media.js +5 -5
  213. package/dist/test-utils/mocks/match-media.js.map +1 -1
  214. package/dist/test-utils/vitest/timers.d.ts +1 -1
  215. package/dist/test-utils/vitest/timers.js +1 -1
  216. package/dist/test-utils/vitest/timers.js.map +1 -1
  217. package/dist/tooltip/Tooltip.js.map +1 -1
  218. package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
  219. package/dist/tooltip/useTooltip.js.map +1 -1
  220. package/dist/transition/CSSTransition.js.map +1 -1
  221. package/dist/transition/Collapse.js.map +1 -1
  222. package/dist/transition/CrossFade.js.map +1 -1
  223. package/dist/transition/ScaleTransition.js.map +1 -1
  224. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  225. package/dist/transition/Slide.js.map +1 -1
  226. package/dist/transition/SlideContainer.js.map +1 -1
  227. package/dist/transition/types.js.map +1 -1
  228. package/dist/transition/useCollapseTransition.js.map +1 -1
  229. package/dist/transition/useCrossFadeTransition.js.map +1 -1
  230. package/dist/transition/useMaxWidthTransition.js.map +1 -1
  231. package/dist/transition/useScaleTransition.js.map +1 -1
  232. package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
  233. package/dist/tree/Tree.js.map +1 -1
  234. package/dist/tree/TreeItem.js.map +1 -1
  235. package/dist/tree/TreeProvider.js.map +1 -1
  236. package/dist/tree/styles.js.map +1 -1
  237. package/dist/tree/types.js.map +1 -1
  238. package/dist/tree/useTreeMovement.js.map +1 -1
  239. package/dist/typography/HighlightTextMark.js.map +1 -1
  240. package/dist/typography/Mark.js.map +1 -1
  241. package/dist/typography/TextContainer.js.map +1 -1
  242. package/dist/typography/Typography.js.map +1 -1
  243. package/dist/typography/_typography.scss +0 -1
  244. package/dist/useElementSize.js.map +1 -1
  245. package/dist/useIntersectionObserver.js.map +1 -1
  246. package/dist/useMutationObserver.js.map +1 -1
  247. package/dist/useWindowSize.js.map +1 -1
  248. package/dist/utils/getNumberOfDigits.d.ts +7 -0
  249. package/dist/utils/getNumberOfDigits.js +11 -0
  250. package/dist/utils/getNumberOfDigits.js.map +1 -0
  251. package/dist/utils/nearest.js +2 -1
  252. package/dist/utils/nearest.js.map +1 -1
  253. package/dist/utils/useDevEffect.d.ts +7 -0
  254. package/dist/utils/useDevEffect.js +8 -0
  255. package/dist/utils/useDevEffect.js.map +1 -0
  256. package/dist/window-splitter/WindowSplitter.js +3 -2
  257. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  258. package/dist/window-splitter/_window-splitter.scss +60 -12
  259. package/dist/window-splitter/styles.d.ts +9 -0
  260. package/dist/window-splitter/styles.js +3 -2
  261. package/dist/window-splitter/styles.js.map +1 -1
  262. package/dist/window-splitter/useWindowSplitter.js.map +1 -1
  263. package/package.json +38 -30
  264. package/src/CoreProviders.tsx +1 -0
  265. package/src/app-bar/AppBar.tsx +1 -2
  266. package/src/app-bar/AppBarTitle.tsx +1 -2
  267. package/src/autocomplete/AutocompleteListboxChildren.tsx +3 -1
  268. package/src/autocomplete/types.ts +24 -19
  269. package/src/autocomplete/utils.ts +9 -6
  270. package/src/avatar/Avatar.tsx +2 -1
  271. package/src/box/styles.ts +39 -0
  272. package/src/button/Button.tsx +2 -1
  273. package/src/button/FloatingActionButton.tsx +2 -1
  274. package/src/card/Card.tsx +2 -1
  275. package/src/card/CardContent.tsx +1 -2
  276. package/src/card/ClickableCard.tsx +1 -2
  277. package/src/chip/Chip.tsx +2 -1
  278. package/src/datetime/NativeDateField.tsx +2 -1
  279. package/src/datetime/NativeTimeField.tsx +2 -1
  280. package/src/datetime/useDateField.ts +13 -8
  281. package/src/datetime/useTimeField.ts +13 -8
  282. package/src/dialog/Dialog.tsx +2 -1
  283. package/src/dialog/DialogContainer.tsx +1 -2
  284. package/src/dialog/DialogContent.tsx +1 -2
  285. package/src/dialog/DialogFooter.tsx +1 -2
  286. package/src/divider/Divider.tsx +1 -2
  287. package/src/draggable/useDraggable.ts +4 -4
  288. package/src/draggable/utils.ts +4 -2
  289. package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -2
  290. package/src/files/FileInput.tsx +2 -1
  291. package/src/files/useFileUpload.ts +6 -6
  292. package/src/files/validation.ts +1 -2
  293. package/src/focus/useFocusContainer.ts +4 -4
  294. package/src/form/Fieldset.tsx +25 -3
  295. package/src/form/FormMessageContainer.tsx +1 -2
  296. package/src/form/FormMessageCounter.tsx +1 -2
  297. package/src/form/InputToggle.tsx +3 -3
  298. package/src/form/Legend.tsx +55 -10
  299. package/src/form/Listbox.tsx +1 -2
  300. package/src/form/ListboxProvider.ts +3 -2
  301. package/src/form/NativeSelect.tsx +2 -1
  302. package/src/form/Password.tsx +4 -2
  303. package/src/form/ResizingTextAreaWrapper.tsx +1 -2
  304. package/src/form/Select.tsx +2 -1
  305. package/src/form/Slider.tsx +2 -1
  306. package/src/form/SliderContainer.tsx +1 -2
  307. package/src/form/SliderThumb.tsx +6 -3
  308. package/src/form/SliderTrack.tsx +2 -1
  309. package/src/form/SliderValueMarks.tsx +1 -2
  310. package/src/form/Switch.tsx +2 -1
  311. package/src/form/TextArea.tsx +1 -2
  312. package/src/form/TextField.tsx +2 -1
  313. package/src/form/TextFieldContainer.tsx +1 -2
  314. package/src/form/fieldsetStyles.ts +18 -3
  315. package/src/form/inputToggleStyles.ts +4 -2
  316. package/src/form/labelStyles.ts +1 -1
  317. package/src/form/legendStyles.ts +132 -0
  318. package/src/form/selectUtils.ts +3 -2
  319. package/src/form/textFieldContainerStyles.ts +1 -2
  320. package/src/form/types.ts +35 -17
  321. package/src/form/useCheckboxGroup.ts +3 -2
  322. package/src/form/useCombobox.ts +8 -3
  323. package/src/form/useNumberField.ts +36 -35
  324. package/src/form/useRangeSlider.ts +1 -2
  325. package/src/form/useSlider.ts +1 -2
  326. package/src/form/useTextField.ts +9 -4
  327. package/src/hoverMode/useHoverMode.ts +4 -8
  328. package/src/icon/FontIcon.tsx +1 -2
  329. package/src/icon/IconRotator.tsx +1 -2
  330. package/src/icon/MaterialIcon.tsx +2 -1
  331. package/src/icon/MaterialSymbol.tsx +2 -1
  332. package/src/icon/SVGIcon.tsx +1 -2
  333. package/src/icon/config.tsx +10 -7
  334. package/src/icon/materialConfig.ts +1 -2
  335. package/src/icon/styles.ts +1 -2
  336. package/src/interaction/UserInteractionModeProvider.tsx +9 -4
  337. package/src/interaction/types.ts +1 -2
  338. package/src/interaction/useElementInteraction.tsx +3 -2
  339. package/src/layout/LayoutAppBar.tsx +6 -6
  340. package/src/layout/LayoutNav.tsx +2 -1
  341. package/src/layout/LayoutWindowSplitter.tsx +2 -1
  342. package/src/layout/Main.tsx +1 -2
  343. package/src/layout/useExpandableLayout.ts +63 -5
  344. package/src/layout/useHorizontalLayoutTransition.ts +1 -2
  345. package/src/layout/useLayoutTree.ts +2 -2
  346. package/src/layout/useLayoutWindowSplitter.ts +6 -6
  347. package/src/layout/useResizableLayout.ts +3 -6
  348. package/src/link/Link.tsx +1 -2
  349. package/src/link/SkipToMainContent.tsx +20 -23
  350. package/src/list/List.tsx +1 -2
  351. package/src/list/ListItem.tsx +2 -1
  352. package/src/list/ListItemAddon.tsx +2 -1
  353. package/src/list/ListItemLink.tsx +2 -1
  354. package/src/list/ListSubheader.tsx +1 -2
  355. package/src/list/getListItemHeight.ts +8 -9
  356. package/src/list/listItemStyles.ts +1 -2
  357. package/src/list/types.ts +1 -2
  358. package/src/media-queries/AppSizeProvider.tsx +8 -10
  359. package/src/media-queries/appSize.ts +3 -0
  360. package/src/media-queries/config.ts +41 -0
  361. package/src/menu/DropdownMenu.tsx +4 -5
  362. package/src/menu/Menu.tsx +2 -1
  363. package/src/menu/MenuItemButton.tsx +1 -2
  364. package/src/menu/MenuItemFileInput.tsx +2 -1
  365. package/src/menu/MenuItemInputToggle.tsx +3 -3
  366. package/src/menu/MenuItemSeparator.tsx +2 -1
  367. package/src/menu/MenuVisibilityProvider.tsx +4 -2
  368. package/src/menu/MenuWidget.tsx +1 -2
  369. package/src/menu/useContextMenu.ts +4 -2
  370. package/src/movement/types.ts +52 -13
  371. package/src/movement/useKeyboardMovementProvider.ts +77 -38
  372. package/src/navigation/CollapsibleNavGroup.tsx +1 -2
  373. package/src/navigation/NavItem.tsx +1 -2
  374. package/src/navigation/NavItemButton.tsx +2 -1
  375. package/src/navigation/NavItemLink.tsx +2 -1
  376. package/src/navigation/getTableOfContentsHeadings.ts +1 -2
  377. package/src/navigation/types.ts +1 -2
  378. package/src/overlay/Overlay.tsx +2 -1
  379. package/src/positioning/createHorizontalPosition.ts +10 -12
  380. package/src/positioning/createVerticalPosition.ts +10 -11
  381. package/src/positioning/useFixedPositioning.ts +6 -3
  382. package/src/progress/CircularProgress.tsx +2 -1
  383. package/src/progress/LinearProgress.tsx +2 -1
  384. package/src/progress/linearProgressStyles.ts +1 -2
  385. package/src/responsive-item/ResponsiveItem.tsx +1 -2
  386. package/src/responsive-item/ResponsiveItemOverlay.tsx +2 -1
  387. package/src/searching/caseInsensitive.ts +2 -4
  388. package/src/segmented-button/SegmentedButton.tsx +2 -1
  389. package/src/segmented-button/SegmentedButtonContainer.tsx +2 -1
  390. package/src/segmented-button/segmentedButtonStyles.ts +1 -2
  391. package/src/sheet/Sheet.tsx +1 -2
  392. package/src/snackbar/Toast.tsx +2 -1
  393. package/src/spinbutton/SpinButton.tsx +98 -0
  394. package/src/spinbutton/SpinButtonGroupProvider.tsx +32 -0
  395. package/src/spinbutton/defaults.ts +45 -0
  396. package/src/spinbutton/types.ts +413 -0
  397. package/src/spinbutton/useSpinButton.ts +311 -0
  398. package/src/spinbutton/useSpinButtonGroupProvider.ts +104 -0
  399. package/src/spinbutton/utils/deselectNode.ts +17 -0
  400. package/src/spinbutton/utils/resolveInputEvent.ts +112 -0
  401. package/src/spinbutton/utils/selectNode.ts +15 -0
  402. package/src/table/StickyTableSection.tsx +2 -1
  403. package/src/table/Table.tsx +1 -2
  404. package/src/table/TableBody.tsx +2 -1
  405. package/src/table/TableCellContent.tsx +1 -2
  406. package/src/table/TableCheckbox.tsx +1 -2
  407. package/src/table/TableFooter.tsx +1 -2
  408. package/src/table/TableHeader.tsx +1 -2
  409. package/src/table/TableRadio.tsx +1 -2
  410. package/src/table/TableRow.tsx +1 -2
  411. package/src/table/useStickyTableSection.tsx +1 -2
  412. package/src/tabs/SimpleTabPanel.tsx +2 -1
  413. package/src/tabs/SimpleTabPanels.tsx +2 -1
  414. package/src/tabs/Tab.tsx +3 -6
  415. package/src/tabs/TabList.tsx +2 -1
  416. package/src/tabs/TabListScrollButton.tsx +1 -2
  417. package/src/tabs/useMaxTabPanelHeight.ts +7 -4
  418. package/src/test-utils/data-testid.ts +1 -2
  419. package/src/test-utils/mocks/match-media.ts +5 -10
  420. package/src/test-utils/vitest/timers.ts +1 -1
  421. package/src/tooltip/Tooltip.tsx +2 -1
  422. package/src/tooltip/TooltipHoverModeProvider.tsx +1 -2
  423. package/src/tooltip/useTooltip.ts +9 -5
  424. package/src/transition/CSSTransition.tsx +2 -1
  425. package/src/transition/Collapse.tsx +4 -2
  426. package/src/transition/CrossFade.tsx +2 -1
  427. package/src/transition/ScaleTransition.tsx +2 -1
  428. package/src/transition/SkeletonPlaceholder.tsx +1 -2
  429. package/src/transition/Slide.tsx +2 -1
  430. package/src/transition/SlideContainer.tsx +1 -2
  431. package/src/transition/types.ts +15 -16
  432. package/src/transition/useCollapseTransition.ts +6 -5
  433. package/src/transition/useCrossFadeTransition.ts +3 -2
  434. package/src/transition/useMaxWidthTransition.ts +1 -2
  435. package/src/transition/useScaleTransition.ts +3 -2
  436. package/src/transition/useSkeletonPlaceholder.ts +1 -2
  437. package/src/tree/Tree.tsx +2 -1
  438. package/src/tree/TreeItem.tsx +2 -1
  439. package/src/tree/TreeProvider.tsx +4 -4
  440. package/src/tree/styles.ts +1 -2
  441. package/src/tree/types.ts +1 -2
  442. package/src/tree/useTreeMovement.ts +1 -2
  443. package/src/typography/HighlightTextMark.tsx +1 -2
  444. package/src/typography/Mark.tsx +1 -2
  445. package/src/typography/TextContainer.tsx +1 -2
  446. package/src/typography/Typography.tsx +1 -2
  447. package/src/useElementSize.ts +7 -4
  448. package/src/useIntersectionObserver.ts +3 -2
  449. package/src/useMutationObserver.ts +3 -2
  450. package/src/useWindowSize.ts +4 -2
  451. package/src/utils/getNumberOfDigits.ts +18 -0
  452. package/src/utils/nearest.ts +2 -1
  453. package/src/utils/useDevEffect.ts +9 -0
  454. package/src/window-splitter/WindowSplitter.tsx +5 -2
  455. package/src/window-splitter/styles.ts +13 -2
  456. package/src/window-splitter/useWindowSplitter.ts +3 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tree/useTreeMovement.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n FocusEventHandler,\n KeyboardEventHandler,\n MouseEventHandler,\n Ref,\n} from \"react\";\nimport { useRef } from \"react\";\n\nimport type { KeyboardMovementProviderImplementation } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { getNextFocusableIndex } from \"../movement/utils.js\";\nimport type { NonNullMutableRef } from \"../types.js\";\nimport type { TreeItemMetadataLookup } from \"./TreeProvider.js\";\nimport type { TreeData, TreeItemNode } from \"./types.js\";\nimport type { TreeExpansion } from \"./useTreeExpansion.js\";\nimport type { TreeItemChildIds } from \"./useTreeItems.js\";\n\n/**\n * This helps catch the edge case where the collapse transition has occurred for\n * a tree item group, but the user uses the `ArrowDown` key before it has\n * finished. So to do this:\n *\n * - find the parent group of the tree item\n * - find the tree item that controls the group (the element before the group)\n * - check if the `aria-expanded` state is `\"false\"` meaning it is considered\n * closed\n *\n * @internal\n * @since 6.0.0\n */\nconst isParentItemCollapsing = (item: HTMLElement): boolean =>\n item\n .closest(\"[role='group']\")\n ?.previousElementSibling?.getAttribute(\"aria-expanded\") === \"false\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nconst getVisibleTreeItems = (\n container: HTMLElement\n): readonly HTMLElement[] => {\n const items = [\n ...container.querySelectorAll<HTMLElement>('[role=\"treeitem\"]'),\n ];\n\n return items.filter(\n (item) =>\n // do not include items that have a `hidden` parent group\n item.offsetParent &&\n // do not include items that are about to become hidden\n !isParentItemCollapsing(item)\n );\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovementOptions<T extends TreeItemNode> extends TreeExpansion {\n ref?: Ref<HTMLUListElement>;\n data: TreeData<T>;\n onClick: MouseEventHandler<HTMLUListElement> | undefined;\n onFocus: FocusEventHandler<HTMLUListElement> | undefined;\n onKeyDown: KeyboardEventHandler<HTMLUListElement> | undefined;\n selectedIds: ReadonlySet<string>;\n treeItemChildIds: TreeItemChildIds;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovement\n extends KeyboardMovementProviderImplementation<HTMLUListElement> {\n /**\n * This will be mutated by the `TreeItem` component and used to handle\n * keyboard movement.\n */\n metadataLookup: NonNullMutableRef<TreeItemMetadataLookup>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useTreeMovement<T extends TreeItemNode>(\n options: TreeMovementOptions<T>\n): TreeMovement {\n const {\n ref,\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n } = options;\n\n const metadataLookup = useRef<TreeItemMetadataLookup>({\n expandable: {},\n disabledItems: {},\n elementToItem: {},\n itemToElement: {},\n });\n const movement = useKeyboardMovementProvider({\n ref,\n onClick,\n onFocus,\n onKeyDown,\n extendKeyDown(movementData) {\n const { event, activeDescendantId, currentFocusIndex, setFocusIndex } =\n movementData;\n const { expandable, disabledItems, elementToItem, itemToElement } =\n metadataLookup.current;\n const itemId = elementToItem[activeDescendantId];\n const item = data[itemId];\n\n /* c8 ignore start */\n if (!item) {\n return;\n }\n /* c8 ignore stop */\n\n const disabled = disabledItems[itemId];\n const expanded = expandedIds.has(itemId);\n\n let flagged = false;\n switch (event.key) {\n case \"ArrowLeft\":\n if (expanded && !disabled) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else if (item.parentId) {\n // do not flag for this case since setFocusIndex already does this\n const parentId = itemToElement[item.parentId];\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = focusables.findIndex(\n (element) => element.id === parentId\n );\n setFocusIndex(index, focusables);\n }\n\n break;\n case \"ArrowRight\":\n if (expandable[itemId] && !disabled) {\n if (!expanded) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else {\n // do not flag for this case since setFocusIndex already does this\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = getNextFocusableIndex({\n loopable: false,\n increment: true,\n focusables,\n includeDisabled: true,\n currentFocusIndex: currentFocusIndex.current,\n });\n\n setFocusIndex(index, focusables);\n }\n }\n\n break;\n case \"*\": {\n flagged = true;\n const itemIds = treeItemChildIds.get(item.parentId);\n if (itemIds) {\n const expandableIds = [...itemIds].filter(\n (itemId) => expandable[itemId]\n );\n if (expandableIds.length) {\n expandMultipleTreeItems(\n (prev) => new Set([...prev, ...expandableIds])\n );\n currentFocusIndex.current = -1;\n }\n }\n break;\n }\n }\n\n if (flagged) {\n event.stopPropagation();\n event.preventDefault();\n }\n },\n searchable: true,\n tabIndexBehavior: \"virtual\",\n getFocusableElements: getVisibleTreeItems,\n getDefaultFocusedIndex(options) {\n const { focusables } = options;\n const { elementToItem } = metadataLookup.current;\n\n return focusables.findIndex((element) =>\n selectedIds.has(elementToItem[element.id])\n );\n },\n });\n\n return {\n metadataLookup,\n ...movement,\n };\n}\n"],"names":["useRef","useKeyboardMovementProvider","getNextFocusableIndex","isParentItemCollapsing","item","closest","previousElementSibling","getAttribute","getVisibleTreeItems","container","items","querySelectorAll","filter","offsetParent","useTreeMovement","options","ref","onClick","onFocus","onKeyDown","data","expandedIds","selectedIds","treeItemChildIds","toggleTreeItemExpansion","expandMultipleTreeItems","metadataLookup","expandable","disabledItems","elementToItem","itemToElement","movement","extendKeyDown","movementData","event","activeDescendantId","currentFocusIndex","setFocusIndex","current","itemId","disabled","expanded","has","flagged","key","parentId","focusables","currentTarget","index","findIndex","element","id","loopable","increment","includeDisabled","itemIds","get","expandableIds","length","prev","Set","stopPropagation","preventDefault","searchable","tabIndexBehavior","getFocusableElements","getDefaultFocusedIndex"],"mappings":"AAAA;AAQA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,2BAA2B,QAAQ,6CAA6C;AACzF,SAASC,qBAAqB,QAAQ,uBAAuB;AAO7D;;;;;;;;;;;;CAYC,GACD,MAAMC,yBAAyB,CAACC,OAC9BA,KACGC,OAAO,CAAC,mBACPC,wBAAwBC,aAAa,qBAAqB;AAEhE;;;CAGC,GACD,MAAMC,sBAAsB,CAC1BC;IAEA,MAAMC,QAAQ;WACTD,UAAUE,gBAAgB,CAAc;KAC5C;IAED,OAAOD,MAAME,MAAM,CACjB,CAACR,OACC,yDAAyD;QACzDA,KAAKS,YAAY,IACjB,uDAAuD;QACvD,CAACV,uBAAuBC;AAE9B;AA6BA;;;CAGC,GACD,OAAO,SAASU,gBACdC,OAA+B;IAE/B,MAAM,EACJC,GAAG,EACHC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACxB,GAAGV;IAEJ,MAAMW,iBAAiB1B,OAA+B;QACpD2B,YAAY,CAAC;QACbC,eAAe,CAAC;QAChBC,eAAe,CAAC;QAChBC,eAAe,CAAC;IAClB;IACA,MAAMC,WAAW9B,4BAA4B;QAC3Ce;QACAC;QACAC;QACAC;QACAa,eAAcC,YAAY;YACxB,MAAM,EAAEC,KAAK,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,aAAa,EAAE,GACnEJ;YACF,MAAM,EAAEN,UAAU,EAAEC,aAAa,EAAEC,aAAa,EAAEC,aAAa,EAAE,GAC/DJ,eAAeY,OAAO;YACxB,MAAMC,SAASV,aAAa,CAACM,mBAAmB;YAChD,MAAM/B,OAAOgB,IAAI,CAACmB,OAAO;YAEzB,mBAAmB,GACnB,IAAI,CAACnC,MAAM;gBACT;YACF;YACA,kBAAkB,GAElB,MAAMoC,WAAWZ,aAAa,CAACW,OAAO;YACtC,MAAME,WAAWpB,YAAYqB,GAAG,CAACH;YAEjC,IAAII,UAAU;YACd,OAAQT,MAAMU,GAAG;gBACf,KAAK;oBACH,IAAIH,YAAY,CAACD,UAAU;wBACzBG,UAAU;wBACVnB,wBAAwBe;oBAC1B,OAAO,IAAInC,KAAKyC,QAAQ,EAAE;wBACxB,kEAAkE;wBAClE,MAAMA,WAAWf,aAAa,CAAC1B,KAAKyC,QAAQ,CAAC;wBAC7C,MAAMC,aAAatC,oBAAoB0B,MAAMa,aAAa;wBAC1D,MAAMC,QAAQF,WAAWG,SAAS,CAChC,CAACC,UAAYA,QAAQC,EAAE,KAAKN;wBAE9BR,cAAcW,OAAOF;oBACvB;oBAEA;gBACF,KAAK;oBACH,IAAInB,UAAU,CAACY,OAAO,IAAI,CAACC,UAAU;wBACnC,IAAI,CAACC,UAAU;4BACbE,UAAU;4BACVnB,wBAAwBe;wBAC1B,OAAO;4BACL,kEAAkE;4BAClE,MAAMO,aAAatC,oBAAoB0B,MAAMa,aAAa;4BAC1D,MAAMC,QAAQ9C,sBAAsB;gCAClCkD,UAAU;gCACVC,WAAW;gCACXP;gCACAQ,iBAAiB;gCACjBlB,mBAAmBA,kBAAkBE,OAAO;4BAC9C;4BAEAD,cAAcW,OAAOF;wBACvB;oBACF;oBAEA;gBACF,KAAK;oBAAK;wBACRH,UAAU;wBACV,MAAMY,UAAUhC,iBAAiBiC,GAAG,CAACpD,KAAKyC,QAAQ;wBAClD,IAAIU,SAAS;4BACX,MAAME,gBAAgB;mCAAIF;6BAAQ,CAAC3C,MAAM,CACvC,CAAC2B,SAAWZ,UAAU,CAACY,OAAO;4BAEhC,IAAIkB,cAAcC,MAAM,EAAE;gCACxBjC,wBACE,CAACkC,OAAS,IAAIC,IAAI;2CAAID;2CAASF;qCAAc;gCAE/CrB,kBAAkBE,OAAO,GAAG,CAAC;4BAC/B;wBACF;wBACA;oBACF;YACF;YAEA,IAAIK,SAAS;gBACXT,MAAM2B,eAAe;gBACrB3B,MAAM4B,cAAc;YACtB;QACF;QACAC,YAAY;QACZC,kBAAkB;QAClBC,sBAAsBzD;QACtB0D,wBAAuBnD,OAAO;YAC5B,MAAM,EAAE+B,UAAU,EAAE,GAAG/B;YACvB,MAAM,EAAEc,aAAa,EAAE,GAAGH,eAAeY,OAAO;YAEhD,OAAOQ,WAAWG,SAAS,CAAC,CAACC,UAC3B5B,YAAYoB,GAAG,CAACb,aAAa,CAACqB,QAAQC,EAAE,CAAC;QAE7C;IACF;IAEA,OAAO;QACLzB;QACA,GAAGK,QAAQ;IACb;AACF"}
1
+ {"version":3,"sources":["../../src/tree/useTreeMovement.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n FocusEventHandler,\n KeyboardEventHandler,\n MouseEventHandler,\n Ref,\n} from \"react\";\nimport { useRef } from \"react\";\n\nimport type { KeyboardMovementProviderImplementation } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { getNextFocusableIndex } from \"../movement/utils.js\";\nimport type { NonNullMutableRef } from \"../types.js\";\nimport type { TreeItemMetadataLookup } from \"./TreeProvider.js\";\nimport type { TreeData, TreeItemNode } from \"./types.js\";\nimport type { TreeExpansion } from \"./useTreeExpansion.js\";\nimport type { TreeItemChildIds } from \"./useTreeItems.js\";\n\n/**\n * This helps catch the edge case where the collapse transition has occurred for\n * a tree item group, but the user uses the `ArrowDown` key before it has\n * finished. So to do this:\n *\n * - find the parent group of the tree item\n * - find the tree item that controls the group (the element before the group)\n * - check if the `aria-expanded` state is `\"false\"` meaning it is considered\n * closed\n *\n * @internal\n * @since 6.0.0\n */\nconst isParentItemCollapsing = (item: HTMLElement): boolean =>\n item\n .closest(\"[role='group']\")\n ?.previousElementSibling?.getAttribute(\"aria-expanded\") === \"false\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nconst getVisibleTreeItems = (\n container: HTMLElement\n): readonly HTMLElement[] => {\n const items = [\n ...container.querySelectorAll<HTMLElement>('[role=\"treeitem\"]'),\n ];\n\n return items.filter(\n (item) =>\n // do not include items that have a `hidden` parent group\n item.offsetParent &&\n // do not include items that are about to become hidden\n !isParentItemCollapsing(item)\n );\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovementOptions<T extends TreeItemNode> extends TreeExpansion {\n ref?: Ref<HTMLUListElement>;\n data: TreeData<T>;\n onClick: MouseEventHandler<HTMLUListElement> | undefined;\n onFocus: FocusEventHandler<HTMLUListElement> | undefined;\n onKeyDown: KeyboardEventHandler<HTMLUListElement> | undefined;\n selectedIds: ReadonlySet<string>;\n treeItemChildIds: TreeItemChildIds;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface TreeMovement extends KeyboardMovementProviderImplementation<HTMLUListElement> {\n /**\n * This will be mutated by the `TreeItem` component and used to handle\n * keyboard movement.\n */\n metadataLookup: NonNullMutableRef<TreeItemMetadataLookup>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function useTreeMovement<T extends TreeItemNode>(\n options: TreeMovementOptions<T>\n): TreeMovement {\n const {\n ref,\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n } = options;\n\n const metadataLookup = useRef<TreeItemMetadataLookup>({\n expandable: {},\n disabledItems: {},\n elementToItem: {},\n itemToElement: {},\n });\n const movement = useKeyboardMovementProvider({\n ref,\n onClick,\n onFocus,\n onKeyDown,\n extendKeyDown(movementData) {\n const { event, activeDescendantId, currentFocusIndex, setFocusIndex } =\n movementData;\n const { expandable, disabledItems, elementToItem, itemToElement } =\n metadataLookup.current;\n const itemId = elementToItem[activeDescendantId];\n const item = data[itemId];\n\n /* c8 ignore start */\n if (!item) {\n return;\n }\n /* c8 ignore stop */\n\n const disabled = disabledItems[itemId];\n const expanded = expandedIds.has(itemId);\n\n let flagged = false;\n switch (event.key) {\n case \"ArrowLeft\":\n if (expanded && !disabled) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else if (item.parentId) {\n // do not flag for this case since setFocusIndex already does this\n const parentId = itemToElement[item.parentId];\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = focusables.findIndex(\n (element) => element.id === parentId\n );\n setFocusIndex(index, focusables);\n }\n\n break;\n case \"ArrowRight\":\n if (expandable[itemId] && !disabled) {\n if (!expanded) {\n flagged = true;\n toggleTreeItemExpansion(itemId);\n } else {\n // do not flag for this case since setFocusIndex already does this\n const focusables = getVisibleTreeItems(event.currentTarget);\n const index = getNextFocusableIndex({\n loopable: false,\n increment: true,\n focusables,\n includeDisabled: true,\n currentFocusIndex: currentFocusIndex.current,\n });\n\n setFocusIndex(index, focusables);\n }\n }\n\n break;\n case \"*\": {\n flagged = true;\n const itemIds = treeItemChildIds.get(item.parentId);\n if (itemIds) {\n const expandableIds = [...itemIds].filter(\n (itemId) => expandable[itemId]\n );\n if (expandableIds.length) {\n expandMultipleTreeItems(\n (prev) => new Set([...prev, ...expandableIds])\n );\n currentFocusIndex.current = -1;\n }\n }\n break;\n }\n }\n\n if (flagged) {\n event.stopPropagation();\n event.preventDefault();\n }\n },\n searchable: true,\n tabIndexBehavior: \"virtual\",\n getFocusableElements: getVisibleTreeItems,\n getDefaultFocusedIndex(options) {\n const { focusables } = options;\n const { elementToItem } = metadataLookup.current;\n\n return focusables.findIndex((element) =>\n selectedIds.has(elementToItem[element.id])\n );\n },\n });\n\n return {\n metadataLookup,\n ...movement,\n };\n}\n"],"names":["useRef","useKeyboardMovementProvider","getNextFocusableIndex","isParentItemCollapsing","item","closest","previousElementSibling","getAttribute","getVisibleTreeItems","container","items","querySelectorAll","filter","offsetParent","useTreeMovement","options","ref","onClick","onFocus","onKeyDown","data","expandedIds","selectedIds","treeItemChildIds","toggleTreeItemExpansion","expandMultipleTreeItems","metadataLookup","expandable","disabledItems","elementToItem","itemToElement","movement","extendKeyDown","movementData","event","activeDescendantId","currentFocusIndex","setFocusIndex","current","itemId","disabled","expanded","has","flagged","key","parentId","focusables","currentTarget","index","findIndex","element","id","loopable","increment","includeDisabled","itemIds","get","expandableIds","length","prev","Set","stopPropagation","preventDefault","searchable","tabIndexBehavior","getFocusableElements","getDefaultFocusedIndex"],"mappings":"AAAA;AAQA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,2BAA2B,QAAQ,6CAA6C;AACzF,SAASC,qBAAqB,QAAQ,uBAAuB;AAO7D;;;;;;;;;;;;CAYC,GACD,MAAMC,yBAAyB,CAACC,OAC9BA,KACGC,OAAO,CAAC,mBACPC,wBAAwBC,aAAa,qBAAqB;AAEhE;;;CAGC,GACD,MAAMC,sBAAsB,CAC1BC;IAEA,MAAMC,QAAQ;WACTD,UAAUE,gBAAgB,CAAc;KAC5C;IAED,OAAOD,MAAME,MAAM,CACjB,CAACR,OACC,yDAAyD;QACzDA,KAAKS,YAAY,IACjB,uDAAuD;QACvD,CAACV,uBAAuBC;AAE9B;AA4BA;;;CAGC,GACD,OAAO,SAASU,gBACdC,OAA+B;IAE/B,MAAM,EACJC,GAAG,EACHC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACxB,GAAGV;IAEJ,MAAMW,iBAAiB1B,OAA+B;QACpD2B,YAAY,CAAC;QACbC,eAAe,CAAC;QAChBC,eAAe,CAAC;QAChBC,eAAe,CAAC;IAClB;IACA,MAAMC,WAAW9B,4BAA4B;QAC3Ce;QACAC;QACAC;QACAC;QACAa,eAAcC,YAAY;YACxB,MAAM,EAAEC,KAAK,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,aAAa,EAAE,GACnEJ;YACF,MAAM,EAAEN,UAAU,EAAEC,aAAa,EAAEC,aAAa,EAAEC,aAAa,EAAE,GAC/DJ,eAAeY,OAAO;YACxB,MAAMC,SAASV,aAAa,CAACM,mBAAmB;YAChD,MAAM/B,OAAOgB,IAAI,CAACmB,OAAO;YAEzB,mBAAmB,GACnB,IAAI,CAACnC,MAAM;gBACT;YACF;YACA,kBAAkB,GAElB,MAAMoC,WAAWZ,aAAa,CAACW,OAAO;YACtC,MAAME,WAAWpB,YAAYqB,GAAG,CAACH;YAEjC,IAAII,UAAU;YACd,OAAQT,MAAMU,GAAG;gBACf,KAAK;oBACH,IAAIH,YAAY,CAACD,UAAU;wBACzBG,UAAU;wBACVnB,wBAAwBe;oBAC1B,OAAO,IAAInC,KAAKyC,QAAQ,EAAE;wBACxB,kEAAkE;wBAClE,MAAMA,WAAWf,aAAa,CAAC1B,KAAKyC,QAAQ,CAAC;wBAC7C,MAAMC,aAAatC,oBAAoB0B,MAAMa,aAAa;wBAC1D,MAAMC,QAAQF,WAAWG,SAAS,CAChC,CAACC,UAAYA,QAAQC,EAAE,KAAKN;wBAE9BR,cAAcW,OAAOF;oBACvB;oBAEA;gBACF,KAAK;oBACH,IAAInB,UAAU,CAACY,OAAO,IAAI,CAACC,UAAU;wBACnC,IAAI,CAACC,UAAU;4BACbE,UAAU;4BACVnB,wBAAwBe;wBAC1B,OAAO;4BACL,kEAAkE;4BAClE,MAAMO,aAAatC,oBAAoB0B,MAAMa,aAAa;4BAC1D,MAAMC,QAAQ9C,sBAAsB;gCAClCkD,UAAU;gCACVC,WAAW;gCACXP;gCACAQ,iBAAiB;gCACjBlB,mBAAmBA,kBAAkBE,OAAO;4BAC9C;4BAEAD,cAAcW,OAAOF;wBACvB;oBACF;oBAEA;gBACF,KAAK;oBAAK;wBACRH,UAAU;wBACV,MAAMY,UAAUhC,iBAAiBiC,GAAG,CAACpD,KAAKyC,QAAQ;wBAClD,IAAIU,SAAS;4BACX,MAAME,gBAAgB;mCAAIF;6BAAQ,CAAC3C,MAAM,CACvC,CAAC2B,SAAWZ,UAAU,CAACY,OAAO;4BAEhC,IAAIkB,cAAcC,MAAM,EAAE;gCACxBjC,wBACE,CAACkC,OAAS,IAAIC,IAAI;2CAAID;2CAASF;qCAAc;gCAE/CrB,kBAAkBE,OAAO,GAAG,CAAC;4BAC/B;wBACF;wBACA;oBACF;YACF;YAEA,IAAIK,SAAS;gBACXT,MAAM2B,eAAe;gBACrB3B,MAAM4B,cAAc;YACtB;QACF;QACAC,YAAY;QACZC,kBAAkB;QAClBC,sBAAsBzD;QACtB0D,wBAAuBnD,OAAO;YAC5B,MAAM,EAAE+B,UAAU,EAAE,GAAG/B;YACvB,MAAM,EAAEc,aAAa,EAAE,GAAGH,eAAeY,OAAO;YAEhD,OAAOQ,WAAWG,SAAS,CAAC,CAACC,UAC3B5B,YAAYoB,GAAG,CAACb,aAAa,CAACqB,QAAQC,EAAE,CAAC;QAE7C;IACF;IAEA,OAAO;QACLzB;QACA,GAAGK,QAAQ;IACb;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/HighlightTextMark.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\n\nimport { type HighlightTextComponentProps } from \"./HighlightText.js\";\nimport { Mark, type MarkProps } from \"./Mark.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface HighlightTextMarkProps\n extends HighlightTextComponentProps,\n Omit<MarkProps, \"children\"> {}\n\n/**\n * This is the default implementation for the `HighlightText` component that\n * just omits the `match` prop from {@link HighlightTextComponentProps} and\n * passes the rest to the {@link Mark}.\n *\n * @since 6.0.0\n */\nexport function HighlightTextMark(\n props: Readonly<HighlightTextMarkProps>\n): ReactElement {\n const { match: _match, ...remaining } = props;\n return <Mark {...remaining} />;\n}\n"],"names":["Mark","HighlightTextMark","props","match","_match","remaining"],"mappings":";AAGA,SAASA,IAAI,QAAwB,YAAY;AASjD;;;;;;CAMC,GACD,OAAO,SAASC,kBACdC,KAAuC;IAEvC,MAAM,EAAEC,OAAOC,MAAM,EAAE,GAAGC,WAAW,GAAGH;IACxC,qBAAO,KAACF;QAAM,GAAGK,SAAS;;AAC5B"}
1
+ {"version":3,"sources":["../../src/typography/HighlightTextMark.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\n\nimport { type HighlightTextComponentProps } from \"./HighlightText.js\";\nimport { Mark, type MarkProps } from \"./Mark.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface HighlightTextMarkProps\n extends HighlightTextComponentProps, Omit<MarkProps, \"children\"> {}\n\n/**\n * This is the default implementation for the `HighlightText` component that\n * just omits the `match` prop from {@link HighlightTextComponentProps} and\n * passes the rest to the {@link Mark}.\n *\n * @since 6.0.0\n */\nexport function HighlightTextMark(\n props: Readonly<HighlightTextMarkProps>\n): ReactElement {\n const { match: _match, ...remaining } = props;\n return <Mark {...remaining} />;\n}\n"],"names":["Mark","HighlightTextMark","props","match","_match","remaining"],"mappings":";AAGA,SAASA,IAAI,QAAwB,YAAY;AAQjD;;;;;;CAMC,GACD,OAAO,SAASC,kBACdC,KAAuC;IAEvC,MAAM,EAAEC,OAAOC,MAAM,EAAE,GAAGC,WAAW,GAAGH;IACxC,qBAAO,KAACF;QAAM,GAAGK,SAAS;;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/Mark.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { type MarkClassNameOptions, mark } from \"./markStyles.js\";\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends MarkClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface MarkProps\n extends HTMLAttributes<HTMLElement>,\n MarkClassNameOptions {\n children: ReactNode;\n}\n\n/**\n * The `Mark` component can be used in place of the `mark` HTMLElement with\n * some default styles.\n *\n * @example Simple Example\n * ```tsx\n * import { Mark } from \"@react-md/core/typography/Mark\";\n *\n * export function Example() {\n * return (\n * <>\n * Some text <Mark>that has highlights</Mark> and some other text.\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/mark | Mark Demos}\n * @since 6.0.0\n */\nexport const Mark = forwardRef<HTMLElement, MarkProps>(\n function Mark(props, ref) {\n const { children, className, ...remaining } = props;\n return (\n <mark {...remaining} ref={ref} className={mark({ className })}>\n {children}\n </mark>\n );\n }\n);\n"],"names":["forwardRef","mark","Mark","props","ref","children","className","remaining"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAAoCC,IAAI,QAAQ,kBAAkB;AAalE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,qBAAOF,WAClB,SAASE,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,WAAW,GAAGJ;IAC9C,qBACE,KAACF;QAAM,GAAGM,SAAS;QAAEH,KAAKA;QAAKE,WAAWL,KAAK;YAAEK;QAAU;kBACxDD;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/typography/Mark.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { type MarkClassNameOptions, mark } from \"./markStyles.js\";\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends MarkClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface MarkProps\n extends HTMLAttributes<HTMLElement>, MarkClassNameOptions {\n children: ReactNode;\n}\n\n/**\n * The `Mark` component can be used in place of the `mark` HTMLElement with\n * some default styles.\n *\n * @example Simple Example\n * ```tsx\n * import { Mark } from \"@react-md/core/typography/Mark\";\n *\n * export function Example() {\n * return (\n * <>\n * Some text <Mark>that has highlights</Mark> and some other text.\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/mark | Mark Demos}\n * @since 6.0.0\n */\nexport const Mark = forwardRef<HTMLElement, MarkProps>(\n function Mark(props, ref) {\n const { children, className, ...remaining } = props;\n return (\n <mark {...remaining} ref={ref} className={mark({ className })}>\n {children}\n </mark>\n );\n }\n);\n"],"names":["forwardRef","mark","Mark","props","ref","children","className","remaining"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAAoCC,IAAI,QAAQ,kBAAkB;AAYlE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,qBAAOF,WAClB,SAASE,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,WAAW,GAAGJ;IAC9C,qBACE,KAACF;QAAM,GAAGM,SAAS;QAAEH,KAAKA;QAAKE,WAAWL,KAAK;YAAEK;QAAU;kBACxDD;;AAGP,GACA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/TextContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport {\n type TextContainerClassNameOptions,\n textContainer,\n} from \"./textContainerStyles.js\";\n\n/**\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport interface TextContainerProps\n extends HTMLAttributes<HTMLDivElement>,\n TextContainerClassNameOptions {}\n\n/**\n * This component should be used to render text based content with an\n * appropriate max line length to optimize legibility.\n *\n * @example Simple Example\n * ```tsx\n * import { TextContainer } from \"@react-md/core/typography/TextContainer\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <TextContainer>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </TextContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/text-container | TextContainer Demos}\n * @see {@link textContainer} If you only want to apply this class to an\n * element.\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport const TextContainer = forwardRef<HTMLDivElement, TextContainerProps>(\n function TextContainer(props, ref) {\n const { className, children, ...remaining } = props;\n\n return (\n <div {...remaining} ref={ref} className={textContainer({ className })}>\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","textContainer","TextContainer","props","ref","className","children","remaining","div"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAEEC,aAAa,QACR,2BAA2B;AAYlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC,GACD,OAAO,MAAMC,8BAAgBF,WAC3B,SAASE,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE9C,qBACE,KAACK;QAAK,GAAGD,SAAS;QAAEH,KAAKA;QAAKC,WAAWJ,cAAc;YAAEI;QAAU;kBAChEC;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/typography/TextContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport {\n type TextContainerClassNameOptions,\n textContainer,\n} from \"./textContainerStyles.js\";\n\n/**\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport interface TextContainerProps\n extends HTMLAttributes<HTMLDivElement>, TextContainerClassNameOptions {}\n\n/**\n * This component should be used to render text based content with an\n * appropriate max line length to optimize legibility.\n *\n * @example Simple Example\n * ```tsx\n * import { TextContainer } from \"@react-md/core/typography/TextContainer\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <TextContainer>\n * <Typography type=\"headline-1\">Heading</Typography>\n * <Typography>\n * Pretend this is a giant paragraph of text that wraps multiple lines.\n * </Typography>\n * <Typography>\n * Pretend this is another giant paragraph of text that wraps multiple\n * lines.\n * </Typography>\n * </TextContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/text-container | TextContainer Demos}\n * @see {@link textContainer} If you only want to apply this class to an\n * element.\n * @since 6.0.0 Removed the `size` option since there is no longer a\n * different line-length for mobile and desktop.\n * @since 6.0.0 Removed the `clone` prop and the children render function\n * behavior. Use the `textContainer` class name utility instead.\n */\nexport const TextContainer = forwardRef<HTMLDivElement, TextContainerProps>(\n function TextContainer(props, ref) {\n const { className, children, ...remaining } = props;\n\n return (\n <div {...remaining} ref={ref} className={textContainer({ className })}>\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","textContainer","TextContainer","props","ref","className","children","remaining","div"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAEEC,aAAa,QACR,2BAA2B;AAWlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC,GACD,OAAO,MAAMC,8BAAgBF,WAC3B,SAASE,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE9C,qBACE,KAACK;QAAK,GAAGD,SAAS;QAAEH,KAAKA;QAAKC,WAAWJ,cAAc;YAAEI;QAAU;kBAChEC;;AAGP,GACA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typography/Typography.tsx"],"sourcesContent":["import {\n type ElementType,\n type HTMLAttributes,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport {\n type TypographyClassNameOptions,\n type TypographyType,\n typography,\n} from \"./typographyStyles.js\";\n\n/**\n * A union of the default supported elements that the `Typography` component can\n * be rendered as. This is mostly used for adding the correct `HTMLAttributes`\n * and enabling the forward ref.\n *\n * @since 4.0.0\n */\nexport type TypographyHTMLElement =\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLSpanElement\n | HTMLDivElement\n | HTMLAnchorElement\n | HTMLBodyElement\n | HTMLHtmlElement;\n\n/** @since 6.0.0 */\nexport type CustomTypographyComponent = ElementType<\n HTMLAttributes<TypographyHTMLElement> & { className: string }\n>;\n\n/** @internal */\nfunction getComponent(\n as: CustomTypographyComponent | undefined,\n type: TypographyType\n): ElementType {\n if (as) {\n return as;\n }\n\n switch (type) {\n case \"headline-1\":\n return \"h1\";\n case \"headline-2\":\n return \"h2\";\n case \"headline-3\":\n return \"h3\";\n case \"headline-4\":\n return \"h4\";\n case \"headline-5\":\n return \"h5\";\n case \"headline-6\":\n case \"subtitle-1\":\n case \"subtitle-2\":\n return \"h6\";\n case \"body-1\":\n case \"body-2\":\n return \"p\";\n case \"caption\":\n return \"caption\";\n default:\n return \"span\";\n }\n}\n\n/**\n * @since 6.0.0 Renamed `component` to `as`.\n * @since 6.0.0 Removed the children render function behavior. Use the\n * `typography` class name utility instead.\n */\nexport interface TypographyProps\n extends HTMLAttributes<TypographyHTMLElement>,\n TypographyClassNameOptions {\n /**\n * The component to render as when the children are not a render function. If\n * this prop is omitted, the component will be determined by the `type` prop\n * where:\n *\n * - `\"headline-1\" -> <h1>`\n * - `\"headline-2\" -> <h2>`\n * - `\"headline-3\" -> <h3>`\n * - `\"headline-4\" -> <h4>`\n * - `\"headline-5\" -> <h5>`\n * - `\"headline-6\" -> <h6>`\n * - `\"subtitle-1\" -> <h5>`\n * - `\"subtitle-2\" -> <h6>`\n * - `\"body-1\" -> <p>`\n * - `\"body-2\" -> <p>`\n * - `\"caption\" -> <caption>`\n * - `\"overline\" -> <span>`\n *\n * @since 6.0.0 Renamed from `component`\n */\n as?: CustomTypographyComponent;\n}\n\n/**\n * Render text with one of the material design typography styles applied and\n * optional styles like font-weight, font-style, text color, etc.\n *\n * @example All Example\n * ```tsx\n * import { Typography } from \"@react-md/core/typography/Typography\":\n *\n * export function Example() {\n * return (\n * <>\n * <Typography type=\"headline-1\">Headline 1</Typography>\n * <Typography type=\"headline-2\">Headline 2</Typography>\n * <Typography type=\"headline-3\">Headline 3</Typography>\n * <Typography type=\"headline-4\">Headline 4</Typography>\n * <Typography type=\"headline-5\">Headline 5</Typography>\n * <Typography type=\"headline-6\">Headline 6</Typography>\n * <Typography type=\"subtitle-1\">Subtitle 1</Typography>\n * <Typography type=\"subtitle-2\">Subtitle 2</Typography>\n * <Typography>\n * A paragraph of text.\n * </Typography>\n * <Typography type=\"body-1\">\n * A paragraph of text.\n * </Typography>\n * <Typography type=\"body-2\">\n * Another paragraph of text.\n * </Typography>\n * <Typography type=\"caption\" component=\"h5\">\n * Caption text\n * </Typography>\n * <Typography type=\"overline\" component=\"h5\">\n * Overline text\n * </Typography>\n * </>\n * ):\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/typography | Typography Demos}\n * @since 6.0.0 Removed the children render function behavior . Use the\n * `typography` class name utility instead.\n */\nexport const Typography = forwardRef<TypographyHTMLElement, TypographyProps>(\n function Typography(props, ref): ReactElement {\n const {\n as,\n type = \"body-1\",\n className,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textColor,\n textDecoration,\n textTransform,\n textOverflow,\n children,\n ...remaining\n } = props;\n\n const Component = getComponent(as, type);\n return (\n <Component\n {...remaining}\n ref={ref}\n className={typography({\n type,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textColor,\n textDecoration,\n textTransform,\n textOverflow,\n className,\n })}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["forwardRef","typography","getComponent","as","type","Typography","props","ref","className","margin","fontStyle","fontWeight","textAlign","textColor","textDecoration","textTransform","textOverflow","children","remaining","Component"],"mappings":";AAAA,SAIEA,UAAU,QACL,QAAQ;AAEf,SAGEC,UAAU,QACL,wBAAwB;AAuB/B,cAAc,GACd,SAASC,aACPC,EAAyC,EACzCC,IAAoB;IAEpB,IAAID,IAAI;QACN,OAAOA;IACT;IAEA,OAAQC;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GACD,OAAO,MAAMC,2BAAaL,WACxB,SAASK,WAAWC,KAAK,EAAEC,GAAG;IAC5B,MAAM,EACJJ,EAAE,EACFC,OAAO,QAAQ,EACfI,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACZC,QAAQ,EACR,GAAGC,WACJ,GAAGZ;IAEJ,MAAMa,YAAYjB,aAAaC,IAAIC;IACnC,qBACE,KAACe;QACE,GAAGD,SAAS;QACbX,KAAKA;QACLC,WAAWP,WAAW;YACpBG;YACAK;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAR;QACF;kBAECS;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/typography/Typography.tsx"],"sourcesContent":["import {\n type ElementType,\n type HTMLAttributes,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport {\n type TypographyClassNameOptions,\n type TypographyType,\n typography,\n} from \"./typographyStyles.js\";\n\n/**\n * A union of the default supported elements that the `Typography` component can\n * be rendered as. This is mostly used for adding the correct `HTMLAttributes`\n * and enabling the forward ref.\n *\n * @since 4.0.0\n */\nexport type TypographyHTMLElement =\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLSpanElement\n | HTMLDivElement\n | HTMLAnchorElement\n | HTMLBodyElement\n | HTMLHtmlElement;\n\n/** @since 6.0.0 */\nexport type CustomTypographyComponent = ElementType<\n HTMLAttributes<TypographyHTMLElement> & { className: string }\n>;\n\n/** @internal */\nfunction getComponent(\n as: CustomTypographyComponent | undefined,\n type: TypographyType\n): ElementType {\n if (as) {\n return as;\n }\n\n switch (type) {\n case \"headline-1\":\n return \"h1\";\n case \"headline-2\":\n return \"h2\";\n case \"headline-3\":\n return \"h3\";\n case \"headline-4\":\n return \"h4\";\n case \"headline-5\":\n return \"h5\";\n case \"headline-6\":\n case \"subtitle-1\":\n case \"subtitle-2\":\n return \"h6\";\n case \"body-1\":\n case \"body-2\":\n return \"p\";\n case \"caption\":\n return \"caption\";\n default:\n return \"span\";\n }\n}\n\n/**\n * @since 6.0.0 Renamed `component` to `as`.\n * @since 6.0.0 Removed the children render function behavior. Use the\n * `typography` class name utility instead.\n */\nexport interface TypographyProps\n extends HTMLAttributes<TypographyHTMLElement>, TypographyClassNameOptions {\n /**\n * The component to render as when the children are not a render function. If\n * this prop is omitted, the component will be determined by the `type` prop\n * where:\n *\n * - `\"headline-1\" -> <h1>`\n * - `\"headline-2\" -> <h2>`\n * - `\"headline-3\" -> <h3>`\n * - `\"headline-4\" -> <h4>`\n * - `\"headline-5\" -> <h5>`\n * - `\"headline-6\" -> <h6>`\n * - `\"subtitle-1\" -> <h5>`\n * - `\"subtitle-2\" -> <h6>`\n * - `\"body-1\" -> <p>`\n * - `\"body-2\" -> <p>`\n * - `\"caption\" -> <caption>`\n * - `\"overline\" -> <span>`\n *\n * @since 6.0.0 Renamed from `component`\n */\n as?: CustomTypographyComponent;\n}\n\n/**\n * Render text with one of the material design typography styles applied and\n * optional styles like font-weight, font-style, text color, etc.\n *\n * @example All Example\n * ```tsx\n * import { Typography } from \"@react-md/core/typography/Typography\":\n *\n * export function Example() {\n * return (\n * <>\n * <Typography type=\"headline-1\">Headline 1</Typography>\n * <Typography type=\"headline-2\">Headline 2</Typography>\n * <Typography type=\"headline-3\">Headline 3</Typography>\n * <Typography type=\"headline-4\">Headline 4</Typography>\n * <Typography type=\"headline-5\">Headline 5</Typography>\n * <Typography type=\"headline-6\">Headline 6</Typography>\n * <Typography type=\"subtitle-1\">Subtitle 1</Typography>\n * <Typography type=\"subtitle-2\">Subtitle 2</Typography>\n * <Typography>\n * A paragraph of text.\n * </Typography>\n * <Typography type=\"body-1\">\n * A paragraph of text.\n * </Typography>\n * <Typography type=\"body-2\">\n * Another paragraph of text.\n * </Typography>\n * <Typography type=\"caption\" component=\"h5\">\n * Caption text\n * </Typography>\n * <Typography type=\"overline\" component=\"h5\">\n * Overline text\n * </Typography>\n * </>\n * ):\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/typography | Typography Demos}\n * @since 6.0.0 Removed the children render function behavior . Use the\n * `typography` class name utility instead.\n */\nexport const Typography = forwardRef<TypographyHTMLElement, TypographyProps>(\n function Typography(props, ref): ReactElement {\n const {\n as,\n type = \"body-1\",\n className,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textColor,\n textDecoration,\n textTransform,\n textOverflow,\n children,\n ...remaining\n } = props;\n\n const Component = getComponent(as, type);\n return (\n <Component\n {...remaining}\n ref={ref}\n className={typography({\n type,\n margin,\n fontStyle,\n fontWeight,\n textAlign,\n textColor,\n textDecoration,\n textTransform,\n textOverflow,\n className,\n })}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["forwardRef","typography","getComponent","as","type","Typography","props","ref","className","margin","fontStyle","fontWeight","textAlign","textColor","textDecoration","textTransform","textOverflow","children","remaining","Component"],"mappings":";AAAA,SAIEA,UAAU,QACL,QAAQ;AAEf,SAGEC,UAAU,QACL,wBAAwB;AAuB/B,cAAc,GACd,SAASC,aACPC,EAAyC,EACzCC,IAAoB;IAEpB,IAAID,IAAI;QACN,OAAOA;IACT;IAEA,OAAQC;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GACD,OAAO,MAAMC,2BAAaL,WACxB,SAASK,WAAWC,KAAK,EAAEC,GAAG;IAC5B,MAAM,EACJJ,EAAE,EACFC,OAAO,QAAQ,EACfI,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACZC,QAAQ,EACR,GAAGC,WACJ,GAAGZ;IAEJ,MAAMa,YAAYjB,aAAaC,IAAIC;IACnC,qBACE,KAACe;QACE,GAAGD,SAAS;QACbX,KAAKA;QACLC,WAAWP,WAAW;YACpBG;YACAK;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAR;QACF;kBAECS;;AAGP,GACA"}
@@ -175,7 +175,6 @@ $line-height: 1.5rem !default;
175
175
  /// @type Map
176
176
  $base-recommended-font-styles: (
177
177
  font-family: var(--rmd-font-family),
178
- overflow: inherit,
179
178
  overflow-wrap: break-word,
180
179
  text-overflow: inherit,
181
180
  -moz-osx-font-smoothing: grayscale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useElementSize.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefCallback, useCallback, useRef, useState } from \"react\";\n\nimport { type ElementSize, type UseStateInitializer } from \"./types.js\";\nimport {\n type ResizeObserverHookOptions,\n useResizeObserver,\n} from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeOptions<E extends HTMLElement>\n extends Omit<ResizeObserverHookOptions<E>, \"onUpdate\"> {\n /** @defaultValue `{ height: 0, width: 0 }` */\n defaultValue?: UseStateInitializer<ElementSize>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeImplementation<E extends HTMLElement>\n extends ElementSize {\n elementRef: RefCallback<E>;\n\n /**\n * This will be `true` once the resize observer's callback is triggered at\n * least once.\n *\n * This was added so that generating custom properties that have a reasonable\n * default value set in css don't cause major layout shifts when a default\n * value cannot be provided.\n *\n * @example\n * ```tsx\n * const { height, width, observedOnce } = useElementSize();\n * useCSSVariables(useMemo(() => {\n * if (!observedOnce) {\n * return []\n * }\n *\n * // something that uses the element's height, width, or both\n * return [{ var: \"--something\", value: height / width * 0.5 }];\n * }, [height, width, observedOnce]));\n * ```\n */\n observedOnce: boolean;\n}\n\n/**\n * A small wrapper around the {@link useResizeObserver} hook to calculate the\n * element's size.\n *\n * @example Simple Example\n * ```tsx\n * import { useElementSize } from \"@react-md/core/useElementSize\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width, elementRef } = useElementSize();\n *\n * return (\n * <div ref={elementRef}>\n * {`height: ${height}, width: ${width}`}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useElementSize<E extends HTMLElement>(\n options: ElementSizeOptions<E> = {}\n): ElementSizeImplementation<E> {\n const { defaultValue } = options;\n\n const observedOnce = useRef(false);\n const [size, setSize] = useState<ElementSize>(() => {\n if (typeof defaultValue === \"function\") {\n return defaultValue();\n }\n\n return (\n defaultValue ?? {\n height: 0,\n width: 0,\n }\n );\n });\n\n const elementRef = useResizeObserver({\n ...options,\n onUpdate: useCallback((entry) => {\n observedOnce.current = true;\n const size = entry.borderBoxSize[0];\n\n setSize({\n height: size.blockSize,\n width: size.inlineSize,\n });\n }, []),\n });\n\n return {\n ...size,\n elementRef,\n observedOnce: observedOnce.current,\n };\n}\n"],"names":["useCallback","useRef","useState","useResizeObserver","useElementSize","options","defaultValue","observedOnce","size","setSize","height","width","elementRef","onUpdate","entry","current","borderBoxSize","blockSize","inlineSize"],"mappings":"AAAA;AAEA,SAA2BA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGxE,SAEEC,iBAAiB,QACZ,yBAAyB;AA0ChC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,eACdC,UAAiC,CAAC,CAAC;IAEnC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IAEzB,MAAME,eAAeN,OAAO;IAC5B,MAAM,CAACO,MAAMC,QAAQ,GAAGP,SAAsB;QAC5C,IAAI,OAAOI,iBAAiB,YAAY;YACtC,OAAOA;QACT;QAEA,OACEA,gBAAgB;YACdI,QAAQ;YACRC,OAAO;QACT;IAEJ;IAEA,MAAMC,aAAaT,kBAAkB;QACnC,GAAGE,OAAO;QACVQ,UAAUb,YAAY,CAACc;YACrBP,aAAaQ,OAAO,GAAG;YACvB,MAAMP,OAAOM,MAAME,aAAa,CAAC,EAAE;YAEnCP,QAAQ;gBACNC,QAAQF,KAAKS,SAAS;gBACtBN,OAAOH,KAAKU,UAAU;YACxB;QACF,GAAG,EAAE;IACP;IAEA,OAAO;QACL,GAAGV,IAAI;QACPI;QACAL,cAAcA,aAAaQ,OAAO;IACpC;AACF"}
1
+ {"version":3,"sources":["../src/useElementSize.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefCallback, useCallback, useRef, useState } from \"react\";\n\nimport { type ElementSize, type UseStateInitializer } from \"./types.js\";\nimport {\n type ResizeObserverHookOptions,\n useResizeObserver,\n} from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeOptions<E extends HTMLElement> extends Omit<\n ResizeObserverHookOptions<E>,\n \"onUpdate\"\n> {\n /** @defaultValue `{ height: 0, width: 0 }` */\n defaultValue?: UseStateInitializer<ElementSize>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSizeImplementation<\n E extends HTMLElement,\n> extends ElementSize {\n elementRef: RefCallback<E>;\n\n /**\n * This will be `true` once the resize observer's callback is triggered at\n * least once.\n *\n * This was added so that generating custom properties that have a reasonable\n * default value set in css don't cause major layout shifts when a default\n * value cannot be provided.\n *\n * @example\n * ```tsx\n * const { height, width, observedOnce } = useElementSize();\n * useCSSVariables(useMemo(() => {\n * if (!observedOnce) {\n * return []\n * }\n *\n * // something that uses the element's height, width, or both\n * return [{ var: \"--something\", value: height / width * 0.5 }];\n * }, [height, width, observedOnce]));\n * ```\n */\n observedOnce: boolean;\n}\n\n/**\n * A small wrapper around the {@link useResizeObserver} hook to calculate the\n * element's size.\n *\n * @example Simple Example\n * ```tsx\n * import { useElementSize } from \"@react-md/core/useElementSize\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width, elementRef } = useElementSize();\n *\n * return (\n * <div ref={elementRef}>\n * {`height: ${height}, width: ${width}`}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useElementSize<E extends HTMLElement>(\n options: ElementSizeOptions<E> = {}\n): ElementSizeImplementation<E> {\n const { defaultValue } = options;\n\n const observedOnce = useRef(false);\n const [size, setSize] = useState<ElementSize>(() => {\n if (typeof defaultValue === \"function\") {\n return defaultValue();\n }\n\n return (\n defaultValue ?? {\n height: 0,\n width: 0,\n }\n );\n });\n\n const elementRef = useResizeObserver({\n ...options,\n onUpdate: useCallback((entry) => {\n observedOnce.current = true;\n const size = entry.borderBoxSize[0];\n\n setSize({\n height: size.blockSize,\n width: size.inlineSize,\n });\n }, []),\n });\n\n return {\n ...size,\n elementRef,\n observedOnce: observedOnce.current,\n };\n}\n"],"names":["useCallback","useRef","useState","useResizeObserver","useElementSize","options","defaultValue","observedOnce","size","setSize","height","width","elementRef","onUpdate","entry","current","borderBoxSize","blockSize","inlineSize"],"mappings":"AAAA;AAEA,SAA2BA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGxE,SAEEC,iBAAiB,QACZ,yBAAyB;AA6ChC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,eACdC,UAAiC,CAAC,CAAC;IAEnC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IAEzB,MAAME,eAAeN,OAAO;IAC5B,MAAM,CAACO,MAAMC,QAAQ,GAAGP,SAAsB;QAC5C,IAAI,OAAOI,iBAAiB,YAAY;YACtC,OAAOA;QACT;QAEA,OACEA,gBAAgB;YACdI,QAAQ;YACRC,OAAO;QACT;IAEJ;IAEA,MAAMC,aAAaT,kBAAkB;QACnC,GAAGE,OAAO;QACVQ,UAAUb,YAAY,CAACc;YACrBP,aAAaQ,OAAO,GAAG;YACvB,MAAMP,OAAOM,MAAME,aAAa,CAAC,EAAE;YAEnCP,QAAQ;gBACNC,QAAQF,KAAKS,SAAS;gBACtBN,OAAOH,KAAKU,UAAU;YACxB;QACF,GAAG,EAAE;IACP;IAEA,OAAO;QACL,GAAGV,IAAI;QACPI;QACAL,cAAcA,aAAaQ,OAAO;IACpC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useIntersectionObserver.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback, type RefObject } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/** @since 6.0.0 */\nexport type IntersectionObserverRoot = IntersectionObserverInit[\"root\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverThreshold =\n IntersectionObserverInit[\"threshold\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverRootMargin =\n IntersectionObserverInit[\"rootMargin\"];\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface BaseIntersectionObserverHookOptions {\n /**\n * This is the same as the normal `root` for an IntersectionObserverInit, but\n * also supports refs.\n */\n root?: RefObject<IntersectionObserverRoot> | IntersectionObserverRoot;\n\n /**\n * Set this to `true` if the intersection observer behavior should be\n * disabled.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * **When using a list of thresholds, they must either be defined outside of\n * the component or wrapped in a `useMemo` to prevent the IntersectionObserver\n * from being re-created each render.**\n *\n * @example Moving Out of Render\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example() {\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * })\n * }\n * ```\n *\n * @example Wrapping in useMemo\n * ```tsx\n * interface ExampleProps {\n * min: number;\n * max: number;\n * }\n *\n * function Example({ min, max }: ExampleProps): ReactElement {\n * const targetRef = useIntersectionObserver({\n * threshold: useMemo(() => [min, max], [min, max]),\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * });\n * }\n * ```\n *\n * @see {@link getThreshold}\n */\n threshold?: IntersectionObserverThreshold;\n\n /** @see {@link getRootMargin} */\n rootMargin?: IntersectionObserverRootMargin;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link threshold} which is\n * generally useful if you need access to the DOM or do some expensive\n * computation.\n *\n * @example Simple Example\n * ```tsx\n * const targetRef = useIntersectionObserver({\n * getThreshold: useCallback(() => {\n * // pretend some expensive computation\n * return [0, 0.25, 0.5, 0.75, 1];\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * If this option is provided, {@link threshold}'s value will be ignored.\n */\n getThreshold?: () => IntersectionObserverThreshold;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link rootMargin} which is\n * generally useful if you need access to the DOM.\n *\n * @example Simple Example\n * ```tsx\n * const nodeRef = useRef<HTMLElement>();\n * const targetRef = useIntersectionObserver({\n * getRootMargin: useCallback(() => {\n * return `-${nodeRef.current.offsetHeight - 1}px 0px 0px`;\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * Note: If this option is provided, {@link rootMargin} will be ignored.\n */\n getRootMargin?: () => IntersectionObserverRootMargin;\n}\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface IntersectionObserverHookOptions<E extends HTMLElement>\n extends BaseIntersectionObserverHookOptions {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * @example Simple Example\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example(): ReactElement {\n * const [intersecting, setIntersecting] = useState(false);\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) {\n * setIntersecting(entry.isIntersecting);\n * }, []),\n * });\n *\n * // implementation\n * }\n * ```\n */\n onUpdate: (entries: readonly IntersectionObserverEntry[]) => void;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * If this is defined, the {@link ref} will be ignored along with the returned\n * ref.\n *\n * @example Watching Queried Elements\n * ```tsx\n * function Example(): ReactElement {\n * useIntersectionObserver({\n * onUpdate: useCallback((entries) => {\n * entries.forEach((entry) => {\n * // do stuff\n * });\n *\n * setIntersectingIds(intersecting);\n * }, []),\n * getTargets: useCallback(() => {\n * return document.querySelectorAll('h1, h2, h3, h4, h5, h6');\n * }, []),\n * }),\n *\n * return <div {...props} />;\n * }\n * ```\n */\n getTargets?: () => readonly Element[];\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#a_simple_example\n *\n * import { useIntersectionObserver } from \"@react-md/core/useIntersectionObserver\";\n * import { type ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * import styles from \"./Example.module.scss\";\n *\n * const numSteps = 20;\n * const thresholds = Array.from({ length: numSteps }, (_, i) => i / numSteps);\n * thresholds.push(0);\n *\n * const INCREASING = \"rgba(40, 40, 190, ratio)\";\n * const DECREASING = \"rgba(190, 40, 40, ratio)\";\n *\n * export default function Example(): ReactElement {\n * const [{ ratio, increasing }, setState] = useState({\n * ratio: 0.0,\n * increasing: true,\n * });\n *\n * const targetRef = useIntersectionObserver({\n * threshold: thresholds,\n * rootMargin: \"0px\",\n * onUpdate: useCallback(([entry]) => {\n * const { intersectionRatio } = entry;\n * setState((prevState) => {\n * return {\n * ratio: intersectionRatio,\n * increasing: intersectionRatio > prevState.ratio,\n * };\n * });\n * }, []),\n * });\n *\n * return (\n * <div\n * ref={targetRef}\n * className={styles.box}\n * style={{\n * backgroundColor: (increasing ? INCREASING : DECREASING).replace(\n * \"ratio\",\n * `${ratio}`\n * ),\n * }}\n * >\n * <div className={styles.vertical}>\n * Welcome to <strong>The Box!</strong>\n * </div>\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n */\nexport function useIntersectionObserver<E extends HTMLElement>(\n options: IntersectionObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n root,\n disabled = false,\n onUpdate,\n threshold,\n rootMargin,\n getTargets,\n getThreshold,\n getRootMargin,\n } = options;\n\n const [targetNodeRef, targetRef] = useEnsuredRef(ref);\n\n useEffect(() => {\n const element = targetNodeRef.current;\n let targets: readonly Element[] = [];\n if (getTargets) {\n targets = getTargets();\n } else if (element) {\n targets = [element];\n }\n\n if (disabled || !targets.length) {\n return;\n }\n\n let resolvedRoot: IntersectionObserverRoot;\n if (root && \"current\" in root) {\n resolvedRoot = root.current;\n } else {\n resolvedRoot = root;\n }\n\n const options: IntersectionObserverInit = {\n root: resolvedRoot,\n threshold: (getThreshold || (() => threshold))(),\n rootMargin: (getRootMargin || (() => rootMargin))(),\n };\n\n // Just like the ResizeObserver, you can see performance improvements by\n // sharing a single intersection observer but I don't think it's worth the\n // effort to implement here since I'd need to:\n // - check if there is an observer with the same options\n // - if there is, add the callback to that existing observer\n // - if there isn't, create a new observer\n // - when cleaning up, check if there are any other existing callbacks\n // - disconnect and remove the observer if there are none left\n const observer = new IntersectionObserver(onUpdate, options);\n targets.forEach((target) => {\n observer.observe(target);\n });\n\n return () => {\n observer.disconnect();\n };\n }, [\n disabled,\n getRootMargin,\n getTargets,\n getThreshold,\n onUpdate,\n root,\n rootMargin,\n targetNodeRef,\n threshold,\n ]);\n\n return targetRef;\n}\n"],"names":["useEffect","useEnsuredRef","useIntersectionObserver","options","ref","root","disabled","onUpdate","threshold","rootMargin","getTargets","getThreshold","getRootMargin","targetNodeRef","targetRef","element","current","targets","length","resolvedRoot","observer","IntersectionObserver","forEach","target","observe","disconnect"],"mappings":"AAAA;AAGA,SAASA,SAAS,QAAQ,QAAQ;AAElC,SAASC,aAAa,QAAQ,qBAAqB;AA2LnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DC,GACD,OAAO,SAASC,wBACdC,OAA2C;IAE3C,MAAM,EACJC,GAAG,EACHC,IAAI,EACJC,WAAW,KAAK,EAChBC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAM,CAACU,eAAeC,UAAU,GAAGb,cAAcG;IAEjDJ,UAAU;QACR,MAAMe,UAAUF,cAAcG,OAAO;QACrC,IAAIC,UAA8B,EAAE;QACpC,IAAIP,YAAY;YACdO,UAAUP;QACZ,OAAO,IAAIK,SAAS;YAClBE,UAAU;gBAACF;aAAQ;QACrB;QAEA,IAAIT,YAAY,CAACW,QAAQC,MAAM,EAAE;YAC/B;QACF;QAEA,IAAIC;QACJ,IAAId,QAAQ,aAAaA,MAAM;YAC7Bc,eAAed,KAAKW,OAAO;QAC7B,OAAO;YACLG,eAAed;QACjB;QAEA,MAAMF,UAAoC;YACxCE,MAAMc;YACNX,WAAW,AAACG,CAAAA,gBAAiB,CAAA,IAAMH,SAAQ,CAAC;YAC5CC,YAAY,AAACG,CAAAA,iBAAkB,CAAA,IAAMH,UAAS,CAAC;QACjD;QAEA,wEAAwE;QACxE,0EAA0E;QAC1E,8CAA8C;QAC9C,wDAAwD;QACxD,8DAA8D;QAC9D,4CAA4C;QAC5C,sEAAsE;QACtE,gEAAgE;QAChE,MAAMW,WAAW,IAAIC,qBAAqBd,UAAUJ;QACpDc,QAAQK,OAAO,CAAC,CAACC;YACfH,SAASI,OAAO,CAACD;QACnB;QAEA,OAAO;YACLH,SAASK,UAAU;QACrB;IACF,GAAG;QACDnB;QACAM;QACAF;QACAC;QACAJ;QACAF;QACAI;QACAI;QACAL;KACD;IAED,OAAOM;AACT"}
1
+ {"version":3,"sources":["../src/useIntersectionObserver.ts"],"sourcesContent":["\"use client\";\n\nimport { type Ref, type RefCallback, type RefObject } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/** @since 6.0.0 */\nexport type IntersectionObserverRoot = IntersectionObserverInit[\"root\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverThreshold =\n IntersectionObserverInit[\"threshold\"];\n/** @since 6.0.0 */\nexport type IntersectionObserverRootMargin =\n IntersectionObserverInit[\"rootMargin\"];\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface BaseIntersectionObserverHookOptions {\n /**\n * This is the same as the normal `root` for an IntersectionObserverInit, but\n * also supports refs.\n */\n root?: RefObject<IntersectionObserverRoot> | IntersectionObserverRoot;\n\n /**\n * Set this to `true` if the intersection observer behavior should be\n * disabled.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * **When using a list of thresholds, they must either be defined outside of\n * the component or wrapped in a `useMemo` to prevent the IntersectionObserver\n * from being re-created each render.**\n *\n * @example Moving Out of Render\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example() {\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * })\n * }\n * ```\n *\n * @example Wrapping in useMemo\n * ```tsx\n * interface ExampleProps {\n * min: number;\n * max: number;\n * }\n *\n * function Example({ min, max }: ExampleProps): ReactElement {\n * const targetRef = useIntersectionObserver({\n * threshold: useMemo(() => [min, max], [min, max]),\n * onUpdate: useCallback(([entry]) => {\n * // do something\n * }, []),\n * });\n * }\n * ```\n *\n * @see {@link getThreshold}\n */\n threshold?: IntersectionObserverThreshold;\n\n /** @see {@link getRootMargin} */\n rootMargin?: IntersectionObserverRootMargin;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link threshold} which is\n * generally useful if you need access to the DOM or do some expensive\n * computation.\n *\n * @example Simple Example\n * ```tsx\n * const targetRef = useIntersectionObserver({\n * getThreshold: useCallback(() => {\n * // pretend some expensive computation\n * return [0, 0.25, 0.5, 0.75, 1];\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * If this option is provided, {@link threshold}'s value will be ignored.\n */\n getThreshold?: () => IntersectionObserverThreshold;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * This can be used to dynamically generate the {@link rootMargin} which is\n * generally useful if you need access to the DOM.\n *\n * @example Simple Example\n * ```tsx\n * const nodeRef = useRef<HTMLElement>();\n * const targetRef = useIntersectionObserver({\n * getRootMargin: useCallback(() => {\n * return `-${nodeRef.current.offsetHeight - 1}px 0px 0px`;\n * }, []),\n * onUpdate: useCallback(() => {\n * // do something\n * }, []),\n * });\n * ```\n *\n * Note: If this option is provided, {@link rootMargin} will be ignored.\n */\n getRootMargin?: () => IntersectionObserverRootMargin;\n}\n\n/**\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#intersection_observer_options}\n * @since 6.0.0\n */\nexport interface IntersectionObserverHookOptions<\n E extends HTMLElement,\n> extends BaseIntersectionObserverHookOptions {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * @example Simple Example\n * ```tsx\n * const threshold = [0, 0.25, 0.5, 0.75, 1];\n *\n * function Example(): ReactElement {\n * const [intersecting, setIntersecting] = useState(false);\n * const targetRef = useIntersectionObserver({\n * threshold,\n * onUpdate: useCallback(([entry]) {\n * setIntersecting(entry.isIntersecting);\n * }, []),\n * });\n *\n * // implementation\n * }\n * ```\n */\n onUpdate: (entries: readonly IntersectionObserverEntry[]) => void;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * IntersectionObserver each render.**\n *\n * If this is defined, the {@link ref} will be ignored along with the returned\n * ref.\n *\n * @example Watching Queried Elements\n * ```tsx\n * function Example(): ReactElement {\n * useIntersectionObserver({\n * onUpdate: useCallback((entries) => {\n * entries.forEach((entry) => {\n * // do stuff\n * });\n *\n * setIntersectingIds(intersecting);\n * }, []),\n * getTargets: useCallback(() => {\n * return document.querySelectorAll('h1, h2, h3, h4, h5, h6');\n * }, []),\n * }),\n *\n * return <div {...props} />;\n * }\n * ```\n */\n getTargets?: () => readonly Element[];\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#a_simple_example\n *\n * import { useIntersectionObserver } from \"@react-md/core/useIntersectionObserver\";\n * import { type ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * import styles from \"./Example.module.scss\";\n *\n * const numSteps = 20;\n * const thresholds = Array.from({ length: numSteps }, (_, i) => i / numSteps);\n * thresholds.push(0);\n *\n * const INCREASING = \"rgba(40, 40, 190, ratio)\";\n * const DECREASING = \"rgba(190, 40, 40, ratio)\";\n *\n * export default function Example(): ReactElement {\n * const [{ ratio, increasing }, setState] = useState({\n * ratio: 0.0,\n * increasing: true,\n * });\n *\n * const targetRef = useIntersectionObserver({\n * threshold: thresholds,\n * rootMargin: \"0px\",\n * onUpdate: useCallback(([entry]) => {\n * const { intersectionRatio } = entry;\n * setState((prevState) => {\n * return {\n * ratio: intersectionRatio,\n * increasing: intersectionRatio > prevState.ratio,\n * };\n * });\n * }, []),\n * });\n *\n * return (\n * <div\n * ref={targetRef}\n * className={styles.box}\n * style={{\n * backgroundColor: (increasing ? INCREASING : DECREASING).replace(\n * \"ratio\",\n * `${ratio}`\n * ),\n * }}\n * >\n * <div className={styles.vertical}>\n * Welcome to <strong>The Box!</strong>\n * </div>\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n */\nexport function useIntersectionObserver<E extends HTMLElement>(\n options: IntersectionObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n root,\n disabled = false,\n onUpdate,\n threshold,\n rootMargin,\n getTargets,\n getThreshold,\n getRootMargin,\n } = options;\n\n const [targetNodeRef, targetRef] = useEnsuredRef(ref);\n\n useEffect(() => {\n const element = targetNodeRef.current;\n let targets: readonly Element[] = [];\n if (getTargets) {\n targets = getTargets();\n } else if (element) {\n targets = [element];\n }\n\n if (disabled || !targets.length) {\n return;\n }\n\n let resolvedRoot: IntersectionObserverRoot;\n if (root && \"current\" in root) {\n resolvedRoot = root.current;\n } else {\n resolvedRoot = root;\n }\n\n const options: IntersectionObserverInit = {\n root: resolvedRoot,\n threshold: (getThreshold || (() => threshold))(),\n rootMargin: (getRootMargin || (() => rootMargin))(),\n };\n\n // Just like the ResizeObserver, you can see performance improvements by\n // sharing a single intersection observer but I don't think it's worth the\n // effort to implement here since I'd need to:\n // - check if there is an observer with the same options\n // - if there is, add the callback to that existing observer\n // - if there isn't, create a new observer\n // - when cleaning up, check if there are any other existing callbacks\n // - disconnect and remove the observer if there are none left\n const observer = new IntersectionObserver(onUpdate, options);\n targets.forEach((target) => {\n observer.observe(target);\n });\n\n return () => {\n observer.disconnect();\n };\n }, [\n disabled,\n getRootMargin,\n getTargets,\n getThreshold,\n onUpdate,\n root,\n rootMargin,\n targetNodeRef,\n threshold,\n ]);\n\n return targetRef;\n}\n"],"names":["useEffect","useEnsuredRef","useIntersectionObserver","options","ref","root","disabled","onUpdate","threshold","rootMargin","getTargets","getThreshold","getRootMargin","targetNodeRef","targetRef","element","current","targets","length","resolvedRoot","observer","IntersectionObserver","forEach","target","observe","disconnect"],"mappings":"AAAA;AAGA,SAASA,SAAS,QAAQ,QAAQ;AAElC,SAASC,aAAa,QAAQ,qBAAqB;AA4LnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DC,GACD,OAAO,SAASC,wBACdC,OAA2C;IAE3C,MAAM,EACJC,GAAG,EACHC,IAAI,EACJC,WAAW,KAAK,EAChBC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAM,CAACU,eAAeC,UAAU,GAAGb,cAAcG;IAEjDJ,UAAU;QACR,MAAMe,UAAUF,cAAcG,OAAO;QACrC,IAAIC,UAA8B,EAAE;QACpC,IAAIP,YAAY;YACdO,UAAUP;QACZ,OAAO,IAAIK,SAAS;YAClBE,UAAU;gBAACF;aAAQ;QACrB;QAEA,IAAIT,YAAY,CAACW,QAAQC,MAAM,EAAE;YAC/B;QACF;QAEA,IAAIC;QACJ,IAAId,QAAQ,aAAaA,MAAM;YAC7Bc,eAAed,KAAKW,OAAO;QAC7B,OAAO;YACLG,eAAed;QACjB;QAEA,MAAMF,UAAoC;YACxCE,MAAMc;YACNX,WAAW,AAACG,CAAAA,gBAAiB,CAAA,IAAMH,SAAQ,CAAC;YAC5CC,YAAY,AAACG,CAAAA,iBAAkB,CAAA,IAAMH,UAAS,CAAC;QACjD;QAEA,wEAAwE;QACxE,0EAA0E;QAC1E,8CAA8C;QAC9C,wDAAwD;QACxD,8DAA8D;QAC9D,4CAA4C;QAC5C,sEAAsE;QACtE,gEAAgE;QAChE,MAAMW,WAAW,IAAIC,qBAAqBd,UAAUJ;QACpDc,QAAQK,OAAO,CAAC,CAACC;YACfH,SAASI,OAAO,CAACD;QACnB;QAEA,OAAO;YACLH,SAASK,UAAU;QACrB;IACF,GAAG;QACDnB;QACAM;QACAF;QACAC;QACAJ;QACAF;QACAI;QACAI;QACAL;KACD;IAED,OAAOM;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useMutationObserver.ts"],"sourcesContent":["import { type Ref, type RefCallback, useEffect } from \"react\";\n\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MutationObserverHookOptions<E extends HTMLElement>\n extends MutationObserverInit {\n ref?: Ref<E>;\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options\n * @defaultValue `!childList && !attributes && !characterData`\n */\n disabled?: boolean;\n\n onUpdate: (mutation: MutationRecord) => void;\n}\n\n/**\n * The mutation observer is used to track the changes made to the DOM tree.\n *\n * @example Simple Example\n * ```tsx\n * import { useMutationObserver } from \"@react-md/core/useMutationObserver\";\n * import { useCallback, type HTMLAttributes, type ReactElement } from \"react\";\n *\n * function Example(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const { children, ...remaining } = props;\n *\n * const targetRef = useMutationObserver({\n * subtree: true,\n * attributes: true,\n * childList: true,\n * onUpdate: useCallback((mutation) => {\n * switch (mutation.type) {\n * case \"childList\":\n * console.log(\"A child node has been added or removed\");\n * break;\n * case \"attributes\":\n * console.log(`The ${mutation.attributeName} attribute was modified`);\n * break\n * }\n *\n * }, []),\n * });\n *\n * return (\n * <div {...remaining} ref={targetRef}>\n * {children}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useMutationObserver<E extends HTMLElement>(\n options: MutationObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n disabled = !childList && !attributes && !characterData,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const observerTarget = targetNodeRef.current;\n if (!observerTarget) {\n return;\n }\n\n const observer = new MutationObserver((records) => {\n const [entry] = records;\n if (entry) {\n onUpdate(entry);\n }\n });\n\n observer.observe(observerTarget, {\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n });\n return () => {\n observer.disconnect();\n };\n }, [\n attributeFilter,\n attributeOldValue,\n attributes,\n characterData,\n characterDataOldValue,\n childList,\n disabled,\n onUpdate,\n subtree,\n targetNodeRef,\n ]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","useMutationObserver","options","ref","onUpdate","attributes","attributeFilter","attributeOldValue","subtree","childList","characterData","characterDataOldValue","disabled","targetNodeRef","refCallback","observerTarget","current","observer","MutationObserver","records","entry","observe","disconnect"],"mappings":"AAAA,SAAqCA,SAAS,QAAQ,QAAQ;AAE9D,SAASC,aAAa,QAAQ,qBAAqB;AAkBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GACD,OAAO,SAASC,oBACdC,OAAuC;IAEvC,MAAM,EACJC,GAAG,EACHC,QAAQ,EACRC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,qBAAqB,EACrBC,WAAW,CAACH,aAAa,CAACJ,cAAc,CAACK,aAAa,EACvD,GAAGR;IAEJ,MAAM,CAACW,eAAeC,YAAY,GAAGd,cAAcG;IACnDJ,UAAU;QACR,IAAIa,UAAU;YACZ;QACF;QAEA,MAAMG,iBAAiBF,cAAcG,OAAO;QAC5C,IAAI,CAACD,gBAAgB;YACnB;QACF;QAEA,MAAME,WAAW,IAAIC,iBAAiB,CAACC;YACrC,MAAM,CAACC,MAAM,GAAGD;YAChB,IAAIC,OAAO;gBACThB,SAASgB;YACX;QACF;QAEAH,SAASI,OAAO,CAACN,gBAAgB;YAC/BV;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACA,OAAO;YACLM,SAASK,UAAU;QACrB;IACF,GAAG;QACDhB;QACAC;QACAF;QACAK;QACAC;QACAF;QACAG;QACAR;QACAI;QACAK;KACD;IAED,OAAOC;AACT"}
1
+ {"version":3,"sources":["../src/useMutationObserver.ts"],"sourcesContent":["import { type Ref, type RefCallback, useEffect } from \"react\";\n\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MutationObserverHookOptions<\n E extends HTMLElement,\n> extends MutationObserverInit {\n ref?: Ref<E>;\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options\n * @defaultValue `!childList && !attributes && !characterData`\n */\n disabled?: boolean;\n\n onUpdate: (mutation: MutationRecord) => void;\n}\n\n/**\n * The mutation observer is used to track the changes made to the DOM tree.\n *\n * @example Simple Example\n * ```tsx\n * import { useMutationObserver } from \"@react-md/core/useMutationObserver\";\n * import { useCallback, type HTMLAttributes, type ReactElement } from \"react\";\n *\n * function Example(props: HTMLAttributes<HTMLDivElement>): ReactElement {\n * const { children, ...remaining } = props;\n *\n * const targetRef = useMutationObserver({\n * subtree: true,\n * attributes: true,\n * childList: true,\n * onUpdate: useCallback((mutation) => {\n * switch (mutation.type) {\n * case \"childList\":\n * console.log(\"A child node has been added or removed\");\n * break;\n * case \"attributes\":\n * console.log(`The ${mutation.attributeName} attribute was modified`);\n * break\n * }\n *\n * }, []),\n * });\n *\n * return (\n * <div {...remaining} ref={targetRef}>\n * {children}\n * </div>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useMutationObserver<E extends HTMLElement>(\n options: MutationObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n disabled = !childList && !attributes && !characterData,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const observerTarget = targetNodeRef.current;\n if (!observerTarget) {\n return;\n }\n\n const observer = new MutationObserver((records) => {\n const [entry] = records;\n if (entry) {\n onUpdate(entry);\n }\n });\n\n observer.observe(observerTarget, {\n attributes,\n attributeFilter,\n attributeOldValue,\n subtree,\n childList,\n characterData,\n characterDataOldValue,\n });\n return () => {\n observer.disconnect();\n };\n }, [\n attributeFilter,\n attributeOldValue,\n attributes,\n characterData,\n characterDataOldValue,\n childList,\n disabled,\n onUpdate,\n subtree,\n targetNodeRef,\n ]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","useMutationObserver","options","ref","onUpdate","attributes","attributeFilter","attributeOldValue","subtree","childList","characterData","characterDataOldValue","disabled","targetNodeRef","refCallback","observerTarget","current","observer","MutationObserver","records","entry","observe","disconnect"],"mappings":"AAAA,SAAqCA,SAAS,QAAQ,QAAQ;AAE9D,SAASC,aAAa,QAAQ,qBAAqB;AAmBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GACD,OAAO,SAASC,oBACdC,OAAuC;IAEvC,MAAM,EACJC,GAAG,EACHC,QAAQ,EACRC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,qBAAqB,EACrBC,WAAW,CAACH,aAAa,CAACJ,cAAc,CAACK,aAAa,EACvD,GAAGR;IAEJ,MAAM,CAACW,eAAeC,YAAY,GAAGd,cAAcG;IACnDJ,UAAU;QACR,IAAIa,UAAU;YACZ;QACF;QAEA,MAAMG,iBAAiBF,cAAcG,OAAO;QAC5C,IAAI,CAACD,gBAAgB;YACnB;QACF;QAEA,MAAME,WAAW,IAAIC,iBAAiB,CAACC;YACrC,MAAM,CAACC,MAAM,GAAGD;YAChB,IAAIC,OAAO;gBACThB,SAASgB;YACX;QACF;QAEAH,SAASI,OAAO,CAACN,gBAAgB;YAC/BV;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QACA,OAAO;YACLM,SAASK,UAAU;QACrB;IACF,GAAG;QACDhB;QACAC;QACAF;QACAK;QACAC;QACAF;QACAG;QACAR;QACAI;QACAK;KACD;IAED,OAAOC;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useWindowSize.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\nimport { useSsr } from \"./SsrProvider.js\";\nimport { type ElementSize } from \"./types.js\";\nimport {\n type ResizeListenerOptions,\n useResizeListener,\n} from \"./useResizeListener.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSizeOptions\n extends Omit<ResizeListenerOptions, \"disabled\" | \"onUpdate\"> {\n /**\n * The default value to use in SSR environments for the window's height.\n *\n * @defaultValue `0`\n */\n ssrHeight?: number;\n\n /**\n * The default value to use in SSR environments for the window's width.\n *\n * @defaultValue `0`\n */\n ssrWidth?: number;\n\n /**\n * Set this to `true` to ignore resize events that only updated the height.\n * The hook can be disabled by setting this and {@link disableWidth} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` to ignore resize events that only updated the width.\n * The hook can be disabled by setting this and {@link disableHeight} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * This is just a convenience wrapper around the {@link useResizeListener}.\n *\n * @example Simple Example\n * ```tsx\n * import { useWindowSize } from \"@react-md/core/useWindowSize\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width } = useWindowSize();\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useWindowSize(options: WindowSizeOptions = {}): ElementSize {\n const {\n once,\n signal,\n capture,\n passive,\n throttle,\n ssrHeight = 0,\n ssrWidth = 0,\n disableWidth,\n disableHeight,\n } = options;\n\n const ssr = useSsr();\n const [size, setSize] = useState(() => {\n if (typeof window === \"undefined\" || ssr) {\n return {\n height: ssrHeight,\n width: ssrWidth,\n };\n }\n\n return {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n });\n\n useResizeListener({\n once,\n signal,\n capture,\n passive,\n throttle,\n disabled: disableHeight && disableWidth,\n onUpdate: useCallback(() => {\n setSize((prevSize) => {\n const nextSize: ElementSize = {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n\n const isHeightChange =\n !disableHeight && prevSize.height !== nextSize.height;\n const isWidthChange =\n !disableWidth && prevSize.width !== nextSize.width;\n\n return isHeightChange || isWidthChange ? nextSize : prevSize;\n });\n }, [disableHeight, disableWidth]),\n });\n\n return size;\n}\n"],"names":["useCallback","useState","useSsr","useResizeListener","useWindowSize","options","once","signal","capture","passive","throttle","ssrHeight","ssrWidth","disableWidth","disableHeight","ssr","size","setSize","window","height","width","innerHeight","innerWidth","disabled","onUpdate","prevSize","nextSize","isHeightChange","isWidthChange"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE9C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,SAEEC,iBAAiB,QACZ,yBAAyB;AAwChC;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASC,cAAcC,UAA6B,CAAC,CAAC;IAC3D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,YAAY,CAAC,EACbC,WAAW,CAAC,EACZC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAMU,MAAMb;IACZ,MAAM,CAACc,MAAMC,QAAQ,GAAGhB,SAAS;QAC/B,IAAI,OAAOiB,WAAW,eAAeH,KAAK;YACxC,OAAO;gBACLI,QAAQR;gBACRS,OAAOR;YACT;QACF;QAEA,OAAO;YACLO,QAAQD,OAAOG,WAAW;YAC1BD,OAAOF,OAAOI,UAAU;QAC1B;IACF;IAEAnB,kBAAkB;QAChBG;QACAC;QACAC;QACAC;QACAC;QACAa,UAAUT,iBAAiBD;QAC3BW,UAAUxB,YAAY;YACpBiB,QAAQ,CAACQ;gBACP,MAAMC,WAAwB;oBAC5BP,QAAQD,OAAOG,WAAW;oBAC1BD,OAAOF,OAAOI,UAAU;gBAC1B;gBAEA,MAAMK,iBACJ,CAACb,iBAAiBW,SAASN,MAAM,KAAKO,SAASP,MAAM;gBACvD,MAAMS,gBACJ,CAACf,gBAAgBY,SAASL,KAAK,KAAKM,SAASN,KAAK;gBAEpD,OAAOO,kBAAkBC,gBAAgBF,WAAWD;YACtD;QACF,GAAG;YAACX;YAAeD;SAAa;IAClC;IAEA,OAAOG;AACT"}
1
+ {"version":3,"sources":["../src/useWindowSize.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\nimport { useSsr } from \"./SsrProvider.js\";\nimport { type ElementSize } from \"./types.js\";\nimport {\n type ResizeListenerOptions,\n useResizeListener,\n} from \"./useResizeListener.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSizeOptions extends Omit<\n ResizeListenerOptions,\n \"disabled\" | \"onUpdate\"\n> {\n /**\n * The default value to use in SSR environments for the window's height.\n *\n * @defaultValue `0`\n */\n ssrHeight?: number;\n\n /**\n * The default value to use in SSR environments for the window's width.\n *\n * @defaultValue `0`\n */\n ssrWidth?: number;\n\n /**\n * Set this to `true` to ignore resize events that only updated the height.\n * The hook can be disabled by setting this and {@link disableWidth} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` to ignore resize events that only updated the width.\n * The hook can be disabled by setting this and {@link disableHeight} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * This is just a convenience wrapper around the {@link useResizeListener}.\n *\n * @example Simple Example\n * ```tsx\n * import { useWindowSize } from \"@react-md/core/useWindowSize\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width } = useWindowSize();\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useWindowSize(options: WindowSizeOptions = {}): ElementSize {\n const {\n once,\n signal,\n capture,\n passive,\n throttle,\n ssrHeight = 0,\n ssrWidth = 0,\n disableWidth,\n disableHeight,\n } = options;\n\n const ssr = useSsr();\n const [size, setSize] = useState(() => {\n if (typeof window === \"undefined\" || ssr) {\n return {\n height: ssrHeight,\n width: ssrWidth,\n };\n }\n\n return {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n });\n\n useResizeListener({\n once,\n signal,\n capture,\n passive,\n throttle,\n disabled: disableHeight && disableWidth,\n onUpdate: useCallback(() => {\n setSize((prevSize) => {\n const nextSize: ElementSize = {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n\n const isHeightChange =\n !disableHeight && prevSize.height !== nextSize.height;\n const isWidthChange =\n !disableWidth && prevSize.width !== nextSize.width;\n\n return isHeightChange || isWidthChange ? nextSize : prevSize;\n });\n }, [disableHeight, disableWidth]),\n });\n\n return size;\n}\n"],"names":["useCallback","useState","useSsr","useResizeListener","useWindowSize","options","once","signal","capture","passive","throttle","ssrHeight","ssrWidth","disableWidth","disableHeight","ssr","size","setSize","window","height","width","innerHeight","innerWidth","disabled","onUpdate","prevSize","nextSize","isHeightChange","isWidthChange"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE9C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,SAEEC,iBAAiB,QACZ,yBAAyB;AA0ChC;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASC,cAAcC,UAA6B,CAAC,CAAC;IAC3D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,YAAY,CAAC,EACbC,WAAW,CAAC,EACZC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAMU,MAAMb;IACZ,MAAM,CAACc,MAAMC,QAAQ,GAAGhB,SAAS;QAC/B,IAAI,OAAOiB,WAAW,eAAeH,KAAK;YACxC,OAAO;gBACLI,QAAQR;gBACRS,OAAOR;YACT;QACF;QAEA,OAAO;YACLO,QAAQD,OAAOG,WAAW;YAC1BD,OAAOF,OAAOI,UAAU;QAC1B;IACF;IAEAnB,kBAAkB;QAChBG;QACAC;QACAC;QACAC;QACAC;QACAa,UAAUT,iBAAiBD;QAC3BW,UAAUxB,YAAY;YACpBiB,QAAQ,CAACQ;gBACP,MAAMC,WAAwB;oBAC5BP,QAAQD,OAAOG,WAAW;oBAC1BD,OAAOF,OAAOI,UAAU;gBAC1B;gBAEA,MAAMK,iBACJ,CAACb,iBAAiBW,SAASN,MAAM,KAAKO,SAASP,MAAM;gBACvD,MAAMS,gBACJ,CAACf,gBAAgBY,SAASL,KAAK,KAAKM,SAASN,KAAK;gBAEpD,OAAOO,kBAAkBC,gBAAgBF,WAAWD;YACtD;QACF,GAAG;YAACX;YAAeD;SAAa;IAClC;IAEA,OAAOG;AACT"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @since 6.4.0
3
+ * @see {@link https://stackoverflow.com/a/28203456}
4
+ */
5
+ export declare function getNumberOfDigits(value: number): number;
6
+ export declare function getNumberOfDigits(value: undefined): undefined;
7
+ export declare function getNumberOfDigits(value: number | undefined): number | undefined;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @since 6.4.0
3
+ * @see {@link https://stackoverflow.com/a/28203456}
4
+ */ export function getNumberOfDigits(value) {
5
+ if (typeof value !== "number") {
6
+ return;
7
+ }
8
+ return (Math.log10((value ^ value >> 31) - (value >> 31)) | 0) + 1;
9
+ }
10
+
11
+ //# sourceMappingURL=getNumberOfDigits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/getNumberOfDigits.ts"],"sourcesContent":["/**\n * @since 6.4.0\n * @see {@link https://stackoverflow.com/a/28203456}\n */\nexport function getNumberOfDigits(value: number): number;\nexport function getNumberOfDigits(value: undefined): undefined;\nexport function getNumberOfDigits(\n value: number | undefined\n): number | undefined;\nexport function getNumberOfDigits(\n value: number | undefined\n): number | undefined {\n if (typeof value !== \"number\") {\n return;\n }\n\n return (Math.log10((value ^ (value >> 31)) - (value >> 31)) | 0) + 1;\n}\n"],"names":["getNumberOfDigits","value","Math","log10"],"mappings":"AAAA;;;CAGC,GAMD,OAAO,SAASA,kBACdC,KAAyB;IAEzB,IAAI,OAAOA,UAAU,UAAU;QAC7B;IACF;IAEA,OAAO,AAACC,CAAAA,KAAKC,KAAK,CAAC,AAACF,CAAAA,QAASA,SAAS,EAAE,IAAMA,CAAAA,SAAS,EAAC,KAAM,CAAA,IAAK;AACrE"}
@@ -1,3 +1,4 @@
1
+ import { getNumberOfDigits } from "./getNumberOfDigits.js";
1
2
  /**
2
3
  * Rounds a number to the nearest step within a min/max range.
3
4
  *
@@ -16,7 +17,7 @@
16
17
  // precision gets weird:
17
18
  // 0.28 * 100 === 28.000000000000004
18
19
  const step = range / steps;
19
- const decimals = Number.isInteger(step) ? range % steps : `${step}`.split(".")[1].length;
20
+ const decimals = Number.isInteger(step) ? range % steps : getNumberOfDigits(parseInt(`${step}`.split(".")[1]));
20
21
  return Math.min(max, Math.max(min, parseFloat((zeroToOne * range + min).toFixed(decimals))));
21
22
  }
22
23
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/nearest.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface NearestOptions extends MinMaxRange {\n steps: number;\n value: number;\n\n /** @defaultValue `max - min` */\n range?: number;\n}\n\n/**\n * Rounds a number to the nearest step within a min/max range.\n *\n * @see https://stackoverflow.com/a/13635455\n * @returns the value rounded to the nearest step in the min/max range\n * @since 2.5.0 Added the `range` param\n * @since 6.0.0 Converted to using an object instead of multiple arguments.\n */\nexport function nearest(options: NearestOptions): number {\n const { min, max, steps, value, range = max - min } = options;\n if (min === max) {\n return max;\n }\n\n const rounded = Math.round(((value - min) * steps) / range) / steps;\n const zeroToOne = Math.min(Math.max(rounded, 0), 1);\n\n // have to calculate the number of allowed decimal places since decimal\n // precision gets weird:\n // 0.28 * 100 === 28.000000000000004\n const step = range / steps;\n const decimals = Number.isInteger(step)\n ? range % steps\n : `${step}`.split(\".\")[1].length;\n\n return Math.min(\n max,\n Math.max(min, parseFloat((zeroToOne * range + min).toFixed(decimals)))\n );\n}\n"],"names":["nearest","options","min","max","steps","value","range","rounded","Math","round","zeroToOne","step","decimals","Number","isInteger","split","length","parseFloat","toFixed"],"mappings":"AAcA;;;;;;;CAOC,GACD,OAAO,SAASA,QAAQC,OAAuB;IAC7C,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,EAAEC,QAAQH,MAAMD,GAAG,EAAE,GAAGD;IACtD,IAAIC,QAAQC,KAAK;QACf,OAAOA;IACT;IAEA,MAAMI,UAAUC,KAAKC,KAAK,CAAC,AAAEJ,CAAAA,QAAQH,GAAE,IAAKE,QAASE,SAASF;IAC9D,MAAMM,YAAYF,KAAKN,GAAG,CAACM,KAAKL,GAAG,CAACI,SAAS,IAAI;IAEjD,uEAAuE;IACvE,wBAAwB;IACxB,oCAAoC;IACpC,MAAMI,OAAOL,QAAQF;IACrB,MAAMQ,WAAWC,OAAOC,SAAS,CAACH,QAC9BL,QAAQF,QACR,GAAGO,MAAM,CAACI,KAAK,CAAC,IAAI,CAAC,EAAE,CAACC,MAAM;IAElC,OAAOR,KAAKN,GAAG,CACbC,KACAK,KAAKL,GAAG,CAACD,KAAKe,WAAW,AAACP,CAAAA,YAAYJ,QAAQJ,GAAE,EAAGgB,OAAO,CAACN;AAE/D"}
1
+ {"version":3,"sources":["../../src/utils/nearest.ts"],"sourcesContent":["import { type MinMaxRange } from \"../types.js\";\nimport { getNumberOfDigits } from \"./getNumberOfDigits.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface NearestOptions extends MinMaxRange {\n steps: number;\n value: number;\n\n /** @defaultValue `max - min` */\n range?: number;\n}\n\n/**\n * Rounds a number to the nearest step within a min/max range.\n *\n * @see https://stackoverflow.com/a/13635455\n * @returns the value rounded to the nearest step in the min/max range\n * @since 2.5.0 Added the `range` param\n * @since 6.0.0 Converted to using an object instead of multiple arguments.\n */\nexport function nearest(options: NearestOptions): number {\n const { min, max, steps, value, range = max - min } = options;\n if (min === max) {\n return max;\n }\n\n const rounded = Math.round(((value - min) * steps) / range) / steps;\n const zeroToOne = Math.min(Math.max(rounded, 0), 1);\n\n // have to calculate the number of allowed decimal places since decimal\n // precision gets weird:\n // 0.28 * 100 === 28.000000000000004\n const step = range / steps;\n const decimals = Number.isInteger(step)\n ? range % steps\n : getNumberOfDigits(parseInt(`${step}`.split(\".\")[1]));\n\n return Math.min(\n max,\n Math.max(min, parseFloat((zeroToOne * range + min).toFixed(decimals)))\n );\n}\n"],"names":["getNumberOfDigits","nearest","options","min","max","steps","value","range","rounded","Math","round","zeroToOne","step","decimals","Number","isInteger","parseInt","split","parseFloat","toFixed"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,yBAAyB;AAc3D;;;;;;;CAOC,GACD,OAAO,SAASC,QAAQC,OAAuB;IAC7C,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,EAAEC,QAAQH,MAAMD,GAAG,EAAE,GAAGD;IACtD,IAAIC,QAAQC,KAAK;QACf,OAAOA;IACT;IAEA,MAAMI,UAAUC,KAAKC,KAAK,CAAC,AAAEJ,CAAAA,QAAQH,GAAE,IAAKE,QAASE,SAASF;IAC9D,MAAMM,YAAYF,KAAKN,GAAG,CAACM,KAAKL,GAAG,CAACI,SAAS,IAAI;IAEjD,uEAAuE;IACvE,wBAAwB;IACxB,oCAAoC;IACpC,MAAMI,OAAOL,QAAQF;IACrB,MAAMQ,WAAWC,OAAOC,SAAS,CAACH,QAC9BL,QAAQF,QACRL,kBAAkBgB,SAAS,GAAGJ,MAAM,CAACK,KAAK,CAAC,IAAI,CAAC,EAAE;IAEtD,OAAOR,KAAKN,GAAG,CACbC,KACAK,KAAKL,GAAG,CAACD,KAAKe,WAAW,AAACP,CAAAA,YAAYJ,QAAQJ,GAAE,EAAGgB,OAAO,CAACN;AAE/D"}
@@ -0,0 +1,7 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * This will be a no-op when `process.env.NODE_ENV === "production"`.
4
+ * Otherwise, it will be a normal `useEffect` call
5
+ * @since 6.4.0
6
+ */
7
+ export declare const useDevEffect: typeof useEffect;
@@ -0,0 +1,8 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * This will be a no-op when `process.env.NODE_ENV === "production"`.
4
+ * Otherwise, it will be a normal `useEffect` call
5
+ * @since 6.4.0
6
+ */ export const useDevEffect = process.env.NODE_ENV === "production" ? ()=>{} : useEffect;
7
+
8
+ //# sourceMappingURL=useDevEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/useDevEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * This will be a no-op when `process.env.NODE_ENV === \"production\"`.\n * Otherwise, it will be a normal `useEffect` call\n * @since 6.4.0\n */\nexport const useDevEffect =\n process.env.NODE_ENV === \"production\" ? () => {} : useEffect;\n"],"names":["useEffect","useDevEffect","process","env","NODE_ENV"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAElC;;;;CAIC,GACD,OAAO,MAAMC,eACXC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe,KAAO,IAAIJ,UAAU"}
@@ -45,7 +45,7 @@ import { windowSplitter } from "./styles.js";
45
45
  * @see {@link https://react-md.dev/components/window-splitter | WindowSplitter Demos}
46
46
  * @since 6.0.0
47
47
  */ export const WindowSplitter = /*#__PURE__*/ forwardRef(function WindowSplitter(props, ref) {
48
- const { role = "separator", className, dragging, reversed, disableFixed = false, ...remaining } = props;
48
+ const { role = "separator", className, dragging, reversed, disableFixed, inactiveBackground, ...remaining } = props;
49
49
  const vertical = props["aria-orientation"] === "vertical";
50
50
  return /*#__PURE__*/ _jsx("button", {
51
51
  ...remaining,
@@ -57,7 +57,8 @@ import { windowSplitter } from "./styles.js";
57
57
  reversed,
58
58
  dragging,
59
59
  vertical,
60
- disableFixed
60
+ disableFixed,
61
+ inactiveBackground
61
62
  })
62
63
  });
63
64
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/window-splitter/WindowSplitter.tsx"],"sourcesContent":["import { type ButtonHTMLAttributes, forwardRef } from \"react\";\n\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport {\n type BaseWindowSplitterClassNameOptions,\n windowSplitter,\n} from \"./styles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useWindowSplitter } from \"./useWindowSplitter.js\";\n\n/**\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/}\n * @since 6.0.0\n * @since 6.3.1 Extends BaseWindowSplitterClassNameOptions for CSSProperties\n * module augmentation.\n */\nexport interface BaseWindowSplitterProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\">,\n BaseWindowSplitterClassNameOptions {\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n \"aria-controls\": string;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n dragging: boolean;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n reversed: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport type WindowSplitterProps = LabelRequiredForA11y<BaseWindowSplitterProps>;\n\n/**\n * The `WindowSplitter` should be used with the `useWindowSplitter` hook to\n * resize parts of a layout.\n *\n * See the `useResizableLayout` hook if the entire page layout should be\n * resizable.\n *\n * @example Simple Example\n * ```tsx\n * \"use client\";\n * import { WindowSplitter } from \"@react-md/core/window-splitter/WindowSplitter\";\n * import { useWindowSplitter } from \"@react-md/core/window-splitter/useWindowSplitter\";\n * import { useId, type ReactElement } from \"react\";\n *\n * export function Example(): ReactElement {\n * const panelId = useId();\n * const { value, splitterProps } = useWindowSplitter({\n * min: 120,\n * max: 380,\n * });\n *\n * return (\n * <div\n * style={{\n * \"--rmd-window-splitter-position\": `${value}px`,\n * display: \"grid\",\n * gridTemplateColumns: \"var(--rmd-window-splitter-position, 120px) 1fr\",\n * }}\n * >\n * <div>Panel 1</div>\n * <WindowSplitter\n * {...splitterProps}\n * aria-controls={panelId}\n * aria-labelledby={panelId}\n * />\n * <div>Panel 2</div>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/window-splitter | WindowSplitter Demos}\n * @since 6.0.0\n */\nexport const WindowSplitter = forwardRef<\n HTMLButtonElement,\n WindowSplitterProps\n>(function WindowSplitter(props, ref) {\n const {\n role = \"separator\",\n className,\n dragging,\n reversed,\n disableFixed = false,\n ...remaining\n } = props;\n const vertical = props[\"aria-orientation\"] === \"vertical\";\n\n return (\n <button\n {...remaining}\n ref={ref}\n type=\"button\"\n role={role}\n className={windowSplitter({\n className,\n reversed,\n dragging,\n vertical,\n disableFixed,\n })}\n />\n );\n});\n"],"names":["forwardRef","windowSplitter","WindowSplitter","props","ref","role","className","dragging","reversed","disableFixed","remaining","vertical","button","type"],"mappings":";AAAA,SAAoCA,UAAU,QAAQ,QAAQ;AAG9D,SAEEC,cAAc,QACT,cAAc;AAkCrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GACD,OAAO,MAAMC,+BAAiBF,WAG5B,SAASE,eAAeC,KAAK,EAAEC,GAAG;IAClC,MAAM,EACJC,OAAO,WAAW,EAClBC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,eAAe,KAAK,EACpB,GAAGC,WACJ,GAAGP;IACJ,MAAMQ,WAAWR,KAAK,CAAC,mBAAmB,KAAK;IAE/C,qBACE,KAACS;QACE,GAAGF,SAAS;QACbN,KAAKA;QACLS,MAAK;QACLR,MAAMA;QACNC,WAAWL,eAAe;YACxBK;YACAE;YACAD;YACAI;YACAF;QACF;;AAGN,GAAG"}
1
+ {"version":3,"sources":["../../src/window-splitter/WindowSplitter.tsx"],"sourcesContent":["import { type ButtonHTMLAttributes, forwardRef } from \"react\";\n\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport {\n type BaseWindowSplitterClassNameOptions,\n windowSplitter,\n} from \"./styles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useWindowSplitter } from \"./useWindowSplitter.js\";\n\n/**\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/}\n * @since 6.0.0\n * @since 6.3.1 Extends BaseWindowSplitterClassNameOptions for CSSProperties\n * module augmentation.\n */\nexport interface BaseWindowSplitterProps\n extends\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\">,\n BaseWindowSplitterClassNameOptions {\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n \"aria-controls\": string;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n dragging: boolean;\n\n /**\n * This will be provided by the {@link useWindowSplitter} hook.\n */\n reversed: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport type WindowSplitterProps = LabelRequiredForA11y<BaseWindowSplitterProps>;\n\n/**\n * The `WindowSplitter` should be used with the `useWindowSplitter` hook to\n * resize parts of a layout.\n *\n * See the `useResizableLayout` hook if the entire page layout should be\n * resizable.\n *\n * @example Simple Example\n * ```tsx\n * \"use client\";\n * import { WindowSplitter } from \"@react-md/core/window-splitter/WindowSplitter\";\n * import { useWindowSplitter } from \"@react-md/core/window-splitter/useWindowSplitter\";\n * import { useId, type ReactElement } from \"react\";\n *\n * export function Example(): ReactElement {\n * const panelId = useId();\n * const { value, splitterProps } = useWindowSplitter({\n * min: 120,\n * max: 380,\n * });\n *\n * return (\n * <div\n * style={{\n * \"--rmd-window-splitter-position\": `${value}px`,\n * display: \"grid\",\n * gridTemplateColumns: \"var(--rmd-window-splitter-position, 120px) 1fr\",\n * }}\n * >\n * <div>Panel 1</div>\n * <WindowSplitter\n * {...splitterProps}\n * aria-controls={panelId}\n * aria-labelledby={panelId}\n * />\n * <div>Panel 2</div>\n * </div>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/window-splitter | WindowSplitter Demos}\n * @since 6.0.0\n */\nexport const WindowSplitter = forwardRef<\n HTMLButtonElement,\n WindowSplitterProps\n>(function WindowSplitter(props, ref) {\n const {\n role = \"separator\",\n className,\n dragging,\n reversed,\n disableFixed,\n inactiveBackground,\n ...remaining\n } = props;\n const vertical = props[\"aria-orientation\"] === \"vertical\";\n\n return (\n <button\n {...remaining}\n ref={ref}\n type=\"button\"\n role={role}\n className={windowSplitter({\n className,\n reversed,\n dragging,\n vertical,\n disableFixed,\n inactiveBackground,\n })}\n />\n );\n});\n"],"names":["forwardRef","windowSplitter","WindowSplitter","props","ref","role","className","dragging","reversed","disableFixed","inactiveBackground","remaining","vertical","button","type"],"mappings":";AAAA,SAAoCA,UAAU,QAAQ,QAAQ;AAG9D,SAEEC,cAAc,QACT,cAAc;AAmCrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GACD,OAAO,MAAMC,+BAAiBF,WAG5B,SAASE,eAAeC,KAAK,EAAEC,GAAG;IAClC,MAAM,EACJC,OAAO,WAAW,EAClBC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZC,kBAAkB,EAClB,GAAGC,WACJ,GAAGR;IACJ,MAAMS,WAAWT,KAAK,CAAC,mBAAmB,KAAK;IAE/C,qBACE,KAACU;QACE,GAAGF,SAAS;QACbP,KAAKA;QACLU,MAAK;QACLT,MAAMA;QACNC,WAAWL,eAAe;YACxBK;YACAE;YACAD;YACAK;YACAH;YACAC;QACF;;AAGN,GAAG"}
@@ -4,6 +4,7 @@
4
4
 
5
5
  @use "sass:map";
6
6
  @use "../utils";
7
+ @use "../divider/divider";
7
8
  @use "../interaction/interaction";
8
9
  @use "../transition/transition";
9
10
 
@@ -27,6 +28,11 @@ $disable-reversed: false !default;
27
28
  /// @type Boolean
28
29
  $disable-absolute-position: false !default;
29
30
 
31
+ /// Set to `true` to disable the inactive `background-color` styles.
32
+ /// @since 6.4.0
33
+ /// @type Boolean
34
+ $disable-inactive-background-color: false !default;
35
+
30
36
  /// The default `WindowSplitter` draggable area.
31
37
  /// @type Number
32
38
  $size: 1rem !default;
@@ -35,10 +41,15 @@ $size: 1rem !default;
35
41
  /// @type Number
36
42
  $background-size: 0.25rem !default;
37
43
 
38
- /// The default `background-color` for the `WindowSplitter`.
44
+ /// The default `background-color` for the `WindowSplitter` while being
45
+ /// interacted with by the user.
39
46
  /// @type Color
40
47
  $background-color: interaction.get-var(focus-color) !default;
41
48
 
49
+ /// An optional `background-color` to use while the
50
+ /// @type Color
51
+ $inactive-background-color: divider.get-var(color) !default;
52
+
42
53
  /// The default `z-index` for the `WindowSplitter`.
43
54
  /// @type Number
44
55
  $z-index: 30 !default;
@@ -54,6 +65,7 @@ $variables: (
54
65
  z,
55
66
  position,
56
67
  background-color,
68
+ inactive-background-color,
57
69
  opacity
58
70
  );
59
71
 
@@ -97,6 +109,13 @@ $variables: (
97
109
  @if $background-color != interaction.get-var(focus-color) {
98
110
  @include set-var(background-color, $background-color);
99
111
  }
112
+ @if not
113
+ $disable-inactive-background-color and
114
+ $inactive-background-color !=
115
+ divider.get-var(color)
116
+ {
117
+ @include set-var(background-color, $inactive-background-color);
118
+ }
100
119
  }
101
120
  }
102
121
 
@@ -106,10 +125,15 @@ $variables: (
106
125
  /// layer behavior
107
126
  @mixin styles($disable-layer: false) {
108
127
  @if not $disable-everything {
128
+ $pseudo-selectors: if(
129
+ not $disable-inactive-background-color,
130
+ "&::before, ",
131
+ ""
132
+ ) +
133
+ "&::after";
134
+
109
135
  @include utils.optional-layer(window-splitter, $disable-layer) {
110
136
  .rmd-window-splitter {
111
- @include use-var(opacity);
112
-
113
137
  background-color: transparent;
114
138
  border: 0;
115
139
  inset: 0;
@@ -117,9 +141,14 @@ $variables: (
117
141
  padding: 0;
118
142
  position: fixed;
119
143
  transform: translate3d(get-var(x, 0), get-var(y, 0), get-var(z, 0));
120
- transition: opacity transition.$linear-duration;
121
144
  z-index: $z-index;
122
145
 
146
+ #{$pseudo-selectors} {
147
+ content: "";
148
+ inset: 0;
149
+ position: absolute;
150
+ }
151
+
123
152
  &::after {
124
153
  @include use-var(
125
154
  background-color,
@@ -129,10 +158,29 @@ $variables: (
129
158
  null
130
159
  )
131
160
  );
161
+ @include use-var(opacity);
132
162
 
133
- content: "";
134
- inset: 0;
135
- position: absolute;
163
+ transition: opacity transition.$linear-duration;
164
+ }
165
+
166
+ @if not $disable-inactive-background-color {
167
+ &--no-inactive-bg::before {
168
+ display: none;
169
+ }
170
+
171
+ &::before {
172
+ @include use-var(
173
+ background-color,
174
+ inactive-background-color,
175
+ if(
176
+ $inactive-background-color == divider.get-var(color),
177
+ $inactive-background-color,
178
+ null
179
+ )
180
+ );
181
+
182
+ pointer-events: none;
183
+ }
136
184
  }
137
185
 
138
186
  @if not $disable-horizontal {
@@ -142,7 +190,7 @@ $variables: (
142
190
 
143
191
  cursor: col-resize;
144
192
 
145
- &::after {
193
+ #{$pseudo-selectors} {
146
194
  @include use-var(width, background-size);
147
195
  }
148
196
 
@@ -158,7 +206,7 @@ $variables: (
158
206
  calc(100dvw - get-var(size) - get-var(position))
159
207
  );
160
208
 
161
- &::after {
209
+ #{$pseudo-selectors} {
162
210
  margin-left: auto;
163
211
  }
164
212
 
@@ -168,7 +216,7 @@ $variables: (
168
216
  calc(-100dvw + get-var(size) + get-var(position))
169
217
  );
170
218
 
171
- &::after {
219
+ #{$pseudo-selectors} {
172
220
  margin-left: 0;
173
221
  margin-right: auto;
174
222
  }
@@ -185,7 +233,7 @@ $variables: (
185
233
  cursor: row-resize;
186
234
  width: 100%;
187
235
 
188
- &::after {
236
+ #{$pseudo-selectors} {
189
237
  @include use-var(height, background-size);
190
238
  }
191
239
  }
@@ -197,7 +245,7 @@ $variables: (
197
245
  calc(100dvh - get-var(size) - get-var(position))
198
246
  );
199
247
 
200
- &::after {
248
+ #{$pseudo-selectors} {
201
249
  transform: translateY(
202
250
  calc(get-var(size) - get-var(background-size))
203
251
  );
@@ -7,6 +7,7 @@ declare module "react" {
7
7
  "--rmd-window-splitter-z"?: string | number;
8
8
  "--rmd-window-splitter-position"?: string | number;
9
9
  "--rmd-window-splitter-backgrond-color"?: string;
10
+ "--rmd-window-splitter-inactive-backgrond-color"?: string;
10
11
  "--rmd-window-splitter-opacity"?: string | number;
11
12
  }
12
13
  }
@@ -22,6 +23,14 @@ export interface BaseWindowSplitterClassNameOptions {
22
23
  * @defaultValue `false`
23
24
  */
24
25
  disableFixed?: boolean;
26
+ /**
27
+ * Set to `true` to enable a background-color to the `WindowSplitter` even
28
+ * while not being interacted with by the user.
29
+ *
30
+ * @since 6.4.0
31
+ * @defaultValue `false`
32
+ */
33
+ inactiveBackground?: boolean;
25
34
  }
26
35
  /**
27
36
  * @since 6.0.0
@@ -4,14 +4,15 @@ const styles = bem("rmd-window-splitter");
4
4
  /**
5
5
  * @since 6.0.0
6
6
  */ export function windowSplitter(options = {}) {
7
- const { vertical = false, dragging, reversed, disableFixed, className } = options;
7
+ const { vertical = false, dragging, reversed, disableFixed, inactiveBackground, className } = options;
8
8
  return cnb(styles({
9
9
  h: !vertical,
10
10
  hr: !vertical && reversed,
11
11
  v: vertical,
12
12
  vr: vertical && reversed,
13
13
  a: disableFixed,
14
- dragging
14
+ dragging,
15
+ "no-inactive-bg": !inactiveBackground
15
16
  }), className);
16
17
  }
17
18