@builder.io/sdk-solid 0.11.1 → 0.11.3

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 CHANGED
@@ -1,14 +1,12 @@
1
1
  import * as solid_js from 'solid-js';
2
2
 
3
- /**
4
- * This import is used by the Svelte SDK. Do not remove.
5
- */
6
3
  interface ButtonProps {
7
4
  attributes?: any;
8
5
  text?: string;
9
6
  link?: string;
10
7
  openLinkInNewTab?: boolean;
11
8
  }
9
+
12
10
  declare function Button(props: ButtonProps): solid_js.JSX.Element;
13
11
 
14
12
  type JSONValue$1 = string | number | boolean | JSONObject$1 | JSONArray$1;
@@ -81,9 +79,6 @@ type Nullable<T> = T | null | undefined;
81
79
  type Dictionary<T> = {
82
80
  [key: string]: T;
83
81
  };
84
- type Prettify<T> = {
85
- [K in keyof T]: T[K];
86
- } & {};
87
82
 
88
83
  type BlocksWrapperProps = {
89
84
  blocks: BuilderBlock[] | undefined;
@@ -477,7 +472,7 @@ type Column = {
477
472
  blocks: BuilderBlock[];
478
473
  width?: number;
479
474
  };
480
- type StackColumnsAt = "tablet" | "mobile" | "never";
475
+ type StackColumnsAt = 'tablet' | 'mobile' | 'never';
481
476
  interface ColumnProps extends BuilderComponentsProp {
482
477
  columns?: Column[];
483
478
  builderBlock: BuilderBlock;
@@ -493,6 +488,7 @@ interface FragmentProps {
493
488
  attributes?: any;
494
489
  children?: any;
495
490
  }
491
+
496
492
  declare function FragmentComponent(props: FragmentProps): solid_js.JSX.Element;
497
493
 
498
494
  interface ImageProps {
@@ -503,7 +499,7 @@ interface ImageProps {
503
499
  height?: number;
504
500
  width?: number;
505
501
  altText?: string;
506
- backgroundSize?: "cover" | "contain";
502
+ backgroundSize?: 'cover' | 'contain';
507
503
  backgroundPosition?: string;
508
504
  srcset?: string;
509
505
  aspectRatio?: number;
@@ -516,20 +512,15 @@ interface ImageProps {
516
512
 
517
513
  declare function Image(props: ImageProps): solid_js.JSX.Element;
518
514
 
519
- /**
520
- * This import is used by the Svelte SDK. Do not remove.
521
- */
522
515
  interface SectionProps {
523
516
  maxWidth?: number;
524
517
  attributes?: any;
525
518
  children?: any;
526
519
  builderBlock?: any;
527
520
  }
521
+
528
522
  declare function SectionComponent(props: SectionProps): solid_js.JSX.Element;
529
523
 
530
- /**
531
- * This import is used by the Svelte SDK. Do not remove.
532
- */
533
524
  interface SymbolInfo {
534
525
  model?: string;
535
526
  entry?: string;
@@ -538,9 +529,6 @@ interface SymbolInfo {
538
529
  inline?: boolean;
539
530
  dynamic?: boolean;
540
531
  }
541
- /**
542
- * This import is used by the Svelte SDK. Do not remove.
543
- */
544
532
  interface SymbolProps extends BuilderComponentsProp {
545
533
  symbol?: SymbolInfo;
546
534
  dataOnly?: boolean;
@@ -551,9 +539,10 @@ interface SymbolProps extends BuilderComponentsProp {
551
539
 
552
540
  declare function Symbol(props: PropsWithBuilderData<SymbolProps>): solid_js.JSX.Element;
553
541
 
554
- interface TextProps {
542
+ type TextProps = {
555
543
  text?: string;
556
- }
544
+ };
545
+
557
546
  declare function Text(props: TextProps): solid_js.JSX.Element;
558
547
 
559
548
  interface VideoProps {
@@ -567,9 +556,9 @@ interface VideoProps {
567
556
  aspectRatio?: number;
568
557
  width?: number;
569
558
  height?: number;
570
- fit?: "contain" | "cover" | "fill";
571
- preload?: "auto" | "metadata" | "none";
572
- position?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
559
+ fit?: 'contain' | 'cover' | 'fill';
560
+ preload?: 'auto' | 'metadata' | 'none';
561
+ position?: 'center' | 'top' | 'left' | 'right' | 'bottom' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
573
562
  posterImage?: string;
574
563
  lazyLoad?: boolean;
575
564
  children?: any;
@@ -579,7 +568,7 @@ interface VideoProps {
579
568
 
580
569
  declare function Video(props: VideoProps): solid_js.JSX.Element;
581
570
 
582
- type BlocksProps = Partial<Omit<BlocksWrapperProps, "BlocksWrapper" | "BlocksWrapperProps">> & {
571
+ type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>> & {
583
572
  context?: BuilderContextInterface;
584
573
  registeredComponents?: RegisteredComponents;
585
574
  };
@@ -587,19 +576,48 @@ type BlocksProps = Partial<Omit<BlocksWrapperProps, "BlocksWrapper" | "BlocksWra
587
576
  declare function Blocks(props: BlocksProps): solid_js.JSX.Element;
588
577
 
589
578
  interface ContentVariantsPrps {
579
+ /**
580
+ * The Builder content JSON to render (required).
581
+ */
590
582
  content?: Nullable<BuilderContent>;
583
+ /**
584
+ * The Builder content `model` to render (required).
585
+ */
591
586
  model?: string;
587
+ /**
588
+ * Additional data to inject into your Builder content (optional).
589
+ */
592
590
  data?: {
593
591
  [key: string]: any;
594
592
  };
593
+ /**
594
+ *
595
+ */
595
596
  context?: BuilderRenderContext;
597
+ /**
598
+ * Your API Key: needed to dynamically fetch symbols (required).
599
+ */
596
600
  apiKey: string;
597
601
  apiVersion?: ApiVersion;
602
+ /**
603
+ * An array of custom components to register (optional).
604
+ */
598
605
  customComponents?: RegisteredComponent[];
606
+ /**
607
+ * A boolean to enable or disable tracking (optional). Defaults to `true`.
608
+ */
599
609
  canTrack?: boolean;
610
+ /**
611
+ * If provided, the API will auto-resolve localized objects to the value of this `locale` key (optional).
612
+ */
600
613
  locale?: string;
601
- /** @deprecated use `enrich` instead **/
614
+ /** @deprecated use `enrich` instead */
602
615
  includeRefs?: boolean;
616
+ /**
617
+ * A boolean to enable or disable enriching API content (optional).
618
+ *
619
+ * Enriching will Include multilevel references in the response. Defaults to `false`.
620
+ */
603
621
  enrich?: boolean;
604
622
  /**
605
623
  * The element that wraps your content. Defaults to `div` ('ScrollView' in React Native).
@@ -671,9 +689,9 @@ type Settings = {
671
689
  declare function setEditorSettings(newSettings: Settings): void;
672
690
 
673
691
  interface GetContentOptions {
674
- /** The model to get content for */
692
+ /** The model to get content for (required) */
675
693
  model: string;
676
- /** Your public API key */
694
+ /** Your public API key (required) */
677
695
  apiKey: string;
678
696
  /** Number of items to fetch. Default is 1 */
679
697
  limit?: number;
@@ -814,7 +832,7 @@ interface GetContentOptions {
814
832
  }
815
833
 
816
834
  /**
817
- * Returns a the first entry that matches the given options.
835
+ * Returns the first content entry that matches the given options.
818
836
  */
819
837
  declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
820
838
  /**
@@ -895,37 +913,6 @@ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | '
895
913
  };
896
914
  declare const track: (args: EventProperties) => Promise<void | Response>;
897
915
 
898
- /**
899
- * Lol Typescript
900
- * https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
901
- */
902
- type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
903
- type OptionalFieldsOnly<T> = {
904
- [K in keyof T as T[K] extends Required<T>[K] ? IfAny<T[K], K, never> : K]: T[K];
905
- };
906
- type RequiredFieldsOnly<T> = {
907
- [K in keyof T as T[K] extends Required<T>[K] ? IfAny<T[K], never, K> : never]: T[K];
908
- };
909
- type Enforced<T> = {
910
- [K in keyof T]-?: T[K];
911
- };
912
- type AndUndefined<T> = {
913
- [K in keyof T]: T[K] | undefined;
914
- };
915
- /**
916
- * Enforce that all optional fields are undefined
917
- * @example
918
- * type Foo = { a: string, b?: number }
919
- * type Bar = EnforcePartials<Foo> // { a: string, b: number | undefined }
920
- */
921
- type EnforcePartials<From> = Prettify<AndUndefined<Enforced<OptionalFieldsOnly<From>>> & RequiredFieldsOnly<From>>;
922
-
923
- interface InternalRenderProps {
924
- showContent: boolean;
925
- isSsrAbTest: boolean;
926
- }
927
- type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps>;
928
-
929
916
  type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
930
917
  model?: string;
931
918
  }) & ({
@@ -976,4 +963,4 @@ type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
976
963
  */
977
964
  declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<ContentVariantsPrps>;
978
965
 
979
- export { Blocks, Button, Columns, ComponentInfo, ContentVariants as Content, ContentProps, FragmentComponent as Fragment, Image, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RenderBlocks, RenderContent, SectionComponent as Section, Settings, Symbol, Text, Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
966
+ export { Blocks, BlocksProps, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RenderBlocks, RenderContent, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
@@ -785,7 +785,7 @@ function ComponentRef(props) {
785
785
  return Wrapper();
786
786
  },
787
787
  get children() {
788
- return [createComponent(For, {
788
+ return createComponent(For, {
789
789
  get each() {
790
790
  return props.blockChildren;
791
791
  },
@@ -793,7 +793,7 @@ function ComponentRef(props) {
793
793
  _index();
794
794
  return createComponent(block_default, {
795
795
  get key() {
796
- return "block-" + child.id;
796
+ return child.id;
797
797
  },
798
798
  block: child,
799
799
  get context() {
@@ -804,23 +804,7 @@ function ComponentRef(props) {
804
804
  }
805
805
  });
806
806
  }
807
- }), createComponent(For, {
808
- get each() {
809
- return props.blockChildren;
810
- },
811
- children: (child, _index) => {
812
- _index();
813
- return createComponent(block_styles_default, {
814
- get key() {
815
- return "block-style-" + child.id;
816
- },
817
- block: child,
818
- get context() {
819
- return props.context;
820
- }
821
- });
822
- }
823
- })];
807
+ });
824
808
  }
825
809
  }));
826
810
  }
@@ -916,7 +900,14 @@ function Block(props) {
916
900
  return canShowBlock();
917
901
  },
918
902
  get children() {
919
- return createComponent(Show, {
903
+ return [createComponent(block_styles_default, {
904
+ get block() {
905
+ return props.block;
906
+ },
907
+ get context() {
908
+ return props.context;
909
+ }
910
+ }), createComponent(Show, {
920
911
  get fallback() {
921
912
  return createComponent(component_ref_default, {
922
913
  get componentRef() {
@@ -1043,7 +1034,7 @@ function Block(props) {
1043
1034
  _index();
1044
1035
  return createComponent(Block, {
1045
1036
  get key() {
1046
- return "block-" + child.id;
1037
+ return child.id;
1047
1038
  },
1048
1039
  block: child,
1049
1040
  get context() {
@@ -1054,29 +1045,13 @@ function Block(props) {
1054
1045
  }
1055
1046
  });
1056
1047
  }
1057
- }), createComponent(For, {
1058
- get each() {
1059
- return childrenWithoutParentComponent();
1060
- },
1061
- children: (child, _index) => {
1062
- _index();
1063
- return createComponent(block_styles_default, {
1064
- get key() {
1065
- return "block-style-" + child.id;
1066
- },
1067
- block: child,
1068
- get context() {
1069
- return childrenContext();
1070
- }
1071
- });
1072
- }
1073
1048
  })];
1074
1049
  }
1075
1050
  });
1076
1051
  }
1077
1052
  })];
1078
1053
  }
1079
- });
1054
+ })];
1080
1055
  }
1081
1056
  });
1082
1057
  }
@@ -1163,7 +1138,7 @@ function Blocks(props) {
1163
1138
  return props.context?.BlocksWrapperProps;
1164
1139
  },
1165
1140
  get children() {
1166
- return [createComponent(Show, {
1141
+ return createComponent(Show, {
1167
1142
  get when() {
1168
1143
  return props.blocks;
1169
1144
  },
@@ -1176,7 +1151,7 @@ function Blocks(props) {
1176
1151
  _index();
1177
1152
  return createComponent(block_default, {
1178
1153
  get key() {
1179
- return "render-block-" + block.id;
1154
+ return block.id;
1180
1155
  },
1181
1156
  block,
1182
1157
  get context() {
@@ -1189,30 +1164,7 @@ function Blocks(props) {
1189
1164
  }
1190
1165
  });
1191
1166
  }
1192
- }), createComponent(Show, {
1193
- get when() {
1194
- return props.blocks;
1195
- },
1196
- get children() {
1197
- return createComponent(For, {
1198
- get each() {
1199
- return props.blocks;
1200
- },
1201
- children: (block, _index) => {
1202
- _index();
1203
- return createComponent(block_styles_default, {
1204
- get key() {
1205
- return "block-style-" + block.id;
1206
- },
1207
- block,
1208
- get context() {
1209
- return props.context || builderContext;
1210
- }
1211
- });
1212
- }
1213
- });
1214
- }
1215
- })];
1167
+ });
1216
1168
  }
1217
1169
  });
1218
1170
  }
@@ -3298,7 +3250,7 @@ var getInteractionPropertiesForEvent = (event) => {
3298
3250
  };
3299
3251
 
3300
3252
  // src/constants/sdk-version.ts
3301
- var SDK_VERSION = "0.11.1";
3253
+ var SDK_VERSION = "0.11.3";
3302
3254
 
3303
3255
  // src/functions/register.ts
3304
3256
  var registry = {};
@@ -756,25 +756,15 @@ function ComponentRef(props) {
756
756
  contextValue: props.context
757
757
  })}
