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