'use client' import { createCheckbox } from '@gluestack-ui/checkbox' import { IPrimitiveIcon, PrimitiveIcon, UIIcon } from '@gluestack-ui/icon' import type { VariantProps } from '@gluestack-ui/nativewind-utils' import { tva } from '@gluestack-ui/nativewind-utils/tva' import { useStyleContext, withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext' import { cssInterop } from 'nativewind' import { Check } from 'phosphor-react-native' import React, { FC, ReactNode } from 'react' import { Pressable, View } from 'react-native' import type { ViewProps } from 'react-native' import Text from '../text' const IndicatorWrapper = React.forwardRef, ViewProps & { states?: any }>( function IndicatorWrapper({ ...props }, ref) { const { size: parentSize } = useStyleContext(SCOPE) return ( {props.states.active && ( )} ) }, ) const IconWrapper = React.forwardRef< React.ComponentRef, IPrimitiveIcon & { dataSet?: Record } >(function IconWrapper({ ...props }, ref) { return }) const SCOPE = 'CHECKBOX' const UICheckbox = createCheckbox({ Root: withStyleContext(Pressable, SCOPE), Group: View, Icon: IconWrapper, Label: View, Indicator: IndicatorWrapper, }) cssInterop(PrimitiveIcon, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, fill: true, color: 'classNameColor', stroke: true, }, }, }) const checkboxStyle = tva({ base: 'group/checkbox flex-row items-center justify-start', variants: { size: { lg: 'gap-2', md: 'gap-2', }, }, }) const checkboxIndicatorStyle = tva({ base: '-z-5 relative items-center justify-center rounded-[var(--checkbox-radius)] border-selector-border bg-selector-background data-[checked=true]:border-selector-border-active data-[checked=true]:bg-selector-accent-true data-[invalid=true]:border-destructive-border data-[active=true]:data-[checked=true]:bg-selector-accent-onTap data-[active=true]:data-[checked=true]:border-selector-border-active data-[active=true]:!border-selector-border-onTap data-[disabled=true]:border-disabled-border data-[disabled=true]:bg-disabled', parentVariants: { size: { lg: 'size-[var(--lg-checkbox-size)] border-[length:var(--lg-checkbox-border-size)]', md: 'size-[var(--checkbox-size)] border-[length:var(--checkbox-border-size)]', }, }, }) const checkboxOnTapStyle = tva({ base: 'absolute rounded-full bg-selector-accent-onTap opacity-5', parentVariants: { size: { lg: '-left-[calc(var(--lg-radio-onTap-size)/2-var(--lg-radio-size)/2)] -top-[calc(var(--lg-radio-onTap-size)/2-var(--lg-radio-size)/2)] size-[var(--lg-radio-onTap-size)]', md: '-left-[calc(var(--radio-onTap-size)/2-var(--radio-size)/2)] -top-[calc(var(--radio-onTap-size)/2-var(--radio-size)/2)] size-[var(--radio-onTap-size)]', }, }, }) const checkboxIconStyle = tva({ base: 'fill-selector-foreground data-[disabled=true]:fill-disabled-foreground', parentVariants: { size: { lg: 'size-[var(--lg-checkbox-icon-size)]', md: 'size-[var(--checkbox-icon-size)]', }, }, }) const CheckboxGroup = UICheckbox.Group type ICheckboxProps = React.ComponentPropsWithoutRef & VariantProps const CheckboxWrapper = React.forwardRef, ICheckboxProps>(function Checkbox( { className, size = 'md', ...props }, ref, ) { return ( ) }) type ICheckboxIndicatorProps = React.ComponentPropsWithoutRef & VariantProps const CheckboxIndicator = React.forwardRef, ICheckboxIndicatorProps>( function CheckboxIndicator({ className, ...props }, ref) { const { size: parentSize } = useStyleContext(SCOPE) return ( ) }, ) type ICheckboxLabelProps = React.ComponentPropsWithoutRef const CheckboxLabel = React.forwardRef, ICheckboxLabelProps>( function CheckboxLabel({ className, children, ...props }, ref) { return ( {typeof children === 'string' ? ( {children} ) : ( children )} ) }, ) type ICheckboxIconProps = React.ComponentPropsWithoutRef & VariantProps const CheckboxIcon = React.forwardRef, ICheckboxIconProps>( function CheckboxIcon({ className, size, ...props }, ref) { const { size: parentSize, isDisabled } = useStyleContext(SCOPE) if (typeof size === 'number') { return ( ) } else if ((props.height !== undefined || props.width !== undefined) && size === undefined) { return ( ) } return ( ) }, ) const Checkbox: FC = ({ label, ...props }) => { return ( {label && {label}} ) } Checkbox.displayName = 'Checkbox' CheckboxWrapper.displayName = 'CheckboxWrapper' CheckboxIndicator.displayName = 'CheckboxIndicator' CheckboxLabel.displayName = 'CheckboxLabel' CheckboxIcon.displayName = 'CheckboxIcon' export { Checkbox, CheckboxWrapper, CheckboxIndicator, CheckboxLabel, CheckboxIcon, CheckboxGroup }