@builder.io/sdk-react-nextjs 0.18.1 → 0.18.8

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.
Files changed (61) hide show
  1. package/lib/browser/blocks/custom-code/custom-code.cjs +1 -1
  2. package/lib/browser/blocks/custom-code/custom-code.mjs +27 -17
  3. package/lib/browser/blocks/embed/embed.cjs +1 -1
  4. package/lib/browser/blocks/embed/embed.mjs +16 -15
  5. package/lib/browser/blocks/image/component-info.cjs +1 -1
  6. package/lib/browser/blocks/image/component-info.mjs +12 -8
  7. package/lib/browser/blocks/image/image.cjs +4 -4
  8. package/lib/browser/blocks/image/image.mjs +14 -13
  9. package/lib/browser/components/blocks/blocks-wrapper.cjs +2 -2
  10. package/lib/browser/components/blocks/blocks-wrapper.mjs +18 -16
  11. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  12. package/lib/browser/components/content/components/enable-editor.mjs +65 -58
  13. package/lib/browser/components/content-variants/helpers.cjs +9 -9
  14. package/lib/browser/components/content-variants/helpers.mjs +16 -16
  15. package/lib/browser/components/content-variants/inlined-fns.cjs +5 -2
  16. package/lib/browser/components/content-variants/inlined-fns.mjs +5 -2
  17. package/lib/browser/constants/sdk-version.cjs +1 -1
  18. package/lib/browser/constants/sdk-version.mjs +1 -1
  19. package/lib/edge/blocks/custom-code/custom-code.cjs +1 -1
  20. package/lib/edge/blocks/custom-code/custom-code.mjs +27 -17
  21. package/lib/edge/blocks/embed/embed.cjs +1 -1
  22. package/lib/edge/blocks/embed/embed.mjs +16 -15
  23. package/lib/edge/blocks/image/component-info.cjs +1 -1
  24. package/lib/edge/blocks/image/component-info.mjs +12 -8
  25. package/lib/edge/blocks/image/image.cjs +4 -4
  26. package/lib/edge/blocks/image/image.mjs +14 -13
  27. package/lib/edge/components/blocks/blocks-wrapper.cjs +2 -2
  28. package/lib/edge/components/blocks/blocks-wrapper.mjs +18 -16
  29. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  30. package/lib/edge/components/content/components/enable-editor.mjs +65 -58
  31. package/lib/edge/components/content-variants/helpers.cjs +9 -9
  32. package/lib/edge/components/content-variants/helpers.mjs +16 -16
  33. package/lib/edge/components/content-variants/inlined-fns.cjs +5 -2
  34. package/lib/edge/components/content-variants/inlined-fns.mjs +5 -2
  35. package/lib/edge/constants/sdk-version.cjs +1 -1
  36. package/lib/edge/constants/sdk-version.mjs +1 -1
  37. package/lib/node/blocks/custom-code/custom-code.cjs +1 -1
  38. package/lib/node/blocks/custom-code/custom-code.mjs +27 -17
  39. package/lib/node/blocks/embed/embed.cjs +1 -1
  40. package/lib/node/blocks/embed/embed.mjs +16 -15
  41. package/lib/node/blocks/image/component-info.cjs +1 -1
  42. package/lib/node/blocks/image/component-info.mjs +12 -8
  43. package/lib/node/blocks/image/image.cjs +4 -4
  44. package/lib/node/blocks/image/image.mjs +14 -13
  45. package/lib/node/components/blocks/blocks-wrapper.cjs +2 -2
  46. package/lib/node/components/blocks/blocks-wrapper.mjs +18 -16
  47. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  48. package/lib/node/components/content/components/enable-editor.mjs +65 -58
  49. package/lib/node/components/content-variants/helpers.cjs +9 -9
  50. package/lib/node/components/content-variants/helpers.mjs +16 -16
  51. package/lib/node/components/content-variants/inlined-fns.cjs +5 -2
  52. package/lib/node/components/content-variants/inlined-fns.mjs +5 -2
  53. package/lib/node/constants/sdk-version.cjs +1 -1
  54. package/lib/node/constants/sdk-version.mjs +1 -1
  55. package/package.json +1 -1
  56. package/types/cjs/blocks/image/image.types.d.ts +1 -0
  57. package/types/cjs/components/content-variants/inlined-fns.d.ts +1 -1
  58. package/types/cjs/constants/sdk-version.d.ts +1 -1
  59. package/types/esm/blocks/image/image.types.d.ts +1 -0
  60. package/types/esm/components/content-variants/inlined-fns.d.ts +1 -1
  61. package/types/esm/constants/sdk-version.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as k } from "react/jsx-runtime";
3
- import { useRef as P, useState as f, useEffect as l } from "react";
3
+ import { useRef as P, useState as m, useEffect as c } from "react";
4
4
  import O from "../../../context/builder.context.mjs";
5
5
  import { evaluate as W } from "../../../functions/evaluate/evaluate.mjs";
6
6
  import { fastClone as j } from "../../../functions/fast-clone.mjs";
@@ -9,21 +9,23 @@ import { isBrowser as L } from "../../../functions/is-browser.mjs";
9
9
  import { isEditing as g } from "../../../functions/is-editing.mjs";
