AiAssistant.tsx
2 days ago
App.tsx
2 days ago
BuilderSync.ts
2 days ago
ControlRenderer.tsx
2 days ago
HoverTip.tsx
2 days ago
Popover.tsx
2 days ago
PreviewBridge.ts
2 days ago
PreviewPane.tsx
2 days ago
constants.ts
2 days ago
cssVars.ts
2 days ago
globals.d.ts
2 days ago
index.tsx
2 days ago
panes.tsx
2 days ago
store.ts
2 days ago
style.scss
2 days ago
types.ts
2 days ago
types.ts
182 lines
| 1 | /** |
| 2 | * Style Customizer v2 — shared types. Mirror the PHP contract (Schema.php & Sanitizer.php); |
| 3 | * the schema itself is fetched from the REST endpoint at runtime. |
| 4 | */ |
| 5 | |
| 6 | export type Device = 'desktop' | 'tablet' | 'mobile'; |
| 7 | |
| 8 | export type ControlType = |
| 9 | | 'slider' |
| 10 | | 'color' |
| 11 | | 'box4' |
| 12 | | 'select' |
| 13 | | 'align' |
| 14 | | 'fontstyle' |
| 15 | | 'media' |
| 16 | | 'toggle'; |
| 17 | |
| 18 | /** A 4-side box value — the legacy associative shape the compiler reads (never indexed). */ |
| 19 | export interface BoxValue { |
| 20 | top: number; |
| 21 | right: number; |
| 22 | bottom: number; |
| 23 | left: number; |
| 24 | unit?: string; |
| 25 | } |
| 26 | |
| 27 | /** Font-style flags — stored with the old customizer's keys for lossless migration. */ |
| 28 | export interface FontStyleValue { |
| 29 | bold: boolean; |
| 30 | italic: boolean; |
| 31 | underline: boolean; |
| 32 | uppercase: boolean; |
| 33 | /** Explicit weight (e.g. '600'); '' ("Auto", also every pre-existing value) derives from `bold`. */ |
| 34 | weight?: string; |
| 35 | } |
| 36 | |
| 37 | /** A single sanitizable value for a token. */ |
| 38 | export type ScalarValue = number | string | boolean | BoxValue | FontStyleValue; |
| 39 | |
| 40 | /** A token's per-device bag; only `desktop` is guaranteed. */ |
| 41 | export type DeviceBag = Partial<Record<Device, ScalarValue>> & { desktop: ScalarValue }; |
| 42 | |
| 43 | export interface SelectOption { |
| 44 | value: string; |
| 45 | label: string; |
| 46 | } |
| 47 | |
| 48 | /** One schema token, as delivered by the REST GET (already normalized in PHP). */ |
| 49 | export interface Token { |
| 50 | key: string; |
| 51 | section: string; |
| 52 | group: string; |
| 53 | label: string; |
| 54 | type: ControlType; |
| 55 | var: string | null; |
| 56 | default: ScalarValue; |
| 57 | state: string | null; |
| 58 | responsive: boolean; |
| 59 | advanced: boolean; |
| 60 | hidden: boolean; |
| 61 | tier: 'free' | 'pro'; |
| 62 | keywords: string[]; |
| 63 | // Optional, type-specific extras. |
| 64 | min?: number; |
| 65 | max?: number; |
| 66 | step?: number; |
| 67 | unit?: string; |
| 68 | options?: SelectOption[]; |
| 69 | units?: string[]; |
| 70 | corners?: boolean; |
| 71 | deps?: string[]; |
| 72 | vars?: Record<string, string>; |
| 73 | neutral_weight?: string; |
| 74 | weight_options?: SelectOption[]; |
| 75 | show_when_image?: boolean; |
| 76 | special?: string; |
| 77 | /** Runtime option source; `google_fonts` = fill the dropdown from payload.google_fonts. */ |
| 78 | source?: string; |
| 79 | /** Whether this `color` token's CSS rule uses the `background` shorthand (not `background-color` |
| 80 | * or `color`/`border-color`), so a `linear-gradient()`/`radial-gradient()` value renders correctly. */ |
| 81 | gradientable?: boolean; |
| 82 | } |
| 83 | |
| 84 | export interface SectionState { |
| 85 | id: string; |
| 86 | label: string; |
| 87 | } |
| 88 | |
| 89 | export interface Section { |
| 90 | key: string; |
| 91 | title: string; |
| 92 | hint: string; |
| 93 | variants?: string[]; |
| 94 | states?: string[]; |
| 95 | /** 'pro' sections render as a locked upgrade teaser in free (see Schema::sections()). */ |
| 96 | tier?: 'free' | 'pro'; |
| 97 | } |
| 98 | |
| 99 | export interface Palette { |
| 100 | id: string; |
| 101 | name: string; |
| 102 | is_pro: boolean; |
| 103 | is_custom?: boolean; |
| 104 | colors: Record<string, string>; |
| 105 | } |
| 106 | |
| 107 | /** A style template (built-in v1 set migrated server-side, or a user-saved one). */ |
| 108 | export interface Template { |
| 109 | id: string; |
| 110 | name: string; |
| 111 | image: string; |
| 112 | palette: string; |
| 113 | tokens: Record<string, DeviceBag>; |
| 114 | /** True for user-created templates (deletable). */ |
| 115 | custom?: boolean; |
| 116 | /** True for Pro-only built-in templates (locked in free). */ |
| 117 | is_pro?: boolean; |
| 118 | /** True for the old, superseded default set — kept for existing forms, hidden from the picker grid. */ |
| 119 | legacy?: boolean; |
| 120 | } |
| 121 | |
| 122 | /** The stored style record (matches Sanitizer::sanitize_record()). */ |
| 123 | export interface StyleRecord { |
| 124 | schema_version: number; |
| 125 | tokens: Record<string, DeviceBag>; |
| 126 | palette?: string; |
| 127 | template?: string; |
| 128 | custom_css?: string; |
| 129 | _updated_at?: number; |
| 130 | } |
| 131 | |
| 132 | /** The REST GET payload. */ |
| 133 | export interface StylePayload { |
| 134 | form_id: number; |
| 135 | schema_version: number; |
| 136 | schema: Token[]; |
| 137 | sections: Record<string, Omit<Section, 'key'>>; |
| 138 | palettes: Palette[]; |
| 139 | palette_map: Record<string, string[]>; |
| 140 | templates: Template[]; |
| 141 | user_templates: Template[]; |
| 142 | breakpoints: Record<string, number>; |
| 143 | pro_active: boolean; |
| 144 | /** Full Google Fonts family list for the Font Family dropdown (matches the v1 customizer). */ |
| 145 | google_fonts: string[]; |
| 146 | /** "Apply Theme Style" — true = theme styling, false = Everest Forms' default styling. */ |
| 147 | apply_theme_style: boolean; |
| 148 | record: StyleRecord; |
| 149 | /** Drives the migration notice. */ |
| 150 | migration: MigrationInfo; |
| 151 | } |
| 152 | |
| 153 | export interface MigrationInfo { |
| 154 | /** The served record was auto-migrated from a legacy shape. */ |
| 155 | just_migrated: boolean; |
| 156 | } |
| 157 | |
| 158 | /** Bootstrap data localized by BuilderPanel.php. */ |
| 159 | export interface BootstrapSettings { |
| 160 | restBase: string; |
| 161 | formId: number; |
| 162 | formTitle: string; |
| 163 | previewUrl: string; |
| 164 | frontendCssUrl: string; |
| 165 | wrapperId: string; |
| 166 | markerClass: string; |
| 167 | /** Per-page-load token scoping the live-preview draft to this builder session. */ |
| 168 | previewSession: string; |
| 169 | /** Whether the ThemeGrill AI Cloud integration is present on this site; drives the AI launcher. */ |
| 170 | aiEnabled: boolean; |
| 171 | /** True on local/staging where the gateway is unreachable — the launcher shows but is greyed out. */ |
| 172 | aiDisabled?: boolean; |
| 173 | /** admin-ajax.php URL, used for the discovery-hint dismissal call. */ |
| 174 | ajaxUrl: string; |
| 175 | /** Nonce for the shared `evf_ai_dismiss_hint` AJAX action (see EVF_AI_Ajax::dismiss_hint()). */ |
| 176 | aiNonce: string; |
| 177 | /** Whether this user has already dismissed (or engaged with) the "Style with AI" discovery hint. */ |
| 178 | aiHintDismissed: boolean; |
| 179 | /** The full REST GET payload, localized inline so the panel can init without a network round-trip. */ |
| 180 | payload?: StylePayload; |
| 181 | } |
| 182 |