@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.
- package/dist/_a11y.scss +3 -1
- package/dist/_box-shadows.scss +20 -12
- package/dist/_core.scss +1 -1
- package/dist/_utils.scss +26 -11
- package/dist/app-bar/_app-bar.scss +3 -3
- package/dist/autocomplete/AutocompleteChip.js +2 -2
- package/dist/autocomplete/AutocompleteChip.js.map +1 -1
- package/dist/autocomplete/AutocompleteListboxChildren.js +1 -1
- package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
- package/dist/autocomplete/_autocomplete.scss +20 -16
- package/dist/autocomplete/useAutocomplete.js +4 -4
- package/dist/autocomplete/useAutocomplete.js.map +1 -1
- package/dist/autocomplete/utils.js +3 -3
- package/dist/autocomplete/utils.js.map +1 -1
- package/dist/avatar/_avatar.scss +2 -1
- package/dist/box/styles.js +2 -2
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.js +1 -1
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/_button.scss +9 -5
- package/dist/card/_card.scss +6 -6
- package/dist/chip/Chip.js +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/_chip.scss +6 -6
- package/dist/cssUtils.d.ts +11 -6
- package/dist/cssUtils.js.map +1 -1
- package/dist/datetime/useTimeField.js +1 -1
- package/dist/datetime/useTimeField.js.map +1 -1
- package/dist/delegateEvent.js +9 -9
- package/dist/delegateEvent.js.map +1 -1
- package/dist/dialog/_dialog.scss +6 -6
- package/dist/divider/_divider.scss +6 -2
- package/dist/draggable/useDraggable.js +4 -4
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.js +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.js +1 -1
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/useExpansionPanels.js +1 -1
- package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
- package/dist/files/FileInput.js +1 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/files/createAcceptFromExtensions.d.ts +5 -0
- package/dist/files/createAcceptFromExtensions.js +15 -0
- package/dist/files/createAcceptFromExtensions.js.map +1 -0
- package/dist/files/useFileUpload.js +45 -41
- package/dist/files/useFileUpload.js.map +1 -1
- package/dist/files/utils.js +14 -10
- package/dist/files/utils.js.map +1 -1
- package/dist/files/validation.js +7 -8
- package/dist/files/validation.js.map +1 -1
- package/dist/focus/useFocusContainer.js +1 -1
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/focus/utils.js +12 -7
- package/dist/focus/utils.js.map +1 -1
- package/dist/form/InputToggleIcon.js +5 -1
- package/dist/form/InputToggleIcon.js.map +1 -1
- package/dist/form/NativeSelect.js +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Select.d.ts +24 -0
- package/dist/form/Select.js +19 -8
- package/dist/form/Select.js.map +1 -1
- package/dist/form/SelectedOption.d.ts +1 -2
- package/dist/form/SelectedOption.js +2 -2
- package/dist/form/SelectedOption.js.map +1 -1
- package/dist/form/_input-toggle.scss +6 -5
- package/dist/form/_label.scss +2 -2
- package/dist/form/_legend.scss +22 -13
- package/dist/form/_slider.scss +7 -5
- package/dist/form/_switch.scss +7 -5
- package/dist/form/_text-field.scss +13 -11
- package/dist/form/formConfig.js +1 -1
- package/dist/form/formConfig.js.map +1 -1
- package/dist/form/inputToggleStyles.js +7 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/legendStyles.d.ts +1 -1
- package/dist/form/legendStyles.js.map +1 -1
- package/dist/form/selectUtils.js +2 -2
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/useCombobox.js +1 -0
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useFormReset.js +2 -2
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useNumberField.js +1 -1
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useResizingTextArea.js +4 -4
- package/dist/form/useResizingTextArea.js.map +1 -1
- package/dist/form/useSelectCombobox.js +1 -1
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hoverMode/useHoverMode.js +8 -8
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/hoverMode/useHoverModeProvider.js +3 -3
- package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
- package/dist/icon/config.js +3 -3
- package/dist/icon/config.js.map +1 -1
- package/dist/icon/materialConfig.js +1 -1
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.js +11 -10
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/_interaction.scss +5 -3
- package/dist/interaction/utils.js +7 -3
- package/dist/interaction/utils.js.map +1 -1
- package/dist/layout/useExpandableLayout.js +3 -4
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useMainTabIndex.js +1 -1
- package/dist/layout/useMainTabIndex.js.map +1 -1
- package/dist/list/ListItem.js +1 -1
- package/dist/list/ListItem.js.map +1 -1
- package/dist/media-queries/AppSizeProvider.js +1 -1
- package/dist/media-queries/AppSizeProvider.js.map +1 -1
- package/dist/media-queries/config.js +2 -2
- package/dist/media-queries/config.js.map +1 -1
- package/dist/media-queries/useMediaQuery.js +3 -3
- package/dist/media-queries/useMediaQuery.js.map +1 -1
- package/dist/menu/Menu.js +4 -4
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuItemButton.js +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemFileInput.js +1 -1
- package/dist/menu/MenuItemFileInput.js.map +1 -1
- package/dist/menu/MenuWidget.js +2 -2
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/movement/findMatchIndex.js +2 -2
- package/dist/movement/findMatchIndex.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.js +2 -2
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/movement/utils.js +12 -10
- package/dist/movement/utils.js.map +1 -1
- package/dist/navigation/getTableOfContentsHeadings.js +4 -3
- package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
- package/dist/navigation/useActiveHeadingId.js +9 -9
- package/dist/navigation/useActiveHeadingId.js.map +1 -1
- package/dist/navigation/useTableOfContentsHeadings.js +1 -1
- package/dist/navigation/useTableOfContentsHeadings.js.map +1 -1
- package/dist/navigation/utils.js +6 -5
- package/dist/navigation/utils.js.map +1 -1
- package/dist/portal/PortalContainerProvider.js +5 -3
- package/dist/portal/PortalContainerProvider.js.map +1 -1
- package/dist/positioning/getFixedPosition.js +2 -4
- package/dist/positioning/getFixedPosition.js.map +1 -1
- package/dist/positioning/useFixedPositioning.js +2 -2
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/positioning/utils.js +3 -3
- package/dist/positioning/utils.js.map +1 -1
- package/dist/scroll/getScrollbarWidth.js +4 -4
- package/dist/scroll/getScrollbarWidth.js.map +1 -1
- package/dist/searching/fuzzy.js +3 -2
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/toSearchQuery.js +1 -1
- package/dist/searching/toSearchQuery.js.map +1 -1
- package/dist/searching/utils.js +1 -1
- package/dist/searching/utils.js.map +1 -1
- package/dist/snackbar/Toast.js +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastContent.js +2 -2
- package/dist/snackbar/ToastContent.js.map +1 -1
- package/dist/snackbar/ToastManager.d.ts +1 -1
- package/dist/snackbar/ToastManager.js +11 -11
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/_snackbar.scss +3 -3
- package/dist/spinbutton/useSpinButton.js +1 -1
- package/dist/spinbutton/useSpinButton.js.map +1 -1
- package/dist/spinbutton/utils/deselectNode.js +1 -1
- package/dist/spinbutton/utils/deselectNode.js.map +1 -1
- package/dist/spinbutton/utils/resolveInputEvent.js +1 -1
- package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -1
- package/dist/spinbutton/utils/selectNode.js +1 -1
- package/dist/spinbutton/utils/selectNode.js.map +1 -1
- package/dist/storage/useStorage.js +8 -3
- package/dist/storage/useStorage.js.map +1 -1
- package/dist/table/useStickyTableSection.js +1 -1
- package/dist/table/useStickyTableSection.js.map +1 -1
- package/dist/tabs/TabList.js +2 -2
- package/dist/tabs/TabList.js.map +1 -1
- package/dist/tabs/_tabs.scss +5 -6
- package/dist/tabs/useMaxTabPanelHeight.js +4 -3
- package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
- package/dist/tabs/useTabList.js +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/test-utils/jest-globals/match-media.d.ts +1 -1
- package/dist/test-utils/jest-globals/match-media.js +1 -1
- package/dist/test-utils/jest-globals/match-media.js.map +1 -1
- package/dist/test-utils/jest-globals/timers.js +1 -1
- package/dist/test-utils/jest-globals/timers.js.map +1 -1
- package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js +1 -1
- package/dist/test-utils/jest-globals/uploadMenuItemFileInput.js.map +1 -1
- package/dist/test-utils/mocks/ResizeObserver.js +2 -2
- package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
- package/dist/test-utils/polyfills/IntersectionObserver.js +2 -2
- package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/polyfills/ResizeObserver.js +2 -2
- package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
- package/dist/test-utils/polyfills/TextDecoder.js +2 -2
- package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
- package/dist/test-utils/polyfills/TextEncoder.js +2 -2
- package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
- package/dist/test-utils/polyfills/matchMedia.js +2 -2
- package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/offsetParent.js +2 -2
- package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
- package/dist/test-utils/polyfills/scrollIntoView.js +1 -1
- package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
- package/dist/test-utils/queries/select.js +2 -2
- package/dist/test-utils/queries/select.js.map +1 -1
- package/dist/test-utils/queries/slider.js +1 -1
- package/dist/test-utils/queries/slider.js.map +1 -1
- package/dist/test-utils/utils/createFileList.js +2 -0
- package/dist/test-utils/utils/createFileList.js.map +1 -1
- package/dist/test-utils/utils/createMatchMediaSpy.d.ts +1 -1
- package/dist/test-utils/utils/createMatchMediaSpy.js +3 -3
- package/dist/test-utils/utils/createMatchMediaSpy.js.map +1 -1
- package/dist/test-utils/vitest/match-media.d.ts +1 -1
- package/dist/test-utils/vitest/match-media.js +1 -1
- package/dist/test-utils/vitest/match-media.js.map +1 -1
- package/dist/test-utils/vitest/timers.js +1 -1
- package/dist/test-utils/vitest/timers.js.map +1 -1
- package/dist/test-utils/vitest/uploadMenuItemFileInput.js +1 -1
- package/dist/test-utils/vitest/uploadMenuItemFileInput.js.map +1 -1
- package/dist/theme/ThemeProvider.js +2 -2
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/_a11y.scss +3 -1
- package/dist/theme/_theme.scss +16 -12
- package/dist/theme/getDerivedTheme.js +1 -1
- package/dist/theme/getDerivedTheme.js.map +1 -1
- package/dist/theme/useCSSVariables.js +5 -5
- package/dist/theme/useCSSVariables.js.map +1 -1
- package/dist/theme/useColorSchemeMetaTag.js +2 -2
- package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
- package/dist/theme/useInlineCSSVariables.js +4 -3
- package/dist/theme/useInlineCSSVariables.js.map +1 -1
- package/dist/theme/utils.js +8 -8
- package/dist/theme/utils.js.map +1 -1
- package/dist/tooltip/useTooltip.js +7 -7
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/tooltip/useTooltipPosition.js +1 -1
- package/dist/tooltip/useTooltipPosition.js.map +1 -1
- package/dist/transition/useCarousel.js +2 -2
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useCollapseTransition.js +1 -1
- package/dist/transition/useCollapseTransition.js.map +1 -1
- package/dist/transition/useSkeletonPlaceholder.js +4 -4
- package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
- package/dist/transition/useTransition.js +2 -2
- package/dist/transition/useTransition.js.map +1 -1
- package/dist/transition/utils.js +5 -5
- package/dist/transition/utils.js.map +1 -1
- package/dist/tree/TreeItem.js +1 -1
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/useTreeItems.js +7 -5
- package/dist/tree/useTreeItems.js.map +1 -1
- package/dist/tree/useTreeMovement.js +1 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/tree/utils.js +6 -9
- package/dist/tree/utils.js.map +1 -1
- package/dist/typography/HighlightText.js +2 -1
- package/dist/typography/HighlightText.js.map +1 -1
- package/dist/typography/SrOnly.js +7 -1
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/useDebouncedFunction.js +4 -4
- package/dist/useDebouncedFunction.js.map +1 -1
- package/dist/useDropzone.js +9 -9
- package/dist/useDropzone.js.map +1 -1
- package/dist/useEnsuredState.js +5 -5
- package/dist/useEnsuredState.js.map +1 -1
- package/dist/useIntersectionObserver.js +3 -3
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useIsomorphicLayoutEffect.js +1 -1
- package/dist/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/useOrientation.js +1 -1
- package/dist/useOrientation.js.map +1 -1
- package/dist/useReadonlySet.js +1 -1
- package/dist/useReadonlySet.js.map +1 -1
- package/dist/useResizeListener.js +2 -2
- package/dist/useResizeListener.js.map +1 -1
- package/dist/useResizeObserver.js +3 -4
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/useThrottledFunction.js +3 -3
- package/dist/useThrottledFunction.js.map +1 -1
- package/dist/useWindowSize.js +1 -1
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/alphaNumericSort.js +3 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/dist/utils/bem.js +9 -12
- package/dist/utils/bem.js.map +1 -1
- package/dist/utils/getNumberOfDigits.js +1 -0
- package/dist/utils/getNumberOfDigits.js.map +1 -1
- package/dist/utils/getRangeDefaultValue.js +1 -1
- package/dist/utils/getRangeDefaultValue.js.map +1 -1
- package/dist/utils/nearest.js +2 -2
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/parseCssLengthUnit.js +3 -3
- package/dist/utils/parseCssLengthUnit.js.map +1 -1
- package/dist/utils/trigonometry.js +1 -1
- package/dist/utils/trigonometry.js.map +1 -1
- package/dist/window-splitter/_window-splitter.scss +15 -17
- package/package.json +9 -7
- package/src/autocomplete/AutocompleteChip.tsx +2 -2
- package/src/autocomplete/AutocompleteListboxChildren.tsx +1 -1
- package/src/autocomplete/useAutocomplete.ts +4 -4
- package/src/autocomplete/utils.ts +3 -3
- package/src/box/styles.ts +2 -2
- package/src/button/AsyncButton.tsx +1 -3
- package/src/chip/Chip.tsx +1 -2
- package/src/cssUtils.ts +12 -6
- package/src/datetime/useTimeField.ts +1 -1
- package/src/delegateEvent.ts +9 -9
- package/src/draggable/useDraggable.ts +4 -4
- package/src/draggable/utils.ts +1 -1
- package/src/expansion-panel/ExpansionPanel.tsx +1 -1
- package/src/expansion-panel/useExpansionPanels.ts +1 -1
- package/src/files/FileInput.tsx +1 -1
- package/src/files/createAcceptFromExtensions.ts +18 -0
- package/src/files/useFileUpload.ts +36 -37
- package/src/files/utils.ts +15 -11
- package/src/files/validation.ts +7 -9
- package/src/focus/useFocusContainer.ts +1 -1
- package/src/focus/utils.ts +11 -6
- package/src/form/InputToggleIcon.tsx +5 -5
- package/src/form/NativeSelect.tsx +1 -1
- package/src/form/Select.tsx +58 -7
- package/src/form/SelectedOption.tsx +2 -4
- package/src/form/formConfig.ts +1 -1
- package/src/form/inputToggleStyles.ts +9 -4
- package/src/form/legendStyles.ts +1 -1
- package/src/form/selectUtils.ts +2 -2
- package/src/form/useCombobox.ts +1 -0
- package/src/form/useFormReset.ts +2 -2
- package/src/form/useNumberField.ts +1 -1
- package/src/form/useResizingTextArea.ts +5 -5
- package/src/form/useSelectCombobox.ts +1 -4
- package/src/form/validation.ts +1 -1
- package/src/hoverMode/useHoverMode.ts +9 -9
- package/src/hoverMode/useHoverModeProvider.ts +4 -4
- package/src/icon/config.tsx +3 -3
- package/src/icon/materialConfig.ts +1 -1
- package/src/interaction/UserInteractionModeProvider.tsx +11 -10
- package/src/interaction/utils.ts +3 -3
- package/src/layout/useExpandableLayout.ts +3 -4
- package/src/layout/useMainTabIndex.ts +1 -1
- package/src/list/ListItem.tsx +1 -1
- package/src/media-queries/AppSizeProvider.tsx +1 -1
- package/src/media-queries/config.ts +2 -2
- package/src/media-queries/useMediaQuery.ts +3 -3
- package/src/menu/Menu.tsx +4 -4
- package/src/menu/MenuItemButton.tsx +1 -1
- package/src/menu/MenuItemFileInput.tsx +1 -1
- package/src/menu/MenuWidget.tsx +6 -4
- package/src/movement/findMatchIndex.ts +2 -2
- package/src/movement/useKeyboardMovementProvider.ts +2 -2
- package/src/movement/utils.ts +15 -14
- package/src/navigation/getTableOfContentsHeadings.ts +4 -3
- package/src/navigation/useActiveHeadingId.ts +8 -8
- package/src/navigation/useTableOfContentsHeadings.ts +1 -1
- package/src/navigation/utils.ts +6 -5
- package/src/portal/PortalContainerProvider.tsx +5 -3
- package/src/positioning/getFixedPosition.ts +9 -6
- package/src/positioning/useFixedPositioning.ts +2 -2
- package/src/positioning/utils.ts +3 -3
- package/src/scroll/getScrollbarWidth.ts +4 -4
- package/src/searching/fuzzy.ts +7 -3
- package/src/searching/toSearchQuery.ts +1 -1
- package/src/searching/utils.ts +1 -1
- package/src/snackbar/Toast.tsx +1 -1
- package/src/snackbar/ToastContent.tsx +2 -2
- package/src/snackbar/ToastManager.ts +11 -12
- package/src/spinbutton/useSpinButton.ts +1 -1
- package/src/spinbutton/utils/deselectNode.ts +1 -1
- package/src/spinbutton/utils/resolveInputEvent.ts +1 -1
- package/src/spinbutton/utils/selectNode.ts +1 -1
- package/src/storage/useStorage.ts +7 -2
- package/src/table/useStickyTableSection.tsx +1 -1
- package/src/tabs/TabList.tsx +2 -2
- package/src/tabs/useMaxTabPanelHeight.ts +6 -3
- package/src/tabs/useTabList.ts +2 -2
- package/src/test-utils/jest-globals/match-media.ts +5 -2
- package/src/test-utils/jest-globals/timers.ts +1 -1
- package/src/test-utils/jest-globals/uploadMenuItemFileInput.ts +1 -1
- package/src/test-utils/mocks/ResizeObserver.ts +2 -2
- package/src/test-utils/polyfills/IntersectionObserver.ts +2 -2
- package/src/test-utils/polyfills/ResizeObserver.ts +2 -2
- package/src/test-utils/polyfills/TextDecoder.ts +2 -2
- package/src/test-utils/polyfills/TextEncoder.ts +2 -2
- package/src/test-utils/polyfills/matchMedia.ts +5 -2
- package/src/test-utils/polyfills/offsetParent.ts +2 -2
- package/src/test-utils/polyfills/scrollIntoView.ts +1 -1
- package/src/test-utils/queries/select.ts +2 -2
- package/src/test-utils/queries/slider.ts +1 -1
- package/src/test-utils/utils/createFileList.ts +2 -0
- package/src/test-utils/utils/createMatchMediaSpy.ts +4 -4
- package/src/test-utils/vitest/match-media.ts +2 -2
- package/src/test-utils/vitest/timers.ts +1 -1
- package/src/test-utils/vitest/uploadMenuItemFileInput.ts +1 -1
- package/src/theme/ThemeProvider.tsx +2 -2
- package/src/theme/getDerivedTheme.ts +1 -1
- package/src/theme/useCSSVariables.ts +5 -5
- package/src/theme/useColorSchemeMetaTag.ts +2 -2
- package/src/theme/useInlineCSSVariables.ts +6 -7
- package/src/theme/utils.ts +8 -8
- package/src/tooltip/useTooltip.ts +7 -7
- package/src/tooltip/useTooltipPosition.ts +1 -1
- package/src/transition/useCarousel.ts +2 -2
- package/src/transition/useCollapseTransition.ts +1 -1
- package/src/transition/useSkeletonPlaceholder.ts +4 -4
- package/src/transition/useTransition.ts +2 -2
- package/src/transition/utils.ts +5 -5
- package/src/tree/TreeItem.tsx +1 -1
- package/src/tree/useTreeItems.ts +5 -5
- package/src/tree/useTreeMovement.ts +1 -1
- package/src/tree/utils.ts +9 -9
- package/src/typography/HighlightText.tsx +4 -3
- package/src/typography/SrOnly.tsx +9 -2
- package/src/useDebouncedFunction.ts +5 -5
- package/src/useDropzone.ts +10 -10
- package/src/useEnsuredState.ts +5 -5
- package/src/useIntersectionObserver.ts +3 -3
- package/src/useIsomorphicLayoutEffect.ts +3 -3
- package/src/useOrientation.ts +1 -1
- package/src/useReadonlySet.ts +3 -1
- package/src/useResizeListener.ts +2 -2
- package/src/useResizeObserver.ts +3 -4
- package/src/useThrottledFunction.ts +4 -4
- package/src/useWindowSize.ts +1 -1
- package/src/utils/alphaNumericSort.ts +1 -1
- package/src/utils/bem.ts +15 -16
- package/src/utils/getNumberOfDigits.ts +1 -0
- package/src/utils/getRangeDefaultValue.ts +1 -1
- package/src/utils/nearest.ts +5 -2
- package/src/utils/parseCssLengthUnit.ts +5 -4
- package/src/utils/trigonometry.ts +1 -1
package/src/files/validation.ts
CHANGED
|
@@ -389,7 +389,7 @@ export function validateFiles<CustomError>(
|
|
|
389
389
|
const extraFiles: File[] = [];
|
|
390
390
|
const extensionRegExp =
|
|
391
391
|
extensions.length > 0
|
|
392
|
-
? new RegExp(
|
|
392
|
+
? new RegExp(String.raw`\.(${extensions.join("|")})$`, "i")
|
|
393
393
|
: undefined;
|
|
394
394
|
|
|
395
395
|
let maxFilesReached = maxFiles > 0 && totalFiles >= maxFiles;
|
|
@@ -398,9 +398,7 @@ export function validateFiles<CustomError>(
|
|
|
398
398
|
const minErrors: File[] = [];
|
|
399
399
|
const maxErrors: File[] = [];
|
|
400
400
|
const totalSizeErrors: File[] = [];
|
|
401
|
-
for (
|
|
402
|
-
const file = files[i];
|
|
403
|
-
|
|
401
|
+
for (const file of files) {
|
|
404
402
|
let valid = true;
|
|
405
403
|
const { size } = file;
|
|
406
404
|
if (!isValidFileName(file, extensionRegExp, extensions)) {
|
|
@@ -433,23 +431,23 @@ export function validateFiles<CustomError>(
|
|
|
433
431
|
}
|
|
434
432
|
}
|
|
435
433
|
|
|
436
|
-
if (extensionErrors.length) {
|
|
434
|
+
if (extensionErrors.length > 0) {
|
|
437
435
|
errors.push(new FileExtensionError(extensionErrors, extensions));
|
|
438
436
|
}
|
|
439
437
|
|
|
440
|
-
if (minErrors.length) {
|
|
438
|
+
if (minErrors.length > 0) {
|
|
441
439
|
errors.push(new FileSizeError(minErrors, "min", minFileSize));
|
|
442
440
|
}
|
|
443
441
|
|
|
444
|
-
if (maxErrors.length) {
|
|
442
|
+
if (maxErrors.length > 0) {
|
|
445
443
|
errors.push(new FileSizeError(maxErrors, "max", maxFileSize));
|
|
446
444
|
}
|
|
447
445
|
|
|
448
|
-
if (totalSizeErrors.length) {
|
|
446
|
+
if (totalSizeErrors.length > 0) {
|
|
449
447
|
errors.push(new FileSizeError(totalSizeErrors, "total", totalFileSize));
|
|
450
448
|
}
|
|
451
449
|
|
|
452
|
-
if (extraFiles.length) {
|
|
450
|
+
if (extraFiles.length > 0) {
|
|
453
451
|
errors.push(new TooManyFilesError(extraFiles, maxFiles));
|
|
454
452
|
}
|
|
455
453
|
|
|
@@ -208,7 +208,7 @@ export function useFocusContainer<E extends HTMLElement>(
|
|
|
208
208
|
|
|
209
209
|
// For some reason, the `"Enter"` keydown event fires at a different timing
|
|
210
210
|
// than the Space keydown event.
|
|
211
|
-
|
|
211
|
+
globalThis.requestAnimationFrame(() => {
|
|
212
212
|
prevFocus.current?.focus();
|
|
213
213
|
});
|
|
214
214
|
},
|
package/src/focus/utils.ts
CHANGED
|
@@ -34,6 +34,7 @@ export const PROGRAMMATICALLY_FOCUSABLE = queries.join(",");
|
|
|
34
34
|
* `tabindex="-1"` applied instead of only elements that had a manual tab index
|
|
35
35
|
* applied.
|
|
36
36
|
*/
|
|
37
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
37
38
|
export const TAB_FOCUSABLE = queries.reduce((fullQuery, query) => {
|
|
38
39
|
const prefix = `${fullQuery}${fullQuery ? "," : ""}`;
|
|
39
40
|
const notProgrammaticQuery = `${query}:not([tabindex="-1"])`;
|
|
@@ -135,12 +136,16 @@ export function focusElementWithin(options: FocusElementWithinOptions): void {
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
let element: HTMLElement | null = null;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
switch (type) {
|
|
140
|
+
case "first":
|
|
141
|
+
[element] = elements;
|
|
142
|
+
break;
|
|
143
|
+
case "last":
|
|
144
|
+
element = elements.at(-1) ?? null;
|
|
145
|
+
break;
|
|
146
|
+
case "query":
|
|
147
|
+
element = document.querySelector<HTMLElement>(query);
|
|
148
|
+
break;
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
if (!element && isFocusable(container)) {
|
|
@@ -90,11 +90,11 @@ export const InputToggleIcon = forwardRef<
|
|
|
90
90
|
const uncontrolled = typeof checked !== "boolean";
|
|
91
91
|
if (!uncontrolled || !FORM_CONFIG.uncontrolledToggles) {
|
|
92
92
|
active = !!checked && !error;
|
|
93
|
-
|
|
94
|
-
?
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
if (checked) {
|
|
94
|
+
icon = indeterminate ? indeterminateIcon : checkedIcon;
|
|
95
|
+
} else {
|
|
96
|
+
icon = uncheckedIcon;
|
|
97
|
+
}
|
|
98
98
|
} else {
|
|
99
99
|
icon = (
|
|
100
100
|
<>
|
|
@@ -156,7 +156,7 @@ export const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
|
|
|
156
156
|
const underlined = theme === "underline" || theme === "filled";
|
|
157
157
|
|
|
158
158
|
let rightAddon = propRightAddon;
|
|
159
|
-
if (
|
|
159
|
+
if (propRightAddon === undefined && !multiple) {
|
|
160
160
|
rightAddon = icon;
|
|
161
161
|
}
|
|
162
162
|
|
package/src/form/Select.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { useEnsuredId } from "../useEnsuredId.js";
|
|
27
27
|
import { useEnsuredRef } from "../useEnsuredRef.js";
|
|
28
28
|
import { Listbox } from "./Listbox.js";
|
|
29
|
+
import { type OptionProps } from "./Option.js";
|
|
29
30
|
import { SelectedOption } from "./SelectedOption.js";
|
|
30
31
|
import {
|
|
31
32
|
TextFieldContainer,
|
|
@@ -46,6 +47,41 @@ const noop = (): void => {
|
|
|
46
47
|
// do nothing
|
|
47
48
|
};
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @since 6.5.0
|
|
52
|
+
*/
|
|
53
|
+
export interface GetSelectedOptionChildrenOptions<
|
|
54
|
+
Value extends string = string,
|
|
55
|
+
> {
|
|
56
|
+
value: "" | Value;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The option will be undefined if there is no value or matching option.
|
|
60
|
+
*/
|
|
61
|
+
option: OptionProps | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This is a pass-through of the {@link SelectProps.placeholder}
|
|
65
|
+
*/
|
|
66
|
+
placeholder?: ReactNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This is a pass-through of the {@link SelectProps.selectedOptionProps}
|
|
70
|
+
*/
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @since 6.5.0
|
|
76
|
+
*/
|
|
77
|
+
const defaultGetSelectedOptionChildren = (
|
|
78
|
+
options: GetSelectedOptionChildrenOptions
|
|
79
|
+
): ReactNode => {
|
|
80
|
+
const { children, option, placeholder } = options;
|
|
81
|
+
|
|
82
|
+
return children ?? (option?.children || placeholder);
|
|
83
|
+
};
|
|
84
|
+
|
|
49
85
|
/**
|
|
50
86
|
* This is a convenience type for casting the `event.currentTarget.value` of a
|
|
51
87
|
* `Select`'s change event to be union of available values.
|
|
@@ -206,6 +242,14 @@ export interface SelectProps<Value extends string>
|
|
|
206
242
|
*/
|
|
207
243
|
disableSelectedIcon?: boolean;
|
|
208
244
|
|
|
245
|
+
/**
|
|
246
|
+
* @since 6.5.0
|
|
247
|
+
* @defaultValue `({ children, option, placeholder }) => children ?? (option?.children || placeholder)`
|
|
248
|
+
*/
|
|
249
|
+
getSelectedOptionChildren?: (
|
|
250
|
+
options: GetSelectedOptionChildrenOptions<Value>
|
|
251
|
+
) => ReactNode;
|
|
252
|
+
|
|
209
253
|
/**
|
|
210
254
|
* This should be the available `Option`s for the select to choose from. It
|
|
211
255
|
* can also contain `OptGroup` or any other elements but only clicking on an
|
|
@@ -266,6 +310,7 @@ export function Select<Value extends string>(
|
|
|
266
310
|
label,
|
|
267
311
|
labelProps = {},
|
|
268
312
|
selectedOptionProps,
|
|
313
|
+
getSelectedOptionChildren = defaultGetSelectedOptionChildren,
|
|
269
314
|
icon: propIcon,
|
|
270
315
|
value,
|
|
271
316
|
defaultValue,
|
|
@@ -288,13 +333,13 @@ export function Select<Value extends string>(
|
|
|
288
333
|
const labelId = label ? selectLabelId : undefined;
|
|
289
334
|
|
|
290
335
|
const [localValue, setLocalValue] = useState(() => {
|
|
291
|
-
if (
|
|
336
|
+
if (defaultValue !== undefined) {
|
|
292
337
|
return defaultValue;
|
|
293
338
|
}
|
|
294
339
|
|
|
295
|
-
return
|
|
340
|
+
return value !== undefined ? value : EMPTY_STRING;
|
|
296
341
|
});
|
|
297
|
-
const currentValue =
|
|
342
|
+
const currentValue = value === undefined ? localValue : value;
|
|
298
343
|
const initialValue = useRef(currentValue);
|
|
299
344
|
const { options, currentOption } = extractOptionsFromChildren(
|
|
300
345
|
children,
|
|
@@ -326,7 +371,7 @@ export function Select<Value extends string>(
|
|
|
326
371
|
const icon = getIcon("dropdown", propIcon);
|
|
327
372
|
const theme = getFormConfig("theme", propTheme);
|
|
328
373
|
let rightAddon = propRightAddon;
|
|
329
|
-
if (
|
|
374
|
+
if (rightAddon === undefined && icon) {
|
|
330
375
|
rightAddon = <IconRotator rotated={visible}>{icon}</IconRotator>;
|
|
331
376
|
}
|
|
332
377
|
|
|
@@ -351,10 +396,16 @@ export function Select<Value extends string>(
|
|
|
351
396
|
>
|
|
352
397
|
<SelectedOption
|
|
353
398
|
option={currentOption}
|
|
354
|
-
placeholder={placeholder}
|
|
355
399
|
disableAddon={disableOptionAddon}
|
|
356
400
|
{...selectedOptionProps}
|
|
357
|
-
|
|
401
|
+
>
|
|
402
|
+
{getSelectedOptionChildren({
|
|
403
|
+
value: currentValue,
|
|
404
|
+
option: currentOption,
|
|
405
|
+
placeholder,
|
|
406
|
+
children: selectedOptionProps?.children,
|
|
407
|
+
})}
|
|
408
|
+
</SelectedOption>
|
|
358
409
|
<input
|
|
359
410
|
aria-hidden
|
|
360
411
|
id={inputId}
|
|
@@ -372,7 +423,7 @@ export function Select<Value extends string>(
|
|
|
372
423
|
className={cnb(select({ theme }), textField())}
|
|
373
424
|
onChange={(event) => {
|
|
374
425
|
onChange(event as SelectChangeEvent<Value>);
|
|
375
|
-
if (
|
|
426
|
+
if (value !== undefined) {
|
|
376
427
|
return;
|
|
377
428
|
}
|
|
378
429
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cnb } from "cnbuilder";
|
|
2
|
-
import { type ReactElement
|
|
2
|
+
import { type ReactElement } from "react";
|
|
3
3
|
|
|
4
4
|
import { Box, type BoxProps } from "../box/Box.js";
|
|
5
5
|
import { cssUtils } from "../cssUtils.js";
|
|
@@ -12,7 +12,6 @@ import { textField } from "./textFieldStyles.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export interface SelectedOptionProps extends BoxProps {
|
|
14
14
|
option: OptionProps | undefined;
|
|
15
|
-
placeholder?: ReactNode;
|
|
16
15
|
disableAddon: boolean;
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -29,11 +28,10 @@ export function SelectedOption(props: SelectedOptionProps): ReactElement {
|
|
|
29
28
|
className,
|
|
30
29
|
disableWrap = true,
|
|
31
30
|
disablePadding = true,
|
|
32
|
-
placeholder,
|
|
33
31
|
...remaining
|
|
34
32
|
} = props;
|
|
35
33
|
|
|
36
|
-
let children =
|
|
34
|
+
let { children } = remaining;
|
|
37
35
|
// when the children are a string or number, wrap it in additional span so
|
|
38
36
|
// that overflow can be ellipsis-ed
|
|
39
37
|
if (typeof children === "string" || typeof children === "number") {
|
package/src/form/formConfig.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cnb } from "cnbuilder";
|
|
2
2
|
|
|
3
|
-
import { cssUtils } from "../cssUtils.js";
|
|
3
|
+
import { type TextColor, type ThemeColor, cssUtils } from "../cssUtils.js";
|
|
4
4
|
import { bem } from "../utils/bem.js";
|
|
5
5
|
import { type FormComponentStates } from "./types.js";
|
|
6
6
|
|
|
@@ -60,6 +60,13 @@ export function inputToggle(options: InputToggleClassNameOptions): string {
|
|
|
60
60
|
uncontrolled,
|
|
61
61
|
} = options;
|
|
62
62
|
|
|
63
|
+
let textColor: TextColor | ThemeColor | undefined;
|
|
64
|
+
if (disabled) {
|
|
65
|
+
textColor = "text-disabled";
|
|
66
|
+
} else if (error) {
|
|
67
|
+
textColor = "error";
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
return cnb(
|
|
64
71
|
`rmd-${type}`,
|
|
65
72
|
styles({
|
|
@@ -72,9 +79,7 @@ export function inputToggle(options: InputToggleClassNameOptions): string {
|
|
|
72
79
|
large: size === "large",
|
|
73
80
|
uncontrolled,
|
|
74
81
|
}),
|
|
75
|
-
cssUtils({
|
|
76
|
-
textColor: disabled ? "text-disabled" : error ? "error" : undefined,
|
|
77
|
-
}),
|
|
82
|
+
cssUtils({ textColor }),
|
|
78
83
|
className
|
|
79
84
|
);
|
|
80
85
|
}
|
package/src/form/legendStyles.ts
CHANGED
|
@@ -13,7 +13,7 @@ const styles = bem("rmd-legend");
|
|
|
13
13
|
*/
|
|
14
14
|
export type LegendLabelClassNameOptions = Pick<
|
|
15
15
|
LabelClassNameOptions,
|
|
16
|
-
"active" | "gap" | "
|
|
16
|
+
"active" | "gap" | "error" | "stacked" | "disabled" | "reversed"
|
|
17
17
|
>;
|
|
18
18
|
|
|
19
19
|
/**
|
package/src/form/selectUtils.ts
CHANGED
|
@@ -77,10 +77,10 @@ export function extractOptionsFromChildren<Value extends string | number>(
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const { value, disabled, children } = child.props;
|
|
80
|
-
if (
|
|
80
|
+
if (value !== undefined) {
|
|
81
81
|
if (
|
|
82
82
|
value === currentValue ||
|
|
83
|
-
(!currentOption &&
|
|
83
|
+
(!currentOption && currentValue === undefined)
|
|
84
84
|
) {
|
|
85
85
|
currentOption = child.props;
|
|
86
86
|
}
|
package/src/form/useCombobox.ts
CHANGED
|
@@ -491,6 +491,7 @@ export function useCombobox<
|
|
|
491
491
|
// to really make sure the item is in view. An alternative would be to
|
|
492
492
|
// implement a custom scrollIntoView behavior again like the previous
|
|
493
493
|
// versions of react-md, but this is less lines of code
|
|
494
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
494
495
|
const attemptScroll = (): void => {
|
|
495
496
|
const activeOption = document.getElementById(activeDescendantId);
|
|
496
497
|
if (activeOption) {
|
package/src/form/useFormReset.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function useFormReset(options: FormResetOptions): void {
|
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
const element = elementRef.current;
|
|
32
|
-
if (!element || (
|
|
32
|
+
if (!element || (defaultValue === undefined && !onReset)) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -44,7 +44,7 @@ export function useFormReset(options: FormResetOptions): void {
|
|
|
44
44
|
const handleReset = (): void => {
|
|
45
45
|
if (onReset) {
|
|
46
46
|
onReset();
|
|
47
|
-
} else if (
|
|
47
|
+
} else if (defaultValue !== undefined) {
|
|
48
48
|
triggerManualChangeEvent(element, defaultValue);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -411,7 +411,7 @@ export function useNumberField(
|
|
|
411
411
|
if (!Number.isNaN(value)) {
|
|
412
412
|
setNumber(value);
|
|
413
413
|
input.value = `${value}`;
|
|
414
|
-
} else if (
|
|
414
|
+
} else if (initial.current === undefined) {
|
|
415
415
|
setNumber(undefined);
|
|
416
416
|
}
|
|
417
417
|
},
|
|
@@ -112,21 +112,21 @@ export function useResizingTextArea(
|
|
|
112
112
|
}
|
|
113
113
|
/* c8 ignore stop */
|
|
114
114
|
|
|
115
|
-
const containerStyles =
|
|
115
|
+
const containerStyles = globalThis.getComputedStyle(container);
|
|
116
116
|
const isBorderBox = containerStyles.boxSizing === "border-box";
|
|
117
117
|
let borderHeight = 0;
|
|
118
118
|
if (isBorderBox) {
|
|
119
119
|
borderHeight =
|
|
120
|
-
parseFloat(containerStyles.borderTopWidth) +
|
|
121
|
-
parseFloat(containerStyles.borderBottomWidth);
|
|
120
|
+
Number.parseFloat(containerStyles.borderTopWidth) +
|
|
121
|
+
Number.parseFloat(containerStyles.borderBottomWidth);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
let nextHeight = mask.scrollHeight + borderHeight;
|
|
125
125
|
if (maxRows > 0) {
|
|
126
126
|
nextHeight -= borderHeight;
|
|
127
|
-
const maskStyles =
|
|
127
|
+
const maskStyles = globalThis.getComputedStyle(mask);
|
|
128
128
|
// in tests, this is `"normal"` by default instead of a number
|
|
129
|
-
let lineHeight = parseFloat(maskStyles.lineHeight);
|
|
129
|
+
let lineHeight = Number.parseFloat(maskStyles.lineHeight);
|
|
130
130
|
if (Number.isNaN(lineHeight)) {
|
|
131
131
|
lineHeight = DEFAULT_LINE_HEIGHT;
|
|
132
132
|
}
|
package/src/form/validation.ts
CHANGED
|
@@ -181,7 +181,7 @@ export const defaultGetErrorMessage: GetErrorMessage = (options) => {
|
|
|
181
181
|
|
|
182
182
|
const keys = typeof validate === "string" ? [validate] : validate;
|
|
183
183
|
|
|
184
|
-
return keys.length &&
|
|
184
|
+
return keys.length > 0 &&
|
|
185
185
|
VALIDITY_STATE_KEYS.some((key) => validity[key] && keys.includes(key))
|
|
186
186
|
? validationMessage
|
|
187
187
|
: "";
|
|
@@ -166,15 +166,15 @@ export function useHoverMode(
|
|
|
166
166
|
const state = useState(defaultVisible);
|
|
167
167
|
let visible: boolean | undefined;
|
|
168
168
|
let setVisible: UseStateSetter<boolean>;
|
|
169
|
-
if (
|
|
169
|
+
if (propSetVisible !== undefined) {
|
|
170
170
|
setVisible = propSetVisible;
|
|
171
171
|
} else {
|
|
172
172
|
[visible, setVisible] = state;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
const visibilityTimeout = useRef<
|
|
175
|
+
const visibilityTimeout = useRef<NodeJS.Timeout>();
|
|
176
176
|
const clearVisibilityTimeout = useCallback(() => {
|
|
177
|
-
|
|
177
|
+
globalThis.clearTimeout(visibilityTimeout.current);
|
|
178
178
|
}, []);
|
|
179
179
|
|
|
180
180
|
// if the element is near the viewport edge, the mouseleave event might not
|
|
@@ -187,7 +187,7 @@ export function useHoverMode(
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
const handler = (): void => {
|
|
190
|
-
|
|
190
|
+
globalThis.clearTimeout(visibilityTimeout.current);
|
|
191
191
|
|
|
192
192
|
// might need to play with this more or make it configurable. if the mouse
|
|
193
193
|
// leaves the window, you're _normally_ not interacting with the app
|
|
@@ -203,7 +203,7 @@ export function useHoverMode(
|
|
|
203
203
|
|
|
204
204
|
useEffect(() => {
|
|
205
205
|
return () => {
|
|
206
|
-
|
|
206
|
+
globalThis.clearTimeout(visibilityTimeout.current);
|
|
207
207
|
};
|
|
208
208
|
}, []);
|
|
209
209
|
|
|
@@ -213,12 +213,12 @@ export function useHoverMode(
|
|
|
213
213
|
startShowFlow: useCallback(
|
|
214
214
|
(eventOrId) => {
|
|
215
215
|
const hoverTimeout = hoverTime ?? hoverTimeoutRef.current;
|
|
216
|
-
if (disabled ||
|
|
216
|
+
if (disabled || hoverTimeout === undefined) {
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
let id: string;
|
|
221
|
-
if (typeof eventOrId === "string" ||
|
|
221
|
+
if (typeof eventOrId === "string" || eventOrId === undefined) {
|
|
222
222
|
id = eventOrId || "";
|
|
223
223
|
} else {
|
|
224
224
|
id = eventOrId.currentTarget.id;
|
|
@@ -226,7 +226,7 @@ export function useHoverMode(
|
|
|
226
226
|
|
|
227
227
|
clearDisableTimer();
|
|
228
228
|
clearVisibilityTimeout();
|
|
229
|
-
visibilityTimeout.current =
|
|
229
|
+
visibilityTimeout.current = globalThis.setTimeout(() => {
|
|
230
230
|
enableHoverMode(id);
|
|
231
231
|
setVisible(true);
|
|
232
232
|
}, hoverTimeout);
|
|
@@ -248,7 +248,7 @@ export function useHoverMode(
|
|
|
248
248
|
|
|
249
249
|
startDisableTimer();
|
|
250
250
|
clearVisibilityTimeout();
|
|
251
|
-
visibilityTimeout.current =
|
|
251
|
+
visibilityTimeout.current = globalThis.setTimeout(() => {
|
|
252
252
|
setVisible(false);
|
|
253
253
|
}, leaveTime ?? leaveTimeoutRef.current);
|
|
254
254
|
}, [
|
|
@@ -261,9 +261,9 @@ export function useHoverModeProvider(
|
|
|
261
261
|
const hoverTimeoutRef = useRef(hoverTimeout);
|
|
262
262
|
const leaveTimeoutRef = useRef(leaveTimeout);
|
|
263
263
|
const animatedOnceRef = useRef(!!defaultActiveId);
|
|
264
|
-
const disableHoverModeTimeout = useRef<
|
|
264
|
+
const disableHoverModeTimeout = useRef<NodeJS.Timeout>();
|
|
265
265
|
const clearDisableTimer = useCallback(() => {
|
|
266
|
-
|
|
266
|
+
globalThis.clearTimeout(disableHoverModeTimeout.current);
|
|
267
267
|
}, []);
|
|
268
268
|
const enableHoverMode = useCallback(
|
|
269
269
|
(activeId: string) => {
|
|
@@ -292,7 +292,7 @@ export function useHoverModeProvider(
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
clearDisableTimer();
|
|
295
|
-
disableHoverModeTimeout.current =
|
|
295
|
+
disableHoverModeTimeout.current = globalThis.setTimeout(() => {
|
|
296
296
|
disableHoverMode();
|
|
297
297
|
}, disableTimeout);
|
|
298
298
|
}, [clearDisableTimer, disableHoverMode, disableTimeout]);
|
|
@@ -300,7 +300,7 @@ export function useHoverModeProvider(
|
|
|
300
300
|
useEffect(() => {
|
|
301
301
|
hoverTimeoutRef.current = hoverTimeout;
|
|
302
302
|
return () => {
|
|
303
|
-
|
|
303
|
+
globalThis.clearTimeout(disableHoverModeTimeout.current);
|
|
304
304
|
};
|
|
305
305
|
}, [hoverTimeout]);
|
|
306
306
|
|
package/src/icon/config.tsx
CHANGED
|
@@ -289,13 +289,13 @@ export const ICON_CONFIG: ConfiguredIcons = {
|
|
|
289
289
|
*/
|
|
290
290
|
export function configureIcons(overrides: ConfiguredIcons): void {
|
|
291
291
|
if (process.env.NODE_ENV !== "production") {
|
|
292
|
-
|
|
292
|
+
for (const [name, value] of Object.entries(overrides)) {
|
|
293
293
|
if (!(name in ICON_CONFIG)) {
|
|
294
294
|
throw new Error(`${name} is an invalid react-md icon name.`);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
ICON_CONFIG[name as keyof ConfiguredIcons] = value;
|
|
298
|
-
}
|
|
298
|
+
}
|
|
299
299
|
} else {
|
|
300
300
|
Object.assign(ICON_CONFIG, overrides);
|
|
301
301
|
}
|
|
@@ -312,7 +312,7 @@ export function getIcon(
|
|
|
312
312
|
name: ConfigurableIconName,
|
|
313
313
|
override?: ReactNode
|
|
314
314
|
): ReactNode {
|
|
315
|
-
if (
|
|
315
|
+
if (override !== undefined) {
|
|
316
316
|
return override;
|
|
317
317
|
}
|
|
318
318
|
|
|
@@ -183,7 +183,7 @@ interface ApplyOptions {
|
|
|
183
183
|
|
|
184
184
|
const applyVar = (options: ApplyOptions): CSSProperties | undefined => {
|
|
185
185
|
const { name, value, defaultValue, style } = options;
|
|
186
|
-
if (
|
|
186
|
+
if (value !== undefined && value !== defaultValue) {
|
|
187
187
|
const varName = `--rmd-symbol-${name}` as const;
|
|
188
188
|
return {
|
|
189
189
|
...style,
|
|
@@ -86,6 +86,7 @@ export interface UserInteractionModeProviderProps {
|
|
|
86
86
|
export function UserInteractionModeProvider(
|
|
87
87
|
props: UserInteractionModeProviderProps
|
|
88
88
|
): ReactElement {
|
|
89
|
+
// eslint-disable-next-line react/prop-types
|
|
89
90
|
const { children, now = DATE_NOW } =
|
|
90
91
|
props as UserInteractionModeProviderProps & {
|
|
91
92
|
now?: () => number;
|
|
@@ -172,26 +173,26 @@ export function UserInteractionModeProvider(
|
|
|
172
173
|
|
|
173
174
|
const className = `rmd-${mode}-mode`;
|
|
174
175
|
document.body.classList.add(className);
|
|
175
|
-
|
|
176
|
+
globalThis.addEventListener("touchstart", handleTouchStart, true);
|
|
176
177
|
if (mode === "mouse") {
|
|
177
|
-
|
|
178
|
+
globalThis.addEventListener("keydown", enableKeyboardMode, true);
|
|
178
179
|
} else if (mode === "keyboard") {
|
|
179
|
-
|
|
180
|
+
globalThis.addEventListener("mousedown", enableMouseMode, true);
|
|
180
181
|
} else {
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
globalThis.addEventListener("mousemove", handleMouseMove, true);
|
|
183
|
+
globalThis.addEventListener("contextmenu", handleContextMenu, true);
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
return () => {
|
|
186
187
|
document.body.classList.remove(className);
|
|
187
|
-
|
|
188
|
+
globalThis.removeEventListener("touchstart", handleTouchStart, true);
|
|
188
189
|
if (mode === "mouse") {
|
|
189
|
-
|
|
190
|
+
globalThis.removeEventListener("keydown", enableKeyboardMode, true);
|
|
190
191
|
} else if (mode === "keyboard") {
|
|
191
|
-
|
|
192
|
+
globalThis.removeEventListener("mousedown", enableMouseMode, true);
|
|
192
193
|
} else {
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
globalThis.removeEventListener("mousemove", handleMouseMove, true);
|
|
195
|
+
globalThis.removeEventListener("contextmenu", handleContextMenu, true);
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
198
|
}, [mode, now]);
|
package/src/interaction/utils.ts
CHANGED
|
@@ -92,7 +92,7 @@ export function releaseRipple(
|
|
|
92
92
|
return state;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const ripples = state.ripples
|
|
95
|
+
const ripples = [...state.ripples];
|
|
96
96
|
const ripple = ripples[i];
|
|
97
97
|
ripples[i] = {
|
|
98
98
|
...ripple,
|
|
@@ -115,12 +115,12 @@ export function updateRipplesState(
|
|
|
115
115
|
): ElementInteractionState {
|
|
116
116
|
const { type, ripple, state, holding } = options;
|
|
117
117
|
|
|
118
|
-
const rippleIndex = state.ripples.
|
|
118
|
+
const rippleIndex = state.ripples.indexOf(ripple);
|
|
119
119
|
if (rippleIndex === -1) {
|
|
120
120
|
return state;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
const ripples = state.ripples
|
|
123
|
+
const ripples = [...state.ripples];
|
|
124
124
|
if (type === "exited") {
|
|
125
125
|
ripples.splice(rippleIndex, 1);
|
|
126
126
|
} else {
|
|
@@ -283,15 +283,14 @@ export function useExpandableLayout(
|
|
|
283
283
|
query = temporaryUntil;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
const timeout =
|
|
286
|
+
const timeout = globalThis.setTimeout(() => {
|
|
287
287
|
let found = false;
|
|
288
288
|
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
289
289
|
const sheet = document.styleSheets[i];
|
|
290
290
|
|
|
291
291
|
try {
|
|
292
292
|
const rules = sheet.cssRules;
|
|
293
|
-
for (
|
|
294
|
-
const rule = rules[j];
|
|
293
|
+
for (const rule of rules) {
|
|
295
294
|
if (
|
|
296
295
|
rule.cssText.includes(".rmd-layout") &&
|
|
297
296
|
rule.cssText.includes(`@media ${query}`)
|
|
@@ -318,7 +317,7 @@ export function useExpandableLayout(
|
|
|
318
317
|
}, 3000);
|
|
319
318
|
|
|
320
319
|
return () => {
|
|
321
|
-
|
|
320
|
+
globalThis.clearTimeout(timeout);
|
|
322
321
|
};
|
|
323
322
|
}, [temporaryUntil]);
|
|
324
323
|
|