{
  "name": "drawer",
  "type": "ui:component",
  "title": "Drawer & yield* promptDrawer()",
  "description": "Mobile-first bottom action drawer built on Sheet plus Aster-native yield* promptDrawer() flow.",
  "dependencies": [],
  "registryDependencies": [
    "theme",
    "sheet",
    "button"
  ],
  "files": [
    {
      "path": "src/ui/drawer.tsx",
      "target": "src/ui/drawer.tsx",
      "sha256": "5f941de3508247cbd12556b46d7aa55050b577dee301c174158068a929a0ce0c",
      "content": "import './theme.css';\nimport { signal, type View } from '@fierst/aster';\nimport { Sheet } from './sheet';\nimport { Button } from './button';\n\nexport function Drawer({\n  id,\n  open,\n  title,\n  description,\n  footer,\n  onClose,\n  class: extraClass,\n  children,\n}: {\n  id?: string;\n  open?: any;\n  title?: string;\n  description?: string;\n  footer?: View;\n  onClose?: () => void;\n  class?: string;\n  children?: View;\n}) {\n  return (\n    <Sheet\n      id={id}\n      open={open}\n      side=\"bottom\"\n      title={title}\n      description={description}\n      footer={footer}\n      onClose={onClose}\n      class={extraClass}\n    >\n      {children}\n    </Sheet>\n  );\n}\n\nexport interface DrawerAction {\n  id: string;\n  label: string;\n  danger?: boolean;\n}\n\n/**\n * Aster-native `yield*` Mobile Action Sheet Flow:\n *   const actionId = yield* promptDrawer({ title: 'Deployment Actions', actions: [...] });\n */\nexport function* promptDrawer(opts: {\n  title: string;\n  description?: string;\n  actions: readonly DrawerAction[];\n  cancelLabel?: string;\n}): Generator<View, string | null, any> {\n  const decided = signal(false);\n  let picked: string | null = null;\n\n  while (!decided()) {\n    yield (\n      <Drawer\n        open={[\n          () => !decided(),\n          (v: boolean) => {\n            if (!v && !decided()) {\n              picked = null;\n              decided.set(true);\n            }\n          },\n        ]}\n        title={opts.title}\n        description={opts.description}\n        footer={\n          <Button\n            variant=\"outline\"\n            style=\"width:100%\"\n            onClick={() => {\n              picked = null;\n              decided.set(true);\n            }}\n          >\n            {opts.cancelLabel ?? 'Cancel'}\n          </Button>\n        }\n      >\n        <div style=\"display:grid; gap:0.5rem\">\n          {opts.actions.map((act) => (\n            <Button\n              key={act.id}\n              variant={act.danger ? 'destructive' : 'outline'}\n              style=\"width:100%; justify-content:flex-start\"\n              onClick={() => {\n                picked = act.id;\n                decided.set(true);\n              }}\n            >\n              {act.label}\n            </Button>\n          ))}\n        </div>\n      </Drawer>\n    );\n  }\n\n  return picked;\n}\n"
    }
  ]
}
