'use client'; import { createMenu } from '@gluestack-ui/core/menu/creator'; import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { tva } from '@gluestack-ui/utils/nativewind-utils'; import { styled } from 'nativewind'; import React from 'react'; import { Pressable, ScrollView, Text, View } from 'react-native'; import Animated, { FadeOut, ZoomIn } from 'react-native-reanimated'; const AnimatedView = Animated.createAnimatedComponent(ScrollView); const menuStyle = tva({ base: 'rounded-md bg-popover text-popover-foreground border border-border p-1 shadow-hard-5 max-h-[300px] overflow-y-auto', }); const menuItemStyle = tva({ base: 'min-w-[200px] p-3 flex-row items-center rounded data-[hover=true]:bg-accent data-[hover=true]:text-accent-foreground data-[active=true]:bg-accent data-[active=true]:text-accent-foreground data-[focus=true]:bg-accent data-[focus=true]:text-accent-foreground data-[focus=true]:web:outline-none data-[focus=true]:web:outline-0 data-[disabled=true]:opacity-40 data-[disabled=true]:web:cursor-not-allowed data-[focus-visible=true]:web:outline-2 data-[focus-visible=true]:web:outline-ring data-[focus-visible=true]:web:outline data-[focus-visible=true]:web:cursor-pointer data-[disabled=true]:data-[focus=true]:bg-transparent', }); const menuBackdropStyle = tva({ base: 'absolute top-0 bottom-0 left-0 right-0 web:cursor-default', }); const menuSeparatorStyle = tva({ base: 'bg-border h-px w-full', }); const menuItemLabelStyle = tva({ base: 'text-popover-foreground font-normal font-body', variants: { isTruncated: { true: 'web:truncate', }, bold: { true: 'font-bold', }, underline: { true: 'underline', }, strikeThrough: { true: 'line-through', }, sub: { true: 'text-xs', }, italic: { true: 'italic', }, highlight: { true: 'bg-yellow-500', }, }, }); const BackdropPressable = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef & VariantProps >(function BackdropPressable({ className, ...props }, ref) { return ( ); }); type IMenuItemProps = VariantProps & { className?: string; } & React.ComponentPropsWithoutRef; const Item = React.forwardRef< React.ComponentRef, IMenuItemProps >(function Item({ className, ...props }, ref) { return ( ); }); const Separator = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef & VariantProps >(function Separator({ className, ...props }, ref) { return ( ); }); const StyledAnimatedView = styled(AnimatedView, { className: 'style', }); export const UIMenu = createMenu({ Root: StyledAnimatedView, Item: Item, Label: Text, Backdrop: BackdropPressable, Separator: Separator, }); type IMenuProps = React.ComponentProps & VariantProps & { className?: string }; type IMenuItemLabelProps = React.ComponentProps & VariantProps & { className?: string }; const Menu = React.forwardRef, IMenuProps>( function Menu({ className, ...props }, ref) { return ( ); } ); const MenuItem = UIMenu.Item; const MenuItemLabel = React.forwardRef< React.ComponentRef, IMenuItemLabelProps >(function MenuItemLabel( { className, isTruncated, bold, underline, strikeThrough, sub, italic, highlight, ...props }, ref ) { return ( ); }); const MenuSeparator = UIMenu.Separator; Menu.displayName = 'Menu'; MenuItem.displayName = 'MenuItem'; MenuItemLabel.displayName = 'MenuItemLabel'; MenuSeparator.displayName = 'MenuSeparator'; export { Menu, MenuItem, MenuItemLabel, MenuSeparator };