10
10
  import { isPreviewing as B } from "../../../functions/is-previewing.mjs";
11
11
  import { logFetch as F } from "../../../functions/log-fetch.mjs";
12
- import { createRegisterComponentMessage as z } from "../../../functions/register-component.mjs";
12
+ import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
13
13
  import { _track as H } from "../../../functions/track/index.mjs";
14
- import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
14
+ import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
15
15
  import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
16
- import { postPreviewContent as G } from "../../../helpers/preview-lru-cache/set.mjs";
17
- import { createEditorListener as J } from "../../../helpers/subscribe-to-editor.mjs";
18
- import { registerInsertMenu as Q, setupBrowserForEditing as X } from "../../../scripts/init-editing.mjs";
19
- import { triggerAnimation as Y } from "../../block/animator.mjs";
16
+ import { getCookieSync as G } from "../../../helpers/cookie.mjs";
17
+ import { postPreviewContent as J } from "../../../helpers/preview-lru-cache/set.mjs";
18
+ import { createEditorListener as Q } from "../../../helpers/subscribe-to-editor.mjs";
19
+ import { registerInsertMenu as X, setupBrowserForEditing as Y } from "../../../scripts/init-editing.mjs";
20
+ import { triggerAnimation as Z } from "../../block/animator.mjs";
20
21
  import { needsElementRefDivForEditing as q } from "./enable-editor.helpers.mjs";
