import type { ReactNode } from "react";
import { StatusBadge } from "~/components/console/status-badge.tsx";
import { cn } from "~/lib/utils.ts";
/** 分区内锚点 id:`<分区>-<节>`,URL hash 写作 `#<分区>/<节>` */
export const anchorId = (section: string, anchor: string) => `settings-${section}-${anchor}`;
/** 节卡片内边距;SaveBar 用同一组负边距贴满卡片底边 */
const SLAB_PAD = "p-5 sm:p-6";
/**
* 设置分区里的一节:标题(h3)+ 一句说明 + 未保存提示 + 内容;带锚点。
* 层级:页面 h1「设置」→ 分区 h2 → 节 h3。节内的保存放在节尾的 SaveBar,不放标题行。
*/
export function SettingsBlock({
section,
anchor,
title,
description,
dirty,
actions,
plain,
children,
}: {
section: string;
anchor: string;
title: string;
description?: ReactNode;
dirty?: boolean;
/** 标题行右侧:只放"添加 / 打开"这类入口,保存用 SaveBar */
actions?: ReactNode;
/** 不包卡片(内容自带 DataTable 卡片时用) */
plain?: boolean;
children: ReactNode;
}) {
const id = anchorId(section, anchor);
return (
{description}
{title}
{dirty ?
{description ?
{dirty ? "有未保存的修改" : (note ?? "")}
{children}