@react-md/core 6.3.3 → 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/box/_box.scss +20 -1
- package/dist/box/styles.d.ts +39 -0
- package/dist/box/styles.js +39 -0
- package/dist/box/styles.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.d.ts +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 +38 -30
- 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/box/styles.ts +39 -0
- 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 +9 -4
- 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
package/dist/tabs/TabList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tabs/TabList.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport {\n type BaseTabListScrollButtonProps,\n TabListScrollButton,\n} from \"./TabListScrollButton.js\";\nimport { type GetTabListScrollToOptions } from \"./getTabListScrollToOptions.js\";\nimport { type TabListClassNameOptions, tabList } from \"./tabListStyles.js\";\nimport {\n type TabListActivationMode,\n type TabListScrollButtonsBehavior,\n} from \"./types.js\";\nimport { useTabList } from \"./useTabList.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useTabs } from \"./useTabs.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface TabListProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/tabs/TabList.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport {\n type BaseTabListScrollButtonProps,\n TabListScrollButton,\n} from \"./TabListScrollButton.js\";\nimport { type GetTabListScrollToOptions } from \"./getTabListScrollToOptions.js\";\nimport { type TabListClassNameOptions, tabList } from \"./tabListStyles.js\";\nimport {\n type TabListActivationMode,\n type TabListScrollButtonsBehavior,\n} from \"./types.js\";\nimport { useTabList } from \"./useTabList.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useTabs } from \"./useTabs.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface TabListProps\n extends\n HTMLAttributes<HTMLDivElement>,\n Omit<TabListClassNameOptions, \"animate\" | \"indicator\"> {\n activeIndex: number;\n setActiveIndex: (nextActiveIndex: number) => void;\n\n /**\n * Set this to `true` to show a scrollbar when the number of tabs cause\n * overflow.\n *\n * @see {@link scrollButtons}\n * @defaultValue `false`\n */\n scrollbar?: boolean;\n\n /**\n * Set this to `true` to disable the active tab indicator from animating\n * when a new tab is selected.\n *\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * This should be equal to the `$tabs-transition-duration` variable.\n *\n * @defaultValue `150`\n */\n transitionDuration?: number;\n\n /**\n * @defaultValue `\"manual\"`\n * @see {@link TabListActivationMode}\n */\n activationMode?: TabListActivationMode;\n\n /**\n * @defaultValue `false`\n * @see {@link TabListScrollButtonsBehavior}\n */\n scrollButtons?: TabListScrollButtonsBehavior;\n\n /**\n * A convenience prop for the {@link BaseTabListScrollButtonProps.getScrollToOptions}\n * on {@link forwardScrollButtonProps} and {@link backwardScrollButtonProps}.\n */\n getScrollToOptions?: GetTabListScrollToOptions;\n\n /**\n * Any additional props that should be passed to the scroll forward button.\n *\n * @example\n * ```tsx\n * forwardScrollButtonProps={{\n * \"aria-label\": \"Scroll right\",\n * theme: \"primary\",\n * themeType: \"contained\",\n * className: styles.buttonContainer,\n * buttonProps: {\n * className: styles.button,\n * }\n * }}\n * ```\n */\n forwardScrollButtonProps?: BaseTabListScrollButtonProps;\n\n /**\n * Any additional props that should be passed to the scroll backward button.\n *\n * @example\n * ```tsx\n * forwardScrollButtonProps={{\n * \"aria-label\": \"Scroll left\",\n * theme: \"primary\",\n * themeType: \"contained\",\n * className: styles.buttonContainer,\n * buttonProps: {\n * className: styles.button,\n * }\n * }}\n * ```\n */\n backwardScrollButtonProps?: BaseTabListScrollButtonProps;\n}\n\n/**\n * **Client Component**\n *\n * @see {@link https://react-md.dev/components/tabs | Tabs Demos}\n * @see {@link useTabs} for example usage.\n * @since 6.0.0\n */\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(\n function TabList(props, ref) {\n const {\n style,\n onClick,\n onFocus,\n onKeyDown,\n className,\n children,\n activeIndex,\n setActiveIndex,\n activationMode = \"manual\",\n align = \"left\",\n padded = false,\n inline = false,\n vertical = false,\n scrollbar = false,\n scrollButtons = false,\n fullWidthTabs,\n disableTransition = false,\n transitionDuration = 150,\n getScrollToOptions,\n forwardScrollButtonProps,\n backwardScrollButtonProps,\n ...remaining\n } = props;\n\n const {\n elementProps,\n movementContext,\n backwardProps,\n forwardProps,\n showScrollButtons,\n } = useTabList({\n ref,\n style,\n onClick,\n onFocus,\n onKeyDown,\n vertical,\n activeIndex,\n setActiveIndex,\n activationMode,\n scrollButtons,\n disableTransition,\n });\n\n const prevActiveIndex = useRef(activeIndex);\n const [animate, setAnimate] = useState(false);\n useEffect(() => {\n const isSameIndex = activeIndex === prevActiveIndex.current;\n prevActiveIndex.current = activeIndex;\n if (disableTransition || isSameIndex) {\n return;\n }\n\n setAnimate(true);\n const timeout = window.setTimeout(() => {\n setAnimate(false);\n }, transitionDuration);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [activeIndex, disableTransition, transitionDuration]);\n\n return (\n <KeyboardMovementProvider value={movementContext}>\n <div\n {...remaining}\n {...elementProps}\n role=\"tablist\"\n className={tabList({\n align,\n padded,\n inline,\n animate: !disableTransition && animate,\n vertical,\n scrollbar,\n indicator: !disableTransition,\n fullWidthTabs,\n className,\n })}\n >\n {showScrollButtons && (\n <TabListScrollButton\n getScrollToOptions={getScrollToOptions}\n {...backwardScrollButtonProps}\n {...backwardProps}\n />\n )}\n {children}\n {showScrollButtons && (\n <TabListScrollButton\n getScrollToOptions={getScrollToOptions}\n {...forwardScrollButtonProps}\n {...forwardProps}\n />\n )}\n </div>\n </KeyboardMovementProvider>\n );\n }\n);\n"],"names":["forwardRef","useEffect","useRef","useState","KeyboardMovementProvider","TabListScrollButton","tabList","useTabList","TabList","props","ref","style","onClick","onFocus","onKeyDown","className","children","activeIndex","setActiveIndex","activationMode","align","padded","inline","vertical","scrollbar","scrollButtons","fullWidthTabs","disableTransition","transitionDuration","getScrollToOptions","forwardScrollButtonProps","backwardScrollButtonProps","remaining","elementProps","movementContext","backwardProps","forwardProps","showScrollButtons","prevActiveIndex","animate","setAnimate","isSameIndex","current","timeout","window","setTimeout","clearTimeout","value","div","role","indicator"],"mappings":"AAAA;;AAEA,SAEEA,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAEf,SAASC,wBAAwB,QAAQ,6CAA6C;AACtF,SAEEC,mBAAmB,QACd,2BAA2B;AAElC,SAAuCC,OAAO,QAAQ,qBAAqB;AAK3E,SAASC,UAAU,QAAQ,kBAAkB;AA6F7C;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAUR,WACrB,SAASQ,QAAQC,KAAK,EAAEC,GAAG;IACzB,MAAM,EACJC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,cAAc,EACdC,iBAAiB,QAAQ,EACzBC,QAAQ,MAAM,EACdC,SAAS,KAAK,EACdC,SAAS,KAAK,EACdC,WAAW,KAAK,EAChBC,YAAY,KAAK,EACjBC,gBAAgB,KAAK,EACrBC,aAAa,EACbC,oBAAoB,KAAK,EACzBC,qBAAqB,GAAG,EACxBC,kBAAkB,EAClBC,wBAAwB,EACxBC,yBAAyB,EACzB,GAAGC,WACJ,GAAGvB;IAEJ,MAAM,EACJwB,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EAClB,GAAG9B,WAAW;QACbG;QACAC;QACAC;QACAC;QACAC;QACAS;QACAN;QACAC;QACAC;QACAM;QACAE;IACF;IAEA,MAAMW,kBAAkBpC,OAAOe;IAC/B,MAAM,CAACsB,SAASC,WAAW,GAAGrC,SAAS;IACvCF,UAAU;QACR,MAAMwC,cAAcxB,gBAAgBqB,gBAAgBI,OAAO;QAC3DJ,gBAAgBI,OAAO,GAAGzB;QAC1B,IAAIU,qBAAqBc,aAAa;YACpC;QACF;QAEAD,WAAW;QACX,MAAMG,UAAUC,OAAOC,UAAU,CAAC;YAChCL,WAAW;QACb,GAAGZ;QAEH,OAAO;YACLgB,OAAOE,YAAY,CAACH;QACtB;IACF,GAAG;QAAC1B;QAAaU;QAAmBC;KAAmB;IAEvD,qBACE,KAACxB;QAAyB2C,OAAOb;kBAC/B,cAAA,MAACc;YACE,GAAGhB,SAAS;YACZ,GAAGC,YAAY;YAChBgB,MAAK;YACLlC,WAAWT,QAAQ;gBACjBc;gBACAC;gBACAC;gBACAiB,SAAS,CAACZ,qBAAqBY;gBAC/BhB;gBACAC;gBACA0B,WAAW,CAACvB;gBACZD;gBACAX;YACF;;gBAECsB,mCACC,KAAChC;oBACCwB,oBAAoBA;oBACnB,GAAGE,yBAAyB;oBAC5B,GAAGI,aAAa;;gBAGpBnB;gBACAqB,mCACC,KAAChC;oBACCwB,oBAAoBA;oBACnB,GAAGC,wBAAwB;oBAC3B,GAAGM,YAAY;;;;;AAM5B,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tabs/TabListScrollButton.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIntersectionObserver } from \"../useIntersectionObserver.js\";\nimport { applyRef } from \"../utils/applyRef.js\";\nimport {\n type GetTabListScrollToOptions,\n getTabListScrollToOptions,\n} from \"./getTabListScrollToOptions.js\";\nimport {\n tabListScrollButton,\n tabListScrollButtonContainer,\n} from \"./tabListScrollButtonStyles.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface BaseTabListScrollButtonProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/tabs/TabListScrollButton.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIntersectionObserver } from \"../useIntersectionObserver.js\";\nimport { applyRef } from \"../utils/applyRef.js\";\nimport {\n type GetTabListScrollToOptions,\n getTabListScrollToOptions,\n} from \"./getTabListScrollToOptions.js\";\nimport {\n tabListScrollButton,\n tabListScrollButtonContainer,\n} from \"./tabListScrollButtonStyles.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface BaseTabListScrollButtonProps\n extends HTMLAttributes<HTMLDivElement>, ButtonClassNameThemeOptions {\n buttonProps?: PropsWithRef<ButtonProps>;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /** @defaultValue {@link getTabListScrollToOptions} */\n getScrollToOptions?: GetTabListScrollToOptions;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface TabListScrollButtonProps extends BaseTabListScrollButtonProps {\n type: \"back\" | \"forward\";\n /** @defaultValue `false` */\n vertical?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 6.0.0\n */\nexport const TabListScrollButton = forwardRef<\n HTMLDivElement,\n TabListScrollButtonProps\n>(function TabListScrollButton(props, ref) {\n const {\n \"aria-label\": ariaLabel,\n className,\n buttonProps,\n type,\n theme,\n themeType,\n buttonType = \"icon\",\n disabled: propDisabled,\n children: propChildren,\n getScrollToOptions = getTabListScrollToOptions,\n vertical = false,\n disableTransition = false,\n ...remaining\n } = props;\n\n const forward = type === \"forward\";\n const iconButton = buttonType === \"icon\";\n const icon = getIcon(type);\n const children = propChildren || icon;\n\n const root = useRef<HTMLElement | null>(null);\n const isRTL = useDir().dir === \"rtl\";\n const [disabled, setDisabled] = useState(!forward);\n const nodeRef = useIntersectionObserver({\n root,\n rootMargin: \"1px\",\n onUpdate: useCallback(([entry]) => {\n setDisabled(entry.intersectionRatio === 1);\n }, []),\n });\n\n return (\n <>\n {!forward && <span ref={nodeRef} />}\n <div\n {...remaining}\n ref={(instance) => {\n applyRef(instance, ref);\n root.current = instance?.parentElement || null;\n }}\n className={tabListScrollButtonContainer({\n forward,\n vertical,\n className,\n })}\n >\n <Button\n aria-label={ariaLabel || (iconButton ? type : undefined)}\n theme={theme}\n themeType={themeType}\n buttonType={buttonType}\n disabled={propDisabled || disabled}\n {...buttonProps}\n className={tabListScrollButton({\n className: buttonProps?.className,\n vertical,\n })}\n onClick={(event) => {\n buttonProps?.onClick?.(event);\n const container = root.current;\n if (!container) {\n return;\n }\n\n container.scrollTo(\n getScrollToOptions({\n isRTL,\n animate: !disableTransition,\n vertical,\n container,\n increment: forward,\n })\n );\n }}\n >\n {children}\n </Button>\n </div>\n {forward && <span ref={nodeRef} />}\n </>\n );\n});\n"],"names":["forwardRef","useCallback","useRef","useState","Button","getIcon","useDir","useIntersectionObserver","applyRef","getTabListScrollToOptions","tabListScrollButton","tabListScrollButtonContainer","TabListScrollButton","props","ref","ariaLabel","className","buttonProps","type","theme","themeType","buttonType","disabled","propDisabled","children","propChildren","getScrollToOptions","vertical","disableTransition","remaining","forward","iconButton","icon","root","isRTL","dir","setDisabled","nodeRef","rootMargin","onUpdate","entry","intersectionRatio","span","div","instance","current","parentElement","aria-label","undefined","onClick","event","container","scrollTo","animate","increment"],"mappings":"AAAA;;AAEA,SAEEA,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAEf,SAASC,MAAM,QAA0B,sBAAsB;AAE/D,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,MAAM,QAAQ,4CAA4C;AACnE,SAASC,uBAAuB,QAAQ,gCAAgC;AACxE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAEEC,yBAAyB,QACpB,iCAAiC;AACxC,SACEC,mBAAmB,EACnBC,4BAA4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,SAAS,CAACC;wBACRjC,aAAagC,UAAUC;wBACvB,MAAMC,YAAYlB,KAAKY,OAAO;wBAC9B,IAAI,CAACM,WAAW;4BACd;wBACF;wBAEAA,UAAUC,QAAQ,CAChB1B,mBAAmB;4BACjBQ;4BACAmB,SAAS,CAACzB;4BACVD;4BACAwB;4BACAG,WAAWxB;wBACb;oBAEJ;8BAECN;;;YAGJM,yBAAW,KAACY;gBAAK5B,KAAKuB;;;;AAG7B,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tabs/useMaxTabPanelHeight.ts"],"sourcesContent":["import { type CSSProperties, type Ref, useCallback, useState } from \"react\";\n\nimport { type UseStateInitializer } from \"../types.js\";\nimport { useResizeObserver } from \"../useResizeObserver.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport {\n type ProvidedTabPanelsProps,\n type TabsImplementation,\n} from \"./useTabs.js\";\nimport { getTabPanelRoleOnly } from \"./utils.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MaxTabPanelHeightOptions<E extends HTMLElement
|
|
1
|
+
{"version":3,"sources":["../../src/tabs/useMaxTabPanelHeight.ts"],"sourcesContent":["import { type CSSProperties, type Ref, useCallback, useState } from \"react\";\n\nimport { type UseStateInitializer } from \"../types.js\";\nimport { useResizeObserver } from \"../useResizeObserver.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport {\n type ProvidedTabPanelsProps,\n type TabsImplementation,\n} from \"./useTabs.js\";\nimport { getTabPanelRoleOnly } from \"./utils.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MaxTabPanelHeightOptions<E extends HTMLElement> extends Pick<\n TabsImplementation,\n \"getTabPanelsProps\"\n> {\n ref?: Ref<E>;\n style?: CSSProperties;\n\n /**\n * @defaultValue `undefined`\n */\n defaultHeight?: UseStateInitializer<string | number>;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ProvidedMaxTabPanelsHeightProps<\n E extends HTMLElement,\n> extends ProvidedTabPanelsProps<E> {\n style: CSSProperties;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface MaxTabPanelHeightImplementation<E extends HTMLElement> {\n getMaxTabPanelHeightProps: (\n style?: CSSProperties\n ) => ProvidedMaxTabPanelsHeightProps<E>;\n}\n\n/**\n * The `useMaxTabPanelHeight` hook can be used to enforce the tab panels to\n * have the same height so content does not shift below the tab panels by\n * calculating the height of all tabs and setting the height to the largest\n * value.\n *\n * If a maximum height should be used, set it through CSS and scrollbars will\n * appear in each tab panel.\n *\n * @example Main Usage\n * ```tsx\n * import { Tab } from \"@react-md/core/tabs/Tab\";\n * import { TabList } from \"@react-md/core/tabs/TabList\";\n * import { useMaxTabPanelHeight } from \"@react-md/core/tabs/useMaxTabPanelHeight\";\n * import { useTabs } from \"@react-md/core/tabs/useTabs\";\n * import { Slide } from \"@react-md/core/transition/Slide\";\n * import { SlideContainer } from \"@react-md/core/transition/SlideContainer\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { getTabProps, getTabListProps, getTabPanelProps, getTabPanelsProps } =\n * useTabs();\n * const { getMaxTabPanelHeightProps } = useMaxTabPanelHeight({\n * getTabPanelsProps,\n * });\n *\n * return (\n * <>\n * <TabList {...getTabListProps()}>\n * <Tab {...getTabProps(0)}>Tab 1</Tab>\n * <Tab {...getTabProps(1)}>Tab 2</Tab>\n * <Tab {...getTabProps(2)}>Tab 3</Tab>\n * </TabList>\n * <SlideContainer {...getMaxTabPanelHeightProps()}>\n * <Slide {...getTabPanelProps(0)}>\n * <Tab1Content />\n * </Slide>\n * <Slide {...getTabPanelProps(1)}>\n * <Tab2Content />\n * </Slide>\n * <Slide {...getTabPanelProps(2)}>\n * <Tab3Content />\n * </Slide>\n * </SlideContainer>\n * </>\n * );\n * }\n * ```\n *\n * NOTE: This will **not work** when dynamically rendering the active tab panel\n * by enabling the `temporary` prop on the `Slide` or custom behavior.\n *\n * @since 6.0.0\n */\nexport function useMaxTabPanelHeight<E extends HTMLElement = HTMLDivElement>(\n options: MaxTabPanelHeightOptions<E>\n): MaxTabPanelHeightImplementation<E> {\n const { ref, style, defaultHeight, getTabPanelsProps } = options;\n\n const [height, setHeight] = useState(defaultHeight);\n const panelRef = useResizeObserver({\n ref,\n onUpdate: useCallback((entry) => {\n const element = entry.target as HTMLElement;\n const { height } = element.style;\n element.style.height = \"\";\n const panels = getTabPanelRoleOnly(element);\n const maxHeight = panels.reduce((maxHeight, panel) => {\n let { scrollHeight } = panel;\n if (panel.classList.contains(DISPLAY_NONE_CLASS)) {\n panel.classList.toggle(DISPLAY_NONE_CLASS);\n ({ scrollHeight } = panel);\n panel.classList.toggle(DISPLAY_NONE_CLASS);\n }\n\n return Math.max(maxHeight, scrollHeight);\n }, 0);\n element.style.height = height;\n\n // don't set the height to 0 since it usually means a calculation issue\n setHeight((prevHeight) => (maxHeight <= 0 ? prevHeight : maxHeight));\n }, []),\n });\n\n return {\n getMaxTabPanelHeightProps: (moreStyle) => ({\n ...getTabPanelsProps(panelRef),\n style: {\n height,\n ...style,\n ...moreStyle,\n },\n }),\n };\n}\n"],"names":["useCallback","useState","useResizeObserver","DISPLAY_NONE_CLASS","getTabPanelRoleOnly","useMaxTabPanelHeight","options","ref","style","defaultHeight","getTabPanelsProps","height","setHeight","panelRef","onUpdate","entry","element","target","panels","maxHeight","reduce","panel","scrollHeight","classList","contains","toggle","Math","max","prevHeight","getMaxTabPanelHeightProps","moreStyle"],"mappings":"AAAA,SAAuCA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAG5E,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,kBAAkB,QAAQ,+BAA+B;AAKlE,SAASC,mBAAmB,QAAQ,aAAa;AAoCjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDC,GACD,OAAO,SAASC,qBACdC,OAAoC;IAEpC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAEC,aAAa,EAAEC,iBAAiB,EAAE,GAAGJ;IAEzD,MAAM,CAACK,QAAQC,UAAU,GAAGX,SAASQ;IACrC,MAAMI,WAAWX,kBAAkB;QACjCK;QACAO,UAAUd,YAAY,CAACe;YACrB,MAAMC,UAAUD,MAAME,MAAM;YAC5B,MAAM,EAAEN,MAAM,EAAE,GAAGK,QAAQR,KAAK;YAChCQ,QAAQR,KAAK,CAACG,MAAM,GAAG;YACvB,MAAMO,SAASd,oBAAoBY;YACnC,MAAMG,YAAYD,OAAOE,MAAM,CAAC,CAACD,WAAWE;gBAC1C,IAAI,EAAEC,YAAY,EAAE,GAAGD;gBACvB,IAAIA,MAAME,SAAS,CAACC,QAAQ,CAACrB,qBAAqB;oBAChDkB,MAAME,SAAS,CAACE,MAAM,CAACtB;oBACtB,CAAA,EAAEmB,YAAY,EAAE,GAAGD,KAAI;oBACxBA,MAAME,SAAS,CAACE,MAAM,CAACtB;gBACzB;gBAEA,OAAOuB,KAAKC,GAAG,CAACR,WAAWG;YAC7B,GAAG;YACHN,QAAQR,KAAK,CAACG,MAAM,GAAGA;YAEvB,uEAAuE;YACvEC,UAAU,CAACgB,aAAgBT,aAAa,IAAIS,aAAaT;QAC3D,GAAG,EAAE;IACP;IAEA,OAAO;QACLU,2BAA2B,CAACC,YAAe,CAAA;gBACzC,GAAGpB,kBAAkBG,SAAS;gBAC9BL,OAAO;oBACLG;oBACA,GAAGH,KAAK;oBACR,GAAGsB,SAAS;gBACd;YACF,CAAA;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test-utils/data-testid.ts"],"sourcesContent":["/// <reference types=\"react\" />\n\ndeclare module \"react\" {\n interface HTMLAttributes<T>\n extends React.AriaAttributes
|
|
1
|
+
{"version":3,"sources":["../../src/test-utils/data-testid.ts"],"sourcesContent":["/// <reference types=\"react\" />\n\ndeclare module \"react\" {\n interface HTMLAttributes<T>\n extends React.AriaAttributes, React.DOMAttributes<T> {\n \"data-testid\"?: string | number;\n }\n}\n"],"names":[],"mappings":"AAAA,+BAA+B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MEDIA_QUERY_CONFIG } from "../../media-queries/config.js";
|
|
2
2
|
const noop = ()=>{
|
|
3
3
|
// do nothing
|
|
4
4
|
};
|
|
@@ -18,19 +18,19 @@ const noop = ()=>{
|
|
|
18
18
|
/**
|
|
19
19
|
* @since 6.0.0
|
|
20
20
|
* @returns `true` for phone media queries
|
|
21
|
-
*/ export const matchPhone = (query)=>query.includes(
|
|
21
|
+
*/ export const matchPhone = (query)=>query.includes(`${MEDIA_QUERY_CONFIG.phoneMaxWidth}`);
|
|
22
22
|
/**
|
|
23
23
|
* @since 6.0.0
|
|
24
24
|
* @returns `true` for tablet media queries
|
|
25
|
-
*/ export const matchTablet = (query)=>query.includes(
|
|
25
|
+
*/ export const matchTablet = (query)=>query.includes(`${MEDIA_QUERY_CONFIG.tabletMinWidth}`);
|
|
26
26
|
/**
|
|
27
27
|
* @since 6.0.0
|
|
28
28
|
* @returns `true` for desktop media queries
|
|
29
|
-
*/ export const matchDesktop = (query)=>query.includes(
|
|
29
|
+
*/ export const matchDesktop = (query)=>query.includes(`${MEDIA_QUERY_CONFIG.desktopMinWidth}`);
|
|
30
30
|
/**
|
|
31
31
|
* @since 6.0.0
|
|
32
32
|
* @returns `true` for large desktop media queries
|
|
33
|
-
*/ export const matchLargeDesktop = (query)=>query.includes(
|
|
33
|
+
*/ export const matchLargeDesktop = (query)=>query.includes(`${MEDIA_QUERY_CONFIG.desktopLargeMinWidth}`);
|
|
34
34
|
/**
|
|
35
35
|
* @since 6.0.0
|
|
36
36
|
* @returns `true` for both desktop and large desktop media queries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/test-utils/mocks/match-media.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/test-utils/mocks/match-media.ts"],"sourcesContent":["import { MEDIA_QUERY_CONFIG } from \"../../media-queries/config.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface MatchMediaChangeViewport {\n /**\n * @example Default Behavior\n * ```tsx\n * const matchMedia = spyOnMatchMedia();\n * render(<Test />);\n *\n * // expect desktop results\n *\n * matchMedia.changeViewport(matchPhone);\n * // expect phone results\n * ```\n *\n * @example Custom Act Behavior\n * ```tsx\n * const matchMedia = spyOnMatchMedia();\n * const { rerender } = render(<Test />);\n *\n * // expect desktop results\n *\n * matchMedia.changeViewport(matchPhone, false);\n * rerender(<Test key=\"new-key\" />);\n *\n * // expect phone results\n * ```\n */\n changeViewport: (matcher: MatchMediaMatcher, disableAct?: boolean) => void;\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const BASE_MEDIA_QUERY_LIST: MediaQueryList = {\n media: \"\",\n matches: false,\n onchange: noop,\n addListener: noop,\n addEventListener: noop,\n removeEventListener: noop,\n removeListener: noop,\n dispatchEvent: () => false,\n};\n\n/** @since 6.0.0 */\nexport type MatchMediaMatcher = (query: string) => boolean;\n\n/**\n * @since 6.0.0\n * @returns `true` for phone media queries\n */\nexport const matchPhone: MatchMediaMatcher = (query) =>\n query.includes(`${MEDIA_QUERY_CONFIG.phoneMaxWidth}`);\n\n/**\n * @since 6.0.0\n * @returns `true` for tablet media queries\n */\nexport const matchTablet: MatchMediaMatcher = (query) =>\n query.includes(`${MEDIA_QUERY_CONFIG.tabletMinWidth}`);\n\n/**\n * @since 6.0.0\n * @returns `true` for desktop media queries\n */\nexport const matchDesktop: MatchMediaMatcher = (query) =>\n query.includes(`${MEDIA_QUERY_CONFIG.desktopMinWidth}`);\n\n/**\n * @since 6.0.0\n * @returns `true` for large desktop media queries\n */\nexport const matchLargeDesktop: MatchMediaMatcher = (query) =>\n query.includes(`${MEDIA_QUERY_CONFIG.desktopLargeMinWidth}`);\n\n/**\n * @since 6.0.0\n * @returns `true` for both desktop and large desktop media queries\n */\nexport const matchAnyDesktop: MatchMediaMatcher = (query) =>\n matchDesktop(query) || matchLargeDesktop(query);\n"],"names":["MEDIA_QUERY_CONFIG","noop","BASE_MEDIA_QUERY_LIST","media","matches","onchange","addListener","addEventListener","removeEventListener","removeListener","dispatchEvent","matchPhone","query","includes","phoneMaxWidth","matchTablet","tabletMinWidth","matchDesktop","desktopMinWidth","matchLargeDesktop","desktopLargeMinWidth","matchAnyDesktop"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,gCAAgC;AAkCnE,MAAMC,OAAO;AACX,aAAa;AACf;AAEA;;;CAGC,GACD,OAAO,MAAMC,wBAAwC;IACnDC,OAAO;IACPC,SAAS;IACTC,UAAUJ;IACVK,aAAaL;IACbM,kBAAkBN;IAClBO,qBAAqBP;IACrBQ,gBAAgBR;IAChBS,eAAe,IAAM;AACvB,EAAE;AAKF;;;CAGC,GACD,OAAO,MAAMC,aAAgC,CAACC,QAC5CA,MAAMC,QAAQ,CAAC,GAAGb,mBAAmBc,aAAa,EAAE,EAAE;AAExD;;;CAGC,GACD,OAAO,MAAMC,cAAiC,CAACH,QAC7CA,MAAMC,QAAQ,CAAC,GAAGb,mBAAmBgB,cAAc,EAAE,EAAE;AAEzD;;;CAGC,GACD,OAAO,MAAMC,eAAkC,CAACL,QAC9CA,MAAMC,QAAQ,CAAC,GAAGb,mBAAmBkB,eAAe,EAAE,EAAE;AAE1D;;;CAGC,GACD,OAAO,MAAMC,oBAAuC,CAACP,QACnDA,MAAMC,QAAQ,CAAC,GAAGb,mBAAmBoB,oBAAoB,EAAE,EAAE;AAE/D;;;CAGC,GACD,OAAO,MAAMC,kBAAqC,CAACT,QACjDK,aAAaL,UAAUO,kBAAkBP,OAAO"}
|
|
@@ -25,7 +25,7 @@ export type RafSpy = MockInstance<typeof requestAnimationFrame>;
|
|
|
25
25
|
* import { testImmediateRaf } from "@react-md/core/test-utils/vitest";
|
|
26
26
|
*
|
|
27
27
|
* afterEach(() => {
|
|
28
|
-
*
|
|
28
|
+
* vi.restoreAllMocks();
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* describe("some test suite", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/test-utils/vitest/timers.ts"],"sourcesContent":["import { type MockInstance, vi } from \"vitest\";\n\n/**\n * @since 6.0.0\n */\nexport type RafSpy = MockInstance<typeof requestAnimationFrame>;\n\n/**\n * @example\n * ```ts\n * import { testImmediateRaf } from \"@react-md/core/test-utils/vitest\";\n *\n * describe(\"some test suite\", () => {\n * it(\"should test something with requestAnimationFrame\", () => {\n * const raf = testImmediateRaf();\n *\n * // do some testing with requestAnimationFrame\n *\n * // reset to original at the end of the test\n * raf.mockRestore()\n * });\n * });\n * ```\n *\n * @example Automatic Cleanup\n * ```ts\n * import { testImmediateRaf } from \"@react-md/core/test-utils/vitest\";\n *\n * afterEach(() => {\n *
|
|
1
|
+
{"version":3,"sources":["../../../src/test-utils/vitest/timers.ts"],"sourcesContent":["import { type MockInstance, vi } from \"vitest\";\n\n/**\n * @since 6.0.0\n */\nexport type RafSpy = MockInstance<typeof requestAnimationFrame>;\n\n/**\n * @example\n * ```ts\n * import { testImmediateRaf } from \"@react-md/core/test-utils/vitest\";\n *\n * describe(\"some test suite\", () => {\n * it(\"should test something with requestAnimationFrame\", () => {\n * const raf = testImmediateRaf();\n *\n * // do some testing with requestAnimationFrame\n *\n * // reset to original at the end of the test\n * raf.mockRestore()\n * });\n * });\n * ```\n *\n * @example Automatic Cleanup\n * ```ts\n * import { testImmediateRaf } from \"@react-md/core/test-utils/vitest\";\n *\n * afterEach(() => {\n * vi.restoreAllMocks();\n * });\n *\n * describe(\"some test suite\", () => {\n * it(\"should test something with requestAnimationFrame\", () => {\n * const raf = testImmediateRaf();\n *\n * // do some testing with requestAnimationFrame\n * });\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const testImmediateRaf = (): RafSpy =>\n vi.spyOn(window, \"requestAnimationFrame\").mockImplementation((cb) => {\n cb(0);\n return 0;\n });\n"],"names":["vi","testImmediateRaf","spyOn","window","mockImplementation","cb"],"mappings":"AAAA,SAA4BA,EAAE,QAAQ,SAAS;AAO/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCC,GACD,OAAO,MAAMC,mBAAmB,IAC9BD,GAAGE,KAAK,CAACC,QAAQ,yBAAyBC,kBAAkB,CAAC,CAACC;QAC5DA,GAAG;QACH,OAAO;IACT,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { Portal } from \"../portal/Portal.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type SSRTransitionOptions,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n DEFAULT_TOOLTIP_CLASSNAMES,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_TIMEOUT,\n} from \"./constants.js\";\nimport { type TooltipClassNameOptions, tooltip } from \"./styles.js\";\n\n/**\n * The base props for the `Tooltip` component. This can be extended when\n * creating custom tooltip implementations.\n *\n * @since 2.8.0 Supports the `RenderConditionalPortalProps`\n * @since 6.0.0 The `id` prop is optional.\n * @since 6.0.0 Removed `lineWrap` for `textOverflow`\n * @since 6.0.0 No longer supports the `RenderConditionalPortalProps` other than\n * `portal` with the `disablePortal` prop.\n * @since 6.3.1 Extends TooltipClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface TooltipProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { Portal } from \"../portal/Portal.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type SSRTransitionOptions,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n DEFAULT_TOOLTIP_CLASSNAMES,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_TIMEOUT,\n} from \"./constants.js\";\nimport { type TooltipClassNameOptions, tooltip } from \"./styles.js\";\n\n/**\n * The base props for the `Tooltip` component. This can be extended when\n * creating custom tooltip implementations.\n *\n * @since 2.8.0 Supports the `RenderConditionalPortalProps`\n * @since 6.0.0 The `id` prop is optional.\n * @since 6.0.0 Removed `lineWrap` for `textOverflow`\n * @since 6.0.0 No longer supports the `RenderConditionalPortalProps` other than\n * `portal` with the `disablePortal` prop.\n * @since 6.3.1 Extends TooltipClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface TooltipProps\n extends\n HTMLAttributes<HTMLSpanElement>,\n TooltipClassNameOptions,\n CSSTransitionComponentProps,\n SSRTransitionOptions,\n TransitionActions {\n visible: boolean;\n\n /**\n * @see {@link CSSTransitionComponentProps.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @see {@link CSSTransitionComponentProps.timeout}\n * @defaultValue `DEFAULT_TOOLTIP_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link CSSTransitionComponentProps.classNames}\n * @defaultValue `DEFAULT_TOOLTIP_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n}\n\n/**\n * **Client Component**\n *\n * This is the base tooltip component that can only be used to render a tooltip\n * with an animation when the visibility changes. If this component is used, you\n * will need to manually add all the event listeners and triggers to change the\n * `visible` prop.\n *\n * @example Simple Usage\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n *\n * function Example() {\n * const { elementProps, tooltipProps } = useTooltip();\n *\n * return (\n * <>\n * <Button {...elementProps}>Button</Button>\n * <Tooltip {...tooltipProps}>\n * Tooltip Content\n * </Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n */\nexport const Tooltip = forwardRef<HTMLSpanElement, TooltipProps>(\n function Tooltip(props, nodeRef) {\n const {\n id: propId,\n dense,\n visible,\n children,\n appear,\n enter,\n exit,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n timeout = DEFAULT_TOOLTIP_TIMEOUT,\n classNames = DEFAULT_TOOLTIP_CLASSNAMES,\n className,\n position = DEFAULT_TOOLTIP_POSITION,\n temporary = true,\n exitedHidden = !temporary,\n textOverflow,\n disablePortal: propDisablePortal,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"tooltip\");\n\n const { rendered, elementProps, disablePortal } = useCSSTransition({\n nodeRef,\n appear,\n enter,\n exit,\n transitionIn: visible,\n timeout,\n classNames,\n className: tooltip({\n dense,\n position,\n className,\n textOverflow,\n }),\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n temporary,\n exitedHidden,\n disablePortal: propDisablePortal,\n });\n\n return (\n <Portal disabled={disablePortal}>\n {rendered && (\n <span {...remaining} {...elementProps} id={id} role=\"tooltip\">\n {children}\n </span>\n )}\n </Portal>\n );\n }\n);\n"],"names":["forwardRef","Portal","useCSSTransition","useEnsuredId","DEFAULT_TOOLTIP_CLASSNAMES","DEFAULT_TOOLTIP_POSITION","DEFAULT_TOOLTIP_TIMEOUT","tooltip","Tooltip","props","nodeRef","id","propId","dense","visible","children","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","timeout","classNames","className","position","temporary","exitedHidden","textOverflow","disablePortal","propDisablePortal","remaining","rendered","elementProps","transitionIn","disabled","span","role"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAASC,MAAM,QAAQ,sBAAsB;AAQ7C,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SACEC,0BAA0B,EAC1BC,wBAAwB,EACxBC,uBAAuB,QAClB,iBAAiB;AACxB,SAAuCC,OAAO,QAAQ,cAAc;AA0CpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMC,wBAAUR,WACrB,SAASQ,QAAQC,KAAK,EAAEC,OAAO;IAC7B,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,OAAO,EACPC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,UAAUnB,uBAAuB,EACjCoB,aAAatB,0BAA0B,EACvCuB,SAAS,EACTC,WAAWvB,wBAAwB,EACnCwB,YAAY,IAAI,EAChBC,eAAe,CAACD,SAAS,EACzBE,YAAY,EACZC,eAAeC,iBAAiB,EAChC,GAAGC,WACJ,GAAGzB;IACJ,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,MAAM,EAAEuB,QAAQ,EAAEC,YAAY,EAAEJ,aAAa,EAAE,GAAG9B,iBAAiB;QACjEQ;QACAM;QACAC;QACAC;QACAmB,cAAcvB;QACdW;QACAC;QACAC,WAAWpB,QAAQ;YACjBM;YACAe;YACAD;YACAI;QACF;QACAZ;QACAC;QACAC;QACAC;QACAC;QACAC;QACAK;QACAC;QACAE,eAAeC;IACjB;IAEA,qBACE,KAAChC;QAAOqC,UAAUN;kBACfG,0BACC,KAACI;YAAM,GAAGL,SAAS;YAAG,GAAGE,YAAY;YAAEzB,IAAIA;YAAI6B,MAAK;sBACjDzB;;;AAKX,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tooltip/TooltipHoverModeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport {\n type HoverModeConfiguration,\n type HoverModeContext,\n createHoverModeContext,\n useHoverModeProvider,\n} from \"../hoverMode/useHoverModeProvider.js\";\nimport { DEFAULT_TOOLTIP_DELAY } from \"./constants.js\";\n\n/** @since 6.0.0 */\nexport type TooltipHoverModeContext = HoverModeContext;\n\nconst context = createContext<TooltipHoverModeContext>(\n createHoverModeContext({\n hoverTimeout: DEFAULT_TOOLTIP_DELAY,\n leaveTimeout: 0,\n })\n);\ncontext.displayName = \"TooltipHoverMode\";\nconst { Provider } = context;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function useTooltipHoverMode(): Readonly<TooltipHoverModeContext> {\n return useContext(context);\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TooltipHoverModeProviderProps
|
|
1
|
+
{"version":3,"sources":["../../src/tooltip/TooltipHoverModeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport {\n type HoverModeConfiguration,\n type HoverModeContext,\n createHoverModeContext,\n useHoverModeProvider,\n} from \"../hoverMode/useHoverModeProvider.js\";\nimport { DEFAULT_TOOLTIP_DELAY } from \"./constants.js\";\n\n/** @since 6.0.0 */\nexport type TooltipHoverModeContext = HoverModeContext;\n\nconst context = createContext<TooltipHoverModeContext>(\n createHoverModeContext({\n hoverTimeout: DEFAULT_TOOLTIP_DELAY,\n leaveTimeout: 0,\n })\n);\ncontext.displayName = \"TooltipHoverMode\";\nconst { Provider } = context;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function useTooltipHoverMode(): Readonly<TooltipHoverModeContext> {\n return useContext(context);\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TooltipHoverModeProviderProps extends Partial<HoverModeConfiguration> {\n children: ReactNode;\n\n /**\n * @see {@link HoverModeConfiguration.hoverTimeout}\n * @defaultValue `1000`\n */\n hoverTimeout?: number;\n\n /**\n * @see {@link HoverModeConfiguration.leaveTimeout}\n * @defaultValue `0`\n */\n leaveTimeout?: number;\n\n /**\n * @see {@link HoverModeConfiguration.disableTimeout}\n * @defaultValue `1000`\n */\n disableTimeout?: number;\n}\n\n/**\n * **Client Component**\n *\n * Updates all tooltips that are rendered as a child anywhere in the React tree\n * to immediately appear for a short duration once a tooltip has become visible.\n * You can also use this provider to configure all tooltips' visibility delay to\n * a new value.\n *\n * @example Configuration Example\n * ```tsx\n * <TooltipHoverModeProvider\n * // wait 3 seconds before displaying any tooltips\n * hoverTimeout={3000}\n *\n * // wait 1 second before hiding any tooltips\n * leaveTimeout={1000}\n *\n * // disable the hover mode functionality only if another tooltip has not\n * // been visible for 20 seconds\n * disableTimeout={20000}\n * >\n * <RestOfTheApp />\n * </TooltipHoverModeProvider>\n * ```\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n * @since 6.0.0\n */\nexport function TooltipHoverModeProvider(\n props: TooltipHoverModeProviderProps\n): ReactElement {\n const {\n hoverTimeout = DEFAULT_TOOLTIP_DELAY,\n leaveTimeout = 0,\n disableTimeout = DEFAULT_TOOLTIP_DELAY,\n defaultActiveId,\n children,\n } = props;\n const context = useHoverModeProvider({\n hoverTimeout,\n leaveTimeout,\n disableTimeout,\n defaultActiveId,\n });\n\n return <Provider value={context}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","createHoverModeContext","useHoverModeProvider","DEFAULT_TOOLTIP_DELAY","context","hoverTimeout","leaveTimeout","displayName","Provider","useTooltipHoverMode","TooltipHoverModeProvider","props","disableTimeout","defaultActiveId","children","value"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,QACL,QAAQ;AAEf,SAGEC,sBAAsB,EACtBC,oBAAoB,QACf,uCAAuC;AAC9C,SAASC,qBAAqB,QAAQ,iBAAiB;AAKvD,MAAMC,wBAAUL,cACdE,uBAAuB;IACrBI,cAAcF;IACdG,cAAc;AAChB;AAEFF,QAAQG,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;AAErB;;;CAGC,GACD,OAAO,SAASK;IACd,OAAOT,WAAWI;AACpB;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,SAASM,yBACdC,KAAoC;IAEpC,MAAM,EACJN,eAAeF,qBAAqB,EACpCG,eAAe,CAAC,EAChBM,iBAAiBT,qBAAqB,EACtCU,eAAe,EACfC,QAAQ,EACT,GAAGH;IACJ,MAAMP,UAAUF,qBAAqB;QACnCG;QACAC;QACAM;QACAC;IACF;IAEA,qBAAO,KAACL;QAASO,OAAOX;kBAAUU;;AACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tooltip/useTooltip.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type FocusEvent,\n type MouseEvent,\n type MutableRefObject,\n type Ref,\n type RefObject,\n type TouchEvent,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from \"react\";\n\nimport {\n type ControlledHoverModeImplementation,\n useHoverMode,\n} from \"../hoverMode/useHoverMode.js\";\nimport {\n type UserInteractionMode,\n useUserInteractionMode,\n} from \"../interaction/UserInteractionModeProvider.js\";\nimport { type SimplePosition } from \"../positioning/types.js\";\nimport {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type FixedPositioningOptions,\n type FixedPositioningTransitionCallbacks,\n useFixedPositioning,\n} from \"../positioning/useFixedPositioning.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { usePageInactive } from \"../usePageInactive.js\";\nimport { parseCssLengthUnit } from \"../utils/parseCssLengthUnit.js\";\nimport { useTooltipHoverMode } from \"./TooltipHoverModeProvider.js\";\nimport {\n DEFAULT_TOOLTIP_DENSE_SPACING,\n DEFAULT_TOOLTIP_MARGIN,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_SPACING,\n DEFAULT_TOOLTIP_THRESHOLD,\n TOOLTIP_SPACING_VAR,\n} from \"./constants.js\";\nimport {\n type TooltipPositionHookOptions,\n useTooltipPosition,\n} from \"./useTooltipPosition.js\";\nimport { getAnchor } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/** @since 2.8.0 */\nexport interface TooltipPositioningOptions {\n style?: CSSProperties;\n\n /**\n * @see {@link FixedPositioningOptions.vwMargin}\n * @defaultValue `16`\n */\n vwMargin?: number;\n\n /**\n * @see {@link FixedPositioningOptions.vhMargin}\n * @defaultValue `16`\n */\n vhMargin?: number;\n\n /**\n * Set this to `true` to reduce the font size and padding on the tooltip and\n * the amount of spacing between the tooltipped element and the tooltip.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * The amount of spacing to use between the tooltipped element and the tooltip\n * when {@link disableAutoSpacing} is `false`.\n *\n * @defaultValue `\"1.5rem`\n */\n spacing?: number | string;\n\n /**\n * The amount of spacing to use between the tooltipped element and the tooltip\n * when {@link disableAutoSpacing} is `false` and {@link dense} is `true`.\n *\n * @defaultValue `\"0.875rem`\n */\n denseSpacing?: number | string;\n\n /**\n * Set this to `true` to prevent the {@link defaultPosition} to swap to the\n * other side of the tooltipped element when it is too close to the viewport\n * edge. This will always be `true` if a {@link position} is provided.\n *\n * @defaultValue `false`\n */\n disableSwapping?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disableAutoSpacing?: boolean;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Removed the `TooltipTouchEventHandlers` and\n * `TooltipKeyboardEventHandlers` types, removed the need for the `onKeyDown`\n * event.\n */\nexport interface TooltippedElementEventHandlers<\n E extends HTMLElement = HTMLButtonElement,\n> {\n onBlur?: (event: FocusEvent<E>) => void;\n onFocus?: (event: FocusEvent<E>) => void;\n onMouseEnter?: (event: MouseEvent<E>) => void;\n onMouseLeave?: (event: MouseEvent<E>) => void;\n onTouchStart?: (event: TouchEvent<E>) => void;\n onTouchEnd?: (event: TouchEvent<E>) => void;\n onContextMenu?: (event: MouseEvent<E>) => void;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Renamed from `TooltipHookProvidedElementProps`\n */\nexport interface ProvidedTooltippedElementProps<E extends HTMLElement>\n extends Required<TooltippedElementEventHandlers<E>> {\n \"aria-describedby\": string | undefined;\n id: string;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 A major API change for the hover mode behavior and no longer\n * requires a `baseId`/`id` for the tooltip. Also renamed from\n * `TooltipHookOptions` to `TooltipOptions` to match other hook naming\n * conventions.\n */\nexport interface TooltipOptions<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n> extends FixedPositioningTransitionCallbacks,\n TooltippedElementEventHandlers<TooltippedElement>,\n TooltipPositioningOptions,\n TooltipPositionHookOptions {\n /**\n * @defaultValue `\"tooltip-\" + useId()`\n */\n id?: string;\n\n /**\n * An optional override for the `aria-describedby`\n */\n describedBy?: string;\n\n /**\n * Any styles to be merged with the fixed positioning styles for the tooltip.\n */\n style?: CSSProperties;\n\n /**\n * Boolean if the event handlers should no longer attempt to show a tooltip. This\n * should be set to `true` when your component might not have a tooltip associated\n * with it.\n *\n * @example Real World Example\n * ```tsx\n * // This is _almost_ the source code for the `TooltippedButton` provided by react-md\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n * import { type ReactElement, type ReactNode } from \"react\";\n *\n * export interface TooltippedButtonProps extends ButtonProps {\n * tooltip?: ReactNode;\n * }\n *\n * export function TooltippedButton({\n * id,\n * tooltip,\n * children,\n * onBlur,\n * onFocus,\n * onMouseEnter,\n * onMouseLeave,\n * onTouchStart,\n * onTouchEnd,\n * onContextMenu,\n * ...props\n * }: TooltippedButtonProps): ReactElement {\n * const { elementProps, tooltipProps } = useTooltip({\n * id,\n * disabled: !tooltip,\n * onBlur,\n * onFocus,\n * onMouseEnter,\n * onMouseLeave,\n * onTouchStart,\n * onTouchEnd,\n * onContextMenu,\n * });\n *\n * return (\n * <>\n * <Button {...props} {...elementProps}>\n * {children}\n * </Button>\n * <Tooltip {...tooltipProps}>{tooltip}</Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @defaultValue `false`\n * @since 5.1.0\n */\n disabled?: boolean;\n\n /**\n * The amount of time (in ms) to hover an element before the tooltip becomes\n * visible.\n *\n * The default value is really the current hover timeout from the\n * `TooltipHoverModeProvider`.\n *\n * @defaultValue `1000`\n */\n hoverTimeout?: number;\n\n /**\n * The amount of time to wait before triggering the exit animation for the\n * tooltip.\n *\n * The default value is really the current leaveTimeout timeout from the\n * `TooltipHoverModeProvider`.\n *\n * @defaultValue `0`\n */\n leaveTimeout?: number;\n\n /**\n * Set this to `true` to only allow the tooltip to become visible when the\n * `event .currentTarget` or `overflowRef` has text overflow.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n overflowOnly?: boolean;\n\n /**\n * @see {@link FixedPositioningOptions.disabled}\n * @defaultValue `false`\n */\n disableFixedPositioning?: boolean;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 This was renamed from `TooltipHookProvidedTooltipProps`\n */\nexport interface ProvidedTooltipProps<E extends HTMLElement = HTMLSpanElement>\n extends Required<FixedPositioningTransitionCallbacks> {\n id: string;\n ref: Ref<E>;\n dense: boolean;\n style: CSSProperties | undefined;\n visible: boolean;\n position: SimplePosition;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 No longer returns any properties from the hover mode provider\n * because of the major API change to hover mode.. Also renamed from\n * `TooltipHookReturnValue` to `TooltipImplementation` to match other hook\n * naming conventions.\n */\nexport interface TooltipImplementation<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n TooltipElement extends HTMLElement = HTMLSpanElement,\n> extends ControlledHoverModeImplementation {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n animatedOnce: boolean;\n initiatedBy: MutableRefObject<UserInteractionMode | null>;\n elementProps: ProvidedTooltippedElementProps<TooltippedElement>;\n tooltipProps: ProvidedTooltipProps<TooltipElement>;\n\n /**\n * This is a wrapper around the {@link setVisible} behavior that will also\n * clear any pending timeouts.\n */\n hideTooltip: () => void;\n\n /**\n * @since 6.0.0\n */\n overflowRef: RefObject<HTMLElement>;\n}\n\n/**\n * @example Simple Usage\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n *\n * function Example() {\n * const { elementProps, tooltipProps } = useTooltip();\n *\n * return (\n * <>\n * <Button {...elementProps}>Button</Button>\n * <Tooltip {...tooltipProps}>\n * Tooltip Content\n * </Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @example Overflow-only Tooltips\n * ```tsx\n * import { cssUtils } from \"@react-md/core/cssUtils\";\n * import { Link, type LinkProps } from \"@react-md/core/link/Link\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n * import { type ReactElement } from \"react\";\n *\n * function NavigationLink(props: LinkProps): ReactElement {\n * const { children, ...remaining } = props;\n *\n * // using the `overflowRef` is optional and will default to the\n * // `event.currentTarget` when `null`\n * const { overflowRef, elementProps, tooltipProps } = useOverflowTooltip({\n * // just to pass any event handlers\n * ...remaining,\n * overflowOnly: true,\n * });\n *\n * return (\n * <Link {...remaining} {...elementProps} style={{ width: \"100%\" }}>\n * <span ref={overflowRef} className={cssUtils({ textOverflow: \"ellipsis\" })}>\n * {children}\n * </span>\n * <Tooltip {...tooltipProps}>\n * {children}\n * </Tooltip>\n * </Link>\n * );\n * }\n *\n * function Example(): ReactElement {\n * return (\n * <div style={{ width: \"10rem\", overflow: \"auto\" }}>\n * <NavigationLink href=\"/\">Home</NavigationLink>\n * <NavigationLink href=\"/some-path\">\n * Super long text that will be truncated with ellipsis and\n * have a tooltip appear\n * </NavigationLink>\n * </div>\n * );\n * }\n * ```\n *\n * ## Inspecting Tooltip Styles\n *\n * Since tooltips will disappear on blur, mouseleave, etc, it is a bit hard to\n * inspect the tooltip styles. In dev mode, you can manually set the visibility\n * to `true` through the dev tools.\n * - find your tooltip implementation\n * - expand the Tooltip hook\n * - expand the HoverMode hook\n * - set the first boolean state to `true`\n *\n * The tooltip will now remain visible allowing you to find it within the\n * \"Inspector\" tab in the dev tools.\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n * @since 2.8.0\n * @since 6.0.0 Uses a separate `TooltipHoverModeProvider`.\n *\n * TODO: I need to fix the tooltip for click events and history changes since\n * the mouseleave event will not be correctly bubbled if hovering a child\n * element when the click or history update happens. this causes the tooltip to\n * stay visible\n */\nexport function useTooltip<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n TooltipElement extends HTMLElement = HTMLSpanElement,\n>(\n options: TooltipOptions<TooltippedElement> = {}\n): TooltipImplementation<TooltippedElement, TooltipElement> {\n const {\n id: propId,\n style: propStyle,\n disabled = false,\n describedBy,\n dense = false,\n hoverTimeout,\n leaveTimeout,\n vwMargin = DEFAULT_TOOLTIP_MARGIN,\n vhMargin = DEFAULT_TOOLTIP_MARGIN,\n spacing = DEFAULT_TOOLTIP_SPACING,\n denseSpacing = DEFAULT_TOOLTIP_DENSE_SPACING,\n disableSwapping,\n disableAutoSpacing,\n position: determinedPosition,\n defaultPosition = DEFAULT_TOOLTIP_POSITION,\n threshold = DEFAULT_TOOLTIP_THRESHOLD,\n onBlur = noop,\n onFocus = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n onTouchStart = noop,\n onTouchEnd = noop,\n onContextMenu = noop,\n onEnter = noop,\n onEntering,\n onEntered = noop,\n onExited,\n overflowOnly,\n disableFixedPositioning,\n } = options;\n\n const fallbackId = useId();\n const id = propId || fallbackId;\n const tooltipId = `${id}-tooltip`;\n const {\n animatedOnceRef,\n hoverTimeoutRef,\n leaveTimeoutRef,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n } = useTooltipHoverMode();\n const {\n visible,\n setVisible,\n startShowFlow,\n startHideFlow,\n clearVisibilityTimeout,\n } = useHoverMode({\n hoverTimeout,\n hoverTimeoutRef,\n leaveTimeout,\n leaveTimeoutRef,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n });\n const [position, updatePosition] = useTooltipPosition({\n position: determinedPosition,\n defaultPosition,\n threshold,\n });\n\n const mode = useUserInteractionMode();\n const elementRef = useRef<HTMLElement | null>(null);\n const tooltipRef = useRef<TooltipElement>(null);\n const overflowRef = useRef<HTMLElement>(null);\n const initiatedBy = useRef<UserInteractionMode | null>(null);\n const { ref, style, callbacks } = useFixedPositioning({\n nodeRef: tooltipRef,\n style: propStyle,\n fixedTo: elementRef,\n anchor: getAnchor(position),\n disableSwapping: disableSwapping ?? !!determinedPosition,\n disabled: disableFixedPositioning,\n getFixedPositionOptions() {\n let tooltipSpacing = dense ? denseSpacing : spacing;\n const tooltip = tooltipRef.current;\n if (!disableAutoSpacing && tooltip) {\n tooltipSpacing =\n window\n .getComputedStyle(tooltip)\n .getPropertyValue(TOOLTIP_SPACING_VAR) || spacing;\n }\n\n const currentSpacing = parseCssLengthUnit({\n value: tooltipSpacing,\n });\n const horizontal = position === \"left\" || position === \"right\";\n\n return {\n vwMargin,\n vhMargin,\n xMargin: horizontal ? currentSpacing : undefined,\n yMargin: horizontal ? undefined : currentSpacing,\n };\n },\n onEnter(appearing) {\n onEnter(appearing);\n\n // This allows you to inspect the tooltip styles through the element\n // inspector without first hovering or focusing the tooltipped element\n // beforehand by setting the `HoverMode` hook to `true`\n if (process.env.NODE_ENV !== \"production\" && !elementRef.current) {\n elementRef.current = document.getElementById(id);\n }\n },\n onEntering,\n onEntered(appearing) {\n onEntered(appearing);\n\n animatedOnceRef.current = true;\n },\n onExited,\n });\n\n const hideTooltip = useCallback(() => {\n initiatedBy.current = null;\n disableHoverMode();\n clearVisibilityTimeout();\n setVisible(false);\n }, [clearVisibilityTimeout, disableHoverMode, setVisible]);\n\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === \"Escape\") {\n hideTooltip();\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n window.addEventListener(\"scroll\", hideTooltip, true);\n window.addEventListener(\"touchend\", hideTooltip, true);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n window.removeEventListener(\"scroll\", hideTooltip, true);\n window.removeEventListener(\"touchend\", hideTooltip, true);\n };\n }, [hideTooltip, visible]);\n\n const refocusFrame = useRef(0);\n const pageInactive = useRef(false);\n usePageInactive({\n disabled,\n onDisabledCleanup: hideTooltip,\n onChange(active) {\n if (active) {\n refocusFrame.current = window.requestAnimationFrame(() => {\n pageInactive.current = false;\n });\n return;\n }\n\n pageInactive.current = true;\n hideTooltip();\n },\n });\n\n const isNotOverflown = (currentTarget: HTMLElement): boolean => {\n if (!overflowOnly) {\n return false;\n }\n\n const element = overflowRef.current || currentTarget;\n return !element || element.offsetWidth >= element.scrollWidth;\n };\n\n return {\n visible,\n setVisible,\n hideTooltip,\n animatedOnce: animatedOnceRef.current,\n initiatedBy,\n overflowRef,\n startShowFlow,\n startHideFlow,\n clearVisibilityTimeout,\n tooltipProps: {\n id: tooltipId,\n ref,\n dense,\n style,\n visible,\n position,\n ...callbacks,\n },\n elementProps: {\n \"aria-describedby\": cnb(visible && tooltipId, describedBy) || undefined,\n id,\n onMouseEnter(event) {\n onMouseEnter(event);\n if (\n disabled ||\n mode === \"touch\" ||\n initiatedBy.current !== null ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n initiatedBy.current = \"mouse\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onMouseLeave(event) {\n onMouseLeave(event);\n if (disabled || initiatedBy.current !== \"mouse\") {\n return;\n }\n\n startHideFlow();\n initiatedBy.current = null;\n },\n onBlur(event) {\n onBlur(event);\n if (disabled) {\n return;\n }\n\n initiatedBy.current = null;\n startHideFlow();\n },\n onFocus(event) {\n onFocus(event);\n // skip the focus events when the browser is re-focused if the user\n // pressed alt-tab, minimized the browser, etc\n if (\n disabled ||\n mode !== \"keyboard\" ||\n initiatedBy.current !== null ||\n pageInactive.current ||\n isNotOverflown(event.currentTarget)\n ) {\n pageInactive.current = false;\n return;\n }\n\n initiatedBy.current = \"keyboard\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onTouchStart(event) {\n onTouchStart(event);\n if (\n disabled ||\n initiatedBy.current !== null ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n initiatedBy.current = \"touch\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onTouchEnd(event) {\n onTouchEnd(event);\n if (disabled) {\n return;\n }\n\n initiatedBy.current = null;\n startHideFlow();\n },\n onContextMenu(event) {\n onContextMenu(event);\n if (\n disabled ||\n initiatedBy.current !== \"touch\" ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n event.preventDefault();\n const selection = window.getSelection();\n const node = selection?.anchorNode?.parentElement;\n if (node && event.currentTarget.contains(node)) {\n selection.empty();\n }\n },\n },\n };\n}\n"],"names":["cnb","useCallback","useEffect","useId","useRef","useHoverMode","useUserInteractionMode","useFixedPositioning","usePageInactive","parseCssLengthUnit","useTooltipHoverMode","DEFAULT_TOOLTIP_DENSE_SPACING","DEFAULT_TOOLTIP_MARGIN","DEFAULT_TOOLTIP_POSITION","DEFAULT_TOOLTIP_SPACING","DEFAULT_TOOLTIP_THRESHOLD","TOOLTIP_SPACING_VAR","useTooltipPosition","getAnchor","noop","useTooltip","options","id","propId","style","propStyle","disabled","describedBy","dense","hoverTimeout","leaveTimeout","vwMargin","vhMargin","spacing","denseSpacing","disableSwapping","disableAutoSpacing","position","determinedPosition","defaultPosition","threshold","onBlur","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","onContextMenu","onEnter","onEntering","onEntered","onExited","overflowOnly","disableFixedPositioning","fallbackId","tooltipId","animatedOnceRef","hoverTimeoutRef","leaveTimeoutRef","enableHoverMode","disableHoverMode","startDisableTimer","clearDisableTimer","visible","setVisible","startShowFlow","startHideFlow","clearVisibilityTimeout","updatePosition","mode","elementRef","tooltipRef","overflowRef","initiatedBy","ref","callbacks","nodeRef","fixedTo","anchor","getFixedPositionOptions","tooltipSpacing","tooltip","current","window","getComputedStyle","getPropertyValue","currentSpacing","value","horizontal","xMargin","undefined","yMargin","appearing","process","env","NODE_ENV","document","getElementById","hideTooltip","handleKeyDown","event","key","addEventListener","removeEventListener","refocusFrame","pageInactive","onDisabledCleanup","onChange","active","requestAnimationFrame","isNotOverflown","currentTarget","element","offsetWidth","scrollWidth","animatedOnce","tooltipProps","elementProps","preventDefault","selection","getSelection","node","anchorNode","parentElement","contains","empty"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAQEC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,MAAM,QACD,QAAQ;AAEf,SAEEC,YAAY,QACP,+BAA+B;AACtC,SAEEC,sBAAsB,QACjB,gDAAgD;AAEvD,SAIEC,mBAAmB,QACd,wCAAwC;AAE/C,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,kBAAkB,QAAQ,iCAAiC;AACpE,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SACEC,6BAA6B,EAC7BC,sBAAsB,EACtBC,wBAAwB,EACxBC,uBAAuB,EACvBC,yBAAyB,EACzBC,mBAAmB,QACd,iBAAiB;AACxB,SAEEC,kBAAkB,QACb,0BAA0B;AACjC,SAASC,SAAS,QAAQ,aAAa;AAEvC,MAAMC,OAAO;AACX,aAAa;AACf;AA6PA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFC,GACD,OAAO,SAASC,WAIdC,UAA6C,CAAC,CAAC;IAE/C,MAAM,EACJC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F;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/tooltip/useTooltip.ts"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type FocusEvent,\n type MouseEvent,\n type MutableRefObject,\n type Ref,\n type RefObject,\n type TouchEvent,\n useCallback,\n useEffect,\n useId,\n useRef,\n} from \"react\";\n\nimport {\n type ControlledHoverModeImplementation,\n useHoverMode,\n} from \"../hoverMode/useHoverMode.js\";\nimport {\n type UserInteractionMode,\n useUserInteractionMode,\n} from \"../interaction/UserInteractionModeProvider.js\";\nimport { type SimplePosition } from \"../positioning/types.js\";\nimport {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type FixedPositioningOptions,\n type FixedPositioningTransitionCallbacks,\n useFixedPositioning,\n} from \"../positioning/useFixedPositioning.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { usePageInactive } from \"../usePageInactive.js\";\nimport { parseCssLengthUnit } from \"../utils/parseCssLengthUnit.js\";\nimport { useTooltipHoverMode } from \"./TooltipHoverModeProvider.js\";\nimport {\n DEFAULT_TOOLTIP_DENSE_SPACING,\n DEFAULT_TOOLTIP_MARGIN,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_SPACING,\n DEFAULT_TOOLTIP_THRESHOLD,\n TOOLTIP_SPACING_VAR,\n} from \"./constants.js\";\nimport {\n type TooltipPositionHookOptions,\n useTooltipPosition,\n} from \"./useTooltipPosition.js\";\nimport { getAnchor } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/** @since 2.8.0 */\nexport interface TooltipPositioningOptions {\n style?: CSSProperties;\n\n /**\n * @see {@link FixedPositioningOptions.vwMargin}\n * @defaultValue `16`\n */\n vwMargin?: number;\n\n /**\n * @see {@link FixedPositioningOptions.vhMargin}\n * @defaultValue `16`\n */\n vhMargin?: number;\n\n /**\n * Set this to `true` to reduce the font size and padding on the tooltip and\n * the amount of spacing between the tooltipped element and the tooltip.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * The amount of spacing to use between the tooltipped element and the tooltip\n * when {@link disableAutoSpacing} is `false`.\n *\n * @defaultValue `\"1.5rem`\n */\n spacing?: number | string;\n\n /**\n * The amount of spacing to use between the tooltipped element and the tooltip\n * when {@link disableAutoSpacing} is `false` and {@link dense} is `true`.\n *\n * @defaultValue `\"0.875rem`\n */\n denseSpacing?: number | string;\n\n /**\n * Set this to `true` to prevent the {@link defaultPosition} to swap to the\n * other side of the tooltipped element when it is too close to the viewport\n * edge. This will always be `true` if a {@link position} is provided.\n *\n * @defaultValue `false`\n */\n disableSwapping?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disableAutoSpacing?: boolean;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Removed the `TooltipTouchEventHandlers` and\n * `TooltipKeyboardEventHandlers` types, removed the need for the `onKeyDown`\n * event.\n */\nexport interface TooltippedElementEventHandlers<\n E extends HTMLElement = HTMLButtonElement,\n> {\n onBlur?: (event: FocusEvent<E>) => void;\n onFocus?: (event: FocusEvent<E>) => void;\n onMouseEnter?: (event: MouseEvent<E>) => void;\n onMouseLeave?: (event: MouseEvent<E>) => void;\n onTouchStart?: (event: TouchEvent<E>) => void;\n onTouchEnd?: (event: TouchEvent<E>) => void;\n onContextMenu?: (event: MouseEvent<E>) => void;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 Renamed from `TooltipHookProvidedElementProps`\n */\nexport interface ProvidedTooltippedElementProps<\n E extends HTMLElement,\n> extends Required<TooltippedElementEventHandlers<E>> {\n \"aria-describedby\": string | undefined;\n id: string;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 A major API change for the hover mode behavior and no longer\n * requires a `baseId`/`id` for the tooltip. Also renamed from\n * `TooltipHookOptions` to `TooltipOptions` to match other hook naming\n * conventions.\n */\nexport interface TooltipOptions<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n>\n extends\n FixedPositioningTransitionCallbacks,\n TooltippedElementEventHandlers<TooltippedElement>,\n TooltipPositioningOptions,\n TooltipPositionHookOptions {\n /**\n * @defaultValue `\"tooltip-\" + useId()`\n */\n id?: string;\n\n /**\n * An optional override for the `aria-describedby`\n */\n describedBy?: string;\n\n /**\n * Any styles to be merged with the fixed positioning styles for the tooltip.\n */\n style?: CSSProperties;\n\n /**\n * Boolean if the event handlers should no longer attempt to show a tooltip. This\n * should be set to `true` when your component might not have a tooltip associated\n * with it.\n *\n * @example Real World Example\n * ```tsx\n * // This is _almost_ the source code for the `TooltippedButton` provided by react-md\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n * import { type ReactElement, type ReactNode } from \"react\";\n *\n * export interface TooltippedButtonProps extends ButtonProps {\n * tooltip?: ReactNode;\n * }\n *\n * export function TooltippedButton({\n * id,\n * tooltip,\n * children,\n * onBlur,\n * onFocus,\n * onMouseEnter,\n * onMouseLeave,\n * onTouchStart,\n * onTouchEnd,\n * onContextMenu,\n * ...props\n * }: TooltippedButtonProps): ReactElement {\n * const { elementProps, tooltipProps } = useTooltip({\n * id,\n * disabled: !tooltip,\n * onBlur,\n * onFocus,\n * onMouseEnter,\n * onMouseLeave,\n * onTouchStart,\n * onTouchEnd,\n * onContextMenu,\n * });\n *\n * return (\n * <>\n * <Button {...props} {...elementProps}>\n * {children}\n * </Button>\n * <Tooltip {...tooltipProps}>{tooltip}</Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @defaultValue `false`\n * @since 5.1.0\n */\n disabled?: boolean;\n\n /**\n * The amount of time (in ms) to hover an element before the tooltip becomes\n * visible.\n *\n * The default value is really the current hover timeout from the\n * `TooltipHoverModeProvider`.\n *\n * @defaultValue `1000`\n */\n hoverTimeout?: number;\n\n /**\n * The amount of time to wait before triggering the exit animation for the\n * tooltip.\n *\n * The default value is really the current leaveTimeout timeout from the\n * `TooltipHoverModeProvider`.\n *\n * @defaultValue `0`\n */\n leaveTimeout?: number;\n\n /**\n * Set this to `true` to only allow the tooltip to become visible when the\n * `event .currentTarget` or `overflowRef` has text overflow.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n overflowOnly?: boolean;\n\n /**\n * @see {@link FixedPositioningOptions.disabled}\n * @defaultValue `false`\n */\n disableFixedPositioning?: boolean;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 This was renamed from `TooltipHookProvidedTooltipProps`\n */\nexport interface ProvidedTooltipProps<\n E extends HTMLElement = HTMLSpanElement,\n> extends Required<FixedPositioningTransitionCallbacks> {\n id: string;\n ref: Ref<E>;\n dense: boolean;\n style: CSSProperties | undefined;\n visible: boolean;\n position: SimplePosition;\n}\n\n/**\n * @since 2.8.0\n * @since 6.0.0 No longer returns any properties from the hover mode provider\n * because of the major API change to hover mode.. Also renamed from\n * `TooltipHookReturnValue` to `TooltipImplementation` to match other hook\n * naming conventions.\n */\nexport interface TooltipImplementation<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n TooltipElement extends HTMLElement = HTMLSpanElement,\n> extends ControlledHoverModeImplementation {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n animatedOnce: boolean;\n initiatedBy: MutableRefObject<UserInteractionMode | null>;\n elementProps: ProvidedTooltippedElementProps<TooltippedElement>;\n tooltipProps: ProvidedTooltipProps<TooltipElement>;\n\n /**\n * This is a wrapper around the {@link setVisible} behavior that will also\n * clear any pending timeouts.\n */\n hideTooltip: () => void;\n\n /**\n * @since 6.0.0\n */\n overflowRef: RefObject<HTMLElement>;\n}\n\n/**\n * @example Simple Usage\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n *\n * function Example() {\n * const { elementProps, tooltipProps } = useTooltip();\n *\n * return (\n * <>\n * <Button {...elementProps}>Button</Button>\n * <Tooltip {...tooltipProps}>\n * Tooltip Content\n * </Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @example Overflow-only Tooltips\n * ```tsx\n * import { cssUtils } from \"@react-md/core/cssUtils\";\n * import { Link, type LinkProps } from \"@react-md/core/link/Link\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n * import { type ReactElement } from \"react\";\n *\n * function NavigationLink(props: LinkProps): ReactElement {\n * const { children, ...remaining } = props;\n *\n * // using the `overflowRef` is optional and will default to the\n * // `event.currentTarget` when `null`\n * const { overflowRef, elementProps, tooltipProps } = useOverflowTooltip({\n * // just to pass any event handlers\n * ...remaining,\n * overflowOnly: true,\n * });\n *\n * return (\n * <Link {...remaining} {...elementProps} style={{ width: \"100%\" }}>\n * <span ref={overflowRef} className={cssUtils({ textOverflow: \"ellipsis\" })}>\n * {children}\n * </span>\n * <Tooltip {...tooltipProps}>\n * {children}\n * </Tooltip>\n * </Link>\n * );\n * }\n *\n * function Example(): ReactElement {\n * return (\n * <div style={{ width: \"10rem\", overflow: \"auto\" }}>\n * <NavigationLink href=\"/\">Home</NavigationLink>\n * <NavigationLink href=\"/some-path\">\n * Super long text that will be truncated with ellipsis and\n * have a tooltip appear\n * </NavigationLink>\n * </div>\n * );\n * }\n * ```\n *\n * ## Inspecting Tooltip Styles\n *\n * Since tooltips will disappear on blur, mouseleave, etc, it is a bit hard to\n * inspect the tooltip styles. In dev mode, you can manually set the visibility\n * to `true` through the dev tools.\n * - find your tooltip implementation\n * - expand the Tooltip hook\n * - expand the HoverMode hook\n * - set the first boolean state to `true`\n *\n * The tooltip will now remain visible allowing you to find it within the\n * \"Inspector\" tab in the dev tools.\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n * @since 2.8.0\n * @since 6.0.0 Uses a separate `TooltipHoverModeProvider`.\n *\n * TODO: I need to fix the tooltip for click events and history changes since\n * the mouseleave event will not be correctly bubbled if hovering a child\n * element when the click or history update happens. this causes the tooltip to\n * stay visible\n */\nexport function useTooltip<\n TooltippedElement extends HTMLElement = HTMLButtonElement,\n TooltipElement extends HTMLElement = HTMLSpanElement,\n>(\n options: TooltipOptions<TooltippedElement> = {}\n): TooltipImplementation<TooltippedElement, TooltipElement> {\n const {\n id: propId,\n style: propStyle,\n disabled = false,\n describedBy,\n dense = false,\n hoverTimeout,\n leaveTimeout,\n vwMargin = DEFAULT_TOOLTIP_MARGIN,\n vhMargin = DEFAULT_TOOLTIP_MARGIN,\n spacing = DEFAULT_TOOLTIP_SPACING,\n denseSpacing = DEFAULT_TOOLTIP_DENSE_SPACING,\n disableSwapping,\n disableAutoSpacing,\n position: determinedPosition,\n defaultPosition = DEFAULT_TOOLTIP_POSITION,\n threshold = DEFAULT_TOOLTIP_THRESHOLD,\n onBlur = noop,\n onFocus = noop,\n onMouseEnter = noop,\n onMouseLeave = noop,\n onTouchStart = noop,\n onTouchEnd = noop,\n onContextMenu = noop,\n onEnter = noop,\n onEntering,\n onEntered = noop,\n onExited,\n overflowOnly,\n disableFixedPositioning,\n } = options;\n\n const fallbackId = useId();\n const id = propId || fallbackId;\n const tooltipId = `${id}-tooltip`;\n const {\n animatedOnceRef,\n hoverTimeoutRef,\n leaveTimeoutRef,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n } = useTooltipHoverMode();\n const {\n visible,\n setVisible,\n startShowFlow,\n startHideFlow,\n clearVisibilityTimeout,\n } = useHoverMode({\n hoverTimeout,\n hoverTimeoutRef,\n leaveTimeout,\n leaveTimeoutRef,\n enableHoverMode,\n disableHoverMode,\n startDisableTimer,\n clearDisableTimer,\n });\n const [position, updatePosition] = useTooltipPosition({\n position: determinedPosition,\n defaultPosition,\n threshold,\n });\n\n const mode = useUserInteractionMode();\n const elementRef = useRef<HTMLElement | null>(null);\n const tooltipRef = useRef<TooltipElement>(null);\n const overflowRef = useRef<HTMLElement>(null);\n const initiatedBy = useRef<UserInteractionMode | null>(null);\n const { ref, style, callbacks } = useFixedPositioning({\n nodeRef: tooltipRef,\n style: propStyle,\n fixedTo: elementRef,\n anchor: getAnchor(position),\n disableSwapping: disableSwapping ?? !!determinedPosition,\n disabled: disableFixedPositioning,\n getFixedPositionOptions() {\n let tooltipSpacing = dense ? denseSpacing : spacing;\n const tooltip = tooltipRef.current;\n if (!disableAutoSpacing && tooltip) {\n tooltipSpacing =\n window\n .getComputedStyle(tooltip)\n .getPropertyValue(TOOLTIP_SPACING_VAR) || spacing;\n }\n\n const currentSpacing = parseCssLengthUnit({\n value: tooltipSpacing,\n });\n const horizontal = position === \"left\" || position === \"right\";\n\n return {\n vwMargin,\n vhMargin,\n xMargin: horizontal ? currentSpacing : undefined,\n yMargin: horizontal ? undefined : currentSpacing,\n };\n },\n onEnter(appearing) {\n onEnter(appearing);\n\n // This allows you to inspect the tooltip styles through the element\n // inspector without first hovering or focusing the tooltipped element\n // beforehand by setting the `HoverMode` hook to `true`\n if (process.env.NODE_ENV !== \"production\" && !elementRef.current) {\n elementRef.current = document.getElementById(id);\n }\n },\n onEntering,\n onEntered(appearing) {\n onEntered(appearing);\n\n animatedOnceRef.current = true;\n },\n onExited,\n });\n\n const hideTooltip = useCallback(() => {\n initiatedBy.current = null;\n disableHoverMode();\n clearVisibilityTimeout();\n setVisible(false);\n }, [clearVisibilityTimeout, disableHoverMode, setVisible]);\n\n useEffect(() => {\n if (!visible) {\n return;\n }\n\n const handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === \"Escape\") {\n hideTooltip();\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n window.addEventListener(\"scroll\", hideTooltip, true);\n window.addEventListener(\"touchend\", hideTooltip, true);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n window.removeEventListener(\"scroll\", hideTooltip, true);\n window.removeEventListener(\"touchend\", hideTooltip, true);\n };\n }, [hideTooltip, visible]);\n\n const refocusFrame = useRef(0);\n const pageInactive = useRef(false);\n usePageInactive({\n disabled,\n onDisabledCleanup: hideTooltip,\n onChange(active) {\n if (active) {\n refocusFrame.current = window.requestAnimationFrame(() => {\n pageInactive.current = false;\n });\n return;\n }\n\n pageInactive.current = true;\n hideTooltip();\n },\n });\n\n const isNotOverflown = (currentTarget: HTMLElement): boolean => {\n if (!overflowOnly) {\n return false;\n }\n\n const element = overflowRef.current || currentTarget;\n return !element || element.offsetWidth >= element.scrollWidth;\n };\n\n return {\n visible,\n setVisible,\n hideTooltip,\n animatedOnce: animatedOnceRef.current,\n initiatedBy,\n overflowRef,\n startShowFlow,\n startHideFlow,\n clearVisibilityTimeout,\n tooltipProps: {\n id: tooltipId,\n ref,\n dense,\n style,\n visible,\n position,\n ...callbacks,\n },\n elementProps: {\n \"aria-describedby\": cnb(visible && tooltipId, describedBy) || undefined,\n id,\n onMouseEnter(event) {\n onMouseEnter(event);\n if (\n disabled ||\n mode === \"touch\" ||\n initiatedBy.current !== null ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n initiatedBy.current = \"mouse\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onMouseLeave(event) {\n onMouseLeave(event);\n if (disabled || initiatedBy.current !== \"mouse\") {\n return;\n }\n\n startHideFlow();\n initiatedBy.current = null;\n },\n onBlur(event) {\n onBlur(event);\n if (disabled) {\n return;\n }\n\n initiatedBy.current = null;\n startHideFlow();\n },\n onFocus(event) {\n onFocus(event);\n // skip the focus events when the browser is re-focused if the user\n // pressed alt-tab, minimized the browser, etc\n if (\n disabled ||\n mode !== \"keyboard\" ||\n initiatedBy.current !== null ||\n pageInactive.current ||\n isNotOverflown(event.currentTarget)\n ) {\n pageInactive.current = false;\n return;\n }\n\n initiatedBy.current = \"keyboard\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onTouchStart(event) {\n onTouchStart(event);\n if (\n disabled ||\n initiatedBy.current !== null ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n initiatedBy.current = \"touch\";\n elementRef.current = event.currentTarget;\n updatePosition(event.currentTarget);\n startShowFlow(id);\n },\n onTouchEnd(event) {\n onTouchEnd(event);\n if (disabled) {\n return;\n }\n\n initiatedBy.current = null;\n startHideFlow();\n },\n onContextMenu(event) {\n onContextMenu(event);\n if (\n disabled ||\n initiatedBy.current !== \"touch\" ||\n isNotOverflown(event.currentTarget)\n ) {\n return;\n }\n\n event.preventDefault();\n const selection = window.getSelection();\n const node = selection?.anchorNode?.parentElement;\n if (node && event.currentTarget.contains(node)) {\n selection.empty();\n }\n },\n },\n };\n}\n"],"names":["cnb","useCallback","useEffect","useId","useRef","useHoverMode","useUserInteractionMode","useFixedPositioning","usePageInactive","parseCssLengthUnit","useTooltipHoverMode","DEFAULT_TOOLTIP_DENSE_SPACING","DEFAULT_TOOLTIP_MARGIN","DEFAULT_TOOLTIP_POSITION","DEFAULT_TOOLTIP_SPACING","DEFAULT_TOOLTIP_THRESHOLD","TOOLTIP_SPACING_VAR","useTooltipPosition","getAnchor","noop","useTooltip","options","id","propId","style","propStyle","disabled","describedBy","dense","hoverTimeout","leaveTimeout","vwMargin","vhMargin","spacing","denseSpacing","disableSwapping","disableAutoSpacing","position","determinedPosition","defaultPosition","threshold","onBlur","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","onContextMenu","onEnter","onEntering","onEntered","onExited","overflowOnly","disableFixedPositioning","fallbackId","tooltipId","animatedOnceRef","hoverTimeoutRef","leaveTimeoutRef","enableHoverMode","disableHoverMode","startDisableTimer","clearDisableTimer","visible","setVisible","startShowFlow","startHideFlow","clearVisibilityTimeout","updatePosition","mode","elementRef","tooltipRef","overflowRef","initiatedBy","ref","callbacks","nodeRef","fixedTo","anchor","getFixedPositionOptions","tooltipSpacing","tooltip","current","window","getComputedStyle","getPropertyValue","currentSpacing","value","horizontal","xMargin","undefined","yMargin","appearing","process","env","NODE_ENV","document","getElementById","hideTooltip","handleKeyDown","event","key","addEventListener","removeEventListener","refocusFrame","pageInactive","onDisabledCleanup","onChange","active","requestAnimationFrame","isNotOverflown","currentTarget","element","offsetWidth","scrollWidth","animatedOnce","tooltipProps","elementProps","preventDefault","selection","getSelection","node","anchorNode","parentElement","contains","empty"],"mappings":"AAAA;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAQEC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,MAAM,QACD,QAAQ;AAEf,SAEEC,YAAY,QACP,+BAA+B;AACtC,SAEEC,sBAAsB,QACjB,gDAAgD;AAEvD,SAIEC,mBAAmB,QACd,wCAAwC;AAE/C,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SAASC,kBAAkB,QAAQ,iCAAiC;AACpE,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SACEC,6BAA6B,EAC7BC,sBAAsB,EACtBC,wBAAwB,EACxBC,uBAAuB,EACvBC,yBAAyB,EACzBC,mBAAmB,QACd,iBAAiB;AACxB,SAEEC,kBAAkB,QACb,0BAA0B;AACjC,SAASC,SAAS,QAAQ,aAAa;AAEvC,MAAMC,OAAO;AACX,aAAa;AACf;AAiQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFC,GACD,OAAO,SAASC,WAIdC,UAA6C,CAAC,CAAC;IAE/C,MAAM,EACJC,IAAIC,MAAM,EACVC,OAAOC,SAAS,EAChBC,WAAW,KAAK,EAChBC,WAAW,EACXC,QAAQ,KAAK,EACbC,YAAY,EACZC,YAAY,EACZC,WAAWnB,sBAAsB,EACjCoB,WAAWpB,sBAAsB,EACjCqB,UAAUnB,uBAAuB,EACjCoB,eAAevB,6BAA6B,EAC5CwB,eAAe,EACfC,kBAAkB,EAClBC,UAAUC,kBAAkB,EAC5BC,kBAAkB1B,wBAAwB,EAC1C2B,YAAYzB,yBAAyB,EACrC0B,SAAStB,IAAI,EACbuB,UAAUvB,IAAI,EACdwB,eAAexB,IAAI,EACnByB,eA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N,aAAavB,OAAO,GAAG;oBACvB;gBACF;gBAEAT,YAAYS,OAAO,GAAG;gBACtBZ,WAAWY,OAAO,GAAGkB,MAAMW,aAAa;gBACxC3C,eAAegC,MAAMW,aAAa;gBAClC9C,cAAc3C;YAChB;YACAuB,cAAauD,KAAK;gBAChBvD,aAAauD;gBACb,IACE1E,YACA+C,YAAYS,OAAO,KAAK,QACxB4B,eAAeV,MAAMW,aAAa,GAClC;oBACA;gBACF;gBAEAtC,YAAYS,OAAO,GAAG;gBACtBZ,WAAWY,OAAO,GAAGkB,MAAMW,aAAa;gBACxC3C,eAAegC,MAAMW,aAAa;gBAClC9C,cAAc3C;YAChB;YACAwB,YAAWsD,KAAK;gBACdtD,WAAWsD;gBACX,IAAI1E,UAAU;oBACZ;gBACF;gBAEA+C,YAAYS,OAAO,GAAG;gBACtBhB;YACF;YACAnB,eAAcqD,KAAK;gBACjBrD,cAAcqD;gBACd,IACE1E,YACA+C,YAAYS,OAAO,KAAK,WACxB4B,eAAeV,MAAMW,aAAa,GAClC;oBACA;gBACF;gBAEAX,MAAMkB,cAAc;gBACpB,MAAMC,YAAYpC,OAAOqC,YAAY;gBACrC,MAAMC,OAAOF,WAAWG,YAAYC;gBACpC,IAAIF,QAAQrB,MAAMW,aAAa,CAACa,QAAQ,CAACH,OAAO;oBAC9CF,UAAUM,KAAK;gBACjB;YACF;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/CSSTransition.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport {\n type CSSTransitionComponentImplementation,\n type CSSTransitionHookOptions,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 4.0.0\n */\nexport interface CSSTransitionProps<E extends HTMLElement>\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/transition/CSSTransition.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport {\n type CSSTransitionComponentImplementation,\n type CSSTransitionHookOptions,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 4.0.0\n */\nexport interface CSSTransitionProps<E extends HTMLElement>\n extends\n CSSTransitionHookOptions<E>,\n CSSTransitionComponentImplementation<E> {}\n\n/**\n * **Client Component**\n *\n * This is a component implementation of the {@link useCSSTransition} hook that\n * implements the `temporary` behavior. Since this component uses the\n * `React.cloneElement` to inject the `ref` and `className` into the `children`,\n * it is recommended to use the hook instead.\n *\n * @example Simple Example\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button } from \"@react-md/core/button/Button\":\n * import { CSSTransition } from \"@react-md/core/transition/CSSTransition\":\n *\n * // pretend global styles:\n * //\n * // .opacity--enter {\n * // opacity: 0;\n * // transition: opacity .3s;\n * // }\n * //\n * // .opacity--enter-active {\n * // opacity: 1;\n * // }\n * //\n * // .opacity--exit {\n * // opacity: 1;\n * // }\n * //\n * // .opacity--exit-active {\n * // opacity: 0;\n * // transition: opacity .3s;\n * // }\n *\n * function Example(): ReactElement {\n * const [transitionIn, setTransitionIn] = useState(false);\n *\n * return (\n * <>\n * <Button onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * <CSSTransition\n * timeout={300}\n * className=\"opacity\"\n * temporary\n * transitionIn={transitionIn}\n * >\n * <div>\n * This is some content that will animate!\n * </div>\n * </CSSTransition>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/css-transition | CSSTransition Demos}\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 4.0.0\n */\nexport function CSSTransition<E extends HTMLElement>(\n props: CSSTransitionProps<E>\n): ReactElement | null {\n const { children, className, ...options } = props;\n const child = Children.only(children);\n const { elementProps, rendered } = useCSSTransition({\n ...options,\n className: cnb(child.props.className, className),\n });\n\n return <>{rendered && cloneElement(children, elementProps)}</>;\n}\n"],"names":["cnb","Children","cloneElement","useCSSTransition","CSSTransition","props","children","className","options","child","only","elementProps","rendered"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,EAAqBC,YAAY,QAAQ,QAAQ;AAMlE,SAASC,gBAAgB,QAAQ,wBAAwB;AAYzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DC,GACD,OAAO,SAASC,cACdC,KAA4B;IAE5B,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,SAAS,GAAGH;IAC5C,MAAMI,QAAQR,SAASS,IAAI,CAACJ;IAC5B,MAAM,EAAEK,YAAY,EAAEC,QAAQ,EAAE,GAAGT,iBAAiB;QAClD,GAAGK,OAAO;QACVD,WAAWP,IAAIS,MAAMJ,KAAK,CAACE,SAAS,EAAEA;IACxC;IAEA,qBAAO;kBAAGK,0BAAYV,aAAaI,UAAUK;;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/Collapse.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport {\n type CollapseElementProps,\n type CollapseTransitionHookOptions,\n useCollapseTransition,\n} from \"./useCollapseTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n *\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API.\n */\nexport interface CollapseProps<E extends HTMLElement
|
|
1
|
+
{"version":3,"sources":["../../src/transition/Collapse.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport {\n type CollapseElementProps,\n type CollapseTransitionHookOptions,\n useCollapseTransition,\n} from \"./useCollapseTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n *\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API.\n */\nexport interface CollapseProps<E extends HTMLElement> extends Omit<\n CollapseTransitionHookOptions<E>,\n \"transitionIn\"\n> {\n /**\n * The child element that should have a `ref` and the `style`/`className`\n * props cloned into using the `cloneElement` API. If the child is a custom\n * component, you **must** use `React.forwardRef` and pass the `ref` and the\n * other props for the transition to work correctly.\n */\n children: ReactElement<CollapseElementProps<E>>;\n\n /**\n * Boolean if the element should be collapsed.\n *\n * @see {@link CollapseTransitionHookOptions.transitionIn}\n */\n collapsed: boolean;\n}\n\n/**\n * **Client Component**\n *\n * This is a component implementation of the {@link useCollapseTransition} hook\n * that implements the `temporary` behavior. Since this component uses the\n * `React.cloneElement` to inject the `ref` and `className` into the `children`,\n * it is recommended to use the hook instead.\n *\n * @example Simple Example\n * ```tsx\n * function Example(): ReactElement {\n * const [collapsed, setCollapsed] = useState(true);\n *\n * return (\n * <>\n * <Button onClick={() => setCollapsed(!collapsed)}>\n * Toggle\n * </Button>\n * <Collapse collapsed={collapsed}>\n * <div>\n * Some content that should only be visible while not collapsed.\n * </div>\n * </Collapse>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/collapse | Collapse Demos}\n * @see {@link useCollapseTransition} for additional examples\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API.\n */\nexport function Collapse<E extends HTMLElement>(\n props: CollapseProps<E>\n): ReactElement {\n const { children, collapsed, className, ...options } = props;\n const child = Children.only(children);\n const { elementProps, rendered } = useCollapseTransition({\n ...options,\n className: cnb(child.props.className, className),\n transitionIn: !collapsed,\n });\n\n return <>{rendered && cloneElement(children, elementProps)}</>;\n}\n"],"names":["cnb","Children","cloneElement","useCollapseTransition","Collapse","props","children","collapsed","className","options","child","only","elementProps","rendered","transitionIn"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,EAAqBC,YAAY,QAAQ,QAAQ;AAElE,SAGEC,qBAAqB,QAChB,6BAA6B;AA6BpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GACD,OAAO,SAASC,SACdC,KAAuB;IAEvB,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGC,SAAS,GAAGJ;IACvD,MAAMK,QAAQT,SAASU,IAAI,CAACL;IAC5B,MAAM,EAAEM,YAAY,EAAEC,QAAQ,EAAE,GAAGV,sBAAsB;QACvD,GAAGM,OAAO;QACVD,WAAWR,IAAIU,MAAML,KAAK,CAACG,SAAS,EAAEA;QACtCM,cAAc,CAACP;IACjB;IAEA,qBAAO;kBAAGM,0BAAYX,aAAaI,UAAUM;;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/CrossFade.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport { type CSSTransitionComponentImplementation } from \"./types.js\";\nimport {\n type CrossFadeTransitionHookOptions,\n useCrossFadeTransition,\n} from \"./useCrossFadeTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API\n */\nexport interface CrossFadeProps<E extends HTMLElement>\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/transition/CrossFade.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport { type CSSTransitionComponentImplementation } from \"./types.js\";\nimport {\n type CrossFadeTransitionHookOptions,\n useCrossFadeTransition,\n} from \"./useCrossFadeTransition.js\";\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API\n */\nexport interface CrossFadeProps<E extends HTMLElement>\n extends\n CrossFadeTransitionHookOptions<E>,\n CSSTransitionComponentImplementation<E> {\n /**\n * Unlike the {@link useCrossFadeTransition}, the `appear` value is defaulted\n * to `true` so that the transition can occur when the `key` changes.\n *\n * @see {@link CrossFadeTransitionHookOptions.appear}\n * @defaultValue `true`\n */\n appear?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * This is a component implementation of the {@link useCrossFadeTransition} hook\n * that implements the `temporary` behavior. Since this component uses the\n * `React.cloneElement` to inject the `ref` and `className` into the `children`,\n * it is recommended to use the hook instead.\n *\n * @example Appear transitions with a React key\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { CrossFade } from \"@react-md/transition\";\n *\n * import Page1 from \"./Page1\";\n * import Page2 from \"./Page2\";\n * import Page3 from \"./Page3\";\n *\n * function Example(): ReactElement {\n * const [page, setPage] = useState(0):\n *\n * let content: ReactNode;\n * switch (page) {\n * case 0:\n * content = <Page1 />\n * break:\n * case 1:\n * content = <Page2 />\n * break;\n * case 2:\n * content = <Page3 />\n * break;\n * default:\n * content = null;\n * }\n *\n * return (\n * <>\n * <Button\n * onClick={() => {\n * setPage(prevPage => {\n * const nextPage = prevPage + 1;\n * if (nextPage > 2) {\n * return 0;\n * }\n *\n * return nextPage;\n * })\n * }}\n * >\n * Change Page\n * </Button>\n * <CrossFade key={page}>\n * <div>{content}</div>\n * </CrossFade>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/cross-fade | CrossFade Demos}\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 Updated for the new CSS Transition API and no longer supports\n * wrapping children in a `<div>`.\n */\nexport function CrossFade<E extends HTMLElement>(\n props: CrossFadeProps<E>\n): ReactElement {\n const { appear = true, children, className, ...options } = props;\n\n const child = Children.only(children);\n const { elementProps, rendered } = useCrossFadeTransition({\n ...options,\n appear,\n className: cnb(child.props.className, className),\n });\n\n return <>{rendered && cloneElement(children, elementProps)}</>;\n}\n"],"names":["cnb","Children","cloneElement","useCrossFadeTransition","CrossFade","props","appear","children","className","options","child","only","elementProps","rendered"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,EAAqBC,YAAY,QAAQ,QAAQ;AAGlE,SAEEC,sBAAsB,QACjB,8BAA8B;AAsBrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEC,GACD,OAAO,SAASC,UACdC,KAAwB;IAExB,MAAM,EAAEC,SAAS,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,SAAS,GAAGJ;IAE3D,MAAMK,QAAQT,SAASU,IAAI,CAACJ;IAC5B,MAAM,EAAEK,YAAY,EAAEC,QAAQ,EAAE,GAAGV,uBAAuB;QACxD,GAAGM,OAAO;QACVH;QACAE,WAAWR,IAAIU,MAAML,KAAK,CAACG,SAAS,EAAEA;IACxC;IAEA,qBAAO;kBAAGK,0BAAYX,aAAaK,UAAUK;;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/ScaleTransition.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport { type CSSTransitionComponentImplementation } from \"./types.js\";\nimport {\n type ScaleTransitionHookOptions,\n useScaleTransition,\n} from \"./useScaleTransition.js\";\n\n/**\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 The typeParam was added\n * @since 6.0.0 Removed portal props\n */\nexport interface ScaleTransitionProps<E extends HTMLElement>\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/transition/ScaleTransition.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { Children, type ReactElement, cloneElement } from \"react\";\n\nimport { type CSSTransitionComponentImplementation } from \"./types.js\";\nimport {\n type ScaleTransitionHookOptions,\n useScaleTransition,\n} from \"./useScaleTransition.js\";\n\n/**\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 The typeParam was added\n * @since 6.0.0 Removed portal props\n */\nexport interface ScaleTransitionProps<E extends HTMLElement>\n extends\n CSSTransitionComponentImplementation<E>,\n ScaleTransitionHookOptions<E> {}\n\n/**\n * **Client Component**\n *\n * A component implementation of the {@link useScaleTransition} hook that just\n * has some reasonable defaults and supports portalling the children. Since this\n * component uses the `React.cloneElement` to inject the `ref` and `className`\n * into the `children`, it is recommended to use the hook instead.\n *\n * @example Dropdown Menu Example\n * ```tsx\n * import { ReactElement, useRef, useState } from \"react\";\n * import { Button } from \"@react-md/core/button/Button\";\n * import { useFixedPositioning } from \"@react-md/core/positioning/useFixedPositioning\";\n * import { useScaleTransition } from \"@react-md/core/transition/useScaleTransition\";\n *\n * function Example(): ReactElement {\n * const buttonRef = useRef<HTMLButtonElement>(null);\n * const [transitionIn, setTransitionIn] = useState(false);\n * const { style, transitionOptions } = useFixedPositioning({\n * fixedTo: buttonRef,\n * });\n *\n * return (\n * <>\n * <Button ref={buttonRef} onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * <ScaleTransition\n * {...transitionOptions}\n * vertical\n * transitionIn={transitionIn}\n * >\n * <div style={style}>\n * Some content within a menu\n * </div>\n * </ScaleTransition>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/scale-transition | ScaleTransition Demos}\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @since 2.0.0\n * @since 4.0.0 The typeParam was added and the API was updated.\n * @since 6.0.0 Removed the built-in support for portalling.\n */\nexport function ScaleTransition<E extends HTMLElement>(\n props: ScaleTransitionProps<E>\n): ReactElement {\n const { children, className, ...options } = props;\n const child = Children.only(children);\n\n const { elementProps, rendered } = useScaleTransition({\n ...options,\n className: cnb(child.props.className, className),\n });\n\n return <>{rendered && cloneElement(children, elementProps)}</>;\n}\n"],"names":["cnb","Children","cloneElement","useScaleTransition","ScaleTransition","props","children","className","options","child","only","elementProps","rendered"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,QAAQ,EAAqBC,YAAY,QAAQ,QAAQ;AAGlE,SAEEC,kBAAkB,QACb,0BAA0B;AAcjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CC,GACD,OAAO,SAASC,gBACdC,KAA8B;IAE9B,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,SAAS,GAAGH;IAC5C,MAAMI,QAAQR,SAASS,IAAI,CAACJ;IAE5B,MAAM,EAAEK,YAAY,EAAEC,QAAQ,EAAE,GAAGT,mBAAmB;QACpD,GAAGK,OAAO;QACVD,WAAWP,IAAIS,MAAMJ,KAAK,CAACE,SAAS,EAAEA;IACxC;IAEA,qBAAO;kBAAGK,0BAAYV,aAAaI,UAAUK;;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/SkeletonPlaceholder.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport {\n type SkeletonPlaceholderOptions,\n useSkeletonPlaceholder,\n} from \"./useSkeletonPlaceholder.js\";\n\n/** @since 6.0.0 */\nexport interface SkeletonPlaceholderProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/transition/SkeletonPlaceholder.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport {\n type SkeletonPlaceholderOptions,\n useSkeletonPlaceholder,\n} from \"./useSkeletonPlaceholder.js\";\n\n/** @since 6.0.0 */\nexport interface SkeletonPlaceholderProps\n extends HTMLAttributes<HTMLDivElement>, SkeletonPlaceholderOptions {\n /**\n * @defaultValue `!!children`\n * @see {@link SkeletonPlaceholderOptions.disabled}\n */\n disabled?: boolean;\n\n /** @see {@link SkeletonPlaceholderOptions.disabled} for an example */\n children?: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"@react\";\n * import { SkeletonPlaceholder } from \"@react-md/core/transition/SkeletonPlaceholder\";\n *\n * interface ExampleProps {\n * loading: boolean;\n * children: ReactNode;\n * }\n *\n * export default function Example({ loading, children }: ExampleProps): ReactElement {\n * if (loading) {\n * return <SkeletonPlaceholder />;\n * }\n *\n * return <>{children}</>;\n * }\n * ```\n *\n * @example Pre-rendered Layout\n * ```tsx\n * import type { ReactElement } from \"@react\";\n * import { SkeletonPlaceholder } from \"@react-md/core/transition/SkeletonPlaceholder\";\n *\n * interface Data {\n * id: string;\n * name: string;\n * createdBy: string\n * createdOn: string;\n * modifiedBy: string;\n * modifiedOn: string;\n * }\n *\n * function ShowData({\n * id,\n * name,\n * createdBy,\n * createdOn,\n * modifiedBy,\n * modifiedOn,\n * }: Partial<Data>:: ReactElement {\n * const loading =\n * !name &&\n * !createdBy &&\n * !createdOn &&\n * !modifiedBy &&\n * !modifiedOn;\n *\n * return (\n * <Box grid gridName=\"custom-class-name\">\n * <SkeletonPlaceholder disabled={!loading}>\n * {id}\n * </SkeletonPlaceholder>\n * <SkeletonPlaceholder disabled={!loading}>\n * {name}\n * </SkeletonPlaceholder>\n * <SkeletonPlaceholder disabled={!loading}>\n * {createdOn}\n * </SkeletonPlaceholder>\n * <SkeletonPlaceholder disabled={!loading}>\n * {createdBy}\n * </SkeletonPlaceholder>\n * <SkeletonPlaceholder disabled={!loading}>\n * {modifiedOn}\n * </SkeletonPlaceholder>\n * <SkeletonPlaceholder disabled={!loading}>\n * {modifiedBy}\n * </SkeletonPlaceholder>\n * </Box>\n * );\n * }\n *\n * export function Example(): ReactElement {\n * const { data } = useLoadSomeDataQuery();\n *\n * const items = useMemo(() => {\n * // if the data has been fetched, just return the data\n * if (data) {\n * return data;\n * }\n *\n * // if the data does not exist, set up a skeleton of your layout by\n * // rendering a random number of items.\n * //\n * // NOTE: This is memoized so you don't create a random length each\n * // render\n * const length = randomInt({ min: 3, max: 10 })\n * return Array.from({ length }, (_, i) => ({ id: `placeholder-${i}` }));\n * }, [data])\n *\n * return (\n * <List>\n * {items.map((item) => <ShowData {...item} />)}\n * </List>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/skeleton-placeholder | SkeletonPlaceholder Demos}\n * @since 6.0.0\n */\nexport const SkeletonPlaceholder = forwardRef<\n HTMLDivElement,\n SkeletonPlaceholderProps\n>(function SkeletonPlaceholder(props, ref): ReactElement {\n const {\n style,\n className,\n height,\n width,\n children,\n disabled = !!children,\n delay,\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n ...remaining\n } = props;\n const skeleton = useSkeletonPlaceholder({\n disabled,\n style,\n className,\n height,\n width,\n delay,\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n });\n\n return (\n <div {...remaining} ref={ref} {...skeleton}>\n {children}\n </div>\n );\n});\n"],"names":["forwardRef","useSkeletonPlaceholder","SkeletonPlaceholder","props","ref","style","className","height","width","children","disabled","delay","minDelay","maxDelay","minPercentage","maxPercentage","remaining","skeleton","div"],"mappings":"AAAA;;AAEA,SAIEA,UAAU,QACL,QAAQ;AAEf,SAEEC,sBAAsB,QACjB,8BAA8B;AAerC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuGC,GACD,OAAO,MAAMC,oCAAsBF,WAGjC,SAASE,oBAAoBC,KAAK,EAAEC,GAAG;IACvC,MAAM,EACJC,KAAK,EACLC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,WAAW,CAAC,CAACD,QAAQ,EACrBE,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,aAAa,EACbC,aAAa,EACb,GAAGC,WACJ,GAAGb;IACJ,MAAMc,WAAWhB,uBAAuB;QACtCS;QACAL;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,qBACE,KAACG;QAAK,GAAGF,SAAS;QAAEZ,KAAKA;QAAM,GAAGa,QAAQ;kBACvCR;;AAGP,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/Slide.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport {\n type CSSTransitionComponentProps,\n type TransitionActions,\n type TransitionTimeout,\n} from \"./types.js\";\nimport {\n DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n useSlideTransition,\n} from \"./useSlideTransition.js\";\n\n// NOTE: Tis is in both `useSlideTransition` and `Slide` since there are no\n// reusable types between these two files.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-slide-duration\"?: string | number;\n }\n}\n\n/** @since 6.0.0 */\nexport interface SlideProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/transition/Slide.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, type ReactNode, forwardRef } from \"react\";\n\nimport {\n type CSSTransitionComponentProps,\n type TransitionActions,\n type TransitionTimeout,\n} from \"./types.js\";\nimport {\n DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n useSlideTransition,\n} from \"./useSlideTransition.js\";\n\n// NOTE: Tis is in both `useSlideTransition` and `Slide` since there are no\n// reusable types between these two files.\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-slide-duration\"?: string | number;\n }\n}\n\n/** @since 6.0.0 */\nexport interface SlideProps\n extends\n HTMLAttributes<HTMLDivElement>,\n CSSTransitionComponentProps,\n TransitionActions {\n /**\n * Set this to `true` to animate this slide into view within a\n * `SlideContainer`. When this switches from `true` to `false`, it will\n * animate out.\n */\n active: boolean;\n\n /** @defaultValue {@link DEFAULT_SLIDE_TRANSITION_DURATION} */\n timeout?: TransitionTimeout;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * A reasonable default for handling a slide transition using\n * {@link useSlideTransition}.\n *\n * @see {@link https://react-md.dev/components/slide | Slide Demos}\n * @see {@link SlideContainer} for example usage.\n * @since 6.0.0\n */\nexport const Slide = forwardRef<HTMLDivElement, SlideProps>(\n function Slide(props, nodeRef) {\n const {\n active,\n appear,\n enter,\n exit,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n className,\n children,\n timeout = DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n temporary = false,\n exitedHidden = true,\n ...remaining\n } = props;\n\n const { rendered, elementProps } = useSlideTransition({\n nodeRef,\n appear,\n enter,\n exit,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n className,\n timeout,\n temporary,\n transitionIn: active,\n exitedHidden,\n });\n\n if (!rendered) {\n return null;\n }\n\n return (\n <div {...remaining} {...elementProps}>\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","DEFAULT_SLIDE_TRANSITION_TIMEOUT","useSlideTransition","Slide","props","nodeRef","active","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","className","children","timeout","temporary","exitedHidden","remaining","rendered","elementProps","transitionIn","div"],"mappings":"AAAA;;AAEA,SAA8CA,UAAU,QAAQ,QAAQ;AAOxE,SACEC,gCAAgC,EAChCC,kBAAkB,QACb,0BAA0B;AA4BjC;;;;;;;;;CASC,GACD,OAAO,MAAMC,sBAAQH,WACnB,SAASG,MAAMC,KAAK,EAAEC,OAAO;IAC3B,MAAM,EACJC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,OAAO,EACPC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,UAAUjB,gCAAgC,EAC1CkB,YAAY,KAAK,EACjBC,eAAe,IAAI,EACnB,GAAGC,WACJ,GAAGjB;IAEJ,MAAM,EAAEkB,QAAQ,EAAEC,YAAY,EAAE,GAAGrB,mBAAmB;QACpDG;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAE;QACAC;QACAK,cAAclB;QACdc;IACF;IAEA,IAAI,CAACE,UAAU;QACb,OAAO;IACT;IAEA,qBACE,KAACG;QAAK,GAAGJ,SAAS;QAAG,GAAGE,YAAY;kBACjCN;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/SlideContainer.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-slide-container\");\n\n/**\n * @example Direction \"forward\"\n * ```\n * -------------\n * | |\n * | Slide 1 | Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 | Slide 2 |\n * | |\n * -------------\n * ```\n *\n * @example Direction \"backward\"\n * ```\n * -------------\n * | |\n * Slide 1 | Slide 2 |\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * | Slide 1 | Slide 2\n * | |\n * -------------\n * ```\n *\n * @since 6.0.0\n */\nexport type SlideDirection = \"backward\" | \"forward\";\n\n/** @since 6.0.0 */\nexport interface SlideContainerClassNameOptions {\n className?: string;\n\n /** @see {@link SlideDirection} */\n direction: SlideDirection;\n\n vertical?: boolean;\n}\n\n/**\n * @see {@link useSlideTransition} for an example\n * @since 6.0.0\n */\nexport function slideContainer(\n options: SlideContainerClassNameOptions\n): string {\n const { className, direction, vertical } = options;\n\n return cnb(styles({ [direction]: true, vertical }), className);\n}\n\n/** @since 6.0.0 */\nexport interface SlideContainerProps\n extends HTMLAttributes<HTMLDivElement
|
|
1
|
+
{"version":3,"sources":["../../src/transition/SlideContainer.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-slide-container\");\n\n/**\n * @example Direction \"forward\"\n * ```\n * -------------\n * | |\n * | Slide 1 | Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 | Slide 2 |\n * | |\n * -------------\n * ```\n *\n * @example Direction \"backward\"\n * ```\n * -------------\n * | |\n * Slide 1 | Slide 2 |\n * | |\n * -------------\n * -------------\n * | |\n * Slide 1 Slide 2\n * | |\n * -------------\n * -------------\n * | |\n * | Slide 1 | Slide 2\n * | |\n * -------------\n * ```\n *\n * @since 6.0.0\n */\nexport type SlideDirection = \"backward\" | \"forward\";\n\n/** @since 6.0.0 */\nexport interface SlideContainerClassNameOptions {\n className?: string;\n\n /** @see {@link SlideDirection} */\n direction: SlideDirection;\n\n vertical?: boolean;\n}\n\n/**\n * @see {@link useSlideTransition} for an example\n * @since 6.0.0\n */\nexport function slideContainer(\n options: SlideContainerClassNameOptions\n): string {\n const { className, direction, vertical } = options;\n\n return cnb(styles({ [direction]: true, vertical }), className);\n}\n\n/** @since 6.0.0 */\nexport interface SlideContainerProps\n extends HTMLAttributes<HTMLDivElement>, SlideContainerClassNameOptions {}\n\n/**\n * The `SlideContainer` is used to enable a slide transition when child `Slide`\n * components change.\n *\n * @example Simple Example\n * ```tsx\n * import { Slide } from \"@react-md/core/transition/Slide\";\n * import { SlideContainer } from \"@react-md/core/transition/SlideContainer\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useState } from \"react\";\n *\n * interface State {\n * direction: SlideDirection;\n * activeIndex: number;\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * direction: \"forward\",\n * activeIndex: 0,\n * });\n * const { direction, activeIndex } = state;\n *\n * // when changing a slide, `direction` should be set to \"forward\" if the\n * // previous `activeIndex` is less than the next index\n * //\n * // i.e.\n * // setState((prevState) => ({\n * // direction: prevState.activeIndex < index ? \"forward\" : \"backward\",\n * // activeIndex: index,\n * // }))\n *\n * return (\n * <SlideContainer direction={direction}>\n * <Slide active={activeIndex === 0}>\n * Slide 1\n * </Slide>\n * <Slide active={activeIndex === 1}>\n * Slide 2\n * </Slide>\n * <Slide active={activeIndex === 2}>\n * Slide 3\n * </Slide>\n * </SlideContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/slide | Slide Demos}\n * @since 6.0.0\n */\nexport const SlideContainer = forwardRef<HTMLDivElement, SlideContainerProps>(\n function SlideContainer(props, ref) {\n const { className, direction, vertical, children, ...remaining } = props;\n\n return (\n <div\n {...remaining}\n ref={ref}\n className={slideContainer({ className, direction, vertical })}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["cnb","forwardRef","bem","styles","slideContainer","options","className","direction","vertical","SlideContainer","props","ref","children","remaining","div"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAA8BC,UAAU,QAAQ,QAAQ;AAExD,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAuDnB;;;CAGC,GACD,OAAO,SAASE,eACdC,OAAuC;IAEvC,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGH;IAE3C,OAAOL,IAAIG,OAAO;QAAE,CAACI,UAAU,EAAE;QAAMC;IAAS,IAAIF;AACtD;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDC,GACD,OAAO,MAAMG,+BAAiBR,WAC5B,SAASQ,eAAeC,KAAK,EAAEC,GAAG;IAChC,MAAM,EAAEL,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAEI,QAAQ,EAAE,GAAGC,WAAW,GAAGH;IAEnE,qBACE,KAACI;QACE,GAAGD,SAAS;QACbF,KAAKA;QACLL,WAAWF,eAAe;YAAEE;YAAWC;YAAWC;QAAS;kBAE1DI;;AAGP,GACA"}
|