e6b3199490
之前遇到几次弹窗的样式不生效,bug 现在在画布agent的删除对话弹窗又出现了, 这个pr把类似的修改集中到最下层的UnifiedModal,适用于所有的modal, 一些特殊的modal有特殊处理. 画布agent的删除对话弹窗  --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/122 Reviewed-by: 段舒康 <kdletters@qq.com> Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
121 lines
3.1 KiB
TypeScript
121 lines
3.1 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
|
|
import { PlatformActionButton } from './PlatformActionButton';
|
|
import { UnifiedModal, type UnifiedModalPortalTheme } from './UnifiedModal';
|
|
|
|
type UnifiedConfirmDialogTone = 'primary' | 'danger';
|
|
|
|
type UnifiedConfirmDialogProps = {
|
|
open: boolean;
|
|
title: string;
|
|
description?: ReactNode;
|
|
children?: ReactNode;
|
|
onClose: () => void;
|
|
confirmLabel?: string;
|
|
busyConfirmLabel?: string;
|
|
onConfirm?: () => void;
|
|
confirmTone?: UnifiedConfirmDialogTone;
|
|
confirmClassName?: string;
|
|
confirmDisabled?: boolean;
|
|
cancelLabel?: string;
|
|
showCancel?: boolean;
|
|
cancelDisabled?: boolean;
|
|
busy?: boolean;
|
|
closeOnBackdrop?: boolean;
|
|
showCloseButton?: boolean;
|
|
portal?: boolean;
|
|
portalTheme?: UnifiedModalPortalTheme;
|
|
size?: 'sm' | 'md';
|
|
overlayClassName?: string;
|
|
panelClassName?: string;
|
|
footerClassName?: string;
|
|
zIndexClassName?: string;
|
|
};
|
|
|
|
/**
|
|
* 统一提示 / 确认弹窗。
|
|
* 业务层只描述操作语义,按钮布局、处理中禁用和关闭路径统一在这里收口。
|
|
*/
|
|
export function UnifiedConfirmDialog({
|
|
open,
|
|
title,
|
|
description,
|
|
children,
|
|
onClose,
|
|
confirmLabel = '确定',
|
|
busyConfirmLabel,
|
|
onConfirm,
|
|
confirmTone = 'primary',
|
|
confirmClassName,
|
|
confirmDisabled = false,
|
|
cancelLabel = '取消',
|
|
showCancel = false,
|
|
cancelDisabled = false,
|
|
busy = false,
|
|
closeOnBackdrop = true,
|
|
showCloseButton = true,
|
|
portal = true,
|
|
portalTheme = 'auto',
|
|
size = 'sm',
|
|
overlayClassName,
|
|
panelClassName,
|
|
footerClassName,
|
|
zIndexClassName,
|
|
}: UnifiedConfirmDialogProps) {
|
|
const disabled = busy || confirmDisabled;
|
|
const renderedConfirmLabel =
|
|
busy && busyConfirmLabel ? busyConfirmLabel : confirmLabel;
|
|
|
|
return (
|
|
<UnifiedModal
|
|
open={open}
|
|
title={title}
|
|
description={description}
|
|
onClose={onClose}
|
|
closeDisabled={busy}
|
|
closeOnBackdrop={closeOnBackdrop && !busy}
|
|
showCloseButton={showCloseButton}
|
|
portal={portal}
|
|
portalTheme={portalTheme}
|
|
size={size}
|
|
overlayClassName={overlayClassName}
|
|
panelClassName={panelClassName}
|
|
zIndexClassName={zIndexClassName}
|
|
bodyClassName="px-4 py-4 sm:px-5 sm:py-5"
|
|
footerClassName={footerClassName ?? 'justify-end px-4 py-4 sm:px-5'}
|
|
footer={
|
|
<>
|
|
{showCancel ? (
|
|
<PlatformActionButton
|
|
onClick={onClose}
|
|
disabled={busy || cancelDisabled}
|
|
tone="ghost"
|
|
size="sm"
|
|
shape="pill"
|
|
className="min-h-0 px-4 py-2"
|
|
>
|
|
{cancelLabel}
|
|
</PlatformActionButton>
|
|
) : null}
|
|
<PlatformActionButton
|
|
onClick={onConfirm ?? onClose}
|
|
disabled={disabled}
|
|
tone={confirmTone}
|
|
size="sm"
|
|
shape="pill"
|
|
className={`min-h-0 px-4 py-2 ${confirmClassName ?? ''}`}
|
|
>
|
|
{renderedConfirmLabel}
|
|
</PlatformActionButton>
|
|
</>
|
|
}
|
|
>
|
|
{children ? (
|
|
<div className="text-sm leading-6 text-[var(--platform-text-base)]">
|
|
{children}
|
|
</div>
|
|
) : null}
|
|
</UnifiedModal>
|
|
);
|
|
}
|