import { Loader2 } from "lucide-react";
import type { ReactNode } from "react";
/** 站点设置工作区:限宽、主内容区内左对齐,不写入后台公共主容器 */
export function AdminSettingsPage({
children,
className,
}: {
children: ReactNode;
className?: string;
}) {
return
{children}
;
}
/** 分类导航 + 主表单列 */
export function AdminSettingsWork({
nav,
children,
}: {
nav: ReactNode;
children: ReactNode;
}) {
return (
);
}
/** 一组相关设置:标题、说明、字段、底部操作,减少逐项套卡片 */
export function AdminSettingsGroup({
title,
description,
children,
footer,
id,
className,
}: {
title: string;
description?: ReactNode;
children: ReactNode;
footer?: ReactNode;
id?: string;
className?: string;
}) {
return (
{title}
{description != null && description !== "" ? (
{description}
) : null}
{children}
{footer != null ? {footer}
: null}
);
}
/** 标签列 + 控件列;窄表单自动改为上下堆叠 */
export function AdminSettingsRow({
label,
htmlFor,
hint,
hintBelow,
error,
errorId,
children,
wide,
className,
}: {
label: ReactNode;
htmlFor?: string;
/** 短说明,紧邻标签 */
hint?: ReactNode;
/** 长说明,放在控件下方 */
hintBelow?: ReactNode;
error?: ReactNode;
errorId?: string;
children: ReactNode;
/** 简介等较长控件 */
wide?: boolean;
className?: string;
}) {
const Tag = htmlFor ? "label" : "div";
return (
{label}
{hint != null && hint !== "" ?
{hint}
: null}
{children}
{hintBelow != null && hintBelow !== "" ? (
{hintBelow}
) : null}
{error != null && error !== "" ? (
{error}
) : null}
);
}
/** 保存单元底部操作:按钮与状态贴齐控件列左边缘 */
export function AdminSettingsActions({
dirty,
saving,
saveLabel,
onSave,
onDiscard,
saveDisabled,
error,
children,
}: {
dirty: boolean;
saving?: boolean;
saveLabel: string;
onSave: () => void;
onDiscard?: () => void;
saveDisabled?: boolean;
error?: string;
children?: ReactNode;
}) {
const status = saving ? "正在保存…" : error ? error : dirty ? "有未保存的修改" : "已保存";
return (
{children}
{onDiscard ? (
) : null}
{status}
);
}