New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stylished-components

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylished-components - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

2

lib/stylished-components.esm.js

@@ -5,2 +5,2 @@ /**

import e,{Component as t}from"react";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function s(){return(s=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 i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return function(){var t,r=a(e);if(l()){var n=a(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return u(this,t)}}var p=function(e){return String.fromCharCode(e+(e>25?39:97))},h=function(){var e=Math.floor(9999999999999*Math.random());return"stylished-".concat(function(e){var t,r="";for(t=e;t>52;t=Math.floor(t/52))r=p(t%52)+r;return p(t%52)+r}(e))},d=function(){var e=document.createElement("style");e.setAttribute("data-stylished","0.1.7"),document.head.appendChild(e)},m=function(){return document.querySelector("style[data-stylished]")},v=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},g=function(e){return v(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)},y=function(e){return e.match(/((&.*:.*hover[\s]*).*?[^}]*})/g)},S=new function e(){var t=this;r(this,e),this.cssImportStatements=[],this.cssKeyframeStatements=[],this.cssRegex=new RegExp("([\\s\\S]*?){([\\s\\S]*?)}","gi"),this.cssMediaQueryRegex="((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.cssKeyframeRegex="((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.combinedCSSRegex="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",this.cssCommentsRegex="(\\/\\*[\\s\\S]*?\\*\\/)",this.cssImportStatementRegex=new RegExp("@import .*?;","gi"),this.stripComments=function(e){var r=new RegExp(t.cssCommentsRegex,"gi");return e.replace(r,"")},this.parseCSS=function(e){if(void 0===e)return[];for(var r=[];;){var n=t.cssImportStatementRegex.exec(e);if(null===n)break;t.cssImportStatements.push(n[0]),r.push({selector:"@imports",type:"imports",styles:n[0]})}e=e.replace(t.cssImportStatementRegex,"");for(var o,s=new RegExp(t.cssKeyframeRegex,"gi");null!==(o=s.exec(e));)r.push({selector:"@keyframes",type:"keyframes",styles:o[0]});e=e.replace(s,"");for(var i=new RegExp(t.combinedCSSRegex,"gi");null!==(o=i.exec(e));){var a="";a=void 0===o[2]?o[5].split("\r\n").join("\n").trim():o[2].split("\r\n").join("\n").trim();var c=new RegExp(t.cssCommentsRegex,"gi"),l=c.exec(a);if(null!==l&&(a=a.replace(c,"").trim()),-1!==(a=a.replace(/\n+/,"\n")).indexOf("@media")){var u={selector:a,type:"media",subStyles:t.parseCSS("".concat(o[3],"\n}"))};null!==l&&(u.comments=l[0]),r.push(u)}else{var f={selector:a,rules:t.parseRules(o[6])};"@font-face"===a&&(f.type="font-face"),null!==l&&(f.comments=l[0]),r.push(f)}}return r},this.parseRules=function(e){var t=[];e=(e=e.split("\r\n").join("\n")).split(";");for(var r=0;r<e.length;r++){var n=e[r];if(-1!==(n=n.trim()).indexOf(":")){var o=(n=n.split(":"))[0].trim(),s=n.slice(1).join(":").trim();if(o.length<1||s.length<1)continue;t.push({directive:o,value:s})}else"base64,"===n.trim().substr(0,7)?t[t.length-1].value+=n.trim():n.length>0&&t.push({directive:"",value:n,defective:!0})}return t},this.findCorrespondingRule=function(e,t,r){void 0===r&&(r=!1);for(var n=!1,o=0;o<e.length&&(e[o].directive!==t||(n=e[o],r!==e[o].value));o++);return n},this.findBySelector=function(e,r,n){void 0===n&&(n=!1);for(var o=[],s=0;s<e.length;s++)!1===n?e[s].selector===r&&o.push(e[s]):-1!==e[s].selector.indexOf(r)&&o.push(e[s]);if("@imports"===r||o.length<2)return o;for(var i=o[0],a=1;a<o.length;a++)t.intelligentCSSPush([i],o[a]);return[i]},this.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},this.compressCSS=function(e){for(var r=[],n={},o=0;o<e.length;o++){var s=e[o];if(!0!==n[s.selector]){var i=t.findBySelector(e,s.selector);0!==i.length&&(r=r.concat(i),n[s.selector]=!0)}}return r},this.cssDiff=function(e,r){if(e.selector!==r.selector)return!1;if("media"===e.type||"media"===r.type)return!1;for(var n,o,s={selector:e.selector,rules:[]},i=0;i<e.rules.length;i++)n=e.rules[i],(!1===(o=t.findCorrespondingRule(r.rules,n.directive,n.value))||n.value!==o.value)&&s.rules.push(n);for(var a=0;a<r.rules.length;a++)o=r.rules[a],!1===(n=t.findCorrespondingRule(e.rules,o.directive))&&(o.type="DELETED",s.rules.push(o));return 0!==s.rules.length&&s},this.intelligentMerge=function(e,r,n){void 0===n&&(n=!1);for(var o=0;o<r.length;o++)t.intelligentCSSPush(e,r[o],n);for(var s=0;s<e.length;s++){var i=e[s];"media"!==i.type&&"keyframes"!==i.type&&(i.rules=t.compactRules(i.rules))}},this.intelligentCSSPush=function(e,r,n){var o=r.selector,s=!1;if(void 0===n&&(n=!1),!1===n){for(var i=0;i<e.length;i++)if(e[i].selector===o){s=e[i];break}}else for(var a=e.length-1;a>-1;a--)if(e[a].selector===o){s=e[a];break}if(!1===s)e.push(r);else if("media"!==r.type)for(var c=0;c<r.rules.length;c++){var l=r.rules[c],u=t.findCorrespondingRule(s.rules,l.directive);!1===u?s.rules.push(l):"DELETED"===l.type?u.type="DELETED":u.value=l.value}else s.subStyles=s.subStyles.concat(r.subStyles)},this.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},this.getCSSForEditor=function(e,r){void 0===r&&(r=0);var n="";void 0===e&&(e=t.css);for(var o=0;o<e.length;o++)"imports"===e[o].type&&(n+="".concat(e[o].styles,"\n\n"));for(var s=0;s<e.length;s++){var i=e[s];if(void 0!==i.selector){var a="";void 0!==i.comments&&(a="".concat(i.comments,"\n")),"media"===i.type?(n+="".concat(a+i.selector,"{\n"),n+=t.getCSSForEditor(i.subStyles,r+1),n+="}\n\n"):"keyframes"!==i.type&&"imports"!==i.type&&(n+="".concat(t.getSpaces(r)+a+i.selector," {\n"),n+=t.getCSSOfRules(i.rules,r+1),n+="".concat(t.getSpaces(r),"}\n\n"))}}for(var c=0;c<e.length;c++)"keyframes"===e[c].type&&(n+="".concat(e[c].styles,"\n\n"));return n},this.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},this.getCSSOfRules=function(e,r){for(var n="",o=0;o<e.length;o++)void 0!==e[o]&&(void 0===e[o].defective?n+="".concat(t.getSpaces(r)+e[o].directive,": ").concat(e[o].value,";\n"):n+="".concat(t.getSpaces(r)+e[o].value,";\n"));return n||"\n"},this.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},this.applyNamespacing=function(e,r){var n=e,o=".".concat(t.cssPreviewNamespace);void 0!==r&&(o=r),"string"==typeof e&&(n=t.parseCSS(e));for(var s=0;s<n.length;s++){var i=n[s];if(!(i.selector.indexOf("@font-face")>-1||i.selector.indexOf("keyframes")>-1||i.selector.indexOf("@import")>-1||i.selector.indexOf(".form-all")>-1||i.selector.indexOf("#stage")>-1))if("media"!==i.type){for(var a=i.selector.split(","),c=[],l=0;l<a.length;l++)-1===a[l].indexOf(".supernova")?c.push("".concat(o," ").concat(a[l])):c.push(a[l]);i.selector=c.join(",")}else i.subStyles=t.applyNamespacing(i.subStyles,r)}return n},this.clearNamespacing=function(e,r){void 0===r&&(r=!1);var n=e,o=".".concat(t.cssPreviewNamespace);"string"==typeof e&&(n=t.parseCSS(e));for(var s=0;s<n.length;s++){var i=n[s];if("media"!==i.type){for(var a=i.selector.split(","),c=[],l=0;l<a.length;l++)c.push(a[l].split("".concat(o," ")).join(""));i.selector=c.join(",")}else i.subStyles=t.clearNamespacing(i.subStyles,!0)}return!1===r?t.getCSSForEditor(n):n},this.createStyleElement=function(e,r,n){if(void 0===n&&(n=!1),!1===t.testMode&&"nonamespace"!==n&&(r=t.applyNamespacing(r)),"string"!=typeof r&&(r=t.getCSSForEditor(r)),!0===n&&(r=t.getCSSForEditor(t.parseCSS(r))),!1!==t.testMode)return t.testMode("create style #".concat(e),r);var o=document.getElementById(e);o&&o.parentNode.removeChild(o);var s=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=e,i.type="text/css",s.appendChild(i),i.styleSheet&&!i.sheet?i.styleSheet.cssText=r:i.appendChild(document.createTextNode(r))}},b=function(n){return function(a){for(var c=arguments.length,l=new Array(c>1?c-1:0),u=1;u<c;u++)l[u-1]=arguments[u];return function(c){i(p,t);var u=f(p);function p(){return r(this,p),u.apply(this,arguments)}return o(p,[{key:"componentDidMount",value:function(){this.init()}},{key:"componentDidUpdate",value:function(){this.init()}},{key:"init",value:function(){var e=this,t=l.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+a[n+1]}),a[0]),r=h(),n=v(t),o=g(n),s=y(n);o&&o.forEach((function(e){return n=n.replace(e,"")})),s&&s.forEach((function(e){return n=n.replace(e,"")}));var i=".".concat(r," {").concat(n,"}");o&&o.length&&S.parseCSS(o.join("")).forEach((function(e){var t="".concat(e.selector," { .").concat(r," {");e.subStyles.forEach((function(e){e.rules.forEach((function(e){t+="".concat(e.directive,": ").concat(e.value,";")}))})),i+="\n".concat(t+="}}")}));s&&s.length&&s.forEach((function(e){i+=e.replace("&:",".".concat(r,":"))}));var c=m();c||(d(),c=m()),this.element.setAttribute("class",r),c.textContent+=i}},{key:"render",value:function(){var t=this;return e.createElement(n,s({},this.props,{ref:function(e){return t.element=e}}))}}]),p}()}};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){b[e]=b(e)}));export default b;
import e,{Component as t}from"react";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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)}}function s(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function o(){return(o=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 i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return function(){var t,r=c(e);if(l()){var n=c(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return u(this,t)}}var p=function(e){return String.fromCharCode(e+(e>25?39:97))},h=function(){var e=Math.floor(9999999999999*Math.random());return"stylished-".concat(function(e){var t,r="";for(t=e;t>52;t=Math.floor(t/52))r=p(t%52)+r;return p(t%52)+r}(e))},v=function(){var e=document.createElement("style");e.setAttribute("data-stylished","0.1.8"),document.head.appendChild(e)},m=function(){return document.querySelector("style[data-stylished]")},d=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},g=function(e){return d(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)},y=function(e){return e.match(/((&.*:.*hover[\s]*).*?[^}]*})/g)},S=new function e(){var t=this;r(this,e),this.cssImportStatements=[],this.cssKeyframeStatements=[],this.cssRegex=new RegExp("([\\s\\S]*?){([\\s\\S]*?)}","gi"),this.cssMediaQueryRegex="((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.cssKeyframeRegex="((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.combinedCSSRegex="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",this.cssCommentsRegex="(\\/\\*[\\s\\S]*?\\*\\/)",this.cssImportStatementRegex=new RegExp("@import .*?;","gi"),this.stripComments=function(e){var r=new RegExp(t.cssCommentsRegex,"gi");return e.replace(r,"")},this.parseCSS=function(e){if(void 0===e)return[];for(var r=[];;){var n=t.cssImportStatementRegex.exec(e);if(null===n)break;t.cssImportStatements.push(n[0]),r.push({selector:"@imports",type:"imports",styles:n[0]})}e=e.replace(t.cssImportStatementRegex,"");for(var s,o=new RegExp(t.cssKeyframeRegex,"gi");null!==(s=o.exec(e));)r.push({selector:"@keyframes",type:"keyframes",styles:s[0]});e=e.replace(o,"");for(var i=new RegExp(t.combinedCSSRegex,"gi");null!==(s=i.exec(e));){var c="";c=void 0===s[2]?s[5].split("\r\n").join("\n").trim():s[2].split("\r\n").join("\n").trim();var a=new RegExp(t.cssCommentsRegex,"gi"),l=a.exec(c);if(null!==l&&(c=c.replace(a,"").trim()),-1!==(c=c.replace(/\n+/,"\n")).indexOf("@media")){var u={selector:c,type:"media",subStyles:t.parseCSS("".concat(s[3],"\n}"))};null!==l&&(u.comments=l[0]),r.push(u)}else{var f={selector:c,rules:t.parseRules(s[6])};"@font-face"===c&&(f.type="font-face"),null!==l&&(f.comments=l[0]),r.push(f)}}return r},this.parseRules=function(e){var t=[];e=(e=e.split("\r\n").join("\n")).split(";");for(var r=0;r<e.length;r++){var n=e[r];if(-1!==(n=n.trim()).indexOf(":")){var s=(n=n.split(":"))[0].trim(),o=n.slice(1).join(":").trim();if(s.length<1||o.length<1)continue;t.push({directive:s,value:o})}else"base64,"===n.trim().substr(0,7)?t[t.length-1].value+=n.trim():n.length>0&&t.push({directive:"",value:n,defective:!0})}return t},this.findCorrespondingRule=function(e,t,r){void 0===r&&(r=!1);for(var n=!1,s=0;s<e.length&&(e[s].directive!==t||(n=e[s],r!==e[s].value));s++);return n},this.findBySelector=function(e,r,n){void 0===n&&(n=!1);for(var s=[],o=0;o<e.length;o++)!1===n?e[o].selector===r&&s.push(e[o]):-1!==e[o].selector.indexOf(r)&&s.push(e[o]);if("@imports"===r||s.length<2)return s;for(var i=s[0],c=1;c<s.length;c++)t.intelligentCSSPush([i],s[c]);return[i]},this.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},this.compressCSS=function(e){for(var r=[],n={},s=0;s<e.length;s++){var o=e[s];if(!0!==n[o.selector]){var i=t.findBySelector(e,o.selector);0!==i.length&&(r=r.concat(i),n[o.selector]=!0)}}return r},this.cssDiff=function(e,r){if(e.selector!==r.selector)return!1;if("media"===e.type||"media"===r.type)return!1;for(var n,s,o={selector:e.selector,rules:[]},i=0;i<e.rules.length;i++)n=e.rules[i],(!1===(s=t.findCorrespondingRule(r.rules,n.directive,n.value))||n.value!==s.value)&&o.rules.push(n);for(var c=0;c<r.rules.length;c++)s=r.rules[c],!1===(n=t.findCorrespondingRule(e.rules,s.directive))&&(s.type="DELETED",o.rules.push(s));return 0!==o.rules.length&&o},this.intelligentMerge=function(e,r,n){void 0===n&&(n=!1);for(var s=0;s<r.length;s++)t.intelligentCSSPush(e,r[s],n);for(var o=0;o<e.length;o++){var i=e[o];"media"!==i.type&&"keyframes"!==i.type&&(i.rules=t.compactRules(i.rules))}},this.intelligentCSSPush=function(e,r,n){var s=r.selector,o=!1;if(void 0===n&&(n=!1),!1===n){for(var i=0;i<e.length;i++)if(e[i].selector===s){o=e[i];break}}else for(var c=e.length-1;c>-1;c--)if(e[c].selector===s){o=e[c];break}if(!1===o)e.push(r);else if("media"!==r.type)for(var a=0;a<r.rules.length;a++){var l=r.rules[a],u=t.findCorrespondingRule(o.rules,l.directive);!1===u?o.rules.push(l):"DELETED"===l.type?u.type="DELETED":u.value=l.value}else o.subStyles=o.subStyles.concat(r.subStyles)},this.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},this.getCSSForEditor=function(e,r){void 0===r&&(r=0);var n="";void 0===e&&(e=t.css);for(var s=0;s<e.length;s++)"imports"===e[s].type&&(n+="".concat(e[s].styles,"\n\n"));for(var o=0;o<e.length;o++){var i=e[o];if(void 0!==i.selector){var c="";void 0!==i.comments&&(c="".concat(i.comments,"\n")),"media"===i.type?(n+="".concat(c+i.selector,"{\n"),n+=t.getCSSForEditor(i.subStyles,r+1),n+="}\n\n"):"keyframes"!==i.type&&"imports"!==i.type&&(n+="".concat(t.getSpaces(r)+c+i.selector," {\n"),n+=t.getCSSOfRules(i.rules,r+1),n+="".concat(t.getSpaces(r),"}\n\n"))}}for(var a=0;a<e.length;a++)"keyframes"===e[a].type&&(n+="".concat(e[a].styles,"\n\n"));return n},this.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},this.getCSSOfRules=function(e,r){for(var n="",s=0;s<e.length;s++)void 0!==e[s]&&(void 0===e[s].defective?n+="".concat(t.getSpaces(r)+e[s].directive,": ").concat(e[s].value,";\n"):n+="".concat(t.getSpaces(r)+e[s].value,";\n"));return n||"\n"},this.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},this.applyNamespacing=function(e,r){var n=e,s=".".concat(t.cssPreviewNamespace);void 0!==r&&(s=r),"string"==typeof e&&(n=t.parseCSS(e));for(var o=0;o<n.length;o++){var i=n[o];if(!(i.selector.indexOf("@font-face")>-1||i.selector.indexOf("keyframes")>-1||i.selector.indexOf("@import")>-1||i.selector.indexOf(".form-all")>-1||i.selector.indexOf("#stage")>-1))if("media"!==i.type){for(var c=i.selector.split(","),a=[],l=0;l<c.length;l++)-1===c[l].indexOf(".supernova")?a.push("".concat(s," ").concat(c[l])):a.push(c[l]);i.selector=a.join(",")}else i.subStyles=t.applyNamespacing(i.subStyles,r)}return n},this.clearNamespacing=function(e,r){void 0===r&&(r=!1);var n=e,s=".".concat(t.cssPreviewNamespace);"string"==typeof e&&(n=t.parseCSS(e));for(var o=0;o<n.length;o++){var i=n[o];if("media"!==i.type){for(var c=i.selector.split(","),a=[],l=0;l<c.length;l++)a.push(c[l].split("".concat(s," ")).join(""));i.selector=a.join(",")}else i.subStyles=t.clearNamespacing(i.subStyles,!0)}return!1===r?t.getCSSForEditor(n):n},this.createStyleElement=function(e,r,n){if(void 0===n&&(n=!1),!1===t.testMode&&"nonamespace"!==n&&(r=t.applyNamespacing(r)),"string"!=typeof r&&(r=t.getCSSForEditor(r)),!0===n&&(r=t.getCSSForEditor(t.parseCSS(r))),!1!==t.testMode)return t.testMode("create style #".concat(e),r);var s=document.getElementById(e);s&&s.parentNode.removeChild(s);var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=e,i.type="text/css",o.appendChild(i),i.styleSheet&&!i.sheet?i.styleSheet.cssText=r:i.appendChild(document.createTextNode(r))}};export default function(n){return function(c){for(var a=arguments.length,l=new Array(a>1?a-1:0),u=1;u<a;u++)l[u-1]=arguments[u];return function(a){i(p,t);var u=f(p);function p(){return r(this,p),u.apply(this,arguments)}return s(p,[{key:"componentDidMount",value:function(){this.init()}},{key:"componentDidUpdate",value:function(){this.init()}},{key:"init",value:function(){var e=this,t=l.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+c[n+1]}),c[0]),r=h(),n=d(t),s=g(n),o=y(n);s&&s.forEach((function(e){return n=n.replace(e,"")})),o&&o.forEach((function(e){return n=n.replace(e,"")}));var i=".".concat(r," {").concat(n,"}");s&&s.length&&S.parseCSS(s.join("")).forEach((function(e){var t="".concat(e.selector," { .").concat(r," {");e.subStyles.forEach((function(e){e.rules.forEach((function(e){t+="".concat(e.directive,": ").concat(e.value,";")}))})),i+="\n".concat(t+="}}")}));o&&o.length&&o.forEach((function(e){i+=e.replace("&:",".".concat(r,":"))}));var a=m();a||(v(),a=m()),this.element.setAttribute("class",r),a.textContent+=i}},{key:"render",value:function(){var t=this;return e.createElement(n,o({},this.props,{ref:function(e){return t.element=e}}))}}]),p}()}}
{
"name": "stylished-components",
"version": "0.1.7",
"version": "0.1.8",
"description": "Tiny Styled Components Library for React",
"main": "lib/stylished-components.esm.js",
"scripts": {
"prepublish": "npm run build && npm test",
"build": "./node_modules/.bin/rollup -c",
"clean": "rimraf lib",
"prepublish": "npm run clean && npm run build && npm test",
"build": "node rollup.config.dev.js",
"rollup": "./node_modules/.bin/rollup -c",
"flow": "flow",
"test": "start-server-and-test dev http://localhost:3000 cyp:run",
"test": "start-server-and-test devserver http://localhost:3000 cyp:run",
"cyp:open": "cypress open",
"cyp:run": "cypress run",
"cyp": "BROWSER=open start-server-and-test dev http://localhost:3000 cyp",
"cyp": "BROWSER=open start-server-and-test devserver http://localhost:3000 cyp:open",
"lint": "eslint src",
"dev": "cd __tests__/app && npm start"
"devserver": "cd __tests__/app && npm start"
},

@@ -35,2 +37,5 @@ "peerDependencies": {

"babel-loader": "^8.1.0",
"chalk": "^3.0.0",
"clear": "^0.1.0",
"clui": "^0.3.6",
"cypress": "^4.2.0",

@@ -45,4 +50,7 @@ "eslint": "^6.8.0",

"eslint-plugin-react-hooks": "^3.0.0",
"figlet": "^1.3.0",
"flow-bin": "^0.121.0",
"inquirer": "^7.1.0",
"jest": "^25.2.4",
"minimist": "^1.2.5",
"prettier": "^2.0.2",

@@ -49,0 +57,0 @@ "react": "^16.13.1",

@@ -15,8 +15,5 @@ [![npm version](https://badge.fury.io/js/stylished-components.svg)](https://badge.fury.io/js/stylished-components)

We provide es, cjs, and umd modules. The es build is import by default. In order to import cjs or umd:
By default, we only include es module with our bundle. We do provide the ability to easily bundle cjs and umd by forking this repo and running `npm run build` (or `yarn`)
```javascript
import stylished from 'stylished-components/lib/stylished-components.cjs.js'; // cjs
import stylished from 'stylished-components/lib/stylished-components.umd.js'; // umd
```
- #### Media Queries

@@ -26,3 +23,3 @@ To use media queries, leave off the class name but keep the curly braces, like:

```javascript
const MyComponent = stylished('div')`
const MediaQueryDiv = stylished('div')`
@media (min-width: 900px) {{

@@ -35,2 +32,15 @@ color: orange;

- #### Hover
To use hover, place an `&` before hover, like:
```javascript
const HoverDiv = stylished('div')`
background-color: blue;
&:hover {
background-color: green;
}
`;
```
# Parameters

@@ -59,2 +69,8 @@

/* Can use hover, too! */
/* Just use the & sign, like so */
&:hover {
color: green;
}
/* ~almost~ anything CSS goes! */

@@ -87,1 +103,17 @@ `;

```
# NPM Scripts
- `npm test`
- launches test app (built with create-react-app) from `__tests__/app`
- *browser does not auto-open by default*
- then runs `cypress run`
- `npm run build`
- prompts you for which module types to bundle before bundling
- `npm run rollup`
- bundles all module types without prompting (esm, cjs, umd)
- `npm run cyp`
- starts dev server and opens cypress without automatically testing
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