@builder.io/sdk-solid 0.8.1 → 0.10.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.
@@ -55,7 +55,9 @@ var builder_context_default = createContext({
55
55
  apiKey: null,
56
56
  apiVersion: void 0,
57
57
  componentInfos: {},
58
- inheritedStyles: {}
58
+ inheritedStyles: {},
59
+ BlocksWrapper: "div",
60
+ BlocksWrapperProps: {}
59
61
  });
60
62
  var components_context_default = createContext({ registeredComponents: {} });
61
63
 
@@ -608,78 +610,10 @@ function getBlockActions(options) {
608
610
  return obj;
609
611
  }
610
612
 
611
- // src/functions/sanitize-react-native-block-styles.ts
612
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
613
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
614
- var normalizeNumber = (value) => {
615
- if (Number.isNaN(value)) {
616
- return void 0;
617
- } else if (value < 0) {
618
- return 0;
619
- } else {
620
- return value;
621
- }
622
- };
623
- var sanitizeReactNativeBlockStyles = (styles) => {
624
- return Object.keys(styles).reduce((acc, key) => {
625
- const propertyValue = styles[key];
626
- if (key === "display" && !displayValues.has(propertyValue)) {
627
- return acc;
628
- }
629
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
630
- return acc;
631
- }
632
- if (typeof propertyValue === "string") {
633
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
634
- if (isPixelUnit) {
635
- const newValue = parseFloat(propertyValue);
636
- const normalizedValue = normalizeNumber(newValue);
637
- if (normalizedValue) {
638
- return {
639
- ...acc,
640
- [key]: normalizedValue
641
- };
642
- } else {
643
- return acc;
644
- }
645
- } else if (propertyValue === "0") {
646
- return {
647
- ...acc,
648
- [key]: 0
649
- };
650
- }
651
- }
652
- return {
653
- ...acc,
654
- [key]: propertyValue
655
- };
656
- }, {});
657
- };
658
-
659
- // src/functions/get-react-native-block-styles.ts
660
- function getReactNativeBlockStyles({
661
- block,
662
- context,
663
- blockStyles
664
- }) {
665
- const responsiveStyles = block.responsiveStyles;
666
- if (!responsiveStyles) {
667
- return {};
668
- }
669
- const styles = {
670
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
671
- ...context.inheritedStyles,
672
- ...responsiveStyles.large || {},
673
- ...responsiveStyles.medium || {},
674
- ...responsiveStyles.small || {},
675
- ...blockStyles
676
- };
677
- const newStyles = sanitizeReactNativeBlockStyles(styles);
678
- return newStyles;
679
- }
680
-
681
613
  // src/functions/transform-block-properties.ts
682
- function transformBlockProperties(properties) {
614
+ function transformBlockProperties({
615
+ properties
616
+ }) {
683
617
  return properties;
684
618
  }
685
619
 
@@ -700,14 +634,11 @@ function getBlockProperties({
700
634
  style: block.style ? getStyleAttribute(block.style) : void 0,
701
635
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
702
636
  };
703
- if (TARGET === "reactNative") {
704
- properties.style = getReactNativeBlockStyles({
705
- block,
706
- context,
707
- blockStyles: properties.style
708
- });
709
- }
710
- return transformBlockProperties(properties);
637
+ return transformBlockProperties({
638
+ properties,
639
+ context,
640
+ block
641
+ });
711
642
  }
712
643
  function getStyleAttribute(style) {
713
644
  switch (TARGET) {
@@ -1145,7 +1076,6 @@ function Block(props) {
1145
1076
  });
1146
1077
  }
1147
1078
  var block_default = Block;
1148
- var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1149
1079
  function BlocksWrapper(props) {
1150
1080
  function className() {
1151
1081
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -1172,33 +1102,35 @@ function BlocksWrapper(props) {
1172
1102
  }, "*");
1173
1103
  }
1174
1104
  }
