@builder.io/sdk-react 0.7.4 → 0.7.5

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.
@@ -176,24 +176,24 @@ output;
176
176
  event: i,
177
177
  state: l
178
178
  }), s = getIsolateContext(), d = s.global;
179
- d.setSync("global", d.derefInto()), d.setSync("log", function(...S) {
180
- console.log(...S);
181
- }), d.setSync(BUILDER_SET_STATE_NAME, function(S, g) {
182
- set(r, S, g), a == null || a(r);
183
- }), c.forEach(([S, g]) => {
184
- const y = typeof g == "object" ? new ivm.Reference(
179
+ d.setSync("global", d.derefInto()), d.setSync("log", function(...y) {
180
+ console.log(...y);
181
+ }), d.setSync(BUILDER_SET_STATE_NAME, function(y, m) {
182
+ set(r, y, m), a == null || a(r);
183
+ }), c.forEach(([y, m]) => {
184
+ const x = typeof m == "object" ? new ivm.Reference(
185
185
  // workaround: methods with default values for arguments is not being cloned over
186
- S === "builder" ? {
187
- ...g,
188
- getUserAttributes: () => g.getUserAttributes()
189
- } : g
186
+ y === "builder" ? {
187
+ ...m,
188
+ getUserAttributes: () => m.getUserAttributes()
189
+ } : m
190
190
  ) : null;
191
- d.setSync(getSyncValName(S), y);
191
+ d.setSync(getSyncValName(y), x);
192
192
  }), d.setSync(INJECTED_IVM_GLOBAL, ivm);
193
- const f = processCode({
193
+ const g = processCode({
194
194
  code: e,
195
195
  args: c
196
- }), b = s.evalSync(f);
196
+ }), b = s.evalSync(g);
197
197
  try {
198
198
  return JSON.parse(b);
199
199
  } catch {
@@ -412,7 +412,7 @@ function BlockStyles(e) {
412
412
  return checkIsDefined(i.hide) ? !i.hide : checkIsDefined(i.show) ? i.show : !0;
413
413
  }
414
414
  function n() {
415
- var g;
415
+ var m;
416
416
  const i = getProcessedBlock({
417
417
  block: e.block,
418
418
  localState: e.context.localState,
@@ -421,11 +421,11 @@ function BlockStyles(e) {
421
421
  context: e.context.context,
422
422
  shouldEvaluateBindings: !0
423
423
  }), o = i.responsiveStyles, a = e.context.content, r = getSizesForBreakpoints(
424
- ((g = a == null ? void 0 : a.meta) == null ? void 0 : g.breakpoints) || {}
424
+ ((m = a == null ? void 0 : a.meta) == null ? void 0 : m.breakpoints) || {}
425
425
  ), l = o == null ? void 0 : o.large, c = o == null ? void 0 : o.medium, s = o == null ? void 0 : o.small, d = i.id;
426
426
  if (!d)
427
427
  return "";
428
- const f = l ? createCssClass({
428
+ const g = l ? createCssClass({
429
429
  className: d,
430
430
  styles: l
431
431
  }) : "", b = c ? createCssClass({
@@ -435,7 +435,7 @@ function BlockStyles(e) {
435
435
  "medium",
436
436
  r
437
437
  )
438
- }) : "", S = s ? createCssClass({
438
+ }) : "", y = s ? createCssClass({
439
439
  className: d,
440
440
  styles: s,
441
441
  mediaQuery: getMaxWidthQueryForSize(
@@ -443,7 +443,7 @@ function BlockStyles(e) {
443
443
  r
444
444
  )
445
445
  }) : "";
446
- return [f, b, S].join(" ");
446
+ return [g, b, y].join(" ");
447
447
  }
448
448
  return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: n() }) }) : null });
449
449
  }
@@ -657,7 +657,7 @@ function RepeatedBlock(e) {
657
657
  ) });
658
658
  }
