@builder.io/sdk-solid 0.8.1 → 0.9.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/lib/node/dev.jsx CHANGED
@@ -41,7 +41,9 @@ var builder_context_default = createContext({
41
41
  apiKey: null,
42
42
  apiVersion: void 0,
43
43
  componentInfos: {},
44
- inheritedStyles: {}
44
+ inheritedStyles: {},
45
+ BlocksWrapper: "div",
46
+ BlocksWrapperProps: {}
45
47
  });
46
48
 
47
49
  // src/context/components.context.ts
@@ -724,85 +726,10 @@ function getBlockActions(options) {
724
726
  return obj;
725
727
  }
726
728
 
727
- // src/functions/sanitize-react-native-block-styles.ts
728
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
729
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
730
- var SHOW_WARNINGS = false;
731
- var normalizeNumber = (value) => {
732
- if (Number.isNaN(value)) {
733
- return void 0;
734
- } else if (value < 0) {
735
- return 0;
736
- } else {
737
- return value;
738
- }
739
- };
740
- var sanitizeReactNativeBlockStyles = (styles) => {
741
- return Object.keys(styles).reduce((acc, key) => {
742
- const propertyValue = styles[key];
743
- if (key === "display" && !displayValues.has(propertyValue)) {
744
- if (SHOW_WARNINGS) {
745
- console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
746
- }
747
- return acc;
748
- }
749
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
750
- if (SHOW_WARNINGS) {
751
- console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
752
- }
753
- return acc;
754
- }
755
- if (typeof propertyValue === "string") {
756
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
757
- if (isPixelUnit) {
758
- const newValue = parseFloat(propertyValue);
759
- const normalizedValue = normalizeNumber(newValue);
760
- if (normalizedValue) {
761
- return {
762
- ...acc,
763
- [key]: normalizedValue
764
- };
765
- } else {
766
- return acc;
767
- }
768
- } else if (propertyValue === "0") {
769
- return {
770
- ...acc,
771
- [key]: 0
772
- };
773
- }
774
- }
775
- return {
776
- ...acc,
777
- [key]: propertyValue
778
- };
779
- }, {});
780
- };
781
-
782
- // src/functions/get-react-native-block-styles.ts
783
- function getReactNativeBlockStyles({
784
- block,
785
- context,
786
- blockStyles
787
- }) {
788
- const responsiveStyles = block.responsiveStyles;
789
- if (!responsiveStyles) {
790
- return {};
791
- }
792
- const styles = {
793
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
794
- ...context.inheritedStyles,
795
- ...responsiveStyles.large || {},
796
- ...responsiveStyles.medium || {},
797
- ...responsiveStyles.small || {},
798
- ...blockStyles
799
- };
800
- const newStyles = sanitizeReactNativeBlockStyles(styles);
801
- return newStyles;
802
- }
803
-
804
729
  // src/functions/transform-block-properties.ts
