{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-upload",
  "type": "registry:ui",
  "title": "FileUpload",
  "description": "The upload trigger — a dropzone or a button — plus the hidden file input.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/file-upload/FileUpload.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/file-upload/FileUpload.tsx",
      "content": "'use client';\n\nimport React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport type { FileUploadProps, FileUploadWithSubComponents } from './FileUpload.types';\nimport { FileUploadDropzone } from './FileUploadDropzone';\nimport { FileUploadTrigger } from './FileUploadTrigger';\n\n/**\n * The upload trigger — a dropzone or a button — plus, when a file-handling\n * library hands one over, its hidden file input. Purely presentational: the\n * library owns state, drag tracking and the picker; `onBrowse` is its `open()`.\n */\nconst FileUpload = React.forwardRef<HTMLDivElement, FileUploadProps>(\n  (\n    {\n      className,\n      disabled = false,\n      inputProps,\n      labels,\n      type = 'dropzone',\n      browse,\n      onBrowse,\n      isDragActive,\n      zoneProps,\n      defaultMotion,\n      ...props\n    },\n    ref,\n  ) => {\n    const motion = useDefaultMotion(defaultMotion);\n\n    return (\n      <div ref={ref} data-slot=\"file-upload\" className={cn('flex flex-col', className)} {...props}>\n        {inputProps && (\n          // A library's file input, visually hidden and out of the tab order by\n          // default — the zone or the Browse button is the control, this is only\n          // the mechanism. Anything in `inputProps` overrides these (react-dropzone\n          // brings its own `display: none`). `disabled` has to reach the input\n          // itself: it sits outside the zone, so the zone's `pointer-events-none`\n          // does not cover it.\n          <input\n            type=\"file\"\n            tabIndex={-1}\n            {...inputProps}\n            disabled={disabled || inputProps.disabled}\n            className={cn('sr-only', inputProps.className)}\n          />\n        )}\n\n        {type === 'button' ? (\n          <FileUploadTrigger\n            disabled={disabled}\n            onBrowse={onBrowse}\n            label={labels?.upload}\n            defaultMotion={motion}\n          />\n        ) : (\n          <FileUploadDropzone\n            disabled={disabled}\n            isDragActive={isDragActive}\n            browse={browse}\n            onBrowse={onBrowse}\n            zoneProps={zoneProps}\n            labels={labels}\n            defaultMotion={motion}\n          />\n        )}\n      </div>\n    );\n  },\n) as FileUploadWithSubComponents;\n\nFileUpload.displayName = 'FileUpload';\nFileUpload.Dropzone = FileUploadDropzone;\nFileUpload.Trigger = FileUploadTrigger;\n\nexport { FileUpload };\n"
    },
    {
      "path": "src/components/file-upload/FileUpload.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/file-upload/FileUpload.types.ts",
      "content": "import type {\n  ForwardRefExoticComponent,\n  HTMLAttributes,\n  InputHTMLAttributes,\n  PropsWithoutRef,\n  ReactNode,\n  RefAttributes,\n} from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { FileUploadDropzone } from './FileUploadDropzone';\nimport type { FileUploadTrigger } from './FileUploadTrigger';\n\nexport type FileUploadLabels = {\n  /** Instruction displayed in the idle dropzone. */\n  dropzone?: ReactNode;\n  /** Instruction displayed while dragging files over the dropzone. */\n  dropzoneActive?: ReactNode;\n  /** Text accompanying the Browse button inside the dropzone. */\n  dropzoneBrowse?: ReactNode;\n  /** Label for the Browse button. */\n  browse?: ReactNode;\n  /** Label for the compact upload trigger. */\n  upload?: ReactNode;\n};\n\n/** The drop area: with `browse` it carries a Browse button, otherwise the whole zone is the control. */\nexport type FileUploadDropzoneProps = MotionProps & {\n  /** Disables the trigger and the Browse button. */\n  disabled?: boolean;\n  /** Marks the dropzone as actively receiving a drag — typically from react-dropzone. */\n  isDragActive?: boolean;\n  /** Renders the Browse button — Figma's `Type=Button`. Without it the zone itself is the control (`Type=Area`). */\n  browse?: boolean;\n  /** Opens the file picker — a file-handling library's `open()`. Called from the Browse button, or from the zone itself on `Type=Area`. */\n  onBrowse: () => void;\n  /**\n   * Spread onto the zone — a file-handling library's root props, for drag and\n   * drop. Only the drag props are kept: `onClick`, `onKeyDown`, `onKeyUp`,\n   * `tabIndex` and `role` are dropped, since activation is the component's\n   * and ends in `onBrowse`.\n   */\n  zoneProps?: HTMLAttributes<HTMLElement>;\n  /** Override default text labels for the dropzone, active dropzone, browse button, and upload button. */\n  labels?: Pick<FileUploadLabels, 'dropzone' | 'dropzoneActive' | 'dropzoneBrowse' | 'browse'>;\n};\n\n/** The control that opens or toggles the associated content. */\nexport type FileUploadTriggerProps = MotionProps & {\n  /** Disables the trigger and the Browse button. */\n  disabled?: boolean;\n  /** Opens the file picker — a file-handling library’s `open()`. Called from the Browse button, from the `Type=Area` zone, or from the button trigger. */\n  onBrowse: () => void;\n  /** Visible label for the control. */\n  label?: ReactNode;\n};\n\n/** A file browsing trigger or dropzone connected to an upload handler. */\nexport type FileUploadProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> &\n  MotionProps & {\n    /** The dropzone (default) or the compact button trigger — Figma's `File Upload` `Type`. */\n    type?: 'dropzone' | 'button';\n    /** Disables the trigger and the Browse button. */\n    disabled?: boolean;\n    /** Dropzone only: renders the Browse button inside the zone — Figma's `Type=Button`. */\n    browse?: boolean;\n    /** Opens the file picker — a file-handling library's `open()`. */\n    onBrowse: () => void;\n    /**\n     * Renders a hidden `<input type=\"file\">` with these props — a file-handling\n     * library's input props. `type=\"file\"`, `sr-only` and `tabIndex={-1}` are\n     * the defaults; anything given here wins.\n     */\n    inputProps?: InputHTMLAttributes<HTMLInputElement>;\n    /** Override default text labels for the dropzone, active dropzone, browse button, and upload button. */\n    labels?: FileUploadLabels;\n    /** Dropzone only: marks the zone as receiving a drag. */\n    isDragActive?: boolean;\n    /** Dropzone only: spread onto the zone — a library's root props, drag props only. */\n    zoneProps?: HTMLAttributes<HTMLElement>;\n  };\n\nexport type FileUploadWithSubComponents = ForwardRefExoticComponent<\n  PropsWithoutRef<FileUploadProps> & RefAttributes<HTMLDivElement>\n> & {\n  Dropzone: typeof FileUploadDropzone;\n  Trigger: typeof FileUploadTrigger;\n};\n"
    },
    {
      "path": "src/components/file-upload/FileUpload.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/file-upload/FileUpload.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\n/* The dashed frame is an SVG <rect> drawn by FileUploadDropzone, not a CSS\n   border: Figma's dash is exactly 4 on / 4 off, and CSS `border-dashed` has a\n   UA-defined pitch that cannot be tuned. The rect reads its colour from\n   `--dropzone-stroke`, set by the state classes below; it sits inside the\n   padding box, so the zone keeps Figma's 180 / 132px height. */\nexport const dropzoneVariants = cva(\n  cn(\n    'rounded-ws-container-md gap-ws-5 p-ws-16 relative flex flex-col items-center justify-center',\n    'bg-ws-dynamic-secondary-alpha-default text-ws-static-base',\n    '[--dropzone-stroke:var(--border-color-ws-dynamic-secondary-default)]',\n    /* The ring colour is set unconditionally, as Button does: `transition-colors`\n       covers `outline-color`, so a colour applied only under `focus-visible`\n       animates from the initial `currentColor` — a black flash before the brand\n       ring. */\n    'focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default',\n  ),\n  {\n    variants: {\n      /* Hover and pressed belong to `Type=Area`, where the whole zone is the\n         control. `Type=Button` keeps the zone at its default colours and\n         hovers the Browse button alone, as Figma draws it — the zone is still\n         a drop target, but not something you click. */\n      type: {\n        area: cn(\n          'cursor-pointer',\n          'hover:bg-ws-dynamic-secondary-alpha-hover hover:[--dropzone-stroke:var(--border-color-ws-dynamic-secondary-hover)]',\n          'active:bg-ws-dynamic-secondary-alpha-pressed active:[--dropzone-stroke:var(--border-color-ws-dynamic-secondary-pressed)]',\n        ),\n        button: 'cursor-default',\n      },\n      /* A file dragged over the zone takes the hover look on both types — it\n         is a drop target either way. Browsers do not apply `:hover` during a\n         native drag, so it has to be explicit. Figma has no drag state. */\n      isDragActive: {\n        true: 'bg-ws-dynamic-secondary-alpha-hover [--dropzone-stroke:var(--border-color-ws-dynamic-secondary-hover)]',\n        false: '',\n      },\n      disabled: {\n        true: cn(\n          'pointer-events-none cursor-default',\n          'bg-ws-dynamic-secondary-alpha-default text-ws-static-subtle',\n          '[--dropzone-stroke:var(--border-color-ws-dynamic-secondary-disabled)]',\n        ),\n        false: '',\n      },\n    },\n    defaultVariants: {\n      type: 'area',\n      disabled: false,\n      isDragActive: false,\n    },\n  },\n);\n\nexport const dropzoneMotionVariants = cva('', {\n  variants: {\n    enabled: { true: hoverTintMotion, false: '' },\n    type: { area: '', button: '' },\n  },\n  compoundVariants: [{ enabled: true, type: 'area', className: pressMotion }],\n  defaultVariants: { enabled: true, type: 'area' },\n});\n\nexport const dropzoneStrokeMotionVariants = cva('', {\n  variants: {\n    enabled: {\n      true: 'transition-[stroke] duration-(--ws-motion-duration-quick) ease-(--ws-motion-ease-out)',\n      false: '',\n    },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/file-upload/FileUploadDropzone.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/file-upload/FileUploadDropzone.tsx",
      "content": "'use client';\n\nimport { RiUpload2Line } from '@remixicon/react';\nimport type { HTMLAttributes, KeyboardEvent } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { Button } from '../button/Button';\nimport type { FileUploadDropzoneProps } from './FileUpload.types';\nimport {\n  dropzoneMotionVariants,\n  dropzoneStrokeMotionVariants,\n  dropzoneVariants,\n} from './FileUpload.variants';\n\nconst ZONE_ACTIVATION_PROPS = ['onClick', 'onKeyDown', 'onKeyUp', 'tabIndex', 'role'] as const;\n\n/**\n * The zone takes only the drag props from a library's root props. Activation\n * — click, keyboard, role, tab stop — is this component's and always ends in\n * `onBrowse`; a library's click-anywhere root props would otherwise make the\n * area a second, invisible button on `Type=Button`, or open the picker twice on `Type=Area`.\n */\nconst dropOnly = (zoneProps?: HTMLAttributes<HTMLElement>) => {\n  if (!zoneProps) return undefined;\n  const rest = { ...zoneProps };\n  ZONE_ACTIVATION_PROPS.forEach((key) => delete rest[key]);\n  return rest;\n};\n\n/**\n * The drop area. With `browse` it carries a Browse button (Figma's\n * `Type=Button`); without one the whole zone is the control (`Type=Area`).\n * Either way `onBrowse` opens the picker. Wire `zoneProps` to a file-handling\n * library's root props for drag and drop.\n */\nexport const FileUploadDropzone = ({\n  disabled = false,\n  isDragActive = false,\n  browse = false,\n  onBrowse,\n  zoneProps,\n  labels,\n  defaultMotion,\n}: FileUploadDropzoneProps) => {\n  const motion = useDefaultMotion(defaultMotion);\n  const type = browse ? 'button' : 'area';\n\n  const dropzoneLabel = isDragActive\n    ? (labels?.dropzoneActive ?? 'Drop files here')\n    : browse\n      ? (labels?.dropzoneBrowse ?? 'Drop files here to upload or...')\n      : (labels?.dropzone ?? 'Click or drop files to upload');\n\n  const open = () => {\n    if (!disabled) onBrowse();\n  };\n\n  /* `Type=Area` has no button inside it, so the zone itself is the control: it\n     takes the button role, sits in the tab order and answers Enter / Space. */\n  const areaProps =\n    type === 'area'\n      ? {\n          role: 'button',\n          tabIndex: disabled ? -1 : 0,\n          'aria-disabled': disabled || undefined,\n          onClick: open,\n          onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => {\n            if (event.key !== 'Enter' && event.key !== ' ') return;\n            event.preventDefault();\n            open();\n          },\n        }\n      : undefined;\n\n  return (\n    <div\n      data-slot=\"file-upload-dropzone\"\n      {...dropOnly(zoneProps)}\n      {...areaProps}\n      className={cn(\n        dropzoneVariants({ type, disabled, isDragActive }),\n        dropzoneMotionVariants({ enabled: motion, type }),\n        zoneProps?.className,\n      )}\n    >\n      {/* Figma's dashed frame: 1px, 4 on / 4 off, following the 12px corners.\n          A CSS border-dashed cannot be given that pitch — see dropzoneVariants. */}\n      <svg\n        aria-hidden=\"true\"\n        focusable=\"false\"\n        className=\"pointer-events-none absolute inset-0 size-full overflow-visible\"\n      >\n        <rect\n          x=\"0.5\"\n          y=\"0.5\"\n          strokeWidth=\"1\"\n          strokeDasharray=\"4 4\"\n          // The path starts at x + rx = 12.5, so without this every dash straddles a\n          // half pixel and rasterises as a soft 5 / 3; shifted by 0.5 it lands on\n          // whole pixels along the top edge, crisp 4 / 4 like Figma's.\n          strokeDashoffset=\"0.5\"\n          className={cn(\n            'h-[calc(100%-1px)] w-[calc(100%-1px)] fill-none stroke-(--dropzone-stroke) [rx:var(--radius-ws-container-md)]',\n            dropzoneStrokeMotionVariants({ enabled: motion }),\n          )}\n        />\n      </svg>\n      <RiUpload2Line aria-hidden=\"true\" focusable=\"false\" className=\"size-ws-12 shrink-0\" />\n      {/* Label and Browse button share their own 16px stack — the 8px gap above\n          only separates the icon from the block below it. */}\n      <div className=\"gap-ws-9 flex w-full flex-col items-center\">\n        <span className=\"typography-label-sm text-center\">{dropzoneLabel}</span>\n        {browse && (\n          <Button\n            variant=\"secondary\"\n            preset=\"border\"\n            size=\"sm\"\n            disabled={disabled}\n            className={cn(isDragActive && 'pointer-events-none opacity-0')}\n            onClick={() => onBrowse()}\n            type=\"button\"\n            defaultMotion={motion}\n          >\n            {labels?.browse ?? 'Browse files'}\n          </Button>\n        )}\n      </div>\n    </div>\n  );\n};\n\nFileUploadDropzone.displayName = 'FileUpload.Dropzone';\n"
    },
    {
      "path": "src/components/file-upload/FileUploadTrigger.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/file-upload/FileUploadTrigger.tsx",
      "content": "'use client';\n\nimport { RiAddLine } from '@remixicon/react';\n\nimport { Button } from '../button/Button';\nimport type { FileUploadTriggerProps } from './FileUpload.types';\n\n/** The compact trigger: a secondary button that opens the file picker. Figma's `File Upload` `Type=Button`. */\nexport const FileUploadTrigger = ({\n  disabled = false,\n  onBrowse,\n  label,\n  defaultMotion,\n}: FileUploadTriggerProps) => (\n  <Button\n    data-slot=\"file-upload-trigger\"\n    variant=\"secondary\"\n    preset=\"border\"\n    size=\"sm\"\n    disabled={disabled}\n    onClick={onBrowse}\n    type=\"button\"\n    defaultMotion={defaultMotion}\n  >\n    <Button.Icon icon={RiAddLine} />\n    {label ?? 'Upload'}\n  </Button>\n);\n\nFileUploadTrigger.displayName = 'FileUpload.Trigger';\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
