/** * @file ui:bottom-sheet * @requires @seed-design/lynx-react@>=0.1.0 <1.0.0 * @requires @seed-design/lynx-css@>=0.1.0 <1.0.0 **/import { BottomSheet as SeedBottomSheet, type BottomSheetBodyProps as SeedBottomSheetBodyProps, type BottomSheetContentProps as SeedBottomSheetContentProps, type BottomSheetFooterProps as SeedBottomSheetFooterProps, type BottomSheetRootProps as SeedBottomSheetRootProps, type BottomSheetRootRef as SeedBottomSheetRootRef, type BottomSheetTriggerProps as SeedBottomSheetTriggerProps,} from "@seed-design/lynx-react";import { forwardRef, type ForwardRefExoticComponent, type PropsWithoutRef, type ReactNode, type RefAttributes,} from "@lynx-js/react";export interface BottomSheetRootProps extends SeedBottomSheetRootProps {}export type BottomSheetRootRef = SeedBottomSheetRootRef;/** * @see https://crispy.carrot-soft.tech/lynx/components/bottom-sheet */export const BottomSheetRoot: ForwardRefExoticComponent< PropsWithoutRef<BottomSheetRootProps> & RefAttributes<SeedBottomSheetRootRef>> = forwardRef<SeedBottomSheetRootRef, BottomSheetRootProps>((props, ref) => { return <SeedBottomSheet.Root ref={ref} {...props} />;});BottomSheetRoot.displayName = "BottomSheetRoot";export interface BottomSheetTriggerProps extends SeedBottomSheetTriggerProps {}export const BottomSheetTrigger = SeedBottomSheet.Trigger;export interface BottomSheetContentProps extends Omit<SeedBottomSheetContentProps, "title"> { title?: ReactNode; description?: ReactNode; /** * @default false */ showHandle?: boolean;}/** * Positioner / Backdrop / Handle / Header / Title / Description을 내부에서 조립해 * 사용자가 단일 컴포넌트로 콘텐츠를 구성할 수 있도록 한다. * * 웹 BottomSheetContent와 달리 아래는 Lynx에서 미지원: * - `showCloseButton` (Tier B: SVG 지원 후 추가 예정) * - `accessibility-label` 기반 VisuallyHidden 제목 fallback (VisuallyHidden 미구현) */export const BottomSheetContent = (props: BottomSheetContentProps) => { const { children, title, description, showHandle = false, ...otherProps } = props; const shouldRenderHeader = title || description; return ( <SeedBottomSheet.Positioner> <SeedBottomSheet.Backdrop /> <SeedBottomSheet.Content {...otherProps}> {showHandle && <SeedBottomSheet.Handle />} {shouldRenderHeader && ( <SeedBottomSheet.Header> {title && <SeedBottomSheet.Title>{title}</SeedBottomSheet.Title>} {description && ( <SeedBottomSheet.Description>{description}</SeedBottomSheet.Description> )} </SeedBottomSheet.Header> )} {children} </SeedBottomSheet.Content> </SeedBottomSheet.Positioner> );};export interface BottomSheetBodyProps extends SeedBottomSheetBodyProps {}export const BottomSheetBody: (props: BottomSheetBodyProps) => ReactNode = SeedBottomSheet.Body;export interface BottomSheetFooterProps extends SeedBottomSheetFooterProps {}export const BottomSheetFooter: (props: BottomSheetFooterProps) => ReactNode = SeedBottomSheet.Footer;/** * This file is a snippet from Crispy, helping you get started quickly with @seed-design/* packages. * You can extend this snippet however you want. */
@seed-design/lynx-react's BottomSheet wraps @lynx-js/lynx-ui-sheet. Drag, spring, snap, and presence behaviors are handled by lynx-ui-sheet. Crispy provides public APIs and recipe slot styles.
The Registry BottomSheetContent internally assembles Positioner, Backdrop, and Header. BottomSheetTrigger must be placed outside Content to open the sheet by tapping.
In the low-level package API, specifying container to BottomSheet.Positioner uses the <overlay> XElement. The Registry default uses <view>. If you need container, verify that your app's Lynx Engine supports <overlay>.
To open and close the Bottom Sheet in ways other than using Trigger, control the state with open and onOpenChange. The example below opens the Bottom Sheet 1 second after tapping a button.
Lynx's onOpenChange only passes the changed open value. The React version's details.reason is not supported. If you need the reason for opening or closing, record the reason in separate state from event handlers on buttons owned by your app and Trigger. Background tap and drag cannot be distinguished by callback value alone.
BottomSheetBody renders a native <view>. To create a scrollable area with a maximum of 300px, place <scroll-view> inside Body and specify height, maxHeight, and flex: "none" together. If you only specify maxHeight on Lynx's scroll-view, the area may shrink to 0px because content size cannot be calculated as height.
In snapPoints, you can use pixel numbers, percentages based on screen height, or "fit" to match content size. The array order becomes the snap index, and initialSnap specifies the height when first opened.
In onSnapChange, you can receive the current index and pixel-calculated height. Use ref's snapTo method to move to your desired height.
Verify the final behavior of drag and snap animations in Lynx Explorer from the QR code tab. Device and gesture handling results may differ in the document preview.
Lynx does not support fadeFromIndex. Use the default Backdrop provided by Registry. If dim changes per snap index are absolutely necessary, assemble Backdrop directly with the low-level package API and control opacity based on onSnapChange state.
Lynx's BottomSheetContent does not support showCloseButton and CloseButton. If a close button is needed, use controlled state and change open to false from a button in BottomSheetFooter.
Lynx does not have a dismissible prop to control background tap, drag, and ESC close at once. Drag can be prevented with enableDragToClose={false} on BottomSheetRoot. If you also need to prevent background tap, assemble with the low-level package API and pass clickToClose={false} to BottomSheet.Backdrop. Lynx does not have ESC key close behavior like the web. If you've prevented close behavior, provide an explicit close button in Footer or elsewhere.
BottomSheetBody is a native <view> that does not determine scroll method. If scroll hints are needed, place ScrollFog directly inside Body. In this structure, you can control size, placement, hideScrollBar, and native scroll-view props directly where they're used.
Native fading-edge-length displays fog only at edges where scrollable content remains. Initially at the bottom, it displays at the top when scrolled to the end.
Pass handleOnly to <BottomSheetRoot> to restrict the vertical gesture area that moves the Bottom Sheet to the Handle. Use this option together with <BottomSheetContent showHandle>. For long body text, this combination is recommended to prevent overlap between scroll areas inside Body and sheet drag.