@builder.io/sdk-react-nextjs 0.17.1 → 0.17.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/blocks/text/text.cjs +1 -1
- package/lib/browser/blocks/text/text.mjs +6 -24
- package/lib/browser/components/block/block.cjs +1 -1
- package/lib/browser/components/block/block.mjs +27 -28
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +102 -96
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-block-component-options.cjs +1 -1
- package/lib/browser/functions/get-block-component-options.mjs +21 -5
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/browser/functions/get-processed-block.cjs +1 -1
- package/lib/browser/functions/get-processed-block.mjs +18 -19
- package/lib/browser/helpers/flatten.cjs +1 -1
- package/lib/browser/helpers/flatten.mjs +28 -15
- package/lib/edge/blocks/text/text.cjs +1 -1
- package/lib/edge/blocks/text/text.mjs +6 -24
- package/lib/edge/components/block/block.cjs +1 -1
- package/lib/edge/components/block/block.mjs +27 -28
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +102 -96
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +5 -5
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +25 -28
- package/lib/edge/functions/get-block-component-options.cjs +1 -1
- package/lib/edge/functions/get-block-component-options.mjs +21 -5
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/edge/functions/get-processed-block.cjs +1 -1
- package/lib/edge/functions/get-processed-block.mjs +18 -19
- package/lib/edge/helpers/flatten.cjs +1 -1
- package/lib/edge/helpers/flatten.mjs +28 -15
- package/lib/node/blocks/text/text.cjs +1 -1
- package/lib/node/blocks/text/text.mjs +6 -24
- package/lib/node/components/block/block.cjs +1 -1
- package/lib/node/components/block/block.mjs +27 -28
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +102 -96
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-block-component-options.cjs +1 -1
- package/lib/node/functions/get-block-component-options.mjs +21 -5
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +60 -40
- package/lib/node/functions/get-processed-block.cjs +1 -1
- package/lib/node/functions/get-processed-block.mjs +18 -19
- package/lib/node/helpers/flatten.cjs +1 -1
- package/lib/node/helpers/flatten.mjs +28 -15
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/get-block-component-options.d.ts +2 -1
- package/types/cjs/functions/get-processed-block.d.ts +1 -6
- package/types/cjs/helpers/flatten.d.ts +6 -0
- package/types/cjs/server-index.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/get-block-component-options.d.ts +2 -1
- package/types/esm/functions/get-processed-block.d.ts +1 -6
- package/types/esm/helpers/flatten.d.ts +6 -0
- package/types/esm/server-index.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime");function r(e){var t;return n.jsx("div",{className:"builder-text",dangerouslySetInnerHTML:{__html:((t=e.text)==null?void 0:t.toString())||""},style:{outline:"none"}})}module.exports=r;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
function o(e) {
|
|
3
|
+
var t;
|
|
4
|
+
return /* @__PURE__ */ n(
|
|
5
5
|
"div",
|
|
6
6
|
{
|
|
7
7
|
className: "builder-text",
|
|
8
|
-
dangerouslySetInnerHTML: { __html:
|
|
9
|
-
var e;
|
|
10
|
-
const o = t.builderContext, {
|
|
11
|
-
context: n,
|
|
12
|
-
localState: r,
|
|
13
|
-
rootState: c,
|
|
14
|
-
rootSetState: s
|
|
15
|
-
} = o;
|
|
16
|
-
return String(((e = t.text) == null ? void 0 : e.toString()) || "").replace(
|
|
17
|
-
/{{([^}]+)}}/g,
|
|
18
|
-
(d, x) => l({
|
|
19
|
-
code: x,
|
|
20
|
-
context: n,
|
|
21
|
-
localState: r,
|
|
22
|
-
rootState: c,
|
|
23
|
-
rootSetState: s
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
}() },
|
|
8
|
+
dangerouslySetInnerHTML: { __html: ((t = e.text) == null ? void 0 : t.toString()) || "" },
|
|
27
9
|
style: {
|
|
28
10
|
outline: "none"
|
|
29
11
|
}
|
|
@@ -31,5 +13,5 @@ function f(t) {
|
|
|
31
13
|
);
|
|
32
14
|
}
|
|
33
15
|
export {
|
|
34
|
-
|
|
16
|
+
o as default
|
|
35
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),v=require("../../constants/target.cjs"),S=require("../../functions/get-block-component-options.cjs"),j=require("../../functions/get-processed-block.cjs"),P=require("../../functions/is-previewing.cjs");require("../../functions/get-fetch.cjs");const m=require("./block.helpers.cjs"),q=require("./components/block-styles.cjs"),O=require("./components/block-wrapper.cjs"),p=require("./components/component-ref/component-ref.cjs"),g=require("./components/repeated-block.cjs");function b(e){var a,C,x,h;const d=function(){return m.getRepeatItemData({block:e.block,context:e.context})},u={value:null,update:!1},c=function(){var i;if(u.value&&!u.update&&!P.isPreviewing())return u.value;const r=(i=e.block.repeat)!=null&&i.collection?e.block:j.getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context});return u.value=r,u.update=!1,r},l=function(){return m.getComponent({block:c(),registeredComponents:e.registeredComponents,model:e.context.model})},f=function(){var i;return e.block.tagName==="a"||((i=c().properties)==null?void 0:i.href)||c().href?e.linkComponent||"a":e.block.tagName||"div"},B=function(){var s,k;if((s=e.block.repeat)!=null&&s.collection)return!!((k=d())!=null&&k.length);const r="hide"in c()?c().hide:!1;return("show"in c()?c().show:!0)&&!r},R=function(){var i,s;return!((i=l())!=null&&i.component)&&!d()?(s=c().children)!=null?s:[]:[]},n=function(){var r,i,s,k;return{blockChildren:(r=c().children)!=null?r:[],componentRef:(i=l())==null?void 0:i.component,componentOptions:{...S.getBlockComponentOptions(c(),e.context),...m.provideBuilderBlock(l(),c()),...m.provideBuilderContext(l(),e.context),...m.provideLinkComponent(l(),e.linkComponent),...m.provideRegisteredComponents(l(),e.registeredComponents,e.context.model)},context:e.context,linkComponent:e.linkComponent,registeredComponents:e.registeredComponents,builderBlock:c(),includeBlockProps:((s=l())==null?void 0:s.noWrap)===!0,isInteractive:!((k=l())!=null&&k.isRSC&&v.TARGET==="rsc")}};return t.jsx(t.Fragment,{children:B()?t.jsxs(t.Fragment,{children:[t.jsx(q,{block:c(),context:e.context}),(a=l())!=null&&a.noWrap?d()?t.jsx(t.Fragment,{children:(h=d())==null?void 0:h.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}):t.jsx(t.Fragment,{children:d()?t.jsx(t.Fragment,{children:(x=d())==null?void 0:x.map((o,r)=>t.jsx(g,{repeatContext:o.context,block:o.block,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},r))}):t.jsxs(O,{Wrapper:f(),block:c(),context:e.context,children:[t.jsx(p,{componentRef:n().componentRef,componentOptions:n().componentOptions,blockChildren:n().blockChildren,context:n().context,registeredComponents:n().registeredComponents,linkComponent:n().linkComponent,builderBlock:n().builderBlock,includeBlockProps:n().includeBlockProps,isInteractive:n().isInteractive}),(C=R())==null?void 0:C.map(o=>t.jsx(b,{block:o,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent,context:e.context},o.id))]})})]}):null})}module.exports=b;
|
|
@@ -6,10 +6,10 @@ import { isPreviewing as I } from "../../functions/is-previewing.mjs";
|
|
|
6
6
|
import "../../functions/get-fetch.mjs";
|
|
7
7
|
import { getRepeatItemData as O, getComponent as w, provideBuilderBlock as W, provideBuilderContext as T, provideLinkComponent as L, provideRegisteredComponents as U } from "./block.helpers.mjs";
|
|
8
8
|
import j from "./components/block-styles.mjs";
|
|
9
|
-
import
|
|
9
|
+
import N from "./components/block-wrapper.mjs";
|
|
10
10
|
import x from "./components/component-ref/component-ref.mjs";
|
|
11
11
|
import b from "./components/repeated-block.mjs";
|
|
12
|
-
function
|
|
12
|
+
function y(e) {
|
|
13
13
|
var a, C, p, f;
|
|
14
14
|
const d = function() {
|
|
15
15
|
return O({
|
|
@@ -19,7 +19,7 @@ function N(e) {
|
|
|
19
19
|
}, s = {
|
|
20
20
|
value: null,
|
|
21
21
|
update: !1
|
|
22
|
-
},
|
|
22
|
+
}, n = function() {
|
|
23
23
|
var i;
|
|
24
24
|
if (s.value && !s.update && !I())
|
|
25
25
|
return s.value;
|
|
@@ -28,36 +28,35 @@ function N(e) {
|
|
|
28
28
|
localState: e.context.localState,
|
|
29
29
|
rootState: e.context.rootState,
|
|
30
30
|
rootSetState: e.context.rootSetState,
|
|
31
|
-
context: e.context.context
|
|
32
|
-
shouldEvaluateBindings: !0
|
|
31
|
+
context: e.context.context
|
|
33
32
|
});
|
|
34
33
|
return s.value = c, s.update = !1, c;
|
|
35
34
|
}, r = function() {
|
|
36
35
|
return w({
|
|
37
|
-
block:
|
|
36
|
+
block: n(),
|
|
38
37
|
registeredComponents: e.registeredComponents,
|
|
39
38
|
model: e.context.model
|
|
40
39
|
});
|
|
41
40
|
}, g = function() {
|
|
42
41
|
var i;
|
|
43
|
-
return e.block.tagName === "a" || ((i =
|
|
42
|
+
return e.block.tagName === "a" || ((i = n().properties) == null ? void 0 : i.href) || n().href ? e.linkComponent || "a" : e.block.tagName || "div";
|
|
44
43
|
}, B = function() {
|
|
45
44
|
var m, k;
|
|
46
45
|
if ((m = e.block.repeat) != null && m.collection)
|
|
47
46
|
return !!((k = d()) != null && k.length);
|
|
48
|
-
const c = "hide" in
|
|
49
|
-
return ("show" in
|
|
47
|
+
const c = "hide" in n() ? n().hide : !1;
|
|
48
|
+
return ("show" in n() ? n().show : !0) && !c;
|
|
50
49
|
}, R = function() {
|
|
51
50
|
var i, m;
|
|
52
|
-
return !((i = r()) != null && i.component) && !d() ? (m =
|
|
51
|
+
return !((i = r()) != null && i.component) && !d() ? (m = n().children) != null ? m : [] : [];
|
|
53
52
|
}, o = function() {
|
|
54
53
|
var c, i, m, k;
|
|
55
54
|
return {
|
|
56
|
-
blockChildren: (c =
|
|
55
|
+
blockChildren: (c = n().children) != null ? c : [],
|
|
57
56
|
componentRef: (i = r()) == null ? void 0 : i.component,
|
|
58
57
|
componentOptions: {
|
|
59
|
-
...S(
|
|
60
|
-
...W(r(),
|
|
58
|
+
...S(n(), e.context),
|
|
59
|
+
...W(r(), n()),
|
|
61
60
|
...T(r(), e.context),
|
|
62
61
|
...L(r(), e.linkComponent),
|
|
63
62
|
...U(
|
|
@@ -69,18 +68,18 @@ function N(e) {
|
|
|
69
68
|
context: e.context,
|
|
70
69
|
linkComponent: e.linkComponent,
|
|
71
70
|
registeredComponents: e.registeredComponents,
|
|
72
|
-
builderBlock:
|
|
71
|
+
builderBlock: n(),
|
|
73
72
|
includeBlockProps: ((m = r()) == null ? void 0 : m.noWrap) === !0,
|
|
74
73
|
isInteractive: !((k = r()) != null && k.isRSC && v === "rsc")
|
|
75
74
|
};
|
|
76
75
|
};
|
|
77
76
|
return /* @__PURE__ */ l(u, { children: B() ? /* @__PURE__ */ h(u, { children: [
|
|
78
|
-
/* @__PURE__ */ l(j, { block:
|
|
79
|
-
(a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((
|
|
77
|
+
/* @__PURE__ */ l(j, { block: n(), context: e.context }),
|
|
78
|
+
(a = r()) != null && a.noWrap ? d() ? /* @__PURE__ */ l(u, { children: (f = d()) == null ? void 0 : f.map((t, c) => /* @__PURE__ */ l(
|
|
80
79
|
b,
|
|
81
80
|
{
|
|
82
|
-
repeatContext:
|
|
83
|
-
block:
|
|
81
|
+
repeatContext: t.context,
|
|
82
|
+
block: t.block,
|
|
84
83
|
registeredComponents: e.registeredComponents,
|
|
85
84
|
linkComponent: e.linkComponent
|
|
86
85
|
},
|
|
@@ -98,20 +97,20 @@ function N(e) {
|
|
|
98
97
|
includeBlockProps: o().includeBlockProps,
|
|
99
98
|
isInteractive: o().isInteractive
|
|
100
99
|
}
|
|
101
|
-
) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((
|
|
100
|
+
) : /* @__PURE__ */ l(u, { children: d() ? /* @__PURE__ */ l(u, { children: (p = d()) == null ? void 0 : p.map((t, c) => /* @__PURE__ */ l(
|
|
102
101
|
b,
|
|
103
102
|
{
|
|
104
|
-
repeatContext:
|
|
105
|
-
block:
|
|
103
|
+
repeatContext: t.context,
|
|
104
|
+
block: t.block,
|
|
106
105
|
registeredComponents: e.registeredComponents,
|
|
107
106
|
linkComponent: e.linkComponent
|
|
108
107
|
},
|
|
109
108
|
c
|
|
110
109
|
)) }) : /* @__PURE__ */ h(
|
|
111
|
-
|
|
110
|
+
N,
|
|
112
111
|
{
|
|
113
112
|
Wrapper: g(),
|
|
114
|
-
block:
|
|
113
|
+
block: n(),
|
|
115
114
|
context: e.context,
|
|
116
115
|
children: [
|
|
117
116
|
/* @__PURE__ */ l(
|
|
@@ -128,15 +127,15 @@ function N(e) {
|
|
|
128
127
|
isInteractive: o().isInteractive
|
|
129
128
|
}
|
|
130
129
|
),
|
|
131
|
-
(C = R()) == null ? void 0 : C.map((
|
|
132
|
-
|
|
130
|
+
(C = R()) == null ? void 0 : C.map((t) => /* @__PURE__ */ l(
|
|
131
|
+
y,
|
|
133
132
|
{
|
|
134
|
-
block:
|
|
133
|
+
block: t,
|
|
135
134
|
registeredComponents: e.registeredComponents,
|
|
136
135
|
linkComponent: e.linkComponent,
|
|
137
136
|
context: e.context
|
|
138
137
|
},
|
|
139
|
-
|
|
138
|
+
t.id
|
|
140
139
|
))
|
|
141
140
|
]
|
|
142
141
|
}
|
|
@@ -144,5 +143,5 @@ function N(e) {
|
|
|
144
143
|
] }) : null });
|
|
145
144
|
}
|
|
146
145
|
export {
|
|
147
|
-
|
|
146
|
+
y as default
|
|
148
147
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const w=require("react/jsx-runtime"),o=require("react"),F=require("../../../context/builder.context.cjs"),V=require("../../../functions/evaluate/evaluate.cjs"),M=require("../../../functions/fast-clone.cjs"),N=require("../../../functions/get-content/index.cjs"),k=require("../../../functions/is-browser.cjs"),g=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/preview-lru-cache/set.cjs"),G=require("../../../helpers/subscribe-to-editor.cjs"),L=require("../../../scripts/init-editing.cjs"),J=require("../../block/animator.cjs"),H=require("./enable-editor.helpers.cjs"),Q=require("./styles.helpers.cjs"),X=require("next/navigation");function Y(e){var q,I,R;const l=o.useRef(null);function f(n){var i,a;const t={...e.builderContextSignal.rootState,...n};e.builderContextSignal.rootSetState?(a=(i=e.builderContextSignal).rootSetState)==null||a.call(i,t):e.builderContextSignal.rootState=t}function m(n){var i,a,r,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:{...(a=e.builderContextSignal.content)==null?void 0:a.meta,...n==null?void 0:n.meta,breakpoints:((r=n==null?void 0:n.meta)==null?void 0:r.breakpoints)||((d=(c=e.builderContextSignal.content)==null?void 0:c.meta)==null?void 0:d.breakpoints)}};z.postPreviewContent({value:t,key:t.id}).then(()=>{j.refresh()})}function T(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[D,Z]=o.useState(()=>e.contentWrapper||"div");function S(n){return G.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:t=>{var r;const{breakpoints:i,contentId:a}=t;!a||a!==((r=e.builderContextSignal.content)==null?void 0:r.id)||i&&m({meta:{breakpoints:i}})},animation:t=>{J.triggerAnimation(t)},contentUpdate:t=>{m(t)}}})(n)}const[v,p]=o.useState(()=>({})),[b,ee]=o.useState(()=>({})),[h,K]=o.useState(()=>!1);function _(n){var t,i;if(e.builderContextSignal.content){const a=(t=e.builderContextSignal.content)==null?void 0:t.testVariationId,r=(i=e.builderContextSignal.content)==null?void 0:i.id;y._track({apiHost:e.apiHost,type:"click",canTrack:P.getDefaultCanTrack(e.canTrack),contentId:r,apiKey:e.apiKey,variationId:a!==r?a:void 0,...$.getInteractionPropertiesForEvent(n),unique:!h})}h||K(!0)}function U(){var t,i,a;const n=(a=(i=(t=e.builderContextSignal.content)==null?void 0:t.data)==null?void 0:i.httpRequests)!=null?a:{};Object.entries(n).forEach(([r,c])=>{if(!c||b[r]||v[r]&&!g.isEditing())return;b[r]=!0;const d=c.replace(/{{([^}]+)}}/g,(s,B)=>String(V.evaluate({code:B,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));W.logFetch(d),fetch(d).then(s=>s.json()).then(s=>{f({[r]:s}),v[r]=!0}).catch(s=>{console.error("error fetching dynamic data",c,s)}).finally(()=>{b[r]=!1})})}function u(){g.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:M.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(n){window.addEventListener("message",S),L.registerInsertMenu(),L.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(t=>{var i,a;if(!e.model||!((i=t.models)!=null&&i.length)||t.models.includes(e.model)){const r=A.createRegisterComponentMessage(t);(a=window.parent)==null||a.postMessage(r,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",u)}function x(n){var c;const t=new URL(location.href).searchParams,i=t.get("builder.preview"),a=t.get(`builder.overrides.${i}`),r=t.get("apiKey")||t.get("builder.space");(i==="BUILDER_STUDIO"||i===e.model&&r===e.apiKey&&(!e.content||a===e.content.id))&&N.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 j=X.useRouter(),C=o.useRef(!1);return C.current||(U(),u(),C.current=!0),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initeditingbldr",E),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initeditingbldr",E)}},[]),o.useEffect(()=>{var n;return(n=l.current)==null||n.addEventListener("initpreviewingbldr",x),()=>{var t;return(t=l.current)==null?void 0:t.removeEventListener("initpreviewingbldr",x)}},[]),o.useEffect(()=>{var n,t;if(k.isBrowser()){if(g.isEditing()&&!e.isNestedRender&&l.current&&l.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&P.getDefaultCanTrack(e.canTrack)){const a=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,r=(t=e.builderContextSignal.content)==null?void 0:t.id,c=e.apiKey;y._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:r,apiKey:c,variationId:a!==r?a:void 0})}O.isPreviewing()&&g.isEditing()}},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{u()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&f(e.data)},[e.data]),o.useEffect(()=>{e.locale&&f({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{k.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",u))},[]),w.jsx(F.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||H.needsElementRefDivForEditing()?w.jsx(D,{ref:l,onClick:n=>_(n),"builder-content-id":(q=e.builderContextSignal.content)==null?void 0:q.id,"builder-model":e.model,className:Q.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},...T(),...e.contentWrapperProps,children:e.children}):null})}module.exports=Y;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import { evaluate as
|
|
6
|
-
import { fastClone as
|
|
7
|
-
import { fetchOneEntry as
|
|
8
|
-
import { isBrowser as
|
|
2
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as P, useState as s, useEffect as l } from "react";
|
|
4
|
+
import O from "../../../context/builder.context.mjs";
|
|
5
|
+
import { evaluate as W } from "../../../functions/evaluate/evaluate.mjs";
|
|
6
|
+
import { fastClone as j } from "../../../functions/fast-clone.mjs";
|
|
7
|
+
import { fetchOneEntry as A } from "../../../functions/get-content/index.mjs";
|
|
8
|
+
import { isBrowser as L } from "../../../functions/is-browser.mjs";
|
|
9
9
|
import { isEditing as f } from "../../../functions/is-editing.mjs";
|
|
10
|
-
import { isPreviewing as
|
|
11
|
-
import { logFetch as
|
|
10
|
+
import { isPreviewing as B } from "../../../functions/is-previewing.mjs";
|
|
11
|
+
import { logFetch as F } from "../../../functions/log-fetch.mjs";
|
|
12
12
|
import { createRegisterComponentMessage as z } from "../../../functions/register-component.mjs";
|
|
13
|
-
import { _track as
|
|
13
|
+
import { _track as H } from "../../../functions/track/index.mjs";
|
|
14
14
|
import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
|
|
15
15
|
import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
|
|
16
16
|
import { postPreviewContent as G } from "../../../helpers/preview-lru-cache/set.mjs";
|
|
@@ -20,37 +20,37 @@ import { triggerAnimation as Y } from "../../block/animator.mjs";
|
|
|
20
20
|
import { needsElementRefDivForEditing as q } from "./enable-editor.helpers.mjs";
|
|
21
21
|
import { getWrapperClassName as Z } from "./styles.helpers.mjs";
|
|
22
22
|
import { useRouter as p } from "next/navigation";
|
|
23
|
-
function
|
|
24
|
-
var
|
|
25
|
-
const
|
|
23
|
+
function we(e) {
|
|
24
|
+
var R, w, y;
|
|
25
|
+
const c = P(null);
|
|
26
26
|
function g(n) {
|
|
27
|
-
var
|
|
27
|
+
var i, a;
|
|
28
28
|
const t = {
|
|
29
29
|
...e.builderContextSignal.rootState,
|
|
30
30
|
...n
|
|
31
31
|
};
|
|
32
|
-
e.builderContextSignal.rootSetState ? (
|
|
32
|
+
e.builderContextSignal.rootSetState ? (a = (i = e.builderContextSignal).rootSetState) == null || a.call(i, t) : e.builderContextSignal.rootState = t;
|
|
33
33
|
}
|
|
34
34
|
function b(n) {
|
|
35
|
-
var
|
|
35
|
+
var i, a, r, o, d;
|
|
36
36
|
const t = {
|
|
37
37
|
...e.builderContextSignal.content,
|
|
38
38
|
...n,
|
|
39
39
|
data: {
|
|
40
|
-
...(
|
|
40
|
+
...(i = e.builderContextSignal.content) == null ? void 0 : i.data,
|
|
41
41
|
...n == null ? void 0 : n.data
|
|
42
42
|
},
|
|
43
43
|
meta: {
|
|
44
|
-
...(
|
|
44
|
+
...(a = e.builderContextSignal.content) == null ? void 0 : a.meta,
|
|
45
45
|
...n == null ? void 0 : n.meta,
|
|
46
|
-
breakpoints: ((
|
|
46
|
+
breakpoints: ((r = n == null ? void 0 : n.meta) == null ? void 0 : r.breakpoints) || ((d = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : d.breakpoints)
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
G({
|
|
50
50
|
value: t,
|
|
51
51
|
key: t.id
|
|
52
52
|
}).then(() => {
|
|
53
|
-
|
|
53
|
+
M.refresh();
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function T() {
|
|
@@ -59,20 +59,20 @@ function Re(e) {
|
|
|
59
59
|
"aria-hidden": !0
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
const [
|
|
62
|
+
const [D, ee] = s(
|
|
63
63
|
() => e.contentWrapper || "div"
|
|
64
64
|
);
|
|
65
|
-
function
|
|
65
|
+
function v(n) {
|
|
66
66
|
return J({
|
|
67
67
|
model: e.model,
|
|
68
68
|
trustedHosts: e.trustedHosts,
|
|
69
69
|
callbacks: {
|
|
70
70
|
configureSdk: (t) => {
|
|
71
|
-
var
|
|
72
|
-
const { breakpoints:
|
|
73
|
-
!
|
|
71
|
+
var r;
|
|
72
|
+
const { breakpoints: i, contentId: a } = t;
|
|
73
|
+
!a || a !== ((r = e.builderContextSignal.content) == null ? void 0 : r.id) || i && b({
|
|
74
74
|
meta: {
|
|
75
|
-
breakpoints:
|
|
75
|
+
breakpoints: i
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
},
|
|
@@ -85,36 +85,36 @@ function Re(e) {
|
|
|
85
85
|
}
|
|
86
86
|
})(n);
|
|
87
87
|
}
|
|
88
|
-
const [h, te] =
|
|
89
|
-
function
|
|
90
|
-
var t,
|
|
88
|
+
const [h, te] = s(() => ({})), [S, ne] = s(() => ({})), [x, U] = s(() => !1);
|
|
89
|
+
function V(n) {
|
|
90
|
+
var t, i;
|
|
91
91
|
if (e.builderContextSignal.content) {
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const a = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, r = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
|
|
93
|
+
H({
|
|
94
94
|
apiHost: e.apiHost,
|
|
95
95
|
type: "click",
|
|
96
96
|
canTrack: K(e.canTrack),
|
|
97
|
-
contentId:
|
|
97
|
+
contentId: r,
|
|
98
98
|
apiKey: e.apiKey,
|
|
99
|
-
variationId:
|
|
99
|
+
variationId: a !== r ? a : void 0,
|
|
100
100
|
...$(n),
|
|
101
101
|
unique: !x
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
x ||
|
|
104
|
+
x || U(!0);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
var t,
|
|
108
|
-
const n = (
|
|
109
|
-
Object.entries(n).forEach(([
|
|
110
|
-
if (!o ||
|
|
106
|
+
function _() {
|
|
107
|
+
var t, i, a;
|
|
108
|
+
const n = (a = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? a : {};
|
|
109
|
+
Object.entries(n).forEach(([r, o]) => {
|
|
110
|
+
if (!o || S[r] || h[r] && !f())
|
|
111
111
|
return;
|
|
112
|
-
|
|
113
|
-
const
|
|
112
|
+
S[r] = !0;
|
|
113
|
+
const d = o.replace(
|
|
114
114
|
/{{([^}]+)}}/g,
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
code:
|
|
115
|
+
(u, N) => String(
|
|
116
|
+
W({
|
|
117
|
+
code: N,
|
|
118
118
|
context: e.context || {},
|
|
119
119
|
localState: void 0,
|
|
120
120
|
rootState: e.builderContextSignal.rootState,
|
|
@@ -122,24 +122,24 @@ function Re(e) {
|
|
|
122
122
|
})
|
|
123
123
|
)
|
|
124
124
|
);
|
|
125
|
-
|
|
125
|
+
F(d), fetch(d).then((u) => u.json()).then((u) => {
|
|
126
126
|
g({
|
|
127
|
-
[
|
|
128
|
-
}), h[
|
|
129
|
-
}).catch((
|
|
130
|
-
console.error("error fetching dynamic data", o,
|
|
127
|
+
[r]: u
|
|
128
|
+
}), h[r] = !0;
|
|
129
|
+
}).catch((u) => {
|
|
130
|
+
console.error("error fetching dynamic data", o, u);
|
|
131
131
|
}).finally(() => {
|
|
132
|
-
|
|
132
|
+
S[r] = !1;
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function m() {
|
|
137
137
|
f() && window.dispatchEvent(
|
|
138
138
|
new CustomEvent(
|
|
139
139
|
"builder:component:stateChange",
|
|
140
140
|
{
|
|
141
141
|
detail: {
|
|
142
|
-
state:
|
|
142
|
+
state: j(e.builderContextSignal.rootState),
|
|
143
143
|
ref: {
|
|
144
144
|
name: e.model
|
|
145
145
|
}
|
|
@@ -149,7 +149,7 @@ function Re(e) {
|
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
function C(n) {
|
|
152
|
-
window.addEventListener("message",
|
|
152
|
+
window.addEventListener("message", v), Q(), X({
|
|
153
153
|
...e.locale ? {
|
|
154
154
|
locale: e.locale
|
|
155
155
|
} : {},
|
|
@@ -162,92 +162,98 @@ function Re(e) {
|
|
|
162
162
|
}), Object.values(
|
|
163
163
|
e.builderContextSignal.componentInfos
|
|
164
164
|
).forEach((t) => {
|
|
165
|
-
var
|
|
166
|
-
if (!e.model || !((
|
|
167
|
-
const
|
|
168
|
-
(
|
|
165
|
+
var i, a;
|
|
166
|
+
if (!e.model || !((i = t.models) != null && i.length) || t.models.includes(e.model)) {
|
|
167
|
+
const r = z(t);
|
|
168
|
+
(a = window.parent) == null || a.postMessage(r, "*");
|
|
169
169
|
}
|
|
170
170
|
}), window.addEventListener(
|
|
171
171
|
"builder:component:stateChangeListenerActivated",
|
|
172
|
-
|
|
172
|
+
m
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
function E(n) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
r
|
|
180
|
-
|
|
176
|
+
var o;
|
|
177
|
+
const t = new URL(location.href).searchParams, i = t.get("builder.preview"), a = t.get(
|
|
178
|
+
`builder.overrides.${i}`
|
|
179
|
+
), r = t.get("apiKey") || t.get("builder.space");
|
|
180
|
+
(i === "BUILDER_STUDIO" || i === e.model && r === e.apiKey && (!e.content || a === e.content.id)) && A({
|
|
181
|
+
model: e.model || "",
|
|
181
182
|
apiKey: e.apiKey,
|
|
182
|
-
apiVersion: e.builderContextSignal.apiVersion
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
apiVersion: e.builderContextSignal.apiVersion,
|
|
184
|
+
...i === "BUILDER_STUDIO" && ((o = e.context) != null && o.symbolId) ? {
|
|
185
|
+
query: {
|
|
186
|
+
id: e.context.symbolId
|
|
187
|
+
}
|
|
188
|
+
} : {}
|
|
189
|
+
}).then((d) => {
|
|
190
|
+
d && b(d);
|
|
185
191
|
});
|
|
186
192
|
}
|
|
187
|
-
const
|
|
188
|
-
return I.current || (
|
|
193
|
+
const M = p(), I = P(!1);
|
|
194
|
+
return I.current || (_(), m(), I.current = !0), l(() => {
|
|
189
195
|
var n;
|
|
190
|
-
return (n =
|
|
196
|
+
return (n = c.current) == null || n.addEventListener(
|
|
191
197
|
"initeditingbldr",
|
|
192
198
|
C
|
|
193
199
|
), () => {
|
|
194
200
|
var t;
|
|
195
|
-
return (t =
|
|
201
|
+
return (t = c.current) == null ? void 0 : t.removeEventListener(
|
|
196
202
|
"initeditingbldr",
|
|
197
203
|
C
|
|
198
204
|
);
|
|
199
205
|
};
|
|
200
|
-
}, []),
|
|
206
|
+
}, []), l(() => {
|
|
201
207
|
var n;
|
|
202
|
-
return (n =
|
|
208
|
+
return (n = c.current) == null || n.addEventListener(
|
|
203
209
|
"initpreviewingbldr",
|
|
204
210
|
E
|
|
205
211
|
), () => {
|
|
206
212
|
var t;
|
|
207
|
-
return (t =
|
|
213
|
+
return (t = c.current) == null ? void 0 : t.removeEventListener(
|
|
208
214
|
"initpreviewingbldr",
|
|
209
215
|
E
|
|
210
216
|
);
|
|
211
217
|
};
|
|
212
|
-
}, []),
|
|
218
|
+
}, []), l(() => {
|
|
213
219
|
var n, t;
|
|
214
|
-
if (
|
|
215
|
-
if (f() && !e.isNestedRender &&
|
|
216
|
-
const
|
|
217
|
-
|
|
220
|
+
if (L()) {
|
|
221
|
+
if (f() && !e.isNestedRender && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && K(e.canTrack)) {
|
|
222
|
+
const a = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, r = (t = e.builderContextSignal.content) == null ? void 0 : t.id, o = e.apiKey;
|
|
223
|
+
H({
|
|
218
224
|
apiHost: e.apiHost,
|
|
219
225
|
type: "impression",
|
|
220
226
|
canTrack: !0,
|
|
221
|
-
contentId:
|
|
227
|
+
contentId: r,
|
|
222
228
|
apiKey: o,
|
|
223
|
-
variationId:
|
|
229
|
+
variationId: a !== r ? a : void 0
|
|
224
230
|
});
|
|
225
231
|
}
|
|
226
|
-
|
|
232
|
+
B() && f();
|
|
227
233
|
}
|
|
228
|
-
}, []),
|
|
229
|
-
}, [e.content]),
|
|
230
|
-
|
|
231
|
-
}, [e.builderContextSignal.rootState]),
|
|
234
|
+
}, []), l(() => {
|
|
235
|
+
}, [e.content]), l(() => {
|
|
236
|
+
m();
|
|
237
|
+
}, [e.builderContextSignal.rootState]), l(() => {
|
|
232
238
|
e.data && g(e.data);
|
|
233
|
-
}, [e.data]),
|
|
239
|
+
}, [e.data]), l(() => {
|
|
234
240
|
e.locale && g({
|
|
235
241
|
locale: e.locale
|
|
236
242
|
});
|
|
237
|
-
}, [e.locale]),
|
|
238
|
-
|
|
243
|
+
}, [e.locale]), l(() => () => {
|
|
244
|
+
L() && (window.removeEventListener("message", v), window.removeEventListener(
|
|
239
245
|
"builder:component:stateChangeListenerActivated",
|
|
240
|
-
|
|
246
|
+
m
|
|
241
247
|
));
|
|
242
|
-
}, []), /* @__PURE__ */
|
|
243
|
-
|
|
248
|
+
}, []), /* @__PURE__ */ k(O.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content || q() ? /* @__PURE__ */ k(
|
|
249
|
+
D,
|
|
244
250
|
{
|
|
245
|
-
ref:
|
|
246
|
-
onClick: (n) =>
|
|
247
|
-
"builder-content-id": (
|
|
251
|
+
ref: c,
|
|
252
|
+
onClick: (n) => V(n),
|
|
253
|
+
"builder-content-id": (R = e.builderContextSignal.content) == null ? void 0 : R.id,
|
|
248
254
|
"builder-model": e.model,
|
|
249
255
|
className: Z(
|
|
250
|
-
((
|
|
256
|
+
((w = e.content) == null ? void 0 : w.testVariationId) || ((y = e.content) == null ? void 0 : y.id)
|
|
251
257
|
),
|
|
252
258
|
style: {
|
|
253
259
|
display: !e.builderContextSignal.content && q() ? "none" : void 0
|
|
@@ -259,5 +265,5 @@ function Re(e) {
|
|
|
259
265
|
) : null });
|
|
260
266
|
}
|
|
261
267
|
export {
|
|
262
|
-
|
|
268
|
+
we as default
|
|
263
269
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.2";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./evaluate/evaluate.cjs");function i(t,e){var o;return{...(o=t.component)==null?void 0:o.options,...t.options,...r(t,e)}}const r=(t,e)=>{var o,n;if(((o=t.component)==null?void 0:o.name)==="Text"&&((n=t.component.options)!=null&&n.text)&&typeof t.component.options.text=="string")return{...t.component.options,text:t.component.options.text.replace(/{{([^}]+)}}/g,(s,p)=>a.evaluate({code:p,context:e,localState:e.localState,rootState:e.rootState,rootSetState:e.rootSetState}))}};exports.getBlockComponentOptions=i;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { evaluate as a } from "./evaluate/evaluate.mjs";
|
|
2
|
+
function s(t, o) {
|
|
3
|
+
var e;
|
|
3
4
|
return {
|
|
4
|
-
...(
|
|
5
|
-
...
|
|
5
|
+
...(e = t.component) == null ? void 0 : e.options,
|
|
6
|
+
...t.options,
|
|
7
|
+
...r(t, o)
|
|
6
8
|
};
|
|
7
9
|
}
|
|
10
|
+
const r = (t, o) => {
|
|
11
|
+
var e, n;
|
|
12
|
+
if (((e = t.component) == null ? void 0 : e.name) === "Text" && ((n = t.component.options) != null && n.text) && typeof t.component.options.text == "string")
|
|
13
|
+
return {
|
|
14
|
+
...t.component.options,
|
|
15
|
+
text: t.component.options.text.replace(/{{([^}]+)}}/g, (i, p) => a({
|
|
16
|
+
code: p,
|
|
17
|
+
context: o,
|
|
18
|
+
localState: o.localState,
|
|
19
|
+
rootState: o.rootState,
|
|
20
|
+
rootSetState: o.rootSetState
|
|
21
|
+
}))
|
|
22
|
+
};
|
|
23
|
+
};
|
|
8
24
|
export {
|
|
9
|
-
|
|
25
|
+
s as getBlockComponentOptions
|
|
10
26
|
};
|