@fower/parser
Advanced tools
Comparing version 1.29.0 to 1.30.0
@@ -7,7 +7,6 @@ 'use strict'; | ||
var store = require('@fower/store'); | ||
var cache = require('@fower/cache'); | ||
var utils = require('@fower/utils'); | ||
var colorHelper = require('@fower/color-helper'); | ||
var sheet = require('@fower/sheet'); | ||
var cssObjectProcessor = require('@fower/css-object-processor'); | ||
var utils = require('@fower/utils'); | ||
@@ -98,2 +97,4 @@ function _defineProperties(target, props) { | ||
var colorKeys = ['color', 'backgroundColor', 'borderColor']; | ||
var reactProps = ['children', 'onClick', 'onChange', 'onBlur', 'className', 'placeholder']; | ||
@@ -106,2 +107,4 @@ /** | ||
function Parser(props) { | ||
var _store$config$mode; | ||
if (props === void 0) { | ||
@@ -124,3 +127,3 @@ props = {}; | ||
if (store.store.config.autoDarkMode) { | ||
if ((_store$config$mode = store.store.config.mode) != null && _store$config$mode.autoDarkMode) { | ||
this.autoDarkMode(); | ||
@@ -140,10 +143,8 @@ } | ||
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos, | ||
theme = _this$config.theme; | ||
var _ref = theme || {}, | ||
breakpoints = _ref.breakpoints, | ||
modes = _ref.modes; | ||
theme = _this$config.theme, | ||
mode = _this$config.mode; | ||
var modeList = mode.modeList; | ||
var breakpoints = theme.breakpoints || {}; | ||
var breakpointKeys = Object.keys(breakpoints); | ||
var modeKeys = modes || []; | ||
var modeKeys = modeList || []; | ||
var pseudoKeys = pseudos; | ||
@@ -246,64 +247,85 @@ var _props$excludedProps = props.excludedProps, | ||
_proto.autoDarkMode = function autoDarkMode() { | ||
var colorMap = { | ||
white: 'black', | ||
black: 'white', | ||
'50': '900', | ||
'100': '800', | ||
'200': '700', | ||
'300': '600', | ||
'400': '500', | ||
'500': '400', | ||
'600': '300', | ||
'700': '200', | ||
'800': '100', | ||
'900': '50' | ||
}; | ||
var colorKeys = ['color', 'backgroundColor', 'borderColor']; | ||
var darkAtoms = []; | ||
/** TODO: hack for auto dark mode, need to refactor */ | ||
_proto.getAutoDarkModeAtom = function getAutoDarkModeAtom(atom$1) { | ||
var _options$style; | ||
for (var _iterator3 = _createForOfIteratorHelperLoose(this.atoms), _step3; !(_step3 = _iterator3()).done;) { | ||
var atom$1 = _step3.value; | ||
if (atom$1.meta.mode) return null; | ||
if (!atom$1.style) return null; | ||
var entries = Object.entries(atom$1.style); | ||
if (!(entries != null && entries.length)) return null; | ||
var options = {}; | ||
var darkColor = ''; | ||
var config = store.store.config; | ||
var mappings = config.mode.autoDarkMode.mappings; | ||
var colors = config.theme.colors; | ||
var _entries$ = entries[0], | ||
colorKey = _entries$[0], | ||
colorName = _entries$[1]; // check is valid color key | ||
if (colorKeys.includes(atom$1.type) && !atom$1.meta.mode) { | ||
var find = this.atoms.find(function (i) { | ||
return colorKeys.includes(i.type) && i.meta.mode === 'dark'; | ||
}); | ||
if (find) continue; | ||
var entries = Object.entries(atom$1.style); | ||
if (!(entries != null && entries.length)) continue; | ||
var _entries$ = entries[0], | ||
colorValue = _entries$[1]; | ||
if (!colorValue) continue; | ||
if (!colorKeys.includes(colorKey)) return null; // only color in theme is valid | ||
var _ref2 = colorValue.match(/^([a-z]+)(\d+)$/i) || [], | ||
mapKey = _ref2[2]; | ||
if (!colors[colorName]) return null; // if scale is existed, scale should be 100,200,300,400... | ||
if (['white', 'black'].includes(colorValue)) mapKey = colorValue; | ||
var str = JSON.stringify(atom$1).replace(new RegExp("" + mapKey, 'g'), colorMap[mapKey]); | ||
if (mapKey === 'white') str = str.replace(/White/g, 'Black'); | ||
if (mapKey === 'black') str = str.replace(/Black/g, 'White'); | ||
var cloned = JSON.parse(str); | ||
var _ref = colorName.match(/^([a-z]+)(\d+)$/i) || [], | ||
scale = _ref[2]; // is disable, eg: { red200: false} | ||
var _darkAtom = new atom.Atom(_extends({}, cloned, { | ||
propKey: cloned.propKey + '--dark', | ||
meta: _extends({}, cloned.meta, { | ||
mode: 'dark' | ||
}) | ||
})); | ||
var cachedAtom = cache.atomCache.get(_darkAtom.id); | ||
if (mappings[colorName] === false) return null; | ||
if (cachedAtom) { | ||
darkAtoms.push(cachedAtom); | ||
} else { | ||
darkAtoms.push(_darkAtom); | ||
} | ||
if (mappings[colorName]) { | ||
darkColor = mappings[colorName]; | ||
} else { | ||
darkColor = colorName.replace(scale, mappings[scale]); | ||
} | ||
var isColor = colorKey === 'color'; | ||
var isBgColor = colorKey === 'backgroundColor'; | ||
var isBorderColor = colorKey === 'borderColor'; | ||
if (colors[darkColor]) { | ||
if (isColor) { | ||
options.propKey = darkColor; | ||
} else if (isBgColor) { | ||
options.propKey = "bg" + utils.upFirst(darkColor); | ||
} else if (isBorderColor) { | ||
options.propKey = "border" + utils.upFirst(darkColor); | ||
} | ||
options.propValue = true; | ||
} else { | ||
if (isColor) { | ||
options.propKey = 'color'; | ||
options.propValue = darkColor; | ||
} else if (isBgColor) { | ||
options.propKey = 'bg'; | ||
options.propValue = darkColor; | ||
} else if (isBorderColor) { | ||
options.propKey = 'borderColor'; | ||
options.propValue = darkColor; | ||
} | ||
} | ||
for (var _i2 = 0, _darkAtoms = darkAtoms; _i2 < _darkAtoms.length; _i2++) { | ||
var darkAtom = _darkAtoms[_i2]; | ||
this.addAtom(darkAtom); | ||
options.style = (_options$style = {}, _options$style[colorKey] = darkColor, _options$style); | ||
return new atom.Atom(_extends({}, options, { | ||
meta: _extends({}, atom$1.meta, { | ||
mode: 'dark' | ||
}) | ||
})); | ||
}; | ||
_proto.autoDarkMode = function autoDarkMode() { | ||
for (var _iterator3 = _createForOfIteratorHelperLoose(this.atoms), _step3; !(_step3 = _iterator3()).done;) { | ||
var atom = _step3.value; | ||
var find = this.atoms.find(function (i) { | ||
return colorKeys.includes(i.type) && i.meta.mode === 'dark'; | ||
}); | ||
if (find) continue; | ||
var darkAtom = this.getAutoDarkModeAtom(atom); | ||
if (!darkAtom) continue; | ||
var cachedAtom = store.store.atomCache.get(darkAtom.id); | ||
if (cachedAtom) { | ||
this.addAtom(cachedAtom); | ||
} else { | ||
this.addAtom(darkAtom); | ||
} | ||
} | ||
@@ -363,5 +385,5 @@ } | ||
colorPostfix = meta.colorPostfix; | ||
return Object.entries(style).reduce(function (r, _ref3) { | ||
var key = _ref3[0], | ||
value = _ref3[1]; | ||
return Object.entries(style).reduce(function (r, _ref2) { | ||
var key = _ref2[0], | ||
value = _ref2[1]; | ||
var cssKey = utils.jsKeyToCssKey(key); | ||
@@ -371,9 +393,13 @@ var posfix = important ? ' !important' : ''; | ||
if (colorPostfix) { | ||
value = colorHelper.formatColor(colors[value] || value, colorPostfix); | ||
} else { | ||
value = _this.formatCssValue(cssKey, colors[value] || value); | ||
try { | ||
if (colorPostfix) { | ||
value = colorHelper.formatColor((colors == null ? void 0 : colors[value]) || value, colorPostfix); | ||
} else { | ||
value = _this.formatCssValue(cssKey, (colors == null ? void 0 : colors[value]) || value); | ||
} | ||
return r + (cssKey + ": " + value + posfix + ";"); | ||
} catch (error) { | ||
return ''; | ||
} | ||
return r + (cssKey + ": " + value + posfix + ";"); | ||
}, ''); | ||
@@ -386,4 +412,4 @@ }; | ||
// if not cached, let's cache it | ||
if (!cache.atomCache.get(atom.id)) { | ||
cache.atomCache.set(atom.id, atom); | ||
if (!store.store.atomCache.get(atom.id)) { | ||
store.store.atomCache.set(atom.id, atom); | ||
} | ||
@@ -393,5 +419,5 @@ | ||
var _ref4 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {}, | ||
_ref4$modes = _ref4.modes, | ||
modes = _ref4$modes === void 0 ? {} : _ref4$modes; | ||
var _ref3 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {}, | ||
_ref3$modes = _ref3.modes, | ||
modes = _ref3$modes === void 0 ? {} : _ref3$modes; | ||
@@ -401,4 +427,4 @@ var entries = Object.entries(modes); | ||
for (var _i3 = 0, _entries2 = entries; _i3 < _entries2.length; _i3++) { | ||
var _entries2$_i = _entries2[_i3], | ||
for (var _i2 = 0, _entries2 = entries; _i2 < _entries2.length; _i2++) { | ||
var _entries2$_i = _entries2[_i2], | ||
mode = _entries2$_i[0], | ||
@@ -468,3 +494,3 @@ colors = _entries2$_i[1]; | ||
var cachedAtom = cache.atomCache.get(atom.id); | ||
var cachedAtom = store.store.atomCache.get(atom.id); | ||
@@ -524,5 +550,5 @@ if (cachedAtom) { | ||
if (selectorType === 'pseudo' && option.meta) { | ||
var _ref5 = selector.match(/(:+)(.+)/) || [], | ||
pseudoPrefix = _ref5[1], | ||
pseudo = _ref5[2]; | ||
var _ref4 = selector.match(/(:+)(.+)/) || [], | ||
pseudoPrefix = _ref4[1], | ||
pseudo = _ref4[2]; | ||
@@ -551,3 +577,3 @@ option.meta.pseudoPrefix = pseudoPrefix; | ||
var cachedAtom = cache.atomCache.get(atom$1.id); | ||
var cachedAtom = store.store.atomCache.get(atom$1.id); | ||
@@ -620,7 +646,7 @@ if (cachedAtom) { | ||
var colors = store.store.theme.colors; | ||
var style = Object.entries(atom.style).reduce(function (c, _ref6) { | ||
var style = Object.entries(atom.style).reduce(function (c, _ref5) { | ||
var _extends3; | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
var key = _ref5[0], | ||
value = _ref5[1]; | ||
@@ -648,4 +674,4 @@ var cssValue = _this3.formatCssValue(utils.jsKeyToCssKey(key), colors[value] || value); | ||
var _this$config$theme$mo = this.config.theme.modePrefix, | ||
modePrefix = _this$config$theme$mo === void 0 ? '' : _this$config$theme$mo; | ||
var _this$config$mode$cla = this.config.mode.classPrefix, | ||
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla; | ||
var rules = []; // sort responsive style | ||
@@ -691,3 +717,3 @@ | ||
if (pseudo) selector = selector + pseudoPrefix + pseudo; | ||
if (mode) selector = "." + modePrefix + mode + " " + selector; | ||
if (mode) selector = "." + classPrefix + mode + " " + selector; | ||
if (childSelector) selector = selector + " " + childSelector; | ||
@@ -703,5 +729,4 @@ rule = selector + " { " + _this4.styleToString(style, atom.meta) + " }"; | ||
if (_ret === "continue") continue; | ||
} // console.log('this.atoms-----:', this.atoms) | ||
} | ||
return rules; | ||
@@ -717,7 +742,7 @@ }; | ||
var parsedProps = entries.reduce(function (result, _ref7) { | ||
var key = _ref7[0], | ||
value = _ref7[1]; | ||
var parsedProps = entries.reduce(function (result, _ref6) { | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
var find = atoms.find(function (atom) { | ||
return [atom.propKey, atom.key, atom.id, 'css'].includes(key); | ||
return [atom.propKey, atom.key, 'css'].includes(key); | ||
}); | ||
@@ -724,0 +749,0 @@ if (!find) result[key] = value; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@fower/atom"),t=require("@fower/store"),r=require("@fower/cache"),n=require("@fower/color-helper"),i=require("@fower/sheet"),o=require("@fower/css-object-processor"),s=require("@fower/utils");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c=/(-columns|(^|[^e]-)padding|[^t]-spacing|l-align|rows|(^|(^border|[dkmnptx]|le|ne)-)width|^border|tom|[ek]-start|(o|[^e]-du)ration|us|(^|[^tv]-)left|(^|-)top|tance|rgin|e-offset|(er|g|n|t)-block|(^|[^tv]-)right|basis|[gnt]-inline|gap|(^|[^e]-)height|ness|(^|[^p]-)inset|[ek]-end|elay|tline|ve|dent|-rotate|n-rule|(c|ck|d|ne|t)-size)$/;function d(e){return c.test(e)}var f=["children","onClick","onChange","onBlur","className","placeholder"];exports.Parser=function(){function u(e){void 0===e&&(e={}),this.props=e,this.atoms=[],this.getClassNameById=function(e){return t.store.config.prefix+e},this.traverseProps(e),t.store.config.autoDarkMode&&this.autoDarkMode()}var c,m=u.prototype;return m.traverseProps=function(r){if(!s.isEmptyObj(r)){var n=this.config,i=n.pseudos,o=void 0===i?[]:i,u=n.theme||{},c=u.breakpoints,d=u.modes,m=Object.keys(c),h=d||[],p=o,v=r.excludedProps,y=void 0===v?[]:v,b=Object.entries(r);if(null!=r&&r.className)for(var g,k=l(r.className.split(/\s+/));!(g=k()).done;)b.push([g.value,!0]);for(var S=0,A=b;S<A.length;S++){var C=A[S],j=C[0],O=C[1];if(!y.includes(j)&&!f.includes(j)&&this.isValidProp(j,O))if("css"!==j){if(j.startsWith("_")){var w=j.replace(/^_/,""),N=Array.isArray(O)?O.reduce((function(e,t){var r;return a({},e,((r={})[t]=!0,r))}),{}):O;if(h.includes(w)){this.parseCSSObject(N,{mode:w});continue}if(m.includes(w)){this.parseCSSObject(N,{breakpoint:c[w]});continue}if(p.includes(w)){this.parseCSSObject(N,{pseudo:":"+w});continue}}var P=t.store.compositions.get(j);if(P){this.parseCSSObject(P,{});var K=new e.Atom({propKey:j,propValue:O});K.handled=!0,K.style={},this.addAtom(K)}else{var x=new e.Atom({propKey:j,propValue:O});try{this.mutateAtom(x),x.handled&&this.addAtom(x)}catch(e){continue}}}else this.parseCSSObject(O,{})}for(var V,q=l(this.plugins);!(V=q()).done;){var I=V.value;I.afterAtomStyleCreate&&I.afterAtomStyleCreate(this)}}},m.autoDarkMode=function(){for(var t,n={white:"black",black:"white",50:"900",100:"800",200:"700",300:"600",400:"500",500:"400",600:"300",700:"200",800:"100",900:"50"},i=["color","backgroundColor","borderColor"],o=[],s=l(this.atoms);!(t=s()).done;){var u=t.value;if(i.includes(u.type)&&!u.meta.mode){if(this.atoms.find((function(e){return i.includes(e.type)&&"dark"===e.meta.mode})))continue;var c=Object.entries(u.style);if(null==c||!c.length)continue;var d=c[0][1];if(!d)continue;var f=(d.match(/^([a-z]+)(\d+)$/i)||[])[2];["white","black"].includes(d)&&(f=d);var m=JSON.stringify(u).replace(new RegExp(""+f,"g"),n[f]);"white"===f&&(m=m.replace(/White/g,"Black")),"black"===f&&(m=m.replace(/Black/g,"White"));var h=JSON.parse(m),p=new e.Atom(a({},h,{propKey:h.propKey+"--dark",meta:a({},h.meta,{mode:"dark"})})),v=r.atomCache.get(p.id);o.push(v||p)}}for(var y=0,b=o;y<b.length;y++)this.addAtom(b[y])},m.formatCssValue=function(e,r){if(!d(e))return r;var n;if(s.isPercentNumber(String(r)))return String(r).replace("p","%");if(!s.isNumber(r))return r;if((n=Number(r))<1&&n>0)return 100*n+"%";var i=t.store.config;return"none"!==i.unit?i.transformUnit?i.transformUnit(n):r+t.store.config.unit:n},m.styleToString=function(e,r){var i=this,o=r.important,a=r.colorPostfix;return Object.entries(e).reduce((function(e,r){var u=r[1],l=s.jsKeyToCssKey(r[0]),c=o?" !important":"",d=t.store.theme.colors;return e+(l+": ")+(u=a?n.formatColor(d[u]||u,a):i.formatCssValue(l,d[u]||u))+c+";"}),"")},m.addAtom=function(e){var t;r.atomCache.get(e.id)||r.atomCache.set(e.id,e);for(var n=i.styleSheet.getSsrAtomIds(),o=((null==(t=this.config.theme)?void 0:t.colors)||{}).modes,s=0,u=Object.entries(void 0===o?{}:o);s<u.length;s++){var l=u[s],c=l[0],d=l[1];if(e.style){var f=Object.entries(e.style);if(f.length){var m=f[0],h=m[0],p=d[m[1]];if(p){var v="--"+c,y=JSON.parse(JSON.stringify(e));y.key=e.key+v,y.id=e.id+v,y.meta=a({mode:c},e.meta),y.style[h]=p,n.includes(y.id)&&(y.inserted=!0),this.atoms.push(y)}}}}n.includes(e.id)&&(e.inserted=!0),this.atoms.push(e)},m.isValidProp=function(e,t){return"css"===e||!!e.startsWith("_")||!!Array.isArray(t)||!!["string","boolean","number","undefined"].includes(typeof t)},m.mutateAtom=function(e){for(var t,n=l(this.plugins);!(t=n()).done;){var i=t.value;null!=i.isMatch&&i.isMatch(e.key)&&i.beforeHandleAtom&&(e=i.beforeHandleAtom(e,this))}var o=r.atomCache.get(e.id);if(o)throw this.addAtom(o),new Error("atom is cached, add to this.atoms derectly, no need to mutate");if(e.handled)throw this.addAtom(e),new Error("atom is handled, add to this.atoms derectly ,no need to mutate");for(var s,a=l(this.plugins);!(s=a()).done;){var u=s.value;if(null!=u.isMatch&&u.isMatch(e.key)){u.beforeHandleAtom&&(e=u.beforeHandleAtom(e,this)),u.handleAtom&&(e=null==u.handleAtom?void 0:u.handleAtom(e,this)),e.handled=!0;break}}},m.parseCSSObject=function(t,n){void 0===n&&(n={});for(var i,s=l(o.parse(t));!(i=s()).done;){var u=i.value,c=u.selector,d=u.selectorType,f=u.style,m=Object.entries(f);if(m.length){var h=m[0],p={propKey:h[0],propValue:h[1],meta:a({},n)};if("pseudo"===d&&p.meta){var v=c.match(/(:+)(.+)/)||[],y=v[2];p.meta.pseudoPrefix=v[1],p.meta.pseudo=y}"child"===d&&p.meta&&(p.meta.childSelector=c);var b=new e.Atom(p);try{this.mutateAtom(b)}catch(e){continue}b.style||(b.style=f,b.handled=!0);var g=r.atomCache.get(b.id);this.addAtom(g||b)}}},m.makeResponsiveStyle=function(e,t){return"@media (min-width: "+e+") {"+t+"}"},m.getClassNames=function(){var e=this,t=[];this.atoms.reduce((function(r,n){if(!n.style||!Object.keys(n.style).length)return r;var i=r.findIndex((function(e){return e.styleKeysHash===n.styleKeysHash}));if(!n.isValid)return r;var o=e.getClassNameById(n.id);return-1===i?(t.push(o),r=[].concat(r,[n])):(r.splice(i,1,n),t.splice(i,1,o)),r}),[]);var r=this.props.className,n=(void 0===r?"":r).split(/\s+/).filter((function(e){return!t.includes(e)&&!!e}));return t=t.concat(n),this.hasResponsive&&t.unshift(this.uniqueClassName),t},m.toStyle=function(){var e=this;return this.atoms.reduce((function(r,n){if(!n.isValid)return r;var i=t.store.theme.colors,o=Object.entries(n.style).reduce((function(t,r){var n,o=r[0],u=r[1],l=e.formatCssValue(s.jsKeyToCssKey(o),i[u]||u);return a({},t,((n={})[o]=l,n))}),{});return a({},r,o)}),{})},m.toRules=function(e){var t=this;void 0===e&&(e=!1);var r=this.config.theme.modePrefix,n=void 0===r?"":r,i=[];this.atoms=this.atoms.sort((function(e,t){return parseInt(t.meta.breakpoint||"0")-parseInt(e.meta.breakpoint||"0")}));for(var o,a=function(){var r=o.value,a="",u=r.id,l=r.style,c=void 0===l?{}:l,d=r.meta;if(!r.isValid)return"continue";if(s.isEmptyObj(c))return"continue";if(!e&&r.inserted)return"continue";r.inserted=!0;var f=d.pseudo,m=d.pseudoPrefix,h=d.mode,p=d.breakpoint,v=void 0===p?"":p,y=d.childSelector,b=t.atoms.find((function(e){return e.styleKeys===r.styleKeys&&(r.meta.breakpoint||e.meta.breakpoint)}))||r.meta.breakpoint?"."+t.uniqueClassName:"",g=t.getClassNameById(u),k=d.global?d.global:b+"."+g;f&&(k=k+m+f),h&&(k="."+n+h+" "+k),y&&(k=k+" "+y),a=k+" { "+t.styleToString(c,r.meta)+" }",v&&(a=t.makeResponsiveStyle(v,a)),i.push(a)},u=l(this.atoms);!(o=u()).done;)a();return i},m.getParsedProps=function(){var e=this.props,t=this.atoms;return s.isEmptyObj(e)?{}:Object.entries(e).reduce((function(e,r){var n=r[0],i=r[1];return t.find((function(e){return[e.propKey,e.key,e.id,"css"].includes(n)}))||(e[n]=i),e}),{})},m.insertRule=function(){var e=this.toRules();i.styleSheet.insertStyles(e)},(c=[{key:"uniqueClassName",get:function(){return s.objectToClassName(Object.keys(this.props))}},{key:"hasResponsive",get:function(){return!!this.atoms.find((function(e){return!!e.meta.breakpoint}))}},{key:"config",get:function(){return t.store.config}},{key:"plugins",get:function(){return t.store.config.plugins}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(u.prototype,c),u}(),exports.isUnitProp=d; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@fower/atom"),t=require("@fower/store"),r=require("@fower/utils"),o=require("@fower/color-helper"),n=require("@fower/sheet"),i=require("@fower/css-object-processor");function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l=/(-columns|(^|[^e]-)padding|[^t]-spacing|l-align|rows|(^|(^border|[dkmnptx]|le|ne)-)width|^border|tom|[ek]-start|(o|[^e]-du)ration|us|(^|[^tv]-)left|(^|-)top|tance|rgin|e-offset|(er|g|n|t)-block|(^|[^tv]-)right|basis|[gnt]-inline|gap|(^|[^e]-)height|ness|(^|[^p]-)inset|[ek]-end|elay|tline|ve|dent|-rotate|n-rule|(c|ck|d|ne|t)-size)$/;function c(e){return l.test(e)}var d=["color","backgroundColor","borderColor"],f=["children","onClick","onChange","onBlur","className","placeholder"];exports.Parser=function(){function a(e){var r;void 0===e&&(e={}),this.props=e,this.atoms=[],this.getClassNameById=function(e){return t.store.config.prefix+e},this.traverseProps(e),null!=(r=t.store.config.mode)&&r.autoDarkMode&&this.autoDarkMode()}var l,p=a.prototype;return p.traverseProps=function(o){if(!r.isEmptyObj(o)){var n=this.config,i=n.pseudos,a=void 0===i?[]:i,l=n.mode.modeList,c=n.theme.breakpoints||{},d=Object.keys(c),p=l||[],m=a,h=o.excludedProps,v=void 0===h?[]:h,y=Object.entries(o);if(null!=o&&o.className)for(var b,g=u(o.className.split(/\s+/));!(b=g()).done;)y.push([b.value,!0]);for(var k=0,A=y;k<A.length;k++){var C=A[k],S=C[0],j=C[1];if(!v.includes(S)&&!f.includes(S)&&this.isValidProp(S,j))if("css"!==S){if(S.startsWith("_")){var O=S.replace(/^_/,""),w=Array.isArray(j)?j.reduce((function(e,t){var r;return s({},e,((r={})[t]=!0,r))}),{}):j;if(p.includes(O)){this.parseCSSObject(w,{mode:O});continue}if(d.includes(O)){this.parseCSSObject(w,{breakpoint:c[O]});continue}if(m.includes(O)){this.parseCSSObject(w,{pseudo:":"+O});continue}}var K=t.store.compositions.get(S);if(K){this.parseCSSObject(K,{});var N=new e.Atom({propKey:S,propValue:j});N.handled=!0,N.style={},this.addAtom(N)}else{var P=new e.Atom({propKey:S,propValue:j});try{this.mutateAtom(P),P.handled&&this.addAtom(P)}catch(e){continue}}}else this.parseCSSObject(j,{})}for(var V,x=u(this.plugins);!(V=x()).done;){var M=V.value;M.afterAtomStyleCreate&&M.afterAtomStyleCreate(this)}}},p.getAutoDarkModeAtom=function(o){var n;if(o.meta.mode)return null;if(!o.style)return null;var i=Object.entries(o.style);if(null==i||!i.length)return null;var a,u={},l=t.store.config,c=l.mode.autoDarkMode.mappings,f=l.theme.colors,p=i[0],m=p[0],h=p[1];if(!d.includes(m))return null;if(!f[h])return null;var v=(h.match(/^([a-z]+)(\d+)$/i)||[])[2];if(!1===c[h])return null;var y="color"===m,b="backgroundColor"===m,g="borderColor"===m;return f[a=c[h]?c[h]:h.replace(v,c[v])]?(y?u.propKey=a:b?u.propKey="bg"+r.upFirst(a):g&&(u.propKey="border"+r.upFirst(a)),u.propValue=!0):y?(u.propKey="color",u.propValue=a):b?(u.propKey="bg",u.propValue=a):g&&(u.propKey="borderColor",u.propValue=a),u.style=((n={})[m]=a,n),new e.Atom(s({},u,{meta:s({},o.meta,{mode:"dark"})}))},p.autoDarkMode=function(){for(var e,r=u(this.atoms);!(e=r()).done;){var o=e.value;if(!this.atoms.find((function(e){return d.includes(e.type)&&"dark"===e.meta.mode}))){var n=this.getAutoDarkModeAtom(o);if(n){var i=t.store.atomCache.get(n.id);this.addAtom(i||n)}}}},p.formatCssValue=function(e,o){if(!c(e))return o;var n;if(r.isPercentNumber(String(o)))return String(o).replace("p","%");if(!r.isNumber(o))return o;if((n=Number(o))<1&&n>0)return 100*n+"%";var i=t.store.config;return"none"!==i.unit?i.transformUnit?i.transformUnit(n):o+t.store.config.unit:n},p.styleToString=function(e,n){var i=this,s=n.important,a=n.colorPostfix;return Object.entries(e).reduce((function(e,n){var u=n[1],l=r.jsKeyToCssKey(n[0]),c=s?" !important":"",d=t.store.theme.colors;try{return e+(l+": ")+(u=a?o.formatColor((null==d?void 0:d[u])||u,a):i.formatCssValue(l,(null==d?void 0:d[u])||u))+c+";"}catch(e){return""}}),"")},p.addAtom=function(e){var r;t.store.atomCache.get(e.id)||t.store.atomCache.set(e.id,e);for(var o=n.styleSheet.getSsrAtomIds(),i=((null==(r=this.config.theme)?void 0:r.colors)||{}).modes,a=0,u=Object.entries(void 0===i?{}:i);a<u.length;a++){var l=u[a],c=l[0],d=l[1];if(e.style){var f=Object.entries(e.style);if(f.length){var p=f[0],m=p[0],h=d[p[1]];if(h){var v="--"+c,y=JSON.parse(JSON.stringify(e));y.key=e.key+v,y.id=e.id+v,y.meta=s({mode:c},e.meta),y.style[m]=h,o.includes(y.id)&&(y.inserted=!0),this.atoms.push(y)}}}}o.includes(e.id)&&(e.inserted=!0),this.atoms.push(e)},p.isValidProp=function(e,t){return"css"===e||!!e.startsWith("_")||!!Array.isArray(t)||!!["string","boolean","number","undefined"].includes(typeof t)},p.mutateAtom=function(e){for(var r,o=u(this.plugins);!(r=o()).done;){var n=r.value;null!=n.isMatch&&n.isMatch(e.key)&&n.beforeHandleAtom&&(e=n.beforeHandleAtom(e,this))}var i=t.store.atomCache.get(e.id);if(i)throw this.addAtom(i),new Error("atom is cached, add to this.atoms derectly, no need to mutate");if(e.handled)throw this.addAtom(e),new Error("atom is handled, add to this.atoms derectly ,no need to mutate");for(var s,a=u(this.plugins);!(s=a()).done;){var l=s.value;if(null!=l.isMatch&&l.isMatch(e.key)){l.beforeHandleAtom&&(e=l.beforeHandleAtom(e,this)),l.handleAtom&&(e=null==l.handleAtom?void 0:l.handleAtom(e,this)),e.handled=!0;break}}},p.parseCSSObject=function(r,o){void 0===o&&(o={});for(var n,a=u(i.parse(r));!(n=a()).done;){var l=n.value,c=l.selector,d=l.selectorType,f=l.style,p=Object.entries(f);if(p.length){var m=p[0],h={propKey:m[0],propValue:m[1],meta:s({},o)};if("pseudo"===d&&h.meta){var v=c.match(/(:+)(.+)/)||[],y=v[2];h.meta.pseudoPrefix=v[1],h.meta.pseudo=y}"child"===d&&h.meta&&(h.meta.childSelector=c);var b=new e.Atom(h);try{this.mutateAtom(b)}catch(e){continue}b.style||(b.style=f,b.handled=!0);var g=t.store.atomCache.get(b.id);this.addAtom(g||b)}}},p.makeResponsiveStyle=function(e,t){return"@media (min-width: "+e+") {"+t+"}"},p.getClassNames=function(){var e=this,t=[];this.atoms.reduce((function(r,o){if(!o.style||!Object.keys(o.style).length)return r;var n=r.findIndex((function(e){return e.styleKeysHash===o.styleKeysHash}));if(!o.isValid)return r;var i=e.getClassNameById(o.id);return-1===n?(t.push(i),r=[].concat(r,[o])):(r.splice(n,1,o),t.splice(n,1,i)),r}),[]);var r=this.props.className,o=(void 0===r?"":r).split(/\s+/).filter((function(e){return!t.includes(e)&&!!e}));return t=t.concat(o),this.hasResponsive&&t.unshift(this.uniqueClassName),t},p.toStyle=function(){var e=this;return this.atoms.reduce((function(o,n){if(!n.isValid)return o;var i=t.store.theme.colors,a=Object.entries(n.style).reduce((function(t,o){var n,a=o[0],u=o[1],l=e.formatCssValue(r.jsKeyToCssKey(a),i[u]||u);return s({},t,((n={})[a]=l,n))}),{});return s({},o,a)}),{})},p.toRules=function(e){var t=this;void 0===e&&(e=!1);var o=this.config.mode.classPrefix,n=void 0===o?"":o,i=[];this.atoms=this.atoms.sort((function(e,t){return parseInt(t.meta.breakpoint||"0")-parseInt(e.meta.breakpoint||"0")}));for(var s,a=function(){var o=s.value,a="",u=o.id,l=o.style,c=void 0===l?{}:l,d=o.meta;if(!o.isValid)return"continue";if(r.isEmptyObj(c))return"continue";if(!e&&o.inserted)return"continue";o.inserted=!0;var f=d.pseudo,p=d.pseudoPrefix,m=d.mode,h=d.breakpoint,v=void 0===h?"":h,y=d.childSelector,b=t.atoms.find((function(e){return e.styleKeys===o.styleKeys&&(o.meta.breakpoint||e.meta.breakpoint)}))||o.meta.breakpoint?"."+t.uniqueClassName:"",g=t.getClassNameById(u),k=d.global?d.global:b+"."+g;f&&(k=k+p+f),m&&(k="."+n+m+" "+k),y&&(k=k+" "+y),a=k+" { "+t.styleToString(c,o.meta)+" }",v&&(a=t.makeResponsiveStyle(v,a)),i.push(a)},l=u(this.atoms);!(s=l()).done;)a();return i},p.getParsedProps=function(){var e=this.props,t=this.atoms;return r.isEmptyObj(e)?{}:Object.entries(e).reduce((function(e,r){var o=r[0],n=r[1];return t.find((function(e){return[e.propKey,e.key,"css"].includes(o)}))||(e[o]=n),e}),{})},p.insertRule=function(){var e=this.toRules();n.styleSheet.insertStyles(e)},(l=[{key:"uniqueClassName",get:function(){return r.objectToClassName(Object.keys(this.props))}},{key:"hasResponsive",get:function(){return!!this.atoms.find((function(e){return!!e.meta.breakpoint}))}},{key:"config",get:function(){return t.store.config}},{key:"plugins",get:function(){return t.store.config.plugins}}])&&function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(a.prototype,l),a}(),exports.isUnitProp=c; | ||
//# sourceMappingURL=parser.cjs.production.min.js.map |
@@ -21,3 +21,3 @@ import { Atom } from '@fower/atom'; | ||
get hasResponsive(): boolean; | ||
get config(): any; | ||
get config(): import("@fower/types").Configuration; | ||
get plugins(): any[]; | ||
@@ -29,2 +29,3 @@ getClassNameById: (id: string) => string; | ||
traverseProps(props: Props): void; | ||
getAutoDarkModeAtom(atom: Atom): Atom | null; | ||
autoDarkMode(): void; | ||
@@ -31,0 +32,0 @@ /** |
import { Atom } from '@fower/atom'; | ||
import { store } from '@fower/store'; | ||
import { atomCache } from '@fower/cache'; | ||
import { isEmptyObj, upFirst, isPercentNumber, isNumber, jsKeyToCssKey, objectToClassName } from '@fower/utils'; | ||
import { formatColor } from '@fower/color-helper'; | ||
import { styleSheet } from '@fower/sheet'; | ||
import { parse } from '@fower/css-object-processor'; | ||
import { isEmptyObj, isPercentNumber, isNumber, jsKeyToCssKey, objectToClassName } from '@fower/utils'; | ||
@@ -93,2 +92,4 @@ function _defineProperties(target, props) { | ||
var colorKeys = ['color', 'backgroundColor', 'borderColor']; | ||
var reactProps = ['children', 'onClick', 'onChange', 'onBlur', 'className', 'placeholder']; | ||
@@ -101,2 +102,4 @@ /** | ||
function Parser(props) { | ||
var _store$config$mode; | ||
if (props === void 0) { | ||
@@ -119,3 +122,3 @@ props = {}; | ||
if (store.config.autoDarkMode) { | ||
if ((_store$config$mode = store.config.mode) != null && _store$config$mode.autoDarkMode) { | ||
this.autoDarkMode(); | ||
@@ -135,10 +138,8 @@ } | ||
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos, | ||
theme = _this$config.theme; | ||
var _ref = theme || {}, | ||
breakpoints = _ref.breakpoints, | ||
modes = _ref.modes; | ||
theme = _this$config.theme, | ||
mode = _this$config.mode; | ||
var modeList = mode.modeList; | ||
var breakpoints = theme.breakpoints || {}; | ||
var breakpointKeys = Object.keys(breakpoints); | ||
var modeKeys = modes || []; | ||
var modeKeys = modeList || []; | ||
var pseudoKeys = pseudos; | ||
@@ -241,64 +242,85 @@ var _props$excludedProps = props.excludedProps, | ||
_proto.autoDarkMode = function autoDarkMode() { | ||
var colorMap = { | ||
white: 'black', | ||
black: 'white', | ||
'50': '900', | ||
'100': '800', | ||
'200': '700', | ||
'300': '600', | ||
'400': '500', | ||
'500': '400', | ||
'600': '300', | ||
'700': '200', | ||
'800': '100', | ||
'900': '50' | ||
}; | ||
var colorKeys = ['color', 'backgroundColor', 'borderColor']; | ||
var darkAtoms = []; | ||
/** TODO: hack for auto dark mode, need to refactor */ | ||
_proto.getAutoDarkModeAtom = function getAutoDarkModeAtom(atom) { | ||
var _options$style; | ||
for (var _iterator3 = _createForOfIteratorHelperLoose(this.atoms), _step3; !(_step3 = _iterator3()).done;) { | ||
var atom = _step3.value; | ||
if (atom.meta.mode) return null; | ||
if (!atom.style) return null; | ||
var entries = Object.entries(atom.style); | ||
if (!(entries != null && entries.length)) return null; | ||
var options = {}; | ||
var darkColor = ''; | ||
var config = store.config; | ||
var mappings = config.mode.autoDarkMode.mappings; | ||
var colors = config.theme.colors; | ||
var _entries$ = entries[0], | ||
colorKey = _entries$[0], | ||
colorName = _entries$[1]; // check is valid color key | ||
if (colorKeys.includes(atom.type) && !atom.meta.mode) { | ||
var find = this.atoms.find(function (i) { | ||
return colorKeys.includes(i.type) && i.meta.mode === 'dark'; | ||
}); | ||
if (find) continue; | ||
var entries = Object.entries(atom.style); | ||
if (!(entries != null && entries.length)) continue; | ||
var _entries$ = entries[0], | ||
colorValue = _entries$[1]; | ||
if (!colorValue) continue; | ||
if (!colorKeys.includes(colorKey)) return null; // only color in theme is valid | ||
var _ref2 = colorValue.match(/^([a-z]+)(\d+)$/i) || [], | ||
mapKey = _ref2[2]; | ||
if (!colors[colorName]) return null; // if scale is existed, scale should be 100,200,300,400... | ||
if (['white', 'black'].includes(colorValue)) mapKey = colorValue; | ||
var str = JSON.stringify(atom).replace(new RegExp("" + mapKey, 'g'), colorMap[mapKey]); | ||
if (mapKey === 'white') str = str.replace(/White/g, 'Black'); | ||
if (mapKey === 'black') str = str.replace(/Black/g, 'White'); | ||
var cloned = JSON.parse(str); | ||
var _ref = colorName.match(/^([a-z]+)(\d+)$/i) || [], | ||
scale = _ref[2]; // is disable, eg: { red200: false} | ||
var _darkAtom = new Atom(_extends({}, cloned, { | ||
propKey: cloned.propKey + '--dark', | ||
meta: _extends({}, cloned.meta, { | ||
mode: 'dark' | ||
}) | ||
})); | ||
var cachedAtom = atomCache.get(_darkAtom.id); | ||
if (mappings[colorName] === false) return null; | ||
if (cachedAtom) { | ||
darkAtoms.push(cachedAtom); | ||
} else { | ||
darkAtoms.push(_darkAtom); | ||
} | ||
if (mappings[colorName]) { | ||
darkColor = mappings[colorName]; | ||
} else { | ||
darkColor = colorName.replace(scale, mappings[scale]); | ||
} | ||
var isColor = colorKey === 'color'; | ||
var isBgColor = colorKey === 'backgroundColor'; | ||
var isBorderColor = colorKey === 'borderColor'; | ||
if (colors[darkColor]) { | ||
if (isColor) { | ||
options.propKey = darkColor; | ||
} else if (isBgColor) { | ||
options.propKey = "bg" + upFirst(darkColor); | ||
} else if (isBorderColor) { | ||
options.propKey = "border" + upFirst(darkColor); | ||
} | ||
options.propValue = true; | ||
} else { | ||
if (isColor) { | ||
options.propKey = 'color'; | ||
options.propValue = darkColor; | ||
} else if (isBgColor) { | ||
options.propKey = 'bg'; | ||
options.propValue = darkColor; | ||
} else if (isBorderColor) { | ||
options.propKey = 'borderColor'; | ||
options.propValue = darkColor; | ||
} | ||
} | ||
for (var _i2 = 0, _darkAtoms = darkAtoms; _i2 < _darkAtoms.length; _i2++) { | ||
var darkAtom = _darkAtoms[_i2]; | ||
this.addAtom(darkAtom); | ||
options.style = (_options$style = {}, _options$style[colorKey] = darkColor, _options$style); | ||
return new Atom(_extends({}, options, { | ||
meta: _extends({}, atom.meta, { | ||
mode: 'dark' | ||
}) | ||
})); | ||
}; | ||
_proto.autoDarkMode = function autoDarkMode() { | ||
for (var _iterator3 = _createForOfIteratorHelperLoose(this.atoms), _step3; !(_step3 = _iterator3()).done;) { | ||
var atom = _step3.value; | ||
var find = this.atoms.find(function (i) { | ||
return colorKeys.includes(i.type) && i.meta.mode === 'dark'; | ||
}); | ||
if (find) continue; | ||
var darkAtom = this.getAutoDarkModeAtom(atom); | ||
if (!darkAtom) continue; | ||
var cachedAtom = store.atomCache.get(darkAtom.id); | ||
if (cachedAtom) { | ||
this.addAtom(cachedAtom); | ||
} else { | ||
this.addAtom(darkAtom); | ||
} | ||
} | ||
@@ -358,5 +380,5 @@ } | ||
colorPostfix = meta.colorPostfix; | ||
return Object.entries(style).reduce(function (r, _ref3) { | ||
var key = _ref3[0], | ||
value = _ref3[1]; | ||
return Object.entries(style).reduce(function (r, _ref2) { | ||
var key = _ref2[0], | ||
value = _ref2[1]; | ||
var cssKey = jsKeyToCssKey(key); | ||
@@ -366,9 +388,13 @@ var posfix = important ? ' !important' : ''; | ||
if (colorPostfix) { | ||
value = formatColor(colors[value] || value, colorPostfix); | ||
} else { | ||
value = _this.formatCssValue(cssKey, colors[value] || value); | ||
try { | ||
if (colorPostfix) { | ||
value = formatColor((colors == null ? void 0 : colors[value]) || value, colorPostfix); | ||
} else { | ||
value = _this.formatCssValue(cssKey, (colors == null ? void 0 : colors[value]) || value); | ||
} | ||
return r + (cssKey + ": " + value + posfix + ";"); | ||
} catch (error) { | ||
return ''; | ||
} | ||
return r + (cssKey + ": " + value + posfix + ";"); | ||
}, ''); | ||
@@ -381,4 +407,4 @@ }; | ||
// if not cached, let's cache it | ||
if (!atomCache.get(atom.id)) { | ||
atomCache.set(atom.id, atom); | ||
if (!store.atomCache.get(atom.id)) { | ||
store.atomCache.set(atom.id, atom); | ||
} | ||
@@ -388,5 +414,5 @@ | ||
var _ref4 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {}, | ||
_ref4$modes = _ref4.modes, | ||
modes = _ref4$modes === void 0 ? {} : _ref4$modes; | ||
var _ref3 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {}, | ||
_ref3$modes = _ref3.modes, | ||
modes = _ref3$modes === void 0 ? {} : _ref3$modes; | ||
@@ -396,4 +422,4 @@ var entries = Object.entries(modes); | ||
for (var _i3 = 0, _entries2 = entries; _i3 < _entries2.length; _i3++) { | ||
var _entries2$_i = _entries2[_i3], | ||
for (var _i2 = 0, _entries2 = entries; _i2 < _entries2.length; _i2++) { | ||
var _entries2$_i = _entries2[_i2], | ||
mode = _entries2$_i[0], | ||
@@ -463,3 +489,3 @@ colors = _entries2$_i[1]; | ||
var cachedAtom = atomCache.get(atom.id); | ||
var cachedAtom = store.atomCache.get(atom.id); | ||
@@ -519,5 +545,5 @@ if (cachedAtom) { | ||
if (selectorType === 'pseudo' && option.meta) { | ||
var _ref5 = selector.match(/(:+)(.+)/) || [], | ||
pseudoPrefix = _ref5[1], | ||
pseudo = _ref5[2]; | ||
var _ref4 = selector.match(/(:+)(.+)/) || [], | ||
pseudoPrefix = _ref4[1], | ||
pseudo = _ref4[2]; | ||
@@ -546,3 +572,3 @@ option.meta.pseudoPrefix = pseudoPrefix; | ||
var cachedAtom = atomCache.get(atom.id); | ||
var cachedAtom = store.atomCache.get(atom.id); | ||
@@ -615,7 +641,7 @@ if (cachedAtom) { | ||
var colors = store.theme.colors; | ||
var style = Object.entries(atom.style).reduce(function (c, _ref6) { | ||
var style = Object.entries(atom.style).reduce(function (c, _ref5) { | ||
var _extends3; | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
var key = _ref5[0], | ||
value = _ref5[1]; | ||
@@ -643,4 +669,4 @@ var cssValue = _this3.formatCssValue(jsKeyToCssKey(key), colors[value] || value); | ||
var _this$config$theme$mo = this.config.theme.modePrefix, | ||
modePrefix = _this$config$theme$mo === void 0 ? '' : _this$config$theme$mo; | ||
var _this$config$mode$cla = this.config.mode.classPrefix, | ||
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla; | ||
var rules = []; // sort responsive style | ||
@@ -686,3 +712,3 @@ | ||
if (pseudo) selector = selector + pseudoPrefix + pseudo; | ||
if (mode) selector = "." + modePrefix + mode + " " + selector; | ||
if (mode) selector = "." + classPrefix + mode + " " + selector; | ||
if (childSelector) selector = selector + " " + childSelector; | ||
@@ -698,5 +724,4 @@ rule = selector + " { " + _this4.styleToString(style, atom.meta) + " }"; | ||
if (_ret === "continue") continue; | ||
} // console.log('this.atoms-----:', this.atoms) | ||
} | ||
return rules; | ||
@@ -712,7 +737,7 @@ }; | ||
var parsedProps = entries.reduce(function (result, _ref7) { | ||
var key = _ref7[0], | ||
value = _ref7[1]; | ||
var parsedProps = entries.reduce(function (result, _ref6) { | ||
var key = _ref6[0], | ||
value = _ref6[1]; | ||
var find = atoms.find(function (atom) { | ||
return [atom.propKey, atom.key, atom.id, 'css'].includes(key); | ||
return [atom.propKey, atom.key, 'css'].includes(key); | ||
}); | ||
@@ -719,0 +744,0 @@ if (!find) result[key] = value; |
{ | ||
"name": "@fower/parser", | ||
"version": "1.29.0", | ||
"version": "1.30.0", | ||
"license": "MIT", | ||
@@ -24,11 +24,10 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@fower/atom": "^1.29.0", | ||
"@fower/cache": "^1.29.0", | ||
"@fower/css-object-processor": "^1.29.0", | ||
"@fower/sheet": "^1.29.0", | ||
"@fower/store": "^1.29.0", | ||
"@fower/types": "^1.29.0", | ||
"@fower/utils": "^1.29.0" | ||
"@fower/atom": "^1.30.0", | ||
"@fower/css-object-processor": "^1.30.0", | ||
"@fower/sheet": "^1.30.0", | ||
"@fower/store": "^1.30.0", | ||
"@fower/types": "^1.30.0", | ||
"@fower/utils": "^1.30.0" | ||
}, | ||
"gitHead": "ac5536937911f0fde336b2830f5991c645608f86" | ||
"gitHead": "c79b3d7a6f046ef1d309772e85e20a4440d488ba" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158121
6
1389
- Removed@fower/cache@^1.29.0
- Removed@fower/cache@1.29.0(transitive)
Updated@fower/atom@^1.30.0
Updated@fower/sheet@^1.30.0
Updated@fower/store@^1.30.0
Updated@fower/types@^1.30.0
Updated@fower/utils@^1.30.0