diff --git a/src/components/Poprompt.tsx b/src/components/Poprompt.tsx new file mode 100644 index 0000000..410e552 --- /dev/null +++ b/src/components/Poprompt.tsx @@ -0,0 +1,50 @@ +import { memo, ReactNode, useState } from 'react' +import { Button, ButtonProps, Form, FormProps, Popover, PopoverProps } from 'antd' + +export type PopromptProps = PopoverProps & { + children?: ReactNode + footer?: ReactNode + text?: string + onDone?: (values: any) => void + formProps?: FormProps + buttonProps?: ButtonProps +} + +export const Poprompt = memo(({ formProps, buttonProps, footer, children, onDone, text, ...other }) => { + const [visible, setVisible] = useState(false) + + const onFormFinish = (values: any) => { + setVisible(false) + onDone?.(values) + } + + return ( + + {children} + + {footer ?? ( +
+ + +
+ )} +
+ + )} + trigger={'click'} + {...other} + visible={visible} + onVisibleChange={(visible) => setVisible(visible)} + > + +
+ ) +}) + +export default Poprompt