@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.
package/lib/edge/index.js CHANGED
@@ -61,7 +61,9 @@ var builder_context_default = createContext({
61
61
  apiKey: null,
62
62
  apiVersion: void 0,
63
63
  componentInfos: {},
64
- inheritedStyles: {}
64
+ inheritedStyles: {},
65
+ BlocksWrapper: "div",
66
+ BlocksWrapperProps: {}
65
67
  });
66
68
  var components_context_default = createContext({ registeredComponents: {} });
67
69
 
@@ -3761,78 +3763,10 @@ function getBlockActions(options) {
3761
3763
  return obj;
3762
3764
  }
3763
3765
 
3764
- // src/functions/sanitize-react-native-block-styles.ts
3765
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
3766
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
3767
- var normalizeNumber = (value) => {
3768
- if (Number.isNaN(value)) {
3769
- return void 0;
3770
- } else if (value < 0) {
3771
- return 0;
3772
- } else {
3773
- return value;
3774
- }
3775
- };
3776
- var sanitizeReactNativeBlockStyles = (styles) => {
3777
- return Object.keys(styles).reduce((acc, key) => {
3778
- const propertyValue = styles[key];
3779
- if (key === "display" && !displayValues.has(propertyValue)) {
3780
- return acc;
3781
- }
3782
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
3783
- return acc;
3784
- }
3785
- if (typeof propertyValue === "string") {
3786
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
3787
- if (isPixelUnit) {
3788
- const newValue = parseFloat(propertyValue);
3789
- const normalizedValue = normalizeNumber(newValue);
3790
- if (normalizedValue) {
3791
- return {
3792
- ...acc,
3793
- [key]: normalizedValue
3794
- };
3795
- } else {
3796
- return acc;
3797
- }
3798
- } else if (propertyValue === "0") {
3799
- return {
3800
- ...acc,
3801
- [key]: 0
3802
- };
3803
- }
3804
- }
3805
- return {
3806
- ...acc,
3807
- [key]: propertyValue
3808
- };
3809
- }, {});
3810
- };
3811
-
3812
- // src/functions/get-react-native-block-styles.ts
3813
- function getReactNativeBlockStyles({
3814
- block,
3815
- context,
3816
- blockStyles
3817
- }) {
3818
- const responsiveStyles = block.responsiveStyles;
3819
- if (!responsiveStyles) {
3820
- return {};
3821
- }
3822
- const styles = {
3823
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
3824
- ...context.inheritedStyles,
3825
- ...responsiveStyles.large || {},
3826
- ...responsiveStyles.medium || {},
3827
- ...responsiveStyles.small || {},
3828
- ...blockStyles
3829
- };
3830
- const newStyles = sanitizeReactNativeBlockStyles(styles);
3831
- return newStyles;
3832
- }
3833
-
3834
3766
  // src/functions/transform-block-properties.ts
3835
- function transformBlockProperties(properties) {
3767
+ function transformBlockProperties({
3768
+ properties
3769
+ }) {
3836
3770
  return properties;
3837
3771
  }
3838
3772
 
@@ -3853,14 +3787,11 @@ function getBlockProperties({
3853
3787
  style: block.style ? getStyleAttribute(block.style) : void 0,
3854
3788
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
3855
3789
  };
3856
- if (TARGET === "reactNative") {
3857
- properties.style = getReactNativeBlockStyles({
3858
- block,
3859
- context,
3860
- blockStyles: properties.style
3861
- });
3862
- }
3863
- return transformBlockProperties(properties);
3790
+ return transformBlockProperties({
3791
+ properties,
3792
+ context,
3793
+ block
3794
+ });
3864
3795
  }
3865
3796
  function getStyleAttribute(style) {
3866
3797
  switch (TARGET) {
@@ -4298,7 +4229,6 @@ function Block(props) {
4298
4229
  });
4299
4230
  }
4300
4231
  var block_default = Block;
4301
- var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
4302
4232
  function BlocksWrapper(props) {
4303
4233
  function className() {
4304
4234
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -4325,33 +4255,35 @@ function BlocksWrapper(props) {
4325
4255
  }, "*");
4326
4256
  }
4327
4257
  }
