@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/edge/index.mjs
CHANGED
|
@@ -19,11 +19,11 @@ function Yr(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__ */ p("style", { children: `.button-
|
|
26
|
+
/* @__PURE__ */ p("style", { children: `.button-3ecc5438 {
|
|
27
27
|
all: unset;
|
|
28
28
|
}` })
|
|
29
29
|
] });
|
|
@@ -2846,8 +2846,7 @@ function Yt(e) {
|
|
|
2846
2846
|
let s = Ti(i);
|
|
2847
2847
|
if (e.stripPrefix)
|
|
2848
2848
|
switch (nt) {
|
|
2849
|
-
case "
|
|
2850
|
-
case "vue3":
|
|
2849
|
+
case "vue":
|
|
2851
2850
|
s = s.replace("v-on:", "");
|
|
2852
2851
|
break;
|
|
2853
2852
|
case "svelte":
|
|
@@ -2887,8 +2886,7 @@ function mt({
|
|
|
2887
2886
|
function Oi(e) {
|
|
2888
2887
|
switch (nt) {
|
|
2889
2888
|
case "svelte":
|
|
2890
|
-
case "
|
|
2891
|
-
case "vue3":
|
|
2889
|
+
case "vue":
|
|
2892
2890
|
case "solid":
|
|
2893
2891
|
return wr(e).join(" ");
|
|
2894
2892
|
case "qwik":
|
|
@@ -2947,7 +2945,7 @@ function Pi(e) {
|
|
|
2947
2945
|
e.Wrapper,
|
|
2948
2946
|
{
|
|
2949
2947
|
...e.wrapperProps,
|
|
2950
|
-
attributes: {
|
|
2948
|
+
attributes: e.includeBlockProps ? {
|
|
2951
2949
|
...mt({
|
|
2952
2950
|
block: e.block,
|
|
2953
2951
|
context: e.context
|
|
@@ -2959,7 +2957,7 @@ function Pi(e) {
|
|
|
2959
2957
|
localState: e.context.localState,
|
|
2960
2958
|
context: e.context.context
|
|
2961
2959
|
})
|
|
2962
|
-
},
|
|
2960
|
+
} : {},
|
|
2963
2961
|
children: e.children
|
|
2964
2962
|
}
|
|
2965
2963
|
);
|
|
@@ -2972,23 +2970,27 @@ const Ni = ({
|
|
|
2972
2970
|
includeBlockProps: i,
|
|
2973
2971
|
isInteractive: a,
|
|
2974
2972
|
contextValue: s
|
|
2975
|
-
}) =>
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2973
|
+
}) => {
|
|
2974
|
+
const u = {
|
|
2975
|
+
...e,
|
|
2976
|
+
/**
|
|
2977
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
2978
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
2979
|
+
*/
|
|
2980
|
+
...i ? {
|
|
2981
|
+
attributes: mt({
|
|
2982
|
+
block: t,
|
|
2983
|
+
context: s
|
|
2984
|
+
})
|
|
2985
|
+
} : {}
|
|
2986
|
+
};
|
|
2987
|
+
return a ? {
|
|
2988
|
+
Wrapper: n,
|
|
2989
|
+
block: t,
|
|
2990
|
+
context: r,
|
|
2991
|
+
wrapperProps: e,
|
|
2992
|
+
includeBlockProps: i
|
|
2993
|
+
} : u;
|
|
2992
2994
|
};
|
|
2993
2995
|
function nr(e) {
|
|
2994
2996
|
var n, i;
|
|
@@ -4503,7 +4505,7 @@ const po = (e, t, r = !0) => {
|
|
|
4503
4505
|
builderElementIndex: r && n ? [].slice.call(document.getElementsByClassName(n)).indexOf(r) : void 0
|
|
4504
4506
|
}
|
|
4505
4507
|
};
|
|
4506
|
-
}, vo = "0.
|
|
4508
|
+
}, vo = "0.11.1", yo = () => {
|
|
4507
4509
|
Hr("insertMenu", {
|
|
4508
4510
|
name: "_default",
|
|
4509
4511
|
default: !0,
|
package/lib/node/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),react=require("react"),serverEntry=require("./server-entry-df9eba5d.cjs"),node_module=require("node:module");var _documentCurrentScript=typeof document!="undefined"?document.currentScript:null;function Button(e){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.link?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("a",{...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"button",children:e.text})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.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 jsxRuntime=require("react/jsx-runtime"),react=require("react"),serverEntry=require("./server-entry-df9eba5d.cjs"),node_module=require("node:module");var _documentCurrentScript=typeof document!="undefined"?document.currentScript:null;function Button(e){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.link?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("a",{...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"button",children:e.text})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-3ecc5438",children:e.text})}),jsxRuntime.jsx("style",{children:`.button-3ecc5438 {
|
|
2
2
|
all: unset;
|
|
3
3
|
}`})]})}const builderContext=react.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{},BlocksWrapper:"div",BlocksWrapperProps:{}}),ComponentsContext=react.createContext({registeredComponents:{}});function getBlockComponentOptions(e){var t;return{...(t=e.component)==null?void 0:t.options,...e.options,builderBlock:e}}const getFunctionArguments=({builder:e,context:t,event:n,state:i})=>Object.entries({state:i,Builder:e,builder:e,context:t,event:n}),getBuilderGlobals=()=>({isEditing:serverEntry.isEditing(),isBrowser:serverEntry.isBrowser(),isServer:!serverEntry.isBrowser(),getUserAttributes:()=>serverEntry.getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e,runInBrowser=({code:e,builder:t,context:n,event:i,localState:r,rootSetState:o,rootState:a})=>{const s=getFunctionArguments({builder:t,context:n,event:i,state:flattenState(a,r,o)});return new Function(...s.map(([c])=>c),e)(...s.map(([,c])=>c))};function flattenState(e,t,n){if(e===t)throw new Error("rootState === localState");return new Proxy(e,{get:(i,r)=>t&&r in t?t[r]:e[r],set:(i,r,o)=>{if(t&&r in t)throw new Error("Writing to local state is not allowed as it is read-only.");return e[r]=o,n==null||n(e),!0}})}const set=(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((r,o,a)=>Object(r[o])===r[o]?r[o]:r[o]=Math.abs(Number(i[a+1]))>>0===+i[a+1]?[]:{},e)[i[i.length-1]]=n,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=node_module.createRequire(typeof document=="undefined"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.src||new URL("index.cjs",document.baseURI).href)}catch(error){try{safeDynamicRequire=eval("require")}catch(e){}}const ivm=safeDynamicRequire("isolated-vm"),getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
4
4
|
var refToProxy = (obj) => {
|
|
@@ -47,7 +47,7 @@ output;
|
|
|
47
47
|
${convertStyleMapToCSS(n)}
|
|
48
48
|
}`;return e?`${e} {
|
|
49
49
|
${i}
|
|
50
|
-
}`:i};function InlinedStyles(e){return jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function BlockStyles(e){function t(){const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return serverEntry.checkIsDefined(i.hide)?!i.hide:serverEntry.checkIsDefined(i.show)?i.show:!0}function n(){var f;const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0}),r=i.responsiveStyles,o=e.context.content,a=getSizesForBreakpoints(((f=o==null?void 0:o.meta)==null?void 0:f.breakpoints)||{}),s=r==null?void 0:r.large,c=r==null?void 0:r.medium,l=r==null?void 0:r.small,u=i.id;if(!u)return"";const g=s?createCssClass({className:u,styles:s}):"",b=c?createCssClass({className:u,styles:c,mediaQuery:getMaxWidthQueryForSize("medium",a)}):"",y=l?createCssClass({className:u,styles:l,mediaQuery:getMaxWidthQueryForSize("small",a)}):"";return[g,b,y].join(" ")}return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n()&&t()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedStyles,{styles:n()})}):null})}function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}const getEventHandlerName=e=>`on${capitalizeFirstLetter(e)}`,createEventHandler=(e,t)=>n=>evaluate({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:n,isExpression:!1});function getBlockActions(e){var i;const t={},n=(i=e.block.actions)!=null?i:{};for(const r in n){if(!n.hasOwnProperty(r))continue;const o=n[r];let a=getEventHandlerName(r);if(e.stripPrefix)switch(serverEntry.TARGET){case"
|
|
50
|
+
}`:i};function InlinedStyles(e){return jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:e.styles},id:e.id})}function BlockStyles(e){function t(){const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0});return serverEntry.checkIsDefined(i.hide)?!i.hide:serverEntry.checkIsDefined(i.show)?i.show:!0}function n(){var f;const i=getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0}),r=i.responsiveStyles,o=e.context.content,a=getSizesForBreakpoints(((f=o==null?void 0:o.meta)==null?void 0:f.breakpoints)||{}),s=r==null?void 0:r.large,c=r==null?void 0:r.medium,l=r==null?void 0:r.small,u=i.id;if(!u)return"";const g=s?createCssClass({className:u,styles:s}):"",b=c?createCssClass({className:u,styles:c,mediaQuery:getMaxWidthQueryForSize("medium",a)}):"",y=l?createCssClass({className:u,styles:l,mediaQuery:getMaxWidthQueryForSize("small",a)}):"";return[g,b,y].join(" ")}return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n()&&t()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(InlinedStyles,{styles:n()})}):null})}function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}const getEventHandlerName=e=>`on${capitalizeFirstLetter(e)}`,createEventHandler=(e,t)=>n=>evaluate({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:n,isExpression:!1});function getBlockActions(e){var i;const t={},n=(i=e.block.actions)!=null?i:{};for(const r in n){if(!n.hasOwnProperty(r))continue;const o=n[r];let a=getEventHandlerName(r);if(e.stripPrefix)switch(serverEntry.TARGET){case"vue":a=a.replace("v-on:","");break;case"svelte":a=a.replace("on:","");break}t[a]=createEventHandler(o,e)}return t}function transformBlockProperties({properties:e}){return e.className=e.class,delete e.class,e}const extractRelevantRootBlockProperties=e=>({href:e.href});function getBlockProperties({block:e,context:t}){var i;const n={...extractRelevantRootBlockProperties(e),...e.properties,"builder-id":e.id,style:e.style?getStyleAttribute(e.style):void 0,class:[e.id,"builder-block",e.class,(i=e.properties)==null?void 0:i.class].filter(Boolean).join(" ")};return transformBlockProperties({properties:n,context:t,block:e})}function getStyleAttribute(e){switch(serverEntry.TARGET){case"svelte":case"vue":case"solid":return convertStyleMapToCSSArray(e).join(" ");case"qwik":case"reactNative":case"react":case"rsc":return e}}function BlockWrapper(e){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" ",e.hasChildren?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(e.Wrapper,{...getBlockProperties({block:e.block,context:e.context}),...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," "]})}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(e.Wrapper,{...getBlockProperties({block:e.block,context:e.context}),...getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function InteractiveElement(e){return jsxRuntime.jsx(e.Wrapper,{...e.wrapperProps,attributes:e.includeBlockProps?{...getBlockProperties({block:e.block,context:e.context}),...getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})}:{},children:e.children})}const getWrapperProps=({componentOptions:e,builderBlock:t,context:n,componentRef:i,includeBlockProps:r,isInteractive:o,contextValue:a})=>{const s={...e,...r?{attributes:getBlockProperties({block:t,context:a})}:{}};return o?{Wrapper:i,block:t,context:n,wrapperProps:e,includeBlockProps:r}:s};function ComponentRef(e){var i,r;const[t,n]=react.useState(()=>e.isInteractive?InteractiveElement:e.componentRef);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.componentRef?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(t,{...getWrapperProps({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(o=>jsxRuntime.jsx(Block,{block:o,context:e.context,registeredComponents:e.registeredComponents},"block-"+o.id)),(r=e.blockChildren)==null?void 0:r.map(o=>jsxRuntime.jsx(BlockStyles,{block:o,context:e.context},"block-style-"+o.id))]})}):null})}function RepeatedBlock(e){const[t,n]=react.useState(()=>e.repeatContext);return jsxRuntime.jsx(builderContext.Provider,{value:t,children:jsxRuntime.jsx(Block,{block:e.block,context:t,registeredComponents:e.registeredComponents})})}function Block(e){var u,g,b,y;function t(){return getComponent({block:e.block,context:e.context,registeredComponents:e.registeredComponents})}function n(){return getRepeatItemData({block:e.block,context:e.context})}function i(){var f;return(f=e.block.repeat)!=null&&f.collection?e.block:getProcessedBlock({block:e.block,localState:e.context.localState,rootState:e.context.rootState,rootSetState:e.context.rootSetState,context:e.context.context,shouldEvaluateBindings:!0})}function r(){return e.block.tagName||"div"}function o(){var k,j;if((k=e.block.repeat)!=null&&k.collection)return!!((j=n==null?void 0:n())!=null&&j.length);const f="hide"in i()?i().hide:!1;return("show"in i()?i().show:!0)&&!f}function a(){var S,k;return!((S=t==null?void 0:t())!=null&&S.component)&&!n()?(k=i().children)!=null?k:[]:[]}function s(){var f,S,k,j,C,p;return{blockChildren:(f=i().children)!=null?f:[],componentRef:(S=t==null?void 0:t())==null?void 0:S.component,componentOptions:{...getBlockComponentOptions(i()),builderContext:e.context,...((k=t==null?void 0:t())==null?void 0:k.name)==="Symbol"||((j=t==null?void 0:t())==null?void 0:j.name)==="Columns"?{builderComponents:e.registeredComponents}:{}},context:c,registeredComponents:e.registeredComponents,builderBlock:i(),includeBlockProps:((C=t==null?void 0:t())==null?void 0:C.noWrap)===!0,isInteractive:!((p=t==null?void 0:t())!=null&&p.isRSC)}}const[c,l]=react.useState(()=>e.context);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:o()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(u=t==null?void 0:t())!=null&&u.noWrap?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(ComponentRef,{componentRef:s().componentRef,componentOptions:s().componentOptions,blockChildren:s().blockChildren,context:s().context,registeredComponents:s().registeredComponents,builderBlock:s().builderBlock,includeBlockProps:s().includeBlockProps,isInteractive:s().isInteractive})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[isEmptyHtmlElement(r())?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(BlockWrapper,{Wrapper:r(),block:i(),context:e.context,hasChildren:!1})}):null,!isEmptyHtmlElement(r())&&n()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:(g=n())==null?void 0:g.map((f,S)=>jsxRuntime.jsx(RepeatedBlock,{repeatContext:f.context,block:f.block,registeredComponents:e.registeredComponents},S))}):null,!isEmptyHtmlElement(r())&&!n()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(BlockWrapper,{Wrapper:r(),block:i(),context:e.context,hasChildren:!0,children:[jsxRuntime.jsx(ComponentRef,{componentRef:s().componentRef,componentOptions:s().componentOptions,blockChildren:s().blockChildren,context:s().context,registeredComponents:s().registeredComponents,builderBlock:s().builderBlock,includeBlockProps:s().includeBlockProps,isInteractive:s().isInteractive}),(b=a())==null?void 0:b.map(f=>jsxRuntime.jsx(Block,{block:f,context:c,registeredComponents:e.registeredComponents},"block-"+f.id)),(y=a())==null?void 0:y.map(f=>jsxRuntime.jsx(BlockStyles,{block:f,context:c},"block-style-"+f.id))]})}):null]})}):null})}function BlocksWrapper(e){function t(){var r;return"builder-blocks"+((r=e.blocks)!=null&&r.length?"":" no-blocks")}function n(){var r,o;serverEntry.isEditing()&&!((r=e.blocks)!=null&&r.length)&&((o=window.parent)==null||o.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function i(){var r,o;serverEntry.isEditing()&&!((r=e.blocks)!=null&&r.length)&&((o=window.parent)==null||o.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(e.BlocksWrapper,{className:t()+" props-blocks-wrapper-4f2c12d8","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:r=>n(),onMouseEnter:r=>i(),onKeyPress:r=>n(),...e.BlocksWrapperProps,children:e.children}),jsxRuntime.jsx("style",{children:`.props-blocks-wrapper-4f2c12d8 {
|
|
51
51
|
display: flex;
|
|
52
52
|
flex-direction: column;
|
|
53
53
|
align-items: stretch;
|
|
@@ -196,7 +196,7 @@ output;
|
|
|
196
196
|
"${t}",${JSON.stringify(e)}, ${isHydrationTarget}
|
|
197
197
|
)`,getUpdateVariantVisibilityScript=({contentId:e,variationId:t})=>`window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
198
198
|
"${t}", "${e}", ${isHydrationTarget}
|
|
199
|
-
)`;function InlinedScript(e){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function round(e){return Math.round(e*1e3)/1e3}const findParentElement=(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},findBuilderParent=e=>findParentElement(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),computeOffset=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=round(i/n.width),a=round(r/n.height);return{x:o,y:a}},getInteractionPropertiesForEvent=e=>{const t=e.target,n=t&&findBuilderParent(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?computeOffset({event:e,target:t}):void 0,builderTargetOffset:n?computeOffset({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},SDK_VERSION="0.
|
|
199
|
+
)`;function InlinedScript(e){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},id:e.id||""})}function round(e){return Math.round(e*1e3)/1e3}const findParentElement=(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},findBuilderParent=e=>findParentElement(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),computeOffset=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=round(i/n.width),a=round(r/n.height);return{x:o,y:a}},getInteractionPropertiesForEvent=e=>{const t=e.target,n=t&&findBuilderParent(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?computeOffset({event:e,target:t}):void 0,builderTargetOffset:n?computeOffset({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},SDK_VERSION="0.11.1",registerInsertMenu=()=>{serverEntry.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 isSetupForEditing=!1;const setupBrowserForEditing=(e={})=>{var t,n;isSetupForEditing||(isSetupForEditing=!0,serverEntry.isBrowser()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:serverEntry.TARGET,version:SDK_VERSION,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",({data:i})=>{var r,o;if(i!=null&&i.type)switch(i.type){case"builder.evaluate":{const a=i.data.text,s=i.data.arguments||[],c=i.data.id,l=new Function(a);let u,g=null;try{u=l.apply(null,s)}catch(b){g=b}g?(r=window.parent)==null||r.postMessage({type:"builder.evaluateError",data:{id:c,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(b=>{var y;(y=window.parent)==null||y.postMessage({type:"builder.evaluateResult",data:{id:c,result:b}},"*")}).catch(console.error):(o=window.parent)==null||o.postMessage({type:"builder.evaluateResult",data:{result:u,id:c}},"*");break}}})))};function EnableEditor(e){var T,w,P,A,F,_,V;const t=react.useRef(null),[n,i]=react.useState(()=>0);function r(d){var x,h,v,R,B;const m={...e.builderContextSignal.content,...d,data:{...(x=e.builderContextSignal.content)==null?void 0:x.data,...d==null?void 0:d.data},meta:{...(h=e.builderContextSignal.content)==null?void 0:h.meta,...d==null?void 0:d.meta,breakpoints:((v=d==null?void 0:d.meta)==null?void 0:v.breakpoints)||((B=(R=e.builderContextSignal.content)==null?void 0:R.meta)==null?void 0:B.breakpoints)}};e.setBuilderContextSignal(W=>({...W,content:m}))}react.useState(()=>0);const[o,a]=react.useState(()=>!1),[s,c]=react.useState(()=>e.contentWrapper||"div");function l(d){var x;const{data:m}=d;if(m)switch(m.type){case"builder.configureSdk":{const h=m.data,{breakpoints:v,contentId:R}=h;if(!R||R!==((x=e.builderContextSignal.content)==null?void 0:x.id))return;v&&r({meta:{breakpoints:v}}),i(n+1);break}case"builder.contentUpdate":{const h=m.data,v=h.key||h.alias||h.entry||h.modelName,R=h.data;v===e.model&&(r(R),i(n+1));break}}}function u(){var m,x;const d=(x=(m=e.builderContextSignal.content)==null?void 0:m.data)==null?void 0:x.jsCode;d&&evaluate({code:d,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[g,b]=react.useState(()=>({})),[y,f]=react.useState(()=>!1);function S(d){var m,x;if(e.builderContextSignal.content){const h=(m=e.builderContextSignal.content)==null?void 0:m.testVariationId,v=(x=e.builderContextSignal.content)==null?void 0:x.id;serverEntry._track({type:"click",canTrack:serverEntry.getDefaultCanTrack(e.canTrack),contentId:v,apiKey:e.apiKey,variationId:h!==v?h:void 0,...getInteractionPropertiesForEvent(d),unique:!y})}y||f(!0)}function k(d){return d.replace(/{{([^}]+)}}/g,(m,x)=>evaluate({code:x,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function j({url:d,key:m}){serverEntry.fetch(d).then(x=>x.json()).then(x=>{var v,R;const h={...e.builderContextSignal.rootState,[m]:x};(R=(v=e.builderContextSignal).rootSetState)==null||R.call(v,h),g[m]=!0}).catch(x=>{console.error("error fetching dynamic data",d,x)})}function C(){var m,x,h;const d=(h=(x=(m=e.builderContextSignal.content)==null?void 0:m.data)==null?void 0:x.httpRequests)!=null?h:{};Object.entries(d).forEach(([v,R])=>{if(R&&(!g[v]||serverEntry.isEditing())){const B=k(R);j({url:B,key:v})}})}function p(){serverEntry.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:serverEntry.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function E(d){i(n+1),window.addEventListener("message",l),registerInsertMenu(),setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(m=>{var h;const x=serverEntry.createRegisterComponentMessage(m);(h=window.parent)==null||h.postMessage(x,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",p)}function I(d){const m=new URL(location.href).searchParams,x=m.get("builder.preview"),h=m.get(`builder.preview.${x}`),v=m.get("apiKey")||m.get("builder.space");x===e.model&&v===e.apiKey&&(!e.content||h===e.content.id)&&serverEntry.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(R=>{R&&r(R)})}return react.useEffect(()=>{var d;return(d=t.current)==null||d.addEventListener("initeditingbldr",E),()=>{var m;return(m=t.current)==null?void 0:m.removeEventListener("initeditingbldr",E)}},[]),react.useEffect(()=>{var d;return(d=t.current)==null||d.addEventListener("initpreviewingbldr",I),()=>{var m;return(m=t.current)==null?void 0:m.removeEventListener("initpreviewingbldr",I)}},[]),react.useEffect(()=>{var d,m;if(serverEntry.isBrowser()){if(serverEntry.isEditing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&serverEntry.getDefaultCanTrack(e.canTrack)){const h=(d=e.builderContextSignal.content)==null?void 0:d.testVariationId,v=(m=e.builderContextSignal.content)==null?void 0:m.id,R=e.apiKey;serverEntry._track({type:"impression",canTrack:!0,contentId:v,apiKey:R,variationId:h!==v?h:void 0})}serverEntry.isPreviewing()&&t.current&&t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"))}},[]),react.useEffect(()=>{e.apiKey||serverEntry.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),u(),C(),p()},[]),react.useEffect(()=>{e.content&&r(e.content)},[e.content]),react.useEffect(()=>{},[o]),react.useEffect(()=>{u()},[(w=(T=e.builderContextSignal.content)==null?void 0:T.data)==null?void 0:w.jsCode,e.builderContextSignal.rootState]),react.useEffect(()=>{C()},[(A=(P=e.builderContextSignal.content)==null?void 0:P.data)==null?void 0:A.httpRequests]),react.useEffect(()=>{p()},[e.builderContextSignal.rootState]),react.useEffect(()=>()=>{serverEntry.isBrowser()&&(window.removeEventListener("message",l),window.removeEventListener("builder:component:stateChangeListenerActivated",p))},[]),jsxRuntime.jsx(builderContext.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?jsxRuntime.jsx(jsxRuntime.Fragment,{children:react.createElement(s,{key:n,ref:t,onClick:d=>S(d),"builder-content-id":(F=e.builderContextSignal.content)==null?void 0:F.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},...e.contentWrapperProps,className:`variant-${((_=e.content)==null?void 0:_.testVariationId)||((V=e.content)==null?void 0:V.id)}`},e.children)}):null})}const getCssFromFont=e=>{var o,a;const t=e.family+(e.kind&&!e.kind.includes("#")?", "+e.kind:""),n=t.split(",")[0],i=(a=e.fileUrl)!=null?a:(o=e==null?void 0:e.files)==null?void 0:o.regular;let r="";if(i&&t&&n&&(r+=`
|
|
200
200
|
@font-face {
|
|
201
201
|
font-family: "${t}";
|
|
202
202
|
src: local("${n}"), url('${i}') format('woff2');
|
package/lib/node/index.mjs
CHANGED
|
@@ -20,11 +20,11 @@ function Button(e) {
|
|
|
20
20
|
{
|
|
21
21
|
...e.attributes,
|
|
22
22
|
style: e.attributes.style,
|
|
23
|
-
className: e.attributes.className + " button-
|
|
23
|
+
className: e.attributes.className + " button-3ecc5438",
|
|
24
24
|
children: e.text
|
|
25
25
|
}
|
|
26
26
|
) }),
|
|
27
|
-
/* @__PURE__ */ jsx("style", { children: `.button-
|
|
27
|
+
/* @__PURE__ */ jsx("style", { children: `.button-3ecc5438 {
|
|
28
28
|
all: unset;
|
|
29
29
|
}` })
|
|
30
30
|
] });
|
|
@@ -477,8 +477,7 @@ function getBlockActions(e) {
|
|
|
477
477
|
let r = getEventHandlerName(o);
|
|
478
478
|
if (e.stripPrefix)
|
|
479
479
|
switch (TARGET) {
|
|
480
|
-
case "
|
|
481
|
-
case "vue3":
|
|
480
|
+
case "vue":
|
|
482
481
|
r = r.replace("v-on:", "");
|
|
483
482
|
break;
|
|
484
483
|
case "svelte":
|
|
@@ -518,8 +517,7 @@ function getBlockProperties({
|
|
|
518
517
|
function getStyleAttribute(e) {
|
|
519
518
|
switch (TARGET) {
|
|
520
519
|
case "svelte":
|
|
521
|
-
case "
|
|
522
|
-
case "vue3":
|
|
520
|
+
case "vue":
|
|
523
521
|
case "solid":
|
|
524
522
|
return convertStyleMapToCSSArray(e).join(" ");
|
|
525
523
|
case "qwik":
|
|
@@ -578,7 +576,7 @@ function InteractiveElement(e) {
|
|
|
578
576
|
e.Wrapper,
|
|
579
577
|
{
|
|
580
578
|
...e.wrapperProps,
|
|
581
|
-
attributes: {
|
|
579
|
+
attributes: e.includeBlockProps ? {
|
|
582
580
|
...getBlockProperties({
|
|
583
581
|
block: e.block,
|
|
584
582
|
context: e.context
|
|
@@ -590,7 +588,7 @@ function InteractiveElement(e) {
|
|
|
590
588
|
localState: e.context.localState,
|
|
591
589
|
context: e.context.context
|
|
592
590
|
})
|
|
593
|
-
},
|
|
591
|
+
} : {},
|
|
594
592
|
children: e.children
|
|
595
593
|
}
|
|
596
594
|
);
|
|
@@ -603,23 +601,27 @@ const getWrapperProps = ({
|
|
|
603
601
|
includeBlockProps: o,
|
|
604
602
|
isInteractive: a,
|
|
605
603
|
contextValue: r
|
|
606
|
-
}) =>
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
604
|
+
}) => {
|
|
605
|
+
const c = {
|
|
606
|
+
...e,
|
|
607
|
+
/**
|
|
608
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
609
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
610
|
+
*/
|
|
611
|
+
...o ? {
|
|
612
|
+
attributes: getBlockProperties({
|
|
613
|
+
block: t,
|
|
614
|
+
context: r
|
|
615
|
+
})
|
|
616
|
+
} : {}
|
|
617
|
+
};
|
|
618
|
+
return a ? {
|
|
619
|
+
Wrapper: i,
|
|
620
|
+
block: t,
|
|
621
|
+
context: n,
|
|
622
|
+
wrapperProps: e,
|
|
623
|
+
includeBlockProps: o
|
|
624
|
+
} : c;
|
|
623
625
|
};
|
|
624
626
|
function ComponentRef(e) {
|
|
625
627
|
var i, o;
|
|
@@ -2134,7 +2136,7 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2134
2136
|
builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
|
|
2135
2137
|
}
|
|
2136
2138
|
};
|
|
2137
|
-
}, SDK_VERSION = "0.
|
|
2139
|
+
}, SDK_VERSION = "0.11.1", registerInsertMenu = () => {
|
|
2138
2140
|
register("insertMenu", {
|
|
2139
2141
|
name: "_default",
|
|
2140
2142
|
default: !0,
|
package/package.json
CHANGED
|
@@ -3,10 +3,11 @@ export type InteractiveElementProps = {
|
|
|
3
3
|
Wrapper: any;
|
|
4
4
|
block: BuilderBlock;
|
|
5
5
|
context: BuilderContextInterface;
|
|
6
|
-
wrapperProps:
|
|
6
|
+
wrapperProps: Dictionary<any>;
|
|
7
|
+
includeBlockProps: boolean;
|
|
7
8
|
};
|
|
8
9
|
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
9
10
|
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
10
|
-
import type { PropsWithChildren } from "../../../types/typescript.js";
|
|
11
|
+
import type { Dictionary, PropsWithChildren } from "../../../types/typescript.js";
|
|
11
12
|
declare function InteractiveElement(props: PropsWithChildren<InteractiveElementProps>): React.JSX.Element;
|
|
12
13
|
export default InteractiveElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.11.1";
|
package/types/types/targets.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Target = '
|
|
1
|
+
export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
|