'use client'; import { H4 } from '@expo/html-elements'; import { createActionsheet } from '@gluestack-ui/core/actionsheet/creator'; import { UIIcon } from '@gluestack-ui/core/icon/creator'; import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { tva } from '@gluestack-ui/utils/nativewind-utils'; import { AnimatePresence, createMotionAnimatedComponent, Motion, MotionComponentProps, } from '@legendapp/motion'; import { styled } from 'nativewind'; import React from 'react'; import { FlatList, Pressable, PressableProps, ScrollView, SectionList, Text, View, ViewStyle, VirtualizedList, } from 'react-native'; const ItemWrapper = React.forwardRef< React.ComponentRef, PressableProps >(function ItemWrapper({ ...props }, ref) { return ; }); type IMotionViewProps = React.ComponentProps & MotionComponentProps; const MotionView = Motion.View as React.ComponentType; type IAnimatedPressableProps = React.ComponentProps & MotionComponentProps; const AnimatedPressable = createMotionAnimatedComponent( Pressable ) as React.ComponentType; const StyledUIIcon = styled(UIIcon, { className: "style" }); export const UIActionsheet = createActionsheet({ Root: View, Content: MotionView, Item: ItemWrapper, ItemText: Text, DragIndicator: View, IndicatorWrapper: View, Backdrop: AnimatedPressable, ScrollView: ScrollView, VirtualizedList: VirtualizedList, FlatList: FlatList, SectionList: SectionList, SectionHeaderText: H4, Icon: StyledUIIcon, AnimatePresence: AnimatePresence, }); const actionsheetStyle = tva({ base: 'w-full h-full web:pointer-events-none' }); const actionsheetContentStyle = tva({ base: 'items-center rounded-t-lg p-4 bg-background web:pointer-events-auto web:select-none border-t border-border dark:border-border/10 max-h-[80vh] pb-safe', }); const actionsheetItemStyle = tva({ base: 'w-full flex-row items-center p-3 rounded-sm data-[disabled=true]:opacity-40 data-[disabled=true]:web:pointer-events-auto data-[disabled=true]:web:cursor-not-allowed data-[hover=true]:bg-accent data-[active=true]:bg-accent data-[focus=true]:bg-accent web:data-[focus-visible=true]:bg-accent gap-2', }); const actionsheetItemTextStyle = tva({ base: 'text-foreground font-normal text-sm', variants: { isTruncated: { true: '', }, bold: { true: 'font-bold', }, underline: { true: 'underline', }, strikeThrough: { true: 'line-through', }, }, }); const actionsheetDragIndicatorStyle = tva({ base: 'w-[100px] h-2 bg-muted rounded-full', }); const actionsheetDragIndicatorWrapperStyle = tva({ base: 'w-full py-1 items-center', }); const actionsheetBackdropStyle = tva({ base: 'absolute left-0 top-0 right-0 bottom-0 bg-[#000]/50 web:cursor-default web:pointer-events-auto', }); const actionsheetScrollViewStyle = tva({ base: 'w-full h-auto', }); const actionsheetVirtualizedListStyle = tva({ base: 'w-full h-auto', }); const actionsheetFlatListStyle = tva({ base: 'w-full h-auto', }); const actionsheetSectionListStyle = tva({ base: 'w-full h-auto', }); const actionsheetSectionHeaderTextStyle = tva({ base: 'leading-5 font-semibold my-0 text-muted-foreground p-3 uppercase text-xs', variants: { isTruncated: { true: '', }, bold: { true: 'font-bold', }, underline: { true: 'underline', }, strikeThrough: { true: 'line-through', }, sub: { true: 'text-xs', }, italic: { true: 'italic', }, highlight: { true: 'bg-yellow-500', }, }, }); const actionsheetIconStyle = tva({ base: 'text-foreground fill-none h-4 w-4', }); type IActionsheetProps = VariantProps & React.ComponentPropsWithoutRef; type IActionsheetContentProps = VariantProps & React.ComponentPropsWithoutRef & { className?: string; }; type IActionsheetItemProps = VariantProps & React.ComponentPropsWithoutRef; type IActionsheetItemTextProps = VariantProps & React.ComponentPropsWithoutRef; type IActionsheetDragIndicatorProps = VariantProps< typeof actionsheetDragIndicatorStyle > & React.ComponentPropsWithoutRef; type IActionsheetDragIndicatorWrapperProps = VariantProps< typeof actionsheetDragIndicatorWrapperStyle > & React.ComponentPropsWithoutRef; type IActionsheetBackdropProps = VariantProps & React.ComponentPropsWithoutRef & { className?: string; }; type IActionsheetScrollViewProps = VariantProps< typeof actionsheetScrollViewStyle > & React.ComponentPropsWithoutRef; type IActionsheetVirtualizedListProps = VariantProps< typeof actionsheetVirtualizedListStyle > & React.ComponentPropsWithoutRef; type IActionsheetFlatListProps = VariantProps & React.ComponentPropsWithoutRef; type IActionsheetSectionListProps = VariantProps< typeof actionsheetSectionListStyle > & React.ComponentPropsWithoutRef; type IActionsheetSectionHeaderTextProps = VariantProps< typeof actionsheetSectionHeaderTextStyle > & React.ComponentPropsWithoutRef; type IActionsheetIconProps = VariantProps & React.ComponentPropsWithoutRef & { className?: string; as?: React.ElementType; height?: number; width?: number; }; const Actionsheet = React.forwardRef< React.ComponentRef, IActionsheetProps >(function Actionsheet({ className, ...props }, ref) { return ( ); }); const ActionsheetContent = React.forwardRef< React.ComponentRef, IActionsheetContentProps >(function ActionsheetContent({ className, ...props }, ref) { return ( ); }); const ActionsheetItem = React.forwardRef< React.ComponentRef, IActionsheetItemProps >(function ActionsheetItem({ className, ...props }, ref) { return ( ); }); const ActionsheetItemText = React.forwardRef< React.ComponentRef, IActionsheetItemTextProps >(function ActionsheetItemText( { isTruncated, bold, underline, strikeThrough, className, ...props }, ref ) { return ( ); }); const ActionsheetDragIndicator = React.forwardRef< React.ComponentRef, IActionsheetDragIndicatorProps >(function ActionsheetDragIndicator({ className, ...props }, ref) { return ( ); }); const ActionsheetDragIndicatorWrapper = React.forwardRef< React.ComponentRef, IActionsheetDragIndicatorWrapperProps >(function ActionsheetDragIndicatorWrapper({ className, ...props }, ref) { return ( ); }); const ActionsheetBackdrop = React.forwardRef< React.ComponentRef, IActionsheetBackdropProps >(function ActionsheetBackdrop({ className, ...props }, ref) { return ( ); }); const ActionsheetScrollView = React.forwardRef< React.ComponentRef, IActionsheetScrollViewProps >(function ActionsheetScrollView({ className, ...props }, ref) { return ( ); }); const ActionsheetVirtualizedList = React.forwardRef< React.ComponentRef, IActionsheetVirtualizedListProps >(function ActionsheetVirtualizedList({ className, ...props }, ref) { return ( ); }); const ActionsheetFlatList = React.forwardRef< React.ComponentRef, IActionsheetFlatListProps >(function ActionsheetFlatList({ className, ...props }, ref) { return ( ); }); const ActionsheetSectionList = React.forwardRef< React.ComponentRef, IActionsheetSectionListProps >(function ActionsheetSectionList({ className, ...props }, ref) { return ( ); }); const ActionsheetSectionHeaderText = React.forwardRef< React.ComponentRef, IActionsheetSectionHeaderTextProps >(function ActionsheetSectionHeaderText( { className, isTruncated, bold, underline, strikeThrough, sub, italic, highlight, ...props }, ref ) { return ( ); }); const ActionsheetIcon = React.forwardRef< React.ComponentRef, IActionsheetIconProps >(function ActionsheetIcon({ className, height, width, ...props }, ref) { if (typeof height === 'number' || typeof width === 'number') { return ( ); } return ( ); }); export { Actionsheet, ActionsheetBackdrop, ActionsheetContent, ActionsheetDragIndicator, ActionsheetDragIndicatorWrapper, ActionsheetFlatList, ActionsheetIcon, ActionsheetItem, ActionsheetItemText, ActionsheetScrollView, ActionsheetSectionHeaderText, ActionsheetSectionList, ActionsheetVirtualizedList };