import React, { useState } from 'react'; import en_GB from '../../locale/source/en_GB'; import { Select, Modal, Button, Tooltip, Popover, ConfigProvider, Tag, Space } from '../../index'; import CollapsibleInModal from './CollapsibleInModal'; import DynamicContextDemo from './DynamicContext'; export default { title: 'Modal', parameters: { chromatic: { disableSnapshot: true }, }, } export { CollapsibleInModal, DynamicContextDemo } const Option = Select.Option; const DialogComponent = props => { const [visible, setVisible] = useState(false); const handleOk = e => { setVisible(false); }; const handleCancel = e => { setVisible(false); }; return (

basic modal

); }; export const Default = () => ; Default.story = { name: 'default', }; export const ClickMaskClosableFalse = () => ; ClickMaskClosableFalse.story = { name: 'click mask closable false', }; function useLoading() { const [loading, setLoading] = useState(false); function startQuery() { setLoading(true); } return [loading, { startQuery }]; } function DialogComponentWithLoading() { const [loading, actions] = useLoading(); return ; } export const WithLoadingTodo = () => ; WithLoadingTodo.story = { name: 'with loading todo', }; function success() { Modal.success('bla bla bla...'); } function info() { Modal.info('info'); } function error() { Modal.error({ title: 'Unfortunately, there is an error', content: 'bla bla bla...' }); } function warning() { Modal.warning({ title: 'Warning: be cautious ahead', content: 'bla bla bla...' }); } function confirm() { Modal.confirm({ title: 'Are you sure ?', content: 'bla bla bla...' }); } export const ConfirmModal = () => (
); ConfirmModal.story = { name: 'confirm modal', }; const Test = () => { let modal; const showModal = () => { modal = Modal.info({ title: '修改的标题', content: ( <> ), }); }; return ; }; export const ModalDestroy = () => ; ModalDestroy.story = { name: 'modal.destroy', }; const ScrollComponent = props => { const [visible, setVisible] = useState(true); const handleOk = e => { setVisible(false); }; const handleCancel = e => { setVisible(false); }; return (
test tooltip in modal
); }; export const Scroll = () => ; Scroll.story = { name: 'scroll', }; const Popup = () => { const [visible, setVisible] = useState(false); const getContainer = () => { return document.querySelector('.modal-container'); }; return (
Render in this

setVisible(false)} width={200} // centered // style={{ top: '10px' }} getPopupContainer={getContainer} >

This is the content of a basic sidesheet.

Here is more content...

); }; export const RenderInCustomContainer = () => ; RenderInCustomContainer.story = { name: 'render in custom container', }; export const KeepDom = () => ; KeepDom.story = { name: 'keepDOM', }; export const KeepDomNotLazy = () => ; KeepDomNotLazy.story = { name: 'keepDOM && not lazy', }; export const UseModalDemo = () => { const [modal, contextHolder] = Modal.useModal(); const config = { 'title': 'old title', 'content': 'old content' }; return (
{contextHolder}
); }; UseModalDemo.storyName = "useModal"; export const UseModalDestroy = () => { const [modal, contextHolder] = Modal.useModal(); const config = { 'title': 'old title', 'content': 'old content' }; return (
{contextHolder}
); }; UseModalDestroy.storyName = "useModal destroy"; export const UseModalAfterClose = () => { const [modal, contextHolder] = Modal.useModal(); const [closed, setClosed] = React.useState(false); const [leave, setLeave] = React.useState(false); const config = { title: 'old title', content: 'old content', afterClose: () => { setClosed(true); }, motion: { didLeave: () => { console.log('didLeave'); setLeave(true); } } }; return ( {`closed: ${closed}`} {/* {`motion leave: ${leave}`} */} {contextHolder} ); }; UseModalAfterClose.storyName = "useModal afterClose";