1175
- return (() => {
1176
- const _el$ = _tmpl$4();
1177
- spread(_el$, mergeProps({
1178
- get ["class"]() {
1179
- return className() + " " + css({
1180
- display: "flex",
1181
- flexDirection: "column",
1182
- alignItems: "stretch"
1183
- });
1184
- },
1185
- get ["builder-path"]() {
1186
- return props.path;
1187
- },
1188
- get ["builder-parent-id"]() {
1189
- return props.parent;
1190
- }
1191
- }, {}, {
1192
- get style() {
1193
- return props.styleProp;
1194
- },
1195
- "onClick": (event) => onClick(),
1196
- "onMouseEnter": (event) => onMouseEnter(),
1197
- "onKeyPress": (event) => onClick()
1198
- }), false, true);
1199
- insert(_el$, () => props.children);
1200
- return _el$;
1201
- })();
1105
+ return createComponent(Dynamic, mergeProps({
1106
+ get ["class"]() {
1107
+ return className() + " " + css({
1108
+ display: "flex",
1109
+ flexDirection: "column",
1110
+ alignItems: "stretch"
1111
+ });
1112
+ },
1113
+ get ["builder-path"]() {
1114
+ return props.path;
1115
+ },
1116
+ get ["builder-parent-id"]() {
1117
+ return props.parent;
1118
+ }
1119
+ }, {}, {
1120
+ get style() {
1121
+ return props.styleProp;
1122
+ },
1123
+ onClick: (event) => onClick(),
1124
+ onMouseEnter: (event) => onMouseEnter(),
1125
+ onKeyPress: (event) => onClick()
1126
+ }, () => props.BlocksWrapperProps, {
1127
+ get component() {
1128
+ return props.BlocksWrapper;
1129
+ },
1130
+ get children() {
1131
+ return props.children;
1132
+ }
1133
+ }));
1202
1134
  }
1203
1135
  var blocks_wrapper_default = BlocksWrapper;
1204
1136
 
