import type { ReactNode } from "react"; import FieldLabel from "./help/FieldLabel"; import ActionToolbar from "./ActionToolbar"; type PolicySectionProps = { title?: ReactNode; summary?: ReactNode; actions?: ReactNode; children: ReactNode; className?: string; headingClassName?: string; }; type PolicyTableProps = { children: ReactNode; fieldLabel: ReactNode; settingLabel: ReactNode; effectiveLabel?: ReactNode; lowerLevelLabel?: ReactNode; showEffectiveColumn?: boolean; showAllowColumn?: boolean; className?: string; rowClassName?: string; headerClassName?: string; }; type PolicyRowProps = { label: ReactNode; help?: ReactNode; note?: ReactNode; control: ReactNode; effective?: ReactNode; effectiveHelp?: ReactNode; allowControl?: ReactNode; className?: string; labelClassName?: string; controlClassName?: string; effectiveClassName?: string; effectiveCellClassName?: string; }; export function PolicySection({ title, summary, actions, children, className = "", headingClassName = "" }: PolicySectionProps) { return (
{(title || summary || actions) && {title &&

{title}

} {actions ?? summary}
} {children}
); } export function PolicyTable({ children, fieldLabel, settingLabel, effectiveLabel, lowerLevelLabel, showEffectiveColumn = false, showAllowColumn = false, className = "", rowClassName = "", headerClassName = "" }: PolicyTableProps) { return (
{fieldLabel} {settingLabel} {showEffectiveColumn && {effectiveLabel}} {showAllowColumn && {lowerLevelLabel}}
{children}
); } export function PolicyRow({ label, help, note, control, effective, effectiveHelp, allowControl, className = "", labelClassName = "", controlClassName = "", effectiveClassName = "", effectiveCellClassName = "" }: PolicyRowProps) { return (
{help ? {label} : {label} } {note && (typeof note === "string" ? {note} : note)}
{control}
{effective !== undefined &&
{effectiveHelp ? {effective} : {effective} }
} {allowControl}
); }