feat(ui): new workflow node panel

This commit is contained in:
Fu Diwei
2025-01-05 22:53:12 +08:00
parent e4c51aece4
commit 350160833b
19 changed files with 601 additions and 511 deletions

View File

@@ -0,0 +1,41 @@
import React, { useEffect } from "react";
import { useControllableValue } from "ahooks";
import { Drawer } from "antd";
export type PanelProps = {
children: React.ReactNode;
defaultOpen?: boolean;
extra?: React.ReactNode;
footer?: React.ReactNode;
open?: boolean;
title?: React.ReactNode;
onClose?: () => void | Promise<unknown>;
onOpenChange?: (open: boolean) => void;
};
const Panel = ({ children, extra, footer, title, onClose, ...props }: PanelProps) => {
const [open, setOpen] = useControllableValue<boolean>(props, {
valuePropName: "open",
defaultValuePropName: "defaultOpen",
trigger: "onOpenChange",
});
const handleClose = async () => {
try {
const ret = await onClose?.();
if (ret != null && !ret) return;
setOpen(false);
} catch {
return;
}
};
return (
<Drawer destroyOnClose extra={extra} footer={footer} open={open} title={title} width={640} onClose={handleClose}>
{children}
</Drawer>
);
};
export default Panel;