@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/dev.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
 
@@ -3766,85 +3768,10 @@ function getBlockActions(options) {
3766
3768
  return obj;
3767
3769
  }
3768
3770
 
3769
- // src/functions/sanitize-react-native-block-styles.ts
3770
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
3771
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
3772
- var SHOW_WARNINGS = false;
3773
- var normalizeNumber = (value) => {
3774
- if (Number.isNaN(value)) {
3775
- return void 0;
3776
- } else if (value < 0) {
3777
- return 0;
3778
- } else {
3779
- return value;
3780
- }
3781
- };
3782
- var sanitizeReactNativeBlockStyles = (styles) => {
3783
- return Object.keys(styles).reduce((acc, key) => {
3784
- const propertyValue = styles[key];
3785
- if (key === "display" && !displayValues.has(propertyValue)) {
3786
- if (SHOW_WARNINGS) {
3787
- console.warn(`Style value for key "display" must be "flex" or "none" but had ${propertyValue}`);
3788
- }
3789
- return acc;
3790
- }
3791
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
3792
- if (SHOW_WARNINGS) {
3793
- console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
3794
- }
3795
- return acc;
3796
- }
3797
- if (typeof propertyValue === "string") {
3798
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
3799
- if (isPixelUnit) {
3800
- const newValue = parseFloat(propertyValue);
3801
- const normalizedValue = normalizeNumber(newValue);
3802
- if (normalizedValue) {
3803
- return {
3804
- ...acc,
3805
- [key]: normalizedValue
3806
- };
3807
- } else {
3808
- return acc;
3809
- }
3810
- } else if (propertyValue === "0") {
3811
- return {
3812
- ...acc,
3813
- [key]: 0
3814
- };
3815
- }
3816
- }
3817
- return {
3818
- ...acc,
3819
- [key]: propertyValue
3820
- };
3821
- }, {});
3822
- };
3823
-
3824
- // src/functions/get-react-native-block-styles.ts
3825
- function getReactNativeBlockStyles({
3826
- block,
3827
- context,
3828
- blockStyles
3829
- }) {
3830
- const responsiveStyles = block.responsiveStyles;
3831
- if (!responsiveStyles) {
3832
- return {};
3833
- }
3834
- const styles = {
3835
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
3836
- ...context.inheritedStyles,
3837
- ...responsiveStyles.large || {},
3838
- ...responsiveStyles.medium || {},
3839
- ...responsiveStyles.small || {},
3840
- ...blockStyles
3841
- };
3842
- const newStyles = sanitizeReactNativeBlockStyles(styles);
3843
- return newStyles;
3844
- }
3845
-
3846
3771
  // src/functions/transform-block-properties.ts
3847
- function transformBlockProperties(properties) {
3772
+ function transformBlockProperties({
3773
+ properties
3774
+ }) {
3848
3775
  return properties;
3849
3776
  }
3850
3777
 
@@ -3865,14 +3792,11 @@ function getBlockProperties({
3865
3792
  style: block.style ? getStyleAttribute(block.style) : void 0,
3866
3793
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
3867
3794
  };
3868
- if (TARGET === "reactNative") {
3869
- properties.style = getReactNativeBlockStyles({
3870
- block,
3871
- context,
3872
- blockStyles: properties.style
3873
- });
3874
- }
3875
- return transformBlockProperties(properties);
3795
+ return transformBlockProperties({
3796
+ properties,
3797
+ context,
3798
+ block
3799
+ });
3876
3800
  }
3877
3801
  function getStyleAttribute(style) {
3878
3802
  switch (TARGET) {
@@ -4310,7 +4234,6 @@ function Block(props) {
4310
4234
  });
4311
4235
  }
4312
4236
  var block_default = Block;
4313
- var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
4314
4237
  function BlocksWrapper(props) {
4315
4238
  function className() {
4316
4239
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -4337,33 +4260,35 @@ function BlocksWrapper(props) {
4337
4260
  }, "*");
4338
4261
  }
4339
4262
  }
