@gem-sdk/core 2.0.0-staging.781 → 2.0.0-staging.798
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";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js"),getResonsiveValue=require("./get-resonsive-value.js"),device=require("../constants/device.js");const isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,a=i,s=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&s&&s!=i&&(a=s),"FILE_CONTENT"===l&&o?.liquid&&a&&(r=`{{ "${a.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&a&&(r=`{{ "${a}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:t}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return device.DEVICES.forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:getResonsiveValue.getResponsiveValueByScreen(o,"desktop"),tablet:getResonsiveValue.getResponsiveValueByScreen(o,"tablet"),mobile:getResonsiveValue.getResponsiveValueByScreen(o,"mobile")},i={};return device.DEVICES.forEach(e=>{let l=getResonsiveValue.getResponsiveValueByScreen(t,e),r=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(i,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),r&&"none"!==r&&Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r})}),{...i,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o)}};exports.GRADIENT_BGR_KEY=GRADIENT_BGR_KEY,exports.composeBackgroundCss=composeBackgroundCss,exports.getBgByDevice=getBgByDevice,exports.getBgImageByDevice=getBgImageByDevice,exports.getBgVideoByDevice=getBgVideoByDevice,exports.getColor=getColor,exports.getGradientBgrStyleByDevice=getGradientBgrStyleByDevice,exports.getGradientBgrStyleForButton=getGradientBgrStyleForButton,exports.getStyleBackgroundByDevice=getStyleBackgroundByDevice,exports.getStyleBgColor=getStyleBgColor,exports.makeFixedBgAttachment=makeFixedBgAttachment;
|
|
1
|
+
"use strict";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js"),getResonsiveValue=require("./get-resonsive-value.js"),device=require("../constants/device.js");const isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,a=i,s=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&s&&s!=i&&(a=s),"FILE_CONTENT"===l&&o?.liquid&&a&&(r=`{{ "${a.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&a&&(r=`{{ "${a}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:t}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return device.DEVICES.forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:getResonsiveValue.getResponsiveValueByScreen(o,"desktop"),tablet:getResonsiveValue.getResponsiveValueByScreen(o,"tablet"),mobile:getResonsiveValue.getResponsiveValueByScreen(o,"mobile")},i={};return device.DEVICES.forEach(e=>{let l=getResonsiveValue.getResponsiveValueByScreen(t,e),r=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(i,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),r&&"none"!==r&&Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r})}),{...i,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o),...getStyleBgAttachment(o)}};exports.GRADIENT_BGR_KEY=GRADIENT_BGR_KEY,exports.composeBackgroundCss=composeBackgroundCss,exports.getBgByDevice=getBgByDevice,exports.getBgImageByDevice=getBgImageByDevice,exports.getBgVideoByDevice=getBgVideoByDevice,exports.getColor=getColor,exports.getGradientBgrStyleByDevice=getGradientBgrStyleByDevice,exports.getGradientBgrStyleForButton=getGradientBgrStyleForButton,exports.getStyleBackgroundByDevice=getStyleBackgroundByDevice,exports.getStyleBgColor=getStyleBgColor,exports.makeFixedBgAttachment=makeFixedBgAttachment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as o}from"./colors.js";import{makeStyleResponsive as g}from"./make-style.js";import{getResponsiveValueByScreen as i}from"./get-resonsive-value.js";import{DEVICES as l}from"../constants/device.js";let isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return g("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return g("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,B=i,a=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&a&&a!=i&&(B=a),"FILE_CONTENT"===l&&o?.liquid&&B&&(r=`{{ "${B.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&B&&(r=`{{ "${B}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return g("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return g("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return g("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return g("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${o(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,o)=>{let g=e[t]??"";return"fixed"===o?{wrapper:{[`--pos${g}`]:"absolute",[`--top${g}`]:"0",[`--left${g}`]:"0",[`--w${g}`]:"100%",[`--h${g}`]:"100%"},content:{[`--pos${g}`]:"fixed",[`--w${g}`]:"100vw",[`--h${g}`]:"100vh",[`--bga${g}`]:"unset"}}:{wrapper:{[`--pos${g}`]:"absolute"},content:{[`--w${g}`]:"100%",[`--h${g}`]:"100%",[`--pos${g}`]:"absolute",[`--bga${g}`]:o}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return l.forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:i(o,"desktop"),tablet:i(o,"tablet"),mobile:i(o,"mobile")},r={};return l.forEach(e=>{let l=i(t,e),B=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(r,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(r,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),B&&"none"!==B&&Object.assign(r,{[`--bgi${"desktop"!==e?"-"+e:""}`]:B})}),{...r,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o)}};export{GRADIENT_BGR_KEY,composeBackgroundCss,getBgByDevice,getBgImageByDevice,getBgVideoByDevice,getColor,getGradientBgrStyleByDevice,getGradientBgrStyleForButton,getStyleBackgroundByDevice,getStyleBgColor,makeFixedBgAttachment};
|
|
1
|
+
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as o}from"./colors.js";import{makeStyleResponsive as g}from"./make-style.js";import{getResponsiveValueByScreen as i}from"./get-resonsive-value.js";import{DEVICES as l}from"../constants/device.js";let isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return g("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return g("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,B=i,a=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&a&&a!=i&&(B=a),"FILE_CONTENT"===l&&o?.liquid&&B&&(r=`{{ "${B.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&B&&(r=`{{ "${B}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return g("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return g("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return g("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return g("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${o(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,o)=>{let g=e[t]??"";return"fixed"===o?{wrapper:{[`--pos${g}`]:"absolute",[`--top${g}`]:"0",[`--left${g}`]:"0",[`--w${g}`]:"100%",[`--h${g}`]:"100%"},content:{[`--pos${g}`]:"fixed",[`--w${g}`]:"100vw",[`--h${g}`]:"100vh",[`--bga${g}`]:"unset"}}:{wrapper:{[`--pos${g}`]:"absolute"},content:{[`--w${g}`]:"100%",[`--h${g}`]:"100%",[`--pos${g}`]:"absolute",[`--bga${g}`]:o}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return l.forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:i(o,"desktop"),tablet:i(o,"tablet"),mobile:i(o,"mobile")},r={};return l.forEach(e=>{let l=i(t,e),B=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(r,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(r,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),B&&"none"!==B&&Object.assign(r,{[`--bgi${"desktop"!==e?"-"+e:""}`]:B})}),{...r,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o),...getStyleBgAttachment(o)}};export{GRADIENT_BGR_KEY,composeBackgroundCss,getBgByDevice,getBgImageByDevice,getBgVideoByDevice,getColor,getGradientBgrStyleByDevice,getGradientBgrStyleForButton,getStyleBackgroundByDevice,getStyleBgColor,makeFixedBgAttachment};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -36495,8 +36495,8 @@ type Background = {
|
|
|
36495
36495
|
storage?: 'THEME' | 'FILE_CONTENT';
|
|
36496
36496
|
backupFilePath?: string;
|
|
36497
36497
|
};
|
|
36498
|
-
size?: BgSize
|
|
36499
|
-
position?: BgPosition
|
|
36498
|
+
size?: BgSize;
|
|
36499
|
+
position?: BgPosition;
|
|
36500
36500
|
repeat?: BgRepeat$2;
|
|
36501
36501
|
attachment?: BgAttachment$2;
|
|
36502
36502
|
video?: string;
|
|
@@ -36505,9 +36505,9 @@ type Background = {
|
|
|
36505
36505
|
loop?: boolean;
|
|
36506
36506
|
lazyLoad?: boolean;
|
|
36507
36507
|
};
|
|
36508
|
-
type BgSize
|
|
36508
|
+
type BgSize = 'cover' | 'contain' | '100% 100%';
|
|
36509
36509
|
type BgRepeat$2 = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
|
36510
|
-
type BgPosition
|
|
36510
|
+
type BgPosition = {
|
|
36511
36511
|
x: number;
|
|
36512
36512
|
y: number;
|
|
36513
36513
|
};
|
|
@@ -36967,12 +36967,12 @@ type ProductInputCurrencyUnitControlType<T> = SharedControlType<T> & {
|
|
|
36967
36967
|
type PostPurchaseFontSize = 'default' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
36968
36968
|
type PostPurchaseFontWeight = 'normal' | 'bold';
|
|
36969
36969
|
type PostPurchaseTextTransform = 'none' | 'uppercase' | 'capitalize' | 'lowercase';
|
|
36970
|
-
type
|
|
36970
|
+
type PostPurchaseDefaultTextColor = 'success' | 'warning' | 'critical' | 'default' | 'defaultButton' | 'defaultLink';
|
|
36971
36971
|
type PostPurchaseTypo = {
|
|
36972
36972
|
fontSize?: PostPurchaseFontSize;
|
|
36973
36973
|
fontWeight?: PostPurchaseFontWeight;
|
|
36974
36974
|
textTransform?: PostPurchaseTextTransform;
|
|
36975
|
-
textColor?:
|
|
36975
|
+
textColor?: PostPurchaseDefaultTextColor;
|
|
36976
36976
|
};
|
|
36977
36977
|
type PostPurchaseTypoLabel = {
|
|
36978
36978
|
fontSize?: string;
|
|
@@ -37235,8 +37235,8 @@ type BackgroundImageValue = {
|
|
|
37235
37235
|
storage?: 'THEME' | 'FILE_CONTENT';
|
|
37236
37236
|
backupFilePath?: string;
|
|
37237
37237
|
};
|
|
37238
|
-
size?: BgSize
|
|
37239
|
-
position?: BgPosition
|
|
37238
|
+
size?: BgSize;
|
|
37239
|
+
position?: BgPosition;
|
|
37240
37240
|
repeat?: BgRepeat$1;
|
|
37241
37241
|
attachment?: BgAttachment$1;
|
|
37242
37242
|
altText?: string;
|
|
@@ -37244,12 +37244,7 @@ type BackgroundImageValue = {
|
|
|
37244
37244
|
lazyLoad?: boolean;
|
|
37245
37245
|
preload?: boolean;
|
|
37246
37246
|
};
|
|
37247
|
-
type BgSize$1 = 'cover' | 'contain' | '100% 100%';
|
|
37248
37247
|
type BgRepeat$1 = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
|
37249
|
-
type BgPosition$1 = {
|
|
37250
|
-
x: number;
|
|
37251
|
-
y: number;
|
|
37252
|
-
};
|
|
37253
37248
|
type BgAttachment$1 = 'scroll' | 'fixed' | 'local';
|
|
37254
37249
|
|
|
37255
37250
|
type BackgroundVideoType<T> = SharedControlType<T> & {
|
|
@@ -37272,7 +37267,7 @@ type ShadowV2ControlType<T> = SharedControlType<T> & {
|
|
|
37272
37267
|
type BackgroundMediaControlType<T> = SharedControlType<T> & {
|
|
37273
37268
|
type: 'background-media';
|
|
37274
37269
|
value?: BackgroundMedia;
|
|
37275
|
-
showVideo?:
|
|
37270
|
+
showVideo?: boolean;
|
|
37276
37271
|
hideImage?: boolean;
|
|
37277
37272
|
};
|
|
37278
37273
|
type BackgroundMedia = {
|
|
@@ -37309,12 +37304,7 @@ type FallbackImageProps = {
|
|
|
37309
37304
|
backupFilePath?: string;
|
|
37310
37305
|
hiddenLCP?: boolean;
|
|
37311
37306
|
};
|
|
37312
|
-
type BgSize = 'cover' | 'contain';
|
|
37313
37307
|
type BgRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
|
37314
|
-
type BgPosition = {
|
|
37315
|
-
x: number;
|
|
37316
|
-
y: number;
|
|
37317
|
-
};
|
|
37318
37308
|
type BgAttachment = 'scroll' | 'fixed' | 'local';
|
|
37319
37309
|
|
|
37320
37310
|
type ImageV2ControlType<T> = SharedControlType<T> & {
|
|
@@ -37703,6 +37693,9 @@ declare const getBgByDevice: (data: {
|
|
|
37703
37693
|
backgroundColor: Partial<Record<NameDevices, string>> | undefined;
|
|
37704
37694
|
backgroundImage: Partial<Record<NameDevices, BackgroundImageValue>> | undefined;
|
|
37705
37695
|
}) => {
|
|
37696
|
+
"--bga": string;
|
|
37697
|
+
"--bga-tablet": string;
|
|
37698
|
+
"--bga-mobile": string;
|
|
37706
37699
|
"--bgr": string;
|
|
37707
37700
|
"--bgr-tablet": string;
|
|
37708
37701
|
"--bgr-mobile": string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "2.0.0-staging.
|
|
3
|
+
"version": "2.0.0-staging.798",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@gem-sdk/adapter-shopify": "2.0.0-staging.711",
|
|
31
|
-
"@gem-sdk/styles": "2.0.0-staging.
|
|
31
|
+
"@gem-sdk/styles": "2.0.0-staging.784",
|
|
32
32
|
"@types/classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|