import { IconAlertTriangle, IconRefresh } from '@douyinfe/semi-icons';
import { Button, Card, CardGroup, Empty, Spin, Typography } from '@douyinfe/semi-ui';
import type { ReactNode } from 'react';
type StateScope = 'page' | 'panel' | 'inline';
type StateKind = 'loading' | 'empty' | 'error';
const PAGE_LOADING_SKELETON =
;
const PANEL_LOADING_SKELETON =
;
function stateRole(kind: StateKind) {
return kind === 'error' ? 'alert' : 'status';
}
function StateSurface({
kind,
scope,
title,
description,
className = '',
action,
compact = false
}: {
kind: StateKind;
scope: StateScope;
title: string;
description?: string;
className?: string;
action?: ReactNode;
compact?: boolean;
}) {
const classes = ['v2-state-surface', `is-${kind}`, `is-${scope}`, compact ? 'is-compact' : '', className].filter(Boolean).join(' ');
return
{kind === 'empty'
? {action}
:
{kind === 'loading' ? : }
{title}{description ? {description} : null}
{action ?
{action}
: null}
}
{kind === 'loading' ? (scope === 'page' ? PAGE_LOADING_SKELETON : PANEL_LOADING_SKELETON) : null}
;
}
export function PageLoading({ label = '正在加载车辆数据' }: { label?: string }) {
return ;
}
export function PanelLoading({
title = '正在读取数据',
description = '当前结果返回后会自动更新。',
className = '',
compact = false
}: {
title?: string;
description?: string;
className?: string;
compact?: boolean;
}) {
return ;
}
export function PanelEmpty({
title,
description,
className = '',
action
}: {
title: string;
description?: string;
className?: string;
action?: ReactNode;
}) {
return ;
}
export type WorkspaceEmptyGuideStep = {
title: string;
description: string;
icon?: ReactNode;
};
export function WorkspaceEmptyGuide({
title,
description,
steps,
icon,
eyebrow,
action,
secondaryAction,
className = ''
}: {
title: string;
description: string;
steps: WorkspaceEmptyGuideStep[];
icon?: ReactNode;
eyebrow?: string;
action?: ReactNode;
secondaryAction?: ReactNode;
className?: string;
}) {
const classes = ['v2-state-surface', 'is-empty', 'is-panel', 'v2-workspace-empty-guide', className].filter(Boolean).join(' ');
return
{eyebrow ? {eyebrow} : null}
{icon} : undefined}
title={title}
description={description}
/>
{steps.map((step, index) =>
{step.icon ?? index + 1}
{step.title}{step.description}
)}
{action || secondaryAction ? {action}{secondaryAction}
: null}
;
}
export function InlineError({ message, onRetry }: { message: string; onRetry?: () => void }) {
return } aria-label="重试" onClick={onRetry}>重试 : null}
/>;
}
export function EmptyState({ title = '暂无符合条件的车辆' }: { title?: string }) {
return ;
}