758
758
  component={Wrapper()}
759
- >
760
- <For each={props.blockChildren}>{(child, _index) => {
761
- const index = _index();
762
- return <Block_default
763
- key={"block-" + child.id}
764
- block={child}
765
- context={props.context}
766
- registeredComponents={props.registeredComponents}
767
- />;
768
- }}</For>
769
- <For each={props.blockChildren}>{(child, _index) => {
770
- const index = _index();
771
- return <Block_styles_default
772
- key={"block-style-" + child.id}
773
- block={child}
774
- context={props.context}
775
- />;
776
- }}</For>
777
- </Dynamic3></Show4>;
759
+ ><For each={props.blockChildren}>{(child, _index) => {
760
+ const index = _index();
761
+ return <Block_default
762
+ key={child.id}
763
+ block={child}
764
+ context={props.context}
765
+ registeredComponents={props.registeredComponents}
766
+ />;
767
+ }}</For></Dynamic3></Show4>;
778
768
  }
779
769
  var Component_ref_default = ComponentRef;
780
770
 
@@ -851,41 +841,10 @@ function Block(props) {
851
841
  isInteractive: !blockComponent()?.isRSC
852
842
  };
853
843
  }
854
- return <Show5 when={canShowBlock()}><Show5
855
- fallback={<Component_ref_default
856
- componentRef={componentRefProps().componentRef}
857
- componentOptions={componentRefProps().componentOptions}
858
- blockChildren={componentRefProps().blockChildren}
859
- context={componentRefProps().context}
860
- registeredComponents={componentRefProps().registeredComponents}
861
- builderBlock={componentRefProps().builderBlock}
862
- includeBlockProps={componentRefProps().includeBlockProps}
863
- isInteractive={componentRefProps().isInteractive}
864
- />}
865
- when={!blockComponent()?.noWrap}
866
- >
867
- <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
868
- Wrapper={Tag()}
869
- block={processedBlock()}
870
- context={props.context}
871
- hasChildren={false}
872
- /></Show5>
873
- <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
874
- const index = _index();
875
- return <Repeated_block_default
876
- key={index}
877
- repeatContext={data.context}
878
- block={data.block}
879
- registeredComponents={props.registeredComponents}
880
- />;
881
- }}</For2></Show5>
882
- <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
883
- Wrapper={Tag()}
884
- block={processedBlock()}
885
- context={props.context}
886
- hasChildren={true}
887
- >
888
- <Component_ref_default
844
+ return <Show5 when={canShowBlock()}>
845
+ <Block_styles_default block={props.block} context={props.context} />
846
+ <Show5
847
+ fallback={<Component_ref_default
889
848
  componentRef={componentRefProps().componentRef}
890
849
  componentOptions={componentRefProps().componentOptions}
891
850
  blockChildren={componentRefProps().blockChildren}
@@ -894,26 +853,52 @@ function Block(props) {
894
853
  builderBlock={componentRefProps().builderBlock}
895
854
  includeBlockProps={componentRefProps().includeBlockProps}
896
855
  isInteractive={componentRefProps().isInteractive}
897
- />
898
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
856
+ />}
857
+ when={!blockComponent()?.noWrap}
858
+ >
859
+ <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
860
+ Wrapper={Tag()}
861
+ block={processedBlock()}
862
+ context={props.context}
863
+ hasChildren={false}
864
+ /></Show5>
865
+ <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
899
866
  const index = _index();
900
- return <Block
901
- key={"block-" + child.id}
902
- block={child}
903
- context={childrenContext()}
867
+ return <Repeated_block_default
868
+ key={index}
869
+ repeatContext={data.context}
870
+ block={data.block}
904
871
  registeredComponents={props.registeredComponents}
905
872
  />;
906
- }}</For2>
907
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
908
- const index = _index();
909
- return <Block_styles_default
910
- key={"block-style-" + child.id}
911
- block={child}
912
- context={childrenContext()}
913
- />;
914
- }}</For2>
915
- </Block_wrapper_default></Show5>
916
- </Show5></Show5>;
873
+ }}</For2></Show5>
874
+ <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
875
+ Wrapper={Tag()}
876
+ block={processedBlock()}
877
+ context={props.context}
878
+ hasChildren={true}
879
+ >
880
+ <Component_ref_default
881
+ componentRef={componentRefProps().componentRef}
882
+ componentOptions={componentRefProps().componentOptions}
883
+ blockChildren={componentRefProps().blockChildren}
884
+ context={componentRefProps().context}
885
+ registeredComponents={componentRefProps().registeredComponents}
886
+ builderBlock={componentRefProps().builderBlock}
887
+ includeBlockProps={componentRefProps().includeBlockProps}
888
+ isInteractive={componentRefProps().isInteractive}
889
+ />
890
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
891
+ const index = _index();
892
+ return <Block
893
+ key={child.id}
894
+ block={child}
895
+ context={childrenContext()}
896
+ registeredComponents={props.registeredComponents}
897
+ />;
898
+ }}</For2>
899
+ </Block_wrapper_default></Show5>
900
+ </Show5>
901
+ </Show5>;
917
902
  }
