@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/dist/form/Select.d.ts
CHANGED
|
@@ -2,8 +2,27 @@ import { type ChangeEvent, type HTMLAttributes, type InputHTMLAttributes, type R
|
|
|
2
2
|
import { type BoxProps } from "../box/Box.js";
|
|
3
3
|
import { type MenuProps } from "../menu/Menu.js";
|
|
4
4
|
import { type LabelA11y, type PropsWithRef, type RequireAtLeastOne } from "../types.js";
|
|
5
|
+
import { type OptionProps } from "./Option.js";
|
|
5
6
|
import { type TextFieldContainerProps } from "./TextFieldContainer.js";
|
|
6
7
|
import { type UserAgentAutocompleteProps } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* @since 6.5.0
|
|
10
|
+
*/
|
|
11
|
+
export interface GetSelectedOptionChildrenOptions<Value extends string = string> {
|
|
12
|
+
value: "" | Value;
|
|
13
|
+
/**
|
|
14
|
+
* The option will be undefined if there is no value or matching option.
|
|
15
|
+
*/
|
|
16
|
+
option: OptionProps | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* This is a pass-through of the {@link SelectProps.placeholder}
|
|
19
|
+
*/
|
|
20
|
+
placeholder?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* This is a pass-through of the {@link SelectProps.selectedOptionProps}
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
7
26
|
/**
|
|
8
27
|
* This is a convenience type for casting the `event.currentTarget.value` of a
|
|
9
28
|
* `Select`'s change event to be union of available values.
|
|
@@ -145,6 +164,11 @@ export interface SelectProps<Value extends string> extends Omit<TextFieldContain
|
|
|
145
164
|
* @defaultValue `false`
|
|
146
165
|
*/
|
|
147
166
|
disableSelectedIcon?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* @since 6.5.0
|
|
169
|
+
* @defaultValue `({ children, option, placeholder }) => children ?? (option?.children || placeholder)`
|
|
170
|
+
*/
|
|
171
|
+
getSelectedOptionChildren?: (options: GetSelectedOptionChildrenOptions<Value>) => ReactNode;
|
|
148
172
|
/**
|
|
149
173
|
* This should be the available `Option`s for the select to choose from. It
|
|
150
174
|
* can also contain `OptGroup` or any other elements but only clicking on an
|
package/dist/form/Select.js
CHANGED
|
@@ -22,6 +22,12 @@ const EMPTY_STRING = "";
|
|
|
22
22
|
const noop = ()=>{
|
|
23
23
|
// do nothing
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* @since 6.5.0
|
|
27
|
+
*/ const defaultGetSelectedOptionChildren = (options)=>{
|
|
28
|
+
const { children, option, placeholder } = options;
|
|
29
|
+
return children ?? (option?.children || placeholder);
|
|
30
|
+
};
|
|
25
31
|
/**
|
|
26
32
|
* **Client Component**
|
|
27
33
|
*
|
|
@@ -53,19 +59,19 @@ const noop = ()=>{
|
|
|
53
59
|
* @see {@link https://react-md.dev/components/select | Select Demos}
|
|
54
60
|
* @since 6.0.0 Rewritten with a new API.
|
|
55
61
|
*/ export function Select(props) {
|
|
56
|
-
const { id, form, autoCompleteValue, autoComplete = autoCompleteValue, name = autoCompleteValue, className, onClick, onFocus, onKeyDown, inputRef: propInputRef, inputProps, containerRef, placeholder, menuProps = {}, label, labelProps = {}, selectedOptionProps, icon: propIcon, value, defaultValue, theme: propTheme, onChange = noop, rightAddon: propRightAddon, active = false, required, selectedIconAfter = false, disableOptionAddon = false, disableSelectedIcon = false, children, ...remaining } = props;
|
|
62
|
+
const { id, form, autoCompleteValue, autoComplete = autoCompleteValue, name = autoCompleteValue, className, onClick, onFocus, onKeyDown, inputRef: propInputRef, inputProps, containerRef, placeholder, menuProps = {}, label, labelProps = {}, selectedOptionProps, getSelectedOptionChildren = defaultGetSelectedOptionChildren, icon: propIcon, value, defaultValue, theme: propTheme, onChange = noop, rightAddon: propRightAddon, active = false, required, selectedIconAfter = false, disableOptionAddon = false, disableSelectedIcon = false, children, ...remaining } = props;
|
|
57
63
|
const { dense, error, disabled } = props;
|
|
58
64
|
const comboboxId = useEnsuredId(id, "select");
|
|
59
65
|
const inputId = useEnsuredId(inputProps?.id, "select-value");
|
|
60
66
|
const selectLabelId = useEnsuredId(labelProps.id, "select-label");
|
|
61
67
|
const labelId = label ? selectLabelId : undefined;
|
|
62
68
|
const [localValue, setLocalValue] = useState(()=>{
|
|
63
|
-
if (
|
|
69
|
+
if (defaultValue !== undefined) {
|
|
64
70
|
return defaultValue;
|
|
65
71
|
}
|
|
66
|
-
return
|
|
72
|
+
return value !== undefined ? value : EMPTY_STRING;
|
|
67
73
|
});
|
|
68
|
-
const currentValue =
|
|
74
|
+
const currentValue = value === undefined ? localValue : value;
|
|
69
75
|
const initialValue = useRef(currentValue);
|
|
70
76
|
const { options, currentOption } = extractOptionsFromChildren(children, currentValue);
|
|
71
77
|
const { visible, comboboxProps, movementContext, getMenuProps } = useSelectCombobox({
|
|
@@ -90,7 +96,7 @@ const noop = ()=>{
|
|
|
90
96
|
const icon = getIcon("dropdown", propIcon);
|
|
91
97
|
const theme = getFormConfig("theme", propTheme);
|
|
92
98
|
let rightAddon = propRightAddon;
|
|
93
|
-
if (
|
|
99
|
+
if (rightAddon === undefined && icon) {
|
|
94
100
|
rightAddon = /*#__PURE__*/ _jsx(IconRotator, {
|
|
95
101
|
rotated: visible,
|
|
96
102
|
children: icon
|
|
@@ -117,9 +123,14 @@ const noop = ()=>{
|
|
|
117
123
|
children: [
|
|
118
124
|
/*#__PURE__*/ _jsx(SelectedOption, {
|
|
119
125
|
option: currentOption,
|
|
120
|
-
placeholder: placeholder,
|
|
121
126
|
disableAddon: disableOptionAddon,
|
|
122
|
-
...selectedOptionProps
|
|
127
|
+
...selectedOptionProps,
|
|
128
|
+
children: getSelectedOptionChildren({
|
|
129
|
+
value: currentValue,
|
|
130
|
+
option: currentOption,
|
|
131
|
+
placeholder,
|
|
132
|
+
children: selectedOptionProps?.children
|
|
133
|
+
})
|
|
123
134
|
}),
|
|
124
135
|
/*#__PURE__*/ _jsx("input", {
|
|
125
136
|
"aria-hidden": true,
|
|
@@ -140,7 +151,7 @@ const noop = ()=>{
|
|
|
140
151
|
}), textField()),
|
|
141
152
|
onChange: (event)=>{
|
|
142
153
|
onChange(event);
|
|
143
|
-
if (
|
|
154
|
+
if (value !== undefined) {
|
|
144
155
|
return;
|
|
145
156
|
}
|
|
146
157
|
const nextValue = event.currentTarget.value;
|
package/dist/form/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/Select.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ChangeEvent,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { type BoxProps } from \"../box/Box.js\";\nimport { IconRotator } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type MenuProps } from \"../menu/Menu.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport {\n type LabelA11y,\n type PropsWithRef,\n type RequireAtLeastOne,\n} from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { Listbox } from \"./Listbox.js\";\nimport { SelectedOption } from \"./SelectedOption.js\";\nimport {\n TextFieldContainer,\n type TextFieldContainerProps,\n} from \"./TextFieldContainer.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { label as labelStyles } from \"./labelStyles.js\";\nimport { select } from \"./selectStyles.js\";\nimport { extractOptionsFromChildren } from \"./selectUtils.js\";\nimport { textField } from \"./textFieldStyles.js\";\nimport { type UserAgentAutocompleteProps } from \"./types.js\";\nimport { useFormReset } from \"./useFormReset.js\";\nimport { useSelectCombobox } from \"./useSelectCombobox.js\";\nimport { triggerManualChangeEvent } from \"./utils.js\";\n\nconst EMPTY_STRING = \"\" as const;\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * This is a convenience type for casting the `event.currentTarget.value` of a\n * `Select`'s change event to be union of available values.\n *\n * Note: The change event does not provide any sort of validation on the value\n * so automation tools like Cypress, Playwright, or Selenium might set an\n * invalid value. This also does not work for numbers, so you will need to\n * implement that yourself.\n *\n * @example Simple Usage\n * ```tsx\n * import { Select, type SelectChangeEvent } from \"@react-md/core/form/Select\";\n * import { Option } from \"@react-md/core/form/Option\";\n * import type { ReactElement } from \"react\";\n *\n * type Value = \"\" | \"a\" | \"b\" | \"c\" | \"d\";\n *\n * function Example(): ReactElement {\n * const [value, setValue] = useState<Value>(\"\");\n *\n * const handleChange = (event: SelectChangeEvent<Value>): void => {\n * // No type error!\n * // `event.currentTarget.value`'s type is `Value` instead of a generic `string`\n * setValue(event.currentTarget.value);\n * };\n *\n * return (\n * <Select\n * label=\"Label\"\n * value={value}\n * onChange={handleChange}\n * >\n * <Option value=\"a\">First</Option>\n * <Option value=\"b\">Second</Option>\n * <Option value=\"c\">Third</Option>\n * <Option value=\"d\">Fourth</Option>\n * </Select>\n * );\n * }\n * ```\n * @since 6.0.0\n */\nexport type SelectChangeEvent<Value extends string> =\n ChangeEvent<HTMLInputElement> & { currentTarget: { value: Value } };\n\n/**\n * @since 6.0.0 Rewritten with a new API.\n */\nexport interface SelectProps<Value extends string>\n extends\n Omit<TextFieldContainerProps, \"label\">,\n Pick<InputHTMLAttributes<HTMLInputElement>, \"form\" | \"required\">,\n UserAgentAutocompleteProps {\n /**\n * @defaultValue `\"select-\" + useId()`\n */\n id?: string;\n\n /**\n * Optional placeholder text or element to render while no options have been\n * selected.\n */\n placeholder?: ReactNode;\n\n /**\n * Set this to a custom dropdown icon or `null` to not render a dropdown icon.\n *\n * @defaultValue `getIcon(\"dropdown\")`\n */\n icon?: ReactNode;\n\n /**\n * Set this value to fully control the value of the select component. The\n * {@link onChange} handler **must** also be provided if this prop exists.\n */\n value?: Value;\n\n /**\n * An optional default value when the value of the select component is\n * uncontrolled.\n *\n * @defaultValue `\"\"`\n */\n defaultValue?: Value;\n\n /** @see {@link SelectChangeEvent} */\n onChange?: (event: SelectChangeEvent<Value>) => void;\n\n /**\n * An optional floating label to display like other form fields.\n */\n label?: ReactNode;\n\n /**\n * Optional props to pass to the `<span>` that surrounds the {@link label}\n */\n labelProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional ref to pass to the hidden `<input type=\"text\" />` element that\n * stores the current value. This is really only useful if you'd like to keep\n * this component uncontrolled and access the value through\n * `inputRef.current.value`.\n */\n inputRef?: Ref<HTMLInputElement>;\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n\n /**\n * A ref for the container `<div>` element.\n */\n containerRef?: Ref<HTMLDivElement>;\n\n /**\n * Any additional props to provide to the `Menu` component that renders all\n * the `Option`s.\n *\n * The menu will always have these default values unless explicity\n * overwritten by this prop:\n *\n * - `aria-labelledby={label ? labelId : id}` -- this will be undefined if\n * `aria-label` is provided\n * - `anchor={BELOW_CENTER_ANCHOR}`\n * - `width=\"min\"`\n */\n menuProps?: PropsWithRef<\n Omit<MenuProps, \"visible\" | \"onRequestClose\" | \"fixedTo\">\n >;\n\n /**\n * Any additional props to pass to the div that contains the current visible\n * option.\n */\n selectedOptionProps?: BoxProps;\n\n /**\n * Set this to `true` if all the `Option` components should display the\n * selected icon after the children instead of before.\n *\n * @see {@link disableSelectedIcon} to remove the selected icon instead.\n *\n * @defaultValue `false`\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` to prevent the current option from rendering the\n * `leftAddon` in the `TextFieldContainer`.\n *\n * @defaultValue `false`\n */\n disableOptionAddon?: boolean;\n\n /**\n * Set this to `true` to update all the `Option` components to no longer\n * render an icon while selected.\n *\n * @defaultValue `false`\n */\n disableSelectedIcon?: boolean;\n\n /**\n * This should be the available `Option`s for the select to choose from. It\n * can also contain `OptGroup` or any other elements but only clicking on an\n * `Option` component will update the value.\n */\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Option } from \"@react-md/core/form/Option\";\n * import { Select } from \"@react-md/core/form/Select\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const [value, setValue] = useState(\"\");\n *\n * return (\n * <Select\n * label=\"Select\"\n * value={value}\n * onChange={(event) => setValue(event.currentTarget.value)}\n * placeholder=\"Select a value\"\n * >\n * <Option value=\"a\">Option 1</Option>\n * <Option value=\"b\">Option 2</Option>\n * <Option value=\"c\">Option 3</Option>\n * <Option value=\"d\">Option 4</Option>\n * </Select>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/select | Select Demos}\n * @since 6.0.0 Rewritten with a new API.\n */\nexport function Select<Value extends string>(\n props: RequireAtLeastOne<SelectProps<Value>, \"label\" | keyof LabelA11y>\n): ReactElement {\n const {\n id,\n form,\n autoCompleteValue,\n autoComplete = autoCompleteValue,\n name = autoCompleteValue,\n className,\n onClick,\n onFocus,\n onKeyDown,\n inputRef: propInputRef,\n inputProps,\n containerRef,\n placeholder,\n menuProps = {},\n label,\n labelProps = {},\n selectedOptionProps,\n icon: propIcon,\n value,\n defaultValue,\n theme: propTheme,\n onChange = noop,\n rightAddon: propRightAddon,\n active = false,\n required,\n selectedIconAfter = false,\n disableOptionAddon = false,\n disableSelectedIcon = false,\n children,\n ...remaining\n } = props;\n const { dense, error, disabled } = props;\n\n const comboboxId = useEnsuredId(id, \"select\");\n const inputId = useEnsuredId(inputProps?.id, \"select-value\");\n const selectLabelId = useEnsuredId(labelProps.id, \"select-label\");\n const labelId = label ? selectLabelId : undefined;\n\n const [localValue, setLocalValue] = useState(() => {\n if (typeof defaultValue !== \"undefined\") {\n return defaultValue;\n }\n\n return typeof value !== \"undefined\" ? value : EMPTY_STRING;\n });\n const currentValue = typeof value === \"undefined\" ? localValue : value;\n const initialValue = useRef(currentValue);\n const { options, currentOption } = extractOptionsFromChildren(\n children,\n currentValue\n );\n\n const { visible, comboboxProps, movementContext, getMenuProps } =\n useSelectCombobox({\n form,\n value: currentValue,\n values: options,\n onClick,\n onFocus,\n onKeyDown,\n disabled,\n popupId: menuProps.id,\n popupRef: menuProps.ref,\n comboboxId,\n comboboxRef: containerRef,\n });\n\n const [inputRef, inputRefCallback] = useEnsuredRef(propInputRef);\n useFormReset({\n form,\n elementRef: inputRef,\n defaultValue: initialValue.current,\n });\n\n const icon = getIcon(\"dropdown\", propIcon);\n const theme = getFormConfig(\"theme\", propTheme);\n let rightAddon = propRightAddon;\n if (typeof rightAddon === \"undefined\" && icon) {\n rightAddon = <IconRotator rotated={visible}>{icon}</IconRotator>;\n }\n\n const { ref: listboxRef, ...listboxProps } = getMenuProps(menuProps);\n let listboxLabelledBy = menuProps[\"aria-labelledby\"];\n const listboxLabel = menuProps[\"aria-label\"];\n if (!listboxLabel && !listboxLabelledBy) {\n listboxLabelledBy = labelId || comboboxId;\n }\n\n return (\n <KeyboardMovementProvider value={movementContext}>\n <TextFieldContainer\n aria-labelledby={labelId}\n {...remaining}\n {...comboboxProps}\n label={!!label}\n theme={theme}\n active={active || visible}\n className={cnb(\"rmd-select-container\", className)}\n rightAddon={rightAddon}\n >\n <SelectedOption\n option={currentOption}\n placeholder={placeholder}\n disableAddon={disableOptionAddon}\n {...selectedOptionProps}\n />\n <input\n aria-hidden\n id={inputId}\n ref={inputRefCallback}\n type=\"text\"\n autoComplete={autoComplete}\n name={name}\n tabIndex={-1}\n disabled={disabled}\n required={required}\n placeholder=\" \"\n {...inputProps}\n value={value}\n defaultValue={defaultValue}\n className={cnb(select({ theme }), textField())}\n onChange={(event) => {\n onChange(event as SelectChangeEvent<Value>);\n if (typeof value !== \"undefined\") {\n return;\n }\n\n const nextValue = event.currentTarget.value;\n const nextOption = options.find((option) => option === nextValue);\n\n setLocalValue(nextOption ?? initialValue.current);\n }}\n />\n {label && (\n <span\n {...labelProps}\n id={labelId}\n className={labelStyles({\n dense,\n error,\n disabled,\n active: active || visible,\n floating: true,\n floatingActive: !!placeholder || !!currentOption,\n className: labelProps.className,\n })}\n >\n {label}\n </span>\n )}\n </TextFieldContainer>\n <Listbox\n {...listboxProps}\n aria-label={listboxLabel}\n aria-labelledby={listboxLabelledBy as string}\n nodeRef={listboxRef}\n value={currentValue}\n setValue={useCallback(\n (option: \"\" | Value) => {\n triggerManualChangeEvent(inputRef.current, option);\n },\n [inputRef]\n )}\n selectedIconAfter={selectedIconAfter}\n disableSelectedIcon={disableSelectedIcon}\n >\n {children}\n </Listbox>\n </KeyboardMovementProvider>\n );\n}\n"],"names":["cnb","useCallback","useRef","useState","IconRotator","getIcon","KeyboardMovementProvider","useEnsuredId","useEnsuredRef","Listbox","SelectedOption","TextFieldContainer","getFormConfig","label","labelStyles","select","extractOptionsFromChildren","textField","useFormReset","useSelectCombobox","triggerManualChangeEvent","EMPTY_STRING","noop","Select","props","id","form","autoCompleteValue","autoComplete","name","className","onClick","onFocus","onKeyDown","inputRef","propInputRef","inputProps","containerRef","placeholder","menuProps","labelProps","selectedOptionProps","icon","propIcon","value","defaultValue","theme","propTheme","onChange","rightAddon","propRightAddon","active","required","selectedIconAfter","disableOptionAddon","disableSelectedIcon","children","remaining","dense","error","disabled","comboboxId","inputId","selectLabelId","labelId","undefined","localValue","setLocalValue","currentValue","initialValue","options","currentOption","visible","comboboxProps","movementContext","getMenuProps","values","popupId","popupRef","ref","comboboxRef","inputRefCallback","elementRef","current","rotated","listboxRef","listboxProps","listboxLabelledBy","listboxLabel","aria-labelledby","option","disableAddon","input","aria-hidden","type","tabIndex","event","nextValue","currentTarget","nextOption","find","span","floating","floatingActive","aria-label","nodeRef","setValue"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAOEC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAGf,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,wBAAwB,QAAQ,6CAA6C;AAMtF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SACEC,kBAAkB,QAEb,0BAA0B;AACjC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,SAASC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,0BAA0B,QAAQ,mBAAmB;AAC9D,SAASC,SAAS,QAAQ,uBAAuB;AAEjD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,MAAMC,eAAe;AACrB,MAAMC,OAAO;AACX,aAAa;AACf;AA0KA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GACD,OAAO,SAASC,OACdC,KAAuE;IAEvE,MAAM,EACJC,EAAE,EACFC,IAAI,EACJC,iBAAiB,EACjBC,eAAeD,iBAAiB,EAChCE,OAAOF,iBAAiB,EACxBG,SAAS,EACTC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,UAAUC,YAAY,EACtBC,UAAU,EACVC,YAAY,EACZC,WAAW,EACXC,YAAY,CAAC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BAClD;;oBAEDtE,uBACC,KAACwF;wBACE,GAAG7D,UAAU;wBACdf,IAAIuC;wBACJlC,WAAWhB,YAAY;4BACrB4C;4BACAC;4BACAC;4BACAT,QAAQA,UAAUqB;4BAClB8B,UAAU;4BACVC,gBAAgB,CAAC,CAACjE,eAAe,CAAC,CAACiC;4BACnCzC,WAAWU,WAAWV,SAAS;wBACjC;kCAECjB;;;;0BAIP,KAACJ;gBACE,GAAG6E,YAAY;gBAChBkB,cAAYhB;gBACZC,mBAAiBF;gBACjBkB,SAASpB;gBACTzC,OAAOwB;gBACPsC,UAAUzG,YACR,CAACyF;oBACCtE,yBAAyBc,SAASiD,OAAO,EAAEO;gBAC7C,GACA;oBAACxD;iBAAS;gBAEZmB,mBAAmBA;gBACnBE,qBAAqBA;0BAEpBC;;;;AAIT"}
|
|
1
|
+
{"version":3,"sources":["../../src/form/Select.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ChangeEvent,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { type BoxProps } from \"../box/Box.js\";\nimport { IconRotator } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type MenuProps } from \"../menu/Menu.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport {\n type LabelA11y,\n type PropsWithRef,\n type RequireAtLeastOne,\n} from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { Listbox } from \"./Listbox.js\";\nimport { type OptionProps } from \"./Option.js\";\nimport { SelectedOption } from \"./SelectedOption.js\";\nimport {\n TextFieldContainer,\n type TextFieldContainerProps,\n} from \"./TextFieldContainer.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { label as labelStyles } from \"./labelStyles.js\";\nimport { select } from \"./selectStyles.js\";\nimport { extractOptionsFromChildren } from \"./selectUtils.js\";\nimport { textField } from \"./textFieldStyles.js\";\nimport { type UserAgentAutocompleteProps } from \"./types.js\";\nimport { useFormReset } from \"./useFormReset.js\";\nimport { useSelectCombobox } from \"./useSelectCombobox.js\";\nimport { triggerManualChangeEvent } from \"./utils.js\";\n\nconst EMPTY_STRING = \"\" as const;\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.5.0\n */\nexport interface GetSelectedOptionChildrenOptions<\n Value extends string = string,\n> {\n value: \"\" | Value;\n\n /**\n * The option will be undefined if there is no value or matching option.\n */\n option: OptionProps | undefined;\n\n /**\n * This is a pass-through of the {@link SelectProps.placeholder}\n */\n placeholder?: ReactNode;\n\n /**\n * This is a pass-through of the {@link SelectProps.selectedOptionProps}\n */\n children?: ReactNode;\n}\n\n/**\n * @since 6.5.0\n */\nconst defaultGetSelectedOptionChildren = (\n options: GetSelectedOptionChildrenOptions\n): ReactNode => {\n const { children, option, placeholder } = options;\n\n return children ?? (option?.children || placeholder);\n};\n\n/**\n * This is a convenience type for casting the `event.currentTarget.value` of a\n * `Select`'s change event to be union of available values.\n *\n * Note: The change event does not provide any sort of validation on the value\n * so automation tools like Cypress, Playwright, or Selenium might set an\n * invalid value. This also does not work for numbers, so you will need to\n * implement that yourself.\n *\n * @example Simple Usage\n * ```tsx\n * import { Select, type SelectChangeEvent } from \"@react-md/core/form/Select\";\n * import { Option } from \"@react-md/core/form/Option\";\n * import type { ReactElement } from \"react\";\n *\n * type Value = \"\" | \"a\" | \"b\" | \"c\" | \"d\";\n *\n * function Example(): ReactElement {\n * const [value, setValue] = useState<Value>(\"\");\n *\n * const handleChange = (event: SelectChangeEvent<Value>): void => {\n * // No type error!\n * // `event.currentTarget.value`'s type is `Value` instead of a generic `string`\n * setValue(event.currentTarget.value);\n * };\n *\n * return (\n * <Select\n * label=\"Label\"\n * value={value}\n * onChange={handleChange}\n * >\n * <Option value=\"a\">First</Option>\n * <Option value=\"b\">Second</Option>\n * <Option value=\"c\">Third</Option>\n * <Option value=\"d\">Fourth</Option>\n * </Select>\n * );\n * }\n * ```\n * @since 6.0.0\n */\nexport type SelectChangeEvent<Value extends string> =\n ChangeEvent<HTMLInputElement> & { currentTarget: { value: Value } };\n\n/**\n * @since 6.0.0 Rewritten with a new API.\n */\nexport interface SelectProps<Value extends string>\n extends\n Omit<TextFieldContainerProps, \"label\">,\n Pick<InputHTMLAttributes<HTMLInputElement>, \"form\" | \"required\">,\n UserAgentAutocompleteProps {\n /**\n * @defaultValue `\"select-\" + useId()`\n */\n id?: string;\n\n /**\n * Optional placeholder text or element to render while no options have been\n * selected.\n */\n placeholder?: ReactNode;\n\n /**\n * Set this to a custom dropdown icon or `null` to not render a dropdown icon.\n *\n * @defaultValue `getIcon(\"dropdown\")`\n */\n icon?: ReactNode;\n\n /**\n * Set this value to fully control the value of the select component. The\n * {@link onChange} handler **must** also be provided if this prop exists.\n */\n value?: Value;\n\n /**\n * An optional default value when the value of the select component is\n * uncontrolled.\n *\n * @defaultValue `\"\"`\n */\n defaultValue?: Value;\n\n /** @see {@link SelectChangeEvent} */\n onChange?: (event: SelectChangeEvent<Value>) => void;\n\n /**\n * An optional floating label to display like other form fields.\n */\n label?: ReactNode;\n\n /**\n * Optional props to pass to the `<span>` that surrounds the {@link label}\n */\n labelProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional ref to pass to the hidden `<input type=\"text\" />` element that\n * stores the current value. This is really only useful if you'd like to keep\n * this component uncontrolled and access the value through\n * `inputRef.current.value`.\n */\n inputRef?: Ref<HTMLInputElement>;\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n\n /**\n * A ref for the container `<div>` element.\n */\n containerRef?: Ref<HTMLDivElement>;\n\n /**\n * Any additional props to provide to the `Menu` component that renders all\n * the `Option`s.\n *\n * The menu will always have these default values unless explicity\n * overwritten by this prop:\n *\n * - `aria-labelledby={label ? labelId : id}` -- this will be undefined if\n * `aria-label` is provided\n * - `anchor={BELOW_CENTER_ANCHOR}`\n * - `width=\"min\"`\n */\n menuProps?: PropsWithRef<\n Omit<MenuProps, \"visible\" | \"onRequestClose\" | \"fixedTo\">\n >;\n\n /**\n * Any additional props to pass to the div that contains the current visible\n * option.\n */\n selectedOptionProps?: BoxProps;\n\n /**\n * Set this to `true` if all the `Option` components should display the\n * selected icon after the children instead of before.\n *\n * @see {@link disableSelectedIcon} to remove the selected icon instead.\n *\n * @defaultValue `false`\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` to prevent the current option from rendering the\n * `leftAddon` in the `TextFieldContainer`.\n *\n * @defaultValue `false`\n */\n disableOptionAddon?: boolean;\n\n /**\n * Set this to `true` to update all the `Option` components to no longer\n * render an icon while selected.\n *\n * @defaultValue `false`\n */\n disableSelectedIcon?: boolean;\n\n /**\n * @since 6.5.0\n * @defaultValue `({ children, option, placeholder }) => children ?? (option?.children || placeholder)`\n */\n getSelectedOptionChildren?: (\n options: GetSelectedOptionChildrenOptions<Value>\n ) => ReactNode;\n\n /**\n * This should be the available `Option`s for the select to choose from. It\n * can also contain `OptGroup` or any other elements but only clicking on an\n * `Option` component will update the value.\n */\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Option } from \"@react-md/core/form/Option\";\n * import { Select } from \"@react-md/core/form/Select\";\n * import { useState, type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const [value, setValue] = useState(\"\");\n *\n * return (\n * <Select\n * label=\"Select\"\n * value={value}\n * onChange={(event) => setValue(event.currentTarget.value)}\n * placeholder=\"Select a value\"\n * >\n * <Option value=\"a\">Option 1</Option>\n * <Option value=\"b\">Option 2</Option>\n * <Option value=\"c\">Option 3</Option>\n * <Option value=\"d\">Option 4</Option>\n * </Select>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/select | Select Demos}\n * @since 6.0.0 Rewritten with a new API.\n */\nexport function Select<Value extends string>(\n props: RequireAtLeastOne<SelectProps<Value>, \"label\" | keyof LabelA11y>\n): ReactElement {\n const {\n id,\n form,\n autoCompleteValue,\n autoComplete = autoCompleteValue,\n name = autoCompleteValue,\n className,\n onClick,\n onFocus,\n onKeyDown,\n inputRef: propInputRef,\n inputProps,\n containerRef,\n placeholder,\n menuProps = {},\n label,\n labelProps = {},\n selectedOptionProps,\n getSelectedOptionChildren = defaultGetSelectedOptionChildren,\n icon: propIcon,\n value,\n defaultValue,\n theme: propTheme,\n onChange = noop,\n rightAddon: propRightAddon,\n active = false,\n required,\n selectedIconAfter = false,\n disableOptionAddon = false,\n disableSelectedIcon = false,\n children,\n ...remaining\n } = props;\n const { dense, error, disabled } = props;\n\n const comboboxId = useEnsuredId(id, \"select\");\n const inputId = useEnsuredId(inputProps?.id, \"select-value\");\n const selectLabelId = useEnsuredId(labelProps.id, \"select-label\");\n const labelId = label ? selectLabelId : undefined;\n\n const [localValue, setLocalValue] = useState(() => {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n\n return value !== undefined ? value : EMPTY_STRING;\n });\n const currentValue = value === undefined ? localValue : value;\n const initialValue = useRef(currentValue);\n const { options, currentOption } = extractOptionsFromChildren(\n children,\n currentValue\n );\n\n const { visible, comboboxProps, movementContext, getMenuProps } =\n useSelectCombobox({\n form,\n value: currentValue,\n values: options,\n onClick,\n onFocus,\n onKeyDown,\n disabled,\n popupId: menuProps.id,\n popupRef: menuProps.ref,\n comboboxId,\n comboboxRef: containerRef,\n });\n\n const [inputRef, inputRefCallback] = useEnsuredRef(propInputRef);\n useFormReset({\n form,\n elementRef: inputRef,\n defaultValue: initialValue.current,\n });\n\n const icon = getIcon(\"dropdown\", propIcon);\n const theme = getFormConfig(\"theme\", propTheme);\n let rightAddon = propRightAddon;\n if (rightAddon === undefined && icon) {\n rightAddon = <IconRotator rotated={visible}>{icon}</IconRotator>;\n }\n\n const { ref: listboxRef, ...listboxProps } = getMenuProps(menuProps);\n let listboxLabelledBy = menuProps[\"aria-labelledby\"];\n const listboxLabel = menuProps[\"aria-label\"];\n if (!listboxLabel && !listboxLabelledBy) {\n listboxLabelledBy = labelId || comboboxId;\n }\n\n return (\n <KeyboardMovementProvider value={movementContext}>\n <TextFieldContainer\n aria-labelledby={labelId}\n {...remaining}\n {...comboboxProps}\n label={!!label}\n theme={theme}\n active={active || visible}\n className={cnb(\"rmd-select-container\", className)}\n rightAddon={rightAddon}\n >\n <SelectedOption\n option={currentOption}\n disableAddon={disableOptionAddon}\n {...selectedOptionProps}\n >\n {getSelectedOptionChildren({\n value: currentValue,\n option: currentOption,\n placeholder,\n children: selectedOptionProps?.children,\n })}\n </SelectedOption>\n <input\n aria-hidden\n id={inputId}\n ref={inputRefCallback}\n type=\"text\"\n autoComplete={autoComplete}\n name={name}\n tabIndex={-1}\n disabled={disabled}\n required={required}\n placeholder=\" \"\n {...inputProps}\n value={value}\n defaultValue={defaultValue}\n className={cnb(select({ theme }), textField())}\n onChange={(event) => {\n onChange(event as SelectChangeEvent<Value>);\n if (value !== undefined) {\n return;\n }\n\n const nextValue = event.currentTarget.value;\n const nextOption = options.find((option) => option === nextValue);\n\n setLocalValue(nextOption ?? initialValue.current);\n }}\n />\n {label && (\n <span\n {...labelProps}\n id={labelId}\n className={labelStyles({\n dense,\n error,\n disabled,\n active: active || visible,\n floating: true,\n floatingActive: !!placeholder || !!currentOption,\n className: labelProps.className,\n })}\n >\n {label}\n </span>\n )}\n </TextFieldContainer>\n <Listbox\n {...listboxProps}\n aria-label={listboxLabel}\n aria-labelledby={listboxLabelledBy as string}\n nodeRef={listboxRef}\n value={currentValue}\n setValue={useCallback(\n (option: \"\" | Value) => {\n triggerManualChangeEvent(inputRef.current, option);\n },\n [inputRef]\n )}\n selectedIconAfter={selectedIconAfter}\n disableSelectedIcon={disableSelectedIcon}\n >\n {children}\n </Listbox>\n </KeyboardMovementProvider>\n );\n}\n"],"names":["cnb","useCallback","useRef","useState","IconRotator","getIcon","KeyboardMovementProvider","useEnsuredId","useEnsuredRef","Listbox","SelectedOption","TextFieldContainer","getFormConfig","label","labelStyles","select","extractOptionsFromChildren","textField","useFormReset","useSelectCombobox","triggerManualChangeEvent","EMPTY_STRING","noop","defaultGetSelectedOptionChildren","options","children","option","placeholder","Select","props","id","form","autoCompleteValue","autoComplete","name","className","onClick","onFocus","onKeyDown","inputRef","propInputRef","inputProps","containerRef","menuProps","labelProps","selectedOptionProps","getSelectedOptionChildren","icon","propIcon","value","defaultValue","theme","propTheme","onChange","rightAddon","propRightAddon","active","required","selectedIconAfter","disableOptionAddon","disableSelectedIcon","remaining","dense","error","disabled","comboboxId","inputId","selectLabelId","labelId","undefined","localValue","setLocalValue","currentValue","initialValue","currentOption","visible","comboboxProps","movementContext","getMenuProps","values","popupId","popupRef","ref","comboboxRef","inputRefCallback","elementRef","current","rotated","listboxRef","listboxProps","listboxLabelledBy","listboxLabel","aria-labelledby","disableAddon","input","aria-hidden","type","tabIndex","event","nextValue","currentTarget","nextOption","find","span","floating","floatingActive","aria-label","nodeRef","setValue"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAOEC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAGf,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,wBAAwB,QAAQ,6CAA6C;AAMtF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,OAAO,QAAQ,eAAe;AAEvC,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SACEC,kBAAkB,QAEb,0BAA0B;AACjC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,SAASC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,0BAA0B,QAAQ,mBAAmB;AAC9D,SAASC,SAAS,QAAQ,uBAAuB;AAEjD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,iBAAiB,QAAQ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
import { type ReactElement } from "react";
|
|
2
2
|
import { type BoxProps } from "../box/Box.js";
|
|
3
3
|
import { type OptionProps } from "./Option.js";
|
|
4
4
|
/**
|
|
@@ -7,7 +7,6 @@ import { type OptionProps } from "./Option.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export interface SelectedOptionProps extends BoxProps {
|
|
9
9
|
option: OptionProps | undefined;
|
|
10
|
-
placeholder?: ReactNode;
|
|
11
10
|
disableAddon: boolean;
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
@@ -9,8 +9,8 @@ import { textField } from "./textFieldStyles.js";
|
|
|
9
9
|
* @since 6.0.0
|
|
10
10
|
* @internal
|
|
11
11
|
*/ export function SelectedOption(props) {
|
|
12
|
-
const { disableAddon, option, className, disableWrap = true, disablePadding = true,
|
|
13
|
-
let children =
|
|
12
|
+
const { disableAddon, option, className, disableWrap = true, disablePadding = true, ...remaining } = props;
|
|
13
|
+
let { children } = remaining;
|
|
14
14
|
// when the children are a string or number, wrap it in additional span so
|
|
15
15
|
// that overflow can be ellipsis-ed
|
|
16
16
|
if (typeof children === "string" || typeof children === "number") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/SelectedOption.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type ReactElement
|
|
1
|
+
{"version":3,"sources":["../../src/form/SelectedOption.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type ReactElement } from \"react\";\n\nimport { Box, type BoxProps } from \"../box/Box.js\";\nimport { cssUtils } from \"../cssUtils.js\";\nimport { type OptionProps } from \"./Option.js\";\nimport { textField } from \"./textFieldStyles.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface SelectedOptionProps extends BoxProps {\n option: OptionProps | undefined;\n disableAddon: boolean;\n}\n\n/**\n * This component is used to render the current option.\n *\n * @since 6.0.0\n * @internal\n */\nexport function SelectedOption(props: SelectedOptionProps): ReactElement {\n const {\n disableAddon,\n option,\n className,\n disableWrap = true,\n disablePadding = true,\n ...remaining\n } = props;\n\n let { children } = remaining;\n // when the children are a string or number, wrap it in additional span so\n // that overflow can be ellipsis-ed\n if (typeof children === \"string\" || typeof children === \"number\") {\n children = (\n <span className={cssUtils({ textOverflow: \"ellipsis\" })}>{children}</span>\n );\n }\n\n return (\n <Box\n {...remaining}\n className={cnb(\"rmd-selected-option\", textField(), className)}\n disableWrap={disableWrap}\n disablePadding={disablePadding}\n >\n {!disableAddon && option?.leftAddon}\n {children}\n </Box>\n );\n}\n"],"names":["cnb","Box","cssUtils","textField","SelectedOption","props","disableAddon","option","className","disableWrap","disablePadding","remaining","children","span","textOverflow","leftAddon"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAGhC,SAASC,GAAG,QAAuB,gBAAgB;AACnD,SAASC,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,SAAS,QAAQ,uBAAuB;AAWjD;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,YAAY,EACZC,MAAM,EACNC,SAAS,EACTC,cAAc,IAAI,EAClBC,iBAAiB,IAAI,EACrB,GAAGC,WACJ,GAAGN;IAEJ,IAAI,EAAEO,QAAQ,EAAE,GAAGD;IACnB,0EAA0E;IAC1E,mCAAmC;IACnC,IAAI,OAAOC,aAAa,YAAY,OAAOA,aAAa,UAAU;QAChEA,yBACE,KAACC;YAAKL,WAAWN,SAAS;gBAAEY,cAAc;YAAW;sBAAKF;;IAE9D;IAEA,qBACE,MAACX;QACE,GAAGU,SAAS;QACbH,WAAWR,IAAI,uBAAuBG,aAAaK;QACnDC,aAAaA;QACbC,gBAAgBA;;YAEf,CAACJ,gBAAgBC,QAAQQ;YACzBH;;;AAGP"}
|
|
@@ -91,13 +91,14 @@ $large-size: 2rem !default;
|
|
|
91
91
|
@include hidden-input-styles(true);
|
|
92
92
|
|
|
93
93
|
.rmd-input-toggle {
|
|
94
|
+
$focus-selector: "&:has(:focus-visible)";
|
|
95
|
+
@if utils.$disable-has-selectors or utils.$disable-focus-visible {
|
|
96
|
+
$focus-selector: "&:focus-within";
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
@include icon.set-var(color, currentcolor);
|
|
95
100
|
@include interaction.surface(
|
|
96
|
-
$focus-selector:
|
|
97
|
-
utils.$disable-has-selectors or utils.$disable-focus-visible,
|
|
98
|
-
"&:focus-within",
|
|
99
|
-
"&:has(:focus-visible)"
|
|
100
|
-
),
|
|
101
|
+
$focus-selector: $focus-selector,
|
|
101
102
|
$keyboard-only-focus: utils.$disable-has-selectors or
|
|
102
103
|
utils.$disable-focus-visible,
|
|
103
104
|
$disabled-selector: "&--disabled",
|
package/dist/form/_label.scss
CHANGED
|
@@ -151,8 +151,8 @@ $variables: (
|
|
|
151
151
|
@include use-var(background-color, active-background-color);
|
|
152
152
|
@include use-var(padding, active-padding);
|
|
153
153
|
|
|
154
|
-
transform:
|
|
155
|
-
|
|
154
|
+
transform: translate(get-var(floating-active-x), get-var(floating-active-y))
|
|
155
|
+
scale($floating-scale);
|
|
156
156
|
// need to add the `transform-origin` because of the scaling applied.
|
|
157
157
|
// it'll change the position based on the size of the label otherwise
|
|
158
158
|
transform-origin: 0 0;
|
package/dist/form/_legend.scss
CHANGED
|
@@ -28,33 +28,42 @@ $disable-floating: false !default;
|
|
|
28
28
|
@if not $disable-floating {
|
|
29
29
|
&--floating {
|
|
30
30
|
@include label.set-var(floating-active-y, -50%);
|
|
31
|
-
@include label.set-var(active-padding, 0 label.$floating-padding);
|
|
32
|
-
@include label.set-var(
|
|
33
|
-
active-background-color,
|
|
34
|
-
theme.theme-get-var(background-color)
|
|
35
|
-
);
|
|
36
31
|
@include label.set-var(
|
|
37
32
|
floating-active-x,
|
|
38
33
|
text-field.get-var(padding-left)
|
|
39
34
|
);
|
|
35
|
+
|
|
36
|
+
.rmd-fieldset:has(:focus-within) & {
|
|
37
|
+
@include label.active-styles;
|
|
38
|
+
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
@if not base.$form-disable-filled-theme {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
&--floating-filled {
|
|
43
|
+
@include text-field.set-var(
|
|
44
|
+
padding-left,
|
|
45
|
+
text-field.get-var(filled-padding)
|
|
46
|
+
);
|
|
47
|
+
@include label.set-var(floating-active-y, -100%);
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
@if not base.$form-disable-underlined-theme {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
&--floating-underline {
|
|
53
|
+
@include text-field.set-var(
|
|
54
|
+
padding-left,
|
|
55
|
+
text-field.get-var(underlined-padding)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
@if not base.$form-disable-outlined-theme {
|
|
57
61
|
&--floating-outline {
|
|
62
|
+
@include label.set-var(active-padding, 0 label.$floating-padding);
|
|
63
|
+
@include label.set-var(
|
|
64
|
+
active-background-color,
|
|
65
|
+
theme.theme-get-var(background-color)
|
|
66
|
+
);
|
|
58
67
|
@include text-field.set-var(
|
|
59
68
|
padding-left,
|
|
60
69
|
text-field.get-var(outlined-padding)
|
package/dist/form/_slider.scss
CHANGED
|
@@ -634,11 +634,13 @@ $variables: (
|
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
.rmd-slider-thumb {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
637
|
+
$color-name: active-color;
|
|
638
|
+
$color-fallback: null;
|
|
639
|
+
@if $track-color {
|
|
640
|
+
$color-name: color;
|
|
641
|
+
$color-fallback: theme.theme-color-var-fallback($track-color);
|
|
642
|
+
}
|
|
643
|
+
@include use-var(background-color, $color-name, $color-fallback);
|
|
642
644
|
|
|
643
645
|
border-radius: $thumb-border-radius;
|
|
644
646
|
height: $thumb-size;
|
package/dist/form/_switch.scss
CHANGED
|
@@ -80,10 +80,10 @@ $track-light-background-color: colors.$grey-400 !default;
|
|
|
80
80
|
|
|
81
81
|
/// The background color to apply to the `SwitchTrack` in the dark theme.
|
|
82
82
|
/// @type Color
|
|
83
|
+
// prettier-ignore
|
|
83
84
|
$track-dark-background-color: if(
|
|
84
|
-
theme.$disable-dark-elevation
|
|
85
|
-
|
|
86
|
-
map.get(theme.$dark-elevation-colors, 24)
|
|
85
|
+
sass(theme.$disable-dark-elevation): $track-light-background-color;
|
|
86
|
+
else: map.get(theme.$dark-elevation-colors, 24)
|
|
87
87
|
) !default;
|
|
88
88
|
|
|
89
89
|
/// The default background color to apply to the `SwitchTrack`.
|
|
@@ -274,8 +274,10 @@ $variables: (track-background-color, ball-background-color);
|
|
|
274
274
|
z-index: 0;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
$active-selector: ".rmd-switch__input:checked + &"
|
|
278
|
-
|
|
277
|
+
$active-selector: ".rmd-switch__input:checked + &";
|
|
278
|
+
@if not $disable-menu-item-switch {
|
|
279
|
+
$active-selector: $active-selector + ", &--active";
|
|
280
|
+
}
|
|
279
281
|
|
|
280
282
|
#{$active-selector} {
|
|
281
283
|
$offset: $ball-size + $ball-offset;
|
|
@@ -271,6 +271,11 @@ $variables: (
|
|
|
271
271
|
/// @param {any} fallback [null] - An optional fallback value
|
|
272
272
|
/// @returns {String} a `var()` statement
|
|
273
273
|
@function get-var($name, $fallback: null) {
|
|
274
|
+
@if $name == underlined-padding and not $underlined-padding and not $fallback
|
|
275
|
+
{
|
|
276
|
+
$fallback: 0px;
|
|
277
|
+
}
|
|
278
|
+
|
|
274
279
|
$var: utils.get-var-name($variables, $name, "text-field");
|
|
275
280
|
@if $fallback {
|
|
276
281
|
@return var(#{$var}, #{$fallback});
|
|
@@ -502,17 +507,14 @@ $variables: (
|
|
|
502
507
|
&--filled {
|
|
503
508
|
@include theme.theme-set-var(background-color, get-var(filled-color));
|
|
504
509
|
@include theme.theme-use-var(background-color);
|
|
505
|
-
@include set-var(padding-left,
|
|
506
|
-
@include set-var(padding-right,
|
|
510
|
+
@include set-var(padding-left, get-var(filled-padding));
|
|
511
|
+
@include set-var(padding-right, get-var(filled-padding));
|
|
507
512
|
@if not label.$disable-floating {
|
|
508
|
-
@include label.set-var(
|
|
509
|
-
floating-active-x,
|
|
510
|
-
$filled-padding + label.$floating-padding
|
|
511
|
-
);
|
|
513
|
+
@include label.set-var(floating-active-x, get-var(filled-padding));
|
|
512
514
|
}
|
|
513
515
|
|
|
514
516
|
@if not $disable-addon {
|
|
515
|
-
@include set-var(addon-left-offset,
|
|
517
|
+
@include set-var(addon-left-offset, get-var(filled-padding));
|
|
516
518
|
}
|
|
517
519
|
}
|
|
518
520
|
}
|
|
@@ -529,8 +531,8 @@ $variables: (
|
|
|
529
531
|
border-bottom-width: $border-width;
|
|
530
532
|
|
|
531
533
|
@if $underlined-padding {
|
|
532
|
-
@include set-var(padding-left,
|
|
533
|
-
@include set-var(padding-right,
|
|
534
|
+
@include set-var(padding-left, get-var(underlined-padding));
|
|
535
|
+
@include set-var(padding-right, get-var(underlined-padding));
|
|
534
536
|
}
|
|
535
537
|
|
|
536
538
|
&::after {
|
|
@@ -594,8 +596,8 @@ $variables: (
|
|
|
594
596
|
|
|
595
597
|
@if not $disable-addon {
|
|
596
598
|
$addon-offset: calc(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
+
icon.get-var(size) +
|
|
600
|
+
get-var(underlined-padding) +
|
|
599
601
|
$underlined-label-left-offset *
|
|
600
602
|
2
|
|
601
603
|
);
|
package/dist/form/formConfig.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/formConfig.ts"],"sourcesContent":["import {\n type FormConfiguration,\n type FormTheme,\n type FormUnderlineDirection,\n} from \"./types.js\";\n\n// NOTE: Uses get/set for test mocking\n\nlet theme: FormTheme = \"outline\";\nlet underlineDirection: FormUnderlineDirection = \"left\";\nlet uncontrolledToggles = true;\n\n/**\n * @since 6.0.0\n */\nexport const FORM_CONFIG: FormConfiguration = {\n get theme() {\n return theme;\n },\n set theme(nextTheme: FormTheme) {\n theme = nextTheme;\n },\n get underlineDirection() {\n return underlineDirection;\n },\n set underlineDirection(nextUnderlineDirection: FormUnderlineDirection) {\n underlineDirection = nextUnderlineDirection;\n },\n get uncontrolledToggles() {\n return uncontrolledToggles;\n },\n set uncontrolledToggles(nextUncontrolledToggles: boolean) {\n uncontrolledToggles = nextUncontrolledToggles;\n },\n};\n\n/**\n * @since 6.0.0\n */\nexport function getFormConfig<N extends keyof FormConfiguration>(\n name: N,\n override?: FormConfiguration[N]\n): FormConfiguration[N] {\n if (
|
|
1
|
+
{"version":3,"sources":["../../src/form/formConfig.ts"],"sourcesContent":["import {\n type FormConfiguration,\n type FormTheme,\n type FormUnderlineDirection,\n} from \"./types.js\";\n\n// NOTE: Uses get/set for test mocking\n\nlet theme: FormTheme = \"outline\";\nlet underlineDirection: FormUnderlineDirection = \"left\";\nlet uncontrolledToggles = true;\n\n/**\n * @since 6.0.0\n */\nexport const FORM_CONFIG: FormConfiguration = {\n get theme() {\n return theme;\n },\n set theme(nextTheme: FormTheme) {\n theme = nextTheme;\n },\n get underlineDirection() {\n return underlineDirection;\n },\n set underlineDirection(nextUnderlineDirection: FormUnderlineDirection) {\n underlineDirection = nextUnderlineDirection;\n },\n get uncontrolledToggles() {\n return uncontrolledToggles;\n },\n set uncontrolledToggles(nextUncontrolledToggles: boolean) {\n uncontrolledToggles = nextUncontrolledToggles;\n },\n};\n\n/**\n * @since 6.0.0\n */\nexport function getFormConfig<N extends keyof FormConfiguration>(\n name: N,\n override?: FormConfiguration[N]\n): FormConfiguration[N] {\n if (override !== undefined) {\n return override;\n }\n\n return FORM_CONFIG[name];\n}\n"],"names":["theme","underlineDirection","uncontrolledToggles","FORM_CONFIG","nextTheme","nextUnderlineDirection","nextUncontrolledToggles","getFormConfig","name","override","undefined"],"mappings":"AAMA,sCAAsC;AAEtC,IAAIA,QAAmB;AACvB,IAAIC,qBAA6C;AACjD,IAAIC,sBAAsB;AAE1B;;CAEC,GACD,OAAO,MAAMC,cAAiC;IAC5C,IAAIH,SAAQ;QACV,OAAOA;IACT;IACA,IAAIA,OAAMI,UAAsB;QAC9BJ,QAAQI;IACV;IACA,IAAIH,sBAAqB;QACvB,OAAOA;IACT;IACA,IAAIA,oBAAmBI,uBAAgD;QACrEJ,qBAAqBI;IACvB;IACA,IAAIH,uBAAsB;QACxB,OAAOA;IACT;IACA,IAAIA,qBAAoBI,wBAAkC;QACxDJ,sBAAsBI;IACxB;AACF,EAAE;AAEF;;CAEC,GACD,OAAO,SAASC,cACdC,IAAO,EACPC,QAA+B;IAE/B,IAAIA,aAAaC,WAAW;QAC1B,OAAOD;IACT;IAEA,OAAON,WAAW,CAACK,KAAK;AAC1B"}
|
|
@@ -6,6 +6,12 @@ const styles = bem("rmd-input-toggle");
|
|
|
6
6
|
* @since 6.0.0
|
|
7
7
|
*/ export function inputToggle(options) {
|
|
8
8
|
const { className, em = true, type, size = "auto", error, active = false, disabled = false, uncontrolled } = options;
|
|
9
|
+
let textColor;
|
|
10
|
+
if (disabled) {
|
|
11
|
+
textColor = "text-disabled";
|
|
12
|
+
} else if (error) {
|
|
13
|
+
textColor = "error";
|
|
14
|
+
}
|
|
9
15
|
return cnb(`rmd-${type}`, styles({
|
|
10
16
|
em,
|
|
11
17
|
active: active && !disabled,
|
|
@@ -16,7 +22,7 @@ const styles = bem("rmd-input-toggle");
|
|
|
16
22
|
large: size === "large",
|
|
17
23
|
uncontrolled
|
|
18
24
|
}), cssUtils({
|
|
19
|
-
textColor
|
|
25
|
+
textColor
|
|
20
26
|
}), className);
|
|
21
27
|
}
|
|
22
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/inputToggleStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { type FormComponentStates } from \"./types.js\";\n\nconst styles = bem(\"rmd-input-toggle\");\n\n/**\n * The size to use for the `Checkbox` or `Radio` component. Each of these values\n * except for `\"auto\"` map to Sass variables:\n * - `\"small\"` - `$input-toggle-small-size`\n * - `\"dense\"` - `$input-toggle-dense-size`\n * - `\"normal\"` - `$input-toggle-large-size`\n * - `\"large\"` - `$input-toggle-large-size`\n *\n * When this is set to `\"auto\"`, the size will be determined by the current\n * `font-size` of the `Label` element.\n *\n * @since 6.0.0\n */\nexport type InputToggleSize = \"auto\" | \"small\" | \"dense\" | \"normal\" | \"large\";\n\n/** @since 6.0.0 */\nexport interface InputToggleClassNameOptions extends Omit<\n FormComponentStates,\n \"readOnly\"\n> {\n className?: string;\n type: \"checkbox\" | \"radio\";\n\n /**\n * Set the icon size to `1em` to allow easy sizing through font size.\n *\n * @defaultValue `true`\n */\n em?: boolean;\n\n /**\n * @see {@link InputToggleSize}\n * @defaultValue `\"auto\"`\n */\n size?: InputToggleSize;\n\n uncontrolled?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function inputToggle(options: InputToggleClassNameOptions): string {\n const {\n className,\n em = true,\n type,\n size = \"auto\",\n error,\n active = false,\n disabled = false,\n uncontrolled,\n } = options;\n\n return cnb(\n `rmd-${type}`,\n styles({\n em,\n active: active && !disabled,\n disabled,\n small: size === \"small\",\n dense: size === \"dense\",\n normal: size === \"normal\",\n large: size === \"large\",\n uncontrolled,\n }),\n cssUtils({
|
|
1
|
+
{"version":3,"sources":["../../src/form/inputToggleStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type TextColor, type ThemeColor, cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { type FormComponentStates } from \"./types.js\";\n\nconst styles = bem(\"rmd-input-toggle\");\n\n/**\n * The size to use for the `Checkbox` or `Radio` component. Each of these values\n * except for `\"auto\"` map to Sass variables:\n * - `\"small\"` - `$input-toggle-small-size`\n * - `\"dense\"` - `$input-toggle-dense-size`\n * - `\"normal\"` - `$input-toggle-large-size`\n * - `\"large\"` - `$input-toggle-large-size`\n *\n * When this is set to `\"auto\"`, the size will be determined by the current\n * `font-size` of the `Label` element.\n *\n * @since 6.0.0\n */\nexport type InputToggleSize = \"auto\" | \"small\" | \"dense\" | \"normal\" | \"large\";\n\n/** @since 6.0.0 */\nexport interface InputToggleClassNameOptions extends Omit<\n FormComponentStates,\n \"readOnly\"\n> {\n className?: string;\n type: \"checkbox\" | \"radio\";\n\n /**\n * Set the icon size to `1em` to allow easy sizing through font size.\n *\n * @defaultValue `true`\n */\n em?: boolean;\n\n /**\n * @see {@link InputToggleSize}\n * @defaultValue `\"auto\"`\n */\n size?: InputToggleSize;\n\n uncontrolled?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function inputToggle(options: InputToggleClassNameOptions): string {\n const {\n className,\n em = true,\n type,\n size = \"auto\",\n error,\n active = false,\n disabled = false,\n uncontrolled,\n } = options;\n\n let textColor: TextColor | ThemeColor | undefined;\n if (disabled) {\n textColor = \"text-disabled\";\n } else if (error) {\n textColor = \"error\";\n }\n\n return cnb(\n `rmd-${type}`,\n styles({\n em,\n active: active && !disabled,\n disabled,\n small: size === \"small\",\n dense: size === \"dense\",\n normal: size === \"normal\",\n large: size === \"large\",\n uncontrolled,\n }),\n cssUtils({ textColor }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","inputToggle","options","className","em","type","size","error","active","disabled","uncontrolled","textColor","small","dense","normal","large"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA0CC,QAAQ,QAAQ,iBAAiB;AAC3E,SAASC,GAAG,QAAQ,kBAAkB;AAGtC,MAAMC,SAASD,IAAI;AAyCnB;;CAEC,GACD,OAAO,SAASE,YAAYC,OAAoC;IAC9D,MAAM,EACJC,SAAS,EACTC,KAAK,IAAI,EACTC,IAAI,EACJC,OAAO,MAAM,EACbC,KAAK,EACLC,SAAS,KAAK,EACdC,WAAW,KAAK,EAChBC,YAAY,EACb,GAAGR;IAEJ,IAAIS;IACJ,IAAIF,UAAU;QACZE,YAAY;IACd,OAAO,IAAIJ,OAAO;QAChBI,YAAY;IACd;IAEA,OAAOd,IACL,CAAC,IAAI,EAAEQ,MAAM,EACbL,OAAO;QACLI;QACAI,QAAQA,UAAU,CAACC;QACnBA;QACAG,OAAON,SAAS;QAChBO,OAAOP,SAAS;QAChBQ,QAAQR,SAAS;QACjBS,OAAOT,SAAS;QAChBI;IACF,IACAZ,SAAS;QAAEa;IAAU,IACrBR;AAEJ"}
|
|
@@ -2,7 +2,7 @@ import { type FormTheme, type LabelClassNameOptions } from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* @since 6.4.0
|
|
4
4
|
*/
|
|
5
|
-
export type LegendLabelClassNameOptions = Pick<LabelClassNameOptions, "active" | "gap" | "
|
|
5
|
+
export type LegendLabelClassNameOptions = Pick<LabelClassNameOptions, "active" | "gap" | "error" | "stacked" | "disabled" | "reversed">;
|
|
6
6
|
/**
|
|
7
7
|
* @since 6.4.0
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/legendStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { label } from \"./labelStyles.js\";\nimport { type FormTheme, type LabelClassNameOptions } from \"./types.js\";\n\nconst styles = bem(\"rmd-legend\");\n\n/**\n * @since 6.4.0\n */\nexport type LegendLabelClassNameOptions = Pick<\n LabelClassNameOptions,\n \"active\" | \"gap\" | \"
|
|
1
|
+
{"version":3,"sources":["../../src/form/legendStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { label } from \"./labelStyles.js\";\nimport { type FormTheme, type LabelClassNameOptions } from \"./types.js\";\n\nconst styles = bem(\"rmd-legend\");\n\n/**\n * @since 6.4.0\n */\nexport type LegendLabelClassNameOptions = Pick<\n LabelClassNameOptions,\n \"active\" | \"gap\" | \"error\" | \"stacked\" | \"disabled\" | \"reversed\"\n>;\n\n/**\n * @since 6.4.0\n */\nexport interface LegendClassNameOptions extends LegendLabelClassNameOptions {\n className?: string;\n\n /**\n * @defaultValue `false`\n */\n srOnly?: boolean;\n\n /**\n * Set this to `true` to make the `<legend>` have the styles of a floating label.\n * This requires the parent `<fieldset>` to have the `floatingLegend` flag\n * enabled.\n *\n * @defaultValue `false`\n */\n floating?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link FormTheme}\n * @defaultValue `getFormConfig(\"theme\")`\n */\n theme?: FormTheme;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.active}\n * @defaultValue `false`\n */\n active?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.gap}\n * @defaultValue `false`\n */\n gap?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.disabled}\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.dense}\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.error}\n * @defaultValue `false`\n */\n error?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.stacked}\n * @defaultValue `false`\n */\n stacked?: boolean;\n\n /**\n * This will only apply if {@link floating} is `true`.\n *\n * @see {@link LabelClassNameOptions.reversed}\n * @defaultValue `false`\n */\n reversed?: boolean;\n}\n\n/**\n * @since 6.4.0\n */\nexport function legend(options: LegendClassNameOptions = {}): string {\n const {\n className,\n srOnly,\n floating,\n theme = getFormConfig(\"theme\"),\n ...labelOptions\n } = options;\n\n return cnb(\n styles({\n floating,\n \"floating-filled\": floating && theme === \"filled\",\n \"floating-underline\": floating && theme === \"underline\",\n \"floating-outline\": floating && theme === \"outline\",\n }),\n floating &&\n label({\n ...labelOptions,\n floating: true,\n floatingActive: true,\n }),\n cssUtils({ srOnly }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","getFormConfig","label","styles","legend","options","className","srOnly","floating","theme","labelOptions","floatingActive"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,KAAK,QAAQ,mBAAmB;AAGzC,MAAMC,SAASH,IAAI;AA+FnB;;CAEC,GACD,OAAO,SAASI,OAAOC,UAAkC,CAAC,CAAC;IACzD,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,QAAQR,cAAc,QAAQ,EAC9B,GAAGS,cACJ,GAAGL;IAEJ,OAAOP,IACLK,OAAO;QACLK;QACA,mBAAmBA,YAAYC,UAAU;QACzC,sBAAsBD,YAAYC,UAAU;QAC5C,oBAAoBD,YAAYC,UAAU;IAC5C,IACAD,YACEN,MAAM;QACJ,GAAGQ,YAAY;QACfF,UAAU;QACVG,gBAAgB;IAClB,IACFZ,SAAS;QAAEQ;IAAO,IAClBD;AAEJ"}
|
package/dist/form/selectUtils.js
CHANGED
|
@@ -38,8 +38,8 @@ import { Children, isValidElement } from "react";
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const { value, disabled, children } = child.props;
|
|
41
|
-
if (
|
|
42
|
-
if (value === currentValue || !currentOption &&
|
|
41
|
+
if (value !== undefined) {
|
|
42
|
+
if (value === currentValue || !currentOption && currentValue === undefined) {
|
|
43
43
|
currentOption = child.props;
|
|
44
44
|
}
|
|
45
45
|
if (!disabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/selectUtils.ts"],"sourcesContent":["import { Children, type ReactNode, isValidElement } from \"react\";\n\nimport { type MenuItemProps } from \"../menu/MenuItem.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface SelectOption<\n Value extends string | number = string,\n> extends MenuItemProps {\n value: Value;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nfunction getLabelFromChildren(children: ReactNode): string {\n if (!children) {\n return \"\";\n }\n\n if (typeof children === \"string\" || typeof children === \"number\") {\n return `${children}`;\n }\n\n if (isValidElement<{ children: ReactNode; hidden?: boolean }>(children)) {\n if (children.props.hidden) {\n return \"\";\n }\n\n return getLabelFromChildren(children.props.children);\n }\n\n const childList = Children.toArray(children);\n for (const child of childList) {\n if (typeof child === \"string\" || typeof child === \"number\") {\n return `${child}`[0].toUpperCase();\n }\n\n if (\n isValidElement<{ children: ReactNode; hidden?: boolean }>(child) &&\n !child.props.hidden\n ) {\n return getLabelFromChildren(child.props.children);\n }\n }\n\n return \"\";\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\ninterface ExtractedOptions<Value extends string | number> {\n options: readonly Value[];\n currentOption: SelectOption<Value> | undefined;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function extractOptionsFromChildren<Value extends string | number>(\n children: ReactNode,\n currentValue: Value | undefined\n): ExtractedOptions<Value> {\n let currentOption: SelectOption<Value> | undefined;\n\n const options: Value[] = [];\n const searchValues: string[] = [];\n Children.forEach(children, (child) => {\n if (!isValidElement<SelectOption<Value>>(child)) {\n return;\n }\n\n const { value, disabled, children } = child.props;\n if (
|
|
1
|
+
{"version":3,"sources":["../../src/form/selectUtils.ts"],"sourcesContent":["import { Children, type ReactNode, isValidElement } from \"react\";\n\nimport { type MenuItemProps } from \"../menu/MenuItem.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface SelectOption<\n Value extends string | number = string,\n> extends MenuItemProps {\n value: Value;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nfunction getLabelFromChildren(children: ReactNode): string {\n if (!children) {\n return \"\";\n }\n\n if (typeof children === \"string\" || typeof children === \"number\") {\n return `${children}`;\n }\n\n if (isValidElement<{ children: ReactNode; hidden?: boolean }>(children)) {\n if (children.props.hidden) {\n return \"\";\n }\n\n return getLabelFromChildren(children.props.children);\n }\n\n const childList = Children.toArray(children);\n for (const child of childList) {\n if (typeof child === \"string\" || typeof child === \"number\") {\n return `${child}`[0].toUpperCase();\n }\n\n if (\n isValidElement<{ children: ReactNode; hidden?: boolean }>(child) &&\n !child.props.hidden\n ) {\n return getLabelFromChildren(child.props.children);\n }\n }\n\n return \"\";\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\ninterface ExtractedOptions<Value extends string | number> {\n options: readonly Value[];\n currentOption: SelectOption<Value> | undefined;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function extractOptionsFromChildren<Value extends string | number>(\n children: ReactNode,\n currentValue: Value | undefined\n): ExtractedOptions<Value> {\n let currentOption: SelectOption<Value> | undefined;\n\n const options: Value[] = [];\n const searchValues: string[] = [];\n Children.forEach(children, (child) => {\n if (!isValidElement<SelectOption<Value>>(child)) {\n return;\n }\n\n const { value, disabled, children } = child.props;\n if (value !== undefined) {\n if (\n value === currentValue ||\n (!currentOption && currentValue === undefined)\n ) {\n currentOption = child.props;\n }\n\n if (!disabled) {\n options.push(child.props.value);\n searchValues.push(getLabelFromChildren(children));\n }\n } else if (children) {\n const result = extractOptionsFromChildren(children, currentValue);\n if (!currentOption) {\n ({ currentOption } = result);\n }\n\n options.push(...result.options);\n }\n });\n\n return {\n options,\n currentOption,\n };\n}\n"],"names":["Children","isValidElement","getLabelFromChildren","children","props","hidden","childList","toArray","child","toUpperCase","extractOptionsFromChildren","currentValue","currentOption","options","searchValues","forEach","value","disabled","undefined","push","result"],"mappings":"AAAA,SAASA,QAAQ,EAAkBC,cAAc,QAAQ,QAAQ;AAcjE;;;CAGC,GACD,SAASC,qBAAqBC,QAAmB;IAC/C,IAAI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,EAAE,GAAGQ,MAAK;YAC5B;YAEAP,QAAQM,IAAI,IAAIC,OAAOP,OAAO;QAChC;IACF;IAEA,OAAO;QACLA;QACAD;IACF;AACF"}
|
package/dist/form/useCombobox.js
CHANGED
|
@@ -145,6 +145,7 @@ const noop = ()=>{
|
|
|
145
145
|
// to really make sure the item is in view. An alternative would be to
|
|
146
146
|
// implement a custom scrollIntoView behavior again like the previous
|
|
147
147
|
// versions of react-md, but this is less lines of code
|
|
148
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
148
149
|
const attemptScroll = ()=>{
|
|
149
150
|
const activeOption = document.getElementById(activeDescendantId);
|
|
150
151
|
if (activeOption) {
|