{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chip",
  "title": "Chip",
  "description": "Displays a compact, rounded chip element.",
  "registryDependencies": [],
  "files": [
    {
      "path": "ui/chip.tsx",
      "content": "import { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n  Children,\n  cloneElement,\n  createContext,\n  useContext,\n  useMemo,\n} from \"react\";\nimport { Pressable, Text } from \"react-native\";\nimport { cn } from \"../lib/utils\";\n\n// Types\ntype InternalChipContextType = VariantProps<typeof chipVariants> & {\n  disabled?: boolean;\n};\n\ntype ChipChildProps = {\n  children: React.ReactNode;\n  className?: string;\n};\n\nexport type ChipProps = React.ComponentProps<typeof Pressable> &\n  InternalChipContextType & {\n    children: React.ReactNode;\n  };\n\n// Context\nconst ChipContext = createContext<InternalChipContextType | null>(null);\n\nconst useChipContext = () => {\n  const context = useContext(ChipContext);\n  if (!context) {\n    throw new Error(\"useChipContext must be used within a Chip component\");\n  }\n  return context;\n};\n\n// Components\nexport const Chip = ({\n  accessibilityRole = \"button\",\n  children,\n  className,\n  disabled,\n  variant,\n  ...props\n}: ChipProps) => {\n  const ctx = useMemo(() => {\n    return {\n      disabled,\n      variant,\n    };\n  }, [disabled, variant]);\n\n  return (\n    <ChipContext.Provider value={ctx}>\n      <Pressable\n        accessibilityRole={accessibilityRole}\n        accessibilityState={{ disabled }}\n        className={cn(chipVariants({ className, variant }))}\n        {...props}\n      >\n        {Children.map(children, (child) => {\n          if (typeof child === \"string\") {\n            return <ChipText>{child}</ChipText>;\n          }\n\n          return child;\n        })}\n      </Pressable>\n    </ChipContext.Provider>\n  );\n};\n\nexport const ChipText = (props: ChipChildProps) => {\n  const ctx = useChipContext();\n\n  return (\n    <Text {...props} className={cn(chipTextVariants(ctx), props.className)} />\n  );\n};\n\nexport const ChipIcon = ({ children, ...props }: ChipChildProps) => {\n  const ctx = useChipContext();\n\n  const child = Children.only(children);\n\n  if (!child) {\n    if (__DEV__) {\n      throw new Error(\"ChipIcon expects a single React element as children\");\n    }\n    return null;\n  }\n\n  return cloneElement(child as React.ReactElement<ChipChildProps>, {\n    ...props,\n    className: cn(chipIconVariants(ctx), props.className),\n  });\n};\n\n// Styles\nconst chipVariants = cva(\n  \"flex w-fit shrink-0 flex-row items-center justify-center gap-1 self-start overflow-hidden whitespace-nowrap rounded-full px-2.5 py-1.5 font-medium text-xs\",\n  {\n    defaultVariants: {\n      variant: \"default\",\n    },\n    variants: {\n      variant: {\n        default: \"bg-primary active:bg-primary/80\",\n        destructive:\n          \"bg-destructive active:bg-destructive/80 dark:bg-destructive/60\",\n        outline:\n          \"border border-border bg-card active:bg-accent/90 dark:border-input dark:bg-input/30 dark:active:bg-input/50\",\n        secondary: \"bg-secondary active:bg-secondary/50\",\n      },\n    },\n  }\n);\n\nconst chipTextVariants = cva(\n  \"whitespace-nowrap font-semibold text-sm leading-tight\",\n  {\n    defaultVariants: {\n      variant: \"default\",\n    },\n    variants: {\n      variant: {\n        default: \"text-primary-foreground\",\n        destructive: \"text-white\",\n        outline: \"text-foreground\",\n        secondary: \"text-secondary-foreground\",\n      },\n    },\n  }\n);\n\nconst chipIconVariants = cva(\"size-4\", {\n  defaultVariants: {\n    variant: \"default\",\n  },\n  variants: {\n    variant: {\n      default: \"text-primary-foreground\",\n      destructive: \"text-white\",\n      outline: \"text-foreground\",\n      secondary: \"text-secondary-foreground\",\n    },\n  },\n});\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
