@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/list/listItemStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemHeight,\n} from \"./types.js\";\n\nconst styles = bem(\"rmd-list-item\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-list-item-keyline\"?: string | number;\n \"--rmd-list-item-padding-h\"?: string | number;\n \"--rmd-list-item-padding-v\"?: string | number;\n \"--rmd-list-item-height\"?: string | number;\n \"--rmd-list-item-medium-height\"?: string | number;\n \"--rmd-list-item-large-height\"?: string | number;\n \"--rmd-list-item-extra-large-height\"?: string | number;\n \"--rmd-list-item-multiline-height\"?: string | number;\n \"--rmd-list-item-media-size\"?: string | number;\n \"--rmd-list-item-media-spacing\"?: string | number;\n \"--rmd-list-item-text-multiline-height\"?: string | number;\n \"--rmd-list-item-multiline-clamp\"?: string | number;\n }\n}\n\n/** @since 6.3.1 */\nexport interface BaseListItemClassNameOptions {\n className?: string;\n\n /**\n * @see {@link ListItemHeight}\n * @defaultValue `\"auto\"`\n */\n height?: ListItemHeight;\n\n /**\n * @defaultValue `false`\n */\n multiline?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabled?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabledOpacity?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface ListItemClassNameOptions extends BaseListItemClassNameOptions {\n /**\n * Set this to `false` if the list item should not gain the interaction\n * states: hover, focus, press, etc. This is kind of like being disabled\n * without the disabled styles being applied.\n *\n * @defaultValue `true`\n */\n clickable?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface InternalListItemClassNameOptions\n extends ListItemClassNameOptions {\n /**\n * @defaultValue `false`\n */\n link?: boolean;\n\n /**\n * This is prop is used internally when integrating with the\n * {@link useElementInteraction} hook.\n */\n pressedClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItem(\n options: InternalListItemClassNameOptions = {}\n): string {\n const {\n className,\n link = false,\n height = \"auto\",\n clickable = true,\n multiline = false,\n disabled = false,\n disabledOpacity = false,\n pressedClassName,\n } = options;\n\n return cnb(\n styles({\n link,\n [height]: height !== \"auto\",\n multiline,\n \"disabled-color\": disabled && !disabledOpacity,\n \"disabled-opacity\": disabled && disabledOpacity,\n }),\n cssUtils({ surface: clickable }),\n pressedClassName,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemTextClassNameOptions {\n className?: string;\n /**\n * @defaultValue `false`\n */\n clamped?: boolean;\n\n /**\n * @defaultValue `false`\n */\n secondary?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItemText(\n options: ListItemTextClassNameOptions = {}\n): string {\n const { className, secondary = false, clamped = false } = options;\n\n return cnb(\n styles(\"text\", {\n clamped: secondary && clamped,\n secondary,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemAddonClassNameOptions {\n className?: string;\n\n /**\n * The addon type that is used to adjust the spacing styles.\n *\n * @defaultValue `\"icon\"`\n */\n type?: ListItemAddonType;\n\n /**\n * The vertical position to use for the addon.\n *\n * @defaultValue `\"middle\"`\n */\n position?: ListItemAddonPosition;\n\n /**\n * Boolean if the addon should appear after the `children`.\n *\n * @defaultValue `false`\n */\n addonAfter?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableCenteredMedia?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableBeforeSpacing?: boolean;\n}\n\n/**\n *\n * @since 6.0.0\n */\nexport function listItemAddon(\n options: ListItemAddonClassNameOptions = {}\n): string {\n const {\n type = \"icon\",\n position = \"middle\",\n className,\n addonAfter = false,\n disableCenteredMedia = false,\n disableBeforeSpacing = false,\n } = options;\n\n const isMedia = type === \"media\" || type === \"large-media\";\n const isAvatar = type === \"avatar\";\n\n return cnb(\n styles(\"addon\", {\n [position]: position !== \"middle\",\n before: !disableBeforeSpacing && !addonAfter,\n \"avatar-before\": !disableBeforeSpacing && !addonAfter && isAvatar,\n media: isMedia,\n \"media-large\": type === \"large-media\",\n \"media-centered\": isMedia && !disableCenteredMedia,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","listItem","options","className","link","height","clickable","multiline","disabled","disabledOpacity","pressedClassName","surface","listItemText","secondary","clamped","listItemAddon","type","position","addonAfter","disableCenteredMedia","disableBeforeSpacing","isMedia","isAvatar","before","media"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AAOtC,MAAMC,SAASD,IAAI;AA8EnB;;CAEC,GACD,OAAO,SAASE,SACdC,UAA4C,CAAC,CAAC;IAE9C,MAAM,EACJC,SAAS,EACTC,OAAO,KAAK,EACZC,SAAS,MAAM,EACfC,YAAY,IAAI,EAChBC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,KAAK,EACvBC,gBAAgB,EACjB,GAAGR;IAEJ,OAAOL,IACLG,OAAO;QACLI;QACA,CAACC,OAAO,EAAEA,WAAW;QACrBE;QACA,kBAAkBC,YAAY,CAACC;QAC/B,oBAAoBD,YAAYC;IAClC,IACAX,SAAS;QAAEa,SAASL;IAAU,IAC9BI,kBACAP;AAEJ;AAgBA;;CAEC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAEU,YAAY,KAAK,EAAEC,UAAU,KAAK,EAAE,GAAGZ;IAE1D,OAAOL,IACLG,OAAO,QAAQ;QACbc,SAASD,aAAaC;QACtBD;IACF,IACAV;AAEJ;AAoDA;;;CAGC,GACD,OAAO,SAASY,cACdb,UAAyC,CAAC,CAAC;IAE3C,MAAM,EACJc,OAAO,MAAM,EACbC,WAAW,QAAQ,EACnBd,SAAS,EACTe,aAAa,KAAK,EAClBC,uBAAuB,KAAK,EAC5BC,uBAAuB,KAAK,EAC7B,GAAGlB;IAEJ,MAAMmB,UAAUL,SAAS,WAAWA,SAAS;IAC7C,MAAMM,WAAWN,SAAS;IAE1B,OAAOnB,IACLG,OAAO,SAAS;QACd,CAACiB,SAAS,EAAEA,aAAa;QACzBM,QAAQ,CAACH,wBAAwB,CAACF;QAClC,iBAAiB,CAACE,wBAAwB,CAACF,cAAcI;QACzDE,OAAOH;QACP,eAAeL,SAAS;QACxB,kBAAkBK,WAAW,CAACF;IAChC,IACAhB;AAEJ"}
1
+ {"version":3,"sources":["../../src/list/listItemStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemHeight,\n} from \"./types.js\";\n\nconst styles = bem(\"rmd-list-item\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-list-item-keyline\"?: string | number;\n \"--rmd-list-item-padding-h\"?: string | number;\n \"--rmd-list-item-padding-v\"?: string | number;\n \"--rmd-list-item-height\"?: string | number;\n \"--rmd-list-item-medium-height\"?: string | number;\n \"--rmd-list-item-large-height\"?: string | number;\n \"--rmd-list-item-extra-large-height\"?: string | number;\n \"--rmd-list-item-multiline-height\"?: string | number;\n \"--rmd-list-item-media-size\"?: string | number;\n \"--rmd-list-item-media-spacing\"?: string | number;\n \"--rmd-list-item-text-multiline-height\"?: string | number;\n \"--rmd-list-item-multiline-clamp\"?: string | number;\n }\n}\n\n/** @since 6.3.1 */\nexport interface BaseListItemClassNameOptions {\n className?: string;\n\n /**\n * @see {@link ListItemHeight}\n * @defaultValue `\"auto\"`\n */\n height?: ListItemHeight;\n\n /**\n * @defaultValue `false`\n */\n multiline?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabled?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabledOpacity?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface ListItemClassNameOptions extends BaseListItemClassNameOptions {\n /**\n * Set this to `false` if the list item should not gain the interaction\n * states: hover, focus, press, etc. This is kind of like being disabled\n * without the disabled styles being applied.\n *\n * @defaultValue `true`\n */\n clickable?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface InternalListItemClassNameOptions extends ListItemClassNameOptions {\n /**\n * @defaultValue `false`\n */\n link?: boolean;\n\n /**\n * This is prop is used internally when integrating with the\n * {@link useElementInteraction} hook.\n */\n pressedClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItem(\n options: InternalListItemClassNameOptions = {}\n): string {\n const {\n className,\n link = false,\n height = \"auto\",\n clickable = true,\n multiline = false,\n disabled = false,\n disabledOpacity = false,\n pressedClassName,\n } = options;\n\n return cnb(\n styles({\n link,\n [height]: height !== \"auto\",\n multiline,\n \"disabled-color\": disabled && !disabledOpacity,\n \"disabled-opacity\": disabled && disabledOpacity,\n }),\n cssUtils({ surface: clickable }),\n pressedClassName,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemTextClassNameOptions {\n className?: string;\n /**\n * @defaultValue `false`\n */\n clamped?: boolean;\n\n /**\n * @defaultValue `false`\n */\n secondary?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItemText(\n options: ListItemTextClassNameOptions = {}\n): string {\n const { className, secondary = false, clamped = false } = options;\n\n return cnb(\n styles(\"text\", {\n clamped: secondary && clamped,\n secondary,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemAddonClassNameOptions {\n className?: string;\n\n /**\n * The addon type that is used to adjust the spacing styles.\n *\n * @defaultValue `\"icon\"`\n */\n type?: ListItemAddonType;\n\n /**\n * The vertical position to use for the addon.\n *\n * @defaultValue `\"middle\"`\n */\n position?: ListItemAddonPosition;\n\n /**\n * Boolean if the addon should appear after the `children`.\n *\n * @defaultValue `false`\n */\n addonAfter?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableCenteredMedia?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableBeforeSpacing?: boolean;\n}\n\n/**\n *\n * @since 6.0.0\n */\nexport function listItemAddon(\n options: ListItemAddonClassNameOptions = {}\n): string {\n const {\n type = \"icon\",\n position = \"middle\",\n className,\n addonAfter = false,\n disableCenteredMedia = false,\n disableBeforeSpacing = false,\n } = options;\n\n const isMedia = type === \"media\" || type === \"large-media\";\n const isAvatar = type === \"avatar\";\n\n return cnb(\n styles(\"addon\", {\n [position]: position !== \"middle\",\n before: !disableBeforeSpacing && !addonAfter,\n \"avatar-before\": !disableBeforeSpacing && !addonAfter && isAvatar,\n media: isMedia,\n \"media-large\": type === \"large-media\",\n \"media-centered\": isMedia && !disableCenteredMedia,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","listItem","options","className","link","height","clickable","multiline","disabled","disabledOpacity","pressedClassName","surface","listItemText","secondary","clamped","listItemAddon","type","position","addonAfter","disableCenteredMedia","disableBeforeSpacing","isMedia","isAvatar","before","media"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AAOtC,MAAMC,SAASD,IAAI;AA6EnB;;CAEC,GACD,OAAO,SAASE,SACdC,UAA4C,CAAC,CAAC;IAE9C,MAAM,EACJC,SAAS,EACTC,OAAO,KAAK,EACZC,SAAS,MAAM,EACfC,YAAY,IAAI,EAChBC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,KAAK,EACvBC,gBAAgB,EACjB,GAAGR;IAEJ,OAAOL,IACLG,OAAO;QACLI;QACA,CAACC,OAAO,EAAEA,WAAW;QACrBE;QACA,kBAAkBC,YAAY,CAACC;QAC/B,oBAAoBD,YAAYC;IAClC,IACAX,SAAS;QAAEa,SAASL;IAAU,IAC9BI,kBACAP;AAEJ;AAgBA;;CAEC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAEU,YAAY,KAAK,EAAEC,UAAU,KAAK,EAAE,GAAGZ;IAE1D,OAAOL,IACLG,OAAO,QAAQ;QACbc,SAASD,aAAaC;QACtBD;IACF,IACAV;AAEJ;AAoDA;;;CAGC,GACD,OAAO,SAASY,cACdb,UAAyC,CAAC,CAAC;IAE3C,MAAM,EACJc,OAAO,MAAM,EACbC,WAAW,QAAQ,EACnBd,SAAS,EACTe,aAAa,KAAK,EAClBC,uBAAuB,KAAK,EAC5BC,uBAAuB,KAAK,EAC7B,GAAGlB;IAEJ,MAAMmB,UAAUL,SAAS,WAAWA,SAAS;IAC7C,MAAMM,WAAWN,SAAS;IAE1B,OAAOnB,IACLG,OAAO,SAAS;QACd,CAACiB,SAAS,EAAEA,aAAa;QACzBM,QAAQ,CAACH,wBAAwB,CAACF;QAClC,iBAAiB,CAACE,wBAAwB,CAACF,cAAcI;QACzDE,OAAOH;QACP,eAAeL,SAAS;QACxB,kBAAkBK,WAAW,CAACF;IAChC,IACAhB;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/list/types.ts"],"sourcesContent":["import { type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\n/**\n * The height to apply to the list item.\n *\n * Conversions:\n *\n * - height !== undefined && height !== \"auto\" -&gt; height\n * - secondaryText or left/right addon is media/media-large -&gt; \"extra-large\"\n * - left/right addon is avatar -&gt; \"large\"\n * - left/right addon is icon -&gt; \"medium\"\n * - no addons and no secondary text -&gt; \"normal\"\n */\nexport type ListItemHeight =\n | \"auto\"\n | \"normal\"\n | \"medium\"\n | \"large\"\n | \"extra-large\";\n\nexport type ListItemAddonPosition = \"top\" | \"middle\" | \"bottom\";\nexport type ListItemAddonType = \"icon\" | \"avatar\" | \"media\" | \"large-media\";\n\n/** @since 6.0.0 */\nexport interface ListItemChildrenAddonProps {\n /**\n * An optional addon to display to the left of the `primaryText` or\n * `children` and should be used with the `leftAddonType` prop to adjust\n * spacing.\n */\n leftAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the left of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n leftAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the left icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n leftAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n leftAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `leftAddonType === \"media\" || leftAddonType === \"large-media\"`\n * @since 6.0.0\n */\n leftAddonForceWrap?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableLeftAddonSpacing?: boolean;\n\n /**\n * An optional addon to display to the right of the `primaryText` or\n * `children` and should be used with the `rightAddonType` prop to adjust\n * spacing.\n */\n rightAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the right of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n rightAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the right icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n rightAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n rightAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `rightAddonType === \"media\" || rightAddonType === \"large-media\"`\n * @since 6.0.0\n */\n rightAddonForceWrap?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableLeftAddonCenteredMedia?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableRightAddonCenteredMedia?: boolean;\n}\n\n/**\n * Note: This interface was added since there are components that replace the\n * {@link ListItemChildrenAddonProps} with renamed versions but should still\n * support everything for rendering text.\n *\n * @since 6.0.0\n */\nexport interface ListItemChildrenTextProps {\n /**\n * The main content to display that defaults to being wrapped in the\n * `ListItemText` component. Enable the {@link disableTextChildren} prop to\n * render without the additional `ListItemText` wrapper.\n */\n children?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link children}, {@link primaryText}, and {@link secondaryText}.\n *\n * @since 6.0.0\n */\n textProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `primaryText` and optionally `secondaryText` within the list item.\n */\n textClassName?: string;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `secondaryText` within the list item.\n */\n secondaryTextClassName?: string;\n\n /**\n * Set this to `true` if the {@link children} should not automatically be\n * wrapped in the `ListItemText` component.\n *\n * @since 6.0.0 Renamed from `textChildren` since it was defaulted on.\n * @defaultValue `false`\n */\n disableTextChildren?: boolean;\n\n /**\n * An optional element that should be rendered as the `primaryText` within the\n * list item. It is most likely easier to use the `children` prop instead, but\n * this allows you to create more complex components with the `ListItem` since\n * you can provided `children` and have the styles for the `primaryText` still\n * applied. By default, this will only allow one line of text and add ellipsis\n * for any text overflow.\n */\n primaryText?: ReactNode;\n\n /**\n * An optional element that should be rendered as the `secondaryText` within\n * the list item. By default, this will only span one line and add ellipsis\n * for overflow.\n */\n secondaryText?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link secondaryText}.\n *\n * @since 6.0.0\n */\n secondaryTextProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Set this to `true` to allow the {@link secondaryText} to span multiple\n * lines and use the CSS clamp after two lines of text are visible. The number\n * of lines can be configured by `core.$list-item-multiline-clamp` or\n * `@include core.list-set-var(item-multiline-clamp, $new-value)`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp}\n * @defaultValue `false`\n */\n multiline?: boolean;\n}\n\n/**\n * @since 6.0.0 Extends the `ListItemChildrenTextProps` and\n * `ListItemChildrenAddonProps` interfaces.\n * @since 6.0.0 Added `textProps` and `secondaryTextClassName`\n * @since 6.0.0 Renamed `textChildren` to `disableTextChildren`\n */\nexport interface ListItemChildrenProps\n extends ListItemChildrenTextProps,\n ListItemChildrenAddonProps {}\n"],"names":[],"mappings":"AA8NA;;;;;CAKC,GACD,WAEiC"}
1
+ {"version":3,"sources":["../../src/list/types.ts"],"sourcesContent":["import { type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\n/**\n * The height to apply to the list item.\n *\n * Conversions:\n *\n * - height !== undefined && height !== \"auto\" -&gt; height\n * - secondaryText or left/right addon is media/media-large -&gt; \"extra-large\"\n * - left/right addon is avatar -&gt; \"large\"\n * - left/right addon is icon -&gt; \"medium\"\n * - no addons and no secondary text -&gt; \"normal\"\n */\nexport type ListItemHeight =\n | \"auto\"\n | \"normal\"\n | \"medium\"\n | \"large\"\n | \"extra-large\";\n\nexport type ListItemAddonPosition = \"top\" | \"middle\" | \"bottom\";\nexport type ListItemAddonType = \"icon\" | \"avatar\" | \"media\" | \"large-media\";\n\n/** @since 6.0.0 */\nexport interface ListItemChildrenAddonProps {\n /**\n * An optional addon to display to the left of the `primaryText` or\n * `children` and should be used with the `leftAddonType` prop to adjust\n * spacing.\n */\n leftAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the left of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n leftAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the left icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n leftAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n leftAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `leftAddonType === \"media\" || leftAddonType === \"large-media\"`\n * @since 6.0.0\n */\n leftAddonForceWrap?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableLeftAddonSpacing?: boolean;\n\n /**\n * An optional addon to display to the right of the `primaryText` or\n * `children` and should be used with the `rightAddonType` prop to adjust\n * spacing.\n */\n rightAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the right of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n rightAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the right icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n rightAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n rightAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `rightAddonType === \"media\" || rightAddonType === \"large-media\"`\n * @since 6.0.0\n */\n rightAddonForceWrap?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableLeftAddonCenteredMedia?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableRightAddonCenteredMedia?: boolean;\n}\n\n/**\n * Note: This interface was added since there are components that replace the\n * {@link ListItemChildrenAddonProps} with renamed versions but should still\n * support everything for rendering text.\n *\n * @since 6.0.0\n */\nexport interface ListItemChildrenTextProps {\n /**\n * The main content to display that defaults to being wrapped in the\n * `ListItemText` component. Enable the {@link disableTextChildren} prop to\n * render without the additional `ListItemText` wrapper.\n */\n children?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link children}, {@link primaryText}, and {@link secondaryText}.\n *\n * @since 6.0.0\n */\n textProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `primaryText` and optionally `secondaryText` within the list item.\n */\n textClassName?: string;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `secondaryText` within the list item.\n */\n secondaryTextClassName?: string;\n\n /**\n * Set this to `true` if the {@link children} should not automatically be\n * wrapped in the `ListItemText` component.\n *\n * @since 6.0.0 Renamed from `textChildren` since it was defaulted on.\n * @defaultValue `false`\n */\n disableTextChildren?: boolean;\n\n /**\n * An optional element that should be rendered as the `primaryText` within the\n * list item. It is most likely easier to use the `children` prop instead, but\n * this allows you to create more complex components with the `ListItem` since\n * you can provided `children` and have the styles for the `primaryText` still\n * applied. By default, this will only allow one line of text and add ellipsis\n * for any text overflow.\n */\n primaryText?: ReactNode;\n\n /**\n * An optional element that should be rendered as the `secondaryText` within\n * the list item. By default, this will only span one line and add ellipsis\n * for overflow.\n */\n secondaryText?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link secondaryText}.\n *\n * @since 6.0.0\n */\n secondaryTextProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Set this to `true` to allow the {@link secondaryText} to span multiple\n * lines and use the CSS clamp after two lines of text are visible. The number\n * of lines can be configured by `core.$list-item-multiline-clamp` or\n * `@include core.list-set-var(item-multiline-clamp, $new-value)`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp}\n * @defaultValue `false`\n */\n multiline?: boolean;\n}\n\n/**\n * @since 6.0.0 Extends the `ListItemChildrenTextProps` and\n * `ListItemChildrenAddonProps` interfaces.\n * @since 6.0.0 Added `textProps` and `secondaryTextClassName`\n * @since 6.0.0 Renamed `textChildren` to `disableTextChildren`\n */\nexport interface ListItemChildrenProps\n extends ListItemChildrenTextProps, ListItemChildrenAddonProps {}\n"],"names":[],"mappings":"AA8NA;;;;;CAKC,GACD,WACkE"}
@@ -25,6 +25,8 @@ export declare function useAppSize(): Readonly<AppSize>;
25
25
  * @since 6.0.0 Renamed from `AppSizeListenerProps`.
26
26
  * @since 6.0.0 Removed the `onChange` prop
27
27
  * @since 6.0.0 Renamed `defaultSize` to `ssrSize`
28
+ * @since 6.4.0 Deprecated the `AppSizeQueries` in favor
29
+ * of the `MEDIA_QUERY_CONFIG`
28
30
  */
29
31
  export interface AppSizeProviderProps extends AppSizeQueries {
30
32
  /**
@@ -3,7 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useMemo } from "react";
4
4
  import { useSsr } from "../SsrProvider.js";
5
5
  import { useOrientation } from "../useOrientation.js";
6
- import { DEFAULT_APP_SIZE, DEFAULT_DESKTOP_LARGE_MIN_WIDTH, DEFAULT_DESKTOP_MIN_WIDTH, DEFAULT_PHONE_MAX_WIDTH, DEFAULT_TABLET_MAX_WIDTH, DEFAULT_TABLET_MIN_WIDTH } from "./appSize.js";
6
+ import { DEFAULT_APP_SIZE } from "./appSize.js";
7
+ import { MEDIA_QUERY_CONFIG } from "./config.js";
7
8
  import { useMediaQuery } from "./useMediaQuery.js";
8
9
  const context = /*#__PURE__*/ createContext({
9
10
  __root: false,
@@ -51,7 +52,7 @@ const { Provider } = context;
51
52
  * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}
52
53
  * @since 6.0.0 Renamed from `AppSizeListener`
53
54
  */ export function AppSizeProvider(props) {
54
- const { ssrSize = DEFAULT_APP_SIZE, phoneMaxWidth = DEFAULT_PHONE_MAX_WIDTH, tabletMinWidth = DEFAULT_TABLET_MIN_WIDTH, tabletMaxWidth = DEFAULT_TABLET_MAX_WIDTH, desktopMinWidth = DEFAULT_DESKTOP_MIN_WIDTH, desktopLargeMinWidth = DEFAULT_DESKTOP_LARGE_MIN_WIDTH, children } = props;
55
+ const { ssrSize = DEFAULT_APP_SIZE, phoneMaxWidth = MEDIA_QUERY_CONFIG.phoneMaxWidth, tabletMinWidth = MEDIA_QUERY_CONFIG.tabletMinWidth, tabletMaxWidth = MEDIA_QUERY_CONFIG.tabletMaxWidth, desktopMinWidth = MEDIA_QUERY_CONFIG.desktopMinWidth, desktopLargeMinWidth = MEDIA_QUERY_CONFIG.desktopLargeMinWidth, children } = props;
55
56
  const { __root } = useContext(context);
56
57
  if (__root) {
57
58
  throw new Error("The `AppSizeProvider` cannot be mounted multiple times.");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/media-queries/AppSizeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n} from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useOrientation } from \"../useOrientation.js\";\nimport {\n type AppSize,\n type AppSizeQueries,\n DEFAULT_APP_SIZE,\n DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n DEFAULT_DESKTOP_MIN_WIDTH,\n DEFAULT_PHONE_MAX_WIDTH,\n DEFAULT_TABLET_MAX_WIDTH,\n DEFAULT_TABLET_MIN_WIDTH,\n} from \"./appSize.js\";\nimport { useMediaQuery } from \"./useMediaQuery.js\";\n\n/** @internal */\ninterface AppSizeContext extends AppSize {\n __root: boolean;\n}\n\nconst context = createContext<AppSizeContext>({\n __root: false,\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n});\ncontext.displayName = \"AppSize\";\nconst { Provider } = context;\n\n/**\n * **Note**: The app size object returned by this hook will **not** be equal\n * between renders.\n *\n * @example Simple Example\n * ```tsx\n * import { useAppSize } from \"@react-md/core/media-queries/AppSizeProvider\";\n *\n * function Example() {\n * const { isPhone, isTablet, isDesktop, isLargeDesktop, isLandscape } =\n * useAppSize()\n *\n * // do something based on the app size\n * return null;\n * }\n * ```\n *\n * @returns the current app size.\n * @throws \"The `AppSizeProvider` has not been mounted.\"\n */\nexport function useAppSize(): Readonly<AppSize> {\n const { __root, ...appSize } = useContext(context);\n if (!__root) {\n throw new Error(\"The `AppSizeProvider` has not been mounted.\");\n }\n\n return appSize;\n}\n\n/**\n * @since 6.0.0 Renamed from `AppSizeListenerProps`.\n * @since 6.0.0 Removed the `onChange` prop\n * @since 6.0.0 Renamed `defaultSize` to `ssrSize`\n */\nexport interface AppSizeProviderProps extends AppSizeQueries {\n /**\n * @defaultValue `DEFAULT_APP_SIZE`\n * @see {@link DEFAULT_APP_SIZE}\n * @since 6.0.0\n */\n ssrSize?: Readonly<AppSize>;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component should be mounted near the root of your app to determine the\n * current app size based on different media queries.\n *\n * @see {@link https://react-md.dev/components/core-providers | CoreProviders Demos}\n * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}\n * @since 6.0.0 Renamed from `AppSizeListener`\n */\nexport function AppSizeProvider(props: AppSizeProviderProps): ReactElement {\n const {\n ssrSize = DEFAULT_APP_SIZE,\n phoneMaxWidth = DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth = DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth = DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth = DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth = DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n children,\n } = props;\n const { __root } = useContext(context);\n if (__root) {\n throw new Error(\"The `AppSizeProvider` cannot be mounted multiple times.\");\n }\n\n const ssr = useSsr();\n const matchesDesktop = useMediaQuery(\n `screen and (min-width: ${desktopMinWidth})`\n );\n const matchesLargeDesktop = useMediaQuery(\n `screen and (min-width: ${desktopLargeMinWidth})`\n );\n const matchesTablet = useMediaQuery(\n `screen and (min-width: ${tabletMinWidth}) and (max-width: ${tabletMaxWidth})`\n );\n const matchesPhone = useMediaQuery(\n `screen and (max-width: ${phoneMaxWidth})`\n );\n const isDesktop = matchesDesktop;\n const isTablet = !matchesDesktop && matchesTablet;\n const isPhone = !isTablet && !isDesktop && matchesPhone;\n const isLandscape = useOrientation().includes(\"landscape\");\n const isLargeDesktop = matchesLargeDesktop;\n\n const appSize = useMemo<AppSizeContext>(\n () => ({\n __root: true,\n isPhone,\n isTablet,\n isDesktop,\n isLargeDesktop,\n isLandscape,\n }),\n [isDesktop, isLandscape, isLargeDesktop, isPhone, isTablet]\n );\n\n let value = appSize;\n if (ssr || typeof window === \"undefined\") {\n value = {\n __root: true,\n ...ssrSize,\n };\n }\n\n return <Provider value={value}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","useSsr","useOrientation","DEFAULT_APP_SIZE","DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","useMediaQuery","context","__root","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape","displayName","Provider","useAppSize","appSize","Error","AppSizeProvider","props","ssrSize","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","children","ssr","matchesDesktop","matchesLargeDesktop","matchesTablet","matchesPhone","includes","value","window"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,EACVC,OAAO,QACF,QAAQ;AAEf,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAGEC,gBAAgB,EAChBC,+BAA+B,EAC/BC,yBAAyB,EACzBC,uBAAuB,EACvBC,wBAAwB,EACxBC,wBAAwB,QACnB,eAAe;AACtB,SAASC,aAAa,QAAQ,qBAAqB;AAOnD,MAAMC,wBAAUZ,cAA8B;IAC5Ca,QAAQ;IACRC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf;AACAN,QAAQO,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGR;AAErB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASS;IACd,MAAM,EAAER,MAAM,EAAE,GAAGS,SAAS,GAAGrB,WAAWW;IAC1C,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIU,MAAM;IAClB;IAEA,OAAOD;AACT;AAiBA;;;;;;;;;CASC,GACD,OAAO,SAASE,gBAAgBC,KAA2B;IACzD,MAAM,EACJC,UAAUrB,gBAAgB,EAC1BsB,gBAAgBnB,uBAAuB,EACvCoB,iBAAiBlB,wBAAwB,EACzCmB,iBAAiBpB,wBAAwB,EACzCqB,kBAAkBvB,yBAAyB,EAC3CwB,uBAAuBzB,+BAA+B,EACtD0B,QAAQ,EACT,GAAGP;IACJ,MAAM,EAAEZ,MAAM,EAAE,GAAGZ,WAAWW;IAC9B,IAAIC,QAAQ;QACV,MAAM,IAAIU,MAAM;IAClB;IAEA,MAAMU,MAAM9B;IACZ,MAAM+B,iBAAiBvB,cACrB,CAAC,uBAAuB,EAAEmB,gBAAgB,CAAC,CAAC;IAE9C,MAAMK,sBAAsBxB,cAC1B,CAAC,uBAAuB,EAAEoB,qBAAqB,CAAC,CAAC;IAEnD,MAAMK,gBAAgBzB,cACpB,CAAC,uBAAuB,EAAEiB,eAAe,kBAAkB,EAAEC,eAAe,CAAC,CAAC;IAEhF,MAAMQ,eAAe1B,cACnB,CAAC,uBAAuB,EAAEgB,cAAc,CAAC,CAAC;IAE5C,MAAMX,YAAYkB;IAClB,MAAMnB,WAAW,CAACmB,kBAAkBE;IACpC,MAAMtB,UAAU,CAACC,YAAY,CAACC,aAAaqB;IAC3C,MAAMnB,cAAcd,iBAAiBkC,QAAQ,CAAC;IAC9C,MAAMrB,iBAAiBkB;IAEvB,MAAMb,UAAUpB,QACd,IAAO,CAAA;YACLW,QAAQ;YACRC;YACAC;YACAC;YACAC;YACAC;QACF,CAAA,GACA;QAACF;QAAWE;QAAaD;QAAgBH;QAASC;KAAS;IAG7D,IAAIwB,QAAQjB;IACZ,IAAIW,OAAO,OAAOO,WAAW,aAAa;QACxCD,QAAQ;YACN1B,QAAQ;YACR,GAAGa,OAAO;QACZ;IACF;IAEA,qBAAO,KAACN;QAASmB,OAAOA;kBAAQP;;AAClC"}
1
+ {"version":3,"sources":["../../src/media-queries/AppSizeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n} from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useOrientation } from \"../useOrientation.js\";\nimport {\n type AppSize,\n type AppSizeQueries,\n DEFAULT_APP_SIZE,\n} from \"./appSize.js\";\nimport { MEDIA_QUERY_CONFIG } from \"./config.js\";\nimport { useMediaQuery } from \"./useMediaQuery.js\";\n\n/** @internal */\ninterface AppSizeContext extends AppSize {\n __root: boolean;\n}\n\nconst context = createContext<AppSizeContext>({\n __root: false,\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n});\ncontext.displayName = \"AppSize\";\nconst { Provider } = context;\n\n/**\n * **Note**: The app size object returned by this hook will **not** be equal\n * between renders.\n *\n * @example Simple Example\n * ```tsx\n * import { useAppSize } from \"@react-md/core/media-queries/AppSizeProvider\";\n *\n * function Example() {\n * const { isPhone, isTablet, isDesktop, isLargeDesktop, isLandscape } =\n * useAppSize()\n *\n * // do something based on the app size\n * return null;\n * }\n * ```\n *\n * @returns the current app size.\n * @throws \"The `AppSizeProvider` has not been mounted.\"\n */\nexport function useAppSize(): Readonly<AppSize> {\n const { __root, ...appSize } = useContext(context);\n if (!__root) {\n throw new Error(\"The `AppSizeProvider` has not been mounted.\");\n }\n\n return appSize;\n}\n\n/**\n * @since 6.0.0 Renamed from `AppSizeListenerProps`.\n * @since 6.0.0 Removed the `onChange` prop\n * @since 6.0.0 Renamed `defaultSize` to `ssrSize`\n * @since 6.4.0 Deprecated the `AppSizeQueries` in favor\n * of the `MEDIA_QUERY_CONFIG`\n */\nexport interface AppSizeProviderProps extends AppSizeQueries {\n /**\n * @defaultValue `DEFAULT_APP_SIZE`\n * @see {@link DEFAULT_APP_SIZE}\n * @since 6.0.0\n */\n ssrSize?: Readonly<AppSize>;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component should be mounted near the root of your app to determine the\n * current app size based on different media queries.\n *\n * @see {@link https://react-md.dev/components/core-providers | CoreProviders Demos}\n * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}\n * @since 6.0.0 Renamed from `AppSizeListener`\n */\nexport function AppSizeProvider(props: AppSizeProviderProps): ReactElement {\n const {\n ssrSize = DEFAULT_APP_SIZE,\n phoneMaxWidth = MEDIA_QUERY_CONFIG.phoneMaxWidth,\n tabletMinWidth = MEDIA_QUERY_CONFIG.tabletMinWidth,\n tabletMaxWidth = MEDIA_QUERY_CONFIG.tabletMaxWidth,\n desktopMinWidth = MEDIA_QUERY_CONFIG.desktopMinWidth,\n desktopLargeMinWidth = MEDIA_QUERY_CONFIG.desktopLargeMinWidth,\n children,\n } = props;\n const { __root } = useContext(context);\n if (__root) {\n throw new Error(\"The `AppSizeProvider` cannot be mounted multiple times.\");\n }\n\n const ssr = useSsr();\n const matchesDesktop = useMediaQuery(\n `screen and (min-width: ${desktopMinWidth})`\n );\n const matchesLargeDesktop = useMediaQuery(\n `screen and (min-width: ${desktopLargeMinWidth})`\n );\n const matchesTablet = useMediaQuery(\n `screen and (min-width: ${tabletMinWidth}) and (max-width: ${tabletMaxWidth})`\n );\n const matchesPhone = useMediaQuery(\n `screen and (max-width: ${phoneMaxWidth})`\n );\n const isDesktop = matchesDesktop;\n const isTablet = !matchesDesktop && matchesTablet;\n const isPhone = !isTablet && !isDesktop && matchesPhone;\n const isLandscape = useOrientation().includes(\"landscape\");\n const isLargeDesktop = matchesLargeDesktop;\n\n const appSize = useMemo<AppSizeContext>(\n () => ({\n __root: true,\n isPhone,\n isTablet,\n isDesktop,\n isLargeDesktop,\n isLandscape,\n }),\n [isDesktop, isLandscape, isLargeDesktop, isPhone, isTablet]\n );\n\n let value = appSize;\n if (ssr || typeof window === \"undefined\") {\n value = {\n __root: true,\n ...ssrSize,\n };\n }\n\n return <Provider value={value}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","useSsr","useOrientation","DEFAULT_APP_SIZE","MEDIA_QUERY_CONFIG","useMediaQuery","context","__root","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape","displayName","Provider","useAppSize","appSize","Error","AppSizeProvider","props","ssrSize","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","children","ssr","matchesDesktop","matchesLargeDesktop","matchesTablet","matchesPhone","includes","value","window"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,EACVC,OAAO,QACF,QAAQ;AAEf,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAGEC,gBAAgB,QACX,eAAe;AACtB,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,aAAa,QAAQ,qBAAqB;AAOnD,MAAMC,wBAAUR,cAA8B;IAC5CS,QAAQ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;IAEvB,MAAMb,UAAUhB,QACd,IAAO,CAAA;YACLO,QAAQ;YACRC;YACAC;YACAC;YACAC;YACAC;QACF,CAAA,GACA;QAACF;QAAWE;QAAaD;QAAgBH;QAASC;KAAS;IAG7D,IAAIwB,QAAQjB;IACZ,IAAIW,OAAO,OAAOO,WAAW,aAAa;QACxCD,QAAQ;YACN1B,QAAQ;YACR,GAAGa,OAAO;QACZ;IACF;IAEA,qBAAO,KAACN;QAASmB,OAAOA;kBAAQP;;AAClC"}
@@ -49,6 +49,9 @@ export interface AppSizeQueries {
49
49
  */
50
50
  desktopLargeMinWidth?: QuerySize;
51
51
  }
52
+ /**
53
+ * @deprecated Use `MEDIA_QUERY_CONFIG` instead.
54
+ */
52
55
  export declare const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries>;
53
56
  /**
54
57
  * The current size for your application. This should work both server side and
@@ -3,7 +3,9 @@
3
3
  /** @defaultValue `64em` */ export const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em`;
4
4
  /** @defaultValue `64.0625em` */ export const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em`;
5
5
  /** @defaultValue `80em` */ export const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${1280 / 16}em`;
6
- export const DEFAULT_APP_SIZE_QUERIES = {
6
+ /**
7
+ * @deprecated Use `MEDIA_QUERY_CONFIG` instead.
8
+ */ export const DEFAULT_APP_SIZE_QUERIES = {
7
9
  phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,
8
10
  tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,
9
11
  tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/media-queries/appSize.ts"],"sourcesContent":["export type QuerySize = number | `${number}${string}`;\n\n/** @defaultValue `47.9375em` */\nexport const DEFAULT_PHONE_MAX_WIDTH = `${767 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `48em` */\nexport const DEFAULT_TABLET_MIN_WIDTH = `${768 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64em` */\nexport const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64.0625em` */\nexport const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `80em` */\nexport const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${\n 1280 / 16\n}em` satisfies QuerySize;\n\nexport interface AppSizeQueries {\n /**\n * The max width to use for phones. This one is a max width unlike the others\n * since everything from 0 to this value will be considered a phone.\n *\n * @defaultValue `47.9375em`\n * @see {@link DEFAULT_PHONE_MAX_WIDTH}\n */\n phoneMaxWidth?: QuerySize;\n\n /**\n * The min width for a tablet device.\n *\n * @defaultValue `48em`\n * @see {@link DEFAULT_TABLET_MIN_WIDTH}\n */\n tabletMinWidth?: QuerySize;\n\n /**\n * The max width for a tablet device. This should normally be `1px` less than\n * the `desktopMinWidth`, but it can be any value if needed. The tablet has a\n * range of min to max so that you can have a bit more control.\n *\n * @defaultValue `64em`\n * @see {@link DEFAULT_TABLET_MAX_WIDTH}\n */\n tabletMaxWidth?: QuerySize;\n\n /**\n * The min width for a desktop screen.\n *\n * @defaultValue `64.0625em`\n * @see {@link DEFAULT_DESKTOP_MIN_WIDTH}\n */\n desktopMinWidth?: QuerySize;\n\n /**\n * The min width for a large (1440p, 4k, etc) desktop screen.\n *\n * @defaultValue `80em`\n * @see {@link DEFAULT_DESKTOP_LARGE_MIN_WIDTH}\n */\n desktopLargeMinWidth?: QuerySize;\n}\n\nexport const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries> = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * The current size for your application. This should work both server side and\n * client side, but you will have much better results client side.\n */\nexport interface AppSize {\n /**\n * Boolean if currently matching a phone by comparing the max width of the\n * device.\n */\n isPhone: boolean;\n\n /**\n * Boolean if currently matching a tablet by comparing the max width of the\n * device.\n */\n isTablet: boolean;\n\n /**\n * Boolean if currently matching a desktop screen by comparing the max width\n * of the device.\n */\n isDesktop: boolean;\n\n /**\n * Boolean if currently matching a large desktop screen by comparing the max\n * width of the device.\n */\n isLargeDesktop: boolean;\n\n /**\n * Boolean if the app is considered to be in landscape mode. This will just\n * verify that the window width is greater than the window height.\n *\n * NOTE: This might not be super accurate on Android devices since the soft\n * keyboard will change the dimensions of the viewport when it appears. It is\n * recommended to use the `useOrientation` hook as well if you'd like to get\n * the current orientation type.\n */\n isLandscape: boolean;\n}\n\nexport const DEFAULT_APP_SIZE: AppSize = {\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n};\n"],"names":["DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_APP_SIZE_QUERIES","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","DEFAULT_APP_SIZE","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape"],"mappings":"AAEA,8BAA8B,GAC9B,OAAO,MAAMA,0BAA0B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE3E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE7E,8BAA8B,GAC9B,OAAO,MAAMC,4BAA4B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE9E,yBAAyB,GACzB,OAAO,MAAMC,kCAAkC,GAC7C,OAAO,GACR,EAAE,CAAC,CAAqB;AA+CzB,OAAO,MAAMC,2BAAqD;IAChEC,eAAeN;IACfO,gBAAgBN;IAChBO,gBAAgBN;IAChBO,iBAAiBN;IACjBO,sBAAsBN;AACxB,EAAE;AA2CF,OAAO,MAAMO,mBAA4B;IACvCC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf,EAAE"}
1
+ {"version":3,"sources":["../../src/media-queries/appSize.ts"],"sourcesContent":["export type QuerySize = number | `${number}${string}`;\n\n/** @defaultValue `47.9375em` */\nexport const DEFAULT_PHONE_MAX_WIDTH = `${767 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `48em` */\nexport const DEFAULT_TABLET_MIN_WIDTH = `${768 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64em` */\nexport const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64.0625em` */\nexport const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `80em` */\nexport const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${\n 1280 / 16\n}em` satisfies QuerySize;\n\nexport interface AppSizeQueries {\n /**\n * The max width to use for phones. This one is a max width unlike the others\n * since everything from 0 to this value will be considered a phone.\n *\n * @defaultValue `47.9375em`\n * @see {@link DEFAULT_PHONE_MAX_WIDTH}\n */\n phoneMaxWidth?: QuerySize;\n\n /**\n * The min width for a tablet device.\n *\n * @defaultValue `48em`\n * @see {@link DEFAULT_TABLET_MIN_WIDTH}\n */\n tabletMinWidth?: QuerySize;\n\n /**\n * The max width for a tablet device. This should normally be `1px` less than\n * the `desktopMinWidth`, but it can be any value if needed. The tablet has a\n * range of min to max so that you can have a bit more control.\n *\n * @defaultValue `64em`\n * @see {@link DEFAULT_TABLET_MAX_WIDTH}\n */\n tabletMaxWidth?: QuerySize;\n\n /**\n * The min width for a desktop screen.\n *\n * @defaultValue `64.0625em`\n * @see {@link DEFAULT_DESKTOP_MIN_WIDTH}\n */\n desktopMinWidth?: QuerySize;\n\n /**\n * The min width for a large (1440p, 4k, etc) desktop screen.\n *\n * @defaultValue `80em`\n * @see {@link DEFAULT_DESKTOP_LARGE_MIN_WIDTH}\n */\n desktopLargeMinWidth?: QuerySize;\n}\n\n/**\n * @deprecated Use `MEDIA_QUERY_CONFIG` instead.\n */\nexport const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries> = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * The current size for your application. This should work both server side and\n * client side, but you will have much better results client side.\n */\nexport interface AppSize {\n /**\n * Boolean if currently matching a phone by comparing the max width of the\n * device.\n */\n isPhone: boolean;\n\n /**\n * Boolean if currently matching a tablet by comparing the max width of the\n * device.\n */\n isTablet: boolean;\n\n /**\n * Boolean if currently matching a desktop screen by comparing the max width\n * of the device.\n */\n isDesktop: boolean;\n\n /**\n * Boolean if currently matching a large desktop screen by comparing the max\n * width of the device.\n */\n isLargeDesktop: boolean;\n\n /**\n * Boolean if the app is considered to be in landscape mode. This will just\n * verify that the window width is greater than the window height.\n *\n * NOTE: This might not be super accurate on Android devices since the soft\n * keyboard will change the dimensions of the viewport when it appears. It is\n * recommended to use the `useOrientation` hook as well if you'd like to get\n * the current orientation type.\n */\n isLandscape: boolean;\n}\n\nexport const DEFAULT_APP_SIZE: AppSize = {\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n};\n"],"names":["DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_APP_SIZE_QUERIES","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","DEFAULT_APP_SIZE","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape"],"mappings":"AAEA,8BAA8B,GAC9B,OAAO,MAAMA,0BAA0B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE3E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE7E,8BAA8B,GAC9B,OAAO,MAAMC,4BAA4B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE9E,yBAAyB,GACzB,OAAO,MAAMC,kCAAkC,GAC7C,OAAO,GACR,EAAE,CAAC,CAAqB;AA+CzB;;CAEC,GACD,OAAO,MAAMC,2BAAqD;IAChEC,eAAeN;IACfO,gBAAgBN;IAChBO,gBAAgBN;IAChBO,iBAAiBN;IACjBO,sBAAsBN;AACxB,EAAE;AA2CF,OAAO,MAAMO,mBAA4B;IACvCC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf,EAAE"}
@@ -0,0 +1,11 @@
1
+ import { type AppSizeQueries } from "./appSize.js";
2
+ /** @since 6.4.0 */
3
+ export type MediaQueryConfig = Required<AppSizeQueries>;
4
+ /**
5
+ * @since 6.4.0
6
+ */
7
+ export declare const MEDIA_QUERY_CONFIG: MediaQueryConfig;
8
+ /**
9
+ * @since 6.4.0
10
+ */
11
+ export declare function configureMediaQueries(queries: Readonly<Partial<MediaQueryConfig>>): void;
@@ -0,0 +1,26 @@
1
+ import { DEFAULT_DESKTOP_LARGE_MIN_WIDTH, DEFAULT_DESKTOP_MIN_WIDTH, DEFAULT_PHONE_MAX_WIDTH, DEFAULT_TABLET_MAX_WIDTH, DEFAULT_TABLET_MIN_WIDTH } from "./appSize.js";
2
+ /**
3
+ * @since 6.4.0
4
+ */ export const MEDIA_QUERY_CONFIG = {
5
+ phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,
6
+ tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,
7
+ tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,
8
+ desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,
9
+ desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH
10
+ };
11
+ /**
12
+ * @since 6.4.0
13
+ */ export function configureMediaQueries(queries) {
14
+ if (process.env.NODE_ENV !== "production") {
15
+ Object.entries(queries).forEach(([name, value])=>{
16
+ if (!(name in MEDIA_QUERY_CONFIG)) {
17
+ throw new Error(`${name} is an invalid react-md media query.`);
18
+ }
19
+ MEDIA_QUERY_CONFIG[name] = value;
20
+ });
21
+ } else {
22
+ Object.assign(MEDIA_QUERY_CONFIG, queries);
23
+ }
24
+ }
25
+
26
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/media-queries/config.ts"],"sourcesContent":["import {\n type AppSizeQueries,\n DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n DEFAULT_DESKTOP_MIN_WIDTH,\n DEFAULT_PHONE_MAX_WIDTH,\n DEFAULT_TABLET_MAX_WIDTH,\n DEFAULT_TABLET_MIN_WIDTH,\n} from \"./appSize.js\";\n\n/** @since 6.4.0 */\nexport type MediaQueryConfig = Required<AppSizeQueries>;\n\n/**\n * @since 6.4.0\n */\nexport const MEDIA_QUERY_CONFIG: MediaQueryConfig = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * @since 6.4.0\n */\nexport function configureMediaQueries(\n queries: Readonly<Partial<MediaQueryConfig>>\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n Object.entries(queries).forEach(([name, value]) => {\n if (!(name in MEDIA_QUERY_CONFIG)) {\n throw new Error(`${name} is an invalid react-md media query.`);\n }\n\n MEDIA_QUERY_CONFIG[name as keyof MediaQueryConfig] = value;\n });\n } else {\n Object.assign(MEDIA_QUERY_CONFIG, queries);\n }\n}\n"],"names":["DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","MEDIA_QUERY_CONFIG","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","configureMediaQueries","queries","process","env","NODE_ENV","Object","entries","forEach","name","value","Error","assign"],"mappings":"AAAA,SAEEA,+BAA+B,EAC/BC,yBAAyB,EACzBC,uBAAuB,EACvBC,wBAAwB,EACxBC,wBAAwB,QACnB,eAAe;AAKtB;;CAEC,GACD,OAAO,MAAMC,qBAAuC;IAClDC,eAAeJ;IACfK,gBAAgBH;IAChBI,gBAAgBL;IAChBM,iBAAiBR;IACjBS,sBAAsBV;AACxB,EAAE;AAEF;;CAEC,GACD,OAAO,SAASW,sBACdC,OAA4C;IAE5C,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzCC,OAAOC,OAAO,CAACL,SAASM,OAAO,CAAC,CAAC,CAACC,MAAMC,MAAM;YAC5C,IAAI,CAAED,CAAAA,QAAQd,kBAAiB,GAAI;gBACjC,MAAM,IAAIgB,MAAM,GAAGF,KAAK,oCAAoC,CAAC;YAC/D;YAEAd,kBAAkB,CAACc,KAA+B,GAAGC;QACvD;IACF,OAAO;QACLJ,OAAOM,MAAM,CAACjB,oBAAoBO;IACpC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/DropdownMenu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { getLastFocusableIndex } from \"../movement/utils.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport {\n Menu,\n type MenuConvenienceProps,\n type MenuListConvenienceProps,\n} from \"./Menu.js\";\nimport { MenuButton, type MenuButtonProps } from \"./MenuButton.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuItemButton, type MenuItemButtonProps } from \"./MenuItemButton.js\";\nimport { type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuVisibilityProvider } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nexport interface BaseDropdownMenuProps\n extends MenuConfiguration,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps,\n MenuConvenienceProps {\n buttonChildren: ReactNode;\n}\n\nexport interface DropdownMenuButtonProps\n extends MenuButtonProps,\n BaseDropdownMenuProps {}\n\nexport interface DropdownMenuItemButtonProps\n extends MenuItemButtonProps,\n BaseDropdownMenuProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface DropdownMenuStateProps {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use an `&` instead of `|` to allow autocompletion to\n * work better by default. It's up to the user to make sure they don't provide\n * incorrect props.\n */\nexport type DropdownMenuProps = DropdownMenuButtonProps &\n DropdownMenuItemButtonProps &\n (DropdownMenuStateProps | { visible?: never; setVisible?: never });\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @example Nested Dropdown Menus\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * <DropdownMenu buttonChildren=\"Nested Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Nested Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Nested Item 2\n * </MenuItem>\n * </DropdownMenu>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport function DropdownMenu(props: DropdownMenuProps): ReactElement {\n const {\n id: propId,\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n buttonChildren,\n iconRotatorProps: propIconRotatorProps,\n disableTransition: propDisableTransition,\n floating,\n anchor,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n initialX,\n initialY,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n preventScroll,\n closeOnResize,\n closeOnScroll,\n getFixedPositionOptions,\n children,\n temporary,\n disablePortal,\n disableElevation,\n menuProps,\n menuStyle,\n menuClassName,\n sheetProps,\n sheetStyle,\n sheetClassName,\n visible: propVisible,\n setVisible: propSetVisible,\n ...remaining\n } = props;\n\n const fixedTo = useRef<HTMLElement | HTMLButtonElement>(null);\n const defaultFocusIndex = useRef(0);\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: false,\n });\n const { menubar, menuitem, activeIdRef, animatedOnceRef } =\n useMenuBarContext();\n const id = useEnsuredId(propId, `menu${menuitem ? \"item\" : \"button\"}`);\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n const keyboard = mode === \"keyboard\";\n const disableTransition =\n propDisableTransition ??\n (animatedOnceRef.current &&\n menubar &&\n !!activeIdRef.current &&\n (mouse || keyboard));\n\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n let iconRotatorProps = propIconRotatorProps;\n if (disableTransition) {\n iconRotatorProps = {\n disableTransition,\n ...propIconRotatorProps,\n };\n }\n\n let toggle: ReactElement;\n if (menuitem) {\n toggle = (\n <MenuItemButton\n {...(remaining as DropdownMenuItemButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLLIElement>}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuItemButton>\n );\n } else {\n toggle = (\n <MenuButton\n {...(remaining as DropdownMenuButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLButtonElement>}\n floating={floating}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuButton>\n );\n }\n\n return (\n <MenuVisibilityProvider\n visible={visible}\n setVisible={setVisible}\n defaultFocusIndex={defaultFocusIndex}\n >\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n {toggle}\n </MenuConfigurationProvider>\n <Menu\n aria-labelledby={(menuProps?.[\"aria-label\"] ? undefined : id) as string}\n style={menuStyle}\n className={menuClassName}\n sheetProps={sheetProps}\n sheetStyle={sheetStyle}\n sheetClassName={sheetClassName}\n temporary={temporary}\n disablePortal={disablePortal}\n disableElevation={disableElevation}\n disableTransition={disableTransition}\n floating={floating}\n anchor={anchor}\n vwMargin={vwMargin}\n vhMargin={vhMargin}\n xMargin={xMargin}\n yMargin={yMargin}\n initialX={initialX}\n initialY={initialY}\n width={width}\n transformOrigin={transformOrigin}\n preventOverlap={preventOverlap}\n disableSwapping={disableSwapping}\n disableVHBounds={disableVHBounds}\n preventScroll={preventScroll}\n closeOnResize={closeOnResize}\n closeOnScroll={closeOnScroll}\n getFixedPositionOptions={getFixedPositionOptions}\n horizontal={horizontal}\n sheetHeader={sheetHeader}\n sheetFooter={sheetFooter}\n renderAsSheet={renderAsSheet}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n {...menuProps}\n fixedTo={fixedTo}\n visible={visible}\n getDefaultFocusedIndex={(options) => {\n const defaultIndex = defaultFocusIndex.current;\n if (defaultIndex < 0) {\n return getLastFocusableIndex(options);\n }\n\n return defaultIndex;\n }}\n onRequestClose={onRequestClose}\n onEntered={(appearing) => {\n menuProps?.onEntered?.(appearing);\n // this will be called before `getDefaultFocusedIndex`\n if (disableTransition) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n }}\n >\n {children}\n </Menu>\n </MenuVisibilityProvider>\n );\n}\n"],"names":["useCallback","useRef","useUserInteractionMode","getLastFocusableIndex","useEnsuredId","useEnsuredState","Menu","MenuButton","MenuConfigurationProvider","MenuItemButton","MenuVisibilityProvider","useMenuBarContext","DropdownMenu","props","id","propId","horizontal","sheetHeader","sheetFooter","renderAsSheet","sheetPosition","sheetVerticalSize","buttonChildren","iconRotatorProps","propIconRotatorProps","disableTransition","propDisableTransition","floating","anchor","vwMargin","vhMargin","xMargin","yMargin","initialX","initialY","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","preventScroll","closeOnResize","closeOnScroll","getFixedPositionOptions","children","temporary","disablePortal","disableElevation","menuProps","menuStyle","menuClassName","sheetProps","sheetStyle","sheetClassName","visible","propVisible","setVisible","propSetVisible","remaining","fixedTo","defaultFocusIndex","name","value","setValue","defaultValue","menubar","menuitem","activeIdRef","animatedOnceRef","mode","mouse","keyboard","current","onRequestClose","toggle","ref","aria-labelledby","undefined","style","className","getDefaultFocusedIndex","options","defaultIndex","onEntered","appearing"],"mappings":"AAAA;;AAEA,SAIEA,WAAW,EACXC,MAAM,QACD,QAAQ;AAEf,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,qBAAqB,QAAQ,uBAAuB;AAE7D,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SACEC,IAAI,QAGC,YAAY;AACnB,SAASC,UAAU,QAA8B,kBAAkB;AACnE,SAEEC,yBAAyB,QACpB,iCAAiC;AACxC,SAASC,cAAc,QAAkC,sBAAsB;AAE/E,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,iBAAiB,QAAQ,0BAA0B;AAoC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,MAAM,EACJC,IAAIC,MAAM,EACVC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,cAAc,EACdC,kBAAkBC,oBAAoB,EACtCC,mBAAmBC,qBAAqB,EACxCC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,eAAe,EACfC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,aAAa,EACbC,aAAa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;;0BAEnB,KAACpD;gBACCQ,YAAYA;gBACZG,eAAeA;gBACfD,aAAaA;gBACbD,aAAaA;gBACbG,eAAeA;gBACfC,mBAAmBA;0BAElBqD;;0BAEH,KAACpE;gBACCsE,mBAAkB5B,WAAW,CAAC,aAAa,GAAG6B,YAAY/D;gBAC1DgE,OAAO7B;gBACP8B,WAAW7B;gBACXC,YAAYA;gBACZC,YAAYA;gBACZC,gBAAgBA;gBAChBR,WAAWA;gBACXC,eAAeA;gBACfC,kBAAkBA;gBAClBtB,mBAAmBA;gBACnBE,UAAUA;gBACVC,QAAQA;gBACRC,UAAUA;gBACVC,UAAUA;gBACVC,SAASA;gBACTC,SAASA;gBACTC,UAAUA;gBACVC,UAAUA;gBACVC,OAAOA;gBACPC,iBAAiBA;gBACjBC,gBAAgBA;gBAChBC,iBAAiBA;gBACjBC,iBAAiBA;gBACjBC,eAAeA;gBACfC,eAAeA;gBACfC,eAAeA;gBACfC,yBAAyBA;gBACzB3B,YAAYA;gBACZC,aAAaA;gBACbC,aAAaA;gBACbC,eAAeA;gBACfC,eAAeA;gBACfC,mBAAmBA;gBAClB,GAAG2B,SAAS;gBACbW,SAASA;gBACTL,SAASA;gBACT0B,wBAAwB,CAACC;oBACvB,MAAMC,eAAetB,kBAAkBY,OAAO;oBAC9C,IAAIU,eAAe,GAAG;wBACpB,OAAO/E,sBAAsB8E;oBAC/B;oBAEA,OAAOC;gBACT;gBACAT,gBAAgBA;gBAChBU,WAAW,CAACC;oBACVpC,WAAWmC,YAAYC;oBACvB,sDAAsD;oBACtD,IAAI3D,mBAAmB;wBACrB;oBACF;oBAEAmC,kBAAkBY,OAAO,GAAG;gBAC9B;0BAEC5B;;;;AAIT"}
1
+ {"version":3,"sources":["../../src/menu/DropdownMenu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { getLastFocusableIndex } from \"../movement/utils.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport {\n Menu,\n type MenuConvenienceProps,\n type MenuListConvenienceProps,\n} from \"./Menu.js\";\nimport { MenuButton, type MenuButtonProps } from \"./MenuButton.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuItemButton, type MenuItemButtonProps } from \"./MenuItemButton.js\";\nimport { type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuVisibilityProvider } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nexport interface BaseDropdownMenuProps\n extends\n MenuConfiguration,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps,\n MenuConvenienceProps {\n buttonChildren: ReactNode;\n}\n\nexport interface DropdownMenuButtonProps\n extends MenuButtonProps, BaseDropdownMenuProps {}\n\nexport interface DropdownMenuItemButtonProps\n extends MenuItemButtonProps, BaseDropdownMenuProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface DropdownMenuStateProps {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use an `&` instead of `|` to allow autocompletion to\n * work better by default. It's up to the user to make sure they don't provide\n * incorrect props.\n */\nexport type DropdownMenuProps = DropdownMenuButtonProps &\n DropdownMenuItemButtonProps &\n (DropdownMenuStateProps | { visible?: never; setVisible?: never });\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @example Nested Dropdown Menus\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * <DropdownMenu buttonChildren=\"Nested Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Nested Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Nested Item 2\n * </MenuItem>\n * </DropdownMenu>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport function DropdownMenu(props: DropdownMenuProps): ReactElement {\n const {\n id: propId,\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n buttonChildren,\n iconRotatorProps: propIconRotatorProps,\n disableTransition: propDisableTransition,\n floating,\n anchor,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n initialX,\n initialY,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n preventScroll,\n closeOnResize,\n closeOnScroll,\n getFixedPositionOptions,\n children,\n temporary,\n disablePortal,\n disableElevation,\n menuProps,\n menuStyle,\n menuClassName,\n sheetProps,\n sheetStyle,\n sheetClassName,\n visible: propVisible,\n setVisible: propSetVisible,\n ...remaining\n } = props;\n\n const fixedTo = useRef<HTMLElement | HTMLButtonElement>(null);\n const defaultFocusIndex = useRef(0);\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: false,\n });\n const { menubar, menuitem, activeIdRef, animatedOnceRef } =\n useMenuBarContext();\n const id = useEnsuredId(propId, `menu${menuitem ? \"item\" : \"button\"}`);\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n const keyboard = mode === \"keyboard\";\n const disableTransition =\n propDisableTransition ??\n (animatedOnceRef.current &&\n menubar &&\n !!activeIdRef.current &&\n (mouse || keyboard));\n\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n let iconRotatorProps = propIconRotatorProps;\n if (disableTransition) {\n iconRotatorProps = {\n disableTransition,\n ...propIconRotatorProps,\n };\n }\n\n let toggle: ReactElement;\n if (menuitem) {\n toggle = (\n <MenuItemButton\n {...(remaining as DropdownMenuItemButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLLIElement>}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuItemButton>\n );\n } else {\n toggle = (\n <MenuButton\n {...(remaining as DropdownMenuButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLButtonElement>}\n floating={floating}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuButton>\n );\n }\n\n return (\n <MenuVisibilityProvider\n visible={visible}\n setVisible={setVisible}\n defaultFocusIndex={defaultFocusIndex}\n >\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n {toggle}\n </MenuConfigurationProvider>\n <Menu\n aria-labelledby={(menuProps?.[\"aria-label\"] ? undefined : id) as string}\n style={menuStyle}\n className={menuClassName}\n sheetProps={sheetProps}\n sheetStyle={sheetStyle}\n sheetClassName={sheetClassName}\n temporary={temporary}\n disablePortal={disablePortal}\n disableElevation={disableElevation}\n disableTransition={disableTransition}\n floating={floating}\n anchor={anchor}\n vwMargin={vwMargin}\n vhMargin={vhMargin}\n xMargin={xMargin}\n yMargin={yMargin}\n initialX={initialX}\n initialY={initialY}\n width={width}\n transformOrigin={transformOrigin}\n preventOverlap={preventOverlap}\n disableSwapping={disableSwapping}\n disableVHBounds={disableVHBounds}\n preventScroll={preventScroll}\n closeOnResize={closeOnResize}\n closeOnScroll={closeOnScroll}\n getFixedPositionOptions={getFixedPositionOptions}\n horizontal={horizontal}\n sheetHeader={sheetHeader}\n sheetFooter={sheetFooter}\n renderAsSheet={renderAsSheet}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n {...menuProps}\n fixedTo={fixedTo}\n visible={visible}\n getDefaultFocusedIndex={(options) => {\n const defaultIndex = defaultFocusIndex.current;\n if (defaultIndex < 0) {\n return getLastFocusableIndex(options);\n }\n\n return defaultIndex;\n }}\n onRequestClose={onRequestClose}\n onEntered={(appearing) => {\n menuProps?.onEntered?.(appearing);\n // this will be called before `getDefaultFocusedIndex`\n if (disableTransition) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n }}\n >\n {children}\n </Menu>\n </MenuVisibilityProvider>\n );\n}\n"],"names":["useCallback","useRef","useUserInteractionMode","getLastFocusableIndex","useEnsuredId","useEnsuredState","Menu","MenuButton","MenuConfigurationProvider","MenuItemButton","MenuVisibilityProvider","useMenuBarContext","DropdownMenu","props","id","propId","horizontal","sheetHeader","sheetFooter","renderAsSheet","sheetPosition","sheetVerticalSize","buttonChildren","iconRotatorProps","propIconRotatorProps","disableTransition","propDisableTransition","floating","anchor","vwMargin","vhMargin","xMargin","yMargin","initialX","initialY","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","preventScroll","closeOnResize","closeOnScroll","getFixedPositionOptions","children","temporary","disablePortal","disableElevation","menuProps","menuStyle","menuClassName","sheetProps","sheetStyle","sheetClassName","visible","propVisible","setVisible","propSetVisible","remaining","fixedTo","defaultFocusIndex","name","value","setValue","defaultValue","menubar","menuitem","activeIdRef","animatedOnceRef","mode","mouse","keyboard","current","onRequestClose","toggle","ref","aria-labelledby","undefined","style","className","getDefaultFocusedIndex","options","defaultIndex","onEntered","appearing"],"mappings":"AAAA;;AAEA,SAIEA,WAAW,EACXC,MAAM,QACD,QAAQ;AAEf,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,qBAAqB,QAAQ,uBAAuB;AAE7D,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SACEC,IAAI,QAGC,YAAY;AACnB,SAASC,UAAU,QAA8B,kBAAkB;AACnE,SAEEC,yBAAyB,QACpB,iCAAiC;AACxC,SAASC,cAAc,QAAkC,sBAAsB;AAE/E,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,iBAAiB,QAAQ,0BAA0B;AAmC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,MAAM,EACJC,IAAIC,MAAM,EACVC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,cAAc,EACdC,kBAAkBC,oBAAoB,EACtCC,mBAAmBC,qBAAqB,EACxCC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,eAAe,EACfC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,uBAAuB,EACvBC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,UAAU,EACVC,UAAU,EACVC,cAAc,EACdC,SAASC,WAAW,EACpBC,YAAYC,cAAc,EAC1B,GAAGC,WACJ,GAAG7C;IAEJ,MAAM8C,UAAU1D,OAAwC;IACxD,MAAM2D,oBA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BAChBR,WAAWA;gBACXC,eAAeA;gBACfC,kBAAkBA;gBAClBtB,mBAAmBA;gBACnBE,UAAUA;gBACVC,QAAQA;gBACRC,UAAUA;gBACVC,UAAUA;gBACVC,SAASA;gBACTC,SAASA;gBACTC,UAAUA;gBACVC,UAAUA;gBACVC,OAAOA;gBACPC,iBAAiBA;gBACjBC,gBAAgBA;gBAChBC,iBAAiBA;gBACjBC,iBAAiBA;gBACjBC,eAAeA;gBACfC,eAAeA;gBACfC,eAAeA;gBACfC,yBAAyBA;gBACzB3B,YAAYA;gBACZC,aAAaA;gBACbC,aAAaA;gBACbC,eAAeA;gBACfC,eAAeA;gBACfC,mBAAmBA;gBAClB,GAAG2B,SAAS;gBACbW,SAASA;gBACTL,SAASA;gBACT0B,wBAAwB,CAACC;oBACvB,MAAMC,eAAetB,kBAAkBY,OAAO;oBAC9C,IAAIU,eAAe,GAAG;wBACpB,OAAO/E,sBAAsB8E;oBAC/B;oBAEA,OAAOC;gBACT;gBACAT,gBAAgBA;gBAChBU,WAAW,CAACC;oBACVpC,WAAWmC,YAAYC;oBACvB,sDAAsD;oBACtD,IAAI3D,mBAAmB;wBACrB;oBACF;oBAEAmC,kBAAkBY,OAAO,GAAG;gBAC9B;0BAEC5B;;;;AAIT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/Menu.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n forwardRef,\n useEffect,\n useRef,\n} from \"react\";\n\nimport { type FloatingActionButtonPosition } from \"../button/FloatingActionButton.js\";\nimport { useFocusContainer } from \"../focus/useFocusContainer.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { type ListProps } from \"../list/List.js\";\nimport { useAppSize } from \"../media-queries/AppSizeProvider.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { Portal } from \"../portal/Portal.js\";\nimport { type CalculateFixedPositionOptions } from \"../positioning/types.js\";\nimport {\n type FixedPositioningOptions,\n useFixedPositioning,\n} from \"../positioning/useFixedPositioning.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type ScaleTransitionHookOptions,\n useScaleTransition,\n} from \"../transition/useScaleTransition.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n type MenuOrientationProps,\n useMenuConfiguration,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuSheet, type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuWidget } from \"./MenuWidget.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\nimport { getDefaultAnchor } from \"./utils.js\";\n\n// NOTE: The augmentation is in this file since no types are imported from the\n// `styles` file at this time\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-menu-background-color\"?: string;\n \"--rmd-menu-color\"?: string;\n \"--rmd-menu-min-width\"?: string | number;\n \"--rmd-menu-spacing\"?: string | number;\n }\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\n/** @since 5.0.0 */\nexport type MenuTransitionProps = Omit<\n ScaleTransitionHookOptions<HTMLDivElement>,\n \"transitionIn\" | \"vertical\" | \"nodeRef\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface MenuConfigurationProps extends CalculateFixedPositionOptions {\n /**\n * @see {@link ScaleTransitionHookOptions.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disablePortal?: boolean;\n\n /**\n * Boolean if the menu should not gain the elevation styles and should only be\n * set to `true` when rendering within a `Sheet`.\n *\n * @defaultValue `false`\n */\n disableElevation?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * @see {@link FixedPositioningOptions.transformOrigin}\n * @defaultValue `true`\n */\n transformOrigin?: boolean;\n\n /**\n * Boolean if the menu should close if the page is scrolled. The default\n * behavior is to just update the position of the menu relative to the menu\n * button until it can no longer be visible within the viewport.\n *\n * @defaultValue `false`\n */\n closeOnScroll?: boolean;\n\n /**\n * Boolean if the page should no longer be scrollable while the menu is\n * visible.\n *\n * @defaultValue `false`\n */\n preventScroll?: boolean;\n\n /**\n * Boolean if the menu should close instead of repositioning itself if the\n * browser window is resized.\n *\n * @defaultValue `false`\n */\n closeOnResize?: boolean;\n\n /** @see {@link FixedPositioningOptions.getFixedPositionOptions} */\n getFixedPositionOptions?: () => CalculateFixedPositionOptions;\n\n /**\n * @defaultValue `false`\n * @see {@link FixedPositioningOptions.disabled}\n */\n disableFixedPositioning?: boolean;\n}\n\n/**\n * @since 5.1.0\n * @since 6.0.0 Renamed from `MenuListProps` to `MenuListConvenienceProps`\n */\nexport interface MenuListConvenienceProps {\n /**\n * An optional style to provide to the `List` component that surrounds the\n * `MenuItem` within a `Menu`.\n */\n listStyle?: CSSProperties;\n\n /**\n * An optional className to provide to the `List` component that surrounds the\n * `MenuItem` within a `Menu`.\n */\n listClassName?: string;\n\n /**\n * Any additional props to pass to the `List` component that surrounds the\n * `Menu`'s `MenuItem`s.\n */\n listProps?: PropsWithRef<Omit<ListProps, \"horizontal\">>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface MenuConvenienceProps extends MenuConfigurationProps {\n /**\n * This can be used to apply additional props to the `Menu` component.\n *\n * Note: You can override the `style` and `className` using\n * {@link menuStyle} and {@link menuClassName} instead for convenience.\n *\n * @example\n * ```tsx\n * <DropdownMenu\n * {...props}\n * menuProps={{\n * style: {\n * // custom inline style\n * },\n * className: \"come-class-name\",\n * getFixedPositionOptions: () => ({\n * preventOverlap: true,\n * }),\n * }}\n * />\n * ```\n */\n menuProps?: PropsWithRef<\n Omit<\n MenuProps,\n | \"children\"\n | \"fixedTo\"\n | \"visible\"\n | \"onRequestClose\"\n | \"getDefaultFocusedIndex\"\n >\n >;\n\n /**\n * Convenience prop to apply custom style to the `Menu` component.\n */\n menuStyle?: CSSProperties;\n\n /**\n * Convenience prop to apply custom class name to the `Menu` component.\n */\n menuClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport type MenuFixedPositioningOptions = Omit<\n FixedPositioningOptions<HTMLElement, HTMLDivElement>,\n \"onScroll\" | \"onResize\" | \"nodeRef\" | \"disabled\"\n>;\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest Menu, Transition, and Portal API.\n */\nexport interface MenuProps\n extends HTMLAttributes<HTMLDivElement>,\n MenuConfiguration,\n MenuConfigurationProps,\n MenuFixedPositioningOptions,\n MenuOrientationProps,\n MenuTransitionProps,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps {\n visible: boolean;\n onRequestClose: () => void;\n\n /**\n * @defaultValue `\"menu-\" + useId()`\n */\n id?: string;\n\n /**\n * This is used to set the default focus index when the menu is visible.\n *\n * @internal\n */\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n\n /**\n * Custom style that should be applied to the menu only while not rendered\n * within a sheet since the {@link style} would be applied to both versions.\n */\n menuStyle?: CSSProperties;\n\n /**\n * Custom class name that should be applied only while not rendered within a\n * sheet.\n */\n menuClassName?: string;\n\n /**\n * @internal\n *\n * This is only used to update the default anchor when the DropdownMenu's\n * toggle is a floating action button.\n */\n floating?: FloatingActionButtonPosition;\n}\n\n/**\n * **Client Component**\n *\n * This component should generally only be used to implement context menus with\n * the `useContextMenu` hook. Otherwise, the `DropdownMenu` component should be\n * used.\n *\n * @see The `useContextMenu` hook for an example.\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated this component to implement all the `Menu`\n * functionality instead of requiring the `useMenu` hook and `MenuWidget`\n * component. In addition, the `renderAsSheet` behavior has been moved into this\n * implementation so that the `MenuRenderer` is no longer required and context\n * menus can appear as a `Sheet`.\n */\nexport const Menu = forwardRef<HTMLDivElement, LabelRequiredForA11y<MenuProps>>(\n function Menu(props, propRef) {\n const {\n id: propId,\n style: propStyle,\n role = \"menu\",\n children,\n horizontal: _horizontal,\n sheetHeader: _sheetHeader,\n sheetFooter: _sheetFooter,\n renderAsSheet: _renderAsSheet,\n sheetPosition: _sheetPosition,\n sheetVerticalSize: _sheetVerticalSize,\n sheetProps,\n sheetStyle,\n sheetClassName,\n menuStyle,\n menuClassName,\n disableElevation = false,\n temporary = true,\n tabIndex = -1,\n fixedTo,\n className,\n classNames,\n timeout,\n appear,\n enter,\n exit,\n onEnter,\n onEntering = noop,\n onEntered = noop,\n onExit,\n onExiting,\n onExited = noop,\n onKeyDown = noop,\n listProps,\n listStyle,\n listClassName,\n visible,\n onRequestClose,\n floating,\n anchor,\n closeOnResize = false,\n closeOnScroll = false,\n preventScroll = false,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n width,\n transformOrigin = true,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n initialX,\n initialY,\n disableFixedPositioning,\n getFixedPositionOptions,\n disablePortal: propDisablePortal,\n disableTransition,\n ...remaining\n } = props;\n const { \"aria-label\": ariaLabel, \"aria-labelledby\": ariaLabelledBy } =\n props;\n\n const id = useEnsuredId(propId, \"menu\");\n const {\n root,\n menubar,\n menuitem,\n activeId,\n animatedOnceRef,\n hoverTimeoutRef,\n disableHoverMode,\n } = useMenuBarContext();\n const {\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n } = useMenuConfiguration(props);\n const { isPhone } = useAppSize();\n const isSheet =\n renderAsSheet === true || (renderAsSheet === \"phone\" && isPhone);\n\n const entered = useRef(false);\n const cancelUnmountFocus = useRef(false);\n const hideWithoutRefocus = (): void => {\n cancelUnmountFocus.current = true;\n onRequestClose();\n };\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n\n const { eventHandlers, transitionOptions } = useFocusContainer({\n nodeRef: propRef,\n activate: visible,\n onKeyDown(event) {\n onKeyDown(event);\n\n // when a menu is within a sheet, it should not trigger the custom\n // keyboard behavior\n if (isSheet) {\n return;\n }\n\n switch (event.key) {\n case \"Escape\":\n // prevent parent components that have an \"Escape\" keypress event\n // from being triggered as well\n event.stopPropagation();\n disableHoverMode();\n onRequestClose();\n break;\n case \"Tab\":\n // since menus are portalled, tab index is kinda broke so just close\n // the menu instead of doing default tab behavior\n event.preventDefault();\n\n if (!menuitem) {\n // pressing the tab key should still cascade close all menus\n event.stopPropagation();\n }\n disableHoverMode();\n onRequestClose();\n break;\n case \"ArrowUp\":\n if (!root && menuitem && horizontal) {\n event.stopPropagation();\n event.preventDefault();\n onRequestClose();\n }\n break;\n case \"ArrowLeft\":\n if (!root && menuitem && !horizontal) {\n event.stopPropagation();\n event.preventDefault();\n onRequestClose();\n }\n break;\n }\n },\n onEnter,\n onEntering(appearing) {\n onEntering(appearing);\n entered.current = true;\n },\n onEntered(appearing) {\n onEntered(appearing);\n entered.current = true;\n cancelUnmountFocus.current = false;\n animatedOnceRef.current = true;\n },\n onExit,\n onExiting,\n onExited() {\n onExited();\n entered.current = false;\n },\n disableTransition,\n isFocusTypeDisabled(type) {\n if (role === \"listbox\") {\n return !isSheet;\n }\n\n if (type === \"keyboard\") {\n return isSheet;\n }\n\n const isHoverDisabled = mouse && hoverTimeoutRef.current === 0;\n if (type === \"mount\") {\n return isHoverDisabled;\n }\n\n return (\n isHoverDisabled ||\n cancelUnmountFocus.current ||\n (root && !!activeId && id !== activeId)\n );\n },\n });\n\n const { ref, style, callbacks, updateStyle } = useFixedPositioning({\n ...transitionOptions,\n disabled: disableFixedPositioning,\n style: isSheet ? propStyle : menuStyle,\n fixedTo,\n anchor: getDefaultAnchor({\n anchor,\n menubar,\n floating,\n menuitem: !root && menuitem,\n horizontal,\n }),\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n initialX,\n initialY,\n getFixedPositionOptions,\n onResize: closeOnResize ? hideWithoutRefocus : undefined,\n onScroll(_event, data) {\n if (!data.visible || closeOnScroll) {\n hideWithoutRefocus();\n }\n },\n });\n const { rendered, disablePortal, elementProps } = useScaleTransition({\n className: cnb(!isSheet && menuClassName, className),\n transitionIn: visible,\n vertical: !horizontal,\n temporary,\n timeout: isSheet || disableTransition ? 0 : timeout,\n classNames,\n appear,\n enter,\n exit,\n exitedHidden: true,\n // merge the transition callbacks\n ...transitionOptions,\n ...callbacks,\n // but prefer the latest defined ref\n nodeRef: ref,\n });\n useScrollLock(visible && preventScroll);\n\n // need to make sure that the useEffect does not refire for hiding on click\n // events because of the `window.requestAnimationFrame`. It'll make it so\n // that menu items that update state are unable to close when clicked\n const hide = useRef(onRequestClose);\n useEffect(() => {\n hide.current = onRequestClose;\n });\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const callback = (event: globalThis.MouseEvent): void => {\n // this is required for when the transition is disabled\n if (!entered.current) {\n return;\n }\n\n // if the user clicks outside of the menu to close it, the toggle button\n // should not be focused. instead the nearest focusable element from the\n // click event should be focused when Tab or Shift + tab is pressed\n cancelUnmountFocus.current =\n !(event.target instanceof HTMLElement) ||\n !event.target.closest(`[role=\"${role}\"]`);\n\n // this won't be called if `event.stopPropagation()` is called\n hide.current();\n disableHoverMode();\n };\n\n // wait an animation frame so the initial click event that caused the menu\n // to become visible does not immediately close the menu\n const frame = window.requestAnimationFrame(() => {\n window.addEventListener(\"click\", callback);\n });\n\n return () => {\n window.cancelAnimationFrame(frame);\n window.removeEventListener(\"click\", callback);\n };\n }, [disableHoverMode, role, visible]);\n useIsomorphicLayoutEffect(() => {\n if (!visible) {\n return;\n }\n\n updateStyle();\n }, [updateStyle, children, visible]);\n\n return (\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n <MenuSheet\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy as string}\n header={sheetHeader}\n footer={sheetFooter}\n position={sheetPosition}\n verticalSize={sheetVerticalSize}\n visible={visible}\n enabled={isSheet}\n onRequestClose={onRequestClose}\n style={sheetStyle}\n className={sheetClassName}\n disablePortal={propDisablePortal}\n temporary={temporary}\n disableTransition={disableTransition}\n {...sheetProps}\n >\n <Portal disabled={isSheet || (propDisablePortal ?? disablePortal)}>\n {(rendered || isSheet) && (\n <MenuWidget\n {...remaining}\n {...elementProps}\n {...eventHandlers}\n id={id}\n role={role}\n style={isSheet ? propStyle : style}\n isSheet={isSheet}\n tabIndex={tabIndex}\n horizontal={horizontal}\n listProps={listProps}\n listStyle={listStyle}\n listClassName={listClassName}\n disableElevation={disableElevation}\n cancelUnmountFocus={cancelUnmountFocus}\n >\n {children}\n </MenuWidget>\n )}\n </Portal>\n </MenuSheet>\n </MenuConfigurationProvider>\n );\n }\n);\n"],"names":["cnb","forwardRef","useEffect","useRef","useFocusContainer","useUserInteractionMode","useAppSize","Portal","useFixedPositioning","useScrollLock","useScaleTransition","useEnsuredId","useIsomorphicLayoutEffect","MenuConfigurationProvider","useMenuConfiguration","MenuSheet","MenuWidget","useMenuBarContext","getDefaultAnchor","noop","Menu","props","propRef","id","propId","style","propStyle","role","children","horizontal","_horizontal","sheetHeader","_sheetHeader","sheetFooter","_sheetFooter","renderAsSheet","_renderAsSheet","sheetPosition","_sheetPosition","sheetVerticalSize","_sheetVerticalSize","sheetProps","sheetStyle","sheetClassName","menuStyle","menuClassName","disableElevation","temporary","tabIndex","fixedTo","className","classNames","timeout","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","onKeyDown","listProps","listStyle","listClassName","visible","onRequestClose","floating","anchor","closeOnResize","closeOnScroll","preventScroll","vwMargin","vhMargin","xMargin","yMargin","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","initialX","initialY","disableFixedPositioning","getFixedPositionOptions","disablePortal","propDisablePortal","disableTransition","remaining","ariaLabel","ariaLabelledBy","root","menubar","menuitem","activeId","animatedOnceRef","hoverTimeoutRef","disableHoverMode","isPhone","isSheet","entered","cancelUnmountFocus","hideWithoutRefocus","current","mode","mouse","eventHandlers","transitionOptions","nodeRef","activate","event","key","stopPropagation","preventDefault","appearing","isFocusTypeDisabled","type","isHoverDisabled","ref","callbacks","updateStyle","disabled","onResize","undefined","onScroll","_event","data","rendered","elementProps","transitionIn","vertical","exitedHidden","hide","callback","target","HTMLElement","closest","frame","window","requestAnimationFrame","addEventListener","cancelAnimationFrame","removeEventListener","aria-label","aria-labelledby","header","footer","position","verticalSize","enabled"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAGEC,UAAU,EACVC,SAAS,EACTC,MAAM,QACD,QAAQ;AAGf,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,sBAAsB,QAAQ,gDAAgD;AAEvF,SAASC,UAAU,QAAQ,sCAAsC;AAEjE,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,SAEEC,mBAAmB,QACd,wCAAwC;AAC/C,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAEEC,kBAAkB,QACb,sCAAsC;AAE7C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,yBAAyB,QAAQ,kCAAkC;AAC5E,SAEEC,yBAAyB,EAEzBC,oBAAoB,QACf,iCAAiC;AACxC,SAASC,SAAS,QAAwC,iBAAiB;AAC3E,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,gBAAgB,QAAQ,aAAa;AAa9C,MAAMC,OAAO;AACX,aAAa;AACf;AA8MA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,qBAAOnB,WAClB,SAASmB,KAAKC,KAAK,EAAEC,OAAO;IAC1B,MAAM,EACJC,IAAIC,MAAM,EACVC,OAAOC,SAAS,EAChBC,OAAO,MAAM,EACbC,QAAQ,EACRC,YAAYC,WAAW,EACvB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Z,GAAGwC,YAAY;oBACf,GAAGtB,aAAa;oBACjBpF,IAAIA;oBACJI,MAAMA;oBACNF,OAAO2E,UAAU1E,YAAYD;oBAC7B2E,SAASA;oBACTpD,UAAUA;oBACVnB,YAAYA;oBACZkC,WAAWA;oBACXC,WAAWA;oBACXC,eAAeA;oBACfnB,kBAAkBA;oBAClBwD,oBAAoBA;8BAEnB1E;;;;;AAOf,GACA"}
1
+ {"version":3,"sources":["../../src/menu/Menu.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n forwardRef,\n useEffect,\n useRef,\n} from \"react\";\n\nimport { type FloatingActionButtonPosition } from \"../button/FloatingActionButton.js\";\nimport { useFocusContainer } from \"../focus/useFocusContainer.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { type ListProps } from \"../list/List.js\";\nimport { useAppSize } from \"../media-queries/AppSizeProvider.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { Portal } from \"../portal/Portal.js\";\nimport { type CalculateFixedPositionOptions } from \"../positioning/types.js\";\nimport {\n type FixedPositioningOptions,\n useFixedPositioning,\n} from \"../positioning/useFixedPositioning.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type ScaleTransitionHookOptions,\n useScaleTransition,\n} from \"../transition/useScaleTransition.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n type MenuOrientationProps,\n useMenuConfiguration,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuSheet, type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuWidget } from \"./MenuWidget.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\nimport { getDefaultAnchor } from \"./utils.js\";\n\n// NOTE: The augmentation is in this file since no types are imported from the\n// `styles` file at this time\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-menu-background-color\"?: string;\n \"--rmd-menu-color\"?: string;\n \"--rmd-menu-min-width\"?: string | number;\n \"--rmd-menu-spacing\"?: string | number;\n }\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\n/** @since 5.0.0 */\nexport type MenuTransitionProps = Omit<\n ScaleTransitionHookOptions<HTMLDivElement>,\n \"transitionIn\" | \"vertical\" | \"nodeRef\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface MenuConfigurationProps extends CalculateFixedPositionOptions {\n /**\n * @see {@link ScaleTransitionHookOptions.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disablePortal?: boolean;\n\n /**\n * Boolean if the menu should not gain the elevation styles and should only be\n * set to `true` when rendering within a `Sheet`.\n *\n * @defaultValue `false`\n */\n disableElevation?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * @see {@link FixedPositioningOptions.transformOrigin}\n * @defaultValue `true`\n */\n transformOrigin?: boolean;\n\n /**\n * Boolean if the menu should close if the page is scrolled. The default\n * behavior is to just update the position of the menu relative to the menu\n * button until it can no longer be visible within the viewport.\n *\n * @defaultValue `false`\n */\n closeOnScroll?: boolean;\n\n /**\n * Boolean if the page should no longer be scrollable while the menu is\n * visible.\n *\n * @defaultValue `false`\n */\n preventScroll?: boolean;\n\n /**\n * Boolean if the menu should close instead of repositioning itself if the\n * browser window is resized.\n *\n * @defaultValue `false`\n */\n closeOnResize?: boolean;\n\n /** @see {@link FixedPositioningOptions.getFixedPositionOptions} */\n getFixedPositionOptions?: () => CalculateFixedPositionOptions;\n\n /**\n * @defaultValue `false`\n * @see {@link FixedPositioningOptions.disabled}\n */\n disableFixedPositioning?: boolean;\n}\n\n/**\n * @since 5.1.0\n * @since 6.0.0 Renamed from `MenuListProps` to `MenuListConvenienceProps`\n */\nexport interface MenuListConvenienceProps {\n /**\n * An optional style to provide to the `List` component that surrounds the\n * `MenuItem` within a `Menu`.\n */\n listStyle?: CSSProperties;\n\n /**\n * An optional className to provide to the `List` component that surrounds the\n * `MenuItem` within a `Menu`.\n */\n listClassName?: string;\n\n /**\n * Any additional props to pass to the `List` component that surrounds the\n * `Menu`'s `MenuItem`s.\n */\n listProps?: PropsWithRef<Omit<ListProps, \"horizontal\">>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface MenuConvenienceProps extends MenuConfigurationProps {\n /**\n * This can be used to apply additional props to the `Menu` component.\n *\n * Note: You can override the `style` and `className` using\n * {@link menuStyle} and {@link menuClassName} instead for convenience.\n *\n * @example\n * ```tsx\n * <DropdownMenu\n * {...props}\n * menuProps={{\n * style: {\n * // custom inline style\n * },\n * className: \"come-class-name\",\n * getFixedPositionOptions: () => ({\n * preventOverlap: true,\n * }),\n * }}\n * />\n * ```\n */\n menuProps?: PropsWithRef<\n Omit<\n MenuProps,\n | \"children\"\n | \"fixedTo\"\n | \"visible\"\n | \"onRequestClose\"\n | \"getDefaultFocusedIndex\"\n >\n >;\n\n /**\n * Convenience prop to apply custom style to the `Menu` component.\n */\n menuStyle?: CSSProperties;\n\n /**\n * Convenience prop to apply custom class name to the `Menu` component.\n */\n menuClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport type MenuFixedPositioningOptions = Omit<\n FixedPositioningOptions<HTMLElement, HTMLDivElement>,\n \"onScroll\" | \"onResize\" | \"nodeRef\" | \"disabled\"\n>;\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest Menu, Transition, and Portal API.\n */\nexport interface MenuProps\n extends\n HTMLAttributes<HTMLDivElement>,\n MenuConfiguration,\n MenuConfigurationProps,\n MenuFixedPositioningOptions,\n MenuOrientationProps,\n MenuTransitionProps,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps {\n visible: boolean;\n onRequestClose: () => void;\n\n /**\n * @defaultValue `\"menu-\" + useId()`\n */\n id?: string;\n\n /**\n * This is used to set the default focus index when the menu is visible.\n *\n * @internal\n */\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n\n /**\n * Custom style that should be applied to the menu only while not rendered\n * within a sheet since the {@link style} would be applied to both versions.\n */\n menuStyle?: CSSProperties;\n\n /**\n * Custom class name that should be applied only while not rendered within a\n * sheet.\n */\n menuClassName?: string;\n\n /**\n * @internal\n *\n * This is only used to update the default anchor when the DropdownMenu's\n * toggle is a floating action button.\n */\n floating?: FloatingActionButtonPosition;\n}\n\n/**\n * **Client Component**\n *\n * This component should generally only be used to implement context menus with\n * the `useContextMenu` hook. Otherwise, the `DropdownMenu` component should be\n * used.\n *\n * @see The `useContextMenu` hook for an example.\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated this component to implement all the `Menu`\n * functionality instead of requiring the `useMenu` hook and `MenuWidget`\n * component. In addition, the `renderAsSheet` behavior has been moved into this\n * implementation so that the `MenuRenderer` is no longer required and context\n * menus can appear as a `Sheet`.\n */\nexport const Menu = forwardRef<HTMLDivElement, LabelRequiredForA11y<MenuProps>>(\n function Menu(props, propRef) {\n const {\n id: propId,\n style: propStyle,\n role = \"menu\",\n children,\n horizontal: _horizontal,\n sheetHeader: _sheetHeader,\n sheetFooter: _sheetFooter,\n renderAsSheet: _renderAsSheet,\n sheetPosition: _sheetPosition,\n sheetVerticalSize: _sheetVerticalSize,\n sheetProps,\n sheetStyle,\n sheetClassName,\n menuStyle,\n menuClassName,\n disableElevation = false,\n temporary = true,\n tabIndex = -1,\n fixedTo,\n className,\n classNames,\n timeout,\n appear,\n enter,\n exit,\n onEnter,\n onEntering = noop,\n onEntered = noop,\n onExit,\n onExiting,\n onExited = noop,\n onKeyDown = noop,\n listProps,\n listStyle,\n listClassName,\n visible,\n onRequestClose,\n floating,\n anchor,\n closeOnResize = false,\n closeOnScroll = false,\n preventScroll = false,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n width,\n transformOrigin = true,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n initialX,\n initialY,\n disableFixedPositioning,\n getFixedPositionOptions,\n disablePortal: propDisablePortal,\n disableTransition,\n ...remaining\n } = props;\n const { \"aria-label\": ariaLabel, \"aria-labelledby\": ariaLabelledBy } =\n props;\n\n const id = useEnsuredId(propId, \"menu\");\n const {\n root,\n menubar,\n menuitem,\n activeId,\n animatedOnceRef,\n hoverTimeoutRef,\n disableHoverMode,\n } = useMenuBarContext();\n const {\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n } = useMenuConfiguration(props);\n const { isPhone } = useAppSize();\n const isSheet =\n renderAsSheet === true || (renderAsSheet === \"phone\" && isPhone);\n\n const entered = useRef(false);\n const cancelUnmountFocus = useRef(false);\n const hideWithoutRefocus = (): void => {\n cancelUnmountFocus.current = true;\n onRequestClose();\n };\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n\n const { eventHandlers, transitionOptions } = useFocusContainer({\n nodeRef: propRef,\n activate: visible,\n onKeyDown(event) {\n onKeyDown(event);\n\n // when a menu is within a sheet, it should not trigger the custom\n // keyboard behavior\n if (isSheet) {\n return;\n }\n\n switch (event.key) {\n case \"Escape\":\n // prevent parent components that have an \"Escape\" keypress event\n // from being triggered as well\n event.stopPropagation();\n disableHoverMode();\n onRequestClose();\n break;\n case \"Tab\":\n // since menus are portalled, tab index is kinda broke so just close\n // the menu instead of doing default tab behavior\n event.preventDefault();\n\n if (!menuitem) {\n // pressing the tab key should still cascade close all menus\n event.stopPropagation();\n }\n disableHoverMode();\n onRequestClose();\n break;\n case \"ArrowUp\":\n if (!root && menuitem && horizontal) {\n event.stopPropagation();\n event.preventDefault();\n onRequestClose();\n }\n break;\n case \"ArrowLeft\":\n if (!root && menuitem && !horizontal) {\n event.stopPropagation();\n event.preventDefault();\n onRequestClose();\n }\n break;\n }\n },\n onEnter,\n onEntering(appearing) {\n onEntering(appearing);\n entered.current = true;\n },\n onEntered(appearing) {\n onEntered(appearing);\n entered.current = true;\n cancelUnmountFocus.current = false;\n animatedOnceRef.current = true;\n },\n onExit,\n onExiting,\n onExited() {\n onExited();\n entered.current = false;\n },\n disableTransition,\n isFocusTypeDisabled(type) {\n if (role === \"listbox\") {\n return !isSheet;\n }\n\n if (type === \"keyboard\") {\n return isSheet;\n }\n\n const isHoverDisabled = mouse && hoverTimeoutRef.current === 0;\n if (type === \"mount\") {\n return isHoverDisabled;\n }\n\n return (\n isHoverDisabled ||\n cancelUnmountFocus.current ||\n (root && !!activeId && id !== activeId)\n );\n },\n });\n\n const { ref, style, callbacks, updateStyle } = useFixedPositioning({\n ...transitionOptions,\n disabled: disableFixedPositioning,\n style: isSheet ? propStyle : menuStyle,\n fixedTo,\n anchor: getDefaultAnchor({\n anchor,\n menubar,\n floating,\n menuitem: !root && menuitem,\n horizontal,\n }),\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n initialX,\n initialY,\n getFixedPositionOptions,\n onResize: closeOnResize ? hideWithoutRefocus : undefined,\n onScroll(_event, data) {\n if (!data.visible || closeOnScroll) {\n hideWithoutRefocus();\n }\n },\n });\n const { rendered, disablePortal, elementProps } = useScaleTransition({\n className: cnb(!isSheet && menuClassName, className),\n transitionIn: visible,\n vertical: !horizontal,\n temporary,\n timeout: isSheet || disableTransition ? 0 : timeout,\n classNames,\n appear,\n enter,\n exit,\n exitedHidden: true,\n // merge the transition callbacks\n ...transitionOptions,\n ...callbacks,\n // but prefer the latest defined ref\n nodeRef: ref,\n });\n useScrollLock(visible && preventScroll);\n\n // need to make sure that the useEffect does not refire for hiding on click\n // events because of the `window.requestAnimationFrame`. It'll make it so\n // that menu items that update state are unable to close when clicked\n const hide = useRef(onRequestClose);\n useEffect(() => {\n hide.current = onRequestClose;\n });\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const callback = (event: globalThis.MouseEvent): void => {\n // this is required for when the transition is disabled\n if (!entered.current) {\n return;\n }\n\n // if the user clicks outside of the menu to close it, the toggle button\n // should not be focused. instead the nearest focusable element from the\n // click event should be focused when Tab or Shift + tab is pressed\n cancelUnmountFocus.current =\n !(event.target instanceof HTMLElement) ||\n !event.target.closest(`[role=\"${role}\"]`);\n\n // this won't be called if `event.stopPropagation()` is called\n hide.current();\n disableHoverMode();\n };\n\n // wait an animation frame so the initial click event that caused the menu\n // to become visible does not immediately close the menu\n const frame = window.requestAnimationFrame(() => {\n window.addEventListener(\"click\", callback);\n });\n\n return () => {\n window.cancelAnimationFrame(frame);\n window.removeEventListener(\"click\", callback);\n };\n }, [disableHoverMode, role, visible]);\n useIsomorphicLayoutEffect(() => {\n if (!visible) {\n return;\n }\n\n updateStyle();\n }, [updateStyle, children, visible]);\n\n return (\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n <MenuSheet\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy as string}\n header={sheetHeader}\n footer={sheetFooter}\n position={sheetPosition}\n verticalSize={sheetVerticalSize}\n visible={visible}\n enabled={isSheet}\n onRequestClose={onRequestClose}\n style={sheetStyle}\n className={sheetClassName}\n disablePortal={propDisablePortal}\n temporary={temporary}\n disableTransition={disableTransition}\n {...sheetProps}\n >\n <Portal disabled={isSheet || (propDisablePortal ?? disablePortal)}>\n {(rendered || isSheet) && (\n <MenuWidget\n {...remaining}\n {...elementProps}\n {...eventHandlers}\n id={id}\n role={role}\n style={isSheet ? propStyle : style}\n isSheet={isSheet}\n tabIndex={tabIndex}\n horizontal={horizontal}\n listProps={listProps}\n listStyle={listStyle}\n listClassName={listClassName}\n disableElevation={disableElevation}\n cancelUnmountFocus={cancelUnmountFocus}\n >\n {children}\n </MenuWidget>\n )}\n </Portal>\n </MenuSheet>\n </MenuConfigurationProvider>\n );\n }\n);\n"],"names":["cnb","forwardRef","useEffect","useRef","useFocusContainer","useUserInteractionMode","useAppSize","Portal","useFixedPositioning","useScrollLock","useScaleTransition","useEnsuredId","useIsomorphicLayoutEffect","MenuConfigurationProvider","useMenuConfiguration","MenuSheet","MenuWidget","useMenuBarContext","getDefaultAnchor","noop","Menu","props","propRef","id","propId","style","propStyle","role","children","horizontal","_horizontal","sheetHeader","_sheetHeader","sheetFooter","_sheetFooter","renderAsSheet","_renderAsSheet","sheetPosition","_sheetPosition","sheetVerticalSize","_sheetVerticalSize","sheetProps","sheetStyle","sheetClassName","menuStyle","menuClassName","disableElevation","temporary","tabIndex","fixedTo","className","classNames","timeout","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","onKeyDown","listProps","listStyle","listClassName","visible","onRequestClose","floating","anchor","closeOnResize","closeOnScroll","preventScroll","vwMargin","vhMargin","xMargin","yMargin","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","initialX","initialY","disableFixedPositioning","getFixedPositionOptions","disablePortal","propDisablePortal","disableTransition","remaining","ariaLabel","ariaLabelledBy","root","menubar","menuitem","activeId","animatedOnceRef","hoverTimeoutRef","disableHoverMode","isPhone","isSheet","entered","cancelUnmountFocus","hideWithoutRefocus","current","mode","mouse","eventHandlers","transitionOptions","nodeRef","activate","event","key","stopPropagation","preventDefault","appearing","isFocusTypeDisabled","type","isHoverDisabled","ref","callbacks","updateStyle","disabled","onResize","undefined","onScroll","_event","data","rendered","elementProps","transitionIn","vertical","exitedHidden","hide","callback","target","HTMLElement","closest","frame","window","requestAnimationFrame","addEventListener","cancelAnimationFrame","removeEventListener","aria-label","aria-labelledby","header","footer","position","verticalSize","enabled"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAGEC,UAAU,EACVC,SAAS,EACTC,MAAM,QACD,QAAQ;AAGf,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,sBAAsB,QAAQ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YAC5BC,OAAOI,mBAAmB,CAAC,SAAST;QACtC;IACF,GAAG;QAACpC;QAAkBvE;QAAMuC;KAAQ;IACpCtD,0BAA0B;QACxB,IAAI,CAACsD,SAAS;YACZ;QACF;QAEAuD;IACF,GAAG;QAACA;QAAa7F;QAAUsC;KAAQ;IAEnC,qBACE,KAACrD;QACCgB,YAAYA;QACZM,eAAeA;QACfF,aAAaA;QACbF,aAAaA;QACbM,eAAeA;QACfE,mBAAmBA;kBAEnB,cAAA,KAACxB;YACCiI,cAAYtD;YACZuD,mBAAiBtD;YACjBuD,QAAQnH;YACRoH,QAAQlH;YACRmH,UAAU/G;YACVgH,cAAc9G;YACd2B,SAASA;YACToF,SAASlD;YACTjC,gBAAgBA;YAChB1C,OAAOiB;YACPQ,WAAWP;YACX2C,eAAeC;YACfxC,WAAWA;YACXyC,mBAAmBA;YAClB,GAAG/C,UAAU;sBAEd,cAAA,KAAClC;gBAAOmH,UAAUtB,WAAYb,CAAAA,qBAAqBD,aAAY;0BAC5D,AAAC0C,CAAAA,YAAY5B,OAAM,mBAClB,KAACpF;oBACE,GAAGyE,SAAS;oBACZ,GAAGwC,YAAY;oBACf,GAAGtB,aAAa;oBACjBpF,IAAIA;oBACJI,MAAMA;oBACNF,OAAO2E,UAAU1E,YAAYD;oBAC7B2E,SAASA;oBACTpD,UAAUA;oBACVnB,YAAYA;oBACZkC,WAAWA;oBACXC,WAAWA;oBACXC,eAAeA;oBACfnB,kBAAkBA;oBAClBwD,oBAAoBA;8BAEnB1E;;;;;AAOf,GACA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/MenuItemButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useEffect } from \"react\";\n\nimport { useHoverMode } from \"../hoverMode/useHoverMode.js\";\nimport { IconRotator } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useAppSize } from \"../media-queries/AppSizeProvider.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { type BaseMenuButtonProps } from \"./MenuButton.js\";\nimport { useMenuConfiguration } from \"./MenuConfigurationProvider.js\";\nimport { MenuItem, type MenuItemProps } from \"./MenuItem.js\";\nimport { useMenuVisibility } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport interface MenuItemButtonProps\n extends BaseMenuButtonProps,\n MenuItemProps {}\n\n/**\n * **Client Component**\n *\n * This is just an internal component that handles rendering a submenu as a\n * menuitem for a `DropdownMenu` with a conditional dropdown icon.\n *\n * @internal\n * @since 5.0.0\n */\nexport const MenuItemButton = forwardRef<HTMLLIElement, MenuItemButtonProps>(\n function MenuItemButton(props, ref) {\n const {\n id: propId,\n children,\n height: propHeight,\n onClick = noop,\n onKeyDown = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n rightAddon: propRightAddon,\n iconRotatorProps,\n disableDropdownIcon = typeof propRightAddon !== \"undefined\",\n ...remaining\n } = props;\n const { disabled } = props;\n\n const id = useEnsuredId(propId, \"menuitem\");\n const mode = useUserInteractionMode();\n const { renderAsSheet } = useMenuConfiguration();\n const { isPhone } = useAppSize();\n const isSheet =\n renderAsSheet === true || (renderAsSheet === \"phone\" && isPhone);\n const {\n root,\n menubar,\n activeId,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n leaveTimeoutRef,\n hoverTimeoutRef,\n } = useMenuBarContext();\n const { visible, setVisible, defaultFocusIndex } = useMenuVisibility();\n const { startShowFlow, clearVisibilityTimeout } = useHoverMode({\n setVisible,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n leaveTimeoutRef,\n hoverTimeoutRef,\n clearDisableTimer,\n });\n const { horizontal } = useMenuConfiguration();\n\n useEffect(() => {\n setVisible(id === activeId);\n }, [activeId, defaultFocusIndex, id, menubar, setVisible]);\n\n let height = propHeight;\n let rightAddon = propRightAddon;\n const dropdownIcon = getIcon(root ? \"dropdown\" : \"forward\");\n if (!disableDropdownIcon) {\n if (!height && !props.leftAddon) {\n height = \"normal\";\n }\n\n rightAddon = (\n <IconRotator {...iconRotatorProps} rotated={visible}>\n {dropdownIcon}\n </IconRotator>\n );\n }\n\n const updateVisibility = (nextVisible: boolean, focusIndex = 0): void => {\n defaultFocusIndex.current = focusIndex;\n setVisible(nextVisible);\n if (!menubar) {\n return;\n }\n\n if (nextVisible) {\n enableHoverMode(id);\n } else {\n disableHoverMode();\n }\n };\n\n return (\n <MenuItem\n {...remaining}\n aria-haspopup={isSheet ? \"dialog\" : \"menu\"}\n aria-expanded={visible || undefined}\n id={id}\n ref={ref}\n rightAddon={rightAddon}\n onClick={(event) => {\n onClick(event);\n\n event.stopPropagation();\n updateVisibility(!visible);\n }}\n onKeyDown={(event) => {\n onKeyDown(event);\n\n switch (event.key) {\n case \"ArrowDown\":\n if (horizontal || root) {\n event.preventDefault();\n event.stopPropagation();\n updateVisibility(true);\n }\n break;\n case \"ArrowRight\":\n if (!horizontal && !root) {\n event.preventDefault();\n event.stopPropagation();\n updateVisibility(true);\n }\n break;\n }\n }}\n onMouseEnter={(event) => {\n onMouseEnter(event);\n if (mode === \"touch\" || disabled || !menubar) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n startShowFlow(id);\n }}\n onMouseLeave={(event) => {\n onMouseLeave(event);\n if (mode === \"touch\" || disabled || !menubar) {\n return;\n }\n\n clearVisibilityTimeout();\n }}\n >\n {children}\n </MenuItem>\n );\n }\n);\n"],"names":["forwardRef","useEffect","useHoverMode","IconRotator","getIcon","useUserInteractionMode","useAppSize","useEnsuredId","useMenuConfiguration","MenuItem","useMenuVisibility","useMenuBarContext","noop","MenuItemButton","props","ref","id","propId","children","height","propHeight","onClick","onKeyDown","onMouseEnter","onMouseLeave","rightAddon","propRightAddon","iconRotatorProps","disableDropdownIcon","remaining","disabled","mode","renderAsSheet","isPhone","isSheet","root","menubar","activeId","enableHoverMode","disableHoverMode","startDisableTimer","clearDisableTimer","leaveTimeoutRef","hoverTimeoutRef","visible","setVisible","defaultFocusIndex","startShowFlow","clearVisibilityTimeout","horizontal","dropdownIcon","leftAddon","rotated","updateVisibility","nextVisible","focusIndex","current","aria-haspopup","aria-expanded","undefined","event","stopPropagation","key","preventDefault"],"mappings":"AAAA;;AAEA,SAASA,UAAU,EAAEC,SAAS,QAAQ,QAAQ;AAE9C,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,UAAU,QAAQ,sCAAsC;AACjE,SAASC,YAAY,QAAQ,qBAAqB;AAElD,SAASC,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,QAAQ,QAA4B,gBAAgB;AAC7D,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,iBAAiB,QAAQ,0BAA0B;AAE5D,MAAMC,OAAO;AACX,aAAa;AACf;AAUA;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAAiBb,WAC5B,SAASa,eAAeC,KAAK,EAAEC,GAAG;IAChC,MAAM,EACJC,IAAIC,MAAM,EACVC,QAAQ,EACRC,QAAQC,UAAU,EAClBC,UAAUT,IAAI,EACdU,YAAYV,IAAI,EAChBW,eAAeX,IAAI,EACnBY,eAAeZ,IAAI,EACnBa,YAAYC,cAAc,EAC1BC,gBAAgB,EAChBC,sBAAsB,OAAOF,mBAAmB,WAAW,EAC3D,GAAGG,WACJ,GAAGf;IACJ,MAAM,EAAEgB,QAAQ,EAAE,GAAGhB;IAErB,MAAME,KAAKT,aAAaU,QAAQ;IAChC,MAAMc,OAAO1B;IACb,MAAM,EAAE2B,aAAa,EAAE,GAAGxB;IAC1B,MAAM,EAAEyB,OAAO,EAAE,GAAG3B;IACpB,MAAM4B,UACJF,kBAAkB,Q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H,IAAIb,cAAcd,MAAM;wBACtByB,MAAMG,cAAc;wBACpBH,MAAMC,eAAe;wBACrBR,iBAAiB;oBACnB;oBACA;gBACF,KAAK;oBACH,IAAI,CAACJ,cAAc,CAACd,MAAM;wBACxByB,MAAMG,cAAc;wBACpBH,MAAMC,eAAe;wBACrBR,iBAAiB;oBACnB;oBACA;YACJ;QACF;QACA9B,cAAc,CAACqC;YACbrC,aAAaqC;YACb,IAAI7B,SAAS,WAAWD,YAAY,CAACM,SAAS;gBAC5C;YACF;YAEAU,kBAAkBU,OAAO,GAAG;YAC5BT,cAAc/B;QAChB;QACAQ,cAAc,CAACoC;YACbpC,aAAaoC;YACb,IAAI7B,SAAS,WAAWD,YAAY,CAACM,SAAS;gBAC5C;YACF;YAEAY;QACF;kBAEC9B;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/menu/MenuItemButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useEffect } from \"react\";\n\nimport { useHoverMode } from \"../hoverMode/useHoverMode.js\";\nimport { IconRotator } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useAppSize } from \"../media-queries/AppSizeProvider.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { type BaseMenuButtonProps } from \"./MenuButton.js\";\nimport { useMenuConfiguration } from \"./MenuConfigurationProvider.js\";\nimport { MenuItem, type MenuItemProps } from \"./MenuItem.js\";\nimport { useMenuVisibility } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport interface MenuItemButtonProps\n extends BaseMenuButtonProps, MenuItemProps {}\n\n/**\n * **Client Component**\n *\n * This is just an internal component that handles rendering a submenu as a\n * menuitem for a `DropdownMenu` with a conditional dropdown icon.\n *\n * @internal\n * @since 5.0.0\n */\nexport const MenuItemButton = forwardRef<HTMLLIElement, MenuItemButtonProps>(\n function MenuItemButton(props, ref) {\n const {\n id: propId,\n children,\n height: propHeight,\n onClick = noop,\n onKeyDown = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n rightAddon: propRightAddon,\n iconRotatorProps,\n disableDropdownIcon = typeof propRightAddon !== \"undefined\",\n ...remaining\n } = props;\n const { disabled } = props;\n\n const id = useEnsuredId(propId, \"menuitem\");\n const mode = useUserInteractionMode();\n const { renderAsSheet } = useMenuConfiguration();\n const { isPhone } = useAppSize();\n const isSheet =\n renderAsSheet === true || (renderAsSheet === \"phone\" && isPhone);\n const {\n root,\n menubar,\n activeId,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n leaveTimeoutRef,\n hoverTimeoutRef,\n } = useMenuBarContext();\n const { visible, setVisible, defaultFocusIndex } = useMenuVisibility();\n const { startShowFlow, clearVisibilityTimeout } = useHoverMode({\n setVisible,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n leaveTimeoutRef,\n hoverTimeoutRef,\n clearDisableTimer,\n });\n const { horizontal } = useMenuConfiguration();\n\n useEffect(() => {\n setVisible(id === activeId);\n }, [activeId, defaultFocusIndex, id, menubar, setVisible]);\n\n let height = propHeight;\n let rightAddon = propRightAddon;\n const dropdownIcon = getIcon(root ? \"dropdown\" : \"forward\");\n if (!disableDropdownIcon) {\n if (!height && !props.leftAddon) {\n height = \"normal\";\n }\n\n rightAddon = (\n <IconRotator {...iconRotatorProps} rotated={visible}>\n {dropdownIcon}\n </IconRotator>\n );\n }\n\n const updateVisibility = (nextVisible: boolean, focusIndex = 0): void => {\n defaultFocusIndex.current = focusIndex;\n setVisible(nextVisible);\n if (!menubar) {\n return;\n }\n\n if (nextVisible) {\n enableHoverMode(id);\n } else {\n disableHoverMode();\n }\n };\n\n return (\n <MenuItem\n {...remaining}\n aria-haspopup={isSheet ? \"dialog\" : \"menu\"}\n aria-expanded={visible || undefined}\n id={id}\n ref={ref}\n rightAddon={rightAddon}\n onClick={(event) => {\n onClick(event);\n\n event.stopPropagation();\n updateVisibility(!visible);\n }}\n onKeyDown={(event) => {\n onKeyDown(event);\n\n switch (event.key) {\n case \"ArrowDown\":\n if (horizontal || root) {\n event.preventDefault();\n event.stopPropagation();\n updateVisibility(true);\n }\n break;\n case \"ArrowRight\":\n if (!horizontal && !root) {\n event.preventDefault();\n event.stopPropagation();\n updateVisibility(true);\n }\n break;\n }\n }}\n onMouseEnter={(event) => {\n onMouseEnter(event);\n if (mode === \"touch\" || disabled || !menubar) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n startShowFlow(id);\n }}\n onMouseLeave={(event) => {\n onMouseLeave(event);\n if (mode === \"touch\" || disabled || !menubar) {\n return;\n }\n\n clearVisibilityTimeout();\n }}\n >\n {children}\n </MenuItem>\n );\n }\n);\n"],"names":["forwardRef","useEffect","useHoverMode","IconRotator","getIcon","useUserInteractionMode","useAppSize","useEnsuredId","useMenuConfiguration","MenuItem","useMenuVisibility","useMenuBarContext","noop","MenuItemButton","props","ref","id","propId","children","height","propHeight","onClick","onKeyDown","onMouseEnter","onMouseLeave","rightAddon","propRightAddon","iconRotatorProps","disableDropdownIcon","remaining","disabled","mode","renderAsSheet","isPhone","isSheet","root","menubar","activeId","enableHoverMode","disableHoverMode","startDisableTimer","clearDisableTimer","leaveTimeoutRef","hoverTimeoutRef","visible","setVisible","defaultFocusIndex","startShowFlow","clearVisibilityTimeout","horizontal","dropdownIcon","leftAddon","rotated","updateVisibility","nextVisible","focusIndex","current","aria-haspopup","aria-expanded","undefined","event","stopPropagation","key","preventDefault"],"mappings":"AAAA;;AAEA,SAASA,UAAU,EAAEC,SAAS,QAAQ,QAAQ;AAE9C,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,UAAU,QAAQ,sC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;YAEAY;QACF;kBAEC9B;;AAGP,GACA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/MenuItemFileInput.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ChangeEventHandler,\n type InputHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { MenuItem, type MenuItemProps } from \"./MenuItem.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0 Removed most of the shared `FileInputProps` from this\n * implementation.\n */\nexport interface MenuItemFileInputProps\n extends Omit<MenuItemProps, \"onChange\">,\n Pick<\n InputHTMLAttributes<HTMLInputElement>,\n \"accept\" | \"capture\" | \"multiple\"\n > {\n /**\n * A change event handler that should do something with the selected files.\n * Usually the `onChange` returned by `useFileUpload` or:\n *\n * ```ts\n * onChange={(event) => {\n * const { files } = event.currentTarget;\n * // do something with files\n * }}\n * ```\n *\n * This is actually a native `Event` and not a `SyntheticEvent` because the\n * file input is created through `document.createElement` instead of `React`.\n * You can still access the files through `event.currentTarget.files` like\n * normal.\n */\n onChange: ChangeEventHandler<HTMLInputElement>;\n\n /**\n * Set this to `true` if the `Menu` should not close when the file input's\n * menu item is clicked.\n *\n * @defaultValue `false`\n */\n preventMenuHideOnClick?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * A wrapper for the `<input type=\"file\">` element that works within menus.\n *\n * @see {@link https://react-md.dev/components/menu#menuitemfileinput-example | DropdownMenu Demos}\n * @since 5.0.0\n * @since 6.0.0 No longer creates an invisible file input element within the\n * menu item. This allows the menu to be closed immediately when this menu item\n * is clicked.\n */\nexport const MenuItemFileInput = forwardRef<\n HTMLLIElement,\n MenuItemFileInputProps\n>(function MenuItemFileInput(props, ref) {\n const {\n id: propId,\n onClick = noop,\n onChange,\n accept,\n capture,\n multiple,\n children,\n leftAddon: propLeftAddon,\n preventMenuHideOnClick = false,\n ...remaining\n } = props;\n\n const id = useEnsuredId(propId, \"menu-item\");\n const leftAddon = getIcon(\"upload\", propLeftAddon);\n\n return (\n <MenuItem\n {...remaining}\n id={id}\n ref={ref}\n leftAddon={leftAddon}\n onClick={(event) => {\n onClick(event);\n\n if (preventMenuHideOnClick) {\n event.stopPropagation();\n }\n\n // Since the menu closes when the menu item is clicked causing the\n // elements to be removed from the DOM, a normal `<input type=\"file\" />`\n // can't be used. Instead, create a temporary file input element and\n // click it to trigger the file upload behavior.\n let input: HTMLInputElement | null = document.createElement(\"input\");\n input.type = \"file\";\n if (accept) {\n input.accept = accept;\n }\n if (multiple) {\n input.multiple = multiple;\n }\n if (capture) {\n input.capture = capture === true ? \"\" : capture;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n input.onchange = onChange;\n input.click();\n input = null;\n }}\n >\n {children}\n </MenuItem>\n );\n});\n"],"names":["forwardRef","getIcon","useEnsuredId","MenuItem","noop","MenuItemFileInput","props","ref","id","propId","onClick","onChange","accept","capture","multiple","children","leftAddon","propLeftAddon","preventMenuHideOnClick","remaining","event","stopPropagation","input","document","createElement","type","onchange","click"],"mappings":"AAAA;;AAEA,SAGEA,UAAU,QACL,QAAQ;AAEf,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,QAAQ,QAA4B,gBAAgB;AAE7D,MAAMC,OAAO;AACX,aAAa;AACf;AAuCA;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,kCAAoBL,WAG/B,SAASK,kBAAkBC,KAAK,EAAEC,GAAG;IACrC,MAAM,EACJC,IAAIC,MAAM,EACVC,UAAUN,IAAI,EACdO,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,WAAWC,aAAa,EACxBC,yBAAyB,KAAK,EAC9B,GAAGC,WACJ,GAAGb;IAEJ,MAAME,KAAKN,aAAaO,QAAQ;IAChC,MAAMO,YAAYf,QAAQ,UAAUgB;IAEpC,qBACE,KAACd;QACE,GAAGgB,SAAS;QACbX,IAAIA;QACJD,KAAKA;QACLS,WAAWA;QACXN,SAAS,CAACU;YACRV,QAAQU;YAER,IAAIF,wBAAwB;gBAC1BE,MAAMC,eAAe;YACvB;YAEA,kEAAkE;YAClE,wEAAwE;YACxE,oEAAoE;YACpE,gDAAgD;YAChD,IAAIC,QAAiCC,SAASC,aAAa,CAAC;YAC5DF,MAAMG,IAAI,GAAG;YACb,IAAIb,QAAQ;gBACVU,MAAMV,MAAM,GAAGA;YACjB;YACA,IAAIE,UAAU;gBACZQ,MAAMR,QAAQ,GAAGA;YACnB;YACA,IAAID,SAAS;gBACXS,MAAMT,OAAO,GAAGA,YAAY,OAAO,KAAKA;YAC1C;YAEA,6DAA6D;YAC7D,mBAAmB;YACnBS,MAAMI,QAAQ,GAAGf;YACjBW,MAAMK,KAAK;YACXL,QAAQ;QACV;kBAECP;;AAGP,GAAG"}
1
+ {"version":3,"sources":["../../src/menu/MenuItemFileInput.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ChangeEventHandler,\n type InputHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { MenuItem, type MenuItemProps } from \"./MenuItem.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0 Removed most of the shared `FileInputProps` from this\n * implementation.\n */\nexport interface MenuItemFileInputProps\n extends\n Omit<MenuItemProps, \"onChange\">,\n Pick<\n InputHTMLAttributes<HTMLInputElement>,\n \"accept\" | \"capture\" | \"multiple\"\n > {\n /**\n * A change event handler that should do something with the selected files.\n * Usually the `onChange` returned by `useFileUpload` or:\n *\n * ```ts\n * onChange={(event) => {\n * const { files } = event.currentTarget;\n * // do something with files\n * }}\n * ```\n *\n * This is actually a native `Event` and not a `SyntheticEvent` because the\n * file input is created through `document.createElement` instead of `React`.\n * You can still access the files through `event.currentTarget.files` like\n * normal.\n */\n onChange: ChangeEventHandler<HTMLInputElement>;\n\n /**\n * Set this to `true` if the `Menu` should not close when the file input's\n * menu item is clicked.\n *\n * @defaultValue `false`\n */\n preventMenuHideOnClick?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * A wrapper for the `<input type=\"file\">` element that works within menus.\n *\n * @see {@link https://react-md.dev/components/menu#menuitemfileinput-example | DropdownMenu Demos}\n * @since 5.0.0\n * @since 6.0.0 No longer creates an invisible file input element within the\n * menu item. This allows the menu to be closed immediately when this menu item\n * is clicked.\n */\nexport const MenuItemFileInput = forwardRef<\n HTMLLIElement,\n MenuItemFileInputProps\n>(function MenuItemFileInput(props, ref) {\n const {\n id: propId,\n onClick = noop,\n onChange,\n accept,\n capture,\n multiple,\n children,\n leftAddon: propLeftAddon,\n preventMenuHideOnClick = false,\n ...remaining\n } = props;\n\n const id = useEnsuredId(propId, \"menu-item\");\n const leftAddon = getIcon(\"upload\", propLeftAddon);\n\n return (\n <MenuItem\n {...remaining}\n id={id}\n ref={ref}\n leftAddon={leftAddon}\n onClick={(event) => {\n onClick(event);\n\n if (preventMenuHideOnClick) {\n event.stopPropagation();\n }\n\n // Since the menu closes when the menu item is clicked causing the\n // elements to be removed from the DOM, a normal `<input type=\"file\" />`\n // can't be used. Instead, create a temporary file input element and\n // click it to trigger the file upload behavior.\n let input: HTMLInputElement | null = document.createElement(\"input\");\n input.type = \"file\";\n if (accept) {\n input.accept = accept;\n }\n if (multiple) {\n input.multiple = multiple;\n }\n if (capture) {\n input.capture = capture === true ? \"\" : capture;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n input.onchange = onChange;\n input.click();\n input = null;\n }}\n >\n {children}\n </MenuItem>\n );\n});\n"],"names":["forwardRef","getIcon","useEnsuredId","MenuItem","noop","MenuItemFileInput","props","ref","id","propId","onClick","onChange","accept","capture","multiple","children","leftAddon","propLeftAddon","preventMenuHideOnClick","remaining","event","stopPropagation","input","document","createElement","type","onchange","click"],"mappings":"AAAA;;AAEA,SAGEA,UAAU,QACL,QAAQ;AAEf,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,QAAQ,QAA4B,gBAAgB;AAE7D,MAAMC,OAAO;AACX,aAAa;AACf;AAwCA;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,kCAAoBL,WAG/B,SAASK,kBAAkBC,KAAK,EAAEC,GAAG;IACrC,MAAM,EACJC,IAAIC,MAAM,EACVC,UAAUN,IAAI,EACdO,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,WAAWC,aAAa,EACxBC,yBAAyB,KAAK,EAC9B,GAAGC,WACJ,GAAGb;IAEJ,MAAME,KAAKN,aAAaO,QAAQ;IAChC,MAAMO,YAAYf,QAAQ,UAAUgB;IAEpC,qBACE,KAACd;QACE,GAAGgB,SAAS;QACbX,IAAIA;QACJD,KAAKA;QACLS,WAAWA;QACXN,SAAS,CAACU;YACRV,QAAQU;YAER,IAAIF,wBAAwB;gBAC1BE,MAAMC,eAAe;YACvB;YAEA,kEAAkE;YAClE,wEAAwE;YACxE,oEAAoE;YACpE,gDAAgD;YAChD,IAAIC,QAAiCC,SAASC,aAAa,CAAC;YAC5DF,MAAMG,IAAI,GAAG;YACb,IAAIb,QAAQ;gBACVU,MAAMV,MAAM,GAAGA;YACjB;YACA,IAAIE,UAAU;gBACZQ,MAAMR,QAAQ,GAAGA;YACnB;YACA,IAAID,SAAS;gBACXS,MAAMT,OAAO,GAAGA,YAAY,OAAO,KAAKA;YAC1C;YAEA,6DAA6D;YAC7D,mBAAmB;YACnBS,MAAMI,QAAQ,GAAGf;YACjBW,MAAMK,KAAK;YACXL,QAAQ;QACV;kBAECP;;AAGP,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/MenuItemInputToggle.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type MouseEvent,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport {\n type ConfigurableInputToggleIconProps,\n type IndeterminateCheckboxProps,\n} from \"../form/InputToggle.js\";\nimport { InputToggleIcon } from \"../form/InputToggleIcon.js\";\nimport { SwitchTrack } from \"../form/SwitchTrack.js\";\nimport { type InputToggleSize } from \"../form/inputToggleStyles.js\";\nimport { ListItem } from \"../list/ListItem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemChildrenTextProps,\n type ListItemHeight,\n} from \"../list/types.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n menuItemInputToggle,\n menuItemInputToggleBall,\n menuItemInputToggleIcon,\n menuItemInputToggleTrack,\n} from \"./styles.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type MenuItemInputToggleCheckedCallback = (\n checked: boolean,\n event: MouseEvent<HTMLLIElement>\n) => void;\n\n/** @since 2.8.0 */\nexport interface BaseMenuItemInputToggleProps\n extends HTMLAttributes<HTMLLIElement>,\n ConfigurableInputToggleIconProps,\n ListItemChildrenTextProps {\n checked: boolean;\n onCheckedChange: MenuItemInputToggleCheckedCallback;\n\n /**\n * @defaultValue `\"menu-item-\" + useId()`\n */\n id?: string;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the `Menu` should not close when the input toggle is\n * clicked. This can be useful when interacting with a checkbox group within a\n * menu or allowing the user to select multiple options before closing the\n * menu.\n *\n * @defaultValue `false`\n */\n preventMenuHideOnClick?: boolean;\n\n /**\n * This is set to `\"auto\"` by default so the icon shrinks back down to the\n * default icon size instead of relative to the current font size. You\n * probably don't want to change this since it'll also modify the height of\n * the menu item\n *\n * @defaultValue `\"auto\"`\n */\n size?: InputToggleSize;\n\n /** @defaultValue `\"auto\"` */\n height?: ListItemHeight;\n\n /** @defaultValue `false` */\n iconAfter?: boolean;\n\n addon?: ReactNode;\n addonType?: ListItemAddonType;\n addonPosition?: ListItemAddonPosition;\n\n /** @defaultValue `false` */\n addonForceWrap?: boolean;\n\n /** @defaultValue `false` */\n disableAddonCenteredMedia?: boolean;\n}\n\nexport interface MenuItemCheckboxProps\n extends BaseMenuItemInputToggleProps,\n IndeterminateCheckboxProps {}\n\nexport type MenuItemRadioProps = BaseMenuItemInputToggleProps;\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Added additional props for styling the track and ball.\n */\nexport interface MenuItemSwitchProps extends BaseMenuItemInputToggleProps {\n trackProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n trackStyle?: CSSProperties;\n trackClassName?: string;\n ballProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n ballStyle?: CSSProperties;\n ballClassName?: string;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Updated to be a union of the different props to enforce the\n * correct props based on `type`\n */\nexport type MenuItemInputToggleProps =\n | (MenuItemCheckboxProps & { type: \"checkbox\" })\n | (MenuItemRadioProps & { type: \"radio\" })\n | (MenuItemSwitchProps & { type: \"switch\" });\n\n/**\n * **Client Component**\n *\n * This is a low-level component that should probably not be used externally and\n * instead the `MenuItemCheckbox`, `MenuItemRadio`, or `MenuItemSwitch` should\n * be used instead.\n *\n * @see {@link https://react-md.dev/components/menu | DropdownMenu Demos}\n * @see {@link MenuItemCheckbox} for checkbox examples\n * @see {@link MenuItemRadio} for radio examples\n * @see {@link MenuItemSwitch} for switch examples\n * @since 2.8.0\n */\nexport const MenuItemInputToggle = forwardRef<\n HTMLLIElement,\n MenuItemInputToggleProps\n>(function MenuItemInputToggle(props, ref) {\n const {\n id: propId,\n type,\n disabled = false,\n checked,\n onCheckedChange,\n preventMenuHideOnClick = false,\n onClick = noop,\n className,\n tabIndex = -1,\n children,\n size = \"auto\",\n icon: propIcon,\n iconAfter = false,\n iconProps,\n iconStyle,\n iconClassName,\n checkedIcon,\n indeterminate,\n indeterminateIcon,\n addon,\n addonType,\n addonPosition,\n addonForceWrap,\n disableAddonCenteredMedia,\n ballProps,\n ballStyle,\n ballClassName,\n trackProps,\n trackStyle,\n trackClassName,\n ...remaining\n } = props as MenuItemSwitchProps &\n MenuItemCheckboxProps & { type: \"checkbox\" | \"radio\" | \"switch\" };\n const id = useEnsuredId(propId, \"menu-item\");\n\n let icon = propIcon;\n if (type === \"switch\") {\n icon = (\n <SwitchTrack\n style={trackStyle}\n {...trackProps}\n className={cnb(\n menuItemInputToggleTrack(),\n trackClassName,\n trackProps?.className\n )}\n active={checked}\n ballProps={ballProps}\n ballStyle={ballStyle}\n ballClassName={cnb(menuItemInputToggleBall(), ballClassName)}\n />\n );\n } else {\n icon = (\n <InputToggleIcon\n style={iconStyle}\n disableEm\n {...iconProps}\n className={cnb(\n menuItemInputToggleIcon(),\n iconClassName,\n iconProps?.className\n )}\n size={size}\n type={type}\n checked={checked}\n disabled={disabled}\n icon={propIcon}\n checkedIcon={checkedIcon}\n indeterminate={indeterminate}\n indeterminateIcon={indeterminateIcon}\n />\n );\n }\n\n let leftAddon: ReactNode;\n let leftAddonType: ListItemAddonType | undefined;\n let leftAddonPosition: ListItemAddonPosition | undefined;\n let leftAddonForceWrap: boolean | undefined;\n let disableLeftAddonCenteredMedia: boolean | undefined;\n let rightAddon: ReactNode;\n let rightAddonType: ListItemAddonType | undefined;\n let rightAddonPosition: ListItemAddonPosition | undefined;\n let rightAddonForceWrap: boolean | undefined;\n let disableRightAddonCenteredMedia: boolean | undefined;\n if (iconAfter) {\n leftAddon = addon;\n leftAddonType = addonType;\n leftAddonPosition = addonPosition;\n leftAddonForceWrap = addonForceWrap;\n disableLeftAddonCenteredMedia = disableAddonCenteredMedia;\n rightAddon = icon;\n } else {\n leftAddon = icon;\n rightAddon = addon;\n rightAddonType = addonType;\n rightAddonPosition = addonPosition;\n rightAddonForceWrap = addonForceWrap;\n disableRightAddonCenteredMedia = disableAddonCenteredMedia;\n }\n\n return (\n <ListItem\n {...remaining}\n // I'm not actually sure if this is correct\n aria-checked={indeterminate && checked ? \"mixed\" : checked}\n id={id}\n role={type === \"radio\" ? \"menuitemradio\" : \"menuitemcheckbox\"}\n onClick={(event) => {\n onClick(event);\n onCheckedChange(!checked, event);\n\n if (preventMenuHideOnClick) {\n event.stopPropagation();\n }\n }}\n ref={ref}\n className={menuItemInputToggle({ type, className })}\n disabled={disabled}\n tabIndex={tabIndex}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonForceWrap={leftAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonForceWrap={rightAddonForceWrap}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItem>\n );\n});\n"],"names":["cnb","forwardRef","InputToggleIcon","SwitchTrack","ListItem","useEnsuredId","menuItemInputToggle","menuItemInputToggleBall","menuItemInputToggleIcon","menuItemInputToggleTrack","noop","MenuItemInputToggle","props","ref","id","propId","type","disabled","checked","onCheckedChange","preventMenuHideOnClick","onClick","className","tabIndex","children","size","icon","propIcon","iconAfter","iconProps","iconStyle","iconClassName","checkedIcon","indeterminate","indeterminateIcon","addon","addonType","addonPosition","addonForceWrap","disableAddonCenteredMedia","ballProps","ballStyle","ballClassName","trackProps","trackStyle","trackClassName","remaining","style","active","disableEm","leftAddon","leftAddonType","leftAddonPosition","leftAddonForceWrap","disableLeftAddonCenteredMedia","rightAddon","rightAddonType","rightAddonPosition","rightAddonForceWrap","disableRightAddonCenteredMedia","aria-checked","role","event","stopPropagation"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UAAU,QACL,QAAQ;AAMf,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,QAAQ,QAAQ,sBAAsB;AAQ/C,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,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAI/B,WAAW;QACbsB,YAAYf;QACZgB,gBAAgBf;QAChBgB,oBAAoBf;QACpBgB,qBAAqBf;QACrBgB,gCAAgCf;QAChCgB,aAAa7B;IACf,OAAO;QACLwB,YAAYxB;QACZ6B,aAAapB;QACbqB,iBAAiBpB;QACjBqB,qBAAqBpB;QACrBqB,sBAAsBpB;QACtBqB,iCAAiCpB;IACnC;IAEA,qBACE,KAACnC;QACE,GAAG0C,SAAS;QACb,2CAA2C;QAC3Cc,gBAAc3B,iBAAiBf,UAAU,UAAUA;QACnDJ,IAAIA;QACJ+C,MAAM7C,SAAS,UAAU,kBAAkB;QAC3CK,SAAS,CAACyC;YACRzC,QAAQyC;YACR3C,gBAAgB,CAACD,SAAS4C;YAE1B,IAAI1C,wBAAwB;gBAC1B0C,MAAMC,eAAe;YACvB;QACF;QACAlD,KAAKA;QACLS,WAAWhB,oBAAoB;YAAEU;YAAMM;QAAU;QACjDL,UAAUA;QACVM,UAAUA;QACV2B,WAAWA;QACXC,eAAeA;QACfC,mBAAmBA;QACnBC,oBAAoBA;QACpBC,+BAA+BA;QAC/BC,YAAYA;QACZC,gBAAgBA;QAChBC,oBAAoBA;QACpBC,qBAAqBA;QACrBC,gCAAgCA;kBAE/BnC;;AAGP,GAAG"}
1
+ {"version":3,"sources":["../../src/menu/MenuItemInputToggle.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type MouseEvent,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport {\n type ConfigurableInputToggleIconProps,\n type IndeterminateCheckboxProps,\n} from \"../form/InputToggle.js\";\nimport { InputToggleIcon } from \"../form/InputToggleIcon.js\";\nimport { SwitchTrack } from \"../form/SwitchTrack.js\";\nimport { type InputToggleSize } from \"../form/inputToggleStyles.js\";\nimport { ListItem } from \"../list/ListItem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemChildrenTextProps,\n type ListItemHeight,\n} from \"../list/types.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n menuItemInputToggle,\n menuItemInputToggleBall,\n menuItemInputToggleIcon,\n menuItemInputToggleTrack,\n} from \"./styles.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type MenuItemInputToggleCheckedCallback = (\n checked: boolean,\n event: MouseEvent<HTMLLIElement>\n) => void;\n\n/** @since 2.8.0 */\nexport interface BaseMenuItemInputToggleProps\n extends\n HTMLAttributes<HTMLLIElement>,\n ConfigurableInputToggleIconProps,\n ListItemChildrenTextProps {\n checked: boolean;\n onCheckedChange: MenuItemInputToggleCheckedCallback;\n\n /**\n * @defaultValue `\"menu-item-\" + useId()`\n */\n id?: string;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the `Menu` should not close when the input toggle is\n * clicked. This can be useful when interacting with a checkbox group within a\n * menu or allowing the user to select multiple options before closing the\n * menu.\n *\n * @defaultValue `false`\n */\n preventMenuHideOnClick?: boolean;\n\n /**\n * This is set to `\"auto\"` by default so the icon shrinks back down to the\n * default icon size instead of relative to the current font size. You\n * probably don't want to change this since it'll also modify the height of\n * the menu item\n *\n * @defaultValue `\"auto\"`\n */\n size?: InputToggleSize;\n\n /** @defaultValue `\"auto\"` */\n height?: ListItemHeight;\n\n /** @defaultValue `false` */\n iconAfter?: boolean;\n\n addon?: ReactNode;\n addonType?: ListItemAddonType;\n addonPosition?: ListItemAddonPosition;\n\n /** @defaultValue `false` */\n addonForceWrap?: boolean;\n\n /** @defaultValue `false` */\n disableAddonCenteredMedia?: boolean;\n}\n\nexport interface MenuItemCheckboxProps\n extends BaseMenuItemInputToggleProps, IndeterminateCheckboxProps {}\n\nexport type MenuItemRadioProps = BaseMenuItemInputToggleProps;\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Added additional props for styling the track and ball.\n */\nexport interface MenuItemSwitchProps extends BaseMenuItemInputToggleProps {\n trackProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n trackStyle?: CSSProperties;\n trackClassName?: string;\n ballProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n ballStyle?: CSSProperties;\n ballClassName?: string;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Updated to be a union of the different props to enforce the\n * correct props based on `type`\n */\nexport type MenuItemInputToggleProps =\n | (MenuItemCheckboxProps & { type: \"checkbox\" })\n | (MenuItemRadioProps & { type: \"radio\" })\n | (MenuItemSwitchProps & { type: \"switch\" });\n\n/**\n * **Client Component**\n *\n * This is a low-level component that should probably not be used externally and\n * instead the `MenuItemCheckbox`, `MenuItemRadio`, or `MenuItemSwitch` should\n * be used instead.\n *\n * @see {@link https://react-md.dev/components/menu | DropdownMenu Demos}\n * @see {@link MenuItemCheckbox} for checkbox examples\n * @see {@link MenuItemRadio} for radio examples\n * @see {@link MenuItemSwitch} for switch examples\n * @since 2.8.0\n */\nexport const MenuItemInputToggle = forwardRef<\n HTMLLIElement,\n MenuItemInputToggleProps\n>(function MenuItemInputToggle(props, ref) {\n const {\n id: propId,\n type,\n disabled = false,\n checked,\n onCheckedChange,\n preventMenuHideOnClick = false,\n onClick = noop,\n className,\n tabIndex = -1,\n children,\n size = \"auto\",\n icon: propIcon,\n iconAfter = false,\n iconProps,\n iconStyle,\n iconClassName,\n checkedIcon,\n indeterminate,\n indeterminateIcon,\n addon,\n addonType,\n addonPosition,\n addonForceWrap,\n disableAddonCenteredMedia,\n ballProps,\n ballStyle,\n ballClassName,\n trackProps,\n trackStyle,\n trackClassName,\n ...remaining\n } = props as MenuItemSwitchProps &\n MenuItemCheckboxProps & { type: \"checkbox\" | \"radio\" | \"switch\" };\n const id = useEnsuredId(propId, \"menu-item\");\n\n let icon = propIcon;\n if (type === \"switch\") {\n icon = (\n <SwitchTrack\n style={trackStyle}\n {...trackProps}\n className={cnb(\n menuItemInputToggleTrack(),\n trackClassName,\n trackProps?.className\n )}\n active={checked}\n ballProps={ballProps}\n ballStyle={ballStyle}\n ballClassName={cnb(menuItemInputToggleBall(), ballClassName)}\n />\n );\n } else {\n icon = (\n <InputToggleIcon\n style={iconStyle}\n disableEm\n {...iconProps}\n className={cnb(\n menuItemInputToggleIcon(),\n iconClassName,\n iconProps?.className\n )}\n size={size}\n type={type}\n checked={checked}\n disabled={disabled}\n icon={propIcon}\n checkedIcon={checkedIcon}\n indeterminate={indeterminate}\n indeterminateIcon={indeterminateIcon}\n />\n );\n }\n\n let leftAddon: ReactNode;\n let leftAddonType: ListItemAddonType | undefined;\n let leftAddonPosition: ListItemAddonPosition | undefined;\n let leftAddonForceWrap: boolean | undefined;\n let disableLeftAddonCenteredMedia: boolean | undefined;\n let rightAddon: ReactNode;\n let rightAddonType: ListItemAddonType | undefined;\n let rightAddonPosition: ListItemAddonPosition | undefined;\n let rightAddonForceWrap: boolean | undefined;\n let disableRightAddonCenteredMedia: boolean | undefined;\n if (iconAfter) {\n leftAddon = addon;\n leftAddonType = addonType;\n leftAddonPosition = addonPosition;\n leftAddonForceWrap = addonForceWrap;\n disableLeftAddonCenteredMedia = disableAddonCenteredMedia;\n rightAddon = icon;\n } else {\n leftAddon = icon;\n rightAddon = addon;\n rightAddonType = addonType;\n rightAddonPosition = addonPosition;\n rightAddonForceWrap = addonForceWrap;\n disableRightAddonCenteredMedia = disableAddonCenteredMedia;\n }\n\n return (\n <ListItem\n {...remaining}\n // I'm not actually sure if this is correct\n aria-checked={indeterminate && checked ? \"mixed\" : checked}\n id={id}\n role={type === \"radio\" ? \"menuitemradio\" : \"menuitemcheckbox\"}\n onClick={(event) => {\n onClick(event);\n onCheckedChange(!checked, event);\n\n if (preventMenuHideOnClick) {\n event.stopPropagation();\n }\n }}\n ref={ref}\n className={menuItemInputToggle({ type, className })}\n disabled={disabled}\n tabIndex={tabIndex}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonForceWrap={leftAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonForceWrap={rightAddonForceWrap}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItem>\n );\n});\n"],"names":["cnb","forwardRef","InputToggleIcon","SwitchTrack","ListItem","useEnsuredId","menuItemInputToggle","menuItemInputToggleBall","menuItemInputToggleIcon","menuItemInputToggleTrack","noop","MenuItemInputToggle","props","ref","id","propId","type","disabled","checked","onCheckedChange","preventMenuHideOnClick","onClick","className","tabIndex","children","size","icon","propIcon","iconAfter","iconProps","iconStyle","iconClassName","checkedIcon","indeterminate","indeterminateIcon","addon","addonType","addonPosition","addonForceWrap","disableAddonCenteredMedia","ballProps","ballStyle","ballClassName","trackProps","trackStyle","trackClassName","remaining","style","active","disableEm","leftAddon","leftAddonType","leftAddonPosition","leftAddonForceWrap","disableLeftAddonCenteredMedia","rightAddon","rightAddonType","rightAddonPosition","rightAddonForceWrap","disableRightAddonCenteredMedia","aria-checked","role","event","stopPropagation"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UAAU,QACL,QAAQ;AAMf,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,QAAQ,QAAQ,sBAAsB;AAQ/C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,wBAAwB,QACnB,cAAc;AAErB,MAAMC,OAAO;AACX,aAAa;AACf;AA4FA;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,oCAAsBV,WAGjC,SAASU,oBAAoBC,KAA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