/** * The builder's settings dialog โ one shell for every column, row, element * and off-canvas panel settings window, drawn like the rest of the builder: * an icon tile + title + context line, segmented tabs, a scrolling body, and * a footer bar with the actions. * * Built on core's Modal (focus trap, Esc, overlay) with its own header hidden. */ import { __ } from '@wordpress/i18n'; import { FormToggle, Modal } from '@wordpress/components'; import { X, type LucideIcon } from '../../icons'; import type { ReactNode } from 'react'; export interface BuilderModalTab { key: string; label: string; } interface BuilderModalProps { title: string; /** Where this lives, e.g. "Main Header ยท Column 2". */ subtitle?: string; icon: LucideIcon; onClose: () => void; tabs?: BuilderModalTab[]; activeTab?: string; onTabChange?: ( key: string ) => void; /** Actions pinned under the body; start (left) and end (right) groups. */ footerStart?: ReactNode; footerEnd?: ReactNode; children: ReactNode; } export default function BuilderModal( { title, subtitle, icon: Icon, onClose, tabs, activeTab, onTabChange, footerStart, footerEnd, children, }: BuilderModalProps ) { const hasFooter = !! ( footerStart || footerEnd ); return ( { title } { subtitle && ( { subtitle } ) } { tabs && tabs.length > 1 && ( { tabs.map( ( tab ) => ( onTabChange?.( tab.key ) } > { tab.label } ) ) } ) } { children } { hasFooter && ( { footerStart } { footerEnd } ) } ); } interface ToggleRowProps { id: string; label: string; help?: string; checked: boolean; onChange: ( checked: boolean ) => void; } /** * A switch row โ label and help on the left, the switch on the right โ for * stacking on/off options into one bordered list. * @param props * @param props.id * @param props.label * @param props.help * @param props.checked * @param props.onChange */ export function BuilderToggleRow( { id, label, help, checked, onChange, }: ToggleRowProps ) { return ( { label } { help && ( { help } ) } onChange( event.target.checked ) } /> ); }
{ subtitle }