@gem-sdk/core 5.0.0 → 7.0.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.
@@ -1 +1 @@
1
- "use strict";var useSWR=require("swr"),getCollection=require("./queries/get-collection.js"),getProduct=require("./queries/get-product.js"),getProducts=require("./queries/get-products.js"),query=require("./query.js");const prefetchQueries=(e,t)=>{let r=[];return Object.keys(e).forEach(s=>{let u;let o=e[s];switch(o.tag){case"Product":{if(o.settings?.isAuto)break;let e={id:o.settings?.productSetting?.productId??"latest",isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductQueryKey(e)),func:getProduct.getProduct,variables:e};break}case"ProductList":{let e=o.settings?.productSetting;if(e?.productSrc==="Collection"){let r={id:e?.collectionId??"latest",numberOfProducts:o.settings?.numberOfProducts??4,orderBy:o.settings?.orderBy,isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateCollectionQueryKey(r)),func:getCollection.getCollection,variables:r}}else{let r={ids:[...e?.productIds??[]].sort(),isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductsQueryKey(r)),func:getProducts.getProducts,variables:r}}}}u&&r.push(u)}),r.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};exports.prefetchQueries=prefetchQueries;
1
+ "use strict";var useSWR=require("swr"),getCollection=require("./queries/get-collection.js"),getProduct=require("./queries/get-product.js"),getProducts=require("./queries/get-products.js"),query=require("./query.js");const prefetchQueries=(e,t)=>{let r=[];return Object.keys(e).forEach(s=>{let u;let o=e[s];switch(o.tag){case"Product":{if(o.settings?.isAuto)break;let e={id:o.settings?.productSetting?.productId??"latest",isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductQueryKey(e)),func:getProduct.getProduct,variables:e};break}case"ProductList":case"ProductListV3":{let e=o.settings?.productSetting;if(e?.productSrc==="Collection"){let r={id:e?.collectionId??"latest",numberOfProducts:o.settings?.numberOfProducts??4,orderBy:o.settings?.orderBy,isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateCollectionQueryKey(r)),func:getCollection.getCollection,variables:r}}else{let r={ids:[...e?.productIds??[]].sort(),isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductsQueryKey(r)),func:getProducts.getProducts,variables:r}}}}u&&r.push(u)}),r.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};exports.prefetchQueries=prefetchQueries;
@@ -1,19 +1,19 @@
1
- "use strict";var colors=require("./colors.js"),makeStyle=require("./make-style.js");const genTypoClass=e=>`gp-g-${e}`,composeTypographyCss=e=>{let o=e?.custom,{fontFamily:t,fontSize:p,fontStyle:s,fontWeight:a,lineHeight:y,letterSpacing:l}=o?.desktop??{};return`
1
+ "use strict";var device=require("../constants/device.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js");const genTypoClass=e=>`gp-g-${e}`,composeTypographyCss=e=>{let o=e?.custom,{fontFamily:t,fontSize:p,fontStyle:s,fontWeight:a,lineHeight:r,letterSpacing:y}=o?.desktop??{};return`
2
2
  ${t?`fontFamily: ${composeFontFamilyTypographyV2({fontFamily:t})};`:""}
3
3
  ${p?`font-size: ${p};`:""}
4
4
  ${s?`font-style: ${s};`:""}
5
5
  ${a?`font-weight: ${a};`:""}
6
- ${l?`letter-spacing: ${l};`:""}
7
- ${y?`line-height: ${y};`:""}
8
- `},composeTypographyV2Css=(e,o)=>{let t=e?.custom,{fontFamily:p,fontSize:s,fontWeight:a,lineHeight:y,letterSpacing:l,textShadow:r,hasShadowText:n}=t??{},i=e?.attrs,m=r&&"none"!==r.type&&!1!==r.enable,{bold:c,italic:g,underline:h,transform:$,color:f}=i??{},T=o?"!important":"";return`
9
- ${p?`font-family: ${composeFontFamilyTypographyV2({fontFamily:p,type:e?.type})} ${T}`:""};
10
- ${s?.desktop?`font-size: ${s?.desktop} ${T}`:""};
11
- ${f?`color: ${colors.getSingleColorVariable(f)} ${T}`:""};
12
- ${c?`font-weight: bold ${T}`:a?`font-weight: ${a} ${T}`:""};
13
- ${l?.desktop?`letter-spacing: ${l?.desktop} ${T}`:""};
14
- ${y?.desktop?`line-height: ${y?.desktop} ${T}`:""};
15
- ${g?`font-style: italic ${T}`:""};
16
- ${h?`text-decoration-line: underline ${T}`:""};
17
- ${$?`text-transform: ${$} ${T}`:""};
18
- ${m&&n?`text-shadow: ${composeTextShadowCss(r||{})}`:"none"};
19
- `},composeTextShadowCss=e=>{let o="number"==typeof e?.angle?e?.angle:0,t=o*Math.PI/180,p=parseFloat(e?.distance??"0");if(isNaN(p))return"none";let s=Math.round(Math.cos(t)*p*100)/100,a=Math.round(Math.sin(t)*p*100)/100;return`${s}px ${a}px ${e?.blur??"0"} ${e.color}`},composeTextHoverColorCss=(e,o)=>{if(e){let t=o?"!important":"",p=colors.getSingleColorVariable(e.hover);return`${p?`color: ${p} ${t}`:""}`}};function getCustomCSSByDevice(e,o){if(!e||!o)return{};let t="desktop"!==o&&o?`-${o}`:"",{fontFamily:p}=e?.[o]??{};return{[`--size${t}`]:e?.[o]?.fontSize,[`--lh${t}`]:e?.[o]?.lineHeight,[`--fs${t}`]:e?.[o]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:e?.[o]?.fontWeight,[`--ls${t}`]:e?.[o]?.letterSpacing}}const composeTypography=e=>e?makeStyle.removeNullUndefined({...getCustomCSSByDevice(e,"desktop"),...getCustomCSSByDevice(e,"tablet"),...getCustomCSSByDevice(e,"mobile")}):{},composeTypographyV2=(e,o)=>e?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:o?.italic?void 0:e?.fontStyle,ff:composeFontFamilyTypographyV2(e),weight:o?.bold?void 0:e?.fontWeight}),...makeStyle.makeStyleResponsive("size",e?.fontSize),...makeStyle.makeStyleResponsive("lh",e?.lineHeight),...makeStyle.makeStyleResponsive("ls",e?.letterSpacing)}):{},composeFontFamilyTypographyV2=e=>{let{fontFamily:o,isCustom:t,fallbackFontFamily:p,type:s}=e||{};if(!o)return t?p:void 0;if("string"==typeof o)return getFontUsedByTypographyV2({fontFamily:o,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")});if("object"==typeof o&&"string"==typeof o?.value){if("theme"===o.type){let e=o?.value.includes("--g-theme-font")?`var(${o?.value})`:o?.value;return`${e}, var(--g-font-body)`}return getFontUsedByTypographyV2({fontFamily:o.value,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")})}},getFontUsedByTypographyV2=({fontFamily:e,fallbackFontFamily:o})=>{if(e)return`var(--g-font-${e?.replace(/ /g,"-")}, '${e}'), ${o}`},composeTypographyAttr=e=>e?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:e?.italic?"italic":void 0,weight:e?.bold?"bold":void 0,c:colors.getSingleColorVariable(e?.color),tt:e?.transform,tdl:e?.underline?"underline":void 0})}):{},composeTypographyClassName=(e,o)=>e?e?.type&&!isCustomTypo(e.custom)?genTypoClass(e.type):"":o?.type&&genTypoClass(o?.type),composeFallbackTypographyStyle=e=>e.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(e,o,t)=>{if(e){let o=composeFallbackTypographyStyle(e.type??"heading"),p={...e.custom,fallbackFontFamily:o,isCustom:isCustomTypo(e.custom)};return{...composeTypographyV2(p,e.attrs),...!t&&composeTypographyAttr(e.attrs)}}return{...o?.type?{}:composeTypography(o?.custom)}},isCustomTypo=e=>e&&Object.keys(e).length>1||e&&1===Object.keys(e).length&&!e.fontSize;exports.composeFallbackTypographyStyle=composeFallbackTypographyStyle,exports.composeFontFamilyTypographyV2=composeFontFamilyTypographyV2,exports.composeTextHoverColorCss=composeTextHoverColorCss,exports.composeTypography=composeTypography,exports.composeTypographyAttr=composeTypographyAttr,exports.composeTypographyClassName=composeTypographyClassName,exports.composeTypographyCss=composeTypographyCss,exports.composeTypographyStyle=composeTypographyStyle,exports.composeTypographyV2=composeTypographyV2,exports.composeTypographyV2Css=composeTypographyV2Css,exports.genTypoClass=genTypoClass;
6
+ ${y?`letter-spacing: ${y};`:""}
7
+ ${r?`line-height: ${r};`:""}
8
+ `},composeTypographyV2Css=(e,o)=>{let t=e?.custom,{fontFamily:p,fontSize:s,fontWeight:a,lineHeight:r,letterSpacing:y,textShadow:l,hasShadowText:n}=t??{},i=e?.attrs,c=l&&"none"!==l.type&&!1!==l.enable,{bold:m,italic:g,underline:h,transform:$,color:d}=i??{},f=o?"!important":"";return`
9
+ ${p?`font-family: ${composeFontFamilyTypographyV2({fontFamily:p,type:e?.type})} ${f}`:""};
10
+ ${s?.desktop?`font-size: ${s?.desktop} ${f}`:""};
11
+ ${d?`color: ${colors.getSingleColorVariable(d)} ${f}`:""};
12
+ ${m?`font-weight: bold ${f}`:a?`font-weight: ${a} ${f}`:""};
13
+ ${y?.desktop?`letter-spacing: ${y?.desktop} ${f}`:""};
14
+ ${r?.desktop?`line-height: ${r?.desktop} ${f}`:""};
15
+ ${g?`font-style: italic ${f}`:""};
16
+ ${h?`text-decoration-line: underline ${f}`:""};
17
+ ${$?`text-transform: ${$} ${f}`:""};
18
+ ${c&&n?`text-shadow: ${composeTextShadowCss(l||{})}`:"none"};
19
+ `},composeTextShadowCss=e=>{let o="number"==typeof e?.angle?e?.angle:0,t=o*Math.PI/180,p=parseFloat(e?.distance??"0");if(isNaN(p))return"none";let s=Math.round(Math.cos(t)*p*100)/100,a=Math.round(Math.sin(t)*p*100)/100;return`${s}px ${a}px ${e?.blur??"0"} ${e.color}`},composeTextHoverColorCss=(e,o)=>{if(e){let t=o?"!important":"",p=colors.getSingleColorVariable(e.hover);return`${p?`color: ${p} ${t}`:""}`}};function getCustomCSSByDevice(e,o){if(!e||!o)return{};let t="desktop"!==o&&o?`-${o}`:"",{fontFamily:p}=e?.[o]??{};return{[`--size${t}`]:e?.[o]?.fontSize,[`--lh${t}`]:e?.[o]?.lineHeight,[`--fs${t}`]:e?.[o]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:e?.[o]?.fontWeight,[`--ls${t}`]:e?.[o]?.letterSpacing}}const composeTypography=e=>e?makeStyle.removeNullUndefined({...getCustomCSSByDevice(e,"desktop"),...getCustomCSSByDevice(e,"tablet"),...getCustomCSSByDevice(e,"mobile")}):{},convertPercentToEmLetterSpacing=e=>e?device.DEVICES.reduce((o,t)=>{let p=e[t];return{...o,[t]:p?.includes("%")?`${(.01*parseFloat(p)).toFixed(2)}em`:p}},{}):{},composeTypographyV2=(e,o)=>{if(!e)return{};let t=convertPercentToEmLetterSpacing(e?.letterSpacing);return makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:o?.italic?void 0:e?.fontStyle,ff:composeFontFamilyTypographyV2(e),weight:o?.bold?void 0:e?.fontWeight}),...makeStyle.makeStyleResponsive("size",e?.fontSize),...makeStyle.makeStyleResponsive("lh",e?.lineHeight),...makeStyle.makeStyleResponsive("ls",t)})},composeFontFamilyTypographyV2=e=>{let{fontFamily:o,isCustom:t,fallbackFontFamily:p,type:s}=e||{};if(!o)return t?p:void 0;if("string"==typeof o)return getFontUsedByTypographyV2({fontFamily:o,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")});if("object"==typeof o&&"string"==typeof o?.value){if("theme"===o.type){let e=o?.value.includes("--g-theme-font")?`var(${o?.value})`:o?.value;return`${e}, var(--g-font-body)`}return getFontUsedByTypographyV2({fontFamily:o.value,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")})}},getFontUsedByTypographyV2=({fontFamily:e,fallbackFontFamily:o})=>{if(e)return`var(--g-font-${e?.replace(/ /g,"-")}, '${e}'), ${o}`},composeTypographyAttr=e=>e?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:e?.italic?"italic":void 0,weight:e?.bold?"bold":void 0,c:colors.getSingleColorVariable(e?.color),tt:e?.transform,tdl:e?.underline?"underline":void 0})}):{},composeTypographyClassName=(e,o)=>e?e?.type&&!isCustomTypo(e.custom)?genTypoClass(e.type):"":o?.type&&genTypoClass(o?.type),composeFallbackTypographyStyle=e=>e.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(e,o,t)=>{if(e){let o=composeFallbackTypographyStyle(e.type??"heading"),p={...e.custom,fallbackFontFamily:o,isCustom:isCustomTypo(e.custom)};return{...composeTypographyV2(p,e.attrs),...!t&&composeTypographyAttr(e.attrs)}}return{...o?.type?{}:composeTypography(o?.custom)}},isCustomTypo=e=>e&&Object.keys(e).length>1||e&&1===Object.keys(e).length&&!e.fontSize;exports.composeFallbackTypographyStyle=composeFallbackTypographyStyle,exports.composeFontFamilyTypographyV2=composeFontFamilyTypographyV2,exports.composeTextHoverColorCss=composeTextHoverColorCss,exports.composeTypography=composeTypography,exports.composeTypographyAttr=composeTypographyAttr,exports.composeTypographyClassName=composeTypographyClassName,exports.composeTypographyCss=composeTypographyCss,exports.composeTypographyStyle=composeTypographyStyle,exports.composeTypographyV2=composeTypographyV2,exports.composeTypographyV2Css=composeTypographyV2Css,exports.genTypoClass=genTypoClass;
@@ -1 +1 @@
1
- import{unstable_serialize as e}from"swr";import{getCollection as t}from"./queries/get-collection.js";import{getProduct as r}from"./queries/get-product.js";import{getProducts as s}from"./queries/get-products.js";import{generateCollectionQueryKey as o,generateProductsQueryKey as i,generateProductQueryKey as c}from"./query.js";let prefetchQueries=(u,l)=>{let n=[];return Object.keys(u).forEach(p=>{let f;let d=u[p];switch(d.tag){case"Product":{if(d.settings?.isAuto)break;let t={id:d.settings?.productSetting?.productId??"latest",isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(c(t)),func:r,variables:t};break}case"ProductList":{let r=d.settings?.productSetting;if(r?.productSrc==="Collection"){let s={id:r?.collectionId??"latest",numberOfProducts:d.settings?.numberOfProducts??4,orderBy:d.settings?.orderBy,isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(o(s)),func:t,variables:s}}else{let t={ids:[...r?.productIds??[]].sort(),isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(i(t)),func:s,variables:t}}}}f&&n.push(f)}),n.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};export{prefetchQueries};
1
+ import{unstable_serialize as e}from"swr";import{getCollection as t}from"./queries/get-collection.js";import{getProduct as r}from"./queries/get-product.js";import{getProducts as s}from"./queries/get-products.js";import{generateCollectionQueryKey as o,generateProductsQueryKey as i,generateProductQueryKey as c}from"./query.js";let prefetchQueries=(u,l)=>{let n=[];return Object.keys(u).forEach(p=>{let d;let f=u[p];switch(f.tag){case"Product":{if(f.settings?.isAuto)break;let t={id:f.settings?.productSetting?.productId??"latest",isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(c(t)),func:r,variables:t};break}case"ProductList":case"ProductListV3":{let r=f.settings?.productSetting;if(r?.productSrc==="Collection"){let s={id:r?.collectionId??"latest",numberOfProducts:f.settings?.numberOfProducts??4,orderBy:f.settings?.orderBy,isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(o(s)),func:t,variables:s}}else{let t={ids:[...r?.productIds??[]].sort(),isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(i(t)),func:s,variables:t}}}}d&&n.push(d)}),n.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};export{prefetchQueries};
@@ -1,19 +1,19 @@
1
- import{getSingleColorVariable as o}from"./colors.js";import{removeNullUndefined as e,makeStyle as t,makeStyleResponsive as p}from"./make-style.js";let genTypoClass=o=>`gp-g-${o}`,composeTypographyCss=o=>{let e=o?.custom,{fontFamily:t,fontSize:p,fontStyle:a,fontWeight:s,lineHeight:y,letterSpacing:l}=e?.desktop??{};return`
1
+ import{DEVICES as e}from"../constants/device.js";import{getSingleColorVariable as o}from"./colors.js";import{removeNullUndefined as t,makeStyle as p,makeStyleResponsive as a}from"./make-style.js";let genTypoClass=e=>`gp-g-${e}`,composeTypographyCss=e=>{let o=e?.custom,{fontFamily:t,fontSize:p,fontStyle:a,fontWeight:s,lineHeight:r,letterSpacing:y}=o?.desktop??{};return`
2
2
  ${t?`fontFamily: ${composeFontFamilyTypographyV2({fontFamily:t})};`:""}
3
3
  ${p?`font-size: ${p};`:""}
4
4
  ${a?`font-style: ${a};`:""}
5
5
  ${s?`font-weight: ${s};`:""}
6
- ${l?`letter-spacing: ${l};`:""}
7
- ${y?`line-height: ${y};`:""}
8
- `},composeTypographyV2Css=(e,t)=>{let p=e?.custom,{fontFamily:a,fontSize:s,fontWeight:y,lineHeight:l,letterSpacing:r,textShadow:n,hasShadowText:i}=p??{},g=e?.attrs,c=n&&"none"!==n.type&&!1!==n.enable,{bold:m,italic:h,underline:$,transform:f,color:d}=g??{},u=t?"!important":"";return`
6
+ ${y?`letter-spacing: ${y};`:""}
7
+ ${r?`line-height: ${r};`:""}
8
+ `},composeTypographyV2Css=(e,t)=>{let p=e?.custom,{fontFamily:a,fontSize:s,fontWeight:r,lineHeight:y,letterSpacing:l,textShadow:n,hasShadowText:i}=p??{},c=e?.attrs,g=n&&"none"!==n.type&&!1!==n.enable,{bold:m,italic:h,underline:$,transform:f,color:d}=c??{},u=t?"!important":"";return`
9
9
  ${a?`font-family: ${composeFontFamilyTypographyV2({fontFamily:a,type:e?.type})} ${u}`:""};
10
10
  ${s?.desktop?`font-size: ${s?.desktop} ${u}`:""};
11
11
  ${d?`color: ${o(d)} ${u}`:""};
12
- ${m?`font-weight: bold ${u}`:y?`font-weight: ${y} ${u}`:""};
13
- ${r?.desktop?`letter-spacing: ${r?.desktop} ${u}`:""};
14
- ${l?.desktop?`line-height: ${l?.desktop} ${u}`:""};
12
+ ${m?`font-weight: bold ${u}`:r?`font-weight: ${r} ${u}`:""};
13
+ ${l?.desktop?`letter-spacing: ${l?.desktop} ${u}`:""};
14
+ ${y?.desktop?`line-height: ${y?.desktop} ${u}`:""};
15
15
  ${h?`font-style: italic ${u}`:""};
16
16
  ${$?`text-decoration-line: underline ${u}`:""};
17
17
  ${f?`text-transform: ${f} ${u}`:""};
18
- ${c&&i?`text-shadow: ${composeTextShadowCss(n||{})}`:"none"};
19
- `},composeTextShadowCss=o=>{let e="number"==typeof o?.angle?o?.angle:0,t=e*Math.PI/180,p=parseFloat(o?.distance??"0");if(isNaN(p))return"none";let a=Math.round(Math.cos(t)*p*100)/100,s=Math.round(Math.sin(t)*p*100)/100;return`${a}px ${s}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(e,t)=>{if(e){let p=t?"!important":"",a=o(e.hover);return`${a?`color: ${a} ${p}`:""}`}};function getCustomCSSByDevice(o,e){if(!o||!e)return{};let t="desktop"!==e&&e?`-${e}`:"",{fontFamily:p}=o?.[e]??{};return{[`--size${t}`]:o?.[e]?.fontSize,[`--lh${t}`]:o?.[e]?.lineHeight,[`--fs${t}`]:o?.[e]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:o?.[e]?.fontWeight,[`--ls${t}`]:o?.[e]?.letterSpacing}}let composeTypography=o=>o?e({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,a)=>o?e({...t({fs:a?.italic?void 0:o?.fontStyle,ff:composeFontFamilyTypographyV2(o),weight:a?.bold?void 0:o?.fontWeight}),...p("size",o?.fontSize),...p("lh",o?.lineHeight),...p("ls",o?.letterSpacing)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:a}=o||{};if(!e)return t?p:void 0;if("string"==typeof e)return getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")});if("object"==typeof e&&"string"==typeof e?.value){if("theme"===e.type){let o=e?.value.includes("--g-theme-font")?`var(${e?.value})`:e?.value;return`${o}, var(--g-font-body)`}return getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")})}},getFontUsedByTypographyV2=({fontFamily:o,fallbackFontFamily:e})=>{if(o)return`var(--g-font-${o?.replace(/ /g,"-")}, '${o}'), ${e}`},composeTypographyAttr=p=>p?e({...t({fs:p?.italic?"italic":void 0,weight:p?.bold?"bold":void 0,c:o(p?.color),tt:p?.transform,tdl:p?.underline?"underline":void 0})}):{},composeTypographyClassName=(o,e)=>o?o?.type&&!isCustomTypo(o.custom)?genTypoClass(o.type):"":e?.type&&genTypoClass(e?.type),composeFallbackTypographyStyle=o=>o.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(o,e,t)=>{if(o){let e=composeFallbackTypographyStyle(o.type??"heading"),p={...o.custom,fallbackFontFamily:e,isCustom:isCustomTypo(o.custom)};return{...composeTypographyV2(p,o.attrs),...!t&&composeTypographyAttr(o.attrs)}}return{...e?.type?{}:composeTypography(e?.custom)}},isCustomTypo=o=>o&&Object.keys(o).length>1||o&&1===Object.keys(o).length&&!o.fontSize;export{composeFallbackTypographyStyle,composeFontFamilyTypographyV2,composeTextHoverColorCss,composeTypography,composeTypographyAttr,composeTypographyClassName,composeTypographyCss,composeTypographyStyle,composeTypographyV2,composeTypographyV2Css,genTypoClass};
18
+ ${g&&i?`text-shadow: ${composeTextShadowCss(n||{})}`:"none"};
19
+ `},composeTextShadowCss=e=>{let o="number"==typeof e?.angle?e?.angle:0,t=o*Math.PI/180,p=parseFloat(e?.distance??"0");if(isNaN(p))return"none";let a=Math.round(Math.cos(t)*p*100)/100,s=Math.round(Math.sin(t)*p*100)/100;return`${a}px ${s}px ${e?.blur??"0"} ${e.color}`},composeTextHoverColorCss=(e,t)=>{if(e){let p=t?"!important":"",a=o(e.hover);return`${a?`color: ${a} ${p}`:""}`}};function getCustomCSSByDevice(e,o){if(!e||!o)return{};let t="desktop"!==o&&o?`-${o}`:"",{fontFamily:p}=e?.[o]??{};return{[`--size${t}`]:e?.[o]?.fontSize,[`--lh${t}`]:e?.[o]?.lineHeight,[`--fs${t}`]:e?.[o]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:e?.[o]?.fontWeight,[`--ls${t}`]:e?.[o]?.letterSpacing}}let composeTypography=e=>e?t({...getCustomCSSByDevice(e,"desktop"),...getCustomCSSByDevice(e,"tablet"),...getCustomCSSByDevice(e,"mobile")}):{},convertPercentToEmLetterSpacing=o=>o?e.reduce((e,t)=>{let p=o[t];return{...e,[t]:p?.includes("%")?`${(.01*parseFloat(p)).toFixed(2)}em`:p}},{}):{},composeTypographyV2=(e,o)=>{if(!e)return{};let s=convertPercentToEmLetterSpacing(e?.letterSpacing);return t({...p({fs:o?.italic?void 0:e?.fontStyle,ff:composeFontFamilyTypographyV2(e),weight:o?.bold?void 0:e?.fontWeight}),...a("size",e?.fontSize),...a("lh",e?.lineHeight),...a("ls",s)})},composeFontFamilyTypographyV2=e=>{let{fontFamily:o,isCustom:t,fallbackFontFamily:p,type:a}=e||{};if(!o)return t?p:void 0;if("string"==typeof o)return getFontUsedByTypographyV2({fontFamily:o,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")});if("object"==typeof o&&"string"==typeof o?.value){if("theme"===o.type){let e=o?.value.includes("--g-theme-font")?`var(${o?.value})`:o?.value;return`${e}, var(--g-font-body)`}return getFontUsedByTypographyV2({fontFamily:o.value,fallbackFontFamily:e?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")})}},getFontUsedByTypographyV2=({fontFamily:e,fallbackFontFamily:o})=>{if(e)return`var(--g-font-${e?.replace(/ /g,"-")}, '${e}'), ${o}`},composeTypographyAttr=e=>e?t({...p({fs:e?.italic?"italic":void 0,weight:e?.bold?"bold":void 0,c:o(e?.color),tt:e?.transform,tdl:e?.underline?"underline":void 0})}):{},composeTypographyClassName=(e,o)=>e?e?.type&&!isCustomTypo(e.custom)?genTypoClass(e.type):"":o?.type&&genTypoClass(o?.type),composeFallbackTypographyStyle=e=>e.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(e,o,t)=>{if(e){let o=composeFallbackTypographyStyle(e.type??"heading"),p={...e.custom,fallbackFontFamily:o,isCustom:isCustomTypo(e.custom)};return{...composeTypographyV2(p,e.attrs),...!t&&composeTypographyAttr(e.attrs)}}return{...o?.type?{}:composeTypography(o?.custom)}},isCustomTypo=e=>e&&Object.keys(e).length>1||e&&1===Object.keys(e).length&&!e.fontSize;export{composeFallbackTypographyStyle,composeFontFamilyTypographyV2,composeTextHoverColorCss,composeTypography,composeTypographyAttr,composeTypographyClassName,composeTypographyCss,composeTypographyStyle,composeTypographyV2,composeTypographyV2Css,genTypoClass};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "5.0.0",
3
+ "version": "7.0.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -27,8 +27,8 @@
27
27
  "type-check": "yarn tsc --noEmit"
28
28
  },
29
29
  "devDependencies": {
30
- "@gem-sdk/adapter-shopify": "5.0.0",
31
- "@gem-sdk/styles": "5.0.0",
30
+ "@gem-sdk/adapter-shopify": "7.0.0",
31
+ "@gem-sdk/styles": "7.0.0",
32
32
  "@types/classnames": "^2.3.1"
33
33
  },
34
34
  "dependencies": {