{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog",
  "title": "Dialog",
  "description": "A dialog that rises into the centre and leaves faster than it came, and is a sheet on the bottom edge of a small screen. Long content scrolls inside, and the box follows its content when that changes height.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/panel.json",
    "https://kinoui.com/r/refs.json",
    "https://kinoui.com/r/button.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/dialog.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport {\n  PanelCloseIcon,\n  PanelSurface,\n  panelBodyClassName,\n  panelBodyContentClassName,\n  panelBodyFrameClassName,\n  panelCloseClassName,\n  panelDescriptionClassName,\n  panelDialogClassName,\n  panelFooterClassName,\n  panelFooterTint,\n  panelHeaderClassName,\n  panelOverlayClassName,\n  panelTitleClassName,\n  useScrollRegion,\n} from '@/registry/lib/panel'\nimport { mergeRefs } from '@/registry/lib/refs'\nimport type { DialogContentState } from '@ui-sdk/react/dialog'\nimport {\n  Dialog as DialogPrimitive,\n  DialogBackdrop as DialogBackdropPrimitive,\n  DialogClose as DialogClosePrimitive,\n  DialogContent as DialogContentPrimitive,\n  DialogDescription as DialogDescriptionPrimitive,\n  DialogTitle as DialogTitlePrimitive,\n  DialogTrigger as DialogTriggerPrimitive,\n} from '@ui-sdk/react/dialog'\nimport { type PartProps, renderElement } from '@ui-sdk/react/primitive'\nimport { type ComponentProps, type ReactNode, useMemo, useRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\nfunction Dialog(props: ComponentProps<typeof DialogPrimitive>) {\n  return <DialogPrimitive {...props} />\n}\n\nfunction DialogTrigger(props: ComponentProps<typeof DialogTriggerPrimitive>) {\n  return <DialogTriggerPrimitive {...props} />\n}\n\nfunction DialogClose(props: ComponentProps<typeof DialogClosePrimitive>) {\n  return <DialogClosePrimitive {...props} />\n}\n\n/**\n * The dim behind the dialog. A dialog opened from another one leaves its\n * dim out: the one below already dims the page, and steps back itself.\n */\nfunction DialogBackdrop({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof DialogBackdropPrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <DialogBackdropPrimitive\n      className={cn(\n        panelOverlayClassName,\n        'data-nested:invisible has-[~[data-instant]]:transition-none',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * The centred dialog with its dim. When its content changes height while it\n * is open, the box resizes and the footer stays on its bottom edge.\n * `className` goes to the box; `children` are its parts, or a function of\n * its state that returns them, such as to read the `payload` a trigger\n * passed. With `bare`, it is the box alone, laid out by its own classes, for\n * a dialog that isn't centred over the page, such as a chat window in a\n * corner. With `data-instant`, it opens and closes at once, with its dim,\n * for a dialog a key opens many times a day, such as the Command menu.\n */\nfunction DialogContent<Payload = unknown>({\n  className,\n  children,\n  showCloseButton = true,\n  bare = false,\n  inline,\n  ref,\n  ...props\n}: Omit<\n  ComponentProps<typeof DialogContentPrimitive<Payload>>,\n  'className' | 'children'\n> & {\n  className?: string\n  children?: ReactNode | ((state: DialogContentState<Payload>) => ReactNode)\n  showCloseButton?: boolean\n  bare?: boolean\n}) {\n  const parts = (state: DialogContentState<Payload>) =>\n    typeof children === 'function' ? children(state) : children\n  if (bare) {\n    return (\n      <DialogContentPrimitive<Payload>\n        ref={ref}\n        inline={inline}\n        className={cn('focus-visible:outline-hidden', className)}\n        {...props}\n      >\n        {parts}\n      </DialogContentPrimitive>\n    )\n  }\n  return (\n    <>\n      <DialogBackdrop />\n      <DialogContentPrimitive<Payload>\n        ref={ref}\n        inline={inline}\n        className={cn(\n          panelDialogClassName,\n          panelFooterTint,\n          'data-instant:transition-none',\n          className,\n        )}\n        {...props}\n      >\n        {(state) => (\n          <PanelSurface\n            closeButton={\n              showCloseButton ? (\n                <DialogClosePrimitive\n                  render={\n                    <Button\n                      variant='ghost'\n                      size='icon-sm'\n                      className={panelCloseClassName}\n                    />\n                  }\n                  aria-label='Close'\n                >\n                  <PanelCloseIcon />\n                </DialogClosePrimitive>\n              ) : null\n            }\n          >\n            {parts(state)}\n          </PanelSurface>\n        )}\n      </DialogContentPrimitive>\n    </>\n  )\n}\n\nfunction DialogHeader({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    {\n      'data-slot': 'dialog-header',\n      className: cn(panelHeaderClassName, className),\n      ...props,\n    },\n    render,\n  )\n}\n\nfunction DialogTitle({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof DialogTitlePrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <DialogTitlePrimitive className={cn(panelTitleClassName, className)} {...props} />\n  )\n}\n\nfunction DialogDescription({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof DialogDescriptionPrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <DialogDescriptionPrimitive\n      className={cn(panelDescriptionClassName, className)}\n      {...props}\n    />\n  )\n}\n\n/**\n * What scrolls when the dialog is taller than the screen, between the header\n * and the footer. `className` goes to its content, every other prop to the\n * element that scrolls. While it scrolls it takes focus, so the keyboard can\n * scroll it, as a region named by the dialog's title.\n */\nfunction DialogBody({ className, children, ref, ...props }: ComponentProps<'div'>) {\n  const scrollerRef = useRef<HTMLDivElement>(null)\n  const contentRef = useRef<HTMLDivElement>(null)\n  const scrollRegion = useScrollRegion(scrollerRef, contentRef)\n  const own = useMemo(() => mergeRefs(scrollerRef, ref), [ref])\n\n  return (\n    <div\n      data-panel='body'\n      className={cn(\n        panelBodyFrameClassName,\n        '[@container_(height<28rem)]:flex-none [@media(height<28rem)]:flex-none',\n      )}\n    >\n      <div\n        ref={own}\n        data-slot='dialog-body'\n        {...scrollRegion}\n        className={cn(\n          panelBodyClassName,\n          '[@container_(height<28rem)]:flex-none [@container_(height<28rem)]:overflow-visible [@media(height<28rem)]:flex-none [@media(height<28rem)]:overflow-visible',\n        )}\n        {...props}\n      >\n        <div\n          ref={contentRef}\n          data-slot='dialog-body-content'\n          className={cn(panelBodyContentClassName, className)}\n        >\n          {children}\n        </div>\n      </div>\n    </div>\n  )\n}\n\nfunction DialogFooter({\n  className,\n  render,\n  ...props\n}: Omit<PartProps<'div'>, 'className'> & { className?: string }) {\n  return renderElement(\n    'div',\n    {\n      'data-slot': 'dialog-footer',\n      'data-panel': 'footer',\n      className: cn(panelFooterClassName, className),\n      ...props,\n    },\n    render,\n  )\n}\n\nexport {\n  Dialog,\n  DialogBackdrop,\n  DialogBody,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/dialog.tsx"
    }
  ],
  "type": "registry:component"
}