{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kit-b-directory",
  "type": "registry:lib",
  "title": "Kit b-directory",
  "description": "Helpers shared by the directory blocks.",
  "dependencies": [
    "lucide-react@^1.49.0"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/copy-button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/_shared/b-directory-kit.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/_shared/b-directory-kit.tsx",
      "content": "// Helpers shared by package B (directory, hero, steps, assistant, gallery). React lives here, never in spec files.\nimport type { FormEvent, KeyboardEvent, ReactNode } from 'react';\nimport { ChevronRight, Terminal } from 'lucide-react';\nimport { Text, type PropPath } from '../../editing';\nimport { safeHref } from '../../ui/button';\nimport { CopyButton } from '../../ui/copy-button';\nimport { cn } from '../../lib/utils';\nimport { Gate, Opt, useEditing } from './kit';\n\n/** Breadcrumb trail. The last crumb is the current page and is not a link. Renders nothing when empty (unless editing). */\nexport function Breadcrumbs({ path = ['breadcrumbs'], items, className }: { path?: PropPath; items: { label: string; href: string }[]; className?: string }) {\n  if (items.length === 0) return null;\n  const last = items.length - 1;\n  return (\n    <nav aria-label=\"Breadcrumb\" className={className}>\n      <ol className=\"flex flex-wrap items-center gap-1 text-kh-small text-kh-muted\">\n        {items.map((b, i) => (\n          <Gate key={i} label={b.label}>\n          <li className=\"flex items-center gap-1\">\n            {i === last ? (\n              <span aria-current=\"page\" className=\"text-kh-ink\">\n                <Text path={[...path, i, 'label']} value={b.label} as=\"span\" />\n              </span>\n            ) : (\n              <>\n                <a href={safeHref(b.href)} className=\"inline-flex min-h-9 items-center rounded-kh-sm hover:text-kh-ink focus-visible:outline-2 focus-visible:outline-(--kh-focus)\">\n                  <Text path={[...path, i, 'label']} value={b.label} as=\"span\" />\n                </a>\n                <ChevronRight aria-hidden className=\"size-3.5\" />\n              </>\n            )}\n          </li>\n          </Gate>\n        ))}\n      </ol>\n    </nav>\n  );\n}\n\n/**\n * A text field whose visible placeholder is an editable slot. The real input carries the accessible name and an empty\n * placeholder; the slot is laid over it and hides once the field has a value.\n */\n/** Enter sends the form from a growing one-line field, as it does from an input; Shift+Enter and IME composition are left alone. */\nfunction sendOnEnter(e: KeyboardEvent<HTMLTextAreaElement>) {\n  if (e.key !== 'Enter' || e.shiftKey || e.nativeEvent.isComposing) return;\n  e.preventDefault();\n  e.currentTarget.form?.requestSubmit();\n}\n\n/** Browsers without field-sizing: fit the height to the text, capped by the CSS max-height (two lines). Set from script, so the server HTML carries no style attribute (CSP). */\nfunction fitTwoLines(e: FormEvent<HTMLTextAreaElement>) {\n  const el = e.currentTarget;\n  if (typeof CSS !== 'undefined' && CSS.supports?.('field-sizing', 'content')) return;\n  el.style.height = 'auto';\n  el.style.height = `${el.scrollHeight}px`;\n}\n\nexport function SlotField({\n  path, value, multiline, grow, icon, className, fieldClassName, name, required, inputType = 'text', ariaLabel, inputProps,\n}: {\n  path: PropPath; value: string; multiline?: boolean;\n  /** A one-line text field that grows to two lines as text wraps (a one-row text area; Enter sends the form). */ grow?: boolean; icon?: ReactNode; className?: string; fieldClassName?: string;\n  /** Form field name, so a native submit carries the value. */ name?: string; required?: boolean; inputType?: 'text' | 'url';\n  /** The field's accessible name, when it should not be the placeholder text (the placeholder is often an example). */ ariaLabel?: string;\n  /** Extra attributes for the real input or textarea (pattern, aria-invalid, onInvalid...). */ inputProps?: Record<string, unknown>;\n}) {\n  const shared = cn('peer w-full bg-transparent text-kh-body text-kh-ink outline-none placeholder:text-transparent', fieldClassName);\n  return (\n    <label className={cn('relative flex w-full cursor-text', className)}>\n      {icon}\n      <span className=\"relative min-w-0 flex-1\">\n        {grow && !multiline ? (\n          <textarea\n            name={name} required={required} aria-label={ariaLabel || value} placeholder=\" \" rows={1} onKeyDown={sendOnEnter} onInput={fitTwoLines} {...inputProps}\n            className={cn(shared, 'block min-h-11 max-h-[calc(2lh+1.25rem)] resize-none overflow-y-auto py-2.5 leading-normal [field-sizing:content]')}\n          />\n        ) : multiline ? (\n          <textarea name={name} required={required} aria-label={ariaLabel || value} placeholder=\" \" rows={3} {...inputProps} className={cn(shared, 'resize-none leading-normal')} />\n        ) : (\n          <input type={inputType} name={name} required={required} inputMode={inputType === 'url' ? 'url' : undefined} autoComplete={inputType === 'url' ? 'url' : undefined} aria-label={ariaLabel || value} placeholder=\" \" {...inputProps} className={cn(shared, 'min-h-11')} />\n        )}\n        <Text\n          path={path}\n          value={value}\n          as=\"span\"\n          className={cn('pointer-events-none absolute left-0 truncate text-kh-body text-kh-muted peer-[:not(:placeholder-shown)]:hidden', multiline ? 'right-0 top-0 whitespace-pre-wrap' : 'inset-y-0 right-0 flex items-center')}\n        />\n      </span>\n    </label>\n  );\n}\n\n/** A terminal command and its output beside a labelled prompt: the shared panel of hero-terminal and features-terminal. */\nexport function TerminalPanels({ terminal, prompt, className }: {\n  terminal: { command: string; output: string }; prompt: { label: string; text: string }; className?: string;\n}) {\n  return (\n    <div className={cn('flex flex-col gap-4', className)}>\n      {/* the terminal re-maps tokens with the internal console tone, so it stays a dark console in light and dark mode */}\n      <div data-kh-tone=\"console\" className=\"overflow-hidden rounded-kh-xl border border-kh-line bg-kh-canvas text-kh-ink shadow-kh-2\">\n        <div className=\"flex items-center gap-2 border-b border-kh-line px-4 py-2.5 text-kh-caption text-kh-muted\">\n          <Terminal aria-hidden className=\"size-3.5\" />\n          <span>Terminal</span>\n        </div>\n        <div className=\"space-y-2 px-4 py-4 font-kh-mono text-kh-small\">\n          <div className=\"flex items-center gap-2\">\n            <span aria-hidden className=\"select-none text-kh-muted\">$</span>\n            <div tabIndex={0} role=\"group\" aria-label=\"Command\" className=\"min-w-0 flex-1 overflow-x-auto whitespace-nowrap focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)\"><Text path={['terminal', 'command']} value={terminal.command} as=\"code\" /></div>\n            <CopyButton value={terminal.command} label=\"Copy command\" className=\"-my-1 -mr-2\" />\n          </div>\n          <Opt path={['terminal', 'output']} value={terminal.output} className=\"text-kh-accent [overflow-wrap:anywhere]\" placeholder=\"Output\" />\n        </div>\n      </div>\n      <div className=\"rounded-kh-xl border border-kh-line bg-kh-surface p-5 shadow-kh-1\">\n        <Text path={['prompt', 'label']} value={prompt.label} as=\"p\" className=\"text-kh-caption font-medium uppercase tracking-wider text-kh-muted\" />\n        <Text path={['prompt', 'text']} value={prompt.text} as=\"p\" multiline className=\"mt-2 text-kh-body text-kh-ink\" />\n      </div>\n    </div>\n  );\n}\n\n/** True when the block header (eyebrow, title, description) has nothing to show and nothing to edit. */\nexport function useHeaderEmpty(...values: (string | undefined)[]) {\n  const editing = useEditing();\n  return !editing && values.every((v) => !v);\n}\n\n/** A copyable code snippet. */\nexport function CodeSnippet({ path, value, className }: { path: PropPath; value: string; className?: string }) {\n  return (\n    // A first line longer than the block scrolls under an overlaid button at any width, so the copy button gets its own strip above\n    // the code (KB-432). Only when the button is there: without script it draws nothing, and the code starts at the top.\n    <div className={cn('relative rounded-kh-lg border border-kh-line bg-kh-surface-2 [&:has(>button)>pre]:pt-12', className)}>\n      <pre tabIndex={0} className=\"overflow-x-auto p-4 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={path} value={value} as=\"code\" multiline className=\"whitespace-pre\" />\n      </pre>\n      <CopyButton value={value} label=\"Copy code\" className=\"absolute right-2 top-2\" />\n    </div>\n  );\n}\n"
    }
  ]
}
