Socket
Socket
Sign inDemoInstall

fela-plugin-unit

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-plugin-unit - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

397

dist/fela-plugin-unit.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.FelaPluginUnit = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.FelaPluginUnit = factory());
}(this, function () { 'use strict';
var babelHelpers = {};
babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var babelHelpers = {};
babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
babelHelpers.classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
babelHelpers.extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
babelHelpers.createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
return target;
};
}();
babelHelpers.extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
babelHelpers;
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; }
babelHelpers;
var emptyFunction = __commonjs(function (module) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; }
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
var emptyFunction = __commonjs(function (module) {
"use strict";
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function makeEmptyFunction(arg) {
return function () {
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
module.exports = emptyFunction;
});
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
var require$$0 = (emptyFunction && typeof emptyFunction === 'object' && 'default' in emptyFunction ? emptyFunction['default'] : emptyFunction);
module.exports = emptyFunction;
});
var warning = __commonjs(function (module) {
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var require$$0 = (emptyFunction && typeof emptyFunction === 'object' && 'default' in emptyFunction ? emptyFunction['default'] : emptyFunction);
'use strict';
var warning = __commonjs(function (module) {
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var emptyFunction = require$$0;
'use strict';
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var emptyFunction = require$$0;
var warning = emptyFunction;
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
if (true) {
warning = function warning(condition, format) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var warning = emptyFunction;
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (true) {
warning = function warning(condition, format) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
if (format.indexOf('Failed Composite propType: ') === 0) {
return; // Ignore CompositeComponent proptype check.
}
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
}
};
}
if (format.indexOf('Failed Composite propType: ') === 0) {
return; // Ignore CompositeComponent proptype check.
}
module.exports = warning;
});
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
}
};
}
var warning$1 = (warning && typeof warning === 'object' && 'default' in warning ? warning['default'] : warning);
module.exports = warning;
});
var index$1 = __commonjs(function (module) {
'use strict';
var warning$1 = (warning && typeof warning === 'object' && 'default' in warning ? warning['default'] : warning);
var uppercasePattern = /[A-Z]/g;
var msPattern = /^ms-/;
var index = __commonjs(function (module) {
var unitlessProperties = {
animationIterationCount: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridColumn: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
function hyphenateStyleName(string) {
return string.replace(uppercasePattern, '-$&').toLowerCase().replace(msPattern, '-ms-');
}
// SVG-related properties
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
};
module.exports = hyphenateStyleName;
});
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
var require$$0$1 = (index$1 && typeof index$1 === 'object' && 'default' in index$1 ? index$1['default'] : index$1);
function getPrefixedKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.slice(1);
}
var index = __commonjs(function (module) {
var hyphenateStyleName = require$$0$1;
// add all prefixed properties as well
Object.keys(unitlessProperties).forEach(function (property) {
prefixes.forEach(function (prefix) {
unitlessProperties[getPrefixedKey(prefix, property)] = true;
});
});
var unitlessProperties = {
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
fontWeight: true,
lineHeight: true,
opacity: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
module.exports = function (property) {
return unitlessProperties[property];
};
});
// SVG-related properties
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
};
var isUnitlessCSSProperty = (index && typeof index === 'object' && 'default' in index ? index['default'] : index);
var prefixedUnitlessProperties = {
animationIterationCount: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridColumn: true,
order: true,
lineClamp: true
};
function addUnitIfNeeded(property, value, unit) {
var valueType = typeof value === 'undefined' ? 'undefined' : babelHelpers.typeof(value);
if (valueType === 'number' || valueType === 'string' && value == parseFloat(value)) {
// eslint-disable-line
value += unit;
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
function getPrefixedKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.slice(1);
}
return value;
}
// add all prefixed properties to the unitless properties
Object.keys(prefixedUnitlessProperties).forEach(function (property) {
unitlessProperties[property] = true;
function unit() {
var unit = arguments.length <= 0 || arguments[0] === undefined ? 'px' : arguments[0];
prefixes.forEach(function (prefix) {
unitlessProperties[getPrefixedKey(prefix, property)] = true;
});
});
warning$1(unit.match(/ch|em|ex|rem|vh|vw|vmin|vmax|px|cm|mm|in|pc|pt|mozmm|%/) !== null, 'You are using an invalid unit `' + unit + '`. Consider using one of the following ch, em, ex, rem, vh, vw, vmin, vmax, px, cm, mm, in, pc, pt, mozmm or %.');
// add all hypenated properties as well
Object.keys(unitlessProperties).forEach(function (property) {
unitlessProperties[hyphenateStyleName(property)] = true;
});
return function (pluginInterface) {
var style = pluginInterface.style;
var processStyle = pluginInterface.processStyle;
module.exports = function (property) {
return unitlessProperties[property];
};
});
var isUnitlessCSSProperty = (index && typeof index === 'object' && 'default' in index ? index['default'] : index);
function addUnitIfNeeded(property, value, unit) {
var valueType = typeof value === 'undefined' ? 'undefined' : babelHelpers.typeof(value);
if (valueType === 'number' || valueType === 'string' && value == parseFloat(value)) {
// eslint-disable-line
value += unit;
}
return value;
}
function addUnit(style, unit) {
Object.keys(style).forEach(function (property) {

@@ -250,5 +244,3 @@ if (!isUnitlessCSSProperty(property)) {

} else if (value instanceof Object) {
style[property] = processStyle(babelHelpers.extends({}, pluginInterface, {
style: value
}));
style[property] = addUnit(value, unit);
} else {

@@ -261,8 +253,17 @@ style[property] = addUnitIfNeeded(property, value, unit);

return style;
};
}
}
return unit;
var unit = (function () {
var unit = arguments.length <= 0 || arguments[0] === undefined ? 'px' : arguments[0];
warning$1(unit.match(/ch|em|ex|rem|vh|vw|vmin|vmax|px|cm|mm|in|pc|pt|mozmm|%/) !== null, 'You are using an invalid unit `' + unit + '`. Consider using one of the following ch, em, ex, rem, vh, vw, vmin, vmax, px, cm, mm, in, pc, pt, mozmm or %.');
return function (style) {
return addUnit(style, unit);
};
})
return unit;
}));
//# sourceMappingURL=fela-plugin-unit.js.map

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.FelaPluginUnit=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,e,n){var o="undefined"==typeof e?"undefined":r["typeof"](e);return("number"===o||"string"===o&&e==parseFloat(e))&&(e+=n),e}function n(){var t=arguments.length<=0||void 0===arguments[0]?"px":arguments[0];return function(n){var o=n.style,i=n.processStyle;return Object.keys(o).forEach(function(u){if(!a(u)){var f=o[u];Array.isArray(f)?o[u]=f.map(function(n){return e(u,n,t)}):f instanceof Object?o[u]=i(r["extends"]({},n,{style:f})):o[u]=e(u,f,t)}}),o}}var r={};r["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},r.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r.createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),r["extends"]=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};var o=t(function(t){function e(t){return function(){return t}}var n=function(){};n.thatReturns=e,n.thatReturnsFalse=e(!1),n.thatReturnsTrue=e(!0),n.thatReturnsNull=e(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(t){return t},t.exports=n}),i=o&&"object"==typeof o&&"default"in o?o["default"]:o,u=(t(function(t){var e=i,n=e;t.exports=n}),t(function(t){function e(t,e){return t+e.charAt(0).toUpperCase()+e.slice(1)}var n={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},r=["Webkit","ms","Moz","O"];Object.keys(n).forEach(function(t){r.forEach(function(r){n[e(r,t)]=!0})}),t.exports=function(t){return n[t]}})),a=u&&"object"==typeof u&&"default"in u?u["default"]:u;return n});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.FelaPluginUnit=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,e,n){var r="undefined"==typeof e?"undefined":o["typeof"](e);return("number"===r||"string"===r&&e==parseFloat(e))&&(e+=n),e}function n(t,o){return Object.keys(t).forEach(function(r){if(!c(r)){var i=t[r];Array.isArray(i)?t[r]=i.map(function(t){return e(r,t,o)}):i instanceof Object?t[r]=n(i,o):t[r]=e(r,i,o)}}),t}var o={};o["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o["extends"]=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t};var r=t(function(t){function e(t){return function(){return t}}var n=function(){};n.thatReturns=e,n.thatReturnsFalse=e(!1),n.thatReturnsTrue=e(!0),n.thatReturnsNull=e(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(t){return t},t.exports=n}),i=r&&"object"==typeof r&&"default"in r?r["default"]:r,u=(t(function(t){var e=i,n=e;t.exports=n}),t(function(t){function e(t){return t.replace(n,"-$&").toLowerCase().replace(o,"-ms-")}var n=/[A-Z]/g,o=/^ms-/;t.exports=e})),f=u&&"object"==typeof u&&"default"in u?u["default"]:u,a=t(function(t){function e(t,e){return t+e.charAt(0).toUpperCase()+e.slice(1)}var n=f,o={borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},r={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,order:!0,lineClamp:!0},i=["Webkit","ms","Moz","O"];Object.keys(r).forEach(function(t){o[t]=!0,i.forEach(function(n){o[e(n,t)]=!0})}),Object.keys(o).forEach(function(t){o[n(t)]=!0}),t.exports=function(t){return o[t]}}),c=a&&"object"==typeof a&&"default"in a?a["default"]:a,s=function(){var t=arguments.length<=0||void 0===arguments[0]?"px":arguments[0];return function(e){return n(e,t)}};return s});
{
"name": "fela-plugin-unit",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Fela plugin to automatically add units if required",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,4 +0,29 @@

# Unit plugin for Fela
# fela-plugin-unit
Plugin that automatically adds units to values if needed.
Check out the [Fela repository](https://github.com/rofrischmann/fela) for further information.
Always writing length values as string with a value applied seems not like the JavaScript way to do it. You can also use mathematics to process number values. <br>
It is aware of unitless properties such as `lineHeight` and also adds units to multiple values inside an array.
```javascript
{
width: 25,
lineHeight: 1.4,
height: '53'
}
```
would be transformed into:
```javascript
{
width: '25px',
lineHeight: 1.4,
height: '53px'
}
```
### Configuration
By default it adds `px` to the value, but you may use units other than that.
```javascript
import unit from 'fela-plugin-unit'
const plugin = unit('em')
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc