/** * Shared shapes for the admin settings app. * * The server-side schema (see Aureon\Core\Settings::schema()) is broad, so * the more structural sections (buttons/header/footer/layout…) stay loosely * typed (Record) rather than fully modeled here. Only the * shapes components actually destructure (colors) are typed precisely. */ export interface ColorField { key: string; label: string; group: string; description: string; } export interface ColorGroup { key: string; label: string; } export interface ColorsSchema { label: string; path: string; groups: ColorGroup[]; fields: ColorField[]; } export interface TypographyOption { value: string; label: string; } export interface TypographyTab { key: string; label: string; } export interface TypographySectionSchema { key: string; tab: string; path: string; family_role: string; label: string; description: string; } export interface TypographySchema { label: string; family_path: string; families: TypographyOption[]; weights: TypographyOption[]; transforms: TypographyOption[]; decorations: TypographyOption[]; scales: TypographyOption[]; tabs: TypographyTab[]; sections: Record< string, TypographySectionSchema >; } export interface FontChoice { value: string; label: string; category: string; source: 'system' | 'google'; } export interface FontPairingsSchema { label: string; path: string; fonts: FontChoice[]; maxPairings: number; } export interface FontLibraryCatalogEntry { slug: string; label: string; category: string; styles: string; variants: string[]; popularity: number; } export interface FontLibrarySchema { label: string; path: string; catalog: FontLibraryCatalogEntry[]; maxFonts: number; customUploadsAllowed?: boolean; selfHostEnabled?: boolean; } export interface ScaleField { key: string; label: string; description?: string; } export interface ScaleSchema { label: string; path: string; fields: ScaleField[]; } // One choice in a `design.buttons.*` enum field (style/size/alignment/ // border_style/hover_transform). `key` matches the server's BUTTON_ENUM_CHOICES // value, not `value` — mirrors the shape Settings::schema() actually emits for // these options (see includes/Core/Settings.php, buttons section). export interface ButtonOption { key: string; label: string; description?: string; } export interface ButtonsSchema extends ScaleSchema { style_path?: string; style_options?: ButtonOption[]; size_options?: ButtonOption[]; alignment_options?: ButtonOption[]; border_style_options?: ButtonOption[]; hover_transform_options?: ButtonOption[]; } export interface SettingsSchema { colors?: ColorsSchema; typography?: TypographySchema; font_pairings?: FontPairingsSchema; font_library?: FontLibrarySchema; spacing?: ScaleSchema; buttons?: ButtonsSchema; header?: Record< string, unknown >; footer?: Record< string, unknown >; layout?: Record< string, unknown >; title_area?: Record< string, unknown >; blog?: Record< string, unknown >; dark_mode?: Record< string, unknown >; woocommerce?: Record< string, unknown >; presets?: Record< string, unknown >; tools?: Record< string, unknown >; sidebar?: Record< string, unknown >; performance?: Record< string, unknown >; } export interface FontPairing { id: string; heading: string; body: string; } export interface FontPairingsSettings { active: string; items: FontPairing[]; } export interface FontLibraryEntry { id: string; source: 'google' | 'custom'; family: string; styles: string; status: 'active' | 'inactive'; added_on: number; slug?: string; attachment_id?: number; files?: Record< string, string >; } export interface FontLibrarySettings { items: FontLibraryEntry[]; } export interface TypographyFieldValues { size?: string; line_height?: string; weight?: string; transform?: string; decoration?: string; letter_spacing?: string; scale?: string; base_size?: string; color?: string; overrides?: Record< string, string >; } export interface DesignSettings { colors: Record< string, string >; font_family?: Record< string, string >; font_sizes?: Record< string, string >; typography?: Record< string, TypographyFieldValues >; spacing?: Record< string, string >; radius?: Record< string, string >; // Global button styling (style/size/alignment/padding/border/hover/focus). // Loosely typed like the rest of this structural section — buttons.tsx // reads it as Record. buttons?: Record< string, string | boolean >; } export interface WorkingSettings { design: DesignSettings; header?: Record< string, unknown >; footer?: Record< string, unknown >; layout?: Record< string, unknown >; title_area?: Record< string, unknown >; blog?: Record< string, unknown >; // No `dark_mode` here: those values live behind Aureon Nexus's own route // now (see PanelValues / customizer/store.ts's panelValues.dark_mode), not the theme's // working tree. `modules.dark_mode.enabled` (covered by the index // signature below) is still the master on/off flag. woocommerce?: Record< string, unknown >; font_pairings?: FontPairingsSettings; font_library?: FontLibrarySettings; performance?: Record< string, unknown >; schema_version?: number; [ key: string ]: unknown; } export interface Notice { status: 'success' | 'error'; text: string; } export type SectionGroup = 'global' | 'blocks' | 'advanced' | 'modules'; // A registered feature module, serialized from the PHP Module_Registry into // window.aureonAdmin.modules. Metadata only — enabled state lives in the // settings tree at `enabledPath`; `sectionKey` names the Settings section shown // while the module is on (null when the module has no config UI). export interface FeatureModule { id: string; label: string; description: string; icon: string; category: string; enabledPath: string; sectionKey: string | null; // Provenance badge slug (`pro`, `beta`, `new`), from a module that also // implements Aureon\Modules\Badged_Module. Empty for most modules. badge?: string; } export interface Section { key: string; label: string; enabled: boolean; group: SectionGroup; // Lucide icon name, for sections that aren't in the sidebar's own key → icon // map (i.e. plugin-contributed ones). See module-icons.ts. icon?: string; // Provenance badge slug shown beside the nav entry. badge?: string; } // One control in a plugin-contributed section. Mirrors the descriptors // normalized by Aureon\Customizer\Admin_Panel::panel_fields() — see that // method for the full contract. export interface PanelFieldOption { value: string; label: string; } export type PanelTone = 'info' | 'success' | 'warning' | 'error' | ''; // One row of a `repeater`'s value — a form field a site owner defined // themselves (Aureon Nexus's sign-up form builder is the first caller). The // value at a repeater's `key` is `PanelRepeaterItem[]`. export interface PanelRepeaterItem { key: string; label: string; type: string; required: boolean; // Meaningful only when `type` is one the caller's `typeOptions` marks as // needing them (a dropdown's choices) — carried on every row regardless, // since the shape has to be uniform for a plugin's PHP sanitizer to trust. options: string[]; // Meaningful only for a `checkbox` row — whether it starts ticked (a // newsletter opt-in, say, as opposed to a Terms of Service agreement, // which shouldn't). Carried on every row for the same reason `options` is. default: boolean; // Whether this row appears on the form at all — separate from `required`, // which only matters once a row is shown. Lets an admin keep a field // configured (label, type, choices intact) but pull it off the live form // without deleting and later rebuilding it. enabled: boolean; // Placeholder text shown inside an empty text/email/tel/textarea input. // Meaningless for `select`/`checkbox`, but carried on every row like // `options` and `default` are, for the same uniform-shape reason. placeholder: string; // Optional help text shown under the field on the live form — what // `help` is for every other field type in this panel, just carried in // the row's own data instead of the descriptor, since every row needs // its own. description: string; // The leading glyph shown both in this row's own line and on the live // form's input — a caller-supplied key resolved by the same icon set the // front-end already draws from (not a Lucide name), since the row and // the actual rendered field have to agree. Empty defers to a type-based // default (see `TYPE_ICON` in repeater-field.tsx) rather than drawing // nothing. icon: string; } // A row the repeater always shows pinned above the editable list, read-only // (no drag, no edit, no remove) — Username/Email/Password, the fields // WordPress itself requires and {@see PanelRepeaterItem} rows can never // remove or replace. Exists purely so the list reads as the *whole* form // rather than leaving three fields to a footnote underneath it. export interface PanelRepeaterPinnedItem { label: string; type: string; icon: string; } // One row of a `detaillist`: a label, and a value read from `key`. export interface PanelDetailRow { label: string; key: string; // Adds a copy button beside the value — for a key or an id worth lifting out. copy?: boolean; // Draws the value as a pill rather than plain text. badge?: boolean; // Prefixes the value with a tone dot, coloured by `toneKey`. dot?: boolean; toneKey?: string; } export interface PanelField { type: | 'select' | 'toggle' | 'checkboxes' | 'text' | 'secret' | 'textarea' | 'notice' | 'copy' | 'link' | 'helpcard' | 'row' | 'statecard' | 'detaillist' | 'checklist' | 'status' | 'action' | 'group' | 'repeater'; key?: string; label?: string; help?: string; placeholder?: string; options?: PanelFieldOption[]; // `textarea` only: row count for the control. Defaults to 4 on the PHP side. rows?: number; // Conditions, each naming a sibling key: render only while truthy / only while // falsy / render but disabled while truthy. showIf?: string; hideIf?: string; disabledIf?: string; // The mirror of `disabledIf`: disabled *until* that sibling is truthy — how a // per-card Save says it has nothing to save yet. disabledUnless?: string; // Groups this field under a surface-level tab (see `PanelSurface.tabs`). // Empty/absent renders the field above the tab bar, regardless of which // tab is active. tab?: string; // `notice`, `copy`, `link` and `helpcard`: static copy. A notice takes an // optional single link; a copy card shows `text` as its value and offers a // Copy button; a link is `label` pointing at `url`; a helpcard is a titled // callout opening `url` — with `urlLabel` it gets a button, without one the // whole card is the link. text?: string; url?: string; urlLabel?: string; // `copy` only: read the value from this sibling instead of static `text`, for // a string that an action can change while the panel is open. textKey?: string; // `copy`: `card` (default) stands alone, `field` sits in a column like a // labelled control. `checkboxes`: `chips` draws each box as its own tile // inside a titled panel rather than as a plain list. `link`: `button` or // `button-primary` draws the link as a button rather than inline text. // Distinct from `variant`, which is the `action` type's button style. layout?: string; // `statecard` only: the small uppercase line above the state itself, and the // sibling holding the sentence under it. The state's own text comes from // `key`, and `toneKey` colours the whole card. eyebrow?: string; helpKey?: string; // `detaillist` only: the label/value rows, each reading its value from a // sibling key. `copy` adds a copy button, `badge` draws the value as a pill, // and `dot` prefixes it with a tone dot. Named apart from `rows`, which is // the textarea's row count. detailRows?: PanelDetailRow[]; // `checklist` only: the ticked lines, which are static copy rather than // values — an entitlement list doesn't vary per site. items?: string[]; tone?: PanelTone; // `group` only: the fields this card wraps, and the sibling key its head // switch writes. With `toggleKey` the body is hidden while that value is // falsy, so the switch reads as the subject of the card. fields?: PanelField[]; toggleKey?: string; // `group` only: whether switching `toggleKey` off hides the card's body. // Defaults true on the PHP side. toggleHidesBody?: boolean; // `group` only: sibling keys holding a read-only state pill for the card's // head and the tone that colours it. Renders beside `toggleKey`, not // instead of it. statusKey?: string; statusToneKey?: string; // `group` only: lay the body out in two columns rather than one stack. columns?: number; // `group` only: a step number in place of the icon tile, for a card that is // one stage of an ordered setup. step?: number; // `group` only: visible text beside the head switch. Without it the switch is // labelled by the card's title for assistive tech and shows nothing. toggleLabel?: string; // `group` only: a link at the end of the head row — "where do I find this?" // beside the field that wants it. headLink?: { label: string; url: string }; // Keeps a control's label for assistive tech but drops it from the page, for // a field whose card title already names it. hideLabel?: boolean; // Icon name for a `group`'s head tile, a `copy` card's or a `helpcard`'s, or // the override a `status` uses in place of the glyph its tone would pick. icon?: string; // `group` only: `brand` drops the tinted tile around a multi-colour mark. iconStyle?: 'default' | 'brand'; // `status` only: the sibling key holding the tone for the displayed value. toneKey?: string; // `action` only: the action name POSTed to the surface's route, and the label // shown while it runs. action?: string; // `destructive` is not a WP button variant but a flag on top of `secondary`: // an action that takes something away shouldn't wear the brand colour. variant?: 'primary' | 'secondary' | 'destructive'; busy?: string; // `action` and an `action`-driven `helpcard`: shows this dialog before // actually running the action, rather than firing on the first click — for // one that can't be undone (a reset, a delete). confirm?: { title: string; description: string; confirmLabel?: string }; // `repeater` only: singular noun for one row ("Field") used in its own // remove-confirmation and empty state, the label on its "Add" button, and // the field-type choices each row's own `type` picker offers. itemLabel?: string; addLabel?: string; typeOptions?: PanelFieldOption[]; // `repeater` only: the icon choices each row's own `icon` picker offers. iconOptions?: PanelFieldOption[]; // `repeater` only: read-only rows pinned above the editable list — see // `PanelRepeaterPinnedItem`. pinnedItems?: PanelRepeaterPinnedItem[]; } // The parts a plugin-contributed section and area share. Values live behind the // surface's own `restPath` (GET → { settings }, POST the values object, or // POST { action, values } for an action button) because the plugin owns its // storage, not the theme's option. export interface PanelSurface { key: string; label: string; description: string; icon: string; // Dotted path in the theme settings tree gating visibility (typically a // module's master flag). Empty means always visible. gatePath: string; restPath: string; // Provenance badge slug (`pro`, `beta`, `new`), shown beside the surface's nav // entry or area tab. badge: string; // False for a surface with no savable values — its edits never mark the panel // dirty and Save never posts to it (a license screen, say, where actions are // the only writes). saves: boolean; // Which sidebar group an *area's* nav entry joins — see `AreaGroup`. Named // apart from `PanelSection.group`, which is the Settings sidebar's own // grouping for sections and a different closed set entirely. areaGroup?: AreaGroup; // Optional sub-tabs a field joins via its own `tab` key. Empty for a // surface plain enough to stay one flat list, which is most of them. tabs: { key: string; label: string; icon?: string; description?: string }[]; // How `tabs` above renders — see ``'s own `variant` prop. tabsVariant: 'underline' | 'cards'; fields: PanelField[]; // An optional documentation link, drawn as a card at the end of the // surface's heading row. Empty `url` means the surface has none. docs?: { url: string; label: string; help: string }; // A built-in (or another plugin's) section key this surface's fields append // to, instead of getting a nav entry of their own. Empty for a normal // section/area. See Aureon\Customizer\Admin_Panel::panel_surface(). target: string; // Front-end page the Customizer previews while this surface's section is // open. Empty for none. See `bindSurfacePreviews()` in customizer/sections.tsx. previewUrl?: string; } // From window.aureonAdmin.sections — a surface in the Settings sidebar. // `target`-less entries get their own nav item; the rest are picked up by // SECTION_EXTRAS in customizer/sections.tsx and rendered inline inside the section they name. export interface PanelSection extends PanelSurface { group: SectionGroup; } // From window.aureonAdmin.areas — a surface in the top-level area switcher, // rendered full-width with no section nav and no live preview. export type PanelArea = PanelSurface; // Working values for every plugin-contributed surface, keyed by surface key. export type PanelValues = Record< string, Record< string, unknown > >; // Writes one field of the surface being rendered. export type SetPanelValue = ( field: string, value: unknown ) => void; // Runs one `action` field against the surface's route. export type RunPanelAction = ( action: string ) => void; // One targeted plugin surface's fields, pre-bound to its own values/setValue // by `extrasFor()` in customizer/sections.tsx — ready for a built-in section // (Performance, WooCommerce, …) to drop inline via PanelFieldsList. See the // `target` contract on PanelSurface. export interface SectionExtra { key: string; fields: PanelField[]; values: Record< string, unknown >; setValue: SetPanelValue; // `action` fields bypass the panel's Save button entirely and POST an // action name to the surface's own route, so an inline extra needs this // bound the same way a full `PanelSection` does — without it a targeted // action button (Nexus's "Switch to Classic Cart", the first) renders // correctly but does nothing when clicked. runAction: RunPanelAction; // The action currently in flight on this surface, if any — drives the // button's busy state. pendingAction?: string; } // Per-view extras for a section with multiple sub-views switched by an // internal chip row rather than a nav entry (currently just WooCommerce: // shop/product/cart/checkout) — a plugin targets one *view*, not just the // section, by suffixing the section key (`woocommerce_cart`, …), so the // section component can render each view's own extras in place rather than // dumping every targeted field into whichever view happens to render first. export type ViewedSectionExtras = Partial< Record< string, SectionExtra[] > >; // Which group a plugin-contributed area belongs to — see `AREA_GROUPS` in // Admin_Panel::panel_surface(). export type AreaGroup = | 'setup' | 'features' | 'membership' | 'advanced' | 'tools'; export type SetPath = ( path: string, value: unknown ) => void; declare global { interface Window { aureonAdmin?: { // REST route the control schema is re-read from — see // settings-transport.ts. settingsPath: string; // Dotted `design.*` leaf (or bare top-level key) → the // `wp.customize` id it was registered under — see // Aureon\Customizer\Customizer::setting_ids(). What the controls // read/write through, via customize-bridge.ts. settingIds: Record< string, string >; defaults: Partial< WorkingSettings >; schema: SettingsSchema; fontDownloadPath: string; previewUrls?: Record< string, string >; // The redesigned Static Front Page control's "Add Page" links — see // StaticFrontPageSection. newPageUrl: string; modules?: FeatureModule[]; sections?: PanelSection[]; areas?: PanelArea[]; }; } }