import { bottomSheet, type BottomSheetVariantProps } from "@seed-design/css/recipes/bottom-sheet"; import { composeRefs } from "@radix-ui/react-compose-refs"; import { dataAttr } from "@seed-design/dom-utils"; import { Drawer } from "@seed-design/react-drawer"; import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive"; import clsx from "clsx"; import { forwardRef } from "react"; import { createRenderTrackingContext } from "../../utils/createRenderTrackingContext"; import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext"; import { withStyleProps, type StyleProps } from "../../utils/styled"; const { withContext, useClassNames, ClassNamesProvider } = createSlotRecipeContext(bottomSheet); const closeButtonTracker = createRenderTrackingContext("BottomSheetCloseButton"); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetRootProps extends BottomSheetVariantProps, Omit {} export function BottomSheetRoot(props: BottomSheetRootProps) { const [variantProps, otherProps] = bottomSheet.splitVariantProps({ direction: "bottom" as const, lazyMount: true, unmountOnExit: true, ...props, }); const classNames = bottomSheet(variantProps); return ( ); } //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetTriggerProps extends Drawer.TriggerProps {} export const BottomSheetTrigger = Drawer.Trigger; //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetPositionerProps extends Drawer.PositionerProps {} export const BottomSheetPositioner = withContext( Drawer.Positioner, "positioner", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetBackdropProps extends Drawer.BackdropProps {} export const BottomSheetBackdrop = withContext( Drawer.Backdrop, "backdrop", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetContentProps extends Drawer.ContentProps {} export const BottomSheetContent = withContext( Drawer.Content, "content", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetHeaderProps extends Drawer.HeaderProps {} export const BottomSheetHeader = withContext( Drawer.Header, "header", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetTitleProps extends Drawer.TitleProps {} export const BottomSheetTitle = forwardRef( ({ className, ...props }, ref) => { const classNames = useClassNames(); const { isRendered } = closeButtonTracker.useRenderTracking(); return ( ); }, ); BottomSheetTitle.displayName = "BottomSheetTitle"; //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetDescriptionProps extends Drawer.DescriptionProps {} export const BottomSheetDescription = withContext< HTMLParagraphElement, BottomSheetDescriptionProps >(Drawer.Description, "description"); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetBodyProps extends PrimitiveProps, Pick< StyleProps, "paddingX" | "height" | "maxHeight" | "minHeight" | "justifyContent" | "alignItems" >, React.HTMLAttributes {} export const BottomSheetBody = withContext( withStyleProps(Primitive.div), "body", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetFooterProps extends PrimitiveProps, React.HTMLAttributes {} export const BottomSheetFooter = withContext( Primitive.div, "footer", ); //////////////////////////////////////////////////////////////////////////////////// export interface BottomSheetCloseButtonProps extends Drawer.CloseButtonProps {} export const BottomSheetCloseButton = forwardRef( ({ className, ...props }, ref) => { const classNames = useClassNames(); const { trackRef } = closeButtonTracker.useRenderTracking(); return ( ); }, ); BottomSheetCloseButton.displayName = "BottomSheetCloseButton";