4340
- return (() => {
4341
- const _el$ = _tmpl$4();
4342
- spread(_el$, mergeProps({
4343
- get ["class"]() {
4344
- return className() + " " + css({
4345
- display: "flex",
4346
- flexDirection: "column",
4347
- alignItems: "stretch"
4348
- });
4349
- },
4350
- get ["builder-path"]() {
4351
- return props.path;
4352
- },
4353
- get ["builder-parent-id"]() {
4354
- return props.parent;
4355
- }
4356
- }, {}, {
4357
- get style() {
4358
- return props.styleProp;
4359
- },
4360
- "onClick": (event) => onClick(),
4361
- "onMouseEnter": (event) => onMouseEnter(),
4362
- "onKeyPress": (event) => onClick()
4363
- }), false, true);
4364
- insert(_el$, () => props.children);
4365
- return _el$;
4366
- })();
4263
+ return createComponent(Dynamic, mergeProps({
4264
+ get ["class"]() {
4265
+ return className() + " " + css({
4266
+ display: "flex",
4267
+ flexDirection: "column",
4268
+ alignItems: "stretch"
4269
+ });
4270
+ },
4271
+ get ["builder-path"]() {
4272
+ return props.path;
4273
+ },
4274
+ get ["builder-parent-id"]() {
4275
+ return props.parent;
4276
+ }
4277
+ }, {}, {
4278
+ get style() {
4279
+ return props.styleProp;
4280
+ },
4281
+ onClick: (event) => onClick(),
4282
+ onMouseEnter: (event) => onMouseEnter(),
4283
+ onKeyPress: (event) => onClick()
4284
+ }, () => props.BlocksWrapperProps, {
4285
+ get component() {
4286
+ return props.BlocksWrapper;
4287
+ },
4288
+ get children() {
4289
+ return props.children;
4290
+ }
4291
+ }));
4367
4292
  }
4368
4293
  var blocks_wrapper_default = BlocksWrapper;
4369
4294
 
