{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cookie-consent-bar",
  "title": "Cookie consent bar",
  "description": "A bar above the header, in the page’s flow, that asks about cookies, with Reject all as easy as Accept all. It covers nothing: the page makes room for it and for the switches Customise opens.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/badge.json",
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/collapsible.json",
    "https://kinoui.com/r/consent.json",
    "https://kinoui.com/r/cookie-consent-parts.json",
    "https://kinoui.com/r/hero-parts.json",
    "https://kinoui.com/r/panel.json",
    "https://kinoui.com/r/skeleton.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/cookie-consent-bar/cookie-consent-bar.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport { Collapsible, CollapsiblePanel } from '@/registry/components/kino/collapsible'\nimport type { Consent } from '@/registry/lib/consent'\nimport {\n  CookieConsentCategory,\n  CookieConsentDescription,\n  cookieConsentFocusClassName,\n  type CookieConsentText,\n  defaultText,\n  useCookieConsent,\n} from '@/registry/lib/cookie-consent-parts'\nimport { pageColumnClassName } from '@/registry/lib/hero-parts'\nimport { panelTitleClassName } from '@/registry/lib/panel'\nimport { type ComponentProps, useId, useRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A bar at the top of the page, in its flow, that asks about cookies:\n * Customise, Reject all and Accept all, as easy as each other. It covers\n * nothing, so it never hides what has focus (WCAG 2.4.11), and the page\n * makes room for it on `layout`, as it does when Customise opens a switch\n * for each category below it. Put it first in the page, above the header.\n *\n *   <CookieConsentBar consent={consent} />\n *   <SiteHeader … />\n */\n\ninterface CookieConsentBarProps<Id extends string>\n  extends Omit<ComponentProps<'div'>, 'title'>, CookieConsentText {\n  consent: Consent<Id>\n}\n\nfunction CookieConsentBar<Id extends string>({\n  consent,\n  title = defaultText.title,\n  description = defaultText.description,\n  policyHref,\n  className,\n  ...props\n}: CookieConsentBarProps<Id>) {\n  const surfaceRef = useRef<HTMLElement>(null)\n  const model = useCookieConsent(consent, surfaceRef)\n  const titleId = useId()\n  // Reject all and Accept all weigh the same; once the switches show, Save choices leads.\n  const answerVariant = model.customising ? 'outline' : 'default'\n  return (\n    <div\n      data-slot='cookie-consent'\n      className={cn('@container/cookie-consent w-full', className)}\n      {...props}\n    >\n      {/* Closed on the server and through hydration, so it opens onto the page once it knows to. */}\n      {/* The page opens it and an answer closes it, so an agent answers, as a person does. */}\n      <Collapsible open={model.shown} disabled role='group' aria-labelledby={titleId}>\n        <CollapsiblePanel className='p-0'>\n          <section\n            ref={surfaceRef}\n            aria-labelledby={titleId}\n            tabIndex={-1}\n            className={cn(\n              cookieConsentFocusClassName,\n              'bg-muted/60 border-b focus-visible:ring-inset',\n            )}\n          >\n            <div\n              className={cn(\n                pageColumnClassName,\n                'flex flex-col gap-3 py-4 @3xl/cookie-consent:flex-row @3xl/cookie-consent:items-center @3xl/cookie-consent:gap-8',\n              )}\n            >\n              <div className='min-w-0 flex-1'>\n                <h2 id={titleId} className={panelTitleClassName}>\n                  {title}\n                </h2>\n                <CookieConsentDescription\n                  className='mt-0.5'\n                  description={description}\n                  policyHref={policyHref}\n                />\n              </div>\n              <div className='flex shrink-0 flex-col gap-2 @xs/cookie-consent:flex-row'>\n                <Button\n                  variant={model.customising ? 'default' : 'ghost'}\n                  className='@xs/cookie-consent:me-auto @3xl/cookie-consent:me-0'\n                  onClick={model.customiseOrSave}\n                >\n                  {model.customising ? 'Save choices' : 'Customise'}\n                </Button>\n                <Button variant={answerVariant} onClick={model.rejectAll}>\n                  Reject all\n                </Button>\n                <Button variant={answerVariant} onClick={model.acceptAll}>\n                  Accept all\n                </Button>\n              </div>\n            </div>\n            {/* The Customise button opens it, so an agent presses that, as a person does. */}\n            <Collapsible\n              open={model.customising}\n              disabled\n              role='group'\n              aria-label='Cookie categories'\n            >\n              <CollapsiblePanel className='p-0'>\n                <div\n                  className={cn(\n                    pageColumnClassName,\n                    'grid gap-x-8 gap-y-4 pt-1 pb-5 @2xl/cookie-consent:grid-cols-2 @5xl/cookie-consent:grid-cols-4',\n                  )}\n                >\n                  {model.categories.map((category) => (\n                    <CookieConsentCategory\n                      key={category.id}\n                      category={category}\n                      model={model}\n                      className=\"bg-background content-start rounded-(--surface-radius) border p-(--surface-padding) [grid-template-areas:'label_control'_'message_message']\"\n                    />\n                  ))}\n                </div>\n              </CollapsiblePanel>\n            </Collapsible>\n          </section>\n        </CollapsiblePanel>\n      </Collapsible>\n    </div>\n  )\n}\n\nexport { CookieConsentBar }\n\nexport type { CookieConsentBarProps }\n",
      "type": "registry:component",
      "target": "@components/kino/cookie-consent-bar/cookie-consent-bar.tsx"
    }
  ],
  "type": "registry:block"
}