@loworbitstudio/visor 1.39.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "0.4.0",
3
- "generated_at": "2026-10-17T22:26:39.314Z",
3
+ "generated_at": "2026-10-27T04:04:23.584Z",
4
4
  "components": {
5
5
  "accessibility-specimen": {
6
6
  "changeType": "current",
@@ -832,7 +832,7 @@
832
832
  {
833
833
  "path": "components/ui/dialog/dialog.tsx",
834
834
  "type": "registry:ui",
835
- "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\"\nimport { ArrowLeftIcon, XIcon } from \"@phosphor-icons/react\"\nimport { cn } from \"../../../lib/utils\"\nimport styles from \"./dialog.module.css\"\n\ntype DialogPresentation = \"dialog\" | \"sheet\" | \"responsive\"\n\ninterface DialogContextValue {\n /** The presentation actually in force: `responsive` has already been resolved. */\n presentation: \"dialog\" | \"sheet\"\n container: HTMLElement | null | undefined\n open: boolean\n}\n\nconst DialogContext = React.createContext<DialogContextValue>({\n presentation: \"dialog\",\n container: undefined,\n open: false,\n})\n\nexport interface DialogProps\n extends React.ComponentProps<typeof DialogPrimitive.Root> {\n /**\n * How the content is presented. `dialog` is a centred modal, `sheet` is a\n * bottom sheet, `responsive` is a dialog from `breakpoint` up and a sheet\n * below it. The content, focus trap and Escape handling are identical.\n */\n presentation?: DialogPresentation\n /**\n * Viewport width at which `responsive` switches from sheet to dialog. A\n * number is px; a string is any CSS length (`\"40rem\"`). Defaults to 640.\n */\n breakpoint?: number | string\n /**\n * Element the overlay and content portal into, covering only that element.\n * A scoped dialog is not modal: it traps focus inside the content and makes\n * the container's other children `inert`, but leaves everything outside the\n * container interactive (Radix modal mode would aria-hide the page and block\n * pointer events on `body`). Pass the element itself (hold it in state), not\n * a ref. The container is given `position: relative` if it is `static`.\n */\n container?: HTMLElement | null\n}\n\nfunction Dialog({\n presentation = \"dialog\",\n breakpoint = 640,\n container,\n modal = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n ...props\n}: DialogProps) {\n const minWidth = typeof breakpoint === \"number\" ? `${breakpoint}px` : breakpoint\n const isWide = useMinWidth(minWidth)\n const resolved =\n presentation === \"responsive\" ? (isWide ? \"dialog\" : \"sheet\") : presentation\n\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const open = openProp ?? uncontrolledOpen\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n setUncontrolledOpen(next)\n onOpenChange?.(next)\n },\n [onOpenChange]\n )\n\n const value = React.useMemo(\n () => ({ presentation: resolved, container, open }),\n [resolved, container, open]\n )\n\n return (\n <DialogContext.Provider value={value}>\n <DialogPrimitive.Root\n data-slot=\"dialog\"\n modal={container ? false : modal}\n open={open}\n onOpenChange={handleOpenChange}\n {...props}\n />\n </DialogContext.Provider>\n )\n}\nDialog.displayName = \"Dialog\"\n\n/** True when the viewport is at least `minWidth` wide. Desktop where matchMedia is absent. */\nfunction useMinWidth(minWidth: string): boolean {\n const query = `(min-width: ${minWidth})`\n const [matches, setMatches] = React.useState<boolean>(() =>\n typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(query).matches\n : true\n )\n React.useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return\n const mq = window.matchMedia(query)\n setMatches(mq.matches)\n const onChange = (e: MediaQueryListEvent) => setMatches(e.matches)\n mq.addEventListener(\"change\", onChange)\n return () => mq.removeEventListener(\"change\", onChange)\n }, [query])\n return matches\n}\n\n/**\n * Scoped dialogs: make every other child of the container inert while open, and\n * make sure the container can anchor absolutely positioned content.\n */\nfunction useScopedContainer(container: HTMLElement | null | undefined, node: HTMLElement | null) {\n React.useEffect(() => {\n if (!container || !node) return\n let branch: HTMLElement = node\n while (branch.parentElement && branch.parentElement !== container) {\n branch = branch.parentElement\n }\n if (branch.parentElement !== container) return\n\n const inerted: Element[] = []\n for (const child of Array.from(container.children)) {\n if (child !== branch && !child.hasAttribute(\"inert\")) {\n child.setAttribute(\"inert\", \"\")\n inerted.push(child)\n }\n }\n const anchored = getComputedStyle(container).position === \"static\"\n if (anchored) container.style.position = \"relative\"\n\n return () => {\n for (const child of inerted) child.removeAttribute(\"inert\")\n if (anchored) container.style.position = \"\"\n }\n }, [container, node])\n}\n\n/**\n * Bottom sheet: keep the panel above the on-screen keyboard. The layout\n * viewport does not shrink on iOS, so size to the visual viewport and lift the\n * panel by the keyboard's height; keep the focused field in view.\n */\nfunction useKeyboardAvoidance(enabled: boolean, node: HTMLElement | null) {\n React.useEffect(() => {\n if (!enabled || !node || typeof window === \"undefined\") return\n const vv = window.visualViewport\n if (!vv) return\n const update = () => {\n const inset = Math.max(0, window.innerHeight - vv.height - vv.offsetTop)\n node.style.setProperty(\"--dialog-viewport-height\", `${vv.height}px`)\n node.style.setProperty(\"--dialog-keyboard-inset\", `${inset}px`)\n const active = document.activeElement\n if (inset > 0 && active instanceof HTMLElement && node.contains(active)) {\n active.scrollIntoView?.({ block: \"nearest\" })\n }\n }\n update()\n vv.addEventListener(\"resize\", update)\n vv.addEventListener(\"scroll\", update)\n return () => {\n vv.removeEventListener(\"resize\", update)\n vv.removeEventListener(\"scroll\", update)\n node.style.removeProperty(\"--dialog-viewport-height\")\n node.style.removeProperty(\"--dialog-keyboard-inset\")\n }\n }, [enabled, node])\n}\n\nconst DRAG_DISMISS_DISTANCE = 80\n\nfunction DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\nDialogTrigger.displayName = \"DialogTrigger\"\n\nfunction DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\nDialogClose.displayName = \"DialogClose\"\n\nfunction DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\nDialogPortal.displayName = \"DialogPortal\"\n\nconst DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n React.ComponentProps<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n data-slot=\"dialog-overlay\"\n className={cn(styles.overlay, className)}\n {...props}\n />\n))\nDialogOverlay.displayName = \"DialogOverlay\"\n\n/** Backdrop for a scoped dialog. Radix renders no overlay outside modal mode. */\nconst DialogScrim = React.forwardRef<HTMLDivElement, React.ComponentProps<\"div\">>(\n ({ className, ...props }, ref) => {\n const { open } = React.useContext(DialogContext)\n return (\n <div\n ref={ref}\n data-slot=\"dialog-overlay\"\n data-state={open ? \"open\" : \"closed\"}\n aria-hidden=\"true\"\n className={cn(styles.overlay, styles.scrim, className)}\n {...props}\n />\n )\n }\n)\nDialogScrim.displayName = \"DialogScrim\"\n\nexport interface DialogContentProps\n extends React.ComponentProps<typeof DialogPrimitive.Content> {\n /** Show a drag handle (sheet presentation only). Dragging down dismisses. */\n showHandle?: boolean\n}\n\nconst DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(({ className, children, showHandle = false, onInteractOutside, onFocus, ...props }, ref) => {\n const { presentation, container } = React.useContext(DialogContext)\n const scoped = Boolean(container)\n const isSheet = presentation === \"sheet\"\n const [node, setNode] = React.useState<HTMLDivElement | null>(null)\n const closeRef = React.useRef<HTMLButtonElement>(null)\n const dragStart = React.useRef<number | null>(null)\n\n const setRefs = React.useCallback(\n (el: HTMLDivElement | null) => {\n setNode(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = el\n },\n [ref]\n )\n\n useScopedContainer(container, node)\n useKeyboardAvoidance(isSheet && !scoped, node)\n\n const handleInteractOutside: typeof onInteractOutside = (event) => {\n onInteractOutside?.(event)\n if (!scoped || event.defaultPrevented) return\n // Only the scrim dismisses. A press on the page outside the container, or on\n // the container's inert siblings, must leave the dialog open.\n const target = event.target\n if (!(target instanceof Element && target.closest('[data-slot=\"dialog-overlay\"]'))) {\n event.preventDefault()\n }\n }\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n onFocus?.(event)\n const target = event.target\n if (isSheet && target instanceof HTMLElement && target.matches(\"input, textarea, select, [contenteditable]\")) {\n requestAnimationFrame(() => target.scrollIntoView?.({ block: \"nearest\" }))\n }\n }\n\n const dragTo = (clientY: number, commit: boolean) => {\n if (dragStart.current === null || !node) return\n const dy = Math.max(0, clientY - dragStart.current)\n if (!commit) {\n node.style.transition = \"none\"\n node.style.transform = `translateY(${dy}px)`\n return\n }\n dragStart.current = null\n node.style.transition = \"\"\n node.style.transform = \"\"\n if (dy > DRAG_DISMISS_DISTANCE) closeRef.current?.click()\n }\n\n return (\n <DialogPortal container={container}>\n {scoped ? <DialogScrim /> : <DialogOverlay />}\n <DialogPrimitive.Content\n ref={setRefs}\n data-slot=\"dialog-content\"\n data-presentation={presentation}\n data-scoped={scoped ? \"\" : undefined}\n className={cn(\n styles.content,\n isSheet && styles.presentationSheet,\n scoped && styles.scoped,\n className\n )}\n onInteractOutside={handleInteractOutside}\n onFocus={handleFocus}\n {...props}\n >\n {isSheet && showHandle && (\n <div\n data-slot=\"dialog-handle\"\n aria-hidden=\"true\"\n className={styles.handle}\n onPointerDown={(e) => {\n dragStart.current = e.clientY\n e.currentTarget.setPointerCapture?.(e.pointerId)\n }}\n onPointerMove={(e) => dragTo(e.clientY, false)}\n onPointerUp={(e) => dragTo(e.clientY, true)}\n onPointerCancel={() => dragTo(dragStart.current ?? 0, true)}\n />\n )}\n {children}\n <DialogPrimitive.Close ref={closeRef} className={styles.closeButton}>\n <XIcon className={styles.closeIcon} />\n <span className={styles.srOnly}>Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n )\n})\nDialogContent.displayName = \"DialogContent\"\n\nexport interface DialogHeaderProps extends React.ComponentProps<\"div\"> {\n /** Leading back action, rendered before the title (see `DialogBack`). */\n back?: React.ReactNode\n}\n\nfunction DialogHeader({ className, back, children, ...props }: DialogHeaderProps) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(styles.header, back ? styles.headerWithBack : undefined, className)}\n {...props}\n >\n {back ? (\n <>\n <div data-slot=\"dialog-back-slot\" className={styles.backSlot}>{back}</div>\n <div className={styles.headerBody}>{children}</div>\n </>\n ) : (\n children\n )}\n </div>\n )\n}\nDialogHeader.displayName = \"DialogHeader\"\n\nconst DialogBack = React.forwardRef<HTMLButtonElement, React.ComponentProps<\"button\">>(\n ({ className, children, type = \"button\", \"aria-label\": ariaLabel = \"Back\", ...props }, ref) => (\n <button\n ref={ref}\n type={type}\n data-slot=\"dialog-back\"\n aria-label={ariaLabel}\n className={cn(styles.backButton, className)}\n {...props}\n >\n {children ?? <ArrowLeftIcon className={styles.closeIcon} aria-hidden=\"true\" />}\n </button>\n )\n)\nDialogBack.displayName = \"DialogBack\"\n\nfunction DialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(styles.footer, className)}\n {...props}\n />\n )\n}\nDialogFooter.displayName = \"DialogFooter\"\n\nconst DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n React.ComponentProps<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n data-slot=\"dialog-title\"\n className={cn(styles.title, className)}\n {...props}\n />\n))\nDialogTitle.displayName = \"DialogTitle\"\n\nconst DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n React.ComponentProps<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n data-slot=\"dialog-description\"\n className={cn(styles.description, className)}\n {...props}\n />\n))\nDialogDescription.displayName = \"DialogDescription\"\n\nexport {\n Dialog,\n DialogTrigger,\n DialogClose,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogHeader,\n DialogBack,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n}\n"
835
+ "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\"\nimport { ArrowLeftIcon, XIcon } from \"@phosphor-icons/react\"\nimport { cn } from \"../../../lib/utils\"\nimport styles from \"./dialog.module.css\"\n\ntype DialogPresentation = \"dialog\" | \"sheet\" | \"responsive\"\n\ninterface DialogContextValue {\n /** The presentation actually in force: `responsive` has already been resolved. */\n presentation: \"dialog\" | \"sheet\"\n container: HTMLElement | null | undefined\n open: boolean\n}\n\nconst DialogContext = React.createContext<DialogContextValue>({\n presentation: \"dialog\",\n container: undefined,\n open: false,\n})\n\nexport interface DialogProps\n extends React.ComponentProps<typeof DialogPrimitive.Root> {\n /**\n * How the content is presented. `dialog` is a centred modal, `sheet` is a\n * bottom sheet, `responsive` is a dialog from `breakpoint` up and a sheet\n * below it. The content, focus trap and Escape handling are identical.\n */\n presentation?: DialogPresentation\n /**\n * Viewport width at which `responsive` switches from sheet to dialog. A\n * number is px; a string is any CSS length (`\"40rem\"`). Defaults to 640.\n */\n breakpoint?: number | string\n /**\n * Element the overlay and content portal into, covering only that element.\n * A scoped dialog is not modal: it traps focus inside the content and makes\n * the container's other children `inert`, but leaves everything outside the\n * container interactive (Radix modal mode would aria-hide the page and block\n * pointer events on `body`). Pass the element itself (hold it in state), not\n * a ref. The container is given `position: relative` if it is `static`.\n */\n container?: HTMLElement | null\n}\n\nfunction Dialog({\n presentation = \"dialog\",\n breakpoint = 640,\n container,\n modal = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n ...props\n}: DialogProps) {\n const minWidth = typeof breakpoint === \"number\" ? `${breakpoint}px` : breakpoint\n const isWide = useMinWidth(minWidth)\n const resolved =\n presentation === \"responsive\" ? (isWide ? \"dialog\" : \"sheet\") : presentation\n\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const open = openProp ?? uncontrolledOpen\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n setUncontrolledOpen(next)\n onOpenChange?.(next)\n },\n [onOpenChange]\n )\n\n const value = React.useMemo(\n () => ({ presentation: resolved, container, open }),\n [resolved, container, open]\n )\n\n return (\n <DialogContext.Provider value={value}>\n <DialogPrimitive.Root\n data-slot=\"dialog\"\n modal={container ? false : modal}\n open={open}\n onOpenChange={handleOpenChange}\n {...props}\n />\n </DialogContext.Provider>\n )\n}\nDialog.displayName = \"Dialog\"\n\n/** True when the viewport is at least `minWidth` wide. Desktop where matchMedia is absent. */\nfunction useMinWidth(minWidth: string): boolean {\n const query = `(min-width: ${minWidth})`\n const [matches, setMatches] = React.useState<boolean>(() =>\n typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(query).matches\n : true\n )\n React.useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return\n const mq = window.matchMedia(query)\n setMatches(mq.matches)\n const onChange = (e: MediaQueryListEvent) => setMatches(e.matches)\n mq.addEventListener(\"change\", onChange)\n return () => mq.removeEventListener(\"change\", onChange)\n }, [query])\n return matches\n}\n\n/**\n * Scoped dialogs: make every other child of the container inert while open, and\n * make sure the container can anchor absolutely positioned content.\n */\nfunction useScopedContainer(container: HTMLElement | null | undefined, node: HTMLElement | null) {\n React.useEffect(() => {\n if (!container || !node) return\n let branch: HTMLElement = node\n while (branch.parentElement && branch.parentElement !== container) {\n branch = branch.parentElement\n }\n if (branch.parentElement !== container) return\n\n const inerted: Element[] = []\n for (const child of Array.from(container.children)) {\n if (child !== branch && !child.hasAttribute(\"inert\")) {\n child.setAttribute(\"inert\", \"\")\n inerted.push(child)\n }\n }\n const anchored = getComputedStyle(container).position === \"static\"\n if (anchored) container.style.position = \"relative\"\n\n return () => {\n for (const child of inerted) child.removeAttribute(\"inert\")\n if (anchored) container.style.position = \"\"\n }\n }, [container, node])\n}\n\n/**\n * Bottom sheet: keep the panel above the on-screen keyboard. The layout\n * viewport does not shrink on iOS, so size to the visual viewport and lift the\n * panel by the keyboard's height; keep the focused field in view.\n */\nfunction useKeyboardAvoidance(enabled: boolean, node: HTMLElement | null) {\n React.useEffect(() => {\n if (!enabled || !node || typeof window === \"undefined\") return\n const vv = window.visualViewport\n if (!vv) return\n const update = () => {\n const inset = Math.max(0, window.innerHeight - vv.height - vv.offsetTop)\n node.style.setProperty(\"--dialog-viewport-height\", `${vv.height}px`)\n node.style.setProperty(\"--dialog-keyboard-inset\", `${inset}px`)\n const active = document.activeElement\n if (inset > 0 && active instanceof HTMLElement && node.contains(active)) {\n active.scrollIntoView?.({ block: \"nearest\" })\n }\n }\n update()\n vv.addEventListener(\"resize\", update)\n vv.addEventListener(\"scroll\", update)\n return () => {\n vv.removeEventListener(\"resize\", update)\n vv.removeEventListener(\"scroll\", update)\n node.style.removeProperty(\"--dialog-viewport-height\")\n node.style.removeProperty(\"--dialog-keyboard-inset\")\n }\n }, [enabled, node])\n}\n\nconst DRAG_DISMISS_DISTANCE = 80\n\nfunction DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\nDialogTrigger.displayName = \"DialogTrigger\"\n\nfunction DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\nDialogClose.displayName = \"DialogClose\"\n\nfunction DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\nDialogPortal.displayName = \"DialogPortal\"\n\nconst DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n React.ComponentProps<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n data-slot=\"dialog-overlay\"\n className={cn(styles.overlay, className)}\n {...props}\n />\n))\nDialogOverlay.displayName = \"DialogOverlay\"\n\n/** Backdrop for a scoped dialog. Radix renders no overlay outside modal mode. */\nconst DialogScrim = React.forwardRef<HTMLDivElement, React.ComponentProps<\"div\">>(\n ({ className, ...props }, ref) => {\n const { open } = React.useContext(DialogContext)\n return (\n <div\n ref={ref}\n data-slot=\"dialog-overlay\"\n data-state={open ? \"open\" : \"closed\"}\n aria-hidden=\"true\"\n className={cn(styles.overlay, styles.scrim, className)}\n {...props}\n />\n )\n }\n)\nDialogScrim.displayName = \"DialogScrim\"\n\nexport interface DialogContentProps\n extends React.ComponentProps<typeof DialogPrimitive.Content> {\n /** Show a drag handle (sheet presentation only). Dragging down dismisses. */\n showHandle?: boolean\n /**\n * Render the X close button. Default `true`. Hide it only when the content\n * carries its own dismiss action; Escape still closes. Drag-to-dismiss needs it.\n */\n showCloseButton?: boolean\n}\n\nconst DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(({ className, children, showHandle = false, showCloseButton = true, onInteractOutside, onFocus, ...props }, ref) => {\n const { presentation, container } = React.useContext(DialogContext)\n const scoped = Boolean(container)\n const isSheet = presentation === \"sheet\"\n const [node, setNode] = React.useState<HTMLDivElement | null>(null)\n const closeRef = React.useRef<HTMLButtonElement>(null)\n const dragStart = React.useRef<number | null>(null)\n\n const setRefs = React.useCallback(\n (el: HTMLDivElement | null) => {\n setNode(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = el\n },\n [ref]\n )\n\n useScopedContainer(container, node)\n useKeyboardAvoidance(isSheet && !scoped, node)\n\n const handleInteractOutside: typeof onInteractOutside = (event) => {\n onInteractOutside?.(event)\n if (!scoped || event.defaultPrevented) return\n // Only the scrim dismisses. A press on the page outside the container, or on\n // the container's inert siblings, must leave the dialog open.\n const target = event.target\n if (!(target instanceof Element && target.closest('[data-slot=\"dialog-overlay\"]'))) {\n event.preventDefault()\n }\n }\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n onFocus?.(event)\n const target = event.target\n if (isSheet && target instanceof HTMLElement && target.matches(\"input, textarea, select, [contenteditable]\")) {\n requestAnimationFrame(() => target.scrollIntoView?.({ block: \"nearest\" }))\n }\n }\n\n const dragTo = (clientY: number, commit: boolean) => {\n if (dragStart.current === null || !node) return\n const dy = Math.max(0, clientY - dragStart.current)\n if (!commit) {\n node.style.transition = \"none\"\n node.style.transform = `translateY(${dy}px)`\n return\n }\n dragStart.current = null\n node.style.transition = \"\"\n node.style.transform = \"\"\n if (dy > DRAG_DISMISS_DISTANCE) closeRef.current?.click()\n }\n\n return (\n <DialogPortal container={container}>\n {scoped ? <DialogScrim /> : <DialogOverlay />}\n <DialogPrimitive.Content\n ref={setRefs}\n data-slot=\"dialog-content\"\n data-presentation={presentation}\n data-scoped={scoped ? \"\" : undefined}\n className={cn(\n styles.content,\n isSheet && styles.presentationSheet,\n scoped && styles.scoped,\n className\n )}\n onInteractOutside={handleInteractOutside}\n onFocus={handleFocus}\n {...props}\n >\n {isSheet && showHandle && (\n <div\n data-slot=\"dialog-handle\"\n aria-hidden=\"true\"\n className={styles.handle}\n onPointerDown={(e) => {\n dragStart.current = e.clientY\n e.currentTarget.setPointerCapture?.(e.pointerId)\n }}\n onPointerMove={(e) => dragTo(e.clientY, false)}\n onPointerUp={(e) => dragTo(e.clientY, true)}\n onPointerCancel={() => dragTo(dragStart.current ?? 0, true)}\n />\n )}\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close ref={closeRef} className={styles.closeButton}>\n <XIcon className={styles.closeIcon} />\n <span className={styles.srOnly}>Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n )\n})\nDialogContent.displayName = \"DialogContent\"\n\nexport interface DialogHeaderProps extends React.ComponentProps<\"div\"> {\n /** Leading back action, rendered before the title (see `DialogBack`). */\n back?: React.ReactNode\n}\n\nfunction DialogHeader({ className, back, children, ...props }: DialogHeaderProps) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(styles.header, back ? styles.headerWithBack : undefined, className)}\n {...props}\n >\n {back ? (\n <>\n <div data-slot=\"dialog-back-slot\" className={styles.backSlot}>{back}</div>\n <div className={styles.headerBody}>{children}</div>\n </>\n ) : (\n children\n )}\n </div>\n )\n}\nDialogHeader.displayName = \"DialogHeader\"\n\nconst DialogBack = React.forwardRef<HTMLButtonElement, React.ComponentProps<\"button\">>(\n ({ className, children, type = \"button\", \"aria-label\": ariaLabel = \"Back\", ...props }, ref) => (\n <button\n ref={ref}\n type={type}\n data-slot=\"dialog-back\"\n aria-label={ariaLabel}\n className={cn(styles.backButton, className)}\n {...props}\n >\n {children ?? <ArrowLeftIcon className={styles.closeIcon} aria-hidden=\"true\" />}\n </button>\n )\n)\nDialogBack.displayName = \"DialogBack\"\n\nfunction DialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(styles.footer, className)}\n {...props}\n />\n )\n}\nDialogFooter.displayName = \"DialogFooter\"\n\nconst DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n React.ComponentProps<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n data-slot=\"dialog-title\"\n className={cn(styles.title, className)}\n {...props}\n />\n))\nDialogTitle.displayName = \"DialogTitle\"\n\nconst DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n React.ComponentProps<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n data-slot=\"dialog-description\"\n className={cn(styles.description, className)}\n {...props}\n />\n))\nDialogDescription.displayName = \"DialogDescription\"\n\nexport {\n Dialog,\n DialogTrigger,\n DialogClose,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogHeader,\n DialogBack,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n}\n"
836
836
  },
837
837
  {
838
838
  "path": "components/ui/dialog/dialog.module.css",
@@ -2715,7 +2715,7 @@
2715
2715
  {
2716
2716
  "path": "components/ui/confirm-dialog/confirm-dialog.tsx",
2717
2717
  "type": "registry:ui",
2718
- "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n InfoIcon,\n WarningIcon,\n WarningOctagonIcon,\n} from \"@phosphor-icons/react\"\nimport { cn } from \"../../../lib/utils\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"../dialog/dialog\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport styles from \"./confirm-dialog.module.css\"\n\nexport type ConfirmDialogSeverity =\n | \"info\"\n | \"warning\"\n | \"destructive\"\n /**\n * @deprecated Use `\"destructive\"` instead. `\"danger\"` will be removed in the next major version.\n */\n | \"danger\"\n\n/** Internal normalized severity — `\"danger\"` is collapsed to `\"destructive\"`. */\ntype NormalizedSeverity = \"info\" | \"warning\" | \"destructive\"\n\nfunction normalizeSeverity(s: ConfirmDialogSeverity): NormalizedSeverity {\n return s === \"danger\" ? \"destructive\" : s\n}\n\n/** Severity icon visual treatment.\n *\n * Leave unset for the canonical default — a ~2.5rem tinted circular plate\n * (`surface-*-subtle` tint) stacked ABOVE the title. This is the unchanged\n * default rendering of every existing ConfirmDialog consumer.\n *\n * Set explicitly to opt into the blessed editorial treatments:\n * - `\"plated\"` — a 40px circular plate with a `color-mix` severity wash,\n * leading the title column (golden organization-management Feedback screen).\n * - `\"inline\"` — a small leading icon next to the title (no plate). */\nexport type ConfirmDialogIconTreatment = \"inline\" | \"plated\"\n\n/** Rendering mode. `dialog` (default) wraps content in Radix\n * Dialog/Portal/Overlay with an auto X-close. `inline` renders just the\n * content surface in normal flow — no portal, no overlay, no auto X-close —\n * so consumers can stack multiple dialogs inside one shared scrim. Opt-in. */\nexport type ConfirmDialogMode = \"dialog\" | \"inline\"\n\nexport interface ConfirmDialogProps {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Called when open state changes. */\n onOpenChange?: (open: boolean) => void\n\n /** Optional trigger — wrapped in DialogTrigger. Omit for fully-controlled usage. */\n trigger?: React.ReactNode\n\n /** Dialog title — rendered in DialogTitle next to the severity icon. */\n title: React.ReactNode\n /** Short body above the action row. Used as DialogDescription. */\n description?: React.ReactNode\n /** Richer body slot — overrides description when provided. */\n children?: React.ReactNode\n\n /** Severity — drives icon color, confirm button variant. Default \"warning\". */\n severity?: ConfirmDialogSeverity\n\n /** Custom severity icon — overrides the severity default. Opt-in; omit to\n * use the built-in icon for the active severity. Sizing/color is handled by\n * the icon container, so pass a bare Phosphor icon (no explicit size). */\n icon?: React.ReactNode\n\n /** Severity-icon treatment. Leave unset for the canonical default (a tinted\n * circular plate stacked above the title). Set \"plated\" for the blessed\n * color-mix plate, or \"inline\" for a small leading icon next to the title.\n * Default rendering (unset) is unchanged. */\n iconTreatment?: ConfirmDialogIconTreatment\n\n /** Rendering mode. \"dialog\" (default) uses Radix Dialog + Portal + Overlay +\n * auto X-close. \"inline\" renders only the content surface (no portal, no\n * overlay, no X-close) so multiple dialogs can stack in one shared scrim.\n * Opt-in — default rendering is unchanged. */\n mode?: ConfirmDialogMode\n\n /** Confirm button label. Defaults: \"Delete\" for danger, \"Confirm\" otherwise. */\n confirmLabel?: React.ReactNode\n /** Cancel button label. Default \"Cancel\". */\n cancelLabel?: React.ReactNode\n /** Cancel button variant. Default \"outline\". Golden screens use \"ghost\". */\n cancelVariant?: ButtonProps[\"variant\"]\n\n /** If set, user must type this exact string to enable the confirm button. */\n confirmText?: string\n /** Label for the confirm-text input. Default: `Type ${confirmText} to confirm`. */\n confirmTextLabel?: React.ReactNode\n\n /** Confirm handler. Async-aware: returning a Promise puts the dialog into pending state. */\n onConfirm?: () => void | Promise<void>\n /** Cancel handler. */\n onCancel?: () => void\n\n /** Externally-controlled busy state — overrides internal async pending detection. */\n busy?: boolean\n\n /** Additional className on DialogContent. */\n className?: string\n}\n\nfunction getSeverityIcon(severity: NormalizedSeverity): React.ReactNode {\n switch (severity) {\n case \"info\":\n return <InfoIcon weight=\"fill\" aria-hidden=\"true\" />\n case \"destructive\":\n return <WarningOctagonIcon weight=\"fill\" aria-hidden=\"true\" />\n case \"warning\":\n default:\n return <WarningIcon weight=\"fill\" aria-hidden=\"true\" />\n }\n}\n\n/** Canonical default plate tint (surface-*-subtle stacked plate). */\nfunction getSeverityPlateClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.plateInfo\n case \"destructive\":\n return styles.plateDestructive\n case \"warning\":\n default:\n return styles.plateWarning\n }\n}\n\n/** Inline severity icon color (small leading icon, no plate). */\nfunction getSeverityIconClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.iconInfo\n case \"destructive\":\n return styles.iconDanger\n case \"warning\":\n default:\n return styles.iconWarning\n }\n}\n\n/** Blessed plated tint (color-mix wash). */\nfunction getPlatedIconClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.iconPlatedInfo\n case \"destructive\":\n return styles.iconPlatedDanger\n case \"warning\":\n default:\n return styles.iconPlatedWarning\n }\n}\n\nfunction getConfirmButtonVariant(\n severity: NormalizedSeverity\n): \"default\" | \"destructive\" {\n return severity === \"destructive\" ? \"destructive\" : \"default\"\n}\n\nfunction getDefaultConfirmLabel(severity: NormalizedSeverity): string {\n return severity === \"destructive\" ? \"Delete\" : \"Confirm\"\n}\n\nconst ConfirmDialog = React.forwardRef<\n React.ComponentRef<typeof DialogContent>,\n ConfirmDialogProps\n>(\n (\n {\n open: openProp,\n defaultOpen,\n onOpenChange,\n trigger,\n title,\n description,\n children,\n severity = \"warning\",\n icon,\n iconTreatment,\n mode = \"dialog\",\n confirmLabel,\n cancelLabel = \"Cancel\",\n cancelVariant = \"outline\",\n confirmText,\n confirmTextLabel,\n onConfirm,\n onCancel,\n busy,\n className,\n },\n ref\n ) => {\n const isControlled = openProp !== undefined\n const [internalOpen, setInternalOpen] = React.useState<boolean>(\n defaultOpen ?? false\n )\n const actualOpen = isControlled ? (openProp as boolean) : internalOpen\n\n const [isPending, setIsPending] = React.useState<boolean>(false)\n const [typed, setTyped] = React.useState<string>(\"\")\n\n const cancelButtonRef = React.useRef<HTMLButtonElement | null>(null)\n\n const normalizedSeverity = normalizeSeverity(severity)\n\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setInternalOpen(next)\n }\n onOpenChange?.(next)\n if (!next) {\n // Clear gate typing on close\n setTyped(\"\")\n }\n },\n [isControlled, onOpenChange]\n )\n\n const resolvedConfirmLabel =\n confirmLabel ?? getDefaultConfirmLabel(normalizedSeverity)\n const effectiveBusy = busy ?? isPending\n const gateSatisfied =\n confirmText == null || confirmText.length === 0 || typed === confirmText\n const confirmDisabled = effectiveBusy || !gateSatisfied\n const cancelDisabled = effectiveBusy\n\n const handleConfirmClick = React.useCallback(async () => {\n if (!onConfirm) {\n handleOpenChange(false)\n return\n }\n // Any synchronous throw propagates naturally to React's error boundary.\n const result = onConfirm()\n if (result && typeof (result as Promise<void>).then === \"function\") {\n setIsPending(true)\n try {\n await result\n setIsPending(false)\n handleOpenChange(false)\n } catch (err) {\n // Async rejection — clear pending state, keep dialog open, re-throw\n // so the consumer's error handling (error boundary, onUnhandledRejection)\n // can react to it.\n setIsPending(false)\n throw err\n }\n } else {\n handleOpenChange(false)\n }\n }, [onConfirm, handleOpenChange])\n\n const handleCancelClick = React.useCallback(() => {\n onCancel?.()\n handleOpenChange(false)\n }, [onCancel, handleOpenChange])\n\n const handleOpenAutoFocus = React.useCallback(\n (event: Event) => {\n if (normalizedSeverity === \"destructive\" && cancelButtonRef.current) {\n event.preventDefault()\n cancelButtonRef.current.focus()\n }\n },\n [normalizedSeverity]\n )\n\n const severityIcon = icon ?? getSeverityIcon(normalizedSeverity)\n const confirmVariant = getConfirmButtonVariant(normalizedSeverity)\n const isInline = mode === \"inline\"\n\n // Treatment resolution:\n // - unset → canonical default: tinted plate stacked above title\n // (data-slot=\"confirm-dialog-icon-plate\"). Unchanged.\n // - \"plated\" → blessed plated: 40px color-mix plate leading the\n // title column (data-slot=\"confirm-dialog-icon\").\n // - \"inline\" → blessed inline: small leading icon (no plate).\n const isCanonicalPlate = iconTreatment === undefined\n const isBlessedPlated = iconTreatment === \"plated\"\n\n // Generate stable id for confirm gate input\n const generatedId = React.useId()\n const confirmGateInputId = `${generatedId}-confirm-input`\n\n const hasDescriptionForAria =\n description != null && description !== false && !children\n\n // Canonical default plate — a span carrying the tinted circle, stacked\n // above the title inside .headerStack. Preserved verbatim for backward\n // compatibility (existing consumers + tests query this slot/classes).\n const canonicalPlate = (\n <span\n data-slot=\"confirm-dialog-icon-plate\"\n aria-hidden=\"true\"\n className={cn(styles.iconPlate, getSeverityPlateClass(normalizedSeverity))}\n >\n {severityIcon}\n </span>\n )\n\n // Blessed icon span — used for explicit \"plated\"/\"inline\" treatments.\n const blessedIconClass = isBlessedPlated\n ? cn(styles.iconPlated, getPlatedIconClass(normalizedSeverity))\n : cn(styles.icon, getSeverityIconClass(normalizedSeverity))\n const blessedIconSpan = (\n <span\n data-slot=\"confirm-dialog-icon\"\n aria-hidden=\"true\"\n className={blessedIconClass}\n >\n {severityIcon}\n </span>\n )\n\n // Header layout class per treatment.\n // - canonical default → .headerStack (column: plate above title/description)\n // - blessed plated → .titleRowPlated (column: plate above title)\n // - blessed inline → .titleRow (row: icon next to title)\n const headerLayoutClass = isCanonicalPlate\n ? styles.headerStack\n : isBlessedPlated\n ? styles.titleRowPlated\n : styles.titleRow\n\n const iconElement = isCanonicalPlate ? canonicalPlate : blessedIconSpan\n\n // Dialog-mode header — uses Radix Title/Description (a11y + aria-labelledby).\n // Canonical plate stacks plate + title + description inside one .headerStack;\n // blessed treatments keep description outside the title row.\n const dialogHeader = isCanonicalPlate ? (\n <DialogHeader>\n <div className={headerLayoutClass}>\n {iconElement}\n <DialogTitle>{title}</DialogTitle>\n {hasDescriptionForAria ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </div>\n </DialogHeader>\n ) : (\n <DialogHeader>\n <div className={headerLayoutClass}>\n {iconElement}\n <DialogTitle>{title}</DialogTitle>\n </div>\n {hasDescriptionForAria ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </DialogHeader>\n )\n\n // Inline-mode header — no Dialog context, so render a plain heading/paragraph.\n const inlineHeaderEl = (\n <div className={styles.inlineHeader}>\n <div className={headerLayoutClass}>\n {iconElement}\n <h2 className={styles.inlineTitle}>{title}</h2>\n </div>\n {hasDescriptionForAria ? (\n <p className={styles.inlineDescription}>{description}</p>\n ) : null}\n </div>\n )\n\n const header = isInline ? inlineHeaderEl : dialogHeader\n\n const innerContent = (\n <>\n {header}\n\n {children ? (\n <div data-slot=\"confirm-dialog-body\" className={styles.body}>\n {children}\n </div>\n ) : null}\n\n {confirmText ? (\n <div className={styles.confirmGate}>\n <label\n htmlFor={confirmGateInputId}\n className={styles.confirmGateLabel}\n >\n {confirmTextLabel ?? `Type ${confirmText} to confirm`}\n </label>\n <input\n id={confirmGateInputId}\n type=\"text\"\n autoComplete=\"off\"\n spellCheck={false}\n value={typed}\n onChange={(e) => setTyped(e.target.value)}\n disabled={effectiveBusy}\n className={styles.confirmGateInput}\n data-slot=\"confirm-dialog-gate-input\"\n />\n </div>\n ) : null}\n\n <div\n data-slot=\"confirm-dialog-actions\"\n className={styles.actions}\n role=\"group\"\n >\n <div className={styles.action}>\n <Button\n ref={cancelButtonRef}\n type=\"button\"\n variant={cancelVariant}\n onClick={handleCancelClick}\n disabled={cancelDisabled}\n data-slot=\"confirm-dialog-cancel\"\n >\n {cancelLabel}\n </Button>\n </div>\n <div className={styles.action}>\n <Button\n type=\"button\"\n variant={confirmVariant}\n onClick={handleConfirmClick}\n disabled={confirmDisabled}\n aria-busy={effectiveBusy || undefined}\n data-slot=\"confirm-dialog-confirm\"\n >\n {resolvedConfirmLabel}\n </Button>\n </div>\n </div>\n </>\n )\n\n // Inline (non-portal) mode — render only the content surface. No Radix\n // Dialog/Portal/Overlay/X-close, so consumers can stack multiple dialogs\n // inside one shared scrim. Open/close is consumer-driven; respect `open`.\n if (isInline) {\n if (!actualOpen) {\n return null\n }\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement>}\n role=\"alertdialog\"\n aria-modal={false}\n data-slot=\"confirm-dialog\"\n data-mode=\"inline\"\n data-severity={normalizedSeverity}\n className={cn(styles.root, styles.inlineSurface, className)}\n >\n {innerContent}\n </div>\n )\n }\n\n return (\n <Dialog\n open={actualOpen}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n >\n {trigger ? <DialogTrigger asChild>{trigger}</DialogTrigger> : null}\n <DialogContent\n ref={ref}\n data-slot=\"confirm-dialog\"\n data-severity={normalizedSeverity}\n className={cn(styles.root, className)}\n onOpenAutoFocus={handleOpenAutoFocus}\n >\n {innerContent}\n </DialogContent>\n </Dialog>\n )\n }\n)\nConfirmDialog.displayName = \"ConfirmDialog\"\n\nexport { ConfirmDialog }\n"
2718
+ "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n InfoIcon,\n WarningIcon,\n WarningOctagonIcon,\n} from \"@phosphor-icons/react\"\nimport { cn } from \"../../../lib/utils\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"../dialog/dialog\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport styles from \"./confirm-dialog.module.css\"\n\nexport type ConfirmDialogSeverity =\n | \"info\"\n | \"warning\"\n | \"destructive\"\n /**\n * @deprecated Use `\"destructive\"` instead. `\"danger\"` will be removed in the next major version.\n */\n | \"danger\"\n\n/** Internal normalized severity — `\"danger\"` is collapsed to `\"destructive\"`. */\ntype NormalizedSeverity = \"info\" | \"warning\" | \"destructive\"\n\nfunction normalizeSeverity(s: ConfirmDialogSeverity): NormalizedSeverity {\n return s === \"danger\" ? \"destructive\" : s\n}\n\n/** Severity icon visual treatment.\n *\n * Leave unset for the canonical default — a ~2.5rem tinted circular plate\n * (`surface-*-subtle` tint) stacked ABOVE the title. This is the unchanged\n * default rendering of every existing ConfirmDialog consumer.\n *\n * Set explicitly to opt into the blessed editorial treatments:\n * - `\"plated\"` — a 40px circular plate with a `color-mix` severity wash,\n * leading the title column (golden organization-management Feedback screen).\n * - `\"inline\"` — a small leading icon next to the title (no plate).\n * - `\"none\"` — no icon and no icon container. */\nexport type ConfirmDialogIconTreatment = \"inline\" | \"plated\" | \"none\"\n\n/** Rendering mode. `dialog` (default) wraps content in Radix\n * Dialog/Portal/Overlay with an auto X-close. `inline` renders just the\n * content surface in normal flow — no portal, no overlay, no auto X-close —\n * so consumers can stack multiple dialogs inside one shared scrim. Opt-in. */\nexport type ConfirmDialogMode = \"dialog\" | \"inline\"\n\nexport interface ConfirmDialogProps {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Called when open state changes. */\n onOpenChange?: (open: boolean) => void\n\n /** Optional trigger — wrapped in DialogTrigger. Omit for fully-controlled usage. */\n trigger?: React.ReactNode\n\n /** Dialog title — rendered in DialogTitle next to the severity icon. */\n title: React.ReactNode\n /** Short body above the action row. Used as DialogDescription. */\n description?: React.ReactNode\n /** Richer body slot — overrides description when provided. */\n children?: React.ReactNode\n\n /** Severity — drives icon color, confirm button variant. Default \"warning\". */\n severity?: ConfirmDialogSeverity\n\n /** Custom severity icon — overrides the severity default. Opt-in; omit to\n * use the built-in icon for the active severity. Sizing/color is handled by\n * the icon container, so pass a bare Phosphor icon (no explicit size). */\n icon?: React.ReactNode\n\n /** Severity-icon treatment. Leave unset for the canonical default (a tinted\n * circular plate stacked above the title). Set \"plated\" for the blessed\n * color-mix plate, \"inline\" for a small leading icon next to the title, or\n * \"none\" for no icon at all. Default rendering (unset) is unchanged. */\n iconTreatment?: ConfirmDialogIconTreatment\n\n /** Rendering mode. \"dialog\" (default) uses Radix Dialog + Portal + Overlay +\n * auto X-close. \"inline\" renders only the content surface (no portal, no\n * overlay, no X-close) so multiple dialogs can stack in one shared scrim.\n * Opt-in — default rendering is unchanged. */\n mode?: ConfirmDialogMode\n\n /** Element the dialog portals into instead of `<body>` — passed straight to\n * Dialog's `container`. Use it to render inside the host app's theme root.\n * Dialog mode only. */\n container?: HTMLElement | null\n\n /** Render the X close button. Default `true`. Escape and the focus trap are\n * kept either way. Dialog mode only (inline mode never has one). */\n showCloseButton?: boolean\n\n /** Called when focus moves out of the dialog on close — passed straight to\n * DialogContent. Call `event.preventDefault()` and focus your own target to\n * choose where focus lands. Dialog mode only. */\n onCloseAutoFocus?: (event: Event) => void\n\n /** Confirm button label. Defaults: \"Delete\" for danger, \"Confirm\" otherwise. */\n confirmLabel?: React.ReactNode\n /** Cancel button label. Default \"Cancel\". */\n cancelLabel?: React.ReactNode\n /** Cancel button variant. Default \"outline\". Golden screens use \"ghost\". */\n cancelVariant?: ButtonProps[\"variant\"]\n\n /** If set, user must type this exact string to enable the confirm button. */\n confirmText?: string\n /** Label for the confirm-text input. Default: `Type ${confirmText} to confirm`. */\n confirmTextLabel?: React.ReactNode\n\n /** Confirm handler. Async-aware: returning a Promise puts the dialog into pending state. */\n onConfirm?: () => void | Promise<void>\n /** Cancel handler. */\n onCancel?: () => void\n\n /** Externally-controlled busy state — overrides internal async pending detection. */\n busy?: boolean\n\n /** Additional className on DialogContent. */\n className?: string\n}\n\nfunction getSeverityIcon(severity: NormalizedSeverity): React.ReactNode {\n switch (severity) {\n case \"info\":\n return <InfoIcon weight=\"fill\" aria-hidden=\"true\" />\n case \"destructive\":\n return <WarningOctagonIcon weight=\"fill\" aria-hidden=\"true\" />\n case \"warning\":\n default:\n return <WarningIcon weight=\"fill\" aria-hidden=\"true\" />\n }\n}\n\n/** Canonical default plate tint (surface-*-subtle stacked plate). */\nfunction getSeverityPlateClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.plateInfo\n case \"destructive\":\n return styles.plateDestructive\n case \"warning\":\n default:\n return styles.plateWarning\n }\n}\n\n/** Inline severity icon color (small leading icon, no plate). */\nfunction getSeverityIconClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.iconInfo\n case \"destructive\":\n return styles.iconDanger\n case \"warning\":\n default:\n return styles.iconWarning\n }\n}\n\n/** Blessed plated tint (color-mix wash). */\nfunction getPlatedIconClass(severity: NormalizedSeverity): string {\n switch (severity) {\n case \"info\":\n return styles.iconPlatedInfo\n case \"destructive\":\n return styles.iconPlatedDanger\n case \"warning\":\n default:\n return styles.iconPlatedWarning\n }\n}\n\nfunction getConfirmButtonVariant(\n severity: NormalizedSeverity\n): \"default\" | \"destructive\" {\n return severity === \"destructive\" ? \"destructive\" : \"default\"\n}\n\nfunction getDefaultConfirmLabel(severity: NormalizedSeverity): string {\n return severity === \"destructive\" ? \"Delete\" : \"Confirm\"\n}\n\nconst ConfirmDialog = React.forwardRef<\n React.ComponentRef<typeof DialogContent>,\n ConfirmDialogProps\n>(\n (\n {\n open: openProp,\n defaultOpen,\n onOpenChange,\n trigger,\n title,\n description,\n children,\n severity = \"warning\",\n icon,\n iconTreatment,\n mode = \"dialog\",\n container,\n showCloseButton = true,\n onCloseAutoFocus,\n confirmLabel,\n cancelLabel = \"Cancel\",\n cancelVariant = \"outline\",\n confirmText,\n confirmTextLabel,\n onConfirm,\n onCancel,\n busy,\n className,\n },\n ref\n ) => {\n const isControlled = openProp !== undefined\n const [internalOpen, setInternalOpen] = React.useState<boolean>(\n defaultOpen ?? false\n )\n const actualOpen = isControlled ? (openProp as boolean) : internalOpen\n\n const [isPending, setIsPending] = React.useState<boolean>(false)\n const [typed, setTyped] = React.useState<string>(\"\")\n\n const cancelButtonRef = React.useRef<HTMLButtonElement | null>(null)\n\n const normalizedSeverity = normalizeSeverity(severity)\n\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setInternalOpen(next)\n }\n onOpenChange?.(next)\n if (!next) {\n // Clear gate typing on close\n setTyped(\"\")\n }\n },\n [isControlled, onOpenChange]\n )\n\n const resolvedConfirmLabel =\n confirmLabel ?? getDefaultConfirmLabel(normalizedSeverity)\n const effectiveBusy = busy ?? isPending\n const gateSatisfied =\n confirmText == null || confirmText.length === 0 || typed === confirmText\n const confirmDisabled = effectiveBusy || !gateSatisfied\n const cancelDisabled = effectiveBusy\n\n const handleConfirmClick = React.useCallback(async () => {\n if (!onConfirm) {\n handleOpenChange(false)\n return\n }\n // Any synchronous throw propagates naturally to React's error boundary.\n const result = onConfirm()\n if (result && typeof (result as Promise<void>).then === \"function\") {\n setIsPending(true)\n try {\n await result\n setIsPending(false)\n handleOpenChange(false)\n } catch (err) {\n // Async rejection — clear pending state, keep dialog open, re-throw\n // so the consumer's error handling (error boundary, onUnhandledRejection)\n // can react to it.\n setIsPending(false)\n throw err\n }\n } else {\n handleOpenChange(false)\n }\n }, [onConfirm, handleOpenChange])\n\n const handleCancelClick = React.useCallback(() => {\n onCancel?.()\n handleOpenChange(false)\n }, [onCancel, handleOpenChange])\n\n const handleOpenAutoFocus = React.useCallback(\n (event: Event) => {\n if (normalizedSeverity === \"destructive\" && cancelButtonRef.current) {\n event.preventDefault()\n cancelButtonRef.current.focus()\n }\n },\n [normalizedSeverity]\n )\n\n const severityIcon = icon ?? getSeverityIcon(normalizedSeverity)\n const confirmVariant = getConfirmButtonVariant(normalizedSeverity)\n const isInline = mode === \"inline\"\n\n // Treatment resolution:\n // - unset → canonical default: tinted plate stacked above title\n // (data-slot=\"confirm-dialog-icon-plate\"). Unchanged.\n // - \"plated\" → blessed plated: 40px color-mix plate leading the\n // title column (data-slot=\"confirm-dialog-icon\").\n // - \"inline\" → blessed inline: small leading icon (no plate).\n // - \"none\" → no icon element; title row holds the title alone.\n const isCanonicalPlate = iconTreatment === undefined\n const isBlessedPlated = iconTreatment === \"plated\"\n\n // Generate stable id for confirm gate input\n const generatedId = React.useId()\n const confirmGateInputId = `${generatedId}-confirm-input`\n\n const hasDescriptionForAria =\n description != null && description !== false && !children\n\n // Canonical default plate — a span carrying the tinted circle, stacked\n // above the title inside .headerStack. Preserved verbatim for backward\n // compatibility (existing consumers + tests query this slot/classes).\n const canonicalPlate = (\n <span\n data-slot=\"confirm-dialog-icon-plate\"\n aria-hidden=\"true\"\n className={cn(styles.iconPlate, getSeverityPlateClass(normalizedSeverity))}\n >\n {severityIcon}\n </span>\n )\n\n // Blessed icon span — used for explicit \"plated\"/\"inline\" treatments.\n const blessedIconClass = isBlessedPlated\n ? cn(styles.iconPlated, getPlatedIconClass(normalizedSeverity))\n : cn(styles.icon, getSeverityIconClass(normalizedSeverity))\n const blessedIconSpan = (\n <span\n data-slot=\"confirm-dialog-icon\"\n aria-hidden=\"true\"\n className={blessedIconClass}\n >\n {severityIcon}\n </span>\n )\n\n // Header layout class per treatment.\n // - canonical default → .headerStack (column: plate above title/description)\n // - blessed plated → .titleRowPlated (column: plate above title)\n // - blessed inline → .titleRow (row: icon next to title)\n const headerLayoutClass = isCanonicalPlate\n ? styles.headerStack\n : isBlessedPlated\n ? styles.titleRowPlated\n : styles.titleRow\n\n const iconElement = isCanonicalPlate\n ? canonicalPlate\n : iconTreatment === \"none\"\n ? null\n : blessedIconSpan\n\n // Dialog-mode header — uses Radix Title/Description (a11y + aria-labelledby).\n // Canonical plate stacks plate + title + description inside one .headerStack;\n // blessed treatments keep description outside the title row.\n const dialogHeader = isCanonicalPlate ? (\n <DialogHeader>\n <div className={headerLayoutClass}>\n {iconElement}\n <DialogTitle>{title}</DialogTitle>\n {hasDescriptionForAria ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </div>\n </DialogHeader>\n ) : (\n <DialogHeader>\n <div className={headerLayoutClass}>\n {iconElement}\n <DialogTitle>{title}</DialogTitle>\n </div>\n {hasDescriptionForAria ? (\n <DialogDescription>{description}</DialogDescription>\n ) : null}\n </DialogHeader>\n )\n\n // Inline-mode header — no Dialog context, so render a plain heading/paragraph.\n const inlineHeaderEl = (\n <div className={styles.inlineHeader}>\n <div className={headerLayoutClass}>\n {iconElement}\n <h2 className={styles.inlineTitle}>{title}</h2>\n </div>\n {hasDescriptionForAria ? (\n <p className={styles.inlineDescription}>{description}</p>\n ) : null}\n </div>\n )\n\n const header = isInline ? inlineHeaderEl : dialogHeader\n\n const innerContent = (\n <>\n {header}\n\n {children ? (\n <div data-slot=\"confirm-dialog-body\" className={styles.body}>\n {children}\n </div>\n ) : null}\n\n {confirmText ? (\n <div className={styles.confirmGate}>\n <label\n htmlFor={confirmGateInputId}\n className={styles.confirmGateLabel}\n >\n {confirmTextLabel ?? `Type ${confirmText} to confirm`}\n </label>\n <input\n id={confirmGateInputId}\n type=\"text\"\n autoComplete=\"off\"\n spellCheck={false}\n value={typed}\n onChange={(e) => setTyped(e.target.value)}\n disabled={effectiveBusy}\n className={styles.confirmGateInput}\n data-slot=\"confirm-dialog-gate-input\"\n />\n </div>\n ) : null}\n\n <div\n data-slot=\"confirm-dialog-actions\"\n className={styles.actions}\n role=\"group\"\n >\n <div className={styles.action}>\n <Button\n ref={cancelButtonRef}\n type=\"button\"\n variant={cancelVariant}\n onClick={handleCancelClick}\n disabled={cancelDisabled}\n data-slot=\"confirm-dialog-cancel\"\n >\n {cancelLabel}\n </Button>\n </div>\n <div className={styles.action}>\n <Button\n type=\"button\"\n variant={confirmVariant}\n onClick={handleConfirmClick}\n disabled={confirmDisabled}\n aria-busy={effectiveBusy || undefined}\n data-slot=\"confirm-dialog-confirm\"\n >\n {resolvedConfirmLabel}\n </Button>\n </div>\n </div>\n </>\n )\n\n // Inline (non-portal) mode — render only the content surface. No Radix\n // Dialog/Portal/Overlay/X-close, so consumers can stack multiple dialogs\n // inside one shared scrim. Open/close is consumer-driven; respect `open`.\n if (isInline) {\n if (!actualOpen) {\n return null\n }\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement>}\n role=\"alertdialog\"\n aria-modal={false}\n data-slot=\"confirm-dialog\"\n data-mode=\"inline\"\n data-severity={normalizedSeverity}\n className={cn(styles.root, styles.inlineSurface, className)}\n >\n {innerContent}\n </div>\n )\n }\n\n return (\n <Dialog\n open={actualOpen}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n container={container}\n >\n {trigger ? <DialogTrigger asChild>{trigger}</DialogTrigger> : null}\n <DialogContent\n ref={ref}\n data-slot=\"confirm-dialog\"\n data-severity={normalizedSeverity}\n className={cn(styles.root, className)}\n onOpenAutoFocus={handleOpenAutoFocus}\n onCloseAutoFocus={onCloseAutoFocus}\n showCloseButton={showCloseButton}\n >\n {innerContent}\n </DialogContent>\n </Dialog>\n )\n }\n)\nConfirmDialog.displayName = \"ConfirmDialog\"\n\nexport { ConfirmDialog }\n"
2719
2719
  },
2720
2720
  {
2721
2721
  "path": "components/ui/confirm-dialog/confirm-dialog.module.css",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "0.4.0",
3
- "generated_at": "2026-10-17T22:26:39.303Z",
3
+ "generated_at": "2026-10-27T04:04:23.576Z",
4
4
  "components": {
5
5
  "accessibility-specimen": {
6
6
  "category": "specimen",
@@ -2915,7 +2915,8 @@
2915
2915
  ],
2916
2916
  "iconTreatment": [
2917
2917
  "inline",
2918
- "plated"
2918
+ "plated",
2919
+ "none"
2919
2920
  ],
2920
2921
  "mode": [
2921
2922
  "dialog",
@@ -2952,8 +2953,8 @@
2952
2953
  },
2953
2954
  {
2954
2955
  "name": "iconTreatment",
2955
- "type": "'inline' | 'plated'",
2956
- "description": "Severity-icon treatment. Leave unset for the canonical default — a tinted circular plate stacked above the title. Set \"plated\" for a 40px color-mix severity plate leading the title column, or \"inline\" for a small leading icon next to the title. Default rendering (unset) is unchanged.\n"
2956
+ "type": "'inline' | 'plated' | 'none'",
2957
+ "description": "Severity-icon treatment. Leave unset for the canonical default — a tinted circular plate stacked above the title. Set \"plated\" for a 40px color-mix severity plate leading the title column, or \"inline\" for a small leading icon next to the title, or \"none\" for no icon and no icon container. Default rendering (unset) is unchanged.\n"
2957
2958
  },
2958
2959
  {
2959
2960
  "name": "mode",
@@ -2961,6 +2962,22 @@
2961
2962
  "default": "dialog",
2962
2963
  "description": "Rendering mode. \"dialog\" uses Radix Dialog + Portal + Overlay + auto X-close. \"inline\" renders only the content surface (no portal, no overlay, no X-close) so multiple dialogs can stack inside one shared scrim.\n"
2963
2964
  },
2965
+ {
2966
+ "name": "container",
2967
+ "type": "HTMLElement | null",
2968
+ "description": "Element the dialog portals into instead of document.body, passed straight to Dialog's container. Use it to render inside the host app's theme root. Dialog mode only.\n"
2969
+ },
2970
+ {
2971
+ "name": "showCloseButton",
2972
+ "type": "boolean",
2973
+ "default": "true",
2974
+ "description": "Render the X close button. Escape and the focus trap are kept when it is hidden. Dialog mode only.\n"
2975
+ },
2976
+ {
2977
+ "name": "onCloseAutoFocus",
2978
+ "type": "(event: Event) => void",
2979
+ "description": "Called when focus leaves the dialog on close, passed straight to DialogContent. Call event.preventDefault() and focus your own target to choose where focus lands. Dialog mode only.\n"
2980
+ },
2964
2981
  {
2965
2982
  "name": "cancelVariant",
2966
2983
  "type": "ButtonProps[\"variant\"]",
@@ -3733,6 +3750,12 @@
3733
3750
  "default": false,
3734
3751
  "description": "Show a drag handle on the sheet presentation; dragging down dismisses (DialogContent)"
3735
3752
  },
3753
+ {
3754
+ "name": "showCloseButton",
3755
+ "type": "boolean",
3756
+ "default": "true",
3757
+ "description": "Render the X close button (DialogContent). Hide it only when the content has its own dismiss action; Escape still closes. Drag-to-dismiss needs it."
3758
+ },
3736
3759
  {
3737
3760
  "name": "back",
3738
3761
  "type": "React.ReactNode",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loworbitstudio/visor",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "description": "CLI for the Visor design system — add components, hooks, and utilities to your project.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@aws-sdk/client-s3": "^3.1021.0",
48
48
  "@babel/parser": "^7.26.0",
49
- "@loworbitstudio/visor-theme-engine": "^0.31.0",
49
+ "@loworbitstudio/visor-theme-engine": "^0.31.1",
50
50
  "commander": "^13.1.0",
51
51
  "diff": "^8.0.4",
52
52
  "picocolors": "^1.1.1",