@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.
- package/lib/browser/blocks/custom-code/custom-code.cjs +1 -1
- package/lib/browser/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/browser/blocks/embed/embed.cjs +1 -1
- package/lib/browser/blocks/embed/embed.mjs +16 -15
- package/lib/browser/blocks/image/component-info.cjs +1 -1
- package/lib/browser/blocks/image/component-info.mjs +12 -8
- package/lib/browser/blocks/image/image.cjs +4 -4
- package/lib/browser/blocks/image/image.mjs +14 -13
- package/lib/browser/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/browser/components/blocks/blocks-wrapper.mjs +18 -16
- 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/components/content-variants/helpers.cjs +9 -9
- package/lib/browser/components/content-variants/helpers.mjs +16 -16
- package/lib/browser/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/browser/components/content-variants/inlined-fns.mjs +5 -2
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/edge/blocks/custom-code/custom-code.cjs +1 -1
- package/lib/edge/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/edge/blocks/embed/embed.cjs +1 -1
- package/lib/edge/blocks/embed/embed.mjs +16 -15
- package/lib/edge/blocks/image/component-info.cjs +1 -1
- package/lib/edge/blocks/image/component-info.mjs +12 -8
- package/lib/edge/blocks/image/image.cjs +4 -4
- package/lib/edge/blocks/image/image.mjs +14 -13
- package/lib/edge/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/edge/components/blocks/blocks-wrapper.mjs +18 -16
- 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/components/content-variants/helpers.cjs +9 -9
- package/lib/edge/components/content-variants/helpers.mjs +16 -16
- package/lib/edge/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/edge/components/content-variants/inlined-fns.mjs +5 -2
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/node/blocks/custom-code/custom-code.cjs +1 -1
- package/lib/node/blocks/custom-code/custom-code.mjs +27 -17
- package/lib/node/blocks/embed/embed.cjs +1 -1
- package/lib/node/blocks/embed/embed.mjs +16 -15
- package/lib/node/blocks/image/component-info.cjs +1 -1
- package/lib/node/blocks/image/component-info.mjs +12 -8
- package/lib/node/blocks/image/image.cjs +4 -4
- package/lib/node/blocks/image/image.mjs +14 -13
- package/lib/node/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/node/components/blocks/blocks-wrapper.mjs +18 -16
- 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/components/content-variants/helpers.cjs +9 -9
- package/lib/node/components/content-variants/helpers.mjs +16 -16
- package/lib/node/components/content-variants/inlined-fns.cjs +5 -2
- package/lib/node/components/content-variants/inlined-fns.mjs +5 -2
- 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/blocks/image/image.types.d.ts +1 -0
- package/types/cjs/components/content-variants/inlined-fns.d.ts +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/esm/blocks/image/image.types.d.ts +1 -0
- package/types/esm/components/content-variants/inlined-fns.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { jsxs as a, Fragment as c, jsx as t } from "react/jsx-runtime";
|
|
3
3
|
import { getSrcSet as o } from "./image.helpers.mjs";
|
|
4
4
|
function x(e) {
|
|
5
|
-
var d,
|
|
5
|
+
var d, u, s, g, h, m;
|
|
6
6
|
function n() {
|
|
7
|
-
var
|
|
7
|
+
var f;
|
|
8
8
|
const i = e.image || e.src;
|
|
9
9
|
if (!i || // We can auto add srcset for cdn.builder.io and shopify
|
|
10
10
|
// images, otherwise you can supply this prop manually
|
|
11
11
|
!(typeof i == "string" && (i.match(/builder\.io/) || i.match(/cdn\.shopify\.com/))))
|
|
12
12
|
return e.srcset;
|
|
13
13
|
if (!e.noWebp) {
|
|
14
|
-
if (e.srcset && ((
|
|
14
|
+
if (e.srcset && ((f = e.image) != null && f.includes("builder.io/api/v1/image"))) {
|
|
15
15
|
if (!e.srcset.includes(e.image.split("?")[0]))
|
|
16
16
|
return console.debug("Removed given srcset"), o(i);
|
|
17
17
|
} else if (e.image && !e.srcset)
|
|
@@ -23,7 +23,7 @@ function x(e) {
|
|
|
23
23
|
var l;
|
|
24
24
|
return (l = n == null ? void 0 : n()) != null && l.match(/builder\.io/) && !e.noWebp ? n().replace(/\?/g, "?format=webp&") : "";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function b() {
|
|
27
27
|
const l = {
|
|
28
28
|
position: "absolute",
|
|
29
29
|
height: "100%",
|
|
@@ -43,39 +43,40 @@ function x(e) {
|
|
|
43
43
|
loading: e.highPriority ? "eager" : "lazy",
|
|
44
44
|
fetchPriority: e.highPriority ? "high" : "auto",
|
|
45
45
|
alt: e.altText,
|
|
46
|
+
title: e.title,
|
|
46
47
|
role: e.altText ? void 0 : "presentation",
|
|
47
48
|
style: {
|
|
48
49
|
objectPosition: e.backgroundPosition || "center",
|
|
49
50
|
objectFit: e.backgroundSize || "cover",
|
|
50
|
-
...
|
|
51
|
+
...b()
|
|
51
52
|
},
|
|
52
|
-
className: "builder-image" + (e.className ? " " + e.className : "") + " img-
|
|
53
|
+
className: "builder-image" + (e.className ? " " + e.className : "") + " img-0525a549",
|
|
53
54
|
src: e.image,
|
|
54
55
|
srcSet: n(),
|
|
55
56
|
sizes: e.sizes
|
|
56
57
|
}
|
|
57
58
|
)
|
|
58
59
|
] }),
|
|
59
|
-
e.aspectRatio && !((
|
|
60
|
+
e.aspectRatio && !((u = (d = e.builderBlock) == null ? void 0 : d.children) != null && u.length && e.fitContent) ? /* @__PURE__ */ t(
|
|
60
61
|
"div",
|
|
61
62
|
{
|
|
62
|
-
className: "builder-image-sizer div-
|
|
63
|
+
className: "builder-image-sizer div-0525a549",
|
|
63
64
|
style: {
|
|
64
65
|
paddingTop: e.aspectRatio * 100 + "%"
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
) : null,
|
|
68
|
-
(g = (
|
|
69
|
-
!e.fitContent && ((m = (h = e.builderBlock) == null ? void 0 : h.children) != null && m.length) ? /* @__PURE__ */ t("div", { className: "div-
|
|
69
|
+
(g = (s = e.builderBlock) == null ? void 0 : s.children) != null && g.length && e.fitContent ? /* @__PURE__ */ t(c, { children: e.children }) : null,
|
|
70
|
+
!e.fitContent && ((m = (h = e.builderBlock) == null ? void 0 : h.children) != null && m.length) ? /* @__PURE__ */ t("div", { className: "div-0525a549-2", children: e.children }) : null
|
|
70
71
|
] }),
|
|
71
|
-
/* @__PURE__ */ t("style", { children: `.img-
|
|
72
|
+
/* @__PURE__ */ t("style", { children: `.img-0525a549 {
|
|
72
73
|
opacity: 1;
|
|
73
74
|
transition: opacity 0.2s ease-in-out;
|
|
74
|
-
}.div-
|
|
75
|
+
}.div-0525a549 {
|
|
75
76
|
width: 100%;
|
|
76
77
|
pointer-events: none;
|
|
77
78
|
font-size: 0;
|
|
78
|
-
}.div-
|
|
79
|
+
}.div-0525a549-2 {
|
|
79
80
|
display: flex;
|
|
80
81
|
flex-direction: column;
|
|
81
82
|
align-items: stretch;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
1
|
+
"use client";"use strict";const a=require("react/jsx-runtime"),i=require("react"),r=require("../../functions/is-editing.cjs");function d(e){const c=i.useRef(null);i.useState(()=>!1);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function s(){if(!e.path)return;const t="this.",n="component.options.";return e.path.startsWith(t)?e.path.replace(t,""):e.path.startsWith(n)?e.path:`${n}${e.path||""}`}function l(){var t,n;r.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:s()}},"*"))}function u(){var t,n;r.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:s()}},"*"))}return i.useEffect(()=>{},[]),i.useEffect(()=>{},[e.blocks]),a.jsxs(a.Fragment,{children:[a.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-2b05e766","builder-path":s(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>l(),onMouseEnter:t=>u(),onKeyPress:t=>l(),...e.BlocksWrapperProps,children:e.children}),a.jsx("style",{children:`.props-blocks-wrapper-2b05e766 {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: stretch;
|
|
5
|
-
}`})]})}module.exports=
|
|
5
|
+
}`})]})}module.exports=d;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { isEditing as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
2
|
+
import { jsxs as h, Fragment as f, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as u, useState as k, useEffect as i } from "react";
|
|
4
|
+
import { isEditing as s } from "../../functions/is-editing.mjs";
|
|
5
|
+
function y(e) {
|
|
6
|
+
const c = u(null);
|
|
7
|
+
k(() => !1);
|
|
8
|
+
function o() {
|
|
8
9
|
var t;
|
|
9
10
|
return [
|
|
10
11
|
"builder-blocks",
|
|
@@ -20,7 +21,7 @@ function k(e) {
|
|
|
20
21
|
}
|
|
21
22
|
function l() {
|
|
22
23
|
var t, n;
|
|
23
|
-
|
|
24
|
+
s() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
24
25
|
{
|
|
25
26
|
type: "builder.clickEmptyBlocks",
|
|
26
27
|
data: {
|
|
@@ -31,9 +32,9 @@ function k(e) {
|
|
|
31
32
|
"*"
|
|
32
33
|
));
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function d() {
|
|
35
36
|
var t, n;
|
|
36
|
-
|
|
37
|
+
s() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
37
38
|
{
|
|
38
39
|
type: "builder.hoverEmptyBlocks",
|
|
39
40
|
data: {
|
|
@@ -44,24 +45,25 @@ function k(e) {
|
|
|
44
45
|
"*"
|
|
45
46
|
));
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
-
}, []),
|
|
48
|
+
return i(() => {
|
|
49
|
+
}, []), i(() => {
|
|
50
|
+
}, [e.blocks]), /* @__PURE__ */ h(f, { children: [
|
|
49
51
|
/* @__PURE__ */ r(
|
|
50
52
|
e.BlocksWrapper,
|
|
51
53
|
{
|
|
52
|
-
ref:
|
|
53
|
-
className:
|
|
54
|
+
ref: c,
|
|
55
|
+
className: o() + " props-blocks-wrapper-2b05e766",
|
|
54
56
|
"builder-path": a(),
|
|
55
57
|
"builder-parent-id": e.parent,
|
|
56
58
|
style: e.styleProp,
|
|
57
59
|
onClick: (t) => l(),
|
|
58
|
-
onMouseEnter: (t) =>
|
|
60
|
+
onMouseEnter: (t) => d(),
|
|
59
61
|
onKeyPress: (t) => l(),
|
|
60
62
|
...e.BlocksWrapperProps,
|
|
61
63
|
children: e.children
|
|
62
64
|
}
|
|
63
65
|
),
|
|
64
|
-
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-
|
|
66
|
+
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-2b05e766 {
|
|
65
67
|
display: flex;
|
|
66
68
|
flex-direction: column;
|
|
67
69
|
align-items: stretch;
|
|
@@ -69,5 +71,5 @@ function k(e) {
|
|
|
69
71
|
] });
|
|
70
72
|
}
|
|
71
73
|
export {
|
|
72
|
-
|
|
74
|
+
y as default
|
|
73
75
|
};
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
window.${
|
|
3
|
-
window.${
|
|
4
|
-
`,
|
|
5
|
-
window.${
|
|
6
|
-
"${t}",${JSON.stringify(i)}, ${
|
|
7
|
-
)`,
|
|
8
|
-
"${t}", "${i}", ${
|
|
9
|
-
)`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=
|
|
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
|
|
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
|
|
4
|
-
const
|
|
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",
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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.${
|
|
21
|
-
"${r}", "${i}", ${
|
|
20
|
+
}) => `window.${a}(
|
|
21
|
+
"${r}", "${i}", ${e}
|
|
22
22
|
)`;
|
|
23
23
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.8";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
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;
|