{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "directory-preview",
  "type": "registry:block",
  "title": "Directory, preview",
  "description": "Full-width preview of one block or screen: breadcrumbs, title, status badge, viewport toggle, Preview and Code tabs, actions and a framed stage that renders a registered demo by id.",
  "categories": [
    "directory"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/copy-button.json",
    "https://ui.klarhimmel.com/r/demos.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-b-directory.json",
    "https://ui.klarhimmel.com/r/tabs.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/directory-preview/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/directory-preview/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, media, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  breadcrumbs: z.array(link).max(4),\n  title: t(80),\n  status: t(24),\n  description: t(200),\n  viewports: z.array(req(20)).max(3),\n  tabs: z.array(req(20)).max(2),\n  actions: z.array(link).max(3),\n  demo: t(80),\n  preview: media,\n  code: t(2000),\n});\n\nexport const spec = defineSpec({\n  type: 'directory-preview',\n  aliases: ['directory/preview'],\n  name: 'Directory, preview',\n  category: 'directory',\n  role: 'body',\n  description: 'Full-width preview of one block or screen: breadcrumbs, title, status badge, viewport toggle, Preview and Code tabs, actions and a framed stage that renders a registered demo by id.',\n  schema,\n  defaults: {\n    breadcrumbs: [\n      { label: 'First page', href: '/catalogue/blocks/' },\n      { label: 'Second page', href: '/catalogue/blocks/hero/' },\n      { label: 'Current page', href: '' },\n    ],\n    title: 'Name what is shown',\n    status: 'Free',\n    description: 'Say in one sentence what it is, how it is laid out and when to use it.',\n    viewports: ['Wide view', 'Mid view', 'Narrow view'],\n    tabs: ['First tab', 'Second tab'],\n    actions: [{ label: 'Main action', href: '#copy' }],\n    demo: 'hero-split-sample',\n    preview: { src: '', alt: 'Show the finished block as it looks' },\n    code: \"import Block from '@/blocks/your-block';\\n\\nexport default function Page() {\\n  return (\\n    <Block\\n      props={{\\n        title: 'Say what the page offers',\\n        primary: { label: 'Main action', href: '#go' },\\n      }}\\n    />\\n  );\\n}\",\n  },\n});\n"
    },
    {
      "path": "src/blocks/directory-preview/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/directory-preview/index.tsx",
      "content": "import { useId, useState } from 'react';\nimport { Monitor, Smartphone, Tablet } from 'lucide-react';\nimport { Media, Text, withHeadingLevel } from '../../editing';\nimport { cn } from '../../lib/utils';\nimport { CopyButton } from '../../ui/copy-button';\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs';\nimport { Demo } from '../../demos';\nimport { ActionLink, Container, Opt, Section, useEditing } from '../_shared/kit';\nimport { Breadcrumbs } from '../_shared/b-directory-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\n// Class strings are spelled out so Tailwind sees them.\nconst WIDTHS = ['max-w-full', 'max-w-3xl', 'max-w-sm'];\nconst VIEWPORT_ICONS = [Monitor, Tablet, Smartphone];\n\nfunction DirectoryPreview({ props }: BlockProps<Props>) {\n  const id = useId();\n  const editing = useEditing();\n  const [viewport, setViewport] = useState(0);\n  return (\n    <Section labelledBy={id} className=\"py-10 @3xl:py-14\">\n      <Container>\n        <Breadcrumbs items={props.breadcrumbs} className=\"mb-6\" />\n        <div className=\"flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:justify-between\">\n          <div className=\"min-w-0\">\n            <div className=\"flex flex-wrap items-center gap-3\">\n              <div id={id}>\n                <Text path={['title']} value={props.title} as=\"h2\" className=\"text-kh-title font-semibold\" />\n              </div>\n              <Opt path={['status']} value={props.status} as=\"span\" className=\"inline-flex items-center rounded-kh-pill bg-kh-accent-soft px-2.5 py-0.5 text-kh-caption font-medium text-kh-accent-ink\" placeholder=\"Status\" />\n            </div>\n            <Opt path={['description']} value={props.description} className=\"mt-3 max-w-kh-prose text-kh-body text-kh-muted\" placeholder=\"Description\" />\n          </div>\n          {(props.actions.length > 0 || editing) && (\n            <div className=\"flex shrink-0 flex-wrap gap-3\">\n              {props.actions.map((a, i) => (\n                <ActionLink key={i} path={['actions', i]} value={a} variant=\"secondary\" size=\"md\" />\n              ))}\n            </div>\n          )}\n        </div>\n\n        <Tabs defaultValue=\"0\" className=\"mt-8 overflow-hidden rounded-kh-xl border border-kh-line bg-kh-surface\">\n          <div className=\"flex flex-wrap items-center justify-between gap-3 border-b border-kh-line bg-kh-surface-2 px-3 py-2\">\n            <TabsList label=\"Preview or code\" className=\"bg-kh-surface-3\">\n              {props.tabs.map((tab, i) => (\n                <TabsTrigger key={i} value={String(i)}>\n                  <Text path={['tabs', i]} value={tab} as=\"span\" />\n                </TabsTrigger>\n              ))}\n            </TabsList>\n            {props.viewports.length > 0 && (\n              <div role=\"group\" aria-label=\"Preview width\" className=\"inline-flex items-center gap-1 rounded-kh-lg bg-kh-surface-3 p-1\">\n                {props.viewports.map((label, i) => {\n                  const I = VIEWPORT_ICONS[i] ?? Monitor;\n                  return (\n                    <button\n                      key={i}\n                      type=\"button\"\n                      aria-pressed={viewport === i}\n                      onClick={() => setViewport(i)}\n                      className=\"inline-flex min-h-9 items-center gap-2 rounded-kh px-3 text-kh-small font-medium text-kh-muted transition-colors duration-(--kh-dur) hover:text-kh-ink aria-pressed:bg-kh-surface aria-pressed:text-kh-ink aria-pressed:shadow-kh-1 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-(--kh-focus)\"\n                    >\n                      <I aria-hidden className=\"size-4\" />\n                      <Text path={['viewports', i]} value={label} as=\"span\" className=\"@max-xl:sr-only\" />\n                    </button>\n                  );\n                })}\n              </div>\n            )}\n          </div>\n          <TabsContent value=\"0\" forceMount>\n            <div className=\"bg-kh-surface-2 p-3 @3xl:p-6\">\n              <div\n                className={cn(editing ? 'max-w-full' : (WIDTHS[viewport] ?? 'max-w-full'), 'mx-auto overflow-hidden rounded-kh-lg border border-kh-line bg-kh-canvas [container-type:inline-size]', viewport > 0 && 'shadow-kh-2')}\n              >\n                {props.demo ? <div className=\"flex min-h-56 items-center justify-center p-6 @3xl:p-10\"><div className=\"max-w-full\"><Demo id={props.demo} /></div></div> : <Media path={['preview']} value={props.preview} ratio=\"16 / 9\" />}\n              </div>\n            </div>\n          </TabsContent>\n          {props.tabs.length > 1 && (\n            <TabsContent value=\"1\" forceMount className=\"relative\">\n              <CopyButton value={props.code} label=\"Copy code\" className=\"absolute right-3 top-3\" />\n              <pre tabIndex={0} className=\"overflow-x-auto p-5 pr-14 font-kh-mono text-kh-small leading-relaxed text-kh-ink focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--kh-focus)\">\n                <Text path={['code']} value={props.code} as=\"code\" multiline className=\"whitespace-pre\" />\n              </pre>\n            </TabsContent>\n          )}\n        </Tabs>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(DirectoryPreview);\n"
    }
  ]
}
