fela-monolithic
Advanced tools
Comparing version 4.2.6 to 4.3.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('hyphenate-style-name')) : | ||
typeof define === 'function' && define.amd ? define(['hyphenate-style-name'], factory) : | ||
(global.FelaMonolithic = factory(global.hyphenateStyleName)); | ||
}(this, function (hyphenateStyleName) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('css-in-js-utils/lib/cssifyDeclaration')) : | ||
typeof define === 'function' && define.amd ? define(['css-in-js-utils/lib/cssifyDeclaration'], factory) : | ||
(global.FelaMonolithic = factory(global.cssifyDeclaration)); | ||
}(this, function (cssifyDeclaration) { 'use strict'; | ||
hyphenateStyleName = 'default' in hyphenateStyleName ? hyphenateStyleName['default'] : hyphenateStyleName; | ||
cssifyDeclaration = 'default' in cssifyDeclaration ? cssifyDeclaration['default'] : cssifyDeclaration; | ||
@@ -45,15 +45,4 @@ var babelHelpers = {}; | ||
babelHelpers.toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
babelHelpers; | ||
/* weak */ | ||
function cssifyMediaQueryRules(mediaQuery, mediaQueryRules) { | ||
@@ -67,3 +56,2 @@ if (mediaQueryRules) { | ||
/* weak */ | ||
function generateCombinedMediaQuery(currentMediaQuery, nestedMediaQuery) { | ||
@@ -73,10 +61,6 @@ if (currentMediaQuery.length === 0) { | ||
} | ||
return currentMediaQuery + " and " + nestedMediaQuery; | ||
} | ||
function generateCSSDeclaration(property, value) { | ||
return hyphenateStyleName(property) + ':' + value; | ||
} | ||
/* weak */ | ||
function generateCSSRule(selector, cssDeclaration) { | ||
@@ -86,3 +70,2 @@ return selector + "{" + cssDeclaration + "}"; | ||
/* weak */ | ||
function getCSSSelector(className) { | ||
@@ -94,3 +77,2 @@ var pseudo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
/* weak */ | ||
function isMediaQuery(property) { | ||
@@ -100,12 +82,12 @@ return property.substr(0, 6) === '@media'; | ||
/* weak */ | ||
var regex = /^(:|\[|>|&)/; | ||
function isNestedSelector(property) { | ||
return property.match(/^(:|\[|>|&)/g) !== null; | ||
return regex.test(property); | ||
} | ||
function isUndefinedValue(value) { | ||
return value === undefined || typeof value === 'string' && value.indexOf('undefined') > -1; | ||
return value === undefined || typeof value === 'string' && value.indexOf('undefined') !== -1; | ||
} | ||
/* weak */ | ||
function normalizeNestedProperty(nestedProperty) { | ||
@@ -119,12 +101,11 @@ if (nestedProperty.charAt(0) === '&') { | ||
/* weak */ | ||
var RULE_TYPE = 1; | ||
function generateClassName(str, prefix) { | ||
if (str.className) { | ||
var name = prefix + str.className; | ||
delete str.className; | ||
function generateClassName(style, prefix) { | ||
if (style.className) { | ||
var name = prefix + style.className; | ||
delete style.className; | ||
return name; | ||
} | ||
var stringified = JSON.stringify(str); | ||
var stringified = JSON.stringify(style); | ||
var val = 5381; | ||
@@ -140,3 +121,3 @@ var i = stringified.length; | ||
function addMonolithicClassNames(renderer) { | ||
function useMonolithicRenderer(renderer) { | ||
renderer._parseMonolithicRules = function (selector, styles) { | ||
@@ -156,7 +137,7 @@ var mediaSelector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
} else if (type === 'number' || type === 'string') { | ||
decs.push(generateCSSDeclaration(key, value)); | ||
decs.push(cssifyDeclaration(key, value)); | ||
return 'continue'; | ||
} else if (Array.isArray(value)) { | ||
value.forEach(function (val) { | ||
return decs.push(generateCSSDeclaration(key, val)); | ||
return decs.push(cssifyDeclaration(key, val)); | ||
}); | ||
@@ -206,2 +187,3 @@ return 'continue'; | ||
} | ||
var className = generateClassName(style, renderer.selectorPrefix || 'fela-'); | ||
@@ -257,5 +239,5 @@ var selector = getCSSSelector(className); | ||
var monolithic = (function () { | ||
return addMonolithicClassNames; | ||
}); | ||
function monolithic() { | ||
return useMonolithicRenderer; | ||
} | ||
@@ -262,0 +244,0 @@ return monolithic; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("hyphenate-style-name")):"function"==typeof define&&define.amd?define(["hyphenate-style-name"],n):e.FelaMonolithic=n(e.hyphenateStyleName)}(this,function(e){"use strict";function n(e,n){return n?"@media "+e+"{"+n+"}":""}function r(e,n){return 0===e.length?n:e+" and "+n}function t(n,r){return e(n)+":"+r}function i(e,n){return e+"{"+n+"}"}function o(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"."+e+n}function u(e){return"@media"===e.substr(0,6)}function a(e){return null!==e.match(/^(:|\[|>|&)/g)}function c(e){return void 0===e||"string"==typeof e&&e.indexOf("undefined")>-1}function f(e){return"&"===e.charAt(0)?e.slice(1):e}function l(e,n){if(e.className){var r=n+e.className;return delete e.className,r}for(var t=JSON.stringify(e),i=5381,o=t.length;o;)i=33*i^t.charCodeAt(--o);return n+(i>>>0).toString(36)}function s(e){return e._parseMonolithicRules=function(n,o){var l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",s=[],y=[],d=[],p=function(i){var p=o[i],m="undefined"==typeof p?"undefined":h.typeof(p);if(c(p))return"continue";if("number"===m||"string"===m)return s.push(t(i,p)),"continue";if(Array.isArray(p))return p.forEach(function(e){return s.push(t(i,e))}),"continue";if(a(i))return e._parseMonolithicRules(n+f(i),p,l).rules.forEach(function(e){return y.push(e)}),"continue";if(u(i)){var v=r(l,i.slice(6).trim()),g=e._parseMonolithicRules(n,p,v);return d.push({rules:g.rules,media:v}),g.media.forEach(function(e){return d.push(e)}),"continue"}return e._parseMonolithicRules(n+" "+i,p,l).rules.forEach(function(e){return y.push(e)}),"continue"};for(var m in o){p(m)}return y.unshift(i(n,s.join(";"))),{rules:y,media:d}},e._renderStyleToClassNames=function(r){if(!Object.keys(r).length)return"";var t=l(r,e.selectorPrefix||"fela-"),i=o(t);if(e.cache[t])return" "+t;var u=e._parseMonolithicRules(i,r),a=u.rules,c=u.media,f=a.join("");return e.cache[t]||(e.cache[t]=""),a.length&&(e.rules+=f,e.cache[t]+=f,e._emitChange({selector:i,declaration:f,type:y})),c.length&&c.forEach(function(r){var o=r.media,u=r.rules.join("");e.mediaRules.hasOwnProperty(o)||(e.mediaRules[o]=""),e.mediaRules[o]+=u,e.cache[t]+=n(o,u),e._emitChange({selector:i,declaration:u,media:o,type:y})})," "+t},e}e="default"in e?e.default:e;var h={};h.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h.defineProperty=function(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e},h.extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},h.toConsumableArray=function(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)};var y=1,d=function(){return s};return d}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("css-in-js-utils/lib/cssifyDeclaration")):"function"==typeof define&&define.amd?define(["css-in-js-utils/lib/cssifyDeclaration"],n):e.FelaMonolithic=n(e.cssifyDeclaration)}(this,function(e){"use strict";function n(e,n){return n?"@media "+e+"{"+n+"}":""}function r(e,n){return 0===e.length?n:e+" and "+n}function t(e,n){return e+"{"+n+"}"}function i(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"."+e+n}function o(e){return"@media"===e.substr(0,6)}function u(e){return h.test(e)}function c(e){return void 0===e||"string"==typeof e&&e.indexOf("undefined")!==-1}function a(e){return"&"===e.charAt(0)?e.slice(1):e}function f(e,n){if(e.className){var r=n+e.className;return delete e.className,r}for(var t=JSON.stringify(e),i=5381,o=t.length;o;)i=33*i^t.charCodeAt(--o);return n+(i>>>0).toString(36)}function s(s){return s._parseMonolithicRules=function(n,i){var f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",l=[],h=[],p=[],y=function(t){var y=i[t],m="undefined"==typeof y?"undefined":d.typeof(y);if(c(y))return"continue";if("number"===m||"string"===m)return l.push(e(t,y)),"continue";if(Array.isArray(y))return y.forEach(function(n){return l.push(e(t,n))}),"continue";if(u(t))return s._parseMonolithicRules(n+a(t),y,f).rules.forEach(function(e){return h.push(e)}),"continue";if(o(t)){var b=r(f,t.slice(6).trim()),v=s._parseMonolithicRules(n,y,b);return p.push({rules:v.rules,media:b}),v.media.forEach(function(e){return p.push(e)}),"continue"}return s._parseMonolithicRules(n+" "+t,y,f).rules.forEach(function(e){return h.push(e)}),"continue"};for(var m in i){y(m)}return h.unshift(t(n,l.join(";"))),{rules:h,media:p}},s._renderStyleToClassNames=function(e){if(!Object.keys(e).length)return"";var r=f(e,s.selectorPrefix||"fela-"),t=i(r);if(s.cache[r])return" "+r;var o=s._parseMonolithicRules(t,e),u=o.rules,c=o.media,a=u.join("");return s.cache[r]||(s.cache[r]=""),u.length&&(s.rules+=a,s.cache[r]+=a,s._emitChange({selector:t,declaration:a,type:p})),c.length&&c.forEach(function(e){var i=e.media,o=e.rules.join("");s.mediaRules.hasOwnProperty(i)||(s.mediaRules[i]=""),s.mediaRules[i]+=o,s.cache[r]+=n(i,o),s._emitChange({selector:t,declaration:o,media:i,type:p})})," "+r},s}function l(){return s}e="default"in e?e.default:e;var d={};d.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d.defineProperty=function(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e},d.extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};var h=/^(:|\[|>|&)/,p=1;return l}); |
{ | ||
"name": "fela-monolithic", | ||
"version": "4.2.6", | ||
"version": "4.3.0", | ||
"description": "Fela enhancer for having monolithic classnames", | ||
@@ -25,4 +25,7 @@ "module": "index.es2015.js", | ||
"peerDependencies": { | ||
"fela": "4.2.6" | ||
"fela": "4.3.0" | ||
}, | ||
"dependencies": { | ||
"css-in-js-utils": "^1.0.3" | ||
} | ||
} |
# fela-monolithic | ||
<img alt="npm downloads" src="https://img.shields.io/npm/dm/fela-monolithic.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-1.27kb-brightgreen.svg"> | ||
<img alt="gzipped size" src="https://img.shields.io/badge/gzipped-1.22kb-brightgreen.svg"> | ||
@@ -18,5 +18,5 @@ The monolithic enhancer will use unique class names instead of atomic ones. | ||
<!-- Fela (Development): Unminified version including all warnings --> | ||
<script src="https://unpkg.com/fela-monolithic@4.2.6/dist/fela-monolithic.js"></script> | ||
<script src="https://unpkg.com/fela-monolithic@4.3.0/dist/fela-monolithic.js"></script> | ||
<!-- Fela (Production): Minified version --> | ||
<script src="https://unpkg.com/fela-monolithic@4.2.6/dist/fela-monolithic.min.js"></script> | ||
<script src="https://unpkg.com/fela-monolithic@4.3.0/dist/fela-monolithic.min.js"></script> | ||
``` | ||
@@ -23,0 +23,0 @@ |
Sorry, the diff of this file is not supported yet
26475
2
189
+ Addedcss-in-js-utils@^1.0.3
+ Addedcss-in-js-utils@1.0.3(transitive)
+ Addedfela@4.3.0(transitive)
+ Addedhyphenate-style-name@1.1.0(transitive)
- Removedfela@4.2.6(transitive)
- Removedhyphenate-style-name@1.0.1(transitive)