@@ -1219,6 +1151,12 @@ function Blocks(props) {
1219
1151
  get styleProp() {
1220
1152
  return props.styleProp;
1221
1153
  },
1154
+ get BlocksWrapper() {
1155
+ return props.context?.BlocksWrapper;
1156
+ },
1157
+ get BlocksWrapperProps() {
1158
+ return props.context?.BlocksWrapperProps;
1159
+ },
1222
1160
  get children() {
1223
1161
  return [createComponent(Show, {
1224
1162
  get when() {
@@ -1276,7 +1214,7 @@ function Blocks(props) {
1276
1214
  var blocks_default = Blocks;
1277
1215
 
1278
1216
  // src/blocks/columns/columns.tsx
1279
- var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
1217
+ var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1280
1218
  function Columns(props) {
1281
1219
  const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
1282
1220
  const [cols, setCols] = createSignal(props.columns || []);
@@ -1370,7 +1308,7 @@ function Columns(props) {
1370
1308
  `;
1371
1309
  }
1372
1310
  return (() => {
1373
- const _el$ = _tmpl$5();
1311
+ const _el$ = _tmpl$4();
1374
1312
  spread(_el$, mergeProps({
1375
1313
  get ["class"]() {
1376
1314
  return `builder-columns ${props.builderBlock.id}-breakpoints ` + css({
@@ -1399,7 +1337,7 @@ function Columns(props) {
1399
1337
  children: (column, _index) => {
1400
1338
  const index = _index();
1401
1339
  return (() => {
1402
- const _el$2 = _tmpl$5();
1340
+ const _el$2 = _tmpl$4();
1403
1341
  spread(_el$2, mergeProps({
1404
1342
  get ["class"]() {
1405
1343
  return "builder-column " + css({
@@ -1440,10 +1378,10 @@ function Columns(props) {
1440
1378
  })();
1441
1379
  }
1442
1380
  var columns_default = Columns;
1443
- var _tmpl$6 = /* @__PURE__ */ template(`<span>`);
1381
+ var _tmpl$5 = /* @__PURE__ */ template(`<span>`);
1444
1382
  function FragmentComponent(props) {
1445
1383
  return (() => {
1446
- const _el$ = _tmpl$6();
1384
+ const _el$ = _tmpl$5();
1447
1385
  insert(_el$, () => props.children);
1448
1386
  return _el$;
1449
1387
  })();
@@ -1498,7 +1436,7 @@ function getSrcSet(url) {
1498
1436
  }
1499
1437
 
1500
1438
  // src/blocks/image/image.tsx
1501
- var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
1439
+ var _tmpl$6 = /* @__PURE__ */ template(`<source type=image/webp>`);
1502
1440
  var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
1503
1441
  var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
1504
1442
  function Image(props) {
@@ -1544,7 +1482,7 @@ function Image(props) {
1544
1482
  return webpSrcSet();
1545
1483
  },
1546
1484
  get children() {
1547
- const _el$2 = _tmpl$7();
1485
+ const _el$2 = _tmpl$6();
1548
1486
  effect(() => setAttribute(_el$2, "srcset", webpSrcSet()));
1549
1487
  return _el$2;
1550
1488
  }
@@ -1626,10 +1564,10 @@ function Image(props) {
1626
1564
  })];
1627
1565
  }
1628
1566
  var image_default = Image;
1629
- var _tmpl$8 = /* @__PURE__ */ template(`<section>`);
1567
+ var _tmpl$7 = /* @__PURE__ */ template(`<section>`);
1630
1568
  function SectionComponent(props) {
1631
1569
  return (() => {
1632
- const _el$ = _tmpl$8();
1570
+ const _el$ = _tmpl$7();
1633
1571
  spread(_el$, mergeProps({}, () => props.attributes, {
1634
1572
  get style() {
1635
1573
  return {
@@ -2123,7 +2061,7 @@ var componentInfo3 = {
2123
2061
  advanced: true
2124
2062
  }]
2125
2063
  };
2126
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
2064
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
2127
2065
  function CustomCode(props) {
2128
2066
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2129
2067
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2157,7 +2095,7 @@ function CustomCode(props) {
2157
2095
  }
2158
2096
  });
2159
2097
  return (() => {
2160
- const _el$ = _tmpl$9();
2098
+ const _el$ = _tmpl$8();
2161
2099
  const _ref$ = elementRef;
2162
2100
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2163
2101
  effect((_p$) => {
@@ -2217,7 +2155,7 @@ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "applicati
2217
2155
  var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2218
2156
 
2219
2157
  // src/blocks/embed/embed.tsx
2220
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2158
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2221
2159
  function Embed(props) {
2222
2160
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2223
2161
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2252,7 +2190,7 @@ function Embed(props) {
2252
2190
  }
2253
2191
  createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2254
2192
  return (() => {
2255
- const _el$ = _tmpl$10();
2193
+ const _el$ = _tmpl$9();
2256
2194
  const _ref$ = elem;
2257
2195
  typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2258
2196
  effect(() => _el$.innerHTML = props.content);
@@ -2408,10 +2346,10 @@ var componentInfo7 = {
2408
2346
  noWrap: true,
2409
2347
  static: true
2410
2348
  };
2411
- var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
2349
+ var _tmpl$10 = /* @__PURE__ */ template(`<img>`);
2412
2350
  function ImgComponent(props) {
2413
2351
  return (() => {
2414
- const _el$ = _tmpl$11();
2352
+ const _el$ = _tmpl$10();
2415
2353
  spread(_el$, mergeProps({
2416
2354
  get style() {
2417
2355
  return {
@@ -2532,10 +2470,10 @@ var componentInfo10 = {
2532
2470
  textAlign: "center"
2533
2471
  }
2534
2472
  };
2535
- var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
2473
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class=builder-text>`);
2536
2474
  function Text(props) {
2537
2475
  return (() => {
2538
- const _el$ = _tmpl$12();
2476
+ const _el$ = _tmpl$11();
2539
2477
  _el$.style.setProperty("outline", "none");
2540
2478
  effect(() => _el$.innerHTML = props.text?.toString() || "");
2541
2479
  return _el$;
@@ -2626,7 +2564,7 @@ var componentInfo11 = {
2626
2564
  advanced: true
2627
2565
  }]
2628
2566
  };
2629
- var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2567
+ var _tmpl$12 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2630
2568
  var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
2631
2569
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
2632
2570
  function Video(props) {
@@ -2689,7 +2627,7 @@ function Video(props) {
2689
2627
  return !props.lazyLoad;
2690
2628
  },
2691
2629
  get children() {
2692
- const _el$3 = _tmpl$13();
2630
+ const _el$3 = _tmpl$12();
2693
2631
  effect(() => setAttribute(_el$3, "src", props.video));
2694
2632
  return _el$3;
2695
2633
  }
@@ -2848,10 +2786,10 @@ var getUpdateVariantVisibilityScript = ({
2848
2786
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
2849
2787
  "${variationId}", "${contentId}", ${isHydrationTarget}
2850
2788
  )`;
2851
- var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
2789
+ var _tmpl$13 = /* @__PURE__ */ template(`<script>`);
2852
2790
  function InlinedScript(props) {
2853
2791
  return (() => {
2854
- const _el$ = _tmpl$14();
2792
+ const _el$ = _tmpl$13();
2855
2793
  effect((_p$) => {
2856
2794
  const _v$ = props.scriptStr, _v$2 = props.id || "";
2857
2795
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -3038,7 +2976,7 @@ async function fetchOneEntry(options) {
3038
2976
  limit: 1
3039
2977
  });
3040
2978
  if (allContent) {
3041
- return allContent.results[0] || null;
2979
+ return allContent[0] || null;
3042
2980
  }
3043
2981
  return null;
3044
2982
  }
@@ -3061,9 +2999,9 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
3061
2999
  content.results = newResults;
3062
3000
  }
3063
3001
  if (!canTrack)
3064
- return content;
3002
+ return content.results;
3065
3003
  if (!(isBrowser() || TARGET === "reactNative"))
3066
- return content;
3004
+ return content.results;
3067
3005
  try {
3068
3006
  const newResults = [];
3069
3007
  for (const item of content.results) {
@@ -3076,7 +3014,7 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
3076
3014
  } catch (e) {
3077
3015
  logger.error("Could not process A/B tests. ", e);
3078
3016
  }
3079
- return content;
3017
+ return content.results;
3080
3018
  };
3081
3019
  async function fetchEntries(options) {
3082
3020
  try {
@@ -3346,7 +3284,7 @@ var getInteractionPropertiesForEvent = (event) => {
3346
3284
  };
3347
3285
 
3348
3286
  // src/constants/sdk-version.ts
3349
- var SDK_VERSION = "0.8.1";
3287
+ var SDK_VERSION = "0.10.0";
3350
3288
 
3351
3289
  // src/functions/register.ts
3352
3290
  var registry = {};
@@ -3479,11 +3417,11 @@ var setupBrowserForEditing = (options = {}) => {
3479
3417
  };
3480
3418
 
3481
3419
  // src/components/content/components/enable-editor.tsx
3482
- var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
3483
3420
  function EnableEditor(props) {
3484
3421
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
3485
3422
  createSignal(0);
3486
3423
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
3424
+ const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
3487
3425
  const [httpReqsData, setHttpReqsData] = createSignal({});
3488
3426
  const [clicked, setClicked] = createSignal(false);
3489
3427
  function mergeNewContent(newContent) {
@@ -3715,10 +3653,7 @@ function EnableEditor(props) {
3715
3653
  return props.builderContextSignal.content;
3716
3654
  },
3717
3655
  get children() {
3718
- const _el$ = _tmpl$15();
3719
- const _ref$ = elementRef;
3720
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
3721
- spread(_el$, mergeProps({
3656
+ return createComponent(Dynamic, mergeProps({
3722
3657
  get ["class"]() {
3723
3658
  return `variant-${props.content?.testVariationId || props.content?.id}`;
3724
3659
  }
@@ -3726,7 +3661,11 @@ function EnableEditor(props) {
3726
3661
  get key() {
3727
3662
  return forceReRenderCount();
3728
3663
  },
3729
- "onClick": (event) => onClick(event),
3664
+ ref(r$) {
3665
+ const _ref$ = elementRef;
3666
+ typeof _ref$ === "function" ? _ref$(r$) : elementRef = r$;
3667
+ },
3668
+ onClick: (event) => onClick(event),
3730
3669
  get ["builder-content-id"]() {
3731
3670
  return props.builderContextSignal.content?.id;
3732
3671
  },
@@ -3736,9 +3675,14 @@ function EnableEditor(props) {
3736
3675
  }, {}, () => props.showContent ? {} : {
3737
3676
  hidden: true,
3738
3677
  "aria-hidden": true
3739
- }), false, true);
3740
- insert(_el$, () => props.children);
3741
- return _el$;
3678
+ }, () => props.contentWrapperProps, {
3679
+ get component() {
3680
+ return ContentWrapper();
3681
+ },
3682
+ get children() {
3683
+ return props.children;
3684
+ }
3685
+ }));
3742
3686
  }
3743
3687
  });
3744
3688
  }
@@ -3927,7 +3871,9 @@ function ContentComponent(props) {
3927
3871
  ...acc,
3928
3872
  [info.name]: serializeComponentInfo(info)
3929
3873
  }), {}),
3930
- inheritedStyles: {}
3874
+ inheritedStyles: {},
3875
+ BlocksWrapper: props.blocksWrapper || "div",
3876
+ BlocksWrapperProps: props.blocksWrapperProps || {}
3931
3877
  });
3932
3878
  function contentSetState(newRootState) {
3933
3879
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -3972,6 +3918,12 @@ function ContentComponent(props) {
3972
3918
  },
3973
3919
  get builderContextSignal() {
3974
3920
  return builderContextSignal();
3921
+ },
3922
+ get contentWrapper() {
3923
+ return props.contentWrapper;
3924
+ },
3925
+ get contentWrapperProps() {
3926
+ return props.contentWrapperProps;
3975
3927
  }
3976
3928
  }, {
3977
3929
  setBuilderContextSignal
@@ -4119,6 +4071,18 @@ function ContentVariants(props) {
4119
4071
  },
4120
4072
  get isSsrAbTest() {
4121
4073
  return shouldRenderVariants();
4074
+ },
4075
+ get blocksWrapper() {
4076
+ return props.blocksWrapper;
4077
+ },
4078
+ get blocksWrapperProps() {
4079
+ return props.blocksWrapperProps;
4080
+ },
4081
+ get contentWrapper() {
4082
+ return props.contentWrapper;
4083
+ },
4084
+ get contentWrapperProps() {
4085
+ return props.contentWrapperProps;
4122
4086
  }
4123
4087
  });
4124
4088
  }
@@ -4161,6 +4125,18 @@ function ContentVariants(props) {
4161
4125
  },
4162
4126
  get isSsrAbTest() {
4163
4127
  return shouldRenderVariants();
4128
+ },
4129
+ get blocksWrapper() {
4130
+ return props.blocksWrapper;
4131
+ },
4132
+ get blocksWrapperProps() {
4133
+ return props.blocksWrapperProps;
4134
+ },
4135
+ get contentWrapper() {
4136
+ return props.contentWrapper;
4137
+ },
4138
+ get contentWrapperProps() {
4139
+ return props.contentWrapperProps;
4164
4140
  }
4165
4141
  }))];
4166
4142
  }
@@ -4191,7 +4167,7 @@ var fetchSymbolContent = async ({
4191
4167
  };
4192
4168
 
4193
4169
  // src/blocks/symbol/symbol.tsx
4194
- var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
4170
+ var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
4195
4171
  function Symbol(props) {
4196
4172
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
4197
4173
  function className() {
@@ -4217,7 +4193,7 @@ function Symbol(props) {
4217
4193
  }
4218
4194
  createEffect(on(() => [props.symbol], onUpdateFn_0));
4219
4195
  return (() => {
4220
- const _el$ = _tmpl$16();
4196
+ const _el$ = _tmpl$14();
4221
4197
  spread(_el$, mergeProps({
4222
4198
  get ["class"]() {
4223
4199
  return className();