{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "media-drop-zone",
  "type": "registry:component",
  "title": "DropZone",
  "description": "A drop target that reports files and offers a picker",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-icons.json",
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/media/src/drop-zone.tsx",
      "target": "@ui/gpuixui/media/drop-zone.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props, StyleDesc } from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport { Icon } from \"../icons/index.js\";\nimport { Button } from \"../primitives/button.js\";\nimport { visibleCopy } from \"../primitives/core/index.js\";\nimport { cn } from \"../tw/index.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Option from \"effect/Option\";\nimport * as Str from \"effect/String\";\nimport { useState, type ReactElement } from \"react\";\nimport { recipeStyle, useTheme, type Theme } from \"./internal.js\";\nimport { accessibleName } from \"./name.js\";\n\nexport interface DropEntry {\n  readonly path: string;\n  readonly name: string;\n}\n\nexport interface DropPayload {\n  readonly files: ReadonlyArray<DropEntry>;\n}\n\nexport interface DropZoneProps extends Omit<Props, \"children\"> {\n  readonly label: string;\n\n  readonly description?: string;\n\n  readonly onDrop: (payload: DropPayload) => void;\n\n  readonly onPick?: () => void;\n\n  readonly pickLabel?: string;\n\n  readonly disabled?: boolean;\n  readonly className?: string;\n}\n\nconst DEFAULT_LABEL = \"Drop files\";\n\nconst SEPARATORS = /[\\\\/]/;\n\nconst basename = (path: string): string =>\n  Option.getOrElse(\n    Arr.last(Arr.filter(Str.split(SEPARATORS)(path), Str.isNonEmpty)),\n    () => path,\n  );\n\nexport const dropEntries = (\n  paths: ReadonlyArray<string>,\n): ReadonlyArray<DropEntry> =>\n  Arr.map(paths, (path) => ({ path, name: basename(path) }));\n\nconst zoneStyle = (theme: Theme, hovered: boolean): StyleDesc => ({\n  display: \"flex\",\n  flexDirection: \"column\",\n  alignItems: \"center\",\n  justifyContent: \"center\",\n  gap: theme.spacing.sm,\n  padding: theme.spacing.xl,\n  borderWidth: hovered ? theme.borderWidth.strong : theme.borderWidth.thin,\n  borderStyle: \"dashed\",\n  borderColor: hovered ? theme.colors.ring : theme.colors.borderStrong,\n  backgroundColor: hovered ? theme.colors.accent : theme.colors.muted,\n});\n\nexport interface DropZoneSurface {\n  readonly hovered: boolean;\n  readonly onEnter: () => void;\n  readonly onLeave: () => void;\n}\n\nexport const renderDropZone = (\n  props: DropZoneProps,\n  theme: Theme,\n  surface: DropZoneSurface,\n): ReactElement => {\n  const {\n    label,\n    description,\n    onDrop,\n    onPick,\n    pickLabel,\n    disabled = false,\n    className,\n    style,\n    onMouseEnter,\n    onMouseLeave,\n    onFileDrop,\n    ...rest\n  } = props;\n\n  const highlighted = surface.hovered && !disabled;\n\n  const name = accessibleName(label, DEFAULT_LABEL);\n  const pick = accessibleName(pickLabel, \"Choose files\");\n\n  const copy = visibleCopy(description);\n\n  return (\n    <div\n      {...rest}\n      role=\"group\"\n      aria-label={name}\n      onMouseEnter={(event) => {\n        if (!disabled) surface.onEnter();\n        onMouseEnter?.(event);\n      }}\n      onMouseLeave={(event) => {\n        surface.onLeave();\n        onMouseLeave?.(event);\n      }}\n      onFileDrop={(event) => {\n        if (!disabled) onDrop({ files: dropEntries(event.paths ?? []) });\n        onFileDrop?.(event);\n      }}\n      style={mergeStyles(\n        mergeStyles(\n          recipeStyle(cn(\"rounded-lg\", className), theme),\n          zoneStyle(theme, highlighted),\n        ),\n        style,\n      )}\n    >\n      <Icon name=\"upload\" color={theme.colors.mutedForeground} />\n      <text style={{ color: theme.colors.foreground }}>{name}</text>\n      {copy === undefined ? null : (\n        <text style={{ color: theme.colors.mutedForeground }}>{copy}</text>\n      )}\n      {onPick === undefined ? null : (\n        <Button\n          variant=\"secondary\"\n          size=\"sm\"\n          disabled={disabled}\n          testId=\"drop-zone-pick\"\n          onActivate={() => onPick()}\n        >\n          {pick}\n        </Button>\n      )}\n    </div>\n  );\n};\n\nexport const DropZone = (props: DropZoneProps): ReactElement => {\n  const theme = useTheme();\n  const [hovered, setHovered] = useState(false);\n  return renderDropZone(props, theme, {\n    hovered,\n    onEnter: () => setHovered(true),\n    onLeave: () => setHovered(false),\n  });\n};\n"
    },
    {
      "path": "packages/media/src/internal.ts",
      "target": "@ui/gpuixui/media/internal.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { classesToStyle } from \"../tw/index.js\";\nimport type { Theme } from \"../tokens/index.js\";\n\nexport { ThemeProvider, useTheme } from \"../tokens/react.js\";\nexport type { Theme } from \"../tokens/index.js\";\n\nexport const recipeStyle = (recipe: string, theme: Theme): StyleDesc =>\n  classesToStyle(recipe, theme).style;\n"
    },
    {
      "path": "packages/media/src/name.ts",
      "target": "@ui/gpuixui/media/name.ts",
      "type": "registry:lib",
      "content": "import * as Str from \"effect/String\";\n\nexport const accessibleName = (label: unknown, fallback: string): string => {\n  const text = typeof label === \"string\" ? Str.trim(label) : \"\";\n  return Str.isEmpty(text) ? fallback : text;\n};\n\nexport const PICTURE_NAME = \"Picture\";\n"
    }
  ],
  "docs": "[DropZone](https://gpuixui.sudokw.com/media/drop-zone) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/media/drop-zone",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}