jsx import { jsx } from "@emotion/react" ; import React from "react" ; import { showDialog } from "../Dialog" ; import { AlertWrapper , AlertWrapperProps } from "./Wrapper" ; import isPlainObject from "lodash/isPlainObject" ; import omit from "lodash/omit" ; export interface ShowAlertOption extends AlertWrapperProps { showMask ? : boolean ; } param option export function showAlert ( option ) { let config ; if ( React . isValidElement ( option ) || ! isPlainObject ( option ) ) { config = { title : option , } ; } else { config = option as ShowAlertOption ; } const props = omit ( config , [ "showMask" ] ) ; props . onCancel = async ( ) => { await closeDialog ( ) ; config . onCancel ?. ( ) ; } ; props . onConfirm = async ( ) => { await closeDialog ( ) ; config . onConfirm ?. ( ) ; } ; const closeDialog = showDialog ( { showMask : typeof config . showMask === "undefined" ? true : ! ! config . showMask , content : < AlertWrapper { ... props } / > , } ) ; return closeDialog ; }