{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "banner-cookie",
  "type": "registry:block",
  "title": "Banner, cookie notice",
  "description": "A cookie notice with accept and reject buttons and a link to the policy.",
  "categories": [
    "banner"
  ],
  "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/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/banner-cookie/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/banner-cookie/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  text: t(240),\n  accept: req(24),\n  reject: req(24),\n  policy: link,\n});\n\nexport const spec = defineSpec({\n  type: 'banner-cookie',\n  aliases: ['banner/cookie'],\n  name: 'Banner, cookie notice',\n  category: 'banner',\n  role: 'foot',\n  description: 'A cookie notice with accept and reject buttons and a link to the policy.',\n  schema,\n  defaults: {\n    text: 'Say in a sentence or two what cookies are used for and that the visitor chooses which ones.',\n    accept: 'Accept',\n    reject: 'Decline optional',\n    policy: { label: 'Cookie policy', href: '#cookies' },\n  },\n});\n"
    },
    {
      "path": "src/blocks/banner-cookie/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/banner-cookie/index.tsx",
      "content": "/// <reference path=\"../../css.d.ts\" />\nimport './choice.css';\nimport { useId } from 'react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { buttonClass } from '../../ui/button';\nimport { TextLink } from '../../ui/text-link';\nimport { Container, useEditing, Gate } from '../_shared/kit';\nimport { cn } from '../../lib/utils';\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// Each choice is a label around a native radio that choice.css reads: either one hides the notice with or without script, so the\n// block is a library row (KB-425). As before, the block only hides; storing the choice and holding back cookies is the host's.\nconst choice = (variant: 'primary' | 'secondary') =>\n  cn(buttonClass(variant), 'cursor-pointer has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-(--kh-focus)');\n\nfunction BannerCookie({ props }: BlockProps<Props>) {\n  const editing = useEditing();\n  const name = `kh-consent-${useId()}`;\n  const radio = (value: string) => !editing && <input type=\"radio\" name={name} value={value} data-kh-css-control=\"\" data-kh-consent=\"\" className=\"sr-only\" />;\n  return (\n    <section aria-label=\"Cookie notice\" className=\"kh-cookie-notice border-t border-kh-line bg-kh-surface py-5\">\n      <Container className=\"flex flex-col gap-5 @3xl:flex-row @3xl:items-center @3xl:justify-between @3xl:gap-10\">\n        <div className=\"min-w-0 max-w-kh-narrow\">\n          <p className=\"text-kh-small text-kh-ink-2\">\n            <Text path={['text']} value={props.text} as=\"span\" />{' '}\n            <Gate label={props.policy.label}>\n              <TextLink href={props.policy.href}>\n                <Text path={['policy', 'label']} value={props.policy.label} as=\"span\" />\n              </TextLink>\n            </Gate>\n          </p>\n        </div>\n        <div className=\"flex min-w-0 max-w-full flex-wrap gap-3 @3xl:shrink-0 @3xl:max-w-[60%]\">\n          {(editing || props.reject?.trim()) && (\n            <label className={choice('secondary')}>\n              {radio('reject')}\n              <Text path={['reject']} value={props.reject} as=\"span\" />\n            </label>\n          )}\n          {(editing || props.accept?.trim()) && (\n            <label className={choice('primary')}>\n              {radio('accept')}\n              <Text path={['accept']} value={props.accept} as=\"span\" />\n            </label>\n          )}\n        </div>\n      </Container>\n    </section>\n  );\n}\n\nexport default withHeadingLevel(BannerCookie);\n"
    },
    {
      "path": "src/blocks/banner-cookie/choice.css",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/banner-cookie/choice.css",
      "content": "/* Either choice is a checked radio, and the notice is gone for this page view. No script (KB-425). */\n.kh-cookie-notice:has(input[data-kh-consent]:checked) { display: none; }\n"
    }
  ]
}
