@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.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
 
@@ -737,85 +739,10 @@ function getBlockActions(options) {
737
739
  return obj;
738
740
  }
739
741
 
740
- // src/functions/sanitize-react-native-block-styles.ts
741
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
742
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
743
- var SHOW_WARNINGS = false;
744
- var normalizeNumber = (value) => {
745
- if (Number.isNaN(value)) {
746
- return void 0;
747
- } else if (value < 0) {
748
- return 0;
749
- } else {
750
- return value;
751
- }
752
- };
753
- var sanitizeReactNativeBlockStyles = (styles) => {
754
- return Object.keys(styles).reduce((acc, key) => {
755
- const propertyValue = styles[key];
756
- if (key === "display" && !displayValues.has(propertyValue)) {
757
- if (SHOW_WARNINGS) {
758
- console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
759
- }
760
- return acc;
761
- }
762
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
763
- if (SHOW_WARNINGS) {
764
- console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
765
- }
766
- return acc;
767
- }
768
- if (typeof propertyValue === "string") {
769
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
770
- if (isPixelUnit) {
771
- const newValue = parseFloat(propertyValue);
772
- const normalizedValue = normalizeNumber(newValue);
773
- if (normalizedValue) {
774
- return {
775
- ...acc,
776
- [key]: normalizedValue
777
- };
778
- } else {
779
- return acc;
780
- }
781
- } else if (propertyValue === "0") {
782
- return {
783
- ...acc,
784
- [key]: 0
785
- };
786
- }
787
- }
788
- return {
789
- ...acc,
790
- [key]: propertyValue
791
- };
792
- }, {});
793
- };
794
-
795
- // src/functions/get-react-native-block-styles.ts
796
- function getReactNativeBlockStyles({
797
- block,
798
- context,
799
- blockStyles
800
- }) {
801
- const responsiveStyles = block.responsiveStyles;
802
- if (!responsiveStyles) {
803
- return {};
804
- }
805
- const styles = {
806
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
807
- ...context.inheritedStyles,
808
- ...responsiveStyles.large || {},
809
- ...responsiveStyles.medium || {},
810
- ...responsiveStyles.small || {},
811
- ...blockStyles
812
- };
813
- const newStyles = sanitizeReactNativeBlockStyles(styles);
814
- return newStyles;
815
- }
816
-
817
742
  // src/functions/transform-block-properties.ts
818
- function transformBlockProperties(properties) {
743
+ function transformBlockProperties({
744
+ properties
745
+ }) {
819
746
  return properties;
820
747
  }
821
748
 
@@ -836,14 +763,11 @@ function getBlockProperties({
836
763
  style: block.style ? getStyleAttribute(block.style) : void 0,
837
764
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
838
765
  };
839
- if (TARGET === "reactNative") {
840
- properties.style = getReactNativeBlockStyles({
841
- block,
842
- context,
843
- blockStyles: properties.style
844
- });
845
- }
846
- return transformBlockProperties(properties);
766
+ return transformBlockProperties({
767
+ properties,
768
+ context,
769
+ block
770
+ });
847
771
  }
848
772
  function getStyleAttribute(style) {
849
773
  switch (TARGET) {
@@ -1281,7 +1205,6 @@ function Block(props) {
1281
1205
  });
1282
1206
  }
1283
1207
  var block_default = Block;
1284
- var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1285
1208
  function BlocksWrapper(props) {
1286
1209
  function className() {
1287
1210
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -1308,33 +1231,35 @@ function BlocksWrapper(props) {
1308
1231
  }, "*");
1309
1232
  }
1310
1233
  }
1311
- return (() => {
1312
- const _el$ = _tmpl$4();
1313
- spread(_el$, mergeProps({
1314
- get ["class"]() {
1315
- return className() + " " + css({
1316
- display: "flex",
1317
- flexDirection: "column",
1318
- alignItems: "stretch"
1319
- });
1320
- },
1321
- get ["builder-path"]() {
1322
- return props.path;
1323
- },
1324
- get ["builder-parent-id"]() {
1325
- return props.parent;
1326
- }
1327
- }, {}, {
1328
- get style() {
1329
- return props.styleProp;
1330
- },
1331
- "onClick": (event) => onClick(),
1332
- "onMouseEnter": (event) => onMouseEnter(),
1333
- "onKeyPress": (event) => onClick()
1334
- }), false, true);
1335
- insert(_el$, () => props.children);
1336
- return _el$;
1337
- })();
1234
+ return createComponent(Dynamic, mergeProps({
1235
+ get ["class"]() {
1236
+ return className() + " " + css({
1237
+ display: "flex",
1238
+ flexDirection: "column",
1239
+ alignItems: "stretch"
1240
+ });
1241
+ },
1242
+ get ["builder-path"]() {
1243
+ return props.path;
1244
+ },
1245
+ get ["builder-parent-id"]() {
1246
+ return props.parent;
1247
+ }
1248
+ }, {}, {
1249
+ get style() {
1250
+ return props.styleProp;
1251
+ },
1252
+ onClick: (event) => onClick(),
1253
+ onMouseEnter: (event) => onMouseEnter(),
1254
+ onKeyPress: (event) => onClick()
1255
+ }, () => props.BlocksWrapperProps, {
1256
+ get component() {
1257
+ return props.BlocksWrapper;
1258
+ },
1259
+ get children() {
1260
+ return props.children;
1261
+ }
1262
+ }));
1338
1263
  }
