@builder.io/sdk-solid 1.0.21 → 1.0.22

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
@@ -166,7 +166,8 @@ function isIframe() {
166
166
 
167
167
  // src/functions/is-editing.ts
168
168
  function isEditing(search) {
169
- return isIframe() && (TARGET === "reactNative" || getSearchString(search || window.location.search).indexOf("builder.frameEditing=") !== -1);
169
+ return isIframe() && (TARGET === "reactNative" || // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
170
+ getSearchString(search || window.location.search).indexOf("builder.frameEditing=") !== -1);
170
171
  }
171
172
 
172
173
  // src/functions/track/helpers.ts
@@ -679,9 +680,6 @@ function bindAnimations(animations) {
679
680
  case "pageLoad":
680
681
  triggerAnimation(animation);
681
682
  break;
682
- case "hover":
683
- bindHoverAnimation(animation);
684
- break;
685
683
  case "scrollInView":
686
684
  bindScrollInViewAnimation(animation);
687
685
  break;
@@ -739,33 +737,6 @@ function triggerAnimation(animation) {
739
737
  });
740
738
  });
741
739
  }
742
- function bindHoverAnimation(animation) {
743
- const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
744
- if (!elements.length) {
745
- warnElementNotPresent(animation.elementId || animation.id || "");
746
- return;
747
- }
748
- Array.from(elements).forEach((element) => {
749
- augmentAnimation(animation, element);
750
- const defaultState = animation.steps[0].styles;
751
- const hoverState = animation.steps[1].styles;
752
- function attachDefaultState() {
753
- assign(element.style, defaultState);
754
- }
755
- function attachHoverState() {
756
- assign(element.style, hoverState);
757
- }
758
- attachDefaultState();
759
- element.addEventListener("mouseenter", attachHoverState);
760
- element.addEventListener("mouseleave", attachDefaultState);
761
- setTimeout(() => {
762
- element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
763
- if (animation.delay) {
764
- element.style.transitionDelay = animation.delay + "s";
765
- }
766
- });
767
- });
768
- }
769
740
  function bindScrollInViewAnimation(animation) {
770
741
  const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
771
742
  if (!elements.length) {
@@ -1073,7 +1044,20 @@ function BlockStyles(props) {
1073
1044
  styles: smallStyles,
1074
1045
  mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
1075
1046
  }) : "";
1076
- return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
1047
+ const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
1048
+ let hoverStylesClass = "";
1049
+ if (hoverAnimation) {
1050
+ const hoverStyles = hoverAnimation.steps?.[1]?.styles || {};
1051
+ hoverStylesClass = createCssClass({
1052
+ className: `${className}:hover`,
1053
+ styles: {
1054
+ ...hoverStyles,
1055
+ transition: `all ${hoverAnimation.duration}s ${camelCaseToKebabCase(hoverAnimation.easing)}`,
1056
+ transitionDelay: hoverAnimation.delay ? `${hoverAnimation.delay}s` : "0s"
1057
+ }
1058
+ }) || "";
1059
+ }
1060
+ return [largeStylesClass, mediumStylesClass, smallStylesClass, hoverStylesClass].join(" ");
1077
1061
  });
