{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkbox",
  "type": "registry:ui",
  "title": "Checkbox",
  "description": "Checkbox allows users to select one or more items from a set.",
  "dependencies": [
    "@radix-ui/react-checkbox@^1.3.3",
    "@radix-ui/react-label@^2.1.8",
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/checkbox/Checkbox.context.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/Checkbox.context.ts",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { CheckboxContextType } from './Checkbox.types';\n\nexport const CheckboxContext = createContext<CheckboxContextType | null>(null);\n\nexport const useCheckboxContext = () => {\n  const context = useContext(CheckboxContext);\n\n  if (context === null) {\n    throw new Error('useCheckboxContext must be used within a Checkbox');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/checkbox/Checkbox.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/Checkbox.tsx",
      "content": "'use client';\n\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport * as Label from '@radix-ui/react-label';\nimport { RiCheckLine } from '@remixicon/react';\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { CheckboxContext } from './Checkbox.context';\nimport type { CheckboxProps, CheckboxWithVariants } from './Checkbox.types';\nimport {\n  checkboxCheckedIndicatorVariants,\n  checkboxIndeterminateIndicatorVariants,\n  checkboxIndicatorMotionVariants,\n  checkboxMotionVariants,\n  checkboxVariants,\n} from './Checkbox.variants';\nimport { CheckboxDescription } from './CheckboxDescription';\nimport { CheckboxGroup } from './CheckboxGroup';\nimport { CheckboxLabel } from './CheckboxLabel';\n\nconst Checkbox = React.forwardRef<React.ComponentRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(\n  (\n    {\n      className,\n      size = 'lg',\n      variant = 'primary',\n      id,\n      label,\n      description,\n      disabled,\n      defaultMotion,\n      children,\n      'aria-describedby': ariaDescribedBy,\n      ...props\n    },\n    ref,\n  ) => {\n    const fallbackId = React.useId();\n    const motion = useDefaultMotion(defaultMotion);\n    const checkboxId = id || fallbackId;\n    const descriptionId = `${checkboxId}-description`;\n    const [composedDescriptionId, setComposedDescriptionId] = React.useState<string>();\n    const describedBy =\n      [ariaDescribedBy, label && description ? descriptionId : composedDescriptionId]\n        .filter(Boolean)\n        .join(' ') || undefined;\n\n    const checkboxElement = (\n      <CheckboxPrimitive.Root\n        ref={ref}\n        id={checkboxId}\n        className={cn(\n          checkboxVariants({ size, variant }),\n          checkboxMotionVariants({ enabled: motion }),\n          className,\n        )}\n        disabled={disabled}\n        aria-describedby={describedBy}\n        data-slot=\"checkbox\"\n        {...props}\n      >\n        <CheckboxPrimitive.Indicator\n          className={cn(\n            'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',\n            checkboxIndicatorMotionVariants({ enabled: motion }),\n          )}\n        >\n          <RiCheckLine\n            aria-hidden=\"true\"\n            focusable=\"false\"\n            className={checkboxCheckedIndicatorVariants({ variant })}\n          />\n          <div className={checkboxIndeterminateIndicatorVariants({ size, variant })} />\n        </CheckboxPrimitive.Indicator>\n      </CheckboxPrimitive.Root>\n    );\n    return (\n      <CheckboxContext.Provider\n        value={{\n          disabled,\n          id: checkboxId,\n          descriptionId,\n          onDescriptionIdChange: setComposedDescriptionId,\n        }}\n      >\n        {label ? (\n          <div className={cn('gap-ws-5 flex w-fit')}>\n            {checkboxElement}\n            <div className=\"gap-ws-3 flex flex-col\">\n              <Label.Root\n                data-slot=\"checkbox-label\"\n                htmlFor={checkboxId}\n                className={cn(\n                  'typography-label-sm text-ws-static-base',\n                  disabled ? 'text-ws-static-subtle pointer-events-none' : 'cursor-pointer',\n                )}\n              >\n                {label}\n              </Label.Root>\n              {description && (\n                <div\n                  id={descriptionId}\n                  data-slot=\"checkbox-description\"\n                  className=\"text-ws-static-subtle typography-body-sm\"\n                >\n                  {description}\n                </div>\n              )}\n            </div>\n          </div>\n        ) : children ? (\n          <div className={cn('gap-ws-5 flex w-fit')}>\n            {checkboxElement}\n            <div className=\"gap-ws-3 flex flex-col\">{children}</div>\n          </div>\n        ) : (\n          checkboxElement\n        )}\n      </CheckboxContext.Provider>\n    );\n  },\n) as CheckboxWithVariants;\n\nCheckbox.displayName = 'Checkbox';\nCheckbox.Group = CheckboxGroup;\nCheckbox.Label = CheckboxLabel;\nCheckbox.Description = CheckboxDescription;\n\nexport { Checkbox, CheckboxDescription, CheckboxLabel };\n"
    },
    {
      "path": "src/components/checkbox/Checkbox.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/Checkbox.types.ts",
      "content": "import type * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport type { VariantProps } from 'class-variance-authority';\nimport type { HTMLAttributes } from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { checkboxVariants } from './Checkbox.variants';\nimport type { CheckboxDescription } from './CheckboxDescription';\nimport type { CheckboxGroup } from './CheckboxGroup';\nimport type { CheckboxLabel } from './CheckboxLabel';\n\nexport type CheckboxContextType = {\n  disabled?: boolean;\n  id?: string;\n  descriptionId?: string;\n  onDescriptionIdChange?: (id: string | undefined) => void;\n};\n\ntype CheckboxPropsBase = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> &\n  MotionProps &\n  VariantProps<typeof checkboxVariants>;\n\ntype CheckboxPropsWithLabel = CheckboxPropsBase & {\n  /** Shorthand label, mutually exclusive with composed children. */\n  label: string;\n  /** Supporting text for the shorthand label. Unavailable with composed children. */\n  description?: string;\n  children?: never;\n};\n\ntype CheckboxPropsWithChildren = CheckboxPropsBase & {\n  label?: never;\n  description?: never;\n  /** Composed label and description. Use instead of the shorthand label and description. */\n  children?: React.ReactNode;\n};\n\ntype CheckboxPropsWithoutLabel = CheckboxPropsBase & {\n  label?: never;\n  description?: never;\n  children?: never;\n};\n\n/** A checkbox with optional label and description. */\nexport type CheckboxProps =\n  CheckboxPropsWithLabel | CheckboxPropsWithChildren | CheckboxPropsWithoutLabel;\n\nexport type CheckboxWithVariants = React.ForwardRefExoticComponent<\n  React.PropsWithoutRef<CheckboxProps> &\n    React.RefAttributes<React.ComponentRef<typeof CheckboxPrimitive.Root>>\n> & {\n  Group: typeof CheckboxGroup;\n  Label: typeof CheckboxLabel;\n  Description: typeof CheckboxDescription;\n};\n\n/** The text label associated with `Checkbox`. */\nexport type CheckboxLabelProps = HTMLAttributes<HTMLLabelElement> & {\n  /** ID of the control associated with this label. */\n  htmlFor?: string;\n};\n\n/** A layout container for related checkboxes. Name the group with `aria-labelledby` or `aria-label`. */\nexport type CheckboxGroupProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** Layout direction of the checkbox group. Defaults to `vertical`. */\n  orientation?: 'horizontal' | 'vertical';\n};\n"
    },
    {
      "path": "src/components/checkbox/Checkbox.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/Checkbox.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { boxFillMotion } from '@/lib/wideset/motion/recipes';\n\nexport const checkboxVariants = cva(\n  cn(\n    'group relative flex cursor-pointer border',\n    'disabled:wds-disabled focus-visible:wds-focus-visible',\n    'radix-state-unchecked:disabled:border-ws-dynamic-secondary-disabled radix-state-unchecked:disabled:bg-ws-static-alpha-subtle',\n    'radix-state-checked:disabled:border-none radix-state-checked:disabled:bg-ws-dynamic-primary-disabled',\n    'radix-state-indeterminate:disabled:border-none radix-state-indeterminate:disabled:bg-ws-dynamic-primary-disabled',\n  ),\n  {\n    variants: {\n      size: {\n        // my-ws-2 reproduces Figma's 16×20 Control Container (paddingTop/Bottom = 2)\n        // so the sm control centers against the 20px label line.\n        sm: 'w-ws-control-sm h-ws-control-sm rounded-ws-control-sm my-ws-2',\n        lg: 'w-ws-control-md h-ws-control-md rounded-ws-control-md',\n      },\n      variant: {\n        primary: cn(\n          'outline-ws-dynamic-primary-strong-default',\n          'disabled:text-ws-dynamic-on-primary-disabled',\n          'focus-visible:bg-ws-static-highlight-base',\n\n          'radix-state-unchecked:border-ws-static-strong',\n          'radix-state-unchecked:bg-ws-static-highlight-base',\n          'radix-state-unchecked:hover:border-ws-dynamic-secondary-hover',\n          'radix-state-unchecked:active:border-ws-dynamic-secondary-pressed',\n\n          'radix-state-checked:border-none',\n          'radix-state-checked:bg-ws-dynamic-primary-default',\n          'radix-state-checked:hover:bg-ws-dynamic-primary-hover',\n          'radix-state-checked:hover:text-ws-dynamic-on-primary-hover',\n          'radix-state-checked:active:bg-ws-dynamic-primary-pressed',\n          'radix-state-checked:active:text-ws-dynamic-on-primary-pressed',\n\n          'radix-state-indeterminate:border-none',\n          'radix-state-indeterminate:bg-ws-dynamic-primary-default',\n          'radix-state-indeterminate:hover:bg-ws-dynamic-primary-hover',\n          'radix-state-indeterminate:hover:text-ws-dynamic-on-primary-hover',\n          'radix-state-indeterminate:active:bg-ws-dynamic-primary-pressed',\n          'radix-state-indeterminate:active:text-ws-dynamic-on-primary-pressed',\n        ),\n        danger: cn(\n          'outline-ws-dynamic-danger-strong-default',\n          'disabled:text-ws-dynamic-on-danger-disabled',\n          'focus-visible:bg-ws-static-highlight-base',\n\n          'radix-state-unchecked:border-ws-dynamic-danger-strong-default',\n          'radix-state-unchecked:bg-ws-static-highlight-base',\n          'radix-state-unchecked:hover:border-ws-dynamic-danger-strong-hover',\n          'radix-state-unchecked:active:border-ws-dynamic-danger-strong-pressed',\n\n          'radix-state-checked:border-none',\n          'radix-state-checked:bg-ws-dynamic-danger-default',\n          'radix-state-checked:text-ws-dynamic-on-danger-default',\n          'radix-state-checked:hover:bg-ws-dynamic-danger-hover',\n          'radix-state-checked:hover:text-ws-dynamic-on-danger-hover',\n          'radix-state-checked:active:bg-ws-dynamic-danger-pressed',\n          'radix-state-checked:active:text-ws-dynamic-on-danger-pressed',\n\n          'radix-state-indeterminate:border-none',\n          'radix-state-indeterminate:bg-ws-dynamic-danger-default',\n          'radix-state-indeterminate:text-ws-dynamic-on-danger-default',\n          'radix-state-indeterminate:hover:bg-ws-dynamic-danger-hover',\n          'radix-state-indeterminate:hover:text-ws-dynamic-on-danger-hover',\n          'radix-state-indeterminate:active:bg-ws-dynamic-danger-pressed',\n          'radix-state-indeterminate:active:text-ws-dynamic-on-danger-pressed',\n        ),\n      },\n    },\n    defaultVariants: {\n      size: 'lg',\n      variant: 'primary',\n    },\n  },\n);\n\nexport const checkboxMotionVariants = cva('', {\n  variants: {\n    enabled: { true: boxFillMotion, false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n\nexport const checkboxIndicatorMotionVariants = cva('', {\n  variants: {\n    enabled: {\n      true: cn(\n        'animate-in fade-in-0 zoom-in-[0.4]',\n        'fill-mode-both duration-(--ws-motion-duration-fast) ease-(--ws-motion-ease-bounce)',\n      ),\n      false: '',\n    },\n  },\n  defaultVariants: { enabled: true },\n});\n\nexport const checkboxCheckedIndicatorVariants = cva(\n  // size-ws-9 (=16px) pins the icon to Figma's 16×16 check-line instance at both sizes;\n  // without it the icon renders at 1em and depends on inherited font-size.\n  'group-radix-state-indeterminate:hidden group-radix-state-unchecked:hidden size-ws-9',\n  {\n    variants: {\n      variant: {\n        primary: cn(\n          'text-ws-dynamic-on-primary-default',\n          'group-disabled:text-ws-dynamic-on-primary-disabled',\n        ),\n        danger: cn(\n          'text-ws-dynamic-on-danger-default',\n          'group-disabled:text-ws-dynamic-on-danger-disabled',\n        ),\n      },\n    },\n  },\n);\n\nexport const checkboxIndeterminateIndicatorVariants = cva(\n  'group-radix-state-checked:hidden group-radix-state-unchecked:hidden h-[2px]',\n  {\n    variants: {\n      variant: {\n        primary: cn(\n          'bg-(--ws-dynamic-text-on-primary-default)',\n          'group-disabled:bg-(--ws-dynamic-text-on-primary-disabled)',\n        ),\n        danger: cn(\n          'bg-(--ws-dynamic-text-on-danger-default)',\n          'group-disabled:bg-(--ws-dynamic-text-on-danger-disabled)',\n        ),\n      },\n      size: {\n        sm: 'w-[10px]',\n        lg: 'w-[10px]',\n      },\n    },\n  },\n);\n"
    },
    {
      "path": "src/components/checkbox/CheckboxDescription.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/CheckboxDescription.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { CheckboxContext } from './Checkbox.context';\n\nexport const CheckboxDescription = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ children, className, id: idProp, ...props }, ref) => {\n  const context = React.useContext(CheckboxContext);\n  const id = idProp ?? context?.descriptionId;\n  const onDescriptionIdChange = context?.onDescriptionIdChange;\n\n  React.useEffect(() => {\n    onDescriptionIdChange?.(id);\n    return () => onDescriptionIdChange?.(undefined);\n  }, [id, onDescriptionIdChange]);\n\n  return (\n    <div\n      ref={ref}\n      id={id}\n      data-slot=\"checkbox-description\"\n      className={cn('text-ws-static-subtle typography-body-sm', className)}\n      {...props}\n    >\n      {children}\n    </div>\n  );\n});\n\nCheckboxDescription.displayName = 'Checkbox.Description';\n"
    },
    {
      "path": "src/components/checkbox/CheckboxGroup.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/CheckboxGroup.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { CheckboxGroupProps } from './Checkbox.types';\n\nconst CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(\n  ({ orientation = 'vertical', className, children, ...props }, ref) => (\n    <div\n      ref={ref}\n      className={cn(\n        'flex',\n        orientation === 'vertical' ? 'gap-ws-7 flex-col' : 'gap-ws-11',\n        className,\n      )}\n      role=\"group\"\n      data-slot=\"checkbox-group\"\n      {...props}\n    >\n      {children}\n    </div>\n  ),\n);\n\nCheckboxGroup.displayName = 'Checkbox.Group';\n\nexport { CheckboxGroup };\n"
    },
    {
      "path": "src/components/checkbox/CheckboxLabel.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/checkbox/CheckboxLabel.tsx",
      "content": "'use client';\n\nimport * as Label from '@radix-ui/react-label';\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useCheckboxContext } from './Checkbox.context';\nimport type { CheckboxLabelProps } from './Checkbox.types';\n\nexport const CheckboxLabel = React.forwardRef<HTMLLabelElement, CheckboxLabelProps>(\n  ({ children, htmlFor, className, ...props }, ref) => {\n    const { disabled, id } = useCheckboxContext();\n\n    return (\n      <Label.Root\n        ref={ref}\n        htmlFor={htmlFor || id}\n        className={cn(\n          'typography-label-sm text-ws-static-base cursor-pointer',\n          disabled && 'text-ws-static-subtle pointer-events-none',\n          className,\n        )}\n        data-slot=\"checkbox-label\"\n        {...props}\n      >\n        {children}\n      </Label.Root>\n    );\n  },\n);\n\nCheckboxLabel.displayName = 'Checkbox.Label';\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
