@builder.io/sdk-react-nextjs 0.6.4 → 0.7.0
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/USE_CLIENT_BUNDLE-3a41b1ba.js +23 -0
- package/lib/{node/USE_CLIENT_BUNDLE-f8df6014.mjs → browser/USE_CLIENT_BUNDLE-fc8c1bc0.mjs} +177 -179
- package/lib/{edge/USE_SERVER_BUNDLE-079fd7e9.mjs → browser/USE_SERVER_BUNDLE-226a15ac.mjs} +1 -1
- package/lib/{edge/USE_SERVER_BUNDLE-5955a553.js → browser/USE_SERVER_BUNDLE-d8c698c8.js} +1 -1
- package/lib/browser/{bundle-e116a057.js → bundle-0fae602b.js} +8 -8
- package/lib/browser/{bundle-6ca5e123.mjs → bundle-3b073b16.mjs} +24 -20
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +7 -7
- package/lib/{browser/USE_CLIENT_BUNDLE-f8df6014.mjs → edge/USE_CLIENT_BUNDLE-0e9f8e67.mjs} +177 -179
- package/lib/edge/USE_CLIENT_BUNDLE-d48583e8.js +23 -0
- package/lib/{node/USE_SERVER_BUNDLE-c4ad0f9f.js → edge/USE_SERVER_BUNDLE-105e9ef3.js} +1 -1
- package/lib/{node/USE_SERVER_BUNDLE-a9a2d553.mjs → edge/USE_SERVER_BUNDLE-f6a1e321.mjs} +1 -1
- package/lib/edge/{bundle-df0d312f.js → bundle-0c1d9099.js} +24 -24
- package/lib/edge/{bundle-1e4b4476.mjs → bundle-ed178c62.mjs} +878 -874
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +7 -7
- package/lib/node/USE_CLIENT_BUNDLE-3a41b1ba.js +23 -0
- package/lib/{edge/USE_CLIENT_BUNDLE-bd1c5cd0.mjs → node/USE_CLIENT_BUNDLE-fc8c1bc0.mjs} +177 -179
- package/lib/{browser/USE_SERVER_BUNDLE-a9a2d553.mjs → node/USE_SERVER_BUNDLE-226a15ac.mjs} +1 -1
- package/lib/{browser/USE_SERVER_BUNDLE-c4ad0f9f.js → node/USE_SERVER_BUNDLE-d8c698c8.js} +1 -1
- package/lib/node/{bundle-e116a057.js → bundle-0fae602b.js} +8 -8
- package/lib/node/{bundle-6ca5e123.mjs → bundle-3b073b16.mjs} +24 -20
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +7 -7
- package/package.json +2 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/lib/browser/USE_CLIENT_BUNDLE-4b8ab2a7.js +0 -23
- package/lib/edge/USE_CLIENT_BUNDLE-fc2e4ccd.js +0 -23
- package/lib/node/USE_CLIENT_BUNDLE-4b8ab2a7.js +0 -23
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";"use strict";const t=require("react/jsx-runtime"),n=require("./bundle-0fae602b.js"),d=require("react"),L=require("./USE_SERVER_BUNDLE-d8c698c8.js"),M=require("next/navigation");function W(e){return t.jsxs(t.Fragment,{children:[e.link?t.jsx(t.Fragment,{children:t.jsx("a",{role:"button",...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,children:e.text})}):t.jsx(t.Fragment,{children:t.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-3e7bc8b2",children:e.text})}),t.jsx("style",{children:`.button-3e7bc8b2 {
|
|
2
|
+
all: unset;
|
|
3
|
+
}`})]})}function _(e){return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}function A(e){return t.jsxs(t.Fragment,{children:[" ",e.hasChildren?t.jsx(t.Fragment,{children:t.jsxs(e.Wrapper,{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0}),children:[" ",e.children," "]})}):t.jsx(t.Fragment,{children:t.jsx(e.Wrapper,{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function z(e){function c(){var o;return"builder-blocks"+((o=e.blocks)!=null&&o.length?"":" no-blocks")}function g(){var o,x;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((x=window.parent)==null||x.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function b(){var o,x;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((x=window.parent)==null||x.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:c()+" div-5821bd52","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:o=>g(),onMouseEnter:o=>b(),onKeyPress:o=>g(),children:e.children}),t.jsx("style",{children:`.div-5821bd52 {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: stretch;
|
|
7
|
+
}`})]})}function K(e){return t.jsx("span",{children:e.children})}function D(e){var o,x,k,S;function c(){var f;const r=e.image||e.src;if(!r||!(r.match(/builder\.io/)||r.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((f=e.image)!=null&&f.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),n.getSrcSet(r)}else if(e.image&&!e.srcset)return n.getSrcSet(r);return n.getSrcSet(r)}function g(){var m;return(m=c==null?void 0:c())!=null&&m.match(/builder\.io/)&&!e.noWebp?c().replace(/\?/g,"?format=webp&"):""}function b(){const m={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?m:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[g()?t.jsx(t.Fragment,{children:t.jsx("source",{type:"image/webp",srcSet:g()})}):null,t.jsx("img",{loading:"lazy",alt:e.altText,role:e.altText?"presentation":void 0,style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...b()},className:"builder-image"+(e.className?" "+e.className:"")+" img-ef11a6be",src:e.image,srcSet:c(),sizes:e.sizes})]}),e.aspectRatio&&!((x=(o=e.builderBlock)==null?void 0:o.children)!=null&&x.length&&e.fitContent)?t.jsx(t.Fragment,{children:t.jsx("div",{className:"builder-image-sizer div-ef11a6be",style:{paddingTop:e.aspectRatio*100+"%"}})}):null,(S=(k=e.builderBlock)==null?void 0:k.children)!=null&&S.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&e.children?t.jsx(t.Fragment,{children:t.jsx("div",{className:"div-ef11a6be-2",children:e.children})}):null]}),t.jsx("style",{children:`.img-ef11a6be {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transition: opacity 0.2s ease-in-out;
|
|
10
|
+
}.div-ef11a6be {
|
|
11
|
+
width: 100%;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
font-size: 0;
|
|
14
|
+
}.div-ef11a6be-2 {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
align-items: stretch;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
}`})]})}function V(e){return t.jsx("section",{...e.attributes,style:{width:"100%",alignSelf:"stretch",flexGrow:1,boxSizing:"border-box",maxWidth:e.maxWidth||1200,display:"flex",flexDirection:"column",alignItems:"stretch",marginLeft:"auto",marginRight:"auto"},children:e.children})}function U(e){var b;function c(){return{...e.autoPlay===!0?{autoPlay:!0}:{},...e.muted===!0?{muted:!0}:{},...e.controls===!0?{controls:!0}:{},...e.loop===!0?{loop:!0}:{},...e.playsInline===!0?{playsInline:!0}:{}}}function g(){return{...e.attributes,...c()}}return t.jsx("video",{...g(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(b=e.attributes)==null?void 0:b.style,objectFit:e.fit,objectPosition:e.position,borderRadius:1},src:e.video||"no-src",poster:e.posterImage})}function H(e){const c=d.useRef(null),[g,b]=d.useState(()=>[]),[o,x]=d.useState(()=>[]),[k,S]=d.useState(()=>!1);function m(){if(!c.current||!c.current.getElementsByTagName)return;const r=c.current.getElementsByTagName("script");for(let f=0;f<r.length;f++){const v=r[f];if(v.src&&!g.includes(v.src)){g.push(v.src);const C=document.createElement("script");C.async=!0,C.src=v.src,document.head.appendChild(C)}else if(n.isJsScript(v)&&!o.includes(v.innerText))try{o.push(v.innerText),new Function(v.innerText)()}catch(C){console.warn("`Embed`: Error running script:",C)}}}return d.useEffect(()=>{c.current&&!k&&(S(!0),m())},[c.current,k]),t.jsx("div",{className:"builder-embed",ref:c,dangerouslySetInnerHTML:{__html:e.content}})}function J(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},n.isEditing()&&e.imgSrc||"default-key")}function O(e){const c=d.useRef(null),[g,b]=d.useState(()=>[]),[o,x]=d.useState(()=>[]);function k(){if(c.current&&c.current.getElementsByTagName&&typeof window<"u"){const S=c.current.getElementsByTagName("script");for(let m=0;m<S.length;m++){const r=S[m];if(r.src){if(g.includes(r.src))continue;g.push(r.src);const f=document.createElement("script");f.async=!0,f.src=r.src,document.head.appendChild(f)}else if(!r.type||["text/javascript","application/javascript","application/ecmascript"].includes(r.type)){if(o.includes(r.innerText))continue;try{o.push(r.innerText),new Function(r.innerText)()}catch(f){console.warn("`CustomCode`: Error running script:",f)}}}}}return d.useEffect(()=>{k()},[]),t.jsx("div",{ref:c,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}const G=d.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{}});function Q(e){var j,R,I,w,F;const c=d.useRef(null),[g,b]=d.useState(()=>0);function o(i){var a,s,u,h,P;const l={...e.builderContextSignal.content,...i,data:{...(a=e.builderContextSignal.content)==null?void 0:a.data,...i==null?void 0:i.data},meta:{...(s=e.builderContextSignal.content)==null?void 0:s.meta,...i==null?void 0:i.meta,breakpoints:((u=i==null?void 0:i.meta)==null?void 0:u.breakpoints)||((P=(h=e.builderContextSignal.content)==null?void 0:h.meta)==null?void 0:P.breakpoints)}};L.postPreviewContent({value:l,key:l.id}).then(()=>{q.refresh()})}d.useState(()=>0);const[x,k]=d.useState(()=>!1);function S(i){var a;const{data:l}=i;if(l)switch(l.type){case"builder.configureSdk":{const s=l.data,{breakpoints:u,contentId:h}=s;if(!h||h!==((a=e.builderContextSignal.content)==null?void 0:a.id))return;u&&o({meta:{breakpoints:u}}),b(g+1);break}case"builder.contentUpdate":{const s=l.data,u=s.key||s.alias||s.entry||s.modelName,h=s.data;u===e.model&&(o(h),b(g+1));break}}}function m(){var l,a;const i=(a=(l=e.builderContextSignal.content)==null?void 0:l.data)==null?void 0:a.jsCode;i&&n.evaluate({code:i,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[r,f]=d.useState(()=>({})),[v,C]=d.useState(()=>!1);function B(i){var l,a;if(e.builderContextSignal.content){const s=(l=e.builderContextSignal.content)==null?void 0:l.testVariationId,u=(a=e.builderContextSignal.content)==null?void 0:a.id;n._track({type:"click",canTrack:n.getDefaultCanTrack(e.canTrack),contentId:u,apiKey:e.apiKey,variationId:s!==u?s:void 0,...n.getInteractionPropertiesForEvent(i),unique:!v})}v||C(!0)}function T(i){return i.replace(/{{([^}]+)}}/g,(l,a)=>n.evaluate({code:a,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function N({url:i,key:l}){n.fetch(i).then(a=>a.json()).then(a=>{var u,h;const s={...e.builderContextSignal.rootState,[l]:a};(h=(u=e.builderContextSignal).rootSetState)==null||h.call(u,s),r[l]=!0}).catch(a=>{console.error("error fetching dynamic data",i,a)})}function E(){var l,a;const i=((a=(l=e.builderContextSignal.content)==null?void 0:l.data)==null?void 0:a.httpRequests)??{};Object.entries(i).forEach(([s,u])=>{if(u&&(!r[s]||n.isEditing())){const h=T(u);N({url:h,key:s})}})}function y(){n.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:n.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}const q=M.useRouter();return d.useEffect(()=>{var i,l;if(e.apiKey||n.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),n.isBrowser()){if(n.isEditing()&&(b(g+1),window.addEventListener("message",S),n.registerInsertMenu(),n.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(a=>{var u;const s=n.createRegisterComponentMessage(a);(u=window.parent)==null||u.postMessage(s,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",y)),e.builderContextSignal.content){const a=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,s=(l=e.builderContextSignal.content)==null?void 0:l.id;n._track({type:"impression",canTrack:n.getDefaultCanTrack(e.canTrack),contentId:s,apiKey:e.apiKey,variationId:a!==s?a:void 0})}m(),E(),y()}},[]),d.useEffect(()=>{},[e.content]),d.useEffect(()=>{n.isBrowser()&&(window.removeEventListener("message",S),window.addEventListener("message",S))},[x]),d.useEffect(()=>{m()},[(R=(j=e.builderContextSignal.content)==null?void 0:j.data)==null?void 0:R.jsCode,e.builderContextSignal.rootState]),d.useEffect(()=>{E()},[(w=(I=e.builderContextSignal.content)==null?void 0:I.data)==null?void 0:w.httpRequests]),d.useEffect(()=>{y()},[e.builderContextSignal.rootState]),d.useEffect(()=>()=>{n.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",y))},[]),t.jsx(G.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(t.Fragment,{children:t.jsx("div",{ref:c,onClick:i=>B(i),"builder-content-id":(F=e.builderContextSignal.content)==null?void 0:F.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},className:e.classNameProp,children:e.children},g)}):null})}exports.BlockWrapper=A;exports.BlocksWrapper=z;exports.Button=W;exports.CustomCode=O;exports.Embed=H;exports.EnableEditor=Q;exports.FragmentComponent=K;exports.Image=D;exports.ImgComponent=J;exports.InteractiveElement=_;exports.SectionComponent=V;exports.Video=U;
|