@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/datetime/NativeDateField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type DateFieldOptions, useDateField } from \"./useDateField.js\";\n\n/** @since 6.3.0 */\nexport interface NativeDateFieldProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/NativeDateField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type DateFieldOptions, useDateField } from \"./useDateField.js\";\n\n/** @since 6.3.0 */\nexport interface NativeDateFieldProps\n extends\n Omit<TextFieldProps, keyof DateFieldOptions | \"value\">,\n Omit<DateFieldOptions, \"ref\"> {}\n\n/**\n * The `NativeDateField` is a simple wrapper around the `TextField` using the\n * `useDateField` hook.\n *\n * @example Simple Example\n * ```tsx\n * import { NativeDateField } from \"@react-md/core/datetime/NativeDateField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <NativeDateField label=\"Delivery Date\" name=\"delivery\" />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/native-time-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @since 6.3.0\n */\nexport const NativeDateField = forwardRef<\n HTMLInputElement,\n NativeDateFieldProps\n>(function NativeDateField(props, ref) {\n const {\n id,\n min,\n max,\n step,\n onBlur,\n onInvalid,\n onChange,\n helpText,\n required,\n validationType,\n disableMessage,\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n ...remaining\n } = props;\n const { name, form } = props;\n const { fieldProps } = useDateField({\n id,\n ref,\n name,\n form,\n min,\n max,\n step,\n onBlur,\n onChange,\n onInvalid,\n helpText,\n required,\n validationType,\n disableMessage: disableMessage ?? (!min && !max && !step && !required),\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n });\n\n let { messageProps } = remaining;\n if (fieldProps.messageProps) {\n messageProps = {\n ...fieldProps.messageProps,\n ...remaining.messageProps,\n };\n }\n\n return (\n <TextField {...remaining} {...fieldProps} messageProps={messageProps} />\n );\n});\n"],"names":["forwardRef","TextField","useDateField","NativeDateField","props","ref","id","min","max","step","onBlur","onInvalid","onChange","helpText","required","validationType","disableMessage","errorIcon","isErrored","getErrorIcon","getErrorMessage","onErrorChange","disableReset","defaultValue","remaining","name","form","fieldProps","messageProps"],"mappings":"AAAA;;AAEA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,SAAS,QAA6B,uBAAuB;AACtE,SAAgCC,YAAY,QAAQ,oBAAoB;AAQxE;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,MAAMC,gCAAkBH,WAG7B,SAASG,gBAAgBC,KAAK,EAAEC,GAAG;IACnC,MAAM,EACJC,EAAE,EACFC,GAAG,EACHC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZ,GAAGC,WACJ,GAAGpB;IACJ,MAAM,EAAEqB,IAAI,EAAEC,IAAI,EAAE,GAAGtB;IACvB,MAAM,EAAEuB,UAAU,EAAE,GAAGzB,aAAa;QAClCI;QACAD;QACAoB;QACAC;QACAnB;QACAC;QACAC;QACAC;QACAE;QACAD;QACAE;QACAC;QACAC;QACAC,gBAAgBA,kBAAmB,CAAA,CAACT,OAAO,CAACC,OAAO,CAACC,QAAQ,CAACK,QAAO;QACpEG;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,IAAI,EAAEK,YAAY,EAAE,GAAGJ;IACvB,IAAIG,WAAWC,YAAY,EAAE;QAC3BA,eAAe;YACb,GAAGD,WAAWC,YAAY;YAC1B,GAAGJ,UAAUI,YAAY;QAC3B;IACF;IAEA,qBACE,KAAC3B;QAAW,GAAGuB,SAAS;QAAG,GAAGG,UAAU;QAAEC,cAAcA;;AAE5D,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/datetime/NativeTimeField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type TimeFieldOptions, useTimeField } from \"./useTimeField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface NativeTimeFieldProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/NativeTimeField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type TimeFieldOptions, useTimeField } from \"./useTimeField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface NativeTimeFieldProps\n extends\n Omit<TextFieldProps, keyof TimeFieldOptions | \"value\">,\n Omit<TimeFieldOptions, \"ref\"> {}\n\n/**\n * The `NativeTimeField` is a simple wrapper around the `TextField` using the\n * `useTimeField` hook.\n *\n * @example Simple Example\n * ```tsx\n * import { NativeTimeField } from \"@react-md/core/datetime/NativeTimeField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <NativeTimeField label=\"Time\" name=\"appt\" />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @since 6.3.0\n */\nexport const NativeTimeField = forwardRef<\n HTMLInputElement,\n NativeTimeFieldProps\n>(function NativeTimeField(props, ref) {\n const {\n id,\n min,\n max,\n step,\n onBlur,\n onInvalid,\n onChange,\n helpText,\n required,\n validationType,\n disableMessage,\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n ...remaining\n } = props;\n const { name, form } = props;\n const { fieldProps } = useTimeField({\n id,\n ref,\n name,\n form,\n min,\n max,\n step,\n onBlur,\n onChange,\n onInvalid,\n helpText,\n required,\n validationType,\n disableMessage: disableMessage ?? (!min && !max && !step && !required),\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n });\n\n let { messageProps } = remaining;\n if (fieldProps.messageProps) {\n messageProps = {\n ...fieldProps.messageProps,\n ...remaining.messageProps,\n };\n }\n\n return (\n <TextField {...remaining} {...fieldProps} messageProps={messageProps} />\n );\n});\n"],"names":["forwardRef","TextField","useTimeField","NativeTimeField","props","ref","id","min","max","step","onBlur","onInvalid","onChange","helpText","required","validationType","disableMessage","errorIcon","isErrored","getErrorIcon","getErrorMessage","onErrorChange","disableReset","defaultValue","remaining","name","form","fieldProps","messageProps"],"mappings":"AAAA;;AAEA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,SAAS,QAA6B,uBAAuB;AACtE,SAAgCC,YAAY,QAAQ,oBAAoB;AAUxE;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,MAAMC,gCAAkBH,WAG7B,SAASG,gBAAgBC,KAAK,EAAEC,GAAG;IACnC,MAAM,EACJC,EAAE,EACFC,GAAG,EACHC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZ,GAAGC,WACJ,GAAGpB;IACJ,MAAM,EAAEqB,IAAI,EAAEC,IAAI,EAAE,GAAGtB;IACvB,MAAM,EAAEuB,UAAU,EAAE,GAAGzB,aAAa;QAClCI;QACAD;QACAoB;QACAC;QACAnB;QACAC;QACAC;QACAC;QACAE;QACAD;QACAE;QACAC;QACAC;QACAC,gBAAgBA,kBAAmB,CAAA,CAACT,OAAO,CAACC,OAAO,CAACC,QAAQ,CAACK,QAAO;QACpEG;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,IAAI,EAAEK,YAAY,EAAE,GAAGJ;IACvB,IAAIG,WAAWC,YAAY,EAAE;QAC3BA,eAAe;YACb,GAAGD,WAAWC,YAAY;YAC1B,GAAGJ,UAAUI,YAAY;QAC3B;IACF;IAEA,qBACE,KAAC3B;QAAW,GAAGuB,SAAS;QAAG,GAAGG,UAAU;QAAEC,cAAcA;;AAE5D,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/datetime/useDateField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface DateFieldConstraints {\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#min | min attribute}\n */\n min?: string;\n\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#max | max attribute}\n */\n max?: string;\n\n /**\n * For date inputs, the value of step is given in days; and is treated as a\n * number of milliseconds equal to 86,400,000 times the step value (the\n * underlying numeric value is in milliseconds). The default value of step is\n * 1, indicating 1 day.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#step | step attribute}\n */\n step?: number | \"any\";\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldOptions\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/useDateField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface DateFieldConstraints {\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#min | min attribute}\n */\n min?: string;\n\n /**\n * This **must** be in the format `yyyy-mm-dd`\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#max | max attribute}\n */\n max?: string;\n\n /**\n * For date inputs, the value of step is given in days; and is treated as a\n * number of milliseconds equal to 86,400,000 times the step value (the\n * underlying numeric value is in milliseconds). The default value of step is\n * 1, indicating 1 day.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#step | step attribute}\n */\n step?: number | \"any\";\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldOptions\n extends\n Omit<\n TextFieldHookOptions,\n | \"isNumber\"\n | \"counter\"\n | \"pattern\"\n | \"maxLength\"\n | \"minLength\"\n | \"disableMaxLength\"\n >,\n DateFieldConstraints {}\n\n/** @since 6.3.0 */\nexport interface ProvidedDateFieldProps\n extends\n Omit<ProvidedTextFieldProps, \"value\">,\n Omit<DateFieldConstraints, \"step\"> {\n type: \"date\";\n step?: number | \"any\";\n defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>[\"defaultValue\"];\n}\n\n/** @since 6.3.0 */\nexport interface ProvidedDateFieldMessageProps extends ProvidedDateFieldProps {\n /**\n * These props will be defined as long as the `disableMessage` prop is not\n * `true` from the `useTextField` hook.\n */\n messageProps: ProvidedFormMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldImplementation extends Omit<\n TextFieldImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedDateFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface DateFieldWithMessageImplementation extends Omit<\n TextFieldWithMessageImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedDateFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedDateFieldImplementation extends DateFieldImplementation {\n fieldProps: ProvidedDateFieldProps | ProvidedDateFieldMessageProps;\n}\n\n/**\n * The `useDateField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"date\" />`. It is used in the `NativeDateField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useDateField } from \"@react-md/core/datetime/useDateField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps, error, errorMessage } = useDateField({\n * name: \"delivery\",\n * required: true,\n * min: \"2025-01-01\",\n * max: \"2026-01-01\",\n * disableMessage: true,\n * });\n *\n * // value: `\"\"` or `\"yyyy-mm-dd\"`\n *\n * return <TextField label=\"Delivery Date\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions & { disableMessage: true }\n): DateFieldImplementation;\n\n/**\n * The `useDateField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"date\" />`. It is used in the `NativeDateField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useDateField } from \"@react-md/core/datetime/useDateField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps } = useDateField({\n * name: \"delivery\",\n * required: true,\n * min: \"2025-01-01\",\n * max: \"2026-01-01\",\n * });\n *\n * // value: `\"\"` or `\"yyyy-mm-dd\"`\n *\n * return <TextField label=\"Delivery Date\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions\n): DateFieldWithMessageImplementation;\n\n/**\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-date-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-date-field | useTimeField Demos}\n */\nexport function useDateField(\n options: DateFieldOptions\n): ValidatedDateFieldImplementation {\n const { min, max, step, ...fieldOptions } = options;\n const { fieldProps, ...impl } = useTextField(fieldOptions);\n\n // NOTE: Unlike the other text field components, the `value` should **not**\n // be provided since the time input behaves a bit weirdly with the `onChange`\n // event and it is better to rely on default browser behavior instead of\n // controlling the value. The flow is:\n // - user types `12:30`\n // - `onChange` is fired with `12:30`\n // - user selects `30` and hits backspace\n // - `onChange` is fired with `\"\"`\n // If the `value` is set, the other time values would be lost\n const { value, ...allowedFieldProps } = fieldProps;\n const initial = useRef(value);\n\n return {\n ...impl,\n fieldProps: {\n ...allowedFieldProps,\n defaultValue: initial.current,\n min,\n max,\n step,\n type: \"date\",\n },\n };\n}\n"],"names":["useRef","useTextField","useDateField","options","min","max","step","fieldOptions","fieldProps","impl","value","allowedFieldProps","initial","defaultValue","current","type"],"mappings":"AAAA;AAEA,SAAmCA,MAAM,QAAQ,QAAQ;AAEzD,SAMEC,YAAY,QACP,0BAA0B;AAwJjC;;;;CAIC,GACD,OAAO,SAASC,aACdC,OAAyB;IAEzB,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGC,cAAc,GAAGJ;IAC5C,MAAM,EAAEK,UAAU,EAAE,GAAGC,MAAM,GAAGR,aAAaM;IAE7C,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,sCAAsC;IACtC,uBAAuB;IACvB,uCAAuC;IACvC,yCAAyC;IACzC,oCAAoC;IACpC,6DAA6D;IAC7D,MAAM,EAAEG,KAAK,EAAE,GAAGC,mBAAmB,GAAGH;IACxC,MAAMI,UAAUZ,OAAOU;IAEvB,OAAO;QACL,GAAGD,IAAI;QACPD,YAAY;YACV,GAAGG,iBAAiB;YACpBE,cAAcD,QAAQE,OAAO;YAC7BV;YACAC;YACAC;YACAS,MAAM;QACR;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/datetime/useTimeField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\nimport { type TimeFieldStepOptions, getTimeStep } from \"./utils.js\";\n\n/** @since 6.3.0 */\nexport interface TimeFieldConstraints {\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n min?: string;\n\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n max?: string;\n\n /**\n * For time inputs, the value of step is given in seconds, with a scaling\n * factor of 1000 (since the underlying numeric value is in milliseconds).\n * The default value of step is 60, indicating 60 seconds (or 1 minute, or\n * 60,000 milliseconds).\n *\n * When any is set as the value for step, the default 60 seconds is used, and\n * the seconds value is not displayed in the UI.\n *\n * Here are a few examples:\n *\n * - `15` -> 15 seconds\n * - `60` -> 1 minute\n * - `900` -> 15 minutes\n * - `3600` -> 1 hour\n *\n * Since this might be a bit confusing, the values can be provided in an\n * object instead:\n *\n * ```ts\n * { seconds: 30 }\n * { minutes: 1 }\n * { minutes: 15 }\n * { hours: 1 }\n * { seconds: 15, minutes: 30, hours: 1 }\n * ```\n *\n * NOTE: The `min` and `max` props **must** be provided as well for the\n * `step` to work.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#step | step attribute}\n */\n step?: number | \"any\" | TimeFieldStepOptions;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldOptions\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/useTimeField.ts"],"sourcesContent":["\"use client\";\n\nimport { type InputHTMLAttributes, useRef } from \"react\";\n\nimport {\n type ProvidedFormMessageProps,\n type ProvidedTextFieldProps,\n type TextFieldHookOptions,\n type TextFieldImplementation,\n type TextFieldWithMessageImplementation,\n useTextField,\n} from \"../form/useTextField.js\";\nimport { type TimeFieldStepOptions, getTimeStep } from \"./utils.js\";\n\n/** @since 6.3.0 */\nexport interface TimeFieldConstraints {\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n min?: string;\n\n /**\n * This **must** be in the format `HH:mm`:\n * - `00:30` (12:30 AM)\n * - `15:15` (03:15 PM)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#time_value_format | Time value format}\n */\n max?: string;\n\n /**\n * For time inputs, the value of step is given in seconds, with a scaling\n * factor of 1000 (since the underlying numeric value is in milliseconds).\n * The default value of step is 60, indicating 60 seconds (or 1 minute, or\n * 60,000 milliseconds).\n *\n * When any is set as the value for step, the default 60 seconds is used, and\n * the seconds value is not displayed in the UI.\n *\n * Here are a few examples:\n *\n * - `15` -> 15 seconds\n * - `60` -> 1 minute\n * - `900` -> 15 minutes\n * - `3600` -> 1 hour\n *\n * Since this might be a bit confusing, the values can be provided in an\n * object instead:\n *\n * ```ts\n * { seconds: 30 }\n * { minutes: 1 }\n * { minutes: 15 }\n * { hours: 1 }\n * { seconds: 15, minutes: 30, hours: 1 }\n * ```\n *\n * NOTE: The `min` and `max` props **must** be provided as well for the\n * `step` to work.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time#step | step attribute}\n */\n step?: number | \"any\" | TimeFieldStepOptions;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldOptions\n extends\n Omit<\n TextFieldHookOptions,\n | \"isNumber\"\n | \"counter\"\n | \"pattern\"\n | \"maxLength\"\n | \"minLength\"\n | \"disableMaxLength\"\n >,\n TimeFieldConstraints {}\n\n/** @since 6.3.0 */\nexport interface ProvidedTimeFieldProps\n extends\n Omit<ProvidedTextFieldProps, \"value\">,\n Omit<TimeFieldConstraints, \"step\"> {\n type: \"time\";\n step?: number | \"any\";\n defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>[\"defaultValue\"];\n}\n\n/** @since 6.3.0 */\nexport interface ProvidedTimeFieldMessageProps extends ProvidedTimeFieldProps {\n /**\n * These props will be defined as long as the `disableMessage` prop is not\n * `true` from the `useTextField` hook.\n */\n messageProps: ProvidedFormMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldImplementation extends Omit<\n TextFieldImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldProps;\n}\n\n/** @since 6.3.0 */\nexport interface TimeFieldWithMessageImplementation extends Omit<\n TextFieldWithMessageImplementation,\n \"fieldProps\"\n> {\n fieldProps: ProvidedTimeFieldMessageProps;\n}\n\n/** @since 6.3.0 */\nexport interface ValidatedTimeFieldImplementation extends TimeFieldImplementation {\n fieldProps: ProvidedTimeFieldProps | ProvidedTimeFieldMessageProps;\n}\n\n/**\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions & { disableMessage: true }\n): TimeFieldImplementation;\n\n/**\n * The `useTimeField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"time\" />`. It is used in the `NativeTimeField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useTimeField } from \"@react-md/core/datetime/useTimeField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps, error, errorMessage } = useTimeField({\n * name: \"appt\",\n * required: true,\n * min: \"08:00\",\n * max: \"17:00\",\n * step: { minute: 15 },\n * disableMessage: true,\n * });\n *\n * // value: `\"\"` or `\"HH:mm\"`\n *\n * return <TextField label=\"Appointment\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions\n): TimeFieldWithMessageImplementation;\n\n/**\n * The `useTimeField` is a small wrapper around the {@link useTextField} to be used\n * with `<input type=\"time\" />`. It is used in the `NativeTimeField` if an example\n * implementation would like to be seen.\n *\n * @example Simple Example\n * ```tsx\n * import { useTimeField } from \"@react-md/core/datetime/useTimeField\";\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, fieldProps } = useTimeField({\n * name: \"appt\",\n * required: true,\n * min: \"08:00\",\n * max: \"17:00\",\n * step: { minute: 15 },\n * });\n *\n * // value: `\"\"` or `\"HH:mm\"`\n *\n * return <TextField label=\"Appointment\" {...fieldProps} />\n * }\n * ```\n *\n * @since 6.3.0\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/hooks/use-time-field | useTimeField Demos}\n */\nexport function useTimeField(\n options: TimeFieldOptions\n): ValidatedTimeFieldImplementation {\n const { min, max, step, ...fieldOptions } = options;\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof step !== \"undefined\" &&\n (!min || !max)\n ) {\n throw new Error(\n \"A `step` was provided to a time field without the `min` or `max` props.\"\n );\n }\n\n const { errorMessage, fieldProps, ...impl } = useTextField(fieldOptions);\n\n // NOTE: Unlike the other text field components, the `value` should **not**\n // be provided since the time input behaves a bit weirdly with the `onChange`\n // event and it is better to rely on default browser behavior instead of\n // controlling the value. The flow is:\n // - user types `12:30`\n // - `onChange` is fired with `12:30`\n // - user selects `30` and hits backspace\n // - `onChange` is fired with `\"\"`\n // If the `value` is set, the other time values would be lost\n const { value, ...allowedFieldProps } = fieldProps;\n const initial = useRef(value);\n\n return {\n ...impl,\n errorMessage,\n fieldProps: {\n ...allowedFieldProps,\n defaultValue: initial.current,\n min,\n max,\n step: getTimeStep(step),\n type: \"time\",\n },\n };\n}\n"],"names":["useRef","useTextField","getTimeStep","useTimeField","options","min","max","step","fieldOptions","process","env","NODE_ENV","Error","errorMessage","fieldProps","impl","value","allowedFieldProps","initial","defaultValue","current","type"],"mappings":"AAAA;AAEA,SAAmCA,MAAM,QAAQ,QAAQ;AAEzD,SAMEC,YAAY,QACP,0BAA0B;AACjC,SAAoCC,WAAW,QAAQ,aAAa;AA2JpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,SAASC,aACdC,OAAyB;IAEzB,MAAM,EAAEC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGC,cAAc,GAAGJ;IAC5C,IACEK,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzB,OAAOJ,SAAS,eACf,CAAA,CAACF,OAAO,CAACC,GAAE,GACZ;QACA,MAAM,IAAIM,MACR;IAEJ;IAEA,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGC,MAAM,GAAGd,aAAaO;IAE3D,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,sCAAsC;IACtC,uBAAuB;IACvB,uCAAuC;IACvC,yCAAyC;IACzC,oCAAoC;IACpC,6DAA6D;IAC7D,MAAM,EAAEQ,KAAK,EAAE,GAAGC,mBAAmB,GAAGH;IACxC,MAAMI,UAAUlB,OAAOgB;IAEvB,OAAO;QACL,GAAGD,IAAI;QACPF;QACAC,YAAY;YACV,GAAGG,iBAAiB;YACpBE,cAAcD,QAAQE,OAAO;YAC7Bf;YACAC;YACAC,MAAML,YAAYK;YAClBc,MAAM;QACR;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport {\n type FocusContainerComponentProps,\n useFocusContainer,\n} from \"../focus/useFocusContainer.js\";\nimport { Overlay } from \"../overlay/Overlay.js\";\nimport { Portal } from \"../portal/Portal.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n type ConfigurableDialogContainerProps,\n DialogContainer,\n} from \"./DialogContainer.js\";\nimport {\n NestedDialogProvider,\n useNestedDialogContext,\n} from \"./NestedDialogProvider.js\";\nimport {\n DEFAULT_DIALOG_CLASSNAMES,\n DEFAULT_DIALOG_TIMEOUT,\n type DialogType,\n type DialogWidth,\n dialog,\n} from \"./styles.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\nconst noopBool = (): boolean => false;\n\nexport interface BaseDialogProps\n extends HTMLAttributes<HTMLDivElement>,\n CSSTransitionComponentProps,\n TransitionActions,\n FocusContainerComponentProps {\n /**\n * @defaultValue `\"dialog-\" + useId()`\n */\n id?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @see {@link DialogWidth}\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `\"dialog\"`\n */\n role?: \"dialog\" | \"alertdialog\" | \"menu\" | \"none\";\n\n /**\n * This value controls the visibility of the dialog.\n */\n visible: boolean;\n\n /**\n * This function should set the {@link visible} prop to false to hide the\n * modal when:\n * - the {@link modal} and {@link disableEscapeClose} props are `false` and\n * the user presses the `\"Escape\"` key.\n * - The overlay element is clicked\n */\n onRequestClose: () => void;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /** @defaultValue `-1` */\n tabIndex?: number;\n\n /**\n * Set this value to `true` if the dialog should behave as a modal which\n * prevents the modal from being closed by pressing the `\"Escape\"` key or\n * clicking the overlay. The user **must** click one of the actions within the\n * dialog instead.\n *\n * @defaultValue `false`\n */\n modal?: boolean;\n\n /**\n * Set this to `true` if the dialog should no longer use the `Portal`\n * behavior.\n *\n * @defaultValue `false`\n */\n disablePortal?: boolean;\n\n /**\n * Set this to `true` if you want the page to still be scrollable while the\n * dialog is visible. This should normally be `true` for popovers/fixed\n * dialogs.\n *\n * @defaultValue `type === \"custom\"`\n */\n disableScrollLock?: boolean;\n\n /**\n * Set this to `true` to prevent the dialog from being closed when the\n * `\"Escape\"` key is pressed. This is `true` by default when the {@link modal}\n * prop is `true`\n *\n * @defaultValue `modal`\n */\n disableEscapeClose?: boolean;\n\n /**\n * Set this to `true` if an overlay should not appear behind the dialog.\n *\n * Note: this was changed from `type === \"full-page\"` to `false` so that you\n * can change between full-page and centered based on media queries. If the\n * type changes the overlay would end up rendering above the dialog instead of\n * behind.\n *\n * @see {@link overlayHidden}\n * @defaultValue `false`\n */\n disableOverlay?: boolean;\n\n /**\n * Set this to `true` if an overlay should be appear behind the dialog but\n * have an `opacity: 0`. This is useful if you want to prevent other elements\n * on the page from being clicked while the dialog is visible, but don't want\n * a dark background. i.e. popovers/fixed dialogs.\n *\n * @defaultValue `false`\n */\n overlayHidden?: boolean;\n\n /**\n * Any additional props that should be passed to the overlay element if it is\n * rendered.\n */\n overlayProps?: HTMLAttributes<HTMLSpanElement>;\n\n /**\n * Any additional props that should be passed to the container element when\n * the `type !== \"custom\"`.\n */\n containerProps?: PropsWithRef<ConfigurableDialogContainerProps>;\n\n /**\n * @see {@link DEFAULT_DIALOG_TIMEOUT}\n * @defaultValue `DEFAULT_DIALOG_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link DEFAULT_DIALOG_CLASSNAMES}\n * @defaultValue `DEFAULT_DIALOG_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n\n /**\n * Set this to `true` if the `Dialog` should not gain the normal focus box\n * shadow while it is focused. The `Dialog` should normally only gain focus\n * when it becomes visible and no child elements have `autoFocus` enabled.\n *\n * @since 6.0.0\n * @defaultValue `type === \"full-page\"`\n */\n disableFocusOutline?: boolean;\n}\n\nexport type DialogProps = LabelRequiredForA11y<BaseDialogProps>;\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Dialog } from \"@react-md/core/dialog/Dialog\";\n * import { DialogContent } from \"@react-md/core/dialog/DialogContent\";\n * import { DialogFooter } from \"@react-md/core/dialog/DialogFooter\";\n * import { DialogHeader } from \"@react-md/core/dialog/DialogHeader\";\n * import { DialogTitle } from \"@react-md/core/dialog/DialogTitle\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n * import { useToggle } from \"@react-md/core/useToggle\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const {\n * toggle,\n * disable: onRequestClose,\n * toggled: visible,\n * } = useToggle(false);\n *\n * return (\n * <>\n * <Button onClick={toggle}>Toggle</Button>\n * <Dialog\n * aria-labelledby=\"dialog-title\"\n * visible={visible}\n * onRequestClose={onRequestClose}\n * >\n * <DialogHeader>\n * <DialogTitle id=\"dialog-title\">Simple Dialog</DialogTitle>\n * </DialogHeader>\n * <DialogContent>\n * <Typography margin=\"none\">This is some text in a dialog.</Typography>\n * </DialogContent>\n * <DialogFooter>\n * <Button onClick={onRequestClose}>\n * Close\n * </Button>\n * </DialogFooter>\n * </Dialog>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/dialog | Dialog Demos}\n * @since 6.0.0 The `Dialog` no longer supports focusing elements\n * within once it becomes visible. You must manually add `autoFocus` to a\n * element instead.\n */\nexport const Dialog = forwardRef<HTMLDivElement, DialogProps>(\n function Dialog(props, ref) {\n const {\n id: propId,\n modal = false,\n role = modal ? \"alertdialog\" : \"dialog\",\n type = \"centered\",\n width,\n tabIndex = -1,\n visible,\n onRequestClose,\n containerProps,\n temporary = true,\n className,\n timeout = DEFAULT_DIALOG_TIMEOUT,\n classNames = DEFAULT_DIALOG_CLASSNAMES,\n disableTransition = false,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n exitedHidden = true,\n disableOverlay = false,\n overlayProps,\n overlayHidden,\n onKeyDown = noop,\n isFocusTypeDisabled = noopBool,\n disablePortal: propDisablePortal,\n disableScrollLock = false,\n disableEscapeClose = modal,\n disableFocusOutline = type === \"full-page\",\n children,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"dialog\");\n\n const ssr = useSsr();\n const setChildVisible = useNestedDialogContext();\n\n // this makes it so that as more non-full page dialogs become visible, the\n // overlay does not become darker as more and more overlays are stacked upon\n // each other. only the top-most overlay will have and active background\n // color.\n const [isChildVisible, setIsChildVisible] = useState(false);\n const { eventHandlers, transitionOptions } = useFocusContainer({\n nodeRef: ref,\n activate: visible,\n onEnter(appearing) {\n onEnter(appearing);\n setChildVisible(type !== \"full-page\");\n },\n onEntered(appear) {\n onEntered(appear);\n // this needs to be called onEnter and onEntered just in case the\n // transition is disabled\n setChildVisible(type !== \"full-page\");\n },\n onEntering,\n onExit() {\n onExit();\n setChildVisible(false);\n },\n onExiting,\n onExited() {\n onExited();\n // this needs to be called onExit and onExited just in case the\n // transition is disabled\n setChildVisible(false);\n },\n disableTransition,\n onKeyDown(event) {\n onKeyDown(event);\n if (\n event.isPropagationStopped() ||\n modal ||\n disableEscapeClose ||\n event.key !== \"Escape\"\n ) {\n return;\n }\n\n // prevent parent dialogs from closing as well\n event.stopPropagation();\n onRequestClose();\n },\n isFocusTypeDisabled,\n });\n const { elementProps, stage, rendered, disablePortal } = useCSSTransition({\n transitionIn: visible,\n timeout,\n classNames,\n className: dialog({\n type,\n width,\n fixed: type === \"custom\",\n outline: !disableFocusOutline,\n disableBoxShadow: isChildVisible,\n className,\n }),\n appear: appear && !disableTransition && !ssr,\n enter: enter && !disableTransition,\n exit: exit && !disableTransition,\n temporary,\n exitedHidden,\n disablePortal: propDisablePortal,\n ...transitionOptions,\n });\n useScrollLock(!disableScrollLock && visible);\n\n return (\n <NestedDialogProvider value={setIsChildVisible}>\n {!disableOverlay && (\n <Overlay\n visible={visible}\n disableTransition={disableTransition}\n temporary={temporary}\n disablePortal={disablePortal}\n {...overlayProps}\n onClick={modal ? noop : onRequestClose}\n clickable={!modal}\n noOpacity={overlayHidden || isChildVisible}\n />\n )}\n <Portal disabled={disablePortal}>\n {rendered && (\n <DialogContainer\n enabled={type !== \"custom\"}\n {...containerProps}\n centered={type === \"centered\"}\n displayNone={!temporary && exitedHidden && stage === \"exited\"}\n >\n <div\n aria-modal={modal || undefined}\n {...remaining}\n {...elementProps}\n {...eventHandlers}\n id={id}\n role={role}\n tabIndex={tabIndex}\n >\n {children}\n </div>\n </DialogContainer>\n )}\n </Portal>\n </NestedDialogProvider>\n );\n }\n);\n"],"names":["forwardRef","useState","useSsr","useFocusContainer","Overlay","Portal","useScrollLock","useCSSTransition","useEnsuredId","DialogContainer","NestedDialogProvider","useNestedDialogContext","DEFAULT_DIALOG_CLASSNAMES","DEFAULT_DIALOG_TIMEOUT","dialog","noop","noopBool","Dialog","props","ref","id","propId","modal","role","type","width","tabIndex","visible","onRequestClose","containerProps","temporary","className","timeout","classNames","disableTransition","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","exitedHidden","disableOverlay","overlayProps","overlayHidden","onKeyDown","isFocusTypeDisabled","disablePortal","propDisablePortal","disableScrollLock","disableEscapeClose","disableFocusOutline","children","remaining","ssr","setChildVisible","isChildVisible","setIsChildVisible","eventHandlers","transitionOptions","nodeRef","activate","appearing","event","isPropagationStopped","key","stopPropagation","elementProps","stage","rendered","transitionIn","fixed","outline","disableBoxShadow","value","onClick","clickable","noOpacity","disabled","enabled","centered","displayNone","div","aria-modal","undefined"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AAElE,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAEEC,iBAAiB,QACZ,gCAAgC;AACvC,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,aAAa,QAAQ,6BAA6B;AAO3D,SAASC,gBAAgB,QAAQ,oCAAoC;AAErE,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAEEC,eAAe,QACV,uBAAuB;AAC9B,SACEC,oBAAoB,EACpBC,sBAAsB,QACjB,4BAA4B;AACnC,SACEC,yBAAyB,EACzBC,sBAAsB,EAGtBC,MAAM,QACD,cAAc;AAErB,MAAMC,OAAO;AACX,aAAa;AACf;AAEA,MAAMC,WAAW,IAAe;AAgJhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDC,GACD,OAAO,MAAMC,uBAASjB,WACpB,SAASiB,OAAOC,KAAK,EAAEC,GAAG;IACxB,MAAM,EACJC,IAAIC,MAAM,EACVC,QAAQ,KAAK,EACbC,OAAOD,QAAQ,gBAAgB,QAAQ,EACvCE,OAAO,UAAU,EACjBC,KAAK,EACLC,WAAW,CAAC,CAAC,EACbC,OAAO,EACPC,cAAc,EACdC,cAAc,EACdC,YAAY,IAAI,EAChBC,SAAS,EACTC,UAAUnB,sBAAsB,EAChCoB,aAAarB,yBAAyB,EACtCsB,oBAAoB,KAAK,EACzBC,SAAS,KAAK,EACdC,QAAQ,IAAI,EACZC,OAAO,IAAI,EACXC,UAAUvB,IAAI,EACdwB,aAAaxB,IAAI,EACjByB,YAAYzB,IAAI,EAChB0B,SAAS1B,IAAI,EACb2B,YAAY3B,IAAI,EAChB4B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AAkBjB;YAClB5B;QACF;QACAI,QAAQA,UAAU,CAACD,qBAAqB,CAACuB;QACzCrB,OAAOA,SAAS,CAACF;QACjBG,MAAMA,QAAQ,CAACH;QACfJ;QACAc;QACAM,eAAeC;QACf,GAAGW,iBAAiB;IACtB;IACAxD,cAAc,CAAC8C,qBAAqBzB;IAEpC,qBACE,MAACjB;QAAqBmE,OAAOjB;;YAC1B,CAACf,gCACA,KAACzC;gBACCuB,SAASA;gBACTO,mBAAmBA;gBACnBJ,WAAWA;gBACXoB,eAAeA;gBACd,GAAGJ,YAAY;gBAChBgC,SAASxD,QAAQP,OAAOa;gBACxBmD,WAAW,CAACzD;gBACZ0D,WAAWjC,iBAAiBY;;0BAGhC,KAACtD;gBAAO4E,UAAU/B;0BACfsB,0BACC,KAAC/D;oBACCyE,SAAS1D,SAAS;oBACjB,GAAGK,cAAc;oBAClBsD,UAAU3D,SAAS;oBACnB4D,aAAa,CAACtD,aAAac,gBAAgB2B,UAAU;8BAErD,cAAA,KAACc;wBACCC,cAAYhE,SAASiE;wBACpB,GAAG/B,SAAS;wBACZ,GAAGc,YAAY;wBACf,GAAGT,aAAa;wBACjBzC,IAAIA;wBACJG,MAAMA;wBACNG,UAAUA;kCAET6B;;;;;;AAOf,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport {\n type FocusContainerComponentProps,\n useFocusContainer,\n} from \"../focus/useFocusContainer.js\";\nimport { Overlay } from \"../overlay/Overlay.js\";\nimport { Portal } from \"../portal/Portal.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n type ConfigurableDialogContainerProps,\n DialogContainer,\n} from \"./DialogContainer.js\";\nimport {\n NestedDialogProvider,\n useNestedDialogContext,\n} from \"./NestedDialogProvider.js\";\nimport {\n DEFAULT_DIALOG_CLASSNAMES,\n DEFAULT_DIALOG_TIMEOUT,\n type DialogType,\n type DialogWidth,\n dialog,\n} from \"./styles.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\nconst noopBool = (): boolean => false;\n\nexport interface BaseDialogProps\n extends\n HTMLAttributes<HTMLDivElement>,\n CSSTransitionComponentProps,\n TransitionActions,\n FocusContainerComponentProps {\n /**\n * @defaultValue `\"dialog-\" + useId()`\n */\n id?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @see {@link DialogWidth}\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `\"dialog\"`\n */\n role?: \"dialog\" | \"alertdialog\" | \"menu\" | \"none\";\n\n /**\n * This value controls the visibility of the dialog.\n */\n visible: boolean;\n\n /**\n * This function should set the {@link visible} prop to false to hide the\n * modal when:\n * - the {@link modal} and {@link disableEscapeClose} props are `false` and\n * the user presses the `\"Escape\"` key.\n * - The overlay element is clicked\n */\n onRequestClose: () => void;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /** @defaultValue `-1` */\n tabIndex?: number;\n\n /**\n * Set this value to `true` if the dialog should behave as a modal which\n * prevents the modal from being closed by pressing the `\"Escape\"` key or\n * clicking the overlay. The user **must** click one of the actions within the\n * dialog instead.\n *\n * @defaultValue `false`\n */\n modal?: boolean;\n\n /**\n * Set this to `true` if the dialog should no longer use the `Portal`\n * behavior.\n *\n * @defaultValue `false`\n */\n disablePortal?: boolean;\n\n /**\n * Set this to `true` if you want the page to still be scrollable while the\n * dialog is visible. This should normally be `true` for popovers/fixed\n * dialogs.\n *\n * @defaultValue `type === \"custom\"`\n */\n disableScrollLock?: boolean;\n\n /**\n * Set this to `true` to prevent the dialog from being closed when the\n * `\"Escape\"` key is pressed. This is `true` by default when the {@link modal}\n * prop is `true`\n *\n * @defaultValue `modal`\n */\n disableEscapeClose?: boolean;\n\n /**\n * Set this to `true` if an overlay should not appear behind the dialog.\n *\n * Note: this was changed from `type === \"full-page\"` to `false` so that you\n * can change between full-page and centered based on media queries. If the\n * type changes the overlay would end up rendering above the dialog instead of\n * behind.\n *\n * @see {@link overlayHidden}\n * @defaultValue `false`\n */\n disableOverlay?: boolean;\n\n /**\n * Set this to `true` if an overlay should be appear behind the dialog but\n * have an `opacity: 0`. This is useful if you want to prevent other elements\n * on the page from being clicked while the dialog is visible, but don't want\n * a dark background. i.e. popovers/fixed dialogs.\n *\n * @defaultValue `false`\n */\n overlayHidden?: boolean;\n\n /**\n * Any additional props that should be passed to the overlay element if it is\n * rendered.\n */\n overlayProps?: HTMLAttributes<HTMLSpanElement>;\n\n /**\n * Any additional props that should be passed to the container element when\n * the `type !== \"custom\"`.\n */\n containerProps?: PropsWithRef<ConfigurableDialogContainerProps>;\n\n /**\n * @see {@link DEFAULT_DIALOG_TIMEOUT}\n * @defaultValue `DEFAULT_DIALOG_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link DEFAULT_DIALOG_CLASSNAMES}\n * @defaultValue `DEFAULT_DIALOG_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n\n /**\n * Set this to `true` if the `Dialog` should not gain the normal focus box\n * shadow while it is focused. The `Dialog` should normally only gain focus\n * when it becomes visible and no child elements have `autoFocus` enabled.\n *\n * @since 6.0.0\n * @defaultValue `type === \"full-page\"`\n */\n disableFocusOutline?: boolean;\n}\n\nexport type DialogProps = LabelRequiredForA11y<BaseDialogProps>;\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Dialog } from \"@react-md/core/dialog/Dialog\";\n * import { DialogContent } from \"@react-md/core/dialog/DialogContent\";\n * import { DialogFooter } from \"@react-md/core/dialog/DialogFooter\";\n * import { DialogHeader } from \"@react-md/core/dialog/DialogHeader\";\n * import { DialogTitle } from \"@react-md/core/dialog/DialogTitle\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n * import { useToggle } from \"@react-md/core/useToggle\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const {\n * toggle,\n * disable: onRequestClose,\n * toggled: visible,\n * } = useToggle(false);\n *\n * return (\n * <>\n * <Button onClick={toggle}>Toggle</Button>\n * <Dialog\n * aria-labelledby=\"dialog-title\"\n * visible={visible}\n * onRequestClose={onRequestClose}\n * >\n * <DialogHeader>\n * <DialogTitle id=\"dialog-title\">Simple Dialog</DialogTitle>\n * </DialogHeader>\n * <DialogContent>\n * <Typography margin=\"none\">This is some text in a dialog.</Typography>\n * </DialogContent>\n * <DialogFooter>\n * <Button onClick={onRequestClose}>\n * Close\n * </Button>\n * </DialogFooter>\n * </Dialog>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/dialog | Dialog Demos}\n * @since 6.0.0 The `Dialog` no longer supports focusing elements\n * within once it becomes visible. You must manually add `autoFocus` to a\n * element instead.\n */\nexport const Dialog = forwardRef<HTMLDivElement, DialogProps>(\n function Dialog(props, ref) {\n const {\n id: propId,\n modal = false,\n role = modal ? \"alertdialog\" : \"dialog\",\n type = \"centered\",\n width,\n tabIndex = -1,\n visible,\n onRequestClose,\n containerProps,\n temporary = true,\n className,\n timeout = DEFAULT_DIALOG_TIMEOUT,\n classNames = DEFAULT_DIALOG_CLASSNAMES,\n disableTransition = false,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n exitedHidden = true,\n disableOverlay = false,\n overlayProps,\n overlayHidden,\n onKeyDown = noop,\n isFocusTypeDisabled = noopBool,\n disablePortal: propDisablePortal,\n disableScrollLock = false,\n disableEscapeClose = modal,\n disableFocusOutline = type === \"full-page\",\n children,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"dialog\");\n\n const ssr = useSsr();\n const setChildVisible = useNestedDialogContext();\n\n // this makes it so that as more non-full page dialogs become visible, the\n // overlay does not become darker as more and more overlays are stacked upon\n // each other. only the top-most overlay will have and active background\n // color.\n const [isChildVisible, setIsChildVisible] = useState(false);\n const { eventHandlers, transitionOptions } = useFocusContainer({\n nodeRef: ref,\n activate: visible,\n onEnter(appearing) {\n onEnter(appearing);\n setChildVisible(type !== \"full-page\");\n },\n onEntered(appear) {\n onEntered(appear);\n // this needs to be called onEnter and onEntered just in case the\n // transition is disabled\n setChildVisible(type !== \"full-page\");\n },\n onEntering,\n onExit() {\n onExit();\n setChildVisible(false);\n },\n onExiting,\n onExited() {\n onExited();\n // this needs to be called onExit and onExited just in case the\n // transition is disabled\n setChildVisible(false);\n },\n disableTransition,\n onKeyDown(event) {\n onKeyDown(event);\n if (\n event.isPropagationStopped() ||\n modal ||\n disableEscapeClose ||\n event.key !== \"Escape\"\n ) {\n return;\n }\n\n // prevent parent dialogs from closing as well\n event.stopPropagation();\n onRequestClose();\n },\n isFocusTypeDisabled,\n });\n const { elementProps, stage, rendered, disablePortal } = useCSSTransition({\n transitionIn: visible,\n timeout,\n classNames,\n className: dialog({\n type,\n width,\n fixed: type === \"custom\",\n outline: !disableFocusOutline,\n disableBoxShadow: isChildVisible,\n className,\n }),\n appear: appear && !disableTransition && !ssr,\n enter: enter && !disableTransition,\n exit: exit && !disableTransition,\n temporary,\n exitedHidden,\n disablePortal: propDisablePortal,\n ...transitionOptions,\n });\n useScrollLock(!disableScrollLock && visible);\n\n return (\n <NestedDialogProvider value={setIsChildVisible}>\n {!disableOverlay && (\n <Overlay\n visible={visible}\n disableTransition={disableTransition}\n temporary={temporary}\n disablePortal={disablePortal}\n {...overlayProps}\n onClick={modal ? noop : onRequestClose}\n clickable={!modal}\n noOpacity={overlayHidden || isChildVisible}\n />\n )}\n <Portal disabled={disablePortal}>\n {rendered && (\n <DialogContainer\n enabled={type !== \"custom\"}\n {...containerProps}\n centered={type === \"centered\"}\n displayNone={!temporary && exitedHidden && stage === \"exited\"}\n >\n <div\n aria-modal={modal || undefined}\n {...remaining}\n {...elementProps}\n {...eventHandlers}\n id={id}\n role={role}\n tabIndex={tabIndex}\n >\n {children}\n </div>\n </DialogContainer>\n )}\n </Portal>\n </NestedDialogProvider>\n );\n }\n);\n"],"names":["forwardRef","useState","useSsr","useFocusContainer","Overlay","Portal","useScrollLock","useCSSTransition","useEnsuredId","DialogContainer","NestedDialogProvider","useNestedDialogContext","DEFAULT_DIALOG_CLASSNAMES","DEFAULT_DIALOG_TIMEOUT","dialog","noop","noopBool","Dialog","props","ref","id","propId","modal","role","type","width","tabIndex","visible","onRequestClose","containerProps","temporary","className","timeout","classNames","disableTransition","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","exitedHidden","disableOverlay","overlayProps","overlayHidden","onKeyDown","isFocusTypeDisabled","disablePortal","propDisablePortal","disableScrollLock","disableEscapeClose","disableFocusOutline","children","remaining","ssr","setChildVisible","isChildVisible","setIsChildVisible","eventHandlers","transitionOptions","nodeRef","activate","appearing","event","isPropagationStopped","key","stopPropagation","elementProps","stage","rendered","transitionIn","fixed","outline","disableBoxShadow","value","onClick","clickable","noOpacity","disabled","enabled","centered","displayNone","div","aria-modal","undefined"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AAElE,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAEEC,iBAAiB,QACZ,gCAAgC;AACvC,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,aAAa,QAAQ,6BAA6B;AAO3D,SAASC,gBAAgB,QAAQ,oCAAoC;AAErE,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAEEC,eAAe,QACV,uBAAuB;AAC9B,SACEC,oBAAoB,E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AC/D;oBACCyE,SAAS1D,SAAS;oBACjB,GAAGK,cAAc;oBAClBsD,UAAU3D,SAAS;oBACnB4D,aAAa,CAACtD,aAAac,gBAAgB2B,UAAU;8BAErD,cAAA,KAACc;wBACCC,cAAYhE,SAASiE;wBACpB,GAAG/B,SAAS;wBACZ,GAAGc,YAAY;wBACf,GAAGT,aAAa;wBACjBzC,IAAIA;wBACJG,MAAMA;wBACNG,UAAUA;kCAET6B;;;;;;AAOf,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dialog/DialogContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { dialogContainer } from \"./styles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableDialogContainerProps
|
|
1
|
+
{"version":3,"sources":["../../src/dialog/DialogContainer.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport { dialogContainer } from \"./styles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableDialogContainerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Set to `true` to force the `Dialog` to be wrapped in a `DialogContainer`\n * div. This defaults to `true` for `type !== \"custom\"`.\n */\n enabled?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface DialogContainerProps extends ConfigurableDialogContainerProps {\n enabled: boolean;\n centered: boolean;\n displayNone: boolean;\n children: ReactNode;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const DialogContainer = forwardRef<HTMLDivElement, DialogContainerProps>(\n function DialogContainer(props, ref) {\n const {\n enabled,\n centered,\n displayNone,\n children,\n className,\n ...remaining\n } = props;\n\n if (!enabled) {\n return <>{children}</>;\n }\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={dialogContainer({\n className,\n centered,\n displayNone,\n })}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","dialogContainer","DialogContainer","props","ref","enabled","centered","displayNone","children","className","remaining","div"],"mappings":";AAAA,SAA8CA,UAAU,QAAQ,QAAQ;AAExE,SAASC,eAAe,QAAQ,cAAc;AAwB9C;;;CAGC,GACD,OAAO,MAAMC,gCAAkBF,WAC7B,SAASE,gBAAgBC,KAAK,EAAEC,GAAG;IACjC,MAAM,EACJC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,SAAS,EACT,GAAGC,WACJ,GAAGP;IAEJ,IAAI,CAACE,SAAS;QACZ,qBAAO;sBAAGG;;IACZ;IAEA,qBACE,KAACG;QACE,GAAGD,SAAS;QACbN,KAAKA;QACLK,WAAWR,gBAAgB;YACzBQ;YACAH;YACAC;QACF;kBAECC;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dialog/DialogContent.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DialogContentClassNameOptions, dialogContent } from \"./styles.js\";\n\nexport interface DialogContentProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/dialog/DialogContent.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DialogContentClassNameOptions, dialogContent } from \"./styles.js\";\n\nexport interface DialogContentProps\n extends HTMLAttributes<HTMLDivElement>, DialogContentClassNameOptions {}\n\n/**\n * The `DialogContent` component should be used as a child of the `Dialog`\n * component that applies some reasonable default styles. Look at the `Dialog`\n * or `FixedDialog` components for example usage.\n *\n * @see {@link https://react-md.dev/components/dialog | Dialog Demos}\n */\nexport const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n function DialogContent(props, ref) {\n const { children, className, disablePadding = false, ...remaining } = props;\n return (\n <div\n {...remaining}\n ref={ref}\n className={dialogContent({\n className,\n disablePadding,\n })}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","dialogContent","DialogContent","props","ref","children","className","disablePadding","remaining","div"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAA6CC,aAAa,QAAQ,cAAc;AAKhF;;;;;;CAMC,GACD,OAAO,MAAMC,8BAAgBF,WAC3B,SAASE,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,iBAAiB,KAAK,EAAE,GAAGC,WAAW,GAAGL;IACtE,qBACE,KAACM;QACE,GAAGD,SAAS;QACbJ,KAAKA;QACLE,WAAWL,cAAc;YACvBK;YACAC;QACF;kBAECF;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dialog/DialogFooter.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DialogFooterClassNameOptions, dialogFooter } from \"./styles.js\";\n\nexport interface DialogFooterProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/dialog/DialogFooter.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DialogFooterClassNameOptions, dialogFooter } from \"./styles.js\";\n\nexport interface DialogFooterProps\n extends HTMLAttributes<HTMLDivElement>, DialogFooterClassNameOptions {}\n\n/**\n * The `DialogFooter` is a simple `<footer>` with simple `display: flex` styles\n * applied. Look at the `Dialog` or `FixedDialog` components for example usage.\n *\n * @see {@link https://react-md.dev/components/dialog | Dialog Demos}\n */\nexport const DialogFooter = forwardRef<HTMLDivElement, DialogFooterProps>(\n function DialogFooter(props, ref) {\n const { children, className, align = \"end\", ...remaining } = props;\n return (\n <footer\n {...remaining}\n ref={ref}\n className={dialogFooter({\n align,\n className,\n })}\n >\n {children}\n </footer>\n );\n }\n);\n"],"names":["forwardRef","dialogFooter","DialogFooter","props","ref","children","className","align","remaining","footer"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAA4CC,YAAY,QAAQ,cAAc;AAK9E;;;;;CAKC,GACD,OAAO,MAAMC,6BAAeF,WAC1B,SAASE,aAAaC,KAAK,EAAEC,GAAG;IAC9B,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,KAAK,EAAE,GAAGC,WAAW,GAAGL;IAC7D,qBACE,KAACM;QACE,GAAGD,SAAS;QACbJ,KAAKA;QACLE,WAAWL,aAAa;YACtBM;YACAD;QACF;kBAECD;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { type ElementType, type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DividerClassNameOptions, divider } from \"./styles.js\";\n\nexport type DividerElement = HTMLHRElement | HTMLDivElement;\n\n/**\n * @since 6.0.0 Extends the {@link DividerClassNameOptions}\n */\nexport interface DividerProps\n extends HTMLAttributes<DividerElement
|
|
1
|
+
{"version":3,"sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { type ElementType, type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type DividerClassNameOptions, divider } from \"./styles.js\";\n\nexport type DividerElement = HTMLHRElement | HTMLDivElement;\n\n/**\n * @since 6.0.0 Extends the {@link DividerClassNameOptions}\n */\nexport interface DividerProps\n extends HTMLAttributes<DividerElement>, DividerClassNameOptions {}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Divider } from \"@react-md/core/divider/Divider\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Divider />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/divider | Divider Demos}\n */\nexport const Divider = forwardRef<DividerElement, DividerProps>(\n function Divider(props, ref) {\n const {\n inset = false,\n vertical = false,\n role = \"separator\",\n className,\n ...remaining\n } = props;\n\n const Component = (vertical ? \"div\" : \"hr\") as ElementType;\n\n return (\n <Component\n {...remaining}\n ref={ref}\n role={role}\n className={divider({\n inset,\n vertical,\n className,\n })}\n />\n );\n }\n);\n"],"names":["forwardRef","divider","Divider","props","ref","inset","vertical","role","className","remaining","Component"],"mappings":";AAAA,SAAgDA,UAAU,QAAQ,QAAQ;AAE1E,SAAuCC,OAAO,QAAQ,cAAc;AAUpE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,wBAAUF,WACrB,SAASE,QAAQC,KAAK,EAAEC,GAAG;IACzB,MAAM,EACJC,QAAQ,KAAK,EACbC,WAAW,KAAK,EAChBC,OAAO,WAAW,EAClBC,SAAS,EACT,GAAGC,WACJ,GAAGN;IAEJ,MAAMO,YAAaJ,WAAW,QAAQ;IAEtC,qBACE,KAACI;QACE,GAAGD,SAAS;QACbL,KAAKA;QACLG,MAAMA;QACNC,WAAWP,QAAQ;YACjBI;YACAC;YACAE;QACF;;AAGN,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/draggable/useDraggable.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type HTMLAttributes,\n type Ref,\n type RefCallback,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type NonNullRef,\n type UseStateInitializer,\n type UseStateSetter,\n} from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport { useHtmlClassName } from \"../useHtmlClassName.js\";\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport { getRangeDefaultValue } from \"../utils/getRangeDefaultValue.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\nimport {\n isMouseDragStartEvent,\n isTouchDragStartEvent,\n updateDragPosition,\n} from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type DraggableTouchEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onTouchStart\" | \"onTouchMove\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableMouseEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onMouseDown\" | \"onMouseUp\" | \"onMouseMove\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableKeyboardEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onKeyDown\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableEventHandlers<E extends HTMLElement> =\n DraggableTouchEventHandlers<E> &\n DraggableMouseEventHandlers<E> &\n DraggableKeyboardEventHandlers<E>;\n\n/**\n * @since 6.0.0\n */\nexport interface ControllableDraggableStateOptions {\n value?: number;\n setValue?: UseStateSetter<number>;\n defaultValue?: UseStateInitializer<number>;\n dragging?: boolean;\n setDragging?: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface BaseDraggableOptions<E extends HTMLElement>\n extends DraggableEventHandlers<E>,\n ControllableDraggableStateOptions {\n /**\n * An optional ref to merge with the returned\n * {@link DraggableImplementation.draggableRef}.\n */\n ref?: Ref<E>;\n\n /**\n * The minimum number of pixels allowed for the draggable element. This must\n * be a number greater than or equal to 0.\n *\n * When {@link withinOffsetParent} is set to `true`, this is the minimum value\n * allowed instead of pixels.\n */\n min: number;\n\n /**\n * The maximum number of pixels allowed for the draggable element. This must\n * be a number greater than the {@link min} and usually a number less than the\n * viewport size.\n *\n * When {@link withinOffsetParent} is set to `true`, this is the maximum value\n * allowed instead of pixels.\n */\n max: number;\n\n /**\n * The amount to increment or decrement the value with arrow keys.\n *\n * @defaultValue `1`\n */\n step?: number;\n\n /**\n * This was added to support range sliders where there are two (or more)\n * draggable elements within the same container element and their values\n * cannot pass each other. Without these overrides, the range would keep\n * changing as the other values change, so the drag percentage would be\n * incorrect.\n *\n * @example Range Slider\n * ```ts\n * const min = 0;\n * const max = 100;\n * const minValue = 3;\n * const maxValue = 80;\n *\n * const minValueDraggable = useDraggable({\n * min,\n * max,\n * rangeMax: maxValue,\n * });\n * const maxValueDraggable = useDraggable({\n * min,\n * max,\n * rangeMin: minValue,\n * });\n * ```\n *\n * @defaultValue `min`\n */\n rangeMin?: number;\n\n /**\n * @see {@link rangeMin} for an explanation of this option.\n * @defaultValue `max`\n */\n rangeMax?: number;\n\n /**\n * Set this to `true` to enable dragging vertically instead of horizontally.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n\n /**\n * The default drag behavior is to increase the value when:\n *\n * - dragging `\"right\"` and the writing direction is `\"ltr\"`\n * - dragging `\"left\"` and the writing direction is `\"rtl\"`\n * - dragging `\"upwards\"`\n *\n * When this is set to `true`, the value when increase when:\n *\n * - dragging `\"left\"` and the writing direction is `\"ltr\"`\n * - dragging `\"right\"` and the writing direction is `\"rtl\"`\n * - dragging `\"downwards\"`\n *\n * @defaultValue `false`\n */\n reversed?: boolean;\n\n /**\n * Set this to `true` to disable all drag behavior. This will still call any\n * of the provided {@link DraggableEventHandlers}.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the dragging calculations should be to the\n * `draggableRef.current.offsetParent` instead of the entire window. The main\n * use case for this is sliders.\n *\n * @defaultValue `false`\n */\n withinOffsetParent?: boolean;\n\n /**\n * Set this to `true` to prevent the `document.documentElement` from gaining\n * the `.rmd-dragging` class names while dragging.\n *\n * This should normally remain as `false` to improve performance and prevent\n * other mouse events from firing while dragging.\n *\n * @defaultValue `false`\n */\n disableDraggingClassName?: boolean;\n\n /**\n * Set this to `true` to prevent the vertical or horizontal cursor from\n * appearing while dragging.\n *\n * @defaultValue `false`\n */\n disableDraggingCursorClassName?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface UncontrolledDraggableOptions {\n value?: never;\n setValue?: never;\n dragging?: never;\n setDragging?: never;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ControlledValueDraggableOptions {\n value: number;\n setValue: UseStateSetter<number>;\n defaultValue?: never;\n dragging?: never;\n setDragging?: never;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ControlledDraggingDraggableOptions {\n value?: never;\n setValue?: never;\n defaultValue?: never;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FullyControlledDraggableOptions {\n value: number;\n setValue: UseStateSetter<number>;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type DraggableStateOptions =\n | UncontrolledDraggableOptions\n | ControlledValueDraggableOptions\n | ControlledDraggingDraggableOptions\n | FullyControlledDraggableOptions;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableOptions<E extends HTMLElement = HTMLElement> =\n BaseDraggableOptions<E> & DraggableStateOptions;\n\n/**\n * @since 6.0.0\n */\nexport interface DraggableImplementation<E extends HTMLElement = HTMLElement>\n extends Required<DraggableEventHandlers<E>> {\n mouseEventHandlers: Required<DraggableMouseEventHandlers<E>>;\n touchEventHandlers: Required<DraggableTouchEventHandlers<E>>;\n keyboardEventHandlers: Required<DraggableKeyboardEventHandlers<E>>;\n\n /**\n * Set the {@link value} to {@link DraggableOptions.min}.\n */\n minimum: () => void;\n\n /**\n * Set the {@link value} to {@link DraggableOptions.max}.\n */\n maximum: () => void;\n\n /**\n * Increment the {@link value} by {@link DraggableOptions.step}.\n */\n increment: () => void;\n\n /**\n * Decrement the {@link value} by {@link DraggableOptions.step}.\n */\n decrement: () => void;\n\n /**\n * The current percentage the `value` is within the range.\n *\n * ```ts\n * const percentage =\n * dragging && withinOffsetParent\n * ? : dragPercentage\n * : getPercentage({ min, max, value });\n * ```\n */\n percentage: number;\n\n /**\n * A ref that **Must** be passed to the element that should be draggable.\n */\n draggableRef: RefCallback<E>;\n\n /**\n * This value will only update while dragging with a mouse or touch and should\n * be used for the positioning styles while dragging.\n *\n * Note: The {@link percentage} will use this value while dragging.\n */\n dragPercentage: number;\n\n /**\n * Flag to determine if the user has dragged at least once. Used internally\n * for manually persisting the value into local storage once the user has\n * stopped dragging.\n */\n draggedOnce: NonNullRef<boolean>;\n\n value: number;\n setValue: UseStateSetter<number>;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * This is most likely an internal only hook that provides the functionality for\n * dragging an element through mouse, touch, and keyboard events. The main use\n * cases so far for this hook are:\n * - window splitters\n * - sliders\n *\n * NOTE: This requires `touch-action: none` to be applied to the draggable\n * element to help prevent page scrolling on mobile devices.\n *\n * @see {@link https://react-md.dev/components/use-draggable | useDraggable Demos}\n * @since 6.0.0\n */\nexport function useDraggable<E extends HTMLElement>(\n options: DraggableOptions<E>\n): DraggableImplementation<E> {\n const {\n ref: propRef,\n min,\n max,\n rangeMin = min,\n rangeMax = max,\n step = 1,\n reversed = false,\n vertical = false,\n onKeyDown = noop,\n onMouseUp = noop,\n onMouseDown = noop,\n onMouseMove = noop,\n onTouchStart = noop,\n onTouchMove = noop,\n dragging: propDragging,\n setDragging: propSetDragging,\n value: propValue,\n setValue: propSetValue,\n defaultValue,\n withinOffsetParent = false,\n disabled = false,\n disableDraggingClassName = false,\n disableDraggingCursorClassName = disableDraggingClassName,\n } = options;\n\n const [nodeRef, ref] = useEnsuredRef(propRef);\n const isTouch = useUserInteractionMode() === \"touch\";\n const draggingRef = useRef(false);\n const [dragPercentage, setDragPercentage] = useState(min);\n const [value, setValue] = useEnsuredState({\n value: propValue,\n setValue: propSetValue,\n defaultValue: getRangeDefaultValue({\n min,\n max,\n step: 1,\n defaultValue,\n }),\n });\n const [dragging, setDragging] = useEnsuredState({\n value: propDragging,\n setValue: propSetDragging,\n defaultValue: false,\n });\n\n const isRTL = useDir().dir === \"rtl\";\n const percentage =\n dragging && withinOffsetParent\n ? dragPercentage\n : getPercentage({ min, max, value });\n const maximum = useCallback(() => {\n setValue(max);\n }, [max, setValue]);\n const minimum = useCallback(() => {\n setValue(min);\n }, [min, setValue]);\n const increment = useCallback(() => {\n setValue((prevValue) => withinRange({ min, max, value: prevValue + step }));\n }, [max, min, setValue, step]);\n const decrement = useCallback(() => {\n setValue((prevValue) => withinRange({ min, max, value: prevValue - step }));\n }, [max, min, setValue, step]);\n\n const draggingClassName = dragging && !disableDraggingClassName;\n useHtmlClassName(cnb(draggingClassName && \"rmd-dragging\"));\n useHtmlClassName(\n cnb(\n !disableDraggingCursorClassName &&\n draggingClassName &&\n `rmd-dragging--${vertical ? \"v\" : \"h\"}`\n )\n );\n\n const draggedOnce = useRef(false);\n useEffect(() => {\n if (!dragging) {\n return;\n }\n\n draggedOnce.current = true;\n const updatePosition = (event: MouseEvent | TouchEvent): void => {\n if (!event.cancelable) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n updateDragPosition({\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n isDragStart: false,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n };\n\n const stopDragging = (event: MouseEvent | TouchEvent): void => {\n updatePosition(event);\n setDragging(false);\n draggingRef.current = false;\n // blur the element so that it no longer maintains the `:focus-visible`\n // styles if they were applied. pressing tab would re-focus this element\n // so the tab order is preserved\n nodeRef.current?.blur();\n };\n\n const updateKey = isTouch ? \"touchmove\" : \"mousemove\";\n const stopKey = isTouch ? \"touchend\" : \"mouseup\";\n const passive = isTouch ? { passive: false } : undefined;\n\n window.addEventListener(updateKey, updatePosition, passive);\n window.addEventListener(stopKey, stopDragging);\n return () => {\n window.removeEventListener(updateKey, updatePosition);\n window.removeEventListener(stopKey, stopDragging);\n };\n }, [\n dragging,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]);\n\n const prevRange = useRef({ min, max, step });\n useEffect(() => {\n if (\n prevRange.current.min === min &&\n prevRange.current.max === max &&\n prevRange.current.step === step\n ) {\n return;\n }\n\n prevRange.current = { min, max, step };\n setValue((prevValue) =>\n nearest({\n min,\n max,\n steps: getRangeSteps({ min, max, step }),\n value: prevValue,\n })\n );\n }, [max, min, setValue, step]);\n\n const mouseEventHandlers: Required<DraggableMouseEventHandlers<E>> = {\n onMouseDown: useCallback(\n (event) => {\n onMouseDown(event);\n if (disabled || isTouch || !isMouseDragStartEvent(event)) {\n return;\n }\n\n // don't allow text to be selected\n event.preventDefault();\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n\n // don't set dragging immediately so that click events can still happen\n draggingRef.current = true;\n },\n [\n disabled,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n onMouseDown,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onMouseMove: useCallback(\n (event) => {\n onMouseMove(event);\n if (disabled || isTouch || !draggingRef.current || dragging) {\n return;\n }\n\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n setDragging(true);\n },\n [\n disabled,\n dragging,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n onMouseMove,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onMouseUp: useCallback(\n (event) => {\n onMouseUp(event);\n if (disabled || isTouch) {\n return;\n }\n\n draggingRef.current = false;\n },\n [disabled, isTouch, onMouseUp]\n ),\n };\n const keyboardEventHandlers: Required<DraggableKeyboardEventHandlers<E>> = {\n onKeyDown: useCallback(\n (event) => {\n onKeyDown(event);\n if (disabled) {\n return;\n }\n\n const decrementKey = vertical ? \"ArrowDown\" : \"ArrowLeft\";\n const incrementKey = vertical ? \"ArrowUp\" : \"ArrowRight\";\n\n switch (event.key) {\n case decrementKey:\n event.preventDefault();\n decrement();\n break;\n case incrementKey:\n event.preventDefault();\n increment();\n break;\n case \"Home\":\n event.preventDefault();\n minimum();\n break;\n case \"End\":\n event.preventDefault();\n maximum();\n break;\n }\n },\n [decrement, disabled, increment, maximum, minimum, onKeyDown, vertical]\n ),\n };\n\n // touch devices are a bit weird and cause issues since the \"start\" event is\n // also used for scrolling. If the user quickly grabs the draggable element\n // and drags vertically, most of the time it will try to scroll instead of\n // dragging the element. The workaround is to being the drag events\n // immediately on touchstart and disable scroll behavior for the page.\n //\n // There are also some issues with calling `event.preventDefault()` within\n // touch events even while `{ passive: false } is manually set, so need to\n // also attach a touchmove event.\n useScrollLock(isTouch && dragging);\n const touchEventHandlers: Required<DraggableTouchEventHandlers<E>> = {\n onTouchStart: useCallback(\n (event) => {\n onTouchStart(event);\n if (disabled || !isTouchDragStartEvent(event)) {\n return;\n }\n\n draggingRef.current = true;\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n },\n [\n disabled,\n isRTL,\n max,\n min,\n nodeRef,\n onTouchStart,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onTouchMove: useCallback(\n (event) => {\n onTouchMove(event);\n if (disabled || !draggingRef.current || !event.cancelable) {\n return;\n }\n\n // prevent the document's touchmove event from also firing\n event.stopPropagation();\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n },\n [\n disabled,\n isRTL,\n max,\n min,\n nodeRef,\n onTouchMove,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n };\n\n return {\n ...touchEventHandlers,\n ...mouseEventHandlers,\n ...keyboardEventHandlers,\n value,\n setValue,\n dragging,\n setDragging,\n maximum,\n minimum,\n increment,\n decrement,\n draggedOnce,\n draggableRef: ref,\n percentage,\n dragPercentage,\n touchEventHandlers,\n mouseEventHandlers,\n keyboardEventHandlers,\n };\n}\n"],"names":["cnb","useCallback","useEffect","useRef","useState","useUserInteractionMode","useScrollLock","useDir","useEnsuredRef","useEnsuredState","useHtmlClassName","getPercentage","getRangeDefaultValue","getRangeSteps","nearest","withinRange","isMouseDragStartEvent","isTouchDragStartEvent","updateDragPosition","noop","useDraggable","options","ref","propRef","min","max","rangeMin","rangeMax","step","reversed","vertical","onKeyDown","onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchMove","dragging","propDragging","setDragging","propSetDragging","value","propValue","setValue","propSetValue","defaultValue","withinOffsetParent","disabled","disableDraggingClassName","disableDraggingCursorClassName","nodeRef","isTouch","draggingRef","dragPercentage","setDragPercentage","isRTL","dir","percentage","maximum","minimum","increment","prevValue","decrement","draggingClassName","draggedOnce","current","updatePosition","event","cancelable","preventDefault","stopPropagation","isDragStart","stopDragging","blur","updateKey","stopKey","passive","undefined","window","addEventListener","removeEventListener","prevRange","steps","mouseEventHandlers","keyboardEventHandlers","decrementKey","incrementKey","key","touchEventHandlers","draggableRef"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAIEC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAEf,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,aAAa,QAAQ,6BAA6B;AAM3D,SAASC,MAAM,QAAQ,4CAA4C;AACnE,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,oB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Ac6C,WAAWd;IACzB,MAAMmD,qBAA+D;QACnErD,cAAclC,YACZ,CAACkE;YACChC,aAAagC;YACb,IAAIpB,YAAY,CAAC9B,sBAAsBkD,QAAQ;gBAC7C;YACF;YAEAf,YAAYa,OAAO,GAAG;YACtB/C,mBAAmB;gBACjBqD,aAAa;gBACbJ;gBACAjB;gBACA1B;gBACAC;gBACAG;gBACAF;gBACAC;gBACA4B;gBACA1B;gBACAC;gBACAa;gBACAJ;gBACAe;gBACAR;YACF;QACF,GACA;YACEC;YACAQ;YACA9B;YACAD;YACA0B;YACAf;YACAR;YACAD;YACAG;YACAU;YACAI;YACAf;YACAE;YACAgB;SACD;QAEHV,aAAanC,YACX,CAACkE;YACC/B,YAAY+B;YACZ,IAAIpB,YAAY,CAACK,YAAYa,OAAO,IAAI,CAACE,MAAMC,UAAU,EAAE;gBACzD;YACF;YAEA,0DAA0D;YAC1DD,MAAMG,eAAe;YACrBpD,mBAAmB;gBACjBqD,aAAa;gBACbJ;gBACAjB;gBACA1B;gBACAC;gBACAG;gBACAF;gBACAC;gBACA4B;gBACA1B;gBACAC;gBACAa;gBACAJ;gBACAe;gBACAR;YACF;QACF,GACA;YACEC;YACAQ;YACA9B;YACAD;YACA0B;YACAd;YACAT;YACAD;YACAG;YACAU;YACAI;YACAf;YACAE;YACAgB;SACD;IAEL;IAEA,OAAO;QACL,GAAG0C,kBAAkB;QACrB,GAAGL,kBAAkB;QACrB,GAAGC,qBAAqB;QACxB3C;QACAE;QACAN;QACAE;QACAmB;QACAC;QACAC;QACAE;QACAE;QACAyB,cAAcnE;QACdmC;QACAJ;QACAmC;QACAL;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/draggable/useDraggable.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type HTMLAttributes,\n type Ref,\n type RefCallback,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useScrollLock } from \"../scroll/useScrollLock.js\";\nimport {\n type NonNullRef,\n type UseStateInitializer,\n type UseStateSetter,\n} from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport { useHtmlClassName } from \"../useHtmlClassName.js\";\nimport { getPercentage } from \"../utils/getPercentage.js\";\nimport { getRangeDefaultValue } from \"../utils/getRangeDefaultValue.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\nimport {\n isMouseDragStartEvent,\n isTouchDragStartEvent,\n updateDragPosition,\n} from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type DraggableTouchEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onTouchStart\" | \"onTouchMove\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableMouseEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onMouseDown\" | \"onMouseUp\" | \"onMouseMove\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableKeyboardEventHandlers<E extends HTMLElement> = Pick<\n HTMLAttributes<E>,\n \"onKeyDown\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableEventHandlers<E extends HTMLElement> =\n DraggableTouchEventHandlers<E> &\n DraggableMouseEventHandlers<E> &\n DraggableKeyboardEventHandlers<E>;\n\n/**\n * @since 6.0.0\n */\nexport interface ControllableDraggableStateOptions {\n value?: number;\n setValue?: UseStateSetter<number>;\n defaultValue?: UseStateInitializer<number>;\n dragging?: boolean;\n setDragging?: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface BaseDraggableOptions<E extends HTMLElement>\n extends DraggableEventHandlers<E>, ControllableDraggableStateOptions {\n /**\n * An optional ref to merge with the returned\n * {@link DraggableImplementation.draggableRef}.\n */\n ref?: Ref<E>;\n\n /**\n * The minimum number of pixels allowed for the draggable element. This must\n * be a number greater than or equal to 0.\n *\n * When {@link withinOffsetParent} is set to `true`, this is the minimum value\n * allowed instead of pixels.\n */\n min: number;\n\n /**\n * The maximum number of pixels allowed for the draggable element. This must\n * be a number greater than the {@link min} and usually a number less than the\n * viewport size.\n *\n * When {@link withinOffsetParent} is set to `true`, this is the maximum value\n * allowed instead of pixels.\n */\n max: number;\n\n /**\n * The amount to increment or decrement the value with arrow keys.\n *\n * @defaultValue `1`\n */\n step?: number;\n\n /**\n * This was added to support range sliders where there are two (or more)\n * draggable elements within the same container element and their values\n * cannot pass each other. Without these overrides, the range would keep\n * changing as the other values change, so the drag percentage would be\n * incorrect.\n *\n * @example Range Slider\n * ```ts\n * const min = 0;\n * const max = 100;\n * const minValue = 3;\n * const maxValue = 80;\n *\n * const minValueDraggable = useDraggable({\n * min,\n * max,\n * rangeMax: maxValue,\n * });\n * const maxValueDraggable = useDraggable({\n * min,\n * max,\n * rangeMin: minValue,\n * });\n * ```\n *\n * @defaultValue `min`\n */\n rangeMin?: number;\n\n /**\n * @see {@link rangeMin} for an explanation of this option.\n * @defaultValue `max`\n */\n rangeMax?: number;\n\n /**\n * Set this to `true` to enable dragging vertically instead of horizontally.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n\n /**\n * The default drag behavior is to increase the value when:\n *\n * - dragging `\"right\"` and the writing direction is `\"ltr\"`\n * - dragging `\"left\"` and the writing direction is `\"rtl\"`\n * - dragging `\"upwards\"`\n *\n * When this is set to `true`, the value when increase when:\n *\n * - dragging `\"left\"` and the writing direction is `\"ltr\"`\n * - dragging `\"right\"` and the writing direction is `\"rtl\"`\n * - dragging `\"downwards\"`\n *\n * @defaultValue `false`\n */\n reversed?: boolean;\n\n /**\n * Set this to `true` to disable all drag behavior. This will still call any\n * of the provided {@link DraggableEventHandlers}.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the dragging calculations should be to the\n * `draggableRef.current.offsetParent` instead of the entire window. The main\n * use case for this is sliders.\n *\n * @defaultValue `false`\n */\n withinOffsetParent?: boolean;\n\n /**\n * Set this to `true` to prevent the `document.documentElement` from gaining\n * the `.rmd-dragging` class names while dragging.\n *\n * This should normally remain as `false` to improve performance and prevent\n * other mouse events from firing while dragging.\n *\n * @defaultValue `false`\n */\n disableDraggingClassName?: boolean;\n\n /**\n * Set this to `true` to prevent the vertical or horizontal cursor from\n * appearing while dragging.\n *\n * @defaultValue `false`\n */\n disableDraggingCursorClassName?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface UncontrolledDraggableOptions {\n value?: never;\n setValue?: never;\n dragging?: never;\n setDragging?: never;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ControlledValueDraggableOptions {\n value: number;\n setValue: UseStateSetter<number>;\n defaultValue?: never;\n dragging?: never;\n setDragging?: never;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ControlledDraggingDraggableOptions {\n value?: never;\n setValue?: never;\n defaultValue?: never;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface FullyControlledDraggableOptions {\n value: number;\n setValue: UseStateSetter<number>;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * @since 6.0.0\n */\nexport type DraggableStateOptions =\n | UncontrolledDraggableOptions\n | ControlledValueDraggableOptions\n | ControlledDraggingDraggableOptions\n | FullyControlledDraggableOptions;\n\n/**\n * @since 6.0.0\n */\nexport type DraggableOptions<E extends HTMLElement = HTMLElement> =\n BaseDraggableOptions<E> & DraggableStateOptions;\n\n/**\n * @since 6.0.0\n */\nexport interface DraggableImplementation<\n E extends HTMLElement = HTMLElement,\n> extends Required<DraggableEventHandlers<E>> {\n mouseEventHandlers: Required<DraggableMouseEventHandlers<E>>;\n touchEventHandlers: Required<DraggableTouchEventHandlers<E>>;\n keyboardEventHandlers: Required<DraggableKeyboardEventHandlers<E>>;\n\n /**\n * Set the {@link value} to {@link DraggableOptions.min}.\n */\n minimum: () => void;\n\n /**\n * Set the {@link value} to {@link DraggableOptions.max}.\n */\n maximum: () => void;\n\n /**\n * Increment the {@link value} by {@link DraggableOptions.step}.\n */\n increment: () => void;\n\n /**\n * Decrement the {@link value} by {@link DraggableOptions.step}.\n */\n decrement: () => void;\n\n /**\n * The current percentage the `value` is within the range.\n *\n * ```ts\n * const percentage =\n * dragging && withinOffsetParent\n * ? : dragPercentage\n * : getPercentage({ min, max, value });\n * ```\n */\n percentage: number;\n\n /**\n * A ref that **Must** be passed to the element that should be draggable.\n */\n draggableRef: RefCallback<E>;\n\n /**\n * This value will only update while dragging with a mouse or touch and should\n * be used for the positioning styles while dragging.\n *\n * Note: The {@link percentage} will use this value while dragging.\n */\n dragPercentage: number;\n\n /**\n * Flag to determine if the user has dragged at least once. Used internally\n * for manually persisting the value into local storage once the user has\n * stopped dragging.\n */\n draggedOnce: NonNullRef<boolean>;\n\n value: number;\n setValue: UseStateSetter<number>;\n dragging: boolean;\n setDragging: UseStateSetter<boolean>;\n}\n\n/**\n * This is most likely an internal only hook that provides the functionality for\n * dragging an element through mouse, touch, and keyboard events. The main use\n * cases so far for this hook are:\n * - window splitters\n * - sliders\n *\n * NOTE: This requires `touch-action: none` to be applied to the draggable\n * element to help prevent page scrolling on mobile devices.\n *\n * @see {@link https://react-md.dev/components/use-draggable | useDraggable Demos}\n * @since 6.0.0\n */\nexport function useDraggable<E extends HTMLElement>(\n options: DraggableOptions<E>\n): DraggableImplementation<E> {\n const {\n ref: propRef,\n min,\n max,\n rangeMin = min,\n rangeMax = max,\n step = 1,\n reversed = false,\n vertical = false,\n onKeyDown = noop,\n onMouseUp = noop,\n onMouseDown = noop,\n onMouseMove = noop,\n onTouchStart = noop,\n onTouchMove = noop,\n dragging: propDragging,\n setDragging: propSetDragging,\n value: propValue,\n setValue: propSetValue,\n defaultValue,\n withinOffsetParent = false,\n disabled = false,\n disableDraggingClassName = false,\n disableDraggingCursorClassName = disableDraggingClassName,\n } = options;\n\n const [nodeRef, ref] = useEnsuredRef(propRef);\n const isTouch = useUserInteractionMode() === \"touch\";\n const draggingRef = useRef(false);\n const [dragPercentage, setDragPercentage] = useState(min);\n const [value, setValue] = useEnsuredState({\n value: propValue,\n setValue: propSetValue,\n defaultValue: getRangeDefaultValue({\n min,\n max,\n step: 1,\n defaultValue,\n }),\n });\n const [dragging, setDragging] = useEnsuredState({\n value: propDragging,\n setValue: propSetDragging,\n defaultValue: false,\n });\n\n const isRTL = useDir().dir === \"rtl\";\n const percentage =\n dragging && withinOffsetParent\n ? dragPercentage\n : getPercentage({ min, max, value });\n const maximum = useCallback(() => {\n setValue(max);\n }, [max, setValue]);\n const minimum = useCallback(() => {\n setValue(min);\n }, [min, setValue]);\n const increment = useCallback(() => {\n setValue((prevValue) => withinRange({ min, max, value: prevValue + step }));\n }, [max, min, setValue, step]);\n const decrement = useCallback(() => {\n setValue((prevValue) => withinRange({ min, max, value: prevValue - step }));\n }, [max, min, setValue, step]);\n\n const draggingClassName = dragging && !disableDraggingClassName;\n useHtmlClassName(cnb(draggingClassName && \"rmd-dragging\"));\n useHtmlClassName(\n cnb(\n !disableDraggingCursorClassName &&\n draggingClassName &&\n `rmd-dragging--${vertical ? \"v\" : \"h\"}`\n )\n );\n\n const draggedOnce = useRef(false);\n useEffect(() => {\n if (!dragging) {\n return;\n }\n\n draggedOnce.current = true;\n const updatePosition = (event: MouseEvent | TouchEvent): void => {\n if (!event.cancelable) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n updateDragPosition({\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n isDragStart: false,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n };\n\n const stopDragging = (event: MouseEvent | TouchEvent): void => {\n updatePosition(event);\n setDragging(false);\n draggingRef.current = false;\n // blur the element so that it no longer maintains the `:focus-visible`\n // styles if they were applied. pressing tab would re-focus this element\n // so the tab order is preserved\n nodeRef.current?.blur();\n };\n\n const updateKey = isTouch ? \"touchmove\" : \"mousemove\";\n const stopKey = isTouch ? \"touchend\" : \"mouseup\";\n const passive = isTouch ? { passive: false } : undefined;\n\n window.addEventListener(updateKey, updatePosition, passive);\n window.addEventListener(stopKey, stopDragging);\n return () => {\n window.removeEventListener(updateKey, updatePosition);\n window.removeEventListener(stopKey, stopDragging);\n };\n }, [\n dragging,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]);\n\n const prevRange = useRef({ min, max, step });\n useEffect(() => {\n if (\n prevRange.current.min === min &&\n prevRange.current.max === max &&\n prevRange.current.step === step\n ) {\n return;\n }\n\n prevRange.current = { min, max, step };\n setValue((prevValue) =>\n nearest({\n min,\n max,\n steps: getRangeSteps({ min, max, step }),\n value: prevValue,\n })\n );\n }, [max, min, setValue, step]);\n\n const mouseEventHandlers: Required<DraggableMouseEventHandlers<E>> = {\n onMouseDown: useCallback(\n (event) => {\n onMouseDown(event);\n if (disabled || isTouch || !isMouseDragStartEvent(event)) {\n return;\n }\n\n // don't allow text to be selected\n event.preventDefault();\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n\n // don't set dragging immediately so that click events can still happen\n draggingRef.current = true;\n },\n [\n disabled,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n onMouseDown,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onMouseMove: useCallback(\n (event) => {\n onMouseMove(event);\n if (disabled || isTouch || !draggingRef.current || dragging) {\n return;\n }\n\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n setDragging(true);\n },\n [\n disabled,\n dragging,\n isRTL,\n isTouch,\n max,\n min,\n nodeRef,\n onMouseMove,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onMouseUp: useCallback(\n (event) => {\n onMouseUp(event);\n if (disabled || isTouch) {\n return;\n }\n\n draggingRef.current = false;\n },\n [disabled, isTouch, onMouseUp]\n ),\n };\n const keyboardEventHandlers: Required<DraggableKeyboardEventHandlers<E>> = {\n onKeyDown: useCallback(\n (event) => {\n onKeyDown(event);\n if (disabled) {\n return;\n }\n\n const decrementKey = vertical ? \"ArrowDown\" : \"ArrowLeft\";\n const incrementKey = vertical ? \"ArrowUp\" : \"ArrowRight\";\n\n switch (event.key) {\n case decrementKey:\n event.preventDefault();\n decrement();\n break;\n case incrementKey:\n event.preventDefault();\n increment();\n break;\n case \"Home\":\n event.preventDefault();\n minimum();\n break;\n case \"End\":\n event.preventDefault();\n maximum();\n break;\n }\n },\n [decrement, disabled, increment, maximum, minimum, onKeyDown, vertical]\n ),\n };\n\n // touch devices are a bit weird and cause issues since the \"start\" event is\n // also used for scrolling. If the user quickly grabs the draggable element\n // and drags vertically, most of the time it will try to scroll instead of\n // dragging the element. The workaround is to being the drag events\n // immediately on touchstart and disable scroll behavior for the page.\n //\n // There are also some issues with calling `event.preventDefault()` within\n // touch events even while `{ passive: false } is manually set, so need to\n // also attach a touchmove event.\n useScrollLock(isTouch && dragging);\n const touchEventHandlers: Required<DraggableTouchEventHandlers<E>> = {\n onTouchStart: useCallback(\n (event) => {\n onTouchStart(event);\n if (disabled || !isTouchDragStartEvent(event)) {\n return;\n }\n\n draggingRef.current = true;\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n },\n [\n disabled,\n isRTL,\n max,\n min,\n nodeRef,\n onTouchStart,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n onTouchMove: useCallback(\n (event) => {\n onTouchMove(event);\n if (disabled || !draggingRef.current || !event.cancelable) {\n return;\n }\n\n // prevent the document's touchmove event from also firing\n event.stopPropagation();\n updateDragPosition({\n isDragStart: true,\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n });\n },\n [\n disabled,\n isRTL,\n max,\n min,\n nodeRef,\n onTouchMove,\n rangeMax,\n rangeMin,\n reversed,\n setDragging,\n setValue,\n step,\n vertical,\n withinOffsetParent,\n ]\n ),\n };\n\n return {\n ...touchEventHandlers,\n ...mouseEventHandlers,\n ...keyboardEventHandlers,\n value,\n setValue,\n dragging,\n setDragging,\n maximum,\n minimum,\n increment,\n decrement,\n draggedOnce,\n draggableRef: ref,\n percentage,\n dragPercentage,\n touchEventHandlers,\n mouseEventHandlers,\n keyboardEventHandlers,\n };\n}\n"],"names":["cnb","useCallback","useEffect","useRef","useState","useUserInteractionMode","useScrollLock","useDir","useEnsuredRef","useEnsuredState","useHtmlClassName","getPercentage","getRangeDefaultValue","getRangeSteps","nearest","withinRange","isMouseDragStartEvent","isTouchDragStartEvent","updateDragPosition","noop","useDraggable","options","ref","propRef","min","max","rangeMin","rangeMax","step","reversed","vertical","onKeyDown","onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchMove","dragging","propDragging","setDragging","propSetDragging","value","propValue","setValue","propSetValue","defaultValue","withinOffsetParent","disabled","disableDraggingClassName","disableDraggingCursorClassName","nodeRef","isTouch","draggingRef","dragPercentage","setDragPercentage","isRTL","dir","percentage","maximum","minimum","increment","prevValue","decrement","draggingClassName","draggedOnce","current","updatePosition","event","cancelable","preventDefault","stopPropagation","isDragStart","stopDragging","blur","updateKey","stopKey","passive","undefined","window","addEventListener","removeEventListener","prevRange","steps","mouseEventHandlers","keyboardEventHandlers","decrementKey","incrementKey","key","touchEventHandlers","draggableRef"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAIEC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAEf,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,aAAa,QAAQ,6BAA6B;AAM3D,SAASC,MAAM,QAAQ,4CAA4C;AACnE,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,oBAAoB,QAAQ,mCAAmC;AACxE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,kBAAkB,QACb,aAAa;AAEpB,MAAMC,OAAO;AACX,aAAa;AACf;AAgTA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,aACdC,OAA4B;IAE5B,MAAM,EACJC,KAAKC,OAAO,EACZC,GAAG,EACHC,GAAG,EACHC,WAAWF,GAAG,EACdG,WAAWF,GAAG,EACdG,OAAO,CAAC,EACRC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,YAAYZ,IAAI,EAChBa,YAAYb,IAAI,EAChBc,cAAcd,IAAI,EAClBe,cAAcf,IAAI,EAClBgB,eAAehB,IAAI,EACnBiB,cAAcjB,IAAI,EAClBkB,UAAUC,YAAY,EACtBC,aAAaC,eAAe,EAC5BC,OAAOC,SAAS,EAChBC,UAAUC,YAAY,EACtBC,YAAY,EAC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;gBACA4B;gBACA1B;gBACAC;gBACAa;gBACAJ;gBACAe;gBACAR;YACF;QACF,GACA;YACEC;YACAQ;YACA9B;YACAD;YACA0B;YACAd;YACAT;YACAD;YACAG;YACAU;YACAI;YACAf;YACAE;YACAgB;SACD;IAEL;IAEA,OAAO;QACL,GAAG0C,kBAAkB;QACrB,GAAGL,kBAAkB;QACrB,GAAGC,qBAAqB;QACxB3C;QACAE;QACAN;QACAE;QACAmB;QACAC;QACAC;QACAE;QACAE;QACAyB,cAAcnE;QACdmC;QACAJ;QACAmC;QACAL;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/draggable/utils.ts"],"sourcesContent":["import { type MouseEvent, type RefObject, type TouchEvent } from \"react\";\n\nimport { type MinMaxRange } from \"../types.js\";\nimport {\n type ClientPositionEvent,\n type ClientPositionOptions,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\n\n/**\n * @internal\n */\nexport const isMouseDragStartEvent = (event: MouseEvent): boolean =>\n event.button === 0 &&\n !event.altKey &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey;\n\n/**\n * @internal\n */\nexport const isTouchDragStartEvent = (event: TouchEvent): boolean =>\n event.changedTouches.length === 1;\n\n/**\n * @internal\n */\ninterface DragPositionOptions extends ClientPositionOptions {\n isRTL: boolean;\n reversed: boolean;\n container: Element;\n}\n\n/**\n * @internal\n */\nexport const getDragPosition = (options: DragPositionOptions): number => {\n const { isRTL, reversed, vertical, container } = options;\n\n const clientPosition = getClientPosition(options);\n const { left, right, top } = container.getBoundingClientRect();\n if (vertical) {\n if (reversed) {\n return window.innerHeight - clientPosition;\n }\n\n // added `Math.max` since the `top` will be a negative number if rendered\n // within a portal element like a dialog/sheet\n return clientPosition - Math.max(0, top);\n }\n\n if (reversed ? !isRTL : isRTL) {\n return right - clientPosition;\n }\n\n return clientPosition - left;\n};\n\n/**\n * @internal\n */\ninterface RelativeDragPositionOptions extends DragPositionOptions, MinMaxRange {\n step: number;\n rangeMin: number;\n rangeMax: number;\n}\n\n/**\n * @internal\n */\ninterface RelativeDragPosition {\n value: number;\n dragPercentage: number;\n}\n\n/**\n * @internal\n */\nexport const getRelativeDragPosition = (\n options: RelativeDragPositionOptions\n): RelativeDragPosition => {\n const { min, max, rangeMin, rangeMax, step, isRTL, vertical, container } =\n options;\n\n const { height, width, left, top } = container.getBoundingClientRect();\n const containerSize = vertical ? height : width;\n const containerPosition = vertical ? top + height : left;\n const clientPosition = getClientPosition(options);\n\n const position = vertical\n ? containerPosition - clientPosition\n : clientPosition - containerPosition;\n const distanceDragged = Math.min(Math.max(0, position), containerSize);\n let dragPercentage = distanceDragged / containerSize;\n if (isRTL && !vertical) {\n dragPercentage = 1 - dragPercentage;\n }\n\n const range = rangeMax - rangeMin;\n const steps = getRangeSteps({ min: rangeMin, max: rangeMax, step });\n const value = dragPercentage * range + rangeMin;\n const nextValue = nearest({\n min,\n max,\n steps,\n range,\n value,\n });\n\n return {\n value: nextValue,\n dragPercentage,\n };\n};\n\n/**\n * @internal\n */\ninterface UpdateDragPositionOptions
|
|
1
|
+
{"version":3,"sources":["../../src/draggable/utils.ts"],"sourcesContent":["import { type MouseEvent, type RefObject, type TouchEvent } from \"react\";\n\nimport { type MinMaxRange } from \"../types.js\";\nimport {\n type ClientPositionEvent,\n type ClientPositionOptions,\n getClientPosition,\n} from \"../utils/getClientPosition.js\";\nimport { getRangeSteps } from \"../utils/getRangeSteps.js\";\nimport { nearest } from \"../utils/nearest.js\";\nimport { withinRange } from \"../utils/withinRange.js\";\n\n/**\n * @internal\n */\nexport const isMouseDragStartEvent = (event: MouseEvent): boolean =>\n event.button === 0 &&\n !event.altKey &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey;\n\n/**\n * @internal\n */\nexport const isTouchDragStartEvent = (event: TouchEvent): boolean =>\n event.changedTouches.length === 1;\n\n/**\n * @internal\n */\ninterface DragPositionOptions extends ClientPositionOptions {\n isRTL: boolean;\n reversed: boolean;\n container: Element;\n}\n\n/**\n * @internal\n */\nexport const getDragPosition = (options: DragPositionOptions): number => {\n const { isRTL, reversed, vertical, container } = options;\n\n const clientPosition = getClientPosition(options);\n const { left, right, top } = container.getBoundingClientRect();\n if (vertical) {\n if (reversed) {\n return window.innerHeight - clientPosition;\n }\n\n // added `Math.max` since the `top` will be a negative number if rendered\n // within a portal element like a dialog/sheet\n return clientPosition - Math.max(0, top);\n }\n\n if (reversed ? !isRTL : isRTL) {\n return right - clientPosition;\n }\n\n return clientPosition - left;\n};\n\n/**\n * @internal\n */\ninterface RelativeDragPositionOptions extends DragPositionOptions, MinMaxRange {\n step: number;\n rangeMin: number;\n rangeMax: number;\n}\n\n/**\n * @internal\n */\ninterface RelativeDragPosition {\n value: number;\n dragPercentage: number;\n}\n\n/**\n * @internal\n */\nexport const getRelativeDragPosition = (\n options: RelativeDragPositionOptions\n): RelativeDragPosition => {\n const { min, max, rangeMin, rangeMax, step, isRTL, vertical, container } =\n options;\n\n const { height, width, left, top } = container.getBoundingClientRect();\n const containerSize = vertical ? height : width;\n const containerPosition = vertical ? top + height : left;\n const clientPosition = getClientPosition(options);\n\n const position = vertical\n ? containerPosition - clientPosition\n : clientPosition - containerPosition;\n const distanceDragged = Math.min(Math.max(0, position), containerSize);\n let dragPercentage = distanceDragged / containerSize;\n if (isRTL && !vertical) {\n dragPercentage = 1 - dragPercentage;\n }\n\n const range = rangeMax - rangeMin;\n const steps = getRangeSteps({ min: rangeMin, max: rangeMax, step });\n const value = dragPercentage * range + rangeMin;\n const nextValue = nearest({\n min,\n max,\n steps,\n range,\n value,\n });\n\n return {\n value: nextValue,\n dragPercentage,\n };\n};\n\n/**\n * @internal\n */\ninterface UpdateDragPositionOptions extends Omit<\n RelativeDragPositionOptions,\n \"container\"\n> {\n event: ClientPositionEvent;\n nodeRef: RefObject<HTMLElement>;\n focus?: boolean;\n isDragStart: boolean;\n setValue: (value: number) => void;\n setDragging: (dragging: boolean) => void;\n setDragPercentage: (value: number) => void;\n withinOffsetParent: boolean;\n}\n\n/**\n * @internal\n */\nexport const updateDragPosition = (\n options: UpdateDragPositionOptions\n): void => {\n const {\n event,\n nodeRef,\n min,\n max,\n step,\n rangeMin,\n rangeMax,\n isRTL,\n reversed,\n vertical,\n isDragStart,\n setValue,\n setDragging,\n setDragPercentage,\n withinOffsetParent,\n } = options;\n\n const element = nodeRef.current;\n if (!element) {\n return;\n }\n\n if (isDragStart) {\n // need to focus so that Chromium based browsers allow drag events. this\n // really appeared while trying to create a DnD tree\n element.focus({ preventScroll: true });\n\n if (!withinOffsetParent && !(\"changedTouches\" in event)) {\n return;\n }\n\n // unlike the other flow, start dragging immediately so that you can trigger\n // a mousedown or touchstart event on the container element and drag until\n // the user lets go\n setDragging(true);\n }\n\n // firefox defaults to `document.body` while chrome will return `null`\n const container = element.offsetParent || document.body;\n if (!withinOffsetParent) {\n const dragPosition = getDragPosition({\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n const nextValue = withinRange({\n min,\n max,\n value: dragPosition,\n });\n setValue(nextValue);\n\n return;\n }\n\n const { value, dragPercentage } = getRelativeDragPosition({\n min,\n max,\n rangeMin,\n rangeMax,\n step,\n event,\n isRTL,\n reversed,\n vertical,\n container,\n });\n\n setValue(value);\n setDragPercentage(dragPercentage);\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface DeserializeDraggableValueOptions extends MinMaxRange {\n item: string;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function deserializeDraggableValue(\n options: DeserializeDraggableValueOptions\n): number {\n const { item, min, max } = options;\n\n const value = parseFloat(item);\n if (Number.isNaN(item)) {\n return min;\n }\n\n return Math.max(min, Math.min(max, value));\n}\n"],"names":["getClientPosition","getRangeSteps","nearest","withinRange","isMouseDragStartEvent","event","button","altKey","metaKey","ctrlKey","shiftKey","isTouchDragStartEvent","changedTouches","length","getDragPosition","options","isRTL","reversed","vertical","container","clientPosition","left","right","top","getBoundingClientRect","window","innerHeight","Math","max","getRelativeDragPosition","min","rangeMin","rangeMax","step","height","width","containerSize","containerPosition","position","distanceDragged","dragPercentage","range","steps","value","nextValue","updateDragPosition","nodeRef","isDragStart","setValue","setDragging","setDragPercentage","withinOffsetParent","element","current","focus","preventScroll","offsetParent","document","body","dragPosition","deserializeDraggableValue","item","parseFloat","Number","isNaN"],"mappings":"AAGA,SAGEA,iBAAiB,QACZ,gCAAgC;AACvC,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,WAAW,QAAQ,0BAA0B;AAEtD;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACC,QACpCA,MAAMC,MAAM,KAAK,KACjB,CAACD,MAAME,MAAM,IACb,CAACF,MAAMG,OAAO,IACd,CAACH,MAAMI,OAAO,IACd,CAACJ,MAAMK,QAAQ,CAAC;AAElB;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACN,QACpCA,MAAMO,cAAc,CAACC,MAAM,KAAK,EAAE;AAWpC;;CAEC,GACD,OAAO,MAAMC,kBAAkB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGJ;IAEjD,MAAMK,iBAAiBpB,kBAAkBe;IACzC,MAAM,EAAEM,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGJ,UAAUK,qBAAqB;IAC5D,IAAIN,UAAU;QACZ,IAAID,UAAU;YACZ,OAAOQ,OAAOC,WAAW,GAAGN;QAC9B;QAEA,yEAAyE;QACzE,8CAA8C;QAC9C,OAAOA,iBAAiBO,KAAKC,GAAG,CAAC,GAAGL;IACtC;IAEA,IAAIN,WAAW,CAACD,QAAQA,OAAO;QAC7B,OAAOM,QAAQF;IACjB;IAEA,OAAOA,iBAAiBC;AAC1B,E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AEA,IAAIL,aAAa;QACf,wEAAwE;QACxE,oDAAoD;QACpDK,QAAQE,KAAK,CAAC;YAAEC,eAAe;QAAK;QAEpC,IAAI,CAACJ,sBAAsB,CAAE,CAAA,oBAAoB9C,KAAI,GAAI;YACvD;QACF;QAEA,4EAA4E;QAC5E,0EAA0E;QAC1E,mBAAmB;QACnB4C,YAAY;IACd;IAEA,sEAAsE;IACtE,MAAM9B,YAAYiC,QAAQI,YAAY,IAAIC,SAASC,IAAI;IACvD,IAAI,CAACP,oBAAoB;QACvB,MAAMQ,eAAe7C,gBAAgB;YACnCT;YACAW;YACAC;YACAC;YACAC;QACF;QACA,MAAMyB,YAAYzC,YAAY;YAC5B2B;YACAF;YACAe,OAAOgB;QACT;QACAX,SAASJ;QAET;IACF;IAEA,MAAM,EAAED,KAAK,EAAEH,cAAc,EAAE,GAAGX,wBAAwB;QACxDC;QACAF;QACAG;QACAC;QACAC;QACA5B;QACAW;QACAC;QACAC;QACAC;IACF;IAEA6B,SAASL;IACTO,kBAAkBV;AACpB,EAAE;AAUF;;;CAGC,GACD,OAAO,SAASoB,0BACd7C,OAAyC;IAEzC,MAAM,EAAE8C,IAAI,EAAE/B,GAAG,EAAEF,GAAG,EAAE,GAAGb;IAE3B,MAAM4B,QAAQmB,WAAWD;IACzB,IAAIE,OAAOC,KAAK,CAACH,OAAO;QACtB,OAAO/B;IACT;IAEA,OAAOH,KAAKC,GAAG,CAACE,KAAKH,KAAKG,GAAG,CAACF,KAAKe;AACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/expansion-panel/ExpansionPanelHeader.tsx"],"sourcesContent":["import {\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { ButtonUnstyled } from \"../button/ButtonUnstyled.js\";\nimport { IconRotator, type IconRotatorProps } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { Typography, type TypographyProps } from \"../typography/Typography.js\";\nimport { type TypographyType } from \"../typography/typographyStyles.js\";\nimport { expansionPanelButton, expansionPanelHeading } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Updated to include additional heading/Typography\n * props.\n */\nexport interface ExpansionPanelHeaderProps
|
|
1
|
+
{"version":3,"sources":["../../src/expansion-panel/ExpansionPanelHeader.tsx"],"sourcesContent":["import {\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { ButtonUnstyled } from \"../button/ButtonUnstyled.js\";\nimport { IconRotator, type IconRotatorProps } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { Typography, type TypographyProps } from \"../typography/Typography.js\";\nimport { type TypographyType } from \"../typography/typographyStyles.js\";\nimport { expansionPanelButton, expansionPanelHeading } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Updated to include additional heading/Typography\n * props.\n */\nexport interface ExpansionPanelHeaderProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n id: string;\n\n /**\n * This should be a function that toggles the expansion state for the parent\n * `ExpansionPanel`.\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n expanded: boolean;\n\n /**\n * @defaultValue `\"h3\"`\n */\n as?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n /**\n * @defaultValue `getIcon(\"expander\")`\n */\n icon?: ReactNode;\n\n /**\n * @defaultValue `\"subtitle-1\"`\n */\n headingType?: TypographyType;\n\n /**\n * Any additional props to provide to the heading element that wraps the\n * expansion panel button.\n */\n headingProps?: PropsWithRef<TypographyProps>;\n iconRotatorProps?: Omit<IconRotatorProps, \"rotated\" | \"disableTransition\">;\n\n /**\n * Any children to display **before** the button in the heading element. This\n * should really only be used if you need to add additional clickable elements\n * within the header.\n */\n beforeChildren?: ReactNode;\n\n /**\n * Any children to display **after** the button in the heading element.This\n * should really only be used if you need to add additional clickable elements\n * within the header.\n *\n * @example\n * ```tsx\n * afterChildren={\n * <DropdownMenu buttonType=\"icon\" ButtonChildren={<MoreVertSVGIcon />}>\n * <MenuItem>Item 1</MenuItem>\n * <MenuItem>Item 2</MenuItem>\n * <MenuItem>Item 3</MenuItem>\n * </DropdownMenu>\n * }\n * ```\n */\n afterChildren?: ReactNode;\n\n /**\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n}\n\n/**\n * This is mostly an internal component, but can also be used to implement a\n * custom header implementation if needed. This might really be a client\n * component in practice since the `onClick` prop must be provided.\n *\n * @example Custom Header\n * ```tsx\n * import { ExpansionPanel, type ExpansionPanelProps } from \"@react-md/core/expansion-panel/ExpansionPanel\";\n * import { ExpansionPanelHeader } from \"@react-md/core/expansion-panel/ExpansionPanelHeader\";\n * import { type ReactElement, useId } from \"react\";\n *\n * export type CustomExpansionPanelProps = ExpansionPanelProps & { id: string; };\n *\n * export function CustomExpansionPanel(props: CustomExpansionPanelProps): ReactElement {\n * const {\n * id,\n * disabled,\n * onExpandClick,\n * expanded,\n * disableTransition,\n * headerChildren,\n * } = props;\n *\n * return (\n * <ExpansionPanel\n * {...props}\n * header={(\n * <ExpansionPanelHeader\n * aria-disabled={disabled || undefined}\n * id={id}\n * onClick={onExpandClick}\n * expanded={expanded}\n * disableTransition={disableTransition}\n * // whatever props and any custom implementation\n * >\n * {headerChildren}\n * </ExpansionPanelHeader>\n * )}\n * />\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/expansion-panel | ExpansionPanel Demos}\n * @since 6.0.0 Updated to be wrapped by the {@link Typography}\n * component and rendered as an `<h6>`.\n */\nexport const ExpansionPanelHeader = forwardRef<\n HTMLHeadingElement,\n ExpansionPanelHeaderProps\n>(function ExpansionPanelHeader(props, ref) {\n const {\n id,\n headingType = \"subtitle-1\",\n headingProps,\n iconRotatorProps,\n icon: propIcon,\n expanded,\n className,\n children,\n beforeChildren,\n afterChildren,\n disableTransition = false,\n ...remaining\n } = props;\n\n const icon = getIcon(\"expander\", propIcon);\n\n return (\n <Typography\n ref={ref}\n type={headingType}\n margin=\"none\"\n {...headingProps}\n className={expansionPanelHeading(headingProps)}\n >\n {beforeChildren}\n <ButtonUnstyled\n {...remaining}\n aria-expanded={expanded}\n id={id}\n className={expansionPanelButton({ className })}\n >\n {children}\n {icon && (\n <IconRotator\n {...iconRotatorProps}\n rotated={expanded}\n disableTransition={disableTransition}\n >\n {icon}\n </IconRotator>\n )}\n </ButtonUnstyled>\n {afterChildren}\n </Typography>\n );\n});\n"],"names":["forwardRef","ButtonUnstyled","IconRotator","getIcon","Typography","expansionPanelButton","expansionPanelHeading","ExpansionPanelHeader","props","ref","id","headingType","headingProps","iconRotatorProps","icon","propIcon","expanded","className","children","beforeChildren","afterChildren","disableTransition","remaining","type","margin","aria-expanded","rotated"],"mappings":";AAAA,SAIEA,UAAU,QACL,QAAQ;AAEf,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,WAAW,QAA+B,yBAAyB;AAC5E,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,UAAU,QAA8B,8BAA8B;AAE/E,SAASC,oBAAoB,EAAEC,qBAAqB,QAAQ,cAAc;AAqE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CC,GACD,OAAO,MAAMC,qCAAuBP,WAGlC,SAASO,qBAAqBC,KAAK,EAAEC,GAAG;IACxC,MAAM,EACJC,EAAE,EACFC,cAAc,YAAY,EAC1BC,YAAY,EACZC,gBAAgB,EAChBC,MAAMC,QAAQ,EACdC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,oBAAoB,KAAK,EACzB,GAAGC,WACJ,GAAGd;IAEJ,MAAMM,OAAOX,QAAQ,YAAYY;IAEjC,qBACE,MAACX;QACCK,KAAKA;QACLc,MAAMZ;QACNa,QAAO;QACN,GAAGZ,YAAY;QAChBK,WAAWX,sBAAsBM;;YAEhCO;0BACD,MAAClB;gBACE,GAAGqB,SAAS;gBACbG,iBAAeT;gBACfN,IAAIA;gBACJO,WAAWZ,qBAAqB;oBAAEY;gBAAU;;oBAE3CC;oBACAJ,sBACC,KAACZ;wBACE,GAAGW,gBAAgB;wBACpBa,SAASV;wBACTK,mBAAmBA;kCAElBP;;;;YAINM;;;AAGP,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/files/FileInput.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { SrOnly } from \"../typography/SrOnly.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { fileInput } from \"./styles.js\";\n\n/** @since 6.0.0 */\nexport type FileInputHTMLAttributes = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\"\n>;\n\n/**\n * @since 6.0.0 Removed the `disableIconSpacing` prop since it is no\n * longer required.\n */\nexport interface FileInputProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/files/FileInput.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { SrOnly } from \"../typography/SrOnly.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { fileInput } from \"./styles.js\";\n\n/** @since 6.0.0 */\nexport type FileInputHTMLAttributes = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\"\n>;\n\n/**\n * @since 6.0.0 Removed the `disableIconSpacing` prop since it is no\n * longer required.\n */\nexport interface FileInputProps\n extends\n ButtonClassNameThemeOptions,\n FileInputHTMLAttributes,\n ComponentWithRippleProps {\n /**\n * This is the label text for icon-only file inputs.\n *\n * @defaultValue `\"Upload\"`\n */\n srOnlyLabel?: ReactNode;\n\n /**\n * Any additional props to provide to the container `<label>` element since\n * most props get passed to the `<input type=\"file\">`. So this would be useful\n * for inline style or click handlers.\n */\n labelProps?: PropsWithRef<LabelHTMLAttributes<HTMLLabelElement>>;\n\n /**\n * An optional icon to display for the file input.\n *\n * @defaultValue `getIcon(\"upload\")`\n */\n icon?: ReactNode;\n\n /**\n * Boolean if the icon should appear after the children in the label.\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n\n /**\n * Boolean if the file input should no longer allow the same file to be\n * selected multiple times and trigger the `onChange` each time it is\n * selected.\n *\n * @defaultValue `false`\n */\n disableRepeatableFiles?: boolean;\n\n /**\n * Children should generally be provided when the {@link buttonType} is\n * set to `\"text\"`. This defaults to a screen-reader only accessible text.\n *\n * @defaultValue `<SrOnly phoneOnly={responsive}>Upload</SrOnly>`\n */\n children?: ReactNode;\n}\n\n/**\n * **Client Component**\n * This might be able to become a server component if I remove the getIcon hook\n *\n * @example Simple Example\n * ```tsx\n * import { FileInput } from \"@react-md/core/files/FileInput\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import type { ReactElement } from \"react\";\n *\n * const extensions = [\n * \"svg\",\n * \"jpeg\",\n * \"jpg\",\n * \"png\",\n * \"apng\",\n * \"mkv\",\n * \"mp4\",\n * \"mpeg\",\n * \"mpg\",\n * \"webm\",\n * \"mov\",\n * ] as const;\n *\n * const FOUR_HUNDRED_MB = 400 * 1024 * 1024;\n * const maxFiles = 10;\n *\n * function Example(): ReactElement {\n * const { stats, errors, onChange, clearErrors, reset, remove, accept } =\n * useFileUpload({\n * maxFiles,\n * maxFileSize: FOUR_HUNDRED_MB,\n * extensions,\n * });\n *\n * return (\n * <Form>\n * <FileInput accept={accept} multiple={maxFiles > 1} onChange={onChange} />\n * <Button onClick={reset} disabled={!stats.length}>\n * Remove all files\n * </Button>\n * </Form>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/file-input | FileInput Demos}\n * @since 6.0.0 Added additional support for `iconSize` and\n * `responsive`. Also removed the `disableIconSpacing` prop since it is no\n * longer required.\n */\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n function FileInput(props, ref) {\n const {\n id: propId,\n className,\n children: propChildren,\n icon: propIcon,\n iconAfter = false,\n srOnlyLabel = \"Upload\",\n disableRepeatableFiles = false,\n labelProps,\n theme = \"primary\",\n themeType = \"contained\",\n buttonType = propChildren ? \"text\" : \"icon\",\n disabled = false,\n iconSize,\n responsive,\n multiple = false,\n disableRipple,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"file-input\");\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n ...labelProps,\n mode: disableRipple ? \"none\" : undefined,\n onClick(event) {\n labelProps?.onClick?.(event);\n\n // stop propagation so 2 ripples are not created\n event.stopPropagation();\n },\n disabled,\n });\n\n const icon = getIcon(\"upload\", propIcon);\n let children = propChildren;\n if (\n typeof propChildren === \"undefined\" &&\n !props[\"aria-label\"] &&\n !props[\"aria-labelledby\"]\n ) {\n children = <SrOnly phoneOnly={responsive}>{srOnlyLabel}</SrOnly>;\n }\n\n return (\n <label\n {...labelProps}\n {...handlers}\n className={fileInput({\n theme,\n themeType,\n buttonType,\n disabled,\n iconSize,\n pressed,\n responsive,\n pressedClassName,\n className: className || labelProps?.className,\n })}\n >\n {!iconAfter && icon}\n {children}\n {iconAfter && icon}\n <input\n {...remaining}\n id={id}\n ref={ref}\n value={\n disableRepeatableFiles || !props.onChange ? remaining.value : \"\"\n }\n type=\"file\"\n className=\"rmd-hidden-input\"\n disabled={disabled}\n multiple={multiple}\n />\n {ripples}\n </label>\n );\n }\n);\n"],"names":["forwardRef","getIcon","useElementInteraction","SrOnly","useEnsuredId","fileInput","FileInput","props","ref","id","propId","className","children","propChildren","icon","propIcon","iconAfter","srOnlyLabel","disableRepeatableFiles","labelProps","theme","themeType","buttonType","disabled","iconSize","responsive","multiple","disableRipple","remaining","pressed","pressedClassName","ripples","handlers","mode","undefined","onClick","event","stopPropagation","phoneOnly","label","input","value","onChange","type"],"mappings":"AAAA;;AAEA,SAIEA,UAAU,QACL,QAAQ;AAGf,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,MAAM,QAAQ,0BAA0B;AACjD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,SAAS,QAAQ,cAAc;AA+DxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDC,GACD,OAAO,MAAMC,0BAAYN,WACvB,SAASM,UAAUC,KAAK,EAAEC,GAAG;IAC3B,MAAM,EACJC,IAAIC,MAAM,EACVC,SAAS,EACTC,UAAUC,YAAY,EACtBC,MAAMC,QAAQ,EACdC,YAAY,KAAK,EACjBC,cAAc,QAAQ,EACtBC,yBAAyB,KAAK,EAC9BC,UAAU,EACVC,QAAQ,SAAS,EACjBC,YAAY,WAAW,EACvBC,aAAaT,eAAe,SAAS,MAAM,EAC3CU,WAAW,KAAK,EAChBC,QAAQ,EACRC,UAAU,EACVC,WAAW,KAAK,EAChBC,aAAa,EACb,GAAGC,WACJ,GAAGrB;IACJ,MAAME,KAAKL,aAAaM,QAAQ;IAChC,MAAM,EAAEmB,OAAO,EAAEC,gBAAgB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GACpD9B,sBAAsB;QACpB,GAAGiB,UAAU;QACbc,MAAMN,gBAAgB,SAASO;QAC/BC,SAAQC,KAAK;YACXjB,YAAYgB,UAAUC;YAEtB,gDAAgD;YAChDA,MAAMC,eAAe;Q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