{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog",
  "title": "Dialog",
  "description": "A dialog that presents itself for the screen: a centered dialog on wider screens and a bottom sheet you can drag away on phones (below 640px).",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-last-input",
    "@ouro/lib-open-mode",
    "@ouro/lib-page-scroll-hold",
    "@ouro/lib-portal-container",
    "@ouro/lib-refs",
    "@ouro/lib-server-element",
    "@ouro/lib-touch-target",
    "@ouro/lib-use-backdrop-anchor",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-keyboard-scrollable",
    "@ouro/lib-use-mounted-open",
    "@ouro/lib-use-sheet-presentation",
    "@ouro/sheet"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/dialog/dialog-parts.tsx",
      "content": "\"use client\";\n\nimport { AlertDialog } from \"@base-ui/react/alert-dialog\";\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, useCallback, useContext, type JSX, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { useBackdropAnchor } from \"@/registry/ouro/lib/ouro/use-backdrop-anchor\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useKeyboardScrollable } from \"@/registry/ouro/lib/ouro/use-keyboard-scrollable\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { holdPageAtPress } from \"@/registry/ouro/lib/ouro/page-scroll-hold\";\nimport { PortalScope } from \"@/registry/ouro/lib/ouro/portal-container\";\nimport { footerClass, iosBackdrop, sheetHint } from \"@/registry/ouro/components/ouro/sheet/sheet-styles\";\nimport { dialogSizes, dialogSizeWarning, type DialogSize } from \"@/registry/ouro/components/ouro/dialog/dialog-styles\";\n\nexport type { DialogSize } from \"@/registry/ouro/components/ouro/dialog/dialog-styles\";\n\nconst DialogContext = createContext(false);\n\n/*\n * Styles. The popup scales from 0.96 and fades in over 300ms, and scales and\n * fades out in 200ms, on the ease-out token; reduced motion keeps only the fade. The viewport keeps a 1rem\n * margin (or the safe area) on every side, so the dialog fits a phone; the body scrolls\n * when the dialog is taller than that. Class strings are literal so the app's Tailwind\n * finds them when it compiles.\n */\n// --ouro-inset-top is the height of an app bar the app draws across the window's top; the dialog layer starts below it.\n// On iOS the backdrop's top is anchored to the screen (useBackdropAnchor), so the inset clips it there instead.\nconst backdropClass =\n  \"fixed inset-0 top-(--ouro-inset-top,0px) z-1000 min-h-dvh bg-(--ouro-backdrop-color) opacity-(--ouro-backdrop-max) \" +\n  \"transition-opacity duration-(--ouro-duration-slow) ease-(--ouro-ease-out) \" +\n  \"data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-(--ouro-duration-base) data-ouro-instant:transition-none \" +\n  iosBackdrop +\n  \" supports-[-webkit-touch-callout:none]:[clip-path:inset(var(--ouro-inset-top,0px)_0_0_0)]\";\n\nconst viewportClass =\n  \"fixed inset-0 top-(--ouro-inset-top,0px) z-1000 box-border flex items-center justify-center \" +\n  \"pt-[max(1rem,env(safe-area-inset-top,0px))] pr-[max(1rem,env(safe-area-inset-right,0px))] \" +\n  \"pb-[max(1rem,env(safe-area-inset-bottom,0px))] pl-[max(1rem,env(safe-area-inset-left,0px))]\";\n\nconst popupClass =\n  \"relative isolate box-border flex max-h-full min-h-0 flex-col outline-none \" +\n  \"rounded-ouro-xl bg-(--ouro-bg) text-popover-foreground ring-1 ring-border/60 \" +\n  \"[--ouro-bg:var(--popover)] [--ouro-bd:color-mix(in_oklab,var(--border)_60%,transparent)] [--ouro-sq-w:1px] \" +\n  \"[--ouro-sq-r:calc(var(--radius)*var(--ouro-radius-scale,1)*1.4)] shadow-(--shadow-xl) \" +\n  \"[transition:transform_var(--ouro-duration-slow)_var(--ouro-ease-out),opacity_var(--ouro-duration-slow)_var(--ouro-ease-out)] \" +\n  \"data-starting-style:[transform:scale(0.96)] data-starting-style:opacity-0 \" +\n  \"data-ending-style:[transform:scale(0.96)] data-ending-style:opacity-0 \" +\n  \"data-ending-style:duration-(--ouro-duration-base) \" +\n  \"motion-reduce:[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] \" +\n  \"motion-reduce:data-starting-style:[transform:none] motion-reduce:data-ending-style:[transform:none] data-ouro-instant:[transition:none]\";\n\n// Running text: the elements Link also treats as text. In a dialog that fits its content they wrap at 65ch, so their\n// one-line width does not widen it, while a table, an image or a grid still does. The rule sits in the ouro-reset\n// layer, so the app's own max-width class on a paragraph wins.\nconst fitClass =\n  \"w-fit min-w-[min(32rem,100%)] \" +\n  \"[@layer_ouro-reset]:[&_:where(p,h1,h2,h3,h4,h5,h6,li,dt,dd,label,legend,blockquote,figcaption,[data-ouro=text],[data-ouro-text])]:max-w-[65ch]\";\n\n// sm, md and lg keep one width whatever the content. auto and the wide sizes fit their content: at least md's width,\n// so a short form does not shrink, and at most their cap and the viewport less its margins. auto's cap is 70% of the\n// screen, from 40rem to 56rem.\nconst popupSizes = {\n  auto: `${fitClass} max-w-[min(100%,clamp(40rem,70vw,56rem))]`,\n  sm: \"w-full max-w-[24rem]\",\n  md: \"w-full max-w-[32rem]\",\n  lg: \"w-full max-w-[40rem]\",\n  xl: `${fitClass} max-w-[min(100%,56rem)]`,\n  \"2xl\": `${fitClass} max-w-[min(100%,72rem)]`,\n  full: `${fitClass} max-w-full`,\n} as const;\n\n/** The JSX that puts a part in its place, for the dev message when it is not. */\nfunction shape(inner: string): string {\n  return `<DialogRoot><DialogTrigger render={<Button>Open</Button>} /><DialogPortal><DialogBackdrop /><DialogViewport><DialogPopup>${inner}</DialogPopup></DialogViewport></DialogPortal></DialogRoot>`;\n}\n\n/** Throws in development, with the JSX the part belongs in, unless it sits inside a dialog root. */\nfunction useDialogPart(part: string, inner: string): void {\n  if (!useContext(DialogContext)) {\n    devThrow(\n      part,\n      \"must be rendered inside <DialogRoot>\",\n      process.env.NODE_ENV !== \"production\" ? shape(inner) : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n}\n\n/**\n * Part: the state owner of a centered dialog built from parts. Use the `Dialog`\n * component instead unless its props cannot express your layout; `Dialog` also becomes a bottom sheet on phones, which parts do not.\n *\n * @example\n * <DialogRoot>\n *   <DialogTrigger render={<Button>Edit</Button>} />\n *   <DialogPortal>\n *     <DialogBackdrop />\n *     <DialogViewport>\n *       <DialogPopup size=\"sm\">\n *         <DialogTitle>Edit recipe</DialogTitle>\n *         <DialogContent>…</DialogContent>\n *         <DialogFooter>\n *           <DialogClose render={<Button>Done</Button>} />\n *         </DialogFooter>\n *       </DialogPopup>\n *     </DialogViewport>\n *   </DialogPortal>\n * </DialogRoot>\n */\nexport function DialogRoot(props: BaseDialog.Root.Props): JSX.Element {\n  return (\n    <DialogContext.Provider value>\n      <BaseDialog.Root {...props} />\n    </DialogContext.Provider>\n  );\n}\n\n/**\n * The root for `ConfirmDialog`: Base UI's alert dialog, which an outside press\n * cannot dismiss. It shares every other part with `DialogRoot`.\n *\n * @internal For `ConfirmDialog`; apps use `ConfirmDialog`.\n * @claim \"It shares every other part with\" registry/ouro/components/ouro/dialog/dialog-parts.tsx verify:fileLine(registry/ouro/components/ouro/dialog/dialog-parts.tsx, /export\\sfunction\\sAlertDialogRoot/)\n */\nexport function AlertDialogRoot(props: AlertDialog.Root.Props): JSX.Element {\n  return (\n    <DialogContext.Provider value>\n      <AlertDialog.Root {...props} />\n    </DialogContext.Provider>\n  );\n}\n\n/** Part: the button that opens the dialog. Pass your button as `render={<Button>Open</Button>}`. */\nexport function DialogTrigger({ onPointerDown, onKeyDown, ...props }: BaseDialog.Trigger.Props): JSX.Element {\n  useDialogPart(\"DialogTrigger\", \"…\");\n  return (\n    <BaseDialog.Trigger\n      {...(props.render === undefined ? { className: \"forced-colors:border forced-colors:border-solid\", \"data-ouro-control\": \"dialog\", \"data-ouro-part\": \"trigger\" } : {})}\n      {...props}\n      onPointerDown={(event) => {\n        onPointerDown?.(event);\n        holdPageAtPress.dialog.onPointerDown(event);\n      }}\n      onKeyDown={(event) => {\n        onKeyDown?.(event);\n        holdPageAtPress.dialog.onKeyDown(event);\n      }}\n    />\n  );\n}\n\n/**\n * Part: moves the dialog to the end of `<body>`, in its own stacking context at the\n * `--ouro-layer` z-index (50 by default, from ouro-base.css). If your app has fixed\n * bars above z-50, raise it in a `:root` rule of your own after the Ouro tokens, outside\n * any `@layer`: `:root { --ouro-layer: 60; }`. Don't edit the line shadcn wrote; `shadcn add` resets it.\n * @claim \"Part: moves the dialog to the\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog stacking above the app's fixed bars > puts the portal on the --ouro-layer level, as its own stacking context)\n * @claim \"Part: moves the dialog to the\" registry/ouro/theme/ouro-base.css verify:fileLine(registry/ouro/theme/ouro-base.css, /^\\s+--ouro-layer:\\s50;/)\n */\nexport function DialogPortal(props: Omit<BaseDialog.Portal.Props, \"className\">): JSX.Element {\n  useDialogPart(\"DialogPortal\", \"…\");\n  return (\n    <BaseDialog.Portal {...props} data-ouro=\"dialog-portal\" className=\"relative isolate z-(--ouro-layer)\">\n      <PortalScope>{props.children}</PortalScope>\n    </BaseDialog.Portal>\n  );\n}\n\n/**\n * Part: the dimming layer behind the dialog. On iOS it stays anchored to the top\n * of the screen on a scrolled page. A `ref` reaches the backdrop element.\n */\nexport function DialogBackdrop({\n  ref,\n  ...props\n}: Omit<BaseDialog.Backdrop.Props, \"className\"> & { ref?: Ref<HTMLDivElement> | undefined }): JSX.Element {\n  useDialogPart(\"DialogBackdrop\", \"…\");\n  const anchorRef = useBackdropAnchor(ref);\n  return <BaseDialog.Backdrop {...props} ref={anchorRef} data-ouro=\"dialog-backdrop\" className={backdropClass} />;\n}\n\n/** Part: the full-screen layer that centers the popup and keeps it clear of the screen edges. */\nexport function DialogViewport(props: Omit<BaseDialog.Viewport.Props, \"className\">): JSX.Element {\n  useDialogPart(\"DialogViewport\", \"…\");\n  return <BaseDialog.Viewport {...props} data-ouro=\"dialog-viewport\" className={viewportClass} />;\n}\n\n/** Props for {@link DialogPopup}. `className` is for layout only (margins, width). */\nexport type DialogPopupProps = Omit<BaseDialog.Popup.Props, \"className\"> & {\n  className?: string | undefined;\n  /**\n   * The panel's width. By default (`auto`) it fits its content and the screen: at least 32rem, so a form or a short\n   * question keeps a comfortable width, and at most 70% of the screen, from 40rem up to 56rem, so a gallery or a table grows\n   * on a big screen. Running text (paragraphs, headings, list items, labels, `Text`) wraps at a readable 65ch and does not\n   * widen it; bare text in a `div` measures as one long line, so put prose in a `<p>`. `xl` (56rem), `2xl` (72rem) and\n   * `full` (the viewport) raise the cap for wide content. `sm` (24rem), `md` (32rem) and `lg` (40rem) pin a fixed width\n   * whatever the content. Every size narrows to the viewport less its 1rem margins (or the safe area). @default \"auto\"\n   *\n   * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > fits size %s to its content, from 32rem up to %ipx)\n   * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > follows the screen by default: a wide table makes it %ipx wide on a %ipx screen)\n   * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps running text at a readable 65ch in size %s, so text alone does not widen it)\n   * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > lets the app's own max-width class on a paragraph win over the 65ch measure)\n   * @claim \"`xl` (56rem), `2xl` (72rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > caps size %s at %ipx wide)\n   * @claim \"`sm` (24rem), `md` (32rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s at %ipx whatever the content)\n   * @claim \"Every size narrows to the viewport\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s inside a 390px phone's 16px margins when presentation is dialog)\n   */\n  size?: DialogSize | (string & { 'Use \"auto\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\" or \"full\"': never }) | undefined;\n};\n\n/**\n * Part: the dialog panel. It scales up from 0.96 and fades in over 300ms, and scales and\n * fades out in 200ms; reduced motion keeps only the fade.\n * @claim \"It scales up from 0.96 and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::motion > scales from 0.96 on the ease-out token and fades, entering in 300ms and leaving in 200ms)\n * @claim \"It scales up from 0.96 and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::motion > drops the scale under reduced motion and keeps the fade)\n */\nexport function DialogPopup({ size: sizeProp = \"auto\", ...props }: DialogPopupProps): JSX.Element {\n  // A size that is not one of Ouro UI's (a type error) warns and renders the default.\n  const size = dialogSizes.includes(sizeProp as DialogSize) ? (sizeProp as DialogSize) : \"auto\";\n  useDevWarnings(\n    \"DialogPopup\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [size !== sizeProp && dialogSizeWarning(String(sizeProp), '<DialogPopup size=\"md\">')]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  useAppearanceClassNameCheck(\n    \"DialogPopup\",\n    props.className,\n    process.env.NODE_ENV !== \"production\"\n      ? sheetHint(\"<DialogPopup>\", \"</DialogPopup>\")\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  return <DialogPopupUnchecked {...props} size={size} />;\n}\n\n/**\n * The popup without its own className check, for `Dialog` and `ConfirmDialog`, which check their own.\n *\n * @internal\n */\nexport function DialogPopupUnchecked({\n  className,\n  size,\n  ref,\n  children,\n  ...props\n}: Omit<DialogPopupProps, \"size\"> & { size: DialogSize }): JSX.Element {\n  useDialogPart(\"DialogPopup\", \"…\");\n  const holdRef = useMergedRef(ref, useHeldTop());\n  return (\n    <BaseDialog.Popup\n      {...props}\n      ref={holdRef}\n      className={cn(popupClass, popupSizes[size], className)}\n      aria-modal=\"true\"\n      data-ouro=\"dialog\"\n      data-ouro-presentation=\"dialog\"\n      data-ouro-squircle=\"\"\n      data-size={size}\n    >\n      <span data-ouro-surface=\"\" aria-hidden=\"true\" style={{ zIndex: -1 }} />\n      {children}\n    </BaseDialog.Popup>\n  );\n}\n\n/**\n * Keeps an open dialog's top edge where it opened while its content grows or shrinks, as a macOS sheet does, so a\n * dialog whose steps tick by grows downward instead of moving as a whole. It opens centred, moves up only as far as\n * it must to stay inside the screen's margin, and centres itself again for a window of a new size.\n */\nfunction useHeldTop(): (popup: HTMLElement) => () => void {\n  return useCallback((popup: HTMLElement) => {\n    const viewport = popup.parentElement!;\n    // Where the popup's top is held, from the viewport's top: where the viewport centred it when it opened.\n    let held: number | undefined;\n    // A relative offset from where the viewport's centring puts it, so the popup's own margins (Lightbox's full\n    // screen) stay as they are.\n    const place = () => {\n      const height = popup.offsetHeight;\n      const natural = popup.offsetTop - (parseFloat(popup.style.top) || 0);\n      const lowest = viewport.clientHeight - parseFloat(getComputedStyle(viewport).paddingBottom) - height;\n      held ??= natural;\n      // Taller than the room, it stays where the viewport puts it; otherwise as near the held top as it fits.\n      // Stryker disable next-line EqualityOperator: at natural === lowest the popup fills the room, so held >= lowest and both give 0.\n      popup.style.top = `${natural > lowest ? 0 : Math.min(held, lowest) - natural}px`;\n    };\n    place();\n    const content = new ResizeObserver(place);\n    content.observe(popup);\n    // A window of a new height centres it again; a width change (a page's scroll bar coming or going) does not.\n    let screenHeight = viewport.clientHeight;\n    const screen = new ResizeObserver(() => {\n      if (viewport.clientHeight !== screenHeight) held = undefined;\n      screenHeight = viewport.clientHeight;\n      place();\n    });\n    screen.observe(viewport);\n    // Stryker disable next-line BlockStatement: the observers watch a popup and viewport that are leaving the page, so no test sees them stop.\n    return () => {\n      // Stryker disable next-line CallExpression: as above.\n      content.disconnect();\n      // Stryker disable next-line CallExpression: as above.\n      screen.disconnect();\n    };\n  },\n  // Stryker disable next-line ArrayDeclaration: the callback reads nothing from render, so any dependency list keeps it.\n  []);\n}\n\n/** Props for {@link DialogTitle}. */\nexport type DialogTitleProps = Omit<BaseDialog.Title.Props, \"className\"> & {\n  /** Hides the title visually; it still names the dialog for screen readers. */\n  visuallyHidden?: boolean | undefined;\n};\n\n/**\n * Part: the dialog's title, which names it. Every dialog needs one.\n *\n * @claim \"Every dialog needs one\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:fileLine(registry/ouro/components/ouro/dialog/dialog.test.tsx, /warns\\swhen\\sthe\\stitle\\sis\\smissing/)\n */\nexport function DialogTitle({ visuallyHidden, ...props }: DialogTitleProps): JSX.Element {\n  useDialogPart(\"DialogTitle\", \"<DialogTitle>…</DialogTitle>…\");\n  return (\n    <BaseDialog.Title\n      {...props}\n      data-ouro-dialog-title=\"\"\n      className={\n        visuallyHidden\n          ? \"sr-only\"\n          : \"m-0 font-[family-name:var(--font-heading,inherit)] text-lg leading-6 font-semibold text-balance text-popover-foreground\"\n      }\n    />\n  );\n}\n\n/** Part: a line under the title that describes the dialog. */\nexport function DialogDescription(props: Omit<BaseDialog.Description.Props, \"className\">): JSX.Element {\n  useDialogPart(\"DialogDescription\", \"<DialogTitle>…</DialogTitle><DialogDescription>…</DialogDescription>…\");\n  return (\n    <BaseDialog.Description\n      {...props}\n      data-ouro-dialog-description=\"\"\n      className=\"m-0 text-sm leading-5 text-pretty text-muted-foreground\"\n    />\n  );\n}\n\n/** Props for {@link DialogContent}. `className` is for layout only. */\nexport type DialogContentProps = Omit<JSX.IntrinsicElements[\"div\"], \"className\"> & { className?: string | undefined };\n\n/**\n * Part: the dialog's body. It scrolls when the dialog is taller than the\n * screen, and while it overflows it is a tab stop, so a keyboard can scroll it.\n * Its focus ring is drawn over the content, so a header that sticks to the top never hides an edge of it.\n * @claim \"Its focus ring is drawn over the content\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::DialogContent > draws its focus ring whole over content that sticks to an edge, and leaves the pointer to the content)\n */\nexport function DialogContent({ className, ref, ...props }: DialogContentProps): JSX.Element {\n  const scrollRef = useMergedRef(ref, useKeyboardScrollable<HTMLDivElement>(props.tabIndex === undefined));\n  useDialogPart(\"DialogContent\", \"<DialogTitle>…</DialogTitle><DialogContent>…</DialogContent>\");\n  useAppearanceClassNameCheck(\n    \"DialogContent\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? sheetHint(\"<DialogContent>\", \"</DialogContent>\")\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  // The wrapper takes the body's place in the dialog's column; the scroller fills it. Its focus ring is a sibling drawn\n  // over the scroller, so content that sticks to an edge inside the body never covers it.\n  return (\n    <div className=\"relative box-border flex min-h-0 flex-auto flex-col\">\n      <div\n        data-ouro-control=\"dialog\"\n        data-ouro-part=\"content\"\n        {...props}\n        ref={scrollRef}\n        data-ouro-dialog-content=\"\"\n        className={cn(\n          \"peer box-border min-h-0 flex-auto overflow-y-auto overscroll-contain px-5 pt-2 pb-5 outline-none focus-visible:isolate\",\n          // Under forced colours, where the body ends while it is one.\n          \"forced-colors:[&[tabindex='0']]:outline-1 forced-colors:[&[tabindex='0']]:outline-solid forced-colors:[&[tabindex='0']]:-outline-offset-1\",\n          className,\n        )}\n      />\n      <span\n        aria-hidden=\"true\"\n        data-dialog-focus-ring=\"\"\n        className=\"pointer-events-none absolute inset-0 hidden rounded-[inherit] outline-ring -outline-offset-2 peer-focus-visible:block peer-focus-visible:outline-2 peer-focus-visible:outline-solid\"\n      />\n    </div>\n  );\n}\n\n/**\n * Part: the actions row. A row at the end on wider screens; on phones the\n * actions stack full width. Put the primary action last, so it sits at the\n * bottom on phones, nearest the thumb.\n */\nexport function DialogFooter(props: Omit<JSX.IntrinsicElements[\"div\"], \"className\">): JSX.Element {\n  useDialogPart(\n    \"DialogFooter\",\n    \"<DialogTitle>…</DialogTitle><DialogContent>…</DialogContent><DialogFooter>…</DialogFooter>\",\n  );\n  return <div {...props} data-ouro-footer=\"\" className={footerClass} />;\n}\n\n/** Part: closes the dialog. Pass your button as `render={<Button>Done</Button>}`. */\nexport function DialogClose(props: BaseDialog.Close.Props): JSX.Element {\n  useDialogPart(\"DialogClose\", \"<DialogTitle>…</DialogTitle><DialogFooter><DialogClose>…</DialogClose></DialogFooter>\");\n  return <BaseDialog.Close {...(props.render === undefined ? { className: \"forced-colors:border forced-colors:border-solid\", \"data-ouro-control\": \"dialog\", \"data-ouro-part\": \"close\" } : {})} {...props} />;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/dialog/dialog-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/dialog/dialog-styles.ts",
      "content": "export { dialogSizes, dialogSizeWarning };\nexport type { DialogSize };\n\n// Value lists and dev-message helpers shared by Dialog and its parts, apart from the\n// components so each component file exports only components (React Fast Refresh). The\n// export list comes first because the shadcn CLI drops comments before a file's first statement.\n\n/**\n * A centered dialog's width. By default (`auto`) it fits its content and the screen: at least 32rem, so a form or a short\n * question keeps a comfortable width, and at most 70% of the screen, from 40rem up to 56rem, so a gallery or a table grows\n * on a big screen. Running text (paragraphs, headings, list items, labels, `Text`) wraps at a readable 65ch and does not\n * widen it; bare text in a `div` measures as one long line, so put prose in a `<p>`. `xl` (56rem), `2xl` (72rem) and\n * `full` (the viewport) raise the cap for wide content. `sm` (24rem), `md` (32rem) and `lg` (40rem) pin a fixed width\n * whatever the content. Every size narrows to the viewport less its 1rem margins (or the safe area).\n *\n * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > fits size %s to its content, from 32rem up to %ipx)\n * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > follows the screen by default: a wide table makes it %ipx wide on a %ipx screen)\n * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps running text at a readable 65ch in size %s, so text alone does not widen it)\n * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > lets the app's own max-width class on a paragraph win over the 65ch measure)\n * @claim \"`xl` (56rem), `2xl` (72rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > caps size %s at %ipx wide)\n * @claim \"`sm` (24rem), `md` (32rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s at %ipx whatever the content)\n * @claim \"Every size narrows to the viewport\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s inside a 390px phone's 16px margins when presentation is dialog)\n */\ntype DialogSize = \"auto\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"full\";\n\n/**\n * The seven sizes, for checking a `size` prop. Shared with `Dialog`.\n *\n * @internal\n * @claim \"The seven sizes, for checking a\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog parts > renders the auto DialogPopup for a size that is not one of Ouro UI's, and warns once with the fix)\n */\nconst dialogSizes: readonly DialogSize[] = [\"auto\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"full\"];\n\n/**\n * The dev message for a size that is not one of {@link dialogSizes}. Development only.\n *\n * @internal\n */\nfunction dialogSizeWarning(size: string, fix: string): readonly [string, string] {\n  return [`size=\"${size}\" is not a size; use ${dialogSizes.map((name) => `\"${name}\"`).join(\", \")}`, fix];\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/dialog/dialog-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/dialog/dialog.tsx",
      "content": "\"use client\";\n\nimport {\n  cloneElement,\n  useRef,\n  useState,\n  type JSX,\n  type KeyboardEvent,\n  type MouseEvent,\n  type PointerEvent,\n  type ReactElement,\n  type ReactNode,\n  type Ref,\n} from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { checkOpenMode, type TriggerOrOpen } from \"@/registry/ouro/lib/ouro/open-mode\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { serverElement } from \"@/registry/ouro/lib/ouro/server-element\";\nimport { TouchTarget } from \"@/registry/ouro/lib/ouro/touch-target\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { lastInput } from \"@/registry/ouro/lib/ouro/last-input\";\nimport { holdPageAtPress } from \"@/registry/ouro/lib/ouro/page-scroll-hold\";\nimport { useMountedOpen } from \"@/registry/ouro/lib/ouro/use-mounted-open\";\nimport { useSheetPresentation } from \"@/registry/ouro/lib/ouro/use-sheet-presentation\";\nimport { sheetHint } from \"@/registry/ouro/components/ouro/sheet/sheet-styles\";\nimport { SheetFrame } from \"@/registry/ouro/components/ouro/sheet/sheet\";\nimport {\n  DialogBackdrop,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogPopupUnchecked,\n  DialogPortal,\n  DialogRoot,\n  DialogTitle,\n  DialogViewport,\n} from \"@/registry/ouro/components/ouro/dialog/dialog-parts\";\nimport { dialogSizes, dialogSizeWarning, type DialogSize } from \"@/registry/ouro/components/ouro/dialog/dialog-styles\";\n\nexport type { DialogSize } from \"@/registry/ouro/components/ouro/dialog/dialog-parts\";\n\n/**\n * How a Dialog presents: `auto` is a centered dialog from 640px up and a bottom sheet below.\n *\n * @claim \"How a Dialog presents: `auto` is\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders a centered dialog at 1280px)\n * @claim \"How a Dialog presents: `auto` is\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders the bottom sheet at 390px)\n */\nexport type DialogPresentation = \"auto\" | \"dialog\" | \"sheet\";\n\nconst presentations: readonly DialogPresentation[] = [\"auto\", \"dialog\", \"sheet\"];\n\n/** Props shared by both ways of opening a Dialog. */\nexport interface DialogBaseProps {\n  /**\n   * Names the dialog for screen readers and shows at its top. Always required; hide it with `hideTitle`.\n   *\n   * @claim \"Always required; hide it with `hideTitle`\" registry/ouro/components/ouro/dialog/dialog.test-d.ts verify:fileLine(registry/ouro/components/ouro/dialog/dialog.test-d.ts, /\\{\\strigger:\\sReactElement;\\schildren:\\s\"Body\"\\s\\}>\\(\\)\\.not\\.toExtend<DialogProps>/)\n   */\n  title: string;\n  /** Hides the title visually. It still names the dialog for screen readers. */\n  hideTitle?: boolean | undefined;\n  /**\n   * The label of the close button, an icon button in the top corner, centered or as a sheet.\n   * Screen-reader users on phones (who have no Escape key) can always reach it.\n   * @default \"Close\"\n   * @claim \"Screen-reader users on phones (who have\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > shows the sheet's close icon button in the top corner in sheet presentation too)\n   */\n  closeLabel?: string | undefined;\n  /** A short line under the title, read out when the dialog opens. */\n  description?: ReactNode;\n  /**\n   * `auto` renders a centered dialog from the `sm` breakpoint (640px) up and a\n   * bottom sheet you can drag away below it. The server renders the dialog form\n   * and corrects it on hydration. A dialog that is closed at load shows nothing until\n   * it opens, so nothing shifts; one that is open at load (a route such as `?edit=1`)\n   * shows as the centered dialog on a phone until hydration swaps it to the sheet.\n   * @default \"auto\"\n   * @claim \"`auto` renders a centered dialog from\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders a centered dialog at 1280px)\n   * @claim \"`auto` renders a centered dialog from\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders the bottom sheet at 390px)\n   */\n  presentation?: DialogPresentation | (string & { 'Use \"auto\", \"dialog\" or \"sheet\"': never }) | undefined;\n  /**\n   * The centered dialog's width. By default (`auto`) it fits its content and the screen: at least 32rem, so a form or a short\n   * question keeps a comfortable width, and at most 70% of the screen, from 40rem up to 56rem, so a gallery or a table grows\n   * on a big screen. Running text (paragraphs, headings, list items, labels, `Text`) wraps at a readable 65ch and does not\n   * widen it; bare text in a `div` measures as one long line, so put prose in a `<p>`. `xl` (56rem), `2xl` (72rem) and\n   * `full` (the viewport) raise the cap for wide content. `sm` (24rem), `md` (32rem) and `lg` (40rem) pin a fixed width\n   * whatever the content. Every size narrows to the viewport less its 1rem margins (or the safe area). @default \"auto\"\n   *\n   * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > fits size %s to its content, from 32rem up to %ipx)\n   * @claim \"By default (`auto`) it fits\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > follows the screen by default: a wide table makes it %ipx wide on a %ipx screen)\n   * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps running text at a readable 65ch in size %s, so text alone does not widen it)\n   * @claim \"Running text (paragraphs, headings, list\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > lets the app's own max-width class on a paragraph win over the 65ch measure)\n   * @claim \"`xl` (56rem), `2xl` (72rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > caps size %s at %ipx wide)\n   * @claim \"`sm` (24rem), `md` (32rem) and\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s at %ipx whatever the content)\n   * @claim \"Every size narrows to the viewport\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > keeps size %s inside a 390px phone's 16px margins when presentation is dialog)\n   */\n  size?: DialogSize | (string & { 'Use \"auto\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\" or \"full\"': never }) | undefined;\n  /**\n   * The actions row: a row at the end on wider screens, stacked full width on\n   * phones. Put the primary action last, so it sits on the right on wider\n   * screens and at the bottom, nearest the thumb, on phones:\n   * `footer={<><Button variant=\"outline\" tone=\"secondary\">Cancel</Button><Button>Save</Button></>}`.\n   * Mark the primary action `default` (`<Button default onClick={save}>Save</Button>`) and Return\n   * presses it from the dialog's fields, as a Mac dialog's default button does.\n   * @claim \"Mark the primary action `default`\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::footer > presses the footer's default action on Return from a field, in a dialog and in a sheet)\n   */\n  footer?: ReactNode;\n  /** The body. It scrolls when the dialog is taller than the screen. */\n  children: ReactNode;\n  /**\n   * Layout only, applied to the panel: margins (`mt-4`). Use `size` for width.\n   * Your classes win over Ouro UI's. Appearance classes warn in development.\n   */\n  className?: string | undefined;\n\n  /** Not a prop. Ouro UI uses `open` with `onOpenChange`: `<Dialog open={open} onOpenChange={setOpen}>`. */\n  isOpen?: { 'Use <Dialog open={open} onOpenChange={setOpen}>': never };\n  /** Not a prop. `onOpenChange(false)` fires on close: `<Dialog open={open} onOpenChange={setOpen}>`. */\n  onClose?: { 'Use <Dialog open={open} onOpenChange={setOpen}>': never };\n  /** Not a prop. A Dialog is centered, or a bottom sheet on phones. For another edge use `<Sheet side=\"…\">`. */\n  position?: { 'Use <Sheet side=\"right\">': never };\n  /** Not a prop. A Dialog is centered, or a bottom sheet on phones. For another edge use `<Sheet side=\"…\">`. */\n  side?: { 'Use <Sheet side=\"right\">': never };\n  /** Not a prop. A Dialog fits its content. For snap points use `<Sheet snapPoints={[0.5, 1]}>`. */\n  snapPoints?: { 'Use <Sheet snapPoints={[0.5, 1]}>': never };\n}\n\n/** An uncontrolled Dialog: `trigger` opens it. */\nexport type DialogWithTriggerProps = DialogBaseProps & {\n  /** The element that opens the dialog, usually a Button: `trigger={<Button>Edit</Button>}`. */\n  trigger: ReactElement;\n  /** Not with `trigger`. Remove `trigger` to control the dialog with `open` and `onOpenChange`. */\n  open?: TriggerOrOpen;\n  /** Not with `trigger`. Remove `trigger` to control the dialog with `open` and `onOpenChange`. */\n  onOpenChange?: never;\n};\n\n/** A controlled Dialog: you own `open` and update it in `onOpenChange`. */\nexport type DialogControlledProps = DialogBaseProps & {\n  /**\n   * Whether the dialog is open. When a touch or pen tap opened it (on your own\n   * button, say), the centered dialog focuses itself rather than its first input,\n   * so no software keyboard pops up; after a key press it focuses the first control.\n   * Keep the Dialog mounted and change `open`: one that mounts already open after a press or a key\n   * (`{editing && <Dialog open … />}`) appears and leaves without its transitions, and says so in development.\n   * @claim \"Keep the Dialog mounted and change\" registry/ouro/components/ouro/dialog/dialog.first-mount.touch.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.first-mount.touch.test.tsx::Dialog mounted by the tap that opens it > says once in development that its open and close transitions don't run)\n   * @claim \"When a touch or pen tap\" registry/ouro/components/ouro/dialog/dialog.touch.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.touch.test.tsx::initial focus in a controlled dialog opened from the app's own button > focuses the centered popup, not its first input, after a tap)\n   * @claim \"When a touch or pen tap\" registry/ouro/components/ouro/dialog/dialog.touch.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.touch.test.tsx::initial focus in a controlled dialog opened from the app's own button > focuses the centered popup's first input after a keyboard open)\n   */\n  open: boolean;\n  /** Called with `false` when the user dismisses the dialog (close button, Escape, outside press, swipe). */\n  onOpenChange: (open: boolean) => void;\n  /** Not with `open`. Remove `open` and `onOpenChange` to let a trigger open the dialog. */\n  trigger?: never;\n};\n\n/** Props for {@link Dialog}: either `trigger`, or `open` with `onOpenChange`. */\nexport type DialogProps = DialogWithTriggerProps | DialogControlledProps;\n\n/** The props Dialog reads from, and adds to, its trigger element. */\ntype TriggerProps = {\n  ref?: Ref<HTMLElement> | undefined;\n  onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;\n  onPointerDown?: ((event: PointerEvent<HTMLElement>) => void) | undefined;\n  onKeyDown?: ((event: KeyboardEvent<HTMLElement>) => void) | undefined;\n  \"aria-haspopup\"?: string;\n  \"aria-expanded\"?: boolean;\n};\n\n/**\n * A compact icon button in the top corner: a centered dialog has no swipe to dismiss.\n * The header's end padding keeps the title clear of it, even when the title is hidden.\n * @claim \"A compact icon button in the\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > has a visible, compact close button in the top corner, labelled by closeLabel)\n */\nconst closeClass =\n  \"absolute top-3 end-3 box-border inline-flex size-8 items-center justify-center m-0 p-0 border-0 rounded-ouro-lg \" +\n  \"forced-colors:border forced-colors:border-solid \" +\n  \"press bg-transparent text-muted-foreground cursor-pointer [-webkit-tap-highlight-color:transparent] \" +\n  \"not-disabled:pointer-fine:hover:bg-accent not-disabled:pointer-fine:hover:text-accent-foreground \" +\n  \"not-disabled:active:bg-accent not-disabled:active:text-accent-foreground motion-safe:not-disabled:active:scale-(--ouro-press-scale) \" +\n  \"disabled:cursor-not-allowed disabled:opacity-50 \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid [&>svg]:size-4\";\n\n/**\n * The close button's icon: a 16px cross in the text color.\n *\n * @claim \"The close button's icon: a 16px\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::centered dialog > has a visible, compact close button in the top corner, labelled by closeLabel)\n * @claim \"The close button's icon: a 16px\" registry/ouro/components/ouro/dialog/dialog.tsx verify:fileLine(registry/ouro/components/ouro/dialog/dialog.tsx, /\\[&>svg\\]:size-4/)\n */\nfunction CloseIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\">\n      <path d=\"M4 4l8 8M12 4l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\n/** The controls a person can focus; a disabled one is left out. */\nconst FOCUSABLE =\n  \"a[href], button:not(:disabled), input:not(:disabled):not([type='hidden']), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n\n/** The fields a person types into or picks from. A footer's buttons are left out, so first focus is not on one that Return would press. */\nconst TEXT_ENTRY =\n  \"input:not(:disabled):not([type='hidden'], [type='button'], [type='submit'], [type='reset'], [type='image'], [type='checkbox'], [type='radio'], [type='range'], [type='color'], [type='file']), select:not(:disabled), textarea:not(:disabled)\";\n\n/**\n * The element a dialog gives first focus: the first control in its body that can be seen, else a\n * field in its footer, else its close button, else the popup itself. The body is skipped: while it\n * scrolls it is a tab stop, and Base UI would focus it first.\n */\nfunction firstFocus(popup: HTMLElement): HTMLElement {\n  const candidates = [\n    ...popup.querySelectorAll<HTMLElement>(`[data-ouro-dialog-content] :is(${FOCUSABLE}), [data-ouro-footer] :is(${TEXT_ENTRY}), [data-ouro-dialog-close]`),\n    popup,\n  ];\n  return candidates.find((element) => element.getClientRects().length > 0)!;\n}\n\n/**\n * A dialog that presents itself for the screen: a centered dialog on wider\n * screens and a bottom sheet you can drag away on phones (below 640px). It\n * handles focus, Escape, outside presses, scroll locking and a close button.\n * Once open, a centered dialog keeps its top edge where it opened while its\n * content grows or shrinks, as a macOS sheet does, and moves up only as far as\n * it must to stay on the screen.\n *\n * Use `trigger` for a dialog a button opens, or `open` with `onOpenChange` to\n * control it. Use `ConfirmDialog` instead to confirm an action, and `Sheet`\n * instead when the panel should slide in from an edge at every width.\n *\n * It stacks above the page at `--ouro-layer`, a z-index of 50 by default (from\n * ouro-base.css). If your app has fixed bars above z-50, raise it in a `:root` rule\n * of your own after the Ouro tokens, outside any `@layer`: `:root { --ouro-layer: 60; }`.\n * Don't edit the `--ouro-layer: 50` line shadcn wrote; `shadcn add` resets it.\n * An app that draws its own bar across the window's top sets `--ouro-inset-top` to that bar's height, and a centered dialog, its backdrop and a full-screen Lightbox open below it.\n *\n * Testing accessibility: in WebKit, Base UI's focus guards take `role=\"button\"`\n * without a name so VoiceOver's cursor stays trapped. Exclude them:\n * `new AxeBuilder({ page }).exclude(\"[data-base-ui-focus-guard]\")`.\n *\n * @group Overlays\n * @see https://ui.ouroboros.bot/docs/dialog\n *\n * @example\n * <Dialog title=\"Edit recipe\" trigger={<Button>Edit</Button>}>\n *   <RecipeForm />\n * </Dialog>\n * <Dialog\n *   title=\"Save to cookbook\"\n *   open={open}\n *   onOpenChange={setOpen}\n *   footer={<Button onClick={() => setOpen(false)}>Done</Button>}\n * >\n *   <CookbookList />\n * </Dialog>\n * @claim \"A dialog that presents itself for\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders a centered dialog at 1280px)\n * @claim \"A dialog that presents itself for\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::automatic presentation > renders the bottom sheet at 390px)\n * @claim \"Once open, a centered dialog\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog's top edge while its content changes > opens centred, then keeps its top edge where it opened as its content grows)\n * @claim \"Once open, a centered dialog\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog's top edge while its content changes > moves up only as far as it must when it grows past the screen's bottom margin)\n * @claim \"It stacks above the page at\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog stacking above the app's fixed bars > puts the portal on the --ouro-layer level, as its own stacking context)\n * @claim \"It stacks above the page at\" registry/ouro/theme/ouro-base.css verify:fileLine(registry/ouro/theme/ouro-base.css, /^\\s+--ouro-layer:\\s50;/)\n * @claim \"a centered dialog, its backdrop and a full-screen Lightbox open below it\" registry/ouro/components/ouro/dialog/dialog.test.tsx verify:testExists(registry/ouro/components/ouro/dialog/dialog.test.tsx::Dialog below an app's own bar > starts the backdrop and the centered viewport below --ouro-inset-top, and centres in the space under it)\n * @claim \"a centered dialog, its backdrop and a full-screen Lightbox open below it\" registry/ouro/components/ouro/lightbox/lightbox.mosaic.test.tsx verify:testExists(registry/ouro/components/ouro/lightbox/lightbox.mosaic.test.tsx::Lightbox full screen > starts below --ouro-inset-top and fills the rest of the window)\n * @claim \"Testing accessibility: in WebKit, Base UI's\" test/axe-exclude.test.tsx verify:testExists(test/axe-exclude.test.tsx::matches the open dialog's focus guards, and with them excluded the accessibility gate finds nothing)\n */\nexport function Dialog(props: DialogProps): JSX.Element {\n  const {\n    title,\n    hideTitle,\n    closeLabel = \"Close\",\n    description,\n    presentation: presentationProp = \"auto\",\n    size: sizeProp = \"auto\",\n    footer,\n    children,\n    className,\n    trigger,\n    open,\n    onOpenChange,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    isOpen,\n    onClose,\n    position,\n    side,\n    snapPoints,\n  } = props as DialogBaseProps & {\n    trigger?: ReactElement;\n    open?: boolean;\n    onOpenChange?: (open: boolean) => void;\n  };\n\n  checkOpenMode(\"Dialog\", \"dialog\", trigger !== undefined, open, onOpenChange);\n  const mountedOpen = useMountedOpen(open);\n\n  // A size or presentation that is not one of Ouro UI's (a type error) warns and renders the default.\n  const size = dialogSizes.includes(sizeProp as DialogSize) ? (sizeProp as DialogSize) : \"auto\";\n  const presentation = presentations.includes(presentationProp as DialogPresentation)\n    ? (presentationProp as DialogPresentation)\n    : \"auto\";\n\n  useAppearanceClassNameCheck(\n    \"Dialog\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? sheetHint('<Dialog title=\"…\">', \"</Dialog>\")\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Dialog\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => {\n          const where = \"a Dialog is centered, or a bottom sheet on phones\";\n          const list = (values: readonly string[]) => values.map((name) => `\"${name}\"`).join(\", \");\n          return [\n            !title && [\"title is required; it names the dialog for screen readers\", '<Dialog title=\"Edit recipe\">'],\n            mountedOpen && [\n              \"mounted already open, so its open and close transitions don't run; mount it closed and change open\",\n              \"<Dialog open={open} onOpenChange={setOpen}>\",\n            ],\n            size !== sizeProp && dialogSizeWarning(String(sizeProp), '<Dialog size=\"md\">'),\n            presentation !== presentationProp && [\n              `presentation=\"${String(presentationProp)}\" is not a presentation; use ${list(presentations)}`,\n              '<Dialog presentation=\"auto\">',\n            ],\n            isOpen !== undefined && [\"isOpen is not a prop\", \"<Dialog open={open} onOpenChange={setOpen}>\"],\n            onClose !== undefined && [\"onClose is not a prop\", \"<Dialog open={open} onOpenChange={setOpen}>\"],\n            position !== undefined && [`position is not a prop; ${where}`, '<Sheet side=\"bottom\">'],\n            side !== undefined && [`side is not a prop; ${where}`, `<Sheet side=\"${String(side)}\">`],\n            snapPoints !== undefined && [\n              \"snapPoints is not a prop; a Dialog fits its content\",\n              \"<Sheet snapPoints={[0.5, 1]}>\",\n            ],\n          ];\n        }\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  return (\n    <DialogFrame\n      title={title}\n      hideTitle={hideTitle}\n      closeLabel={closeLabel}\n      description={description}\n      presentation={presentation}\n      size={size}\n      footer={footer}\n      className={className}\n      trigger={trigger}\n      open={open}\n      onOpenChange={onOpenChange}\n    >\n      {children}\n    </DialogFrame>\n  );\n}\n\n/** Props for {@link DialogFrame}: a Dialog's props after its checks, with `trigger` and `open` allowed together. */\nexport interface DialogFrameProps {\n  title: string;\n  hideTitle?: boolean | undefined;\n  closeLabel: string;\n  description?: ReactNode;\n  presentation: DialogPresentation;\n  size: DialogSize;\n  footer?: ReactNode;\n  children: ReactNode;\n  className?: string | undefined;\n  /** The opening element. May come with `open`, when a pattern such as `EditSheet` owns the state. */\n  trigger?: ReactElement | undefined;\n  open?: boolean | undefined;\n  onOpenChange?: ((open: boolean) => void) | undefined;\n  /** Disables the close button, as `EditSheet` does while a save is pending. */\n  closeDisabled?: boolean | undefined;\n}\n\n/**\n * The dialog's markup and behavior, without prop checks: `Dialog` renders it after its own\n * checks, and `EditSheet` renders it with a trigger and its own open state, so it can close\n * the dialog when a save succeeds and still return focus to the trigger.\n *\n * @internal Shared with `EditSheet`; apps use `Dialog`.\n */\nexport function DialogFrame({\n  title,\n  hideTitle,\n  closeLabel,\n  description,\n  presentation,\n  size,\n  footer,\n  children,\n  className,\n  trigger,\n  open,\n  onOpenChange,\n  closeDisabled,\n}: DialogFrameProps): JSX.Element {\n  // The Dialog owns the open state even with a trigger, so the dialog stays open\n  // when a resize across 640px swaps the centered dialog for the sheet.\n  const [ownOpen, setOwnOpen] = useState(false);\n  const controlled = open !== undefined;\n  const isOpenNow = controlled ? open : ownOpen;\n  const setOpen = controlled ? onOpenChange! : setOwnOpen;\n\n  // The trigger is rendered once, outside both presentations, so its DOM node (and\n  // its focus, and the server-rendered node after hydration) survives a switch\n  // between the centered dialog and the sheet.\n  const triggerRef = useRef<HTMLElement>(null);\n  const popupRef = useRef<HTMLDivElement>(null);\n  // How the trigger last opened the dialog. Base UI's own trigger records this so a\n  // tap focuses the popup instead of the first input (which would raise the\n  // software keyboard); the cloned trigger records it here instead.\n  const [lastPointer, setLastPointer] = useState<string>();\n  const [tapOpened, setTapOpened] = useState(false);\n  // A Server Component's trigger can arrive as a lazy wrapper; resolve it before cloning.\n  const triggerElement = serverElement(trigger);\n  const triggerProps = (triggerElement?.props ?? {}) as TriggerProps;\n  const mergedTriggerRef = useMergedRef(triggerProps.ref, triggerRef);\n  const triggerNode =\n    trigger !== undefined &&\n    cloneElement(triggerElement as ReactElement<TriggerProps>, {\n      ref: mergedTriggerRef,\n      onPointerDown: (event: PointerEvent<HTMLElement>) => {\n        triggerProps.onPointerDown?.(event);\n        setLastPointer(event.pointerType);\n        holdPageAtPress.dialog.onPointerDown(event);\n      },\n      onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n        triggerProps.onKeyDown?.(event);\n        holdPageAtPress.dialog.onKeyDown(event);\n      },\n      onClick: (event: MouseEvent<HTMLElement>) => {\n        triggerProps.onClick?.(event);\n        if (event.defaultPrevented) return;\n        // A click with no pointer behind it (detail 0) came from the keyboard.\n        const pointer = event.detail === 0 ? \"keyboard\" : lastPointer;\n        setTapOpened(pointer === \"touch\" || pointer === \"pen\");\n        setOpen(true);\n      },\n      \"aria-haspopup\": \"dialog\",\n      \"aria-expanded\": isOpenNow,\n    });\n  // Focus returns to the trigger on close, in either presentation.\n  const finalFocus = trigger !== undefined ? { finalFocus: triggerRef } : {};\n  // Focus goes where firstFocus picks, never on a scrolling body. The centered dialog focuses\n  // itself after a touch or pen open. A dialog without a trigger decides when it opens, from the\n  // last press on the page. (The sheet always focuses itself, like a plain Sheet.)\n  const initialFocus = {\n    initialFocus: () => {\n      const touch = trigger === undefined ? lastInput() === \"touch\" || lastInput() === \"pen\" : tapOpened;\n      return touch ? popupRef.current : firstFocus(popupRef.current!);\n    },\n  };\n\n  // The server and hydration render the dialog form; the client corrects it after.\n  const presented = useSheetPresentation(presentation) ? (\n    <SheetFrame\n      title={title}\n      hideTitle={hideTitle}\n      closeLabel={closeLabel}\n      description={description}\n      side=\"bottom\"\n      className={className}\n      open={isOpenNow}\n      onOpenChange={setOpen}\n      footer={footer}\n      presentation=\"sheet\"\n      closeDisabled={closeDisabled}\n      {...finalFocus}\n    >\n      {children}\n    </SheetFrame>\n  ) : (\n    <DialogRoot open={isOpenNow} onOpenChange={(next) => setOpen(next)}>\n      <DialogPortal>\n        <DialogBackdrop />\n        <DialogViewport>\n          <DialogPopupUnchecked\n            ref={popupRef}\n            className={className}\n            size={size}\n            {...finalFocus}\n            {...initialFocus}\n          >\n            {/* Always rendered: with a hidden title it still keeps the body clear of the close button. */}\n            <div data-ouro-dialog-header=\"\" className=\"box-border grid min-h-13 shrink-0 gap-1 pt-5 pe-13 pb-2 ps-5\">\n              <DialogTitle visuallyHidden={hideTitle}>{title}</DialogTitle>\n              {description !== undefined && <DialogDescription>{description}</DialogDescription>}\n            </div>\n            <DialogContent>{children}</DialogContent>\n            {footer !== undefined && <DialogFooter>{footer}</DialogFooter>}\n            <DialogClose data-ouro-dialog-close=\"\" aria-label={closeLabel} disabled={closeDisabled} className={closeClass}>\n              <TouchTarget />\n              <CloseIcon />\n            </DialogClose>\n          </DialogPopupUnchecked>\n        </DialogViewport>\n      </DialogPortal>\n    </DialogRoot>\n  );\n\n  return (\n    <>\n      {triggerNode}\n      {presented}\n    </>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/dialog/dialog.tsx"
    }
  ],
  "docs": "A dialog that presents itself for the screen: a centered dialog on wider screens and a bottom sheet you can drag away on phones (below 640px). Import: import { Dialog } from \"@/components/ouro/dialog/dialog\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: sheet, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/dialog.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}