4328
- return (() => {
4329
- const _el$ = _tmpl$4();
4330
- spread(_el$, mergeProps({
4331
- get ["class"]() {
4332
- return className() + " " + css({
4333
- display: "flex",
4334
- flexDirection: "column",
4335
- alignItems: "stretch"
4336
- });
4337
- },
4338
- get ["builder-path"]() {
4339
- return props.path;
4340
- },
4341
- get ["builder-parent-id"]() {
4342
- return props.parent;
4343
- }
4344
- }, {}, {
4345
- get style() {
4346
- return props.styleProp;
4347
- },
4348
- "onClick": (event) => onClick(),
4349
- "onMouseEnter": (event) => onMouseEnter(),
4350
- "onKeyPress": (event) => onClick()
4351
- }), false, true);
4352
- insert(_el$, () => props.children);
4353
- return _el$;
4354
- })();
4258
+ return createComponent(Dynamic, mergeProps({
4259
+ get ["class"]() {
4260
+ return className() + " " + css({
4261
+ display: "flex",
4262
+ flexDirection: "column",
4263
+ alignItems: "stretch"
4264
+ });
4265
+ },
4266
+ get ["builder-path"]() {
4267
+ return props.path;
4268
+ },
4269
+ get ["builder-parent-id"]() {
4270
+ return props.parent;
4271
+ }
4272
+ }, {}, {
4273
+ get style() {
4274
+ return props.styleProp;
4275
+ },
4276
+ onClick: (event) => onClick(),
4277
+ onMouseEnter: (event) => onMouseEnter(),
4278
+ onKeyPress: (event) => onClick()
4279
+ }, () => props.BlocksWrapperProps, {
4280
+ get component() {
4281
+ return props.BlocksWrapper;
4282
+ },
4283
+ get children() {
4284
+ return props.children;
4285
+ }
4286
+ }));
4355
4287
  }
4356
4288
  var blocks_wrapper_default = BlocksWrapper;
4357
4289
 
