{
 "id": "ai-composer",
 "name": "AI composer",
 "purpose": "Where a person asks an assistant something: attached sources (one still reading), a mode switch, and a send button that stays quiet until there is text.",
 "use_when": [
  "where people ask an assistant a question with files or sources attached",
  "a research or study tool where the answer must come from the person's own documents",
  "a chat screen that needs a few starter questions before the first message"
 ],
 "avoid_when": [
  "a plain search box with no assistant: use command-menu",
  "showing the assistant's answer: this is only the input side"
 ],
 "type": "ai",
 "style": "editorial",
 "width": "medium",
 "tags": {
  "audience": "work",
  "industries": [
   "productivity",
   "education",
   "saas"
  ],
  "keywords": [
   "ai",
   "chat",
   "prompt",
   "attachments",
   "composer"
  ]
 },
 "root": ".odl-ai-composer",
 "parts": [
  {
   "name": "sources",
   "selector": ".odl-sources li",
   "what": "one attached source: name, size or reading progress, and a remove button",
   "slot": "list"
  },
  {
   "name": "question",
   "selector": "textarea",
   "what": "where the person types; grows with the text",
   "slot": "input"
  },
  {
   "name": "attach",
   "selector": ".odl-bar > button[type=\"button\"]",
   "what": "icon button to attach another source",
   "slot": "action"
  },
  {
   "name": "modes",
   "selector": ".odl-modes label",
   "what": "one mode in a radio switch",
   "slot": "list"
  },
  {
   "name": "hint",
   "selector": ".odl-hint",
   "what": "the Enter-to-send shortcut, hidden on narrow screens",
   "slot": "text"
  },
  {
   "name": "send",
   "selector": ".odl-send",
   "what": "the send button, greyed while the box is empty",
   "slot": "action"
  },
  {
   "name": "starters",
   "selector": ".odl-starters li",
   "what": "one suggested question that fills the box",
   "slot": "list"
  }
 ],
 "data": {
  "type": "object",
  "required": [
   "placeholder",
   "modes"
  ],
  "properties": {
   "sources": {
    "type": "array",
    "minItems": 0,
    "maxItems": 6,
    "part": "sources",
    "items": {
     "type": "object",
     "required": [
      "name"
     ],
     "properties": {
      "name": {
       "type": "string",
       "maxLength": 60
      },
      "meta": {
       "type": "string",
       "maxLength": 16
      },
      "uploading": {
       "type": "boolean"
      }
     }
    }
   },
   "placeholder": {
    "type": "string",
    "maxLength": 60,
    "part": "question"
   },
   "modes": {
    "type": "array",
    "minItems": 2,
    "maxItems": 3,
    "part": "modes",
    "items": {
     "type": "object",
     "required": [
      "label"
     ],
     "properties": {
      "label": {
       "type": "string",
       "maxLength": 10
      },
      "value": {
       "type": "string",
       "maxLength": 20
      },
      "checked": {
       "type": "boolean"
      }
     }
    }
   },
   "hint": {
    "type": "string",
    "maxLength": 20,
    "part": "hint"
   },
   "starters": {
    "type": "array",
    "minItems": 0,
    "maxItems": 3,
    "part": "starters",
    "items": {
     "type": "object",
     "required": [
      "text"
     ],
     "properties": {
      "text": {
       "type": "string",
       "maxLength": 40
      }
     }
    }
   }
  }
 },
 "states": {
  "shown": [
   "empty",
   "typing",
   "focus",
   "source uploading",
   "mode picked"
  ],
  "edge": {
   "empty": {
    "status": "shown",
    "how": "an empty box shows the placeholder and the send button turns grey",
    "evidence": ":has(textarea:placeholder-shown) .odl-send"
   },
   "loading": {
    "status": "shown",
    "how": "a source still being read spins its icon and shows its progress",
    "evidence": "is-uploading"
   },
   "error": {
    "status": "not_built",
    "how": "if a source fails to read, mark its chip with a warning icon and text in place of the progress, or put an alert-banners line above the box"
   },
   "disabled": {
    "status": "handled",
    "how": "the send button looks disabled while the box is empty, and the script ignores an empty send",
    "evidence": "if (box.value.trim())"
   },
   "overflow": {
    "status": "handled",
    "how": "the text box grows to a limit and then scrolls; source chips wrap to more lines",
    "evidence": "max-block-size: 14rem"
   },
   "long_text": {
    "status": "handled",
    "how": "long source names are cut with an ellipsis",
    "evidence": "text-overflow: ellipsis"
   },
   "missing_image": {
    "status": "none",
    "how": "the part has no photo"
   }
  }
 },
 "tokens": [
  "--ds-border-width-default",
  "--ds-color-bg-action-primary",
  "--ds-color-bg-action-primary-hover",
  "--ds-color-bg-disabled",
  "--ds-color-bg-neutral-subtle",
  "--ds-color-border-default",
  "--ds-color-border-focus",
  "--ds-color-border-subtle",
  "--ds-color-icon-default",
  "--ds-color-icon-subtle",
  "--ds-color-surface-base",
  "--ds-color-surface-raised",
  "--ds-color-surface-sunken",
  "--ds-color-text-disabled",
  "--ds-color-text-on-action",
  "--ds-color-text-primary",
  "--ds-color-text-secondary",
  "--ds-color-text-tertiary",
  "--ds-elevation-floating",
  "--ds-elevation-raised",
  "--ds-focus-ring-offset",
  "--ds-focus-ring-width",
  "--ds-font-weight-label",
  "--ds-icon-stroke-md",
  "--ds-motion-duration-extra",
  "--ds-motion-duration-short",
  "--ds-motion-easing-linear",
  "--ds-motion-easing-standard",
  "--ds-radius-container",
  "--ds-radius-control",
  "--ds-radius-control-sm",
  "--ds-radius-detail",
  "--ds-radius-full",
  "--ds-radius-overlay",
  "--ds-size-control-md",
  "--ds-size-icon-md",
  "--ds-size-icon-sm",
  "--ds-size-target-min",
  "--ds-space-2",
  "--ds-space-4",
  "--ds-space-inline-sm",
  "--ds-space-inset-lg",
  "--ds-space-inset-md",
  "--ds-space-inset-sm",
  "--ds-space-inset-xs",
  "--ds-space-stack-lg",
  "--ds-space-stack-md",
  "--ds-text-body-lg",
  "--ds-text-body-md",
  "--ds-text-code-sm",
  "--ds-text-label-lg",
  "--ds-text-label-md"
 ],
 "a11y": {
  "summary": "A labelled form: the modes are a native radio group, every icon button has a name, and the focus ring wraps the whole box.",
  "roles": [
   "form",
   "list",
   "radiogroup"
  ],
  "keyboard": [
   "Tab moves through the remove buttons, the question box, the attach button, the mode switch, Send and the starter questions",
   "Enter in the question box sends; Shift+Enter adds a new line",
   "Arrow keys move between the modes, as in any native radio group",
   "Enter or Space on a starter question puts its text in the box and moves focus there"
  ],
  "controls": {
   "button": 9,
   "input": 4,
   "link": 0,
   "select": 0,
   "textarea": 1,
   "summary": 0
  },
  "focus_visible": true,
  "reduced_motion": true,
  "min_target": true
 },
 "files": {
  "html": "components/ai-composer/component.html",
  "bytes": 14147,
  "script": true
 },
 "source": "brand/showcase/components/07-ai-composer",
 "photos": 0,
 "urls": {
  "html": "https://opendesigner.dev/library/ai-composer.html",
  "json": "https://opendesigner.dev/library/ai-composer.json",
  "page": "https://opendesigner.dev/library/ai-composer/"
 },
 "get": {
  "curl": "curl -fsSLo ai-composer.html https://opendesigner.dev/library/ai-composer.html",
  "opendesigner": "python3 path/to/skills/opendesigner/scripts/library.py add ai-composer --from https://opendesigner.dev",
  "prompt": "Add the OpenDesigner component ai-composer to this project: https://opendesigner.dev/library/ai-composer.html. Keep its markup and states; map its --ds-* variables to my tokens."
 }
}