21
- import { getWrapperClassName as Z } from "./styles.helpers.mjs";
22
- import { useRouter as p } from "next/navigation";
23
- function Re(e) {
22
+ import { getWrapperClassName as p } from "./styles.helpers.mjs";
23
+ import { useRouter as ee } from "next/navigation";
24
+ function ke(e) {
24
25
  var y, R, w;
25
- const c = P(null);
26
- function m(n) {
26
+ const u = P(null);
27
+ m(() => !1);
28
+ function s(n) {
27
29
  var i, r;
28
30
  const t = {
29
31
  ...e.builderContextSignal.rootState,
@@ -46,7 +48,7 @@ function Re(e) {
46
48
  breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((d = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : d.breakpoints)
47
49
  }
48
50
  };
49
- G({
51
+ J({
50
52
  value: t,
51
53
  key: t.id
52
54
  }).then(() => {
@@ -59,11 +61,11 @@ function Re(e) {
59
61
  "aria-hidden": !0
60
62
  };
61
63
  }
62
- const [U, ee] = f(
64
+ const [U, te] = m(
63
65
  () => e.contentWrapper || "div"
64
66
  );
65
67
  function v(n) {
66
- return J({
68
+ return Q({
67
69
  model: e.model,
68
70
  trustedHosts: e.trustedHosts,
69
71
  callbacks: {
@@ -77,19 +79,19 @@ function Re(e) {
77
79
  });
78
80
  },
79
81
  animation: (t) => {
80
- Y(t);
82
+ Z(t);
81
83
  },
82
84
  contentUpdate: (t) => {
83
85
  b(t);
84
86
  },
85
87
  stateUpdate: (t) => {
86
- m(t);
88
+ s(t);
87
89
  }
88
90
  }
89
91
  })(n);
90
92
  }
91
- const [h, te] = f(() => ({})), [S, ne] = f(() => ({})), [x, D] = f(() => !1);
92
- function N(n) {
93
+ const [h, ne] = m(() => ({})), [S, ie] = m(() => ({})), [x, D] = m(() => !1);
94
+ function V(n) {
93
95
  var t, i;
94
96
  if (e.builderContextSignal.content) {
95
97
  const r = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, a = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
@@ -100,13 +102,13 @@ function Re(e) {
100
102
  contentId: a,
101
103
  apiKey: e.apiKey,
102
104
  variationId: r !== a ? r : void 0,
103
- ...$(n),
105
+ ...z(n),
104
106
  unique: !x
105
107
  });
106
108
  }
107
109
  x || D(!0);
108
110
  }
109
- function V() {
111
+ function N() {
110
112
  var t, i, r;
111
113
  const n = (r = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? r : {};
112
114
  Object.entries(n).forEach(([a, o]) => {
@@ -115,7 +117,7 @@ function Re(e) {
115
117
  S[a] = !0;
116
118
  const d = o.replace(
117
119
  /{{([^}]+)}}/g,
118
- (u, M) => String(
120
+ (l, M) => String(
119
121
  W({
120
122
  code: M,
121
123
  context: e.context || {},
@@ -125,18 +127,18 @@ function Re(e) {
125
127
  })
126
128
  )
127
129
  );
128
- F(d), fetch(d).then((u) => u.json()).then((u) => {
129
- m({
130
- [a]: u
130
+ F(d), fetch(d).then((l) => l.json()).then((l) => {
131
+ s({
132
+ [a]: l
131
133
  }), h[a] = !0;
132
- }).catch((u) => {
133
- console.error("error fetching dynamic data", o, u);
134
+ }).catch((l) => {
135
+ console.error("error fetching dynamic data", o, l);
134
136
  }).finally(() => {
135
137
  S[a] = !1;
136
138
  });
137
139
  });
138
140
  }
139
- function s() {
141
+ function f() {
140
142
  g() && window.dispatchEvent(
141
143
  new CustomEvent(
142
144
  "builder:component:stateChange",
@@ -153,7 +155,7 @@ function Re(e) {
153
155
  }
154
156
  function C(n) {
155
157
  var t;
156
- window.addEventListener("message", v), Q(), X({
158
+ window.addEventListener("message", v), X(), Y({
157
159
  ...e.locale ? {
158
160
  locale: e.locale
159
161
  } : {},
@@ -170,12 +172,12 @@ function Re(e) {
170
172
  ).forEach((i) => {
171
173
  var r, a;
172
174
  if (!((r = i.models) != null && r.length) || i.models.includes(e.model)) {
173
- const o = z(i);
175
+ const o = $(i);
174
176
  (a = window.parent) == null || a.postMessage(o, "*");
175
177
  }
176
178
  }), window.addEventListener(
177
179
  "builder:component:stateChangeListenerActivated",
178
- s
180
+ f
179
181
  );
180
182
  }
181
183
  function E(n) {
@@ -196,69 +198,74 @@ function Re(e) {
196
198
  d && b(d);
197
199
  });
198
200
  }
199
- const _ = p(), I = P(!1);
200
- return I.current || (V(), s(), I.current = !0), l(() => {
201
+ const _ = ee(), I = P(!1);
202
+ return I.current || (N(), f(), I.current = !0), c(() => {
201
203
  var n;
202
- return (n = c.current) == null || n.addEventListener(
204
+ return (n = u.current) == null || n.addEventListener(
203
205
  "initeditingbldr",
204
206
  C
205
207
  ), () => {
206
208
  var t;
207
- return (t = c.current) == null ? void 0 : t.removeEventListener(
209
+ return (t = u.current) == null ? void 0 : t.removeEventListener(
208
210
  "initeditingbldr",
209
211
  C
210
212
  );
211
213
  };
212
- }, []), l(() => {
214
+ }, []), c(() => {
213
215
  var n;
214
- return (n = c.current) == null || n.addEventListener(
216
+ return (n = u.current) == null || n.addEventListener(
215
217
  "initpreviewingbldr",
216
218
  E
217
219
  ), () => {
218
220
  var t;
219
- return (t = c.current) == null ? void 0 : t.removeEventListener(
221
+ return (t = u.current) == null ? void 0 : t.removeEventListener(
220
222
  "initpreviewingbldr",
221
223
  E
222
224
  );
223
225
  };
224
- }, []), l(() => {
225
- var n, t;
226
+ }, []), c(() => {
227
+ var n, t, i;
226
228
  if (L()) {
227
- if (g() && !e.isNestedRender && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && K(e.canTrack)) {
228
- const r = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, a = (t = e.builderContextSignal.content) == null ? void 0 : t.id, o = e.apiKey;
229
+ g() && !e.isNestedRender && u.current && u.current.dispatchEvent(new CustomEvent("initeditingbldr"));
230
+ const r = e.builderContextSignal.content && K(e.canTrack), a = G({
231
+ name: `builder.tests.${(n = e.builderContextSignal.content) == null ? void 0 : n.id}`,
232
+ canTrack: !0
233
+ }), o = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId;
234
+ if (r && o === a) {
235
+ const d = (i = e.builderContextSignal.content) == null ? void 0 : i.id, l = e.apiKey;
229
236
  H({
230
237
  apiHost: e.apiHost,
231
238
  type: "impression",
232
239
  canTrack: !0,
233
- contentId: a,
234
- apiKey: o,
235
- variationId: r !== a ? r : void 0
240
+ contentId: d,
241
+ apiKey: l,
242
+ variationId: a !== d ? a : void 0
236
243
  });
237
244
  }
238
245
  B() && g();
239
246
  }
240
- }, []), l(() => {
241
- }, [e.content]), l(() => {
242
- s();
243
- }, [e.builderContextSignal.rootState]), l(() => {
244
- e.data && m(e.data);
245
- }, [e.data]), l(() => {
246
- e.locale && m({
247
+ }, []), c(() => {
248
+ }, [e.content]), c(() => {
249
+ f();
250
+ }, [e.builderContextSignal.rootState]), c(() => {
251
+ e.data && s(e.data);
252
+ }, [e.data]), c(() => {
253
+ e.locale && s({
247
254
  locale: e.locale
248
255
  });
249
- }, [e.locale]), l(() => () => {
256
+ }, [e.locale]), c(() => () => {
250
257
  L() && (window.removeEventListener("message", v), window.removeEventListener(
251
258
  "builder:component:stateChangeListenerActivated",
252
- s
259
+ f
253
260
  ));
254
261
  }, []), /* @__PURE__ */ k(O.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content || q() ? /* @__PURE__ */ k(
255
262
  U,
256
263
  {
257
- ref: c,
258
- onClick: (n) => N(n),
264
+ ref: u,
265
+ onClick: (n) => V(n),
259
266
  "builder-content-id": (y = e.builderContextSignal.content) == null ? void 0 : y.id,
260
267
  "builder-model": e.model,
261
- className: Z(
268
+ className: p(
262
269
  ((R = e.content) == null ? void 0 : R.testVariationId) || ((w = e.content) == null ? void 0 : w.id)
263
270
  ),
264
271
  style: {
@@ -271,5 +278,5 @@ function Re(e) {
271
278
  ) : null });
272
279
  }
273
280
  export {
274
- Re as default
281
+ ke as default
275
282
  };
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../constants/target.cjs"),S=require("../../functions/is-browser.cjs"),r=require("./inlined-fns.cjs"),e="builderIoAbTest",s="builderIoRenderContent",a=i=>Object.values((i==null?void 0:i.variations)||{}).map(t=>({...t,testVariationId:t.id,id:i==null?void 0:i.id})),d=({canTrack:i,content:t})=>!(!(a(t).length>0)||!i||S.isBrowser()),I=i=>i==="react"||i==="reactNative",n=I(o.TARGET),T=()=>`
2
- window.${e} = ${r.UPDATE_COOKIES_AND_STYLES_SCRIPT}
3
- window.${s} = ${r.UPDATE_VARIANT_VISIBILITY_SCRIPT}
4
- `,c=(i,t)=>`
5
- window.${e}(
6
- "${t}",${JSON.stringify(i)}, ${n}
7
- )`,g=({contentId:i,variationId:t})=>`window.${s}(
8
- "${t}", "${i}", ${n}
9
- )`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=T;exports.getUpdateCookieAndStylesScript=c;exports.getUpdateVariantVisibilityScript=g;exports.getVariants=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/target.cjs"),S=require("../../functions/is-browser.cjs"),r=require("./inlined-fns.cjs"),s="builderIoAbTest",a="builderIoRenderContent",n=i=>Object.values((i==null?void 0:i.variations)||{}).map(t=>({...t,testVariationId:t.id,id:i==null?void 0:i.id})),d=({canTrack:i,content:t})=>!(!(n(t).length>0)||!i||S.isBrowser()),I=i=>i==="react"||i==="reactNative",T=e.TARGET==="angular",o=I(e.TARGET),c=()=>`
2
+ window.${s} = ${r.UPDATE_COOKIES_AND_STYLES_SCRIPT}
3
+ window.${a} = ${r.UPDATE_VARIANT_VISIBILITY_SCRIPT}
4
+ `,g=(i,t)=>`
5
+ window.${s}(
6
+ "${t}",${JSON.stringify(i)}, ${o}, ${T}
7
+ )`,l=({contentId:i,variationId:t})=>`window.${a}(
8
+ "${t}", "${i}", ${o}
9
+ )`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=c;exports.getUpdateCookieAndStylesScript=g;exports.getUpdateVariantVisibilityScript=l;exports.getVariants=n;
@@ -1,29 +1,29 @@
1
- import { TARGET as e } from "../../constants/target.mjs";
1
+ import { TARGET as t } from "../../constants/target.mjs";
2
2
  import { isBrowser as o } from "../../functions/is-browser.mjs";
3
- import { UPDATE_COOKIES_AND_STYLES_SCRIPT as I, UPDATE_VARIANT_VISIBILITY_SCRIPT as n } from "./inlined-fns.mjs";
4
- const t = "builderIoAbTest", s = "builderIoRenderContent", S = (i) => Object.values((i == null ? void 0 : i.variations) || {}).map((r) => ({
3
+ import { UPDATE_COOKIES_AND_STYLES_SCRIPT as n, UPDATE_VARIANT_VISIBILITY_SCRIPT as I } from "./inlined-fns.mjs";
4
+ const s = "builderIoAbTest", a = "builderIoRenderContent", S = (i) => Object.values((i == null ? void 0 : i.variations) || {}).map((r) => ({
5
5
  ...r,
6
6
  testVariationId: r.id,
7
7
  id: i == null ? void 0 : i.id
8
- })), $ = ({
8
+ })), V = ({
9
9
  canTrack: i,
10
10
  content: r
11
- }) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative", a = T(e), E = () => `
12
- window.${t} = ${I}
11
+ }) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative", d = t === "angular", e = T(t), g = () => `
13
12
  window.${s} = ${n}
14
- `, f = (i, r) => `
15
- window.${t}(
16
- "${r}",${JSON.stringify(i)}, ${a}
17
- )`, l = ({
13
+ window.${a} = ${I}
14
+ `, u = (i, r) => `
15
+ window.${s}(
16
+ "${r}",${JSON.stringify(i)}, ${e}, ${d}
17
+ )`, E = ({
18
18
  contentId: i,
19
19
  variationId: r
20
- }) => `window.${s}(
21
- "${r}", "${i}", ${a}
20
+ }) => `window.${a}(
21
+ "${r}", "${i}", ${e}
22
22
  )`;
23
23
  export {
24
- $ as checkShouldRenderVariants,
25
- E as getInitVariantsFnsScriptString,
26
- f as getUpdateCookieAndStylesScript,
27
- l as getUpdateVariantVisibilityScript,
24
+ V as checkShouldRenderVariants,
25
+ g as getInitVariantsFnsScriptString,
26
+ u as getUpdateCookieAndStylesScript,
27
+ E as getUpdateVariantVisibilityScript,
28
28
  S as getVariants
29
29
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
2
2
  function getAndSetVariantId() {
3
3
  function setCookie(name, value, days) {
4
4
  let expires = '';
@@ -40,7 +40,10 @@
40
40
  return contentId;
41
41
  }
42
42
  const winningVariantId = getAndSetVariantId();
43
- const styleEl = document.currentScript?.previousElementSibling;
43
+ let styleEl = document.currentScript?.previousElementSibling;
44
+ if (isAngularSDK) {
45
+ styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
46
+ }
44
47
  if (isHydrationTarget) {
45
48
  styleEl.remove();
46
49
  const thisScriptEl = document.currentScript;
@@ -1,4 +1,4 @@
1
- const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
1
+ const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
2
2
  function getAndSetVariantId() {
3
3
  function setCookie(name, value, days) {
4
4
  let expires = '';
@@ -40,7 +40,10 @@ const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarge
40
40
  return contentId;
41
41
  }
42
42
  const winningVariantId = getAndSetVariantId();
43
- const styleEl = document.currentScript?.previousElementSibling;
43
+ let styleEl = document.currentScript?.previousElementSibling;
44
+ if (isAngularSDK) {
45
+ styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
46
+ }
44
47
  if (isHydrationTarget) {
45
48
  styleEl.remove();
46
49
  const thisScriptEl = document.currentScript;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.1";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.8";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.18.1";
1
+ const o = "0.18.8";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use client";"use strict";const p=require("react/jsx-runtime"),n=require("react");function l(r){const s=n.useRef(null),[i,d]=n.useState(()=>[]),[u,m]=n.useState(()=>[]);return n.useEffect(()=>{var a;if(!((a=s.current)!=null&&a.getElementsByTagName)||typeof window=="undefined")return;const o=s.current.getElementsByTagName("script");for(let c=0;c<o.length;c++){const e=o[c];if(e.src){if(i.includes(e.src))continue;i.push(e.src);const t=document.createElement("script");t.async=!0,t.src=e.src,document.head.appendChild(t)}else if(!e.type||["text/javascript","application/javascript","application/ecmascript"].includes(e.type)){if(u.includes(e.innerText))continue;try{u.push(e.innerText),new Function(e.innerText)()}catch(t){console.warn("`CustomCode`: Error running script:",t)}}}},[]),p.jsx("div",{ref:s,className:"builder-custom-code"+(r.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:r.code}})}module.exports=l;
1
+ "use client";"use strict";const l=require("react/jsx-runtime"),n=require("react"),p=require("../../functions/is-editing.cjs"),f=require("../../helpers/logger.cjs");function m(s){const r=n.useRef(null),[i,g]=n.useState(()=>[]),[u,E]=n.useState(()=>[]);function o(){var d;if(!r.current||!((d=r.current)!=null&&d.getElementsByTagName)||typeof window=="undefined")return;const a=r.current.getElementsByTagName("script");for(let c=0;c<a.length;c++){const e=a[c];if(e.src){if(i.includes(e.src))continue;i.push(e.src);const t=document.createElement("script");t.async=!0,t.src=e.src,document.head.appendChild(t)}else if(!e.type||["text/javascript","application/javascript","application/ecmascript"].includes(e.type)){if(u.includes(e.innerText))continue;try{u.push(e.innerText),new Function(e.innerText)()}catch(t){f.logger.warn("[BUILDER.IO] `CustomCode`: Error running script:",t)}}}}return n.useEffect(()=>{o()},[]),n.useEffect(()=>{p.isEditing()&&o()},[s.code]),l.jsx("div",{ref:r,className:"builder-custom-code"+(s.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:s.code}})}module.exports=m;
@@ -1,19 +1,21 @@
1
1
  "use client";
2
- import { jsx as p } from "react/jsx-runtime";
3
- import { useRef as l, useState as a, useEffect as d } from "react";
4
- function h(s) {
5
- const n = l(null), [c, m] = a(() => []), [i, f] = a(() => []);
6
- return d(() => {
7
- var u;
8
- if (!((u = n.current) != null && u.getElementsByTagName) || typeof window == "undefined")
2
+ import { jsx as l } from "react/jsx-runtime";
3
+ import { useRef as m, useState as a, useEffect as d } from "react";
4
+ import { isEditing as f } from "../../functions/is-editing.mjs";
5
+ import { logger as g } from "../../helpers/logger.mjs";
6
+ function w(r) {
7
+ const n = m(null), [s, y] = a(() => []), [i, h] = a(() => []);
8
+ function o() {
9
+ var p;
10
+ if (!n.current || !((p = n.current) != null && p.getElementsByTagName) || typeof window == "undefined")
9
11
  return;
10
- const o = n.current.getElementsByTagName("script");
11
- for (let r = 0; r < o.length; r++) {
12
- const e = o[r];
12
+ const u = n.current.getElementsByTagName("script");
13
+ for (let c = 0; c < u.length; c++) {
14
+ const e = u[c];
13
15
  if (e.src) {
14
- if (c.includes(e.src))
16
+ if (s.includes(e.src))
15
17
  continue;
16
- c.push(e.src);
18
+ s.push(e.src);
17
19
  const t = document.createElement("script");
18
20
  t.async = !0, t.src = e.src, document.head.appendChild(t);
19
21
  } else if (!e.type || [
@@ -26,19 +28,27 @@ function h(s) {
26
28
  try {
27
29
  i.push(e.innerText), new Function(e.innerText)();
28
30
  } catch (t) {
29
- console.warn("`CustomCode`: Error running script:", t);
31
+ g.warn(
32
+ "[BUILDER.IO] `CustomCode`: Error running script:",
33
+ t
34
+ );
30
35
  }
31
36
  }
32
37
  }
33
- }, []), /* @__PURE__ */ p(
38
+ }
39
+ return d(() => {
40
+ o();
41
+ }, []), d(() => {
42
+ f() && o();
43
+ }, [r.code]), /* @__PURE__ */ l(
34
44
  "div",
35
45
  {
36
46
  ref: n,
37
- className: "builder-custom-code" + (s.replaceNodes ? " replace-nodes" : ""),
38
- dangerouslySetInnerHTML: { __html: s.code }
47
+ className: "builder-custom-code" + (r.replaceNodes ? " replace-nodes" : ""),
48
+ dangerouslySetInnerHTML: { __html: r.code }
39
49
  }
40
50
  );
41
51
  }
42
52
  export {
43
- h as default
53
+ w as default
44
54
  };
@@ -1 +1 @@
1
- "use client";"use strict";const d=require("react/jsx-runtime"),r=require("react"),m=require("./helpers.cjs");function f(a){const t=r.useRef(null),[c,S]=r.useState(()=>[]),[i,h]=r.useState(()=>[]),[u,l]=r.useState(()=>!1);function p(){if(!t.current||!t.current.getElementsByTagName)return;const o=t.current.getElementsByTagName("script");for(let s=0;s<o.length;s++){const e=o[s];if(e.src&&!c.includes(e.src)){c.push(e.src);const n=document.createElement("script");n.async=!0,n.src=e.src,document.head.appendChild(n)}else if(m.isJsScript(e)&&!i.includes(e.innerText))try{i.push(e.innerText),new Function(e.innerText)()}catch(n){console.warn("`Embed`: Error running script:",n)}}}return r.useEffect(()=>{t.current&&!u&&(l(!0),p())},[t.current,u]),d.jsx("div",{className:"builder-embed",ref:t,dangerouslySetInnerHTML:{__html:a.content}})}module.exports=f;
1
+ "use client";"use strict";const d=require("react/jsx-runtime"),r=require("react"),m=require("../../helpers/logger.cjs"),f=require("./helpers.cjs");function g(l){const t=r.useRef(null),[c,S]=r.useState(()=>[]),[i,h]=r.useState(()=>[]),[u,a]=r.useState(()=>!1);function p(){if(!t.current||!t.current.getElementsByTagName)return;const o=t.current.getElementsByTagName("script");for(let s=0;s<o.length;s++){const e=o[s];if(e.src&&!c.includes(e.src)){c.push(e.src);const n=document.createElement("script");n.async=!0,n.src=e.src,document.head.appendChild(n)}else if(f.isJsScript(e)&&!i.includes(e.innerText))try{i.push(e.innerText),new Function(e.innerText)()}catch(n){m.logger.warn("[BUILDER.IO] `Embed`: Error running script:",n)}}}return r.useEffect(()=>{t.current&&!u&&(a(!0),p())},[t.current,u]),d.jsx("div",{className:"builder-embed",ref:t,dangerouslySetInnerHTML:{__html:l.content}})}module.exports=g;
@@ -1,35 +1,36 @@
1
1
  "use client";
2
- import { jsx as m } from "react/jsx-runtime";
2
+ import { jsx as a } from "react/jsx-runtime";
3
3
  import { useRef as d, useState as s, useEffect as f } from "react";
4
- import { isJsScript as g } from "./helpers.mjs";
5
- function y(l) {
6
- const t = d(null), [c, h] = s(() => []), [i, E] = s(() => []), [u, p] = s(() => !1);
7
- function a() {
4
+ import { logger as g } from "../../helpers/logger.mjs";
5
+ import { isJsScript as E } from "./helpers.mjs";
6
+ function y(m) {
7
+ const t = d(null), [c, h] = s(() => []), [i, I] = s(() => []), [u, p] = s(() => !1);
8
+ function l() {
8
9
  if (!t.current || !t.current.getElementsByTagName)
9
10
  return;
10
11
  const o = t.current.getElementsByTagName("script");
11
- for (let r = 0; r < o.length; r++) {
12
- const e = o[r];
12
+ for (let n = 0; n < o.length; n++) {
13
+ const e = o[n];
13
14
  if (e.src && !c.includes(e.src)) {
14
15
  c.push(e.src);
15
- const n = document.createElement("script");
16
- n.async = !0, n.src = e.src, document.head.appendChild(n);
17
- } else if (g(e) && !i.includes(e.innerText))
16
+ const r = document.createElement("script");
17
+ r.async = !0, r.src = e.src, document.head.appendChild(r);
18
+ } else if (E(e) && !i.includes(e.innerText))
18
19
  try {
19
20
  i.push(e.innerText), new Function(e.innerText)();
20
- } catch (n) {
21
- console.warn("`Embed`: Error running script:", n);
21
+ } catch (r) {
22
+ g.warn("[BUILDER.IO] `Embed`: Error running script:", r);
22
23
  }
23
24
  }
24
25
  }
25
26
  return f(() => {
26
- t.current && !u && (p(!0), a());
27
- }, [t.current, u]), /* @__PURE__ */ m(
27
+ t.current && !u && (p(!0), l());
28
+ }, [t.current, u]), /* @__PURE__ */ a(
28
29
  "div",
29
30
  {
30
31
  className: "builder-embed",
31
32
  ref: t,
32
- dangerouslySetInnerHTML: { __html: l.content }
33
+ dangerouslySetInnerHTML: { __html: m.content }
33
34
  }
34
35
  );
35
36
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants/file-types.cjs"),p={name:"Image",static:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",defaultStyles:{position:"relative",minHeight:"20px",minWidth:"20px",overflow:"hidden"},canHaveChildren:!0,inputs:[{name:"image",type:"file",bubble:!0,allowedFileTypes:m.IMAGE_FILE_TYPES,required:!0,defaultValue:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",onChange:t=>{t.delete("srcset"),t.delete("noWebp");function s(e,o=6e4){return new Promise((u,n)=>{const i=document.createElement("img");let l=!1;i.onload=()=>{l=!0,u(i)},i.addEventListener("error",d=>{console.warn("Image load failed",d.error),n(d.error)}),i.src=e,setTimeout(()=>{l||n(new Error("Image load timed out"))},o)})}function h(e){return Math.round(e*1e3)/1e3}const a=t.get("image"),r=t.get("aspectRatio");if(fetch(a).then(e=>e.blob()).then(e=>{e.type.includes("svg")&&t.set("noWebp",!0)}),a&&(!r||r===.7041))return s(a).then(e=>{const o=t.get("aspectRatio");t.get("image")===a&&(!o||o===.7041)&&e.width&&e.height&&(t.set("aspectRatio",h(e.height/e.width)),t.set("height",e.height),t.set("width",e.width))})}},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"height",type:"number",hideFromUI:!0},{name:"width",type:"number",hideFromUI:!0},{name:"sizes",type:"string",hideFromUI:!0},{name:"srcset",type:"string",hideFromUI:!0},{name:"lazy",type:"boolean",defaultValue:!0,hideFromUI:!0},{name:"fitContent",type:"boolean",helperText:"When child blocks are provided, fit to them instead of using the image's aspect ratio",defaultValue:!0},{name:"highPriority",type:"boolean",advanced:!0,helperText:"Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page."},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],shouldReceiveBuilderProps:{builderBlock:!0}};exports.componentInfo=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../constants/file-types.cjs"),m={name:"Image",static:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",defaultStyles:{position:"relative",minHeight:"20px",minWidth:"20px",overflow:"hidden"},canHaveChildren:!0,inputs:[{name:"image",type:"file",bubble:!0,allowedFileTypes:p.IMAGE_FILE_TYPES,required:!0,defaultValue:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",onChange:t=>{t.delete("srcset"),t.delete("noWebp");function d(e,o=6e4){return new Promise((u,n)=>{const i=document.createElement("img");let l=!1;i.onload=()=>{l=!0,u(i)},i.addEventListener("error",s=>{console.warn("Image load failed",s.error),n(s.error)}),i.src=e,setTimeout(()=>{l||n(new Error("Image load timed out"))},o)})}function h(e){return Math.round(e*1e3)/1e3}const a=t.get("image"),r=t.get("aspectRatio");if(fetch(a).then(e=>e.blob()).then(e=>{e.type.includes("svg")&&t.set("noWebp",!0)}),a&&(!r||r===.7041))return d(a).then(e=>{const o=t.get("aspectRatio");t.get("image")===a&&(!o||o===.7041)&&e.width&&e.height&&(t.set("aspectRatio",h(e.height/e.width)),t.set("height",e.height),t.set("width",e.width))})}},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"title",type:"string",helperText:"Text to display when hovering over the asset"},{name:"height",type:"number",hideFromUI:!0},{name:"width",type:"number",hideFromUI:!0},{name:"sizes",type:"string",hideFromUI:!0},{name:"srcset",type:"string",hideFromUI:!0},{name:"lazy",type:"boolean",defaultValue:!0,hideFromUI:!0},{name:"fitContent",type:"boolean",helperText:"When child blocks are provided, fit to them instead of using the image's aspect ratio",defaultValue:!0},{name:"highPriority",type:"boolean",advanced:!0,helperText:"Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page."},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],shouldReceiveBuilderProps:{builderBlock:!0}};exports.componentInfo=m;
@@ -1,5 +1,5 @@
1
- import { IMAGE_FILE_TYPES as m } from "../../constants/file-types.mjs";
2
- const g = {
1
+ import { IMAGE_FILE_TYPES as p } from "../../constants/file-types.mjs";
2
+ const c = {
3
3
  name: "Image",
4
4
  static: !0,
5
5
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
@@ -14,19 +14,19 @@ const g = {
14
14
  name: "image",
15
15
  type: "file",
16
16
  bubble: !0,
17
- allowedFileTypes: m,
17
+ allowedFileTypes: p,
18
18
  required: !0,
19
19
  defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
20
20
  onChange: (t) => {
21
21
  t.delete("srcset"), t.delete("noWebp");
22
- function h(e, o = 6e4) {
22
+ function d(e, o = 6e4) {
23
23
  return new Promise((u, n) => {
24
24
  const i = document.createElement("img");
25
25
  let l = !1;
26
26
  i.onload = () => {
27
27
  l = !0, u(i);
28
- }, i.addEventListener("error", (d) => {
29
- console.warn("Image load failed", d.error), n(d.error);
28
+ }, i.addEventListener("error", (h) => {
29
+ console.warn("Image load failed", h.error), n(h.error);
30
30
  }), i.src = e, setTimeout(() => {
31
31
  l || n(new Error("Image load timed out"));
32
32
  }, o);
@@ -39,7 +39,7 @@ const g = {
39
39
  if (fetch(a).then((e) => e.blob()).then((e) => {
40
40
  e.type.includes("svg") && t.set("noWebp", !0);
41
41
  }), a && (!r || r === 0.7041))
42
- return h(a).then((e) => {
42
+ return d(a).then((e) => {
43
43
  const o = t.get("aspectRatio");
44
44
  t.get("image") === a && (!o || o === 0.7041) && e.width && e.height && (t.set("aspectRatio", s(e.height / e.width)), t.set("height", e.height), t.set("width", e.width));
45
45
  });
@@ -66,6 +66,10 @@ const g = {
66
66
  name: "altText",
67
67
  type: "string",
68
68
  helperText: "Text to display when the user has images off"
69
+ }, {
70
+ name: "title",
71
+ type: "string",
72
+ helperText: "Text to display when hovering over the asset"
69
73
  }, {
70
74
  name: "height",
71
75
  type: "number",
@@ -109,5 +113,5 @@ const g = {
109
113
  }
110
114
  };
111
115
  export {
112
- g as componentInfo
116
+ c as componentInfo
113
117
  };
@@ -1,11 +1,11 @@
1
- "use client";"use strict";const t=require("react/jsx-runtime"),a=require("./image.helpers.cjs");function b(e){var s,r,u,o,d,g;function n(){var h;const i=e.image||e.src;if(!i||!(typeof i=="string"&&(i.match(/builder\.io/)||i.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((h=e.image)!=null&&h.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),a.getSrcSet(i)}else if(e.image&&!e.srcset)return a.getSrcSet(i);return a.getSrcSet(i)}}function l(){var c;return(c=n==null?void 0:n())!=null&&c.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function m(){const c={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?c:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[l()?t.jsx("source",{type:"image/webp",srcSet:l()}):null,t.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...m()},className:"builder-image"+(e.className?" "+e.className:"")+" img-606b99a4",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(s=e.builderBlock)==null?void 0:s.children)!=null&&r.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-606b99a4",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(o=(u=e.builderBlock)==null?void 0:u.children)!=null&&o.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((g=(d=e.builderBlock)==null?void 0:d.children)!=null&&g.length)?t.jsx("div",{className:"div-606b99a4-2",children:e.children}):null]}),t.jsx("style",{children:`.img-606b99a4 {
1
+ "use client";"use strict";const t=require("react/jsx-runtime"),l=require("./image.helpers.cjs");function f(e){var s,r,u,d,o,g;function n(){var h;const i=e.image||e.src;if(!i||!(typeof i=="string"&&(i.match(/builder\.io/)||i.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((h=e.image)!=null&&h.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),l.getSrcSet(i)}else if(e.image&&!e.srcset)return l.getSrcSet(i);return l.getSrcSet(i)}}function a(){var c;return(c=n==null?void 0:n())!=null&&c.match(/builder\.io/)&&!e.noWebp?n().replace(/\?/g,"?format=webp&"):""}function m(){const c={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?c:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[a()?t.jsx("source",{type:"image/webp",srcSet:a()}):null,t.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,title:e.title,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...m()},className:"builder-image"+(e.className?" "+e.className:"")+" img-0525a549",src:e.image,srcSet:n(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(s=e.builderBlock)==null?void 0:s.children)!=null&&r.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-0525a549",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(d=(u=e.builderBlock)==null?void 0:u.children)!=null&&d.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((g=(o=e.builderBlock)==null?void 0:o.children)!=null&&g.length)?t.jsx("div",{className:"div-0525a549-2",children:e.children}):null]}),t.jsx("style",{children:`.img-0525a549 {
2
2
  opacity: 1;
3
3
  transition: opacity 0.2s ease-in-out;
4
- }.div-606b99a4 {
4
+ }.div-0525a549 {
5
5
  width: 100%;
6
6
  pointer-events: none;
7
7
  font-size: 0;
8
- }.div-606b99a4-2 {
8
+ }.div-0525a549-2 {
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  align-items: stretch;
@@ -14,4 +14,4 @@
14
14
  left: 0;
15
15
  width: 100%;
16
16
  height: 100%;
17
- }`})]})}module.exports=b;
17
+ }`})]})}module.exports=f;