@@ -4384,6 +4309,12 @@ function Blocks(props) {
4384
4309
  get styleProp() {
4385
4310
  return props.styleProp;
4386
4311
  },
4312
+ get BlocksWrapper() {
4313
+ return props.context?.BlocksWrapper;
4314
+ },
4315
+ get BlocksWrapperProps() {
4316
+ return props.context?.BlocksWrapperProps;
4317
+ },
4387
4318
  get children() {
4388
4319
  return [createComponent(Show, {
4389
4320
  get when() {
@@ -4441,7 +4372,7 @@ function Blocks(props) {
4441
4372
  var blocks_default = Blocks;
4442
4373
 
4443
4374
  // src/blocks/columns/columns.tsx
4444
- var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
4375
+ var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
4445
4376
  function Columns(props) {
4446
4377
  const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
4447
4378
  const [cols, setCols] = createSignal(props.columns || []);
@@ -4535,7 +4466,7 @@ function Columns(props) {
4535
4466
  `;
4536
4467
  }
4537
4468
  return (() => {
4538
- const _el$ = _tmpl$5();
4469
+ const _el$ = _tmpl$4();
4539
4470
  spread(_el$, mergeProps({
4540
4471
  get ["class"]() {
4541
4472
  return `builder-columns ${props.builderBlock.id}-breakpoints ` + css({
@@ -4564,7 +4495,7 @@ function Columns(props) {
4564
4495
  children: (column, _index) => {
4565
4496
  const index = _index();
4566
4497
  return (() => {
4567
- const _el$2 = _tmpl$5();
4498
+ const _el$2 = _tmpl$4();
4568
4499
  spread(_el$2, mergeProps({
4569
4500
  get ["class"]() {
4570
4501
  return "builder-column " + css({
@@ -4605,10 +4536,10 @@ function Columns(props) {
4605
4536
  })();
4606
4537
  }
4607
4538
  var columns_default = Columns;
4608
- var _tmpl$6 = /* @__PURE__ */ template(`<span>`);
4539
+ var _tmpl$5 = /* @__PURE__ */ template(`<span>`);
4609
4540
  function FragmentComponent(props) {
4610
4541
  return (() => {
4611
- const _el$ = _tmpl$6();
4542
+ const _el$ = _tmpl$5();
4612
4543
  insert(_el$, () => props.children);
4613
4544
  return _el$;
4614
4545
  })();
@@ -4663,7 +4594,7 @@ function getSrcSet(url) {
4663
4594
  }
4664
4595
 
4665
4596
  // src/blocks/image/image.tsx
4666
- var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
4597
+ var _tmpl$6 = /* @__PURE__ */ template(`<source type=image/webp>`);
4667
4598
  var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
4668
4599
  var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
4669
4600
  function Image(props) {
@@ -4710,7 +4641,7 @@ function Image(props) {
4710
4641
  return webpSrcSet();
4711
4642
  },
4712
4643
  get children() {
4713
- const _el$2 = _tmpl$7();
4644
+ const _el$2 = _tmpl$6();
4714
4645
  effect(() => setAttribute(_el$2, "srcset", webpSrcSet()));
4715
4646
  return _el$2;
4716
4647
  }
@@ -4792,10 +4723,10 @@ function Image(props) {
4792
4723
  })];
4793
4724
  }
4794
4725
  var image_default = Image;
4795
- var _tmpl$8 = /* @__PURE__ */ template(`<section>`);
4726
+ var _tmpl$7 = /* @__PURE__ */ template(`<section>`);
4796
4727
  function SectionComponent(props) {
4797
4728
  return (() => {
4798
- const _el$ = _tmpl$8();
4729
+ const _el$ = _tmpl$7();
4799
4730
  spread(_el$, mergeProps({}, () => props.attributes, {
4800
4731
  get style() {
4801
4732
  return {
@@ -5289,7 +5220,7 @@ var componentInfo3 = {
5289
5220
  advanced: true
5290
5221
  }]
5291
5222
  };
5292
- var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
5223
+ var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
5293
5224
  function CustomCode(props) {
5294
5225
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
5295
5226
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -5324,7 +5255,7 @@ function CustomCode(props) {
5324
5255
  }
5325
5256
  });
5326
5257
  return (() => {
5327
- const _el$ = _tmpl$9();
5258
+ const _el$ = _tmpl$8();
5328
5259
  const _ref$ = elementRef;
5329
5260
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
5330
5261
  effect((_p$) => {
@@ -5384,7 +5315,7 @@ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "applicati
5384
5315
  var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
5385
5316
 
5386
5317
  // src/blocks/embed/embed.tsx
5387
- var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
5318
+ var _tmpl$9 = /* @__PURE__ */ template(`<div class=builder-embed>`);
5388
5319
  function Embed(props) {
5389
5320
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
5390
5321
  const [scriptsRun, setScriptsRun] = createSignal([]);
@@ -5420,7 +5351,7 @@ function Embed(props) {
5420
5351
  }
5421
5352
  createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
5422
5353
  return (() => {
5423
- const _el$ = _tmpl$10();
5354
+ const _el$ = _tmpl$9();
5424
5355
  const _ref$ = elem;
5425
5356
  typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
5426
5357
  effect(() => _el$.innerHTML = props.content);
@@ -5577,10 +5508,10 @@ var componentInfo7 = {
5577
5508
  noWrap: true,
5578
5509
  static: true
5579
5510
  };
5580
- var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
5511
+ var _tmpl$10 = /* @__PURE__ */ template(`<img>`);
5581
5512
  function ImgComponent(props) {
5582
5513
  return (() => {
5583
- const _el$ = _tmpl$11();
5514
+ const _el$ = _tmpl$10();
5584
5515
  spread(_el$, mergeProps({
5585
5516
  get style() {
5586
5517
  return {
@@ -5701,10 +5632,10 @@ var componentInfo10 = {
5701
5632
  textAlign: "center"
5702
5633
  }
5703
5634
  };
5704
- var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
5635
+ var _tmpl$11 = /* @__PURE__ */ template(`<div class=builder-text>`);
5705
5636
  function Text(props) {
5706
5637
  return (() => {
5707
- const _el$ = _tmpl$12();
5638
+ const _el$ = _tmpl$11();
5708
5639
  _el$.style.setProperty("outline", "none");
5709
5640
  effect(() => _el$.innerHTML = props.text?.toString() || "");
5710
5641
  return _el$;
@@ -5795,7 +5726,7 @@ var componentInfo11 = {
5795
5726
  advanced: true
5796
5727
  }]
5797
5728
  };
5798
- var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
5729
+ var _tmpl$12 = /* @__PURE__ */ template(`<source type=video/mp4>`);
5799
5730
  var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
5800
5731
  var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
5801
5732
  function Video(props) {
@@ -5858,7 +5789,7 @@ function Video(props) {
5858
5789
  return !props.lazyLoad;
5859
5790
  },
5860
5791
  get children() {
5861
- const _el$3 = _tmpl$13();
5792
+ const _el$3 = _tmpl$12();
5862
5793
  effect(() => setAttribute(_el$3, "src", props.video));
5863
5794
  return _el$3;
5864
5795
  }
@@ -6017,10 +5948,10 @@ var getUpdateVariantVisibilityScript = ({
6017
5948
  }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
6018
5949
  "${variationId}", "${contentId}", ${isHydrationTarget}
6019
5950
  )`;
6020
- var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
5951
+ var _tmpl$13 = /* @__PURE__ */ template(`<script>`);
6021
5952
  function InlinedScript(props) {
6022
5953
  return (() => {
6023
- const _el$ = _tmpl$14();
5954
+ const _el$ = _tmpl$13();
6024
5955
  effect((_p$) => {
6025
5956
  const _v$ = props.scriptStr, _v$2 = props.id || "";
6026
5957
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
@@ -6209,7 +6140,7 @@ async function fetchOneEntry(options) {
6209
6140
  limit: 1
6210
6141
  });
6211
6142
  if (allContent) {
6212
- return allContent.results[0] || null;
6143
+ return allContent[0] || null;
6213
6144
  }
6214
6145
  return null;
6215
6146
  }
@@ -6232,9 +6163,9 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
6232
6163
  content.results = newResults;
6233
6164
  }
6234
6165
  if (!canTrack)
6235
- return content;
6166
+ return content.results;
6236
6167
  if (!(isBrowser() || TARGET === "reactNative"))
6237
- return content;
6168
+ return content.results;
6238
6169
  try {
6239
6170
  const newResults = [];
6240
6171
  for (const item of content.results) {
@@ -6247,7 +6178,7 @@ var _processContentResult = async (options, content, url = generateContentUrl(op
6247
6178
  } catch (e) {
6248
6179
  logger.error("Could not process A/B tests. ", e);
6249
6180
  }
6250
- return content;
6181
+ return content.results;
6251
6182
  };
6252
6183
  async function fetchEntries(options) {
6253
6184
  try {
@@ -6520,7 +6451,7 @@ var getInteractionPropertiesForEvent = (event) => {
6520
6451
  };
6521
6452
 
6522
6453
  // src/constants/sdk-version.ts
6523
- var SDK_VERSION = "0.8.1";
6454
+ var SDK_VERSION = "0.10.0";
6524
6455
 
6525
6456
  // src/functions/register.ts
6526
6457
  var registry = {};
@@ -6654,11 +6585,11 @@ var setupBrowserForEditing = (options = {}) => {
6654
6585
  };
6655
6586
 
6656
6587
  // src/components/content/components/enable-editor.tsx
6657
- var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
6658
6588
  function EnableEditor(props) {
6659
6589
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
6660
6590
  createSignal(0);
6661
6591
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
6592
+ const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6662
6593
  const [httpReqsData, setHttpReqsData] = createSignal({});
6663
6594
  const [clicked, setClicked] = createSignal(false);
6664
6595
  function mergeNewContent(newContent) {
@@ -6891,10 +6822,7 @@ function EnableEditor(props) {
6891
6822
  return props.builderContextSignal.content;
6892
6823
  },
6893
6824
  get children() {
6894
- const _el$ = _tmpl$15();
6895
- const _ref$ = elementRef;
6896
- typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
6897
- spread(_el$, mergeProps({
6825
+ return createComponent(Dynamic, mergeProps({
6898
6826
  get ["class"]() {
6899
6827
  return `variant-${props.content?.testVariationId || props.content?.id}`;
6900
6828
  }
@@ -6902,7 +6830,11 @@ function EnableEditor(props) {
6902
6830
  get key() {
6903
6831
  return forceReRenderCount();
6904
6832
  },
6905
- "onClick": (event) => onClick(event),
6833
+ ref(r$) {
6834
+ const _ref$ = elementRef;
6835
+ typeof _ref$ === "function" ? _ref$(r$) : elementRef = r$;
6836
+ },
6837
+ onClick: (event) => onClick(event),
6906
6838
  get ["builder-content-id"]() {
6907
6839
  return props.builderContextSignal.content?.id;
6908
6840
  },
@@ -6912,9 +6844,14 @@ function EnableEditor(props) {
6912
6844
  }, {}, () => props.showContent ? {} : {
6913
6845
  hidden: true,
6914
6846
  "aria-hidden": true
6915
- }), false, true);
6916
- insert(_el$, () => props.children);
6917
- return _el$;
6847
+ }, () => props.contentWrapperProps, {
6848
+ get component() {
6849
+ return ContentWrapper();
6850
+ },
6851
+ get children() {
6852
+ return props.children;
6853
+ }
6854
+ }));
6918
6855
  }
6919
6856
  });
6920
6857
  }
@@ -7103,7 +7040,9 @@ function ContentComponent(props) {
7103
7040
  ...acc,
7104
7041
  [info.name]: serializeComponentInfo(info)
7105
7042
  }), {}),
7106
- inheritedStyles: {}
7043
+ inheritedStyles: {},
7044
+ BlocksWrapper: props.blocksWrapper || "div",
7045
+ BlocksWrapperProps: props.blocksWrapperProps || {}
7107
7046
  });
7108
7047
  function contentSetState(newRootState) {
7109
7048
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -7148,6 +7087,12 @@ function ContentComponent(props) {
7148
7087
  },
7149
7088
  get builderContextSignal() {
7150
7089
  return builderContextSignal();
7090
+ },
7091
+ get contentWrapper() {
7092
+ return props.contentWrapper;
7093
+ },
7094
+ get contentWrapperProps() {
7095
+ return props.contentWrapperProps;
7151
7096
  }
7152
7097
  }, {
7153
7098
  setBuilderContextSignal
@@ -7295,6 +7240,18 @@ function ContentVariants(props) {
7295
7240
  },
7296
7241
  get isSsrAbTest() {
7297
7242
  return shouldRenderVariants();
7243
+ },
7244
+ get blocksWrapper() {
7245
+ return props.blocksWrapper;
7246
+ },
7247
+ get blocksWrapperProps() {
7248
+ return props.blocksWrapperProps;
7249
+ },
7250
+ get contentWrapper() {
7251
+ return props.contentWrapper;
7252
+ },
7253
+ get contentWrapperProps() {
7254
+ return props.contentWrapperProps;
7298
7255
  }
7299
7256
  });
7300
7257
  }
@@ -7337,6 +7294,18 @@ function ContentVariants(props) {
7337
7294
  },
7338
7295
  get isSsrAbTest() {
7339
7296
  return shouldRenderVariants();
7297
+ },
7298
+ get blocksWrapper() {
7299
+ return props.blocksWrapper;
7300
+ },
7301
+ get blocksWrapperProps() {
7302
+ return props.blocksWrapperProps;
7303
+ },
7304
+ get contentWrapper() {
7305
+ return props.contentWrapper;
7306
+ },
7307
+ get contentWrapperProps() {
7308
+ return props.contentWrapperProps;
7340
7309
  }
7341
7310
  }))];
7342
7311
  }
@@ -7367,7 +7336,7 @@ var fetchSymbolContent = async ({
7367
7336
  };
7368
7337
 
7369
7338
  // src/blocks/symbol/symbol.tsx
7370
- var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
7339
+ var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
7371
7340
  function Symbol2(props) {
7372
7341
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
7373
7342
  function className() {
@@ -7393,7 +7362,7 @@ function Symbol2(props) {
7393
7362
  }
7394
7363
  createEffect(on(() => [props.symbol], onUpdateFn_0));
7395
7364
  return (() => {
7396
- const _el$ = _tmpl$16();
7365
+ const _el$ = _tmpl$14();
7397
7366
  spread(_el$, mergeProps({
7398
7367
  get ["class"]() {
7399
7368
  return className();