/** * The Settings layout (Fahim, 2026-10-23): one white panel with a side menu * of pages on the left and the open page filling the rest, instead of tabs * over a narrow column. Each page is a `SettingsPage` (its title and one * action) holding `SettingsSection`s split by hairlines. Inside a section, * inputs sit in a `FieldGrid` with labels above them, and on/off settings * are `ToggleRow`s. Help goes in a `?` tip (`ui.HelpTip`), never a sentence * under every field; nothing hides behind "More settings". */ import { __ } from '@wordpress/i18n'; import { Building2, Circle, ListPlus, Mail, Newspaper, PlugZap, Send, ShieldBan, ShieldCheck, } from 'lucide-react'; import { cn, ui } from '../kit'; /** The side menu's icon for each core page; add-on pages bring `icon`. */ const ICONS = { sending: Send, business: Building2, fields: ListPlus, emails: Mail, automatic: Newspaper, spam: ShieldBan, privacy: ShieldCheck, mcp: PlugZap, }; /** * The panel: the side menu and the open page. * * @param {Object} props * @param {Array} props.pages `{ id, label, icon? }`. * @param {string} props.current The open page. * @param {Function} props.onChange Called with a page id. * @param {*} props.children The open page. * @return {Element} The panel. */ export function SettingsFrame( { pages, current, onChange, children } ) { return (
{ children }
); } /** * A settings page: its title and at most one action, then its sections. * * @param {Object} props * @param {*} props.title The page's name. * @param {*} props.actions One button, or a link. * @param {*} props.children `SettingsSection`s. * @return {Element} The page. */ export function SettingsPage( { title, actions, children } ) { return (

{ title }

{ actions && (
{ actions }
) }
{ children }
); } /** * One group of settings, split from the one above by a hairline. * * @param {Object} props * @param {*} props.title The group's name. * @param {*} props.tip Optional help, in a `?` beside the name. * @param {*} props.action Optional link or small button, at the right. * @param {string} props.className Extra classes. * @param {*} props.children Fields, rows, or anything. * @return {Element} The section. */ export function SettingsSection( { title, tip, action, className, children } ) { return (
{ ( title || action ) && (
{ title && (

{ title }

) } { tip && ( { tip } ) }
{ action }
) } { children }
); } /** * Inputs side by side, labels above them; one column on a phone. * * @param {Object} props * @param {number} props.columns 2 (default) or 3. * @param {*} props.children `ui.Field`s. * @return {Element} The grid. */ export function FieldGrid( { columns = 2, children } ) { return (
*]:min-w-0', columns === 3 ? 'sm:grid-cols-2 lg:grid-cols-3' : 'sm:grid-cols-2' ) } > { children }
); } /** * ToggleRows stacked with hairlines between them. * * @param {Object} props * @param {*} props.children `ToggleRow`s. * @return {Element} The list. */ export function ToggleList( { children } ) { return (
{ children }
); } /** * An on/off setting: its name and `?` on the left, the switch on the right. * `children` show under it while it is on (a label for the box it adds, * say). * * @param {Object} props * @param {string} props.id The switch's id. * @param {*} props.label The setting's name. * @param {*} props.tip Optional help. * @param {boolean} props.checked On. * @param {boolean} props.disabled Busy. * @param {Function} props.onChange Called with the new value. * @param {*} props.children Shown while on. * @return {Element} The row. */ export function ToggleRow( { id, label, tip, checked, disabled, onChange, children, } ) { return (
{ tip && { tip } }
{ checked && children && (
{ children }
) }
); }