@builder.io/sdk-react-nextjs 0.18.1 → 0.18.2
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/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +65 -58
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +65 -58
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +65 -58
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const k=require("react/jsx-runtime"),o=require("react"),B=require("../../../context/builder.context.cjs"),F=require("../../../functions/evaluate/evaluate.cjs"),N=require("../../../functions/fast-clone.cjs"),M=require("../../../functions/get-content/index.cjs"),w=require("../../../functions/is-browser.cjs"),f=require("../../../functions/is-editing.cjs"),O=require("../../../functions/is-previewing.cjs"),W=require("../../../functions/log-fetch.cjs"),A=require("../../../functions/register-component.cjs"),y=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),P=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/cookie.cjs"),G=require("../../../helpers/preview-lru-cache/set.cjs"),J=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),Q=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),X=require("./styles.helpers.cjs"),Y=require("next/navigation");function Z(e){var q,I,R;const s=o.useRef(null);o.useState(()=>!1);function u(n){var i,r;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(r=(i=e.builderContextSignal).rootSetState)==null||r.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,r,a,c,d;const t={...e.builderContextSignal.content,...n,data:{...(i=e.builderContextSignal.content)==null?void 0:i.data,...n==null?void 0:n.data},meta:{...(r=e.builderContextSignal.content)==null?void 0:r.meta,...n==null?void 0:n.meta,breakpoints:((a=n==null?void 0:n.meta)==null?void 0:a.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};G.postPreviewContent({value:t,key:t.id}).then(()=>{V.refresh()})}function K(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[T,p]=o.useState(()=>e.contentWrapper||"div");function S(n){return J.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var a;const{breakpoints:i,contentId:r}=t;!r||r!==((a=e.builderContextSignal.content)==null?void 0:a.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{Q.triggerAnimation(t)},contentUpdate:t=>{m(t)},stateUpdate:t=>{u(t)}}})(n)}const[v,ee]=o.useState(()=>({})),[b,te]=o.useState(()=>({})),[h,D]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const r=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,a=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:a,apiKey:e.apiKey,variationId:r!==a?r:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||D(!0)}function U(){var t,i,r;const n=(r=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?r:{};Object.entries(n).forEach(([a,c])=>{if(!c||b[a]||v[a]&&!f.isEditing())return;b[a]=!0;const d=c.replace(/{{([^}]+)}}/g,(l,j)=>String(F.evaluate({code:j,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(l=>l.json()).then(l=>{u({[a]:l}),v[a]=!0}).catch(l=>{console.error("error fetching dynamic data",c,l)}).finally(()=>{b[a]=!1})})}function g(){f.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:N.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){var t;window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{},modelName:(t=e.model)!=null?t:"",apiKey:e.apiKey}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var r,a;if(!((r=i.models)!=null&&r.length)||i.models.includes(e.model)){const c=A.createRegisterComponentMessage(i);(a=window.parent)==null||a.postMessage(c,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",g)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),r=t.get(`builder.overrides.${i}`),a=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&a===e.apiKey&&(!e.content||r===e.content.id))&&M.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...i==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(d=>{d&&m(d)})}const V=Y.useRouter(),C=o.useRef(!1);return C.current||(U(),g(),C.current=!0),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t,i;if(w.isBrowser()){f.isEditing()&&!e.isNestedRender&&s.current&&s.current.dispatchEvent(new CustomEvent("initeditingbldr"));const r=e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack),a=z.getCookieSync({name:`builder.tests.${(n=e.builderContextSignal.content)==null?void 0:n.id}`,canTrack:!0}),c=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId;if(r&&c===a){const d=(i=e.builderContextSignal.content)==null?void 0:i.id,l=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:d,apiKey:l,variationId:a!==d?a:void 0})}O.isPreviewing()&&f.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{g()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&u(e.data)},[e.data]),o.useEffect(()=>{e.locale&&u({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{w.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",g))},[]),k.jsx(B.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?k.jsx(T,{ref:s,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:X.getWrapperClassName(((I=e.content)==null?void 0:I.testVariationId)||((R=e.content)==null?void 0:R.id)),style:{display:!e.builderContextSignal.content&&H.needsElementRefDivForEditing()?"none":void 0},...K(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Z;
|
|
@@ -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
|
|
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
|
|
12
|
+
import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
|
|
13
13
|
import { _track as H } from "../../../functions/track/index.mjs";
|
|
14
|
-
import { getInteractionPropertiesForEvent as
|
|
14
|
+
import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
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
|
|
22
|
-
import { useRouter as
|
|
23
|
-
function
|
|
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
|
|
26
|
-
|
|
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
|
-
|
|
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,
|
|
64
|
+
const [U, te] = m(
|
|
63
65
|
() => e.contentWrapper || "div"
|
|
64
66
|
);
|
|
65
67
|
function v(n) {
|
|
66
|
-
return
|
|
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
|
-
|
|
82
|
+
Z(t);
|
|
81
83
|
},
|
|
82
84
|
contentUpdate: (t) => {
|
|
83
85
|
b(t);
|
|
84
86
|
},
|
|
85
87
|
stateUpdate: (t) => {
|
|
86
|
-
|
|
88
|
+
s(t);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
})(n);
|
|
90
92
|
}
|
|
91
|
-
const [h,
|
|
92
|
-
function
|
|
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
|
-
|
|
105
|
+
...z(n),
|
|
104
106
|
unique: !x
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
109
|
x || D(!0);
|
|
108
110
|
}
|
|
109
|
-
function
|
|
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
|
-
(
|
|
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((
|
|
129
|
-
|
|
130
|
-
[a]:
|
|
130
|
+
F(d), fetch(d).then((l) => l.json()).then((l) => {
|
|
131
|
+
s({
|
|
132
|
+
[a]: l
|
|
131
133
|
}), h[a] = !0;
|
|
132
|
-
}).catch((
|
|
133
|
-
console.error("error fetching dynamic data", o,
|
|
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
|
|
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),
|
|
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 =
|
|
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
|
-
|
|
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 _ =
|
|
200
|
-
return I.current || (
|
|
201
|
+
const _ = ee(), I = P(!1);
|
|
202
|
+
return I.current || (N(), f(), I.current = !0), c(() => {
|
|
201
203
|
var n;
|
|
202
|
-
return (n =
|
|
204
|
+
return (n = u.current) == null || n.addEventListener(
|
|
203
205
|
"initeditingbldr",
|
|
204
206
|
C
|
|
205
207
|
), () => {
|
|
206
208
|
var t;
|
|
207
|
-
return (t =
|
|
209
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
208
210
|
"initeditingbldr",
|
|
209
211
|
C
|
|
210
212
|
);
|
|
211
213
|
};
|
|
212
|
-
}, []),
|
|
214
|
+
}, []), c(() => {
|
|
213
215
|
var n;
|
|
214
|
-
return (n =
|
|
216
|
+
return (n = u.current) == null || n.addEventListener(
|
|
215
217
|
"initpreviewingbldr",
|
|
216
218
|
E
|
|
217
219
|
), () => {
|
|
218
220
|
var t;
|
|
219
|
-
return (t =
|
|
221
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
220
222
|
"initpreviewingbldr",
|
|
221
223
|
E
|
|
222
224
|
);
|
|
223
225
|
};
|
|
224
|
-
}, []),
|
|
225
|
-
var n, t;
|
|
226
|
+
}, []), c(() => {
|
|
227
|
+
var n, t, i;
|
|
226
228
|
if (L()) {
|
|
227
|
-
|
|
228
|
-
|
|
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:
|
|
234
|
-
apiKey:
|
|
235
|
-
variationId:
|
|
240
|
+
contentId: d,
|
|
241
|
+
apiKey: l,
|
|
242
|
+
variationId: a !== d ? a : void 0
|
|
236
243
|
});
|
|
237
244
|
}
|
|
238
245
|
B() && g();
|
|
239
246
|
}
|
|
240
|
-
}, []),
|
|
241
|
-
}, [e.content]),
|
|
242
|
-
|
|
243
|
-
}, [e.builderContextSignal.rootState]),
|
|
244
|
-
e.data &&
|
|
245
|
-
}, [e.data]),
|
|
246
|
-
e.locale &&
|
|
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]),
|
|
256
|
+
}, [e.locale]), c(() => () => {
|
|
250
257
|
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
251
258
|
"builder:component:stateChangeListenerActivated",
|
|
252
|
-
|
|
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:
|
|
258
|
-
onClick: (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:
|
|
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
|
-
|
|
281
|
+
ke as default
|
|
275
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.2";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const k=require("react/jsx-runtime"),o=require("react"),B=require("../../../context/builder.context.cjs"),F=require("../../../functions/evaluate/evaluate.cjs"),N=require("../../../functions/fast-clone.cjs"),M=require("../../../functions/get-content/index.cjs"),w=require("../../../functions/is-browser.cjs"),f=require("../../../functions/is-editing.cjs"),O=require("../../../functions/is-previewing.cjs"),W=require("../../../functions/log-fetch.cjs"),A=require("../../../functions/register-component.cjs"),y=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),P=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/cookie.cjs"),G=require("../../../helpers/preview-lru-cache/set.cjs"),J=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),Q=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),X=require("./styles.helpers.cjs"),Y=require("next/navigation");function Z(e){var q,I,R;const s=o.useRef(null);o.useState(()=>!1);function u(n){var i,r;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(r=(i=e.builderContextSignal).rootSetState)==null||r.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,r,a,c,d;const t={...e.builderContextSignal.content,...n,data:{...(i=e.builderContextSignal.content)==null?void 0:i.data,...n==null?void 0:n.data},meta:{...(r=e.builderContextSignal.content)==null?void 0:r.meta,...n==null?void 0:n.meta,breakpoints:((a=n==null?void 0:n.meta)==null?void 0:a.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};G.postPreviewContent({value:t,key:t.id}).then(()=>{V.refresh()})}function K(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[T,p]=o.useState(()=>e.contentWrapper||"div");function S(n){return J.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var a;const{breakpoints:i,contentId:r}=t;!r||r!==((a=e.builderContextSignal.content)==null?void 0:a.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{Q.triggerAnimation(t)},contentUpdate:t=>{m(t)},stateUpdate:t=>{u(t)}}})(n)}const[v,ee]=o.useState(()=>({})),[b,te]=o.useState(()=>({})),[h,D]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const r=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,a=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:a,apiKey:e.apiKey,variationId:r!==a?r:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||D(!0)}function U(){var t,i,r;const n=(r=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?r:{};Object.entries(n).forEach(([a,c])=>{if(!c||b[a]||v[a]&&!f.isEditing())return;b[a]=!0;const d=c.replace(/{{([^}]+)}}/g,(l,j)=>String(F.evaluate({code:j,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(l=>l.json()).then(l=>{u({[a]:l}),v[a]=!0}).catch(l=>{console.error("error fetching dynamic data",c,l)}).finally(()=>{b[a]=!1})})}function g(){f.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:N.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){var t;window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{},modelName:(t=e.model)!=null?t:"",apiKey:e.apiKey}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var r,a;if(!((r=i.models)!=null&&r.length)||i.models.includes(e.model)){const c=A.createRegisterComponentMessage(i);(a=window.parent)==null||a.postMessage(c,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",g)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),r=t.get(`builder.overrides.${i}`),a=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&a===e.apiKey&&(!e.content||r===e.content.id))&&M.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...i==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(d=>{d&&m(d)})}const V=Y.useRouter(),C=o.useRef(!1);return C.current||(U(),g(),C.current=!0),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t,i;if(w.isBrowser()){f.isEditing()&&!e.isNestedRender&&s.current&&s.current.dispatchEvent(new CustomEvent("initeditingbldr"));const r=e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack),a=z.getCookieSync({name:`builder.tests.${(n=e.builderContextSignal.content)==null?void 0:n.id}`,canTrack:!0}),c=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId;if(r&&c===a){const d=(i=e.builderContextSignal.content)==null?void 0:i.id,l=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:d,apiKey:l,variationId:a!==d?a:void 0})}O.isPreviewing()&&f.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{g()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&u(e.data)},[e.data]),o.useEffect(()=>{e.locale&&u({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{w.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",g))},[]),k.jsx(B.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?k.jsx(T,{ref:s,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:X.getWrapperClassName(((I=e.content)==null?void 0:I.testVariationId)||((R=e.content)==null?void 0:R.id)),style:{display:!e.builderContextSignal.content&&H.needsElementRefDivForEditing()?"none":void 0},...K(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Z;
|
|
@@ -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
|
|
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
|
|
12
|
+
import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
|
|
13
13
|
import { _track as H } from "../../../functions/track/index.mjs";
|
|
14
|
-
import { getInteractionPropertiesForEvent as
|
|
14
|
+
import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
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
|
|
22
|
-
import { useRouter as
|
|
23
|
-
function
|
|
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
|
|
26
|
-
|
|
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
|
-
|
|
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,
|
|
64
|
+
const [U, te] = m(
|
|
63
65
|
() => e.contentWrapper || "div"
|
|
64
66
|
);
|
|
65
67
|
function v(n) {
|
|
66
|
-
return
|
|
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
|
-
|
|
82
|
+
Z(t);
|
|
81
83
|
},
|
|
82
84
|
contentUpdate: (t) => {
|
|
83
85
|
b(t);
|
|
84
86
|
},
|
|
85
87
|
stateUpdate: (t) => {
|
|
86
|
-
|
|
88
|
+
s(t);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
})(n);
|
|
90
92
|
}
|
|
91
|
-
const [h,
|
|
92
|
-
function
|
|
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
|
-
|
|
105
|
+
...z(n),
|
|
104
106
|
unique: !x
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
109
|
x || D(!0);
|
|
108
110
|
}
|
|
109
|
-
function
|
|
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
|
-
(
|
|
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((
|
|
129
|
-
|
|
130
|
-
[a]:
|
|
130
|
+
F(d), fetch(d).then((l) => l.json()).then((l) => {
|
|
131
|
+
s({
|
|
132
|
+
[a]: l
|
|
131
133
|
}), h[a] = !0;
|
|
132
|
-
}).catch((
|
|
133
|
-
console.error("error fetching dynamic data", o,
|
|
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
|
|
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),
|
|
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 =
|
|
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
|
-
|
|
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 _ =
|
|
200
|
-
return I.current || (
|
|
201
|
+
const _ = ee(), I = P(!1);
|
|
202
|
+
return I.current || (N(), f(), I.current = !0), c(() => {
|
|
201
203
|
var n;
|
|
202
|
-
return (n =
|
|
204
|
+
return (n = u.current) == null || n.addEventListener(
|
|
203
205
|
"initeditingbldr",
|
|
204
206
|
C
|
|
205
207
|
), () => {
|
|
206
208
|
var t;
|
|
207
|
-
return (t =
|
|
209
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
208
210
|
"initeditingbldr",
|
|
209
211
|
C
|
|
210
212
|
);
|
|
211
213
|
};
|
|
212
|
-
}, []),
|
|
214
|
+
}, []), c(() => {
|
|
213
215
|
var n;
|
|
214
|
-
return (n =
|
|
216
|
+
return (n = u.current) == null || n.addEventListener(
|
|
215
217
|
"initpreviewingbldr",
|
|
216
218
|
E
|
|
217
219
|
), () => {
|
|
218
220
|
var t;
|
|
219
|
-
return (t =
|
|
221
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
220
222
|
"initpreviewingbldr",
|
|
221
223
|
E
|
|
222
224
|
);
|
|
223
225
|
};
|
|
224
|
-
}, []),
|
|
225
|
-
var n, t;
|
|
226
|
+
}, []), c(() => {
|
|
227
|
+
var n, t, i;
|
|
226
228
|
if (L()) {
|
|
227
|
-
|
|
228
|
-
|
|
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:
|
|
234
|
-
apiKey:
|
|
235
|
-
variationId:
|
|
240
|
+
contentId: d,
|
|
241
|
+
apiKey: l,
|
|
242
|
+
variationId: a !== d ? a : void 0
|
|
236
243
|
});
|
|
237
244
|
}
|
|
238
245
|
B() && g();
|
|
239
246
|
}
|
|
240
|
-
}, []),
|
|
241
|
-
}, [e.content]),
|
|
242
|
-
|
|
243
|
-
}, [e.builderContextSignal.rootState]),
|
|
244
|
-
e.data &&
|
|
245
|
-
}, [e.data]),
|
|
246
|
-
e.locale &&
|
|
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]),
|
|
256
|
+
}, [e.locale]), c(() => () => {
|
|
250
257
|
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
251
258
|
"builder:component:stateChangeListenerActivated",
|
|
252
|
-
|
|
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:
|
|
258
|
-
onClick: (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:
|
|
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
|
-
|
|
281
|
+
ke as default
|
|
275
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.2";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const k=require("react/jsx-runtime"),o=require("react"),B=require("../../../context/builder.context.cjs"),F=require("../../../functions/evaluate/evaluate.cjs"),N=require("../../../functions/fast-clone.cjs"),M=require("../../../functions/get-content/index.cjs"),w=require("../../../functions/is-browser.cjs"),f=require("../../../functions/is-editing.cjs"),O=require("../../../functions/is-previewing.cjs"),W=require("../../../functions/log-fetch.cjs"),A=require("../../../functions/register-component.cjs"),y=require("../../../functions/track/index.cjs"),$=require("../../../functions/track/interaction.cjs"),P=require("../../../helpers/canTrack.cjs"),z=require("../../../helpers/cookie.cjs"),G=require("../../../helpers/preview-lru-cache/set.cjs"),J=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),Q=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),X=require("./styles.helpers.cjs"),Y=require("next/navigation");function Z(e){var q,I,R;const s=o.useRef(null);o.useState(()=>!1);function u(n){var i,r;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(r=(i=e.builderContextSignal).rootSetState)==null||r.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,r,a,c,d;const t={...e.builderContextSignal.content,...n,data:{...(i=e.builderContextSignal.content)==null?void 0:i.data,...n==null?void 0:n.data},meta:{...(r=e.builderContextSignal.content)==null?void 0:r.meta,...n==null?void 0:n.meta,breakpoints:((a=n==null?void 0:n.meta)==null?void 0:a.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};G.postPreviewContent({value:t,key:t.id}).then(()=>{V.refresh()})}function K(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[T,p]=o.useState(()=>e.contentWrapper||"div");function S(n){return J.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var a;const{breakpoints:i,contentId:r}=t;!r||r!==((a=e.builderContextSignal.content)==null?void 0:a.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{Q.triggerAnimation(t)},contentUpdate:t=>{m(t)},stateUpdate:t=>{u(t)}}})(n)}const[v,ee]=o.useState(()=>({})),[b,te]=o.useState(()=>({})),[h,D]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const r=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,a=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:a,apiKey:e.apiKey,variationId:r!==a?r:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||D(!0)}function U(){var t,i,r;const n=(r=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?r:{};Object.entries(n).forEach(([a,c])=>{if(!c||b[a]||v[a]&&!f.isEditing())return;b[a]=!0;const d=c.replace(/{{([^}]+)}}/g,(l,j)=>String(F.evaluate({code:j,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(l=>l.json()).then(l=>{u({[a]:l}),v[a]=!0}).catch(l=>{console.error("error fetching dynamic data",c,l)}).finally(()=>{b[a]=!1})})}function g(){f.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:N.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){var t;window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{},modelName:(t=e.model)!=null?t:"",apiKey:e.apiKey}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var r,a;if(!((r=i.models)!=null&&r.length)||i.models.includes(e.model)){const c=A.createRegisterComponentMessage(i);(a=window.parent)==null||a.postMessage(c,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",g)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),r=t.get(`builder.overrides.${i}`),a=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&a===e.apiKey&&(!e.content||r===e.content.id))&&M.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...i==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(d=>{d&&m(d)})}const V=Y.useRouter(),C=o.useRef(!1);return C.current||(U(),g(),C.current=!0),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=s.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=s.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t,i;if(w.isBrowser()){f.isEditing()&&!e.isNestedRender&&s.current&&s.current.dispatchEvent(new CustomEvent("initeditingbldr"));const r=e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack),a=z.getCookieSync({name:`builder.tests.${(n=e.builderContextSignal.content)==null?void 0:n.id}`,canTrack:!0}),c=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId;if(r&&c===a){const d=(i=e.builderContextSignal.content)==null?void 0:i.id,l=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:d,apiKey:l,variationId:a!==d?a:void 0})}O.isPreviewing()&&f.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{g()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&u(e.data)},[e.data]),o.useEffect(()=>{e.locale&&u({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{w.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",g))},[]),k.jsx(B.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?k.jsx(T,{ref:s,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:X.getWrapperClassName(((I=e.content)==null?void 0:I.testVariationId)||((R=e.content)==null?void 0:R.id)),style:{display:!e.builderContextSignal.content&&H.needsElementRefDivForEditing()?"none":void 0},...K(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Z;
|
|
@@ -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
|
|
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
|
|
12
|
+
import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
|
|
13
13
|
import { _track as H } from "../../../functions/track/index.mjs";
|
|
14
|
-
import { getInteractionPropertiesForEvent as
|
|
14
|
+
import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
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
|
|
22
|
-
import { useRouter as
|
|
23
|
-
function
|
|
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
|
|
26
|
-
|
|
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
|
-
|
|
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,
|
|
64
|
+
const [U, te] = m(
|
|
63
65
|
() => e.contentWrapper || "div"
|
|
64
66
|
);
|
|
65
67
|
function v(n) {
|
|
66
|
-
return
|
|
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
|
-
|
|
82
|
+
Z(t);
|
|
81
83
|
},
|
|
82
84
|
contentUpdate: (t) => {
|
|
83
85
|
b(t);
|
|
84
86
|
},
|
|
85
87
|
stateUpdate: (t) => {
|
|
86
|
-
|
|
88
|
+
s(t);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
})(n);
|
|
90
92
|
}
|
|
91
|
-
const [h,
|
|
92
|
-
function
|
|
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
|
-
|
|
105
|
+
...z(n),
|
|
104
106
|
unique: !x
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
109
|
x || D(!0);
|
|
108
110
|
}
|
|
109
|
-
function
|
|
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
|
-
(
|
|
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((
|
|
129
|
-
|
|
130
|
-
[a]:
|
|
130
|
+
F(d), fetch(d).then((l) => l.json()).then((l) => {
|
|
131
|
+
s({
|
|
132
|
+
[a]: l
|
|
131
133
|
}), h[a] = !0;
|
|
132
|
-
}).catch((
|
|
133
|
-
console.error("error fetching dynamic data", o,
|
|
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
|
|
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),
|
|
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 =
|
|
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
|
-
|
|
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 _ =
|
|
200
|
-
return I.current || (
|
|
201
|
+
const _ = ee(), I = P(!1);
|
|
202
|
+
return I.current || (N(), f(), I.current = !0), c(() => {
|
|
201
203
|
var n;
|
|
202
|
-
return (n =
|
|
204
|
+
return (n = u.current) == null || n.addEventListener(
|
|
203
205
|
"initeditingbldr",
|
|
204
206
|
C
|
|
205
207
|
), () => {
|
|
206
208
|
var t;
|
|
207
|
-
return (t =
|
|
209
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
208
210
|
"initeditingbldr",
|
|
209
211
|
C
|
|
210
212
|
);
|
|
211
213
|
};
|
|
212
|
-
}, []),
|
|
214
|
+
}, []), c(() => {
|
|
213
215
|
var n;
|
|
214
|
-
return (n =
|
|
216
|
+
return (n = u.current) == null || n.addEventListener(
|
|
215
217
|
"initpreviewingbldr",
|
|
216
218
|
E
|
|
217
219
|
), () => {
|
|
218
220
|
var t;
|
|
219
|
-
return (t =
|
|
221
|
+
return (t = u.current) == null ? void 0 : t.removeEventListener(
|
|
220
222
|
"initpreviewingbldr",
|
|
221
223
|
E
|
|
222
224
|
);
|
|
223
225
|
};
|
|
224
|
-
}, []),
|
|
225
|
-
var n, t;
|
|
226
|
+
}, []), c(() => {
|
|
227
|
+
var n, t, i;
|
|
226
228
|
if (L()) {
|
|
227
|
-
|
|
228
|
-
|
|
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:
|
|
234
|
-
apiKey:
|
|
235
|
-
variationId:
|
|
240
|
+
contentId: d,
|
|
241
|
+
apiKey: l,
|
|
242
|
+
variationId: a !== d ? a : void 0
|
|
236
243
|
});
|
|
237
244
|
}
|
|
238
245
|
B() && g();
|
|
239
246
|
}
|
|
240
|
-
}, []),
|
|
241
|
-
}, [e.content]),
|
|
242
|
-
|
|
243
|
-
}, [e.builderContextSignal.rootState]),
|
|
244
|
-
e.data &&
|
|
245
|
-
}, [e.data]),
|
|
246
|
-
e.locale &&
|
|
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]),
|
|
256
|
+
}, [e.locale]), c(() => () => {
|
|
250
257
|
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
251
258
|
"builder:component:stateChangeListenerActivated",
|
|
252
|
-
|
|
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:
|
|
258
|
-
onClick: (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:
|
|
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
|
-
|
|
281
|
+
ke as default
|
|
275
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.2";exports.SDK_VERSION=e;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-nextjs",
|
|
3
3
|
"description": "Builder.io RSC SDK for NextJS App Directory",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.2",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
1
|
+
export declare const SDK_VERSION = "0.18.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.18.
|
|
1
|
+
export declare const SDK_VERSION = "0.18.2";
|