import * as React from 'react'; import { TouchableOpacity, View, ViewStyle } from 'react-native'; import { getColor } from './style-utils'; import Text from './text'; type ChipVariant = 'outline' | 'neutralLow' | 'staticWhite'; type ChipSize = 'small' | 'medium'; type ChipShape = 'pill' | 'round'; interface IconProps { icon: React.ReactNode; gap?: string | number; } interface ChipPreset { backgroundColor: string; textColor: string; borderColor: string; borderWidth: number; } const CHIP_PRESETS: Record = { outline: { backgroundColor: 'transparent', textColor: '#111827', borderColor: '#E5E7EB', borderWidth: 1, }, neutralLow: { backgroundColor: '#F3F4F6', textColor: '#111827', borderColor: 'transparent', borderWidth: 0, }, staticWhite: { backgroundColor: 'transparent', textColor: 'white', borderColor: 'white', borderWidth: 1, }, }; const SIZE_STYLES = { small: { height: 'h-[32px]', padding: 'px-[10px] py-[6px]', textProps: { face: 'body' as const, size: 'small' as const, weight: 'medium' as const, }, }, medium: { height: 'h-[36px]', padding: 'px-[12px] py-[6px]', textProps: { face: 'body' as const, size: 'medium' as const, weight: 'medium' as const, }, }, }; interface ChipProps { variant?: ChipVariant; size?: ChipSize; shape?: ChipShape; text: string; disabled?: boolean; leftIcon?: IconProps; rightIcon?: IconProps; className?: string; style?: ViewStyle; onPress?: () => void; } export default function Chip({ variant = 'outline', size = 'medium', shape = 'pill', text, disabled = false, leftIcon, rightIcon, className, style, onPress, }: ChipProps) { const preset = CHIP_PRESETS[variant]; const sizeStyle = SIZE_STYLES[size]; const shapeClass = shape === 'pill' ? 'rounded-full' : 'rounded-lg'; const getMarginStyle = (gap?: string | number, isLeft: boolean = true) => { if (!gap) return {}; if (typeof gap === 'number') { return isLeft ? { marginRight: gap } : { marginLeft: gap }; } return { className: gap }; }; return ( {leftIcon && ( {leftIcon.icon} )} {text} {rightIcon && ( {rightIcon.icon} )} ); }