@react-md/core 6.4.0 → 6.5.1

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 (431) hide show
  1. package/dist/_a11y.scss +3 -1
  2. package/dist/_box-shadows.scss +20 -12
  3. package/dist/_core.scss +1 -1
  4. package/dist/_utils.scss +26 -11
  5. package/dist/app-bar/_app-bar.scss +3 -3
  6. package/dist/autocomplete/AutocompleteChip.js +2 -2
  7. package/dist/autocomplete/AutocompleteChip.js.map +1 -1
  8. package/dist/autocomplete/AutocompleteListboxChildren.js +1 -1
  9. package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
  10. package/dist/autocomplete/_autocomplete.scss +20 -16
  11. package/dist/autocomplete/useAutocomplete.js +4 -4
  12. package/dist/autocomplete/useAutocomplete.js.map +1 -1
  13. package/dist/autocomplete/utils.js +3 -3
  14. package/dist/autocomplete/utils.js.map +1 -1
  15. package/dist/avatar/_avatar.scss +2 -1
  16. package/dist/box/styles.js +2 -2
  17. package/dist/box/styles.js.map +1 -1
  18. package/dist/button/AsyncButton.js +1 -1
  19. package/dist/button/AsyncButton.js.map +1 -1
  20. package/dist/button/_button.scss +9 -5
  21. package/dist/card/_card.scss +6 -6
  22. package/dist/chip/Chip.js +1 -1
  23. package/dist/chip/Chip.js.map +1 -1
  24. package/dist/chip/_chip.scss +6 -6
  25. package/dist/cssUtils.d.ts +11 -6
  26. package/dist/cssUtils.js.map +1 -1
  27. package/dist/datetime/useTimeField.js +1 -1
  28. package/dist/datetime/useTimeField.js.map +1 -1
  29. package/dist/delegateEvent.js +9 -9
  30. package/dist/delegateEvent.js.map +1 -1
  31. package/dist/dialog/_dialog.scss +6 -6
  32. package/dist/divider/_divider.scss +6 -2
  33. package/dist/draggable/useDraggable.js +4 -4
  34. package/dist/draggable/useDraggable.js.map +1 -1
  35. package/dist/draggable/utils.js +1 -1
  36. package/dist/draggable/utils.js.map +1 -1
  37. package/dist/expansion-panel/ExpansionPanel.js +1 -1
  38. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  39. package/dist/expansion-panel/useExpansionPanels.js +1 -1
  40. package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
  41. package/dist/files/FileInput.js +1 -1
  42. package/dist/files/FileInput.js.map +1 -1
  43. package/dist/files/createAcceptFromExtensions.d.ts +5 -0
  44. package/dist/files/createAcceptFromExtensions.js +15 -0
  45. package/dist/files/createAcceptFromExtensions.js.map +1 -0
  46. package/dist/files/useFileUpload.js +45 -41
  47. package/dist/files/useFileUpload.js.map +1 -1
  48. package/dist/files/utils.js +14 -10
  49. package/dist/files/utils.js.map +1 -1
  50. package/dist/files/validation.js +7 -8
  51. package/dist/files/validation.js.map +1 -1
  52. package/dist/focus/useFocusContainer.js +1 -1
  53. package/dist/focus/useFocusContainer.js.map +1 -1
  54. package/dist/focus/utils.js +12 -7
  55. package/dist/focus/utils.js.map +1 -1
  56. package/dist/form/InputToggleIcon.js +5 -1
  57. package/dist/form/InputToggleIcon.js.map +1 -1
  58. package/dist/form/NativeSelect.js +1 -1
  59. package/dist/form/NativeSelect.js.map +1 -1
  60. package/dist/form/Select.d.ts +24 -0
  61. package/dist/form/Select.js +19 -8
  62. package/dist/form/Select.js.map +1 -1
  63. package/dist/form/SelectedOption.d.ts +1 -2
  64. package/dist/form/SelectedOption.js +2 -2
  65. package/dist/form/SelectedOption.js.map +1 -1
  66. package/dist/form/_input-toggle.scss +6 -5
  67. package/dist/form/_label.scss +2 -2
  68. package/dist/form/_legend.scss +22 -13
  69. package/dist/form/_slider.scss +7 -5
  70. package/dist/form/_switch.scss +7 -5
  71. package/dist/form/_text-field.scss +13 -11
  72. package/dist/form/formConfig.js +1 -1
  73. package/dist/form/formConfig.js.map +1 -1
  74. package/dist/form/inputToggleStyles.js +7 -1
  75. package/dist/form/inputToggleStyles.js.map +1 -1
  76. package/dist/form/legendStyles.d.ts +1 -1
  77. package/dist/form/legendStyles.js.map +1 -1
  78. package/dist/form/selectUtils.js +2 -2
  79. package/dist/form/selectUtils.js.map +1 -1
  80. package/dist/form/useCombobox.js +1 -0
  81. package/dist/form/useCombobox.js.map +1 -1
  82. package/dist/form/useFormReset.js +2 -2
  83. package/dist/form/useFormReset.js.map +1 -1
  84. package/dist/form/useNumberField.js +1 -1
  85. package/dist/form/useNumberField.js.map +1 -1
  86. package/dist/form/useResizingTextArea.js +4 -4
  87. package/dist/form/useResizingTextArea.js.map +1 -1
  88. package/dist/form/useSelectCombobox.js +1 -1
  89. package/dist/form/useSelectCombobox.js.map +1 -1
  90. package/dist/form/validation.js +1 -1
  91. package/dist/form/validation.js.map +1 -1
  92. package/dist/hoverMode/useHoverMode.js +8 -8
  93. package/dist/hoverMode/useHoverMode.js.map +1 -1
  94. package/dist/hoverMode/useHoverModeProvider.js +3 -3
  95. package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
  96. package/dist/icon/config.js +3 -3
  97. package/dist/icon/config.js.map +1 -1
  98. package/dist/icon/materialConfig.js +1 -1
  99. package/dist/icon/materialConfig.js.map +1 -1
  100. package/dist/interaction/UserInteractionModeProvider.js +11 -10
  101. package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
  102. package/dist/interaction/_interaction.scss +5 -3
  103. package/dist/interaction/utils.js +7 -3
  104. package/dist/interaction/utils.js.map +1 -1
  105. package/dist/layout/useExpandableLayout.js +3 -4
  106. package/dist/layout/useExpandableLayout.js.map +1 -1
  107. package/dist/layout/useMainTabIndex.js +1 -1
  108. package/dist/layout/useMainTabIndex.js.map +1 -1
  109. package/dist/list/ListItem.js +1 -1
  110. package/dist/list/ListItem.js.map +1 -1
  111. package/dist/media-queries/AppSizeProvider.js +1 -1
  112. package/dist/media-queries/AppSizeProvider.js.map +1 -1
  113. package/dist/media-queries/config.js +2 -2
  114. package/dist/media-queries/config.js.map +1 -1
  115. package/dist/media-queries/useMediaQuery.js +3 -3
  116. package/dist/media-queries/useMediaQuery.js.map +1 -1
  117. package/dist/menu/Menu.js +4 -4
  118. package/dist/menu/Menu.js.map +1 -1
  119. package/dist/menu/MenuItemButton.js +1 -1
  120. package/dist/menu/MenuItemButton.js.map +1 -1
  121. package/dist/menu/MenuItemFileInput.js +1 -1
  122. package/dist/menu/MenuItemFileInput.js.map +1 -1
  123. package/dist/menu/MenuWidget.js +2 -2
  124. package/dist/menu/MenuWidget.js.map +1 -1
  125. package/dist/movement/findMatchIndex.js +2 -2
  126. package/dist/movement/findMatchIndex.js.map +1 -1
  127. package/dist/movement/useKeyboardMovementProvider.js +2 -2
  128. package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
  129. package/dist/movement/utils.js +12 -10
  130. package/dist/movement/utils.js.map +1 -1
  131. package/dist/navigation/getTableOfContentsHeadings.js +4 -3
  132. package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
  133. package/dist/navigation/useActiveHeadingId.js +9 -9
  134. package/dist/navigation/useActiveHeadingId.js.map +1 -1
  135. package/dist/navigation/useTableOfContentsHeadings.js +1 -1
  136. package/dist/navigation/useTableOfContentsHeadings.js.map +1 -1
  137. package/dist/navigation/utils.js +6 -5
  138. package/dist/navigation/utils.js.map +1 -1
  139. package/dist/portal/PortalContainerProvider.js +5 -3
  140. package/dist/portal/PortalContainerProvider.js.map +1 -1
  141. package/dist/positioning/getFixedPosition.js +2 -4
  142. package/dist/positioning/getFixedPosition.js.map +1 -1
  143. package/dist/positioning/useFixedPositioning.js +2 -2
  144. package/dist/positioning/useFixedPositioning.js.map +1 -1
  145. package/dist/positioning/utils.js +3 -3
  146. package/dist/positioning/utils.js.map +1 -1
  147. package/dist/scroll/getScrollbarWidth.js +4 -4
  148. package/dist/scroll/getScrollbarWidth.js.map +1 -1
  149. package/dist/searching/fuzzy.js +3 -2
  150. package/dist/searching/fuzzy.js.map +1 -1
  151. package/dist/searching/toSearchQuery.js +1 -1
  152. package/dist/searching/toSearchQuery.js.map +1 -1
  153. package/dist/searching/utils.js +1 -1
  154. package/dist/searching/utils.js.map +1 -1
  155. package/dist/snackbar/Toast.js +1 -1
  156. package/dist/snackbar/Toast.js.map +1 -1
  157. package/dist/snackbar/ToastContent.js +2 -2
  158. package/dist/snackbar/ToastContent.js.map +1 -1
  159. package/dist/snackbar/ToastManager.d.ts +1 -1
  160. package/dist/snackbar/ToastManager.js +11 -11
  161. package/dist/snackbar/ToastManager.js.map +1 -1
  162. package/dist/snackbar/_snackbar.scss +3 -3
  163. package/dist/spinbutton/useSpinButton.js +1 -1
  164. package/dist/spinbutton/useSpinButton.js.map +1 -1
  165. package/dist/spinbutton/utils/deselectNode.js +1 -1
  166. package/dist/spinbutton/utils/deselectNode.js.map +1 -1
  167. package/dist/spinbutton/utils/resolveInputEvent.js +1 -1
  168. package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -1
  169. package/dist/spinbutton/utils/selectNode.js +1 -1
  170. package/dist/spinbutton/utils/selectNode.js.map +1 -1
  171. package/dist/storage/useStorage.js +8 -3
  172. package/dist/storage/useStorage.js.map +1 -1
  173. package/dist/table/useStickyTableSection.js +1 -1
  174. package/dist/table/useStickyTableSection.js.map +1 -1
  175. package/dist/tabs/TabList.js +2 -2
  176. package/dist/tabs/TabList.js.map +1 -1
  177. package/dist/tabs/_tabs.scss +5 -6
  178. package/dist/tabs/useMaxTabPanelHeight.js +4 -3
  179. package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
  180. package/dist/tabs/useTabList.js +1 -1
  181. package/dist/tabs/useTabList.js.map +1 -1
  182. package/dist/test-utils/jest-globals/match-media.d.ts +1 -1
  183. package/dist/test-utils/jest-globals/match-media.js +1 -1
  184. package/dist/test-utils/jest-globals/match-media.js.map +1 -1
  185. package/dist/test-utils/jest-globals/timers.js +1 -1
  186. package/dist/test-utils/jest-globals/timers.js.map +1 -1
  187. package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js +1 -1
  188. package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js.map +1 -1
  189. package/dist/test-utils/mocks/ResizeObserver.js +2 -2
  190. package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
  191. package/dist/test-utils/polyfills/IntersectionObserver.js +2 -2
  192. package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
  193. package/dist/test-utils/polyfills/ResizeObserver.js +2 -2
  194. package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
  195. package/dist/test-utils/polyfills/TextDecoder.js +2 -2
  196. package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
  197. package/dist/test-utils/polyfills/TextEncoder.js +2 -2
  198. package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
  199. package/dist/test-utils/polyfills/matchMedia.js +2 -2
  200. package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
  201. package/dist/test-utils/polyfills/offsetParent.js +2 -2
  202. package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
  203. package/dist/test-utils/polyfills/scrollIntoView.js +1 -1
  204. package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
  205. package/dist/test-utils/queries/select.js +2 -2
  206. package/dist/test-utils/queries/select.js.map +1 -1
  207. package/dist/test-utils/queries/slider.js +1 -1
  208. package/dist/test-utils/queries/slider.js.map +1 -1
  209. package/dist/test-utils/utils/createFileList.js +2 -0
  210. package/dist/test-utils/utils/createFileList.js.map +1 -1
  211. package/dist/test-utils/utils/createMatchMediaSpy.d.ts +1 -1
  212. package/dist/test-utils/utils/createMatchMediaSpy.js +3 -3
  213. package/dist/test-utils/utils/createMatchMediaSpy.js.map +1 -1
  214. package/dist/test-utils/vitest/match-media.d.ts +1 -1
  215. package/dist/test-utils/vitest/match-media.js +1 -1
  216. package/dist/test-utils/vitest/match-media.js.map +1 -1
  217. package/dist/test-utils/vitest/timers.js +1 -1
  218. package/dist/test-utils/vitest/timers.js.map +1 -1
  219. package/dist/test-utils/vitest/uploadMenuItemFileInput.js +1 -1
  220. package/dist/test-utils/vitest/uploadMenuItemFileInput.js.map +1 -1
  221. package/dist/theme/ThemeProvider.js +2 -2
  222. package/dist/theme/ThemeProvider.js.map +1 -1
  223. package/dist/theme/_a11y.scss +3 -1
  224. package/dist/theme/_theme.scss +16 -12
  225. package/dist/theme/getDerivedTheme.js +1 -1
  226. package/dist/theme/getDerivedTheme.js.map +1 -1
  227. package/dist/theme/useCSSVariables.js +5 -5
  228. package/dist/theme/useCSSVariables.js.map +1 -1
  229. package/dist/theme/useColorSchemeMetaTag.js +2 -2
  230. package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
  231. package/dist/theme/useInlineCSSVariables.js +4 -3
  232. package/dist/theme/useInlineCSSVariables.js.map +1 -1
  233. package/dist/theme/utils.js +8 -8
  234. package/dist/theme/utils.js.map +1 -1
  235. package/dist/tooltip/useTooltip.js +7 -7
  236. package/dist/tooltip/useTooltip.js.map +1 -1
  237. package/dist/tooltip/useTooltipPosition.js +1 -1
  238. package/dist/tooltip/useTooltipPosition.js.map +1 -1
  239. package/dist/transition/useCarousel.js +2 -2
  240. package/dist/transition/useCarousel.js.map +1 -1
  241. package/dist/transition/useCollapseTransition.js +1 -1
  242. package/dist/transition/useCollapseTransition.js.map +1 -1
  243. package/dist/transition/useSkeletonPlaceholder.js +4 -4
  244. package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
  245. package/dist/transition/useTransition.js +2 -2
  246. package/dist/transition/useTransition.js.map +1 -1
  247. package/dist/transition/utils.js +5 -5
  248. package/dist/transition/utils.js.map +1 -1
  249. package/dist/tree/TreeItem.js +1 -1
  250. package/dist/tree/TreeItem.js.map +1 -1
  251. package/dist/tree/useTreeItems.js +7 -5
  252. package/dist/tree/useTreeItems.js.map +1 -1
  253. package/dist/tree/useTreeMovement.js +1 -1
  254. package/dist/tree/useTreeMovement.js.map +1 -1
  255. package/dist/tree/utils.js +6 -9
  256. package/dist/tree/utils.js.map +1 -1
  257. package/dist/typography/HighlightText.js +2 -1
  258. package/dist/typography/HighlightText.js.map +1 -1
  259. package/dist/typography/SrOnly.js +7 -1
  260. package/dist/typography/SrOnly.js.map +1 -1
  261. package/dist/useDebouncedFunction.js +4 -4
  262. package/dist/useDebouncedFunction.js.map +1 -1
  263. package/dist/useDropzone.js +9 -9
  264. package/dist/useDropzone.js.map +1 -1
  265. package/dist/useEnsuredState.js +5 -5
  266. package/dist/useEnsuredState.js.map +1 -1
  267. package/dist/useIntersectionObserver.js +3 -3
  268. package/dist/useIntersectionObserver.js.map +1 -1
  269. package/dist/useIsomorphicLayoutEffect.js +1 -1
  270. package/dist/useIsomorphicLayoutEffect.js.map +1 -1
  271. package/dist/useOrientation.js +1 -1
  272. package/dist/useOrientation.js.map +1 -1
  273. package/dist/useReadonlySet.js +1 -1
  274. package/dist/useReadonlySet.js.map +1 -1
  275. package/dist/useResizeListener.js +2 -2
  276. package/dist/useResizeListener.js.map +1 -1
  277. package/dist/useResizeObserver.js +3 -4
  278. package/dist/useResizeObserver.js.map +1 -1
  279. package/dist/useThrottledFunction.js +3 -3
  280. package/dist/useThrottledFunction.js.map +1 -1
  281. package/dist/useWindowSize.js +1 -1
  282. package/dist/useWindowSize.js.map +1 -1
  283. package/dist/utils/alphaNumericSort.js +3 -1
  284. package/dist/utils/alphaNumericSort.js.map +1 -1
  285. package/dist/utils/bem.js +9 -12
  286. package/dist/utils/bem.js.map +1 -1
  287. package/dist/utils/getNumberOfDigits.js +1 -0
  288. package/dist/utils/getNumberOfDigits.js.map +1 -1
  289. package/dist/utils/getRangeDefaultValue.js +1 -1
  290. package/dist/utils/getRangeDefaultValue.js.map +1 -1
  291. package/dist/utils/nearest.js +2 -2
  292. package/dist/utils/nearest.js.map +1 -1
  293. package/dist/utils/parseCssLengthUnit.js +3 -3
  294. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  295. package/dist/utils/trigonometry.js +1 -1
  296. package/dist/utils/trigonometry.js.map +1 -1
  297. package/dist/window-splitter/_window-splitter.scss +15 -17
  298. package/package.json +9 -7
  299. package/src/autocomplete/AutocompleteChip.tsx +2 -2
  300. package/src/autocomplete/AutocompleteListboxChildren.tsx +1 -1
  301. package/src/autocomplete/useAutocomplete.ts +4 -4
  302. package/src/autocomplete/utils.ts +3 -3
  303. package/src/box/styles.ts +2 -2
  304. package/src/button/AsyncButton.tsx +1 -3
  305. package/src/chip/Chip.tsx +1 -2
  306. package/src/cssUtils.ts +12 -6
  307. package/src/datetime/useTimeField.ts +1 -1
  308. package/src/delegateEvent.ts +9 -9
  309. package/src/draggable/useDraggable.ts +4 -4
  310. package/src/draggable/utils.ts +1 -1
  311. package/src/expansion-panel/ExpansionPanel.tsx +1 -1
  312. package/src/expansion-panel/useExpansionPanels.ts +1 -1
  313. package/src/files/FileInput.tsx +1 -1
  314. package/src/files/createAcceptFromExtensions.ts +18 -0
  315. package/src/files/useFileUpload.ts +36 -37
  316. package/src/files/utils.ts +15 -11
  317. package/src/files/validation.ts +7 -9
  318. package/src/focus/useFocusContainer.ts +1 -1
  319. package/src/focus/utils.ts +11 -6
  320. package/src/form/InputToggleIcon.tsx +5 -5
  321. package/src/form/NativeSelect.tsx +1 -1
  322. package/src/form/Select.tsx +58 -7
  323. package/src/form/SelectedOption.tsx +2 -4
  324. package/src/form/formConfig.ts +1 -1
  325. package/src/form/inputToggleStyles.ts +9 -4
  326. package/src/form/legendStyles.ts +1 -1
  327. package/src/form/selectUtils.ts +2 -2
  328. package/src/form/useCombobox.ts +1 -0
  329. package/src/form/useFormReset.ts +2 -2
  330. package/src/form/useNumberField.ts +1 -1
  331. package/src/form/useResizingTextArea.ts +5 -5
  332. package/src/form/useSelectCombobox.ts +1 -4
  333. package/src/form/validation.ts +1 -1
  334. package/src/hoverMode/useHoverMode.ts +9 -9
  335. package/src/hoverMode/useHoverModeProvider.ts +4 -4
  336. package/src/icon/config.tsx +3 -3
  337. package/src/icon/materialConfig.ts +1 -1
  338. package/src/interaction/UserInteractionModeProvider.tsx +11 -10
  339. package/src/interaction/utils.ts +3 -3
  340. package/src/layout/useExpandableLayout.ts +3 -4
  341. package/src/layout/useMainTabIndex.ts +1 -1
  342. package/src/list/ListItem.tsx +1 -1
  343. package/src/media-queries/AppSizeProvider.tsx +1 -1
  344. package/src/media-queries/config.ts +2 -2
  345. package/src/media-queries/useMediaQuery.ts +3 -3
  346. package/src/menu/Menu.tsx +4 -4
  347. package/src/menu/MenuItemButton.tsx +1 -1
  348. package/src/menu/MenuItemFileInput.tsx +1 -1
  349. package/src/menu/MenuWidget.tsx +6 -4
  350. package/src/movement/findMatchIndex.ts +2 -2
  351. package/src/movement/useKeyboardMovementProvider.ts +2 -2
  352. package/src/movement/utils.ts +15 -14
  353. package/src/navigation/getTableOfContentsHeadings.ts +4 -3
  354. package/src/navigation/useActiveHeadingId.ts +8 -8
  355. package/src/navigation/useTableOfContentsHeadings.ts +1 -1
  356. package/src/navigation/utils.ts +6 -5
  357. package/src/portal/PortalContainerProvider.tsx +5 -3
  358. package/src/positioning/getFixedPosition.ts +9 -6
  359. package/src/positioning/useFixedPositioning.ts +2 -2
  360. package/src/positioning/utils.ts +3 -3
  361. package/src/scroll/getScrollbarWidth.ts +4 -4
  362. package/src/searching/fuzzy.ts +7 -3
  363. package/src/searching/toSearchQuery.ts +1 -1
  364. package/src/searching/utils.ts +1 -1
  365. package/src/snackbar/Toast.tsx +1 -1
  366. package/src/snackbar/ToastContent.tsx +2 -2
  367. package/src/snackbar/ToastManager.ts +11 -12
  368. package/src/spinbutton/useSpinButton.ts +1 -1
  369. package/src/spinbutton/utils/deselectNode.ts +1 -1
  370. package/src/spinbutton/utils/resolveInputEvent.ts +1 -1
  371. package/src/spinbutton/utils/selectNode.ts +1 -1
  372. package/src/storage/useStorage.ts +7 -2
  373. package/src/table/useStickyTableSection.tsx +1 -1
  374. package/src/tabs/TabList.tsx +2 -2
  375. package/src/tabs/useMaxTabPanelHeight.ts +6 -3
  376. package/src/tabs/useTabList.ts +2 -2
  377. package/src/test-utils/jest-globals/match-media.ts +5 -2
  378. package/src/test-utils/jest-globals/timers.ts +1 -1
  379. package/src/test-utils/jest-globals/uploadMenuItemFileInput.ts +1 -1
  380. package/src/test-utils/mocks/ResizeObserver.ts +2 -2
  381. package/src/test-utils/polyfills/IntersectionObserver.ts +2 -2
  382. package/src/test-utils/polyfills/ResizeObserver.ts +2 -2
  383. package/src/test-utils/polyfills/TextDecoder.ts +2 -2
  384. package/src/test-utils/polyfills/TextEncoder.ts +2 -2
  385. package/src/test-utils/polyfills/matchMedia.ts +5 -2
  386. package/src/test-utils/polyfills/offsetParent.ts +2 -2
  387. package/src/test-utils/polyfills/scrollIntoView.ts +1 -1
  388. package/src/test-utils/queries/select.ts +2 -2
  389. package/src/test-utils/queries/slider.ts +1 -1
  390. package/src/test-utils/utils/createFileList.ts +2 -0
  391. package/src/test-utils/utils/createMatchMediaSpy.ts +4 -4
  392. package/src/test-utils/vitest/match-media.ts +2 -2
  393. package/src/test-utils/vitest/timers.ts +1 -1
  394. package/src/test-utils/vitest/uploadMenuItemFileInput.ts +1 -1
  395. package/src/theme/ThemeProvider.tsx +2 -2
  396. package/src/theme/getDerivedTheme.ts +1 -1
  397. package/src/theme/useCSSVariables.ts +5 -5
  398. package/src/theme/useColorSchemeMetaTag.ts +2 -2
  399. package/src/theme/useInlineCSSVariables.ts +6 -7
  400. package/src/theme/utils.ts +8 -8
  401. package/src/tooltip/useTooltip.ts +7 -7
  402. package/src/tooltip/useTooltipPosition.ts +1 -1
  403. package/src/transition/useCarousel.ts +2 -2
  404. package/src/transition/useCollapseTransition.ts +1 -1
  405. package/src/transition/useSkeletonPlaceholder.ts +4 -4
  406. package/src/transition/useTransition.ts +2 -2
  407. package/src/transition/utils.ts +5 -5
  408. package/src/tree/TreeItem.tsx +1 -1
  409. package/src/tree/useTreeItems.ts +5 -5
  410. package/src/tree/useTreeMovement.ts +1 -1
  411. package/src/tree/utils.ts +9 -9
  412. package/src/typography/HighlightText.tsx +4 -3
  413. package/src/typography/SrOnly.tsx +9 -2
  414. package/src/useDebouncedFunction.ts +5 -5
  415. package/src/useDropzone.ts +10 -10
  416. package/src/useEnsuredState.ts +5 -5
  417. package/src/useIntersectionObserver.ts +3 -3
  418. package/src/useIsomorphicLayoutEffect.ts +3 -3
  419. package/src/useOrientation.ts +1 -1
  420. package/src/useReadonlySet.ts +3 -1
  421. package/src/useResizeListener.ts +2 -2
  422. package/src/useResizeObserver.ts +3 -4
  423. package/src/useThrottledFunction.ts +4 -4
  424. package/src/useWindowSize.ts +1 -1
  425. package/src/utils/alphaNumericSort.ts +1 -1
  426. package/src/utils/bem.ts +15 -16
  427. package/src/utils/getNumberOfDigits.ts +1 -0
  428. package/src/utils/getRangeDefaultValue.ts +1 -1
  429. package/src/utils/nearest.ts +5 -2
  430. package/src/utils/parseCssLengthUnit.ts +5 -4
  431. package/src/utils/trigonometry.ts +1 -1
