@builder.io/sdk-react 0.10.0 → 0.11.1
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/index.cjs +3 -3
- package/lib/browser/index.mjs +58 -56
- package/lib/edge/index.cjs +14 -14
- package/lib/edge/index.mjs +28 -26
- package/lib/node/index.cjs +3 -3
- package/lib/node/index.mjs +28 -26
- package/package.json +1 -1
- package/types/components/block/components/interactive-element.d.ts +3 -2
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/types/targets.d.ts +1 -1
package/lib/browser/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("react"),d=require("./server-entry-df9eba5d.cjs");function de(e){return a.jsxs(a.Fragment,{children:[e.link?a.jsx(a.Fragment,{children:a.jsx("a",{...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"button",children:e.text})}):a.jsx(a.Fragment,{children:a.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("react"),d=require("./server-entry-df9eba5d.cjs");function de(e){return a.jsxs(a.Fragment,{children:[e.link?a.jsx(a.Fragment,{children:a.jsx("a",{...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"button",children:e.text})}):a.jsx(a.Fragment,{children:a.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-3ecc5438",children:e.text})}),a.jsx("style",{children:`.button-3ecc5438 {
|
|
2
2
|
all: unset;
|
|
3
3
|
}`})]})}const q=m.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{},BlocksWrapper:"div",BlocksWrapperProps:{}}),ue=m.createContext({registeredComponents:{}});function Ee(e){var t;return{...(t=e.component)==null?void 0:t.options,...e.options,builderBlock:e}}const Te=({builder:e,context:t,event:n,state:i})=>Object.entries({state:i,Builder:e,builder:e,context:t,event:n}),Re=()=>({isEditing:d.isEditing(),isBrowser:d.isBrowser(),isServer:!d.isBrowser(),getUserAttributes:()=>d.getUserAttributes()}),je=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e,ee=({code:e,builder:t,context:n,event:i,localState:o,rootSetState:r,rootState:c})=>{const l=Te({builder:t,context:n,event:i,state:Pe(c,o,r)});return new Function(...l.map(([s])=>s),e)(...l.map(([,s])=>s))};function Pe(e,t,n){if(e===t)throw new Error("rootState === localState");return new Proxy(e,{get:(i,o)=>t&&o in t?t[o]:e[o],set:(i,o,r)=>{if(t&&o in t)throw new Error("Writing to local state is not allowed as it is read-only.");return e[o]=r,n==null||n(e),!0}})}const Be=e=>(d.isBrowser(),ee(e));function W({code:e,context:t,localState:n,rootState:i,rootSetState:o,event:r,isExpression:c=!0}){if(e===""){d.logger.warn("Skipping evaluation of empty code block.");return}const l={code:je(e,{isExpression:c}),builder:Re(),context:t,event:r,rootSetState:o,rootState:i,localState:n};try{return Be(l)}catch(s){d.logger.error("Failed code evaluation: "+s.message,{code:e});return}}const Fe=(e,t,n)=>{if(Object(e)!==e)return e;const i=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return i.slice(0,-1).reduce((o,r,c)=>Object(o[r])===o[r]?o[r]:o[r]=Math.abs(Number(i[c+1]))>>0===+i[c+1]?[]:{},e)[i[i.length-1]]=n,e};const We=({block:e,context:t,localState:n,rootState:i,rootSetState:o})=>{if(!e.bindings)return e;const r=d.fastClone(e),c={...r,properties:{...r.properties},actions:{...r.actions}};for(const l in e.bindings){const s=e.bindings[l],u=W({code:s,localState:n,rootState:i,rootSetState:o,context:t});Fe(c,l,u)}return c};function $({block:e,context:t,shouldEvaluateBindings:n,localState:i,rootState:o,rootSetState:r}){const c=e;return n?We({block:c,localState:i,rootState:o,rootSetState:r,context:t}):c}const Ae=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],O=e=>typeof e=="string"&&Ae.includes(e.toLowerCase()),Ve=({block:e,context:t,registeredComponents:n})=>{var r;const i=(r=$({block:e,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,context:t.context,shouldEvaluateBindings:!1}).component)==null?void 0:r.name;if(!i)return null;const o=n[i];if(o)return o;console.warn(`
|
|
4
4
|
Could not find a registered component named "${i}".
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
${_e(n)}
|
|
8
8
|
}`;return e?`${e} {
|
|
9
9
|
${i}
|
|
10
|
-
}`:i};function _(e){return a.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function G(e){function t(){const i=$({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return d.checkIsDefined(i.hide)?!i.hide:d.checkIsDefined(i.show)?i.show:!0}function n(){var S;const i=$({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0}),o=i.responsiveStyles,r=e.context.content,c=fe(((S=r==null?void 0:r.meta)==null?void 0:S.breakpoints)||{}),l=o==null?void 0:o.large,s=o==null?void 0:o.medium,u=o==null?void 0:o.small,f=i.id;if(!f)return"";const b=l?U({className:f,styles:l}):"",v=s?U({className:f,styles:s,mediaQuery:te("medium",c)}):"",R=u?U({className:f,styles:u,mediaQuery:te("small",c)}):"";return[b,v,R].join(" ")}return a.jsx(a.Fragment,{children:n()&&t()?a.jsx(a.Fragment,{children:a.jsx(_,{styles:n()})}):null})}function Me(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Le=e=>`on${Me(e)}`,De=(e,t)=>n=>W({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:n,isExpression:!1});function H(e){var i;const t={},n=(i=e.block.actions)!=null?i:{};for(const o in n){if(!n.hasOwnProperty(o))continue;const r=n[o];let c=Le(o);if(e.stripPrefix)switch(d.TARGET){case"
|
|
10
|
+
}`:i};function _(e){return a.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function G(e){function t(){const i=$({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return d.checkIsDefined(i.hide)?!i.hide:d.checkIsDefined(i.show)?i.show:!0}function n(){var S;const i=$({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0}),o=i.responsiveStyles,r=e.context.content,c=fe(((S=r==null?void 0:r.meta)==null?void 0:S.breakpoints)||{}),l=o==null?void 0:o.large,s=o==null?void 0:o.medium,u=o==null?void 0:o.small,f=i.id;if(!f)return"";const b=l?U({className:f,styles:l}):"",v=s?U({className:f,styles:s,mediaQuery:te("medium",c)}):"",R=u?U({className:f,styles:u,mediaQuery:te("small",c)}):"";return[b,v,R].join(" ")}return a.jsx(a.Fragment,{children:n()&&t()?a.jsx(a.Fragment,{children:a.jsx(_,{styles:n()})}):null})}function Me(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Le=e=>`on${Me(e)}`,De=(e,t)=>n=>W({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:n,isExpression:!1});function H(e){var i;const t={},n=(i=e.block.actions)!=null?i:{};for(const o in n){if(!n.hasOwnProperty(o))continue;const r=n[o];let c=Le(o);if(e.stripPrefix)switch(d.TARGET){case"vue":c=c.replace("v-on:","");break;case"svelte":c=c.replace("on:","");break}t[c]=De(r,e)}return t}function Oe({properties:e}){return e.className=e.class,delete e.class,e}const Ue=e=>({href:e.href});function N({block:e,context:t}){var i;const n={...Ue(e),...e.properties,"builder-id":e.id,style:e.style?Ke(e.style):void 0,class:[e.id,"builder-block",e.class,(i=e.properties)==null?void 0:i.class].filter(Boolean).join(" ")};return Oe({properties:n,context:t,block:e})}function Ke(e){switch(d.TARGET){case"svelte":case"vue":case"solid":return ge(e).join(" ");case"qwik":case"reactNative":case"react":case"rsc":return e}}function ne(e){return a.jsxs(a.Fragment,{children:[" ",e.hasChildren?a.jsx(a.Fragment,{children:a.jsxs(e.Wrapper,{...N({block:e.block,context:e.context}),...H({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0}),children:[" ",e.children," "]})}):a.jsx(a.Fragment,{children:a.jsx(e.Wrapper,{...N({block:e.block,context:e.context}),...H({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function He(e){return a.jsx(e.Wrapper,{...e.wrapperProps,attributes:e.includeBlockProps?{...N({block:e.block,context:e.context}),...H({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})}:{},children:e.children})}const ze=({componentOptions:e,builderBlock:t,context:n,componentRef:i,includeBlockProps:o,isInteractive:r,contextValue:c})=>{const l={...e,...o?{attributes:N({block:t,context:c})}:{}};return r?{Wrapper:i,block:t,context:n,wrapperProps:e,includeBlockProps:o}:l};function ie(e){var i,o;const[t,n]=m.useState(()=>e.isInteractive?He:e.componentRef);return a.jsx(a.Fragment,{children:e.componentRef?a.jsx(a.Fragment,{children:a.jsxs(t,{...ze({componentOptions:e.componentOptions,builderBlock:e.builderBlock,context:e.context,componentRef:e.componentRef,includeBlockProps:e.includeBlockProps,isInteractive:e.isInteractive,contextValue:e.context}),children:[(i=e.blockChildren)==null?void 0:i.map(r=>a.jsx(M,{block:r,context:e.context,registeredComponents:e.registeredComponents},"block-"+r.id)),(o=e.blockChildren)==null?void 0:o.map(r=>a.jsx(G,{block:r,context:e.context},"block-style-"+r.id))]})}):null})}function qe(e){const[t,n]=m.useState(()=>e.repeatContext);return a.jsx(q.Provider,{value:t,children:a.jsx(M,{block:e.block,context:t,registeredComponents:e.registeredComponents})})}function M(e){var f,b,v,R;function t(){return Ve({block:e.block,context:e.context,registeredComponents:e.registeredComponents})}function n(){return $e({block:e.block,context:e.context})}function i(){var S;return(S=e.block.repeat)!=null&&S.collection?e.block:$({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0})}function o(){return e.block.tagName||"div"}function r(){var w,T;if((w=e.block.repeat)!=null&&w.collection)return!!((T=n==null?void 0:n())!=null&&T.length);const S="hide"in i()?i().hide:!1;return("show"in i()?i().show:!0)&&!S}function c(){var k,w;return!((k=t==null?void 0:t())!=null&&k.component)&&!n()?(w=i().children)!=null?w:[]:[]}function l(){var S,k,w,T,I,p;return{blockChildren:(S=i().children)!=null?S:[],componentRef:(k=t==null?void 0:t())==null?void 0:k.component,componentOptions:{...Ee(i()),builderContext:e.context,...((w=t==null?void 0:t())==null?void 0:w.name)==="Symbol"||((T=t==null?void 0:t())==null?void 0:T.name)==="Columns"?{builderComponents:e.registeredComponents}:{}},context:s,registeredComponents:e.registeredComponents,builderBlock:i(),includeBlockProps:((I=t==null?void 0:t())==null?void 0:I.noWrap)===!0,isInteractive:!((p=t==null?void 0:t())!=null&&p.isRSC)}}const[s,u]=m.useState(()=>e.context);return a.jsx(a.Fragment,{children:r()?a.jsx(a.Fragment,{children:(f=t==null?void 0:t())!=null&&f.noWrap?a.jsx(a.Fragment,{children:a.jsx(ie,{componentRef:l().componentRef,componentOptions:l().componentOptions,blockChildren:l().blockChildren,context:l().context,registeredComponents:l().registeredComponents,builderBlock:l().builderBlock,includeBlockProps:l().includeBlockProps,isInteractive:l().isInteractive})}):a.jsxs(a.Fragment,{children:[O(o())?a.jsx(a.Fragment,{children:a.jsx(ne,{Wrapper:o(),block:i(),context:e.context,hasChildren:!1})}):null,!O(o())&&n()?a.jsx(a.Fragment,{children:(b=n())==null?void 0:b.map((S,k)=>a.jsx(qe,{repeatContext:S.context,block:S.block,registeredComponents:e.registeredComponents},k))}):null,!O(o())&&!n()?a.jsx(a.Fragment,{children:a.jsxs(ne,{Wrapper:o(),block:i(),context:e.context,hasChildren:!0,children:[a.jsx(ie,{componentRef:l().componentRef,componentOptions:l().componentOptions,blockChildren:l().blockChildren,context:l().context,registeredComponents:l().registeredComponents,builderBlock:l().builderBlock,includeBlockProps:l().includeBlockProps,isInteractive:l().isInteractive}),(v=c())==null?void 0:v.map(S=>a.jsx(M,{block:S,context:s,registeredComponents:e.registeredComponents},"block-"+S.id)),(R=c())==null?void 0:R.map(S=>a.jsx(G,{block:S,context:s},"block-style-"+S.id))]})}):null]})}):null})}function Ge(e){function t(){var o;return"builder-blocks"+((o=e.blocks)!=null&&o.length?"":" no-blocks")}function n(){var o,r;d.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((r=window.parent)==null||r.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function i(){var o,r;d.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((r=window.parent)==null||r.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return a.jsxs(a.Fragment,{children:[a.jsx(e.BlocksWrapper,{className:t()+" props-blocks-wrapper-4f2c12d8","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:o=>n(),onMouseEnter:o=>i(),onKeyPress:o=>n(),...e.BlocksWrapperProps,children:e.children}),a.jsx("style",{children:`.props-blocks-wrapper-4f2c12d8 {
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
13
|
align-items: stretch;
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"${t}",${JSON.stringify(e)}, ${Ce}
|
|
157
157
|
)`,yt=({contentId:e,variationId:t})=>`window.${ke}(
|
|
158
158
|
"${t}", "${e}", ${Ce}
|
|
159
|
-
)`;function z(e){return a.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function re(e){return Math.round(e*1e3)/1e3}const pt=(e,t,n=!0)=>{if(!(e instanceof HTMLElement))return null;let i=n?e:e.parentElement;do{if(!i)return null;if(t(i))return i}while(i=i.parentElement);return null},vt=e=>pt(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),ce=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,o=e.clientY-n.top,r=re(i/n.width),c=re(o/n.height);return{x:r,y:c}},kt=e=>{const t=e.target,n=t&&vt(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?ce({event:e,target:t}):void 0,builderTargetOffset:n?ce({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},Ct="0.
|
|
159
|
+
)`;function z(e){return a.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function re(e){return Math.round(e*1e3)/1e3}const pt=(e,t,n=!0)=>{if(!(e instanceof HTMLElement))return null;let i=n?e:e.parentElement;do{if(!i)return null;if(t(i))return i}while(i=i.parentElement);return null},vt=e=>pt(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),ce=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,o=e.clientY-n.top,r=re(i/n.width),c=re(o/n.height);return{x:r,y:c}},kt=e=>{const t=e.target,n=t&&vt(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?ce({event:e,target:t}):void 0,builderTargetOffset:n?ce({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},Ct="0.11.1",wt=()=>{d.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let le=!1;const It=(e={})=>{var t,n;le||(le=!0,d.isBrowser()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:d.TARGET,version:Ct,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",({data:i})=>{var o,r;if(i!=null&&i.type)switch(i.type){case"builder.evaluate":{const c=i.data.text,l=i.data.arguments||[],s=i.data.id,u=new Function(c);let f,b=null;try{f=u.apply(null,l)}catch(v){b=v}b?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:s,error:b.message}},"*"):f&&typeof f.then=="function"?f.then(v=>{var R;(R=window.parent)==null||R.postMessage({type:"builder.evaluateResult",data:{id:s,result:v}},"*")}).catch(console.error):(r=window.parent)==null||r.postMessage({type:"builder.evaluateResult",data:{result:f,id:s}},"*");break}}})))};function Et(e){var B,F,D,Q,J,X,Z;const t=m.useRef(null),[n,i]=m.useState(()=>0);function o(g){var x,y,C,E,A;const h={...e.builderContextSignal.content,...g,data:{...(x=e.builderContextSignal.content)==null?void 0:x.data,...g==null?void 0:g.data},meta:{...(y=e.builderContextSignal.content)==null?void 0:y.meta,...g==null?void 0:g.meta,breakpoints:((C=g==null?void 0:g.meta)==null?void 0:C.breakpoints)||((A=(E=e.builderContextSignal.content)==null?void 0:E.meta)==null?void 0:A.breakpoints)}};e.setBuilderContextSignal(Ie=>({...Ie,content:h}))}m.useState(()=>0);const[r,c]=m.useState(()=>!1),[l,s]=m.useState(()=>e.contentWrapper||"div");function u(g){var x;const{data:h}=g;if(h)switch(h.type){case"builder.configureSdk":{const y=h.data,{breakpoints:C,contentId:E}=y;if(!E||E!==((x=e.builderContextSignal.content)==null?void 0:x.id))return;C&&o({meta:{breakpoints:C}}),i(n+1);break}case"builder.contentUpdate":{const y=h.data,C=y.key||y.alias||y.entry||y.modelName,E=y.data;C===e.model&&(o(E),i(n+1));break}}}function f(){var h,x;const g=(x=(h=e.builderContextSignal.content)==null?void 0:h.data)==null?void 0:x.jsCode;g&&W({code:g,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[b,v]=m.useState(()=>({})),[R,S]=m.useState(()=>!1);function k(g){var h,x;if(e.builderContextSignal.content){const y=(h=e.builderContextSignal.content)==null?void 0:h.testVariationId,C=(x=e.builderContextSignal.content)==null?void 0:x.id;d._track({type:"click",canTrack:d.getDefaultCanTrack(e.canTrack),contentId:C,apiKey:e.apiKey,variationId:y!==C?y:void 0,...kt(g),unique:!R})}R||S(!0)}function w(g){return g.replace(/{{([^}]+)}}/g,(h,x)=>W({code:x,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function T({url:g,key:h}){d.fetch(g).then(x=>x.json()).then(x=>{var C,E;const y={...e.builderContextSignal.rootState,[h]:x};(E=(C=e.builderContextSignal).rootSetState)==null||E.call(C,y),b[h]=!0}).catch(x=>{console.error("error fetching dynamic data",g,x)})}function I(){var h,x,y;const g=(y=(x=(h=e.builderContextSignal.content)==null?void 0:h.data)==null?void 0:x.httpRequests)!=null?y:{};Object.entries(g).forEach(([C,E])=>{if(E&&(!b[C]||d.isEditing())){const A=w(E);T({url:A,key:C})}})}function p(){d.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:d.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function j(g){i(n+1),window.addEventListener("message",u),wt(),It({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(h=>{var y;const x=d.createRegisterComponentMessage(h);(y=window.parent)==null||y.postMessage(x,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",p)}function P(g){const h=new URL(location.href).searchParams,x=h.get("builder.preview"),y=h.get(`builder.preview.${x}`),C=h.get("apiKey")||h.get("builder.space");x===e.model&&C===e.apiKey&&(!e.content||y===e.content.id)&&d.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(E=>{E&&o(E)})}return m.useEffect(()=>{var g;return(g=t.current)==null||g.addEventListener("initeditingbldr",j),()=>{var h;return(h=t.current)==null?void 0:h.removeEventListener("initeditingbldr",j)}},[]),m.useEffect(()=>{var g;return(g=t.current)==null||g.addEventListener("initpreviewingbldr",P),()=>{var h;return(h=t.current)==null?void 0:h.removeEventListener("initpreviewingbldr",P)}},[]),m.useEffect(()=>{var g,h;if(d.isBrowser()){if(d.isEditing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&d.getDefaultCanTrack(e.canTrack)){const y=(g=e.builderContextSignal.content)==null?void 0:g.testVariationId,C=(h=e.builderContextSignal.content)==null?void 0:h.id,E=e.apiKey;d._track({type:"impression",canTrack:!0,contentId:C,apiKey:E,variationId:y!==C?y:void 0})}d.isPreviewing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"))}},[]),m.useEffect(()=>{e.apiKey||d.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),f(),I(),p()},[]),m.useEffect(()=>{e.content&&o(e.content)},[e.content]),m.useEffect(()=>{},[r]),m.useEffect(()=>{f()},[(F=(B=e.builderContextSignal.content)==null?void 0:B.data)==null?void 0:F.jsCode,e.builderContextSignal.rootState]),m.useEffect(()=>{I()},[(Q=(D=e.builderContextSignal.content)==null?void 0:D.data)==null?void 0:Q.httpRequests]),m.useEffect(()=>{p()},[e.builderContextSignal.rootState]),m.useEffect(()=>()=>{d.isBrowser()&&(window.removeEventListener("message",u),window.removeEventListener("builder:component:stateChangeListenerActivated",p))},[]),a.jsx(q.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?a.jsx(a.Fragment,{children:m.createElement(l,{key:n,ref:t,onClick:g=>k(g),"builder-content-id":(J=e.builderContextSignal.content)==null?void 0:J.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},...e.contentWrapperProps,className:`variant-${((X=e.content)==null?void 0:X.testVariationId)||((Z=e.content)==null?void 0:Z.id)}`},e.children)}):null})}const Tt=e=>{var r,c;const t=e.family+(e.kind&&!e.kind.includes("#")?", "+e.kind:""),n=t.split(",")[0],i=(c=e.fileUrl)!=null?c:(r=e==null?void 0:e.files)==null?void 0:r.regular;let o="";if(i&&t&&n&&(o+=`
|
|
160
160
|
@font-face {
|
|
161
161
|
font-family: "${t}";
|
|
162
162
|
src: local("${n}"), url('${i}') format('woff2');
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as R, Fragment as f, jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { createContext as Ce, useState as S, useContext as se, createElement as we, useRef as ee, useEffect as W } from "react";
|
|
4
|
-
import { i as
|
|
4
|
+
import { i as V, j as $, k as Ne, l as U, m as te, n as J, T as L, r as Fe, o as D, p as de, a as _e, c as Le, b as Ie, q as je, u as ue, v as me, w as Me } from "./server-entry-f978b3a5.js";
|
|
5
5
|
import { _ as un, h as mn, f as fn, g as hn, e as gn, d as bn, s as xn, t as yn } from "./server-entry-f978b3a5.js";
|
|
6
6
|
function Ue(e) {
|
|
7
7
|
return /* @__PURE__ */ R(f, { children: [
|
|
@@ -19,11 +19,11 @@ function Ue(e) {
|
|
|
19
19
|
{
|
|
20
20
|
...e.attributes,
|
|
21
21
|
style: e.attributes.style,
|
|
22
|
-
className: e.attributes.className + " button-
|
|
22
|
+
className: e.attributes.className + " button-3ecc5438",
|
|
23
23
|
children: e.text
|
|
24
24
|
}
|
|
25
25
|
) }),
|
|
26
|
-
/* @__PURE__ */ l("style", { children: `.button-
|
|
26
|
+
/* @__PURE__ */ l("style", { children: `.button-3ecc5438 {
|
|
27
27
|
all: unset;
|
|
28
28
|
}` })
|
|
29
29
|
] });
|
|
@@ -66,7 +66,7 @@ const Oe = ({
|
|
|
66
66
|
context: t,
|
|
67
67
|
event: n
|
|
68
68
|
}), Ke = () => ({
|
|
69
|
-
isEditing:
|
|
69
|
+
isEditing: V(),
|
|
70
70
|
isBrowser: $(),
|
|
71
71
|
isServer: !$(),
|
|
72
72
|
getUserAttributes: () => Ne()
|
|
@@ -374,8 +374,7 @@ function X(e) {
|
|
|
374
374
|
let r = nt(a);
|
|
375
375
|
if (e.stripPrefix)
|
|
376
376
|
switch (L) {
|
|
377
|
-
case "
|
|
378
|
-
case "vue3":
|
|
377
|
+
case "vue":
|
|
379
378
|
r = r.replace("v-on:", "");
|
|
380
379
|
break;
|
|
381
380
|
case "svelte":
|
|
@@ -415,8 +414,7 @@ function K({
|
|
|
415
414
|
function rt(e) {
|
|
416
415
|
switch (L) {
|
|
417
416
|
case "svelte":
|
|
418
|
-
case "
|
|
419
|
-
case "vue3":
|
|
417
|
+
case "vue":
|
|
420
418
|
case "solid":
|
|
421
419
|
return Pe(e).join(" ");
|
|
422
420
|
case "qwik":
|
|
@@ -475,7 +473,7 @@ function lt(e) {
|
|
|
475
473
|
e.Wrapper,
|
|
476
474
|
{
|
|
477
475
|
...e.wrapperProps,
|
|
478
|
-
attributes: {
|
|
476
|
+
attributes: e.includeBlockProps ? {
|
|
479
477
|
...K({
|
|
480
478
|
block: e.block,
|
|
481
479
|
context: e.context
|
|
@@ -487,7 +485,7 @@ function lt(e) {
|
|
|
487
485
|
localState: e.context.localState,
|
|
488
486
|
context: e.context.context
|
|
489
487
|
})
|
|
490
|
-
},
|
|
488
|
+
} : {},
|
|
491
489
|
children: e.children
|
|
492
490
|
}
|
|
493
491
|
);
|
|
@@ -500,23 +498,27 @@ const ct = ({
|
|
|
500
498
|
includeBlockProps: a,
|
|
501
499
|
isInteractive: o,
|
|
502
500
|
contextValue: r
|
|
503
|
-
}) =>
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
501
|
+
}) => {
|
|
502
|
+
const c = {
|
|
503
|
+
...e,
|
|
504
|
+
/**
|
|
505
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
506
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
507
|
+
*/
|
|
508
|
+
...a ? {
|
|
509
|
+
attributes: K({
|
|
510
|
+
block: t,
|
|
511
|
+
context: r
|
|
512
|
+
})
|
|
513
|
+
} : {}
|
|
514
|
+
};
|
|
515
|
+
return o ? {
|
|
516
|
+
Wrapper: i,
|
|
517
|
+
block: t,
|
|
518
|
+
context: n,
|
|
519
|
+
wrapperProps: e,
|
|
520
|
+
includeBlockProps: a
|
|
521
|
+
} : c;
|
|
520
522
|
};
|
|
521
523
|
function be(e) {
|
|
522
524
|
var i, a;
|
|
@@ -709,7 +711,7 @@ function dt(e) {
|
|
|
709
711
|
}
|
|
710
712
|
function n() {
|
|
711
713
|
var a, o;
|
|
712
|
-
|
|
714
|
+
V() && !((a = e.blocks) != null && a.length) && ((o = window.parent) == null || o.postMessage(
|
|
713
715
|
{
|
|
714
716
|
type: "builder.clickEmptyBlocks",
|
|
715
717
|
data: {
|
|
@@ -722,7 +724,7 @@ function dt(e) {
|
|
|
722
724
|
}
|
|
723
725
|
function i() {
|
|
724
726
|
var a, o;
|
|
725
|
-
|
|
727
|
+
V() && !((a = e.blocks) != null && a.length) && ((o = window.parent) == null || o.postMessage(
|
|
726
728
|
{
|
|
727
729
|
type: "builder.hoverEmptyBlocks",
|
|
728
730
|
data: {
|
|
@@ -829,17 +831,17 @@ function ut(e) {
|
|
|
829
831
|
};
|
|
830
832
|
}
|
|
831
833
|
function x(I) {
|
|
832
|
-
const p = I === 0 ? 0 : t, B = s(I),
|
|
834
|
+
const p = I === 0 ? 0 : t, B = s(I), A = `${p}px`, N = "100%", F = 0;
|
|
833
835
|
return {
|
|
834
836
|
width: B,
|
|
835
|
-
["marginLeft"]:
|
|
837
|
+
["marginLeft"]: A,
|
|
836
838
|
"--column-width-mobile": u({
|
|
837
839
|
stackedStyle: N,
|
|
838
840
|
desktopStyle: B
|
|
839
841
|
}),
|
|
840
842
|
"--column-margin-left-mobile": u({
|
|
841
843
|
stackedStyle: F,
|
|
842
|
-
desktopStyle:
|
|
844
|
+
desktopStyle: A
|
|
843
845
|
}),
|
|
844
846
|
"--column-width-tablet": d({
|
|
845
847
|
stackedStyle: N,
|
|
@@ -847,14 +849,14 @@ function ut(e) {
|
|
|
847
849
|
}),
|
|
848
850
|
"--column-margin-left-tablet": d({
|
|
849
851
|
stackedStyle: F,
|
|
850
|
-
desktopStyle:
|
|
852
|
+
desktopStyle: A
|
|
851
853
|
})
|
|
852
854
|
};
|
|
853
855
|
}
|
|
854
856
|
function k(I) {
|
|
855
|
-
var B,
|
|
857
|
+
var B, A;
|
|
856
858
|
return Ee(
|
|
857
|
-
((
|
|
859
|
+
((A = (B = e.builderContext.content) == null ? void 0 : B.meta) == null ? void 0 : A.breakpoints) || {}
|
|
858
860
|
)[I].max;
|
|
859
861
|
}
|
|
860
862
|
function w() {
|
|
@@ -1548,7 +1550,7 @@ function Et(e) {
|
|
|
1548
1550
|
src: e.imgSrc || e.image,
|
|
1549
1551
|
...e.attributes
|
|
1550
1552
|
},
|
|
1551
|
-
|
|
1553
|
+
V() && e.imgSrc || "default-key"
|
|
1552
1554
|
);
|
|
1553
1555
|
}
|
|
1554
1556
|
const Pt = {
|
|
@@ -1642,7 +1644,7 @@ const Pt = {
|
|
|
1642
1644
|
textAlign: "center"
|
|
1643
1645
|
}
|
|
1644
1646
|
};
|
|
1645
|
-
function
|
|
1647
|
+
function At(e) {
|
|
1646
1648
|
var t;
|
|
1647
1649
|
return /* @__PURE__ */ l(
|
|
1648
1650
|
"div",
|
|
@@ -1655,7 +1657,7 @@ function Vt(e) {
|
|
|
1655
1657
|
}
|
|
1656
1658
|
);
|
|
1657
1659
|
}
|
|
1658
|
-
const
|
|
1660
|
+
const Vt = {
|
|
1659
1661
|
name: "Video",
|
|
1660
1662
|
canHaveChildren: !0,
|
|
1661
1663
|
defaultStyles: {
|
|
@@ -1866,11 +1868,11 @@ const ye = () => [{
|
|
|
1866
1868
|
component: nn,
|
|
1867
1869
|
...Wt
|
|
1868
1870
|
}, {
|
|
1869
|
-
component:
|
|
1871
|
+
component: At,
|
|
1870
1872
|
...Bt
|
|
1871
1873
|
}, {
|
|
1872
1874
|
component: $t,
|
|
1873
|
-
...
|
|
1875
|
+
...Vt
|
|
1874
1876
|
}], Nt = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
|
|
1875
1877
|
function getAndSetVariantId() {
|
|
1876
1878
|
function setCookie(name, value, days) {
|
|
@@ -1968,17 +1970,17 @@ const ye = () => [{
|
|
|
1968
1970
|
})), _t = ({
|
|
1969
1971
|
canTrack: e,
|
|
1970
1972
|
content: t
|
|
1971
|
-
}) => !(!(M(t).length > 0) || !e || $()), Lt = (e) => e === "react" || e === "reactNative",
|
|
1973
|
+
}) => !(!(M(t).length > 0) || !e || $()), Lt = (e) => e === "react" || e === "reactNative", Ae = Lt(L), jt = () => `
|
|
1972
1974
|
window.${We} = ${Nt}
|
|
1973
1975
|
window.${Be} = ${Ft}
|
|
1974
1976
|
`, Mt = (e, t) => `
|
|
1975
1977
|
window.${We}(
|
|
1976
|
-
"${t}",${JSON.stringify(e)}, ${
|
|
1978
|
+
"${t}",${JSON.stringify(e)}, ${Ae}
|
|
1977
1979
|
)`, Ut = ({
|
|
1978
1980
|
contentId: e,
|
|
1979
1981
|
variationId: t
|
|
1980
1982
|
}) => `window.${Be}(
|
|
1981
|
-
"${t}", "${e}", ${
|
|
1983
|
+
"${t}", "${e}", ${Ae}
|
|
1982
1984
|
)`;
|
|
1983
1985
|
function Z(e) {
|
|
1984
1986
|
return /* @__PURE__ */ l(
|
|
@@ -2031,7 +2033,7 @@ const Dt = (e, t, n = !0) => {
|
|
|
2031
2033
|
builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
|
|
2032
2034
|
}
|
|
2033
2035
|
};
|
|
2034
|
-
}, Ht = "0.
|
|
2036
|
+
}, Ht = "0.11.1", zt = () => {
|
|
2035
2037
|
Fe("insertMenu", {
|
|
2036
2038
|
name: "_default",
|
|
2037
2039
|
default: !0,
|
|
@@ -2222,7 +2224,7 @@ function Yt(e) {
|
|
|
2222
2224
|
var h, b, y;
|
|
2223
2225
|
const m = (y = (b = (h = e.builderContextSignal.content) == null ? void 0 : h.data) == null ? void 0 : b.httpRequests) != null ? y : {};
|
|
2224
2226
|
Object.entries(m).forEach(([C, T]) => {
|
|
2225
|
-
if (T && (!g[C] ||
|
|
2227
|
+
if (T && (!g[C] || V())) {
|
|
2226
2228
|
const j = w(T);
|
|
2227
2229
|
E({
|
|
2228
2230
|
url: j,
|
|
@@ -2232,7 +2234,7 @@ function Yt(e) {
|
|
|
2232
2234
|
});
|
|
2233
2235
|
}
|
|
2234
2236
|
function p() {
|
|
2235
|
-
|
|
2237
|
+
V() && window.dispatchEvent(
|
|
2236
2238
|
new CustomEvent(
|
|
2237
2239
|
"builder:component:stateChange",
|
|
2238
2240
|
{
|
|
@@ -2268,7 +2270,7 @@ function Yt(e) {
|
|
|
2268
2270
|
p
|
|
2269
2271
|
);
|
|
2270
2272
|
}
|
|
2271
|
-
function
|
|
2273
|
+
function A(m) {
|
|
2272
2274
|
const h = new URL(location.href).searchParams, b = h.get("builder.preview"), y = h.get(
|
|
2273
2275
|
`builder.preview.${b}`
|
|
2274
2276
|
), C = h.get("apiKey") || h.get("builder.space");
|
|
@@ -2296,18 +2298,18 @@ function Yt(e) {
|
|
|
2296
2298
|
var m;
|
|
2297
2299
|
return (m = t.current) == null || m.addEventListener(
|
|
2298
2300
|
"initpreviewingbldr",
|
|
2299
|
-
|
|
2301
|
+
A
|
|
2300
2302
|
), () => {
|
|
2301
2303
|
var h;
|
|
2302
2304
|
return (h = t.current) == null ? void 0 : h.removeEventListener(
|
|
2303
2305
|
"initpreviewingbldr",
|
|
2304
|
-
|
|
2306
|
+
A
|
|
2305
2307
|
);
|
|
2306
2308
|
};
|
|
2307
2309
|
}, []), W(() => {
|
|
2308
2310
|
var m, h;
|
|
2309
2311
|
if ($()) {
|
|
2310
|
-
if (
|
|
2312
|
+
if (V() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && D(e.canTrack)) {
|
|
2311
2313
|
const y = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, C = (h = e.builderContextSignal.content) == null ? void 0 : h.id, T = e.apiKey;
|
|
2312
2314
|
de({
|
|
2313
2315
|
type: "impression",
|
|
@@ -2568,7 +2570,7 @@ function ke(e) {
|
|
|
2568
2570
|
}
|
|
2569
2571
|
);
|
|
2570
2572
|
}
|
|
2571
|
-
function
|
|
2573
|
+
function Ve(e) {
|
|
2572
2574
|
var r, c;
|
|
2573
2575
|
const [t, n] = S(
|
|
2574
2576
|
() => _t({
|
|
@@ -2705,7 +2707,7 @@ function nn(e) {
|
|
|
2705
2707
|
}, []), W(() => {
|
|
2706
2708
|
a();
|
|
2707
2709
|
}, [e.symbol]), /* @__PURE__ */ l("div", { ...e.attributes, className: t(), children: /* @__PURE__ */ l(
|
|
2708
|
-
|
|
2710
|
+
Ve,
|
|
2709
2711
|
{
|
|
2710
2712
|
__isNestedRender: !0,
|
|
2711
2713
|
apiVersion: e.builderContext.apiVersion,
|
|
@@ -2722,19 +2724,19 @@ function nn(e) {
|
|
|
2722
2724
|
}
|
|
2723
2725
|
) });
|
|
2724
2726
|
}
|
|
2725
|
-
const ln = ae, cn =
|
|
2727
|
+
const ln = ae, cn = Ve;
|
|
2726
2728
|
export {
|
|
2727
2729
|
ae as Blocks,
|
|
2728
2730
|
Ue as Button,
|
|
2729
2731
|
ut as Columns,
|
|
2730
|
-
|
|
2732
|
+
Ve as Content,
|
|
2731
2733
|
mt as Fragment,
|
|
2732
2734
|
gt as Image,
|
|
2733
2735
|
ln as RenderBlocks,
|
|
2734
2736
|
cn as RenderContent,
|
|
2735
2737
|
bt as Section,
|
|
2736
2738
|
nn as Symbol,
|
|
2737
|
-
|
|
2739
|
+
At as Text,
|
|
2738
2740
|
$t as Video,
|
|
2739
2741
|
un as _processContentResult,
|
|
2740
2742
|
Le as createRegisterComponentMessage,
|
|
@@ -2744,7 +2746,7 @@ export {
|
|
|
2744
2746
|
hn as getAllContent,
|
|
2745
2747
|
gn as getBuilderSearchParams,
|
|
2746
2748
|
bn as getContent,
|
|
2747
|
-
|
|
2749
|
+
V as isEditing,
|
|
2748
2750
|
_e as isPreviewing,
|
|
2749
2751
|
Fe as register,
|
|
2750
2752
|
xn as setEditorSettings,
|