@contentful/experiences-components-react 1.22.1-dev-20241111T0918-dbe183a.0 → 1.23.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -2
- package/dist/index.js +1034 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,20 +2,24 @@ import React, { forwardRef } from 'react';
|
|
|
2
2
|
import styleInject from 'style-inject';
|
|
3
3
|
import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
|
|
4
4
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
5
|
+
import 'md5';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import 'lodash-es';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* These modes are ONLY intended to be internally used within the context of
|
|
8
11
|
* editing an experience inside of Contentful Studio. i.e. these modes
|
|
9
12
|
* intentionally do not include preview/delivery modes.
|
|
10
13
|
*/
|
|
11
|
-
var StudioCanvasMode;
|
|
14
|
+
var StudioCanvasMode$1;
|
|
12
15
|
(function (StudioCanvasMode) {
|
|
13
16
|
StudioCanvasMode["READ_ONLY"] = "readOnlyMode";
|
|
14
17
|
StudioCanvasMode["EDITOR"] = "editorMode";
|
|
15
18
|
StudioCanvasMode["NONE"] = "none";
|
|
16
|
-
})(StudioCanvasMode || (StudioCanvasMode = {}));
|
|
19
|
+
})(StudioCanvasMode$1 || (StudioCanvasMode$1 = {}));
|
|
20
|
+
const CONTENTFUL_COMPONENT_CATEGORY = 'contentful-component';
|
|
17
21
|
const CONTENTFUL_DEFAULT_CATEGORY = 'Contentful';
|
|
18
|
-
const CONTENTFUL_COMPONENTS = {
|
|
22
|
+
const CONTENTFUL_COMPONENTS$1 = {
|
|
19
23
|
section: {
|
|
20
24
|
id: 'contentful-section',
|
|
21
25
|
name: 'Section',
|
|
@@ -56,12 +60,16 @@ const CONTENTFUL_COMPONENTS = {
|
|
|
56
60
|
id: 'contentful-divider',
|
|
57
61
|
name: 'Divider',
|
|
58
62
|
},
|
|
63
|
+
carousel: {
|
|
64
|
+
id: 'contentful-carousel',
|
|
65
|
+
name: 'Carousel',
|
|
66
|
+
},
|
|
59
67
|
};
|
|
60
|
-
var PostMessageMethods;
|
|
68
|
+
var PostMessageMethods$1;
|
|
61
69
|
(function (PostMessageMethods) {
|
|
62
70
|
PostMessageMethods["REQUEST_ENTITIES"] = "REQUEST_ENTITIES";
|
|
63
71
|
PostMessageMethods["REQUESTED_ENTITIES"] = "REQUESTED_ENTITIES";
|
|
64
|
-
})(PostMessageMethods || (PostMessageMethods = {}));
|
|
72
|
+
})(PostMessageMethods$1 || (PostMessageMethods$1 = {}));
|
|
65
73
|
|
|
66
74
|
function combineClasses(...classes) {
|
|
67
75
|
return classes
|
|
@@ -88,8 +96,8 @@ const Button = ({ children, className, label, onClick, onNavigate, target, url,
|
|
|
88
96
|
};
|
|
89
97
|
|
|
90
98
|
const ButtonComponentDefinition = {
|
|
91
|
-
id: CONTENTFUL_COMPONENTS.button.id,
|
|
92
|
-
name: CONTENTFUL_COMPONENTS.button.name,
|
|
99
|
+
id: CONTENTFUL_COMPONENTS$1.button.id,
|
|
100
|
+
name: CONTENTFUL_COMPONENTS$1.button.name,
|
|
93
101
|
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
94
102
|
builtInStyles: [
|
|
95
103
|
'cfMargin',
|
|
@@ -189,8 +197,8 @@ const Heading = ({ children, className, text, type = 'h1', ...props }) => {
|
|
|
189
197
|
};
|
|
190
198
|
|
|
191
199
|
const HeadingComponentDefinition = {
|
|
192
|
-
id: CONTENTFUL_COMPONENTS.heading.id,
|
|
193
|
-
name: CONTENTFUL_COMPONENTS.heading.name,
|
|
200
|
+
id: CONTENTFUL_COMPONENTS$1.heading.id,
|
|
201
|
+
name: CONTENTFUL_COMPONENTS$1.heading.name,
|
|
194
202
|
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
195
203
|
builtInStyles: [
|
|
196
204
|
'cfMargin',
|
|
@@ -280,8 +288,8 @@ const RichText = ({ as = 'p', className, value, ...props }) => {
|
|
|
280
288
|
};
|
|
281
289
|
|
|
282
290
|
const RichTextComponentDefinition = {
|
|
283
|
-
id: CONTENTFUL_COMPONENTS.richText.id,
|
|
284
|
-
name: CONTENTFUL_COMPONENTS.richText.name,
|
|
291
|
+
id: CONTENTFUL_COMPONENTS$1.richText.id,
|
|
292
|
+
name: CONTENTFUL_COMPONENTS$1.richText.name,
|
|
285
293
|
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
286
294
|
builtInStyles: [
|
|
287
295
|
'cfMargin',
|
|
@@ -374,8 +382,8 @@ const Text = ({ as = 'p', children, className, value, url, target, onNavigate, o
|
|
|
374
382
|
};
|
|
375
383
|
|
|
376
384
|
const TextComponentDefinition = {
|
|
377
|
-
id: CONTENTFUL_COMPONENTS.text.id,
|
|
378
|
-
name: CONTENTFUL_COMPONENTS.text.name,
|
|
385
|
+
id: CONTENTFUL_COMPONENTS$1.text.id,
|
|
386
|
+
name: CONTENTFUL_COMPONENTS$1.text.name,
|
|
379
387
|
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
380
388
|
builtInStyles: [
|
|
381
389
|
'cfMargin',
|
|
@@ -467,8 +475,8 @@ const Image = ({ className = '', src, cfImageAsset, ...props }) => {
|
|
|
467
475
|
};
|
|
468
476
|
|
|
469
477
|
const ImageComponentDefinition = {
|
|
470
|
-
id: CONTENTFUL_COMPONENTS.image.id,
|
|
471
|
-
name: CONTENTFUL_COMPONENTS.image.name,
|
|
478
|
+
id: CONTENTFUL_COMPONENTS$1.image.id,
|
|
479
|
+
name: CONTENTFUL_COMPONENTS$1.image.name,
|
|
472
480
|
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
473
481
|
builtInStyles: ['cfMargin', 'cfPadding', 'cfImageAsset', 'cfImageOptions', 'cfBorderRadius'],
|
|
474
482
|
tooltip: {
|
|
@@ -483,6 +491,940 @@ const ImageComponentDefinition = {
|
|
|
483
491
|
},
|
|
484
492
|
};
|
|
485
493
|
|
|
494
|
+
/**
|
|
495
|
+
* These modes are ONLY intended to be internally used within the context of
|
|
496
|
+
* editing an experience inside of Contentful Studio. i.e. these modes
|
|
497
|
+
* intentionally do not include preview/delivery modes.
|
|
498
|
+
*/
|
|
499
|
+
var StudioCanvasMode;
|
|
500
|
+
(function (StudioCanvasMode) {
|
|
501
|
+
StudioCanvasMode["READ_ONLY"] = "readOnlyMode";
|
|
502
|
+
StudioCanvasMode["EDITOR"] = "editorMode";
|
|
503
|
+
StudioCanvasMode["NONE"] = "none";
|
|
504
|
+
})(StudioCanvasMode || (StudioCanvasMode = {}));
|
|
505
|
+
const CONTENTFUL_COMPONENTS = {
|
|
506
|
+
section: {
|
|
507
|
+
id: 'contentful-section',
|
|
508
|
+
name: 'Section',
|
|
509
|
+
},
|
|
510
|
+
container: {
|
|
511
|
+
id: 'contentful-container',
|
|
512
|
+
name: 'Container',
|
|
513
|
+
},
|
|
514
|
+
columns: {
|
|
515
|
+
id: 'contentful-columns',
|
|
516
|
+
name: 'Columns',
|
|
517
|
+
},
|
|
518
|
+
singleColumn: {
|
|
519
|
+
id: 'contentful-single-column',
|
|
520
|
+
name: 'Column',
|
|
521
|
+
},
|
|
522
|
+
button: {
|
|
523
|
+
id: 'contentful-button',
|
|
524
|
+
name: 'Button',
|
|
525
|
+
},
|
|
526
|
+
heading: {
|
|
527
|
+
id: 'contentful-heading',
|
|
528
|
+
name: 'Heading',
|
|
529
|
+
},
|
|
530
|
+
image: {
|
|
531
|
+
id: 'contentful-image',
|
|
532
|
+
name: 'Image',
|
|
533
|
+
},
|
|
534
|
+
richText: {
|
|
535
|
+
id: 'contentful-richText',
|
|
536
|
+
name: 'Rich Text',
|
|
537
|
+
},
|
|
538
|
+
text: {
|
|
539
|
+
id: 'contentful-text',
|
|
540
|
+
name: 'Text',
|
|
541
|
+
},
|
|
542
|
+
divider: {
|
|
543
|
+
id: 'contentful-divider',
|
|
544
|
+
name: 'Divider',
|
|
545
|
+
},
|
|
546
|
+
carousel: {
|
|
547
|
+
id: 'contentful-carousel',
|
|
548
|
+
name: 'Carousel',
|
|
549
|
+
},
|
|
550
|
+
};
|
|
551
|
+
const DEFAULT_IMAGE_WIDTH = '500px';
|
|
552
|
+
var PostMessageMethods;
|
|
553
|
+
(function (PostMessageMethods) {
|
|
554
|
+
PostMessageMethods["REQUEST_ENTITIES"] = "REQUEST_ENTITIES";
|
|
555
|
+
PostMessageMethods["REQUESTED_ENTITIES"] = "REQUESTED_ENTITIES";
|
|
556
|
+
})(PostMessageMethods || (PostMessageMethods = {}));
|
|
557
|
+
new Set(Object.values(CONTENTFUL_COMPONENTS).map((component) => component.id));
|
|
558
|
+
|
|
559
|
+
// These styles get added to every component, user custom or contentful provided
|
|
560
|
+
const builtInStyles = {
|
|
561
|
+
cfVerticalAlignment: {
|
|
562
|
+
validations: {
|
|
563
|
+
in: [
|
|
564
|
+
{
|
|
565
|
+
value: 'start',
|
|
566
|
+
displayName: 'Align left',
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
value: 'center',
|
|
570
|
+
displayName: 'Align center',
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
value: 'end',
|
|
574
|
+
displayName: 'Align right',
|
|
575
|
+
},
|
|
576
|
+
],
|
|
577
|
+
},
|
|
578
|
+
type: 'Text',
|
|
579
|
+
group: 'style',
|
|
580
|
+
description: 'The horizontal alignment of the section',
|
|
581
|
+
defaultValue: 'center',
|
|
582
|
+
displayName: 'Vertical alignment',
|
|
583
|
+
},
|
|
584
|
+
cfHorizontalAlignment: {
|
|
585
|
+
validations: {
|
|
586
|
+
in: [
|
|
587
|
+
{
|
|
588
|
+
value: 'start',
|
|
589
|
+
displayName: 'Align top',
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
value: 'center',
|
|
593
|
+
displayName: 'Align center',
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
value: 'end',
|
|
597
|
+
displayName: 'Align bottom',
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
},
|
|
601
|
+
type: 'Text',
|
|
602
|
+
group: 'style',
|
|
603
|
+
description: 'The horizontal alignment of the section',
|
|
604
|
+
defaultValue: 'center',
|
|
605
|
+
displayName: 'Horizontal alignment',
|
|
606
|
+
},
|
|
607
|
+
cfVisibility: {
|
|
608
|
+
displayName: 'Visibility toggle',
|
|
609
|
+
type: 'Boolean',
|
|
610
|
+
group: 'style',
|
|
611
|
+
defaultValue: true,
|
|
612
|
+
description: 'The visibility of the component',
|
|
613
|
+
},
|
|
614
|
+
cfMargin: {
|
|
615
|
+
displayName: 'Margin',
|
|
616
|
+
type: 'Text',
|
|
617
|
+
group: 'style',
|
|
618
|
+
description: 'The margin of the section',
|
|
619
|
+
defaultValue: '0 0 0 0',
|
|
620
|
+
},
|
|
621
|
+
cfPadding: {
|
|
622
|
+
displayName: 'Padding',
|
|
623
|
+
type: 'Text',
|
|
624
|
+
group: 'style',
|
|
625
|
+
description: 'The padding of the section',
|
|
626
|
+
defaultValue: '0 0 0 0',
|
|
627
|
+
},
|
|
628
|
+
cfBackgroundColor: {
|
|
629
|
+
displayName: 'Background color',
|
|
630
|
+
type: 'Text',
|
|
631
|
+
group: 'style',
|
|
632
|
+
description: 'The background color of the section',
|
|
633
|
+
defaultValue: 'rgba(0, 0, 0, 0)',
|
|
634
|
+
},
|
|
635
|
+
cfWidth: {
|
|
636
|
+
displayName: 'Width',
|
|
637
|
+
type: 'Text',
|
|
638
|
+
group: 'style',
|
|
639
|
+
description: 'The width of the section',
|
|
640
|
+
defaultValue: '100%',
|
|
641
|
+
},
|
|
642
|
+
cfHeight: {
|
|
643
|
+
displayName: 'Height',
|
|
644
|
+
type: 'Text',
|
|
645
|
+
group: 'style',
|
|
646
|
+
description: 'The height of the section',
|
|
647
|
+
defaultValue: 'fit-content',
|
|
648
|
+
},
|
|
649
|
+
cfMaxWidth: {
|
|
650
|
+
displayName: 'Max width',
|
|
651
|
+
type: 'Text',
|
|
652
|
+
group: 'style',
|
|
653
|
+
description: 'The max-width of the section',
|
|
654
|
+
defaultValue: 'none',
|
|
655
|
+
},
|
|
656
|
+
cfFlexDirection: {
|
|
657
|
+
displayName: 'Direction',
|
|
658
|
+
type: 'Text',
|
|
659
|
+
group: 'style',
|
|
660
|
+
description: 'The orientation of the section',
|
|
661
|
+
defaultValue: 'column',
|
|
662
|
+
},
|
|
663
|
+
cfFlexReverse: {
|
|
664
|
+
displayName: 'Reverse Direction',
|
|
665
|
+
type: 'Boolean',
|
|
666
|
+
group: 'style',
|
|
667
|
+
description: 'Toggle the flex direction to be reversed',
|
|
668
|
+
defaultValue: false,
|
|
669
|
+
},
|
|
670
|
+
cfFlexWrap: {
|
|
671
|
+
displayName: 'Wrap objects',
|
|
672
|
+
type: 'Text',
|
|
673
|
+
group: 'style',
|
|
674
|
+
description: 'Wrap objects',
|
|
675
|
+
defaultValue: 'nowrap',
|
|
676
|
+
},
|
|
677
|
+
cfBorder: {
|
|
678
|
+
displayName: 'Border',
|
|
679
|
+
type: 'Text',
|
|
680
|
+
group: 'style',
|
|
681
|
+
description: 'The border of the section',
|
|
682
|
+
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
683
|
+
},
|
|
684
|
+
cfGap: {
|
|
685
|
+
displayName: 'Gap',
|
|
686
|
+
type: 'Text',
|
|
687
|
+
group: 'style',
|
|
688
|
+
description: 'The spacing between the elements of the section',
|
|
689
|
+
defaultValue: '0px',
|
|
690
|
+
},
|
|
691
|
+
cfHyperlink: {
|
|
692
|
+
displayName: 'Hyperlink',
|
|
693
|
+
type: 'Hyperlink',
|
|
694
|
+
defaultValue: '',
|
|
695
|
+
validations: {
|
|
696
|
+
format: 'URL',
|
|
697
|
+
},
|
|
698
|
+
description: 'hyperlink for section or container',
|
|
699
|
+
},
|
|
700
|
+
cfOpenInNewTab: {
|
|
701
|
+
displayName: 'Hyperlink behaviour',
|
|
702
|
+
type: 'Boolean',
|
|
703
|
+
defaultValue: false,
|
|
704
|
+
description: 'Open in new tab',
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
const optionalBuiltInStyles = {
|
|
708
|
+
cfFontSize: {
|
|
709
|
+
displayName: 'Font Size',
|
|
710
|
+
type: 'Text',
|
|
711
|
+
group: 'style',
|
|
712
|
+
description: 'The font size of the element',
|
|
713
|
+
defaultValue: '16px',
|
|
714
|
+
},
|
|
715
|
+
cfFontWeight: {
|
|
716
|
+
validations: {
|
|
717
|
+
in: [
|
|
718
|
+
{
|
|
719
|
+
value: '400',
|
|
720
|
+
displayName: 'Normal',
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
value: '500',
|
|
724
|
+
displayName: 'Medium',
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
value: '600',
|
|
728
|
+
displayName: 'Semi Bold',
|
|
729
|
+
},
|
|
730
|
+
],
|
|
731
|
+
},
|
|
732
|
+
displayName: 'Font Weight',
|
|
733
|
+
type: 'Text',
|
|
734
|
+
group: 'style',
|
|
735
|
+
description: 'The font weight of the element',
|
|
736
|
+
defaultValue: '400',
|
|
737
|
+
},
|
|
738
|
+
cfImageAsset: {
|
|
739
|
+
displayName: 'Image',
|
|
740
|
+
type: 'Media',
|
|
741
|
+
description: 'Image to display',
|
|
742
|
+
},
|
|
743
|
+
cfImageOptions: {
|
|
744
|
+
displayName: 'Image options',
|
|
745
|
+
type: 'Object',
|
|
746
|
+
group: 'style',
|
|
747
|
+
defaultValue: {
|
|
748
|
+
width: DEFAULT_IMAGE_WIDTH,
|
|
749
|
+
height: '100%',
|
|
750
|
+
targetSize: DEFAULT_IMAGE_WIDTH,
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
cfBackgroundColor: {
|
|
754
|
+
displayName: 'Background color',
|
|
755
|
+
type: 'Text',
|
|
756
|
+
group: 'style',
|
|
757
|
+
description: 'The background color of the element',
|
|
758
|
+
defaultValue: 'rgba(0, 0, 0, 0)',
|
|
759
|
+
},
|
|
760
|
+
cfBackgroundImageUrl: {
|
|
761
|
+
displayName: 'Background image',
|
|
762
|
+
type: 'Media',
|
|
763
|
+
description: 'Background image for component',
|
|
764
|
+
},
|
|
765
|
+
cfBackgroundImageOptions: {
|
|
766
|
+
displayName: 'Background image options',
|
|
767
|
+
type: 'Object',
|
|
768
|
+
group: 'style',
|
|
769
|
+
defaultValue: {
|
|
770
|
+
scaling: 'fill',
|
|
771
|
+
alignment: 'left top',
|
|
772
|
+
targetSize: '2000px',
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
cfBorderRadius: {
|
|
776
|
+
displayName: 'Border Radius',
|
|
777
|
+
type: 'Text',
|
|
778
|
+
group: 'style',
|
|
779
|
+
description: 'The border radius of the section',
|
|
780
|
+
defaultValue: '0px',
|
|
781
|
+
},
|
|
782
|
+
cfLineHeight: {
|
|
783
|
+
displayName: 'Line Height',
|
|
784
|
+
type: 'Text',
|
|
785
|
+
group: 'style',
|
|
786
|
+
description: 'The line height of the element',
|
|
787
|
+
defaultValue: '20px',
|
|
788
|
+
},
|
|
789
|
+
cfLetterSpacing: {
|
|
790
|
+
displayName: 'Letter Spacing',
|
|
791
|
+
type: 'Text',
|
|
792
|
+
group: 'style',
|
|
793
|
+
description: 'The letter spacing of the element',
|
|
794
|
+
defaultValue: '0px',
|
|
795
|
+
},
|
|
796
|
+
cfTextColor: {
|
|
797
|
+
displayName: 'Text Color',
|
|
798
|
+
type: 'Text',
|
|
799
|
+
group: 'style',
|
|
800
|
+
description: 'The text color of the element',
|
|
801
|
+
defaultValue: 'rgba(0, 0, 0, 1)',
|
|
802
|
+
},
|
|
803
|
+
cfTextAlign: {
|
|
804
|
+
validations: {
|
|
805
|
+
in: [
|
|
806
|
+
{
|
|
807
|
+
value: 'left',
|
|
808
|
+
displayName: 'Align left',
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
value: 'center',
|
|
812
|
+
displayName: 'Align center',
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
value: 'right',
|
|
816
|
+
displayName: 'Align right',
|
|
817
|
+
},
|
|
818
|
+
],
|
|
819
|
+
},
|
|
820
|
+
displayName: 'Text Align',
|
|
821
|
+
type: 'Text',
|
|
822
|
+
group: 'style',
|
|
823
|
+
description: 'The text alignment of the element',
|
|
824
|
+
defaultValue: 'left',
|
|
825
|
+
},
|
|
826
|
+
cfTextTransform: {
|
|
827
|
+
validations: {
|
|
828
|
+
in: [
|
|
829
|
+
{
|
|
830
|
+
value: 'none',
|
|
831
|
+
displayName: 'Normal',
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
value: 'capitalize',
|
|
835
|
+
displayName: 'Capitalize',
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
value: 'uppercase',
|
|
839
|
+
displayName: 'Uppercase',
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
value: 'lowercase',
|
|
843
|
+
displayName: 'Lowercase',
|
|
844
|
+
},
|
|
845
|
+
],
|
|
846
|
+
},
|
|
847
|
+
displayName: 'Text Transform',
|
|
848
|
+
type: 'Text',
|
|
849
|
+
group: 'style',
|
|
850
|
+
description: 'The text transform of the element',
|
|
851
|
+
defaultValue: 'none',
|
|
852
|
+
},
|
|
853
|
+
cfTextBold: {
|
|
854
|
+
displayName: 'Bold',
|
|
855
|
+
type: 'Boolean',
|
|
856
|
+
group: 'style',
|
|
857
|
+
description: 'The text bold of the element',
|
|
858
|
+
defaultValue: false,
|
|
859
|
+
},
|
|
860
|
+
cfTextItalic: {
|
|
861
|
+
displayName: 'Italic',
|
|
862
|
+
type: 'Boolean',
|
|
863
|
+
group: 'style',
|
|
864
|
+
description: 'The text italic of the element',
|
|
865
|
+
defaultValue: false,
|
|
866
|
+
},
|
|
867
|
+
cfTextUnderline: {
|
|
868
|
+
displayName: 'Underline',
|
|
869
|
+
type: 'Boolean',
|
|
870
|
+
group: 'style',
|
|
871
|
+
description: 'The text underline of the element',
|
|
872
|
+
defaultValue: false,
|
|
873
|
+
},
|
|
874
|
+
};
|
|
875
|
+
const sectionBuiltInStyles = {
|
|
876
|
+
...builtInStyles,
|
|
877
|
+
cfBorderRadius: optionalBuiltInStyles.cfBorderRadius,
|
|
878
|
+
cfBackgroundImageUrl: optionalBuiltInStyles.cfBackgroundImageUrl,
|
|
879
|
+
cfBackgroundImageOptions: optionalBuiltInStyles.cfBackgroundImageOptions,
|
|
880
|
+
};
|
|
881
|
+
const containerBuiltInStyles = {
|
|
882
|
+
...builtInStyles,
|
|
883
|
+
cfBorderRadius: optionalBuiltInStyles.cfBorderRadius,
|
|
884
|
+
cfBackgroundImageUrl: optionalBuiltInStyles.cfBackgroundImageUrl,
|
|
885
|
+
cfBackgroundImageOptions: optionalBuiltInStyles.cfBackgroundImageOptions,
|
|
886
|
+
cfMargin: {
|
|
887
|
+
displayName: 'Margin',
|
|
888
|
+
type: 'Text',
|
|
889
|
+
group: 'style',
|
|
890
|
+
description: 'The margin of the container',
|
|
891
|
+
// Note: The UI overwrites '0 Auto 0 Auto' as the default value for top-level containers
|
|
892
|
+
defaultValue: '0 0 0 0',
|
|
893
|
+
},
|
|
894
|
+
cfMaxWidth: {
|
|
895
|
+
displayName: 'Max Width',
|
|
896
|
+
type: 'Text',
|
|
897
|
+
group: 'style',
|
|
898
|
+
description: 'The max-width of the section',
|
|
899
|
+
defaultValue: '1192px',
|
|
900
|
+
},
|
|
901
|
+
};
|
|
902
|
+
const dividerBuiltInStyles = {
|
|
903
|
+
cfVisibility: builtInStyles.cfVisibility,
|
|
904
|
+
cfBorderRadius: optionalBuiltInStyles.cfBorderRadius,
|
|
905
|
+
cfMargin: {
|
|
906
|
+
displayName: 'Margin',
|
|
907
|
+
type: 'Text',
|
|
908
|
+
group: 'style',
|
|
909
|
+
description: 'The margin of the divider',
|
|
910
|
+
defaultValue: '20px 0px 20px 0px',
|
|
911
|
+
},
|
|
912
|
+
cfWidth: {
|
|
913
|
+
displayName: 'Width',
|
|
914
|
+
type: 'Text',
|
|
915
|
+
group: 'style',
|
|
916
|
+
description: 'The width of the divider',
|
|
917
|
+
defaultValue: '100%',
|
|
918
|
+
},
|
|
919
|
+
cfHeight: {
|
|
920
|
+
displayName: 'Height',
|
|
921
|
+
type: 'Text',
|
|
922
|
+
group: 'style',
|
|
923
|
+
description: 'The height of the divider',
|
|
924
|
+
defaultValue: '1px',
|
|
925
|
+
},
|
|
926
|
+
cfMaxWidth: {
|
|
927
|
+
displayName: 'Max width',
|
|
928
|
+
type: 'Text',
|
|
929
|
+
group: 'style',
|
|
930
|
+
description: 'The max-width of the divider',
|
|
931
|
+
defaultValue: 'none',
|
|
932
|
+
},
|
|
933
|
+
cfBackgroundColor: {
|
|
934
|
+
displayName: 'Background color',
|
|
935
|
+
type: 'Text',
|
|
936
|
+
group: 'style',
|
|
937
|
+
description: 'The background color of the divider',
|
|
938
|
+
defaultValue: 'rgba(204, 204, 204, 1)',
|
|
939
|
+
},
|
|
940
|
+
};
|
|
941
|
+
const singleColumnBuiltInStyles = {
|
|
942
|
+
cfVisibility: builtInStyles.cfVisibility,
|
|
943
|
+
cfBorderRadius: optionalBuiltInStyles.cfBorderRadius,
|
|
944
|
+
cfBackgroundColor: optionalBuiltInStyles.cfBackgroundColor,
|
|
945
|
+
cfBackgroundImageUrl: optionalBuiltInStyles.cfBackgroundImageUrl,
|
|
946
|
+
cfBackgroundImageOptions: optionalBuiltInStyles.cfBackgroundImageOptions,
|
|
947
|
+
cfVerticalAlignment: {
|
|
948
|
+
validations: {
|
|
949
|
+
in: [
|
|
950
|
+
{
|
|
951
|
+
value: 'start',
|
|
952
|
+
displayName: 'Align left',
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
value: 'center',
|
|
956
|
+
displayName: 'Align center',
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
value: 'end',
|
|
960
|
+
displayName: 'Align right',
|
|
961
|
+
},
|
|
962
|
+
],
|
|
963
|
+
},
|
|
964
|
+
type: 'Text',
|
|
965
|
+
group: 'style',
|
|
966
|
+
description: 'The horizontal alignment of the column',
|
|
967
|
+
defaultValue: 'center',
|
|
968
|
+
displayName: 'Vertical alignment',
|
|
969
|
+
},
|
|
970
|
+
cfHorizontalAlignment: {
|
|
971
|
+
validations: {
|
|
972
|
+
in: [
|
|
973
|
+
{
|
|
974
|
+
value: 'start',
|
|
975
|
+
displayName: 'Align top',
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
value: 'center',
|
|
979
|
+
displayName: 'Align center',
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
value: 'end',
|
|
983
|
+
displayName: 'Align bottom',
|
|
984
|
+
},
|
|
985
|
+
],
|
|
986
|
+
},
|
|
987
|
+
type: 'Text',
|
|
988
|
+
group: 'style',
|
|
989
|
+
description: 'The horizontal alignment of the column',
|
|
990
|
+
defaultValue: 'center',
|
|
991
|
+
displayName: 'Horizontal alignment',
|
|
992
|
+
},
|
|
993
|
+
cfPadding: {
|
|
994
|
+
displayName: 'Padding',
|
|
995
|
+
type: 'Text',
|
|
996
|
+
group: 'style',
|
|
997
|
+
description: 'The padding of the column',
|
|
998
|
+
defaultValue: '0 0 0 0',
|
|
999
|
+
},
|
|
1000
|
+
cfFlexDirection: {
|
|
1001
|
+
displayName: 'Direction',
|
|
1002
|
+
type: 'Text',
|
|
1003
|
+
group: 'style',
|
|
1004
|
+
description: 'The orientation of the column',
|
|
1005
|
+
defaultValue: 'column',
|
|
1006
|
+
},
|
|
1007
|
+
cfFlexWrap: {
|
|
1008
|
+
displayName: 'Wrap objects',
|
|
1009
|
+
type: 'Text',
|
|
1010
|
+
group: 'style',
|
|
1011
|
+
description: 'Wrap objects',
|
|
1012
|
+
defaultValue: 'nowrap',
|
|
1013
|
+
},
|
|
1014
|
+
cfBorder: {
|
|
1015
|
+
displayName: 'Border',
|
|
1016
|
+
type: 'Text',
|
|
1017
|
+
group: 'style',
|
|
1018
|
+
description: 'The border of the column',
|
|
1019
|
+
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
1020
|
+
},
|
|
1021
|
+
cfGap: {
|
|
1022
|
+
displayName: 'Gap',
|
|
1023
|
+
type: 'Text',
|
|
1024
|
+
group: 'style',
|
|
1025
|
+
description: 'The spacing between the elements of the column',
|
|
1026
|
+
defaultValue: '0px',
|
|
1027
|
+
},
|
|
1028
|
+
cfColumnSpan: {
|
|
1029
|
+
type: 'Text',
|
|
1030
|
+
defaultValue: '6',
|
|
1031
|
+
group: 'style',
|
|
1032
|
+
},
|
|
1033
|
+
cfColumnSpanLock: {
|
|
1034
|
+
type: 'Boolean',
|
|
1035
|
+
defaultValue: false,
|
|
1036
|
+
group: 'style',
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
const columnsBuiltInStyles = {
|
|
1040
|
+
cfVisibility: builtInStyles.cfVisibility,
|
|
1041
|
+
cfBorderRadius: optionalBuiltInStyles.cfBorderRadius,
|
|
1042
|
+
cfBackgroundColor: optionalBuiltInStyles.cfBackgroundColor,
|
|
1043
|
+
cfBackgroundImageUrl: optionalBuiltInStyles.cfBackgroundImageUrl,
|
|
1044
|
+
cfBackgroundImageOptions: optionalBuiltInStyles.cfBackgroundImageOptions,
|
|
1045
|
+
cfMargin: {
|
|
1046
|
+
displayName: 'Margin',
|
|
1047
|
+
type: 'Text',
|
|
1048
|
+
group: 'style',
|
|
1049
|
+
description: 'The margin of the columns',
|
|
1050
|
+
// Note: The UI overwrites '0 Auto 0 Auto' as the default value for top-level columns
|
|
1051
|
+
defaultValue: '0 0 0 0',
|
|
1052
|
+
},
|
|
1053
|
+
cfWidth: {
|
|
1054
|
+
displayName: 'Width',
|
|
1055
|
+
type: 'Text',
|
|
1056
|
+
group: 'style',
|
|
1057
|
+
description: 'The width of the columns',
|
|
1058
|
+
defaultValue: '100%',
|
|
1059
|
+
},
|
|
1060
|
+
cfMaxWidth: {
|
|
1061
|
+
displayName: 'Max width',
|
|
1062
|
+
type: 'Text',
|
|
1063
|
+
group: 'style',
|
|
1064
|
+
description: 'The max-width of the columns',
|
|
1065
|
+
defaultValue: '1192px',
|
|
1066
|
+
},
|
|
1067
|
+
cfPadding: {
|
|
1068
|
+
displayName: 'Padding',
|
|
1069
|
+
type: 'Text',
|
|
1070
|
+
group: 'style',
|
|
1071
|
+
description: 'The padding of the columns',
|
|
1072
|
+
defaultValue: '10px 10px 10px 10px',
|
|
1073
|
+
},
|
|
1074
|
+
cfBorder: {
|
|
1075
|
+
displayName: 'Border',
|
|
1076
|
+
type: 'Text',
|
|
1077
|
+
group: 'style',
|
|
1078
|
+
description: 'The border of the columns',
|
|
1079
|
+
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
1080
|
+
},
|
|
1081
|
+
cfGap: {
|
|
1082
|
+
displayName: 'Gap',
|
|
1083
|
+
type: 'Text',
|
|
1084
|
+
group: 'style',
|
|
1085
|
+
description: 'The spacing between the elements of the columns',
|
|
1086
|
+
defaultValue: '10px 10px',
|
|
1087
|
+
},
|
|
1088
|
+
cfColumns: {
|
|
1089
|
+
type: 'Text',
|
|
1090
|
+
defaultValue: '[6,6]',
|
|
1091
|
+
group: 'style',
|
|
1092
|
+
},
|
|
1093
|
+
cfWrapColumns: {
|
|
1094
|
+
type: 'Boolean',
|
|
1095
|
+
defaultValue: false,
|
|
1096
|
+
group: 'style',
|
|
1097
|
+
},
|
|
1098
|
+
cfWrapColumnsCount: {
|
|
1099
|
+
type: 'Text',
|
|
1100
|
+
defaultValue: '2',
|
|
1101
|
+
group: 'style',
|
|
1102
|
+
},
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
// If more than one version is supported, use z.union
|
|
1106
|
+
const SchemaVersions = z.literal('2023-09-28');
|
|
1107
|
+
// Keep deprecated versions here just for reference
|
|
1108
|
+
z.union([
|
|
1109
|
+
z.literal('2023-08-23'),
|
|
1110
|
+
z.literal('2023-07-26'),
|
|
1111
|
+
z.literal('2023-06-27'),
|
|
1112
|
+
]);
|
|
1113
|
+
|
|
1114
|
+
const DefinitionPropertyTypeSchema = z.enum([
|
|
1115
|
+
'Text',
|
|
1116
|
+
'RichText',
|
|
1117
|
+
'Number',
|
|
1118
|
+
'Date',
|
|
1119
|
+
'Boolean',
|
|
1120
|
+
'Location',
|
|
1121
|
+
'Media',
|
|
1122
|
+
'Object',
|
|
1123
|
+
'Hyperlink',
|
|
1124
|
+
'Array',
|
|
1125
|
+
'Link',
|
|
1126
|
+
]);
|
|
1127
|
+
const DefinitionPropertyKeySchema = z
|
|
1128
|
+
.string()
|
|
1129
|
+
.regex(/^[a-zA-Z0-9-_]{1,32}$/, { message: 'Property needs to match: /^[a-zA-Z0-9-_]{1,32}$/' });
|
|
1130
|
+
const PrimitiveValueSchema = z.union([
|
|
1131
|
+
z.string(),
|
|
1132
|
+
z.boolean(),
|
|
1133
|
+
z.number(),
|
|
1134
|
+
z.record(z.any(), z.any()),
|
|
1135
|
+
z.undefined(),
|
|
1136
|
+
]);
|
|
1137
|
+
const uuidKeySchema = z
|
|
1138
|
+
.string()
|
|
1139
|
+
.regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
|
|
1140
|
+
/**
|
|
1141
|
+
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
1142
|
+
* property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
|
|
1143
|
+
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
1144
|
+
*/
|
|
1145
|
+
const propertyKeySchema = z
|
|
1146
|
+
.string()
|
|
1147
|
+
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
1148
|
+
const DataSourceSchema = z.record(uuidKeySchema, z.object({
|
|
1149
|
+
sys: z.object({
|
|
1150
|
+
type: z.literal('Link'),
|
|
1151
|
+
id: z.string(),
|
|
1152
|
+
linkType: z.enum(['Entry', 'Asset']),
|
|
1153
|
+
}),
|
|
1154
|
+
}));
|
|
1155
|
+
const ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));
|
|
1156
|
+
const DesignValueSchema = z
|
|
1157
|
+
.object({
|
|
1158
|
+
type: z.literal('DesignValue'),
|
|
1159
|
+
valuesByBreakpoint: ValuesByBreakpointSchema,
|
|
1160
|
+
})
|
|
1161
|
+
.strict();
|
|
1162
|
+
const BoundValueSchema = z
|
|
1163
|
+
.object({
|
|
1164
|
+
type: z.literal('BoundValue'),
|
|
1165
|
+
path: z.string(),
|
|
1166
|
+
})
|
|
1167
|
+
.strict();
|
|
1168
|
+
const HyperlinkValueSchema = z
|
|
1169
|
+
.object({
|
|
1170
|
+
type: z.literal('HyperlinkValue'),
|
|
1171
|
+
linkTargetKey: z.string(),
|
|
1172
|
+
/** Allows to override parts of the URL, e.g. the locale */
|
|
1173
|
+
overrides: z.object({}).optional(),
|
|
1174
|
+
})
|
|
1175
|
+
.strict();
|
|
1176
|
+
const UnboundValueSchema = z
|
|
1177
|
+
.object({
|
|
1178
|
+
type: z.literal('UnboundValue'),
|
|
1179
|
+
key: z.string(),
|
|
1180
|
+
})
|
|
1181
|
+
.strict();
|
|
1182
|
+
const ComponentValueSchema = z
|
|
1183
|
+
.object({
|
|
1184
|
+
type: z.literal('ComponentValue'),
|
|
1185
|
+
key: z.string(),
|
|
1186
|
+
})
|
|
1187
|
+
.strict();
|
|
1188
|
+
const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
1189
|
+
DesignValueSchema,
|
|
1190
|
+
BoundValueSchema,
|
|
1191
|
+
UnboundValueSchema,
|
|
1192
|
+
HyperlinkValueSchema,
|
|
1193
|
+
ComponentValueSchema,
|
|
1194
|
+
]);
|
|
1195
|
+
const BreakpointSchema = z
|
|
1196
|
+
.object({
|
|
1197
|
+
id: propertyKeySchema,
|
|
1198
|
+
query: z.string().regex(/^\*$|^<[0-9*]+px$/),
|
|
1199
|
+
previewSize: z.string(),
|
|
1200
|
+
displayName: z.string(),
|
|
1201
|
+
displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
1202
|
+
})
|
|
1203
|
+
.strict();
|
|
1204
|
+
const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
|
|
1205
|
+
value: PrimitiveValueSchema,
|
|
1206
|
+
}));
|
|
1207
|
+
// Use helper schema to define a recursive schema with its type correctly below
|
|
1208
|
+
const BaseComponentTreeNodeSchema = z.object({
|
|
1209
|
+
definitionId: DefinitionPropertyKeySchema,
|
|
1210
|
+
displayName: z.string().optional(),
|
|
1211
|
+
slotId: z.string().optional(),
|
|
1212
|
+
variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
1213
|
+
});
|
|
1214
|
+
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
1215
|
+
children: z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
1216
|
+
});
|
|
1217
|
+
const ComponentVariableSchema = z.object({
|
|
1218
|
+
displayName: z.string().optional(),
|
|
1219
|
+
type: DefinitionPropertyTypeSchema,
|
|
1220
|
+
description: z.string().optional(),
|
|
1221
|
+
group: z.string().optional(),
|
|
1222
|
+
defaultValue: PrimitiveValueSchema.or(ComponentPropertyValueSchema).optional(),
|
|
1223
|
+
validations: z
|
|
1224
|
+
.object({
|
|
1225
|
+
required: z.boolean().optional(),
|
|
1226
|
+
format: z.literal('URL').optional(),
|
|
1227
|
+
in: z
|
|
1228
|
+
.array(z.object({
|
|
1229
|
+
value: z.union([z.string(), z.number()]),
|
|
1230
|
+
displayName: z.string().optional(),
|
|
1231
|
+
}))
|
|
1232
|
+
.optional(),
|
|
1233
|
+
})
|
|
1234
|
+
.optional(),
|
|
1235
|
+
});
|
|
1236
|
+
const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
1237
|
+
ComponentVariableSchema);
|
|
1238
|
+
const ComponentSettingsSchema = z.object({
|
|
1239
|
+
variableDefinitions: ComponentVariablesSchema,
|
|
1240
|
+
});
|
|
1241
|
+
const UsedComponentsSchema = z.array(z.object({
|
|
1242
|
+
sys: z.object({
|
|
1243
|
+
type: z.literal('Link'),
|
|
1244
|
+
id: z.string(),
|
|
1245
|
+
linkType: z.literal('Entry'),
|
|
1246
|
+
}),
|
|
1247
|
+
}));
|
|
1248
|
+
const breakpointsRefinement = (value, ctx) => {
|
|
1249
|
+
if (!value.length || value[0].query !== '*') {
|
|
1250
|
+
ctx.addIssue({
|
|
1251
|
+
code: z.ZodIssueCode.custom,
|
|
1252
|
+
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
1256
|
+
// check if the current breakpoint id is found in the rest of the array
|
|
1257
|
+
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
1258
|
+
return breakpointIndex !== currentBreakpointIndex;
|
|
1259
|
+
});
|
|
1260
|
+
if (hasDuplicateIds) {
|
|
1261
|
+
ctx.addIssue({
|
|
1262
|
+
code: z.ZodIssueCode.custom,
|
|
1263
|
+
message: `Breakpoint IDs must be unique`,
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
// Extract the queries boundary by removing the special characters around it
|
|
1267
|
+
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
1268
|
+
// sort updates queries array in place so we need to create a copy
|
|
1269
|
+
const originalQueries = [...queries];
|
|
1270
|
+
queries.sort((q1, q2) => {
|
|
1271
|
+
if (q1 === '*') {
|
|
1272
|
+
return -1;
|
|
1273
|
+
}
|
|
1274
|
+
if (q2 === '*') {
|
|
1275
|
+
return 1;
|
|
1276
|
+
}
|
|
1277
|
+
return q1 > q2 ? -1 : 1;
|
|
1278
|
+
});
|
|
1279
|
+
if (originalQueries.join('') !== queries.join('')) {
|
|
1280
|
+
ctx.addIssue({
|
|
1281
|
+
code: z.ZodIssueCode.custom,
|
|
1282
|
+
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
const ComponentTreeSchema = z
|
|
1287
|
+
.object({
|
|
1288
|
+
breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
1289
|
+
children: z.array(ComponentTreeNodeSchema),
|
|
1290
|
+
schemaVersion: SchemaVersions,
|
|
1291
|
+
})
|
|
1292
|
+
.strict();
|
|
1293
|
+
const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
1294
|
+
z.object({
|
|
1295
|
+
componentTree: localeWrapper(ComponentTreeSchema),
|
|
1296
|
+
dataSource: localeWrapper(DataSourceSchema),
|
|
1297
|
+
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
1298
|
+
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
1299
|
+
componentSettings: localeWrapper(ComponentSettingsSchema).optional(),
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
z.object({
|
|
1303
|
+
id: DefinitionPropertyKeySchema,
|
|
1304
|
+
variables: z.record(DefinitionPropertyKeySchema, ComponentVariableSchema.extend({
|
|
1305
|
+
defaultValue: PrimitiveValueSchema.optional(),
|
|
1306
|
+
}).superRefine((val, ctx) => {
|
|
1307
|
+
switch (val.type) {
|
|
1308
|
+
case 'Array':
|
|
1309
|
+
if (typeof val.defaultValue !== 'undefined') {
|
|
1310
|
+
ctx.addIssue({
|
|
1311
|
+
code: z.ZodIssueCode.custom,
|
|
1312
|
+
message: `defaultValue is not supported for "Array" type for ${ctx.path.join('.')}`,
|
|
1313
|
+
fatal: false,
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
break;
|
|
1317
|
+
case 'Boolean':
|
|
1318
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'boolean') {
|
|
1319
|
+
ctx.addIssue({
|
|
1320
|
+
code: z.ZodIssueCode.custom,
|
|
1321
|
+
message: `defaultValue must be a boolean when type is "Boolean" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1322
|
+
fatal: false,
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
break;
|
|
1326
|
+
case 'Date':
|
|
1327
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'string') {
|
|
1328
|
+
ctx.addIssue({
|
|
1329
|
+
code: z.ZodIssueCode.custom,
|
|
1330
|
+
message: `defaultValue must be a string when type is "Date" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1331
|
+
fatal: false,
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
break;
|
|
1335
|
+
case 'Hyperlink':
|
|
1336
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'string') {
|
|
1337
|
+
ctx.addIssue({
|
|
1338
|
+
code: z.ZodIssueCode.custom,
|
|
1339
|
+
message: `defaultValue must be a string when type is "Hyperlink" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1340
|
+
fatal: false,
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
break;
|
|
1344
|
+
case 'Link':
|
|
1345
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'object') {
|
|
1346
|
+
ctx.addIssue({
|
|
1347
|
+
code: z.ZodIssueCode.custom,
|
|
1348
|
+
message: `defaultValue is not supported for "Link" type for ${ctx.path.join('.')}`,
|
|
1349
|
+
fatal: false,
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
break;
|
|
1353
|
+
case 'Location':
|
|
1354
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'object') {
|
|
1355
|
+
ctx.addIssue({
|
|
1356
|
+
code: z.ZodIssueCode.custom,
|
|
1357
|
+
message: `defaultValue must be an object when type is "Location" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1358
|
+
fatal: false,
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
break;
|
|
1362
|
+
case 'Media':
|
|
1363
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'string') {
|
|
1364
|
+
ctx.addIssue({
|
|
1365
|
+
code: z.ZodIssueCode.custom,
|
|
1366
|
+
message: `defaultValue must be a string when type is "Media" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1367
|
+
fatal: false,
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
break;
|
|
1371
|
+
case 'Number':
|
|
1372
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'number') {
|
|
1373
|
+
ctx.addIssue({
|
|
1374
|
+
code: z.ZodIssueCode.custom,
|
|
1375
|
+
message: `defaultValue must be a number when type is "Number" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1376
|
+
fatal: false,
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
break;
|
|
1380
|
+
case 'Object':
|
|
1381
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'object') {
|
|
1382
|
+
ctx.addIssue({
|
|
1383
|
+
code: z.ZodIssueCode.custom,
|
|
1384
|
+
message: `defaultValue must be an object when type is "Object" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1385
|
+
fatal: false,
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
break;
|
|
1389
|
+
case 'RichText':
|
|
1390
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'object') {
|
|
1391
|
+
ctx.addIssue({
|
|
1392
|
+
code: z.ZodIssueCode.custom,
|
|
1393
|
+
message: `defaultValue must be an object when type is "RichText" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1394
|
+
fatal: false,
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
break;
|
|
1398
|
+
case 'Text':
|
|
1399
|
+
if (typeof val.defaultValue !== 'undefined' && typeof val.defaultValue !== 'string') {
|
|
1400
|
+
ctx.addIssue({
|
|
1401
|
+
code: z.ZodIssueCode.custom,
|
|
1402
|
+
message: `defaultValue must be a string when type is "Text" for ${ctx.path.join('.')}, got ${typeof val.defaultValue} instead`,
|
|
1403
|
+
fatal: false,
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
break;
|
|
1407
|
+
}
|
|
1408
|
+
})),
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
var CodeNames;
|
|
1412
|
+
(function (CodeNames) {
|
|
1413
|
+
CodeNames["Type"] = "type";
|
|
1414
|
+
CodeNames["Required"] = "required";
|
|
1415
|
+
CodeNames["Unexpected"] = "unexpected";
|
|
1416
|
+
CodeNames["Regex"] = "regex";
|
|
1417
|
+
CodeNames["In"] = "in";
|
|
1418
|
+
CodeNames["Size"] = "size";
|
|
1419
|
+
CodeNames["Custom"] = "custom";
|
|
1420
|
+
})(CodeNames || (CodeNames = {}));
|
|
1421
|
+
|
|
1422
|
+
var VisualEditorMode;
|
|
1423
|
+
(function (VisualEditorMode) {
|
|
1424
|
+
VisualEditorMode["LazyLoad"] = "lazyLoad";
|
|
1425
|
+
VisualEditorMode["InjectScript"] = "injectScript";
|
|
1426
|
+
})(VisualEditorMode || (VisualEditorMode = {}));
|
|
1427
|
+
|
|
486
1428
|
var css_248z$2 = ".contentful-container {\n position: relative;\n display: flex;\n box-sizing: border-box;\n pointer-events: all;\n}\n\n.contentful-container::-webkit-scrollbar {\n display: none; /* Safari and Chrome */\n}\n\n.cf-single-column-wrapper {\n position: relative;\n}\n\n.cf-container-wrapper {\n position: relative;\n width: 100%;\n}\n\n.contentful-container:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.contentful-section-label:after {\n content: 'Section';\n}\n\n.contentful-container-label:after {\n content: 'Container';\n}\n\n/* used by ContentfulSectionAsHyperlink.tsx */\n\n.contentful-container-link,\n.contentful-container-link:active,\n.contentful-container-link:visited,\n.contentful-container-link:hover,\n.contentful-container-link:read-write,\n.contentful-container-link:focus-visible {\n color: inherit;\n text-decoration: unset;\n outline: unset;\n}\n";
|
|
487
1429
|
styleInject(css_248z$2);
|
|
488
1430
|
|
|
@@ -547,7 +1489,7 @@ const ContentfulContainer = (props) => {
|
|
|
547
1489
|
// Extract properties that are only available in editor mode
|
|
548
1490
|
const { renderDropzone, node, dragProps = {}, ...editorModeProps } = props;
|
|
549
1491
|
const isEmpty = !node.children.length;
|
|
550
|
-
const isSection = node.data.blockId === CONTENTFUL_COMPONENTS.section.id;
|
|
1492
|
+
const isSection = node.data.blockId === CONTENTFUL_COMPONENTS$1.section.id;
|
|
551
1493
|
return renderDropzone(node, {
|
|
552
1494
|
...editorModeProps,
|
|
553
1495
|
['data-test-id']: 'contentful-container',
|
|
@@ -558,6 +1500,27 @@ const ContentfulContainer = (props) => {
|
|
|
558
1500
|
});
|
|
559
1501
|
};
|
|
560
1502
|
|
|
1503
|
+
const containerDefinition = {
|
|
1504
|
+
id: CONTENTFUL_COMPONENTS$1.container.id,
|
|
1505
|
+
name: CONTENTFUL_COMPONENTS$1.container.name,
|
|
1506
|
+
category: CONTENTFUL_COMPONENT_CATEGORY,
|
|
1507
|
+
children: true,
|
|
1508
|
+
variables: containerBuiltInStyles,
|
|
1509
|
+
tooltip: {
|
|
1510
|
+
description: 'Create a new area or pattern within your page layout by dragging a container onto the canvas. Other components and patterns can be added into a container.',
|
|
1511
|
+
},
|
|
1512
|
+
};
|
|
1513
|
+
const sectionDefinition = {
|
|
1514
|
+
id: CONTENTFUL_COMPONENTS$1.section.id,
|
|
1515
|
+
name: CONTENTFUL_COMPONENTS$1.section.name,
|
|
1516
|
+
category: CONTENTFUL_COMPONENT_CATEGORY,
|
|
1517
|
+
children: true,
|
|
1518
|
+
variables: sectionBuiltInStyles,
|
|
1519
|
+
tooltip: {
|
|
1520
|
+
description: 'Create a new full width section of your experience by dragging this component onto the canvas. Other components and patterns can be added into a section.',
|
|
1521
|
+
},
|
|
1522
|
+
};
|
|
1523
|
+
|
|
561
1524
|
var css_248z$1 = ".cf-divider {\n display: contents;\n position: relative;\n width: 100%;\n height: 100%;\n}\n\n.cf-divider hr {\n border: none;\n}\n\n.cf-divider::before {\n content: \"\";\n position: absolute;\n top: -5px;\n left: -5px;\n bottom: -5px;\n right: -5px;\n pointer-events: all;\n}\n";
|
|
562
1525
|
styleInject(css_248z$1);
|
|
563
1526
|
|
|
@@ -568,6 +1531,17 @@ dragProps: _, ...props }) => {
|
|
|
568
1531
|
React.createElement("hr", { className: className })));
|
|
569
1532
|
};
|
|
570
1533
|
|
|
1534
|
+
const dividerDefinition = {
|
|
1535
|
+
id: CONTENTFUL_COMPONENTS$1.divider.id,
|
|
1536
|
+
name: CONTENTFUL_COMPONENTS$1.divider.name,
|
|
1537
|
+
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
1538
|
+
children: false,
|
|
1539
|
+
variables: dividerBuiltInStyles,
|
|
1540
|
+
tooltip: {
|
|
1541
|
+
description: 'Drop onto the canvas to add a divider.',
|
|
1542
|
+
},
|
|
1543
|
+
};
|
|
1544
|
+
|
|
571
1545
|
var css_248z = ".cf-columns {\n display: flex;\n gap: 24px;\n grid-template-columns: repeat(12, 1fr);\n flex-direction: column;\n min-height: 0; /* NEW */\n min-width: 0; /* NEW; needed for Firefox */\n}\n\n@media (min-width: 768px) {\n .cf-columns {\n display: grid;\n }\n}\n\n.cf-single-column-wrapper {\n position: relative;\n display: flex;\n}\n\n.cf-single-column {\n pointer-events: all;\n}\n\n.cf-single-column-wrapper:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.cf-single-column-label:after {\n content: 'Column';\n}\n";
|
|
572
1546
|
styleInject(css_248z);
|
|
573
1547
|
|
|
@@ -612,6 +1586,24 @@ const SingleColumn = (props) => {
|
|
|
612
1586
|
});
|
|
613
1587
|
};
|
|
614
1588
|
|
|
1589
|
+
const columnsDefinition = {
|
|
1590
|
+
id: CONTENTFUL_COMPONENTS$1.columns.id,
|
|
1591
|
+
name: CONTENTFUL_COMPONENTS$1.columns.name,
|
|
1592
|
+
category: CONTENTFUL_COMPONENT_CATEGORY,
|
|
1593
|
+
children: true,
|
|
1594
|
+
variables: columnsBuiltInStyles,
|
|
1595
|
+
tooltip: {
|
|
1596
|
+
description: 'Add columns to a container to create your desired layout and ensure that the experience is responsive across different screen sizes.',
|
|
1597
|
+
},
|
|
1598
|
+
};
|
|
1599
|
+
const singleColumnDefinition = {
|
|
1600
|
+
id: CONTENTFUL_COMPONENTS$1.singleColumn.id,
|
|
1601
|
+
name: CONTENTFUL_COMPONENTS$1.singleColumn.name,
|
|
1602
|
+
category: CONTENTFUL_COMPONENT_CATEGORY,
|
|
1603
|
+
children: true,
|
|
1604
|
+
variables: singleColumnBuiltInStyles,
|
|
1605
|
+
};
|
|
1606
|
+
|
|
615
1607
|
const assemblyStyle = { display: 'contents' };
|
|
616
1608
|
// Feel free to do any magic as regards variable definitions for assemblies
|
|
617
1609
|
// Or if this isn't necessary by the time we figure that part out, we can bid this part farewell
|
|
@@ -630,5 +1622,30 @@ const Assembly = (props) => {
|
|
|
630
1622
|
return React.createElement("div", { "data-test-id": "assembly", ...props, style: assemblyStyle });
|
|
631
1623
|
};
|
|
632
1624
|
|
|
633
|
-
|
|
1625
|
+
const Carousel = ({ className, children, ...props }) => {
|
|
1626
|
+
return (React.createElement("div", { className: combineClasses(className, 'cf-carousel'), ...props }, children));
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
const carouselDefinition = {
|
|
1630
|
+
id: CONTENTFUL_COMPONENTS$1.carousel.id,
|
|
1631
|
+
name: CONTENTFUL_COMPONENTS$1.carousel.name,
|
|
1632
|
+
category: CONTENTFUL_DEFAULT_CATEGORY,
|
|
1633
|
+
children: true,
|
|
1634
|
+
builtInStyles: [
|
|
1635
|
+
'cfPadding',
|
|
1636
|
+
'cfMargin',
|
|
1637
|
+
'cfHeight',
|
|
1638
|
+
'cfWidth',
|
|
1639
|
+
'cfMaxWidth',
|
|
1640
|
+
'cfBorderRadius',
|
|
1641
|
+
'cfBackgroundColor',
|
|
1642
|
+
'cfBorder',
|
|
1643
|
+
],
|
|
1644
|
+
variables: {},
|
|
1645
|
+
tooltip: {
|
|
1646
|
+
description: 'Drop onto the canvas to add a carousel.',
|
|
1647
|
+
},
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1650
|
+
export { Assembly, Button, ButtonComponentDefinition, Carousel, Columns, ContentfulContainer, ContentfulDivider, Heading, HeadingComponentDefinition, Image, ImageComponentDefinition, RichText, RichTextComponentDefinition, SingleColumn, Text, TextComponentDefinition, carouselDefinition, columnsDefinition, containerDefinition, dividerDefinition, sectionDefinition, singleColumnDefinition };
|
|
634
1651
|
//# sourceMappingURL=index.js.map
|