import { calc } from 'antd/es/theme/internal'; import { DialogModal, Modal, modalStore } from '@kevisual/ui'; import { useEffect, useRef } from 'react'; import '@kevisual/ui/src/index.css'; import { createDOMElement } from './create-dom'; // import '@kevisual/ui/src/components/modal/index.css'; export const App = () => { const showModel = () => { // }; return (
Model
); }; const ModelOne = () => { const ref = useRef(null); const showModel = () => { const model = Modal.render(ref.current!, {}); }; return (
model one
show
当前元素是Model的渲染内容
); }; const ModelTwo = () => { const ref = useRef(null); const showModel = () => { const model = DialogModal.render(ref.current!, { dialogTitle: 'Dialog Modal', width: '400px', dialogTitleCloseIcon: true, contentStyle: { // maxHeight: '100px', // overflow: 'auto', }, }); }; return (
model two
show
当前元素是Modal Dialog 的渲染内容
内容
内容2
内容3
内容4
); }; const ModelTwo2 = () => { const ref = useRef(null); const showModel = () => { const div = createDOMElement(refHide); const model = DialogModal.render(ref.current! || div, { dialogTitle: 'Dialog Modal', width: '400px', dialogTitleCloseIcon: true, contentStyle: { // maxHeight: '100px', // overflow: 'auto', }, }); }; const refHide = (
当前元素是Modal Dialog 的渲染内容
内容
内容2
内容3
内容4
); return (
model two -假入ref的模块没有真实渲染到节点,如何处理。createDOMElement
show
{refHide}
); }; const ModelThree = () => { const ref = useRef(null); let dialog = useRef(null); const showModel = () => { const model = DialogModal.render(ref.current!, { dialogTitle: 'Dialog Modal', width: '400px', dialogTitleCloseIcon: true, open: false, contentStyle: { // maxHeight: '100px', // overflow: 'auto', }, }); const modals = modalStore.getState().modals; console.log('modals', modals.length, model); dialog.current = model; }; return (
model 3
show
当前元素是Modal Dialog 的渲染内容
内容
内容2
内容3
内容4
{ if (dialog.current) { dialog.current.setOpen(true); } console.log('open', dialog.current); }}> 真打开
); }; const Model4 = () => { const ref = useRef(null); let dialog = useRef(null); const showModel = () => { const model = DialogModal.create({ dialogTitle: 'Dialog Modal', width: '400px', dialogTitleCloseIcon: true, open: false, contentStyle: { // maxHeight: '100px', // overflow: 'auto', }, }); const modals = modalStore.getState().modals; console.log('modals', modals.length, model); dialog.current = model; }; return (
model 4
show
当前元素是Modal Dialog 的渲染内容
内容
内容2
内容3
内容4
{ if (dialog.current) { dialog.current.setOpen(true); } console.log('open', dialog.current); }}> 真打开
); };