{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "document-solid",
  "title": "Document (Solid)",
  "description": "A document card with its title, kind and size, copy and download, and a preview that expands.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/markdown-solid",
    "@kind-ui/code-block-solid",
    "@kind-ui/internal-toolbar-solid",
    "@kind-ui/internal-scroll-area-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/document.tsx",
      "content": "import { documentPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, Match, omit, Show, Switch } from \"solid-js\";\nimport { CodeBlock } from \"./code-block\";\nimport {\n  KindScrollArea,\n  KindScrollAreaContent,\n  KindScrollAreaScrollbar,\n  KindScrollAreaThumb,\n  KindScrollAreaViewport,\n} from \"./internal/scroll-area\";\nimport { KindToolbar, KindToolbarButton } from \"./internal/toolbar\";\nimport { Markdown } from \"./markdown\";\n\nconst parts = createParts(documentPrimitive, {\n  root: \"div\",\n  header: \"div\",\n  title: \"span\",\n  meta: \"span\",\n  toolbar: \"div\",\n  copy: \"span\",\n  download: \"span\",\n  body: \"div\",\n  content: \"div\",\n  expand: \"button\",\n});\n\nexport type DocumentProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A document as a card: its title, kind and size, Copy and Download, and a preview that expands. Any `children`\n * replace the default header and body.\n */\nexport function Document(props: DocumentProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <DefaultParts />}</parts.Root>;\n}\n\n/** Holds the title, the meta line and the toolbar. */\nexport const DocumentHeader = parts.Header;\n\nexport type DocumentTitleProps = ComponentProps<typeof parts.Title>;\n\n/** The `label`, unless you pass children. */\nexport function DocumentTitle(props: DocumentTitleProps) {\n  return <parts.Title {...omit(props, \"children\")}>{props.children ?? ((state) => state.label)}</parts.Title>;\n}\n\nexport type DocumentMetaProps = ComponentProps<typeof parts.Meta>;\n\n/** What the document is and its size, like \"Markdown · 2.4 kB\", unless you pass children. */\nexport function DocumentMeta(props: DocumentMetaProps) {\n  return <parts.Meta {...omit(props, \"children\")}>{props.children ?? ((state) => state.meta)}</parts.Meta>;\n}\n\nexport type DocumentToolbarProps = ComponentProps<typeof parts.Toolbar>;\n\n/** A `KindToolbar` with Copy and a Download for each of the `downloads`, unless you pass children. */\nexport function DocumentToolbar(props: DocumentToolbarProps) {\n  return (\n    <parts.Toolbar {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <KindToolbar aria-label=\"Document actions\">\n            <DocumentCopy />\n            <Show when={state.canDownload}>\n              <Show\n                when={state.downloads.length > 1}\n                fallback={<DocumentDownload value={state.downloads[0]?.id} />}\n              >\n                <For each={state.downloads} keyed={(download) => download.id}>\n                  {(download) => <DocumentDownload value={download().id} />}\n                </For>\n              </Show>\n            </Show>\n          </KindToolbar>\n        ))}\n    </parts.Toolbar>\n  );\n}\n\nexport type DocumentCopyProps = ComponentProps<typeof parts.Copy>;\n\n/** Copies the `content`. Wraps a `KindToolbarButton` named \"Copy\", unless you pass children. */\nexport function DocumentCopy(props: DocumentCopyProps) {\n  return (\n    <parts.Copy {...omit(props, \"children\")}>\n      {props.children ?? <KindToolbarButton aria-label=\"Copy\" />}\n    </parts.Copy>\n  );\n}\n\nexport type DocumentDownloadProps = ComponentProps<typeof parts.Download>;\n\n/**\n * Calls `onDownload` with its `value`, a download's `id`. Wraps a `KindToolbarButton` named \"Download\", or showing\n * the download's `label` when there are several, unless you pass children.\n */\nexport function DocumentDownload(props: DocumentDownloadProps) {\n  return (\n    <parts.Download {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <KindToolbarButton aria-label={state.label ? `Download ${state.label}` : \"Download\"}>\n            <Show when={state.label}>\n              <span data-document-download-label=\"\">{state.label}</span>\n            </Show>\n          </KindToolbarButton>\n        ))}\n    </parts.Download>\n  );\n}\n\nexport type DocumentBodyProps = ComponentProps<typeof parts.Body>;\n\n/** The preview: a `KindScrollArea` holding the content, followed by Show more, unless you pass children. */\nexport function DocumentBody(props: DocumentBodyProps) {\n  return (\n    <parts.Body {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <KindScrollArea stickToEnd={state.streaming}>\n              <KindScrollAreaViewport>\n                <KindScrollAreaContent>\n                  <DocumentContent />\n                </KindScrollAreaContent>\n              </KindScrollAreaViewport>\n              <KindScrollAreaScrollbar>\n                <KindScrollAreaThumb />\n              </KindScrollAreaScrollbar>\n            </KindScrollArea>\n            <DocumentExpand />\n          </>\n        ))}\n    </parts.Body>\n  );\n}\n\nexport type DocumentContentProps = ComponentProps<typeof parts.Content>;\n\n/**\n * The `content` as its `format` says: Markdown, a Code Block without its header, or wrapped plain text, unless you\n * pass children.\n */\nexport function DocumentContent(props: DocumentContentProps) {\n  return (\n    <parts.Content {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <Switch fallback={<pre>{state.content}</pre>}>\n            <Match when={state.format === \"markdown\"}>\n              <Markdown source={state.content} streaming={state.streaming} highlight={state.highlight} />\n            </Match>\n            <Match when={state.format === \"code\"}>\n              <CodeBlock\n                header={false}\n                code={state.content}\n                language={state.language}\n                streaming={state.streaming}\n                highlight={state.highlight}\n              />\n            </Match>\n          </Switch>\n        ))}\n    </parts.Content>\n  );\n}\n\nexport type DocumentExpandProps = ComponentProps<typeof parts.Expand>;\n\n/** \"Show more\", or \"Show less\" while expanded. Rendered only while the content overflows the preview. */\nexport function DocumentExpand(props: DocumentExpandProps) {\n  return (\n    <parts.Expand {...omit(props, \"children\")}>{props.children ?? ((state) => state.label)}</parts.Expand>\n  );\n}\n\nfunction DefaultParts() {\n  return (\n    <>\n      <DocumentHeader>\n        <DocumentTitle />\n        <DocumentMeta />\n        <DocumentToolbar />\n      </DocumentHeader>\n      <DocumentBody />\n    </>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/document.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
