@builder.io/sdk-react-nextjs 0.7.0 → 0.7.1-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.
Files changed (37) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-7a3bf41a.mjs +657 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-9195e6a5.js +23 -0
  3. package/lib/{edge/USE_SERVER_BUNDLE-105e9ef3.js → browser/USE_SERVER_BUNDLE-d7b13097.js} +1 -1
  4. package/lib/browser/USE_SERVER_BUNDLE-e5c2279a.mjs +11 -0
  5. package/lib/browser/{bundle-0fae602b.js → bundle-620ae296.js} +5 -5
  6. package/lib/browser/{bundle-3b073b16.mjs → bundle-7285a09d.mjs} +265 -268
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +7 -7
  9. package/lib/edge/USE_CLIENT_BUNDLE-3cca560e.js +23 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-4a0cfa69.mjs +657 -0
  11. package/lib/{node/USE_SERVER_BUNDLE-d8c698c8.js → edge/USE_SERVER_BUNDLE-3f12faf4.js} +1 -1
  12. package/lib/edge/USE_SERVER_BUNDLE-f184d7eb.mjs +11 -0
  13. package/lib/edge/{bundle-0c1d9099.js → bundle-a0f5cad2.js} +5 -5
  14. package/lib/edge/{bundle-ed178c62.mjs → bundle-a5949d33.mjs} +265 -268
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +7 -7
  17. package/lib/node/USE_CLIENT_BUNDLE-63c7fe77.js +61 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-d9e90ed7.mjs +747 -0
  19. package/lib/node/USE_SERVER_BUNDLE-22e86776.mjs +11 -0
  20. package/lib/{browser/USE_SERVER_BUNDLE-d8c698c8.js → node/USE_SERVER_BUNDLE-cd844269.js} +1 -1
  21. package/lib/node/{bundle-3b073b16.mjs → bundle-0358b224.mjs} +415 -444
  22. package/lib/node/bundle-630ffe6d.js +76 -0
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +23 -22
  25. package/package.json +5 -3
  26. package/types/blocks/image/image.d.ts +1 -1
  27. package/types/constants/sdk-version.d.ts +1 -1
  28. package/lib/browser/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  29. package/lib/browser/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  30. package/lib/browser/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  31. package/lib/edge/USE_CLIENT_BUNDLE-0e9f8e67.mjs +0 -618
  32. package/lib/edge/USE_CLIENT_BUNDLE-d48583e8.js +0 -23
  33. package/lib/edge/USE_SERVER_BUNDLE-f6a1e321.mjs +0 -11
  34. package/lib/node/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  35. package/lib/node/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  36. package/lib/node/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  37. package/lib/node/bundle-0fae602b.js +0 -76
@@ -1,10 +1,10 @@
1
- import { B as i, p as m, C as c, R as g, o as p, S as l, T as C, z as d, e as u, E as B, v as S, w as f, x as E, A as R, y as h, i as x, q as k, t as y, u as P, D as b } from "./bundle-3b073b16.mjs";
2
- import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-fc8c1bc0.mjs";
1
+ import { B as i, t as m, C as c, R as g, q as p, S as l, T as C, z as d, m as f, E as u, w as B, n as S, x as E, A as R, y as h, i as x, f as k, u as y, v as P, D as b } from "./bundle-7285a09d.mjs";
2
+ import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-7a3bf41a.mjs";
3
3
  import "lru-cache";
4
4
  import "react/jsx-runtime";
5
5
  import "react";
6
6
  import "next/navigation";
