@react-md/core 1.0.0-next.11 → 1.0.0-next.12
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/.turbo/turbo-build.log +22 -22
- package/.turbo/turbo-lint.log +12 -0
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/CoreProviders.js.map +1 -1
- package/dist/NoSsr.js.map +1 -1
- package/dist/RootHtml.js.map +1 -1
- package/dist/SsrProvider.js.map +1 -1
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.d.ts +2 -1
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.js.map +1 -1
- package/dist/box/Box.js.map +1 -1
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ButtonUnstyled.js.map +1 -1
- package/dist/button/FloatingActionButton.js.map +1 -1
- package/dist/button/TooltippedButton.js.map +1 -1
- package/dist/button/buttonStyles.js.map +1 -1
- package/dist/button/buttonUnstyledStyles.js.map +1 -1
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/CardFooter.js.map +1 -1
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/card/CardSubtitle.js.map +1 -1
- package/dist/card/CardTitle.js.map +1 -1
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/cssUtils.js.map +1 -1
- package/dist/delegateEvent.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/dialog/DialogHeader.js.map +1 -1
- package/dist/dialog/DialogTitle.d.ts +2 -1
- package/dist/dialog/DialogTitle.js.map +1 -1
- package/dist/dialog/FixedDialog.js.map +1 -1
- package/dist/dialog/NestedDialogProvider.js.map +1 -1
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.d.ts +2 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/focus/utils.js.map +1 -1
- package/dist/form/Checkbox.js.map +1 -1
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/FileInput.js.map +1 -1
- package/dist/form/Form.js.map +1 -1
- package/dist/form/FormMessage.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/InputToggleIcon.js.map +1 -1
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/MenuItemCheckbox.js.map +1 -1
- package/dist/form/MenuItemFileInput.js.map +1 -1
- package/dist/form/MenuItemInputToggle.js.map +1 -1
- package/dist/form/MenuItemRadio.js.map +1 -1
- package/dist/form/MenuItemSwitch.js.map +1 -1
- package/dist/form/MenuItemTextField.js.map +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Option.js.map +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Radio.js.map +1 -1
- package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
- package/dist/form/Select.js.map +1 -1
- package/dist/form/SelectedOption.js.map +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderMark.js.map +1 -1
- package/dist/form/SliderMarkLabel.d.ts +2 -1
- package/dist/form/SliderMarkLabel.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/SliderValueTooltip.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldAddon.js.map +1 -1
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/fileUtils.js.map +1 -1
- package/dist/form/formConfig.js.map +1 -1
- package/dist/form/formMessageStyles.js.map +1 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/menuItemInputToggleStyles.js.map +1 -1
- package/dist/form/nativeSelectStyles.js.map +1 -1
- package/dist/form/optionStyles.js.map +1 -1
- package/dist/form/passwordStyles.js.map +1 -1
- package/dist/form/selectStyles.js.map +1 -1
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/switchStyles.js.map +1 -1
- package/dist/form/textAreaStyles.js.map +1 -1
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/textFieldStyles.js.map +1 -1
- 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/useEditableCombobox.js.map +1 -1
- package/dist/form/useFileUpload.js.map +1 -1
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useListboxProvider.js.map +1 -1
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRadioGroup.js.map +1 -1
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useResizingTextArea.js.map +1 -1
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/form/utils.js.map +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/hoverMode/useHoverModeProvider.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/TextIconSpacing.js.map +1 -1
- package/dist/icon/iconConfig.js.map +1 -1
- package/dist/icon/material.js.map +1 -1
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/icon/styles.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction/Ripple.js.map +1 -1
- package/dist/interaction/RippleContainer.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/config.js.map +1 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/useElementInteraction.js.map +1 -1
- package/dist/interaction/useHigherContrastChildren.js.map +1 -1
- package/dist/interaction/utils.js.map +1 -1
- 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/layoutNavStyles.js.map +1 -1
- package/dist/layout/layoutWindowSplitterStyles.js.map +1 -1
- package/dist/layout/mainStyles.js.map +1 -1
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useMainTabIndex.js.map +1 -1
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/layout/useTemporaryLayout.js.map +1 -1
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/link/styles.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/ListItemChildren.js.map +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListItemText.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.js.map +1 -1
- package/dist/media-queries/appSize.js.map +1 -1
- package/dist/media-queries/useMediaQuery.js.map +1 -1
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuButton.js.map +1 -1
- package/dist/menu/MenuConfigurationProvider.js.map +1 -1
- package/dist/menu/MenuItem.js.map +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemCircularProgress.js.map +1 -1
- package/dist/menu/MenuItemGroup.js.map +1 -1
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuSheet.js.map +1 -1
- package/dist/menu/MenuVisibilityProvider.js.map +1 -1
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/MenuWidgetKeyboardProvider.js.map +1 -1
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/menu/useMenuBarProvider.js.map +1 -1
- package/dist/menu/utils.js.map +1 -1
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/findMatchIndex.js.map +1 -1
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/movement/utils.js.map +1 -1
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/overlayStyles.js.map +1 -1
- package/dist/portal/Portal.js.map +1 -1
- package/dist/portal/PortalContainerProvider.js.map +1 -1
- package/dist/positioning/constants.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/getFixedPosition.js.map +1 -1
- package/dist/positioning/types.js.map +1 -1
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/positioning/utils.js.map +1 -1
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/getProgressA11y.js.map +1 -1
- package/dist/progress/types.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemContainer.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/responsive-item/styles.js.map +1 -1
- package/dist/scroll/ScrollLock.js.map +1 -1
- package/dist/scroll/getScrollbarWidth.js.map +1 -1
- package/dist/scroll/useScrollLock.js.map +1 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/toSearchQuery.js.map +1 -1
- package/dist/searching/types.js.map +1 -1
- package/dist/searching/useFuzzyMatch.js.map +1 -1
- package/dist/searching/utils.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/segmentedButtonContainerStyles.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
- package/dist/snackbar/Snackbar.js.map +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastActionButton.js.map +1 -1
- package/dist/snackbar/ToastCloseButton.js.map +1 -1
- package/dist/snackbar/ToastContent.js.map +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/ToastManagerProvider.js.map +1 -1
- package/dist/snackbar/snackbarStyles.js.map +1 -1
- package/dist/snackbar/toastContentStyles.js.map +1 -1
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/snackbar/useCurrentToastActions.js.map +1 -1
- package/dist/suspense/CircularProgressSuspense.js.map +1 -1
- package/dist/suspense/NullSuspense.js.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCellContent.js.map +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableConfigurationProvider.js.map +1 -1
- package/dist/table/TableContainer.js.map +1 -1
- package/dist/table/TableContainerProvider.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/tableCellStyles.js.map +1 -1
- package/dist/table/tableContainerStyles.js.map +1 -1
- package/dist/table/tableFooterStyles.js.map +1 -1
- package/dist/table/tableHeaderStyles.js.map +1 -1
- package/dist/table/tableRowStyles.js.map +1 -1
- package/dist/table/tableStyles.js.map +1 -1
- package/dist/table/types.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/tabIndicatorStyles.js.map +1 -1
- package/dist/tabs/tabListScrollButtonStyles.js.map +1 -1
- package/dist/tabs/tabListStyles.js.map +1 -1
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/tabs/useTabs.js.map +1 -1
- package/dist/tabs/utils.js.map +1 -1
- package/dist/test-utils/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/ResizeObserver.js.map +1 -1
- package/dist/test-utils/data-testid.js.map +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/jest-setup.js.map +1 -1
- package/dist/test-utils/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
- package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
- package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
- package/dist/test-utils/polyfills/index.js.map +1 -1
- package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
- package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
- package/dist/test-utils/render.js.map +1 -1
- package/dist/test-utils/timers.js.map +1 -1
- package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/colors.js.map +1 -1
- package/dist/theme/cssVars.js.map +1 -1
- package/dist/theme/types.js.map +1 -1
- package/dist/theme/useCSSVariables.js.map +1 -1
- package/dist/theme/useColorScheme.js.map +1 -1
- package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
- package/dist/theme/useColorSchemeProvider.js.map +1 -1
- package/dist/theme/usePrefersColorScheme.js.map +1 -1
- package/dist/theme/utils.js.map +1 -1
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/constants.js.map +1 -1
- package/dist/tooltip/tooltipStyles.js.map +1 -1
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/tooltip/useTooltipPosition.js.map +1 -1
- package/dist/tooltip/utils.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/collapseStyles.js.map +1 -1
- package/dist/transition/config.js.map +1 -1
- package/dist/transition/maxWidthTransition.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCSSTransition.js.map +1 -1
- package/dist/transition/useCarousel.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/transition/useSlideTransition.js.map +1 -1
- package/dist/transition/useTransition.js.map +1 -1
- package/dist/transition/utils.js.map +1 -1
- package/dist/tree/DefaultTreeItemRenderer.js.map +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeGroup.js.map +1 -1
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/TreeItemExpander.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/useTree.js.map +1 -1
- package/dist/tree/useTreeExpansion.js.map +1 -1
- package/dist/tree/useTreeItems.js.map +1 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/tree/useTreeSelection.js.map +1 -1
- package/dist/tree/utils.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +1 -40
- package/dist/typography/TextContainer.js +1 -30
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.d.ts +1 -112
- package/dist/typography/Typography.js +1 -89
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/WritingDirectionProvider.js.map +1 -1
- package/dist/typography/textContainerStyles.d.ts +40 -0
- package/dist/typography/textContainerStyles.js +32 -0
- package/dist/typography/textContainerStyles.js.map +1 -0
- package/dist/typography/typographyStyles.d.ts +112 -0
- package/dist/typography/typographyStyles.js +91 -0
- package/dist/typography/typographyStyles.js.map +1 -0
- package/dist/useAsyncAction.js.map +1 -1
- package/dist/useDebouncedFunction.js.map +1 -1
- package/dist/useDropzone.js.map +1 -1
- package/dist/useElementSize.js.map +1 -1
- package/dist/useEnsuredId.js.map +1 -1
- package/dist/useEnsuredRef.js.map +1 -1
- package/dist/useEnsuredState.js.map +1 -1
- package/dist/useHtmlClassName.js.map +1 -1
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/useLocalStorage.js.map +1 -1
- package/dist/useOrientation.js.map +1 -1
- package/dist/usePageInactive.js.map +1 -1
- package/dist/useResizeListener.js.map +1 -1
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/useThrottledFunction.js.map +1 -1
- package/dist/useToggle.js.map +1 -1
- package/dist/useUnmounted.js.map +1 -1
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/RenderRecursively.js.map +1 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/dist/utils/applyRef.js.map +1 -1
- package/dist/utils/bem.js.map +1 -1
- package/dist/utils/getClientPosition.js.map +1 -1
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeDefaultValue.js.map +1 -1
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/identity.js.map +1 -1
- package/dist/utils/isElementVisible.js.map +1 -1
- package/dist/utils/loop.js.map +1 -1
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/parseCssLengthUnit.js.map +1 -1
- package/dist/utils/randomInt.js.map +1 -1
- package/dist/utils/wait.js.map +1 -1
- package/dist/utils/withinRange.js.map +1 -1
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +11 -350
- package/src/app-bar/AppBarTitle.tsx +2 -5
- package/src/dialog/DialogTitle.tsx +1 -1
- package/src/expansion-panel/ExpansionPanelHeader.tsx +3 -6
- package/src/form/SliderMarkLabel.tsx +1 -1
- package/src/index.ts +3 -1
- package/src/typography/TextContainer.tsx +4 -53
- package/src/typography/Typography.tsx +5 -145
- package/src/typography/__tests__/TextContainer.tsx +2 -1
- package/src/typography/__tests__/Typography.tsx +2 -1
- package/src/typography/textContainerStyles.ts +53 -0
- package/src/typography/typographyStyles.ts +145 -0
- package/tsconfig.types.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useCSSTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport type {\n CSSTransitionElementProps,\n CSSTransitionHookOptions,\n CSSTransitionHookReturnValue,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TransitionHookOptions,\n} from \"./types.js\";\nimport { useTransition } from \"./useTransition.js\";\nimport { getTransitionClassNames } from \"./utils.js\";\n\n/**\n * This hook is used to create CSS transitions for different components whenever\n * a {@link TransitionHookOptions.transitionIn} flag is changed.\n *\n * @example\n * Simple Transition\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCSSTransition } from \"@react-md/core\";\n *\n * // Pretend styles\n * // .enter {\n * // opacity: 0.5;\n * // transition: opacity .15s;\n * // }\n * //\n * // .enter--active {\n * // opacity: 1;\n * // }\n * //\n * // .exit {\n * // opacity: 1;\n * // transition: opacity .15s;\n * // }\n * //\n * // .exit--active {\n * // opacity: 0.5;\n * // }\n *\n * function Example(): ReactElement {\n * const [transitionIn, setTransitionIn] = useState(false);\n * const { elementProps } = useCSSTransition({\n * timeout: 150,\n * classNames: {\n * enter: \"enter\",\n * enterActive: \"enter--active\",\n * exit: \"exit\",\n * exitActive: \"exit--active\",\n * },\n * transitionIn,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * <Typography {...elementProps}>\n * Some Opacity Changing Text\n * </Typography>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * Visibility Transition\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCSSTransition } from \"@react-md/core\";\n *\n * // Pretend styles\n * // .enter {\n * // opacity: 0;\n * // transition: opacity .2s;\n * // }\n * //\n * // .enter--active {\n * // opacity: 1;\n * // }\n * //\n * // .exit {\n * // opacity: 1;\n * // transition: opacity .15s;\n * // }\n * //\n * // .exit--active {\n * // opacity: 0;\n * // }\n *\n * function Example(): ReactElement {\n * const [transitionIn, setTransitionIn] = useState(false);\n * const { elementProps, rendered } = useCSSTransition({\n * timeout: {\n * enter: 200,\n * exit: 150,\n * },\n * classNames: {\n * enter: \"enter\",\n * enterActive: \"enter--active\",\n * exit: \"exit\",\n * exitActive: \"exit--active\",\n * },\n * transitionIn,\n * temporary: true,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <Typography {...elementProps}>\n * Some Opacity Changing Text\n * </Typography>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @example\n * Mount Transition\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { useCSSTransition } from \"@react-md/transition\";\n *\n * // Pretend styles\n * // .opacity {\n * // opacity: 0;\n * // transition: opacity .3s;\n * // }\n * //\n * // .opacity--active {\n * // opacity: 1;\n * // }\n * //\n *\n * function Example(): ReactElement {\n * const { elementProps } = useCSSTransition({\n * appear: true,\n * transitionIn: true,\n * timeout: 300,\n * classNames: \"opacity\",\n * })\n *\n * return <div {...elementProps}>Some Content!</div>;\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCSSTransition<E extends HTMLElement>(\n options: CSSTransitionHookOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n className,\n classNames,\n appear = false,\n enter = true,\n exit = true,\n timeout,\n temporary = false,\n exitedHidden = false,\n ...transitionOptions\n } = options;\n\n const { ref, stage, rendered, appearing, transitionTo, disablePortal } =\n useTransition({\n ...transitionOptions,\n appear,\n enter,\n exit,\n timeout,\n reflow: true,\n temporary,\n });\n const isEntering = stage === \"entering\";\n const isEnter = isEntering || stage === \"enter\";\n const isEntered = stage === \"entered\";\n const isExiting = stage === \"exiting\";\n const isExit = isExiting || stage === \"exit\";\n const isExited = stage === \"exited\";\n const transitionClassNames = getTransitionClassNames({\n timeout,\n appear,\n enter,\n exit,\n classNames,\n });\n\n const elementProps: CSSTransitionElementProps<E> = {\n ref,\n className:\n cnb(\n // always apply the provided className first since it makes snapshot\n // tests easier to parse if dynamic classes come afterwards\n className,\n !temporary && exitedHidden && stage === \"exited\" && DISPLAY_NONE_CLASS,\n appearing && isEnter && transitionClassNames.appear,\n appearing && isEntering && transitionClassNames.appearActive,\n appearing && isEntered && transitionClassNames.appearDone,\n !appearing && isEnter && transitionClassNames.enter,\n !appearing && isEntering && transitionClassNames.enterActive,\n !appearing && isEntered && transitionClassNames.enterDone,\n isExit && transitionClassNames.exit,\n isExiting && transitionClassNames.exitActive,\n isExited && transitionClassNames.exitDone\n ) || undefined,\n };\n\n return {\n ...elementProps,\n stage,\n rendered,\n appearing,\n elementProps,\n transitionTo,\n disablePortal,\n };\n}\n"],"names":["cnb","DISPLAY_NONE_CLASS","useTransition","getTransitionClassNames","useCSSTransition","options","className","classNames","appear","enter","exit","timeout","temporary","exitedHidden","transitionOptions","ref","stage","rendered","appearing","transitionTo","disablePortal","reflow","isEntering","isEnter","isEntered","isExiting","isExit","isExited","transitionClassNames","elementProps","appearActive","appearDone","enterActive","enterDone","exitActive","exitDone","undefined"],"mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,kBAAkB,QAAQ,+BAA+B;AAQlE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,uBAAuB,QAAQ,aAAa;AAErD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UAAU,EAC5CP,YAAYC,qBAAqBO,QAAQ,KACtCC;IACT;IAEA,OAAO;QACL,GAAGP,YAAY;QACfb;QACAC;QACAC;QACAW;QACAV;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useCSSTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport type {\n CSSTransitionElementProps,\n CSSTransitionHookOptions,\n CSSTransitionHookReturnValue,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TransitionHookOptions,\n} from \"./types.js\";\nimport { useTransition } from \"./useTransition.js\";\nimport { getTransitionClassNames } from \"./utils.js\";\n\n/**\n * This hook is used to create CSS transitions for different components whenever\n * a {@link TransitionHookOptions.transitionIn} flag is changed.\n *\n * @example\n * Simple Transition\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCSSTransition } from \"@react-md/core\";\n *\n * // Pretend styles\n * // .enter {\n * // opacity: 0.5;\n * // transition: opacity .15s;\n * // }\n * //\n * // .enter--active {\n * // opacity: 1;\n * // }\n * //\n * // .exit {\n * // opacity: 1;\n * // transition: opacity .15s;\n * // }\n * //\n * // .exit--active {\n * // opacity: 0.5;\n * // }\n *\n * function Example(): ReactElement {\n * const [transitionIn, setTransitionIn] = useState(false);\n * const { elementProps } = useCSSTransition({\n * timeout: 150,\n * classNames: {\n * enter: \"enter\",\n * enterActive: \"enter--active\",\n * exit: \"exit\",\n * exitActive: \"exit--active\",\n * },\n * transitionIn,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * <Typography {...elementProps}>\n * Some Opacity Changing Text\n * </Typography>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * Visibility Transition\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCSSTransition } from \"@react-md/core\";\n *\n * // Pretend styles\n * // .enter {\n * // opacity: 0;\n * // transition: opacity .2s;\n * // }\n * //\n * // .enter--active {\n * // opacity: 1;\n * // }\n * //\n * // .exit {\n * // opacity: 1;\n * // transition: opacity .15s;\n * // }\n * //\n * // .exit--active {\n * // opacity: 0;\n * // }\n *\n * function Example(): ReactElement {\n * const [transitionIn, setTransitionIn] = useState(false);\n * const { elementProps, rendered } = useCSSTransition({\n * timeout: {\n * enter: 200,\n * exit: 150,\n * },\n * classNames: {\n * enter: \"enter\",\n * enterActive: \"enter--active\",\n * exit: \"exit\",\n * exitActive: \"exit--active\",\n * },\n * transitionIn,\n * temporary: true,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <Typography {...elementProps}>\n * Some Opacity Changing Text\n * </Typography>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @example\n * Mount Transition\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { useCSSTransition } from \"@react-md/transition\";\n *\n * // Pretend styles\n * // .opacity {\n * // opacity: 0;\n * // transition: opacity .3s;\n * // }\n * //\n * // .opacity--active {\n * // opacity: 1;\n * // }\n * //\n *\n * function Example(): ReactElement {\n * const { elementProps } = useCSSTransition({\n * appear: true,\n * transitionIn: true,\n * timeout: 300,\n * classNames: \"opacity\",\n * })\n *\n * return <div {...elementProps}>Some Content!</div>;\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCSSTransition<E extends HTMLElement>(\n options: CSSTransitionHookOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n className,\n classNames,\n appear = false,\n enter = true,\n exit = true,\n timeout,\n temporary = false,\n exitedHidden = false,\n ...transitionOptions\n } = options;\n\n const { ref, stage, rendered, appearing, transitionTo, disablePortal } =\n useTransition({\n ...transitionOptions,\n appear,\n enter,\n exit,\n timeout,\n reflow: true,\n temporary,\n });\n const isEntering = stage === \"entering\";\n const isEnter = isEntering || stage === \"enter\";\n const isEntered = stage === \"entered\";\n const isExiting = stage === \"exiting\";\n const isExit = isExiting || stage === \"exit\";\n const isExited = stage === \"exited\";\n const transitionClassNames = getTransitionClassNames({\n timeout,\n appear,\n enter,\n exit,\n classNames,\n });\n\n const elementProps: CSSTransitionElementProps<E> = {\n ref,\n className:\n cnb(\n // always apply the provided className first since it makes snapshot\n // tests easier to parse if dynamic classes come afterwards\n className,\n !temporary && exitedHidden && stage === \"exited\" && DISPLAY_NONE_CLASS,\n appearing && isEnter && transitionClassNames.appear,\n appearing && isEntering && transitionClassNames.appearActive,\n appearing && isEntered && transitionClassNames.appearDone,\n !appearing && isEnter && transitionClassNames.enter,\n !appearing && isEntering && transitionClassNames.enterActive,\n !appearing && isEntered && transitionClassNames.enterDone,\n isExit && transitionClassNames.exit,\n isExiting && transitionClassNames.exitActive,\n isExited && transitionClassNames.exitDone\n ) || undefined,\n };\n\n return {\n ...elementProps,\n stage,\n rendered,\n appearing,\n elementProps,\n transitionTo,\n disablePortal,\n };\n}\n"],"names":["cnb","DISPLAY_NONE_CLASS","useTransition","getTransitionClassNames","useCSSTransition","options","className","classNames","appear","enter","exit","timeout","temporary","exitedHidden","transitionOptions","ref","stage","rendered","appearing","transitionTo","disablePortal","reflow","isEntering","isEnter","isEntered","isExiting","isExit","isExited","transitionClassNames","elementProps","appearActive","appearDone","enterActive","enterDone","exitActive","exitDone","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,kBAAkB,QAAQ,+BAA+B;AAQlE,SAASC,aAAa,QAAQ,qBAAqB;AACnD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lB,IAAI,EACnCe,aAAaG,qBAAqBM,UAAU,EAC5CP,YAAYC,qBAAqBO,QAAQ,KACtCC;IACT;IAEA,OAAO;QACL,GAAGP,YAAY;QACfb;QACAC;QACAC;QACAW;QACAV;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useCarousel.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport type { UseStateSetter } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { loop } from \"../utils/loop.js\";\nimport type { SlideDirection } from \"./SlideContainer.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselSlideState {\n direction: SlideDirection;\n activeIndex: number;\n}\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselState extends CarouselSlideState {\n paused: boolean;\n}\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselImplementation extends CarouselState {\n /**\n * Increments the carousel slide active index by 1 ensuring it does not\n * advance past the {@link CarouselOptions.totalSlides} index.\n */\n increment(): void;\n\n /**\n * Decrements the carousel slide active index by 1 and prevents decrementing\n * past 0.\n */\n decrement(): void;\n\n /**\n * This can be used to manually control the {@link paused} state.\n */\n setPaused: UseStateSetter<boolean>;\n\n /**\n * Toggles the {@link paused} state.\n */\n togglePaused(): void;\n\n /**\n * A convenience wrapper for the {@link setCarouselSlideState} that will\n * ensure the {@link CarouselSlideState.direction} is correct based on the\n * current active index and next active index.\n */\n setActiveIndex: UseStateSetter<number>;\n\n /**\n * This can be used if the provided carousel actions do not solve your use\n * case.\n */\n setCarouselSlideState: UseStateSetter<CarouselSlideState>;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface CarouselOptions {\n /**\n * The amount of time in milliseconds each slide should be visible before\n * advancing to the next slide.\n *\n * @defaultValue `8000`\n */\n duration?: number;\n\n /**\n * The total number of slides within your carousel so that you can safely loop\n * through all slides.\n */\n totalSlides: number;\n}\n\n/**\n * @example\n * Accessible Carousel Example\n * ```tsx\n * import { Button, SlideContainer, Slide, useCarousel } from \"@react-md/core\";\n * import ChevronLeftIcon from \"@react-md/material-icons/ChevronLeftIcon\";\n * import ChevronRightIcon from \"@react-md/material-icons/ChevronRightIcon\";\n * import PauseIcon from \"@react-md/material-icons/PauseIcon\";\n * import PlayArrowIcon from \"@react-md/material-icons/PlayArrowIcon\";\n * import type { ReactElement } from \"react\";\n *\n * const slides = [\n * { title: \"Slide 1\" },\n * { title: \"Slide 2\" },\n * { title: \"Slide 3\" },\n * ] as const;\n *\n * function Example(): ReactElement {\n * const {\n * paused,\n * direction,\n * activeIndex,\n * togglePaused,\n * setActiveIndex,\n * increment,\n * decrement,\n * } = useCarousel({\n * duration: 5000,\n * totalSlides: slides.length,\n * });\n *\n * const slideId = useId();\n *\n * return (\n * <div\n * aria-roledescription=\"carousel\"\n * aria-label=\"Carousel\"\n * id={useId()}\n * role=\"region\"\n * >\n * <SlideContainer aria-live=\"off\" direction={direction}>\n * {slides.map(({ title }, index) => (\n * <Slide\n * key={title}\n * aria-label={`Slide ${index + 1} of ${slides.length - 1}`}\n * aria-roledescription=\"slide\"\n * id={`${slideId}-${index}`}\n * role=\"group\"\n * active={activeIndex === index}\n * >\n * {title}\n * </Slide>\n * ))}\n * </SlideContainer>\n * <Button\n * aria-label=\"Pause\"\n * aria-pressed={paused}\n * button=\"icon\"\n * onClick={togglePaused}\n * >\n * {paused ? <PlayArrowIcon /> : <PauseIcon />}\n * </Button>\n * {slides.map(({ title }, index) => (\n * <Button\n * key={title}\n * aria-label={`Slide ${index + 1}`}\n * aria-selected={activeIndex === index}\n * aria-controls={`${slideId}-${index}`}\n * role=\"tab\"\n * onClick={() => setActiveIndex(index))}\n * />\n * ))}\n * <Button\n * aria-label=\"Previous Slide\"\n * onClick={decrement}\n * disabled={activeIndex === 0}\n * buttonType=\"icon\"\n * >\n * <ChevronLeftIcon />\n * </Button>\n * <Button\n * aria-label=\"Next Slide\"\n * onClick={increment}\n * disabled={activeIndex === slides.length - 1}\n * buttonType=\"icon\"\n * >\n * <ChevronRightIcon />\n * </Button>\n * </div>\n * );\n * }\n * ```\n *\n * @remarks \\@since 6.0.0\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/carousel/}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/example-index/carousel/carousel-2-tablist.html}\n */\nexport function useCarousel(options: CarouselOptions): CarouselImplementation {\n const { duration = 8000, totalSlides } = options;\n const total = totalSlides - 1;\n\n const [state, setCarouselSlideState] = useState<CarouselSlideState>({\n direction: \"left\",\n activeIndex: 0,\n });\n const {\n toggled: paused,\n toggle: togglePaused,\n setToggled: setPaused,\n } = useToggle(false);\n const setActiveIndex = useCallback<UseStateSetter<number>>(\n (activeIndexOrGetter) => {\n setCarouselSlideState((prevState) => {\n const prevActiveIndex = prevState.activeIndex;\n const nextActiveIndex =\n typeof activeIndexOrGetter === \"function\"\n ? activeIndexOrGetter(prevActiveIndex)\n : activeIndexOrGetter;\n\n return {\n direction: prevActiveIndex < nextActiveIndex ? \"left\" : \"right\",\n activeIndex: nextActiveIndex,\n };\n });\n },\n []\n );\n const increment = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"left\",\n activeIndex: Math.min(total, prevState.activeIndex + 1),\n }));\n }, [total]);\n const decrement = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"right\",\n activeIndex: Math.max(0, prevState.activeIndex - 1),\n }));\n }, []);\n\n const { activeIndex } = state;\n useEffect(() => {\n if (paused) {\n return;\n }\n\n const timeout = window.setTimeout(() => {\n const nextActiveIndex = loop({\n min: 0,\n max: total,\n value: activeIndex,\n increment: true,\n });\n setCarouselSlideState({\n direction: activeIndex < nextActiveIndex ? \"left\" : \"right\",\n activeIndex: nextActiveIndex,\n });\n }, duration);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [paused, duration, activeIndex, total]);\n\n return {\n ...state,\n increment,\n decrement,\n paused,\n setPaused,\n togglePaused,\n setActiveIndex,\n setCarouselSlideState,\n };\n}\n"],"names":["useCallback","useEffect","useState","useToggle","loop","useCarousel","options","duration","totalSlides","total","state","setCarouselSlideState","direction","activeIndex","toggled","paused","toggle","togglePaused","setToggled","setPaused","setActiveIndex","activeIndexOrGetter","prevState","prevActiveIndex","nextActiveIndex","increment","Math","min","decrement","max","timeout","window","setTimeout","value","clearTimeout"],"mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,mBAAmB;AAuExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EAAEC,WAAW,IAAI,EAAEC,WAAW,EAAE,GAAGF;IACzC,MAAMG,QAAQD,cAAc;IAE5B,MAAM,CAACE,OAAOC,sBAAsB,GAAGT,SAA6B;QAClEU,WAAW;QACXC,aAAa;IACf;IACA,MAAM,EACJC,SAASC,MAAM,EACfC,QAAQC,YAAY,EACpBC,YAAYC,SAAS,EACtB,GAAGhB,UAAU;IACd,MAAMiB,iBAAiBpB,YACrB,CAACqB;QACCV,sBAAsB,CAACW;YACrB,MAAMC,kBAAkBD,UAAUT,WAAW;YAC7C,MAAMW,kBACJ,OAAOH,wBAAwB,aAC3BA,oBAAoBE,mBACpBF;YAEN,OAAO;gBACLT,WAAWW,kBAAkBC,kBAAkB,SAAS;gBACxDX,aAAaW;YACf;QACF;IACF,GACA,EAAE;IAEJ,MAAMC,YAAYzB,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKC,GAAG,CAAClB,OAAOa,UAAUT,WAAW,GAAG;YACvD,CAAA;IACF,GAAG;QAACJ;KAAM;IACV,MAAMmB,YAAY5B,YAAY;QAC5BW,sBAAsB,CAACW,YAAe,CAAA;gBACpCV,WAAW;gBACXC,aAAaa,KAAKG,GAAG,CAAC,GAAGP,UAAUT,WAAW,GAAG;YACnD,CAAA;IACF,GAAG,EAAE;IAEL,MAAM,EAAEA,WAAW,EAAE,GAAGH;IACxBT,UAAU;QACR,IAAIc,QAAQ;YACV;QACF;QAEA,MAAMe,UAAUC,OAAOC,UAAU,CAAC;YAChC,MAAMR,kBAAkBpB,KAAK;gBAC3BuB,KAAK;gBACLE,KAAKpB;gBACLwB,OAAOpB;gBACPY,WAAW;YACb;YACAd,sBAAsB;gBACpBC,WAAWC,cAAcW,kBAAkB,SAAS;gBACpDX,aAAaW;YACf;QACF,GAAGjB;QAEH,OAAO;YACLwB,OAAOG,YAAY,CAACJ;QACtB;IACF,GAAG;QAACf;QAAQR;QAAUM;QAAaJ;KAAM;IAEzC,OAAO;QACL,GAAGC,KAAK;QACRe;QACAG;QACAb;QACAI;QACAF;QACAG;QACAT;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useCarousel.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport type { UseStateSetter } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { loop } from \"../utils/loop.js\";\nimport type { SlideDirection } from \"./SlideContainer.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselSlideState {\n direction: SlideDirection;\n activeIndex: number;\n}\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselState extends CarouselSlideState {\n paused: boolean;\n}\n\n/** @remarks \\@since 6.0.0 */\nexport interface CarouselImplementation extends CarouselState {\n /**\n * Increments the carousel slide active index by 1 ensuring it does not\n * advance past the {@link CarouselOptions.totalSlides} index.\n */\n increment(): void;\n\n /**\n * Decrements the carousel slide active index by 1 and prevents decrementing\n * past 0.\n */\n decrement(): void;\n\n /**\n * This can be used to manually control the {@link paused} state.\n */\n setPaused: UseStateSetter<boolean>;\n\n /**\n * Toggles the {@link paused} state.\n */\n togglePaused(): void;\n\n /**\n * A convenience wrapper for the {@link setCarouselSlideState} that will\n * ensure the {@link CarouselSlideState.direction} is correct based on the\n * current active index and next active index.\n */\n setActiveIndex: UseStateSetter<number>;\n\n /**\n * This can be used if the provided carousel actions do not solve your use\n * case.\n */\n setCarouselSlideState: UseStateSetter<CarouselSlideState>;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface CarouselOptions {\n /**\n * The amount of time in milliseconds each slide should be visible before\n * advancing to the next slide.\n *\n * @defaultValue `8000`\n */\n duration?: number;\n\n /**\n * The total number of slides within your carousel so that you can safely loop\n * through all slides.\n */\n totalSlides: number;\n}\n\n/**\n * @example\n * Accessible Carousel Example\n * ```tsx\n * import { Button, SlideContainer, Slide, useCarousel } from \"@react-md/core\";\n * import ChevronLeftIcon from \"@react-md/material-icons/ChevronLeftIcon\";\n * import ChevronRightIcon from \"@react-md/material-icons/ChevronRightIcon\";\n * import PauseIcon from \"@react-md/material-icons/PauseIcon\";\n * import PlayArrowIcon from \"@react-md/material-icons/PlayArrowIcon\";\n * import type { ReactElement } from \"react\";\n *\n * const slides = [\n * { title: \"Slide 1\" },\n * { title: \"Slide 2\" },\n * { title: \"Slide 3\" },\n * ] as const;\n *\n * function Example(): ReactElement {\n * const {\n * paused,\n * direction,\n * activeIndex,\n * togglePaused,\n * setActiveIndex,\n * increment,\n * decrement,\n * } = useCarousel({\n * duration: 5000,\n * totalSlides: slides.length,\n * });\n *\n * const slideId = useId();\n *\n * return (\n * <div\n * aria-roledescription=\"carousel\"\n * aria-label=\"Carousel\"\n * id={useId()}\n * role=\"region\"\n * >\n * <SlideContainer aria-live=\"off\" direction={direction}>\n * {slides.map(({ title }, index) => (\n * <Slide\n * key={title}\n * aria-label={`Slide ${index + 1} of ${slides.length - 1}`}\n * aria-roledescription=\"slide\"\n * id={`${slideId}-${index}`}\n * role=\"group\"\n * active={activeIndex === index}\n * >\n * {title}\n * </Slide>\n * ))}\n * </SlideContainer>\n * <Button\n * aria-label=\"Pause\"\n * aria-pressed={paused}\n * button=\"icon\"\n * onClick={togglePaused}\n * >\n * {paused ? <PlayArrowIcon /> : <PauseIcon />}\n * </Button>\n * {slides.map(({ title }, index) => (\n * <Button\n * key={title}\n * aria-label={`Slide ${index + 1}`}\n * aria-selected={activeIndex === index}\n * aria-controls={`${slideId}-${index}`}\n * role=\"tab\"\n * onClick={() => setActiveIndex(index))}\n * />\n * ))}\n * <Button\n * aria-label=\"Previous Slide\"\n * onClick={decrement}\n * disabled={activeIndex === 0}\n * buttonType=\"icon\"\n * >\n * <ChevronLeftIcon />\n * </Button>\n * <Button\n * aria-label=\"Next Slide\"\n * onClick={increment}\n * disabled={activeIndex === slides.length - 1}\n * buttonType=\"icon\"\n * >\n * <ChevronRightIcon />\n * </Button>\n * </div>\n * );\n * }\n * ```\n *\n * @remarks \\@since 6.0.0\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/carousel/}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/example-index/carousel/carousel-2-tablist.html}\n */\nexport function useCarousel(options: CarouselOptions): CarouselImplementation {\n const { duration = 8000, totalSlides } = options;\n const total = totalSlides - 1;\n\n const [state, setCarouselSlideState] = useState<CarouselSlideState>({\n direction: \"left\",\n activeIndex: 0,\n });\n const {\n toggled: paused,\n toggle: togglePaused,\n setToggled: setPaused,\n } = useToggle(false);\n const setActiveIndex = useCallback<UseStateSetter<number>>(\n (activeIndexOrGetter) => {\n setCarouselSlideState((prevState) => {\n const prevActiveIndex = prevState.activeIndex;\n const nextActiveIndex =\n typeof activeIndexOrGetter === \"function\"\n ? activeIndexOrGetter(prevActiveIndex)\n : activeIndexOrGetter;\n\n return {\n direction: prevActiveIndex < nextActiveIndex ? \"left\" : \"right\",\n activeIndex: nextActiveIndex,\n };\n });\n },\n []\n );\n const increment = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"left\",\n activeIndex: Math.min(total, prevState.activeIndex + 1),\n }));\n }, [total]);\n const decrement = useCallback(() => {\n setCarouselSlideState((prevState) => ({\n direction: \"right\",\n activeIndex: Math.max(0, prevState.activeIndex - 1),\n }));\n }, []);\n\n const { activeIndex } = state;\n useEffect(() => {\n if (paused) {\n return;\n }\n\n const timeout = window.setTimeout(() => {\n const nextActiveIndex = loop({\n min: 0,\n max: total,\n value: activeIndex,\n increment: true,\n });\n setCarouselSlideState({\n direction: activeIndex < nextActiveIndex ? \"left\" : \"right\",\n activeIndex: nextActiveIndex,\n });\n }, duration);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [paused, duration, activeIndex, total]);\n\n return {\n ...state,\n increment,\n decrement,\n paused,\n setPaused,\n togglePaused,\n setActiveIndex,\n setCarouselSlideState,\n };\n}\n"],"names":["useCallback","useEffect","useState","useToggle","loop","useCarousel","options","duration","totalSlides","total","state","setCarouselSlideState","direction","activeIndex","toggled","paused","toggle","togglePaused","setToggled","setPaused","setActiveIndex","activeIndexOrGetter","prevState","prevActiveIndex","nextActiveIndex","increment","Math","min","decrement","max","timeout","window","setTimeout","value","clearTimeout"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,mBAAmB;AAuExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGC,GACD,OAAO,SAASC,YAAYC,OAAwB;IAClD,MAAM,EAAEC,WAAW,IAAI,EAAEC,WAAW,EAAE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QACAb;QACAI;QACAF;QACAG;QACAT;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useCollapseTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type { CSSProperties } from \"react\";\nimport { useState } from \"react\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport { collapse } from \"./collapseStyles.js\";\nimport type {\n CSSTransitionElementProps,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useTransition } from \"./useTransition.js\";\nimport { getElementSizing, getTransitionTimeout } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @remarks \\@since 2.0.0\n */\nexport const DEFAULT_COLLAPSE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n enter: 250,\n exit: 200,\n};\n\n/**\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseConfigurationStyle {\n /**\n * The minimum height that the collapsed element can be which defaults to `0`.\n * This can either be a number of pixels or a string CSS height value.\n *\n * Setting this value to any non-zero value will allow for the element to\n * shrink to the defined min-height, and then expand to the full height once\n * no longer collapsed.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minHeight?: number | string;\n\n /**\n * The minimum padding-top that the collapsed element can be which defaults to\n * `0`. This can either be a number of pixels or a string CSS `padding-top`\n * value.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minPaddingTop?: number | string;\n\n /**\n * The minimum padding-bottom that the collapsed element can be which defaults\n * to `0`. This can either be a number of pixels or a string CSS\n * `padding-bottom` value.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minPaddingBottom?: number | string;\n}\n\n/**\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseStyle extends CollapseConfigurationStyle {\n /**\n * This will only be set when the {@link TransitionStage} is `\"entering\"` or\n * `\"exiting\"` as `\"${timeout}ms\"`.\n */\n transitionDuration?: string;\n}\n\n/**\n * These props (and `ref`) **must** be passed to a DOM element for the collapse\n * transition to work.\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseElementProps<E extends HTMLElement>\n extends CSSTransitionElementProps<E> {\n /**\n * A merged styled object required for the collapse transition to work.\n *\n * @see {@link CollapseStyle}\n * @see {@link CollapseTransitionHookOptions.style}\n */\n style: CSSProperties;\n}\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseTransitionHookOptions<E extends HTMLElement>\n extends Omit<PreconfiguredCSSTransitionOptions<E>, \"exitedHidden\">,\n CollapseConfigurationStyle {\n /**\n * An optional style to merge with the required collapse transition styles.\n *\n * If any keys from the {@link CollapseStyle} are included in this object,\n * these styles will override and possibly break the collapse transition.\n */\n style?: CSSProperties;\n\n /**\n *\n * @see {@link DEFAULT_COLLAPSE_TIMEOUT}\n * @defaultValue `DEFAULT_COLLAPSE_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n *\n * @defaultValue `minHeight === 0 && minPaddingTop === 0 && minPaddingBottom === 0`\n */\n temporary?: boolean;\n}\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseTransitionHookReturnValue<E extends HTMLElement>\n extends CSSTransitionHookReturnValue<E>,\n CollapseElementProps<E> {\n /**\n * This is just a convenience object so that you don't need to destructure as\n * many variables to pass to an element.\n *\n * @example\n * Simple Usage\n * ```tsx\n * const { elementProps, rendered } = useCollapseTransition({\n * // ...options\n * transitionIn,\n * });\n *\n * if (!rendered) {\n * return null\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n *\n * // This is the long-hand version\n * const { ref, style, className, hidden, rendered } = useCollapseTransition({\n * // ...options\n * transitionIn,\n * });\n *\n * if (!rendered) {\n * return null\n * }\n *\n * return (\n * <div\n * ref={ref}\n * style={style}\n * className={className}\n * hidden={hidden}\n * >\n * {children}\n * </div>\n * );\n * ```\n */\n elementProps: Readonly<CollapseElementProps<E>>;\n}\n\n/**\n * This hook is used to create a transition to collapse and expand an element\n * **inline** with other content like an accordion by animating the\n * `max-height`, `padding-top`, and `padding-bottom` CSS properties. The default\n * behavior is to hide the element completely while collapsed, but providing the\n * `minHeight`, `minPaddingTop`, and `minPaddingBottom` options can make this\n * work like a \"See More\"/\"Preview\" type of element\n *\n * @example\n * Simple Example\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCollapseTransition } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const [collapsed, setCollapsed] = useState(true);\n * const { elementProps, rendered } =\n * useCollapseTransition({\n * transitionIn: !collapsed,\n * // If the collapsible element should maintain state by not unmounting\n * // while collapsed, uncomment this next line\n * // temporary: false,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setCollapsed(!collapsed)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <div {...elementProps}>\n * <Typography>Stuff that should be collapsed</Typography>\n * <div>Whatever content...</div>\n * </div>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @example\n * See More Example\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, IconRotator, Typography, useCollapseTransition } from \"@react-md/core\";\n * import { KeyboardArrowDownSVGIcon } from \"@react-md/material-icons\";\n *\n * import styles from \"./Example.module.scss\";\n * // pretend styles:\n * //\n * // .container {\n * // padding: 1rem;\n * // position: relative;\n * // }\n * //\n * // .button {\n * // position: absolute;\n * // right: 0;\n * // top: 0;\n * // }\n *\n *\n * function Example(): ReactElement {\n * const [collapsed, setCollapsed] = useState(true);\n * const { elementProps } =\n * useCollapseTransition({\n * transitionIn: !collapsed,\n * minHeight: 120,\n * minPaddingTop: 16,\n * className: styles.container,\n * });\n *\n * return (\n * <div {...elementProps}>\n * <Button\n * aria-expanded={!collapsed}\n * aria-label=\"Expand\"\n * onClick={() => setCollapsed(!collapsed)}\n * buttonType=\"icon\"\n * className={styles.button}\n * >\n * <IconRotator rotated={!collapsed}>\n * <KeyboardArrowDownSVGIcon />\n * </IconRotator>\n * </Button>\n * <SomeComponentWithALotOfContent />\n * </div>\n * );\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCollapseTransition<E extends HTMLElement>(\n options: CollapseTransitionHookOptions<E>\n): CollapseTransitionHookReturnValue<E> {\n const {\n nodeRef: propNodeRef,\n style: propStyle,\n className,\n transitionIn,\n timeout = DEFAULT_COLLAPSE_TIMEOUT,\n minHeight = 0,\n minPaddingTop = 0,\n minPaddingBottom = 0,\n temporary = minHeight === 0 &&\n minPaddingTop === 0 &&\n minPaddingBottom === 0,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n } = options;\n\n const [nodeRef, refCallback] = useEnsuredRef(propNodeRef);\n const [style, setStyle] = useState<CSSProperties | undefined>(() => {\n if (transitionIn) {\n return undefined;\n }\n\n return {\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n };\n });\n\n const transitionTimeout = getTransitionTimeout({\n timeout,\n appear,\n enter,\n exit,\n });\n\n const { appearing, rendered, ref, stage, transitionTo, disablePortal } =\n useTransition({\n nodeRef: refCallback,\n timeout,\n transitionIn,\n reflow: true,\n appear,\n enter,\n exit,\n temporary,\n onEnter(appearing) {\n onEnter(appearing);\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n });\n },\n onEntering(appearing) {\n onEntering(appearing);\n const { maxHeight, paddingTop, paddingBottom } = getElementSizing(\n nodeRef.current\n );\n\n const duration = appearing\n ? transitionTimeout.appear\n : transitionTimeout.enter;\n\n setStyle({\n maxHeight,\n paddingTop,\n paddingBottom,\n transitionDuration: `${duration}ms`,\n });\n },\n onEntered(appearing) {\n onEntered(appearing);\n setStyle(undefined);\n },\n onExit() {\n onExit();\n const { maxHeight, paddingTop, paddingBottom } = getElementSizing(\n nodeRef.current\n );\n\n setStyle({\n maxHeight,\n paddingTop,\n paddingBottom,\n transitionDuration: `${transitionTimeout.exit}ms`,\n });\n },\n onExiting() {\n onExiting();\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n transitionDuration: `${transitionTimeout.exit}ms`,\n });\n },\n onExited() {\n onExited();\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n });\n },\n });\n const entering = stage === \"enter\" || stage === \"entering\";\n const exiting = stage === \"exit\" || stage === \"exiting\";\n const collapsible =\n transitionTimeout.enter !== 0 || transitionTimeout.exit !== 0;\n\n const elementProps: CollapseElementProps<E> = {\n ref,\n style: { ...style, ...propStyle },\n className:\n cnb(\n className,\n collapsible &&\n collapse({\n enter: entering,\n leave: exiting,\n disableOverflow: !transitionIn || !!style,\n }),\n stage === \"exited\" &&\n minHeight === 0 &&\n minPaddingTop === 0 &&\n minPaddingBottom === 0 &&\n DISPLAY_NONE_CLASS\n ) || undefined,\n };\n\n return {\n ...elementProps,\n stage,\n rendered,\n appearing,\n elementProps,\n transitionTo,\n disablePortal,\n };\n}\n"],"names":["cnb","useState","useEnsuredRef","DISPLAY_NONE_CLASS","collapse","useTransition","getElementSizing","getTransitionTimeout","noop","DEFAULT_COLLAPSE_TIMEOUT","enter","exit","useCollapseTransition","options","nodeRef","propNodeRef","style","propStyle","className","transitionIn","timeout","minHeight","minPaddingTop","minPaddingBottom","temporary","appear","onEnter","onEntering","onEntered","onExit","onExiting","onExited","refCallback","setStyle","undefined","maxHeight","paddingTop","paddingBottom","transitionTimeout","appearing","rendered","ref","stage","transitionTo","disablePortal","reflow","current","duration","transitionDuration","entering","exiting","collapsible","elementProps","leave","disableOverflow"],"mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,QAAQ,QAAQ,sBAAsB;AAQ/C,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,aAAa;AAEpE,MAAMC,OAAO;AACX,aAAa;AACf;AAEA;;CAEC,GACD,OAAO,MAAMC,2BAA8D;IACzEC,OAAO;IACPC,MAAM;AACR,EAAE;AAgKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FC,GACD,OAAO,SAASC,sBACdC,OAAyC;IAEzC,MAAM,EACJC,SAASC,WAAW,EACpBC,OAAOC,SAAS,EAChBC,SAAS,EACTC,YAAY,EACZC,UAAUX,wBAAwB,EAClCY,YAAY,CAAC,EACbC,gBAAgB,CAAC,EACjBC,mBAAmB,CAAC,EACpBC,YAAYH,cAAc,KACxBC,kBAAkB,KAClBC,qBAAqB,CAAC,EACxBE,SAAS,KAAK,EACdf,QAAQ,IAAI,EACZC,OAAO,IAAI,EACXe,UAAUlB,IAAI,EACdmB,aAAanB,IAAI,EACjBoB,YAAYpB,IAAI,EAChBqB,SAASrB,IAAI,EACbsB,YAAYtB,IAAI,EAChBuB,WAAWvB,IAAI,EAChB,GAAGK;IAEJ,MAAM,CAACC,SAASkB,YAAY,GAAG9B,cAAca;I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e,YAAYd;gBACZe,eAAed;YACjB;QACF;IACF;IACF,MAAM0B,WAAWP,UAAU,WAAWA,UAAU;IAChD,MAAMQ,UAAUR,UAAU,UAAUA,UAAU;IAC9C,MAAMS,cACJb,kBAAkB5B,KAAK,KAAK,KAAK4B,kBAAkB3B,IAAI,KAAK;IAE9D,MAAMyC,eAAwC;QAC5CX;QACAzB,OAAO;YAAE,GAAGA,KAAK;YAAE,GAAGC,SAAS;QAAC;QAChCC,WACElB,IACEkB,WACAiC,eACE/C,SAAS;YACPM,OAAOuC;YACPI,OAAOH;YACPI,iBAAiB,CAACnC,gBAAgB,CAAC,CAACH;QACtC,IACF0B,UAAU,YACRrB,cAAc,KACdC,kBAAkB,KAClBC,qBAAqB,KACrBpB,uBACC+B;IACT;IAEA,OAAO;QACL,GAAGkB,YAAY;QACfV;QACAF;QACAD;QACAa;QACAT;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useCollapseTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type { CSSProperties } from \"react\";\nimport { useState } from \"react\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\nimport { collapse } from \"./collapseStyles.js\";\nimport type {\n CSSTransitionElementProps,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useTransition } from \"./useTransition.js\";\nimport { getElementSizing, getTransitionTimeout } from \"./utils.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @remarks \\@since 2.0.0\n */\nexport const DEFAULT_COLLAPSE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n enter: 250,\n exit: 200,\n};\n\n/**\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseConfigurationStyle {\n /**\n * The minimum height that the collapsed element can be which defaults to `0`.\n * This can either be a number of pixels or a string CSS height value.\n *\n * Setting this value to any non-zero value will allow for the element to\n * shrink to the defined min-height, and then expand to the full height once\n * no longer collapsed.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minHeight?: number | string;\n\n /**\n * The minimum padding-top that the collapsed element can be which defaults to\n * `0`. This can either be a number of pixels or a string CSS `padding-top`\n * value.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minPaddingTop?: number | string;\n\n /**\n * The minimum padding-bottom that the collapsed element can be which defaults\n * to `0`. This can either be a number of pixels or a string CSS\n * `padding-bottom` value.\n *\n * Note: If the `minHeight`, `minPaddingTop`, and `minPaddingBottom` options\n * are all set to `0` (default), the child will be removed from the DOM while\n * collapsed.\n *\n * @defaultValue `0`\n */\n minPaddingBottom?: number | string;\n}\n\n/**\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseStyle extends CollapseConfigurationStyle {\n /**\n * This will only be set when the {@link TransitionStage} is `\"entering\"` or\n * `\"exiting\"` as `\"${timeout}ms\"`.\n */\n transitionDuration?: string;\n}\n\n/**\n * These props (and `ref`) **must** be passed to a DOM element for the collapse\n * transition to work.\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseElementProps<E extends HTMLElement>\n extends CSSTransitionElementProps<E> {\n /**\n * A merged styled object required for the collapse transition to work.\n *\n * @see {@link CollapseStyle}\n * @see {@link CollapseTransitionHookOptions.style}\n */\n style: CSSProperties;\n}\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseTransitionHookOptions<E extends HTMLElement>\n extends Omit<PreconfiguredCSSTransitionOptions<E>, \"exitedHidden\">,\n CollapseConfigurationStyle {\n /**\n * An optional style to merge with the required collapse transition styles.\n *\n * If any keys from the {@link CollapseStyle} are included in this object,\n * these styles will override and possibly break the collapse transition.\n */\n style?: CSSProperties;\n\n /**\n *\n * @see {@link DEFAULT_COLLAPSE_TIMEOUT}\n * @defaultValue `DEFAULT_COLLAPSE_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n *\n * @defaultValue `minHeight === 0 && minPaddingTop === 0 && minPaddingBottom === 0`\n */\n temporary?: boolean;\n}\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CollapseTransitionHookReturnValue<E extends HTMLElement>\n extends CSSTransitionHookReturnValue<E>,\n CollapseElementProps<E> {\n /**\n * This is just a convenience object so that you don't need to destructure as\n * many variables to pass to an element.\n *\n * @example\n * Simple Usage\n * ```tsx\n * const { elementProps, rendered } = useCollapseTransition({\n * // ...options\n * transitionIn,\n * });\n *\n * if (!rendered) {\n * return null\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n *\n * // This is the long-hand version\n * const { ref, style, className, hidden, rendered } = useCollapseTransition({\n * // ...options\n * transitionIn,\n * });\n *\n * if (!rendered) {\n * return null\n * }\n *\n * return (\n * <div\n * ref={ref}\n * style={style}\n * className={className}\n * hidden={hidden}\n * >\n * {children}\n * </div>\n * );\n * ```\n */\n elementProps: Readonly<CollapseElementProps<E>>;\n}\n\n/**\n * This hook is used to create a transition to collapse and expand an element\n * **inline** with other content like an accordion by animating the\n * `max-height`, `padding-top`, and `padding-bottom` CSS properties. The default\n * behavior is to hide the element completely while collapsed, but providing the\n * `minHeight`, `minPaddingTop`, and `minPaddingBottom` options can make this\n * work like a \"See More\"/\"Preview\" type of element\n *\n * @example\n * Simple Example\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, Typography, useCollapseTransition } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const [collapsed, setCollapsed] = useState(true);\n * const { elementProps, rendered } =\n * useCollapseTransition({\n * transitionIn: !collapsed,\n * // If the collapsible element should maintain state by not unmounting\n * // while collapsed, uncomment this next line\n * // temporary: false,\n * });\n *\n * return (\n * <>\n * <Button onClick={() => setCollapsed(!collapsed)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <div {...elementProps}>\n * <Typography>Stuff that should be collapsed</Typography>\n * <div>Whatever content...</div>\n * </div>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @example\n * See More Example\n * ```tsx\n * import { ReactElement, useState } from \"react\";\n * import { Button, IconRotator, Typography, useCollapseTransition } from \"@react-md/core\";\n * import { KeyboardArrowDownSVGIcon } from \"@react-md/material-icons\";\n *\n * import styles from \"./Example.module.scss\";\n * // pretend styles:\n * //\n * // .container {\n * // padding: 1rem;\n * // position: relative;\n * // }\n * //\n * // .button {\n * // position: absolute;\n * // right: 0;\n * // top: 0;\n * // }\n *\n *\n * function Example(): ReactElement {\n * const [collapsed, setCollapsed] = useState(true);\n * const { elementProps } =\n * useCollapseTransition({\n * transitionIn: !collapsed,\n * minHeight: 120,\n * minPaddingTop: 16,\n * className: styles.container,\n * });\n *\n * return (\n * <div {...elementProps}>\n * <Button\n * aria-expanded={!collapsed}\n * aria-label=\"Expand\"\n * onClick={() => setCollapsed(!collapsed)}\n * buttonType=\"icon\"\n * className={styles.button}\n * >\n * <IconRotator rotated={!collapsed}>\n * <KeyboardArrowDownSVGIcon />\n * </IconRotator>\n * </Button>\n * <SomeComponentWithALotOfContent />\n * </div>\n * );\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCollapseTransition<E extends HTMLElement>(\n options: CollapseTransitionHookOptions<E>\n): CollapseTransitionHookReturnValue<E> {\n const {\n nodeRef: propNodeRef,\n style: propStyle,\n className,\n transitionIn,\n timeout = DEFAULT_COLLAPSE_TIMEOUT,\n minHeight = 0,\n minPaddingTop = 0,\n minPaddingBottom = 0,\n temporary = minHeight === 0 &&\n minPaddingTop === 0 &&\n minPaddingBottom === 0,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n } = options;\n\n const [nodeRef, refCallback] = useEnsuredRef(propNodeRef);\n const [style, setStyle] = useState<CSSProperties | undefined>(() => {\n if (transitionIn) {\n return undefined;\n }\n\n return {\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n };\n });\n\n const transitionTimeout = getTransitionTimeout({\n timeout,\n appear,\n enter,\n exit,\n });\n\n const { appearing, rendered, ref, stage, transitionTo, disablePortal } =\n useTransition({\n nodeRef: refCallback,\n timeout,\n transitionIn,\n reflow: true,\n appear,\n enter,\n exit,\n temporary,\n onEnter(appearing) {\n onEnter(appearing);\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n });\n },\n onEntering(appearing) {\n onEntering(appearing);\n const { maxHeight, paddingTop, paddingBottom } = getElementSizing(\n nodeRef.current\n );\n\n const duration = appearing\n ? transitionTimeout.appear\n : transitionTimeout.enter;\n\n setStyle({\n maxHeight,\n paddingTop,\n paddingBottom,\n transitionDuration: `${duration}ms`,\n });\n },\n onEntered(appearing) {\n onEntered(appearing);\n setStyle(undefined);\n },\n onExit() {\n onExit();\n const { maxHeight, paddingTop, paddingBottom } = getElementSizing(\n nodeRef.current\n );\n\n setStyle({\n maxHeight,\n paddingTop,\n paddingBottom,\n transitionDuration: `${transitionTimeout.exit}ms`,\n });\n },\n onExiting() {\n onExiting();\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n transitionDuration: `${transitionTimeout.exit}ms`,\n });\n },\n onExited() {\n onExited();\n setStyle({\n maxHeight: minHeight,\n paddingTop: minPaddingTop,\n paddingBottom: minPaddingBottom,\n });\n },\n });\n const entering = stage === \"enter\" || stage === \"entering\";\n const exiting = stage === \"exit\" || stage === \"exiting\";\n const collapsible =\n transitionTimeout.enter !== 0 || transitionTimeout.exit !== 0;\n\n const elementProps: CollapseElementProps<E> = {\n ref,\n style: { ...style, ...propStyle },\n className:\n cnb(\n className,\n collapsible &&\n collapse({\n enter: entering,\n leave: exiting,\n disableOverflow: !transitionIn || !!style,\n }),\n stage === \"exited\" &&\n minHeight === 0 &&\n minPaddingTop === 0 &&\n minPaddingBottom === 0 &&\n DISPLAY_NONE_CLASS\n ) || undefined,\n };\n\n return {\n ...elementProps,\n stage,\n rendered,\n appearing,\n elementProps,\n transitionTo,\n disablePortal,\n };\n}\n"],"names":["cnb","useState","useEnsuredRef","DISPLAY_NONE_CLASS","collapse","useTransition","getElementSizing","getTransitionTimeout","noop","DEFAULT_COLLAPSE_TIMEOUT","enter","exit","useCollapseTransition","options","nodeRef","propNodeRef","style","propStyle","className","transitionIn","timeout","minHeight","minPaddingTop","minPaddingBottom","temporary","appear","onEnter","onEntering","onEntered","onExit","onExiting","onExited","refCallback","setStyle","undefined","maxHeight","paddingTop","paddingBottom","transitionTimeout","appearing","rendered","ref","stage","transitionTo","disablePortal","reflow","current","duration","transitionDuration","entering","exiting","collapsible","elementProps","leave","disableOverflow"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,QAAQ,QAAQ,sBAAsB;AAQ/C,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gBAAgB,EAA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;IACT;IAEA,OAAO;QACL,GAAGkB,YAAY;QACfV;QACAF;QACAD;QACAa;QACAT;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useCrossFadeTransition.ts"],"sourcesContent":["\"use client\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionInDefaultedOptions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * The default cross fade transition classes to use.\n *\n * @remarks \\@since 2.0.0\n */\nexport const CROSS_FADE_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-cross-fade\",\n appearActive: \"rmd-cross-fade--active\",\n enter: \"rmd-cross-fade\",\n enterActive: \"rmd-cross-fade--active\",\n};\n\n/**\n * The default cross fade transition timeout.\n *\n * @remarks \\@since 2.0.0\n */\nexport const CROSS_FADE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n appear: 300,\n enter: 300,\n exit: 0,\n};\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CrossFadeTransitionHookOptions<E extends HTMLElement>\n extends PreconfiguredCSSTransitionInDefaultedOptions<E> {\n /**\n * @see {@link TransitionTimeout}\n * @see {@link CROSS_FADE_TIMEOUT}\n * @defaultValue `CROSS_FADE_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link CSSTransitionClassNames}\n * @see {@link CROSS_FADE_CLASSNAMES}\n * @defaultValue `CROSS_FADE_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n\n /**\n * @see {@link PreconfiguredCSSTransitionInDefaultedOptions.transitionIn}\n * @defaultValue `true`\n */\n transitionIn?: boolean;\n}\n\n/**\n * This hook is used to create a \"cross fade\" transition -- a transition that\n * gradually increases the opacity and transforms the element vertically a short\n * distance. This is generally used for full page transitions when a route\n * changes.\n *\n * @example\n * New Page Transition with the Layout component\n * ```tsx\n * import { ReactElement, ReactNode, useLayoutEffect } from \"react\";\n * import { useLocation } from \"react-router-dom\":\n * import { Layout, useCrossFadeTransition, useLayoutNavigation } from \"@react-md/core\";\n *\n * import { navItems } from \"./navItems\";\n *\n * interface ExampleProps {\n * children: ReactNode;\n * }\n *\n * function Example({ children }: ExampleProps): ReactElement {\n * const { pathname } = useLocation();\n * const { elementProps, transitionTo } = useCrossFadeTransition();\n *\n * const prevPathname = useRef(pathname);\n * useLayoutEffect(() => {\n * if (prevPathname.current === pathname) {\n * return\n * }\n *\n * prevPathname.current = pathname;\n * transitionTo('enter');\n * }, [pathname, transitionTo])\n *\n * return (\n * <Layout\n * {...useLayoutNavigation(navItems, pathname)}\n * appBarTitle=\"My App\"\n * mainProps={elementProps}\n * >\n * {children}\n * </Layout>\n * );\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCrossFadeTransition<E extends HTMLElement>(\n options: CrossFadeTransitionHookOptions<E> = {}\n): CSSTransitionHookReturnValue<E> {\n const {\n transitionIn = true,\n timeout = CROSS_FADE_TIMEOUT,\n classNames = CROSS_FADE_CLASSNAMES,\n ...cssOptions\n } = options;\n\n return useCSSTransition({\n ...cssOptions,\n timeout,\n classNames,\n transitionIn,\n });\n}\n"],"names":["useCSSTransition","CROSS_FADE_CLASSNAMES","appear","appearActive","enter","enterActive","CROSS_FADE_TIMEOUT","exit","useCrossFadeTransition","options","transitionIn","timeout","classNames","cssOptions"],"mappings":"AAAA;AASA,SAASA,gBAAgB,QAAQ,wBAAwB;AAEzD;;;;CAIC,GACD,OAAO,MAAMC,wBAAiE;IAC5EC,QAAQ;IACRC,cAAc;IACdC,OAAO;IACPC,aAAa;AACf,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMC,qBAAwD;IACnEJ,QAAQ;IACRE,OAAO;IACPG,MAAM;AACR,EAAE;AA8BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GACD,OAAO,SAASC,uBACdC,UAA6C,CAAC,CAAC;IAE/C,MAAM,EACJC,eAAe,IAAI,EACnBC,UAAUL,kBAAkB,EAC5BM,aAAaX,qBAAqB,EAClC,GAAGY,YACJ,GAAGJ;IAEJ,OAAOT,iBAAiB;QACtB,GAAGa,UAAU;QACbF;QACAC;QACAF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useCrossFadeTransition.ts"],"sourcesContent":["\"use client\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionInDefaultedOptions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * The default cross fade transition classes to use.\n *\n * @remarks \\@since 2.0.0\n */\nexport const CROSS_FADE_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-cross-fade\",\n appearActive: \"rmd-cross-fade--active\",\n enter: \"rmd-cross-fade\",\n enterActive: \"rmd-cross-fade--active\",\n};\n\n/**\n * The default cross fade transition timeout.\n *\n * @remarks \\@since 2.0.0\n */\nexport const CROSS_FADE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n appear: 300,\n enter: 300,\n exit: 0,\n};\n\n/**\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface CrossFadeTransitionHookOptions<E extends HTMLElement>\n extends PreconfiguredCSSTransitionInDefaultedOptions<E> {\n /**\n * @see {@link TransitionTimeout}\n * @see {@link CROSS_FADE_TIMEOUT}\n * @defaultValue `CROSS_FADE_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link CSSTransitionClassNames}\n * @see {@link CROSS_FADE_CLASSNAMES}\n * @defaultValue `CROSS_FADE_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n\n /**\n * @see {@link PreconfiguredCSSTransitionInDefaultedOptions.transitionIn}\n * @defaultValue `true`\n */\n transitionIn?: boolean;\n}\n\n/**\n * This hook is used to create a \"cross fade\" transition -- a transition that\n * gradually increases the opacity and transforms the element vertically a short\n * distance. This is generally used for full page transitions when a route\n * changes.\n *\n * @example\n * New Page Transition with the Layout component\n * ```tsx\n * import { ReactElement, ReactNode, useLayoutEffect } from \"react\";\n * import { useLocation } from \"react-router-dom\":\n * import { Layout, useCrossFadeTransition, useLayoutNavigation } from \"@react-md/core\";\n *\n * import { navItems } from \"./navItems\";\n *\n * interface ExampleProps {\n * children: ReactNode;\n * }\n *\n * function Example({ children }: ExampleProps): ReactElement {\n * const { pathname } = useLocation();\n * const { elementProps, transitionTo } = useCrossFadeTransition();\n *\n * const prevPathname = useRef(pathname);\n * useLayoutEffect(() => {\n * if (prevPathname.current === pathname) {\n * return\n * }\n *\n * prevPathname.current = pathname;\n * transitionTo('enter');\n * }, [pathname, transitionTo])\n *\n * return (\n * <Layout\n * {...useLayoutNavigation(navItems, pathname)}\n * appBarTitle=\"My App\"\n * mainProps={elementProps}\n * >\n * {children}\n * </Layout>\n * );\n * }\n * ```\n *\n * @typeParam E - An HTMLElement type used for the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useCrossFadeTransition<E extends HTMLElement>(\n options: CrossFadeTransitionHookOptions<E> = {}\n): CSSTransitionHookReturnValue<E> {\n const {\n transitionIn = true,\n timeout = CROSS_FADE_TIMEOUT,\n classNames = CROSS_FADE_CLASSNAMES,\n ...cssOptions\n } = options;\n\n return useCSSTransition({\n ...cssOptions,\n timeout,\n classNames,\n transitionIn,\n });\n}\n"],"names":["useCSSTransition","CROSS_FADE_CLASSNAMES","appear","appearActive","enter","enterActive","CROSS_FADE_TIMEOUT","exit","useCrossFadeTransition","options","transitionIn","timeout","classNames","cssOptions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AASA,SAASA,gBAAgB,QAAQ,wBAAwB;AAEzD;;;;CAIC,GACD,OAAO,MAAMC,wBAAiE;IAC5EC,QAAQ;IACRC,cAAc;IACdC,OAAO;IACPC,aAAa;AACf,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMC,qBAAwD;IACnEJ,QAAQ;IACRE,OAAO;IACPG,MAAM;AACR,EAAE;AA8BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GACD,OAAO,SAASC,uBACdC,UAA6C,CAAC,CAAC;IAE/C,MAAM,EACJC,eAAe,IAAI,EACnBC,UAAUL,kBAAkB,EAC5BM,aAAaX,qBAAqB,EAClC,GAAGY,YACJ,GAAGJ;IAEJ,OAAOT,iBAAiB;QACtB,GAAGa,UAAU;QACbF;QACAC;QACAF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useMaxWidthTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type { ReactNode } from \"react\";\nimport { Children, cloneElement, isValidElement } from \"react\";\nimport { maxWidthTransition } from \"./maxWidthTransition.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface MaxWidthTransitionOptions {\n element: ReactNode;\n transitionIn: boolean;\n\n className?: string;\n disabled?: boolean;\n disableTransition?: boolean;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport function useMaxWidthTransition(\n options: MaxWidthTransitionOptions\n): ReactNode {\n const { element, disabled, disableTransition, transitionIn, className } =\n options;\n\n if (disabled || !isValidElement<{ className?: string }>(element)) {\n return element;\n }\n\n const child = Children.only(element);\n return cloneElement(element, {\n className: maxWidthTransition({\n className: cnb(child.props.className, className),\n disabled: disableTransition,\n transitionIn,\n }),\n });\n}\n"],"names":["cnb","Children","cloneElement","isValidElement","maxWidthTransition","useMaxWidthTransition","options","element","disabled","disableTransition","transitionIn","className","child","only","props"],"mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAQ,QAAQ;AAC/D,SAASC,kBAAkB,QAAQ,0BAA0B;AAc7D;;CAEC,GACD,OAAO,SAASC,sBACdC,OAAkC;IAElC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,SAAS,EAAE,GACrEL;IAEF,IAAIE,YAAY,CAACL,eAAuCI,UAAU;QAChE,OAAOA;IACT;IAEA,MAAMK,QAAQX,SAASY,IAAI,CAACN;IAC5B,OAAOL,aAAaK,SAAS;QAC3BI,WAAWP,mBAAmB;YAC5BO,WAAWX,IAAIY,MAAME,KAAK,CAACH,SAAS,EAAEA;YACtCH,UAAUC;YACVC;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useMaxWidthTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type { ReactNode } from \"react\";\nimport { Children, cloneElement, isValidElement } from \"react\";\nimport { maxWidthTransition } from \"./maxWidthTransition.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface MaxWidthTransitionOptions {\n element: ReactNode;\n transitionIn: boolean;\n\n className?: string;\n disabled?: boolean;\n disableTransition?: boolean;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport function useMaxWidthTransition(\n options: MaxWidthTransitionOptions\n): ReactNode {\n const { element, disabled, disableTransition, transitionIn, className } =\n options;\n\n if (disabled || !isValidElement<{ className?: string }>(element)) {\n return element;\n }\n\n const child = Children.only(element);\n return cloneElement(element, {\n className: maxWidthTransition({\n className: cnb(child.props.className, className),\n disabled: disableTransition,\n transitionIn,\n }),\n });\n}\n"],"names":["cnb","Children","cloneElement","isValidElement","maxWidthTransition","useMaxWidthTransition","options","element","disabled","disableTransition","transitionIn","className","child","only","props"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAQ,QAAQ;AAC/D,SAASC,kBAAkB,QAAQ,0BAA0B;AAc7D;;CAEC,GACD,OAAO,SAASC,sBACdC,OAAkC;IAElC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,SAAS,EAAE,GACrEL;IAEF,IAAIE,YAAY,CAACL,eAAuCI,UAAU;QAChE,OAAOA;IACT;IAEA,MAAMK,QAAQX,SAASY,IAAI,CAACN;IAC5B,OAAOL,aAAaK,SAAS;QAC3BI,WAAWP,mBAAmB;YAC5BO,WAAWX,IAAIY,MAAME,KAAK,CAACH,SAAS,EAAEA;YACtCH,UAAUC;YACVC;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useScaleTransition.ts"],"sourcesContent":["\"use client\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * The default {@link CSSTransitionClassNames} for a horizontal scale\n * transition.\n *\n * @remarks\n * \\@since 2.0.0\n * \\@since 6.0.0 The class names were updated to be prefixed with\n * `rmd-scale-transition`\n */\nexport const SCALE_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-scale-transition--enter\",\n appearActive: \"rmd-scale-transition--enter-active\",\n enter: \"rmd-scale-transition--enter\",\n enterActive: \"rmd-scale-transition--enter-active\",\n enterDone: \"\",\n exit: \"rmd-scale-transition--exit\",\n exitActive: \"rmd-scale-transition--exit-active\",\n};\n\n/**\n * The default {@link CSSTransitionClassNames} for a vertical scale transition.\n *\n * @remarks\n * \\@since 2.0.0\n * \\@since 6.0.0 The class names were updated to be prefixed with\n * `rmd-scale-y-transition` and merged with the {@link SCALE_CLASSNAMES}\n */\nexport const SCALE_Y_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-scale-transition--enter rmd-scale-transition--y-enter\",\n appearActive:\n \"rmd-scale-transition--enter-active rmd-scale-transition--y-enter-active\",\n enter: \"rmd-scale-transition--enter rmd-scale-transition--y-enter\",\n enterActive:\n \"rmd-scale-transition--enter-active rmd-scale-transition--y-enter-active\",\n enterDone: \"\",\n exit: \"rmd-scale-transition--exit rmd-scale-transition--y-exit\",\n exitActive:\n \"rmd-scale-transition--exit-active rmd-scale-transition--y-exit-active\",\n};\n\n/**\n * The default {@link TransitionTimeout} to use for horizontal and vertical\n * scale transitions.\n *\n * @remarks \\@since 2.0.0\n */\nexport const SCALE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n enter: 200,\n exit: 150,\n};\n\n/**\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface ScaleTransitionHookOptions<E extends HTMLElement>\n extends PreconfiguredCSSTransitionOptions<E> {\n /**\n * Boolean if the scale transition should be vertical instead of horizontal.\n * This really only changes the default value for the {@link classNames}.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n\n /**\n * @see {@link PreconfiguredCSSTransitionOptions.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @see {@link vertical}\n * @see {@link SCALE_CLASSNAMES}\n * @see {@link SCALE_Y_CLASSNAMES}\n * @defaultValue `vertical ? SCALE_Y_CLASSNAMES : SCALE_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n}\n\n/**\n * Implements a scale transition that should generally be used for temporary\n * elements that are positioned via `position: absolute` or `position: fixed`.\n *\n * @example\n * Dropdown Menu Example\n * ```tsx\n * import { ReactElement, useRef, useState } from \"react\";\n * import { Button, useFixedPositioning, useScaleTransition } from \"@react-md/core\";\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 * const { elementProps, rendered } = useScaleTransition({\n * ...transitionOptions,\n * transitionIn,\n * vertical: true,\n * });\n *\n * return (\n * <>\n * <Button ref={buttonRef} onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <div {...elementProps} style={style}>\n * Some content within a menu\n * </div>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useScaleTransition<E extends HTMLElement>(\n options: ScaleTransitionHookOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = SCALE_TIMEOUT,\n vertical = false,\n temporary = true,\n classNames = vertical ? SCALE_Y_CLASSNAMES : SCALE_CLASSNAMES,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n temporary,\n classNames,\n });\n}\n"],"names":["useCSSTransition","SCALE_CLASSNAMES","appear","appearActive","enter","enterActive","enterDone","exit","exitActive","SCALE_Y_CLASSNAMES","SCALE_TIMEOUT","useScaleTransition","options","timeout","vertical","temporary","classNames","transitionOptions"],"mappings":"AAAA;AAQA,SAASA,gBAAgB,QAAQ,wBAAwB;AAEzD;;;;;;;;CAQC,GACD,OAAO,MAAMC,mBAA4D;IACvEC,QAAQ;IACRC,cAAc;IACdC,OAAO;IACPC,aAAa;IACbC,WAAW;IACXC,MAAM;IACNC,YAAY;AACd,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAA8D;IACzEP,QAAQ;IACRC,cACE;IACFC,OAAO;IACPC,aACE;IACFC,WAAW;IACXC,MAAM;IACNC,YACE;AACJ,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,gBAAmD;IAC9DN,OAAO;IACPG,MAAM;AACR,EAAE;AAgCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,SAASI,mBACdC,OAAsC;IAEtC,MAAM,EACJC,UAAUH,aAAa,EACvBI,WAAW,KAAK,EAChBC,YAAY,IAAI,EAChBC,aAAaF,WAAWL,qBAAqBR,gBAAgB,EAC7D,GAAGgB,mBACJ,GAAGL;IAEJ,OAAOZ,iBAAiB;QACtB,GAAGiB,iBAAiB;QACpBJ;QACAE;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useScaleTransition.ts"],"sourcesContent":["\"use client\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeoutObject,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/**\n * The default {@link CSSTransitionClassNames} for a horizontal scale\n * transition.\n *\n * @remarks\n * \\@since 2.0.0\n * \\@since 6.0.0 The class names were updated to be prefixed with\n * `rmd-scale-transition`\n */\nexport const SCALE_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-scale-transition--enter\",\n appearActive: \"rmd-scale-transition--enter-active\",\n enter: \"rmd-scale-transition--enter\",\n enterActive: \"rmd-scale-transition--enter-active\",\n enterDone: \"\",\n exit: \"rmd-scale-transition--exit\",\n exitActive: \"rmd-scale-transition--exit-active\",\n};\n\n/**\n * The default {@link CSSTransitionClassNames} for a vertical scale transition.\n *\n * @remarks\n * \\@since 2.0.0\n * \\@since 6.0.0 The class names were updated to be prefixed with\n * `rmd-scale-y-transition` and merged with the {@link SCALE_CLASSNAMES}\n */\nexport const SCALE_Y_CLASSNAMES: Readonly<CSSTransitionClassNamesObject> = {\n appear: \"rmd-scale-transition--enter rmd-scale-transition--y-enter\",\n appearActive:\n \"rmd-scale-transition--enter-active rmd-scale-transition--y-enter-active\",\n enter: \"rmd-scale-transition--enter rmd-scale-transition--y-enter\",\n enterActive:\n \"rmd-scale-transition--enter-active rmd-scale-transition--y-enter-active\",\n enterDone: \"\",\n exit: \"rmd-scale-transition--exit rmd-scale-transition--y-exit\",\n exitActive:\n \"rmd-scale-transition--exit-active rmd-scale-transition--y-exit-active\",\n};\n\n/**\n * The default {@link TransitionTimeout} to use for horizontal and vertical\n * scale transitions.\n *\n * @remarks \\@since 2.0.0\n */\nexport const SCALE_TIMEOUT: Readonly<TransitionTimeoutObject> = {\n enter: 200,\n exit: 150,\n};\n\n/**\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport interface ScaleTransitionHookOptions<E extends HTMLElement>\n extends PreconfiguredCSSTransitionOptions<E> {\n /**\n * Boolean if the scale transition should be vertical instead of horizontal.\n * This really only changes the default value for the {@link classNames}.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n\n /**\n * @see {@link PreconfiguredCSSTransitionOptions.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @see {@link vertical}\n * @see {@link SCALE_CLASSNAMES}\n * @see {@link SCALE_Y_CLASSNAMES}\n * @defaultValue `vertical ? SCALE_Y_CLASSNAMES : SCALE_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n}\n\n/**\n * Implements a scale transition that should generally be used for temporary\n * elements that are positioned via `position: absolute` or `position: fixed`.\n *\n * @example\n * Dropdown Menu Example\n * ```tsx\n * import { ReactElement, useRef, useState } from \"react\";\n * import { Button, useFixedPositioning, useScaleTransition } from \"@react-md/core\";\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 * const { elementProps, rendered } = useScaleTransition({\n * ...transitionOptions,\n * transitionIn,\n * vertical: true,\n * });\n *\n * return (\n * <>\n * <Button ref={buttonRef} onClick={() => setTransitionIn(!transitionIn)}>\n * Toggle\n * </Button>\n * {rendered && (\n * <div {...elementProps} style={style}>\n * Some content within a menu\n * </div>\n * )}\n * </>\n * );\n * }\n * ```\n *\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useScaleTransition<E extends HTMLElement>(\n options: ScaleTransitionHookOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = SCALE_TIMEOUT,\n vertical = false,\n temporary = true,\n classNames = vertical ? SCALE_Y_CLASSNAMES : SCALE_CLASSNAMES,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n temporary,\n classNames,\n });\n}\n"],"names":["useCSSTransition","SCALE_CLASSNAMES","appear","appearActive","enter","enterActive","enterDone","exit","exitActive","SCALE_Y_CLASSNAMES","SCALE_TIMEOUT","useScaleTransition","options","timeout","vertical","temporary","classNames","transitionOptions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAQA,SAASA,gBAAgB,QAAQ,wBAAwB;AAEzD;;;;;;;;CAQC,GACD,OAAO,MAAMC,mBAA4D;IACvEC,QAAQ;IACRC,cAAc;IACdC,OAAO;IACPC,aAAa;IACbC,WAAW;IACXC,MAAM;IACNC,YAAY;AACd,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAA8D;IACzEP,QAAQ;IACRC,cACE;IACFC,OAAO;IACPC,aACE;IACFC,WAAW;IACXC,MAAM;IACNC,YACE;AACJ,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,gBAAmD;IAC9DN,OAAO;IACPG,MAAM;AACR,EAAE;AAgCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,SAASI,mBACdC,OAAsC;IAEtC,MAAM,EACJC,UAAUH,aAAa,EACvBI,WAAW,KAAK,EAChBC,YAAY,IAAI,EAChBC,aAAaF,WAAWL,qBAAqBR,gBAAgB,EAC7D,GAAGgB,mBACJ,GAAGL;IAEJ,OAAOZ,iBAAiB;QACtB,GAAGiB,iBAAiB;QACpBJ;QACAE;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useSkeletonPlaceholder.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { useEffect, useState, type CSSProperties } from \"react\";\nimport { useSsr } from \"../SsrProvider.js\";\nimport {\n randomSkeletonPlaceholder,\n skeletonPlaceholder,\n type SkeletonPlaceholderRandomOptions,\n} from \"./skeletonPlaceholderUtils.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport interface SkeletonPlaceholderOptions\n extends SkeletonPlaceholderRandomOptions {\n style?: CSSProperties;\n className?: string;\n\n /**\n * Set this to a custom `animation-delay` value (should be in milliseconds).\n *\n * @example\n * ```ts\n * delay=\"200ms\"\n * ```\n */\n delay?: string;\n\n /**\n * Set this value tp a number or length unit string to set the height with\n * inline styles.\n *\n * If this is `undefined`, it will use the skeleton placeholder CSS variable\n * value instead which defaults to `1.125em`\n *\n * @defaultValue `undefined`\n */\n height?: string | number;\n\n /**\n * A custom width to apply to the skeleton placeholder.\n *\n * Set this value to an empty string if you want to control the width through\n * SCSS.\n *\n * @example\n * No Inline Width CSS\n * ```scss\n * @use \"@react-md/core\";\n *\n * .customStyles {\n * // You could use these mixins on a parent element instead which would\n * // set the height and width to all skeleton placeholders that appear as a\n * // child instead\n * // @include core.transition-set-var(skeleton-placeholder-height, 1.5rem);\n * // @include core.transition-set-var(skeleton-placeholder-width, 40%);\n *\n * height: 1,5rem;\n * width: 40%;\n * }\n * ```\n *\n * @example\n * No Inline Width\n * ```ts\n * import type { ReactElement } from \"@react\";\n * import { useSkeletonPlaceholder } from \"@react-md/core\";\n *\n * import styles from \"./MyComponent.module.scss\";\n *\n * export function Example(): ReactElement {\n * const skeletonProps = useSkeletonPlaceholder({\n * width: null,\n * className: styles.customStyles,\n * });\n *\n * return <div {...skeletonProps} />;\n * }\n * ```\n *\n *\n * Set this value to a number or length unit string to set the width with\n * inline styles.\n *\n * @example\n * Custom Inline Width\n * ```ts\n * import type { ReactElement } from \"@react\";\n * import { useSkeletonPlaceholder } from \"@react-md/core\";\n *\n * export function Example(): ReactElement {\n * const skeletonProps = useSkeletonPlaceholder({\n * // any of these are valid\n * // width: 40,\n * // width: \"1rem\",\n * // width: \"1vh\",\n * // width: \"40%\",\n * width: \"1rem\",\n * });\n *\n * return <div {...skeletonProps} />;\n * }\n * ```\n *\n * If this value is `undefined`, a random percentage will be generated instead\n * using the {@link minPercentage} and {@link maxPercentage} options.\n *\n * Set this value to `null` if the size should be derived from the provided\n * `className` instead.\n *\n * @defaultValue `randomInt({ min: minPercentage, max: maxPercentage })%`\n */\n width?: number | string | null;\n\n /**\n * Settings this to `true` will prevent any of the skeleton placeholder styles\n * to be applied. This is really only useful if you can prerender parts of\n * your layout while waiting for the data to load.\n *\n * @example\n * Pre-rendered Layout\n * ```tsx\n * import type { ReactElement } from \"@react\";\n * import { SkeletonPlaceholder } from \"@react-md/core\";\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 gridClassName=\"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 * @defaultValue `false`\n */\n disabled?: boolean;\n}\n\nexport interface SkeletonPlaceholderStylingProps {\n style?: CSSProperties;\n className: string;\n}\n\nexport function useSkeletonPlaceholder(\n options: SkeletonPlaceholderOptions = {}\n): SkeletonPlaceholderStylingProps {\n const {\n style: propStyle,\n className,\n height,\n width: propWidth,\n disabled = false,\n delay: propDelay,\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n } = options;\n const ssr = useSsr();\n\n const isDefinedWidth = typeof propWidth !== \"undefined\";\n const isDefinedDelay = typeof propDelay !== \"undefined\";\n const [randomStyles, setRandomStyles] = useState<CSSProperties>(() => {\n if (typeof window === \"undefined\" || ssr || disabled) {\n return {};\n }\n\n return randomSkeletonPlaceholder({\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n });\n });\n\n useEffect(() => {\n if (!ssr || disabled || (isDefinedDelay && isDefinedWidth)) {\n return;\n }\n\n setRandomStyles(\n randomSkeletonPlaceholder({\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n })\n );\n }, [\n disabled,\n isDefinedDelay,\n isDefinedWidth,\n maxDelay,\n maxPercentage,\n minDelay,\n minPercentage,\n ssr,\n ]);\n\n let width = propWidth;\n let animationDelay = propDelay;\n if (!disabled) {\n if (!isDefinedDelay) {\n ({ animationDelay } = randomStyles);\n }\n if (!isDefinedWidth) {\n ({ width } = randomStyles);\n }\n }\n\n let style: CSSProperties | undefined = propStyle;\n if (!!width || !!animationDelay || typeof height !== \"undefined\") {\n style = {\n ...style,\n height: height ?? style?.height,\n width: width ?? style?.width,\n // Note: not including MozAnimationDelay and WebkitAnimationDelay since\n // they weren't applied when they were set. Probably no longer required?\n animationDelay: animationDelay ?? style?.animationDelay,\n };\n }\n\n return {\n style,\n className: cnb(className, !disabled && skeletonPlaceholder()),\n };\n}\n"],"names":["cnb","useEffect","useState","useSsr","randomSkeletonPlaceholder","skeletonPlaceholder","useSkeletonPlaceholder","options","style","propStyle","className","height","width","propWidth","disabled","delay","propDelay","minDelay","maxDelay","minPercentage","maxPercentage","ssr","isDefinedWidth","isDefinedDelay","randomStyles","setRandomStyles","window","animationDelay"],"mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,SAAS,EAAEC,QAAQ,QAA4B,QAAQ;AAChE,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SACEC,yBAAyB,EACzBC,mBAAmB,QAEd,gCAAgC;AAuMvC,OAAO,SAASC,uBACdC,UAAsC,CAAC,CAAC;IAExC,MAAM,EACJC,OAAOC,SAAS,EAChBC,SAAS,EACTC,MAAM,EACNC,OAAOC,SAAS,EAChBC,WAAW,KAAK,EAChBC,OAAOC,SAAS,EAChBC,QAAQ,EACRC,QAAQ,EACRC,aAAa,EACbC,aAAa,EACd,GAAGb;IACJ,MAAMc,MAAMlB;IAEZ,MAAMmB,iBAAiB,OAAOT,cAAc;IAC5C,MAAMU,iBAAiB,OAAOP,cAAc;IAC5C,MAAM,CAACQ,cAAcC,gBAAgB,GAAGvB,SAAwB;QAC9D,IAAI,OAAOwB,WAAW,eAAeL,OAAOP,UAAU;YACpD,OAAO,CAAC;QACV;QAEA,OAAOV,0BAA0B;YAC/Ba;YACAC;YACAC;YACAC;QACF;IACF;IAEAnB,UAAU;QACR,IAAI,CAACoB,OAAOP,YAAaS,kBAAkBD,gBAAiB;YAC1D;QACF;QAEAG,gBACErB,0BAA0B;YACxBa;YACAC;YACAC;YACAC;QACF;IAEJ,GAAG;QACDN;QACAS;QACAD;QACAJ;QACAE;QACAH;QACAE;QACAE;KACD;IAED,IAAIT,QAAQC;IACZ,IAAIc,iBAAiBX;IACrB,IAAI,CAACF,UAAU;QACb,IAAI,CAACS,gBAAgB;YAClB,CAAA,EAAEI,cAAc,EAAE,GAAGH,YAAW;QACnC;QACA,IAAI,CAACF,gBAAgB;YAClB,CAAA,EAAEV,KAAK,EAAE,GAAGY,YAAW;QAC1B;IACF;IAEA,IAAIhB,QAAmCC;IACvC,IAAI,CAAC,CAACG,SAAS,CAAC,CAACe,kBAAkB,OAAOhB,WAAW,aAAa;QAChEH,QAAQ;YACN,GAAGA,KAAK;YACRG,QAAQA,UAAUH,OAAOG;YACzBC,OAAOA,SAASJ,OAAOI;YACvB,uEAAuE;YACvE,wEAAwE;YACxEe,gBAAgBA,kBAAkBnB,OAAOmB;QAC3C;IACF;IAEA,OAAO;QACLnB;QACAE,WAAWV,IAAIU,WAAW,CAACI,YAAYT;IACzC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useSkeletonPlaceholder.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { useEffect, useState, type CSSProperties } from \"react\";\nimport { useSsr } from \"../SsrProvider.js\";\nimport {\n randomSkeletonPlaceholder,\n skeletonPlaceholder,\n type SkeletonPlaceholderRandomOptions,\n} from \"./skeletonPlaceholderUtils.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport interface SkeletonPlaceholderOptions\n extends SkeletonPlaceholderRandomOptions {\n style?: CSSProperties;\n className?: string;\n\n /**\n * Set this to a custom `animation-delay` value (should be in milliseconds).\n *\n * @example\n * ```ts\n * delay=\"200ms\"\n * ```\n */\n delay?: string;\n\n /**\n * Set this value tp a number or length unit string to set the height with\n * inline styles.\n *\n * If this is `undefined`, it will use the skeleton placeholder CSS variable\n * value instead which defaults to `1.125em`\n *\n * @defaultValue `undefined`\n */\n height?: string | number;\n\n /**\n * A custom width to apply to the skeleton placeholder.\n *\n * Set this value to an empty string if you want to control the width through\n * SCSS.\n *\n * @example\n * No Inline Width CSS\n * ```scss\n * @use \"@react-md/core\";\n *\n * .customStyles {\n * // You could use these mixins on a parent element instead which would\n * // set the height and width to all skeleton placeholders that appear as a\n * // child instead\n * // @include core.transition-set-var(skeleton-placeholder-height, 1.5rem);\n * // @include core.transition-set-var(skeleton-placeholder-width, 40%);\n *\n * height: 1,5rem;\n * width: 40%;\n * }\n * ```\n *\n * @example\n * No Inline Width\n * ```ts\n * import type { ReactElement } from \"@react\";\n * import { useSkeletonPlaceholder } from \"@react-md/core\";\n *\n * import styles from \"./MyComponent.module.scss\";\n *\n * export function Example(): ReactElement {\n * const skeletonProps = useSkeletonPlaceholder({\n * width: null,\n * className: styles.customStyles,\n * });\n *\n * return <div {...skeletonProps} />;\n * }\n * ```\n *\n *\n * Set this value to a number or length unit string to set the width with\n * inline styles.\n *\n * @example\n * Custom Inline Width\n * ```ts\n * import type { ReactElement } from \"@react\";\n * import { useSkeletonPlaceholder } from \"@react-md/core\";\n *\n * export function Example(): ReactElement {\n * const skeletonProps = useSkeletonPlaceholder({\n * // any of these are valid\n * // width: 40,\n * // width: \"1rem\",\n * // width: \"1vh\",\n * // width: \"40%\",\n * width: \"1rem\",\n * });\n *\n * return <div {...skeletonProps} />;\n * }\n * ```\n *\n * If this value is `undefined`, a random percentage will be generated instead\n * using the {@link minPercentage} and {@link maxPercentage} options.\n *\n * Set this value to `null` if the size should be derived from the provided\n * `className` instead.\n *\n * @defaultValue `randomInt({ min: minPercentage, max: maxPercentage })%`\n */\n width?: number | string | null;\n\n /**\n * Settings this to `true` will prevent any of the skeleton placeholder styles\n * to be applied. This is really only useful if you can prerender parts of\n * your layout while waiting for the data to load.\n *\n * @example\n * Pre-rendered Layout\n * ```tsx\n * import type { ReactElement } from \"@react\";\n * import { SkeletonPlaceholder } from \"@react-md/core\";\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 gridClassName=\"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 * @defaultValue `false`\n */\n disabled?: boolean;\n}\n\nexport interface SkeletonPlaceholderStylingProps {\n style?: CSSProperties;\n className: string;\n}\n\nexport function useSkeletonPlaceholder(\n options: SkeletonPlaceholderOptions = {}\n): SkeletonPlaceholderStylingProps {\n const {\n style: propStyle,\n className,\n height,\n width: propWidth,\n disabled = false,\n delay: propDelay,\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n } = options;\n const ssr = useSsr();\n\n const isDefinedWidth = typeof propWidth !== \"undefined\";\n const isDefinedDelay = typeof propDelay !== \"undefined\";\n const [randomStyles, setRandomStyles] = useState<CSSProperties>(() => {\n if (typeof window === \"undefined\" || ssr || disabled) {\n return {};\n }\n\n return randomSkeletonPlaceholder({\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n });\n });\n\n useEffect(() => {\n if (!ssr || disabled || (isDefinedDelay && isDefinedWidth)) {\n return;\n }\n\n setRandomStyles(\n randomSkeletonPlaceholder({\n minDelay,\n maxDelay,\n minPercentage,\n maxPercentage,\n })\n );\n }, [\n disabled,\n isDefinedDelay,\n isDefinedWidth,\n maxDelay,\n maxPercentage,\n minDelay,\n minPercentage,\n ssr,\n ]);\n\n let width = propWidth;\n let animationDelay = propDelay;\n if (!disabled) {\n if (!isDefinedDelay) {\n ({ animationDelay } = randomStyles);\n }\n if (!isDefinedWidth) {\n ({ width } = randomStyles);\n }\n }\n\n let style: CSSProperties | undefined = propStyle;\n if (!!width || !!animationDelay || typeof height !== \"undefined\") {\n style = {\n ...style,\n height: height ?? style?.height,\n width: width ?? style?.width,\n // Note: not including MozAnimationDelay and WebkitAnimationDelay since\n // they weren't applied when they were set. Probably no longer required?\n animationDelay: animationDelay ?? style?.animationDelay,\n };\n }\n\n return {\n style,\n className: cnb(className, !disabled && skeletonPlaceholder()),\n };\n}\n"],"names":["cnb","useEffect","useState","useSsr","randomSkeletonPlaceholder","skeletonPlaceholder","useSkeletonPlaceholder","options","style","propStyle","className","height","width","propWidth","disabled","delay","propDelay","minDelay","maxDelay","minPercentage","maxPercentage","ssr","isDefinedWidth","isDefinedDelay","randomStyles","setRandomStyles","window","animationDelay"],"rangeM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AS,CAAC,CAACe,kBAAkB,OAAOhB,WAAW,aAAa;QAChEH,QAAQ;YACN,GAAGA,KAAK;YACRG,QAAQA,UAAUH,OAAOG;YACzBC,OAAOA,SAASJ,OAAOI;YACvB,uEAAuE;YACvE,wEAAwE;YACxEe,gBAAgBA,kBAAkBnB,OAAOmB;QAC3C;IACF;IAEA,OAAO;QACLnB;QACAE,WAAWV,IAAIU,WAAW,CAACI,YAAYT;IACzC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useSlideTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeout,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_TIMEOUT: Readonly<TransitionTimeout> = 150;\n\n/** @remarks \\@since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_CLASSNAMES: Readonly<CSSTransitionClassNames> =\n {\n enter: \"rmd-slide--enter\",\n enterActive: \"rmd-slide--enter-active rmd-slide--animate\",\n exit: \"rmd-slide--exit\",\n exitActive: \"rmd-slide--exit-active rmd-slide--animate\",\n };\n\n/** @remarks \\@since 6.0.0 */\nexport type SlideTransitionOptions<E extends HTMLElement> =\n PreconfiguredCSSTransitionOptions<E>;\n\n/**\n * @example\n * Simple Example\n * ```tsx\n * import type { SlideDirection } from \"@react-md/core\";\n * import { slideContainer, useSlideTransition } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useState } from \"react\";\n *\n * interface SlideProps {\n * active: boolean;\n * children: ReactNode;\n * }\n *\n * function Slide({ active, children }: SlideProps): ReactElement | null {\n * const { rendered, elementProps } = useSlideTransition({\n * transition: active,\n * });\n *\n * if (!rendered) {\n * return null;\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n * }\n *\n * interface State {\n * direction: SlideDirection;\n * activeIndex: number;\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * direction: \"left\",\n * activeIndex: 0,\n * });\n * const { direction, activeIndex } = state\n *\n * // when changing a slide, `direction` should be set to \"left\" if the\n * // previous `activeIndex` is less than the next index\n * //\n * // i.e.\n * // setState((prevState) => ({\n * // direction: prevState.activeIndex < index ? \"left\" : \"right\",\n * // activeIndex: index,\n * // }))\n *\n * return (\n * <div className={slideContainer({ 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 * </div>\n * );\n * }\n * ```\n *\n * @see {@link SlideContainer} and {@link Slide} for convenient default\n * implementations.\n * @remarks \\@since 6.0.0\n */\nexport function useSlideTransition<E extends HTMLElement>(\n options: SlideTransitionOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n className,\n temporary = false,\n exitedHidden = true,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n className: cnb(\"rmd-slide\", className),\n classNames: DEFAULT_SLIDE_TRANSITION_CLASSNAMES,\n temporary,\n exitedHidden,\n });\n}\n"],"names":["cnb","useCSSTransition","DEFAULT_SLIDE_TRANSITION_TIMEOUT","DEFAULT_SLIDE_TRANSITION_CLASSNAMES","enter","enterActive","exit","exitActive","useSlideTransition","options","timeout","className","temporary","exitedHidden","transitionOptions","classNames"],"mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAOhC,SAASC,gBAAgB,QAAQ,wBAAwB;AAEzD,2BAA2B,GAC3B,OAAO,MAAMC,mCAAgE,IAAI;AAEjF,2BAA2B,GAC3B,OAAO,MAAMC,sCACX;IACEC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;AACd,EAAE;AAMJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEC,GACD,OAAO,SAASC,mBACdC,OAAkC;IAElC,MAAM,EACJC,UAAUR,gCAAgC,EAC1CS,SAAS,EACTC,YAAY,KAAK,EACjBC,eAAe,IAAI,EACnB,GAAGC,mBACJ,GAAGL;IAEJ,OAAOR,iBAAiB;QACtB,GAAGa,iBAAiB;QACpBJ;QACAC,WAAWX,IAAI,aAAaW;QAC5BI,YAAYZ;QACZS;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useSlideTransition.ts"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport type {\n CSSTransitionClassNames,\n CSSTransitionHookReturnValue,\n PreconfiguredCSSTransitionOptions,\n TransitionTimeout,\n} from \"./types.js\";\nimport { useCSSTransition } from \"./useCSSTransition.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_TIMEOUT: Readonly<TransitionTimeout> = 150;\n\n/** @remarks \\@since 6.0.0 */\nexport const DEFAULT_SLIDE_TRANSITION_CLASSNAMES: Readonly<CSSTransitionClassNames> =\n {\n enter: \"rmd-slide--enter\",\n enterActive: \"rmd-slide--enter-active rmd-slide--animate\",\n exit: \"rmd-slide--exit\",\n exitActive: \"rmd-slide--exit-active rmd-slide--animate\",\n };\n\n/** @remarks \\@since 6.0.0 */\nexport type SlideTransitionOptions<E extends HTMLElement> =\n PreconfiguredCSSTransitionOptions<E>;\n\n/**\n * @example\n * Simple Example\n * ```tsx\n * import type { SlideDirection } from \"@react-md/core\";\n * import { slideContainer, useSlideTransition } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useState } from \"react\";\n *\n * interface SlideProps {\n * active: boolean;\n * children: ReactNode;\n * }\n *\n * function Slide({ active, children }: SlideProps): ReactElement | null {\n * const { rendered, elementProps } = useSlideTransition({\n * transition: active,\n * });\n *\n * if (!rendered) {\n * return null;\n * }\n *\n * return <div {...elementProps}>{children}</div>;\n * }\n *\n * interface State {\n * direction: SlideDirection;\n * activeIndex: number;\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * direction: \"left\",\n * activeIndex: 0,\n * });\n * const { direction, activeIndex } = state\n *\n * // when changing a slide, `direction` should be set to \"left\" if the\n * // previous `activeIndex` is less than the next index\n * //\n * // i.e.\n * // setState((prevState) => ({\n * // direction: prevState.activeIndex < index ? \"left\" : \"right\",\n * // activeIndex: index,\n * // }))\n *\n * return (\n * <div className={slideContainer({ 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 * </div>\n * );\n * }\n * ```\n *\n * @see {@link SlideContainer} and {@link Slide} for convenient default\n * implementations.\n * @remarks \\@since 6.0.0\n */\nexport function useSlideTransition<E extends HTMLElement>(\n options: SlideTransitionOptions<E>\n): CSSTransitionHookReturnValue<E> {\n const {\n timeout = DEFAULT_SLIDE_TRANSITION_TIMEOUT,\n className,\n temporary = false,\n exitedHidden = true,\n ...transitionOptions\n } = options;\n\n return useCSSTransition({\n ...transitionOptions,\n timeout,\n className: cnb(\"rmd-slide\", className),\n classNames: DEFAULT_SLIDE_TRANSITION_CLASSNAMES,\n temporary,\n exitedHidden,\n });\n}\n"],"names":["cnb","useCSSTransition","DEFAULT_SLIDE_TRANSITION_TIMEOUT","DEFAULT_SLIDE_TRANSITION_CLASSNAMES","enter","enterActive","exit","exitActive","useSlideTransition","options","timeout","className","temporary","exitedHidden","transitionOptions","classNames"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,GAAG,QAAQ,YAAY;AAOhC,SAASC,gBAAgB,QAAQ,wBAAwB;AAEzD,2BAA2B,GAC3B,OAAO,MAAMC,mCAAgE,IAAI;AAEjF,2BAA2B,GAC3B,OAAO,MAAMC,sCACX;IACEC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,YAAY;AACd,EAAE;AAMJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEC,GACD,OAAO,SAASC,mBACdC,OAAkC;IAElC,MAAM,EACJC,UAAUR,gCAAgC,EAC1CS,SAAS,EACTC,YAAY,KAAK,EACjBC,eAAe,IAAI,EACnB,GAAGC,mBACJ,GAAGL;IAEJ,OAAOR,iBAAiB;QACtB,GAAGa,iBAAiB;QACpBJ;QACAC,WAAWX,IAAI,aAAaW;QAC5BI,YAAYZ;QACZS;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/useTransition.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useReducer, useRef, useState } from \"react\";\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport type {\n TransitionHookOptions,\n TransitionHookReturnValue,\n TransitionStage,\n TransitionState,\n} from \"./types.js\";\nimport { getTransitionTimeout } from \"./utils.js\";\nimport { TRANSITION_CONFIG } from \"./config.js\";\n\nconst INITIAL_STATE: TransitionState = {\n appearing: false,\n rendered: true,\n stage: \"exited\",\n};\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * You'll most likely want to use the {@link useCSSTransition} hook instead\n * since this is just a low-level hook that can be used to transition using\n * timeouts.\n *\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useTransition<E extends HTMLElement>(\n options: TransitionHookOptions<E>\n): TransitionHookReturnValue<E> {\n const {\n nodeRef,\n timeout,\n transitionIn,\n reflow = false,\n temporary = false,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n disablePortal: propDisablePortal,\n } = options;\n\n const configurationRef = useRef({\n timeout: getTransitionTimeout({ timeout, appear, enter, exit }),\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n } as const);\n useIsomorphicLayoutEffect(() => {\n configurationRef.current = {\n timeout: getTransitionTimeout({ timeout, appear, enter, exit }),\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n };\n }, [\n appear,\n enter,\n exit,\n onEnter,\n onEntered,\n onEntering,\n onExit,\n onExited,\n onExiting,\n reflow,\n timeout,\n ]);\n\n const ssr = useSsr();\n const [ref, refCallback] = useEnsuredRef<E>(nodeRef);\n const [disablePortal, setDisablePortal] = useState(ssr);\n const [state, dispatch] = useReducer(\n function reducer(\n state: TransitionState,\n action: TransitionStage | \"unmount\"\n ): TransitionState {\n const { appear, enter, exit } = configurationRef.current.timeout;\n const { appearing } = state;\n switch (action) {\n case \"enter\": {\n const duration = appearing ? appear : enter;\n return {\n stage: duration > 0 ? \"enter\" : \"entered\",\n rendered: true,\n appearing,\n };\n }\n case \"entering\":\n case \"entered\":\n return {\n stage: action,\n rendered: true,\n appearing,\n };\n case \"exit\": {\n const stage = exit > 0 ? \"exit\" : \"exited\";\n return {\n stage,\n rendered: !temporary || stage !== \"exited\",\n appearing: false,\n };\n }\n case \"exiting\":\n case \"exited\":\n return {\n stage: action,\n rendered: true,\n appearing: false,\n };\n case \"unmount\":\n if (state.stage === \"exited\" && !state.appearing && !state.rendered) {\n return state;\n }\n\n return {\n stage: \"exited\",\n rendered: false,\n appearing: false,\n };\n }\n },\n INITIAL_STATE,\n () => {\n let stage: TransitionStage = \"exited\";\n if (transitionIn) {\n stage = appear && !TRANSITION_CONFIG.disabled ? \"enter\" : \"entered\";\n }\n\n return {\n appearing: appear && transitionIn && !TRANSITION_CONFIG.disabled,\n rendered: !temporary || transitionIn,\n stage,\n };\n }\n );\n const { appearing, rendered, stage } = state;\n\n const isFirstRender = useRef(true);\n const isRehydrateAppear = useRef(ssr && !transitionIn);\n const defaultTransitionIn = useRef(transitionIn);\n useEffect(() => {\n const {\n timeout,\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n } = configurationRef.current;\n let { onExited } = configurationRef.current;\n if (isFirstRender.current) {\n // The exited hook should **not** fire on first render since the element\n // was never in the DOM.\n isFirstRender.current = false;\n onExited = noop;\n }\n\n // if the transitionIn did not change between initial render and rehydration,\n // allow the enter transition to behave like normal.\n if (\n isRehydrateAppear.current &&\n !ssr &&\n !transitionIn &&\n !defaultTransitionIn.current\n ) {\n isRehydrateAppear.current = false;\n }\n\n // Cancel any exiting/exited transitions and instead immediately start the\n // enter transition\n if (transitionIn && stage.startsWith(\"exit\")) {\n const nextStage = isRehydrateAppear.current ? \"entered\" : \"enter\";\n dispatch(nextStage);\n return;\n }\n\n // Cancel any entering/entered transitions and instead immediately start the\n // exit transition\n if (!transitionIn && stage.startsWith(\"enter\")) {\n dispatch(\"exit\");\n return;\n }\n\n if (reflow && ref.current && stage !== \"exited\" && stage !== \"entered\") {\n // force reflow by accessing scrollTop\n ref.current.scrollTop;\n }\n\n let duration = 0;\n let nextStage: TransitionStage = stage;\n switch (stage) {\n case \"enter\":\n if (TRANSITION_CONFIG.disabled) {\n nextStage = \"entered\";\n } else {\n onEnter(appearing);\n nextStage = \"entering\";\n }\n break;\n case \"entering\":\n onEntering(appearing);\n duration = timeout.enter;\n nextStage = \"entered\";\n break;\n case \"entered\":\n onEntered(appearing);\n break;\n case \"exit\":\n if (TRANSITION_CONFIG.disabled) {\n nextStage = \"exited\";\n } else {\n onExit();\n nextStage = \"exiting\";\n }\n break;\n case \"exiting\":\n onExiting();\n duration = timeout.exit;\n nextStage = \"exited\";\n break;\n case \"exited\":\n onExited();\n setDisablePortal(false);\n break;\n }\n\n if (stage === nextStage) {\n // this is used to help catch changing the temporary prop.\n // not sure if I should really support that though...\n if (stage === \"exited\" && temporary) {\n dispatch(\"unmount\");\n }\n\n return;\n }\n\n // I used to rely on the `dispatch(\"unmount\")` above, but it seems like\n // there are some cases where re-rendering takes too long so the temporary\n // element flashes\n const dispatchStage =\n temporary && nextStage === \"exited\" ? \"unmount\" : nextStage;\n if (duration <= 0) {\n dispatch(dispatchStage);\n return;\n }\n\n const timer = window.setTimeout(() => {\n dispatch(dispatchStage);\n }, duration);\n\n return () => {\n window.clearTimeout(timer);\n };\n }, [appearing, ref, ssr, stage, temporary, transitionIn]);\n\n return {\n ref: refCallback,\n stage,\n rendered,\n appearing,\n transitionTo: dispatch,\n disablePortal: propDisablePortal || disablePortal,\n };\n}\n"],"names":["useEffect","useReducer","useRef","useState","useSsr","useEnsuredRef","useIsomorphicLayoutEffect","getTransitionTimeout","TRANSITION_CONFIG","INITIAL_STATE","appearing","rendered","stage","noop","useTransition","options","nodeRef","timeout","transitionIn","reflow","temporary","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","disablePortal","propDisablePortal","configurationRef","current","ssr","ref","refCallback","setDisablePortal","state","dispatch","reducer","action","duration","disabled","isFirstRender","isRehydrateAppear","defaultTransitionIn","startsWith","nextStage","scrollTop","dispatchStage","timer","window","setTimeout","clearTimeout","transitionTo"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,yBAAyB,QAAQ,kCAAkC;AAO5E,SAASC,oBAAoB,QAAQ,aAAa;AAClD,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,MAAMC,gBAAiC;IACrCC,WAAW;IACXC,UAAU;IACVC,OAAO;AACT;AAEA,MAAMC,OAAO;AACX,aAAa;AACf;AAEA;;;;;;;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AYA;QACpD,IAAIN,YAAY,GAAG;YACjBH,SAASW;YACT;QACF;QAEA,MAAMC,QAAQC,OAAOC,UAAU,CAAC;YAC9Bd,SAASW;QACX,GAAGR;QAEH,OAAO;YACLU,OAAOE,YAAY,CAACH;QACtB;IACF,GAAG;QAACzC;QAAWyB;QAAKD;QAAKtB;QAAOQ;QAAWF;KAAa;IAExD,OAAO;QACLiB,KAAKC;QACLxB;QACAD;QACAD;QACA6C,cAAchB;QACdT,eAAeC,qBAAqBD;IACtC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/useTransition.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useReducer, useRef, useState } from \"react\";\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport type {\n TransitionHookOptions,\n TransitionHookReturnValue,\n TransitionStage,\n TransitionState,\n} from \"./types.js\";\nimport { getTransitionTimeout } from \"./utils.js\";\nimport { TRANSITION_CONFIG } from \"./config.js\";\n\nconst INITIAL_STATE: TransitionState = {\n appearing: false,\n rendered: true,\n stage: \"exited\",\n};\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * You'll most likely want to use the {@link useCSSTransition} hook instead\n * since this is just a low-level hook that can be used to transition using\n * timeouts.\n *\n * @typeParam E - The HTMLElement type used or the ref required for the\n * transition.\n * @remarks \\@since 4.0.0\n */\nexport function useTransition<E extends HTMLElement>(\n options: TransitionHookOptions<E>\n): TransitionHookReturnValue<E> {\n const {\n nodeRef,\n timeout,\n transitionIn,\n reflow = false,\n temporary = false,\n appear = false,\n enter = true,\n exit = true,\n onEnter = noop,\n onEntering = noop,\n onEntered = noop,\n onExit = noop,\n onExiting = noop,\n onExited = noop,\n disablePortal: propDisablePortal,\n } = options;\n\n const configurationRef = useRef({\n timeout: getTransitionTimeout({ timeout, appear, enter, exit }),\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n } as const);\n useIsomorphicLayoutEffect(() => {\n configurationRef.current = {\n timeout: getTransitionTimeout({ timeout, appear, enter, exit }),\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n };\n }, [\n appear,\n enter,\n exit,\n onEnter,\n onEntered,\n onEntering,\n onExit,\n onExited,\n onExiting,\n reflow,\n timeout,\n ]);\n\n const ssr = useSsr();\n const [ref, refCallback] = useEnsuredRef<E>(nodeRef);\n const [disablePortal, setDisablePortal] = useState(ssr);\n const [state, dispatch] = useReducer(\n function reducer(\n state: TransitionState,\n action: TransitionStage | \"unmount\"\n ): TransitionState {\n const { appear, enter, exit } = configurationRef.current.timeout;\n const { appearing } = state;\n switch (action) {\n case \"enter\": {\n const duration = appearing ? appear : enter;\n return {\n stage: duration > 0 ? \"enter\" : \"entered\",\n rendered: true,\n appearing,\n };\n }\n case \"entering\":\n case \"entered\":\n return {\n stage: action,\n rendered: true,\n appearing,\n };\n case \"exit\": {\n const stage = exit > 0 ? \"exit\" : \"exited\";\n return {\n stage,\n rendered: !temporary || stage !== \"exited\",\n appearing: false,\n };\n }\n case \"exiting\":\n case \"exited\":\n return {\n stage: action,\n rendered: true,\n appearing: false,\n };\n case \"unmount\":\n if (state.stage === \"exited\" && !state.appearing && !state.rendered) {\n return state;\n }\n\n return {\n stage: \"exited\",\n rendered: false,\n appearing: false,\n };\n }\n },\n INITIAL_STATE,\n () => {\n let stage: TransitionStage = \"exited\";\n if (transitionIn) {\n stage = appear && !TRANSITION_CONFIG.disabled ? \"enter\" : \"entered\";\n }\n\n return {\n appearing: appear && transitionIn && !TRANSITION_CONFIG.disabled,\n rendered: !temporary || transitionIn,\n stage,\n };\n }\n );\n const { appearing, rendered, stage } = state;\n\n const isFirstRender = useRef(true);\n const isRehydrateAppear = useRef(ssr && !transitionIn);\n const defaultTransitionIn = useRef(transitionIn);\n useEffect(() => {\n const {\n timeout,\n reflow,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n } = configurationRef.current;\n let { onExited } = configurationRef.current;\n if (isFirstRender.current) {\n // The exited hook should **not** fire on first render since the element\n // was never in the DOM.\n isFirstRender.current = false;\n onExited = noop;\n }\n\n // if the transitionIn did not change between initial render and rehydration,\n // allow the enter transition to behave like normal.\n if (\n isRehydrateAppear.current &&\n !ssr &&\n !transitionIn &&\n !defaultTransitionIn.current\n ) {\n isRehydrateAppear.current = false;\n }\n\n // Cancel any exiting/exited transitions and instead immediately start the\n // enter transition\n if (transitionIn && stage.startsWith(\"exit\")) {\n const nextStage = isRehydrateAppear.current ? \"entered\" : \"enter\";\n dispatch(nextStage);\n return;\n }\n\n // Cancel any entering/entered transitions and instead immediately start the\n // exit transition\n if (!transitionIn && stage.startsWith(\"enter\")) {\n dispatch(\"exit\");\n return;\n }\n\n if (reflow && ref.current && stage !== \"exited\" && stage !== \"entered\") {\n // force reflow by accessing scrollTop\n ref.current.scrollTop;\n }\n\n let duration = 0;\n let nextStage: TransitionStage = stage;\n switch (stage) {\n case \"enter\":\n if (TRANSITION_CONFIG.disabled) {\n nextStage = \"entered\";\n } else {\n onEnter(appearing);\n nextStage = \"entering\";\n }\n break;\n case \"entering\":\n onEntering(appearing);\n duration = timeout.enter;\n nextStage = \"entered\";\n break;\n case \"entered\":\n onEntered(appearing);\n break;\n case \"exit\":\n if (TRANSITION_CONFIG.disabled) {\n nextStage = \"exited\";\n } else {\n onExit();\n nextStage = \"exiting\";\n }\n break;\n case \"exiting\":\n onExiting();\n duration = timeout.exit;\n nextStage = \"exited\";\n break;\n case \"exited\":\n onExited();\n setDisablePortal(false);\n break;\n }\n\n if (stage === nextStage) {\n // this is used to help catch changing the temporary prop.\n // not sure if I should really support that though...\n if (stage === \"exited\" && temporary) {\n dispatch(\"unmount\");\n }\n\n return;\n }\n\n // I used to rely on the `dispatch(\"unmount\")` above, but it seems like\n // there are some cases where re-rendering takes too long so the temporary\n // element flashes\n const dispatchStage =\n temporary && nextStage === \"exited\" ? \"unmount\" : nextStage;\n if (duration <= 0) {\n dispatch(dispatchStage);\n return;\n }\n\n const timer = window.setTimeout(() => {\n dispatch(dispatchStage);\n }, duration);\n\n return () => {\n window.clearTimeout(timer);\n };\n }, [appearing, ref, ssr, stage, temporary, transitionIn]);\n\n return {\n ref: refCallback,\n stage,\n rendered,\n appearing,\n transitionTo: dispatch,\n disablePortal: propDisablePortal || disablePortal,\n };\n}\n"],"names":["useEffect","useReducer","useRef","useState","useSsr","useEnsuredRef","useIsomorphicLayoutEffect","getTransitionTimeout","TRANSITION_CONFIG","INITIAL_STATE","appearing","rendered","stage","noop","useTransition","options","nodeRef","timeout","transitionIn","reflow","temporary","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","disablePortal","propDisablePortal","configurationRef","current","ssr","ref","refCallback","setDisablePortal","state","dispatch","reducer","action","duration","disabled","isFirstRender","isRehydrateAppear","defaultTransitionIn","startsWith","nextStage","scrollTop","dispatchStage","timer","window","setTimeout","clearTimeout","transitionTo"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,yBAAyB,QAAQ,kCAAkC;AAO5E,SAASC,oBAAoB,QAAQ,aAAa;AAClD,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,MAAMC,gBAAiC;IACrCC,WAAW;IACXC,UA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EAA0E;QAC1E,kBAAkB;QAClB,MAAMW,gBACJ9B,aAAa4B,cAAc,WAAW,YAAYA;QACpD,IAAIN,YAAY,GAAG;YACjBH,SAASW;YACT;QACF;QAEA,MAAMC,QAAQC,OAAOC,UAAU,CAAC;YAC9Bd,SAASW;QACX,GAAGR;QAEH,OAAO;YACLU,OAAOE,YAAY,CAACH;QACtB;IACF,GAAG;QAACzC;QAAWyB;QAAKD;QAAKtB;QAAOQ;QAAWF;KAAa;IAExD,OAAO;QACLiB,KAAKC;QACLxB;QACAD;QACAD;QACA6C,cAAchB;QACdT,eAAeC,qBAAqBD;IACtC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transition/utils.ts"],"sourcesContent":["import type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n TransitionActions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface TransitionTimeoutOptions extends Required<TransitionActions> {\n timeout: TransitionTimeout;\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getTransitionTimeout(\n options: Readonly<TransitionTimeoutOptions>\n): Readonly<Required<TransitionTimeoutObject>> {\n const { timeout, appear, enter, exit } = options;\n if (typeof timeout === \"number\") {\n return {\n appear: appear ? timeout : 0,\n enter: enter ? timeout : 0,\n exit: exit ? timeout : 0,\n };\n }\n\n return {\n appear: (appear && (timeout.appear ?? timeout.enter)) || 0,\n enter: (enter && timeout.enter) || 0,\n exit: (exit && timeout.exit) || 0,\n };\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface CollapseSizing {\n maxHeight?: number;\n paddingTop?: number;\n paddingBottom?: number;\n}\n\n/**\n * A small util that will find the max-height, padding-top, and padding-bottom\n * for the provided element. This is really used to be able to transition the\n * max-height value since `max-height: auto` does not transition. The only way\n * to get transition is to change max-height values manually.\n *\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getElementSizing(element: HTMLElement | null): CollapseSizing {\n let maxHeight: number | undefined;\n let paddingTop: number | undefined;\n let paddingBottom: number | undefined;\n if (element) {\n // clone the element so that the total height and padding can be calculated\n // without being affected by the collapse transition inline styles\n const cloned = element.cloneNode(true) as HTMLElement;\n cloned.style.maxHeight = \"\";\n cloned.style.padding = \"\";\n cloned.style.paddingLeft = element.style.paddingLeft;\n cloned.style.paddingRight = element.style.paddingRight;\n cloned.style.visibility = \"hidden\";\n\n const container = element.parentElement || document.body;\n container.appendChild(cloned);\n maxHeight = cloned.scrollHeight;\n const style = window.getComputedStyle(cloned);\n const isContentBox = style.boxSizing === \"content-box\";\n if (style.paddingTop) {\n paddingTop = parseFloat(style.paddingTop);\n if (isContentBox) {\n maxHeight += paddingTop;\n }\n }\n\n if (style.paddingBottom) {\n paddingBottom = parseFloat(style.paddingBottom);\n if (isContentBox) {\n maxHeight += paddingBottom;\n }\n }\n container.removeChild(cloned);\n }\n\n return { maxHeight, paddingTop, paddingBottom };\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface TransitionClassNamesOptions extends TransitionTimeoutOptions {\n classNames: CSSTransitionClassNames;\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getTransitionClassNames(\n options: TransitionClassNamesOptions\n): Readonly<Required<CSSTransitionClassNamesObject>> {\n const { classNames, ...timeoutOptions } = options;\n const timeout = getTransitionTimeout(timeoutOptions);\n\n if (typeof classNames === \"string\") {\n const { appear, enter, exit } = timeout;\n return {\n appear: appear ? `${classNames}--appear` : \"\",\n appearActive: appear ? `${classNames}--appear-active` : \"\",\n appearDone: \"\",\n enter: enter ? `${classNames}--enter` : \"\",\n enterActive: enter ? `${classNames}--enter-active` : \"\",\n enterDone: \"\",\n exit: exit ? `${classNames}--exit` : \"\",\n exitActive: exit ? `${classNames}--exit-active` : \"\",\n exitDone: \"\",\n };\n }\n\n const {\n enter = \"\",\n enterActive = \"\",\n enterDone = \"\",\n exit = \"\",\n exitActive = \"\",\n exitDone = \"\",\n appear = (timeout.appear && enter) || \"\",\n appearActive = (timeout.appear && enterActive) || \"\",\n appearDone = (timeout.appear && enterDone) || \"\",\n } = classNames;\n\n return {\n appear,\n appearActive,\n appearDone,\n enter,\n enterActive,\n enterDone,\n exit,\n exitActive,\n exitDone,\n };\n}\n"],"names":["getTransitionTimeout","options","timeout","appear","enter","exit","getElementSizing","element","maxHeight","paddingTop","paddingBottom","cloned","cloneNode","style","padding","paddingLeft","paddingRight","visibility","container","parentElement","document","body","appendChild","scrollHeight","window","getComputedStyle","isContentBox","boxSizing","parseFloat","removeChild","getTransitionClassNames","classNames","timeoutOptions","appearActive","appearDone","enterActive","enterDone","exitActive","exitDone"],"mappings":"AAgBA;;;CAGC,GACD,OAAO,SAASA,qBACdC,OAA2C;IAE3C,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGJ;IACzC,IAAI,OAAOC,YAAY,UAAU;QAC/B,OAAO;YACLC,QAAQA,SAASD,UAAU;YAC3BE,OAAOA,QAAQF,UAAU;YACzBG,MAAMA,OAAOH,UAAU;QACzB;IACF;IAEA,OAAO;QACLC,QAAQ,AAACA,UAAWD,CAAAA,QAAQC,MAAM,IAAID,QAAQE,KAAK,AAAD,KAAO;QACzDA,OAAO,AAACA,SAASF,QAAQE,KAAK,IAAK;QACnCC,MAAM,AAACA,QAAQH,QAAQG,IAAI,IAAK;IAClC;AACF;AAYA;;;;;;;;CAQC,GACD,OAAO,SAASC,iBAAiBC,OAA2B;IAC1D,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIH,SAAS;QACX,2EAA2E;QAC3E,kEAAkE;QAClE,MAAMI,SAASJ,QAAQK,SAAS,CAAC;QACjCD,OAAOE,KAAK,CAACL,SAAS,GAAG;QACzBG,OAAOE,KAAK,CAACC,OAAO,GAAG;QACvBH,OAAOE,KAAK,CAACE,WAAW,GAAGR,QAAQM,KAAK,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,WAAW,aAAa,CAAC,GAAG;YAClDO,UAAU;QACZ;IACF;IAEA,MAAM,EACJlC,QAAQ,EAAE,EACV+B,cAAc,EAAE,EAChBC,YAAY,EAAE,EACd/B,OAAO,EAAE,EACTgC,aAAa,EAAE,EACfC,WAAW,EAAE,EACbnC,SAAS,AAACD,QAAQC,MAAM,IAAIC,SAAU,EAAE,EACxC6B,eAAe,AAAC/B,QAAQC,MAAM,IAAIgC,eAAgB,EAAE,EACpDD,aAAa,AAAChC,QAAQC,MAAM,IAAIiC,aAAc,EAAE,EACjD,GAAGL;IAEJ,OAAO;QACL5B;QACA8B;QACAC;QACA9B;QACA+B;QACAC;QACA/B;QACAgC;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/transition/utils.ts"],"sourcesContent":["import type {\n CSSTransitionClassNames,\n CSSTransitionClassNamesObject,\n TransitionActions,\n TransitionTimeout,\n TransitionTimeoutObject,\n} from \"./types.js\";\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface TransitionTimeoutOptions extends Required<TransitionActions> {\n timeout: TransitionTimeout;\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getTransitionTimeout(\n options: Readonly<TransitionTimeoutOptions>\n): Readonly<Required<TransitionTimeoutObject>> {\n const { timeout, appear, enter, exit } = options;\n if (typeof timeout === \"number\") {\n return {\n appear: appear ? timeout : 0,\n enter: enter ? timeout : 0,\n exit: exit ? timeout : 0,\n };\n }\n\n return {\n appear: (appear && (timeout.appear ?? timeout.enter)) || 0,\n enter: (enter && timeout.enter) || 0,\n exit: (exit && timeout.exit) || 0,\n };\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface CollapseSizing {\n maxHeight?: number;\n paddingTop?: number;\n paddingBottom?: number;\n}\n\n/**\n * A small util that will find the max-height, padding-top, and padding-bottom\n * for the provided element. This is really used to be able to transition the\n * max-height value since `max-height: auto` does not transition. The only way\n * to get transition is to change max-height values manually.\n *\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getElementSizing(element: HTMLElement | null): CollapseSizing {\n let maxHeight: number | undefined;\n let paddingTop: number | undefined;\n let paddingBottom: number | undefined;\n if (element) {\n // clone the element so that the total height and padding can be calculated\n // without being affected by the collapse transition inline styles\n const cloned = element.cloneNode(true) as HTMLElement;\n cloned.style.maxHeight = \"\";\n cloned.style.padding = \"\";\n cloned.style.paddingLeft = element.style.paddingLeft;\n cloned.style.paddingRight = element.style.paddingRight;\n cloned.style.visibility = \"hidden\";\n\n const container = element.parentElement || document.body;\n container.appendChild(cloned);\n maxHeight = cloned.scrollHeight;\n const style = window.getComputedStyle(cloned);\n const isContentBox = style.boxSizing === \"content-box\";\n if (style.paddingTop) {\n paddingTop = parseFloat(style.paddingTop);\n if (isContentBox) {\n maxHeight += paddingTop;\n }\n }\n\n if (style.paddingBottom) {\n paddingBottom = parseFloat(style.paddingBottom);\n if (isContentBox) {\n maxHeight += paddingBottom;\n }\n }\n container.removeChild(cloned);\n }\n\n return { maxHeight, paddingTop, paddingBottom };\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport interface TransitionClassNamesOptions extends TransitionTimeoutOptions {\n classNames: CSSTransitionClassNames;\n}\n\n/**\n * @remarks \\@since 4.0.0\n * @internal\n */\nexport function getTransitionClassNames(\n options: TransitionClassNamesOptions\n): Readonly<Required<CSSTransitionClassNamesObject>> {\n const { classNames, ...timeoutOptions } = options;\n const timeout = getTransitionTimeout(timeoutOptions);\n\n if (typeof classNames === \"string\") {\n const { appear, enter, exit } = timeout;\n return {\n appear: appear ? `${classNames}--appear` : \"\",\n appearActive: appear ? `${classNames}--appear-active` : \"\",\n appearDone: \"\",\n enter: enter ? `${classNames}--enter` : \"\",\n enterActive: enter ? `${classNames}--enter-active` : \"\",\n enterDone: \"\",\n exit: exit ? `${classNames}--exit` : \"\",\n exitActive: exit ? `${classNames}--exit-active` : \"\",\n exitDone: \"\",\n };\n }\n\n const {\n enter = \"\",\n enterActive = \"\",\n enterDone = \"\",\n exit = \"\",\n exitActive = \"\",\n exitDone = \"\",\n appear = (timeout.appear && enter) || \"\",\n appearActive = (timeout.appear && enterActive) || \"\",\n appearDone = (timeout.appear && enterDone) || \"\",\n } = classNames;\n\n return {\n appear,\n appearActive,\n appearDone,\n enter,\n enterActive,\n enterDone,\n exit,\n exitActive,\n exitDone,\n };\n}\n"],"names":["getTransitionTimeout","options","timeout","appear","enter","exit","getElementSizing","element","maxHeight","paddingTop","paddingBottom","cloned","cloneNode","style","padding","paddingLeft","paddingRight","visibility","container","parentElement","document","body","appendChild","scrollHeight","window","getComputedStyle","isContentBox","boxSizing","parseFloat","removeChild","getTransitionClassNames","classNames","timeoutOptions","appearActive","appearDone","enterActive","enterDone","exitActive","exitDone"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAgBA;;;CAGC,GACD,OAAO,SAASA,qBACdC,OAA2C;IAE3C,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGJ;IACzC,IAAI,OAAOC,YAAY,UAAU;QAC/B,OAAO;YACLC,QAAQA,SAASD,UAAU;YAC3BE,OAAOA,QAAQF,UAAU;YACzBG,MAAMA,OAAOH,UAAU;QACzB;IACF;IAEA,OAAO;QACLC,QAAQ,AAACA,UAAWD,CAAAA,QAAQC,MAAM,IAAID,QAAQE,KAAK,AAAD,KAAO;QACzDA,OAAO,AAACA,SAASF,QAAQE,KAAK,IAAK;QACnCC,MAAM,AAACA,QAAQH,QAAQG,IAAI,IAAK;IAClC;AACF;AAYA;;;;;;;;CAQC,GACD,OAAO,SAASC,iBAAiBC,OAA2B;IAC1D,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIH,SAAS;QACX,2EAA2E;QAC3E,kEAAkE;QAClE,MAAMI,SAASJ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AAQ,CAAC,EAAE2B,WAAW,cAAc,CAAC,GAAG;YACrDK,WAAW;YACX/B,MAAMA,OAAO,CAAC,EAAE0B,WAAW,MAAM,CAAC,GAAG;YACrCM,YAAYhC,OAAO,CAAC,EAAE0B,WAAW,aAAa,CAAC,GAAG;YAClDO,UAAU;QACZ;IACF;IAEA,MAAM,EACJlC,QAAQ,EAAE,EACV+B,cAAc,EAAE,EAChBC,YAAY,EAAE,EACd/B,OAAO,EAAE,EACTgC,aAAa,EAAE,EACfC,WAAW,EAAE,EACbnC,SAAS,AAACD,QAAQC,MAAM,IAAIC,SAAU,EAAE,EACxC6B,eAAe,AAAC/B,QAAQC,MAAM,IAAIgC,eAAgB,EAAE,EACpDD,aAAa,AAAChC,QAAQC,MAAM,IAAIiC,aAAc,EAAE,EACjD,GAAGL;IAEJ,OAAO;QACL5B;QACA8B;QACAC;QACA9B;QACA+B;QACAC;QACA/B;QACAgC;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tree/DefaultTreeItemRenderer.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\nimport { type RenderRecursiveItemsProps } from \"../utils/RenderRecursively.js\";\nimport { TreeItem } from \"./TreeItem.js\";\nimport {\n type DefaultTreeItemNode,\n type TreeData,\n type TreeItemNode,\n} from \"./types.js\";\n\n/**\n * **Client Component**\n *\n * A reasonable default for rendering tree items that will extract all the\n * `ListItemChildrenProps` from the item and attempt to pass them into the\n * `TreeItem`.\n *\n * Look at the `Tree` component for an example of creating a custom\n * implementation.\n *\n * @remarks \\@since 6.0.0\n */\nexport function DefaultTreeItemRenderer<\n T extends TreeItemNode = DefaultTreeItemNode,\n>(props: RenderRecursiveItemsProps<T, TreeData<T>>): ReactElement {\n const { item: _item, parents, children: childItems } = props;\n const item = props.item as DefaultTreeItemNode;\n\n const {\n itemId,\n to,\n href,\n disabled,\n className,\n contentClassName,\n leftAddon,\n leftAddonType,\n leftAddonPosition,\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType,\n rightAddonPosition,\n rightAddonClassName,\n rightAddonForceWrap,\n disableLeftAddonCenteredMedia,\n disableRightAddonCenteredMedia,\n } = item;\n const children = item.name ?? item.children;\n\n return (\n <TreeItem\n to={to}\n href={href}\n depth={parents.length}\n childItems={childItems}\n className={className}\n contentClassName={contentClassName}\n itemId={itemId}\n disabled={disabled}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={leftAddonClassName}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </TreeItem>\n );\n}\n"],"names":["TreeItem","DefaultTreeItemRenderer","props","item","_item","parents","children","childItems","itemId","to","href","disabled","className","contentClassName","leftAddon","leftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","name","depth","length"],"mappings":";AAEA,SAASA,QAAQ,QAAQ,gBAAgB;AAOzC;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,wBAEdC,KAAgD;IAChD,MAAM,EAAEC,MAAMC,KAAK,EAAEC,OAAO,EAAEC,UAAUC,UAAU,EAAE,GAAGL;IACvD,MAAMC,OAAOD,MAAMC,IAAI;IAEvB,MAAM,EACJK,MAAM,EACNC,EAAE,EACFC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,6BAA6B,EAC7BC,8BAA8B,EAC/B,GAAGtB;IACJ,MAAMG,WAAWH,KAAKuB,IAAI,IAAIvB,KAAKG,QAAQ;IAE3C,qBACE,KAACN;QACCS,IAAIA;QACJC,MAAMA;QACNiB,OAAOtB,QAAQuB,MAAM;QACrBrB,YAAYA;QACZK,WAAWA;QACXC,kBAAkBA;QAClBL,QAAQA;QACRG,UAAUA;QACVG,WAAWA;QACXC,eAAeA;QACfC,mBAAmBA;QACnBC,oBAAoBA;QACpBC,oBAAoBA;QACpBC,YAAYA;QACZC,gBAAgBA;QAChBC,oBAAoBA;QACpBC,qBAAqBA;QACrBC,qBAAqBA;QACrBC,+BAA+BA;QAC/BC,gCAAgCA;kBAE/BnB;;AAGP"}
|
|
1
|
+
{"version":3,"sources":["../../src/tree/DefaultTreeItemRenderer.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\nimport { type RenderRecursiveItemsProps } from \"../utils/RenderRecursively.js\";\nimport { TreeItem } from \"./TreeItem.js\";\nimport {\n type DefaultTreeItemNode,\n type TreeData,\n type TreeItemNode,\n} from \"./types.js\";\n\n/**\n * **Client Component**\n *\n * A reasonable default for rendering tree items that will extract all the\n * `ListItemChildrenProps` from the item and attempt to pass them into the\n * `TreeItem`.\n *\n * Look at the `Tree` component for an example of creating a custom\n * implementation.\n *\n * @remarks \\@since 6.0.0\n */\nexport function DefaultTreeItemRenderer<\n T extends TreeItemNode = DefaultTreeItemNode,\n>(props: RenderRecursiveItemsProps<T, TreeData<T>>): ReactElement {\n const { item: _item, parents, children: childItems } = props;\n const item = props.item as DefaultTreeItemNode;\n\n const {\n itemId,\n to,\n href,\n disabled,\n className,\n contentClassName,\n leftAddon,\n leftAddonType,\n leftAddonPosition,\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType,\n rightAddonPosition,\n rightAddonClassName,\n rightAddonForceWrap,\n disableLeftAddonCenteredMedia,\n disableRightAddonCenteredMedia,\n } = item;\n const children = item.name ?? item.children;\n\n return (\n <TreeItem\n to={to}\n href={href}\n depth={parents.length}\n childItems={childItems}\n className={className}\n contentClassName={contentClassName}\n itemId={itemId}\n disabled={disabled}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={leftAddonClassName}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </TreeItem>\n );\n}\n"],"names":["TreeItem","DefaultTreeItemRenderer","props","item","_item","parents","children","childItems","itemId","to","href","disabled","className","contentClassName","leftAddon","leftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","name","depth","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,QAAQ,QAAQ,gBAAgB;AAOzC;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,wBAEdC,KAAgD;IAChD,MAAM,EAAEC,MAAMC,KAAK,EAAEC,OAAO,EAAEC,UAAUC,UAAU,EAAE,GAAGL;IACvD,MAAMC,OAAOD,MAAMC,IAAI;IAEvB,MAAM,EACJK,MAAM,EACNC,EAAE,EACFC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,6BAA6B,EAC7BC,8BAA8B,EAC/B,GAAGtB;IACJ,MAAMG,WAAWH,KAAKuB,IAAI,IAAIvB,KAAKG,QAAQ;IAE3C,qBACE,KAACN;QACCS,IAAIA;QACJC,MAAMA;QACNiB,OAAOtB,QAAQuB,MAAM;QACrBrB,YAAYA;QACZK,WAAWA;QACXC,kBAAkBA;QAClBL,QAAQA;QACRG,UAAUA;QACVG,WAAWA;QACXC,eAAeA;QACfC,mBAAmBA;QACnBC,oBAAoBA;QACpBC,oBAAoBA;QACpBC,YAAYA;QACZC,gBAAgBA;QAChBC,oBAAoBA;QACpBC,qBAAqBA;QACrBC,qBAAqBA;QACrBC,+BAA+BA;QAC/BC,gCAAgCA;kBAE/BnB;;AAGP"}
|
package/dist/tree/Tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tree/Tree.tsx"],"sourcesContent":["\"use client\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { List } from \"../list/List.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n RenderRecursively,\n type RenderRecursiveItemsProps,\n} from \"../utils/RenderRecursively.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { DefaultTreeItemRenderer } from \"./DefaultTreeItemRenderer.js\";\nimport { TreeProvider, type TreeExpansionMode } from \"./TreeProvider.js\";\nimport { tree } from \"./styles.js\";\nimport {\n type TreeData,\n type TreeItemNode,\n type TreeItemSorter,\n} from \"./types.js\";\nimport { type TreeExpansion } from \"./useTreeExpansion.js\";\nimport { useTreeItems } from \"./useTreeItems.js\";\nimport { useTreeMovement } from \"./useTreeMovement.js\";\nimport { type TreeSelection } from \"./useTreeSelection.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tree-depth\"?: number;\n \"--rmd-tree-item-padding\"?: string | number;\n \"--rmd-tree-item-padding-base\"?: string | number;\n \"--rmd-tree-item-padding-incrementor\"?: string | number;\n }\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type TreeHTMLAttributes = Omit<\n HTMLAttributes<HTMLUListElement>,\n \"role\" | \"tabIndex\" | \"children\"\n>;\n\n/**\n * @remarks\n * \\@since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport interface TreeProps<T extends TreeItemNode>\n extends TreeHTMLAttributes,\n TreeExpansion,\n TreeSelection {\n /** @see {@link TreeData} */\n data: TreeData<T>;\n\n /**\n * An optional ref to pass to the tree element.\n *\n * @remarks \\@since 6.0.0\n */\n treeRef?: Ref<HTMLUListElement>;\n\n /** @defaultValue `identity` */\n sort?: TreeItemSorter<T>;\n\n /**\n * Any nodes in the {@Link data} that have a `parentId` set to this value will\n * appear at the root of the tree.\n *\n * @defaultValue `null`\n */\n rootId?: string | null;\n\n /**\n * @defaultValue `\"auto\"`\n * @see {@link TreeExpansionMode}\n */\n expansionMode?: TreeExpansionMode;\n\n /**\n * Set this to `true` to display the expander icon to the left instead of the\n * right. This will also update the styles slightly so you can still provide a\n * `leftAddon`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n\n /**\n * @defaultValue `getIcon(\"expander\")`\n */\n expanderIcon?: ReactNode;\n\n /**\n * Set this to `true` to disable the collapse transition for all tree items.\n *\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * Set this to `true` if the collapsed tree items should be removed from the\n * DOM instead of hidden using `display: none`. This _might_ improve\n * performance for large trees.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n\n /**\n * @example\n * Custom Tree Item Renderer\n * ```tsx\n * import {\n * TreeItem,\n * useKeyboardMovementContext,\n * useTreeContext,\n * type RenderRecursiveItemsProps,\n * } from \"@react-md/core\";\n * import FolderIcon from \"@react-md/material-icons/FolderIcon\";\n * import FolderOpenIcon from \"@react-md/material-icons/FolderOpenIcon\";\n * import { type ReactElement } from \"react\";\n *\n * export function CustomTreeItem(props: TreeItemRendererProps): ReactElement {\n * const { item, ...remaining } = props;\n * const id = useId();\n * const { itemId } = item;\n * const {\n * data,\n * expandedIds,\n * selectedIds,\n * toggleTreeItemExpansion,\n * toggleTreeItemSelection,\n * } = useTreeContext()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * const focused = id === activeDescendantId;\n * const expanded = expandedIds.has(itemId);\n * const selected = selectedIds.has(itemId);\n * const children = ...; // do whatever\n *\n * return (\n * <TreeItem\n * {...remaining}\n * id={id}\n * itemId={itemId}\n * leftAddon={expanded ? <FolderOpenIcon /> : <FolderIcon />}\n * >\n * {children}\n * </TreeItem>\n * );\n * }\n * ```\n *\n * @see {@link DefaultTreeItemRenderer}\n * @defaultValue `DefaultTreeItemRenderer`\n */\n renderer?: ComponentType<RenderRecursiveItemsProps<T, TreeData<T>>>;\n\n /**\n * The link component to use for any tree item nodes that have a `to` or\n * `href`.\n *\n * @see {@link CustomLinkComponent}\n * @defaultValue `Link`\n */\n linkComponent?: CustomLinkComponent;\n}\n\n/**\n * **Client Component**\n *\n * @example\n * Simple Tree\n * ```tsx\n * import type { TreeData } from \"@react-md/core\";\n * import { Tree, useTree } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * const data: TreeData = {\n * \"item-1\": {\n * itemId: \"item-1\",\n * parentId: null,\n * name: \"Root Level Item 1\",\n * },\n * \"item-2\": {\n * itemId: \"item-2\",\n * parentId: \"item-1\",\n * name: \"A child for the first item\",\n * },\n * \"item-3\": {\n * itemId: \"item-3\",\n * parentId: \"item-1\",\n * children: \"Another child for the first item\",\n * },\n * };\n *\n * function Example(): ReactElement {\n * const tree = useTree({\n * // can enable multiple selected items\n * // multiSelect: true,\n *\n * // can set default expanded and selected items\n * // defaultSelectedIds: [\"item-1\"],\n * // defaultExpandedIds: [\"item-1\"],\n * });\n *\n * return (\n * <Tree\n * {...tree}\n * aria-label=\"Tree\"\n * data={data}\n * />\n * );\n * }\n * ```\n *\n * @see {@link TreeProps.renderer} for a custom tree item example.\n *\n * @remarks\n * \\@since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport function Tree<T extends TreeItemNode>(\n props: LabelRequiredForA11y<TreeProps<T>>\n): ReactElement {\n const {\n id,\n data,\n sort = identity,\n rootId = null,\n treeRef,\n className,\n expandedIds,\n selectedIds,\n toggleTreeItemSelection,\n selectMultipleTreeItems,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n onClick,\n onFocus,\n onKeyDown,\n renderer: TreeItemRenderer = DefaultTreeItemRenderer,\n multiSelect = false,\n expansionMode = \"auto\",\n expanderIcon,\n expanderLeft = false,\n linkComponent = \"a\",\n disableTransition = false,\n temporaryChildItems = false,\n ...remaining\n } = props;\n const treeId = useEnsuredId(id, \"tree\");\n const { items, treeItemChildIds } = useTreeItems({\n data,\n sort,\n rootId,\n });\n\n const { metadataLookup, movementContext, movementProps } = useTreeMovement({\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n });\n\n return (\n <TreeProvider\n data={data}\n rootId={rootId}\n multiSelect={multiSelect}\n linkComponent={linkComponent}\n selectedIds={selectedIds}\n expandedIds={expandedIds}\n expanderIcon={expanderIcon}\n expanderLeft={expanderLeft}\n expansionMode={expansionMode}\n metadataLookup={metadataLookup}\n disableTransition={disableTransition}\n temporaryChildItems={temporaryChildItems}\n toggleTreeItemSelection={toggleTreeItemSelection}\n toggleTreeItemExpansion={toggleTreeItemExpansion}\n selectMultipleTreeItems={selectMultipleTreeItems}\n expandMultipleTreeItems={expandMultipleTreeItems}\n >\n <KeyboardMovementProvider value={movementContext}>\n <List\n {...remaining}\n {...movementProps}\n id={treeId}\n ref={treeRef}\n role=\"tree\"\n tabIndex={0}\n className={tree({ className })}\n >\n <RenderRecursively\n items={items}\n getItemKey={(item) => item.itemId}\n render={TreeItemRenderer}\n />\n </List>\n </KeyboardMovementProvider>\n </TreeProvider>\n );\n}\n"],"names":["List","KeyboardMovementProvider","useEnsuredId","RenderRecursively","identity","DefaultTreeItemRenderer","TreeProvider","tree","useTreeItems","useTreeMovement","Tree","props","id","data","sort","rootId","treeRef","className","expandedIds","selectedIds","toggleTreeItemSelection","selectMultipleTreeItems","toggleTreeItemExpansion","expandMultipleTreeItems","onClick","onFocus","onKeyDown","renderer","TreeItemRenderer","multiSelect","expansionMode","expanderIcon","expanderLeft","linkComponent","disableTransition","temporaryChildItems","remaining","treeId","items","treeItemChildIds","metadataLookup","movementContext","movementProps","value","ref","role","tabIndex","getItemKey","item","itemId","render"],"mappings":"AAAA;;AASA,SAASA,IAAI,QAAQ,kBAAkB;AACvC,SAASC,wBAAwB,QAAQ,6CAA6C;AAEtF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SACEC,iBAAiB,QAEZ,gCAAgC;AACvC,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,uBAAuB,QAAQ,+BAA+B;AACvE,SAASC,YAAY,QAAgC,oBAAoB;AACzE,SAASC,IAAI,QAAQ,cAAc;AAOnC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,uBAAuB;AAwJvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DC,GACD,OAAO,SAASC,KACdC,KAAyC;IAEzC,MAAM,EACJC,EAAE,EACFC,IAAI,EACJC,OAAOV,QAAQ,EACfW,SAAS,IAAI,EACbC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,uBAAuB,EACvBC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,UAAUC,mBAAmBvB,uBAAuB,EACpDwB,cAAc,KAAK,EACnBC,gBAAgB,MAAM,EACtBC,YAAY,EACZC,eAAe,KAAK,EACpBC,gBAAgB,GAAG,EACnBC,oBAAoB,KAAK,EACzBC,sBAAsB,KAAK,EAC3B,GAAGC,WACJ,GAAGzB;IACJ,MAAM0B,SAASnC,aAAaU,IAAI;IAChC,MAAM,EAAE0B,KAAK,EAAEC,gBAAgB,EAAE,GAAG/B,aAAa;QAC/CK;QACAC;QACAC;IACF;IAEA,MAAM,EAAEyB,cAAc,EAAEC,eAAe,EAAEC,aAAa,EAAE,GAAGjC,gBAAgB;QACzEe;QACAC;QACAC;QACAb;QACAK;QACAC;QACAoB;QACAjB;QACAC;IACF;IAEA,qBACE,KAACjB;QACCO,MAAMA;QACNE,QAAQA;QACRc,aAAaA;QACbI,eAAeA;QACfd,aAAaA;QACbD,aAAaA;QACba,cAAcA;QACdC,cAAcA;QACdF,eAAeA;QACfU,gBAAgBA;QAChBN,mBAAmBA;QACnBC,qBAAqBA;QACrBf,yBAAyBA;QACzBE,yBAAyBA;QACzBD,yBAAyBA;QACzBE,yBAAyBA;kBAEzB,cAAA,KAACtB;YAAyB0C,OAAOF;sBAC/B,cAAA,KAACzC;gBACE,GAAGoC,SAAS;gBACZ,GAAGM,aAAa;gBACjB9B,IAAIyB;gBACJO,KAAK5B;gBACL6B,MAAK;gBACLC,UAAU;gBACV7B,WAAWV,KAAK;oBAAEU;gBAAU;0BAE5B,cAAA,KAACd;oBACCmC,OAAOA;oBACPS,YAAY,CAACC,OAASA,KAAKC,MAAM;oBACjCC,QAAQtB;;;;;AAMpB"}
|
|
1
|
+
{"version":3,"sources":["../../src/tree/Tree.tsx"],"sourcesContent":["\"use client\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { List } from \"../list/List.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type LabelRequiredForA11y } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n RenderRecursively,\n type RenderRecursiveItemsProps,\n} from \"../utils/RenderRecursively.js\";\nimport { identity } from \"../utils/identity.js\";\nimport { DefaultTreeItemRenderer } from \"./DefaultTreeItemRenderer.js\";\nimport { TreeProvider, type TreeExpansionMode } from \"./TreeProvider.js\";\nimport { tree } from \"./styles.js\";\nimport {\n type TreeData,\n type TreeItemNode,\n type TreeItemSorter,\n} from \"./types.js\";\nimport { type TreeExpansion } from \"./useTreeExpansion.js\";\nimport { useTreeItems } from \"./useTreeItems.js\";\nimport { useTreeMovement } from \"./useTreeMovement.js\";\nimport { type TreeSelection } from \"./useTreeSelection.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tree-depth\"?: number;\n \"--rmd-tree-item-padding\"?: string | number;\n \"--rmd-tree-item-padding-base\"?: string | number;\n \"--rmd-tree-item-padding-incrementor\"?: string | number;\n }\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type TreeHTMLAttributes = Omit<\n HTMLAttributes<HTMLUListElement>,\n \"role\" | \"tabIndex\" | \"children\"\n>;\n\n/**\n * @remarks\n * \\@since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport interface TreeProps<T extends TreeItemNode>\n extends TreeHTMLAttributes,\n TreeExpansion,\n TreeSelection {\n /** @see {@link TreeData} */\n data: TreeData<T>;\n\n /**\n * An optional ref to pass to the tree element.\n *\n * @remarks \\@since 6.0.0\n */\n treeRef?: Ref<HTMLUListElement>;\n\n /** @defaultValue `identity` */\n sort?: TreeItemSorter<T>;\n\n /**\n * Any nodes in the {@Link data} that have a `parentId` set to this value will\n * appear at the root of the tree.\n *\n * @defaultValue `null`\n */\n rootId?: string | null;\n\n /**\n * @defaultValue `\"auto\"`\n * @see {@link TreeExpansionMode}\n */\n expansionMode?: TreeExpansionMode;\n\n /**\n * Set this to `true` to display the expander icon to the left instead of the\n * right. This will also update the styles slightly so you can still provide a\n * `leftAddon`.\n *\n * @defaultValue `false`\n */\n expanderLeft?: boolean;\n\n /**\n * @defaultValue `getIcon(\"expander\")`\n */\n expanderIcon?: ReactNode;\n\n /**\n * Set this to `true` to disable the collapse transition for all tree items.\n *\n * @defaultValue `false`\n */\n disableTransition?: boolean;\n\n /**\n * Set this to `true` if the collapsed tree items should be removed from the\n * DOM instead of hidden using `display: none`. This _might_ improve\n * performance for large trees.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n\n /**\n * @example\n * Custom Tree Item Renderer\n * ```tsx\n * import {\n * TreeItem,\n * useKeyboardMovementContext,\n * useTreeContext,\n * type RenderRecursiveItemsProps,\n * } from \"@react-md/core\";\n * import FolderIcon from \"@react-md/material-icons/FolderIcon\";\n * import FolderOpenIcon from \"@react-md/material-icons/FolderOpenIcon\";\n * import { type ReactElement } from \"react\";\n *\n * export function CustomTreeItem(props: TreeItemRendererProps): ReactElement {\n * const { item, ...remaining } = props;\n * const id = useId();\n * const { itemId } = item;\n * const {\n * data,\n * expandedIds,\n * selectedIds,\n * toggleTreeItemExpansion,\n * toggleTreeItemSelection,\n * } = useTreeContext()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * const focused = id === activeDescendantId;\n * const expanded = expandedIds.has(itemId);\n * const selected = selectedIds.has(itemId);\n * const children = ...; // do whatever\n *\n * return (\n * <TreeItem\n * {...remaining}\n * id={id}\n * itemId={itemId}\n * leftAddon={expanded ? <FolderOpenIcon /> : <FolderIcon />}\n * >\n * {children}\n * </TreeItem>\n * );\n * }\n * ```\n *\n * @see {@link DefaultTreeItemRenderer}\n * @defaultValue `DefaultTreeItemRenderer`\n */\n renderer?: ComponentType<RenderRecursiveItemsProps<T, TreeData<T>>>;\n\n /**\n * The link component to use for any tree item nodes that have a `to` or\n * `href`.\n *\n * @see {@link CustomLinkComponent}\n * @defaultValue `Link`\n */\n linkComponent?: CustomLinkComponent;\n}\n\n/**\n * **Client Component**\n *\n * @example\n * Simple Tree\n * ```tsx\n * import type { TreeData } from \"@react-md/core\";\n * import { Tree, useTree } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * const data: TreeData = {\n * \"item-1\": {\n * itemId: \"item-1\",\n * parentId: null,\n * name: \"Root Level Item 1\",\n * },\n * \"item-2\": {\n * itemId: \"item-2\",\n * parentId: \"item-1\",\n * name: \"A child for the first item\",\n * },\n * \"item-3\": {\n * itemId: \"item-3\",\n * parentId: \"item-1\",\n * children: \"Another child for the first item\",\n * },\n * };\n *\n * function Example(): ReactElement {\n * const tree = useTree({\n * // can enable multiple selected items\n * // multiSelect: true,\n *\n * // can set default expanded and selected items\n * // defaultSelectedIds: [\"item-1\"],\n * // defaultExpandedIds: [\"item-1\"],\n * });\n *\n * return (\n * <Tree\n * {...tree}\n * aria-label=\"Tree\"\n * data={data}\n * />\n * );\n * }\n * ```\n *\n * @see {@link TreeProps.renderer} for a custom tree item example.\n *\n * @remarks\n * \\@since 6.0.0 There was a major API change and the `id` is now `optional`.\n * In addition, the following props were removed:\n * - `itemRenderer`\n * - `labelKey`\n * - `valueKey`\n * - `getItemLabel`\n * - `getItemValue`\n * - `getItemProps`\n */\nexport function Tree<T extends TreeItemNode>(\n props: LabelRequiredForA11y<TreeProps<T>>\n): ReactElement {\n const {\n id,\n data,\n sort = identity,\n rootId = null,\n treeRef,\n className,\n expandedIds,\n selectedIds,\n toggleTreeItemSelection,\n selectMultipleTreeItems,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n onClick,\n onFocus,\n onKeyDown,\n renderer: TreeItemRenderer = DefaultTreeItemRenderer,\n multiSelect = false,\n expansionMode = \"auto\",\n expanderIcon,\n expanderLeft = false,\n linkComponent = \"a\",\n disableTransition = false,\n temporaryChildItems = false,\n ...remaining\n } = props;\n const treeId = useEnsuredId(id, \"tree\");\n const { items, treeItemChildIds } = useTreeItems({\n data,\n sort,\n rootId,\n });\n\n const { metadataLookup, movementContext, movementProps } = useTreeMovement({\n onClick,\n onFocus,\n onKeyDown,\n data,\n expandedIds,\n selectedIds,\n treeItemChildIds,\n toggleTreeItemExpansion,\n expandMultipleTreeItems,\n });\n\n return (\n <TreeProvider\n data={data}\n rootId={rootId}\n multiSelect={multiSelect}\n linkComponent={linkComponent}\n selectedIds={selectedIds}\n expandedIds={expandedIds}\n expanderIcon={expanderIcon}\n expanderLeft={expanderLeft}\n expansionMode={expansionMode}\n metadataLookup={metadataLookup}\n disableTransition={disableTransition}\n temporaryChildItems={temporaryChildItems}\n toggleTreeItemSelection={toggleTreeItemSelection}\n toggleTreeItemExpansion={toggleTreeItemExpansion}\n selectMultipleTreeItems={selectMultipleTreeItems}\n expandMultipleTreeItems={expandMultipleTreeItems}\n >\n <KeyboardMovementProvider value={movementContext}>\n <List\n {...remaining}\n {...movementProps}\n id={treeId}\n ref={treeRef}\n role=\"tree\"\n tabIndex={0}\n className={tree({ className })}\n >\n <RenderRecursively\n items={items}\n getItemKey={(item) => item.itemId}\n render={TreeItemRenderer}\n />\n </List>\n </KeyboardMovementProvider>\n </TreeProvider>\n );\n}\n"],"names":["List","KeyboardMovementProvider","useEnsuredId","RenderRecursively","identity","DefaultTreeItemRenderer","TreeProvider","tree","useTreeItems","useTreeMovement","Tree","props","id","data","sort","rootId","treeRef","className","expandedIds","selectedIds","toggleTreeItemSelection","selectMultipleTreeItems","toggleTreeItemExpansion","expandMultipleTreeItems","onClick","onFocus","onKeyDown","renderer","TreeItemRenderer","multiSelect","expansionMode","expanderIcon","expanderLeft","linkComponent","disableTransition","temporaryChildItems","remaining","treeId","items","treeItemChildIds","metadataLookup","movementContext","movementProps","value","ref","role","tabIndex","getItemKey","item","itemId","render"],"range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AE,GAAGjC,gBAAgB;QACzEe;QACAC;QACAC;QACAb;QACAK;QACAC;QACAoB;QACAjB;QACAC;IACF;IAEA,qBACE,KAACjB;QACCO,MAAMA;QACNE,QAAQA;QACRc,aAAaA;QACbI,eAAeA;QACfd,aAAaA;QACbD,aAAaA;QACba,cAAcA;QACdC,cAAcA;QACdF,eAAeA;QACfU,gBAAgBA;QAChBN,mBAAmBA;QACnBC,qBAAqBA;QACrBf,yBAAyBA;QACzBE,yBAAyBA;QACzBD,yBAAyBA;QACzBE,yBAAyBA;kBAEzB,cAAA,KAACtB;YAAyB0C,OAAOF;sBAC/B,cAAA,KAACzC;gBACE,GAAGoC,SAAS;gBACZ,GAAGM,aAAa;gBACjB9B,IAAIyB;gBACJO,KAAK5B;gBACL6B,MAAK;gBACLC,UAAU;gBACV7B,WAAWV,KAAK;oBAAEU;gBAAU;0BAE5B,cAAA,KAACd;oBACCmC,OAAOA;oBACPS,YAAY,CAACC,OAASA,KAAKC,MAAM;oBACjCC,QAAQtB;;;;;AAMpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tree/TreeGroup.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport { List, type ListProps } from \"../list/List.js\";\nimport { useCollapseTransition } from \"../transition/useCollapseTransition.js\";\nimport { useTreeContext } from \"./TreeProvider.js\";\nimport { treeGroup } from \"./styles.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface OverridableTreeGroupProps extends ListProps {\n /** @defaultValue `false` */\n temporary?: boolean;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n}\n\n/**\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport interface TreeGroupProps extends OverridableTreeGroupProps {\n children: ReactNode;\n depth: number;\n collapsed: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @remarks \\@since 6.0.0 Removed the collapse options and is no longer a\n * \"public\" component.\n */\nexport const TreeGroup = forwardRef<HTMLUListElement, TreeGroupProps>(\n function TreeGroup(props, ref) {\n const {\n className,\n collapsed,\n depth,\n onClick,\n onMouseDown,\n children,\n temporary: propTemporary,\n disableTransition = false,\n ...remaining\n } = props;\n\n const style: CSSProperties = {\n ...remaining.style,\n \"--rmd-tree-depth\": depth,\n };\n\n const { temporaryChildItems } = useTreeContext();\n const temporary = propTemporary ?? temporaryChildItems;\n\n const { elementProps, rendered } = useCollapseTransition({\n style,\n nodeRef: ref,\n enter: !disableTransition,\n exit: !disableTransition,\n transitionIn: !collapsed,\n temporary,\n className: treeGroup({ className }),\n });\n\n if (!rendered || !children) {\n return null;\n }\n\n return (\n <List\n {...remaining}\n onClick={(event) => {\n onClick?.(event);\n // always stop propagation for click events and mousedown for groups\n // so that the parent child item's click and mousedown events aren't\n // also fired while there are disabled child elementsS or\n // non-interactable (like dividers or subheader)\n event.stopPropagation();\n }}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n event.stopPropagation();\n }}\n {...elementProps}\n role=\"group\"\n >\n {children}\n </List>\n );\n }\n);\n"],"names":["forwardRef","List","useCollapseTransition","useTreeContext","treeGroup","TreeGroup","props","ref","className","collapsed","depth","onClick","onMouseDown","children","temporary","propTemporary","disableTransition","remaining","style","temporaryChildItems","elementProps","rendered","nodeRef","enter","exit","transitionIn","event","stopPropagation","role"],"mappings":"AAAA;;AACA,SAASA,UAAU,QAA4C,QAAQ;AACvE,SAASC,IAAI,QAAwB,kBAAkB;AACvD,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,SAAS,QAAQ,cAAc;AAuBxC;;;;;;CAMC,GACD,OAAO,MAAMC,0BAAYL,WACvB,SAASK,UAAUC,KAAK,EAAEC,GAAG;IAC3B,MAAM,EACJC,SAAS,EACTC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,WAAW,EACXC,QAAQ,EACRC,WAAWC,aAAa,EACxBC,oBAAoB,KAAK,EACzB,GAAGC,WACJ,GAAGX;IAEJ,MAAMY,QAAuB;QAC3B,GAAGD,UAAUC,KAAK;QAClB,oBAAoBR;IACtB;IAEA,MAAM,EAAES,mBAAmB,EAAE,GAAGhB;IAChC,MAAMW,YAAYC,iBAAiBI;IAEnC,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGnB,sBAAsB;QACvDgB;QACAI,SAASf;QACTgB,OAAO,CAACP;QACRQ,MAAM,CAACR;QACPS,cAAc,CAAChB;QACfK;QACAN,WAAWJ,UAAU;YAAEI;QAAU;IACnC;IAEA,IAAI,CAACa,YAAY,CAACR,UAAU;QAC1B,OAAO;IACT;IAEA,qBACE,KAACZ;QACE,GAAGgB,SAAS;QACbN,SAAS,CAACe;YACRf,UAAUe;YACV,oEAAoE;YACpE,oEAAoE;YACpE,yDAAyD;YACzD,gDAAgD;YAChDA,MAAMC,eAAe;QACvB;QACAf,aAAa,CAACc;YACZd,cAAcc;YACdA,MAAMC,eAAe;QACvB;QACC,GAAGP,YAAY;QAChBQ,MAAK;kBAEJf;;AAGP,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/tree/TreeGroup.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport { List, type ListProps } from \"../list/List.js\";\nimport { useCollapseTransition } from \"../transition/useCollapseTransition.js\";\nimport { useTreeContext } from \"./TreeProvider.js\";\nimport { treeGroup } from \"./styles.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface OverridableTreeGroupProps extends ListProps {\n /** @defaultValue `false` */\n temporary?: boolean;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n}\n\n/**\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport interface TreeGroupProps extends OverridableTreeGroupProps {\n children: ReactNode;\n depth: number;\n collapsed: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @remarks \\@since 6.0.0 Removed the collapse options and is no longer a\n * \"public\" component.\n */\nexport const TreeGroup = forwardRef<HTMLUListElement, TreeGroupProps>(\n function TreeGroup(props, ref) {\n const {\n className,\n collapsed,\n depth,\n onClick,\n onMouseDown,\n children,\n temporary: propTemporary,\n disableTransition = false,\n ...remaining\n } = props;\n\n const style: CSSProperties = {\n ...remaining.style,\n \"--rmd-tree-depth\": depth,\n };\n\n const { temporaryChildItems } = useTreeContext();\n const temporary = propTemporary ?? temporaryChildItems;\n\n const { elementProps, rendered } = useCollapseTransition({\n style,\n nodeRef: ref,\n enter: !disableTransition,\n exit: !disableTransition,\n transitionIn: !collapsed,\n temporary,\n className: treeGroup({ className }),\n });\n\n if (!rendered || !children) {\n return null;\n }\n\n return (\n <List\n {...remaining}\n onClick={(event) => {\n onClick?.(event);\n // always stop propagation for click events and mousedown for groups\n // so that the parent child item's click and mousedown events aren't\n // also fired while there are disabled child elementsS or\n // non-interactable (like dividers or subheader)\n event.stopPropagation();\n }}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n event.stopPropagation();\n }}\n {...elementProps}\n role=\"group\"\n >\n {children}\n </List>\n );\n }\n);\n"],"names":["forwardRef","List","useCollapseTransition","useTreeContext","treeGroup","TreeGroup","props","ref","className","collapsed","depth","onClick","onMouseDown","children","temporary","propTemporary","disableTransition","remaining","style","temporaryChildItems","elementProps","rendered","nodeRef","enter","exit","transitionIn","event","stopPropagation","role"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,SAASA,UAAU,QAA4C,QAAQ;AACvE,SAASC,IAAI,QAAwB,kBAAkB;AACvD,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,SAAS,QAAQ,cAAc;AAuBxC;;;;;;CAMC,GACD,OAAO,MAAMC,0BAAYL,WACvB,SAASK,UAAUC,KAAK,EAAEC,GAAG;IAC3B,MAAM,EACJC,SAAS,EACTC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,WAAW,EACXC,QAAQ,EACRC,WAAWC,aAAa,EACxBC,oBAAoB,KAAK,EACzB,GAAGC,WACJ,GAAGX;IAEJ,MAAMY,QAAuB;QAC3B,GAAGD,UAAUC,KAAK;QAClB,oBAAoBR;IACtB;IAEA,MAAM,EAAES,mBAAmB,EAAE,GAAGhB;IAChC,MAAMW,YAAYC,iBAAiBI;IAEnC,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGnB,sBAAsB;QACvDgB;QACAI,SAASf;QACTgB,OAAO,CAACP;QACRQ,MAAM,CAACR;QACPS,cAAc,CAAChB;QACfK;QACAN,WAAWJ,UAAU;YAAEI;QAAU;IACnC;IAEA,IAAI,CAACa,YAAY,CAACR,UAAU;QAC1B,OAAO;IACT;IAEA,qBACE,KAACZ;QACE,GAAGgB,SAAS;QACbN,SAAS,CAACe;YACRf,UAAUe;YACV,oEAAoE;YACpE,oEAAoE;YACpE,yDAAyD;YACzD,gDAAgD;YAChDA,MAAMC,eAAe;QACvB;QACAf,aAAa,CAACc;YACZd,cAAcc;YACdA,MAAMC,eAAe;QACvB;QACC,GAAGP,YAAY;QAChBQ,MAAK;kBAEJf;;AAGP,GACA"}
|