2026-02-09 14:43:35 +08:00
"use client" ;
2026-02-12 15:09:52 +08:00
import {
Presence
} from "./chunk-NOU7F7EJ.js" ;
2026-02-09 14:43:35 +08:00
import {
Combination _default ,
DismissableLayer ,
FocusScope ,
Portal ,
hideOthers ,
useFocusGuards
2026-02-11 15:06:59 +08:00
} from "./chunk-TQPPICSF.js" ;
2026-02-09 14:43:35 +08:00
import {
useId
2026-02-11 15:06:59 +08:00
} from "./chunk-LAKFU2YZ.js" ;
2026-02-09 14:43:35 +08:00
import {
Primitive ,
composeEventHandlers ,
createContext2 ,
createContextScope ,
createSlot ,
useControllableState
2026-02-11 15:06:59 +08:00
} from "./chunk-6PGXP53J.js" ;
import "./chunk-4GC24YIX.js" ;
2026-02-09 14:43:35 +08:00
import {
useComposedRefs
2026-02-11 15:06:59 +08:00
} from "./chunk-H5WV2N77.js" ;
2026-02-09 14:43:35 +08:00
import {
require _jsx _runtime
2026-02-11 15:06:59 +08:00
} from "./chunk-GVNB4JNI.js" ;
2026-02-09 14:43:35 +08:00
import {
require _react
2026-02-11 15:06:59 +08:00
} from "./chunk-ZPOJ4WAM.js" ;
2026-02-09 14:43:35 +08:00
import {
_ _toESM
} from "./chunk-G3PMV62Z.js" ;
// node_modules/.pnpm/@radix-ui+react-dialog@1.1._9cd126aa2880bf880e57e64087c058d6/node_modules/@radix-ui/react-dialog/dist/index.mjs
var React = _ _toESM ( require _react ( ) , 1 ) ;
var import _jsx _runtime = _ _toESM ( require _jsx _runtime ( ) , 1 ) ;
var DIALOG _NAME = "Dialog" ;
var [ createDialogContext , createDialogScope ] = createContextScope ( DIALOG _NAME ) ;
var [ DialogProvider , useDialogContext ] = createDialogContext ( DIALOG _NAME ) ;
var Dialog = ( props ) => {
const {
_ _scopeDialog ,
children ,
open : openProp ,
defaultOpen ,
onOpenChange ,
modal = true
} = props ;
const triggerRef = React . useRef ( null ) ;
const contentRef = React . useRef ( null ) ;
const [ open , setOpen ] = useControllableState ( {
prop : openProp ,
defaultProp : defaultOpen ? ? false ,
onChange : onOpenChange ,
caller : DIALOG _NAME
} ) ;
return ( 0 , import _jsx _runtime . jsx ) (
DialogProvider ,
{
scope : _ _scopeDialog ,
triggerRef ,
contentRef ,
contentId : useId ( ) ,
titleId : useId ( ) ,
descriptionId : useId ( ) ,
open ,
onOpenChange : setOpen ,
onOpenToggle : React . useCallback ( ( ) => setOpen ( ( prevOpen ) => ! prevOpen ) , [ setOpen ] ) ,
modal ,
children
}
) ;
} ;
Dialog . displayName = DIALOG _NAME ;
var TRIGGER _NAME = "DialogTrigger" ;
var DialogTrigger = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , ... triggerProps } = props ;
const context = useDialogContext ( TRIGGER _NAME , _ _scopeDialog ) ;
const composedTriggerRef = useComposedRefs ( forwardedRef , context . triggerRef ) ;
return ( 0 , import _jsx _runtime . jsx ) (
Primitive . button ,
{
type : "button" ,
"aria-haspopup" : "dialog" ,
"aria-expanded" : context . open ,
"aria-controls" : context . contentId ,
"data-state" : getState ( context . open ) ,
... triggerProps ,
ref : composedTriggerRef ,
onClick : composeEventHandlers ( props . onClick , context . onOpenToggle )
}
) ;
}
) ;
DialogTrigger . displayName = TRIGGER _NAME ;
var PORTAL _NAME = "DialogPortal" ;
var [ PortalProvider , usePortalContext ] = createDialogContext ( PORTAL _NAME , {
forceMount : void 0
} ) ;
var DialogPortal = ( props ) => {
const { _ _scopeDialog , forceMount , children , container } = props ;
const context = useDialogContext ( PORTAL _NAME , _ _scopeDialog ) ;
return ( 0 , import _jsx _runtime . jsx ) ( PortalProvider , { scope : _ _scopeDialog , forceMount , children : React . Children . map ( children , ( child ) => ( 0 , import _jsx _runtime . jsx ) ( Presence , { present : forceMount || context . open , children : ( 0 , import _jsx _runtime . jsx ) ( Portal , { asChild : true , container , children : child } ) } ) ) } ) ;
} ;
DialogPortal . displayName = PORTAL _NAME ;
var OVERLAY _NAME = "DialogOverlay" ;
var DialogOverlay = React . forwardRef (
( props , forwardedRef ) => {
const portalContext = usePortalContext ( OVERLAY _NAME , props . _ _scopeDialog ) ;
const { forceMount = portalContext . forceMount , ... overlayProps } = props ;
const context = useDialogContext ( OVERLAY _NAME , props . _ _scopeDialog ) ;
return context . modal ? ( 0 , import _jsx _runtime . jsx ) ( Presence , { present : forceMount || context . open , children : ( 0 , import _jsx _runtime . jsx ) ( DialogOverlayImpl , { ... overlayProps , ref : forwardedRef } ) } ) : null ;
}
) ;
DialogOverlay . displayName = OVERLAY _NAME ;
var Slot = createSlot ( "DialogOverlay.RemoveScroll" ) ;
var DialogOverlayImpl = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , ... overlayProps } = props ;
const context = useDialogContext ( OVERLAY _NAME , _ _scopeDialog ) ;
return (
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
// ie. when `Overlay` and `Content` are siblings
( 0 , import _jsx _runtime . jsx ) ( Combination _default , { as : Slot , allowPinchZoom : true , shards : [ context . contentRef ] , children : ( 0 , import _jsx _runtime . jsx ) (
Primitive . div ,
{
"data-state" : getState ( context . open ) ,
... overlayProps ,
ref : forwardedRef ,
style : { pointerEvents : "auto" , ... overlayProps . style }
}
) } )
) ;
}
) ;
var CONTENT _NAME = "DialogContent" ;
var DialogContent = React . forwardRef (
( props , forwardedRef ) => {
const portalContext = usePortalContext ( CONTENT _NAME , props . _ _scopeDialog ) ;
const { forceMount = portalContext . forceMount , ... contentProps } = props ;
const context = useDialogContext ( CONTENT _NAME , props . _ _scopeDialog ) ;
return ( 0 , import _jsx _runtime . jsx ) ( Presence , { present : forceMount || context . open , children : context . modal ? ( 0 , import _jsx _runtime . jsx ) ( DialogContentModal , { ... contentProps , ref : forwardedRef } ) : ( 0 , import _jsx _runtime . jsx ) ( DialogContentNonModal , { ... contentProps , ref : forwardedRef } ) } ) ;
}
) ;
DialogContent . displayName = CONTENT _NAME ;
var DialogContentModal = React . forwardRef (
( props , forwardedRef ) => {
const context = useDialogContext ( CONTENT _NAME , props . _ _scopeDialog ) ;
const contentRef = React . useRef ( null ) ;
const composedRefs = useComposedRefs ( forwardedRef , context . contentRef , contentRef ) ;
React . useEffect ( ( ) => {
const content = contentRef . current ;
if ( content ) return hideOthers ( content ) ;
} , [ ] ) ;
return ( 0 , import _jsx _runtime . jsx ) (
DialogContentImpl ,
{
... props ,
ref : composedRefs ,
trapFocus : context . open ,
disableOutsidePointerEvents : true ,
onCloseAutoFocus : composeEventHandlers ( props . onCloseAutoFocus , ( event ) => {
var _a ;
event . preventDefault ( ) ;
( _a = context . triggerRef . current ) == null ? void 0 : _a . focus ( ) ;
} ) ,
onPointerDownOutside : composeEventHandlers ( props . onPointerDownOutside , ( event ) => {
const originalEvent = event . detail . originalEvent ;
const ctrlLeftClick = originalEvent . button === 0 && originalEvent . ctrlKey === true ;
const isRightClick = originalEvent . button === 2 || ctrlLeftClick ;
if ( isRightClick ) event . preventDefault ( ) ;
} ) ,
onFocusOutside : composeEventHandlers (
props . onFocusOutside ,
( event ) => event . preventDefault ( )
)
}
) ;
}
) ;
var DialogContentNonModal = React . forwardRef (
( props , forwardedRef ) => {
const context = useDialogContext ( CONTENT _NAME , props . _ _scopeDialog ) ;
const hasInteractedOutsideRef = React . useRef ( false ) ;
const hasPointerDownOutsideRef = React . useRef ( false ) ;
return ( 0 , import _jsx _runtime . jsx ) (
DialogContentImpl ,
{
... props ,
ref : forwardedRef ,
trapFocus : false ,
disableOutsidePointerEvents : false ,
onCloseAutoFocus : ( event ) => {
var _a , _b ;
( _a = props . onCloseAutoFocus ) == null ? void 0 : _a . call ( props , event ) ;
if ( ! event . defaultPrevented ) {
if ( ! hasInteractedOutsideRef . current ) ( _b = context . triggerRef . current ) == null ? void 0 : _b . focus ( ) ;
event . preventDefault ( ) ;
}
hasInteractedOutsideRef . current = false ;
hasPointerDownOutsideRef . current = false ;
} ,
onInteractOutside : ( event ) => {
var _a , _b ;
( _a = props . onInteractOutside ) == null ? void 0 : _a . call ( props , event ) ;
if ( ! event . defaultPrevented ) {
hasInteractedOutsideRef . current = true ;
if ( event . detail . originalEvent . type === "pointerdown" ) {
hasPointerDownOutsideRef . current = true ;
}
}
const target = event . target ;
const targetIsTrigger = ( _b = context . triggerRef . current ) == null ? void 0 : _b . contains ( target ) ;
if ( targetIsTrigger ) event . preventDefault ( ) ;
if ( event . detail . originalEvent . type === "focusin" && hasPointerDownOutsideRef . current ) {
event . preventDefault ( ) ;
}
}
}
) ;
}
) ;
var DialogContentImpl = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , trapFocus , onOpenAutoFocus , onCloseAutoFocus , ... contentProps } = props ;
const context = useDialogContext ( CONTENT _NAME , _ _scopeDialog ) ;
const contentRef = React . useRef ( null ) ;
const composedRefs = useComposedRefs ( forwardedRef , contentRef ) ;
useFocusGuards ( ) ;
return ( 0 , import _jsx _runtime . jsxs ) ( import _jsx _runtime . Fragment , { children : [
( 0 , import _jsx _runtime . jsx ) (
FocusScope ,
{
asChild : true ,
loop : true ,
trapped : trapFocus ,
onMountAutoFocus : onOpenAutoFocus ,
onUnmountAutoFocus : onCloseAutoFocus ,
children : ( 0 , import _jsx _runtime . jsx ) (
DismissableLayer ,
{
role : "dialog" ,
id : context . contentId ,
"aria-describedby" : context . descriptionId ,
"aria-labelledby" : context . titleId ,
"data-state" : getState ( context . open ) ,
... contentProps ,
ref : composedRefs ,
onDismiss : ( ) => context . onOpenChange ( false )
}
)
}
) ,
( 0 , import _jsx _runtime . jsxs ) ( import _jsx _runtime . Fragment , { children : [
( 0 , import _jsx _runtime . jsx ) ( TitleWarning , { titleId : context . titleId } ) ,
( 0 , import _jsx _runtime . jsx ) ( DescriptionWarning , { contentRef , descriptionId : context . descriptionId } )
] } )
] } ) ;
}
) ;
var TITLE _NAME = "DialogTitle" ;
var DialogTitle = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , ... titleProps } = props ;
const context = useDialogContext ( TITLE _NAME , _ _scopeDialog ) ;
return ( 0 , import _jsx _runtime . jsx ) ( Primitive . h2 , { id : context . titleId , ... titleProps , ref : forwardedRef } ) ;
}
) ;
DialogTitle . displayName = TITLE _NAME ;
var DESCRIPTION _NAME = "DialogDescription" ;
var DialogDescription = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , ... descriptionProps } = props ;
const context = useDialogContext ( DESCRIPTION _NAME , _ _scopeDialog ) ;
return ( 0 , import _jsx _runtime . jsx ) ( Primitive . p , { id : context . descriptionId , ... descriptionProps , ref : forwardedRef } ) ;
}
) ;
DialogDescription . displayName = DESCRIPTION _NAME ;
var CLOSE _NAME = "DialogClose" ;
var DialogClose = React . forwardRef (
( props , forwardedRef ) => {
const { _ _scopeDialog , ... closeProps } = props ;
const context = useDialogContext ( CLOSE _NAME , _ _scopeDialog ) ;
return ( 0 , import _jsx _runtime . jsx ) (
Primitive . button ,
{
type : "button" ,
... closeProps ,
ref : forwardedRef ,
onClick : composeEventHandlers ( props . onClick , ( ) => context . onOpenChange ( false ) )
}
) ;
}
) ;
DialogClose . displayName = CLOSE _NAME ;
function getState ( open ) {
return open ? "open" : "closed" ;
}
var TITLE _WARNING _NAME = "DialogTitleWarning" ;
var [ WarningProvider , useWarningContext ] = createContext2 ( TITLE _WARNING _NAME , {
contentName : CONTENT _NAME ,
titleName : TITLE _NAME ,
docsSlug : "dialog"
} ) ;
var TitleWarning = ( { titleId } ) => {
const titleWarningContext = useWarningContext ( TITLE _WARNING _NAME ) ;
const MESSAGE = ` \` ${ titleWarningContext . contentName } \` requires a \` ${ titleWarningContext . titleName } \` for the component to be accessible for screen reader users.
If you want to hide the \ ` ${ titleWarningContext . titleName } \` , you can wrap it with our VisuallyHidden component.
For more information , see https : //radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
React . useEffect ( ( ) => {
if ( titleId ) {
const hasTitle = document . getElementById ( titleId ) ;
if ( ! hasTitle ) console . error ( MESSAGE ) ;
}
} , [ MESSAGE , titleId ] ) ;
return null ;
} ;
var DESCRIPTION _WARNING _NAME = "DialogDescriptionWarning" ;
var DescriptionWarning = ( { contentRef , descriptionId } ) => {
const descriptionWarningContext = useWarningContext ( DESCRIPTION _WARNING _NAME ) ;
const MESSAGE = ` Warning: Missing \` Description \` or \` aria-describedby={undefined} \` for { ${ descriptionWarningContext . contentName } }. ` ;
React . useEffect ( ( ) => {
var _a ;
const describedById = ( _a = contentRef . current ) == null ? void 0 : _a . getAttribute ( "aria-describedby" ) ;
if ( descriptionId && describedById ) {
const hasDescription = document . getElementById ( descriptionId ) ;
if ( ! hasDescription ) console . warn ( MESSAGE ) ;
}
} , [ MESSAGE , contentRef , descriptionId ] ) ;
return null ;
} ;
var Root = Dialog ;
var Trigger = DialogTrigger ;
var Portal2 = DialogPortal ;
var Overlay = DialogOverlay ;
var Content = DialogContent ;
var Title = DialogTitle ;
var Description = DialogDescription ;
var Close = DialogClose ;
export {
Close ,
Content ,
Description ,
Dialog ,
DialogClose ,
DialogContent ,
DialogDescription ,
DialogOverlay ,
DialogPortal ,
DialogTitle ,
DialogTrigger ,
Overlay ,
Portal2 as Portal ,
Root ,
Title ,
Trigger ,
WarningProvider ,
createDialogScope
} ;
//# sourceMappingURL=@radix-ui_react-dialog.js.map