import { type CSSProperties, type Dispatch, type SetStateAction } from 'react'; import { PlatformActionButton } from '../common/PlatformActionButton'; import type { CropExpandPanelState, CropExpandRatioValue, } from './ImageCanvasEditorTypes'; type ImageCanvasCropExpandPanelViewProps = { panel: CropExpandPanelState; style: CSSProperties; setCropExpandPanel: Dispatch>; onSubmit: () => void; }; const CROP_EXPAND_RATIO_OPTIONS: Array<{ value: CropExpandRatioValue; label: string; shape?: 'square' | 'landscape' | 'portrait'; }> = [ { value: 'free', label: '自由比例' }, { value: '1:1', label: '1:1', shape: 'square' }, { value: '4:3', label: '4:3', shape: 'landscape' }, { value: '3:4', label: '3:4', shape: 'portrait' }, { value: '16:9', label: '16:9', shape: 'landscape' }, { value: '9:16', label: '9:16', shape: 'portrait' }, ] as const; function resetFailedCropExpandPanel(panel: CropExpandPanelState) { return { ...panel, status: panel.status === 'failed' ? 'idle' : panel.status, errorMessage: panel.status === 'failed' ? undefined : panel.errorMessage, }; } export function ImageCanvasCropExpandPanelView({ panel, style, setCropExpandPanel, onSubmit, }: ImageCanvasCropExpandPanelViewProps) { return (
event.stopPropagation()} onSubmit={(event) => { event.preventDefault(); if (panel.status !== 'processing') { onSubmit(); } }} >
裁扩
{CROP_EXPAND_RATIO_OPTIONS.map((option) => ( ))}
{panel.status === 'failed' ? (

{panel.errorMessage}

) : null}
setCropExpandPanel(null)} > 取消 {panel.status === 'processing' ? '处理中' : '完成'}
); }