From 7a33c5ef2f7167cc9d272d709941934123df9aa6 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Tue, 22 Feb 2022 15:29:50 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20"=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D1=81=20=D0=B2?= =?UTF-8?q?=D1=81=D0=BF=D0=BB=D1=8B=D0=B2=D0=B0=D1=8E=D1=89=D0=B5=D0=B9=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=BE=D0=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Poprompt.tsx | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/components/Poprompt.tsx 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