@gem-sdk/core 2.0.0-staging.982 → 2.0.0-staging.989
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,5 +1,5 @@
|
|
|
1
|
-
"use strict";var constant=require("./constant.js"),makeStyle=require("./make-style.js");const getCornerCSSFromGlobal=e=>e?.radiusType?["custom","circle"].includes(e?.radiusType)?makeStyle.makeStyle({bblr:e.bblr,bbrr:e.bbrr,btlr:e.btlr,btrr:e.btrr}):makeStyle.makeStyle({radius:`var(--g-radius-${e?.radiusType})`}):{},getRadiusCSSFromGlobal=(e,s,t)=>{if(!s||!e)return{};let
|
|
2
|
-
${
|
|
1
|
+
"use strict";var constant=require("./constant.js"),makeStyle=require("./make-style.js");const getCornerCSSFromGlobal=e=>e?.radiusType?["custom","circle"].includes(e?.radiusType)?makeStyle.makeStyle({bblr:e.bblr,bbrr:e.bbrr,btlr:e.btlr,btrr:e.btrr}):makeStyle.makeStyle({radius:`var(--g-radius-${e?.radiusType})`}):{},getRadiusCSSFromGlobal=(e,s,t)=>{if(!s||!e)return{};let r=t&&"desktop"!==t?constant.devicesMapping?.[t]:"",a=constant.stateMapping?.[e];return{[`-${a}-radius${r}`]:`var(--g-radius-${s})`}},getCustomRadius=(e,s,t)=>{let r=["custom","pill","rounded","single","none","circle","square"];if(!s||!e||!r.includes(s?.radiusType??""))return{};let a=t&&"desktop"!==t?constant.devicesMapping?.[t]:"",o=constant.stateMapping?.[e];return{[`-${o}-bblr${a}`]:s.bblr,[`-${o}-bbrr${a}`]:s.bbrr,[`-${o}-btlr${a}`]:s.btlr,[`-${o}-btrr${a}`]:s.btrr}},composeRadius=e=>e?"desktop"in e||"tablet"in e||"mobile"in e?composeRadiusResponsiveState(e):composeRadiusState(e):{},composeRadiusResponsive=e=>{let s={};return Object.assign(s,getCustomRadius("normal",e?.desktop,"desktop")),Object.assign(s,getCustomRadius("normal",e?.tablet,"tablet")),Object.assign(s,getCustomRadius("normal",e?.mobile,"mobile")),s},composeRadiusState=(e,s)=>{let t={},r=["normal","hover","focus","active"];for(let a of r){let r=e?.[a]||e?.normal;if(r)switch(r.radiusType){case"medium":case"large":case"small":Object.assign(t,getRadiusCSSFromGlobal(a,r.radiusType,s));break;default:Object.assign(t,getCustomRadius(a,r,s))}}return t},composeRadiusResponsiveState=e=>{let s={};return Object.assign(s,composeRadiusState(e?.desktop,"desktop")),Object.assign(s,composeRadiusState(e?.tablet,"tablet")),Object.assign(s,composeRadiusState(e?.mobile,"mobile")),s},getRadiusStyleActiveState=e=>{let s=["circle","square","rounded","none","custom"],t=e?.active||e?.normal;return s.includes(t?.radiusType||"")?getCustomRadius("normal",t):getRadiusCSSFromGlobal("normal",t?.radiusType)},composeCornerCss=(e,s=!1)=>{let t;if(!e)return"";let{radiusType:r,bblr:a,bbrr:o,btlr:i,btrr:u}=e,l=s?" !important":"";switch(r){case"medium":case"large":case"small":t=`border-radius: var(--g-radius-${r});`;break;case"circle":case"square":case"none":case"rounded":case"custom":t=`
|
|
2
|
+
${a?`border-bottom-left-radius: ${a}${l};`:""}
|
|
3
3
|
${o?`border-bottom-right-radius: ${o}${l};`:""}
|
|
4
4
|
${i?`border-top-left-radius: ${i}${l};`:""}
|
|
5
5
|
${u?`border-top-right-radius: ${u}${l};`:""}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var colors=require("./colors.js"),makeStyle=require("./make-style.js");const genTypoClass=o=>`gp-g-${o}`,composeTypographyCss=o=>{let e=o?.custom,{fontFamily:t,fontSize:p,fontStyle:s,fontWeight:
|
|
1
|
+
"use strict";var colors=require("./colors.js"),makeStyle=require("./make-style.js");const genTypoClass=o=>`gp-g-${o}`,composeTypographyCss=o=>{let e=o?.custom,{fontFamily:t,fontSize:p,fontStyle:s,fontWeight:a,lineHeight:y,letterSpacing:l}=e?.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
6
|
${l?`letter-spacing: ${l};`:""}
|
|
7
|
-
${
|
|
8
|
-
`},composeTypographyV2Css=(o,e)=>{let t=o?.custom,{fontFamily:p,fontSize:s,fontWeight:
|
|
7
|
+
${y?`line-height: ${y};`:""}
|
|
8
|
+
`},composeTypographyV2Css=(o,e)=>{let t=o?.custom,{fontFamily:p,fontSize:s,fontWeight:a,lineHeight:y,letterSpacing:l,textShadow:r}=t??{},n=o?.attrs,{bold:i,italic:m,underline:c,transform:g,color:h}=n??{},$=e?"!important":"";return`
|
|
9
9
|
${p?`font-family: ${composeFontFamilyTypographyV2({fontFamily:p,type:o?.type})} ${$}`:""};
|
|
10
10
|
${s?.desktop?`font-size: ${s?.desktop} ${$}`:""};
|
|
11
|
-
${h?`color: ${h} ${$}`:""};
|
|
12
|
-
${i?`font-weight: bold ${$}`:
|
|
11
|
+
${h?`color: ${colors.getSingleColorVariable(h)} ${$}`:""};
|
|
12
|
+
${i?`font-weight: bold ${$}`:a?`font-weight: ${a} ${$}`:""};
|
|
13
13
|
${l?`letter-spacing: ${l} ${$}`:""};
|
|
14
|
-
${
|
|
14
|
+
${y?.desktop?`line-height: ${y?.desktop} ${$}`:""};
|
|
15
15
|
${m?`font-style: italic ${$}`:""};
|
|
16
16
|
${c?`text-decoration-line: underline ${$}`:""};
|
|
17
17
|
${g?`text-transform: ${g} ${$}`:""};
|
|
18
18
|
${r&&"none"!==r.type?`text-shadow: ${composeTextShadowCss(r)}`:"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 s=Math.round(Math.cos(t)*p*100)/100,
|
|
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 s=Math.round(Math.cos(t)*p*100)/100,a=Math.round(Math.sin(t)*p*100)/100;return`${s}px ${a}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(o,e)=>{if(o){let t=e?"!important":"",p=colors.getSingleColorVariable(o.hover);return`${p?`color: ${p} ${t}`:""}`}};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}}const composeTypography=o=>o?makeStyle.removeNullUndefined({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,e)=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:e?.italic?void 0:o?.fontStyle,ff:composeFontFamilyTypographyV2(o),weight:e?.bold?void 0:o?.fontWeight,ls:o?.letterSpacing}),...makeStyle.makeStyleResponsive("size",o?.fontSize),...makeStyle.makeStyleResponsive("lh",o?.lineHeight)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:s}=o||{};return e?"string"==typeof e?getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):"object"==typeof e&&"string"==typeof e?.value?"theme"===e.type?`var(${e?.value}), var(--g-font-body)`:getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):void 0:t?p:void 0},getFontUsedByTypographyV2=({fontFamily:o,fallbackFontFamily:e})=>{if(o)return`var(--g-font-${o?.replace(/ /g,"-")}, '${o}'), ${e}`},composeTypographyAttr=o=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:o?.italic?"italic":void 0,weight:o?.bold?"bold":void 0,c:colors.getSingleColorVariable(o?.color),tt:o?.transform,tdl:o?.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;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,6 +1,6 @@
|
|
|
1
|
-
import{devicesMapping as e,stateMapping as s}from"./constant.js";import{makeStyle as
|
|
2
|
-
${
|
|
1
|
+
import{devicesMapping as e,stateMapping as s}from"./constant.js";import{makeStyle as t}from"./make-style.js";let getCornerCSSFromGlobal=e=>e?.radiusType?["custom","circle"].includes(e?.radiusType)?t({bblr:e.bblr,bbrr:e.bbrr,btlr:e.btlr,btrr:e.btrr}):t({radius:`var(--g-radius-${e?.radiusType})`}):{},getRadiusCSSFromGlobal=(t,r,a)=>{if(!r||!t)return{};let o=a&&"desktop"!==a?e?.[a]:"",i=s?.[t];return{[`-${i}-radius${o}`]:`var(--g-radius-${r})`}},getCustomRadius=(t,r,a)=>{let o=["custom","pill","rounded","single","none","circle","square"];if(!r||!t||!o.includes(r?.radiusType??""))return{};let i=a&&"desktop"!==a?e?.[a]:"",u=s?.[t];return{[`-${u}-bblr${i}`]:r.bblr,[`-${u}-bbrr${i}`]:r.bbrr,[`-${u}-btlr${i}`]:r.btlr,[`-${u}-btrr${i}`]:r.btrr}},composeRadius=e=>e?"desktop"in e||"tablet"in e||"mobile"in e?composeRadiusResponsiveState(e):composeRadiusState(e):{},composeRadiusResponsive=e=>{let s={};return Object.assign(s,getCustomRadius("normal",e?.desktop,"desktop")),Object.assign(s,getCustomRadius("normal",e?.tablet,"tablet")),Object.assign(s,getCustomRadius("normal",e?.mobile,"mobile")),s},composeRadiusState=(e,s)=>{let t={},r=["normal","hover","focus","active"];for(let a of r){let r=e?.[a]||e?.normal;if(r)switch(r.radiusType){case"medium":case"large":case"small":Object.assign(t,getRadiusCSSFromGlobal(a,r.radiusType,s));break;default:Object.assign(t,getCustomRadius(a,r,s))}}return t},composeRadiusResponsiveState=e=>{let s={};return Object.assign(s,composeRadiusState(e?.desktop,"desktop")),Object.assign(s,composeRadiusState(e?.tablet,"tablet")),Object.assign(s,composeRadiusState(e?.mobile,"mobile")),s},getRadiusStyleActiveState=e=>{let s=["circle","square","rounded","none","custom"],t=e?.active||e?.normal;return s.includes(t?.radiusType||"")?getCustomRadius("normal",t):getRadiusCSSFromGlobal("normal",t?.radiusType)},composeCornerCss=(e,s=!1)=>{let t;if(!e)return"";let{radiusType:r,bblr:a,bbrr:o,btlr:i,btrr:u}=e,l=s?" !important":"";switch(r){case"medium":case"large":case"small":t=`border-radius: var(--g-radius-${r});`;break;case"circle":case"square":case"none":case"rounded":case"custom":t=`
|
|
2
|
+
${a?`border-bottom-left-radius: ${a}${l};`:""}
|
|
3
3
|
${o?`border-bottom-right-radius: ${o}${l};`:""}
|
|
4
4
|
${i?`border-top-left-radius: ${i}${l};`:""}
|
|
5
5
|
${u?`border-top-right-radius: ${u}${l};`:""}
|
|
6
|
-
`}return
|
|
6
|
+
`}return t};export{composeCornerCss,composeRadius,composeRadiusResponsive,getCornerCSSFromGlobal,getCustomRadius,getRadiusCSSFromGlobal,getRadiusStyleActiveState};
|
|
@@ -5,15 +5,15 @@ import{getSingleColorVariable as o}from"./colors.js";import{removeNullUndefined
|
|
|
5
5
|
${s?`font-weight: ${s};`:""}
|
|
6
6
|
${l?`letter-spacing: ${l};`:""}
|
|
7
7
|
${y?`line-height: ${y};`:""}
|
|
8
|
-
`},composeTypographyV2Css=(
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
18
|
-
${
|
|
8
|
+
`},composeTypographyV2Css=(e,t)=>{let p=e?.custom,{fontFamily:a,fontSize:s,fontWeight:y,lineHeight:l,letterSpacing:r,textShadow:n}=p??{},i=e?.attrs,{bold:g,italic:c,underline:m,transform:h,color:$}=i??{},f=t?"!important":"";return`
|
|
9
|
+
${a?`font-family: ${composeFontFamilyTypographyV2({fontFamily:a,type:e?.type})} ${f}`:""};
|
|
10
|
+
${s?.desktop?`font-size: ${s?.desktop} ${f}`:""};
|
|
11
|
+
${$?`color: ${o($)} ${f}`:""};
|
|
12
|
+
${g?`font-weight: bold ${f}`:y?`font-weight: ${y} ${f}`:""};
|
|
13
|
+
${r?`letter-spacing: ${r} ${f}`:""};
|
|
14
|
+
${l?.desktop?`line-height: ${l?.desktop} ${f}`:""};
|
|
15
|
+
${c?`font-style: italic ${f}`:""};
|
|
16
|
+
${m?`text-decoration-line: underline ${f}`:""};
|
|
17
|
+
${h?`text-transform: ${h} ${f}`:""};
|
|
18
|
+
${n&&"none"!==n.type?`text-shadow: ${composeTextShadowCss(n)}`:"none"};
|
|
19
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,ls:o?.letterSpacing}),...p("size",o?.fontSize),...p("lh",o?.lineHeight)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:a}=o||{};return e?"string"==typeof e?getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")}):"object"==typeof e&&"string"==typeof e?.value?"theme"===e.type?`var(${e?.value}), var(--g-font-body)`:getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")}):void 0:t?p:void 0},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};
|
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.989",
|
|
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.987",
|
|
32
32
|
"@types/classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|