{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chip",
  "type": "registry:ui",
  "title": "Chip",
  "description": "Chip is a compact interactive label for lightweight actions, selections, and filters.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-types.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/chip/Chip.context.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/chip/Chip.context.ts",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { ChipContextValue } from './Chip.types';\n\nexport const ChipContext = createContext<ChipContextValue | undefined>(undefined);\n\nexport const useChipContext = () => {\n  const context = useContext(ChipContext);\n\n  if (context === undefined) {\n    throw new Error('useChipContext must be used within a Chip');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/chip/Chip.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/chip/Chip.tsx",
      "content": "'use client';\n\nimport { forwardRef, type KeyboardEvent } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { ChipContext } from './Chip.context';\nimport type { ChipProps, ChipWithSubComponents } from './Chip.types';\nimport { chipMotionVariants, chipVariants } from './Chip.variants';\nimport { ChipIcon } from './ChipIcon';\n\nconst Chip = forwardRef<HTMLDivElement, ChipProps>(\n  (\n    {\n      className,\n      size = 'md',\n      variant = 'primary',\n      style = 'filled',\n      disabled,\n      defaultMotion,\n      children,\n      onKeyDown,\n      onKeyUp,\n      ...props\n    },\n    ref,\n  ) => {\n    const motion = useDefaultMotion(defaultMotion);\n\n    const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n      onKeyDown?.(event);\n      if (event.defaultPrevented || event.target !== event.currentTarget) return;\n      if (event.key === ' ') {\n        event.preventDefault();\n        return;\n      }\n      if (event.key === 'Enter' && !disabled) {\n        event.preventDefault();\n        event.currentTarget.click();\n      }\n    };\n\n    const handleKeyUp = (event: KeyboardEvent<HTMLDivElement>) => {\n      onKeyUp?.(event);\n      if (event.defaultPrevented || event.target !== event.currentTarget) return;\n      if (event.key === ' ' && !disabled) {\n        event.currentTarget.click();\n      }\n    };\n\n    return (\n      <ChipContext.Provider value={{ size, variant, style }}>\n        <div\n          className={cn(\n            chipVariants({ size, variant, style }),\n            chipMotionVariants({ enabled: motion }),\n            className,\n          )}\n          ref={ref}\n          tabIndex={disabled ? -1 : 0}\n          data-disabled={disabled || undefined}\n          aria-disabled={disabled || undefined}\n          role=\"button\"\n          data-slot=\"chip\"\n          onKeyDown={handleKeyDown}\n          onKeyUp={handleKeyUp}\n          {...props}\n        >\n          {children}\n        </div>\n      </ChipContext.Provider>\n    );\n  },\n) as ChipWithSubComponents;\n\nChip.displayName = 'Chip';\nChip.Icon = ChipIcon;\n\nexport { Chip };\n"
    },
    {
      "path": "src/components/chip/Chip.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/chip/Chip.types.ts",
      "content": "import type { RemixiconComponentType } from '@remixicon/react';\nimport type { VariantProps } from 'class-variance-authority';\nimport type {\n  ForwardRefExoticComponent,\n  HTMLAttributes,\n  PropsWithoutRef,\n  RefAttributes,\n} from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { RemixiconProps } from '@/lib/wideset/icon.types';\nimport type { chipVariants } from './Chip.variants';\nimport type { ChipIcon } from './ChipIcon';\n\nexport type ChipContextValue = {\n  size: VariantProps<typeof chipVariants>['size'];\n  variant: VariantProps<typeof chipVariants>['variant'];\n  style: VariantProps<typeof chipVariants>['style'];\n};\n\n/** An interactive label for selection, filtering, or dismissal. */\nexport type ChipProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> &\n  MotionProps &\n  VariantProps<typeof chipVariants> & {\n    /** Disables the chip interaction while preserving its layout and visual presence. */\n    disabled?: boolean;\n  };\n\nexport type ChipWithSubComponents = ForwardRefExoticComponent<\n  PropsWithoutRef<ChipProps> & RefAttributes<HTMLDivElement>\n> & {\n  Icon: typeof ChipIcon;\n};\n\n/** An icon rendered within `Chip`. */\nexport type ChipIconProps = RemixiconProps & {\n  /** Icon component rendered inside the chip and styled from the current chip context. */\n  icon: RemixiconComponentType;\n};\n"
    },
    {
      "path": "src/components/chip/Chip.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/chip/Chip.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { hoverTintMotion, pressMotion } from '@/lib/wideset/motion/recipes';\n\nexport const chipVariants = cva(\n  cn(\n    'group inline-flex cursor-pointer items-center data-disabled:pointer-events-none data-disabled:cursor-default',\n    'focus-visible:wds-focus-visible focus-visible:outline-ws-dynamic-primary-strong-default',\n  ),\n  {\n    variants: {\n      variant: {\n        primary: '',\n        secondary: '',\n      },\n      // Figma's Filled variants carry no stroke (strokes: []), so the border\n      // belongs to the Border style rather than the base.\n      style: {\n        filled: '',\n        border: 'border',\n      },\n      size: {\n        // gap = Figma frame itemSpacing + the 2px inset its \"Container\" wrapper\n        // adds on each side (Gap/0+2, Gap/2+2, Gap/3+2).\n        sm: 'rounded-ws-control-md typography-caption-strong-md h-ws-11 gap-ws-2 px-ws-3 py-ws-2',\n        md: 'rounded-ws-control-lg typography-label-strong-sm h-ws-14 gap-ws-3 px-ws-6 py-ws-2',\n        lg: 'rounded-ws-control-lg typography-label-strong-sm h-ws-16 gap-ws-4 px-ws-7 py-ws-4',\n      },\n    },\n    compoundVariants: [\n      {\n        variant: 'primary',\n        style: 'filled',\n        className: cn(\n          'bg-ws-dynamic-primary-default hover:bg-ws-dynamic-primary-hover active:bg-ws-dynamic-primary-pressed data-disabled:bg-ws-dynamic-primary-disabled',\n          // Figma binds Dynamic/Text/OnPrimary per state, not just default.\n          'text-ws-dynamic-on-primary-default hover:text-ws-dynamic-on-primary-hover active:text-ws-dynamic-on-primary-pressed data-disabled:text-ws-dynamic-on-primary-disabled',\n        ),\n      },\n      {\n        variant: 'primary',\n        style: 'border',\n        className:\n          'text-ws-dynamic-primary-default hover:text-ws-dynamic-primary-hover active:text-ws-dynamic-primary-pressed bg-ws-static-highlight-base border-ws-dynamic-primary-default hover:border-ws-dynamic-primary-hover active:border-ws-dynamic-primary-pressed data-disabled:border-ws-dynamic-primary-disabled data-disabled:text-ws-dynamic-primary-disabled',\n      },\n      {\n        variant: 'secondary',\n        style: 'filled',\n        // Figma holds the Secondary/Filled fill at Alpha/Strong/Default when\n        // disabled — only the label colour changes — and its label is\n        // Dynamic/Text/Secondary/Default at Default, Hover and Pressed alike.\n        className:\n          'bg-ws-dynamic-secondary-alpha-strong-default hover:bg-ws-dynamic-secondary-alpha-strong-hover active:bg-ws-dynamic-secondary-alpha-strong-pressed text-ws-dynamic-secondary-default data-disabled:text-ws-dynamic-on-secondary-disabled',\n      },\n      {\n        variant: 'secondary',\n        style: 'border',\n        className:\n          'text-ws-dynamic-secondary-default hover:text-ws-dynamic-secondary-hover active:text-ws-dynamic-secondary-pressed bg-ws-static-highlight-base border-ws-dynamic-secondary-default hover:border-ws-dynamic-secondary-hover active:border-ws-dynamic-secondary-pressed data-disabled:border-ws-dynamic-secondary-disabled data-disabled:text-ws-dynamic-on-secondary-disabled',\n      },\n    ],\n    defaultVariants: {\n      variant: 'primary',\n      size: 'md',\n    },\n  },\n);\n\nexport const chipMotionVariants = cva('', {\n  variants: {\n    enabled: { true: cn(hoverTintMotion, pressMotion), false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n\n/**\n * The prefix slot Figma calls `Entity`. It is Size/9 (16) at sm and md and\n * Size/11 (20) at lg — the extra room exists so Logo and Avatar prefixes fit\n * alongside the icon, which stays Size/9 at every size.\n */\nexport const chipIconSlotVariants = cva('inline-flex shrink-0 items-center justify-center', {\n  variants: {\n    size: {\n      sm: 'size-ws-9',\n      md: 'size-ws-9',\n      lg: 'size-ws-11',\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n});\n\nexport const chipIconVariants = cva('', {\n  variants: {\n    variant: {\n      primary: '',\n      secondary: '',\n    },\n    style: {\n      filled: '',\n      border: '',\n    },\n    // Figma draws the glyph at Size/9 (16) at every chip size; only the prefix\n    // slot grows to Size/11 (20) at Large, to make room for Avatar/Logo prefixes.\n    size: {\n      sm: 'size-ws-9',\n      md: 'size-ws-9',\n      lg: 'size-ws-9',\n    },\n  },\n  compoundVariants: [\n    {\n      variant: 'primary',\n      style: 'filled',\n      className:\n        'text-ws-dynamic-on-primary-default group-data-disabled:text-ws-dynamic-on-primary-disabled',\n    },\n    {\n      variant: 'primary',\n      style: 'border',\n      className:\n        'text-ws-dynamic-primary-default group-data-disabled:text-ws-dynamic-primary-disabled',\n    },\n    {\n      variant: 'secondary',\n      style: 'filled',\n      className:\n        'text-ws-dynamic-on-secondary-default group-data-disabled:text-ws-dynamic-on-secondary-disabled',\n    },\n    {\n      variant: 'secondary',\n      style: 'border',\n      className:\n        'text-ws-dynamic-secondary-default group-data-disabled:text-ws-dynamic-on-secondary-disabled',\n    },\n  ],\n  defaultVariants: {\n    variant: 'primary',\n    style: 'filled',\n    size: 'md',\n  },\n});\n"
    },
    {
      "path": "src/components/chip/ChipIcon.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/chip/ChipIcon.tsx",
      "content": "'use client';\n\nimport { forwardRef } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useChipContext } from './Chip.context';\nimport type { ChipIconProps } from './Chip.types';\nimport { chipIconSlotVariants, chipIconVariants } from './Chip.variants';\n\nconst ChipIcon = forwardRef<SVGSVGElement, ChipIconProps>(\n  ({ className, icon: Icon, ...props }, ref) => {\n    const { size, variant, style } = useChipContext();\n\n    return (\n      <span data-slot=\"chip-icon\" className={chipIconSlotVariants({ size })}>\n        <Icon\n          ref={ref}\n          {...props}\n          aria-hidden=\"true\"\n          focusable=\"false\"\n          className={cn(chipIconVariants({ size, variant, style }), className)}\n        />\n      </span>\n    );\n  },\n);\n\nChipIcon.displayName = 'Chip.Icon';\n\nexport { ChipIcon };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