1078
1062
  return createComponent(Show, {
1079
1063
  get when() {
@@ -1405,7 +1389,7 @@ function Block(props) {
1405
1389
  const blockId = processedBlock().id;
1406
1390
  const animations = processedBlock().animations;
1407
1391
  if (animations && blockId) {
1408
- bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1392
+ bindAnimations(animations.map((animation) => ({
1409
1393
  ...animation,
1410
1394
  elementId: blockId
1411
1395
  })));
@@ -4325,14 +4309,12 @@ async function fetchEntries(options) {
4325
4309
  }
4326
4310
 
4327
4311
  // src/functions/is-previewing.ts
4328
- function isPreviewing(search) {
4329
- if (!isBrowser()) {
4330
- return false;
4331
- }
4332
- const normalizedSearch = getSearchString(search || window.location.search);
4333
- if (isEditing(normalizedSearch)) {
4312
+ function isPreviewing(_search) {
4313
+ const search = _search || (isBrowser() ? window.location.search : void 0);
4314
+ if (!search) {
4334
4315
  return false;
4335
4316
  }
4317
+ const normalizedSearch = getSearchString(search);
4336
4318
  return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
4337
4319
  }
4338
4320
 
@@ -4580,7 +4562,7 @@ function isFromTrustedHost(trustedHosts, e) {
4580
4562
  }
4581
4563
 
4582
4564
  // src/constants/sdk-version.ts
4583
- var SDK_VERSION = "1.0.21";
4565
+ var SDK_VERSION = "1.0.22";
4584
4566
 
4585
4567
  // src/functions/register.ts
4586
4568
  var registry = {};
@@ -4956,7 +4938,7 @@ function EnableEditor(props) {
4956
4938
  variationId: variationId !== contentId ? variationId : void 0
4957
4939
  });
4958
4940
  }
4959
- if (isPreviewing()) {
4941
+ if (isPreviewing() && !isEditing()) {
4960
4942
  const searchParams = new URL(location.href).searchParams;
4961
4943
  const searchParamPreviewModel = searchParams.get("builder.preview");
4962
4944
  const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
@@ -152,7 +152,8 @@ function isIframe() {
152
152
 
153
153
  // src/functions/is-editing.ts
154
154
  function isEditing(search) {
155
- return isIframe() && (TARGET === "reactNative" || getSearchString(search || window.location.search).indexOf("builder.frameEditing=") !== -1);
155
+ return isIframe() && (TARGET === "reactNative" || // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
156
+ getSearchString(search || window.location.search).indexOf("builder.frameEditing=") !== -1);
156
157
  }
157
158
 
158
159
  // src/functions/track/helpers.ts
@@ -668,9 +669,6 @@ function bindAnimations(animations) {
668
669
  case "pageLoad":
669
670
  triggerAnimation(animation);
670
671
  break;
671
- case "hover":
672
- bindHoverAnimation(animation);
673
- break;
674
672
  case "scrollInView":
675
673
  bindScrollInViewAnimation(animation);
676
674
  break;
@@ -728,33 +726,6 @@ function triggerAnimation(animation) {
728
726
  });
729
727
  });
730
728
  }
731
- function bindHoverAnimation(animation) {
732
- const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
733
- if (!elements.length) {
734
- warnElementNotPresent(animation.elementId || animation.id || "");
735
- return;
736
- }
737
- Array.from(elements).forEach((element) => {
738
- augmentAnimation(animation, element);
739
- const defaultState = animation.steps[0].styles;
740
- const hoverState = animation.steps[1].styles;
741
- function attachDefaultState() {
742
- assign(element.style, defaultState);
743
- }
744
- function attachHoverState() {
745
- assign(element.style, hoverState);
746
- }
747
- attachDefaultState();
748
- element.addEventListener("mouseenter", attachHoverState);
749
- element.addEventListener("mouseleave", attachDefaultState);
750
- setTimeout(() => {
751
- element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
752
- if (animation.delay) {
753
- element.style.transitionDelay = animation.delay + "s";
754
- }
755
- });
756
- });
757
- }
758
729
  function bindScrollInViewAnimation(animation) {
759
730
  const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
760
731
  if (!elements.length) {
@@ -1062,7 +1033,27 @@ function BlockStyles(props) {
1062
1033
  sizesWithUpdatedBreakpoints
1063
1034
  )
1064
1035
  }) : "";
1065
- return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
1036
+ const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
1037
+ let hoverStylesClass = "";
1038
+ if (hoverAnimation) {
1039
+ const hoverStyles = hoverAnimation.steps?.[1]?.styles || {};
1040
+ hoverStylesClass = createCssClass({
1041
+ className: `${className}:hover`,
1042
+ styles: {
1043
+ ...hoverStyles,
1044
+ transition: `all ${hoverAnimation.duration}s ${camelCaseToKebabCase(
1045
+ hoverAnimation.easing
1046
+ )}`,
1047
+ transitionDelay: hoverAnimation.delay ? `${hoverAnimation.delay}s` : "0s"
1048
+ }
1049
+ }) || "";
1050
+ }
1051
+ return [
1052
+ largeStylesClass,
1053
+ mediumStylesClass,
1054
+ smallStylesClass,
1055
+ hoverStylesClass
1056
+ ].join(" ");
1066
1057
  });
1067
1058
  return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default id="builderio-block" styles={css5()} /></Show2>;
1068
1059
  }
@@ -1341,7 +1332,7 @@ function Block(props) {
1341
1332
  const animations = processedBlock().animations;
1342
1333
  if (animations && blockId) {
1343
1334
  bindAnimations(
1344
- animations.filter((item) => item.trigger !== "hover").map((animation) => ({
1335
+ animations.map((animation) => ({
1345
1336
  ...animation,
1346
1337
  elementId: blockId
1347
1338
  }))
@@ -3910,14 +3901,12 @@ async function fetchEntries(options) {
3910
3901
  }
3911
3902
 
3912
3903
  // src/functions/is-previewing.ts
3913
- function isPreviewing(search) {
3914
- if (!isBrowser()) {
3915
- return false;
3916
- }
3917
- const normalizedSearch = getSearchString(search || window.location.search);
3918
- if (isEditing(normalizedSearch)) {
3904
+ function isPreviewing(_search) {
3905
+ const search = _search || (isBrowser() ? window.location.search : void 0);
3906
+ if (!search) {
3919
3907
  return false;
3920
3908
  }
3909
+ const normalizedSearch = getSearchString(search);
3921
3910
  return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
3922
3911
  }
3923
3912
 
@@ -4165,7 +4154,7 @@ function isFromTrustedHost(trustedHosts, e) {
4165
4154
  }
4166
4155
 
4167
4156
  // src/constants/sdk-version.ts
4168
- var SDK_VERSION = "1.0.21";
4157
+ var SDK_VERSION = "1.0.22";
4169
4158
 
4170
4159
  // src/functions/register.ts
4171
4160
  var registry = {};
@@ -4555,7 +4544,7 @@ function EnableEditor(props) {
4555
4544
  variationId: variationId !== contentId ? variationId : void 0
4556
4545
  });
4557
4546
  }
4558
- if (isPreviewing()) {
4547
+ if (isPreviewing() && !isEditing()) {
4559
4548
  const searchParams = new URL(location.href).searchParams;
4560
4549
  const searchParamPreviewModel = searchParams.get("builder.preview");
4561
4550
  const searchParamPreviewId = searchParams.get(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",