@gem-sdk/core 1.14.0-dev.556 → 1.14.0-dev.563
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react");require("zustand");var BuilderPreviewContext=require("../../contexts/BuilderPreviewContext.js");function Spacing(e){let t=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),r=react.useRef(null),n=react.useRef(null),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react");require("zustand");var BuilderPreviewContext=require("../../contexts/BuilderPreviewContext.js");function Spacing(e){let t=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),r=react.useRef(null),n=react.useRef(null),a=react.useRef(null),i=react.useRef(!1),o=react.useRef(0),u=react.useRef(0),l=e=>{let t=e.clientY,r=Math.ceil(t-o.current),n=u.current||0,a=n+r>=0?`${n+r}px`:"0px";return{newValue:a}},s=e=>{if(r.current&&n.current){let{newValue:t}=l(e);n.current.style.height=t,r.current.style.top=t;let a=r.current.closest("[data-toolbar-wrap]");a&&(a.style.marginBottom=t)}},c=()=>{m()},d=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=!0;let e=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(e),document.addEventListener("mousemove",s),document.addEventListener("mouseup",c)},100)},m=()=>{a.current&&clearTimeout(a.current),i.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),r.current){let t=getComputedStyle(r.current),n=t.top,a=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:e.uid,marginBottom:n}});window.dispatchEvent(a)}let n=r.current?.closest("[data-toolbar-wrap]");n&&(n.style.marginBottom=""),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",c)},p=(e,t)=>{let r=e.children.length;if(r)for(let n=0;n<r;n++){let r=e.children[n];if(r){let e=r.getAttribute(t);if(e)return r}}},g=react.useCallback(e=>{if(i.current)return;let t=e.detail,a=r.current?.closest("[data-toolbar-wrap]"),o=a&&p(a,"data-toolbar"),u=o&&o.getAttribute("data-toolbar-active");if(u&&t?.marginBottom){let e=parseInt(t?.marginBottom),a=`${e}px`;r.current&&n.current&&(e<0?(n.current.style.display="none",r.current.style.display="none"):(n.current.style.display="block",r.current.style.display="block",n.current.style.height=a,r.current.style.top=a))}},[]),b=e=>{let t=e.getAttribute("data-component-tag");return"Dialog"===t},v=e=>{let t=e.getAttribute("data-component-tag");return"Sticky"===t},f=react.useCallback(e=>{let t=r.current?.closest("[data-toolbar-wrap]");if(t){if(b(t)||v(t))return;let a=t&&p(t,"data-toolbar"),i=a&&a.getAttribute("data-toolbar-active");if(i&&e){let t=isNaN(parseInt(e))?0:Math.max(parseInt(e),0),a=`-${t}px`,i=`translate(-${t}px, -100%)`;r.current&&n.current&&(n.current.style.left=a,r.current.style.transform=i)}}},[]),w=react.useCallback(e=>{if(i.current)return;let t=e.detail;t?.paddingLeft&&f(t.paddingLeft)},[f]);return react.useEffect(()=>{let e=r.current?.closest("[data-toolbar-wrap]");if(e){let t=getComputedStyle(e),r=t.paddingLeft;f(r)}}),react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",g),window.addEventListener("editor:toolbar:update-padding-left",w),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",g),window.removeEventListener("editor:toolbar:update-padding-left",w)}),[g,w]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Section"!==e.tag&&jsxRuntime.jsx("div",{"data-spacing":!0,"data-spacing-theme-section":t,className:"absolute w-full bottom-0",children:jsxRuntime.jsxs("div",{"data-spacing-margin-bottom":!0,children:[jsxRuntime.jsx("div",{"data-spacing-margin-bottom-bg":!0,ref:n,children:jsxRuntime.jsx("div",{"data-spacing-margin-bottom-value":!0})}),jsxRuntime.jsx("div",{ref:r,"data-spacing-margin-bottom-drag":!0,onMouseDown:e=>{if(r.current){let t=getComputedStyle(r.current);o.current=e.clientY,u.current=parseFloat(t.top),d()}},onMouseUp:()=>{m()},role:"presentation"})]})})})}require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("vanilla-lazyload"),require("../../hooks/useCartUI.js"),require("react-transition-group"),require("@gem-sdk/core"),require("../../helpers/convert.js"),exports.default=Spacing;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var borders=require("./borders.js"),colors=require("./colors.js"),constant=require("./constant.js"),makeStyle=require("./make-style.js"),radius=require("./radius.js"),shadow=require("./shadow.js");const composeSpacing=({source:e,spacing:s,type:o,suffix:a=""})=>{let{top:r,left:t,bottom:i,right:c}=s;r&&(e[`--${o}t${a}`]=r),t&&(e[`--${o}l${a}`]=t),i&&(e[`--${o}b${a}`]=i),c&&(e[`--${o}r${a}`]=c)},composeSpacingV2=({source:e,spacing:s,suffix:o=""})=>{if(s&&s.margin){let{top:a,left:r,bottom:t,right:i}=s.margin;a&&(e[`--mt${o}`]=a),r&&(e[`--ml${o}`]=r),t&&(e[`--mb${o}`]=t),i&&(e[`--mr${o}`]=i)}if(s&&s.padding){let{top:a,left:r,bottom:t,right:i}=s.padding;a&&(e[`--pt${o}`]=a),r&&(e[`--pl${o}`]=r),t&&(e[`--pb${o}`]=t),i&&(e[`--pr${o}`]=i)}},getAttrValue=(e,s,o)=>{if(null!=s)switch(e){case"bgc":case"c":return colors.isColor(s.toString())?s:`var(--g-c-${s})`;case"d":if(!s)return"none";if(s&&o&&constant.layoutComponent.includes(o))return"grid";return"block";default:return s}};function composeAdvanceStyle(e,s){if(!e)return{};let o={},a=["desktop","tablet","mobile"],r=["hover","normal"];return Object.keys(e).forEach(t=>{let i=e[t];if("cssClass"===t||null==i)return;let c=e.hasBoxShadow?e.hasBoxShadow:{};if("object"==typeof i){if(Array.isArray(i))return;Object.keys(i).forEach(d=>{if(a.includes(d)){let e=i[d];if(void 0!==e){if("border"===t&&Object.assign(o,borders.handleConvertBorderStyle(i),borders.handleConvertBorderWidth(i),borders.handleConvertBorderColor(i)),"rounded"===t&&Object.assign(o,radius.composeRadius(i)),"desktop"===d)switch(t){case"padding":composeSpacing({source:o,spacing:e,type:"p"});break;case"margin":composeSpacing({source:o,spacing:e,type:"m"});break;case"spacing-setting":composeSpacingV2({source:o,spacing:e});break;case"m":case"p":break;default:o[`--${t}`]=getAttrValue(t,e,s)}else switch(t){case"padding":composeSpacing({source:o,spacing:e,type:"p",suffix:`-${d}`});break;case"margin":composeSpacing({source:o,spacing:e,type:"m",suffix:`-${d}`});break;case"spacing-setting":composeSpacingV2({source:o,spacing:e,suffix:`-${d}`});break;case"m":case"p":break;default:o[`--${t}-${d}`]=getAttrValue(t,e,s)}}}else if(r.includes(d))switch(t){case"hasBoxShadow":break;case"boxShadow":Object.assign(o,shadow.getStyleShadowState(i,"box-shadow",c))}else"border"===t&&("none"===i.border&&(i.border="solid",i.color="#121212",i.isCustom=!0,i.width="0px",i.position="all"),Object.assign(o,borders.getBorderStyle(i))),"rounded"===t&&Object.assign(o,radius.getCornerCSSFromGlobal(i)),"hasBoxShadow"===t&&Object.assign(o,shadow.getStyleShadow({value:e.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow})),"boxShadow"===t&&Object.assign(o,shadow.getStyleShadow({value:i,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow}))})}else o[`--${t}`]=getAttrValue(t,i,s),"hasBoxShadow"===t&&e.boxShadow&&Object.assign(o,shadow.getStyleShadow({value:e.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow}))}),o}const splitStyle=(e,s={})=>{let o=e.map(e=>makeStyle.makeStyleKey(e)).flat(),a=Object.keys(s).filter(e=>o.includes(e)),r=a.reduce((e,o)=>({...e,[o]:s[o]}),{}),t=Object.keys(s).filter(e=>!a.includes(e)).reduce((e,o)=>({...e,[o]:s[o]}),{});return[r,t]};exports.composeAdvanceStyle=composeAdvanceStyle,exports.splitStyle=splitStyle;
|
|
1
|
+
"use strict";var borders=require("./borders.js"),colors=require("./colors.js"),constant=require("./constant.js"),makeStyle=require("./make-style.js"),radius=require("./radius.js"),shadow=require("./shadow.js");const composeSpacing=({source:e,spacing:s,type:o,suffix:a=""})=>{let{top:r,left:t,bottom:i,right:c}=s;r&&(e[`--${o}t${a}`]=r),t&&(e[`--${o}l${a}`]=t),i&&(e[`--${o}b${a}`]=i),c&&(e[`--${o}r${a}`]=c)},composeSpacingV2=({source:e,spacing:s,suffix:o=""})=>{if(s&&s.margin){let{top:a,left:r,bottom:t,right:i}=s.margin;a&&(e[`--mt${o}`]=a),r&&(e[`--ml${o}`]="0px"===r?"auto":r),t&&(e[`--mb${o}`]=t),i&&(e[`--mr${o}`]="0px"===i?"auto":i)}if(s&&s.padding){let{top:a,left:r,bottom:t,right:i}=s.padding;a&&(e[`--pt${o}`]=a),r&&(e[`--pl${o}`]=r),t&&(e[`--pb${o}`]=t),i&&(e[`--pr${o}`]=i)}},getAttrValue=(e,s,o)=>{if(null!=s)switch(e){case"bgc":case"c":return colors.isColor(s.toString())?s:`var(--g-c-${s})`;case"d":if(!s)return"none";if(s&&o&&constant.layoutComponent.includes(o))return"grid";return"block";default:return s}};function composeAdvanceStyle(e,s){if(!e)return{};let o={},a=["desktop","tablet","mobile"],r=["hover","normal"];return Object.keys(e).forEach(t=>{let i=e[t];if("cssClass"===t||null==i)return;let c=e.hasBoxShadow?e.hasBoxShadow:{};if("object"==typeof i){if(Array.isArray(i))return;Object.keys(i).forEach(d=>{if(a.includes(d)){let e=i[d];if(void 0!==e){if("border"===t&&Object.assign(o,borders.handleConvertBorderStyle(i),borders.handleConvertBorderWidth(i),borders.handleConvertBorderColor(i)),"rounded"===t&&Object.assign(o,radius.composeRadius(i)),"desktop"===d)switch(t){case"padding":composeSpacing({source:o,spacing:e,type:"p"});break;case"margin":composeSpacing({source:o,spacing:e,type:"m"});break;case"spacing-setting":composeSpacingV2({source:o,spacing:e});break;case"m":case"p":break;default:o[`--${t}`]=getAttrValue(t,e,s)}else switch(t){case"padding":composeSpacing({source:o,spacing:e,type:"p",suffix:`-${d}`});break;case"margin":composeSpacing({source:o,spacing:e,type:"m",suffix:`-${d}`});break;case"spacing-setting":composeSpacingV2({source:o,spacing:e,suffix:`-${d}`});break;case"m":case"p":break;default:o[`--${t}-${d}`]=getAttrValue(t,e,s)}}}else if(r.includes(d))switch(t){case"hasBoxShadow":break;case"boxShadow":Object.assign(o,shadow.getStyleShadowState(i,"box-shadow",c))}else"border"===t&&("none"===i.border&&(i.border="solid",i.color="#121212",i.isCustom=!0,i.width="0px",i.position="all"),Object.assign(o,borders.getBorderStyle(i))),"rounded"===t&&Object.assign(o,radius.getCornerCSSFromGlobal(i)),"hasBoxShadow"===t&&Object.assign(o,shadow.getStyleShadow({value:e.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow})),"boxShadow"===t&&Object.assign(o,shadow.getStyleShadow({value:i,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow}))})}else o[`--${t}`]=getAttrValue(t,i,s),"hasBoxShadow"===t&&e.boxShadow&&Object.assign(o,shadow.getStyleShadow({value:e.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:e.hasBoxShadow}))}),o}const splitStyle=(e,s={})=>{let o=e.map(e=>makeStyle.makeStyleKey(e)).flat(),a=Object.keys(s).filter(e=>o.includes(e)),r=a.reduce((e,o)=>({...e,[o]:s[o]}),{}),t=Object.keys(s).filter(e=>!a.includes(e)).reduce((e,o)=>({...e,[o]:s[o]}),{});return[r,t]};exports.composeAdvanceStyle=composeAdvanceStyle,exports.splitStyle=splitStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as o,useCallback as n,useEffect as
|
|
1
|
+
import{jsx as t,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as o,useCallback as n,useEffect as a}from"react";import"zustand";import{useBuilderPreviewStore as i}from"../../contexts/BuilderPreviewContext.js";import"swr";import"@gem-sdk/adapter-shopify";import"swr/mutation";import"vanilla-lazyload";import"../../hooks/useCartUI.js";import"react-transition-group";import"@gem-sdk/core";import"../../helpers/convert.js";function Spacing(l){let u=i(t=>t.isThemeSectionEditor),d=o(null),c=o(null),s=o(null),m=o(!1),p=o(0),g=o(0),b=t=>{let e=t.clientY,r=Math.ceil(e-p.current),o=g.current||0,n=o+r>=0?`${o+r}px`:"0px";return{newValue:n}},v=t=>{if(d.current&&c.current){let{newValue:e}=b(t);c.current.style.height=e,d.current.style.top=e;let r=d.current.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=e)}},f=()=>{h()},w=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{m.current=!0;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(t),document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)},100)},h=()=>{s.current&&clearTimeout(s.current),m.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),d.current){let t=getComputedStyle(d.current),e=t.top,r=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:l.uid,marginBottom:e}});window.dispatchEvent(r)}let e=d.current?.closest("[data-toolbar-wrap]");e&&(e.style.marginBottom=""),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f)},y=(t,e)=>{let r=t.children.length;if(r)for(let o=0;o<r;o++){let r=t.children[o];if(r){let t=r.getAttribute(e);if(t)return r}}},E=n(t=>{if(m.current)return;let e=t.detail,r=d.current?.closest("[data-toolbar-wrap]"),o=r&&y(r,"data-toolbar"),n=o&&o.getAttribute("data-toolbar-active");if(n&&e?.marginBottom){let t=parseInt(e?.marginBottom),r=`${t}px`;d.current&&c.current&&(t<0?(c.current.style.display="none",d.current.style.display="none"):(c.current.style.display="block",d.current.style.display="block",c.current.style.height=r,d.current.style.top=r))}},[]),L=t=>{let e=t.getAttribute("data-component-tag");return"Dialog"===e},x=t=>{let e=t.getAttribute("data-component-tag");return"Sticky"===e},C=n(t=>{let e=d.current?.closest("[data-toolbar-wrap]");if(e){if(L(e)||x(e))return;let r=e&&y(e,"data-toolbar"),o=r&&r.getAttribute("data-toolbar-active");if(o&&t){let e=isNaN(parseInt(t))?0:Math.max(parseInt(t),0),r=`-${e}px`,o=`translate(-${e}px, -100%)`;d.current&&c.current&&(c.current.style.left=r,d.current.style.transform=o)}}},[]),S=n(t=>{if(m.current)return;let e=t.detail;e?.paddingLeft&&C(e.paddingLeft)},[C]);return a(()=>{let t=d.current?.closest("[data-toolbar-wrap]");if(t){let e=getComputedStyle(t),r=e.paddingLeft;C(r)}}),a(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",E),window.addEventListener("editor:toolbar:update-padding-left",S),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",E),window.removeEventListener("editor:toolbar:update-padding-left",S)}),[E,S]),t(e,{children:"Section"!==l.tag&&t("div",{"data-spacing":!0,"data-spacing-theme-section":u,className:"absolute w-full bottom-0",children:r("div",{"data-spacing-margin-bottom":!0,children:[t("div",{"data-spacing-margin-bottom-bg":!0,ref:c,children:t("div",{"data-spacing-margin-bottom-value":!0})}),t("div",{ref:d,"data-spacing-margin-bottom-drag":!0,onMouseDown:t=>{if(d.current){let e=getComputedStyle(d.current);p.current=t.clientY,g.current=parseFloat(e.top),w()}},onMouseUp:()=>{h()},role:"presentation"})]})})})}export{Spacing as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleConvertBorderStyle as e,handleConvertBorderWidth as s,handleConvertBorderColor as a,getBorderStyle as o}from"./borders.js";import{isColor as t}from"./colors.js";import{layoutComponent as r}from"./constant.js";import{makeStyleKey as i}from"./make-style.js";import{composeRadius as c,getCornerCSSFromGlobal as n}from"./radius.js";import{getStyleShadowState as l,getStyleShadow as p}from"./shadow.js";let composeSpacing=({source:e,spacing:s,type:a,suffix:o=""})=>{let{top:t,left:r,bottom:i,right:c}=s;t&&(e[`--${a}t${o}`]=t),r&&(e[`--${a}l${o}`]=r),i&&(e[`--${a}b${o}`]=i),c&&(e[`--${a}r${o}`]=c)},composeSpacingV2=({source:e,spacing:s,suffix:a=""})=>{if(s&&s.margin){let{top:o,left:t,bottom:r,right:i}=s.margin;o&&(e[`--mt${a}`]=o),t&&(e[`--ml${a}`]=t),r&&(e[`--mb${a}`]=r),i&&(e[`--mr${a}`]=i)}if(s&&s.padding){let{top:o,left:t,bottom:r,right:i}=s.padding;o&&(e[`--pt${a}`]=o),t&&(e[`--pl${a}`]=t),r&&(e[`--pb${a}`]=r),i&&(e[`--pr${a}`]=i)}},getAttrValue=(e,s,a)=>{if(null!=s)switch(e){case"bgc":case"c":return t(s.toString())?s:`var(--g-c-${s})`;case"d":if(!s)return"none";if(s&&a&&r.includes(a))return"grid";return"block";default:return s}};function composeAdvanceStyle(t,r){if(!t)return{};let i={},d=["desktop","tablet","mobile"],b=["hover","normal"];return Object.keys(t).forEach(u=>{let g=t[u];if("cssClass"===u||null==g)return;let m=t.hasBoxShadow?t.hasBoxShadow:{};if("object"==typeof g){if(Array.isArray(g))return;Object.keys(g).forEach(h=>{if(d.includes(h)){let o=g[h];if(void 0!==o){if("border"===u&&Object.assign(i,e(g),s(g),a(g)),"rounded"===u&&Object.assign(i,c(g)),"desktop"===h)switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p"});break;case"margin":composeSpacing({source:i,spacing:o,type:"m"});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o});break;case"m":case"p":break;default:i[`--${u}`]=getAttrValue(u,o,r)}else switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p",suffix:`-${h}`});break;case"margin":composeSpacing({source:i,spacing:o,type:"m",suffix:`-${h}`});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o,suffix:`-${h}`});break;case"m":case"p":break;default:i[`--${u}-${h}`]=getAttrValue(u,o,r)}}}else if(b.includes(h))switch(u){case"hasBoxShadow":break;case"boxShadow":Object.assign(i,l(g,"box-shadow",m))}else"border"===u&&("none"===g.border&&(g.border="solid",g.color="#121212",g.isCustom=!0,g.width="0px",g.position="all"),Object.assign(i,o(g))),"rounded"===u&&Object.assign(i,n(g)),"hasBoxShadow"===u&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow})),"boxShadow"===u&&Object.assign(i,p({value:g,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))})}else i[`--${u}`]=getAttrValue(u,g,r),"hasBoxShadow"===u&&t.boxShadow&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))}),i}let splitStyle=(e,s={})=>{let a=e.map(e=>i(e)).flat(),o=Object.keys(s).filter(e=>a.includes(e)),t=o.reduce((e,a)=>({...e,[a]:s[a]}),{}),r=Object.keys(s).filter(e=>!o.includes(e)).reduce((e,a)=>({...e,[a]:s[a]}),{});return[t,r]};export{composeAdvanceStyle,splitStyle};
|
|
1
|
+
import{handleConvertBorderStyle as e,handleConvertBorderWidth as s,handleConvertBorderColor as a,getBorderStyle as o}from"./borders.js";import{isColor as t}from"./colors.js";import{layoutComponent as r}from"./constant.js";import{makeStyleKey as i}from"./make-style.js";import{composeRadius as c,getCornerCSSFromGlobal as n}from"./radius.js";import{getStyleShadowState as l,getStyleShadow as p}from"./shadow.js";let composeSpacing=({source:e,spacing:s,type:a,suffix:o=""})=>{let{top:t,left:r,bottom:i,right:c}=s;t&&(e[`--${a}t${o}`]=t),r&&(e[`--${a}l${o}`]=r),i&&(e[`--${a}b${o}`]=i),c&&(e[`--${a}r${o}`]=c)},composeSpacingV2=({source:e,spacing:s,suffix:a=""})=>{if(s&&s.margin){let{top:o,left:t,bottom:r,right:i}=s.margin;o&&(e[`--mt${a}`]=o),t&&(e[`--ml${a}`]="0px"===t?"auto":t),r&&(e[`--mb${a}`]=r),i&&(e[`--mr${a}`]="0px"===i?"auto":i)}if(s&&s.padding){let{top:o,left:t,bottom:r,right:i}=s.padding;o&&(e[`--pt${a}`]=o),t&&(e[`--pl${a}`]=t),r&&(e[`--pb${a}`]=r),i&&(e[`--pr${a}`]=i)}},getAttrValue=(e,s,a)=>{if(null!=s)switch(e){case"bgc":case"c":return t(s.toString())?s:`var(--g-c-${s})`;case"d":if(!s)return"none";if(s&&a&&r.includes(a))return"grid";return"block";default:return s}};function composeAdvanceStyle(t,r){if(!t)return{};let i={},d=["desktop","tablet","mobile"],b=["hover","normal"];return Object.keys(t).forEach(u=>{let g=t[u];if("cssClass"===u||null==g)return;let m=t.hasBoxShadow?t.hasBoxShadow:{};if("object"==typeof g){if(Array.isArray(g))return;Object.keys(g).forEach(h=>{if(d.includes(h)){let o=g[h];if(void 0!==o){if("border"===u&&Object.assign(i,e(g),s(g),a(g)),"rounded"===u&&Object.assign(i,c(g)),"desktop"===h)switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p"});break;case"margin":composeSpacing({source:i,spacing:o,type:"m"});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o});break;case"m":case"p":break;default:i[`--${u}`]=getAttrValue(u,o,r)}else switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p",suffix:`-${h}`});break;case"margin":composeSpacing({source:i,spacing:o,type:"m",suffix:`-${h}`});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o,suffix:`-${h}`});break;case"m":case"p":break;default:i[`--${u}-${h}`]=getAttrValue(u,o,r)}}}else if(b.includes(h))switch(u){case"hasBoxShadow":break;case"boxShadow":Object.assign(i,l(g,"box-shadow",m))}else"border"===u&&("none"===g.border&&(g.border="solid",g.color="#121212",g.isCustom=!0,g.width="0px",g.position="all"),Object.assign(i,o(g))),"rounded"===u&&Object.assign(i,n(g)),"hasBoxShadow"===u&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow})),"boxShadow"===u&&Object.assign(i,p({value:g,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))})}else i[`--${u}`]=getAttrValue(u,g,r),"hasBoxShadow"===u&&t.boxShadow&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))}),i}let splitStyle=(e,s={})=>{let a=e.map(e=>i(e)).flat(),o=Object.keys(s).filter(e=>a.includes(e)),t=o.reduce((e,a)=>({...e,[a]:s[a]}),{}),r=Object.keys(s).filter(e=>!o.includes(e)).reduce((e,a)=>({...e,[a]:s[a]}),{});return[t,r]};export{composeAdvanceStyle,splitStyle};
|