-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathindex.ts
More file actions
1538 lines (1360 loc) · 47.4 KB
/
index.ts
File metadata and controls
1538 lines (1360 loc) · 47.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Ycode Type Definitions
*
* Core types for pages, layers, and editor functionality
*/
// UI State Types (for state-specific styling: hover, focus, etc.)
export type UIState = 'neutral' | 'hover' | 'focus' | 'active' | 'disabled' | 'current';
export type Breakpoint = 'mobile' | 'tablet' | 'desktop';
export type StringAssetId = string;
// Design Property Interfaces
export interface LayoutDesign {
isActive?: boolean;
display?: string;
flexDirection?: string;
flexWrap?: string;
justifyContent?: string;
alignItems?: string;
gap?: string;
columnGap?: string;
rowGap?: string;
gapMode?: 'all' | 'individual'; // User's toggle preference for gap
gridTemplateColumns?: string;
gridTemplateRows?: string;
}
export interface TypographyDesign {
isActive?: boolean;
fontSize?: string;
fontWeight?: string;
fontFamily?: string;
fontStyle?: string;
lineHeight?: string;
letterSpacing?: string;
textAlign?: string;
textTransform?: string;
textDecoration?: string;
textDecorationColor?: string;
textDecorationThickness?: string;
underlineOffset?: string;
verticalAlign?: string;
color?: string;
placeholderColor?: string;
}
export interface SpacingDesign {
isActive?: boolean;
margin?: string;
marginTop?: string;
marginRight?: string;
marginBottom?: string;
marginLeft?: string;
marginMode?: 'all' | 'individual'; // User's toggle preference for margin
padding?: string;
paddingTop?: string;
paddingRight?: string;
paddingBottom?: string;
paddingLeft?: string;
paddingMode?: 'all' | 'individual'; // User's toggle preference for padding
}
export interface SizingDesign {
isActive?: boolean;
width?: string;
height?: string;
minWidth?: string;
minHeight?: string;
maxWidth?: string;
maxHeight?: string;
overflow?: string;
aspectRatio?: string | null;
objectFit?: string | null;
gridColumnSpan?: string | null;
gridRowSpan?: string | null;
}
export interface BordersDesign {
isActive?: boolean;
borderWidth?: string;
borderTopWidth?: string;
borderRightWidth?: string;
borderBottomWidth?: string;
borderLeftWidth?: string;
borderWidthMode?: 'all' | 'individual'; // User's toggle preference for border width
borderStyle?: string;
borderColor?: string;
borderRadius?: string;
borderTopLeftRadius?: string;
borderTopRightRadius?: string;
borderBottomLeftRadius?: string;
borderBottomRightRadius?: string;
borderRadiusMode?: 'all' | 'individual'; // User's toggle preference for border radius
divideX?: string;
divideY?: string;
divideStyle?: string;
divideColor?: string;
outlineWidth?: string;
outlineColor?: string;
outlineOffset?: string;
}
export interface BackgroundsDesign {
isActive?: boolean;
backgroundColor?: string;
backgroundImage?: string;
backgroundSize?: string;
backgroundPosition?: string;
backgroundRepeat?: string;
backgroundClip?: string;
/** CSS variable values for background image per breakpoint/state, e.g. { '--bg-img': 'url(...)' } */
bgImageVars?: Record<string, string>;
/** CSS variable values for background gradient per breakpoint/state, e.g. { '--bg-img': 'linear-gradient(...)' } */
bgGradientVars?: Record<string, string>;
}
export interface EffectsDesign {
isActive?: boolean;
opacity?: string;
boxShadow?: string;
blur?: string;
backdropBlur?: string;
filter?: string;
backdropFilter?: string;
}
export interface PositioningDesign {
isActive?: boolean;
position?: string;
top?: string;
right?: string;
bottom?: string;
left?: string;
zIndex?: string;
}
export interface DesignProperties {
layout?: LayoutDesign;
typography?: TypographyDesign;
spacing?: SpacingDesign;
sizing?: SizingDesign;
borders?: BordersDesign;
backgrounds?: BackgroundsDesign;
effects?: EffectsDesign;
positioning?: PositioningDesign;
}
export interface FormSettings {
success_action?: 'message' | 'redirect'; // What happens on successful submission (default: 'message')
success_message?: string; // Message shown on successful submission (deprecated - now uses alert child)
error_message?: string; // Message shown on failed submission (deprecated - now uses alert child)
redirect_url?: LinkSettingsValue; // Link settings for redirect after successful submission
email_notification?: {
enabled: boolean;
to: string; // Email address to send notifications to
subject?: string; // Email subject line
};
}
export type SwiperAnimationEffect = 'slide' | 'fade' | 'cube' | 'flip' | 'coverflow' | 'cards';
export type SliderLoopMode = 'none' | 'loop' | 'rewind';
export type SliderPaginationType = 'bullets' | 'fraction';
export type LightboxOverlay = 'light' | 'dark';
export type LightboxFilesSource = 'files' | 'cms';
export interface LightboxSettings {
files: string[]; // Asset IDs or external URLs (used when filesSource is 'files')
filesSource: LightboxFilesSource; // Whether files come from manual selection or a CMS field
filesField?: FieldVariable | null; // CMS field binding for dynamic images (used when filesSource is 'cms')
thumbnails: boolean;
navigation: boolean;
pagination: boolean;
zoom: boolean; // Pinch-to-zoom on touch devices
doubleTapZoom: boolean; // Double-tap/click to zoom
mousewheel: boolean; // Navigate slides with scroll wheel
overlay: LightboxOverlay;
groupId: string; // Links multiple lightboxes into one shared gallery
animationEffect: SwiperAnimationEffect;
easing: string;
duration: string; // Transition duration in seconds
}
export interface SliderSettings {
navigation: boolean;
groupSlide: number;
slidesPerGroup: number;
loop: SliderLoopMode;
centered: boolean;
touchEvents: boolean;
slideToClicked: boolean;
mousewheel: boolean;
pagination: boolean;
paginationType: SliderPaginationType;
paginationClickable: boolean;
autoplay: boolean;
pauseOnHover: boolean;
delay: string; // Autoplay delay in seconds
animationEffect: SwiperAnimationEffect;
easing: string;
duration: string; // Transition duration in seconds
}
export interface LayerSettings {
id?: string; // Custom element ID
tag?: string; // HTML tag override (e.g., 'h1', 'h2', etc.)
hidden?: boolean; // Element visibility in canvas
customAttributes?: Record<string, string>; // Custom HTML attributes { attributeName: attributeValue }
locale?: {
format?: 'locale' | 'code'; // Display format for `localeSelector` layers (locale => 'English', code => 'EN')
};
htmlEmbed?: {
code?: string; // Custom HTML code to embed
};
slider?: SliderSettings; // Slider-specific settings (only for slider layers)
lightbox?: LightboxSettings; // Lightbox-specific settings (only for lightbox layers)
form?: FormSettings; // Form-specific settings (only for form layers)
filterOnChange?: boolean; // For filter layers: trigger filtering on every input change (debounced)
optionsSource?: {
collectionId: string;
defaultItemId?: string; // item ID to pre-select as default (select elements)
defaultItemIds?: string[]; // item IDs to pre-check as defaults (checkbox groups)
sortFieldId?: string; // field ID to sort options by (undefined = manual/insertion order)
sortOrder?: 'asc' | 'desc'; // sort direction (defaults to 'asc')
};
selectOptionsMode?: 'list' | 'sort_by' | 'sort_order'; // Builder source mode for select options
sortByCollectionId?: string; // Collection to source sort-by field options from
sortByFieldIds?: string[]; // Which field IDs are enabled as sort-by options
isPlaceholder?: boolean; // Marks an <option> child as a placeholder (disabled, hidden, selected)
map?: MapSettings; // Map-specific settings (only for map layers)
}
export type MapProvider = 'mapbox' | 'google';
export type MapStyle = 'streets' | 'satellite' | 'light' | 'dark' | 'outdoors';
export type GoogleMapStyle = 'roadmap' | 'satellite';
export interface MapProviderSettings {
style: string;
interactive: boolean;
scrollZoom: boolean;
showNavControl: boolean;
showScaleBar: boolean;
}
export interface MapSettings {
provider: MapProvider;
latitude: number;
longitude: number;
zoom: number;
markerColor: string | null;
search?: string;
mapbox: MapProviderSettings;
google: MapProviderSettings;
}
// Layer Style Types
export interface LayerStyle {
id: string;
name: string;
group?: string; // Element category (e.g. "text", "block", "button") for scoped filtering
// Style data
classes: string;
design?: DesignProperties;
// Versioning fields
content_hash?: string; // SHA-256 hash for change detection
is_published: boolean;
created_at: string;
updated_at: string;
deleted_at?: string | null; // Soft delete for undo/redo support
}
export interface LayerInteraction {
id: string;
trigger: 'click' | 'hover' | 'scroll-into-view' | 'while-scrolling' | 'load';
timeline: InteractionTimeline;
tweens: InteractionTween[];
}
export interface InteractionTimeline {
breakpoints: Breakpoint[];
repeat: number; // -1 = infinite, 0 = none, n = repeat n times
yoyo: boolean; // reverse direction on each repeat
scrollStart?: string; // e.g., 'top 80%', 'top center' - when trigger enters viewport
scrollEnd?: string; // e.g., 'bottom top' - when trigger leaves viewport (while-scrolling only)
scrub?: boolean | number; // while-scrolling: true for direct link, number for smoothing (seconds)
toggleActions?: string; // scroll-into-view: GSAP toggleActions (e.g., 'play none none none')
}
export interface InteractionTween {
id: string;
layer_id: string;
position: number | string; // GSAP position: number (seconds), ">" (after previous), "<" (with previous)
duration: number; // seconds
ease: string; // GSAP ease (e.g., 'power1.out', 'elastic.inOut')
from: TweenProperties;
to: TweenProperties;
apply_styles: InteractionApplyStyles;
splitText?: {
type: 'chars' | 'words' | 'lines';
stagger: { amount: number }; // GSAP stagger: { amount: totalTime }
};
}
export type ApplyStyles = 'on-load' | 'on-trigger';
export type TweenPropertyKey = 'x' | 'y' | 'rotation' | 'scale' | 'skewX' | 'skewY' | 'autoAlpha' | 'display';
export type InteractionApplyStyles = Record<TweenPropertyKey, ApplyStyles>;
export type TweenProperties = {
[K in TweenPropertyKey]?: string | null;
};
export interface TextStyle {
label?: string; // Display label for the style (e.g., "Bold", "Italic")
classes?: string;
design?: DesignProperties;
styleId?: string; // Layer style applied to this text style
styleOverrides?: { classes?: string; design?: DesignProperties };
}
export interface Layer {
id: string;
key?: string; // Optional internal ID for the layer (i.e. "localeSelectorLabel")
name: string; // Element type name: 'div', 'section', 'text', etc.
customName?: string; // User-defined name for display in the UI
// Restrictions (for layer actions)
restrictions?: {
copy?: boolean; // Whether the layer can be copied / duplicated
delete?: boolean; // Whether the layer can be deleted
ancestor?: string; // The ancestor `layer.name` that the layer should be a child of
editText?: boolean; // Whether the layer text contents can be edited
};
classes: string | string[]; // Tailwind CSS classes (support arrays and strings)
// Text styles object, e.g. `{ bold: { classes: 'font-bold', design: { typography: { fontWeight: 'bold' } } }, ... }`
textStyles?: Record<string, TextStyle>;
// Children
children?: Layer[];
// Special properties
open?: boolean; // Collapsed/expanded state in tree
hidden?: boolean;
hiddenGenerated?: boolean; // Hidden by default, shown via form actions (for alerts)
alertType?: 'success' | 'error'; // Type of alert (for form success/error messages)
// Attributes (for HTML elements)
attributes?: Record<string, any> & {
id?: string; // Custom HTML ID attribute
// Media element attributes (video/audio)
muted?: boolean;
controls?: boolean;
loop?: boolean;
autoplay?: boolean;
volume?: string; // Volume as string (0-100)
preload?: string; // 'none' | 'metadata' | 'auto'
youtubePrivacyMode?: boolean; // Privacy-enhanced mode (uses youtube-nocookie.com)
};
// Design system (structured properties)
design?: DesignProperties;
// Settings (element-specific configuration)
settings?: LayerSettings;
// Layer Styles (reusable design system)
styleId?: string; // Reference to applied LayerStyle
styleOverrides?: {
classes?: string;
design?: DesignProperties;
}; // Tracks local changes after style applied
// Components (reusable layer trees)
componentId?: string; // Reference to applied Component
componentOverrides?: {
text?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (text)
rich_text?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (rich text)
image?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (image)
link?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (link)
audio?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (audio)
video?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (video)
icon?: Record<string, ComponentVariableValue>; // ComponentVariable.id → override value (icon)
variableLinks?: Record<string, string>; // childVariableId → parentVariableId (pass-through from nested component to parent)
};
// Layer variables (layer collection data & dynamic data for texts, assets, links)
variables?: LayerVariables;
// Interactions / Animations (new structured approach)
interactions?: LayerInteraction[];
// SSR-only property for resolved collection items
_collectionItems?: CollectionItemWithValues[];
// SSR-only property for collection item values (used for visibility filtering)
_collectionItemValues?: Record<string, string>;
// SSR-only property for collection item ID (used for link URL building)
_collectionItemId?: string;
// SSR-only property for collection item slug (used for link URL building)
_collectionItemSlug?: string;
// SSR-only property for layer-specific collection data (layer_id -> field values map)
_layerDataMap?: Record<string, Record<string, string>>;
// SSR-only property for master component ID (for translation lookups)
_masterComponentId?: string;
// SSR-only property for original layer ID before instance-specific ID transform (for translation lookups)
_originalLayerId?: string;
// SSR-only property for pagination metadata (when pagination is enabled)
_paginationMeta?: CollectionPaginationMeta;
// SSR-only property for dynamic inline styles from CMS color field bindings
_dynamicStyles?: Record<string, string>;
// SSR-only property for filterable collection config (when collection has linked filter inputs)
_filterConfig?: {
collectionId: string;
collectionLayerId: string;
filters: ConditionalVisibility;
sortBy?: string;
sortOrder?: 'asc' | 'desc';
sortByInputLayerId?: string;
sortOrderInputLayerId?: string;
limit?: number;
paginationMode?: 'pages' | 'load_more';
layerTemplate: Layer[];
collectionLayerClasses?: string[];
collectionLayerTag?: string;
isPublished?: boolean;
};
}
export interface LayerVariables {
// Collection data
collection?: CollectionVariable;
conditionalVisibility?: ConditionalVisibility;
// Variables by type
text?: DynamicTextVariable | DynamicRichTextVariable;
icon?: {
src?: AssetVariable | StaticTextVariable; // Static Asset ID | Static Text (SVG code, internal use only)
};
image?: {
src: AssetVariable | FieldVariable | DynamicTextVariable; // Static Asset ID | Field Variable | Dynamic Text (URL that allows inline variables)
alt: DynamicTextVariable; // Image alt text with inline variables
};
audio?: {
src: AssetVariable | FieldVariable | DynamicTextVariable; // Static Asset ID | Field Variable | Dynamic Text (URL that allows inline variables)
};
video?: {
src?: AssetVariable | VideoVariable | FieldVariable | DynamicTextVariable; // Static Asset ID | Video provider + ID (YouTube) | Field Variable | Dynamic Text (URL that allows inline variables)
poster?: AssetVariable | FieldVariable; // Poster image (asset or field variable)
};
iframe?: {
src: DynamicTextVariable; // Embed URL (allow inline variables)
};
backgroundImage?: {
src: AssetVariable | FieldVariable | DynamicTextVariable; // Static Asset ID | Field Variable | Dynamic Text (URL)
};
link?: LinkSettings;
// Design property bindings (CMS color fields)
design?: {
backgroundColor?: DesignColorVariable;
color?: DesignColorVariable; // text color
borderColor?: DesignColorVariable;
divideColor?: DesignColorVariable;
outlineColor?: DesignColorVariable;
textDecorationColor?: DesignColorVariable;
placeholderColor?: DesignColorVariable;
};
}
/** A gradient stop with optional CMS field binding */
export interface BoundColorStop {
id: string;
position: number;
color: string; // static fallback color
field?: FieldVariable; // optional CMS binding for this stop
}
/** Design color variable supporting solid and gradient CMS bindings.
* Each mode's state is stored separately so switching tabs preserves bindings. */
export interface DesignColorVariable {
type: 'color';
mode: 'solid' | 'linear' | 'radial';
/** Solid mode: the CMS field binding */
field?: FieldVariable;
/** Linear gradient state (preserved across tab switches) */
linear?: { angle?: number; stops?: BoundColorStop[] };
/** Radial gradient state (preserved across tab switches) */
radial?: { stops?: BoundColorStop[] };
}
// Link type discriminator
export type LinkType = 'url' | 'email' | 'phone' | 'asset' | 'page' | 'field';
// Collection link field types (simplified for CMS fields)
export type CollectionLinkType = 'url' | 'page';
// Collection Link Field Value (stored as JSON in collection item values)
// Note: Link behavior (target, rel) is set on the layer, not in the CMS value
export interface CollectionLinkValue {
type: CollectionLinkType;
// URL link - simple string URL
url?: string;
// Page link - link to a page (static or dynamic with static item)
page?: {
id: string; // Page ID
collection_item_id?: string | null; // Static collection item ID (no current-page/current-collection)
anchor_layer_id?: string | null; // Optional layer ID for anchor links
};
}
// Reusable link settings structure
export interface LinkSettings {
type: LinkType;
// URL link - custom URL with inline variables support
url?: DynamicTextVariable;
// Email link - mailto:address (supports inline variables)
email?: DynamicTextVariable;
// Phone link - tel:number (supports inline variables)
phone?: DynamicTextVariable;
// Asset link - link to downloadable asset
asset?: {
id: StringAssetId | null;
};
// Page link - link to a page (static or dynamic)
page?: {
id: string; // Page ID (static or dynamic)
collection_item_id?: string | null; // Collection item ID (for dynamic pages)
};
// Field link - href from collection field (CMS field containing URL)
field?: FieldVariable;
// Anchor - reference to a layer ID to use as #anchor
anchor_layer_id?: string | null;
// Link behavior
target?: '_blank' | '_self' | '_parent' | '_top';
download?: boolean; // Force download the linked resource
rel?: string; // 'noopener noreferrer' | 'nofollow' | 'sponsored' | 'ugc'
}
// Essentially a layer without ID (that can have children without IDs)
// Optional id is allowed for templates with animations that reference specific layers
export interface LayerTemplate extends Omit<Layer, 'id' | 'children'> {
id?: string; // Optional: used when animations reference specific layers
children?: Array<LayerTemplate | LayerTemplateRef>;
// Inlined component metadata (for portable layouts)
_inlinedComponentName?: string; // Component name when inlined for portability
_inlinedComponentVariables?: ComponentVariable[]; // Component variables when inlined
}
// Template reference marker (lazy reference resolved during template instantiation)
export type LayerTemplateRef = { __ref: string } & Partial<Omit<LayerTemplate, 'children'>> & {
children?: Array<LayerTemplate | LayerTemplateRef>;
};
// Block template definition (used in template collections)
export interface BlockTemplate {
icon: string;
name: string;
template: LayerTemplate | LayerTemplateRef;
}
// Component Variable Types (ComponentVariableValue defined after text variable types)
export interface ComponentVariable {
id: string; // Unique variable ID
name: string; // Display name (e.g., "Button title")
type?: 'text' | 'rich_text' | 'image' | 'link' | 'audio' | 'video' | 'icon'; // Variable type (defaults to 'text' for backwards compatibility)
placeholder?: string; // Placeholder text shown in text override inputs
default_value?: ComponentVariableValue; // Default value
}
// Component Types (Reusable Layer Trees)
export interface Component {
id: string;
name: string;
// Component data - complete layer tree
layers: Layer[];
// Component variables - exposed properties for overrides
variables?: ComponentVariable[];
// Versioning fields
content_hash?: string; // SHA-256 hash for change detection
is_published: boolean;
// Auto-generated preview thumbnail URL (stored in Supabase Storage)
thumbnail_url?: string | null;
created_at: string;
updated_at: string;
deleted_at?: string | null; // Soft delete timestamp
}
export interface Page {
id: string;
slug: string;
name: string;
page_folder_id: string | null; // Reference to page_folders
order: number; // Sort order
depth: number; // Depth in hierarchy
is_index: boolean; // Index of the root or parent folder
is_dynamic: boolean; // Dynamic page (CMS-driven)
error_page: number | null; // Error page type: 401, 404, 500
settings: PageSettings; // Page settings (CMS, auth, seo, custom code)
content_hash?: string; // SHA-256 hash of page metadata for change detection
is_published: boolean;
created_at: string;
updated_at: string;
deleted_at: string | null; // Soft delete timestamp
}
export interface PageSettings {
cms?: {
collection_id: string;
slug_field_id: string;
};
auth?: {
enabled: boolean;
password: string;
};
seo?: {
image: StringAssetId | FieldVariable | null; // Asset ID or Field Variable (image field)
title: string;
description: string;
noindex: boolean; // Prevent search engines from indexing the page
};
custom_code?: {
head: string;
body: string;
};
}
export interface PageLayers {
id: string;
page_id: string;
layers: Layer[];
content_hash?: string; // SHA-256 hash of layers and CSS for change detection
is_published: boolean;
created_at: string;
updated_at?: string;
deleted_at: string | null; // Soft delete timestamp
generated_css?: string; // Extracted CSS from Play CDN for published pages
}
export interface PageFolderSettings {
auth?: {
enabled: boolean;
password: string;
};
}
export interface PageFolder {
id: string;
page_folder_id: string | null; // Self-referential: parent folder ID
name: string;
slug: string;
depth: number; // Folder depth in hierarchy (0 for root)
order: number; // Sort order within parent folder
settings: PageFolderSettings; // Settings for auth (enabled + password), etc.
is_published: boolean;
created_at: string;
updated_at: string;
deleted_at: string | null; // Soft delete timestamp
}
// Page/Folder Duplicate Operation Types
export interface PageItemDuplicateMetadata {
tempId: string;
originalName: string;
parentFolderId: string | null;
expectedName: string;
}
export interface PageItemDuplicateResult<T> {
success: boolean;
data?: T;
error?: string;
metadata?: PageItemDuplicateMetadata;
}
// Asset Types
/**
* Asset categories for validation
*/
export type AssetCategory = 'images' | 'videos' | 'audio' | 'documents' | 'icons';
/**
* Category filter for file manager - supports single, multiple, or all categories
*/
export type AssetCategoryFilter = AssetCategory | AssetCategory[] | 'all' | null;
/**
* Asset - Represents any uploaded file (images, videos, documents, etc.)
*
* The asset system is designed to handle any file type, not just images.
* - Images will have width/height dimensions
* - Non-images will have null width/height
* - Use mime_type to determine asset type (e.g., image/, video/, application/pdf)
*/
export interface Asset {
id: string;
filename: string;
storage_path: string | null; // Nullable for SVG icons with inline content
public_url: string | null; // Nullable for SVG icons with inline content
file_size: number;
mime_type: string;
width?: number | null;
height?: number | null;
source: string; // Required: identifies where the asset was uploaded from
asset_folder_id?: string | null;
content?: string | null; // Inline SVG content for icon assets
content_hash?: string | null; // SHA-256 hash for change detection during publishing
is_published: boolean;
created_at: string;
updated_at: string;
deleted_at: string | null;
}
export interface AssetFolder {
id: string;
asset_folder_id: string | null;
name: string;
depth: number;
order: number;
is_published: boolean;
created_at: string;
updated_at: string;
deleted_at: string | null;
}
export interface CreateAssetFolderData {
id?: string;
name: string;
depth?: number;
order?: number;
is_published?: boolean;
asset_folder_id?: string | null;
}
export interface UpdateAssetFolderData {
name?: string;
depth?: number;
order?: number;
is_published?: boolean;
asset_folder_id?: string | null;
}
// Settings Types
export interface SiteSettings {
site_name: string;
site_description: string;
theme?: string;
logo_url?: string;
}
export interface Redirect {
id: string;
oldUrl: string; // Internal path only, e.g. "/about-us"
newUrl: string; // Internal path "/about" OR external URL "https://example.com"
type?: '301' | '302'; // Permanent vs temporary (default 301)
}
export type SmtpProvider = 'google' | 'microsoft365' | 'mailersend' | 'postmark' | 'sendgrid' | 'mailgun' | 'amazonses' | 'other';
export type EmailMode = 'ycode' | 'custom';
export interface EmailSettings {
enabled: boolean;
mode?: EmailMode;
provider: SmtpProvider;
smtpHost: string;
smtpPort: string;
smtpUser: string;
smtpPassword: string;
fromEmail: string;
fromName: string;
}
// Editor State Types
export interface EditorState {
selectedLayerId: string | null; // Legacy - kept for backward compatibility
selectedLayerIds: string[]; // New multi-select
lastSelectedLayerId: string | null; // For Shift+Click range
currentPageId: string | null;
isDragging: boolean;
isLoading: boolean;
isSaving: boolean;
activeBreakpoint: Breakpoint;
activeUIState: UIState; // Current UI state for editing (hover, focus, etc.)
}
// API Response Types
export interface ApiResponse<T> {
data?: T;
error?: string;
message?: string;
}
export interface PaginatedResponse<T> {
data: T[];
total: number;
page: number;
per_page: number;
}
// Supabase Config Types (for setup wizard)
export interface SupabaseConfig {
anonKey: string;
serviceRoleKey: string;
connectionUrl: string; // With [YOUR-PASSWORD] placeholder
dbPassword: string; // Actual password to replace [YOUR-PASSWORD]
}
// Internal credentials structure (derived from SupabaseConfig)
export interface SupabaseCredentials {
anonKey: string;
serviceRoleKey: string;
connectionUrl: string; // Original with placeholder
dbPassword: string;
// Derived properties
projectId: string;
projectUrl: string; // API URL: https://[PROJECT_ID].supabase.co
dbHost: string;
dbPort: number;
dbName: string;
dbUser: string;
}
// Vercel Config Types
export interface VercelConfig {
project_id: string;
token: string;
}
// Setup Wizard Types
export type SetupStep = 'welcome' | 'supabase' | 'migrate' | 'admin' | 'template' | 'complete';
export interface SetupState {
currentStep: SetupStep;
supabaseConfig?: SupabaseConfig;
vercelConfig?: VercelConfig;
adminEmail?: string;
isComplete: boolean;
}
// Auth Types
export interface AuthUser {
id: string;
email: string;
created_at: string;
updated_at: string;
}
export interface AuthSession {
access_token: string;
refresh_token: string;
expires_at: number;
user: AuthUser;
}
export interface AuthState {
user: AuthUser | null;
session: AuthSession | null;
loading: boolean;
initialized: boolean;
error: string | null;
}
// Collaboration Types
export interface CollaborationUser {
user_id: string;
email: string;
display_name: string;
avatar_url: string | null;
color: string;
cursor: { x: number; y: number } | null;
selected_layer_id: string | null;
locked_layer_id: string | null;
is_editing: boolean; // Typing/editing indicator
last_active: number;
page_id: string;
}
// Legacy type - use ResourceLock from useCollaborationPresenceStore instead
export interface LayerLock {
layer_id: string;
user_id: string;
acquired_at: number;
expires_at: number;
}
export interface LayerUpdate {
layer_id: string;
user_id: string;
changes: Partial<Layer>;
timestamp: number;
}
// Base collaboration state - extended in useCollaborationPresenceStore
export interface CollaborationState {
users: Record<string, CollaborationUser>;
isConnected: boolean;
currentUserId: string | null;
currentUserColor: string;
currentUserAvatarUrl: string | null;
}
export interface ActivityNotification {
id: string;
type: 'user_joined' | 'user_left' | 'layer_edit_started' | 'layer_edit_ended' | 'page_published' | 'user_idle' | 'page_created' | 'page_deleted';
user_id: string;
user_name: string;
layer_id?: string;
layer_name?: string;
page_id?: string;
timestamp: number;
message: string;
}
// Collection Types (EAV Architecture)
export type CollectionFieldType = 'text' | 'number' | 'boolean' | 'date' | 'date_only' | 'color' | 'reference' | 'multi_reference' | 'rich_text' | 'image' | 'audio' | 'video' | 'document' | 'link' | 'email' | 'phone' | 'status';
export type CollectionSortDirection = 'asc' | 'desc' | 'manual';
export interface CollectionSorting {
field: string; // field ID or 'manual_order'
direction: CollectionSortDirection;
}
export interface Collection {
id: string; // UUID
name: string;
uuid: string;
created_at: string;
updated_at: string;
deleted_at: string | null;
sorting: CollectionSorting | null;
order: number;
is_published: boolean;
draft_items_count?: number;
has_published_version?: boolean;
}
export interface CreateCollectionData {
name: string;
sorting?: CollectionSorting | null;
order?: number;
is_published?: boolean;
}
export interface UpdateCollectionData {
name?: string;
sorting?: CollectionSorting | null;
order?: number;
}
/** Field-specific settings stored in the data column */
export interface CollectionFieldData {
multiple?: boolean; // For asset fields - allow multiple files
}
export interface CreateCollectionFieldData {
name: string;
key?: string | null;
type: CollectionFieldType;
default?: string | null;
fillable?: boolean;
order: number;
collection_id: string; // UUID
reference_collection_id?: string | null; // UUID
hidden?: boolean;
is_computed?: boolean;
data?: CollectionFieldData;
is_published?: boolean;
}
export interface UpdateCollectionFieldData {
name?: string;
key?: string | null;
type?: CollectionFieldType;
default?: string | null;
fillable?: boolean;
order?: number;
reference_collection_id?: string | null; // UUID
hidden?: boolean;
data?: CollectionFieldData;