/** * The field groups behind Performance's tabs — split out of the section * component so the hub's own inline `TabPanel` (standalone admin page) and * each tab's own mounted leaf (Customizer host, see `tab-section.tsx`) render * the exact same markup from one place. */ import { __ } from '@wordpress/i18n'; import { ToggleControl } from '@wordpress/components'; import { PanelFieldsList } from '../panel-section'; import type { SetPath, SectionExtra } from '../../types'; interface PerformanceSchema { label: string; cssFileCacheEnabled?: boolean; } const isOn = ( performance: Record< string, unknown >, key: string ): boolean => ( key in performance ? !! performance[ key ] : true ); interface RequestsFieldsProps { performance: Record< string, unknown >; setPath: SetPath; } export function RequestsFields( { performance, setPath, }: RequestsFieldsProps ) { return ( <> setPath( 'performance.disable_emojis', checked ) } /> setPath( 'performance.disable_embeds', checked ) } /> ); } interface CachingFieldsProps { performance: Record< string, unknown >; schema: PerformanceSchema; setPath: SetPath; } export function CachingFields( { performance, schema, setPath, }: CachingFieldsProps ) { // The file write is a companion-plugin capability; without it there is // nothing to toggle, so the control isn't shown at all. if ( ! schema.cssFileCacheEnabled ) { return null; } return ( setPath( 'performance.css_file_cache', checked ) } /> ); } interface UploadsFieldsProps { extras?: SectionExtra[]; } export function UploadsFields( { extras }: UploadsFieldsProps ) { return ( <> { ( extras ?? [] ).map( ( extra ) => ( ) ) } ); } export type { PerformanceSchema };