@@ -82,7 +82,7 @@ const { Provider } = context;
82
82
  isTablet
83
83
  ]);
84
84
  let value = appSize;
85
- if (ssr || typeof window === "undefined") {
85
+ if (ssr || globalThis.window === undefined) {
86
86
  value = {
87
87
  __root: true,
88
88
  ...ssrSize
@@ -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} 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;IACRC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf;AACAN,QAAQO,WAA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,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 || globalThis.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","globalThis","window","undefined"],"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;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,GAAGjB,WAAWO;IAC1C,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIU,MAAM;IAClB;IAEA,OAAOD;AACT;AAmBA;;;;;;;;;CASC,GACD,OAAO,SAASE,gBAAgBC,KAA2B;IACzD,MAAM,EACJC,UAAUjB,gBAAgB,EAC1BkB,gBAAgBjB,mBA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4.0
13
13
  */ export function configureMediaQueries(queries) {
14
14
  if (process.env.NODE_ENV !== "production") {
15
- Object.entries(queries).forEach(([name, value])=>{
15
+ for (const [name, value] of Object.entries(queries)){
16
16
  if (!(name in MEDIA_QUERY_CONFIG)) {
17
17
  throw new Error(`${name} is an invalid react-md media query.`);
18
18
  }
19
19
  MEDIA_QUERY_CONFIG[name] = value;
20
- });
20
+ }
21
21
  } else {
22
22
  Object.assign(MEDIA_QUERY_CONFIG, queries);
23
23
  }
@@ -1 +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
+ {"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 for (const [name, value] of Object.entries(queries)) {\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","name","value","Object","entries","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;QACzC,KAAK,MAAM,CAACC,MAAMC,MAAM,IAAIC,OAAOC,OAAO,CAACP,SAAU;YACnD,IAAI,CAAEI,CAAAA,QAAQX,kBAAiB,GAAI;gBACjC,MAAM,IAAIe,MAAM,GAAGJ,KAAK,oCAAoC,CAAC;YAC/D;YAEAX,kBAAkB,CAACW,KAA+B,GAAGC;QACvD;IACF,OAAO;QACLC,OAAOG,MAAM,CAAChB,oBAAoBO;IACpC;AACF"}
@@ -24,16 +24,16 @@ import { useSsr } from "../SsrProvider.js";
24
24
  */ export function useMediaQuery(query, disabled = false) {
25
25
  const ssr = useSsr();
26
26
  const [matches, setMatches] = useState(()=>{
27
- if (typeof window === "undefined" || disabled || ssr) {
27
+ if (globalThis.window === undefined || disabled || ssr) {
28
28
  return false;
29
29
  }
30
- return window.matchMedia(query).matches;
30
+ return globalThis.matchMedia(query).matches;
31
31
  });
32
32
  useEffect(()=>{
33
33
  if (disabled || ssr) {
34
34
  return;
35
35
  }
36
- const result = window.matchMedia(query);
36
+ const result = globalThis.matchMedia(query);
37
37
  setMatches(result.matches);
38
38
  const updater = ({ matches })=>{
39
39
  setMatches(matches);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/media-queries/useMediaQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useMediaQuery } from \"@react-md/core/media-queries/useMediaQuery\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const matches = useMediaQuery(\"screen and (min-width: 768px)\");\n *\n * return <>{matches ? \"Matches\" : \"Doesn't\"}</>;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/hooks/use-media-query | useMediaQuery Demos}\n * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}\n * @param query - The media query to use\n * @param disabled - When `true`, the `window.matchMedia` API will not be\n * activated and the hook will return the last cached value.\n * @returns `true` if the media query matches\n * @since 6.0.0 Removed the `defaultValue` and `checkImmediately` options.\n */\nexport function useMediaQuery(query: string, disabled = false): boolean {\n const ssr = useSsr();\n const [matches, setMatches] = useState(() => {\n if (typeof window === \"undefined\" || disabled || ssr) {\n return false;\n }\n\n return window.matchMedia(query).matches;\n });\n\n useEffect(() => {\n if (disabled || ssr) {\n return;\n }\n\n const result = window.matchMedia(query);\n setMatches(result.matches);\n\n const updater = ({ matches }: MediaQueryListEvent): void => {\n setMatches(matches);\n };\n\n result.addEventListener(\"change\", updater);\n return () => {\n result.removeEventListener(\"change\", updater);\n };\n }, [disabled, query, ssr]);\n\n return matches;\n}\n"],"names":["useEffect","useState","useSsr","useMediaQuery","query","disabled","ssr","matches","setMatches","window","matchMedia","result","updater","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SAASC,MAAM,QAAQ,oBAAoB;AAE3C;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,cAAcC,KAAa,EAAEC,WAAW,KAAK;IAC3D,MAAMC,MAAMJ;IACZ,MAAM,CAACK,SAASC,WAAW,GAAGP,SAAS;QACrC,IAAI,OAAOQ,WAAW,eAAeJ,YAAYC,KAAK;YACpD,OAAO;QACT;QAEA,OAAOG,OAAOC,UAAU,CAACN,OAAOG,OAAO;IACzC;IAEAP,UAAU;QACR,IAAIK,YAAYC,KAAK;YACnB;QACF;QAEA,MAAMK,SAASF,OAAOC,UAAU,CAACN;QACjCI,WAAWG,OAAOJ,OAAO;QAEzB,MAAMK,UAAU,CAAC,EAAEL,OAAO,EAAuB;YAC/CC,WAAWD;QACb;QAEAI,OAAOE,gBAAgB,CAAC,UAAUD;QAClC,OAAO;YACLD,OAAOG,mBAAmB,CAAC,UAAUF;QACvC;IACF,GAAG;QAACP;QAAUD;QAAOE;KAAI;IAEzB,OAAOC;AACT"}
1
+ {"version":3,"sources":["../../src/media-queries/useMediaQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useMediaQuery } from \"@react-md/core/media-queries/useMediaQuery\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const matches = useMediaQuery(\"screen and (min-width: 768px)\");\n *\n * return <>{matches ? \"Matches\" : \"Doesn't\"}</>;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/hooks/use-media-query | useMediaQuery Demos}\n * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}\n * @param query - The media query to use\n * @param disabled - When `true`, the `window.matchMedia` API will not be\n * activated and the hook will return the last cached value.\n * @returns `true` if the media query matches\n * @since 6.0.0 Removed the `defaultValue` and `checkImmediately` options.\n */\nexport function useMediaQuery(query: string, disabled = false): boolean {\n const ssr = useSsr();\n const [matches, setMatches] = useState(() => {\n if (globalThis.window === undefined || disabled || ssr) {\n return false;\n }\n\n return globalThis.matchMedia(query).matches;\n });\n\n useEffect(() => {\n if (disabled || ssr) {\n return;\n }\n\n const result = globalThis.matchMedia(query);\n setMatches(result.matches);\n\n const updater = ({ matches }: MediaQueryListEvent): void => {\n setMatches(matches);\n };\n\n result.addEventListener(\"change\", updater);\n return () => {\n result.removeEventListener(\"change\", updater);\n };\n }, [disabled, query, ssr]);\n\n return matches;\n}\n"],"names":["useEffect","useState","useSsr","useMediaQuery","query","disabled","ssr","matches","setMatches","globalThis","window","undefined","matchMedia","result","updater","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SAASC,MAAM,QAAQ,oBAAoB;AAE3C;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,cAAcC,KAAa,EAAEC,WAAW,KAAK;IAC3D,MAAMC,MAAMJ;IACZ,MAAM,CAACK,SAASC,WAAW,GAAGP,SAAS;QACrC,IAAIQ,WAAWC,MAAM,KAAKC,aAAaN,YAAYC,KAAK;YACtD,OAAO;QACT;QAEA,OAAOG,WAAWG,UAAU,CAACR,OAAOG,OAAO;IAC7C;IAEAP,UAAU;QACR,IAAIK,YAAYC,KAAK;YACnB;QACF;QAEA,MAAMO,SAASJ,WAAWG,UAAU,CAACR;QACrCI,WAAWK,OAAON,OAAO;QAEzB,MAAMO,UAAU,CAAC,EAAEP,OAAO,EAAuB;YAC/CC,WAAWD;QACb;QAEAM,OAAOE,gBAAgB,CAAC,UAAUD;QAClC,OAAO;YACLD,OAAOG,mBAAmB,CAAC,UAAUF;QACvC;IACF,GAAG;QAACT;QAAUD;QAAOE;KAAI;IAEzB,OAAOC;AACT"}
package/dist/menu/Menu.js CHANGED
@@ -203,12 +203,12 @@ const noop = ()=>{
203
203
  };
204
204
  // wait an animation frame so the initial click event that caused the menu
205
205
  // to become visible does not immediately close the menu
206
- const frame = window.requestAnimationFrame(()=>{
207
- window.addEventListener("click", callback);
206
+ const frame = globalThis.requestAnimationFrame(()=>{
207
+ globalThis.addEventListener("click", callback);
208
208
  });
209
209
  return ()=>{
210
- window.cancelAnimationFrame(frame);
211
- window.removeEventListener("click", callback);
210
+ globalThis.cancelAnimationFrame(frame);
211
+ globalThis.removeEventListener("click", callback);
212
212
  };
213
213
  }, [
214
214
  disableHoverMode,
@@ -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\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,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;AA+MA;;;;;;;;;;;;;;;;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,EACvBC,aAAaC,YAAY,EACzBC,aAAaC,YAAY,EACzBC,eAAeC,cAAc,EAC7BC,eAAeC,cAAc,EAC7BC,mBAA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E,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 = globalThis.requestAnimationFrame(() => {\n globalThis.addEventListener(\"click\", callback);\n });\n\n return () => {\n globalThis.cancelAnimationFrame(frame);\n globalThis.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","globalThis","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,s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AMuC;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"}
@@ -23,7 +23,7 @@ const noop = ()=>{
23
23
  * @internal
24
24
  * @since 5.0.0
25
25
  */ export const MenuItemButton = /*#__PURE__*/ forwardRef(function MenuItemButton(props, ref) {
26
- const { id: propId, children, height: propHeight, onClick = noop, onKeyDown = noop, onMouseEnter = noop, onMouseLeave = noop, rightAddon: propRightAddon, iconRotatorProps, disableDropdownIcon = typeof propRightAddon !== "undefined", ...remaining } = props;
26
+ const { id: propId, children, height: propHeight, onClick = noop, onKeyDown = noop, onMouseEnter = noop, onMouseLeave = noop, rightAddon: propRightAddon, iconRotatorProps, disableDropdownIcon = propRightAddon !== undefined, ...remaining } = props;
27
27
  const { disabled } = props;
28
28
  const id = useEnsuredId(propId, "menuitem");
29
29
  const mode = useUserInteractionMode();
@@ -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, 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;AASA;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAAiBb,WAC5B,SAASa,eAAeC,KAAK,EAAEC,GAAG;IAChC,MAAM,EACJC,IAAIC,MAAM,EACVC,QAAQ,EACRC,QAAQC,UAAU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ACX,IAAI,CAAClB,SAAS;YACZ;QACF;QAEA,IAAIkB,aAAa;YACfhB,gBAAgBtB;QAClB,OAAO;YACLuB;QACF;IACF;IAEA,qBACE,KAAC9B;QACE,GAAGoB,SAAS;QACb4B,iBAAevB,UAAU,WAAW;QACpCwB,iBAAed,WAAWe;QAC1B3C,IAAIA;QACJD,KAAKA;QACLU,YAAYA;QACZJ,SAAS,CAACuC;YACRvC,QAAQuC;YAERA,MAAMC,eAAe;YACrBR,iBAAiB,CAACT;QACpB;QACAtB,WAAW,CAACsC;YACVtC,UAAUsC;YAEV,OAAQA,MAAME,GAAG;gBACf,KAAK;oBACH,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 = 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","undefined","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","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;AASA;;;;;;;;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,sBAAsBF,mBAAmBG,SAAS,EAClD,GAAGC,WACJ,GAAGhB;IACJ,MAAM,EAAEiB,QAAQ,EAAE,GAAGjB;IAErB,MAAME,KAAKT,aAAaU,QAAQ;IAChC,MAAMe,OAAO3B;IACb,MAAM,EAAE4B,aAAa,EAAE,GAAGzB;IAC1B,MAAM,EAAE0B,OAAO,EAAE,GAAG5B;IACpB,MAAM6B,UACJF,kBAAkB,QAASA,kBAAkB,WAAWC;IAC1D,MAAM,EACJE,IAAI,EACJC,OAAO,EACPC,QAAQ,EACRC,eAAe,EAC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oBACnB;oBACA;gBACF,KAAK;oBACH,IAAI,CAACJ,cAAc,CAACd,MAAM;wBACxBwB,MAAMG,cAAc;wBACpBH,MAAMC,eAAe;wBACrBP,iBAAiB;oBACnB;oBACA;YACJ;QACF;QACA/B,cAAc,CAACqC;YACbrC,aAAaqC;YACb,IAAI5B,SAAS,WAAWD,YAAY,CAACM,SAAS;gBAC5C;YACF;YAEAU,kBAAkBU,OAAO,GAAG;YAC5BT,cAAchC;QAChB;QACAQ,cAAc,CAACoC;YACbpC,aAAaoC;YACb,IAAI5B,SAAS,WAAWD,YAAY,CAACM,SAAS;gBAC5C;YACF;YAEAY;QACF;kBAEC/B;;AAGP,GACA"}
@@ -48,7 +48,7 @@ const noop = ()=>{
48
48
  }
49
49
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
50
  // @ts-expect-error
51
- input.onchange = onChange;
51
+ input.addEventListener("change", onChange);
52
52
  input.click();
53
53
  input = null;
54
54
  },
@@ -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\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
+ {"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.addEventListener(\"change\", 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","addEventListener","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,gBAAgB,CAAC,UAAUf;YACjCW,MAAMK,KAAK;YACXL,QAAQ;QACV;kBAECP;;AAGP,GAAG"}
@@ -46,7 +46,7 @@ const noop = ()=>{
46
46
  if (!isSheet) {
47
47
  return;
48
48
  }
49
- window.cancelAnimationFrame(sheetBlurredFame.current);
49
+ globalThis.cancelAnimationFrame(sheetBlurredFame.current);
50
50
  setSheetMenuFocused(true);
51
51
  },
52
52
  onKeyDown,
@@ -84,7 +84,7 @@ const noop = ()=>{
84
84
  if (!isSheet) {
85
85
  return;
86
86
  }
87
- sheetBlurredFame.current = window.requestAnimationFrame(()=>{
87
+ sheetBlurredFame.current = globalThis.requestAnimationFrame(()=>{
88
88
  setSheetMenuFocused(false);
89
89
  });
90
90
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu/MenuWidget.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useRef, useState } from \"react\";\n\nimport { List } from \"../list/List.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type NonNullMutableRef } from \"../types.js\";\nimport { type MenuListConvenienceProps } from \"./Menu.js\";\nimport { MenuWidgetKeyboardProvider } from \"./MenuWidgetKeyboardProvider.js\";\nimport { menu } from \"./styles.js\";\nimport {\n MenuBarProvider,\n useMenuBarContext,\n useMenuBarProvider,\n} from \"./useMenuBarProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @internal\n */\nexport interface MenuWidgetProps\n extends HTMLAttributes<HTMLDivElement>, MenuListConvenienceProps {\n isSheet: boolean;\n horizontal: boolean;\n disableElevation?: boolean;\n cancelUnmountFocus: NonNullMutableRef<boolean>;\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * **Client Component**\n *\n * This component was added to support the listbox role and the `useId()` hook.\n * If the `temporary` prop is set, the `MenuItem`'s ids will not be the same the\n * next time the menu opens, so the aria-activedescendant will point to a\n * non-existing id\n *\n * @internal\n */\nexport const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(\n function MenuWidget(props, ref) {\n const {\n id,\n role = \"menu\",\n className,\n listStyle,\n listClassName,\n listProps,\n children,\n onClick,\n onBlur = noop,\n onFocus = noop,\n onKeyDown = noop,\n tabIndex = -1,\n isSheet,\n horizontal,\n disableElevation,\n cancelUnmountFocus,\n getDefaultFocusedIndex,\n ...remaining\n } = props;\n const isListbox = role === \"listbox\";\n const { menubar } = useMenuBarContext();\n\n // Since there is the possibility of other tab focusable elements within the\n // sheet and the menu items are programmatically focused, the menu's\n // tabIndex needs to be set to `-1` while one of the child menu items are\n // focused. This allows Shift+Tab correctly focuses the previous focusable\n // element within the sheet. Since `onFocus` and `onBlur` will be bubbled up\n // to the menu widget each time a new MenuItem is focused, only disable the\n // focused state if the blur event is fired without another focus event\n // within an animation frame.\n const [sheetMenuFocused, setSheetMenuFocused] = useState(false);\n const sheetBlurredFame = useRef(0);\n const menuBarContext = useMenuBarProvider({\n root: false,\n menubar,\n hoverTimeout: menubar ? 0 : undefined,\n defaultActiveId: id,\n });\n const { movementProps, movementContext } = useKeyboardMovementProvider({\n ref,\n onClick,\n onFocus(event) {\n onFocus(event);\n\n if (!isSheet) {\n return;\n }\n\n window.cancelAnimationFrame(sheetBlurredFame.current);\n setSheetMenuFocused(true);\n },\n onKeyDown,\n horizontal,\n loopable: true,\n searchable: true,\n programmatic: true,\n includeDisabled: true,\n getDefaultFocusedIndex,\n });\n\n return (\n <MenuWidgetKeyboardProvider disabled={isListbox} value={movementContext}>\n <MenuBarProvider value={menuBarContext}>\n <div\n aria-orientation={horizontal ? \"horizontal\" : undefined}\n {...remaining}\n {...(isListbox\n ? { onClick, onFocus, onKeyDown, ref }\n : movementProps)}\n id={id}\n role={role}\n className={menu({\n className,\n elevated: !disableElevation && !isSheet,\n horizontal,\n })}\n tabIndex={isSheet && !sheetMenuFocused ? 0 : tabIndex}\n onBlur={(event) => {\n onBlur(event);\n if (!isSheet) {\n return;\n }\n\n sheetBlurredFame.current = window.requestAnimationFrame(() => {\n setSheetMenuFocused(false);\n });\n }}\n >\n <List\n {...listProps}\n style={listStyle ?? listProps?.style}\n className={listClassName || listProps?.className}\n horizontal={horizontal}\n onClick={(event) => {\n listProps?.onClick?.(event);\n\n // this makes it so you can click on the menu/list without\n // closing the menu\n if (event.target === event.currentTarget) {\n event.stopPropagation();\n }\n\n // This might be a test only workaround since clicking links move focus\n // somewhere else\n if (event.target instanceof HTMLElement) {\n cancelUnmountFocus.current = event.currentTarget.contains(\n event.target.closest(\"a\")\n );\n }\n }}\n >\n {children}\n </List>\n </div>\n </MenuBarProvider>\n </MenuWidgetKeyboardProvider>\n );\n }\n);\n"],"names":["forwardRef","useRef","useState","List","useKeyboardMovementProvider","MenuWidgetKeyboardProvider","menu","MenuBarProvider","useMenuBarContext","useMenuBarProvider","noop","MenuWidget","props","ref","id","role","className","listStyle","listClassName","listProps","children","onClick","onBlur","onFocus","onKeyDown","tabIndex","isSheet","horizontal","disableElevation","cancelUnmountFocus","getDefaultFocusedIndex","remaining","isListbox","menubar","sheetMenuFocused","setSheetMenuFocused","sheetBlurredFame","menuBarContext","root","hoverTimeout","undefined","defaultActiveId","movementProps","movementContext","event","window","cancelAnimationFrame","current","loopable","searchable","programmatic","includeDisabled","disabled","value","div","aria-orientation","elevated","requestAnimationFrame","style","target","currentTarget","stopPropagation","HTMLElement","contains","closest"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,IAAI,QAAQ,kBAAkB;AAEvC,SAASC,2BAA2B,QAAQ,6CAA6C;AAGzF,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,IAAI,QAAQ,cAAc;AACnC,SACEC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,QACb,0BAA0B;AAEjC,MAAMC,OAAO;AACX,aAAa;AACf;AAcA;;;;;;;;;CASC,GACD,OAAO,MAAMC,2BAAaX,WACxB,SAASW,WAAWC,KAAK,EAAEC,GAAG;IAC5B,MAAM,EACJC,EAAE,EACFC,OAAO,MAAM,EACbC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,SAASZ,IAAI,EACba,UAAUb,IAAI,EACdc,YAAYd,IAAI,EAChBe,WAAW,CAAC,CAAC,EACbC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,kBAAkB,EAClBC,sBAAsB,EACtB,GAAGC,WACJ,GAAGnB;IACJ,MAAMoB,YAAYjB,SAAS;IAC3B,MAAM,EAAEkB,OAAO,EAAE,GAAGzB;IAEpB,4EAA4E;IAC5E,oEAAoE;IACpE,yEAAyE;IACzE,0EAA0E;IAC1E,4EAA4E;IAC5E,2EAA2E;IAC3E,uEAAuE;IACvE,6BAA6B;IAC7B,MAAM,CAAC0B,kBAAkBC,oBAAoB,GAAGjC,SAAS;IACzD,MAAMkC,mBAAmBnC,OAAO;IAChC,MAAMoC,iBAAiB5B,mBAAmB;QACxC6B,MAAM;QACNL;QACAM,cAAcN,UAAU,IAAIO;QAC5BC,iBAAiB3B;IACnB;IACA,MAAM,EAAE4B,aAAa,EAAEC,eAAe,EAAE,GAAGvC,4BAA4B;QACrES;QACAQ;QACAE,SAAQqB,KAAK;YACXrB,QAA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Mb,GACA"}
1
+ {"version":3,"sources":["../../src/menu/MenuWidget.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useRef, useState } from \"react\";\n\nimport { List } from \"../list/List.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type NonNullMutableRef } from \"../types.js\";\nimport { type MenuListConvenienceProps } from \"./Menu.js\";\nimport { MenuWidgetKeyboardProvider } from \"./MenuWidgetKeyboardProvider.js\";\nimport { menu } from \"./styles.js\";\nimport {\n MenuBarProvider,\n useMenuBarContext,\n useMenuBarProvider,\n} from \"./useMenuBarProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @internal\n */\nexport interface MenuWidgetProps\n extends HTMLAttributes<HTMLDivElement>, MenuListConvenienceProps {\n isSheet: boolean;\n horizontal: boolean;\n disableElevation?: boolean;\n cancelUnmountFocus: NonNullMutableRef<boolean>;\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * **Client Component**\n *\n * This component was added to support the listbox role and the `useId()` hook.\n * If the `temporary` prop is set, the `MenuItem`'s ids will not be the same the\n * next time the menu opens, so the aria-activedescendant will point to a\n * non-existing id\n *\n * @internal\n */\nexport const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(\n function MenuWidget(props, ref) {\n const {\n id,\n role = \"menu\",\n className,\n listStyle,\n listClassName,\n listProps,\n children,\n onClick,\n onBlur = noop,\n onFocus = noop,\n onKeyDown = noop,\n tabIndex = -1,\n isSheet,\n horizontal,\n disableElevation,\n cancelUnmountFocus,\n getDefaultFocusedIndex,\n ...remaining\n } = props;\n const isListbox = role === \"listbox\";\n const { menubar } = useMenuBarContext();\n\n // Since there is the possibility of other tab focusable elements within the\n // sheet and the menu items are programmatically focused, the menu's\n // tabIndex needs to be set to `-1` while one of the child menu items are\n // focused. This allows Shift+Tab correctly focuses the previous focusable\n // element within the sheet. Since `onFocus` and `onBlur` will be bubbled up\n // to the menu widget each time a new MenuItem is focused, only disable the\n // focused state if the blur event is fired without another focus event\n // within an animation frame.\n const [sheetMenuFocused, setSheetMenuFocused] = useState(false);\n const sheetBlurredFame = useRef(0);\n const menuBarContext = useMenuBarProvider({\n root: false,\n menubar,\n hoverTimeout: menubar ? 0 : undefined,\n defaultActiveId: id,\n });\n const { movementProps, movementContext } = useKeyboardMovementProvider({\n ref,\n onClick,\n onFocus(event) {\n onFocus(event);\n\n if (!isSheet) {\n return;\n }\n\n globalThis.cancelAnimationFrame(sheetBlurredFame.current);\n setSheetMenuFocused(true);\n },\n onKeyDown,\n horizontal,\n loopable: true,\n searchable: true,\n programmatic: true,\n includeDisabled: true,\n getDefaultFocusedIndex,\n });\n\n return (\n <MenuWidgetKeyboardProvider disabled={isListbox} value={movementContext}>\n <MenuBarProvider value={menuBarContext}>\n <div\n aria-orientation={horizontal ? \"horizontal\" : undefined}\n {...remaining}\n {...(isListbox\n ? { onClick, onFocus, onKeyDown, ref }\n : movementProps)}\n id={id}\n role={role}\n className={menu({\n className,\n elevated: !disableElevation && !isSheet,\n horizontal,\n })}\n tabIndex={isSheet && !sheetMenuFocused ? 0 : tabIndex}\n onBlur={(event) => {\n onBlur(event);\n if (!isSheet) {\n return;\n }\n\n sheetBlurredFame.current = globalThis.requestAnimationFrame(\n () => {\n setSheetMenuFocused(false);\n }\n );\n }}\n >\n <List\n {...listProps}\n style={listStyle ?? listProps?.style}\n className={listClassName || listProps?.className}\n horizontal={horizontal}\n onClick={(event) => {\n listProps?.onClick?.(event);\n\n // this makes it so you can click on the menu/list without\n // closing the menu\n if (event.target === event.currentTarget) {\n event.stopPropagation();\n }\n\n // This might be a test only workaround since clicking links move focus\n // somewhere else\n if (event.target instanceof HTMLElement) {\n cancelUnmountFocus.current = event.currentTarget.contains(\n event.target.closest(\"a\")\n );\n }\n }}\n >\n {children}\n </List>\n </div>\n </MenuBarProvider>\n </MenuWidgetKeyboardProvider>\n );\n }\n);\n"],"names":["forwardRef","useRef","useState","List","useKeyboardMovementProvider","MenuWidgetKeyboardProvider","menu","MenuBarProvider","useMenuBarContext","useMenuBarProvider","noop","MenuWidget","props","ref","id","role","className","listStyle","listClassName","listProps","children","onClick","onBlur","onFocus","onKeyDown","tabIndex","isSheet","horizontal","disableElevation","cancelUnmountFocus","getDefaultFocusedIndex","remaining","isListbox","menubar","sheetMenuFocused","setSheetMenuFocused","sheetBlurredFame","menuBarContext","root","hoverTimeout","undefined","defaultActiveId","movementProps","movementContext","event","globalThis","cancelAnimationFrame","current","loopable","searchable","programmatic","includeDisabled","disabled","value","div","aria-orientation","elevated","requestAnimationFrame","style","target","currentTarget","stopPropagation","HTMLElement","contains","closest"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,IAAI,QAAQ,kBAAkB;AAEvC,SAASC,2BAA2B,QAAQ,6CAA6C;AAGzF,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,IAAI,QAAQ,cAAc;AACnC,SACEC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,QACb,0BAA0B;AAEjC,MAAMC,OAAO;AACX,aAAa;AACf;AAcA;;;;;;;;;CASC,GACD,OAAO,MAAMC,2BAAaX,WACxB,SAASW,WAAWC,KAAK,EAAEC,GAAG;IAC5B,MAAM,EACJC,EAAE,EACFC,OAAO,MAAM,EACbC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,SAASZ,IAAI,EACba,UAAUb,IAAI,EACdc,YAAYd,IAAI,EAChBe,WAAW,CAAC,CAAC,EACbC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,kBAAkB,EAClBC,sBAAsB,EACtB,GAAGC,WACJ,GAAGnB;IACJ,MAAMoB,YAAYjB,SAAS;IAC3B,MAAM,EAAEkB,OAAO,EAAE,GAAGzB;IAEpB,4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1C,WAAWE,iBAAiBC,WAAWH;oBACvCW,YAAYA;oBACZN,SAAS,CAACuB;wBACRzB,WAAWE,UAAUuB;wBAErB,0DAA0D;wBAC1D,mBAAmB;wBACnB,IAAIA,MAAMe,MAAM,KAAKf,MAAMgB,aAAa,EAAE;4BACxChB,MAAMiB,eAAe;wBACvB;wBAEA,uEAAuE;wBACvE,iBAAiB;wBACjB,IAAIjB,MAAMe,MAAM,YAAYG,aAAa;4BACvCjC,mBAAmBkB,OAAO,GAAGH,MAAMgB,aAAa,CAACG,QAAQ,CACvDnB,MAAMe,MAAM,CAACK,OAAO,CAAC;wBAEzB;oBACF;8BAEC5C;;;;;AAMb,GACA"}
@@ -9,7 +9,7 @@
9
9
  * @internal
10
10
  */ export function findMatchInRange(options) {
11
11
  const { values, startIndex, endIndex } = options;
12
- if (!values.length) {
12
+ if (values.length === 0) {
13
13
  return -1;
14
14
  }
15
15
  const value = options.value.toUpperCase();
@@ -34,7 +34,7 @@
34
34
  */ export function findMatchIndex(options) {
35
35
  const { value, values, startIndex, isSelfMatchable = true } = options;
36
36
  // this was added to support comboboxes when there are no options available
37
- if (!values.length) {
37
+ if (values.length === 0) {
38
38
  return -1;
39
39
  }
40
40
  let index = findMatchInRange({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/movement/findMatchIndex.ts"],"sourcesContent":["/** @internal */\nexport interface BaseOptions {\n /**\n * The current query string to find within the values\n */\n value: string;\n\n /**\n * The list of values to search within\n */\n values: readonly string[];\n\n /**\n * The start index for the search\n */\n startIndex: number;\n}\n\n/** @internal */\nexport interface MatchInRangeOptions extends BaseOptions {\n /**\n * The end index for the search\n */\n endIndex: number;\n}\n\n/**\n * Attempts to find the first match index for a list of values that starts with\n * the provided query string and is within the start and end indexes. If no\n * matches are found, -1 will be returned instead.\n *\n * Since this is normally coming from a keydown event, the query *must* be a\n * string of all capital letters to work as each value will be converted to\n * uppercase before checking.\n * @internal\n */\nexport function findMatchInRange(options: MatchInRangeOptions): number {\n const { values, startIndex, endIndex } = options;\n if (!values.length) {\n return -1;\n }\n\n const value = options.value.toUpperCase();\n\n for (let i = startIndex; i < endIndex; i += 1) {\n const content = values[i];\n if (content.toUpperCase().indexOf(value) === 0) {\n return i;\n }\n }\n\n return -1;\n}\n\n/** @internal */\nexport interface MatchIndexOptions extends BaseOptions {\n /**\n * Boolean if the current index can be included in the search\n *\n * @defaultValue `true`\n */\n isSelfMatchable?: boolean;\n}\n\n/**\n * A function that is used to find the next match index within a list of values\n * by comparing the start values ignoring case.\n *\n * If a match can not be found from the search string, `-1` will be returned.\n * The search value is self-matchable by default, but it can be omitted by\n * disabling the `isSelfMatchable` argument. This will make a self-match return\n * `-1`.\n *\n * @internal\n */\nexport function findMatchIndex(options: MatchIndexOptions): number {\n const { value, values, startIndex, isSelfMatchable = true } = options;\n // this was added to support comboboxes when there are no options available\n if (!values.length) {\n return -1;\n }\n\n let index = findMatchInRange({\n value,\n values,\n startIndex: startIndex + 1,\n endIndex: values.length,\n });\n if (index === -1) {\n const endIndex = startIndex + (isSelfMatchable ? 1 : 0);\n index = findMatchInRange({\n value,\n values,\n startIndex: 0,\n endIndex,\n });\n }\n\n return index;\n}\n"],"names":["findMatchInRange","options","values","startIndex","endIndex","length","value","toUpperCase","i","content","indexOf","findMatchIndex","isSelfMatchable","index"],"mappings":"AAAA,cAAc,GA0Bd;;;;;;;;;CASC,GACD,OAAO,SAASA,iBAAiBC,OAA4B;IAC3D,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGH;IACzC,IAAI,CAACC,OAAOG,MAAM,EAAE;QAClB,OAAO,CAAC;IACV;IAEA,MAAMC,QAAQL,QAAQK,KAAK,CAACC,WAAW;IAEvC,IAAK,IAAIC,IAAIL,YAAYK,IAAIJ,UAAUI,KAAK,EAAG;QAC7C,MAAMC,UAAUP,MAAM,CAACM,EAAE;QACzB,IAAIC,QAAQF,WAAW,GAAGG,OAAO,CAACJ,WAAW,GAAG;YAC9C,OAAOE;QACT;IACF;IAEA,OAAO,CAAC;AACV;AAYA;;;;;;;;;;CAUC,GACD,OAAO,SAASG,eAAeV,OAA0B;IACvD,MAAM,EAAEK,KAAK,EAAEJ,MAAM,EAAEC,UAAU,EAAES,kBAAkB,IAAI,EAAE,GAAGX;IAC9D,2EAA2E;IAC3E,IAAI,CAACC,OAAOG,MAAM,EAAE;QAClB,OAAO,CAAC;IACV;IAEA,IAAIQ,QAAQb,iBAAiB;QAC3BM;QACAJ;QACAC,YAAYA,aAAa;QACzBC,UAAUF,OAAOG,MAAM;IACzB;IACA,IAAIQ,UAAU,CAAC,GAAG;QAChB,MAAMT,WAAWD,aAAcS,CAAAA,kBAAkB,IAAI,CAAA;QACrDC,QAAQb,iBAAiB;YACvBM;YACAJ;YACAC,YAAY;YACZC;QACF;IACF;IAEA,OAAOS;AACT"}
1
+ {"version":3,"sources":["../../src/movement/findMatchIndex.ts"],"sourcesContent":["/** @internal */\nexport interface BaseOptions {\n /**\n * The current query string to find within the values\n */\n value: string;\n\n /**\n * The list of values to search within\n */\n values: readonly string[];\n\n /**\n * The start index for the search\n */\n startIndex: number;\n}\n\n/** @internal */\nexport interface MatchInRangeOptions extends BaseOptions {\n /**\n * The end index for the search\n */\n endIndex: number;\n}\n\n/**\n * Attempts to find the first match index for a list of values that starts with\n * the provided query string and is within the start and end indexes. If no\n * matches are found, -1 will be returned instead.\n *\n * Since this is normally coming from a keydown event, the query *must* be a\n * string of all capital letters to work as each value will be converted to\n * uppercase before checking.\n * @internal\n */\nexport function findMatchInRange(options: MatchInRangeOptions): number {\n const { values, startIndex, endIndex } = options;\n if (values.length === 0) {\n return -1;\n }\n\n const value = options.value.toUpperCase();\n\n for (let i = startIndex; i < endIndex; i += 1) {\n const content = values[i];\n if (content.toUpperCase().indexOf(value) === 0) {\n return i;\n }\n }\n\n return -1;\n}\n\n/** @internal */\nexport interface MatchIndexOptions extends BaseOptions {\n /**\n * Boolean if the current index can be included in the search\n *\n * @defaultValue `true`\n */\n isSelfMatchable?: boolean;\n}\n\n/**\n * A function that is used to find the next match index within a list of values\n * by comparing the start values ignoring case.\n *\n * If a match can not be found from the search string, `-1` will be returned.\n * The search value is self-matchable by default, but it can be omitted by\n * disabling the `isSelfMatchable` argument. This will make a self-match return\n * `-1`.\n *\n * @internal\n */\nexport function findMatchIndex(options: MatchIndexOptions): number {\n const { value, values, startIndex, isSelfMatchable = true } = options;\n // this was added to support comboboxes when there are no options available\n if (values.length === 0) {\n return -1;\n }\n\n let index = findMatchInRange({\n value,\n values,\n startIndex: startIndex + 1,\n endIndex: values.length,\n });\n if (index === -1) {\n const endIndex = startIndex + (isSelfMatchable ? 1 : 0);\n index = findMatchInRange({\n value,\n values,\n startIndex: 0,\n endIndex,\n });\n }\n\n return index;\n}\n"],"names":["findMatchInRange","options","values","startIndex","endIndex","length","value","toUpperCase","i","content","indexOf","findMatchIndex","isSelfMatchable","index"],"mappings":"AAAA,cAAc,GA0Bd;;;;;;;;;CASC,GACD,OAAO,SAASA,iBAAiBC,OAA4B;IAC3D,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGH;IACzC,IAAIC,OAAOG,MAAM,KAAK,GAAG;QACvB,OAAO,CAAC;IACV;IAEA,MAAMC,QAAQL,QAAQK,KAAK,CAACC,WAAW;IAEvC,IAAK,IAAIC,IAAIL,YAAYK,IAAIJ,UAAUI,KAAK,EAAG;QAC7C,MAAMC,UAAUP,MAAM,CAACM,EAAE;QACzB,IAAIC,QAAQF,WAAW,GAAGG,OAAO,CAACJ,WAAW,GAAG;YAC9C,OAAOE;QACT;IACF;IAEA,OAAO,CAAC;AACV;AAYA;;;;;;;;;;CAUC,GACD,OAAO,SAASG,eAAeV,OAA0B;IACvD,MAAM,EAAEK,KAAK,EAAEJ,MAAM,EAAEC,UAAU,EAAES,kBAAkB,IAAI,EAAE,GAAGX;IAC9D,2EAA2E;IAC3E,IAAIC,OAAOG,MAAM,KAAK,GAAG;QACvB,OAAO,CAAC;IACV;IAEA,IAAIQ,QAAQb,iBAAiB;QAC3BM;QACAJ;QACAC,YAAYA,aAAa;QACzBC,UAAUF,OAAOG,MAAM;IACzB;IACA,IAAIQ,UAAU,CAAC,GAAG;QAChB,MAAMT,WAAWD,aAAcS,CAAAA,kBAAkB,IAAI,CAAA;QACrDC,QAAQb,iBAAiB;YACvBM;YACAJ;YACAC,YAAY;YACZC;QACF;IACF;IAEA,OAAOS;AACT"}
@@ -394,7 +394,7 @@ const returnNegative1 = ()=>-1;
394
394
  }
395
395
  const focusables = getFocusableElements(currentTarget, programmatic);
396
396
  const focusedIndex = focusables.findIndex((element)=>element === target || element.contains(target));
397
- if (focusedIndex === -1 || !focusables.length) {
397
+ if (focusedIndex === -1 || focusables.length === 0) {
398
398
  return;
399
399
  }
400
400
  currentFocusIndex.current = focusedIndex;
@@ -423,7 +423,7 @@ const returnNegative1 = ()=>-1;
423
423
  return;
424
424
  }
425
425
  const focusables = getFocusableElements(event.currentTarget, programmatic);
426
- if (!focusables.length) {
426
+ if (focusables.length === 0) {
427
427
  return;
428
428
  }
429
429
  let defaultFocusIndex = getDefaultFocusedIndex({