@loworbitstudio/visor 1.40.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-26T20:00:31.074Z",
3
+ "generated_at": "2026-10-27T04:04:23.584Z",
4
4
  "components": {
5
5
  "accessibility-specimen": {
6
6
  "changeType": "current",
@@ -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).\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 /** 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 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 showCloseButton={showCloseButton}\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-26T20:00:31.066Z",
3
+ "generated_at": "2026-10-27T04:04:23.576Z",
4
4
  "components": {
5
5
  "accessibility-specimen": {
6
6
  "category": "specimen",
@@ -2973,6 +2973,11 @@
2973
2973
  "default": "true",
2974
2974
  "description": "Render the X close button. Escape and the focus trap are kept when it is hidden. Dialog mode only.\n"
2975
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
+ },
2976
2981
  {
2977
2982
  "name": "cancelVariant",
2978
2983
  "type": "ButtonProps[\"variant\"]",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loworbitstudio/visor",
3
- "version": "1.40.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": {