| 11 | deleteItemText?: string |
| 12 | } & PropsWithChildren |
| 13 | > = (props) => { |
| 14 | const { onDelete, confirmText, deleteItemText } = props |
| 15 | |
| 16 | const defaultButton = ( |
| 17 | <StyledButton |
| 18 | variant="secondary" |
| 19 | className="rounded-lg" |
| 20 | onClick={() => { |
| 21 | onDelete().then(() => { |
| 22 | toast.success('删除成功') |
| 23 | }) |
| 24 | }} |
| 25 | > |
| 26 | 确定 |
| 27 | </StyledButton> |
| 28 | ) |
| 29 | |
| 30 | return ( |
| 31 | <FloatPopover |
| 32 | trigger="click" |
| 33 | type="tooltip" |
| 34 | triggerElement={ |
| 35 | <MotionButtonBase className="duration-200 hover:text-red-500"> |
| 36 | 删除 |
| 37 | </MotionButtonBase> |
| 38 | } |
| 39 | > |
| 40 | <div className="flex p-2"> |
| 41 | <p className="text-center text-base font-bold text-error"> |
| 42 | {confirmText ?? |
| 43 | (deleteItemText |
| 44 | ? `确定删除「${deleteItemText}」吗?` |
| 45 | : '确定删除吗?')} |
| 46 | </p> |
| 47 | </div> |
| 48 | <div className="text-right">{props.children || defaultButton}</div> |
| 49 | </FloatPopover> |
| 50 | ) |
| 51 | } |