@builder.io/sdk-react-nextjs 0.14.17 → 0.14.19
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-a0af5379.cjs +21 -0
- package/lib/{node/USE_CLIENT_BUNDLE-8dadab11.js → browser/USE_CLIENT_BUNDLE-b63f19ab.js} +251 -247
- package/lib/{edge/USE_SERVER_BUNDLE-6b33cfd7.js → browser/USE_SERVER_BUNDLE-60e66f1c.js} +1 -1
- package/lib/{edge/USE_SERVER_BUNDLE-4035cf43.cjs → browser/USE_SERVER_BUNDLE-c0e4ee23.cjs} +1 -1
- package/lib/browser/bundle-9732e1d3.cjs +169 -0
- package/lib/browser/{bundle-974bbd75.js → bundle-edd2e835.js} +590 -578
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +4 -4
- package/lib/edge/USE_CLIENT_BUNDLE-0a51f6af.cjs +21 -0
- package/lib/{browser/USE_CLIENT_BUNDLE-f685a480.js → edge/USE_CLIENT_BUNDLE-8bf08d5b.js} +251 -247
- package/lib/{node/USE_SERVER_BUNDLE-d847a064.cjs → edge/USE_SERVER_BUNDLE-7acc7eaf.cjs} +1 -1
- package/lib/{node/USE_SERVER_BUNDLE-d7d118c1.js → edge/USE_SERVER_BUNDLE-90c6ce15.js} +1 -1
- package/lib/edge/bundle-af88805d.cjs +189 -0
- package/lib/edge/{bundle-0e4ba4de.js → bundle-e86f8464.js} +1016 -1004
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +4 -4
- package/lib/node/USE_CLIENT_BUNDLE-8a32af0d.cjs +21 -0
- package/lib/{edge/USE_CLIENT_BUNDLE-bf35f13e.js → node/USE_CLIENT_BUNDLE-e4c15aa7.js} +251 -247
- package/lib/{browser/USE_SERVER_BUNDLE-fbe70d66.js → node/USE_SERVER_BUNDLE-4fd50e3b.js} +1 -1
- package/lib/{browser/USE_SERVER_BUNDLE-1ee4e92a.cjs → node/USE_SERVER_BUNDLE-d6552b77.cjs} +1 -1
- package/lib/node/{bundle-a8217ddb.js → bundle-1280dc1a.js} +256 -242
- package/lib/node/{bundle-39fe7680.cjs → bundle-23855e1a.cjs} +18 -18
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +4 -4
- package/package.json +1 -1
- package/types/cjs/blocks/columns/columns.types.d.ts +1 -1
- package/types/cjs/blocks/columns/helpers.d.ts +1 -0
- package/types/cjs/blocks/tabs/component-info.d.ts +2 -0
- package/types/cjs/blocks/tabs/index.d.ts +1 -0
- package/types/cjs/blocks/tabs/tabs.d.ts +4 -0
- package/types/cjs/blocks/tabs/tabs.types.d.ts +13 -0
- package/types/cjs/blocks/text/text.types.d.ts +2 -1
- package/types/cjs/components/block/block.helpers.d.ts +4 -2
- package/types/cjs/components/content/components/styles.helpers.d.ts +1 -0
- package/types/cjs/components/dynamic-div.d.ts +15 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/types/targets.d.ts +1 -1
- package/types/esm/blocks/columns/columns.types.d.ts +1 -1
- package/types/esm/blocks/columns/helpers.d.ts +1 -0
- package/types/esm/blocks/tabs/component-info.d.ts +2 -0
- package/types/esm/blocks/tabs/index.d.ts +1 -0
- package/types/esm/blocks/tabs/tabs.d.ts +4 -0
- package/types/esm/blocks/tabs/tabs.types.d.ts +13 -0
- package/types/esm/blocks/text/text.types.d.ts +2 -1
- package/types/esm/components/block/block.helpers.d.ts +4 -2
- package/types/esm/components/content/components/styles.helpers.d.ts +1 -0
- package/types/esm/components/dynamic-div.d.ts +15 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/types/targets.d.ts +1 -1
- package/lib/browser/USE_CLIENT_BUNDLE-f11159f6.cjs +0 -21
- package/lib/browser/bundle-e5f3c905.cjs +0 -169
- package/lib/edge/USE_CLIENT_BUNDLE-22f09854.cjs +0 -21
- package/lib/edge/bundle-15a88622.cjs +0 -189
- package/lib/node/USE_CLIENT_BUNDLE-e62d9c72.cjs +0 -21
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";"use strict";const t=require("react/jsx-runtime"),n=require("./bundle-9732e1d3.cjs"),l=require("react"),D=require("./USE_SERVER_BUNDLE-c0e4ee23.cjs"),H=require("next/navigation");function j(e){return t.jsx(t.Fragment,{children:n.isEmptyElement(e.TagName)?t.jsx(t.Fragment,{children:t.jsx(e.TagName,{...e.attributes,...e.actionAttributes})}):t.jsx(t.Fragment,{children:typeof e.TagName=="string"?t.jsx(e.TagName,{...e.attributes,...e.actionAttributes,children:e.children}):t.jsx(e.TagName,{...e.attributes,...e.actionAttributes,children:e.children})})})}function V(e){function c(){return{...e.attributes,[n.getClassPropName()]:`${e.link?"":"builder-button"} ${e.attributes[n.getClassPropName()]||""}`,...e.link?{href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"link"}:{role:"button"}}}return t.jsx(j,{attributes:c(),TagName:e.link?e.builderLinkComponent||"a":"button",actionAttributes:{},children:e.text})}function U(e){return t.jsx(j,{TagName:e.Wrapper,attributes:n.getBlockProperties({block:e.block,context:e.context}),actionAttributes: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})}function O(e){function c(){return e.includeBlockProps?{...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})}:{}}return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:c(),children:e.children})}function $(e){function c(){var o;return"builder-blocks"+((o=e.blocks)!=null&&o.length?"":" no-blocks")}function g(){var o,b;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((b=window.parent)==null||b.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function S(){var o,b;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((b=window.parent)==null||b.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return t.jsxs(t.Fragment,{children:[t.jsx(e.BlocksWrapper,{className:c()+" props-blocks-wrapper-7cd1560e","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:o=>g(),onMouseEnter:o=>S(),onKeyPress:o=>g(),...e.BlocksWrapperProps,children:e.children}),t.jsx("style",{children:`.props-blocks-wrapper-7cd1560e {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: stretch;
|
|
5
|
+
}`})]})}function J(e){return t.jsx("span",{children:e.children})}function G(e){var o,b,v,x,h,s;function c(){var k;const u=e.image||e.src;if(!u||!(u.match(/builder\.io/)||u.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((k=e.image)!=null&&k.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),n.getSrcSet(u)}else if(e.image&&!e.srcset)return n.getSrcSet(u);return n.getSrcSet(u)}function g(){var f;return(f=c==null?void 0:c())!=null&&f.match(/builder\.io/)&&!e.noWebp?c().replace(/\?/g,"?format=webp&"):""}function S(){const f={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?f:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[g()?t.jsx("source",{type:"image/webp",srcSet:g()}):null,t.jsx("img",{loading:"lazy",alt:e.altText,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...S()},className:"builder-image"+(e.className?" "+e.className:"")+" img-3ac67dd4",src:e.image,srcSet:c(),sizes:e.sizes})]}),e.aspectRatio&&!((b=(o=e.builderBlock)==null?void 0:o.children)!=null&&b.length&&e.fitContent)?t.jsx("div",{className:"builder-image-sizer div-3ac67dd4",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(x=(v=e.builderBlock)==null?void 0:v.children)!=null&&x.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&((s=(h=e.builderBlock)==null?void 0:h.children)!=null&&s.length)?t.jsx("div",{className:"div-3ac67dd4-2",children:e.children}):null]}),t.jsx("style",{children:`.img-3ac67dd4 {
|
|
6
|
+
opacity: 1;
|
|
7
|
+
transition: opacity 0.2s ease-in-out;
|
|
8
|
+
}.div-3ac67dd4 {
|
|
9
|
+
width: 100%;
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
font-size: 0;
|
|
12
|
+
}.div-3ac67dd4-2 {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: stretch;
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
}`})]})}function Q(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 X(e){const c=l.useRef(null),[g,S]=l.useState(()=>[]),[o,b]=l.useState(()=>[]);return l.useEffect(()=>{var x;if(!((x=c.current)!=null&&x.getElementsByTagName)||typeof window>"u")return;const v=c.current.getElementsByTagName("script");for(let h=0;h<v.length;h++){const s=v[h];if(s.src){if(g.includes(s.src))continue;g.push(s.src);const f=document.createElement("script");f.async=!0,f.src=s.src,document.head.appendChild(f)}else if(!s.type||["text/javascript","application/javascript","application/ecmascript"].includes(s.type)){if(o.includes(s.innerText))continue;try{o.push(s.innerText),new Function(s.innerText)()}catch(f){console.warn("`CustomCode`: Error running script:",f)}}}},[]),t.jsx("div",{ref:c,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}function Y(e){const c=l.useRef(null),[g,S]=l.useState(()=>[]),[o,b]=l.useState(()=>[]),[v,x]=l.useState(()=>!1);function h(){if(!c.current||!c.current.getElementsByTagName)return;const s=c.current.getElementsByTagName("script");for(let f=0;f<s.length;f++){const u=s[f];if(u.src&&!g.includes(u.src)){g.push(u.src);const k=document.createElement("script");k.async=!0,k.src=u.src,document.head.appendChild(k)}else if(n.isJsScript(u)&&!o.includes(u.innerText))try{o.push(u.innerText),new Function(u.innerText)()}catch(k){console.warn("`Embed`: Error running script:",k)}}}return l.useEffect(()=>{c.current&&!v&&(x(!0),h())},[c.current,v]),t.jsx("div",{className:"builder-embed",ref:c,dangerouslySetInnerHTML:{__html:e.content}})}function Z(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 p(e){var S,o,b,v,x,h,s;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{...c()}}return t.jsxs("div",{style:{position:"relative"},children:[t.jsx("video",{className:"builder-video",...g(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(S=e.attributes)==null?void 0:S.style,objectFit:e.fit,objectPosition:e.position,zIndex:2,borderRadius:"1px",...e.aspectRatio?{position:"absolute"}:null},src:e.video||"no-src",poster:e.posterImage,children:e.lazyLoad?null:t.jsx("source",{type:"video/mp4",src:e.video})}),e.aspectRatio&&!(e.fitContent&&((b=(o=e.builderBlock)==null?void 0:o.children)!=null&&b.length))?t.jsx("div",{style:{width:"100%",paddingTop:e.aspectRatio*100+"%",pointerEvents:"none",fontSize:"0px"}}):null,(x=(v=e.builderBlock)==null?void 0:v.children)!=null&&x.length&&e.fitContent?t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:e.children}):null,(s=(h=e.builderBlock)==null?void 0:h.children)!=null&&s.length&&!e.fitContent?t.jsx("div",{style:{pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"stretch",position:"absolute",top:"0",left:"0",width:"100%",height:"100%"},children:e.children}):null]})}const A=l.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{},BlocksWrapper:"div",BlocksWrapperProps:{}});function ee(e){var T,B,N,L,F,W,q;const c=l.useRef(null);function g(a){var d,r;const i={...e.builderContextSignal.rootState,...a};e.builderContextSignal.rootSetState?(r=(d=e.builderContextSignal).rootSetState)==null||r.call(d,i):e.builderContextSignal.rootState=i}function S(a){var d,r,m,y,C;const i={...e.builderContextSignal.content,...a,data:{...(d=e.builderContextSignal.content)==null?void 0:d.data,...a==null?void 0:a.data},meta:{...(r=e.builderContextSignal.content)==null?void 0:r.meta,...a==null?void 0:a.meta,breakpoints:((m=a==null?void 0:a.meta)==null?void 0:m.breakpoints)||((C=(y=e.builderContextSignal.content)==null?void 0:y.meta)==null?void 0:C.breakpoints)}};D.postPreviewContent({value:i,key:i.id}).then(()=>{z.refresh()})}function o(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[b,v]=l.useState(()=>e.contentWrapper||"div");function x(a){return n.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:i=>{var m;const{breakpoints:d,contentId:r}=i;!r||r!==((m=e.builderContextSignal.content)==null?void 0:m.id)||d&&S({meta:{breakpoints:d}})},animation:i=>{n.triggerAnimation(i)},contentUpdate:i=>{S(i)}}})(a)}function h(){var i,d;const a=(d=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:d.jsCode;a&&n.evaluate({code:a,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState,enableCache:!1})}const[s,f]=l.useState(()=>({})),[u,k]=l.useState(()=>({})),[w,K]=l.useState(()=>!1);function _(a){var i,d;if(e.builderContextSignal.content){const r=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,m=(d=e.builderContextSignal.content)==null?void 0:d.id;n._track({type:"click",canTrack:n.getDefaultCanTrack(e.canTrack),contentId:m,apiKey:e.apiKey,variationId:r!==m?r:void 0,...n.getInteractionPropertiesForEvent(a),unique:!w})}w||K(!0)}function I(){var i,d;const a=((d=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:d.httpRequests)??{};Object.entries(a).forEach(([r,m])=>{if(!m||u[r]||s[r]&&!n.isEditing())return;u[r]=!0;const y=m.replace(/{{([^}]+)}}/g,(C,M)=>String(n.evaluate({code:M,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState,enableCache:!0})));n.fetch(y).then(C=>C.json()).then(C=>{g({[r]:C}),s[r]=!0}).catch(C=>{console.error("error fetching dynamic data",m,C)}).finally(()=>{u[r]=!1})})}function E(){n.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:n.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function R(a){window.addEventListener("message",x),n.registerInsertMenu(),n.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var r;const d=n.createRegisterComponentMessage(i);(r=window.parent)==null||r.postMessage(d,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",E)}function P(a){const i=new URL(location.href).searchParams,d=i.get("builder.preview"),r=i.get(`builder.preview.${d}`),m=i.get("apiKey")||i.get("builder.space");d===e.model&&m===e.apiKey&&(!e.content||r===e.content.id)&&n.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(y=>{y&&S(y)})}const z=H.useRouter();return l.useEffect(()=>{var a;return(a=c.current)==null||a.addEventListener("initeditingbldr",R),()=>{var i;return(i=c.current)==null?void 0:i.removeEventListener("initeditingbldr",R)}},[]),l.useEffect(()=>{var a;return(a=c.current)==null||a.addEventListener("initpreviewingbldr",P),()=>{var i;return(i=c.current)==null?void 0:i.removeEventListener("initpreviewingbldr",P)}},[]),l.useEffect(()=>{var a,i;if(n.isBrowser()){if(n.isEditing()&&c.current&&c.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&n.getDefaultCanTrack(e.canTrack)){const r=(a=e.builderContextSignal.content)==null?void 0:a.testVariationId,m=(i=e.builderContextSignal.content)==null?void 0:i.id,y=e.apiKey;n._track({type:"impression",canTrack:!0,contentId:m,apiKey:y,variationId:r!==m?r:void 0})}n.isPreviewing()&&n.isEditing()}},[]),l.useEffect(()=>{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."),h(),I(),E()},[]),l.useEffect(()=>{},[e.content]),l.useEffect(()=>{h()},[(B=(T=e.builderContextSignal.content)==null?void 0:T.data)==null?void 0:B.jsCode]),l.useEffect(()=>{I()},[(L=(N=e.builderContextSignal.content)==null?void 0:N.data)==null?void 0:L.httpRequests]),l.useEffect(()=>{E()},[e.builderContextSignal.rootState]),l.useEffect(()=>{e.data&&g(e.data)},[e.data]),l.useEffect(()=>{e.locale&&g({locale:e.locale})},[e.locale]),l.useEffect(()=>()=>{n.isBrowser()&&(window.removeEventListener("message",x),window.removeEventListener("builder:component:stateChangeListenerActivated",E))},[]),t.jsx(A.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(b,{ref:c,onClick:a=>_(a),"builder-content-id":(F=e.builderContextSignal.content)==null?void 0:F.id,"builder-model":e.model,...o(),...e.contentWrapperProps,className:n.getWrapperClassName(((W=e.content)==null?void 0:W.testVariationId)||((q=e.content)==null?void 0:q.id)),children:e.children}):null})}exports.BlockWrapper=U;exports.BlocksWrapper=$;exports.Button=V;exports.CustomCode=X;exports.DynamicRenderer=j;exports.Embed=Y;exports.EnableEditor=ee;exports.FragmentComponent=J;exports.Image=G;exports.ImgComponent=Z;exports.InteractiveElement=O;exports.SectionComponent=Q;exports.Video=p;exports.builderContext=A;
|