659
659
  function Block(e) {
660
- var d, f, b, S;
660
+ var d, g, b, y;
661
661
  function t() {
662
662
  return getComponent({
663
663
  block: e.block,
@@ -672,7 +672,8 @@ function Block(e) {
672
672
  });
673
673
  }
674
674
  function i() {
675
- return n() ? e.block : getProcessedBlock({
675
+ var m;
676
+ return (m = e.block.repeat) != null && m.collection ? e.block : getProcessedBlock({
676
677
  block: e.block,
677
678
  localState: e.context.localState,
678
679
  rootState: e.context.rootState,
@@ -685,21 +686,22 @@ function Block(e) {
685
686
  return e.block.tagName || "div";
686
687
  }
687
688
  function a() {
688
- return "hide" in i() ? !i().hide : "show" in i() ? i().show : !0;
689
+ var m, x;
690
+ return "hide" in i() ? !i().hide : "show" in i() ? i().show : !((m = e.block.repeat) != null && m.collection && !((x = n == null ? void 0 : n()) != null && x.length));
689
691
  }
690
692
  function r() {
691
- var y;
692
- return !((y = t == null ? void 0 : t()) != null && y.component) && !n() ? i().children ?? [] : [];
693
+ var x;
694
+ return !((x = t == null ? void 0 : t()) != null && x.component) && !n() ? i().children ?? [] : [];
693
695
  }
694
696
  function l() {
695
- var g, y, E, I, v;
697
+ var m, x, E, I, v;
696
698
  return {
697
699
  blockChildren: i().children ?? [],
698
- componentRef: (g = t == null ? void 0 : t()) == null ? void 0 : g.component,
700
+ componentRef: (m = t == null ? void 0 : t()) == null ? void 0 : m.component,
699
701
  componentOptions: {
700
702
  ...getBlockComponentOptions(i()),
701
703
  builderContext: e.context,
702
- ...((y = t == null ? void 0 : t()) == null ? void 0 : y.name) === "Symbol" || ((E = t == null ? void 0 : t()) == null ? void 0 : E.name) === "Columns" ? {
704
+ ...((x = t == null ? void 0 : t()) == null ? void 0 : x.name) === "Symbol" || ((E = t == null ? void 0 : t()) == null ? void 0 : E.name) === "Columns" ? {
703
705
  builderComponents: e.registeredComponents
704
706
  } : {}
705
707
  },
@@ -733,14 +735,14 @@ function Block(e) {
733
735
  hasChildren: !1
734
736
  }
735
737
  ) }) : null,
736
- !isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (f = n()) == null ? void 0 : f.map((g, y) => /* @__PURE__ */ jsx(
738
+ !isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (g = n()) == null ? void 0 : g.map((m, x) => /* @__PURE__ */ jsx(
737
739
  RepeatedBlock,
738
740
  {
739
- repeatContext: g.context,
740
- block: g.block,
741
+ repeatContext: m.context,
742
+ block: m.block,
741
743
  registeredComponents: e.registeredComponents
742
744
  },
743
- y
745
+ x
744
746
  )) }) : null,
745
747
  !isEmptyHtmlElement(o()) && !n() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
746
748
  BlockWrapper,
@@ -763,22 +765,22 @@ function Block(e) {
763
765
  isInteractive: l().isInteractive
764
766
  }
765
767
  ),
766
- (b = r()) == null ? void 0 : b.map((g) => /* @__PURE__ */ jsx(
768
+ (b = r()) == null ? void 0 : b.map((m) => /* @__PURE__ */ jsx(
767
769
  Block,
768
770
  {
769
- block: g,
771
+ block: m,
770
772
  context: c,
771
773
  registeredComponents: e.registeredComponents
772
774
  },
773
- "block-" + g.id
775
+ "block-" + m.id
774
776
  )),
775
- (S = r()) == null ? void 0 : S.map((g) => /* @__PURE__ */ jsx(
777
+ (y = r()) == null ? void 0 : y.map((m) => /* @__PURE__ */ jsx(
776
778
  BlockStyles,
777
779
  {
778
- block: g,
780
+ block: m,
779
781
  context: c
780
782
  },
781
- "block-style-" + g.id
783
+ "block-style-" + m.id
782
784
  ))
783
785
  ]
784
786
  }
@@ -896,19 +898,19 @@ function Columns(e) {
896
898
  }) {
897
899
  return a === "never" ? C : v;
898
900
  }
899
- const [f, b] = useState(
901
+ const [g, b] = useState(
900
902
  () => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
901
903
  );
902
- function S() {
904
+ function y() {
903
905
  return {
904
- "--flex-dir": f,
906
+ "--flex-dir": g,
905
907
  "--flex-dir-tablet": s({
906
- stackedStyle: f,
908
+ stackedStyle: g,
907
909
  desktopStyle: "row"
908
910
  })
909
911
  };
910
912
  }
911
- function g(v) {
913
+ function m(v) {
912
914
  const C = v === 0 ? 0 : t, T = c(v), w = `${C}px`, R = "100%", j = 0;
913
915
  return {
914
916
  width: T,
@@ -931,7 +933,7 @@ function Columns(e) {
931
933
  })
932
934
  };
933
935
  }
934
- function y(v) {
936
+ function x(v) {
935
937
  var T, w;
936
938
  return getSizesForBreakpoints(
937
939
  ((w = (T = e.builderContext.content) == null ? void 0 : T.meta) == null ? void 0 : w.breakpoints) || {}
@@ -939,7 +941,7 @@ function Columns(e) {
939
941
  }
940
942
  function E() {
941
943
  return `
942
- @media (max-width: ${y("medium")}px) {
944
+ @media (max-width: ${x("medium")}px) {
943
945
  .${e.builderBlock.id}-breakpoints {
944
946
  flex-direction: var(--flex-dir-tablet);
945
947
  align-items: stretch;
@@ -951,7 +953,7 @@ function Columns(e) {
951
953
  }
952
954
  }
953
955
 
954
- @media (max-width: ${y("small")}px) {
956
+ @media (max-width: ${x("small")}px) {
955
957
  .${e.builderBlock.id}-breakpoints {
956
958
  flex-direction: var(--flex-dir);
957
959
  align-items: stretch;
@@ -969,14 +971,14 @@ function Columns(e) {
969
971
  "div",
970
972
  {
971
973
  className: `builder-columns ${e.builderBlock.id}-breakpoints div-53636e90`,
972
- style: S(),
974
+ style: y(),
973
975
  children: [
974
976
  /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: E() }) }),
975
977
  (I = e.columns) == null ? void 0 : I.map((v, C) => /* @__PURE__ */ createElement(
976
978
  "div",
977
979
  {
978
980
  className: "builder-column div-53636e90-2",
979
- style: g(C),
981
+ style: m(C),
980
982
  key: C
981
983
  },
982
984
  /* @__PURE__ */ jsx(
@@ -1471,14 +1473,14 @@ function Embed(e) {
1471
1473
  return;
1472
1474
  const s = t.current.getElementsByTagName("script");
1473
1475
  for (let d = 0; d < s.length; d++) {
1474
- const f = s[d];
1475
- if (f.src && !n.includes(f.src)) {
1476
- n.push(f.src);
1476
+ const g = s[d];
1477
+ if (g.src && !n.includes(g.src)) {
1478
+ n.push(g.src);
1477
1479
  const b = document.createElement("script");
1478
- b.async = !0, b.src = f.src, document.head.appendChild(b);
1479
- } else if (isJsScript(f) && !o.includes(f.innerText))
1480
+ b.async = !0, b.src = g.src, document.head.appendChild(b);
1481
+ } else if (isJsScript(g) && !o.includes(g.innerText))
1480
1482
  try {
1481
- o.push(f.innerText), new Function(f.innerText)();
1483
+ o.push(g.innerText), new Function(g.innerText)();
1482
1484
  } catch (b) {
1483
1485
  console.warn("`Embed`: Error running script:", b);
1484
1486
  }
@@ -1524,13 +1526,13 @@ const componentInfo$6 = {
1524
1526
  function n(r, l = 6e4) {
1525
1527
  return new Promise((c, s) => {
1526
1528
  const d = document.createElement("img");
1527
- let f = !1;
1529
+ let g = !1;
1528
1530
  d.onload = () => {
1529
- f = !0, c(d);
1531
+ g = !0, c(d);
1530
1532
  }, d.addEventListener("error", (b) => {
1531
1533
  console.warn("Image load failed", b.error), s(b.error);
1532
1534
  }), d.src = r, setTimeout(() => {
1533
- f || s(new Error("Image load timed out"));
1535
+ g || s(new Error("Image load timed out"));
1534
1536
  }, l);
1535
1537
  });
1536
1538
  }
@@ -2111,7 +2113,7 @@ const findParentElement = (e, t, n = !0) => {
2111
2113
  builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
2112
2114
  }
2113
2115
  };
2114
- }, SDK_VERSION = "0.7.4", registerInsertMenu = () => {
2116
+ }, SDK_VERSION = "0.7.5", registerInsertMenu = () => {
2115
2117
  register("insertMenu", {
2116
2118
  name: "_default",
2117
2119
  default: !0,
@@ -2161,21 +2163,21 @@ const setupBrowserForEditing = (e = {}) => {
2161
2163
  switch (i.type) {
2162
2164
  case "builder.evaluate": {
2163
2165
  const r = i.data.text, l = i.data.arguments || [], c = i.data.id, s = new Function(r);
2164
- let d, f = null;
2166
+ let d, g = null;
2165
2167
  try {
2166
2168
  d = s.apply(null, l);
2167
2169
  } catch (b) {
2168
- f = b;
2170
+ g = b;
2169
2171
  }
2170
- f ? (o = window.parent) == null || o.postMessage({
2172
+ g ? (o = window.parent) == null || o.postMessage({
2171
2173
  type: "builder.evaluateError",
2172
2174
  data: {
2173
2175
  id: c,
2174
- error: f.message
2176
+ error: g.message
2175
2177
  }
2176
2178
  }, "*") : d && typeof d.then == "function" ? d.then((b) => {
2177
- var S;
2178
- (S = window.parent) == null || S.postMessage({
2179
+ var y;
2180
+ (y = window.parent) == null || y.postMessage({
2179
2181
  type: "builder.evaluateResult",
2180
2182
  data: {
2181
2183
  id: c,
@@ -2198,8 +2200,8 @@ function EnableEditor(e) {
2198
2200
  var T, w, R, j, B, A, P;
2199
2201
  const t = useRef(null), [n, i] = useState(() => 0);
2200
2202
  function o(u) {
2201
- var h, x, p, k, F;
2202
- const m = {
2203
+ var h, S, p, k, F;
2204
+ const f = {
2203
2205
  ...e.builderContextSignal.content,
2204
2206
  ...u,
2205
2207
  data: {
@@ -2207,14 +2209,14 @@ function EnableEditor(e) {
2207
2209
  ...u == null ? void 0 : u.data
2208
2210
  },
2209
2211
  meta: {
2210
- ...(x = e.builderContextSignal.content) == null ? void 0 : x.meta,
2212
+ ...(S = e.builderContextSignal.content) == null ? void 0 : S.meta,
2211
2213
  ...u == null ? void 0 : u.meta,
2212
2214
  breakpoints: ((p = u == null ? void 0 : u.meta) == null ? void 0 : p.breakpoints) || ((F = (k = e.builderContextSignal.content) == null ? void 0 : k.meta) == null ? void 0 : F.breakpoints)
2213
2215
  }
2214
2216
  };
2215
2217
  e.setBuilderContextSignal((_) => ({
2216
2218
  ..._,
2217
- content: m
2219
+ content: f
2218
2220
  }));
2219
2221
  }
2220
2222
  useState(() => 0);
@@ -2223,11 +2225,11 @@ function EnableEditor(e) {
2223
2225
  );
2224
2226
  function l(u) {
2225
2227
  var h;
2226
- const { data: m } = u;
2227
- if (m)
2228
- switch (m.type) {
2228
+ const { data: f } = u;
2229
+ if (f)
2230
+ switch (f.type) {
2229
2231
  case "builder.configureSdk": {
2230
- const x = m.data, { breakpoints: p, contentId: k } = x;
2232
+ const S = f.data, { breakpoints: p, contentId: k } = S;
2231
2233
  if (!k || k !== ((h = e.builderContextSignal.content) == null ? void 0 : h.id))
2232
2234
  return;
2233
2235
  p && o({
@@ -2238,15 +2240,15 @@ function EnableEditor(e) {
2238
2240
  break;
2239
2241
  }
2240
2242
  case "builder.contentUpdate": {
2241
- const x = m.data, p = x.key || x.alias || x.entry || x.modelName, k = x.data;
2243
+ const S = f.data, p = S.key || S.alias || S.entry || S.modelName, k = S.data;
2242
2244
  p === e.model && (o(k), i(n + 1));
2243
2245
  break;
2244
2246
  }
2245
2247
  }
2246
2248
  }
2247
2249
  function c() {
2248
- var m, h;
2249
- const u = (h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.jsCode;
2250
+ var f, h;
2251
+ const u = (h = (f = e.builderContextSignal.content) == null ? void 0 : f.data) == null ? void 0 : h.jsCode;
2250
2252
  u && evaluate({
2251
2253
  code: u,
2252
2254
  context: e.context || {},
@@ -2255,27 +2257,27 @@ function EnableEditor(e) {
2255
2257
  rootSetState: e.builderContextSignal.rootSetState
2256
2258
  });
2257
2259
  }
2258
- const [s, d] = useState(() => ({})), [f, b] = useState(() => !1);
2259
- function S(u) {
2260
- var m, h;
2260
+ const [s, d] = useState(() => ({})), [g, b] = useState(() => !1);
2261
+ function y(u) {
2262
+ var f, h;
2261
2263
  if (e.builderContextSignal.content) {
2262
- const x = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, p = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
2264
+ const S = (f = e.builderContextSignal.content) == null ? void 0 : f.testVariationId, p = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
2263
2265
  _track({
2264
2266
  type: "click",
2265
2267
  canTrack: getDefaultCanTrack(e.canTrack),
2266
2268
  contentId: p,
2267
2269
  apiKey: e.apiKey,
2268
- variationId: x !== p ? x : void 0,
2270
+ variationId: S !== p ? S : void 0,
2269
2271
  ...getInteractionPropertiesForEvent(u),
2270
- unique: !f
2272
+ unique: !g
2271
2273
  });
2272
2274
  }
2273
- f || b(!0);
2275
+ g || b(!0);
2274
2276
  }
2275
- function g(u) {
2277
+ function m(u) {
2276
2278
  return u.replace(
2277
2279
  /{{([^}]+)}}/g,
2278
- (m, h) => evaluate({
2280
+ (f, h) => evaluate({
2279
2281
  code: h,
2280
2282
  context: e.context || {},
2281
2283
  localState: void 0,
@@ -2284,27 +2286,27 @@ function EnableEditor(e) {
2284
2286
  })
2285
2287
  );
2286
2288
  }
2287
- function y({ url: u, key: m }) {
2289
+ function x({ url: u, key: f }) {
2288
2290
  fetch$1(u).then((h) => h.json()).then((h) => {
2289
2291
  var p, k;
2290
- const x = {
2292
+ const S = {
2291
2293
  ...e.builderContextSignal.rootState,
2292
- [m]: h
2294
+ [f]: h
2293
2295
  };
2294
- (k = (p = e.builderContextSignal).rootSetState) == null || k.call(p, x), s[m] = !0;
2296
+ (k = (p = e.builderContextSignal).rootSetState) == null || k.call(p, S), s[f] = !0;
2295
2297
  }).catch((h) => {
2296
2298
  console.error("error fetching dynamic data", u, h);
2297
2299
  });
2298
2300
  }
2299
2301
  function E() {
2300
- var m, h;
2301
- const u = ((h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.httpRequests) ?? {};
2302
- Object.entries(u).forEach(([x, p]) => {
2303
- if (p && (!s[x] || isEditing())) {
2304
- const k = g(p);
2305
- y({
2302
+ var f, h;
2303
+ const u = ((h = (f = e.builderContextSignal.content) == null ? void 0 : f.data) == null ? void 0 : h.httpRequests) ?? {};
2304
+ Object.entries(u).forEach(([S, p]) => {
2305
+ if (p && (!s[S] || isEditing())) {
2306
+ const k = m(p);
2307
+ x({
2306
2308
  url: k,
2307
- key: x
2309
+ key: S
2308
2310
  });
2309
2311
  }
2310
2312
  });
@@ -2337,20 +2339,20 @@ function EnableEditor(e) {
2337
2339
  } : {}
2338
2340
  }), Object.values(
2339
2341
  e.builderContextSignal.componentInfos
2340
- ).forEach((m) => {
2341
- var x;
2342
- const h = createRegisterComponentMessage(m);
2343
- (x = window.parent) == null || x.postMessage(h, "*");
2342
+ ).forEach((f) => {
2343
+ var S;
2344
+ const h = createRegisterComponentMessage(f);
2345
+ (S = window.parent) == null || S.postMessage(h, "*");
2344
2346
  }), window.addEventListener(
2345
2347
  "builder:component:stateChangeListenerActivated",
2346
2348
  I
2347
2349
  );
2348
2350
  }
2349
2351
  function C(u) {
2350
- const m = new URL(location.href).searchParams, h = m.get("builder.preview"), x = m.get(
2352
+ const f = new URL(location.href).searchParams, h = f.get("builder.preview"), S = f.get(
2351
2353
  `builder.preview.${h}`
2352
- ), p = m.get("apiKey") || m.get("builder.space");
2353
- h === e.model && p === e.apiKey && (!e.content || x === e.content.id) && fetchOneEntry({
2354
+ ), p = f.get("apiKey") || f.get("builder.space");
2355
+ h === e.model && p === e.apiKey && (!e.content || S === e.content.id) && fetchOneEntry({
2354
2356
  model: e.model,
2355
2357
  apiKey: e.apiKey,
2356
2358
  apiVersion: e.builderContextSignal.apiVersion
@@ -2364,8 +2366,8 @@ function EnableEditor(e) {
2364
2366
  "initeditingbldr",
2365
2367
  v
2366
2368
  ), () => {
2367
- var m;
2368
- return (m = t.current) == null ? void 0 : m.removeEventListener(
2369
+ var f;
2370
+ return (f = t.current) == null ? void 0 : f.removeEventListener(
2369
2371
  "initeditingbldr",
2370
2372
  v
2371
2373
  );
@@ -2376,23 +2378,23 @@ function EnableEditor(e) {
2376
2378
  "initpreviewingbldr",
2377
2379
  C
2378
2380
  ), () => {
2379
- var m;
2380
- return (m = t.current) == null ? void 0 : m.removeEventListener(
2381
+ var f;
2382
+ return (f = t.current) == null ? void 0 : f.removeEventListener(
2381
2383
  "initpreviewingbldr",
2382
2384
  C
2383
2385
  );
2384
2386
  };
2385
2387
  }, []), useEffect(() => {
2386
- var u, m;
2388
+ var u, f;
2387
2389
  if (isBrowser()) {
2388
2390
  if (isEditing() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && getDefaultCanTrack(e.canTrack)) {
2389
- const x = (u = e.builderContextSignal.content) == null ? void 0 : u.testVariationId, p = (m = e.builderContextSignal.content) == null ? void 0 : m.id, k = e.apiKey;
2391
+ const S = (u = e.builderContextSignal.content) == null ? void 0 : u.testVariationId, p = (f = e.builderContextSignal.content) == null ? void 0 : f.id, k = e.apiKey;
2390
2392
  _track({
2391
2393
  type: "impression",
2392
2394
  canTrack: !0,
2393
2395
  contentId: p,
2394
2396
  apiKey: k,
2395
- variationId: x !== p ? x : void 0
2397
+ variationId: S !== p ? S : void 0
2396
2398
  });
2397
2399
  }
2398
2400
  isPreviewing() && t.current && t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"));
@@ -2423,7 +2425,7 @@ function EnableEditor(e) {
2423
2425
  {
2424
2426
  key: n,
2425
2427
  ref: t,
2426
- onClick: (u) => S(u),
2428
+ onClick: (u) => y(u),
2427
2429
  "builder-content-id": (B = e.builderContextSignal.content) == null ? void 0 : B.id,
2428
2430
  "builder-model": e.model,
2429
2431
  ...e.showContent ? {} : {
@@ -2503,22 +2505,17 @@ const getContextStateInitialValue = ({
2503
2505
  locale: n
2504
2506
  }) => {
2505
2507
  var a, r, l;
2506
- const i = {};
2507
- (r = (a = e == null ? void 0 : e.data) == null ? void 0 : a.inputs) == null || r.forEach((c) => {
2508
- var s;
2509
- c.name && c.defaultValue !== void 0 && ((s = e == null ? void 0 : e.data) != null && s.state) && e.data.state[c.name] === void 0 && (i[c.name] = c.defaultValue);
2510
- });
2511
- const o = {
2512
- ...(l = e == null ? void 0 : e.data) == null ? void 0 : l.state,
2508
+ const i = {}, o = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.state) || {};
2509
+ return (l = (r = e == null ? void 0 : e.data) == null ? void 0 : r.inputs) == null || l.forEach((c) => {
2510
+ c.name && c.defaultValue !== void 0 && (i[c.name] = c.defaultValue);
2511
+ }), {
2512
+ ...i,
2513
+ ...o,
2513
2514
  ...t,
2514
2515
  ...n ? {
2515
2516
  locale: n
2516
2517
  } : {}
2517
2518
  };
2518
- return {
2519
- ...i,
2520
- ...o
2521
- };
2522
2519
  }, getContentInitialValue = ({
2523
2520
  content: e,
2524
2521
  data: t
@@ -2531,22 +2528,22 @@ const getContextStateInitialValue = ({
2531
2528
  meta: e == null ? void 0 : e.meta
2532
2529
  } : void 0;
2533
2530
  function ContentComponent(e) {
2534
- var c, s, d, f, b, S, g;
2531
+ var c, s, d, g, b, y, m;
2535
2532
  const [t, n] = useState(
2536
2533
  () => {
2537
- var y, E;
2534
+ var x, E;
2538
2535
  return getUpdateVariantVisibilityScript({
2539
2536
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2540
- variationId: (y = e.content) == null ? void 0 : y.testVariationId,
2537
+ variationId: (x = e.content) == null ? void 0 : x.testVariationId,
2541
2538
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2542
2539
  contentId: (E = e.content) == null ? void 0 : E.id
2543
2540
  });
2544
2541
  }
2545
2542
  );
2546
- function i(y) {
2543
+ function i(x) {
2547
2544
  l((E) => ({
2548
2545
  ...E,
2549
- rootState: y
2546
+ rootState: x
2550
2547
  }));
2551
2548
  }
2552
2549
  const [o, a] = useState(
@@ -2560,8 +2557,8 @@ function ContentComponent(e) {
2560
2557
  ...components,
2561
2558
  ...e.customComponents || []
2562
2559
  ].reduce(
2563
- (y, { component: E, ...I }) => ({
2564
- ...y,
2560
+ (x, { component: E, ...I }) => ({
2561
+ ...x,
2565
2562
  [I.name]: {
2566
2563
  component: E,
2567
2564
  ...serializeComponentInfo(I)
@@ -2594,8 +2591,8 @@ function ContentComponent(e) {
2594
2591
  ...components,
2595
2592
  ...e.customComponents || []
2596
2593
  ].reduce(
2597
- (y, { component: E, ...I }) => ({
2598
- ...y,
2594
+ (x, { component: E, ...I }) => ({
2595
+ ...x,
2599
2596
  [I.name]: serializeComponentInfo(I)
2600
2597
  }),
2601
2598
  {}
@@ -2629,13 +2626,13 @@ function ContentComponent(e) {
2629
2626
  {
2630
2627
  contentId: (c = r.content) == null ? void 0 : c.id,
2631
2628
  cssCode: (d = (s = r.content) == null ? void 0 : s.data) == null ? void 0 : d.cssCode,
2632
- customFonts: (b = (f = r.content) == null ? void 0 : f.data) == null ? void 0 : b.customFonts
2629
+ customFonts: (b = (g = r.content) == null ? void 0 : g.data) == null ? void 0 : b.customFonts
2633
2630
  }
2634
2631
  ) }),
2635
2632
  /* @__PURE__ */ jsx(
2636
2633
  Blocks,
2637
2634
  {
2638
- blocks: (g = (S = r.content) == null ? void 0 : S.data) == null ? void 0 : g.blocks,
2635
+ blocks: (m = (y = r.content) == null ? void 0 : y.data) == null ? void 0 : m.blocks,
2639
2636
  context: r,
2640
2637
  registeredComponents: o
2641
2638
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.7.4",
4
+ "version": "0.7.5",
5
5
  "files": [
6
6
  "lib",
7
7
  "types"
@@ -2,6 +2,6 @@ import type { BuilderContent } from '../../types/builder-content.js';
2
2
  import type { Nullable } from '../../types/typescript.js';
3
3
  import type { ContentProps } from './content.types.js';
4
4
  export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
- [x: string]: unknown;
5
+ locale?: string;
6
6
  };
7
7
  export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.4";
1
+ export declare const SDK_VERSION = "0.7.5";