Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bss

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bss - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

90

bss.esm.js

@@ -64,2 +64,3 @@ var pseudos = [

bs : 'boxShadow',
bi : 'backgroundImage',
c : 'color',

@@ -109,2 +110,4 @@ d : 'display',

var isProp = /^-?-?[a-z][a-z-_0-9]*$/i;
var memoize = function (fn, cache) {

@@ -154,18 +157,2 @@ if ( cache === void 0 ) cache = {};

function sanitize(styles) {
return Object.keys(styles).reduce(function (acc, key) {
var value = styles[key];
if (!value && value !== 0 && value !== '')
{ return acc }
if (key === 'content' && value.charAt(0) !== '"')
{ acc[key] = '"' + value + '"'; }
else
{ add(acc, key, value); }
return acc
}, {})
}
function assign(obj, obj2) {

@@ -340,5 +327,12 @@ for (var key in obj2) {

writable: true,
value: function ValueOf() {
value: function() {
return '.' + this.class
}
},
toString: {
configurable: true,
writable: true,
value: function() {
return bss.valueOf()
}
}

@@ -454,3 +448,5 @@ });

var b = chain(this);
if (value || style)
if (isTagged(value))
{ b.__style[name] = parse.apply(null, arguments); }
else if (value || style)
{ b.__style[name + (style ? '(' + value + ')' : '')] = parse(style || value); }

@@ -496,5 +492,7 @@ return b

configurable: true,
value: function Helper() {
value: function Helper(input) {
var b = chain(this);
var result = styling.apply(null, arguments);
var result = isTagged(input)
? styling(raw(input, arguments))
: styling.apply(null, arguments);
assign(b.__style, result.__style);

@@ -533,3 +531,9 @@ return b

return string.trim().split(/;|\n/).reduce(function (acc, line) {
if (!line)
{ return acc }
line = last + line.trim();
var ref = line.replace(/[ :]+/, ' ').split(' ');
var key = ref[0];
var tokens = ref.slice(1);
last = line.charAt(line.length - 1) === ',' ? line : '';

@@ -539,11 +543,7 @@ if (last)

if (line.charAt(0) === ',') {
acc[prev] += line;
if (line.charAt(0) === ',' || !isProp.test(key)) {
acc[prev] += ' ' + line;
return acc
}
var ref = line.replace(/[ :]+/, ' ').split(' ');
var key = ref[0];
var tokens = ref.slice(1);
if (!key)

@@ -588,3 +588,2 @@ { return acc }

function parse(input, value) {
var arguments$1 = arguments;
var obj;

@@ -597,7 +596,4 @@

return stringToObject(input)
} else if (Array.isArray(input) && typeof input[0] === 'string') {
var str = '';
for (var i = 0; i < input.length; i++)
{ str += input[i] + (arguments$1[i + 1] || ''); }
return stringToObject(str)
} else if (isTagged(input)) {
return stringToObject(raw(input, arguments))
}

@@ -608,3 +604,33 @@

function isTagged(input) {
return Array.isArray(input) && typeof input[0] === 'string'
}
function raw(input, args) {
var str = '';
for (var i = 0; i < input.length; i++)
{ str += input[i] + (args[i + 1] || ''); }
return str
}
function sanitize(styles) {
return Object.keys(styles).reduce(function (acc, key) {
var value = styles[key];
key = shorts[key] || key;
if (!value && value !== 0 && value !== '')
{ return acc }
if (key === 'content' && value.charAt(0) !== '"')
{ acc[key] = '"' + value + '"'; }
else if (typeof value === 'object')
{ acc[key] = sanitize(value); }
else
{ add(acc, key, value); }
return acc
}, {})
}
export default bss;
//# sourceMappingURL=bss.esm.js.map

@@ -70,2 +70,3 @@ (function (global, factory) {

bs : 'boxShadow',
bi : 'backgroundImage',
c : 'color',

@@ -115,2 +116,4 @@ d : 'display',

var isProp = /^-?-?[a-z][a-z-_0-9]*$/i;
var memoize = function (fn, cache) {

@@ -160,18 +163,2 @@ if ( cache === void 0 ) cache = {};

function sanitize(styles) {
return Object.keys(styles).reduce(function (acc, key) {
var value = styles[key];
if (!value && value !== 0 && value !== '')
{ return acc }
if (key === 'content' && value.charAt(0) !== '"')
{ acc[key] = '"' + value + '"'; }
else
{ add(acc, key, value); }
return acc
}, {})
}
function assign(obj, obj2) {

@@ -346,5 +333,12 @@ for (var key in obj2) {

writable: true,
value: function ValueOf() {
value: function() {
return '.' + this.class
}
},
toString: {
configurable: true,
writable: true,
value: function() {
return bss.valueOf()
}
}

@@ -460,3 +454,5 @@ });

var b = chain(this);
if (value || style)
if (isTagged(value))
{ b.__style[name] = parse.apply(null, arguments); }
else if (value || style)
{ b.__style[name + (style ? '(' + value + ')' : '')] = parse(style || value); }

@@ -502,5 +498,7 @@ return b

configurable: true,
value: function Helper() {
value: function Helper(input) {
var b = chain(this);
var result = styling.apply(null, arguments);
var result = isTagged(input)
? styling(raw(input, arguments))
: styling.apply(null, arguments);
assign(b.__style, result.__style);

@@ -539,3 +537,9 @@ return b

return string.trim().split(/;|\n/).reduce(function (acc, line) {
if (!line)
{ return acc }
line = last + line.trim();
var ref = line.replace(/[ :]+/, ' ').split(' ');
var key = ref[0];
var tokens = ref.slice(1);
last = line.charAt(line.length - 1) === ',' ? line : '';

@@ -545,11 +549,7 @@ if (last)

if (line.charAt(0) === ',') {
acc[prev] += line;
if (line.charAt(0) === ',' || !isProp.test(key)) {
acc[prev] += ' ' + line;
return acc
}
var ref = line.replace(/[ :]+/, ' ').split(' ');
var key = ref[0];
var tokens = ref.slice(1);
if (!key)

@@ -594,3 +594,2 @@ { return acc }

function parse(input, value) {
var arguments$1 = arguments;
var obj;

@@ -603,7 +602,4 @@

return stringToObject(input)
} else if (Array.isArray(input) && typeof input[0] === 'string') {
var str = '';
for (var i = 0; i < input.length; i++)
{ str += input[i] + (arguments$1[i + 1] || ''); }
return stringToObject(str)
} else if (isTagged(input)) {
return stringToObject(raw(input, arguments))
}

@@ -614,2 +610,32 @@

function isTagged(input) {
return Array.isArray(input) && typeof input[0] === 'string'
}
function raw(input, args) {
var str = '';
for (var i = 0; i < input.length; i++)
{ str += input[i] + (args[i + 1] || ''); }
return str
}
function sanitize(styles) {
return Object.keys(styles).reduce(function (acc, key) {
var value = styles[key];
key = shorts[key] || key;
if (!value && value !== 0 && value !== '')
{ return acc }
if (key === 'content' && value.charAt(0) !== '"')
{ acc[key] = '"' + value + '"'; }
else if (typeof value === 'object')
{ acc[key] = sanitize(value); }
else
{ add(acc, key, value); }
return acc
}, {})
}
return bss;

@@ -616,0 +642,0 @@

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.b=e()}(this,function(){"use strict";var i={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",c:"color",d:"display",f:"float",fd:"flexDirection",ff:"fontFamily",fs:"fontSize",h:"height",jc:"justifyContent",l:"left",lh:"lineHeight",ls:"letterSpacing",m:"margin",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mt:"marginTop",o:"opacity",p:"padding",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",pt:"paddingTop",r:"right",t:"top",ta:"textAlign",td:"textDecoration",tt:"textTransform",w:"width"},o=["float"].concat(Object.keys("undefined"==typeof document?{}:function t(e){return e?e.hasOwnProperty("width")?e:t(Object.getPrototypeOf(e)):{}}(document.documentElement.style)).filter(function(t){return-1===t.indexOf("-")&&"length"!==t}));var t=function(e,r){return void 0===r&&(r={}),function(t){return t in r?r[t]:r[t]=e(t)}};function u(t,e,r){e in t?u(t,"!"+e,r):t[e]=function t(e,r){return Array.isArray(r)?r.map(function(t){return d(e,t)}).join(" "):"string"==typeof r?t(e,r.split(" ")):d(e,r)}(e,r)}var c=Object.create(null,{}),a=Object.create(null,{}),l=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,r=t(function(t){var e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),"1px"===e.style[t].slice(-3)?"px":""}catch(t){return""}},{flex:"",boxShadow:"px",border:"px",borderTop:"px",borderRight:"px",borderBottom:"px",borderLeft:"px"});function f(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function s(t){return t.slice("-"===t.charAt(0)?1:0).replace(/-([a-z])/g,function(t){return t[1].toUpperCase()})}function p(e,r,n,i){void 0===n&&(n="");var o={},c=[];return Object.keys(e).forEach(function(t){"@"===t.charAt(0)?c.push(t+"{"+p(e[t],r,n,i)+"}"):"object"==typeof e[t]?c=c.concat(p(e[t],r,n+t,i)):o[t]=e[t]}),Object.keys(o).length&&c.unshift(((i||" "===n.charAt(0)?"":"&")+"&"+n).replace(/&/g,r)+"{"+h(o)+"}"),c}var n=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function h(i){return Object.keys(i).reduce(function(t,e){return t+(r=e.replace(/!/g,""),n=i[e],r=r in c?c[r]:r,(l.test(r)?"-":"")+(y(r)?r:r.replace(/(\B[A-Z])/g,"-$1").toLowerCase())+":"+n+";");var r,n},"")}function d(t,e){return e in a?a[e]:e+(isNaN(e)||null===e||"boolean"==typeof e||y(t)?"":r(t))}function y(t){return"-"===t.charAt(0)&&"-"===t.charAt(1)}var g="object"==typeof document&&document.createElement("style");g&&document.head&&document.head.appendChild(g);var b=g&&g.sheet,m=!1,v=Object.create(null,{}),_=[],j=0,O="b"+("000"+(46656*Math.random()|0).toString(36)).slice(-3)+("000"+(46656*Math.random()|0).toString(36)).slice(-3);function x(t,e){if(_.push(t),m)return g.textContent=_.join("\n");b&&b.insertRule(t,1<arguments.length?e:b.cssRules.length)}var A=Object.create(null);function k(t,e){var r=E(k);return t&&f(r.__style,B.apply(null,arguments)),r}function w(t,e){Object.defineProperty(k,t,{configurable:!0,value:e})}function E(t){var e=Object.create(k,{__style:{value:f({},t.__style)},style:{enumerable:!0,get:function(){var r=this;return Object.keys(this.__style).reduce(function(t,e){return"number"!=typeof r.__style[e]&&"string"!=typeof r.__style[e]||(t[e.replace(/^!/,"")]=r.__style[e]),t},{})}}});return t===k&&(k.__style={}),e}function P(t,e,r){t[e.split(n).map(function(t){return(":"===(t=t.trim()).charAt(0)||"["===t.charAt(0)?"":" ")+t}).join(",&")]=B(r)}function $(r){return function(t){var e=E(this);return t||0===t?0<arguments.length&&u(e.__style,r,Array.prototype.slice.call(arguments)):delete e.__style[r],e}}function C(t,e){p(B(e),t,"",!0).forEach(x)}function S(e,r){if(1===arguments.length)return Object.keys(e).forEach(function(t){return S(t,e[t])});delete k[e],"function"==typeof r?(S[e]=r,Object.defineProperty(k,e,{configurable:!0,value:function(){var t=E(this),e=r.apply(null,arguments);return f(t.__style,e.__style),t}})):(S[e]=B(r),Object.defineProperty(k,e,{configurable:!0,get:function(){var t=E(this);return f(t.__style,B(r)),t}}))}function L(t){var e,r=(e=t).charAt(0)+(e.match(/([A-Z])/g)||[]).join("").toLowerCase(),n=i[r]&&i[r]!==t?t:r;return A[n]=t,n}Object.defineProperties(k,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}}}),w("setDebug",function(t){m=t}),w("$keyframes",function(r){var t=Object.keys(r).reduce(function(t,e){return t+e+"{"+h(B(r[e]))+"}"},"");if(t in z)return z[t];var e=O+M++;return x("@keyframes "+(z[t]=e)+"{"+t+"}"),e}),w("$media",function(t,e){var r=E(this);t&&(r.__style["@media "+t]=B(e));return r}),w("$import",function(t){t&&x("@import "+t+";",0);return E(this)}),w("$nest",function(e,t){var r=E(this);1===arguments.length?Object.keys(e).forEach(function(t){return P(r.__style,t,e[t])}):e&&P(r.__style,e,t);return r}),w("getSheet",function(){var t=_.join("");return _=[],v=Object.create(null,{}),j=0,t}),w("getRules",function(){return _}),w("helper",S),w("css",function(e,t){1===arguments.length?Object.keys(e).forEach(function(t){return C(t,e[t])}):C(e,t);return E(this)}),w("classPrefix",O),o.forEach(function(t){var e,r=t.match(l);if(r){var n=(e=t.replace(l,"$2")).charAt(0).toLowerCase()+e.slice(1);if(-1===o.indexOf(n))return"flexDirection"===n&&(a.flex="-"+r[1].toLowerCase()+"-flex"),w(n,$(c[n]=t)),void w(L(n),k[n])}w(t,$(t)),w(L(t),k[t])}),w("content",function(t){var e=E(this);return e.__style.content='"'+t+'"',e}),Object.defineProperty(k,"class",{set:function(t){this.__class=t},get:function(){return this.__class||function(t){var e=JSON.stringify(t);if(e in v)return v[e];for(var r=O+ ++j,n=p(t,"."+r),i=0;i<n.length;i++)x(n[i]);return v[e]=r}(this.__style)}}),[":active",":any",":checked",":default",":disabled",":empty",":enabled",":first",":first-child",":first-of-type",":fullscreen",":focus",":hover",":indeterminate",":in-range",":invalid",":last-child",":last-of-type",":left",":link",":only-child",":only-of-type",":optional",":out-of-range",":read-only",":read-write",":required",":right",":root",":scope",":target",":valid",":visited",":dir",":lang",":not",":nth-child",":nth-last-child",":nth-last-of-type",":nth-of-type","::after","::before","::first-letter","::first-line","::selection","::backdrop","::placeholder","::marker","::spelling-error","::grammar-error"].forEach(function(n){return w("$"+s(n.replace(/:/g,"")),function(t,e){var r=E(this);return(t||e)&&(r.__style[n+(e?"("+t+")":"")]=B(e||t)),r})}),k.helper("$animate",function(t,e){return k.animation(k.$keyframes(e)+" "+t)});var R=t(function(t){var c,a="";return t.trim().split(/;|\n/).reduce(function(t,e){if(e=a+e.trim(),a=","===e.charAt(e.length-1)?e:"")return t;if(","===e.charAt(0))return t[c]+=e,t;var r=e.replace(/[ :]+/," ").split(" "),n=r[0],i=r.slice(1);if(!n)return t;var o="-"===n.charAt(0)&&"-"===n.charAt(1)?n:s(n);return c=A[o]||o,o in S?f(t,"function"==typeof S[o]?S[o].apply(S,i).__style:S[o]):0<i.length&&u(t,c,i),t},{})}),M=0,z={};function B(t,e){var r,n,i=arguments;if("string"==typeof t)return"string"==typeof e||"number"==typeof e?((r={})[t]=e,r):R(t);if(Array.isArray(t)&&"string"==typeof t[0]){for(var o="",c=0;c<t.length;c++)o+=t[c]+(i[c+1]||"");return R(o)}return t.__style||(n=t,Object.keys(n).reduce(function(t,e){var r=n[e];return(r||0===r||""===r)&&("content"===e&&'"'!==r.charAt(0)?t[e]='"'+r+'"':u(t,e,r)),t},{}))}return k});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.b=e()}(this,function(){"use strict";var i={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",bi:"backgroundImage",c:"color",d:"display",f:"float",fd:"flexDirection",ff:"fontFamily",fs:"fontSize",h:"height",jc:"justifyContent",l:"left",lh:"lineHeight",ls:"letterSpacing",m:"margin",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mt:"marginTop",o:"opacity",p:"padding",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",pt:"paddingTop",r:"right",t:"top",ta:"textAlign",td:"textDecoration",tt:"textTransform",w:"width"},o=["float"].concat(Object.keys("undefined"==typeof document?{}:function t(e){return e?e.hasOwnProperty("width")?e:t(Object.getPrototypeOf(e)):{}}(document.documentElement.style)).filter(function(t){return-1===t.indexOf("-")&&"length"!==t}));var u=/^-?-?[a-z][a-z-_0-9]*$/i,t=function(e,r){return void 0===r&&(r={}),function(t){return t in r?r[t]:r[t]=e(t)}};function l(t,e,r){e in t?l(t,"!"+e,r):t[e]=function t(e,r){return Array.isArray(r)?r.map(function(t){return d(e,t)}).join(" "):"string"==typeof r?t(e,r.split(" ")):d(e,r)}(e,r)}var c=Object.create(null,{}),a=Object.create(null,{}),f=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,r=t(function(t){var e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),"1px"===e.style[t].slice(-3)?"px":""}catch(t){return""}},{flex:"",boxShadow:"px",border:"px",borderTop:"px",borderRight:"px",borderBottom:"px",borderLeft:"px"});function s(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function p(t){return t.slice("-"===t.charAt(0)?1:0).replace(/-([a-z])/g,function(t){return t[1].toUpperCase()})}function y(e,r,n,i){void 0===n&&(n="");var o={},c=[];return Object.keys(e).forEach(function(t){"@"===t.charAt(0)?c.push(t+"{"+y(e[t],r,n,i)+"}"):"object"==typeof e[t]?c=c.concat(y(e[t],r,n+t,i)):o[t]=e[t]}),Object.keys(o).length&&c.unshift(((i||" "===n.charAt(0)?"":"&")+"&"+n).replace(/&/g,r)+"{"+h(o)+"}"),c}var n=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function h(i){return Object.keys(i).reduce(function(t,e){return t+(r=e.replace(/!/g,""),n=i[e],r=r in c?c[r]:r,(f.test(r)?"-":"")+(g(r)?r:r.replace(/(\B[A-Z])/g,"-$1").toLowerCase())+":"+n+";");var r,n},"")}function d(t,e){return e in a?a[e]:e+(isNaN(e)||null===e||"boolean"==typeof e||g(t)?"":r(t))}function g(t){return"-"===t.charAt(0)&&"-"===t.charAt(1)}var b="object"==typeof document&&document.createElement("style");b&&document.head&&document.head.appendChild(b);var m=b&&b.sheet,v=!1,_=Object.create(null,{}),j=[],O=0,x="b"+("000"+(46656*Math.random()|0).toString(36)).slice(-3)+("000"+(46656*Math.random()|0).toString(36)).slice(-3);function A(t,e){if(j.push(t),v)return b.textContent=j.join("\n");m&&m.insertRule(t,1<arguments.length?e:m.cssRules.length)}var k=Object.create(null);function w(t,e){var r=E(w);return t&&s(r.__style,D.apply(null,arguments)),r}function $(t,e){Object.defineProperty(w,t,{configurable:!0,value:e})}function E(t){var e=Object.create(w,{__style:{value:s({},t.__style)},style:{enumerable:!0,get:function(){var r=this;return Object.keys(this.__style).reduce(function(t,e){return"number"!=typeof r.__style[e]&&"string"!=typeof r.__style[e]||(t[e.replace(/^!/,"")]=r.__style[e]),t},{})}}});return t===w&&(w.__style={}),e}function P(t,e,r){t[e.split(n).map(function(t){return(":"===(t=t.trim()).charAt(0)||"["===t.charAt(0)?"":" ")+t}).join(",&")]=D(r)}function S(r){return function(t){var e=E(this);return t||0===t?0<arguments.length&&l(e.__style,r,Array.prototype.slice.call(arguments)):delete e.__style[r],e}}function C(t,e){y(D(e),t,"",!0).forEach(A)}function L(e,n){if(1===arguments.length)return Object.keys(e).forEach(function(t){return L(t,e[t])});delete w[e],"function"==typeof n?(L[e]=n,Object.defineProperty(w,e,{configurable:!0,value:function(t){var e=E(this),r=T(t)?n(N(t,arguments)):n.apply(null,arguments);return s(e.__style,r.__style),e}})):(L[e]=D(n),Object.defineProperty(w,e,{configurable:!0,get:function(){var t=E(this);return s(t.__style,D(n)),t}}))}function R(t){var e,r=(e=t).charAt(0)+(e.match(/([A-Z])/g)||[]).join("").toLowerCase(),n=i[r]&&i[r]!==t?t:r;return k[n]=t,n}Object.defineProperties(w,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}},toString:{configurable:!0,writable:!0,value:function(){return w.valueOf()}}}),$("setDebug",function(t){v=t}),$("$keyframes",function(r){var t=Object.keys(r).reduce(function(t,e){return t+e+"{"+h(D(r[e]))+"}"},"");if(t in B)return B[t];var e=x+M++;return A("@keyframes "+(B[t]=e)+"{"+t+"}"),e}),$("$media",function(t,e){var r=E(this);t&&(r.__style["@media "+t]=D(e));return r}),$("$import",function(t){t&&A("@import "+t+";",0);return E(this)}),$("$nest",function(e,t){var r=E(this);1===arguments.length?Object.keys(e).forEach(function(t){return P(r.__style,t,e[t])}):e&&P(r.__style,e,t);return r}),$("getSheet",function(){var t=j.join("");return j=[],_=Object.create(null,{}),O=0,t}),$("getRules",function(){return j}),$("helper",L),$("css",function(e,t){1===arguments.length?Object.keys(e).forEach(function(t){return C(t,e[t])}):C(e,t);return E(this)}),$("classPrefix",x),o.forEach(function(t){var e,r=t.match(f);if(r){var n=(e=t.replace(f,"$2")).charAt(0).toLowerCase()+e.slice(1);if(-1===o.indexOf(n))return"flexDirection"===n&&(a.flex="-"+r[1].toLowerCase()+"-flex"),$(n,S(c[n]=t)),void $(R(n),w[n])}$(t,S(t)),$(R(t),w[t])}),$("content",function(t){var e=E(this);return e.__style.content='"'+t+'"',e}),Object.defineProperty(w,"class",{set:function(t){this.__class=t},get:function(){return this.__class||function(t){var e=JSON.stringify(t);if(e in _)return _[e];for(var r=x+ ++O,n=y(t,"."+r),i=0;i<n.length;i++)A(n[i]);return _[e]=r}(this.__style)}}),[":active",":any",":checked",":default",":disabled",":empty",":enabled",":first",":first-child",":first-of-type",":fullscreen",":focus",":hover",":indeterminate",":in-range",":invalid",":last-child",":last-of-type",":left",":link",":only-child",":only-of-type",":optional",":out-of-range",":read-only",":read-write",":required",":right",":root",":scope",":target",":valid",":visited",":dir",":lang",":not",":nth-child",":nth-last-child",":nth-last-of-type",":nth-of-type","::after","::before","::first-letter","::first-line","::selection","::backdrop","::placeholder","::marker","::spelling-error","::grammar-error"].forEach(function(n){return $("$"+p(n.replace(/:/g,"")),function(t,e){var r=E(this);return T(t)?r.__style[n]=D.apply(null,arguments):(t||e)&&(r.__style[n+(e?"("+t+")":"")]=D(e||t)),r})}),w.helper("$animate",function(t,e){return w.animation(w.$keyframes(e)+" "+t)});var z=t(function(t){var c,a="";return t.trim().split(/;|\n/).reduce(function(t,e){if(!e)return t;var r=(e=a+e.trim()).replace(/[ :]+/," ").split(" "),n=r[0],i=r.slice(1);if(a=","===e.charAt(e.length-1)?e:"")return t;if(","===e.charAt(0)||!u.test(n))return t[c]+=" "+e,t;if(!n)return t;var o="-"===n.charAt(0)&&"-"===n.charAt(1)?n:p(n);return c=k[o]||o,o in L?s(t,"function"==typeof L[o]?L[o].apply(L,i).__style:L[o]):0<i.length&&l(t,c,i),t},{})}),M=0,B={};function D(t,e){var r;return"string"==typeof t?"string"==typeof e||"number"==typeof e?((r={})[t]=e,r):z(t):T(t)?z(N(t,arguments)):t.__style||function n(i){return Object.keys(i).reduce(function(t,e){var r=i[e];return e=k[e]||e,(r||0===r||""===r)&&("content"===e&&'"'!==r.charAt(0)?t[e]='"'+r+'"':"object"==typeof r?t[e]=n(r):l(t,e,r)),t},{})}(t)}function T(t){return Array.isArray(t)&&"string"==typeof t[0]}function N(t,e){for(var r="",n=0;n<t.length;n++)r+=t[n]+(e[n+1]||"");return r}return w});
//# sourceMappingURL=bss.min.js.map
## [Unreleased]
## 1.4.0 -
Fix css values spanning several lines
Allow shortNamese using object input
Fix pseudos and @rules using object input
Fix calling helpers and pseduos as tagged functions
Add toString to support setting directly to class / className attrs
Add bi as shorthand for background-image
## 1.3.0 -

@@ -4,0 +12,0 @@ Fix leaking instances (memory and styling)

@@ -24,5 +24,5 @@ /* eslint no-invalid-this: 0 */

vendorMap,
sanitize,
initials,
memoize,
isProp,
assign,

@@ -56,5 +56,12 @@ add

writable: true,
value: function ValueOf() {
value: function() {
return '.' + this.class
}
},
toString: {
configurable: true,
writable: true,
value: function() {
return bss.valueOf()
}
}

@@ -169,3 +176,5 @@ })

const b = chain(this)
if (value || style)
if (isTagged(value))
b.__style[name] = parse.apply(null, arguments)
else if (value || style)
b.__style[name + (style ? '(' + value + ')' : '')] = parse(style || value)

@@ -211,5 +220,7 @@ return b

configurable: true,
value: function Helper() {
value: function Helper(input) {
const b = chain(this)
const result = styling.apply(null, arguments)
const result = isTagged(input)
? styling(raw(input, arguments))
: styling.apply(null, arguments)
assign(b.__style, result.__style)

@@ -249,3 +260,7 @@ return b

return string.trim().split(/;|\n/).reduce((acc, line) => {
if (!line)
return acc
line = last + line.trim()
const [key, ...tokens] = line.replace(/[ :]+/, ' ').split(' ')
last = line.charAt(line.length - 1) === ',' ? line : ''

@@ -255,9 +270,7 @@ if (last)

if (line.charAt(0) === ',') {
acc[prev] += line
if (line.charAt(0) === ',' || !isProp.test(key)) {
acc[prev] += ' ' + line
return acc
}
const [key, ...tokens] = line.replace(/[ :]+/, ' ').split(' ')
if (!key)

@@ -308,7 +321,4 @@ return acc

return stringToObject(input)
} else if (Array.isArray(input) && typeof input[0] === 'string') {
let str = ''
for (let i = 0; i < input.length; i++)
str += input[i] + (arguments[i + 1] || '')
return stringToObject(str)
} else if (isTagged(input)) {
return stringToObject(raw(input, arguments))
}

@@ -319,2 +329,32 @@

function isTagged(input) {
return Array.isArray(input) && typeof input[0] === 'string'
}
function raw(input, args) {
let str = ''
for (let i = 0; i < input.length; i++)
str += input[i] + (args[i + 1] || '')
return str
}
function sanitize(styles) {
return Object.keys(styles).reduce((acc, key) => {
const value = styles[key]
key = shorts[key] || key
if (!value && value !== 0 && value !== '')
return acc
if (key === 'content' && value.charAt(0) !== '"')
acc[key] = '"' + value + '"'
else if (typeof value === 'object')
acc[key] = sanitize(value)
else
add(acc, key, value)
return acc
}, {})
}
export default bss

@@ -7,2 +7,3 @@ export default {

bs : 'boxShadow',
bi : 'backgroundImage',
c : 'color',

@@ -9,0 +10,0 @@ d : 'display',

@@ -15,2 +15,4 @@ export const cssProperties = ['float'].concat(Object.keys(

export const isProp = /^-?-?[a-z][a-z-_0-9]*$/i
export const memoize = (fn, cache = {}) => item =>

@@ -57,18 +59,2 @@ item in cache

export function sanitize(styles) {
return Object.keys(styles).reduce((acc, key) => {
const value = styles[key]
if (!value && value !== 0 && value !== '')
return acc
if (key === 'content' && value.charAt(0) !== '"')
acc[key] = '"' + value + '"'
else
add(acc, key, value)
return acc
}, {})
}
export function assign(obj, obj2) {

@@ -75,0 +61,0 @@ for (const key in obj2) {

{
"name": "bss",
"version": "1.3.0",
"version": "1.4.0",
"description": "Better Style Sheets",

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

@@ -104,3 +104,3 @@ [![version](https://img.shields.io/npm/v/bss.svg)]() [![gzipped](http://img.badgesize.io/porsager/bss/master/bss.js.svg?compression=gzip&label=gzipped)]() [![license](https://img.shields.io/github/license/porsager/bss.svg)]()

textAlign: 'center',
$hover: {
':hover': {
backgroundColor: 'red'

@@ -107,0 +107,0 @@ }

@@ -40,2 +40,4 @@ const o = require('ospec')

MozAppearance: '',
transform: '',
position: '',
webkitOverflowScrolling: ''

@@ -64,5 +66,18 @@ }

o('object input with pseduos', function() {
const cls = b({ ':hover': { background: 'red' } }).class
o(b.getSheet()).equals(`.${cls}.${cls}:hover{background:red;}`)
})
o('object input with at-rules', function() {
const cls = b({ '@media (max-width:600px)': { background: 'red' } }).class
o(b.getSheet()).equals(`@media (max-width:600px){.${cls}.${cls}{background:red;}}`)
})
o('object input using shortname properties', function() {
o(b({ bc: 'red' }).style).deepEquals({ backgroundColor: 'red' })
})
o('multiline input', function() {
o(b('transform scale(1)\n,rotate(0)').style).deepEquals({ transform: 'scale(1),rotate(0)' })
o(b('transform scale(1),\nrotate(0)').style).deepEquals({ transform: 'scale(1),rotate(0)' })
o(b('transform scale(1)\nrotate(0)').style).deepEquals({ transform: 'scale(1) rotate(0)' })
})

@@ -133,3 +148,3 @@

o('same named properties style', function() {
o(b.d('-webkit-flex').d('flex').style).deepEquals({display:'flex'})
o(b.d('-webkit-flex').d('flex').style).deepEquals({ display:'flex' })
})

@@ -153,2 +168,11 @@

o('support variables in tagged template literals', function() {
o(b`display ${ 'flex' }`.style).deepEquals({ display: 'flex' })
})
o('support variables in tagged template literals in pseudos', function() {
const cls = b.$hover`display ${ 'flex' }`.class
o(b.getSheet()).equals(`.${cls}.${cls}:hover{display:flex;}`)
})
o('allows vendor prefix', function() {

@@ -249,2 +273,18 @@ const cls = b('-webkit-overflow-scrolling touch').class

})
o('helpers as template literals', function() {
b.helper({
desktop: s => b.$media('(min-width:1024px)', s)
})
const cls = b.desktop`display flex`.class
o(b.getSheet()).equals(`@media (min-width:1024px){.${cls}.${cls}{display:flex;}}`)
})
o('helpers as template literals with variables', function() {
b.helper({
desktop: s => b.$media('(min-width:1024px)', s)
})
const cls = b.desktop`display ${ 'flex' }`.class
o(b.getSheet()).equals(`@media (min-width:1024px){.${cls}.${cls}{display:flex;}}`)
})
})

@@ -290,2 +330,13 @@

})
o('Multiline css', function() {
o(b`
position : absolute;
transform : translate(-50%, -50%)
rotate(-45deg);
`.style).deepEquals({
position: 'absolute',
transform: 'translate(-50%, -50%) rotate(-45deg)'
})
})
})

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

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