import React, { FC, useState } from 'react' import { DialogProps, DialogStatic } from './types' import { getLocale } from '@gm-pc/locales' import _ from 'lodash' import { Modal } from '../modal' import { Button } from '../button' import { Flex } from '../flex' import EVENT_TYPE from '../../event_type' import { LayoutRoot } from '../layout_root' const Dialog: FC & DialogStatic = ({ title = getLocale('提示'), size = 'sm', buttons, onHide = () => Dialog.hide(), children, }) => { const [loading, setLoading] = useState(false) return (
{children}
{buttons && ( {_.map(buttons, (btn) => { const isPrimary = btn.btnType === 'primary' || btn.btnType === 'danger' return ( ) })} )}
) } Dialog.render = function (props: DialogProps): void { window.dispatchEvent(new window.CustomEvent(EVENT_TYPE.MODAL_SHOW)) LayoutRoot.setComponent(LayoutRoot.Type.MODAL, ) } Dialog.hide = function (): void { window.dispatchEvent(new window.CustomEvent(EVENT_TYPE.MODAL_HIDE)) LayoutRoot.removeComponent(LayoutRoot.Type.MODAL) } // input key down export default Dialog