import { message, Col, Modal, Row } from 'antd'; import React, { useState } from 'react'; import { COMPONENT_LIST } from './constant'; function ComponentLibrary(props) { const { visible, onCancel, onOk, addToTable } = props; const [currentItem, setCurrentItem] = useState(null); const handleOk = () => { if (!currentItem) { message.error('请选择控件'); return; } setCurrentItem(null); onOk?.(currentItem); }; const handleCancel = () => { setCurrentItem(null); onCancel?.(); }; return ( {COMPONENT_LIST.map((item) => { if (addToTable && item.props.label === '表格') { return null; } return (
setCurrentItem(item)} style={{ display: 'flex', justifyContent: 'flex-start', alignItems: 'center', border: item === currentItem ? '1px solid #1890FF' : '1px solid #aaa', width: '100%', padding: '4px 12px', cursor: 'pointer', margin: '10px 0', }} > {item.icon} {item.props.label}
); })}
); } export default ComponentLibrary;