{
  "generatedFrom": "image-dropzone.contract.json",
  "component": "Image dropzone",
  "slug": "image-dropzone",
  "group": "Settings",
  "tier": "leaf-lit",
  "summary": "The full-width settings image field where the image IS the field — a dashed upload card with empty / loading / filled states and a Change/Edit/Delete overlay; it emits intents, the host owns the modals (SETTINGS-44).",
  "install": {
    "package": "@ahaslides-product/design",
    "registry": "https://npm.pkg.github.com",
    "scope": "@ahaslides-product",
    "auth": "Published to GitHub Packages — needs a GitHub token with read:packages. Configure the @ahaslides-product scope in .npmrc before installing.",
    "npmrc": "@ahaslides-product:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}   # a GitHub token with read:packages",
    "command": "npm i @ahaslides-product/design",
    "tokenLayer": "import '@ahaslides-product/design/tokens.css';",
    "import": "import '@ahaslides-product/design/aha-image-dropzone';",
    "element": "aha-image-dropzone",
    "registers": "aha-image-dropzone"
  },
  "feeds": {
    "doc": "https://ahaslides-product.github.io/ahaslides-design/image-dropzone/index.html",
    "md": "https://ahaslides-product.github.io/ahaslides-design/image-dropzone/image-dropzone.md",
    "agentJson": "https://ahaslides-product.github.io/ahaslides-design/image-dropzone.agent.json",
    "llms": "https://ahaslides-product.github.io/ahaslides-design/image-dropzone.llms.txt",
    "index": "https://ahaslides-product.github.io/ahaslides-design/llms.txt"
  },
  "recommendedSnippet": "html",
  "vibeCode": "Emit the HTML snippet by default — <aha-image-dropzone> is a standard custom element that renders on open — React/Vue are thin adapters over the same element. Paste into an .html file and it renders with no build step.",
  "frameworks": {
    "react": {
      "via": "web-component",
      "ref": "aha-image-dropzone"
    },
    "vue": {
      "via": "web-component",
      "ref": "aha-image-dropzone"
    },
    "html": {
      "via": "web-component",
      "ref": "aha-image-dropzone",
      "runnable": "paste-and-run — no build step, renders on open"
    }
  },
  "props": [
    {
      "name": "state",
      "type": "empty | loading | filled",
      "default": "empty",
      "desc": "The field's state — drives which affordance shows, at a constant box height"
    },
    {
      "name": "src",
      "type": "string",
      "default": "—",
      "desc": "The image URL when filled"
    },
    {
      "name": "fit",
      "type": "contain | cover",
      "default": "contain",
      "desc": "How the filled image sits in the box — contain (whole image, letterboxed) or cover (fill, cropped)"
    },
    {
      "name": "label",
      "type": "string",
      "default": "Add image",
      "desc": "The empty-state prompt text"
    },
    {
      "name": "disabled",
      "type": "boolean",
      "default": "false",
      "desc": "Non-interactive; grey fill"
    },
    {
      "name": "add / change / edit / delete",
      "type": "CustomEvent",
      "default": "—",
      "desc": "Composed intents — the host runs the corresponding modal/flow"
    }
  ],
  "tokens": [
    "border",
    "border-hover",
    "border-disabled",
    "color-primary",
    "color-error",
    "bg-container",
    "bg-container-secondary",
    "bg-container-disabled",
    "bg-elevated",
    "bg-overlay",
    "text-default",
    "text-tertiary",
    "icon-muted",
    "radius-default",
    "radius-sm",
    "radius-pill"
  ],
  "spec": [
    {
      "label": "Zone",
      "value": "full-width, min-height 132, radius 8"
    },
    {
      "label": "Empty",
      "value": "1px dashed #E3E3E3 card, centred system-image-square + label; click emits `add`"
    },
    {
      "label": "Loading",
      "value": "spinner at the SAME 132 min-height — the panel does not jump"
    },
    {
      "label": "Filled",
      "value": "image fitted (fit=contain default | cover) + hover Change/Edit/Delete overlay; solid border"
    },
    {
      "label": "Intents",
      "value": "add · change · edit · delete — host owns the modals, this owns none"
    },
    {
      "label": "Hover",
      "value": "#D3B4FF border + #6A1EBB label/icon"
    },
    {
      "label": "Disabled",
      "value": "#F1F1F1 fill, #EBEBEB border, not-allowed"
    }
  ],
  "opinion": {
    "whenToUse": [
      {
        "what": "Image dropzone",
        "when": "a standalone MAIN image field — a background/hero image, an interactive-image base, a picture reveal (SETTINGS-44)"
      },
      {
        "what": "Image action button",
        "when": "a per-OPTION image cell in an option row"
      }
    ],
    "note": "The MAIN image field is this dropzone — NOT a hand-rolled \"Add image\"/\"Replace image\" button plus a separate \"Remove image\" danger button (SETTINGS-44). The loading state matches the empty card's height so the panel doesn't jump. It emits intents; the host owns the upload/crop modals.",
    "dsv3": "COVERED — the settings-lab ImageDropzone control mapped into the DS. The dashed card, overlay and states reuse DS V3 tokens; the full-width image-field shape + no-jump loading + intent events are the settings-specific behaviour (SETTINGS-44)."
  },
  "surfaces": [
    "editor",
    "settings"
  ],
  "snippets": {
    "html": "<!-- Paste-and-run: save as .html and open in a browser. No build step.\n     <aha-image-dropzone> is the SAME shared custom element React and Vue consume — here in its native\n     form. Theming comes only from the --aha-* tokens in tokens.css. It EMITS intents\n     (add/change/edit/delete) — the host runs the upload/crop modals; this field owns none. -->\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/tokens.css\">\n<script type=\"module\">\n  import 'https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/aha-image-dropzone.js';   // registers <aha-image-dropzone>\n</script>\n\n<div style=\"max-width:420px\">\n  <aha-image-dropzone id=\"bg\" state=\"empty\" label=\"Add background image\"></aha-image-dropzone>\n</div>\n\n<script type=\"module\">\n  const el = document.getElementById('bg');\n  // The host owns the flow: on `add`, open your uploader, flip to loading, then filled + src.\n  el.addEventListener('add', () => {\n    el.state = 'loading';\n    setTimeout(() => { el.src = 'https://picsum.photos/640/240'; el.state = 'filled'; }, 900);\n  });\n  el.addEventListener('delete', () => { el.removeAttribute('src'); el.state = 'empty'; });\n</script>\n",
    "react": "import '@ahaslides-product/design/aha-image-dropzone'; // registers <aha-image-dropzone>\nimport { useRef, useEffect } from 'react';\n\n// React 18 needs a thin wrapper; React 19 can use <aha-image-dropzone> directly.\n// It emits intents; the host owns the modals — drive state/src from your upload flow.\nfunction AhaImageDropzone({ state, src, label, disabled, onAdd, onChange, onEdit, onDelete }) {\n  const ref = useRef();\n  useEffect(() => {\n    const el = ref.current;\n    const map = { add: onAdd, change: onChange, edit: onEdit, delete: onDelete };\n    const on = Object.entries(map).map(([k, fn]) => { const h = () => fn?.(); el.addEventListener(k, h); return [k, h]; });\n    return () => on.forEach(([k, h]) => el.removeEventListener(k, h));\n  }, [onAdd, onChange, onEdit, onDelete]);\n  return (\n    <aha-image-dropzone\n      ref={ref}\n      state={state || 'empty'}\n      {...(src ? { src } : {})}\n      {...(label ? { label } : {})}\n      {...(disabled ? { disabled: '' } : {})}\n    />\n  );\n}\n\n// usage — the host runs the uploader and flips state\n<AhaImageDropzone\n  state={bg ? 'filled' : 'empty'}\n  src={bg}\n  label=\"Add background image\"\n  onAdd={openUploader}\n  onDelete={() => setBg(null)}\n/>\n",
    "vue": "// main.ts — register the element + mark aha-* as custom elements\nimport '@ahaslides-product/design/aha-image-dropzone';   // registers <aha-image-dropzone>\napp.config.compilerOptions.isCustomElement = (tag) => tag.startsWith('aha-');\n\n// Component.vue\n<script setup>\nimport { ref } from 'vue';\nconst bg = ref(null);\nconst state = ref('empty');\nfunction onAdd() { state.value = 'loading'; upload().then((url) => { bg.value = url; state.value = 'filled'; }); }\nfunction onDelete() { bg.value = null; state.value = 'empty'; }\n</script>\n\n<template>\n  <!-- emits intents; the host owns the upload/crop modals -->\n  <aha-image-dropzone\n    :state=\"state\"\n    :src=\"bg || undefined\"\n    label=\"Add background image\"\n    @add=\"onAdd\"\n    @edit=\"openCropper\"\n    @delete=\"onDelete\"\n  />\n</template>\n"
  }
}
