| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon, Select, DatePicker, Input } from 'antd' |
| | | import { Icon, Select, DatePicker, Input, Popover } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import DateGroup from '../dategroup' |
| | |
| | | |
| | | const { MonthPicker, WeekPicker, RangePicker } = DatePicker |
| | | |
| | | const Card = ({ id, card, moveCard, findCard, editCard, delCard }) => { |
| | | const Card = ({ id, cardIds, card, moveCard, findCard, copyCard, editCard, delCard }) => { |
| | | const originalIndex = findCard(id).index |
| | | const [{ isDragging }, drag] = useDrag({ |
| | | item: { type: 'search', id, originalIndex }, |
| | |
| | | const [, drop] = useDrop({ |
| | | accept: 'search', |
| | | canDrop: () => true, |
| | | drop: (item) => { |
| | | if (!item.hasOwnProperty('originalIndex')) { |
| | | |
| | | } |
| | | }, |
| | | drop: () => {}, |
| | | hover({ id: draggedId }) { |
| | | if (!draggedId) return |
| | | if (!cardIds.includes(draggedId)) return |
| | | if (draggedId !== id) { |
| | | const { index: overIndex } = findCard(id) |
| | | moveCard(draggedId, overIndex) |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <Icon className="edit" title="edit" type="edit" onClick={() => editCard(id)} /> |
| | | <Icon className="copy" title="copy" type="copy" onClick={() => copyCard(id)} /> |
| | | <Icon className="close" title="delete" type="close" onClick={() => delCard(id)} /> |
| | | </div> |
| | | } trigger="hover"> |
| | | <div className="page-card" style={{ opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | | <div className="ant-form-item"> |
| | | {card.type === 'text' ? |
| | | <Input placeholder={card.label} style={{marginTop: '4px'}} value={card.initval} /> : null |
| | | <Input placeholder={card.label} value={card.initval} /> : null |
| | | } |
| | | {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ? |
| | | <Select placeholder={card.label} value={_defaultValue}></Select> : null |
| | |
| | | <div className="input-mask"></div> |
| | | </div> |
| | | </div> |
| | | <Icon className="edit" title="edit" type="edit" onClick={() => editCard(id)} /> |
| | | <Icon className="edit close" title="delete" type="close" onClick={() => delCard(id)} /> |
| | | </div> |
| | | </Popover> |
| | | ) |
| | | } |
| | | export default Card |