918
903
  var Block_default = Block;
919
904
 
@@ -982,25 +967,15 @@ function Blocks(props) {
982
967
  styleProp={props.styleProp}
983
968
  BlocksWrapper={props.context?.BlocksWrapper}
984
969
  BlocksWrapperProps={props.context?.BlocksWrapperProps}
985
- >
986
- <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
987
- const index = _index();
988
- return <Block_default
989
- key={"render-block-" + block.id}
990
- block={block}
991
- context={props.context || builderContext}
992
- registeredComponents={props.registeredComponents || componentsContext.registeredComponents}
993
- />;
994
- }}</For3></Show6>
995
- <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
996
- const index = _index();
997
- return <Block_styles_default
998
- key={"block-style-" + block.id}
999
- block={block}
1000
- context={props.context || builderContext}
1001
- />;
1002
- }}</For3></Show6>
1003
- </Blocks_wrapper_default>;
970
+ ><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
971
+ const index = _index();
972
+ return <Block_default
973
+ key={block.id}
974
+ block={block}
975
+ context={props.context || builderContext}
976
+ registeredComponents={props.registeredComponents || componentsContext.registeredComponents}
977
+ />;
978
+ }}</For3></Show6></Blocks_wrapper_default>;
1004
979
  }
1005
980
  var Blocks_default = Blocks;
1006
981
 
@@ -2963,7 +2938,7 @@ var getInteractionPropertiesForEvent = (event) => {
2963
2938
  };
2964
2939
 
2965
2940
  // src/constants/sdk-version.ts
2966
- var SDK_VERSION = "0.11.1";
2941
+ var SDK_VERSION = "0.11.3";
2967
2942
 
2968
2943
  // src/functions/register.ts
2969
2944
  var registry = {};