// Copyright 2017-2020 @polkadot/react-components authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { BareProps } from './types'; import React from 'react'; import SUIModal from 'semantic-ui-react/dist/commonjs/modules/Modal/Modal'; import Button from './Button'; import ButtonCancel from './ButtonCancel'; import { classes } from './util'; interface ModalProps extends BareProps { children: React.ReactNode; header?: React.ReactNode; open?: boolean; [index: string]: any; } interface ActionsProps extends BareProps { cancelLabel?: string; children: React.ReactNode; withOr?: boolean; onCancel: () => void; } type ModalType = React.FC & { Actions: React.FC; Content: typeof SUIModal.Content; Header: typeof SUIModal.Header; Description: typeof SUIModal.Description; }; function ModalBase (props: ModalProps): React.ReactElement { const { className, children, header, open = true } = props; return ( {header && ( {header} )} {children} ); } function Actions ({ cancelLabel, className, children, withOr = true, onCancel }: ActionsProps): React.ReactElement { return ( {withOr && } {children} ); } const Modal = React.memo(ModalBase) as unknown as ModalType; Modal.Actions = React.memo(Actions); Modal.Content = SUIModal.Content; Modal.Header = SUIModal.Header; Modal.Description = SUIModal.Description; export default Modal;