// styled Sheet = the unstyled @tamagui/ui Sheet behavior primitive + the // default v2-look skin, layered here in `tamagui`. Single skin definition; the // shadcn registry item is generated from this file. import { createRefComponent, type GetProps, type GetRef, styled, withStaticProperties, } from '@tamagui/core' import { Sheet as SheetBehavior, type SheetProps, useSheetContext } from '@tamagui/sheet' const SheetHandleFrame = styled(SheetBehavior.Handle, { displayName: 'SheetHandle', height: 10, borderRadius: 1000, backgroundColor: 'color-5', zIndex: 10, marginHorizontal: '35%', marginBottom: '2', // Handle opacity aesthetics live in the skin, not the behavior package. opacity: '0.5 hover:0.7', variants: { open: { true: { opacity: 1, }, false: { opacity: 0, }, }, } as const, }) // the behavior forwards `open` to its inner handle frame, not to this styled // wrapper, so read the sheet context here and forward `open` — otherwise the // open-opacity variant above never toggles. export const SheetHandle = createRefComponent< GetRef, GetProps >(function SheetHandle(props, ref) { const context = useSheetContext((props as any).scope) return }) export const SheetOverlay = styled(SheetBehavior.Overlay, { displayName: 'SheetOverlay', backgroundColor: 'shadow-color', opacity: 0.45, }) export const SheetContainer = styled(SheetBehavior.Container, { displayName: 'SheetContainer', // no padding on the Container: the keyboard-avoidance measures this frame, and // in snapPointsMode="fit" any vertical padding here inflates the frame beyond // the preserved fit height, so the keyboard lift is off by exactly the padding // (SheetWebKeyboard geometry). Content inset comes from the ScrollView skin + // the consumer's own content padding, matching the pre-skin baseline. }) export const SheetBackground = styled(SheetBehavior.Background, { displayName: 'SheetBackground', backgroundColor: 'background', borderTopLeftRadius: '6', borderTopRightRadius: '6', }) export const SheetScrollView = styled(SheetBehavior.ScrollView, { displayName: 'SheetScrollView', // no flex here: the behavior's fitSizingStyle sets flex per mode (undefined for // snapPointsMode="fit" so the content-sized Container doesn't collapse, 1 // otherwise), and consumer props apply AFTER that guard — a skin-level flex:1 // would override it and collapse the fit-mode scrollview (SheetWebKeyboard). paddingHorizontal: '2', }) const sheetParts = { Container: SheetContainer, Background: SheetBackground, Overlay: SheetOverlay, Handle: SheetHandle, ScrollView: SheetScrollView, } type SheetRef = GetRef export const SheetRoot = createRefComponent( function SheetRoot(props, ref) { return } ) const SheetControlledRoot = createRefComponent< SheetRef, Omit >(function SheetControlled(props, ref) { return }) export const SheetControlled = withStaticProperties(SheetControlledRoot, sheetParts) export const Sheet = withStaticProperties(SheetRoot, { Root: SheetRoot, Controlled: SheetControlled, useAnimatedPosition: SheetBehavior.useAnimatedPosition, ...sheetParts, })