1339
1264
  var blocks_wrapper_default = BlocksWrapper;
1340
1265
 
@@ -1355,6 +1280,12 @@ function Blocks(props) {
1355
1280
  get styleProp() {
1356
1281
  return props.styleProp;
1357
1282
  },
1283
+ get BlocksWrapper() {
1284
+ return props.context?.BlocksWrapper;
1285
+ },
1286
+ get BlocksWrapperProps() {
1287
+ return props.context?.BlocksWrapperProps;
1288
+ },
1358
1289
  get children() {
1359
1290
  return [createComponent(Show, {
1360
1291
  get when() {
@@ -1412,7 +1343,7 @@ function Blocks(props) {
1412
1343
  var blocks_default = Blocks;
1413
1344
 
1414
1345
  // src/blocks/columns/columns.tsx
1415
- var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
1346
+ var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
1416
1347
  function Columns(props) {
1417
1348
  const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
1418
1349
  const [cols, setCols] = createSignal(props.columns || []);
@@ -1506,7 +1437,7 @@ function Columns(props) {
1506
1437
  `;
1507
1438
  }
1508
1439
  return (() => {
1509
- const _el$ = _tmpl$5();
1440
+ const _el$ = _tmpl$4();
1510
1441
  spread(_el$, mergeProps({
1511
1442
  get ["class"]() {
1512
1443
  return `builder-columns ${props.builderBlock.id}-breakpoints ` + css({
@@ -1535,7 +1466,7 @@ function Columns(props) {
1535
1466
  children: (column, _index) => {
1536
1467
  const index = _index();
1537
1468
  return (() => {
1538
- const _el$2 = _tmpl$5();
1469
+ const _el$2 = _tmpl$4();
1539
1470
  spread(_el$2, mergeProps({
1540
1471
  get ["class"]() {
1541
1472
  return "builder-column " + css({
@@ -1576,10 +1507,10 @@ function Columns(props) {
1576
1507
  })();
1577
1508
  }
1578
1509
  var columns_default = Columns;
1579
- var _tmpl$6 = /* @__PURE__ */ template(`<span>`);
1510
+ var _tmpl$5 = /* @__PURE__ */ template(`<span>`);
1580
1511
  function FragmentComponent(props) {
1581
1512
  return (() => {
1582
- const _el$ = _tmpl$6();
1513
+ const _el$ = _tmpl$5();
1583
1514
  insert(_el$, () => props.children);
1584
1515
  return _el$;
1585
1516
  })();
@@ -1634,7 +1565,7 @@ function getSrcSet(url) {
1634
1565
  }
1635
1566
 
1636
1567
  // src/blocks/image/image.tsx
1637
- var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
1568
+ var _tmpl$6 = /* @__PURE__ */ template(`<source type=image/webp>`);
1638
1569
  var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
1639
1570
  var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
1640
1571
  function Image(props) {
@@ -1681,7 +1612,7 @@ function Image(props) {
1681
1612
  return webpSrcSet();
1682
1613
  },
1683
1614
  get children() {
1684
- const _el$2 = _tmpl$7();
1615
+ const _el$2 = _tmpl$6();
1685
1616
  effect(() => setAttribute(_el$2, "srcset", webpSrcSet()));
1686
1617
  return _el$2;
1687
1618
  }
@@ -1763,10 +1694,10 @@ function Image(props) {
1763
1694
  })];
1764
1695
  }
1765
1696
  var image_default = Image;
1766
- var _tmpl$8 = /* @__PURE__ */ template(`<section>`);
1697
+ var _tmpl$7 = /* @__PURE__ */ template(`<section>`);
1767
1698
  function SectionComponent(props) {
1768
1699
  return (() => {
1769
- const _el$ = _tmpl$8();
1700
+ const _el$ = _tmpl$7();
1770
1701
  spread(_el$, mergeProps({}, () => props.attributes, {
1771
1702
  get style() {
1772
1703
  return {
@@ -2260,7 +2191,7 @@ var componentInfo3 = {
2260
2191
  advanced: true
2261
2192
  }]
2262
2193
  };
2263
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
2194
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
2264
2195
  function CustomCode(props) {
2265
2196
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2266
2197
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2295,7 +2226,7 @@ function CustomCode(props) {
2295
2226
  }
2296
2227
  });
2297
2228
  return (() => {
2298
- const _el$ = _tmpl$9();
2229
+ const _el$ = _tmpl$8();
2299
2230
  const _ref$ = elementRef;
2300
2231
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2301
2232
  effect((_p$) => {
@@ -2355,7 +2286,7 @@ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "applicati
2355
2286
  var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2356
2287
 
2357
2288
  // src/blocks/embed/embed.tsx
2358
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2289
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
2359
2290
  function Embed(props) {
2360
2291
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2361
2292
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -2391,7 +2322,7 @@ function Embed(props) {
2391
2322
  }
2392
2323
  createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2393
2324
  return (() => {
2394
- const _el$ = _tmpl$10();
2325
+ const _el$ = _tmpl$9();
2395
2326
  const _ref$ = elem;
2396
2327
  typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2397
2328
  effect(() => _el$.innerHTML = props.content);
@@ -2548,10 +2479,10 @@ var componentInfo7 = {
2548
2479
  noWrap: true,
2549
2480
  static: true
2550
2481
  };
2551
- var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
2482
+ var _tmpl$10 = /* @__PURE__ */ template(`<img>`);
2552
2483
  function ImgComponent(props) {
2553
2484
  return (() => {
2554
- const _el$ = _tmpl$11();
2485
+ const _el$ = _tmpl$10();
2555
2486
  spread(_el$, mergeProps({
2556
2487
  get style() {
2557
2488
  return {
@@ -2672,10 +2603,10 @@ var componentInfo10 = {
2672
2603
  textAlign: "center"
2673
2604
  }
2674
2605
  };
2675
- var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
2606
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class=builder-text>`);
2676
2607
  function Text(props) {
2677
2608
  return (() => {
2678
- const _el$ = _tmpl$12();
2609
+ const _el$ = _tmpl$11();
2679
2610
  _el$.style.setProperty("outline", "none");
2680
2611
  effect(() => _el$.innerHTML = props.text?.toString() || "");
2681
2612
  return _el$;
@@ -2766,7 +2697,7 @@ var componentInfo11 = {
2766
2697
  advanced: true
2767
2698
  }]
2768
2699
  };
2769
- var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2700
+ var _tmpl$12 = /* @__PURE__ */ template(`<source type=video/mp4>`);
2770
2701
  var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
2771
2702
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
2772
2703
  function Video(props) {
@@ -2829,7 +2760,7 @@ function Video(props) {
2829
2760
  return !props.lazyLoad;
2830
2761
  },
2831
2762
  get children() {
2832
- const _el$3 = _tmpl$13();
2763
+ const _el$3 = _tmpl$12();
2833
2764
  effect(() => setAttribute(_el$3, "src", props.video));
2834
2765
  return _el$3;
2835
2766
  }
@@ -2988,10 +2919,10 @@ var getUpdateVariantVisibilityScript = ({
2988
2919
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
2989
2920
  "${variationId}", "${contentId}", ${isHydrationTarget}
2990
2921
  )`;
2991
- var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
2922
+ var _tmpl$13 = /* @__PURE__ */ template(`<script>`);
2992
2923
  function InlinedScript(props) {
2993
2924
  return (() => {
2994
- const _el$ = _tmpl$14();
2925
+ const _el$ = _tmpl$13();
2995
2926
  effect((_p$) => {
2996
2927
  const _v$ = props.scriptStr, _v$2 = props.id || "";
2997
2928
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -3491,7 +3422,7 @@ var getInteractionPropertiesForEvent = (event) => {
3491
3422
  };
3492
3423
 
3493
3424
  // src/constants/sdk-version.ts
3494
- var SDK_VERSION = "0.8.1";
3425
+ var SDK_VERSION = "0.9.0";
3495
3426
 
3496
3427
  // src/functions/register.ts
3497
3428
  var registry = {};
@@ -3625,11 +3556,11 @@ var setupBrowserForEditing = (options = {}) => {
3625
3556
  };
3626
3557
 
3627
3558
  // src/components/content/components/enable-editor.tsx
3628
- var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
3629
3559
  function EnableEditor(props) {
3630
3560
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
3631
3561
  createSignal(0);
3632
3562
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
3563
+ const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
3633
3564
  const [httpReqsData, setHttpReqsData] = createSignal({});
3634
3565
  const [clicked, setClicked] = createSignal(false);
3635
3566
  function mergeNewContent(newContent) {
@@ -3862,10 +3793,7 @@ function EnableEditor(props) {
3862
3793
  return props.builderContextSignal.content;
3863
3794
  },
3864
3795
  get children() {
3865
- const _el$ = _tmpl$15();
3866
- const _ref$ = elementRef;
3867
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
3868
- spread(_el$, mergeProps({
3796
+ return createComponent(Dynamic, mergeProps({
3869
3797
  get ["class"]() {
3870
3798
  return `variant-${props.content?.testVariationId || props.content?.id}`;
3871
3799
  }
@@ -3873,7 +3801,11 @@ function EnableEditor(props) {
3873
3801
  get key() {
3874
3802
  return forceReRenderCount();
3875
3803
  },
3876
- "onClick": (event) => onClick(event),
3804
+ ref(r$) {
3805
+ const _ref$ = elementRef;
3806
+ typeof _ref$ === "function" ? _ref$(r$) : elementRef = r$;
3807
+ },
3808
+ onClick: (event) => onClick(event),
3877
3809
  get ["builder-content-id"]() {
3878
3810
  return props.builderContextSignal.content?.id;
3879
3811
  },
@@ -3883,9 +3815,14 @@ function EnableEditor(props) {
3883
3815
  }, {}, () => props.showContent ? {} : {
3884
3816
  hidden: true,
3885
3817
  "aria-hidden": true
3886
- }), false, true);
3887
- insert(_el$, () => props.children);
3888
- return _el$;
3818
+ }, () => props.contentWrapperProps, {
3819
+ get component() {
3820
+ return ContentWrapper();
3821
+ },
3822
+ get children() {
3823
+ return props.children;
3824
+ }
3825
+ }));
3889
3826
  }
3890
3827
  });
3891
3828
  }
@@ -4074,7 +4011,9 @@ function ContentComponent(props) {
4074
4011
  ...acc,
4075
4012
  [info.name]: serializeComponentInfo(info)
4076
4013
  }), {}),
4077
- inheritedStyles: {}
4014
+ inheritedStyles: {},
4015
+ BlocksWrapper: props.blocksWrapper || "div",
4016
+ BlocksWrapperProps: props.blocksWrapperProps || {}
4078
4017
  });
4079
4018
  function contentSetState(newRootState) {
4080
4019
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -4119,6 +4058,12 @@ function ContentComponent(props) {
4119
4058
  },
4120
4059
  get builderContextSignal() {
4121
4060
  return builderContextSignal();
4061
+ },
4062
+ get contentWrapper() {
4063
+ return props.contentWrapper;
4064
+ },
4065
+ get contentWrapperProps() {
4066
+ return props.contentWrapperProps;
4122
4067
  }
4123
4068
  }, {
4124
4069
  setBuilderContextSignal
@@ -4266,6 +4211,18 @@ function ContentVariants(props) {
4266
4211
  },
4267
4212
  get isSsrAbTest() {
4268
4213
  return shouldRenderVariants();
4214
+ },
4215
+ get blocksWrapper() {
4216
+ return props.blocksWrapper;
4217
+ },
4218
+ get blocksWrapperProps() {
4219
+ return props.blocksWrapperProps;
4220
+ },
4221
+ get contentWrapper() {
4222
+ return props.contentWrapper;
4223
+ },
4224
+ get contentWrapperProps() {
4225
+ return props.contentWrapperProps;
4269
4226
  }
4270
4227
  });
4271
4228
  }
@@ -4308,6 +4265,18 @@ function ContentVariants(props) {
4308
4265
  },
4309
4266
  get isSsrAbTest() {
4310
4267
  return shouldRenderVariants();
4268
+ },
4269
+ get blocksWrapper() {
4270
+ return props.blocksWrapper;
4271
+ },
4272
+ get blocksWrapperProps() {
4273
+ return props.blocksWrapperProps;
4274
+ },
4275
+ get contentWrapper() {
4276
+ return props.contentWrapper;
4277
+ },
4278
+ get contentWrapperProps() {
4279
+ return props.contentWrapperProps;
4311
4280
  }
4312
4281
  }))];
4313
4282
  }
@@ -4338,7 +4307,7 @@ var fetchSymbolContent = async ({
4338
4307
  };
4339
4308
 
4340
4309
  // src/blocks/symbol/symbol.tsx
4341
- var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
4310
+ var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
4342
4311
  function Symbol(props) {
4343
4312
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
4344
4313
  function className() {
@@ -4364,7 +4333,7 @@ function Symbol(props) {
4364
4333
  }
4365
4334
  createEffect(on(() => [props.symbol], onUpdateFn_0));
4366
4335
  return (() => {
4367
- const _el$ = _tmpl$16();
4336
+ const _el$ = _tmpl$14();
4368
4337
  spread(_el$, mergeProps({
4369
4338
  get ["class"]() {
4370
4339
  return className();