7005792580
新增 PlatformUnsavedLeaveConfirmDialog 统一承接未保存离开确认壳层 迁移 RPG 创作编辑器的关闭未保存修改与退出未保存结果确认复用共享组件 补充共享组件测试并更新 PlatformUiKit 收口文档与决策记录
93 lines
2.1 KiB
TypeScript
93 lines
2.1 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
|
|
import { UnifiedConfirmDialog } from './UnifiedConfirmDialog';
|
|
|
|
type PlatformUnsavedLeaveConfirmDialogProps = {
|
|
open: boolean;
|
|
title?: string;
|
|
children?: ReactNode;
|
|
onClose: () => void;
|
|
onConfirm: () => void;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
showCloseButton?: boolean;
|
|
closeOnBackdrop?: boolean;
|
|
portal?: boolean;
|
|
size?: 'sm' | 'md';
|
|
variant?: 'platform' | 'pixel';
|
|
overlayClassName?: string;
|
|
panelClassName?: string;
|
|
};
|
|
|
|
function resolveUnsavedLeaveOverlayClassName(
|
|
variant: 'platform' | 'pixel',
|
|
overlayClassName?: string,
|
|
) {
|
|
if (overlayClassName) {
|
|
return overlayClassName;
|
|
}
|
|
|
|
return variant === 'pixel' ? 'z-[140]' : 'z-[140] !items-center';
|
|
}
|
|
|
|
function resolveUnsavedLeavePanelClassName(
|
|
variant: 'platform' | 'pixel',
|
|
panelClassName?: string,
|
|
) {
|
|
if (panelClassName) {
|
|
return panelClassName;
|
|
}
|
|
|
|
return variant === 'platform'
|
|
? 'platform-remap-surface rounded-[1.5rem]'
|
|
: undefined;
|
|
}
|
|
|
|
/**
|
|
* 平台未保存离开确认弹窗。
|
|
* 统一承接关闭 / 退出前的“继续编辑 + 确认离开”语义和默认平台壳层。
|
|
*/
|
|
export function PlatformUnsavedLeaveConfirmDialog({
|
|
open,
|
|
title = '确认退出',
|
|
children,
|
|
onClose,
|
|
onConfirm,
|
|
confirmLabel,
|
|
cancelLabel = '继续编辑',
|
|
showCloseButton = true,
|
|
closeOnBackdrop = true,
|
|
portal = true,
|
|
size = 'sm',
|
|
variant = 'platform',
|
|
overlayClassName,
|
|
panelClassName,
|
|
}: PlatformUnsavedLeaveConfirmDialogProps) {
|
|
return (
|
|
<UnifiedConfirmDialog
|
|
open={open}
|
|
title={title}
|
|
onClose={onClose}
|
|
onConfirm={onConfirm}
|
|
confirmLabel={confirmLabel ?? title}
|
|
cancelLabel={cancelLabel}
|
|
showCloseButton={showCloseButton}
|
|
closeOnBackdrop={closeOnBackdrop}
|
|
showCancel
|
|
portal={portal}
|
|
size={size}
|
|
variant={variant}
|
|
overlayClassName={resolveUnsavedLeaveOverlayClassName(
|
|
variant,
|
|
overlayClassName,
|
|
)}
|
|
panelClassName={resolveUnsavedLeavePanelClassName(
|
|
variant,
|
|
panelClassName,
|
|
)}
|
|
>
|
|
{children}
|
|
</UnifiedConfirmDialog>
|
|
);
|
|
}
|