@@ -4372,6 +4304,12 @@ function Blocks(props) {
4372
4304
  get styleProp() {
4373
4305
  return props.styleProp;
4374
4306
  },
4307
+ get BlocksWrapper() {
4308
+ return props.context?.BlocksWrapper;
4309
+ },
4310
+ get BlocksWrapperProps() {
4311
+ return props.context?.BlocksWrapperProps;
4312
+ },
4375
4313
  get children() {
4376
4314
  return [createComponent(Show, {
4377
4315
  get when() {
@@ -4429,7 +4367,7 @@ function Blocks(props) {
4429
4367
  var blocks_default = Blocks;
4430
4368
 
4431
4369
  // src/blocks/columns/columns.tsx
4432
- var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
4370
+ var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
4433
4371
  function Columns(props) {
4434
4372
  const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
4435
4373
  const [cols, setCols] = createSignal(props.columns || []);
@@ -4523,7 +4461,7 @@ function Columns(props) {
4523
4461
  `;
4524
4462
  }
4525
4463
  return (() => {
4526
- const _el$ = _tmpl$5();
4464
+ const _el$ = _tmpl$4();
4527
4465
  spread(_el$, mergeProps({
4528
4466
  get ["class"]() {
4529
4467
  return `builder-columns ${props.builderBlock.id}-breakpoints ` + css({
@@ -4552,7 +4490,7 @@ function Columns(props) {
4552
4490
  children: (column, _index) => {
4553
4491
  const index = _index();
4554
4492
  return (() => {
4555
- const _el$2 = _tmpl$5();
4493
+ const _el$2 = _tmpl$4();
4556
4494
  spread(_el$2, mergeProps({
4557
4495
  get ["class"]() {
4558
4496
  return "builder-column " + css({
@@ -4593,10 +4531,10 @@ function Columns(props) {
4593
4531
  })();
4594
4532
  }
4595
4533
  var columns_default = Columns;
4596
- var _tmpl$6 = /* @__PURE__ */ template(`<span>`);
4534
+ var _tmpl$5 = /* @__PURE__ */ template(`<span>`);
4597
4535
  function FragmentComponent(props) {
4598
4536
  return (() => {
4599
- const _el$ = _tmpl$6();
4537
+ const _el$ = _tmpl$5();
4600
4538
  insert(_el$, () => props.children);
4601
4539
  return _el$;
4602
4540
  })();
@@ -4651,7 +4589,7 @@ function getSrcSet(url) {
4651
4589
  }
4652
4590
 
4653
4591
  // src/blocks/image/image.tsx
4654
- var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
4592
+ var _tmpl$6 = /* @__PURE__ */ template(`<source type=image/webp>`);
4655
4593
  var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
4656
4594
  var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
4657
4595
  function Image(props) {
@@ -4697,7 +4635,7 @@ function Image(props) {
4697
4635
  return webpSrcSet();
4698
4636
  },
4699
4637
  get children() {
4700
- const _el$2 = _tmpl$7();
4638
+ const _el$2 = _tmpl$6();
4701
4639
  effect(() => setAttribute(_el$2, "srcset", webpSrcSet()));
4702
4640
  return _el$2;
4703
4641
  }
@@ -4779,10 +4717,10 @@ function Image(props) {
4779
4717
  })];
4780
4718
  }
4781
4719
  var image_default = Image;
4782
- var _tmpl$8 = /* @__PURE__ */ template(`<section>`);
4720
+ var _tmpl$7 = /* @__PURE__ */ template(`<section>`);
4783
4721
  function SectionComponent(props) {
4784
4722
  return (() => {
4785
- const _el$ = _tmpl$8();
4723
+ const _el$ = _tmpl$7();
4786
4724
  spread(_el$, mergeProps({}, () => props.attributes, {
4787
4725
  get style() {
4788
4726
  return {
@@ -5276,7 +5214,7 @@ var componentInfo3 = {
5276
5214
  advanced: true
5277
5215
  }]
5278
5216
  };
5279
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
5217
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
5280
5218
  function CustomCode(props) {
5281
5219
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
5282
5220
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -5310,7 +5248,7 @@ function CustomCode(props) {
5310
5248
  }
5311
5249
  });
5312
5250
  return (() => {
5313
- const _el$ = _tmpl$9();
5251
+ const _el$ = _tmpl$8();
5314
5252
  const _ref$ = elementRef;
5315
5253
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
5316
5254
  effect((_p$) => {
@@ -5370,7 +5308,7 @@ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "applicati
5370
5308
  var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
5371
5309
 
5372
5310
  // src/blocks/embed/embed.tsx
5373
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
5311
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
5374
5312
  function Embed(props) {
5375
5313
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
5376
5314
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -5405,7 +5343,7 @@ function Embed(props) {
5405
5343
  }
5406
5344
  createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
5407
5345
  return (() => {
5408
- const _el$ = _tmpl$10();
5346
+ const _el$ = _tmpl$9();
5409
5347
  const _ref$ = elem;
5410
5348
  typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
5411
5349
  effect(() => _el$.innerHTML = props.content);
@@ -5561,10 +5499,10 @@ var componentInfo7 = {
5561
5499
  noWrap: true,
5562
5500
  static: true
5563
5501
  };
5564
- var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
5502
+ var _tmpl$10 = /* @__PURE__ */ template(`<img>`);
5565
5503
  function ImgComponent(props) {
5566
5504
  return (() => {
5567
- const _el$ = _tmpl$11();
5505
+ const _el$ = _tmpl$10();
5568
5506
  spread(_el$, mergeProps({
5569
5507
  get style() {
5570
5508
  return {
@@ -5685,10 +5623,10 @@ var componentInfo10 = {
5685
5623
  textAlign: "center"
5686
5624
  }
5687
5625
  };
5688
- var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
5626
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class=builder-text>`);
5689
5627
  function Text(props) {
5690
5628
  return (() => {
5691
- const _el$ = _tmpl$12();
5629
+ const _el$ = _tmpl$11();
5692
5630
  _el$.style.setProperty("outline", "none");
5693
5631
  effect(() => _el$.innerHTML = props.text?.toString() || "");
5694
5632
  return _el$;
@@ -5779,7 +5717,7 @@ var componentInfo11 = {
5779
5717
  advanced: true
5780
5718
  }]
5781
5719
  };
5782
- var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
5720
+ var _tmpl$12 = /* @__PURE__ */ template(`<source type=video/mp4>`);
5783
5721
  var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
5784
5722
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
5785
5723
  function Video(props) {
@@ -5842,7 +5780,7 @@ function Video(props) {
5842
5780
  return !props.lazyLoad;
5843
5781
  },
5844
5782
  get children() {
5845
- const _el$3 = _tmpl$13();
5783
+ const _el$3 = _tmpl$12();
5846
5784
  effect(() => setAttribute(_el$3, "src", props.video));
5847
5785
  return _el$3;
5848
5786
  }
@@ -6001,10 +5939,10 @@ var getUpdateVariantVisibilityScript = ({
6001
5939
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
6002
5940
  "${variationId}", "${contentId}", ${isHydrationTarget}
6003
5941
  )`;
6004
- var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
5942
+ var _tmpl$13 = /* @__PURE__ */ template(`<script>`);
6005
5943
  function InlinedScript(props) {
6006
5944
  return (() => {
6007
- const _el$ = _tmpl$14();
5945
+ const _el$ = _tmpl$13();
6008
5946
  effect((_p$) => {
6009
5947
  const _v$ = props.scriptStr, _v$2 = props.id || "";
6010
5948
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -6191,7 +6129,7 @@ async function fetchOneEntry(options) {
6191
6129
  limit: 1
6192
6130
  });
6193
6131
  if (allContent) {
6194
- return allContent.results[0] || null;
6132
+ return allContent[0] || null;
6195
6133
  }
6196
6134
  return null;
6197
6135
  }
@@ -6214,9 +6152,9 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
6214
6152
  content.results = newResults;
6215
6153
  }
6216
6154
  if (!canTrack)
6217
- return content;
6155
+ return content.results;
6218
6156
  if (!(isBrowser() || TARGET === "reactNative"))
6219
- return content;
6157
+ return content.results;
6220
6158
  try {
6221
6159
  const newResults = [];
6222
6160
  for (const item of content.results) {
@@ -6229,7 +6167,7 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
6229
6167
  } catch (e) {
6230
6168
  logger.error("Could not process A/B tests. ", e);
6231
6169
  }
6232
- return content;
6170
+ return content.results;
6233
6171
  };
6234
6172
  async function fetchEntries(options) {
6235
6173
  try {
@@ -6499,7 +6437,7 @@ var getInteractionPropertiesForEvent = (event) => {
6499
6437
  };
6500
6438
 
6501
6439
  // src/constants/sdk-version.ts
6502
- var SDK_VERSION = "0.8.1";
6440
+ var SDK_VERSION = "0.10.0";
6503
6441
 
6504
6442
  // src/functions/register.ts
6505
6443
  var registry = {};
@@ -6632,11 +6570,11 @@ var setupBrowserForEditing = (options = {}) => {
6632
6570
  };
6633
6571
 
6634
6572
  // src/components/content/components/enable-editor.tsx
6635
- var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
6636
6573
  function EnableEditor(props) {
6637
6574
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
6638
6575
  createSignal(0);
6639
6576
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
6577
+ const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6640
6578
  const [httpReqsData, setHttpReqsData] = createSignal({});
6641
6579
  const [clicked, setClicked] = createSignal(false);
6642
6580
  function mergeNewContent(newContent) {
@@ -6868,10 +6806,7 @@ function EnableEditor(props) {
6868
6806
  return props.builderContextSignal.content;
6869
6807
  },
6870
6808
  get children() {
6871
- const _el$ = _tmpl$15();
6872
- const _ref$ = elementRef;
6873
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
6874
- spread(_el$, mergeProps({
6809
+ return createComponent(Dynamic, mergeProps({
6875
6810
  get ["class"]() {
6876
6811
  return `variant-${props.content?.testVariationId || props.content?.id}`;
6877
6812
  }
@@ -6879,7 +6814,11 @@ function EnableEditor(props) {
6879
6814
  get key() {
6880
6815
  return forceReRenderCount();
6881
6816
  },
6882
- "onClick": (event) => onClick(event),
6817
+ ref(r$) {
6818
+ const _ref$ = elementRef;
6819
+ typeof _ref$ === "function" ? _ref$(r$) : elementRef = r$;
6820
+ },
6821
+ onClick: (event) => onClick(event),
6883
6822
  get ["builder-content-id"]() {
6884
6823
  return props.builderContextSignal.content?.id;
6885
6824
  },
@@ -6889,9 +6828,14 @@ function EnableEditor(props) {
6889
6828
  }, {}, () => props.showContent ? {} : {
6890
6829
  hidden: true,
6891
6830
  "aria-hidden": true
6892
- }), false, true);
6893
- insert(_el$, () => props.children);
6894
- return _el$;
6831
+ }, () => props.contentWrapperProps, {
6832
+ get component() {
6833
+ return ContentWrapper();
6834
+ },
6835
+ get children() {
6836
+ return props.children;
6837
+ }
6838
+ }));
6895
6839
  }
6896
6840
  });
6897
6841
  }
@@ -7080,7 +7024,9 @@ function ContentComponent(props) {
7080
7024
  ...acc,
7081
7025
  [info.name]: serializeComponentInfo(info)
7082
7026
  }), {}),
7083
- inheritedStyles: {}
7027
+ inheritedStyles: {},
7028
+ BlocksWrapper: props.blocksWrapper || "div",
7029
+ BlocksWrapperProps: props.blocksWrapperProps || {}
7084
7030
  });
7085
7031
  function contentSetState(newRootState) {
7086
7032
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -7125,6 +7071,12 @@ function ContentComponent(props) {
7125
7071
  },
7126
7072
  get builderContextSignal() {
7127
7073
  return builderContextSignal();
7074
+ },
7075
+ get contentWrapper() {
7076
+ return props.contentWrapper;
7077
+ },
7078
+ get contentWrapperProps() {
7079
+ return props.contentWrapperProps;
7128
7080
  }
7129
7081
  }, {
7130
7082
  setBuilderContextSignal
@@ -7272,6 +7224,18 @@ function ContentVariants(props) {
7272
7224
  },
7273
7225
  get isSsrAbTest() {
7274
7226
  return shouldRenderVariants();
7227
+ },
7228
+ get blocksWrapper() {
7229
+ return props.blocksWrapper;
7230
+ },
7231
+ get blocksWrapperProps() {
7232
+ return props.blocksWrapperProps;
7233
+ },
7234
+ get contentWrapper() {
7235
+ return props.contentWrapper;
7236
+ },
7237
+ get contentWrapperProps() {
7238
+ return props.contentWrapperProps;
7275
7239
  }
7276
7240
  });
7277
7241
  }
@@ -7314,6 +7278,18 @@ function ContentVariants(props) {
7314
7278
  },
7315
7279
  get isSsrAbTest() {
7316
7280
  return shouldRenderVariants();
7281
+ },
7282
+ get blocksWrapper() {
7283
+ return props.blocksWrapper;
7284
+ },
7285
+ get blocksWrapperProps() {
7286
+ return props.blocksWrapperProps;
7287
+ },
7288
+ get contentWrapper() {
7289
+ return props.contentWrapper;
7290
+ },
7291
+ get contentWrapperProps() {
7292
+ return props.contentWrapperProps;
7317
7293
  }
7318
7294
  }))];
7319
7295
  }
@@ -7344,7 +7320,7 @@ var fetchSymbolContent = async ({
7344
7320
  };
7345
7321
 
7346
7322
  // src/blocks/symbol/symbol.tsx
7347
- var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
7323
+ var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
7348
7324
  function Symbol2(props) {
7349
7325
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
7350
7326
  function className() {
@@ -7370,7 +7346,7 @@ function Symbol2(props) {
7370
7346
  }
7371
7347
  createEffect(on(() => [props.symbol], onUpdateFn_0));
7372
7348
  return (() => {
7373
- const _el$ = _tmpl$16();
7349
+ const _el$ = _tmpl$14();
7374
7350
  spread(_el$, mergeProps({
7375
7351
  get ["class"]() {
7376
7352
  return className();