805
- function transformBlockProperties(properties) {
730
+ function transformBlockProperties({
731
+ properties
732
+ }) {
806
733
  return properties;
807
734
  }
808
735
 
@@ -823,14 +750,11 @@ function getBlockProperties({
823
750
  style: block.style ? getStyleAttribute(block.style) : void 0,
824
751
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
825
752
  };
826
- if (TARGET === "reactNative") {
827
- properties.style = getReactNativeBlockStyles({
828
- block,
829
- context,
830
- blockStyles: properties.style
831
- });
832
- }
833
- return transformBlockProperties(properties);
753
+ return transformBlockProperties({
754
+ properties,
755
+ context,
756
+ block
757
+ });
834
758
  }
835
759
  function getStyleAttribute(style) {
836
760
  switch (TARGET) {
@@ -1120,6 +1044,7 @@ function Block(props) {
1120
1044
  var Block_default = Block;
1121
1045
 
1122
1046
  // src/components/blocks/blocks-wrapper.tsx
1047
+ import { Dynamic as Dynamic4 } from "solid-js/web";
1123
1048
  import { css as css2 } from "solid-styled-components";
1124
1049
  function BlocksWrapper(props) {
1125
1050
  function className() {
@@ -1153,7 +1078,7 @@ function BlocksWrapper(props) {
1153
1078
  );
1154
1079
  }
1155
1080
  }
1156
- return <div
1081
+ return <Dynamic4
1157
1082
  class={className() + " " + css2({
1158
1083
  display: "flex",
1159
1084
  flexDirection: "column",
@@ -1166,7 +1091,9 @@ function BlocksWrapper(props) {
1166
1091
  onClick={(event) => onClick()}
1167
1092
  onMouseEnter={(event) => onMouseEnter()}
1168
1093
  onKeyPress={(event) => onClick()}
1169
- >{props.children}</div>;
1094
+ {...props.BlocksWrapperProps}
1095
+ component={props.BlocksWrapper}
1096
+ >{props.children}</Dynamic4>;
1170
1097
  }
1171
1098
  var Blocks_wrapper_default = BlocksWrapper;
1172
1099
 
@@ -1179,6 +1106,8 @@ function Blocks(props) {
1179
1106
  parent={props.parent}
1180
1107
  path={props.path}
1181
1108
  styleProp={props.styleProp}
1109
+ BlocksWrapper={props.context?.BlocksWrapper}
1110
+ BlocksWrapperProps={props.context?.BlocksWrapperProps}
1182
1111
  >
1183
1112
  <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
1184
1113
  const index = _index();
@@ -2673,6 +2602,7 @@ var Inlined_script_default = InlinedScript;
2673
2602
 
2674
2603
  // src/components/content/components/enable-editor.tsx
2675
2604
  import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2605
+ import { Dynamic as Dynamic5 } from "solid-js/web";
2676
2606
 
2677
2607
  // src/helpers/preview-lru-cache/get.ts
2678
2608
  function getPreviewContent(_searchParams) {
@@ -3159,7 +3089,7 @@ var getInteractionPropertiesForEvent = (event) => {
3159
3089
  };
3160
3090
 
3161
3091
  // src/constants/sdk-version.ts
3162
- var SDK_VERSION = "0.8.1";
3092
+ var SDK_VERSION = "0.9.0";
3163
3093
 
3164
3094
  // src/functions/register.ts
3165
3095
  var registry = {};
@@ -3297,6 +3227,9 @@ function EnableEditor(props) {
3297
3227
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
3298
3228
  const [lastUpdated, setLastUpdated] = createSignal10(0);
3299
3229
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
3230
+ const [ContentWrapper, setContentWrapper] = createSignal10(
3231
+ props.contentWrapper || "div"
3232
+ );
3300
3233
  const [httpReqsData, setHttpReqsData] = createSignal10({});
3301
3234
  const [clicked, setClicked] = createSignal10(false);
3302
3235
  function mergeNewContent(newContent) {
@@ -3541,7 +3474,7 @@ function EnableEditor(props) {
3541
3474
  emitStateUpdate();
3542
3475
  }
3543
3476
  createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3544
- return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><div
3477
+ return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
3545
3478
  class={`variant-${props.content?.testVariationId || props.content?.id}`}
3546
3479
  {...{}}
3547
3480
  key={forceReRenderCount()}
@@ -3554,7 +3487,9 @@ function EnableEditor(props) {
3554
3487
  hidden: true,
3555
3488
  "aria-hidden": true
3556
3489
  }}
3557
- >{props.children}</div></Show10></builder_context_default.Provider>;
3490
+ {...props.contentWrapperProps}
3491
+ component={ContentWrapper()}
3492
+ >{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
3558
3493
  }
3559
3494
  var Enable_editor_default = EnableEditor;
3560
3495
 
@@ -3744,7 +3679,9 @@ function ContentComponent(props) {
3744
3679
  }),
3745
3680
  {}
3746
3681
  ),
3747
- inheritedStyles: {}
3682
+ inheritedStyles: {},
3683
+ BlocksWrapper: props.blocksWrapper || "div",
3684
+ BlocksWrapperProps: props.blocksWrapperProps || {}
3748
3685
  });
3749
3686
  function contentSetState(newRootState) {
3750
3687
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -3767,6 +3704,8 @@ function ContentComponent(props) {
3767
3704
  enrich={props.enrich}
3768
3705
  showContent={props.showContent}
3769
3706
  builderContextSignal={builderContextSignal()}
3707
+ contentWrapper={props.contentWrapper}
3708
+ contentWrapperProps={props.contentWrapperProps}
3770
3709
  {...{
3771
3710
  setBuilderContextSignal
3772
3711
  }}
@@ -3845,6 +3784,10 @@ function ContentVariants(props) {
3845
3784
  includeRefs={props.includeRefs}
3846
3785
  enrich={props.enrich}
3847
3786
  isSsrAbTest={shouldRenderVariants()}
3787
+ blocksWrapper={props.blocksWrapper}
3788
+ blocksWrapperProps={props.blocksWrapperProps}
3789
+ contentWrapper={props.contentWrapper}
3790
+ contentWrapperProps={props.contentWrapperProps}
3848
3791
  />;
3849
3792
  }}</For5>
3850
3793
  </Show12>
@@ -3863,6 +3806,10 @@ function ContentVariants(props) {
3863
3806
  includeRefs={props.includeRefs}
3864
3807
  enrich={props.enrich}
3865
3808
  isSsrAbTest={shouldRenderVariants()}
3809
+ blocksWrapper={props.blocksWrapper}
3810
+ blocksWrapperProps={props.blocksWrapperProps}
3811
+ contentWrapper={props.contentWrapper}
3812
+ contentWrapperProps={props.contentWrapperProps}
3866
3813
  />
3867
3814
  </>;
3868
3815
  }