@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/index.js CHANGED
@@ -56,7 +56,9 @@ var builder_context_default = createContext({
56
56
  apiKey: null,
57
57
  apiVersion: void 0,
58
58
  componentInfos: {},
59
- inheritedStyles: {}
59
+ inheritedStyles: {},
60
+ BlocksWrapper: "div",
61
+ BlocksWrapperProps: {}
60
62
  });
61
63
  var components_context_default = createContext({ registeredComponents: {} });
62
64
 
@@ -731,78 +733,10 @@ function getBlockActions(options) {
731
733
  return obj;
732
734
  }
733
735
 
734
- // src/functions/sanitize-react-native-block-styles.ts
735
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
736
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
737
- var normalizeNumber = (value) => {
738
- if (Number.isNaN(value)) {
739
- return void 0;
740
- } else if (value < 0) {
741
- return 0;
742
- } else {
743
- return value;
744
- }
745
- };
746
- var sanitizeReactNativeBlockStyles = (styles) => {
747
- return Object.keys(styles).reduce((acc, key) => {
748
- const propertyValue = styles[key];
749
- if (key === "display" && !displayValues.has(propertyValue)) {
750
- return acc;
751
- }
752
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
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
736
  // src/functions/transform-block-properties.ts
805
- function transformBlockProperties(properties) {
737
+ function transformBlockProperties({
738
+ properties
739
+ }) {
806
740
  return properties;
807
741
  }
808
742
 
@@ -823,14 +757,11 @@ function getBlockProperties({
823
757
  style: block.style ? getStyleAttribute(block.style) : void 0,
824
758
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
825
759
  };
826
- if (TARGET === "reactNative") {
827
- properties.style = getReactNativeBlockStyles({
828
- block,
829
- context,
830
- blockStyles: properties.style
831
- });
832
- }
833
- return transformBlockProperties(properties);
760
+ return transformBlockProperties({
761
+ properties,
762
+ context,
763
+ block
764
+ });
834
765
  }
835
766
  function getStyleAttribute(style) {
836
767
  switch (TARGET) {
@@ -1268,7 +1199,6 @@ function Block(props) {
1268
1199
  });
1269
1200
  }
1270
1201
  var block_default = Block;
1271
- var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1272
1202
  function BlocksWrapper(props) {
1273
1203
  function className() {
1274
1204
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -1295,33 +1225,35 @@ function BlocksWrapper(props) {
1295
1225
  }, "*");
1296
1226
  }
1297
1227
  }
1298
- return (() => {
1299
- const _el$ = _tmpl$4();
1300
- spread(_el$, mergeProps({
1301
- get ["class"]() {
1302
- return className() + " " + css({
1303
- display: "flex",
1304
- flexDirection: "column",
1305
- alignItems: "stretch"
1306
- });
1307
- },
1308
- get ["builder-path"]() {
1309
- return props.path;
1310
- },
1311
- get ["builder-parent-id"]() {
1312
- return props.parent;
1313
- }
1314
- }, {}, {
1315
- get style() {
1316
- return props.styleProp;
1317
- },
1318
- "onClick": (event) => onClick(),
1319
- "onMouseEnter": (event) => onMouseEnter(),
1320
- "onKeyPress": (event) => onClick()
1321
- }), false, true);
1322
- insert(_el$, () => props.children);
1323
- return _el$;
1324
- })();
1228
+ return createComponent(Dynamic, mergeProps({
1229
+ get ["class"]() {
1230
+ return className() + " " + css({
1231
+ display: "flex",
1232
+ flexDirection: "column",
1233
+ alignItems: "stretch"
1234
+ });
1235
+ },
1236
+ get ["builder-path"]() {
1237
+ return props.path;
1238
+ },
1239
+ get ["builder-parent-id"]() {
1240
+ return props.parent;
1241
+ }
1242
+ }, {}, {
1243
+ get style() {
1244
+ return props.styleProp;
1245
+ },
1246
+ onClick: (event) => onClick(),
1247
+ onMouseEnter: (event) => onMouseEnter(),
1248
+ onKeyPress: (event) => onClick()
1249
+ }, () => props.BlocksWrapperProps, {
1250
+ get component() {
1251
+ return props.BlocksWrapper;
1252
+ },
1253
+ get children() {
1254
+ return props.children;
1255
+ }
1256
+ }));
1325
1257
  }
1326
1258
  var blocks_wrapper_default = BlocksWrapper;
1327
1259
 
@@ -1342,6 +1274,12 @@ function Blocks(props) {
1342
1274
  get styleProp() {
1343
1275
  return props.styleProp;
1344
1276
  },
1277
+ get BlocksWrapper() {
1278
+ return props.context?.BlocksWrapper;
1279
+ },
1280
+ get BlocksWrapperProps() {
1281
+ return props.context?.BlocksWrapperProps;
1282
+ },
1345
1283
  get children() {
1346
1284
  return [createComponent(Show, {
1347
1285
  get when() {
@@ -1399,7 +1337,7 @@ function Blocks(props) {
1399
1337
  var blocks_default = Blocks;
1400
1338
 
1401
1339
  // src/blocks/columns/columns.tsx
1402
- var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
1340
+ var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1403
1341
  function Columns(props) {
1404
1342
  const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
1405
1343
  const [cols, setCols] = createSignal(props.columns || []);
@@ -1493,7 +1431,7 @@ function Columns(props) {
1493
1431
  `;
1494
1432
  }
1495
1433
  return (() => {
1496
- const _el$ = _tmpl$5();
1434
+ const _el$ = _tmpl$4();
1497
1435
  spread(_el$, mergeProps({
1498
1436
  get ["class"]() {
1499
1437
  return `builder-columns ${props.builderBlock.id}-breakpoints ` + css({
@@ -1522,7 +1460,7 @@ function Columns(props) {
1522
1460
  children: (column, _index) => {
1523
1461
  const index = _index();
1524
1462
  return (() => {
1525
- const _el$2 = _tmpl$5();
1463
+ const _el$2 = _tmpl$4();
1526
1464
  spread(_el$2, mergeProps({
1527
1465
  get ["class"]() {
1528
1466
  return "builder-column " + css({
@@ -1563,10 +1501,10 @@ function Columns(props) {
1563
1501
  })();
1564
1502
  }
1565
1503
  var columns_default = Columns;
1566
- var _tmpl$6 = /* @__PURE__ */ template(`<span>`);
1504
+ var _tmpl$5 = /* @__PURE__ */ template(`<span>`);
1567
1505
  function FragmentComponent(props) {
1568
1506
  return (() => {
1569
- const _el$ = _tmpl$6();
1507
+ const _el$ = _tmpl$5();
1570
1508
  insert(_el$, () => props.children);
1571
1509
  return _el$;
1572
1510
  })();
@@ -1621,7 +1559,7 @@ function getSrcSet(url) {
1621
1559
  }
1622
1560
 
1623
1561
  // src/blocks/image/image.tsx
1624
- var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
1562
+ var _tmpl$6 = /* @__PURE__ */ template(`<source type=image/webp>`);
1625
1563
  var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
1626
1564
  var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
1627
1565
  function Image(props) {
@@ -1667,7 +1605,7 @@ function Image(props) {
1667
1605
  return webpSrcSet();
1668
1606
  },
1669
1607
  get children() {
1670
- const _el$2 = _tmpl$7();
1608
+ const _el$2 = _tmpl$6();
1671
1609
  effect(() => setAttribute(_el$2, "srcset", webpSrcSet()));
1672
1610
  return _el$2;
1673
1611
  }
@@ -1749,10 +1687,10 @@ function Image(props) {
1749
1687
  })];
1750
1688
  }
1751
1689
  var image_default = Image;
1752
- var _tmpl$8 = /* @__PURE__ */ template(`<section>`);
1690
+ var _tmpl$7 = /* @__PURE__ */ template(`<section>`);
1753
1691
  function SectionComponent(props) {
1754
1692
  return (() => {
1755
- const _el$ = _tmpl$8();
1693
+ const _el$ = _tmpl$7();
1756
1694
  spread(_el$, mergeProps({}, () => props.attributes, {
1757
1695
  get style() {
1758
1696
  return {
@@ -2246,7 +2184,7 @@ var componentInfo3 = {
2246
2184
  advanced: true
2247
2185
  }]
2248
2186
  };
2249
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
2187
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
2250
2188
  function CustomCode(props) {
2251
2189
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2252
2190
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2280,7 +2218,7 @@ function CustomCode(props) {
2280
2218
  }
2281
2219
  });
2282
2220
  return (() => {
2283
- const _el$ = _tmpl$9();
2221
+ const _el$ = _tmpl$8();
2284
2222
  const _ref$ = elementRef;
2285
2223
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2286
2224
  effect((_p$) => {
@@ -2340,7 +2278,7 @@ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "applicati
2340
2278
  var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2341
2279
 
2342
2280
  // src/blocks/embed/embed.tsx
2343
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2281
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2344
2282
  function Embed(props) {
2345
2283
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2346
2284
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2375,7 +2313,7 @@ function Embed(props) {
2375
2313
  }
2376
2314
  createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2377
2315
  return (() => {
2378
- const _el$ = _tmpl$10();
2316
+ const _el$ = _tmpl$9();
2379
2317
  const _ref$ = elem;
2380
2318
  typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2381
2319
  effect(() => _el$.innerHTML = props.content);
@@ -2531,10 +2469,10 @@ var componentInfo7 = {
2531
2469
  noWrap: true,
2532
2470
  static: true
2533
2471
  };
2534
- var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
2472
+ var _tmpl$10 = /* @__PURE__ */ template(`<img>`);
2535
2473
  function ImgComponent(props) {
2536
2474
  return (() => {
2537
- const _el$ = _tmpl$11();
2475
+ const _el$ = _tmpl$10();
2538
2476
  spread(_el$, mergeProps({
2539
2477
  get style() {
2540
2478
  return {
@@ -2655,10 +2593,10 @@ var componentInfo10 = {
2655
2593
  textAlign: "center"
2656
2594
  }
2657
2595
  };
2658
- var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
2596
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class=builder-text>`);
2659
2597
  function Text(props) {
2660
2598
  return (() => {
2661
- const _el$ = _tmpl$12();
2599
+ const _el$ = _tmpl$11();
2662
2600
  _el$.style.setProperty("outline", "none");
2663
2601
  effect(() => _el$.innerHTML = props.text?.toString() || "");
2664
2602
  return _el$;
@@ -2749,7 +2687,7 @@ var componentInfo11 = {
2749
2687
  advanced: true
2750
2688
  }]
2751
2689
  };
2752
- var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2690
+ var _tmpl$12 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2753
2691
  var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
2754
2692
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
2755
2693
  function Video(props) {
@@ -2812,7 +2750,7 @@ function Video(props) {
2812
2750
  return !props.lazyLoad;
2813
2751
  },
2814
2752
  get children() {
2815
- const _el$3 = _tmpl$13();
2753
+ const _el$3 = _tmpl$12();
2816
2754
  effect(() => setAttribute(_el$3, "src", props.video));
2817
2755
  return _el$3;
2818
2756
  }
@@ -2971,10 +2909,10 @@ var getUpdateVariantVisibilityScript = ({
2971
2909
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
2972
2910
  "${variationId}", "${contentId}", ${isHydrationTarget}
2973
2911
  )`;
2974
- var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
2912
+ var _tmpl$13 = /* @__PURE__ */ template(`<script>`);
2975
2913
  function InlinedScript(props) {
2976
2914
  return (() => {
2977
- const _el$ = _tmpl$14();
2915
+ const _el$ = _tmpl$13();
2978
2916
  effect((_p$) => {
2979
2917
  const _v$ = props.scriptStr, _v$2 = props.id || "";
2980
2918
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -3469,7 +3407,7 @@ var getInteractionPropertiesForEvent = (event) => {
3469
3407
  };
3470
3408
 
3471
3409
  // src/constants/sdk-version.ts
3472
- var SDK_VERSION = "0.8.1";
3410
+ var SDK_VERSION = "0.9.0";
3473
3411
 
3474
3412
  // src/functions/register.ts
3475
3413
  var registry = {};
@@ -3602,11 +3540,11 @@ var setupBrowserForEditing = (options = {}) => {
3602
3540
  };
3603
3541
 
3604
3542
  // src/components/content/components/enable-editor.tsx
3605
- var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
3606
3543
  function EnableEditor(props) {
3607
3544
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
3608
3545
  createSignal(0);
3609
3546
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
3547
+ const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
3610
3548
  const [httpReqsData, setHttpReqsData] = createSignal({});
3611
3549
  const [clicked, setClicked] = createSignal(false);
3612
3550
  function mergeNewContent(newContent) {
@@ -3838,10 +3776,7 @@ function EnableEditor(props) {
3838
3776
  return props.builderContextSignal.content;
3839
3777
  },
3840
3778
  get children() {
3841
- const _el$ = _tmpl$15();
3842
- const _ref$ = elementRef;
3843
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
3844
- spread(_el$, mergeProps({
3779
+ return createComponent(Dynamic, mergeProps({
3845
3780
  get ["class"]() {
3846
3781
  return `variant-${props.content?.testVariationId || props.content?.id}`;
3847
3782
  }
@@ -3849,7 +3784,11 @@ function EnableEditor(props) {
3849
3784
  get key() {
3850
3785
  return forceReRenderCount();
3851
3786
  },
3852
- "onClick": (event) => onClick(event),
3787
+ ref(r$) {
3788
+ const _ref$ = elementRef;
3789
+ typeof _ref$ === "function" ? _ref$(r$) : elementRef = r$;
3790
+ },
3791
+ onClick: (event) => onClick(event),
3853
3792
  get ["builder-content-id"]() {
3854
3793
  return props.builderContextSignal.content?.id;
3855
3794
  },
@@ -3859,9 +3798,14 @@ function EnableEditor(props) {
3859
3798
  }, {}, () => props.showContent ? {} : {
3860
3799
  hidden: true,
3861
3800
  "aria-hidden": true
3862
- }), false, true);
3863
- insert(_el$, () => props.children);
3864
- return _el$;
3801
+ }, () => props.contentWrapperProps, {
3802
+ get component() {
3803
+ return ContentWrapper();
3804
+ },
3805
+ get children() {
3806
+ return props.children;
3807
+ }
3808
+ }));
3865
3809
  }
3866
3810
  });
3867
3811
  }
@@ -4050,7 +3994,9 @@ function ContentComponent(props) {
4050
3994
  ...acc,
4051
3995
  [info.name]: serializeComponentInfo(info)
4052
3996
  }), {}),
4053
- inheritedStyles: {}
3997
+ inheritedStyles: {},
3998
+ BlocksWrapper: props.blocksWrapper || "div",
3999
+ BlocksWrapperProps: props.blocksWrapperProps || {}
4054
4000
  });
4055
4001
  function contentSetState(newRootState) {
4056
4002
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -4095,6 +4041,12 @@ function ContentComponent(props) {
4095
4041
  },
4096
4042
  get builderContextSignal() {
4097
4043
  return builderContextSignal();
4044
+ },
4045
+ get contentWrapper() {
4046
+ return props.contentWrapper;
4047
+ },
4048
+ get contentWrapperProps() {
4049
+ return props.contentWrapperProps;
4098
4050
  }
4099
4051
  }, {
4100
4052
  setBuilderContextSignal
@@ -4242,6 +4194,18 @@ function ContentVariants(props) {
4242
4194
  },
4243
4195
  get isSsrAbTest() {
4244
4196
  return shouldRenderVariants();
4197
+ },
4198
+ get blocksWrapper() {
4199
+ return props.blocksWrapper;
4200
+ },
4201
+ get blocksWrapperProps() {
4202
+ return props.blocksWrapperProps;
4203
+ },
4204
+ get contentWrapper() {
4205
+ return props.contentWrapper;
4206
+ },
4207
+ get contentWrapperProps() {
4208
+ return props.contentWrapperProps;
4245
4209
  }
4246
4210
  });
4247
4211
  }
@@ -4284,6 +4248,18 @@ function ContentVariants(props) {
4284
4248
  },
4285
4249
  get isSsrAbTest() {
4286
4250
  return shouldRenderVariants();
4251
+ },
4252
+ get blocksWrapper() {
4253
+ return props.blocksWrapper;
4254
+ },
4255
+ get blocksWrapperProps() {
4256
+ return props.blocksWrapperProps;
4257
+ },
4258
+ get contentWrapper() {
4259
+ return props.contentWrapper;
4260
+ },
4261
+ get contentWrapperProps() {
4262
+ return props.contentWrapperProps;
4287
4263
  }
4288
4264
  }))];
4289
4265
  }
@@ -4314,7 +4290,7 @@ var fetchSymbolContent = async ({
4314
4290
  };
4315
4291
 
4316
4292
  // src/blocks/symbol/symbol.tsx
4317
- var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
4293
+ var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
4318
4294
  function Symbol(props) {
4319
4295
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
4320
4296
  function className() {
@@ -4340,7 +4316,7 @@ function Symbol(props) {
4340
4316
  }
4341
4317
  createEffect(on(() => [props.symbol], onUpdateFn_0));
4342
4318
  return (() => {
4343
- const _el$ = _tmpl$16();
4319
+ const _el$ = _tmpl$14();
4344
4320
  spread(_el$, mergeProps({
4345
4321
  get ["class"]() {
4346
4322
  return className();