@react-md/core 6.3.4 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CoreProviders.d.ts +1 -0
- package/dist/CoreProviders.js.map +1 -1
- package/dist/_base.scss +3 -0
- package/dist/_core.scss +1 -0
- package/dist/_utils.scss +15 -7
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/autocomplete/utils.js.map +1 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/button/FloatingActionButton.js.map +1 -1
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/datetime/NativeDateField.js.map +1 -1
- package/dist/datetime/NativeTimeField.js.map +1 -1
- package/dist/datetime/useDateField.js.map +1 -1
- package/dist/datetime/useTimeField.js.map +1 -1
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/DialogContainer.js.map +1 -1
- package/dist/dialog/DialogContent.js.map +1 -1
- package/dist/dialog/DialogFooter.js.map +1 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/files/useFileUpload.js.map +1 -1
- package/dist/files/validation.js.map +1 -1
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/form/Fieldset.d.ts +19 -0
- package/dist/form/Fieldset.js +22 -2
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Legend.d.ts +27 -5
- package/dist/form/Legend.js +39 -6
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/ListboxProvider.js.map +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
- package/dist/form/Select.js.map +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderThumb.js.map +1 -1
- package/dist/form/SliderTrack.js.map +1 -1
- package/dist/form/SliderValueMarks.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_fieldset.scss +7 -0
- package/dist/form/_legend.scss +68 -0
- package/dist/form/_text-field.scss +39 -4
- package/dist/form/fieldsetStyles.d.ts +6 -1
- package/dist/form/fieldsetStyles.js +3 -2
- package/dist/form/fieldsetStyles.js.map +1 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/labelStyles.d.ts +1 -1
- package/dist/form/labelStyles.js +1 -1
- package/dist/form/labelStyles.js.map +1 -1
- package/dist/form/legendStyles.d.ts +83 -0
- package/dist/form/legendStyles.js +25 -0
- package/dist/form/legendStyles.js.map +1 -0
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/types.d.ts +28 -6
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCheckboxGroup.js.map +1 -1
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useNumberField.js +16 -19
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/icon/FontIcon.js.map +1 -1
- package/dist/icon/IconRotator.js.map +1 -1
- package/dist/icon/MaterialIcon.js.map +1 -1
- package/dist/icon/MaterialSymbol.js.map +1 -1
- package/dist/icon/SVGIcon.js.map +1 -1
- package/dist/icon/config.d.ts +0 -1
- package/dist/icon/config.js +10 -7
- package/dist/icon/config.js.map +1 -1
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/icon/styles.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.js +6 -4
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/useElementInteraction.js.map +1 -1
- package/dist/layout/LayoutAppBar.d.ts +6 -6
- package/dist/layout/LayoutAppBar.js +6 -6
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/layout/LayoutNav.js.map +1 -1
- package/dist/layout/LayoutWindowSplitter.js.map +1 -1
- package/dist/layout/Main.js.map +1 -1
- package/dist/layout/useExpandableLayout.js +43 -0
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.js +19 -21
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/ListItemAddon.js.map +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/getListItemHeight.js.map +1 -1
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/types.js.map +1 -1
- package/dist/media-queries/AppSizeProvider.d.ts +2 -0
- package/dist/media-queries/AppSizeProvider.js +3 -2
- package/dist/media-queries/AppSizeProvider.js.map +1 -1
- package/dist/media-queries/appSize.d.ts +3 -0
- package/dist/media-queries/appSize.js +3 -1
- package/dist/media-queries/appSize.js.map +1 -1
- package/dist/media-queries/config.d.ts +11 -0
- package/dist/media-queries/config.js +26 -0
- package/dist/media-queries/config.js.map +1 -0
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemFileInput.js.map +1 -1
- package/dist/menu/MenuItemInputToggle.js.map +1 -1
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuVisibilityProvider.js.map +1 -1
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/movement/types.d.ts +28 -3
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.js +96 -47
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/NavItemButton.js.map +1 -1
- package/dist/navigation/NavItemLink.js.map +1 -1
- package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
- package/dist/navigation/types.js.map +1 -1
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/linearProgressStyles.js.map +1 -1
- package/dist/responsive-item/ResponsiveItem.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/spinbutton/SpinButton.d.ts +16 -0
- package/dist/spinbutton/SpinButton.js +55 -0
- package/dist/spinbutton/SpinButton.js.map +1 -0
- package/dist/spinbutton/SpinButtonGroupProvider.d.ts +17 -0
- package/dist/spinbutton/SpinButtonGroupProvider.js +19 -0
- package/dist/spinbutton/SpinButtonGroupProvider.js.map +1 -0
- package/dist/spinbutton/defaults.d.ts +9 -0
- package/dist/spinbutton/defaults.js +25 -0
- package/dist/spinbutton/defaults.js.map +1 -0
- package/dist/spinbutton/types.d.ts +324 -0
- package/dist/spinbutton/types.js +5 -0
- package/dist/spinbutton/types.js.map +1 -0
- package/dist/spinbutton/useSpinButton.d.ts +5 -0
- package/dist/spinbutton/useSpinButton.js +260 -0
- package/dist/spinbutton/useSpinButton.js.map +1 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.d.ts +27 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.js +49 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.js.map +1 -0
- package/dist/spinbutton/utils/deselectNode.d.ts +5 -0
- package/dist/spinbutton/utils/deselectNode.js +17 -0
- package/dist/spinbutton/utils/deselectNode.js.map +1 -0
- package/dist/spinbutton/utils/resolveInputEvent.d.ts +30 -0
- package/dist/spinbutton/utils/resolveInputEvent.js +53 -0
- package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -0
- package/dist/spinbutton/utils/selectNode.d.ts +5 -0
- package/dist/spinbutton/utils/selectNode.js +15 -0
- package/dist/spinbutton/utils/selectNode.js.map +1 -0
- package/dist/table/StickyTableSection.js.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCellContent.js.map +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableFooter.js.map +1 -1
- package/dist/table/TableHeader.js.map +1 -1
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/table/TableRow.js.map +1 -1
- package/dist/table/useStickyTableSection.js.map +1 -1
- package/dist/tabs/SimpleTabPanel.js.map +1 -1
- package/dist/tabs/SimpleTabPanels.js.map +1 -1
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/TabList.js.map +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
- package/dist/test-utils/data-testid.js.map +1 -1
- package/dist/test-utils/mocks/match-media.js +5 -5
- package/dist/test-utils/mocks/match-media.js.map +1 -1
- package/dist/test-utils/vitest/timers.d.ts +1 -1
- package/dist/test-utils/vitest/timers.js +1 -1
- package/dist/test-utils/vitest/timers.js.map +1 -1
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/transition/CSSTransition.js.map +1 -1
- package/dist/transition/Collapse.js.map +1 -1
- package/dist/transition/CrossFade.js.map +1 -1
- package/dist/transition/ScaleTransition.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/SlideContainer.js.map +1 -1
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCollapseTransition.js.map +1 -1
- package/dist/transition/useCrossFadeTransition.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useScaleTransition.js.map +1 -1
- package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/TreeProvider.js.map +1 -1
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/types.js.map +1 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/typography/HighlightTextMark.js.map +1 -1
- package/dist/typography/Mark.js.map +1 -1
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/_typography.scss +0 -1
- package/dist/useElementSize.js.map +1 -1
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useMutationObserver.js.map +1 -1
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/getNumberOfDigits.d.ts +7 -0
- package/dist/utils/getNumberOfDigits.js +11 -0
- package/dist/utils/getNumberOfDigits.js.map +1 -0
- package/dist/utils/nearest.js +2 -1
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/useDevEffect.d.ts +7 -0
- package/dist/utils/useDevEffect.js +8 -0
- package/dist/utils/useDevEffect.js.map +1 -0
- package/dist/window-splitter/WindowSplitter.js +3 -2
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/_window-splitter.scss +60 -12
- package/dist/window-splitter/styles.d.ts +9 -0
- package/dist/window-splitter/styles.js +3 -2
- package/dist/window-splitter/styles.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +37 -29
- package/src/CoreProviders.tsx +1 -0
- package/src/app-bar/AppBar.tsx +1 -2
- package/src/app-bar/AppBarTitle.tsx +1 -2
- package/src/autocomplete/AutocompleteListboxChildren.tsx +3 -1
- package/src/autocomplete/types.ts +24 -19
- package/src/autocomplete/utils.ts +9 -6
- package/src/avatar/Avatar.tsx +2 -1
- package/src/button/Button.tsx +2 -1
- package/src/button/FloatingActionButton.tsx +2 -1
- package/src/card/Card.tsx +2 -1
- package/src/card/CardContent.tsx +1 -2
- package/src/card/ClickableCard.tsx +1 -2
- package/src/chip/Chip.tsx +2 -1
- package/src/datetime/NativeDateField.tsx +2 -1
- package/src/datetime/NativeTimeField.tsx +2 -1
- package/src/datetime/useDateField.ts +13 -8
- package/src/datetime/useTimeField.ts +13 -8
- package/src/dialog/Dialog.tsx +2 -1
- package/src/dialog/DialogContainer.tsx +1 -2
- package/src/dialog/DialogContent.tsx +1 -2
- package/src/dialog/DialogFooter.tsx +1 -2
- package/src/divider/Divider.tsx +1 -2
- package/src/draggable/useDraggable.ts +4 -4
- package/src/draggable/utils.ts +4 -2
- package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -2
- package/src/files/FileInput.tsx +2 -1
- package/src/files/useFileUpload.ts +6 -6
- package/src/files/validation.ts +1 -2
- package/src/focus/useFocusContainer.ts +4 -4
- package/src/form/Fieldset.tsx +25 -3
- package/src/form/FormMessageContainer.tsx +1 -2
- package/src/form/FormMessageCounter.tsx +1 -2
- package/src/form/InputToggle.tsx +3 -3
- package/src/form/Legend.tsx +55 -10
- package/src/form/Listbox.tsx +1 -2
- package/src/form/ListboxProvider.ts +3 -2
- package/src/form/NativeSelect.tsx +2 -1
- package/src/form/Password.tsx +4 -2
- package/src/form/ResizingTextAreaWrapper.tsx +1 -2
- package/src/form/Select.tsx +2 -1
- package/src/form/Slider.tsx +2 -1
- package/src/form/SliderContainer.tsx +1 -2
- package/src/form/SliderThumb.tsx +6 -3
- package/src/form/SliderTrack.tsx +2 -1
- package/src/form/SliderValueMarks.tsx +1 -2
- package/src/form/Switch.tsx +2 -1
- package/src/form/TextArea.tsx +1 -2
- package/src/form/TextField.tsx +2 -1
- package/src/form/TextFieldContainer.tsx +1 -2
- package/src/form/fieldsetStyles.ts +18 -3
- package/src/form/inputToggleStyles.ts +4 -2
- package/src/form/labelStyles.ts +1 -1
- package/src/form/legendStyles.ts +132 -0
- package/src/form/selectUtils.ts +3 -2
- package/src/form/textFieldContainerStyles.ts +1 -2
- package/src/form/types.ts +35 -17
- package/src/form/useCheckboxGroup.ts +3 -2
- package/src/form/useCombobox.ts +8 -3
- package/src/form/useNumberField.ts +36 -35
- package/src/form/useRangeSlider.ts +1 -2
- package/src/form/useSlider.ts +1 -2
- package/src/form/useTextField.ts +8 -3
- package/src/hoverMode/useHoverMode.ts +4 -8
- package/src/icon/FontIcon.tsx +1 -2
- package/src/icon/IconRotator.tsx +1 -2
- package/src/icon/MaterialIcon.tsx +2 -1
- package/src/icon/MaterialSymbol.tsx +2 -1
- package/src/icon/SVGIcon.tsx +1 -2
- package/src/icon/config.tsx +10 -7
- package/src/icon/materialConfig.ts +1 -2
- package/src/icon/styles.ts +1 -2
- package/src/interaction/UserInteractionModeProvider.tsx +9 -4
- package/src/interaction/types.ts +1 -2
- package/src/interaction/useElementInteraction.tsx +3 -2
- package/src/layout/LayoutAppBar.tsx +6 -6
- package/src/layout/LayoutNav.tsx +2 -1
- package/src/layout/LayoutWindowSplitter.tsx +2 -1
- package/src/layout/Main.tsx +1 -2
- package/src/layout/useExpandableLayout.ts +63 -5
- package/src/layout/useHorizontalLayoutTransition.ts +1 -2
- package/src/layout/useLayoutTree.ts +2 -2
- package/src/layout/useLayoutWindowSplitter.ts +6 -6
- package/src/layout/useResizableLayout.ts +3 -6
- package/src/link/Link.tsx +1 -2
- package/src/link/SkipToMainContent.tsx +20 -23
- package/src/list/List.tsx +1 -2
- package/src/list/ListItem.tsx +2 -1
- package/src/list/ListItemAddon.tsx +2 -1
- package/src/list/ListItemLink.tsx +2 -1
- package/src/list/ListSubheader.tsx +1 -2
- package/src/list/getListItemHeight.ts +8 -9
- package/src/list/listItemStyles.ts +1 -2
- package/src/list/types.ts +1 -2
- package/src/media-queries/AppSizeProvider.tsx +8 -10
- package/src/media-queries/appSize.ts +3 -0
- package/src/media-queries/config.ts +41 -0
- package/src/menu/DropdownMenu.tsx +4 -5
- package/src/menu/Menu.tsx +2 -1
- package/src/menu/MenuItemButton.tsx +1 -2
- package/src/menu/MenuItemFileInput.tsx +2 -1
- package/src/menu/MenuItemInputToggle.tsx +3 -3
- package/src/menu/MenuItemSeparator.tsx +2 -1
- package/src/menu/MenuVisibilityProvider.tsx +4 -2
- package/src/menu/MenuWidget.tsx +1 -2
- package/src/menu/useContextMenu.ts +4 -2
- package/src/movement/types.ts +52 -13
- package/src/movement/useKeyboardMovementProvider.ts +77 -38
- package/src/navigation/CollapsibleNavGroup.tsx +1 -2
- package/src/navigation/NavItem.tsx +1 -2
- package/src/navigation/NavItemButton.tsx +2 -1
- package/src/navigation/NavItemLink.tsx +2 -1
- package/src/navigation/getTableOfContentsHeadings.ts +1 -2
- package/src/navigation/types.ts +1 -2
- package/src/overlay/Overlay.tsx +2 -1
- package/src/positioning/createHorizontalPosition.ts +10 -12
- package/src/positioning/createVerticalPosition.ts +10 -11
- package/src/positioning/useFixedPositioning.ts +6 -3
- package/src/progress/CircularProgress.tsx +2 -1
- package/src/progress/LinearProgress.tsx +2 -1
- package/src/progress/linearProgressStyles.ts +1 -2
- package/src/responsive-item/ResponsiveItem.tsx +1 -2
- package/src/responsive-item/ResponsiveItemOverlay.tsx +2 -1
- package/src/searching/caseInsensitive.ts +2 -4
- package/src/segmented-button/SegmentedButton.tsx +2 -1
- package/src/segmented-button/SegmentedButtonContainer.tsx +2 -1
- package/src/segmented-button/segmentedButtonStyles.ts +1 -2
- package/src/sheet/Sheet.tsx +1 -2
- package/src/snackbar/Toast.tsx +2 -1
- package/src/spinbutton/SpinButton.tsx +98 -0
- package/src/spinbutton/SpinButtonGroupProvider.tsx +32 -0
- package/src/spinbutton/defaults.ts +45 -0
- package/src/spinbutton/types.ts +413 -0
- package/src/spinbutton/useSpinButton.ts +311 -0
- package/src/spinbutton/useSpinButtonGroupProvider.ts +104 -0
- package/src/spinbutton/utils/deselectNode.ts +17 -0
- package/src/spinbutton/utils/resolveInputEvent.ts +112 -0
- package/src/spinbutton/utils/selectNode.ts +15 -0
- package/src/table/StickyTableSection.tsx +2 -1
- package/src/table/Table.tsx +1 -2
- package/src/table/TableBody.tsx +2 -1
- package/src/table/TableCellContent.tsx +1 -2
- package/src/table/TableCheckbox.tsx +1 -2
- package/src/table/TableFooter.tsx +1 -2
- package/src/table/TableHeader.tsx +1 -2
- package/src/table/TableRadio.tsx +1 -2
- package/src/table/TableRow.tsx +1 -2
- package/src/table/useStickyTableSection.tsx +1 -2
- package/src/tabs/SimpleTabPanel.tsx +2 -1
- package/src/tabs/SimpleTabPanels.tsx +2 -1
- package/src/tabs/Tab.tsx +3 -6
- package/src/tabs/TabList.tsx +2 -1
- package/src/tabs/TabListScrollButton.tsx +1 -2
- package/src/tabs/useMaxTabPanelHeight.ts +7 -4
- package/src/test-utils/data-testid.ts +1 -2
- package/src/test-utils/mocks/match-media.ts +5 -10
- package/src/test-utils/vitest/timers.ts +1 -1
- package/src/tooltip/Tooltip.tsx +2 -1
- package/src/tooltip/TooltipHoverModeProvider.tsx +1 -2
- package/src/tooltip/useTooltip.ts +9 -5
- package/src/transition/CSSTransition.tsx +2 -1
- package/src/transition/Collapse.tsx +4 -2
- package/src/transition/CrossFade.tsx +2 -1
- package/src/transition/ScaleTransition.tsx +2 -1
- package/src/transition/SkeletonPlaceholder.tsx +1 -2
- package/src/transition/Slide.tsx +2 -1
- package/src/transition/SlideContainer.tsx +1 -2
- package/src/transition/types.ts +15 -16
- package/src/transition/useCollapseTransition.ts +6 -5
- package/src/transition/useCrossFadeTransition.ts +3 -2
- package/src/transition/useMaxWidthTransition.ts +1 -2
- package/src/transition/useScaleTransition.ts +3 -2
- package/src/transition/useSkeletonPlaceholder.ts +1 -2
- package/src/tree/Tree.tsx +2 -1
- package/src/tree/TreeItem.tsx +2 -1
- package/src/tree/TreeProvider.tsx +4 -4
- package/src/tree/styles.ts +1 -2
- package/src/tree/types.ts +1 -2
- package/src/tree/useTreeMovement.ts +1 -2
- package/src/typography/HighlightTextMark.tsx +1 -2
- package/src/typography/Mark.tsx +1 -2
- package/src/typography/TextContainer.tsx +1 -2
- package/src/typography/Typography.tsx +1 -2
- package/src/useElementSize.ts +7 -4
- package/src/useIntersectionObserver.ts +3 -2
- package/src/useMutationObserver.ts +3 -2
- package/src/useWindowSize.ts +4 -2
- package/src/utils/getNumberOfDigits.ts +18 -0
- package/src/utils/nearest.ts +2 -1
- package/src/utils/useDevEffect.ts +9 -0
- package/src/window-splitter/WindowSplitter.tsx +5 -2
- package/src/window-splitter/styles.ts +13 -2
- package/src/window-splitter/useWindowSplitter.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/NativeSelect.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n type SelectHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { Label } from \"./Label.js\";\nimport { TextFieldContainer } from \"./TextFieldContainer.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { nativeSelect, nativeSelectContainer } from \"./nativeSelectStyles.js\";\nimport {\n type FormFieldOptions,\n type UserAgentAutocompleteProps,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0 Added support for {@link UserAgentAutocompleteProps}\n */\nexport interface NativeSelectProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/form/NativeSelect.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n type SelectHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { Label } from \"./Label.js\";\nimport { TextFieldContainer } from \"./TextFieldContainer.js\";\nimport { getFormConfig } from \"./formConfig.js\";\nimport { nativeSelect, nativeSelectContainer } from \"./nativeSelectStyles.js\";\nimport {\n type FormFieldOptions,\n type UserAgentAutocompleteProps,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0 Added support for {@link UserAgentAutocompleteProps}\n */\nexport interface NativeSelectProps\n extends\n Omit<SelectHTMLAttributes<HTMLSelectElement>, \"autoComplete\">,\n UserAgentAutocompleteProps,\n FormFieldOptions {\n /**\n * A custom dropdown icon to use instead of the browser's default select\n * dropdown icon.\n *\n * Set this to `null` if the browser's default icon should be used instead.\n *\n * @defaultValue `getIcon(\"dropdown\")`\n */\n icon?: ReactNode;\n\n /**\n * This applies custom inline styles to the `<select>` element since the\n * `style` prop is applied to the container element instead.\n */\n selectStyle?: CSSProperties;\n\n /**\n * This applies custom className to the `<select>` element since the\n * `className` prop is applied to the container element instead.\n */\n selectClassName?: string;\n\n /**\n * This should be a list of `<option>` elements for specific values within the\n * `<select>`.\n *\n * Check out the {@link NativeSelect} for examples around using \"placeholder\"\n * text and requiring a value to be selected.\n */\n children: ReactNode;\n\n /**\n * Optional props to provide to the {@link TextFieldContainer} component.\n * There probably isn't any real use for this prop other than if you need to\n * add a `ref` for some DOM behavior.\n */\n containerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n}\n\n/**\n * This component is a wrapper for the native `<select>` field that applies the\n * same theming as `TextField` and `TextArea` components. This component might\n * not be used much since the `Select` offers more styling options.\n *\n * @example Simple Example\n * ```tsx\n * <NativeSelect label=\"Label\">\n * <option value=\"a\">Value 1</option>\n * <option value=\"b\">Value 2</option>\n * <option value=\"c\">Value 3</option>\n * <option value=\"d\">Value 4</option>\n * </NativeSelect>\n * ```\n *\n * @example Required Value Example\n * ```tsx\n * function Example(): ReactElement {\n * // using `defaultValue=\"\"` makes it so the first option selected by default\n * // and considered an \"invalid\" value since it is `disabled`\n * //\n * // a `name` must be set with `required` so that the form validation will\n * // fire if the value is still the empty string when the form is submitted\n * //\n * // the first `<option>` is kind of like placeholder text since it doesn't\n * // have a value and is disabled by default\n *\n * return (\n * <NativeSelect\n * label=\"State\"\n * name=\"state\"\n * required\n * defaultValue=\"\"\n * >\n * <option value=\"\" disabled>Choose a state</option>\n * {states.map(({ name, code }) => (\n * <option key={code} value={code}>{name}</option>\n * ))}\n * </NativeSelect>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/native-select | NativeSelect Demos}\n */\nexport const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(\n function NativeSelect(props, ref) {\n const {\n id: propId,\n style,\n className,\n icon: propIcon,\n label,\n labelProps,\n labelStyle,\n labelClassName,\n selectStyle,\n selectClassName,\n autoCompleteValue,\n autoComplete = autoCompleteValue,\n name = autoCompleteValue,\n dense,\n error,\n active,\n inline,\n leftAddon,\n rightAddon: propRightAddon,\n leftAddonProps,\n rightAddonProps,\n disableLeftAddonStyles,\n disableRightAddonStyles,\n theme: propTheme,\n underlineDirection: propUnderlineDirection,\n messageProps,\n messageContainerProps,\n containerProps,\n children,\n ...remaining\n } = props;\n const { disabled, readOnly, multiple } = props;\n const id = useEnsuredId(propId, \"select\");\n const theme = getFormConfig(\"theme\", propTheme);\n const underlineDirection = getFormConfig(\n \"underlineDirection\",\n propUnderlineDirection\n );\n const icon = getIcon(\"dropdown\", propIcon);\n const underlined = theme === \"underline\" || theme === \"filled\";\n\n let rightAddon = propRightAddon;\n if (typeof propRightAddon === \"undefined\" && !multiple) {\n rightAddon = icon;\n }\n\n return (\n <FormMessageContainer\n inline={inline}\n {...messageContainerProps}\n messageProps={\n messageProps && {\n error,\n theme,\n ...messageProps,\n }\n }\n >\n <TextFieldContainer\n {...containerProps}\n style={style}\n className={nativeSelectContainer({\n label: !!label,\n multiple,\n underlined,\n className,\n })}\n theme={theme}\n label={!!label}\n error={error}\n dense={dense}\n inline={inline}\n active={active}\n readOnly={readOnly}\n disabled={disabled}\n leftAddon={leftAddon}\n leftAddonProps={leftAddonProps}\n rightAddon={rightAddon}\n rightAddonProps={rightAddonProps}\n underlineDirection={underlineDirection}\n disableLeftAddonStyles={disableLeftAddonStyles}\n disableRightAddonStyles={disableRightAddonStyles}\n >\n <select\n {...remaining}\n id={id}\n ref={ref}\n autoComplete={autoComplete}\n name={name}\n disabled={disabled}\n style={selectStyle}\n className={nativeSelect({\n icon: !!icon,\n className: selectClassName,\n })}\n >\n {children}\n </select>\n {label && (\n <Label\n {...labelProps}\n htmlFor={id}\n style={labelProps?.style ?? labelStyle}\n className={labelProps?.className ?? labelClassName}\n floating\n dense={dense}\n error={error}\n active={active}\n disabled={disabled}\n >\n {label}\n </Label>\n )}\n </TextFieldContainer>\n </FormMessageContainer>\n );\n }\n);\n"],"names":["forwardRef","getIcon","useEnsuredId","FormMessageContainer","Label","TextFieldContainer","getFormConfig","nativeSelect","nativeSelectContainer","NativeSelect","props","ref","id","propId","style","className","icon","propIcon","label","labelProps","labelStyle","labelClassName","selectStyle","selectClassName","autoCompleteValue","autoComplete","name","dense","error","active","inline","leftAddon","rightAddon","propRightAddon","leftAddonProps","rightAddonProps","disableLeftAddonStyles","disableRightAddonStyles","theme","propTheme","underlineDirection","propUnderlineDirection","messageProps","messageContainerProps","containerProps","children","remaining","disabled","readOnly","multiple","underlined","select","htmlFor","floating"],"mappings":";AAAA,SAKEA,UAAU,QACL,QAAQ;AAEf,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,YAAY,EAAEC,qBAAqB,QAAQ,0BAA0B;AAqD9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CC,GACD,OAAO,MAAMC,6BAAeT,WAC1B,SAASS,aAAaC,KAAK,EAAEC,GAAG;IAC9B,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,SAAS,EACTC,MAAMC,QAAQ,EACdC,KAAK,EACLC,UAAU,EACVC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,eAAe,EACfC,iBAAiB,EACjBC,eAAeD,iBAAiB,EAChCE,OAAOF,iBAAiB,EACxBG,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,YAAYC,cAAc,EAC1BC,cAAc,EACdC,eAAe,EACfC,sBAAsB,EACtBC,uBAAuB,EACvBC,OAAOC,SAAS,EAChBC,oBAAoBC,sBAAsB,EAC1CC,YAAY,EACZC,qBAAqB,EACrBC,cAAc,EACdC,QAAQ,EACR,GAAGC,WACJ,GAAGpC;IACJ,MAAM,EAAEqC,QAAQ,EAAEC,QAAQ,EAAE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-
{"version":3,"sources":["../../src/form/Password.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, forwardRef } from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { TextField, type TextFieldProps } from \"./TextField.js\";\nimport {\n password,\n passwordInput,\n passwordInputToggle,\n} from \"./passwordStyles.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * const getVisibilityIcon: GetPasswordVisibilityIcon = (isPasswordVisible) => {\n * if (isPasswordVisible) {\n * return <SecurityIcon />;\n * }\n *\n * return <RemoveRedEyeIcon />;\n * };\n * ```\n *\n * @param isPasswordVisible - `true` when the password is visible and in plain\n * text\n * @returns a custom icon to use for the password visibility toggle.\n */\nexport type GetPasswordVisibilityIcon = (\n isPasswordVisible: boolean\n) => ReactNode;\n\n/**\n * @example Simple Example\n * ```tsx\n * const visibilityIcon: ConfigurableVisibilityIcon = {\n * visible: <SecurityIcon />,\n * invisible: <RemoveRedEyeIcon />,\n * };\n * ```\n */\nexport interface ConfigurableVisibilityIcon {\n /**\n * The icon to display while the password is currently visible as plain text.\n */\n visible: ReactNode;\n\n /**\n * The icon to display while the password is currently invisible as the\n * password input.\n */\n invisible: ReactNode;\n}\n\n/**\n * @since 6.0.0 Removed the `visibilityStyle`, `visibilityClassName`, and\n * `onVisibilityClick` props in favor of `visibilityProps` object.\n * @since 6.0.0 Removed the `disableVisibility` and `rightChildren` props in\n * favor of just using a `TextField` instead of the `Password` component.\n * @since 6.0.0 Merged the `getVisibilityIcon` prop behavior into the\n * `visibilityIcon` prop.\n */\nexport interface PasswordProps
|
|
1
|
+
{"version":3,"sources":["../../src/form/Password.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, forwardRef } from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { TextField, type TextFieldProps } from \"./TextField.js\";\nimport {\n password,\n passwordInput,\n passwordInputToggle,\n} from \"./passwordStyles.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * const getVisibilityIcon: GetPasswordVisibilityIcon = (isPasswordVisible) => {\n * if (isPasswordVisible) {\n * return <SecurityIcon />;\n * }\n *\n * return <RemoveRedEyeIcon />;\n * };\n * ```\n *\n * @param isPasswordVisible - `true` when the password is visible and in plain\n * text\n * @returns a custom icon to use for the password visibility toggle.\n */\nexport type GetPasswordVisibilityIcon = (\n isPasswordVisible: boolean\n) => ReactNode;\n\n/**\n * @example Simple Example\n * ```tsx\n * const visibilityIcon: ConfigurableVisibilityIcon = {\n * visible: <SecurityIcon />,\n * invisible: <RemoveRedEyeIcon />,\n * };\n * ```\n */\nexport interface ConfigurableVisibilityIcon {\n /**\n * The icon to display while the password is currently visible as plain text.\n */\n visible: ReactNode;\n\n /**\n * The icon to display while the password is currently invisible as the\n * password input.\n */\n invisible: ReactNode;\n}\n\n/**\n * @since 6.0.0 Removed the `visibilityStyle`, `visibilityClassName`, and\n * `onVisibilityClick` props in favor of `visibilityProps` object.\n * @since 6.0.0 Removed the `disableVisibility` and `rightChildren` props in\n * favor of just using a `TextField` instead of the `Password` component.\n * @since 6.0.0 Merged the `getVisibilityIcon` prop behavior into the\n * `visibilityIcon` prop.\n */\nexport interface PasswordProps extends Omit<\n TextFieldProps,\n \"type\" | \"rightAddon\"\n> {\n /**\n * @defaultValue `\"password\"`\n * @since 6.0.0 Defaults to `\"password\"`\n */\n name?: string;\n\n /**\n * @example Configurable Visibility Icon Object\n * ```tsx\n * <Password\n * {...props}\n * visibilityIcon={{\n * visible: <SecurityIcon />,\n * invisible: <RemoveRedEyeIcon />,\n * }}\n * />\n * ```\n *\n * @example Get Password Visibility Icon Function\n * ```tsx\n * <Password\n * {...props}\n * visibilityIcon={(isPasswordVisible) => {\n * if (isPasswordVisible) {\n * return <SecurityIcon />;\n * }\n *\n * return <RemoveRedEyeIcon />;\n * }}\n * />\n * ```\n *\n * @example Custom Icon\n * ```tsx\n * <Password\n * {...props}\n * visibilityIcon={<SomeCustomComponent />}\n * />\n * ```\n *\n * @since 6.0.0 Supports dynamically getting the visibility icon with a\n * callback function.\n */\n visibilityIcon?:\n | ConfigurableVisibilityIcon\n | GetPasswordVisibilityIcon\n | ReactNode;\n\n /**\n * The `aria-label` to use for the password visibility icon button.\n *\n * @defaultValue `\"Show password\"`\n */\n visibilityLabel?: string;\n\n /**\n * Any props that should be passed to the password visibility icon button. If\n * `id`, `buttonType`, `aria-label`, `aria-pressed`, or `children` are\n * provided here, they will override the default implementation.\n */\n visibilityProps?: PropsWithRef<ButtonProps>;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Password } from \"@react-md/core/form/Password\";\n *\n * function Example(): ReactElement {\n * return <Password label=\"Password\" required />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/password | Password Demos}\n */\nexport const Password = forwardRef<HTMLInputElement, PasswordProps>(\n function Password(props, ref) {\n const {\n id: propId,\n name = \"password\",\n className,\n inputClassName,\n visibilityIcon: propVisibilityIcon,\n visibilityLabel = \"Show password\",\n visibilityProps,\n ...remaining\n } = props;\n const { toggled: isPasswordVisible, toggle } = useToggle(false);\n\n let currentVisibilityIcon: ReactNode;\n if (\n propVisibilityIcon &&\n typeof propVisibilityIcon === \"object\" &&\n \"visible\" in propVisibilityIcon\n ) {\n currentVisibilityIcon = isPasswordVisible\n ? propVisibilityIcon.visible\n : propVisibilityIcon.invisible;\n } else if (typeof propVisibilityIcon === \"function\") {\n currentVisibilityIcon = propVisibilityIcon(isPasswordVisible);\n } else {\n currentVisibilityIcon = propVisibilityIcon;\n }\n\n const id = useEnsuredId(propId, \"password\");\n const visibilityIcon = getIcon(\"password\", currentVisibilityIcon);\n\n return (\n <TextField\n {...remaining}\n ref={ref}\n name={name}\n type={isPasswordVisible ? \"text\" : \"password\"}\n className={password({ className })}\n inputClassName={passwordInput({ className: inputClassName })}\n rightAddon={\n <Button\n id={`${id}-toggle`}\n buttonType=\"icon\"\n aria-label={visibilityLabel}\n aria-pressed={isPasswordVisible}\n // allow all props except the onClick, className, and aria-pressed to\n // be overridden. onClick can only stop default behavior with\n // `event.stopPropagation()`\n {...visibilityProps}\n className={passwordInputToggle({\n className: visibilityProps?.className,\n })}\n onClick={(event) => {\n visibilityProps?.onClick?.(event);\n if (event.isPropagationStopped()) {\n return;\n }\n\n toggle();\n }}\n >\n {visibilityProps?.children ?? visibilityIcon}\n </Button>\n }\n disableRightAddonStyles\n />\n );\n }\n);\n"],"names":["forwardRef","Button","getIcon","useEnsuredId","useToggle","TextField","password","passwordInput","passwordInputToggle","Password","props","ref","id","propId","name","className","inputClassName","visibilityIcon","propVisibilityIcon","visibilityLabel","visibilityProps","remaining","toggled","isPasswordVisible","toggle","currentVisibilityIcon","visible","invisible","type","rightAddon","buttonType","aria-label","aria-pressed","onClick","event","isPropagationStopped","children","disableRightAddonStyles"],"mappings":"AAAA;;AAEA,SAAyBA,UAAU,QAAQ,QAAQ;AAEnD,SAASC,MAAM,QAA0B,sBAAsB;AAC/D,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAA6B,iBAAiB;AAChE,SACEC,QAAQ,EACRC,aAAa,EACbC,mBAAmB,QACd,sBAAsB;AAuH7B;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,yBAAWT,WACtB,SAASS,SAASC,KAAK,EAAEC,GAAG;IAC1B,MAAM,EACJC,IAAIC,MAAM,EACVC,OAAO,UAAU,EACjBC,SAAS,EACTC,cAAc,EACdC,gBAAgBC,kBAAkB,EAClCC,kBAAkB,eAAe,EACjCC,eAAe,EACf,GAAGC,WACJ,GAAGX;IACJ,MAAM,EAAEY,SAASC,iBAAiB,EAAEC,MAAM,EAAE,GAAGpB,UAAU;IAEzD,IAAIqB;IACJ,IACEP,sBACA,OAAOA,uBAAuB,YAC9B,aAAaA,oBACb;QACAO,wBAAwBF,oBACpBL,mBAAmBQ,OAAO,GAC1BR,mBAAmBS,SAAS;IAClC,OAAO,IAAI,OAAOT,uBAAuB,YAAY;QACnDO,wBAAwBP,mBAAmBK;IAC7C,OAAO;QACLE,wBAAwBP;IAC1B;IAEA,MAAMN,KAAKT,aAAaU,QAAQ;IAChC,MAAMI,iBAAiBf,QAAQ,YAAYuB;IAE3C,qBACE,KAACpB;QACE,GAAGgB,SAAS;QACbV,KAAKA;QACLG,MAAMA;QACNc,MAAML,oBAAoB,SAAS;QACnCR,WAAWT,SAAS;YAAES;QAAU;QAChCC,gBAAgBT,cAAc;YAAEQ,WAAWC;QAAe;QAC1Da,0BACE,KAAC5B;YACCW,IAAI,GAAGA,GAAG,OAAO,CAAC;YAClBkB,YAAW;YACXC,cAAYZ;YACZa,gBAAcT;YAIb,GAAGH,eAAe;YACnBL,WAAWP,oBAAoB;gBAC7BO,WAAWK,iBAAiBL;YAC9B;YACAkB,SAAS,CAACC;gBACRd,iBAAiBa,UAAUC;gBAC3B,IAAIA,MAAMC,oBAAoB,IAAI;oBAChC;gBACF;gBAEAX;YACF;sBAECJ,iBAAiBgB,YAAYnB;;QAGlCoB,uBAAuB;;AAG7B,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/ResizingTextAreaWrapper.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type Ref,\n type TextareaHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { textArea } from \"./textAreaStyles.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ResizingTextAreaWrapperProps
|
|
1
|
+
{"version":3,"sources":["../../src/form/ResizingTextAreaWrapper.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type Ref,\n type TextareaHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { textArea } from \"./textAreaStyles.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ResizingTextAreaWrapperProps extends HTMLAttributes<HTMLDivElement> {\n maskId: string;\n maskRef: Ref<HTMLTextAreaElement>;\n defaultValue?: TextareaHTMLAttributes<HTMLTextAreaElement>[\"defaultValue\"];\n rows: number;\n areaStyle?: CSSProperties;\n areaClassName?: string;\n disableTransition?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const ResizingTextAreaWrapper = forwardRef<\n HTMLDivElement,\n ResizingTextAreaWrapperProps\n>(function ResizingTextAreaWrapper(props, ref) {\n const {\n className,\n rows,\n maskId,\n maskRef,\n areaStyle,\n areaClassName,\n defaultValue,\n disableTransition,\n children,\n ...remaining\n } = props;\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={cnb(\n \"rmd-textarea-container__inner\",\n !disableTransition && \"rmd-textarea-container__inner--animate\",\n className\n )}\n >\n {children}\n <textarea\n aria-hidden\n id={maskId}\n ref={maskRef}\n defaultValue={defaultValue}\n readOnly\n tabIndex={-1}\n rows={rows}\n style={areaStyle}\n className={textArea({\n mask: true,\n resize: \"auto\",\n className: areaClassName,\n })}\n />\n </div>\n );\n});\n"],"names":["cnb","forwardRef","textArea","ResizingTextAreaWrapper","props","ref","className","rows","maskId","maskRef","areaStyle","areaClassName","defaultValue","disableTransition","children","remaining","div","textarea","aria-hidden","id","readOnly","tabIndex","style","mask","resize"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UAAU,QACL,QAAQ;AAEf,SAASC,QAAQ,QAAQ,sBAAsB;AAgB/C;;;CAGC,GACD,OAAO,MAAMC,wCAA0BF,WAGrC,SAASE,wBAAwBC,KAAK,EAAEC,GAAG;IAC3C,MAAM,EACJC,SAAS,EACTC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,QAAQ,EACR,GAAGC,WACJ,GAAGX;IAEJ,qBACE,MAACY;QACE,GAAGD,SAAS;QACbV,KAAKA;QACLC,WAAWN,IACT,iCACA,CAACa,qBAAqB,0CACtBP;;YAGDQ;0BACD,KAACG;gBACCC,aAAW;gBACXC,IAAIX;gBACJH,KAAKI;gBACLG,cAAcA;gBACdQ,QAAQ;gBACRC,UAAU,CAAC;gBACXd,MAAMA;gBACNe,OAAOZ;gBACPJ,WAAWJ,SAAS;oBAClBqB,MAAM;oBACNC,QAAQ;oBACRlB,WAAWK;gBACb;;;;AAIR,GAAG"}
|
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 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,SA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AECjB;;;;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 { 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,sBAAs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EpBC;;;;AAIT"}
|
package/dist/form/Slider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/Slider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useRef,\n} from \"react\";\n\nimport { type TooltipProps } from \"../tooltip/Tooltip.js\";\nimport {\n type LabelRequiredForA11y,\n type PropsWithRef,\n type UseStateSetter,\n} from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { type SliderAddonProps, SliderContainer } from \"./SliderContainer.js\";\nimport {\n type ConfigurableSliderThumbProps,\n SliderThumb,\n type SliderThumbPresentation,\n type SliderThumbProps,\n} from \"./SliderThumb.js\";\nimport { SliderTrack } from \"./SliderTrack.js\";\nimport {\n type SliderMarksOptions,\n SliderValueMarks,\n} from \"./SliderValueMarks.js\";\nimport { getJumpValue, getSliderInputName } from \"./sliderUtils.js\";\nimport { type RangeSliderState } from \"./useRangeSlider.js\";\nimport { type SliderState, type SliderValueOptions } from \"./useSlider.js\";\nimport { useSliderDraggable } from \"./useSliderDraggable.js\";\n\n// NOTE: The augmentation appears in this file since no type definitions are\n// ever imported from the `sliderStyles` file.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-slider-color\"?: string;\n \"--rmd-slider-active-color\"?: string;\n \"--rmd-slider-inactive-color\"?: string;\n \"--rmd-slider-size\"?: string | number;\n \"--rmd-slider-active-size\"?: string | number;\n \"--rmd-slider-inactive-size\"?: string | number;\n \"--rmd-slider-vertical-size\"?: string | number;\n \"--rmd-slider-offset-1\"?: string;\n \"--rmd-slider-offset-2\"?: string;\n \"--rmd-slider-tooltip-scale\"?: string | number;\n \"--rmd-slider-tooltip-translate\"?: string | number;\n \"--rmd-slider-mark-offset\"?: string;\n \"--rmd-slider-mark-active-color\"?: string;\n \"--rmd-slider-mark-active-opacity\"?: string | number;\n \"--rmd-slider-mark-inactive-color\"?: string;\n \"--rmd-slider-mark-inactive-opacity\"?: string | number;\n }\n}\n\nconst emptyString = (): string => \"\";\nconst noop = (): undefined => {\n // do nothing\n};\n\n/**\n * @since 2.5.0\n */\nexport interface BaseSliderProps\n extends HTMLAttributes<HTMLDivElement>,\n SliderThumbPresentation,\n SliderValueOptions,\n SliderAddonProps,\n SliderMarksOptions {\n /**\n * This can be used to apply a ref to the container element since this\n * component does not use `forwardRef`.\n */\n containerRef?: Ref<HTMLDivElement>;\n\n /**\n * The amount to jump the slider's value when the `PageUp` or `PageDown`\n * key is pressed.\n *\n * The default value is 1/10th of the range.\n *\n * @defaultValue `(numberOfSteps / 10) * step`\n */\n jump?: number;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /** @defaultValue `false` */\n vertical?: boolean;\n\n /**\n * This can be used to apply custom styles or a `ref` to the track element if\n * needed.\n */\n trackProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This can be used to configure any additional tooltip props like the\n * CSS transition `classNames`, styles, etc.\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * Note: The `position` will always be `\"above\"` for horizontal sliders and\n * `\"left\"` for vertical sliders.\n */\n tooltipProps?: Omit<Partial<TooltipProps>, \"position\">;\n}\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Only requires `value` and `setValue` props instead of all the\n * slider controls.\n * @since 6.0.0 The `thumbLabel` and `thumbLabelledBy` props were removed. Use\n * the `aria-label` or `aria-labelledby` props instead.\n * @since 6.0.0 The `baseId` prop was removed in favor of `id` or `*Props.id`\n */\nexport interface SliderProps extends BaseSliderProps, SliderState {\n /**\n * Convenience pass-through prop to {@link ConfigurableSliderThumbProps.name} which\n * will be applied to the hidden `<input type=\"range\" />`\n */\n name?: string;\n\n /**\n * Any additional props that should be provided to the thumb element. This can\n * be useful for applying additional styling.\n */\n thumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * This can be used to update the discrete slider's tooltip props.\n *\n * @example Custom Styles\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipProps={(value) => ({\n * className: cssUtils({\n * backgroundColor: value < 30 ? \"warning\" : undefined,\n * }),\n * })}\n * />\n * ```\n */\n getTooltipProps?: (value: number) => Partial<TooltipProps> | undefined;\n\n /**\n * This can be used to update the discrete slider's value tooltip.\n *\n * @example More Value Information\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipChildren={(value) => (\n * <TextIconSpacing icon={<FavoriteIcon />}>\n * {value}\n * </TextIconSpacing>\n * )}\n * />\n * ```\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * @defaultValue `(value) => value`\n */\n getTooltipChildren?: (value: number) => ReactNode;\n}\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Only requires `rangeValue` and `setRangeValue` props instead of\n * all the slider controls.\n * @since 6.0.0 The `thumb1Label`, `thumb1LabelledBy`, `thumb1Props`,\n * `thumb2Label`, `thumb2LabelledBy` and `thumb2Props` were renamed to\n * `minThumbLabel`, `minThumbLabelledBy`, `minThumbProps`, `maxThumbLabel`,\n * `maxThumbLabelledBy`, and `maxThumbProps` respectively.\n */\nexport interface RangeSliderProps extends BaseSliderProps, RangeSliderState {\n /**\n * Convenience pass-through prop for {@link\n * ConfigurableSliderThumbProps.name} for both the {@link minThumbProps} and\n * {@link maxThumbProps}.\n */\n name?: string;\n\n /**\n * Any additional props that should be provided to the min value thumb\n * element. This can be useful for applying additional styling.\n */\n minThumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * Any additional props that should be provided to the max value thumb\n * element. This can be useful for applying additional styling.\n */\n maxThumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * The `aria-label` to apply to the min value.\n *\n * Note: Either this prop or the {@link minThumbLabelledBy} are required for\n * accessibility.\n *\n * @defaultValue `\"Min\"`\n */\n minThumbLabel?: string;\n\n /**\n * Set this to an element's id that labels the min value.\n *\n * Note: Either this prop or the {@link minThumbLabel} are required for\n * accessibility.\n */\n minThumbLabelledBy?: string;\n\n /**\n * The `aria-label` to apply to the max value.\n *\n * Note: Either this prop or the {@link maxThumbLabelledBy} are required for\n * accessibility.\n *\n * @defaultValue `\"Max\"`\n */\n maxThumbLabel?: string;\n\n /**\n * Set this to an element's id that labels the max value.\n *\n * Note: Either this prop or the {@link maxThumbLabel} are required for\n * accessibility.\n */\n maxThumbLabelledBy?: string;\n\n /**\n * This can be used to update the discrete slider's tooltip props.\n *\n * @example Custom Styles\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipProps={(value, isFirstThumb) => ({\n * className: cssUtils({\n * backgroundColor: value < 30 && isFirstThumb ? \"warning\" : undefined,\n * }),\n * })}\n * />\n * ```\n */\n getTooltipProps?: (\n value: number,\n isFirstThumb: boolean\n ) => Partial<TooltipProps>;\n\n /**\n * This can be used to update the discrete slider's value tooltip.\n *\n * @example More Value Information\n * ```tsx\n * <Slider\n * {...rangeSlider}\n * discrete\n * getTooltipChildren={(value, isFirstThumb) => (\n * <TextIconSpacing\n * icon={isFirstThumb ? <FavoriteIcon /> : <CloseIcon /}\n * iconAfter={!isFirstValue}\n * >\n * {value}\n * </TextIconSpacing>\n * )}\n * />\n * ```\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * @defaultValue `(value) => value`\n */\n getTooltipChildren?: (value: number, isFirstThumb: boolean) => ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Form } from \"@react-md/core/form/Form\";\n * import { Slider } from \"@react-md/core/form/Slider\";\n * import { useSlider } from \"@react-md/core/form/useSlider\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const slider = useSlider({\n * // these are the defaults and can be changed\n * min: 0,\n * max: 100,\n * step: 1,\n * defaultValue: 50,\n * });\n *\n * // if you need access to the current value or manually change the value\n * // yourself.\n * const { value, setValue } = slider;\n *\n * return (\n * <Form>\n * <Slider {...slider} aria-label=\"Volume\" />\n * </Form>\n * );\n * }\n * ```\n *\n * @example Range Slider Example\n * ```tsx\n * import { Fieldset } from \"@react-md/core/form/Fieldset\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { Legend } from \"@react-md/core/form/Legend\";\n * import { Slider } from \"@react-md/core/form/Slider\";\n * import { useRangeSlider } from \"@react-md/core/form/useRangeSlider\";\n * import type { ReactElement } from \"react\";\n * import { useId } from \"react\";\n *\n * function Example(): ReactElement {\n * const slider = useRangeSlider({\n * // these are the defaults and can be changed\n * min: 0,\n * max: 100,\n * step: 1,\n * defaultValue: [0, 100],\n * });\n *\n * // if you need access to the current value or manually change the value\n * // yourself.\n * const { rangeValue, setRangeValue } = slider;\n * const [minPrice, maxPrice] = rangeValue;\n *\n * return (\n * <Form>\n * <Fieldset>\n * <Legend>Price Range</Legend>\n * <Slider {...slider} />\n * </Fieldset>\n * </Form>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/slider | Slider Demos}\n * @since 2.5.0\n * @since 6.0.0 The `Slider` and `RangeSlider` have been combined into the\n * single `Slider` component and removed the `label` support.\n * @since 6.0.0 Each thumb includes an invisible `<input type=\"range\">` instead\n * of an `<input type=\"hidden\">`.\n */\nexport function Slider(props: LabelRequiredForA11y<SliderProps>): ReactElement;\nexport function Slider(props: RangeSliderProps): ReactElement;\nexport function Slider(\n props: LabelRequiredForA11y<SliderProps> | RangeSliderProps\n): ReactElement {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n id: propId,\n name,\n min = 0,\n max = 100,\n step = 1,\n jump: propJump,\n vertical = false,\n discrete = false,\n disabled = false,\n getValueText = emptyString,\n children,\n marks = false,\n value,\n setValue,\n rangeValue,\n setRangeValue,\n trackProps,\n thumbProps,\n minThumbProps,\n minThumbLabel,\n minThumbLabelledBy,\n maxThumbProps,\n maxThumbLabel,\n maxThumbLabelledBy,\n tooltipProps,\n containerRef,\n getMarkProps = noop,\n getMarkLabelProps = noop,\n tooltipVisibility = \"auto\",\n getTooltipProps = noop,\n getTooltipChildren = identity,\n disableSmoothDragging = !!marks,\n ...remaining\n } = props as SliderProps & RangeSliderProps;\n\n const jump = getJumpValue({ min, max, step, jump: propJump });\n const isRangeSlider = typeof value !== \"number\";\n\n const thumb1Id = useEnsuredId(propId, \"slider\");\n const thumb2Id = `${thumb1Id}-2`;\n const thumb1Ref = useRef<HTMLSpanElement>(null);\n const thumb2Ref = useRef<HTMLSpanElement>(null);\n const { thumb1Name, thumb2Name } = getSliderInputName(name, isRangeSlider);\n\n let thumb1Max = max;\n let thumb2Min = min;\n let thumb1Label: string | undefined;\n let thumb1LabelledBy: string | undefined;\n let thumb2Label: string | undefined;\n let thumb2LabelledBy: string | undefined;\n let thumb1Value: number;\n let thumb2Value: number;\n let setThumb1Value: UseStateSetter<number>;\n let setThumb2Value: UseStateSetter<number>;\n if (!isRangeSlider) {\n thumb1Value = value;\n setThumb1Value = setValue;\n thumb2Value = max;\n setThumb2Value = noop;\n thumb1Label = ariaLabel;\n thumb1LabelledBy = ariaLabelledBy;\n } else {\n thumb1LabelledBy = minThumbLabelledBy;\n thumb1Label = minThumbLabel || (minThumbLabelledBy ? undefined : \"Min\");\n thumb2LabelledBy = maxThumbLabelledBy;\n thumb2Label = maxThumbLabel || (maxThumbLabelledBy ? undefined : \"Max\");\n\n [thumb1Value, thumb2Value] = rangeValue;\n\n thumb1Max = thumb2Value - step;\n thumb2Min = thumb1Value + step;\n\n setThumb1Value = (valueOrSetter) => {\n setRangeValue((prevRangeValue) => {\n const value =\n typeof valueOrSetter === \"number\"\n ? valueOrSetter\n : valueOrSetter(prevRangeValue[0]);\n\n return [value, prevRangeValue[1]];\n });\n };\n setThumb2Value = (valueOrSetter) => {\n setRangeValue((prevRangeValue) => {\n const value =\n typeof valueOrSetter === \"number\"\n ? valueOrSetter\n : valueOrSetter(prevRangeValue[1]);\n\n return [prevRangeValue[0], value];\n });\n };\n }\n\n const {\n onKeyDown: thumb1OnKeyDown,\n onMouseUp: thumb1OnMouseUp,\n onMouseDown: thumb1OnMouseDown,\n onMouseMove: thumb1OnMouseMove,\n onTouchStart: thumb1OnTouchStart,\n onTouchMove: thumb1OnTouchMove,\n dragPercentage: thumb1DragPercentage,\n draggableRef: thumb1DraggableRef,\n dragging: thumb1Dragging,\n } = useSliderDraggable({\n jump,\n ref: thumb1Ref,\n min,\n max: thumb1Max,\n rangeMax: max,\n step,\n value: thumb1Value,\n setValue: setThumb1Value,\n disabled,\n vertical,\n });\n\n const {\n onKeyDown: thumb2OnKeyDown,\n onMouseUp: thumb2OnMouseUp,\n onMouseDown: thumb2OnMouseDown,\n onMouseMove: thumb2OnMouseMove,\n onTouchStart: thumb2OnTouchStart,\n onTouchMove: thumb2OnTouchMove,\n dragPercentage: thumb2DragPercentage,\n draggableRef: thumb2DraggableRef,\n dragging: thumb2Dragging,\n } = useSliderDraggable({\n jump,\n ref: thumb2Ref,\n min: thumb2Min,\n max,\n rangeMin: min,\n step,\n value: thumb2Value,\n setValue: setThumb2Value,\n vertical,\n disabled,\n });\n\n const dragging = thumb1Dragging || thumb2Dragging;\n const sharedThumbProps = {\n step,\n animate: !dragging,\n discrete,\n disabled,\n vertical,\n getValueText,\n tooltipProps,\n getTooltipProps,\n getTooltipChildren,\n tooltipVisibility,\n disableSmoothDragging,\n } as const satisfies Partial<SliderThumbProps>;\n\n return (\n <SliderContainer {...remaining} ref={containerRef} vertical={vertical}>\n <SliderTrack\n {...trackProps}\n min={min}\n max={max}\n thumb1Ref={thumb1Ref}\n thumb1Value={thumb1Value}\n thumb1Dragging={!disableSmoothDragging && thumb1Dragging}\n thumb1DragPercentage={thumb1DragPercentage}\n thumb1OnMouseUp={thumb1OnMouseUp}\n thumb1OnMouseDown={thumb1OnMouseDown}\n thumb1OnMouseMove={thumb1OnMouseMove}\n thumb1OnTouchStart={thumb1OnTouchStart}\n thumb1OnTouchMove={thumb1OnTouchMove}\n thumb2Ref={thumb2Ref}\n thumb2Value={thumb2Value}\n thumb2Dragging={!disableSmoothDragging && thumb2Dragging}\n thumb2DragPercentage={thumb2DragPercentage}\n thumb2OnMouseUp={thumb2OnMouseUp}\n thumb2OnMouseDown={thumb2OnMouseDown}\n thumb2OnMouseMove={thumb2OnMouseMove}\n thumb2OnTouchStart={thumb2OnTouchStart}\n thumb2OnTouchMove={thumb2OnTouchMove}\n animate={!disableSmoothDragging && !dragging}\n disabled={disabled}\n vertical={vertical}\n isRangeSlider={isRangeSlider}\n >\n <SliderThumb\n aria-label={thumb1Label as string}\n aria-labelledby={thumb1LabelledBy}\n id={thumb1Id}\n name={thumb1Name}\n {...thumbProps}\n {...minThumbProps}\n {...sharedThumbProps}\n ref={thumb1DraggableRef}\n min={min}\n max={thumb1Max}\n value={thumb1Value}\n index={1}\n active={thumb1Dragging}\n onChange={(event) => {\n setThumb1Value(event.currentTarget.valueAsNumber);\n }}\n onKeyDown={thumb1OnKeyDown}\n />\n {isRangeSlider && (\n <SliderThumb\n aria-label={thumb2Label as string}\n aria-labelledby={thumb2LabelledBy}\n id={thumb2Id}\n name={thumb2Name}\n {...maxThumbProps}\n {...sharedThumbProps}\n ref={thumb2DraggableRef}\n min={thumb2Min}\n max={max}\n value={thumb2Value}\n index={2}\n active={thumb2Dragging}\n onChange={(event) => {\n setThumb2Value(event.currentTarget.valueAsNumber);\n }}\n onKeyDown={thumb2OnKeyDown}\n />\n )}\n {marks && (\n <SliderValueMarks\n min={min}\n max={max}\n step={step}\n marks={marks}\n vertical={vertical}\n thumb1Value={thumb1Value}\n thumb2Value={thumb2Value}\n isRangeSlider={isRangeSlider}\n getMarkProps={getMarkProps}\n getMarkLabelProps={getMarkLabelProps}\n />\n )}\n {children}\n </SliderTrack>\n </SliderContainer>\n );\n}\n"],"names":["useRef","useEnsuredId","identity","SliderContainer","SliderThumb","SliderTrack","SliderValueMarks","getJumpValue","getSliderInputName","useSliderDraggable","emptyString","noop","Slider","props","ariaLabel","ariaLabelledBy","id","propId","name","min","max","step","jump","propJump","vertical","discrete","disabled","getValueText","children","marks","value","setValue","rangeValue","setRangeValue","trackProps","thumbProps","minThumbProps","minThumbLabel","minThumbLabelledBy","maxThumbProps","maxThumbLabel","maxThumbLabelledBy","tooltipProps","containerRef","getMarkProps","getMarkLabelProps","tooltipVisibility","getTooltipProps","getTooltipChildren","disableSmoothDragging","remaining","isRangeSlider","thumb1Id","thumb2Id","thumb1Ref","thumb2Ref","thumb1Name","thumb2Name","thumb1Max","thumb2Min","thumb1Label","thumb1LabelledBy","thumb2Label","thumb2LabelledBy","thumb1Value","thumb2Value","setThumb1Value","setThumb2Value","undefined","valueOrSetter","prevRangeValue","onKeyDown","thumb1OnKeyDown","onMouseUp","thumb1OnMouseUp","onMouseDown","thumb1OnMouseDown","onMouseMove","thumb1OnMouseMove","onTouchStart","thumb1OnTouchStart","onTouchMove","thumb1OnTouchMove","dragPercentage","thumb1DragPercentage","draggableRef","thumb1DraggableRef","dragging","thumb1Dragging","ref","rangeMax","thumb2OnKeyDown","thumb2OnMouseUp","thumb2OnMouseDown","thumb2OnMouseMove","thumb2OnTouchStart","thumb2OnTouchMove","thumb2DragPercentage","thumb2DraggableRef","thumb2Dragging","rangeMin","sharedThumbProps","animate","aria-label","aria-labelledby","index","active","onChange","event","currentTarget","valueAsNumber"],"mappings":"AAAA;;AAEA,SAKEA,MAAM,QACD,QAAQ;AAQf,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAAgCC,eAAe,QAAQ,uBAAuB;AAC9E,SAEEC,WAAW,QAGN,mBAAmB;AAC1B,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAEEC,gBAAgB,QACX,wBAAwB;AAC/B,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,mBAAmB;AAGpE,SAASC,kBAAkB,QAAQ,0BAA0B;AAyB7D,MAAMC,cAAc,IAAc;AAClC,MAAMC,OAAO;AACX,aAAa;AACf;AA4SA,OAAO,SAASC,OACdC,KAA2D;IAE3D,MAAM,EACJ,cAAcC,SAAS,EACvB,mBAAmBC,cAAc,EACjCC,IAAIC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,KAAKS;oBACL/E,KAAKwC;oBACLvC,KAAKA;oBACLU,OAAOmC;oBACPwC,OAAO;oBACPC,QAAQP;oBACRQ,UAAU,CAACC;wBACTzC,eAAeyC,MAAMC,aAAa,CAACC,aAAa;oBAClD;oBACAvC,WAAWoB;;gBAGd9D,uBACC,KAACvB;oBACCa,KAAKA;oBACLC,KAAKA;oBACLC,MAAMA;oBACNQ,OAAOA;oBACPL,UAAUA;oBACVwC,aAAaA;oBACbC,aAAaA;oBACbd,eAAeA;oBACfP,cAAcA;oBACdC,mBAAmBA;;gBAGtBjB;;;;AAIT"}
|
|
1
|
+
{"version":3,"sources":["../../src/form/Slider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useRef,\n} from \"react\";\n\nimport { type TooltipProps } from \"../tooltip/Tooltip.js\";\nimport {\n type LabelRequiredForA11y,\n type PropsWithRef,\n type UseStateSetter,\n} from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { type SliderAddonProps, SliderContainer } from \"./SliderContainer.js\";\nimport {\n type ConfigurableSliderThumbProps,\n SliderThumb,\n type SliderThumbPresentation,\n type SliderThumbProps,\n} from \"./SliderThumb.js\";\nimport { SliderTrack } from \"./SliderTrack.js\";\nimport {\n type SliderMarksOptions,\n SliderValueMarks,\n} from \"./SliderValueMarks.js\";\nimport { getJumpValue, getSliderInputName } from \"./sliderUtils.js\";\nimport { type RangeSliderState } from \"./useRangeSlider.js\";\nimport { type SliderState, type SliderValueOptions } from \"./useSlider.js\";\nimport { useSliderDraggable } from \"./useSliderDraggable.js\";\n\n// NOTE: The augmentation appears in this file since no type definitions are\n// ever imported from the `sliderStyles` file.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-slider-color\"?: string;\n \"--rmd-slider-active-color\"?: string;\n \"--rmd-slider-inactive-color\"?: string;\n \"--rmd-slider-size\"?: string | number;\n \"--rmd-slider-active-size\"?: string | number;\n \"--rmd-slider-inactive-size\"?: string | number;\n \"--rmd-slider-vertical-size\"?: string | number;\n \"--rmd-slider-offset-1\"?: string;\n \"--rmd-slider-offset-2\"?: string;\n \"--rmd-slider-tooltip-scale\"?: string | number;\n \"--rmd-slider-tooltip-translate\"?: string | number;\n \"--rmd-slider-mark-offset\"?: string;\n \"--rmd-slider-mark-active-color\"?: string;\n \"--rmd-slider-mark-active-opacity\"?: string | number;\n \"--rmd-slider-mark-inactive-color\"?: string;\n \"--rmd-slider-mark-inactive-opacity\"?: string | number;\n }\n}\n\nconst emptyString = (): string => \"\";\nconst noop = (): undefined => {\n // do nothing\n};\n\n/**\n * @since 2.5.0\n */\nexport interface BaseSliderProps\n extends\n HTMLAttributes<HTMLDivElement>,\n SliderThumbPresentation,\n SliderValueOptions,\n SliderAddonProps,\n SliderMarksOptions {\n /**\n * This can be used to apply a ref to the container element since this\n * component does not use `forwardRef`.\n */\n containerRef?: Ref<HTMLDivElement>;\n\n /**\n * The amount to jump the slider's value when the `PageUp` or `PageDown`\n * key is pressed.\n *\n * The default value is 1/10th of the range.\n *\n * @defaultValue `(numberOfSteps / 10) * step`\n */\n jump?: number;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /** @defaultValue `false` */\n vertical?: boolean;\n\n /**\n * This can be used to apply custom styles or a `ref` to the track element if\n * needed.\n */\n trackProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This can be used to configure any additional tooltip props like the\n * CSS transition `classNames`, styles, etc.\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * Note: The `position` will always be `\"above\"` for horizontal sliders and\n * `\"left\"` for vertical sliders.\n */\n tooltipProps?: Omit<Partial<TooltipProps>, \"position\">;\n}\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Only requires `value` and `setValue` props instead of all the\n * slider controls.\n * @since 6.0.0 The `thumbLabel` and `thumbLabelledBy` props were removed. Use\n * the `aria-label` or `aria-labelledby` props instead.\n * @since 6.0.0 The `baseId` prop was removed in favor of `id` or `*Props.id`\n */\nexport interface SliderProps extends BaseSliderProps, SliderState {\n /**\n * Convenience pass-through prop to {@link ConfigurableSliderThumbProps.name} which\n * will be applied to the hidden `<input type=\"range\" />`\n */\n name?: string;\n\n /**\n * Any additional props that should be provided to the thumb element. This can\n * be useful for applying additional styling.\n */\n thumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * This can be used to update the discrete slider's tooltip props.\n *\n * @example Custom Styles\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipProps={(value) => ({\n * className: cssUtils({\n * backgroundColor: value < 30 ? \"warning\" : undefined,\n * }),\n * })}\n * />\n * ```\n */\n getTooltipProps?: (value: number) => Partial<TooltipProps> | undefined;\n\n /**\n * This can be used to update the discrete slider's value tooltip.\n *\n * @example More Value Information\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipChildren={(value) => (\n * <TextIconSpacing icon={<FavoriteIcon />}>\n * {value}\n * </TextIconSpacing>\n * )}\n * />\n * ```\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * @defaultValue `(value) => value`\n */\n getTooltipChildren?: (value: number) => ReactNode;\n}\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Only requires `rangeValue` and `setRangeValue` props instead of\n * all the slider controls.\n * @since 6.0.0 The `thumb1Label`, `thumb1LabelledBy`, `thumb1Props`,\n * `thumb2Label`, `thumb2LabelledBy` and `thumb2Props` were renamed to\n * `minThumbLabel`, `minThumbLabelledBy`, `minThumbProps`, `maxThumbLabel`,\n * `maxThumbLabelledBy`, and `maxThumbProps` respectively.\n */\nexport interface RangeSliderProps extends BaseSliderProps, RangeSliderState {\n /**\n * Convenience pass-through prop for {@link\n * ConfigurableSliderThumbProps.name} for both the {@link minThumbProps} and\n * {@link maxThumbProps}.\n */\n name?: string;\n\n /**\n * Any additional props that should be provided to the min value thumb\n * element. This can be useful for applying additional styling.\n */\n minThumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * Any additional props that should be provided to the max value thumb\n * element. This can be useful for applying additional styling.\n */\n maxThumbProps?: ConfigurableSliderThumbProps;\n\n /**\n * The `aria-label` to apply to the min value.\n *\n * Note: Either this prop or the {@link minThumbLabelledBy} are required for\n * accessibility.\n *\n * @defaultValue `\"Min\"`\n */\n minThumbLabel?: string;\n\n /**\n * Set this to an element's id that labels the min value.\n *\n * Note: Either this prop or the {@link minThumbLabel} are required for\n * accessibility.\n */\n minThumbLabelledBy?: string;\n\n /**\n * The `aria-label` to apply to the max value.\n *\n * Note: Either this prop or the {@link maxThumbLabelledBy} are required for\n * accessibility.\n *\n * @defaultValue `\"Max\"`\n */\n maxThumbLabel?: string;\n\n /**\n * Set this to an element's id that labels the max value.\n *\n * Note: Either this prop or the {@link maxThumbLabel} are required for\n * accessibility.\n */\n maxThumbLabelledBy?: string;\n\n /**\n * This can be used to update the discrete slider's tooltip props.\n *\n * @example Custom Styles\n * ```tsx\n * <Slider\n * {...slider}\n * discrete\n * getTooltipProps={(value, isFirstThumb) => ({\n * className: cssUtils({\n * backgroundColor: value < 30 && isFirstThumb ? \"warning\" : undefined,\n * }),\n * })}\n * />\n * ```\n */\n getTooltipProps?: (\n value: number,\n isFirstThumb: boolean\n ) => Partial<TooltipProps>;\n\n /**\n * This can be used to update the discrete slider's value tooltip.\n *\n * @example More Value Information\n * ```tsx\n * <Slider\n * {...rangeSlider}\n * discrete\n * getTooltipChildren={(value, isFirstThumb) => (\n * <TextIconSpacing\n * icon={isFirstThumb ? <FavoriteIcon /> : <CloseIcon /}\n * iconAfter={!isFirstValue}\n * >\n * {value}\n * </TextIconSpacing>\n * )}\n * />\n * ```\n *\n * This will only be used when {@link discrete} is `true`.\n *\n * @defaultValue `(value) => value`\n */\n getTooltipChildren?: (value: number, isFirstThumb: boolean) => ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Form } from \"@react-md/core/form/Form\";\n * import { Slider } from \"@react-md/core/form/Slider\";\n * import { useSlider } from \"@react-md/core/form/useSlider\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const slider = useSlider({\n * // these are the defaults and can be changed\n * min: 0,\n * max: 100,\n * step: 1,\n * defaultValue: 50,\n * });\n *\n * // if you need access to the current value or manually change the value\n * // yourself.\n * const { value, setValue } = slider;\n *\n * return (\n * <Form>\n * <Slider {...slider} aria-label=\"Volume\" />\n * </Form>\n * );\n * }\n * ```\n *\n * @example Range Slider Example\n * ```tsx\n * import { Fieldset } from \"@react-md/core/form/Fieldset\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { Legend } from \"@react-md/core/form/Legend\";\n * import { Slider } from \"@react-md/core/form/Slider\";\n * import { useRangeSlider } from \"@react-md/core/form/useRangeSlider\";\n * import type { ReactElement } from \"react\";\n * import { useId } from \"react\";\n *\n * function Example(): ReactElement {\n * const slider = useRangeSlider({\n * // these are the defaults and can be changed\n * min: 0,\n * max: 100,\n * step: 1,\n * defaultValue: [0, 100],\n * });\n *\n * // if you need access to the current value or manually change the value\n * // yourself.\n * const { rangeValue, setRangeValue } = slider;\n * const [minPrice, maxPrice] = rangeValue;\n *\n * return (\n * <Form>\n * <Fieldset>\n * <Legend>Price Range</Legend>\n * <Slider {...slider} />\n * </Fieldset>\n * </Form>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/slider | Slider Demos}\n * @since 2.5.0\n * @since 6.0.0 The `Slider` and `RangeSlider` have been combined into the\n * single `Slider` component and removed the `label` support.\n * @since 6.0.0 Each thumb includes an invisible `<input type=\"range\">` instead\n * of an `<input type=\"hidden\">`.\n */\nexport function Slider(props: LabelRequiredForA11y<SliderProps>): ReactElement;\nexport function Slider(props: RangeSliderProps): ReactElement;\nexport function Slider(\n props: LabelRequiredForA11y<SliderProps> | RangeSliderProps\n): ReactElement {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n id: propId,\n name,\n min = 0,\n max = 100,\n step = 1,\n jump: propJump,\n vertical = false,\n discrete = false,\n disabled = false,\n getValueText = emptyString,\n children,\n marks = false,\n value,\n setValue,\n rangeValue,\n setRangeValue,\n trackProps,\n thumbProps,\n minThumbProps,\n minThumbLabel,\n minThumbLabelledBy,\n maxThumbProps,\n maxThumbLabel,\n maxThumbLabelledBy,\n tooltipProps,\n containerRef,\n getMarkProps = noop,\n getMarkLabelProps = noop,\n tooltipVisibility = \"auto\",\n getTooltipProps = noop,\n getTooltipChildren = identity,\n disableSmoothDragging = !!marks,\n ...remaining\n } = props as SliderProps & RangeSliderProps;\n\n const jump = getJumpValue({ min, max, step, jump: propJump });\n const isRangeSlider = typeof value !== \"number\";\n\n const thumb1Id = useEnsuredId(propId, \"slider\");\n const thumb2Id = `${thumb1Id}-2`;\n const thumb1Ref = useRef<HTMLSpanElement>(null);\n const thumb2Ref = useRef<HTMLSpanElement>(null);\n const { thumb1Name, thumb2Name } = getSliderInputName(name, isRangeSlider);\n\n let thumb1Max = max;\n let thumb2Min = min;\n let thumb1Label: string | undefined;\n let thumb1LabelledBy: string | undefined;\n let thumb2Label: string | undefined;\n let thumb2LabelledBy: string | undefined;\n let thumb1Value: number;\n let thumb2Value: number;\n let setThumb1Value: UseStateSetter<number>;\n let setThumb2Value: UseStateSetter<number>;\n if (!isRangeSlider) {\n thumb1Value = value;\n setThumb1Value = setValue;\n thumb2Value = max;\n setThumb2Value = noop;\n thumb1Label = ariaLabel;\n thumb1LabelledBy = ariaLabelledBy;\n } else {\n thumb1LabelledBy = minThumbLabelledBy;\n thumb1Label = minThumbLabel || (minThumbLabelledBy ? undefined : \"Min\");\n thumb2LabelledBy = maxThumbLabelledBy;\n thumb2Label = maxThumbLabel || (maxThumbLabelledBy ? undefined : \"Max\");\n\n [thumb1Value, thumb2Value] = rangeValue;\n\n thumb1Max = thumb2Value - step;\n thumb2Min = thumb1Value + step;\n\n setThumb1Value = (valueOrSetter) => {\n setRangeValue((prevRangeValue) => {\n const value =\n typeof valueOrSetter === \"number\"\n ? valueOrSetter\n : valueOrSetter(prevRangeValue[0]);\n\n return [value, prevRangeValue[1]];\n });\n };\n setThumb2Value = (valueOrSetter) => {\n setRangeValue((prevRangeValue) => {\n const value =\n typeof valueOrSetter === \"number\"\n ? valueOrSetter\n : valueOrSetter(prevRangeValue[1]);\n\n return [prevRangeValue[0], value];\n });\n };\n }\n\n const {\n onKeyDown: thumb1OnKeyDown,\n onMouseUp: thumb1OnMouseUp,\n onMouseDown: thumb1OnMouseDown,\n onMouseMove: thumb1OnMouseMove,\n onTouchStart: thumb1OnTouchStart,\n onTouchMove: thumb1OnTouchMove,\n dragPercentage: thumb1DragPercentage,\n draggableRef: thumb1DraggableRef,\n dragging: thumb1Dragging,\n } = useSliderDraggable({\n jump,\n ref: thumb1Ref,\n min,\n max: thumb1Max,\n rangeMax: max,\n step,\n value: thumb1Value,\n setValue: setThumb1Value,\n disabled,\n vertical,\n });\n\n const {\n onKeyDown: thumb2OnKeyDown,\n onMouseUp: thumb2OnMouseUp,\n onMouseDown: thumb2OnMouseDown,\n onMouseMove: thumb2OnMouseMove,\n onTouchStart: thumb2OnTouchStart,\n onTouchMove: thumb2OnTouchMove,\n dragPercentage: thumb2DragPercentage,\n draggableRef: thumb2DraggableRef,\n dragging: thumb2Dragging,\n } = useSliderDraggable({\n jump,\n ref: thumb2Ref,\n min: thumb2Min,\n max,\n rangeMin: min,\n step,\n value: thumb2Value,\n setValue: setThumb2Value,\n vertical,\n disabled,\n });\n\n const dragging = thumb1Dragging || thumb2Dragging;\n const sharedThumbProps = {\n step,\n animate: !dragging,\n discrete,\n disabled,\n vertical,\n getValueText,\n tooltipProps,\n getTooltipProps,\n getTooltipChildren,\n tooltipVisibility,\n disableSmoothDragging,\n } as const satisfies Partial<SliderThumbProps>;\n\n return (\n <SliderContainer {...remaining} ref={containerRef} vertical={vertical}>\n <SliderTrack\n {...trackProps}\n min={min}\n max={max}\n thumb1Ref={thumb1Ref}\n thumb1Value={thumb1Value}\n thumb1Dragging={!disableSmoothDragging && thumb1Dragging}\n thumb1DragPercentage={thumb1DragPercentage}\n thumb1OnMouseUp={thumb1OnMouseUp}\n thumb1OnMouseDown={thumb1OnMouseDown}\n thumb1OnMouseMove={thumb1OnMouseMove}\n thumb1OnTouchStart={thumb1OnTouchStart}\n thumb1OnTouchMove={thumb1OnTouchMove}\n thumb2Ref={thumb2Ref}\n thumb2Value={thumb2Value}\n thumb2Dragging={!disableSmoothDragging && thumb2Dragging}\n thumb2DragPercentage={thumb2DragPercentage}\n thumb2OnMouseUp={thumb2OnMouseUp}\n thumb2OnMouseDown={thumb2OnMouseDown}\n thumb2OnMouseMove={thumb2OnMouseMove}\n thumb2OnTouchStart={thumb2OnTouchStart}\n thumb2OnTouchMove={thumb2OnTouchMove}\n animate={!disableSmoothDragging && !dragging}\n disabled={disabled}\n vertical={vertical}\n isRangeSlider={isRangeSlider}\n >\n <SliderThumb\n aria-label={thumb1Label as string}\n aria-labelledby={thumb1LabelledBy}\n id={thumb1Id}\n name={thumb1Name}\n {...thumbProps}\n {...minThumbProps}\n {...sharedThumbProps}\n ref={thumb1DraggableRef}\n min={min}\n max={thumb1Max}\n value={thumb1Value}\n index={1}\n active={thumb1Dragging}\n onChange={(event) => {\n setThumb1Value(event.currentTarget.valueAsNumber);\n }}\n onKeyDown={thumb1OnKeyDown}\n />\n {isRangeSlider && (\n <SliderThumb\n aria-label={thumb2Label as string}\n aria-labelledby={thumb2LabelledBy}\n id={thumb2Id}\n name={thumb2Name}\n {...maxThumbProps}\n {...sharedThumbProps}\n ref={thumb2DraggableRef}\n min={thumb2Min}\n max={max}\n value={thumb2Value}\n index={2}\n active={thumb2Dragging}\n onChange={(event) => {\n setThumb2Value(event.currentTarget.valueAsNumber);\n }}\n onKeyDown={thumb2OnKeyDown}\n />\n )}\n {marks && (\n <SliderValueMarks\n min={min}\n max={max}\n step={step}\n marks={marks}\n vertical={vertical}\n thumb1Value={thumb1Value}\n thumb2Value={thumb2Value}\n isRangeSlider={isRangeSlider}\n getMarkProps={getMarkProps}\n getMarkLabelProps={getMarkLabelProps}\n />\n )}\n {children}\n </SliderTrack>\n </SliderContainer>\n );\n}\n"],"names":["useRef","useEnsuredId","identity","SliderContainer","SliderThumb","SliderTrack","SliderValueMarks","getJumpValue","getSliderInputName","useSliderDraggable","emptyString","noop","Slider","props","ariaLabel","ariaLabelledBy","id","propId","name","min","max","step","jump","propJump","vertical","discrete","disabled","getValueText","children","marks","value","setValue","rangeValue","setRangeValue","trackProps","thumbProps","minThumbProps","minThumbLabel","minThumbLabelledBy","maxThumbProps","maxThumbLabel","maxThumbLabelledBy","tooltipProps","containerRef","getMarkProps","getMarkLabelProps","tooltipVisibility","getTooltipProps","getTooltipChildren","disableSmoothDragging","remaining","isRangeSlider","thumb1Id","thumb2Id","thumb1Ref","thumb2Ref","thumb1Name","thumb2Name","thumb1Max","thumb2Min","thumb1Label","thumb1LabelledBy","thumb2Label","thumb2LabelledBy","thumb1Value","thumb2Value","setThumb1Value","setThumb2Value","undefined","valueOrSetter","prevRangeValue","onKeyDown","thumb1OnKeyDown","onMouseUp","thumb1OnMouseUp","onMouseDown","thumb1OnMouseDown","onMouseMove","thumb1OnMouseMove","onTouchStart","thumb1OnTouchStart","onTouchMove","thumb1OnTouchMove","dragPercentage","thumb1DragPercentage","draggableRef","thumb1DraggableRef","dragging","thumb1Dragging","ref","rangeMax","thumb2OnKeyDown","thumb2OnMouseUp","thumb2OnMouseDown","thumb2OnMouseMove","thumb2OnTouchStart","thumb2OnTouchMove","thumb2DragPercentage","thumb2DraggableRef","thumb2Dragging","rangeMin","sharedThumbProps","animate","aria-label","aria-labelledby","index","active","onChange","event","currentTarget","valueAsNumber"],"mappings":"AAAA;;AAEA,SAKEA,MAAM,QACD,QAAQ;AAQf,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAAgCC,eAAe,QAAQ,uBAAuB;AAC9E,SAEEC,WAAW,QAGN,mBAAmB;AAC1B,SAASC,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nE,KAAKA;oBACLC,KAAKsC;oBACL5B,OAAOkC;oBACPyC,OAAO;oBACPC,QAAQlB;oBACRmB,UAAU,CAACC;wBACT1C,eAAe0C,MAAMC,aAAa,CAACC,aAAa;oBAClD;oBACAvC,WAAWC;;gBAEZrB,+BACC,KAAC/C;oBACCmG,cAAYzC;oBACZ0C,mBAAiBzC;oBACjB/C,IAAIqC;oBACJnC,MAAMuC;oBACL,GAAGlB,aAAa;oBAChB,GAAG8D,gBAAgB;oBACpBZ,KAAKS;oBACL/E,KAAKwC;oBACLvC,KAAKA;oBACLU,OAAOmC;oBACPwC,OAAO;oBACPC,QAAQP;oBACRQ,UAAU,CAACC;wBACTzC,eAAeyC,MAAMC,aAAa,CAACC,aAAa;oBAClD;oBACAvC,WAAWoB;;gBAGd9D,uBACC,KAACvB;oBACCa,KAAKA;oBACLC,KAAKA;oBACLC,MAAMA;oBACNQ,OAAOA;oBACPL,UAAUA;oBACVwC,aAAaA;oBACbC,aAAaA;oBACbd,eAAeA;oBACfP,cAAcA;oBACdC,mBAAmBA;;gBAGtBjB;;;;AAIT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/SliderContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { sliderContainer } from \"./sliderStyles.js\";\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Renamed from `SliderAddons` to `SliderContainerAddonProps`\n */\nexport interface SliderAddonProps {\n /**\n * An optional addon to render before the slider's track. This can be anything\n * and will be wrapped in the `TextIconSpacing` component.\n *\n * When the `vertical` prop is enabled, the addon will appear underneath the\n * track.\n */\n beforeAddon?: ReactNode;\n\n /**\n * An optional addon to render after the slider's track. This can be anything\n * and will be wrapped in the `TextIconSpacing` component.\n *\n * When the `vertical` prop is enabled, the addon will appear above the track.\n */\n afterAddon?: ReactNode;\n}\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Removed the `label` support since you'll generally want to use\n * a `Fieldset` instead.\n */\nexport interface SliderContainerProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/form/SliderContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { sliderContainer } from \"./sliderStyles.js\";\n\n/**\n * @since 2.5.0\n * @since 6.0.0 Renamed from `SliderAddons` to `SliderContainerAddonProps`\n */\nexport interface SliderAddonProps {\n /**\n * An optional addon to render before the slider's track. This can be anything\n * and will be wrapped in the `TextIconSpacing` component.\n *\n * When the `vertical` prop is enabled, the addon will appear underneath the\n * track.\n */\n beforeAddon?: ReactNode;\n\n /**\n * An optional addon to render after the slider's track. This can be anything\n * and will be wrapped in the `TextIconSpacing` component.\n *\n * When the `vertical` prop is enabled, the addon will appear above the track.\n */\n afterAddon?: ReactNode;\n}\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Removed the `label` support since you'll generally want to use\n * a `Fieldset` instead.\n */\nexport interface SliderContainerProps\n extends HTMLAttributes<HTMLDivElement>, SliderAddonProps {\n vertical: boolean;\n}\n\n/**\n * The `SliderContainer` component is mostly an internal component that is\n * built-in to the `Slider` and `RangeSlider` components to add addons to the\n * left or right of the `SliderTrack`. When vertical, it will add addons to the\n * bottom or top instead.\n *\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Removed the `label` support since you'll generally want to use\n * a `Fieldset` instead.\n */\nexport const SliderContainer = forwardRef<HTMLDivElement, SliderContainerProps>(\n function SliderContainer(props, ref) {\n const {\n className,\n children,\n beforeAddon,\n afterAddon,\n vertical,\n ...remaining\n } = props;\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={sliderContainer({\n className,\n vertical,\n beforeAddon: !!beforeAddon,\n afterAddon: !!afterAddon,\n })}\n >\n {beforeAddon}\n {children}\n {afterAddon}\n </div>\n );\n }\n);\n"],"names":["forwardRef","sliderContainer","SliderContainer","props","ref","className","children","beforeAddon","afterAddon","vertical","remaining","div"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAASC,eAAe,QAAQ,oBAAoB;AAoCpD;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,gCAAkBF,WAC7B,SAASE,gBAAgBC,KAAK,EAAEC,GAAG;IACjC,MAAM,EACJC,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,QAAQ,EACR,GAAGC,WACJ,GAAGP;IAEJ,qBACE,MAACQ;QACE,GAAGD,SAAS;QACbN,KAAKA;QACLC,WAAWJ,gBAAgB;YACzBI;YACAI;YACAF,aAAa,CAAC,CAACA;YACfC,YAAY,CAAC,CAACA;QAChB;;YAECD;YACAD;YACAE;;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/SliderThumb.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ChangeEventHandler,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n useEffect,\n useState,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { type TooltipProps } from \"../tooltip/Tooltip.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { SliderValueTooltip } from \"./SliderValueTooltip.js\";\nimport { sliderThumb, sliderThumbInput } from \"./sliderStyles.js\";\nimport { type SliderValueOptions } from \"./useSlider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type SliderTooltipVisibility = \"auto\" | \"hover\" | \"always\";\n\n/**\n * @since 2.5.0\n */\nexport interface SliderThumbPresentation {\n /**\n * Boolean if the slider should act as a discrete slider which will render a\n * tooltip above the thumb while dragging to visualize the current value for\n * the slider.\n *\n * @defaultValue `false`\n */\n discrete?: boolean;\n\n /**\n * A function that is used to help with accessibility by creating a better\n * value string if just a number isn't representative enough of your range.\n *\n * Example:\n *\n * ```tsx\n * const [value, controls] = useSlider(0, {\n * // format to be `$100`, etc\n * getValueText: value => `$${value}`,\n * });\n *\n * return <Slider baseId=\"price-slider\" label=\"Price\" {...controls} />;\n * ```\n *\n * @defaultValue `() => \"\"`\n */\n getValueText?: (value: number) => string;\n\n /**\n * Set this to `true` if the slider's thumb position should only update when\n * the user has dragged to the next value instead of with the mouse.\n *\n * @see {@link marks}\n * @defaultValue `!!marks`\n */\n disableSmoothDragging?: boolean;\n\n /**\n * The discrete slider's value tooltip will only become visible when:\n *\n * - `\"auto\"` - the user is dragging with touch/mouse or focused with a keyboard\n * - `\"hover\"` - the behavior of `\"auto\"` plus while hovering the thumb with a mouse\n * - `\"always\"` - ... always\n *\n * This only applies when the {@link discrete} prop is `true`.\n *\n * @defaultValue `\"auto\"`\n */\n tooltipVisibility?: SliderTooltipVisibility;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableSliderThumbProps\n extends Omit<HTMLAttributes<HTMLSpanElement>, \"onChange\"> {\n name?: string;\n}\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Internal only component.\n */\nexport interface SliderThumbProps\n extends ConfigurableSliderThumbProps,\n Required<SliderValueOptions>,\n Required<SliderThumbPresentation> {\n id: string;\n value: number;\n index: 1 | 2;\n active: boolean;\n animate: boolean;\n disabled: boolean;\n vertical: boolean;\n onChange: ChangeEventHandler<HTMLInputElement>;\n tooltipProps?: Partial<TooltipProps>;\n getTooltipProps: (\n value: number,\n isFirstThumb: boolean\n ) => Partial<TooltipProps> | undefined;\n getTooltipChildren: (value: number, isFirstThumb: boolean) => ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Internal only component.\n */\nexport const SliderThumb = forwardRef<\n HTMLSpanElement,\n LabelRequiredForA11y<SliderThumbProps>\n>(function SliderThumb(props, ref) {\n const {\n id,\n min,\n max,\n name,\n value,\n onChange,\n index,\n getValueText,\n step,\n active,\n animate,\n disabled,\n vertical,\n discrete,\n tabIndex = disabled ? -1 : 0,\n className,\n onFocus = noop,\n onKeyDown = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n tooltipProps,\n getTooltipProps,\n getTooltipChildren,\n disableSmoothDragging,\n tooltipVisibility = \"auto\",\n ...remaining\n } = props;\n const { \"aria-label\": ariaLabel, \"aria-labelledby\": ariaLabelledBy } = props;\n\n const isFirstThumb = index === 1;\n const mode = useUserInteractionMode();\n const keyboard = mode === \"keyboard\";\n const touch = mode === \"touch\";\n const [mouseVisible, setMouseVisible] = useState(false);\n const [keyboardVisible, setKeyboardVisible] = useState(false);\n useEffect(() => {\n if (disabled || !discrete) {\n setKeyboardVisible(false);\n return;\n }\n\n // if the mode changes away from keyboard, need to disable the keyboard\n // state\n setKeyboardVisible((prevVisible) => prevVisible && mode === \"keyboard\");\n }, [disabled, discrete, mode]);\n useEffect(() => {\n if (disabled || !discrete) {\n setMouseVisible(false);\n return;\n }\n\n setMouseVisible((prevVisible) => prevVisible && mode !== \"touch\");\n }, [disabled, discrete, mode]);\n useEffect(() => {\n if (!keyboardVisible) {\n return;\n }\n\n const callback = (): void => {\n setKeyboardVisible(false);\n };\n\n window.addEventListener(\"blur\", callback, true);\n return () => {\n window.removeEventListener(\"blur\", callback);\n };\n }, [keyboardVisible]);\n\n const classNameOptions = {\n index,\n active,\n animate: !disableSmoothDragging && animate,\n disabled,\n vertical,\n className,\n } as const;\n\n return (\n <>\n {disabled && (\n <span\n className={sliderThumb({\n ...classNameOptions,\n mask: true,\n })}\n />\n )}\n <span\n {...remaining}\n id={id}\n ref={ref}\n role=\"slider\"\n aria-disabled={disabled || undefined}\n aria-orientation={vertical ? \"vertical\" : undefined}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={value}\n aria-valuetext={getValueText(value) || undefined}\n tabIndex={tabIndex}\n className={sliderThumb(classNameOptions)}\n onFocus={(event) => {\n onFocus(event);\n\n if (discrete && keyboard) {\n setKeyboardVisible(true);\n }\n }}\n onKeyDown={(event) => {\n onKeyDown(event);\n\n // this allows the tooltip to be visible when switching from mouse to\n // keyboard\n if (discrete && event.key !== \"Tab\") {\n setKeyboardVisible(true);\n }\n }}\n onMouseEnter={(event) => {\n onMouseEnter(event);\n if (discrete && tooltipVisibility === \"hover\" && !touch) {\n setMouseVisible(true);\n }\n }}\n onMouseLeave={(event) => {\n onMouseLeave(event);\n if (discrete && tooltipVisibility === \"hover\" && !touch) {\n setMouseVisible(false);\n }\n }}\n />\n <input\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-hidden\n id={`${id}-value`}\n type=\"range\"\n name={name}\n min={min}\n max={max}\n step={step}\n value={value}\n disabled={disabled}\n tabIndex={-1}\n onChange={onChange}\n className={sliderThumbInput()}\n />\n {discrete && (\n <SliderValueTooltip\n position={vertical ? \"left\" : \"above\"}\n vertical={vertical}\n animate={!disableSmoothDragging && !active}\n visible={\n tooltipVisibility === \"always\" ||\n active ||\n keyboardVisible ||\n mouseVisible\n }\n {...tooltipProps}\n {...getTooltipProps(value, isFirstThumb)}\n index={index}\n >\n {getTooltipChildren(value, isFirstThumb)}\n </SliderValueTooltip>\n )}\n </>\n );\n});\n"],"names":["forwardRef","useEffect","useState","useUserInteractionMode","SliderValueTooltip","sliderThumb","sliderThumbInput","noop","SliderThumb","props","ref","id","min","max","name","value","onChange","index","getValueText","step","active","animate","disabled","vertical","discrete","tabIndex","className","onFocus","onKeyDown","onMouseEnter","onMouseLeave","tooltipProps","getTooltipProps","getTooltipChildren","disableSmoothDragging","tooltipVisibility","remaining","ariaLabel","ariaLabelledBy","isFirstThumb","mode","keyboard","touch","mouseVisible","setMouseVisible","keyboardVisible","setKeyboardVisible","prevVisible","callback","window","addEventListener","removeEventListener","classNameOptions","span","mask","role","aria-disabled","undefined","aria-orientation","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","event","key","input","aria-label","aria-labelledby","aria-hidden","type","position","visible"],"mappings":"AAAA;;AAEA,SAIEA,UAAU,EACVC,SAAS,EACTC,QAAQ,QACH,QAAQ;AAEf,SAASC,sBAAsB,QAAQ,gDAAgD;A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8B,aAAW;gBACXzD,IAAI,GAAGA,GAAG,MAAM,CAAC;gBACjB0D,MAAK;gBACLvD,MAAMA;gBACNF,KAAKA;gBACLC,KAAKA;gBACLM,MAAMA;gBACNJ,OAAOA;gBACPO,UAAUA;gBACVG,UAAU,CAAC;gBACXT,UAAUA;gBACVU,WAAWpB;;YAEZkB,0BACC,KAACpB;gBACCkE,UAAU/C,WAAW,SAAS;gBAC9BA,UAAUA;gBACVF,SAAS,CAACa,yBAAyB,CAACd;gBACpCmD,SACEpC,sBAAsB,YACtBf,UACAyB,mBACAF;gBAED,GAAGZ,YAAY;gBACf,GAAGC,gBAAgBjB,OAAOwB,aAAa;gBACxCtB,OAAOA;0BAENgB,mBAAmBlB,OAAOwB;;;;AAKrC,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../src/form/SliderThumb.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ChangeEventHandler,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n useEffect,\n useState,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { type TooltipProps } from \"../tooltip/Tooltip.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { SliderValueTooltip } from \"./SliderValueTooltip.js\";\nimport { sliderThumb, sliderThumbInput } from \"./sliderStyles.js\";\nimport { type SliderValueOptions } from \"./useSlider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type SliderTooltipVisibility = \"auto\" | \"hover\" | \"always\";\n\n/**\n * @since 2.5.0\n */\nexport interface SliderThumbPresentation {\n /**\n * Boolean if the slider should act as a discrete slider which will render a\n * tooltip above the thumb while dragging to visualize the current value for\n * the slider.\n *\n * @defaultValue `false`\n */\n discrete?: boolean;\n\n /**\n * A function that is used to help with accessibility by creating a better\n * value string if just a number isn't representative enough of your range.\n *\n * Example:\n *\n * ```tsx\n * const [value, controls] = useSlider(0, {\n * // format to be `$100`, etc\n * getValueText: value => `$${value}`,\n * });\n *\n * return <Slider baseId=\"price-slider\" label=\"Price\" {...controls} />;\n * ```\n *\n * @defaultValue `() => \"\"`\n */\n getValueText?: (value: number) => string;\n\n /**\n * Set this to `true` if the slider's thumb position should only update when\n * the user has dragged to the next value instead of with the mouse.\n *\n * @see {@link marks}\n * @defaultValue `!!marks`\n */\n disableSmoothDragging?: boolean;\n\n /**\n * The discrete slider's value tooltip will only become visible when:\n *\n * - `\"auto\"` - the user is dragging with touch/mouse or focused with a keyboard\n * - `\"hover\"` - the behavior of `\"auto\"` plus while hovering the thumb with a mouse\n * - `\"always\"` - ... always\n *\n * This only applies when the {@link discrete} prop is `true`.\n *\n * @defaultValue `\"auto\"`\n */\n tooltipVisibility?: SliderTooltipVisibility;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableSliderThumbProps extends Omit<\n HTMLAttributes<HTMLSpanElement>,\n \"onChange\"\n> {\n name?: string;\n}\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Internal only component.\n */\nexport interface SliderThumbProps\n extends\n ConfigurableSliderThumbProps,\n Required<SliderValueOptions>,\n Required<SliderThumbPresentation> {\n id: string;\n value: number;\n index: 1 | 2;\n active: boolean;\n animate: boolean;\n disabled: boolean;\n vertical: boolean;\n onChange: ChangeEventHandler<HTMLInputElement>;\n tooltipProps?: Partial<TooltipProps>;\n getTooltipProps: (\n value: number,\n isFirstThumb: boolean\n ) => Partial<TooltipProps> | undefined;\n getTooltipChildren: (value: number, isFirstThumb: boolean) => ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Internal only component.\n */\nexport const SliderThumb = forwardRef<\n HTMLSpanElement,\n LabelRequiredForA11y<SliderThumbProps>\n>(function SliderThumb(props, ref) {\n const {\n id,\n min,\n max,\n name,\n value,\n onChange,\n index,\n getValueText,\n step,\n active,\n animate,\n disabled,\n vertical,\n discrete,\n tabIndex = disabled ? -1 : 0,\n className,\n onFocus = noop,\n onKeyDown = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n tooltipProps,\n getTooltipProps,\n getTooltipChildren,\n disableSmoothDragging,\n tooltipVisibility = \"auto\",\n ...remaining\n } = props;\n const { \"aria-label\": ariaLabel, \"aria-labelledby\": ariaLabelledBy } = props;\n\n const isFirstThumb = index === 1;\n const mode = useUserInteractionMode();\n const keyboard = mode === \"keyboard\";\n const touch = mode === \"touch\";\n const [mouseVisible, setMouseVisible] = useState(false);\n const [keyboardVisible, setKeyboardVisible] = useState(false);\n useEffect(() => {\n if (disabled || !discrete) {\n setKeyboardVisible(false);\n return;\n }\n\n // if the mode changes away from keyboard, need to disable the keyboard\n // state\n setKeyboardVisible((prevVisible) => prevVisible && mode === \"keyboard\");\n }, [disabled, discrete, mode]);\n useEffect(() => {\n if (disabled || !discrete) {\n setMouseVisible(false);\n return;\n }\n\n setMouseVisible((prevVisible) => prevVisible && mode !== \"touch\");\n }, [disabled, discrete, mode]);\n useEffect(() => {\n if (!keyboardVisible) {\n return;\n }\n\n const callback = (): void => {\n setKeyboardVisible(false);\n };\n\n window.addEventListener(\"blur\", callback, true);\n return () => {\n window.removeEventListener(\"blur\", callback);\n };\n }, [keyboardVisible]);\n\n const classNameOptions = {\n index,\n active,\n animate: !disableSmoothDragging && animate,\n disabled,\n vertical,\n className,\n } as const;\n\n return (\n <>\n {disabled && (\n <span\n className={sliderThumb({\n ...classNameOptions,\n mask: true,\n })}\n />\n )}\n <span\n {...remaining}\n id={id}\n ref={ref}\n role=\"slider\"\n aria-disabled={disabled || undefined}\n aria-orientation={vertical ? \"vertical\" : undefined}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={value}\n aria-valuetext={getValueText(value) || undefined}\n tabIndex={tabIndex}\n className={sliderThumb(classNameOptions)}\n onFocus={(event) => {\n onFocus(event);\n\n if (discrete && keyboard) {\n setKeyboardVisible(true);\n }\n }}\n onKeyDown={(event) => {\n onKeyDown(event);\n\n // this allows the tooltip to be visible when switching from mouse to\n // keyboard\n if (discrete && event.key !== \"Tab\") {\n setKeyboardVisible(true);\n }\n }}\n onMouseEnter={(event) => {\n onMouseEnter(event);\n if (discrete && tooltipVisibility === \"hover\" && !touch) {\n setMouseVisible(true);\n }\n }}\n onMouseLeave={(event) => {\n onMouseLeave(event);\n if (discrete && tooltipVisibility === \"hover\" && !touch) {\n setMouseVisible(false);\n }\n }}\n />\n <input\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-hidden\n id={`${id}-value`}\n type=\"range\"\n name={name}\n min={min}\n max={max}\n step={step}\n value={value}\n disabled={disabled}\n tabIndex={-1}\n onChange={onChange}\n className={sliderThumbInput()}\n />\n {discrete && (\n <SliderValueTooltip\n position={vertical ? \"left\" : \"above\"}\n vertical={vertical}\n animate={!disableSmoothDragging && !active}\n visible={\n tooltipVisibility === \"always\" ||\n active ||\n keyboardVisible ||\n mouseVisible\n }\n {...tooltipProps}\n {...getTooltipProps(value, isFirstThumb)}\n index={index}\n >\n {getTooltipChildren(value, isFirstThumb)}\n </SliderValueTooltip>\n )}\n </>\n );\n});\n"],"names":["forwardRef","useEffect","useState","useUserInteractionMode","SliderValueTooltip","sliderThumb","sliderThumbInput","noop","SliderThumb","props","ref","id","min","max","name","value","onChange","index","getValueText","step","active","animate","disabled","vertical","discrete","tabIndex","className","onFocus","onKeyDown","onMouseEnter","onMouseLeave","tooltipProps","getTooltipProps","getTooltipChildren","disableSmoothDragging","tooltipVisibility","remaining","ariaLabel","ariaLabelledBy","isFirstThumb","mode","keyboard","touch","mouseVisible","setMouseVisible","keyboardVisible","setKeyboardVisible","prevVisible","callback","window","addEventListener","removeEventListener","classNameOptions","span","mask","role","aria-disabled","undefined","aria-orientation","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","event","key","input","aria-label","aria-labelledby","aria-hidden","type","position","visible"],"mappings":"AAAA;;AAEA,SAIEA,UAAU,EACVC,SAAS,EACTC,QAAQ,QACH,QAAQ;AAEf,SAASC,sBAAs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B,mBAAiB7B;gBACjB8B,aAAW;gBACXzD,IAAI,GAAGA,GAAG,MAAM,CAAC;gBACjB0D,MAAK;gBACLvD,MAAMA;gBACNF,KAAKA;gBACLC,KAAKA;gBACLM,MAAMA;gBACNJ,OAAOA;gBACPO,UAAUA;gBACVG,UAAU,CAAC;gBACXT,UAAUA;gBACVU,WAAWpB;;YAEZkB,0BACC,KAACpB;gBACCkE,UAAU/C,WAAW,SAAS;gBAC9BA,UAAUA;gBACVF,SAAS,CAACa,yBAAyB,CAACd;gBACpCmD,SACEpC,sBAAsB,YACtBf,UACAyB,mBACAF;gBAED,GAAGZ,YAAY;gBACf,GAAGC,gBAAgBjB,OAAOwB,aAAa;gBACxCtB,OAAOA;0BAENgB,mBAAmBlB,OAAOwB;;;;AAKrC,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/SliderTrack.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { sliderTrack } from \"./sliderStyles.js\";\nimport {\n type ClosestThumbEventHandlersOptions,\n type ThumbOffsetsOptions,\n getClosestThumbEventHandlers,\n getThumbOffsets,\n} from \"./sliderUtils.js\";\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Updated to be internal only.\n */\nexport interface SliderTrackProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/form/SliderTrack.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { sliderTrack } from \"./sliderStyles.js\";\nimport {\n type ClosestThumbEventHandlersOptions,\n type ThumbOffsetsOptions,\n getClosestThumbEventHandlers,\n getThumbOffsets,\n} from \"./sliderUtils.js\";\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Updated to be internal only.\n */\nexport interface SliderTrackProps\n extends\n HTMLAttributes<HTMLSpanElement>,\n ClosestThumbEventHandlersOptions,\n ThumbOffsetsOptions {\n animate: boolean;\n disabled: boolean;\n}\n\n/**\n * @internal\n * @since 2.5.0\n * @since 6.0.0 Updated to be internal only.\n */\nexport const SliderTrack = forwardRef<HTMLSpanElement, SliderTrackProps>(\n function SliderTrack(props, ref) {\n const {\n style,\n className,\n animate,\n vertical,\n disabled,\n min,\n max,\n thumb1Ref,\n thumb1Value,\n thumb1Dragging,\n thumb1DragPercentage,\n thumb1OnMouseUp,\n thumb1OnMouseDown,\n thumb1OnMouseMove,\n thumb1OnTouchStart,\n thumb1OnTouchMove,\n thumb2Ref,\n thumb2Value,\n thumb2Dragging,\n thumb2DragPercentage,\n thumb2OnMouseUp,\n thumb2OnMouseDown,\n thumb2OnMouseMove,\n thumb2OnTouchStart,\n thumb2OnTouchMove,\n isRangeSlider,\n children,\n ...remaining\n } = props;\n\n return (\n <span\n {...remaining}\n ref={ref}\n style={{\n ...style,\n ...getThumbOffsets({\n min,\n max,\n thumb1Value,\n thumb1Dragging,\n thumb1DragPercentage,\n thumb2Value,\n thumb2Dragging,\n thumb2DragPercentage,\n isRangeSlider,\n }),\n }}\n className={sliderTrack({\n className,\n animate,\n disabled,\n vertical,\n isRangeSlider,\n })}\n {...getClosestThumbEventHandlers({\n vertical,\n isRangeSlider,\n thumb1Ref,\n thumb1Dragging,\n thumb1OnMouseUp,\n thumb1OnMouseDown,\n thumb1OnMouseMove,\n thumb1OnTouchStart,\n thumb1OnTouchMove,\n thumb2Ref,\n thumb2Dragging,\n thumb2OnMouseUp,\n thumb2OnMouseDown,\n thumb2OnMouseMove,\n thumb2OnTouchStart,\n thumb2OnTouchMove,\n })}\n >\n {children}\n </span>\n );\n }\n);\n"],"names":["forwardRef","sliderTrack","getClosestThumbEventHandlers","getThumbOffsets","SliderTrack","props","ref","style","className","animate","vertical","disabled","min","max","thumb1Ref","thumb1Value","thumb1Dragging","thumb1DragPercentage","thumb1OnMouseUp","thumb1OnMouseDown","thumb1OnMouseMove","thumb1OnTouchStart","thumb1OnTouchMove","thumb2Ref","thumb2Value","thumb2Dragging","thumb2DragPercentage","thumb2OnMouseUp","thumb2OnMouseDown","thumb2OnMouseMove","thumb2OnTouchStart","thumb2OnTouchMove","isRangeSlider","children","remaining","span"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAGEC,4BAA4B,EAC5BC,eAAe,QACV,mBAAmB;AAgB1B;;;;CAIC,GACD,OAAO,MAAMC,4BAAcJ,WACzB,SAASI,YAAYC,KAAK,EAAEC,GAAG;IAC7B,MAAM,EACJC,KAAK,EACLC,SAAS,EACTC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,GAAG,EACHC,GAAG,EACHC,SAAS,EACTC,WAAW,EACXC,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,SAAS,EACTC,WAAW,EACXC,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,aAAa,EACbC,QAAQ,EACR,GAAGC,WACJ,GAAG7B;IAEJ,qBACE,KAAC8B;QACE,GAAGD,SAAS;QACb5B,KAAKA;QACLC,OAAO;YACL,GAAGA,KAAK;YACR,GAAGJ,gBAAgB;gBACjBS;gBACAC;gBACAE;gBACAC;gBACAC;gBACAO;gBACAC;gBACAC;gBACAM;YACF,EAAE;QACJ;QACAxB,WAAWP,YAAY;YACrBO;YACAC;YACAE;YACAD;YACAsB;QACF;QACC,GAAG9B,6BAA6B;YAC/BQ;YACAsB;YACAlB;YACAE;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAE;YACAE;YACAC;YACAC;YACAC;YACAC;QACF,EAAE;kBAEDE;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/SliderValueMarks.tsx"],"sourcesContent":["import {\n Fragment,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport {\n type RangeStepsOptions,\n getRangeSteps,\n} from \"../utils/getRangeSteps.js\";\nimport { SliderMark } from \"./SliderMark.js\";\nimport {\n type CustomizableSliderMarkLabelProps,\n SliderMarkLabel,\n} from \"./SliderMarkLabel.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface SliderValueMark {\n /**\n * An optional label to display alongside the current mark. This will be\n * positioned below the mark for horizontal sliders and to the right for\n * vertical sliders.\n */\n label?: ReactNode;\n\n /**\n * The value of the mark that should be a valid step within the slider.\n */\n value: number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SliderValueMarkState {\n /** The {@link SliderValueMark.value} */\n value: number;\n\n /**\n * No idea if this is actually useful (maybe custom styles?), but it is the\n * current percentage the mark is offset and is what is set as the\n * `left`/`top` values for the mark.\n */\n offset: string;\n\n /**\n * This will be `true` when the mark is being covered by the slider track's\n * active state.\n */\n active: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SliderMarksOptions {\n /**\n * Set this to `true` to display a mark for each step within the slider. This\n * can be used alongside the {@link getMarkProps} and\n * {@link getMarkLabelProps} to customize the styles or display a label for\n * the mark.\n *\n * @example Custom Marks\n * ```tsx\n * const slider = useSlider({ step: 10 });\n *\n * <Slider\n * {...slider}\n * marks={[\n * { value: 0, label: \"Minimum\" },\n * { value: 10 },\n * { value: 20 },\n * { value: 30 },\n * { value: 40 },\n * { value: 50, label: \"Medium\" },\n * { value: 60 },\n * { value: 70 },\n * { value: 80 },\n * { value: 90 },\n * { value: 100, label: \"Maximum\" },\n * ]}\n * />\n * ```\n */\n marks?: boolean | readonly SliderValueMark[];\n\n /**\n * This can be used to override any styles for the specific mark.\n */\n getMarkProps?: (\n options: SliderValueMarkState\n ) => HTMLAttributes<HTMLSpanElement> | undefined;\n\n /**\n * This can be used to override any styles for a specific mark's label or\n * display a label dynamically.\n *\n * @example Dynamic Labels\n * ```tsx\n * <Slider\n * {...slider}\n * marks\n * getMarkLabelProps={({ active, value }) => {\n * if (value % 10 !== 0) {\n * return;\n * }\n *\n * return {\n * children: `${value} degrees`,\n * className: cnb(active && styles.somethingCustom),\n * };\n * }}\n * />\n * ```\n */\n getMarkLabelProps?: (\n options: SliderValueMarkState\n ) => Partial<CustomizableSliderMarkLabelProps> | undefined;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface SliderValueMarksProps\n extends RangeStepsOptions
|
|
1
|
+
{"version":3,"sources":["../../src/form/SliderValueMarks.tsx"],"sourcesContent":["import {\n Fragment,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport {\n type RangeStepsOptions,\n getRangeSteps,\n} from \"../utils/getRangeSteps.js\";\nimport { SliderMark } from \"./SliderMark.js\";\nimport {\n type CustomizableSliderMarkLabelProps,\n SliderMarkLabel,\n} from \"./SliderMarkLabel.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface SliderValueMark {\n /**\n * An optional label to display alongside the current mark. This will be\n * positioned below the mark for horizontal sliders and to the right for\n * vertical sliders.\n */\n label?: ReactNode;\n\n /**\n * The value of the mark that should be a valid step within the slider.\n */\n value: number;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SliderValueMarkState {\n /** The {@link SliderValueMark.value} */\n value: number;\n\n /**\n * No idea if this is actually useful (maybe custom styles?), but it is the\n * current percentage the mark is offset and is what is set as the\n * `left`/`top` values for the mark.\n */\n offset: string;\n\n /**\n * This will be `true` when the mark is being covered by the slider track's\n * active state.\n */\n active: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SliderMarksOptions {\n /**\n * Set this to `true` to display a mark for each step within the slider. This\n * can be used alongside the {@link getMarkProps} and\n * {@link getMarkLabelProps} to customize the styles or display a label for\n * the mark.\n *\n * @example Custom Marks\n * ```tsx\n * const slider = useSlider({ step: 10 });\n *\n * <Slider\n * {...slider}\n * marks={[\n * { value: 0, label: \"Minimum\" },\n * { value: 10 },\n * { value: 20 },\n * { value: 30 },\n * { value: 40 },\n * { value: 50, label: \"Medium\" },\n * { value: 60 },\n * { value: 70 },\n * { value: 80 },\n * { value: 90 },\n * { value: 100, label: \"Maximum\" },\n * ]}\n * />\n * ```\n */\n marks?: boolean | readonly SliderValueMark[];\n\n /**\n * This can be used to override any styles for the specific mark.\n */\n getMarkProps?: (\n options: SliderValueMarkState\n ) => HTMLAttributes<HTMLSpanElement> | undefined;\n\n /**\n * This can be used to override any styles for a specific mark's label or\n * display a label dynamically.\n *\n * @example Dynamic Labels\n * ```tsx\n * <Slider\n * {...slider}\n * marks\n * getMarkLabelProps={({ active, value }) => {\n * if (value % 10 !== 0) {\n * return;\n * }\n *\n * return {\n * children: `${value} degrees`,\n * className: cnb(active && styles.somethingCustom),\n * };\n * }}\n * />\n * ```\n */\n getMarkLabelProps?: (\n options: SliderValueMarkState\n ) => Partial<CustomizableSliderMarkLabelProps> | undefined;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface SliderValueMarksProps\n extends RangeStepsOptions, Required<SliderMarksOptions> {\n vertical: boolean;\n thumb1Value: number;\n thumb2Value: number;\n isRangeSlider: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function SliderValueMarks(props: SliderValueMarksProps): ReactElement {\n const {\n min,\n max,\n step,\n marks: propMarks,\n vertical,\n thumb1Value,\n thumb2Value,\n isRangeSlider,\n getMarkProps,\n getMarkLabelProps,\n } = props;\n\n let marks: readonly SliderValueMark[];\n if (typeof propMarks === \"boolean\") {\n const steps = getRangeSteps({ min, max, step }) + 1;\n marks = Array.from({ length: steps }, (_, i) => ({\n value: min + i * step,\n }));\n } else {\n marks = propMarks;\n }\n\n return (\n <>\n {marks.map(({ value, label: markLabel }) => {\n // I can't think of a good name, but this is when the slider's track's\n // active color is covering the mark which requires different styles\n let active: boolean;\n let percentage = getPercentage({ min, max, value }) * 100;\n let markValue = value;\n if (vertical) {\n // need to reverse the percentage since it uses `top` for positioning\n // where the max value is at the top instead of bottom\n percentage = 100 - percentage;\n\n // need to reverse the mark's value as well for the same reason as\n // above\n markValue = max - value;\n }\n\n if (isRangeSlider) {\n active = markValue > thumb1Value && markValue < thumb2Value;\n } else {\n active = markValue < thumb1Value;\n }\n\n const offset = `${percentage}%`;\n const markProps = getMarkProps({ value, active, offset });\n const labelProps = getMarkLabelProps({ value, active, offset });\n const label = markLabel ?? labelProps?.children ?? null;\n\n return (\n <Fragment key={value}>\n <SliderMark\n {...markProps}\n offset={offset}\n active={active}\n vertical={vertical}\n />\n {label !== null && (\n <SliderMarkLabel\n {...labelProps}\n offset={offset}\n vertical={vertical}\n >\n {label}\n </SliderMarkLabel>\n )}\n </Fragment>\n );\n })}\n </>\n );\n}\n"],"names":["Fragment","getPercentage","getRangeSteps","SliderMark","SliderMarkLabel","SliderValueMarks","props","min","max","step","marks","propMarks","vertical","thumb1Value","thumb2Value","isRangeSlider","getMarkProps","getMarkLabelProps","steps","Array","from","length","_","i","value","map","label","markLabel","active","percentage","markValue","offset","markProps","labelProps","children"],"mappings":";AAAA,SACEA,QAAQ,QAIH,QAAQ;AAEf,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAEEC,aAAa,QACR,4BAA4B;AACnC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAEEC,eAAe,QACV,uBAAuB;AAwH9B;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EACJC,GAAG,EACHC,GAAG,EACHC,IAAI,EACJC,OAAOC,SAAS,EAChBC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EAClB,GAAGX;IAEJ,IAAII;IACJ,IAAI,OAAOC,cAAc,WAAW;QAClC,MAAMO,QAAQhB,cAAc;YAAEK;YAAKC;YAAKC;QAAK,KAAK;QAClDC,QAAQS,MAAMC,IAAI,CAAC;YAAEC,QAAQH;QAAM,GAAG,CAACI,GAAGC,IAAO,CAAA;gBAC/CC,OAAOjB,MAAMgB,IAAId;YACnB,CAAA;IACF,OAAO;QACLC,QAAQC;IACV;IAEA,qBACE;kBACGD,MAAMe,GAAG,CAAC,CAAC,EAAED,KAAK,EAAEE,OAAOC,SAAS,EAAE;YACrC,sEAAsE;YACtE,oEAAoE;YACpE,IAAIC;YACJ,IAAIC,aAAa5B,cAAc;gBAAEM;gBAAKC;gBAAKgB;YAAM,KAAK;YACtD,IAAIM,YAAYN;YAChB,IAAIZ,UAAU;gBACZ,qEAAqE;gBACrE,sDAAsD;gBACtDiB,aAAa,MAAMA;gBAEnB,kEAAkE;gBAClE,QAAQ;gBACRC,YAAYtB,MAAMgB;YACpB;YAEA,IAAIT,eAAe;gBACjBa,SAASE,YAAYjB,eAAeiB,YAAYhB;YAClD,OAAO;gBACLc,SAASE,YAAYjB;YACvB;YAEA,MAAMkB,SAAS,GAAGF,WAAW,CAAC,CAAC;YAC/B,MAAMG,YAAYhB,aAAa;gBAAEQ;gBAAOI;gBAAQG;YAAO;YACvD,MAAME,aAAahB,kBAAkB;gBAAEO;gBAAOI;gBAAQG;YAAO;YAC7D,MAAML,QAAQC,aAAaM,YAAYC,YAAY;YAEnD,qBACE,MAAClC;;kCACC,KAACG;wBACE,GAAG6B,SAAS;wBACbD,QAAQA;wBACRH,QAAQA;wBACRhB,UAAUA;;oBAEXc,UAAU,sBACT,KAACtB;wBACE,GAAG6B,UAAU;wBACdF,QAAQA;wBACRnB,UAAUA;kCAETc;;;eAbQF;QAkBnB;;AAGN"}
|
package/dist/form/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/form/Switch.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { type InputToggleLabelProps } from \"./InputToggle.js\";\nimport { Label } from \"./Label.js\";\nimport { SwitchTrack } from \"./SwitchTrack.js\";\nimport { switchStyles } from \"./switchStyles.js\";\nimport {\n type FormComponentStates,\n type FormMessageContainerExtension,\n} from \"./types.js\";\n\n// NOTE: The augmentation appears in this file since no type definitions are\n// ever imported from the `switchStyles` file.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-switch-track-background-color\"?: string;\n \"--rmd-switch-ball-background-color\"?: string;\n }\n}\n\n/**\n * @since 6.0.0 Added `containerProps` and support for the\n * `FormMessage` behavior.\n */\nexport interface SwitchProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/form/Switch.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { type InputToggleLabelProps } from \"./InputToggle.js\";\nimport { Label } from \"./Label.js\";\nimport { SwitchTrack } from \"./SwitchTrack.js\";\nimport { switchStyles } from \"./switchStyles.js\";\nimport {\n type FormComponentStates,\n type FormMessageContainerExtension,\n} from \"./types.js\";\n\n// NOTE: The augmentation appears in this file since no type definitions are\n// ever imported from the `switchStyles` file.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-switch-track-background-color\"?: string;\n \"--rmd-switch-ball-background-color\"?: string;\n }\n}\n\n/**\n * @since 6.0.0 Added `containerProps` and support for the\n * `FormMessage` behavior.\n */\nexport interface SwitchProps\n extends\n InputHTMLAttributes<HTMLInputElement>,\n InputToggleLabelProps,\n FormMessageContainerExtension,\n FormComponentStates {\n containerProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n trackProps?: PropsWithRef<HTMLAttributes<HTMLDivElement>>;\n trackStyle?: CSSProperties;\n trackClassName?: string;\n ballAddon?: ReactNode;\n ballProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n ballStyle?: CSSProperties;\n ballClassName?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Form } from \"@react-md/core/form/Form\";\n * import { Switch } from \"@react-md/core/form/Switch\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [checked, setChecked] = useState(false);\n *\n * return (\n * <Form>\n * <Switch\n * label=\"Label\"\n * name=\"enabled\"\n * checked={checked}\n * onChange={(event) => setChecked(event.currentTarget.checked)}\n * />\n * </Form>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/switch | Switch Demos}\n * @since 6.0.0 Added support for `FormMessage` behavior.\n */\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(\n function Switch(props, ref) {\n const {\n id: propId,\n label,\n labelProps,\n style,\n className,\n containerProps,\n ballProps,\n ballStyle,\n ballClassName,\n ballAddon,\n trackProps,\n trackStyle,\n trackClassName,\n messageProps,\n messageContainerProps,\n disableLabelGap = false,\n error = false,\n active = false,\n stacked = false,\n iconAfter = false,\n disabled = false,\n readOnly = false,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"switch\");\n\n return (\n <FormMessageContainer\n {...messageContainerProps}\n messageProps={messageProps}\n >\n <Label\n style={style}\n {...labelProps}\n className={cnb(className, labelProps?.className)}\n gap={!disableLabelGap}\n stacked={stacked}\n reversed={!iconAfter}\n active={active}\n error={error}\n disabled={disabled}\n >\n {label}\n <div\n {...containerProps}\n className={switchStyles({\n clickable: !disabled && !readOnly,\n className: containerProps?.className,\n currentColor: active || error,\n })}\n >\n <SwitchTrack\n style={trackStyle}\n {...trackProps}\n className={cnb(trackClassName, trackProps?.className)}\n disabled={disabled}\n ballAddon={ballAddon}\n ballProps={ballProps}\n ballStyle={ballStyle}\n ballClassName={ballClassName}\n >\n <input\n {...remaining}\n id={id}\n ref={ref}\n role=\"switch\"\n type=\"checkbox\"\n className={cnb(\n \"rmd-switch__input rmd-hidden-input\",\n disabled && \"rmd-hidden-input--disabled\"\n )}\n disabled={disabled}\n />\n </SwitchTrack>\n </div>\n </Label>\n </FormMessageContainer>\n );\n }\n);\n"],"names":["cnb","forwardRef","useEnsuredId","FormMessageContainer","Label","SwitchTrack","switchStyles","Switch","props","ref","id","propId","label","labelProps","style","className","containerProps","ballProps","ballStyle","ballClassName","ballAddon","trackProps","trackStyle","trackClassName","messageProps","messageContainerProps","disableLabelGap","error","active","stacked","iconAfter","disabled","readOnly","remaining","gap","reversed","div","clickable","currentColor","input","role","type"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UAAU,QACL,QAAQ;AAGf,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,4BAA4B;AAEjE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,QAAQ,oBAAoB;AAmCjD;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,MAAMC,uBAASN,WACpB,SAASM,OAAOC,KAAK,EAAEC,GAAG;IACxB,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,cAAc,EACdC,YAAY,EACZC,qBAAqB,EACrBC,kBAAkB,KAAK,EACvBC,QAAQ,KAAK,EACbC,SAAS,KAAK,EACdC,UAAU,KAAK,EACfC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChB,GAAGC,WACJ,GAAGzB;IACJ,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,qBACE,KAACR;QACE,GAAGsB,qBAAqB;QACzBD,cAAcA;kBAEd,cAAA,MAACpB;YACCU,OAAOA;YACN,GAAG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