@builder.io/sdk-solid 0.11.2 → 0.11.4

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.2";
3253
+ var SDK_VERSION = "0.11.4";
3302
3254
 
3303
3255
  // src/functions/register.ts
3304
3256
  var registry = {};
@@ -3434,11 +3386,26 @@ var setupBrowserForEditing = (options = {}) => {
3434
3386
  // src/components/content/components/enable-editor.tsx
3435
3387
  function EnableEditor(props) {
3436
3388
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
3389
+ createSignal(true);
3437
3390
  createSignal(0);
3438
3391
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
3439
3392
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
3440
3393
  const [httpReqsData, setHttpReqsData] = createSignal({});
3441
3394
  const [clicked, setClicked] = createSignal(false);
3395
+ function mergeNewRootState(newData) {
3396
+ const combinedState = {
3397
+ ...props.builderContextSignal.rootState,
3398
+ ...newData
3399
+ };
3400
+ if (props.builderContextSignal.rootSetState) {
3401
+ props.builderContextSignal.rootSetState?.(combinedState);
3402
+ } else {
3403
+ props.setBuilderContextSignal((PREVIOUS_VALUE) => ({
3404
+ ...PREVIOUS_VALUE,
3405
+ rootState: combinedState
3406
+ }));
3407
+ }
3408
+ }
3442
3409
  function mergeNewContent(newContent) {
3443
3410
  const newContentValue = {
3444
3411
  ...props.builderContextSignal.content,
@@ -3659,6 +3626,20 @@ function EnableEditor(props) {
3659
3626
  emitStateUpdate();
3660
3627
  }
3661
3628
  createEffect(on(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3629
+ function onUpdateFn_5() {
3630
+ if (props.data) {
3631
+ mergeNewRootState(props.data);
3632
+ }
3633
+ }
3634
+ createEffect(on(() => [props.data], onUpdateFn_5));
3635
+ function onUpdateFn_6() {
3636
+ if (props.locale) {
3637
+ mergeNewRootState({
3638
+ locale: props.locale
3639
+ });
3640
+ }
3641
+ }
3642
+ createEffect(on(() => [props.locale], onUpdateFn_6));
3662
3643
  return createComponent(builder_context_default.Provider, {
3663
3644
  get value() {
3664
3645
  return props.builderContextSignal;
@@ -3794,7 +3775,7 @@ ${getFontCss({
3794
3775
  var styles_default = ContentStyles;
3795
3776
 
3796
3777
  // src/components/content/content.helpers.ts
3797
- var getContextStateInitialValue = ({
3778
+ var getRootStateInitialValue = ({
3798
3779
  content,
3799
3780
  data,
3800
3781
  locale
@@ -3862,7 +3843,7 @@ function ContentComponent(props) {
3862
3843
  data: props.data
3863
3844
  }),
3864
3845
  localState: void 0,
3865
- rootState: getContextStateInitialValue({
3846
+ rootState: getRootStateInitialValue({
3866
3847
  content: props.content,
3867
3848
  data: props.data,
3868
3849
  locale: props.locale
@@ -3908,6 +3889,9 @@ function ContentComponent(props) {
3908
3889
  get content() {
3909
3890
  return props.content;
3910
3891
  },
3892
+ get data() {
3893
+ return props.data;
3894
+ },
3911
3895
  get model() {
3912
3896
  return props.model;
3913
3897
  },