{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "docs-customise",
  "type": "registry:block",
  "title": "Docs, customise panel",
  "description": "The component-page customise panel: a stage and its code beside a list of controls (select, toggle, text). The layout is static; the site wires the controls to the code.",
  "categories": [
    "docs"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-a-docs.json",
    "https://ui.klarhimmel.com/r/switch.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/docs-customise/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/docs-customise/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, media, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  title: t(60),\n  description: t(200),\n  preview: media.optional(),\n  demo: t(80).optional(),\n  filename: t(60),\n  code: t(600),\n  reset: req(20),\n  controls: z.array(z.object({ label: t(30), variant: z.enum(['select', 'toggle', 'text']), value: t(60), options: z.array(t(30)).max(6) })).max(8),\n});\n\nexport const spec = defineSpec({\n  type: 'docs-customise',\n  aliases: ['docs/customise'],\n  name: 'Docs, customise panel',\n  category: 'docs',\n  role: 'body',\n  description: 'The component-page customise panel: a stage and its code beside a list of controls (select, toggle, text). The layout is static; the site wires the controls to the code.',\n  schema,\n  defaults: {\n    title: 'Name the panel',\n    description: 'Say what changing a setting does here',\n    preview: { src: '', alt: 'Show the component' },\n    demo: 'button-primary',\n    filename: 'your-file.tsx',\n    code: '<Component option=\"first\" size=\"md\">\\n  Label text\\n</Component>',\n    reset: 'Reset',\n    controls: [\n      { label: 'Setting one', variant: 'select', value: 'Option one', options: ['Option one', 'Option two', 'Option three', 'Option four'] },\n      { label: 'Setting two', variant: 'select', value: 'Option two', options: ['Option one', 'Option two', 'Option three'] },\n      { label: 'Setting three', variant: 'text', value: 'Text value', options: [] },\n      { label: 'Setting four', variant: 'toggle', value: 'off', options: [] },\n      { label: 'Setting five', variant: 'toggle', value: 'off', options: [] },\n    ],\n  },\n});\n"
    },
    {
      "path": "src/blocks/docs-customise/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/docs-customise/index.tsx",
      "content": "import { useId } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Button } from '../../ui/button';\nimport { Switch } from '../../ui/switch';\nimport { cn } from '../../lib/utils';\nimport { Container, Section, SectionHeader, useEditing } from '../_shared/kit';\nimport { CodePanel, Stage } from '../_shared/a-docs-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>;\ntype Control = Props['controls'][number];\n\nfunction ControlRow({ c, i }: { c: Control; i: number }) {\n  const editing = useEditing();\n  const label = <Text path={['controls', i, 'label']} value={c.label} as=\"span\" placeholder=\"Label\" />;\n  const lid = `${useId()}-l`;\n  if (c.variant === 'toggle')\n    return (\n      <li className=\"flex min-h-11 items-center justify-between gap-4 py-2.5\">\n        <span id={lid} className=\"text-kh-small font-medium\">{label}</span>\n        <span className=\"flex items-center gap-3\">\n          <Text path={['controls', i, 'value']} value={c.value} as=\"span\" className=\"text-kh-caption text-kh-muted\" />\n          <Switch className=\"ring-1 ring-inset ring-kh-line-strong\" aria-labelledby={lid} defaultChecked={/^(on|true|yes)$/i.test(c.value)} />\n        </span>\n      </li>\n    );\n  if (c.variant === 'text')\n    return (\n      <li className=\"py-3\">\n        <p id={lid} className=\"mb-2 text-kh-small font-medium\">{label}</p>\n        <div className=\"flex min-h-11 items-center rounded-kh border border-kh-line-strong bg-kh-surface px-3 text-kh-small\">\n          <Text path={['controls', i, 'value']} value={c.value} as=\"span\" className=\"truncate\" placeholder=\"Value\" />\n        </div>\n      </li>\n    );\n  return (\n    <li className=\"py-3\">\n      <div className=\"mb-2 flex items-baseline justify-between gap-3\">\n        <span id={lid} className=\"text-kh-small font-medium\">{label}</span>\n        <Text path={['controls', i, 'value']} value={c.value} as=\"span\" className=\"text-kh-caption text-kh-muted\" />\n      </div>\n      <ul aria-labelledby={lid} className=\"flex flex-wrap gap-1 rounded-kh-lg bg-kh-surface-2 p-1\">\n        {c.options.map((o, j) => (\n          <li\n            key={j}\n            aria-current={o === c.value ? 'true' : undefined}\n            className={cn('inline-flex min-h-9 items-center rounded-kh px-3 text-kh-small', o === c.value ? 'bg-kh-surface font-medium text-kh-ink shadow-kh-1' : 'text-kh-muted')}\n          >\n            <Text path={['controls', i, 'options', j]} value={o} as=\"span\" />\n          </li>\n        ))}\n      </ul>\n      {editing && c.options.length === 0 ? <p className=\"mt-1 text-kh-caption text-kh-muted\">No options yet</p> : null}\n    </li>\n  );\n}\n\nfunction DocsCustomise({ props }: BlockProps<Props>) {\n  const id = useId();\n  return (\n    <Section labelledBy={id} className=\"py-10 @3xl:py-14\">\n      <Container>\n        <SectionHeader id={id} title={props.title} description={props.description} />\n        <div className=\"mt-8 grid gap-6 @4xl:grid-cols-[minmax(0,1fr)_20rem]\">\n          <div className=\"flex flex-col overflow-hidden rounded-kh-xl border border-kh-line bg-kh-surface\">\n            <Stage demoPath={['demo']} demo={props.demo} mediaPath={['preview']} media={props.preview} ratio=\"16 / 8\" className=\"flex-1\" />\n            <div className=\"border-t border-kh-line\">\n              <CodePanel path={['code']} code={props.code} filename={props.filename} filenamePath={['filename']} flush />\n            </div>\n          </div>\n          <div className=\"self-start rounded-kh-xl border border-kh-line bg-kh-surface px-5 py-2\">\n            <ul className=\"divide-y divide-kh-line\">\n              {props.controls.map((c, i) => (\n                <ControlRow key={i} c={c} i={i} />\n              ))}\n            </ul>\n            <div className=\"border-t border-kh-line py-3\">\n              <Button variant=\"ghost\" size=\"md\" aria-disabled=\"true\" className=\"-ml-3 cursor-default opacity-60 hover:bg-transparent\">\n                <Text path={['reset']} value={props.reset} as=\"span\" />\n              </Button>\n            </div>\n          </div>\n        </div>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(DocsCustomise);\n"
    }
  ]
}
