{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-drop",
  "type": "registry:item",
  "title": "File Drop",
  "description": "A place to drop files, or click to choose them, on a native `<input type=\"file\">`, so the chosen files submit with the form under `name` and the keyboard opens the picker as usual. Files are listed with their size and can be removed. `accept` limits the types (\".pdf,image/*\"), `multiple` allows several, and `max-size` (in MB) turns away files that are too big, saying so.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/file-drop.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/file-drop.js",
      "content": "// Generated by zubra from file-drop.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit, id } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"file-drop\";\n\nexport default $define(tag, {\n  props: {\n    \"label\": { attribute: \"label\", default: \"Attachments\", required: false },\n    \"hint\": { attribute: \"hint\", default: \"\", required: false },\n    \"name\": { attribute: \"name\", default: \"\", required: false },\n    \"accept\": { attribute: \"accept\", default: \"\", required: false },\n    \"multiple\": { attribute: \"multiple\", default: true, required: false },\n    \"maxSize\": { attribute: \"max-size\", default: 0, required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"capture\": { attribute: \"capture\", default: \"\", required: false },\n    \"look\": { attribute: \"look\", default: \"zone\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"fileschange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (file-drop) to ([data-zb-slotted=\\\"file-drop\\\"]) {\\n  :scope { display: block; }\\n  .drop-label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.925rem; }\\n  .drop-zone { display: grid; justify-items: center; gap: 0.35rem; padding: 1.75rem 1rem; border: 2px dashed var(--border, #d4d4d8); border-radius: var(--radius, 0.625rem); background: color-mix(in oklab, var(--muted, #f4f4f5) 40%, var(--background, #fff)); text-align: center; cursor: pointer; transition: border-color var(--duration-fast, 150ms), background var(--duration-fast, 150ms); }\\n  .drop-zone:hover, .drop-over { border-color: var(--primary, #18181b); background: color-mix(in oklab, var(--primary, #18181b) 5%, var(--background, #fff)); }\\n  .drop-zone:focus-within { border-style: solid; border-color: var(--ring, #a1a1aa); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring, #a1a1aa) 40%, transparent); }\\n  .drop-disabled { opacity: 0.55; cursor: not-allowed; }\\n  .drop-main { font-weight: 600; }\\n  .drop-main u { text-underline-offset: 3px; }\\n  .drop-hint { font-size: 0.85rem; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  input { position: absolute; width: 1px; height: 1px; opacity: 0; }\\n  .drop-problem { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--destructive, #dc2626); }\\n  .drop-problem:empty { display: none; }\\n  ul { display: grid; gap: 0.4rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }\\n  li { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border, #e4e4e7); border-radius: calc(var(--radius, 0.625rem) * 0.8); font-size: 0.9rem; }\\n  .drop-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\\n  .drop-size { color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); font-variant-numeric: tabular-nums; }\\n  .drop-remove { width: 1.75rem; height: 1.75rem; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer; }\\n  .drop-remove:hover { background: var(--accent, #f4f4f5); }\\n  .drop-remove:focus-visible { outline: 2px solid var(--ring, #a1a1aa); outline-offset: 1px; }\\n  .drop-button { display: flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: 0.5rem 1rem; border: 1px solid var(--border, #d4d4d8); border-radius: var(--radius, 0.625rem); background: var(--secondary, #f4f4f5); color: var(--secondary-foreground, #18181b); font-weight: 600; text-align: center; cursor: pointer; }\\n  .drop-button:hover { background: color-mix(in oklab, var(--secondary, #f4f4f5) 80%, var(--foreground, #18181b)); }\\n  .drop-button:focus-within { outline: 2px solid var(--ring, #a1a1aa); outline-offset: 2px; }\\n  .drop-button.drop-disabled { opacity: 0.55; cursor: not-allowed; }\\n  .drop-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\\n  .drop-under { display: block; margin-top: 0.35rem; font-size: 0.85rem; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  .drop-under:empty { display: none; }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <span class=\\\"drop-label\\\"></span>\\n  <label class=\\\"drop-box\\\">\\n    <span class=\\\"drop-main\\\"><!----><!--[--><!--]--></span>\\n    <span class=\\\"drop-hint\\\"></span>\\n    <input type=\\\"file\\\">\\n  </label>\\n  <p class=\\\"drop-problem\\\" role=\\\"alert\\\"></p>\\n  <!--[--><!--]-->\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                           \n\n  const inputId = id()\n  const hintId = id()\n  const input = __zubraState(null)\n  const files = __zubraState([])\n  const over = __zubraState(false)\n  const problem = __zubraState(\"\")\n\n  const size = (bytes) => (bytes < 1024 ? `${bytes} B` : bytes < 1048576 ? `${(bytes / 1024).toFixed(0)} KB` : `${(bytes / 1048576).toFixed(1)} MB`)\n  // Put a list of files into the native input (so the form sends exactly those) and the list.\n  function use(list) {\n    const limit = $p.maxSize > 0 ? $p.maxSize * 1048576 : Infinity\n    const kept = [...list].filter((file) => file.size <= limit)\n    const turned = [...list].length - kept.length\n    __zubraAssign(problem, turned ? `${turned === 1 ? \"One file is\" : `${turned} files are`} over ${$p.maxSize} MB and ${turned === 1 ? \"wasn't\" : \"weren't\"} added.` : \"\")\n    const chosen = $p.multiple ? kept : kept.slice(0, 1)\n    if ($p.look === \"button\") {\n      input.get().value = \"\"\n      __zubraAssign(files, [])\n      emit('fileschange', chosen)\n      return\n    }\n    const transfer = new DataTransfer()\n    chosen.forEach((file) => transfer.items.add(file))\n    input.get().files = transfer.files\n    __zubraAssign(files, chosen.map((file, i) => ({ key: `${file.name}-${file.size}-${i}`, file })))\n    emit('fileschange', chosen)\n  }\n  function drop(event) {\n    event.preventDefault()\n    __zubraAssign(over, false)\n    if (!$p.disabled) use($p.multiple ? [...files.get().map((entry) => entry.file), ...event.dataTransfer.files] : event.dataTransfer.files)\n  }\n  function remove(entry) {\n    use(files.get().filter((other) => other !== entry).map((other) => other.file))\n    input.get().focus()\n  }\n    return [\n      { path: [0], toggle: \"drop-hidden\", value: () => ($p.look === \"button\") },\n      { path: [0], attribute: \"id\", value: () => (`${inputId}-label`) },\n      { path: [0], text: () => $t($p.label) },\n      { path: [1], toggle: \"drop-zone\", value: () => ($p.look !== \"button\") },\n      { path: [1], toggle: \"drop-button\", value: () => ($p.look === \"button\") },\n      { path: [1], toggle: \"drop-over\", value: () => $r(over) },\n      { path: [1], toggle: \"drop-disabled\", value: () => $p.disabled },\n      { path: [1], on: \"dragover\", handler: () => (() => !$p.disabled && (__zubraAssign(over, true))), modifiers: { prevent: true } },\n      { path: [1], on: \"dragleave\", handler: () => (() => (__zubraAssign(over, false))) },\n      { path: [1], on: \"drop\", handler: () => $r(drop) },\n      { path: [1, 0], attribute: \"aria-hidden\", value: () => (($p.look === \"button\") ? \"true\" : null) },\n      { path: [1, 0, 0], anchor: () => $t(($p.look === \"button\" ? $p.label : `Drop ${$p.multiple ? \"files\" : \"a file\"} here, or `)) },\n      { path: [1, 0, 1], when: () => ($p.look !== \"button\"), blocks: [{ template: \"<u>choose</u>\", parts: () => [] }, null] },\n      { path: [1, 1], toggle: \"drop-hidden\", value: () => ($p.look === \"button\") },\n      { path: [1, 1], attribute: \"id\", value: () => $r(hintId) },\n      { path: [1, 1], text: () => $t(($p.hint || ($p.maxSize > 0 ? `Up to ${$p.maxSize} MB${$p.multiple ? \" each\" : \"\"}` : \"\"))) },\n      { path: [1, 2], ref: () => (($el) => (__zubraAssign(input, $el))) },\n      { path: [1, 2], attribute: \"id\", value: () => $r(inputId) },\n      { path: [1, 2], attribute: \"name\", value: () => ($p.name || null) },\n      { path: [1, 2], attribute: \"accept\", value: () => ($p.accept || null) },\n      { path: [1, 2], attribute: \"capture\", value: () => ($p.capture || null) },\n      { path: [1, 2], attribute: \"multiple\", boolean: true, value: () => $p.multiple },\n      { path: [1, 2], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [1, 2], attribute: \"aria-labelledby\", value: () => (`${inputId}-label`) },\n      { path: [1, 2], attribute: \"aria-describedby\", value: () => $r(hintId) },\n      { path: [1, 2], on: \"change\", handler: () => ((event) => use(event.target.files)) },\n      { path: [2], text: () => $t($r(problem)) },\n      { path: [3], when: () => ($r(files).length && ($p.look !== \"button\")), blocks: [{ template: \"<ul aria-label=\\\"Chosen files\\\">\\n    <!--[--><!--]-->\\n  </ul>\", parts: () => [{ path: [0, 0], each: () => $r(files), key: (entry, $index) => $r(entry).key, block: { template: \"\\n      <li><span class=\\\"drop-name\\\"></span><span class=\\\"drop-size\\\"></span><button type=\\\"button\\\" class=\\\"drop-remove\\\">×</button></li>\\n    \", parts: (entry, $index) => [{ path: [0, 0], text: () => $t($r(entry).file.name) }, { path: [0, 1], text: () => $t((size($r(entry).file.size))) }, { path: [0, 2], attribute: \"aria-label\", value: () => (`Remove ${$r(entry).file.name}`) }, { path: [0, 2], on: \"click\", handler: () => (() => remove($r(entry))) }] } }] }, null] },\n    ];\n  },\n});\n"
    }
  ]
}
