This commit is contained in:
duanfuxiang
2025-01-05 11:51:39 +08:00
commit 0c7ee142cb
215 changed files with 20611 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import React, { createContext, useContext } from 'react'
const DialogContext = createContext<HTMLElement | null>(null)
export function DialogProvider({
children,
container,
}: {
children: React.ReactNode
container: HTMLElement | null
}) {
return (
<DialogContext.Provider value={container}>
{children}
</DialogContext.Provider>
)
}
export function useDialogContainer() {
const context = useContext(DialogContext)
if (!context) {
throw new Error(
'useDialogContainer must be used within a DialogContainerProvider',
)
}
return context
}