7
- import "./USE_SERVER_BUNDLE-226a15ac.mjs";
7
+ import "./USE_SERVER_BUNDLE-e5c2279a.mjs";
8
8
  export {
9
9
  i as Blocks,
10
10
  w as Button,
@@ -19,10 +19,10 @@ export {
19
19
  C as Text,
20
20
  V as Video,
21
21
  d as _processContentResult,
22
- u as createRegisterComponentMessage,
23
- B as fetchBuilderProps,
24
- S as fetchEntries,
25
- f as fetchOneEntry,
22
+ f as createRegisterComponentMessage,
23
+ u as fetchBuilderProps,
24
+ B as fetchEntries,
25
+ S as fetchOneEntry,
26
26
  E as getAllContent,
27
27
  R as getBuilderSearchParams,
28
28
  h as getContent,
@@ -0,0 +1,23 @@
1
+ "use client";"use strict";const t=require("react/jsx-runtime"),c=require("./bundle-a0f5cad2.js"),o=require("react"),_=require("./USE_SERVER_BUNDLE-3f12faf4.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-35669e6c",children:e.text})}),t.jsx("style",{children:`.button-35669e6c {
2
+ all: unset;
3
+ }`})]})}function A(e){return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...c.getBlockProperties({block:e.block,context:e.context}),...c.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}function V(e){return t.jsxs(t.Fragment,{children:[" ",e.hasChildren?t.jsx(t.Fragment,{children:t.jsxs(e.Wrapper,{...c.getBlockProperties({block:e.block,context:e.context}),...c.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,{...c.getBlockProperties({block:e.block,context:e.context}),...c.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 a(){var s;return"builder-blocks"+((s=e.blocks)!=null&&s.length?"":" no-blocks")}function g(){var s,x;c.isEditing()&&!((s=e.blocks)!=null&&s.length)&&((x=window.parent)==null||x.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function h(){var s,x;c.isEditing()&&!((s=e.blocks)!=null&&s.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:a()+" div-02c7a115","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:s=>g(),onMouseEnter:s=>h(),onKeyPress:s=>g(),children:e.children}),t.jsx("style",{children:`.div-02c7a115 {
4
+ display: flex;
5
+ flex-direction: column;
6
+ align-items: stretch;
7
+ }`})]})}function D(e){return t.jsx("span",{children:e.children})}function U(e){var s,x,k,S;function a(){var b;const d=e.image||e.src;if(!d||!(d.match(/builder\.io/)||d.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((b=e.image)!=null&&b.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),c.getSrcSet(d)}else if(e.image&&!e.srcset)return c.getSrcSet(d);return c.getSrcSet(d)}function g(){var f;return(f=a==null?void 0:a())!=null&&f.match(/builder\.io/)&&!e.noWebp?a().replace(/\?/g,"?format=webp&"):""}function h(){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(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",...h()},className:"builder-image"+(e.className?" "+e.className:"")+" img-497e0136",src:e.image,srcSet:a(),sizes:e.sizes})]}),e.aspectRatio&&!((x=(s=e.builderBlock)==null?void 0:s.children)!=null&&x.length&&e.fitContent)?t.jsx(t.Fragment,{children:t.jsx("div",{className:"builder-image-sizer div-497e0136",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-497e0136-2",children:e.children})}):null]}),t.jsx("style",{children:`.img-497e0136 {
8
+ opacity: 1;
9
+ transition: opacity 0.2s ease-in-out;
10
+ }.div-497e0136 {
11
+ width: 100%;
12
+ pointer-events: none;
13
+ font-size: 0;
14
+ }.div-497e0136-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 H(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 O(e){var h;function a(){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,...a()}}return t.jsx("video",{...g(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(h=e.attributes)==null?void 0:h.style,objectFit:e.fit,objectPosition:e.position,borderRadius:1},src:e.video||"no-src",poster:e.posterImage})}function J(e){const a=o.useRef(null),[g,h]=o.useState(()=>[]),[s,x]=o.useState(()=>[]),[k,S]=o.useState(()=>!1);function f(){if(!a.current||!a.current.getElementsByTagName)return;const d=a.current.getElementsByTagName("script");for(let b=0;b<d.length;b++){const v=d[b];if(v.src&&!g.includes(v.src)){g.push(v.src);const y=document.createElement("script");y.async=!0,y.src=v.src,document.head.appendChild(y)}else if(c.isJsScript(v)&&!s.includes(v.innerText))try{s.push(v.innerText),new Function(v.innerText)()}catch(y){console.warn("`Embed`: Error running script:",y)}}}return o.useEffect(()=>{a.current&&!k&&(S(!0),f())},[a.current,k]),t.jsx("div",{className:"builder-embed",ref:a,dangerouslySetInnerHTML:{__html:e.content}})}function G(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},c.isEditing()&&e.imgSrc||"default-key")}function $(e){const a=o.useRef(null),[g,h]=o.useState(()=>[]),[s,x]=o.useState(()=>[]);return o.useEffect(()=>{var S;if(!((S=a.current)!=null&&S.getElementsByTagName)||typeof window>"u")return;const k=a.current.getElementsByTagName("script");for(let f=0;f<k.length;f++){const d=k[f];if(d.src){if(g.includes(d.src))continue;g.push(d.src);const b=document.createElement("script");b.async=!0,b.src=d.src,document.head.appendChild(b)}else if(!d.type||["text/javascript","application/javascript","application/ecmascript"].includes(d.type)){if(s.includes(d.innerText))continue;try{s.push(d.innerText),new Function(d.innerText)()}catch(b){console.warn("`CustomCode`: Error running script:",b)}}}},[]),t.jsx("div",{ref:a,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}const Q=o.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{}});function X(e){var R,I,P,T,F;const a=o.useRef(null),[g,h]=o.useState(()=>0);function s(n){var r,l,u,m,B;const i={...e.builderContextSignal.content,...n,data:{...(r=e.builderContextSignal.content)==null?void 0:r.data,...n==null?void 0:n.data},meta:{...(l=e.builderContextSignal.content)==null?void 0:l.meta,...n==null?void 0:n.meta,breakpoints:((u=n==null?void 0:n.meta)==null?void 0:u.breakpoints)||((B=(m=e.builderContextSignal.content)==null?void 0:m.meta)==null?void 0:B.breakpoints)}};_.postPreviewContent({value:i,key:i.id}).then(()=>{q.refresh()})}o.useState(()=>0);const[x,k]=o.useState(()=>!1);function S(n){var r;const{data:i}=n;if(i)switch(i.type){case"builder.configureSdk":{const l=i.data,{breakpoints:u,contentId:m}=l;if(!m||m!==((r=e.builderContextSignal.content)==null?void 0:r.id))return;u&&s({meta:{breakpoints:u}}),h(g+1);break}case"builder.contentUpdate":{const l=i.data,u=l.key||l.alias||l.entry||l.modelName,m=l.data;u===e.model&&(s(m),h(g+1));break}}}function f(){var i,r;const n=(r=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:r.jsCode;n&&c.evaluate({code:n,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[d,b]=o.useState(()=>({})),[v,y]=o.useState(()=>!1);function N(n){var i,r;if(e.builderContextSignal.content){const l=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,u=(r=e.builderContextSignal.content)==null?void 0:r.id;c._track({type:"click",canTrack:c.getDefaultCanTrack(e.canTrack),contentId:u,apiKey:e.apiKey,variationId:l!==u?l:void 0,...c.getInteractionPropertiesForEvent(n),unique:!v})}v||y(!0)}function L(n){return n.replace(/{{([^}]+)}}/g,(i,r)=>c.evaluate({code:r,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function K({url:n,key:i}){c.fetch(n).then(r=>r.json()).then(r=>{var u,m;const l={...e.builderContextSignal.rootState,[i]:r};(m=(u=e.builderContextSignal).rootSetState)==null||m.call(u,l),d[i]=!0}).catch(r=>{console.error("error fetching dynamic data",n,r)})}function C(){var i,r;const n=((r=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:r.httpRequests)??{};Object.entries(n).forEach(([l,u])=>{if(u&&(!d[l]||c.isEditing())){const m=L(u);K({url:m,key:l})}})}function E(){c.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:c.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function j(n){h(g+1),window.addEventListener("message",S),c.registerInsertMenu(),c.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var l;const r=c.createRegisterComponentMessage(i);(l=window.parent)==null||l.postMessage(r,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",E)}function w(n){const i=new URL(location.href).searchParams,r=i.get("builder.preview"),l=i.get(`builder.preview.${r}`),u=i.get("apiKey")||i.get("builder.space");r===e.model&&u===e.apiKey&&(!e.content||l===e.content.id)&&c.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(m=>{m&&s(m)})}const q=M.useRouter();return o.useEffect(()=>{var n;return(n=a.current)==null||n.addEventListener("initeditingbldr",j),()=>{var i;return(i=a.current)==null?void 0:i.removeEventListener("initeditingbldr",j)}},[]),o.useEffect(()=>{var n;return(n=a.current)==null||n.addEventListener("initpreviewingbldr",w),()=>{var i;return(i=a.current)==null?void 0:i.removeEventListener("initpreviewingbldr",w)}},[]),o.useEffect(()=>{var n,i;if(c.isBrowser()){if(c.isEditing()&&a.current&&a.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&c.getDefaultCanTrack(e.canTrack)){const l=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,u=(i=e.builderContextSignal.content)==null?void 0:i.id,m=e.apiKey;c._track({type:"impression",canTrack:!0,contentId:u,apiKey:m,variationId:l!==u?l:void 0})}c.isPreviewing()&&a.current}},[]),o.useEffect(()=>{e.apiKey||c.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),f(),C(),E()},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{c.isBrowser()&&(window.removeEventListener("message",S),window.addEventListener("message",S))},[x]),o.useEffect(()=>{f()},[(I=(R=e.builderContextSignal.content)==null?void 0:R.data)==null?void 0:I.jsCode,e.builderContextSignal.rootState]),o.useEffect(()=>{C()},[(T=(P=e.builderContextSignal.content)==null?void 0:P.data)==null?void 0:T.httpRequests]),o.useEffect(()=>{E()},[e.builderContextSignal.rootState]),o.useEffect(()=>()=>{c.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",E))},[]),t.jsx(Q.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(t.Fragment,{children:o.createElement("div",{key:g,ref:a,onClick:n=>N(n),"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},e.children)}):null})}exports.BlockWrapper=V;exports.BlocksWrapper=z;exports.Button=W;exports.CustomCode=$;exports.Embed=J;exports.EnableEditor=X;exports.FragmentComponent=D;exports.Image=U;exports.ImgComponent=G;exports.InteractiveElement=A;exports.SectionComponent=H;exports.Video=O;