stylished-components
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -59,2 +59,2 @@ /** | ||
"use strict";var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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&&s(e.prototype,t),r&&s(e,r),e}function i(){return(i=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 c(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 l(e){return(l=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 u(){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 p(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=l(e);if(u()){var n=l(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return p(this,t)}}var h=function(e){return String.fromCharCode(e+(e>25?39:97))},y=function(){return function(e){var t,r="";for(t=e;t>52;t=Math.floor(t/52))r=h(t%52)+r;return h(t%52)+r}(Math.floor(9999999999999*Math.random()))},v=function(){var e=document.createElement("style");e.setAttribute("data-stylish","stylin"),document.head.appendChild(e)},m=function(){return document.querySelector("style[data-stylish]")},d=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},g=function(e){return d(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var S,b=new((S=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},S.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,s=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=s.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(s,"");for(var o=new RegExp(this.combinedCSSRegex,"gi");null!==(n=o.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),l=c.exec(i);if(null!==l&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var a={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==l&&(a.comments=l[0]),t.push(a)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==l&&(u.comments=l[0]),t.push(u)}}return t},S.prototype.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},S.prototype.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},S.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],s=0;s<e.length;s++)!1===r?e[s].selector===t&&n.push(e[s]):-1!==e[s].selector.indexOf(t)&&n.push(e[s]);if("@imports"===t||n.length<2)return n;var o=n[0];for(s=1;s<n.length;s++)this.intelligentCSSPush([o],n[s]);return[o]},S.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},S.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var s=e[n];if(!0!==r[s.selector]){var o=this.findBySelector(e,s.selector);0!==o.length&&(t=t.concat(o),r[s.selector]=!0)}}return t},S.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,s={selector:e.selector,rules:[]},o=0;o<e.rules.length;o++)r=e.rules[o],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&s.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",s.rules.push(n));return 0!==s.rules.length&&s},S.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var s=e[n];"media"!==s.type&&"keyframes"!==s.type&&(s.rules=this.compactRules(s.rules))}},S.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,s=!1;if(void 0===r&&(r=!1),!1===r){for(var o=0;o<e.length;o++)if(e[o].selector===n){s=e[o];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){s=e[i];break}if(!1===s)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var l=t.rules[c],a=this.findCorrespondingRule(s.rules,l.directive);!1===a?s.rules.push(l):"DELETED"===l.type?a.type="DELETED":a.value=l.value}else s.subStyles=s.subStyles.concat(t.subStyles)},S.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},S.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var s=e[n];if(void 0!==s.selector){var o="";void 0!==s.comments&&(o=s.comments+"\n"),"media"===s.type?(r+=o+s.selector+"{\n",r+=this.getCSSForEditor(s.subStyles,t+1),r+="}\n\n"):"keyframes"!==s.type&&"imports"!==s.type&&(r+=this.getSpaces(t)+o+s.selector+" {\n",r+=this.getCSSOfRules(s.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},S.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},S.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},S.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},S.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if(!(o.selector.indexOf("@font-face")>-1||o.selector.indexOf("keyframes")>-1||o.selector.indexOf("@import")>-1||o.selector.indexOf(".form-all")>-1||o.selector.indexOf("#stage")>-1))if("media"!==o.type){for(var i=o.selector.split(","),c=[],l=0;l<i.length;l++)-1===i[l].indexOf(".supernova")?c.push(n+" "+i[l]):c.push(i[l]);o.selector=c.join(",")}else o.subStyles=this.applyNamespacing(o.subStyles,t)}return r},S.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if("media"!==o.type){for(var i=o.selector.split(","),c=[],l=0;l<i.length;l++)c.push(i[l].split(n+" ").join(""));o.selector=c.join(",")}else o.subStyles=this.clearNamespacing(o.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},S.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=e,o.type="text/css",s.appendChild(o),o.styleSheet&&!o.sheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))},S);module.exports=function(e){return function(s){for(var l=arguments.length,a=new Array(l>1?l-1:0),u=1;u<l;u++)a[u-1]=arguments[u];return function(l){c(p,t.Component);var u=f(p);function p(){return n(this,p),u.apply(this,arguments)}return o(p,[{key:"interpolateStyle",value:function(){var e=this,t=a.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+s[n+1]}),s[0]),r=y(),n=d(t),o=g(n);o&&o.forEach((function(e){return n=n.replace(e,"")}));var i=".".concat(r," {").concat(n,"}");o&&o.length&&b.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+=t+="}}"}));var c=m();c||(v(),c=m()),this.element.setAttribute("class",r),c.textContent+=i}},{key:"componentDidMount",value:function(){this.interpolateStyle()}},{key:"componentDidUpdate",value:function(){this.interpolateStyle()}},{key:"render",value:function(){var t=this;return r.createElement(e,i({},this.props,{ref:function(e){return t.element=e}}))}}]),p}()}}; | ||
"use strict";var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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&&s(e.prototype,t),r&&s(e,r),e}function i(){return(i=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 c(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&&l(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(){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 p(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(u()){var n=a(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return p(this,t)}}var h=function(e){return String.fromCharCode(e+(e>25?39:97))},y=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=h(t%52)+r;return h(t%52)+r}(e))},v=function(){var e=document.createElement("style");e.setAttribute("data-stylished","0.1.5"),document.head.appendChild(e)},d=function(){return document.querySelector("style[data-stylished]")},m=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},g=function(e){return m(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var S,b=new((S=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},S.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,s=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=s.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(s,"");for(var o=new RegExp(this.combinedCSSRegex,"gi");null!==(n=o.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),a=c.exec(i);if(null!==a&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var l={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==a&&(l.comments=a[0]),t.push(l)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==a&&(u.comments=a[0]),t.push(u)}}return t},S.prototype.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},S.prototype.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},S.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],s=0;s<e.length;s++)!1===r?e[s].selector===t&&n.push(e[s]):-1!==e[s].selector.indexOf(t)&&n.push(e[s]);if("@imports"===t||n.length<2)return n;var o=n[0];for(s=1;s<n.length;s++)this.intelligentCSSPush([o],n[s]);return[o]},S.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},S.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var s=e[n];if(!0!==r[s.selector]){var o=this.findBySelector(e,s.selector);0!==o.length&&(t=t.concat(o),r[s.selector]=!0)}}return t},S.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,s={selector:e.selector,rules:[]},o=0;o<e.rules.length;o++)r=e.rules[o],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&s.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",s.rules.push(n));return 0!==s.rules.length&&s},S.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var s=e[n];"media"!==s.type&&"keyframes"!==s.type&&(s.rules=this.compactRules(s.rules))}},S.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,s=!1;if(void 0===r&&(r=!1),!1===r){for(var o=0;o<e.length;o++)if(e[o].selector===n){s=e[o];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){s=e[i];break}if(!1===s)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var a=t.rules[c],l=this.findCorrespondingRule(s.rules,a.directive);!1===l?s.rules.push(a):"DELETED"===a.type?l.type="DELETED":l.value=a.value}else s.subStyles=s.subStyles.concat(t.subStyles)},S.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},S.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var s=e[n];if(void 0!==s.selector){var o="";void 0!==s.comments&&(o=s.comments+"\n"),"media"===s.type?(r+=o+s.selector+"{\n",r+=this.getCSSForEditor(s.subStyles,t+1),r+="}\n\n"):"keyframes"!==s.type&&"imports"!==s.type&&(r+=this.getSpaces(t)+o+s.selector+" {\n",r+=this.getCSSOfRules(s.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},S.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},S.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},S.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},S.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if(!(o.selector.indexOf("@font-face")>-1||o.selector.indexOf("keyframes")>-1||o.selector.indexOf("@import")>-1||o.selector.indexOf(".form-all")>-1||o.selector.indexOf("#stage")>-1))if("media"!==o.type){for(var i=o.selector.split(","),c=[],a=0;a<i.length;a++)-1===i[a].indexOf(".supernova")?c.push(n+" "+i[a]):c.push(i[a]);o.selector=c.join(",")}else o.subStyles=this.applyNamespacing(o.subStyles,t)}return r},S.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if("media"!==o.type){for(var i=o.selector.split(","),c=[],a=0;a<i.length;a++)c.push(i[a].split(n+" ").join(""));o.selector=c.join(",")}else o.subStyles=this.clearNamespacing(o.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},S.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=e,o.type="text/css",s.appendChild(o),o.styleSheet&&!o.sheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))},S);module.exports=function(e){return function(s){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){c(p,t.Component);var u=f(p);function p(){return n(this,p),u.apply(this,arguments)}return o(p,[{key:"init",value:function(){var e=this,t=l.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+s[n+1]}),s[0]),r=y(),n=m(t),o=g(n);o&&o.forEach((function(e){return n=n.replace(e,"")}));var i=".".concat(r," {").concat(n,"}");o&&o.length&&b.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+="}}")}));var c=d();c||(v(),c=d()),this.element.setAttribute("class",r),c.textContent+=i}},{key:"componentDidMount",value:function(){this.init()}},{key:"componentDidUpdate",value:function(){this.init()}},{key:"render",value:function(){var t=this;return r.createElement(e,i({},this.props,{ref:function(e){return t.element=e}}))}}]),p}()}}; |
@@ -59,2 +59,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 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&&l(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 p(e){return function(){var t,r=c(e);if(a()){var n=c(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return u(this,t)}}var f=function(e){return String.fromCharCode(e+(e>25?39:97))},h=function(){return function(e){var t,r="";for(t=e;t>52;t=Math.floor(t/52))r=f(t%52)+r;return f(t%52)+r}(Math.floor(9999999999999*Math.random()))},y=function(){var e=document.createElement("style");e.setAttribute("data-stylish","stylin"),document.head.appendChild(e)},v=function(){return document.querySelector("style[data-stylish]")},m=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},d=function(e){return m(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var g,S=new((g=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},g.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,s=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=s.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(s,"");for(var o=new RegExp(this.combinedCSSRegex,"gi");null!==(n=o.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),l=c.exec(i);if(null!==l&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var a={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==l&&(a.comments=l[0]),t.push(a)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==l&&(u.comments=l[0]),t.push(u)}}return t},g.prototype.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},g.prototype.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},g.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],s=0;s<e.length;s++)!1===r?e[s].selector===t&&n.push(e[s]):-1!==e[s].selector.indexOf(t)&&n.push(e[s]);if("@imports"===t||n.length<2)return n;var o=n[0];for(s=1;s<n.length;s++)this.intelligentCSSPush([o],n[s]);return[o]},g.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},g.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var s=e[n];if(!0!==r[s.selector]){var o=this.findBySelector(e,s.selector);0!==o.length&&(t=t.concat(o),r[s.selector]=!0)}}return t},g.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,s={selector:e.selector,rules:[]},o=0;o<e.rules.length;o++)r=e.rules[o],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&s.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",s.rules.push(n));return 0!==s.rules.length&&s},g.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var s=e[n];"media"!==s.type&&"keyframes"!==s.type&&(s.rules=this.compactRules(s.rules))}},g.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,s=!1;if(void 0===r&&(r=!1),!1===r){for(var o=0;o<e.length;o++)if(e[o].selector===n){s=e[o];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){s=e[i];break}if(!1===s)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var l=t.rules[c],a=this.findCorrespondingRule(s.rules,l.directive);!1===a?s.rules.push(l):"DELETED"===l.type?a.type="DELETED":a.value=l.value}else s.subStyles=s.subStyles.concat(t.subStyles)},g.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},g.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var s=e[n];if(void 0!==s.selector){var o="";void 0!==s.comments&&(o=s.comments+"\n"),"media"===s.type?(r+=o+s.selector+"{\n",r+=this.getCSSForEditor(s.subStyles,t+1),r+="}\n\n"):"keyframes"!==s.type&&"imports"!==s.type&&(r+=this.getSpaces(t)+o+s.selector+" {\n",r+=this.getCSSOfRules(s.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},g.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},g.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},g.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},g.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if(!(o.selector.indexOf("@font-face")>-1||o.selector.indexOf("keyframes")>-1||o.selector.indexOf("@import")>-1||o.selector.indexOf(".form-all")>-1||o.selector.indexOf("#stage")>-1))if("media"!==o.type){for(var i=o.selector.split(","),c=[],l=0;l<i.length;l++)-1===i[l].indexOf(".supernova")?c.push(n+" "+i[l]):c.push(i[l]);o.selector=c.join(",")}else o.subStyles=this.applyNamespacing(o.subStyles,t)}return r},g.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if("media"!==o.type){for(var i=o.selector.split(","),c=[],l=0;l<i.length;l++)c.push(i[l].split(n+" ").join(""));o.selector=c.join(",")}else o.subStyles=this.clearNamespacing(o.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},g.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=e,o.type="text/css",s.appendChild(o),o.styleSheet&&!o.sheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))},g);export default function(n){return function(c){for(var l=arguments.length,a=new Array(l>1?l-1:0),u=1;u<l;u++)a[u-1]=arguments[u];return function(l){i(f,t);var u=p(f);function f(){return r(this,f),u.apply(this,arguments)}return s(f,[{key:"interpolateStyle",value:function(){var e=this,t=a.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+c[n+1]}),c[0]),r=h(),n=m(t),s=d(n);s&&s.forEach((function(e){return n=n.replace(e,"")}));var o=".".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,";")}))})),o+=t+="}}"}));var i=v();i||(y(),i=v()),this.element.setAttribute("class",r),i.textContent+=o}},{key:"componentDidMount",value:function(){this.interpolateStyle()}},{key:"componentDidUpdate",value:function(){this.interpolateStyle()}},{key:"render",value:function(){var t=this;return e.createElement(n,o({},this.props,{ref:function(e){return t.element=e}}))}}]),f}()}} | ||
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 p(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 f=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=f(t%52)+r;return f(t%52)+r}(e))},y=function(){var e=document.createElement("style");e.setAttribute("data-stylished","0.1.5"),document.head.appendChild(e)},v=function(){return document.querySelector("style[data-stylished]")},d=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},m=function(e){return d(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var g,S=new((g=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},g.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,s=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=s.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(s,"");for(var o=new RegExp(this.combinedCSSRegex,"gi");null!==(n=o.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),a=c.exec(i);if(null!==a&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var l={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==a&&(l.comments=a[0]),t.push(l)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==a&&(u.comments=a[0]),t.push(u)}}return t},g.prototype.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},g.prototype.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},g.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],s=0;s<e.length;s++)!1===r?e[s].selector===t&&n.push(e[s]):-1!==e[s].selector.indexOf(t)&&n.push(e[s]);if("@imports"===t||n.length<2)return n;var o=n[0];for(s=1;s<n.length;s++)this.intelligentCSSPush([o],n[s]);return[o]},g.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},g.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var s=e[n];if(!0!==r[s.selector]){var o=this.findBySelector(e,s.selector);0!==o.length&&(t=t.concat(o),r[s.selector]=!0)}}return t},g.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,s={selector:e.selector,rules:[]},o=0;o<e.rules.length;o++)r=e.rules[o],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&s.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",s.rules.push(n));return 0!==s.rules.length&&s},g.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var s=e[n];"media"!==s.type&&"keyframes"!==s.type&&(s.rules=this.compactRules(s.rules))}},g.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,s=!1;if(void 0===r&&(r=!1),!1===r){for(var o=0;o<e.length;o++)if(e[o].selector===n){s=e[o];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){s=e[i];break}if(!1===s)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var a=t.rules[c],l=this.findCorrespondingRule(s.rules,a.directive);!1===l?s.rules.push(a):"DELETED"===a.type?l.type="DELETED":l.value=a.value}else s.subStyles=s.subStyles.concat(t.subStyles)},g.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},g.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var s=e[n];if(void 0!==s.selector){var o="";void 0!==s.comments&&(o=s.comments+"\n"),"media"===s.type?(r+=o+s.selector+"{\n",r+=this.getCSSForEditor(s.subStyles,t+1),r+="}\n\n"):"keyframes"!==s.type&&"imports"!==s.type&&(r+=this.getSpaces(t)+o+s.selector+" {\n",r+=this.getCSSOfRules(s.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},g.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},g.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},g.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},g.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if(!(o.selector.indexOf("@font-face")>-1||o.selector.indexOf("keyframes")>-1||o.selector.indexOf("@import")>-1||o.selector.indexOf(".form-all")>-1||o.selector.indexOf("#stage")>-1))if("media"!==o.type){for(var i=o.selector.split(","),c=[],a=0;a<i.length;a++)-1===i[a].indexOf(".supernova")?c.push(n+" "+i[a]):c.push(i[a]);o.selector=c.join(",")}else o.subStyles=this.applyNamespacing(o.subStyles,t)}return r},g.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var s=0;s<r.length;s++){var o=r[s];if("media"!==o.type){for(var i=o.selector.split(","),c=[],a=0;a<i.length;a++)c.push(i[a].split(n+" ").join(""));o.selector=c.join(",")}else o.subStyles=this.clearNamespacing(o.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},g.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=e,o.type="text/css",s.appendChild(o),o.styleSheet&&!o.sheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))},g);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(f,t);var u=p(f);function f(){return r(this,f),u.apply(this,arguments)}return s(f,[{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=m(n);s&&s.forEach((function(e){return n=n.replace(e,"")}));var o=".".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,";")}))})),o+="\n".concat(t+="}}")}));var i=v();i||(y(),i=v()),this.element.setAttribute("class",r),i.textContent+=o}},{key:"componentDidMount",value:function(){this.init()}},{key:"componentDidUpdate",value:function(){this.init()}},{key:"render",value:function(){var t=this;return e.createElement(n,o({},this.props,{ref:function(e){return t.element=e}}))}}]),f}()}} |
@@ -59,2 +59,2 @@ /** | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).ReactFlexboxSlim=t(e.React)}(this,(function(e){"use strict";var t="default"in e?e.default:e;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&&l(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 p(e){return function(){var t,r=c(e);if(a()){var n=c(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return u(this,t)}}var f=function(e){return String.fromCharCode(e+(e>25?39:97))},h=function(){return function(e){var t,r="";for(t=e;t>52;t=Math.floor(t/52))r=f(t%52)+r;return f(t%52)+r}(Math.floor(9999999999999*Math.random()))},y=function(){var e=document.createElement("style");e.setAttribute("data-stylish","stylin"),document.head.appendChild(e)},d=function(){return document.querySelector("style[data-stylish]")},v=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},m=function(e){return v(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var g,S=new((g=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},g.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,o=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=o.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(o,"");for(var s=new RegExp(this.combinedCSSRegex,"gi");null!==(n=s.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),l=c.exec(i);if(null!==l&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var a={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==l&&(a.comments=l[0]),t.push(a)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==l&&(u.comments=l[0]),t.push(u)}}return t},g.prototype.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},g.prototype.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},g.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],o=0;o<e.length;o++)!1===r?e[o].selector===t&&n.push(e[o]):-1!==e[o].selector.indexOf(t)&&n.push(e[o]);if("@imports"===t||n.length<2)return n;var s=n[0];for(o=1;o<n.length;o++)this.intelligentCSSPush([s],n[o]);return[s]},g.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},g.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var o=e[n];if(!0!==r[o.selector]){var s=this.findBySelector(e,o.selector);0!==s.length&&(t=t.concat(s),r[o.selector]=!0)}}return t},g.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,o={selector:e.selector,rules:[]},s=0;s<e.rules.length;s++)r=e.rules[s],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&o.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",o.rules.push(n));return 0!==o.rules.length&&o},g.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var o=e[n];"media"!==o.type&&"keyframes"!==o.type&&(o.rules=this.compactRules(o.rules))}},g.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,o=!1;if(void 0===r&&(r=!1),!1===r){for(var s=0;s<e.length;s++)if(e[s].selector===n){o=e[s];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){o=e[i];break}if(!1===o)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var l=t.rules[c],a=this.findCorrespondingRule(o.rules,l.directive);!1===a?o.rules.push(l):"DELETED"===l.type?a.type="DELETED":a.value=l.value}else o.subStyles=o.subStyles.concat(t.subStyles)},g.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},g.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var o=e[n];if(void 0!==o.selector){var s="";void 0!==o.comments&&(s=o.comments+"\n"),"media"===o.type?(r+=s+o.selector+"{\n",r+=this.getCSSForEditor(o.subStyles,t+1),r+="}\n\n"):"keyframes"!==o.type&&"imports"!==o.type&&(r+=this.getSpaces(t)+s+o.selector+" {\n",r+=this.getCSSOfRules(o.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},g.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},g.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},g.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},g.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var o=0;o<r.length;o++){var s=r[o];if(!(s.selector.indexOf("@font-face")>-1||s.selector.indexOf("keyframes")>-1||s.selector.indexOf("@import")>-1||s.selector.indexOf(".form-all")>-1||s.selector.indexOf("#stage")>-1))if("media"!==s.type){for(var i=s.selector.split(","),c=[],l=0;l<i.length;l++)-1===i[l].indexOf(".supernova")?c.push(n+" "+i[l]):c.push(i[l]);s.selector=c.join(",")}else s.subStyles=this.applyNamespacing(s.subStyles,t)}return r},g.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var o=0;o<r.length;o++){var s=r[o];if("media"!==s.type){for(var i=s.selector.split(","),c=[],l=0;l<i.length;l++)c.push(i[l].split(n+" ").join(""));s.selector=c.join(",")}else s.subStyles=this.clearNamespacing(s.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},g.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var o=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.id=e,s.type="text/css",o.appendChild(s),s.styleSheet&&!s.sheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))},g);return function(n){return function(c){for(var l=arguments.length,a=new Array(l>1?l-1:0),u=1;u<l;u++)a[u-1]=arguments[u];return function(e){i(u,e);var l=p(u);function u(){return r(this,u),l.apply(this,arguments)}return o(u,[{key:"interpolateStyle",value:function(){var e=this,t=a.reduce((function(t,r,n){return t+("function"==typeof r?r(e.props):r)+c[n+1]}),c[0]),r=h(),n=v(t),o=m(n);o&&o.forEach((function(e){return n=n.replace(e,"")}));var s=".".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,";")}))})),s+=t+="}}"}));var i=d();i||(y(),i=d()),this.element.setAttribute("class",r),i.textContent+=s}},{key:"componentDidMount",value:function(){this.interpolateStyle()}},{key:"componentDidUpdate",value:function(){this.interpolateStyle()}},{key:"render",value:function(){var e=this;return t.createElement(n,s({},this.props,{ref:function(t){return e.element=t}}))}}]),u}(e.Component)}}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).StylishedComponents=t(e.React)}(this,(function(e){"use strict";var t="default"in e?e.default:e;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&&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 p(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 f=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=f(t%52)+r;return f(t%52)+r}(e))},y=function(){var e=document.createElement("style");e.setAttribute("data-stylished","0.1.5"),document.head.appendChild(e)},d=function(){return document.querySelector("style[data-stylished]")},v=function(e){return e.replace(/\n/g,"").replace(/\s+/g," ")},m=function(e){return v(e).match(/((@media [\s]*).*?[^}]*}.*?})/g)};var g,S=new((g=function(){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")}).prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},g.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var r=this.cssImportStatementRegex.exec(e);if(null===r)break;this.cssImportStatements.push(r[0]),t.push({selector:"@imports",type:"imports",styles:r[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var n,o=new RegExp(this.cssKeyframeRegex,"gi");null!==(n=o.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:n[0]});e=e.replace(o,"");for(var s=new RegExp(this.combinedCSSRegex,"gi");null!==(n=s.exec(e));){var i="";i=void 0===n[2]?n[5].split("\r\n").join("\n").trim():n[2].split("\r\n").join("\n").trim();var c=new RegExp(this.cssCommentsRegex,"gi"),a=c.exec(i);if(null!==a&&(i=i.replace(c,"").trim()),-1!==(i=i.replace(/\n+/,"\n")).indexOf("@media")){var l={selector:i,type:"media",subStyles:this.parseCSS(n[3]+"\n}")};null!==a&&(l.comments=a[0]),t.push(l)}else{var u={selector:i,rules:this.parseRules(n[6])};"@font-face"===i&&(u.type="font-face"),null!==a&&(u.comments=a[0]),t.push(u)}}return t},g.prototype.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},g.prototype.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},g.prototype.findBySelector=function(e,t,r){void 0===r&&(r=!1);for(var n=[],o=0;o<e.length;o++)!1===r?e[o].selector===t&&n.push(e[o]):-1!==e[o].selector.indexOf(t)&&n.push(e[o]);if("@imports"===t||n.length<2)return n;var s=n[0];for(o=1;o<n.length;o++)this.intelligentCSSPush([s],n[o]);return[s]},g.prototype.deleteBySelector=function(e,t){for(var r=[],n=0;n<e.length;n++)e[n].selector!==t&&r.push(e[n]);return r},g.prototype.compressCSS=function(e){for(var t=[],r={},n=0;n<e.length;n++){var o=e[n];if(!0!==r[o.selector]){var s=this.findBySelector(e,o.selector);0!==s.length&&(t=t.concat(s),r[o.selector]=!0)}}return t},g.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var r,n,o={selector:e.selector,rules:[]},s=0;s<e.rules.length;s++)r=e.rules[s],(!1===(n=this.findCorrespondingRule(t.rules,r.directive,r.value))||r.value!==n.value)&&o.rules.push(r);for(var i=0;i<t.rules.length;i++)n=t.rules[i],!1===(r=this.findCorrespondingRule(e.rules,n.directive))&&(n.type="DELETED",o.rules.push(n));return 0!==o.rules.length&&o},g.prototype.intelligentMerge=function(e,t,r){void 0===r&&(r=!1);for(var n=0;n<t.length;n++)this.intelligentCSSPush(e,t[n],r);for(n=0;n<e.length;n++){var o=e[n];"media"!==o.type&&"keyframes"!==o.type&&(o.rules=this.compactRules(o.rules))}},g.prototype.intelligentCSSPush=function(e,t,r){var n=t.selector,o=!1;if(void 0===r&&(r=!1),!1===r){for(var s=0;s<e.length;s++)if(e[s].selector===n){o=e[s];break}}else for(var i=e.length-1;i>-1;i--)if(e[i].selector===n){o=e[i];break}if(!1===o)e.push(t);else if("media"!==t.type)for(var c=0;c<t.rules.length;c++){var a=t.rules[c],l=this.findCorrespondingRule(o.rules,a.directive);!1===l?o.rules.push(a):"DELETED"===a.type?l.type="DELETED":l.value=a.value}else o.subStyles=o.subStyles.concat(t.subStyles)},g.prototype.compactRules=function(e){for(var t=[],r=0;r<e.length;r++)"DELETED"!==e[r].type&&t.push(e[r]);return t},g.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var r="";void 0===e&&(e=this.css);for(var n=0;n<e.length;n++)"imports"===e[n].type&&(r+=e[n].styles+"\n\n");for(n=0;n<e.length;n++){var o=e[n];if(void 0!==o.selector){var s="";void 0!==o.comments&&(s=o.comments+"\n"),"media"===o.type?(r+=s+o.selector+"{\n",r+=this.getCSSForEditor(o.subStyles,t+1),r+="}\n\n"):"keyframes"!==o.type&&"imports"!==o.type&&(r+=this.getSpaces(t)+s+o.selector+" {\n",r+=this.getCSSOfRules(o.rules,t+1),r+=this.getSpaces(t)+"}\n\n")}}for(n=0;n<e.length;n++)"keyframes"===e[n].type&&(r+=e[n].styles+"\n\n");return r},g.prototype.getImports=function(e){for(var t=[],r=0;r<e.length;r++)"imports"===e[r].type&&t.push(e[r].styles);return t},g.prototype.getCSSOfRules=function(e,t){for(var r="",n=0;n<e.length;n++)void 0!==e[n]&&(void 0===e[n].defective?r+=this.getSpaces(t)+e[n].directive+": "+e[n].value+";\n":r+=this.getSpaces(t)+e[n].value+";\n");return r||"\n"},g.prototype.getSpaces=function(e){for(var t="",r=0;r<4*e;r++)t+=" ";return t},g.prototype.applyNamespacing=function(e,t){var r=e,n="."+this.cssPreviewNamespace;void 0!==t&&(n=t),"string"==typeof e&&(r=this.parseCSS(e));for(var o=0;o<r.length;o++){var s=r[o];if(!(s.selector.indexOf("@font-face")>-1||s.selector.indexOf("keyframes")>-1||s.selector.indexOf("@import")>-1||s.selector.indexOf(".form-all")>-1||s.selector.indexOf("#stage")>-1))if("media"!==s.type){for(var i=s.selector.split(","),c=[],a=0;a<i.length;a++)-1===i[a].indexOf(".supernova")?c.push(n+" "+i[a]):c.push(i[a]);s.selector=c.join(",")}else s.subStyles=this.applyNamespacing(s.subStyles,t)}return r},g.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var r=e,n="."+this.cssPreviewNamespace;"string"==typeof e&&(r=this.parseCSS(e));for(var o=0;o<r.length;o++){var s=r[o];if("media"!==s.type){for(var i=s.selector.split(","),c=[],a=0;a<i.length;a++)c.push(i[a].split(n+" ").join(""));s.selector=c.join(",")}else s.subStyles=this.clearNamespacing(s.subStyles,!0)}return!1===t?this.getCSSForEditor(r):r},g.prototype.createStyleElement=function(e,t,r){if(void 0===r&&(r=!1),!1===this.testMode&&"nonamespace"!==r&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),!0===r&&(t=this.getCSSForEditor(this.parseCSS(t))),!1!==this.testMode)return this.testMode("create style #"+e,t);var n=document.getElementById(e);n&&n.parentNode.removeChild(n);var o=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.id=e,s.type="text/css",o.appendChild(s),s.styleSheet&&!s.sheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))},g);return 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(e){i(u,e);var a=p(u);function u(){return r(this,u),a.apply(this,arguments)}return o(u,[{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=v(t),o=m(n);o&&o.forEach((function(e){return n=n.replace(e,"")}));var s=".".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,";")}))})),s+="\n".concat(t+="}}")}));var i=d();i||(y(),i=d()),this.element.setAttribute("class",r),i.textContent+=s}},{key:"componentDidMount",value:function(){this.init()}},{key:"componentDidUpdate",value:function(){this.init()}},{key:"render",value:function(){var e=this;return t.createElement(n,s({},this.props,{ref:function(t){return e.element=t}}))}}]),u}(e.Component)}}})); |
{ | ||
"name": "stylished-components", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Tiny Styled Components Library for React", | ||
@@ -19,2 +19,3 @@ "main": "lib/stylished-components.esm.js", | ||
"@babel/preset-react": "^7.9.4", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
@@ -21,0 +22,0 @@ "@rollup/plugin-strip": "^1.3.2", |
import path from 'path'; | ||
import babel from 'rollup-plugin-babel'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import strip from '@rollup/plugin-strip'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import license from 'rollup-plugin-license'; | ||
import resolve from '@rollup/plugin-node-resolve'; // Resolve file extensions | ||
import strip from '@rollup/plugin-strip'; // Remove debugging code (like console.log(), etc..) | ||
import { terser } from 'rollup-plugin-terser'; // Uglify/minify | ||
import license from 'rollup-plugin-license'; // Dumps license into compiled files | ||
import json from '@rollup/plugin-json'; // Lets us import json files as modules | ||
/** | ||
* Root constants that make up the base of our config | ||
*/ | ||
const ROOT_CONSTANTS = { | ||
@@ -39,2 +44,6 @@ input: 'src/StylishedComponents.jsx', | ||
/** | ||
* Constants to be used in Rollup bundles | ||
*/ | ||
const CONSTANTS = { | ||
@@ -44,2 +53,3 @@ ...ROOT_CONSTANTS, | ||
resolve(ROOT_CONSTANTS.plugins.resolve), | ||
json(), | ||
strip(), | ||
@@ -52,3 +62,7 @@ babel(ROOT_CONSTANTS.plugins.babel), | ||
export default [ | ||
/** | ||
* Bundles built here | ||
*/ | ||
const bundles = [ | ||
// ES | ||
@@ -69,3 +83,3 @@ { | ||
file: 'lib/stylished-components.umd.js', | ||
name: 'ReactFlexboxSlim', | ||
name: 'StylishedComponents', | ||
format: 'umd', | ||
@@ -90,1 +104,3 @@ globals: CONSTANTS.output.globals, | ||
]; | ||
export default bundles; |
@@ -15,4 +15,4 @@ import React, { Component } from 'react'; | ||
return class extends Component { | ||
interpolateStyle() { | ||
// Check whether or not the user supplied a function | ||
init() { | ||
// Check whether or not the user supplied props (function or not) | ||
// If so, run the function and add the result to our style object | ||
@@ -40,3 +40,3 @@ const style = exprs.reduce((result, expr, index) => { | ||
// If media queries were found, parse strings to objects, | ||
// If media queries were found, parse strings to array of objects, | ||
// loop through them, and the rules within them, add our | ||
@@ -55,3 +55,3 @@ // custom class name to each rule, then add to our main css (but hoisted) | ||
mediaQueryStr += '}}'; | ||
finalStyles += mediaQueryStr; | ||
finalStyles += `\n${mediaQueryStr}`; | ||
}); | ||
@@ -61,6 +61,6 @@ } | ||
// Check if we already added a stylesheet, if not, add one | ||
let existingSheet = getStylesheet(); | ||
if (!existingSheet) { | ||
let stylesheet = getStylesheet(); | ||
if (!stylesheet) { | ||
makeStylesheet(); | ||
existingSheet = getStylesheet(); | ||
stylesheet = getStylesheet(); | ||
} | ||
@@ -71,11 +71,11 @@ | ||
// Add styles to page | ||
existingSheet.textContent += finalStyles; | ||
stylesheet.textContent += finalStyles; | ||
} | ||
componentDidMount() { | ||
this.interpolateStyle(); | ||
this.init(); | ||
} | ||
componentDidUpdate() { | ||
this.interpolateStyle(); | ||
this.init(); | ||
} | ||
@@ -82,0 +82,0 @@ |
@@ -1,2 +0,4 @@ | ||
/* TAKEN FROM STYLED COMPONENTS */ | ||
import { version } from '../package.json'; | ||
/* THE FOLLOWING 2 FUNCTIONS WERE TAKEN FROM STYLED COMPONENTS */ | ||
/* https://github.com/styled-components/styled-components/blob/v3.3.3/src/utils/generateAlphabeticName.js */ | ||
@@ -12,6 +14,4 @@ const charsLength = 52; | ||
let x; | ||
console.log('\r\n') | ||
for (x = code; x > charsLength; x = Math.floor(x / charsLength)) { | ||
name = getAlphabeticChar(x % charsLength) + name; | ||
console.log('x =', x, ' | ', 'Math.floor(x / charsLength) =', Math.floor(x / charsLength), ' | ', x % charsLength, ' | ', name); | ||
} | ||
@@ -24,3 +24,3 @@ return getAlphabeticChar(x % charsLength) + name; | ||
const randomNumbers = Math.floor(Math.random() * 9999999999999); | ||
return generateAlphabeticName(randomNumbers); | ||
return `stylished-${generateAlphabeticName(randomNumbers)}`; | ||
} | ||
@@ -30,3 +30,3 @@ | ||
const sheet = document.createElement('style'); | ||
sheet.setAttribute('data-stylish', 'stylin'); | ||
sheet.setAttribute('data-stylished', version); | ||
document.head.appendChild(sheet); | ||
@@ -36,3 +36,3 @@ }; | ||
export const getStylesheet = () => { | ||
return document.querySelector('style[data-stylish]'); | ||
return document.querySelector('style[data-stylished]'); | ||
} | ||
@@ -39,0 +39,0 @@ |
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
72488
1114
14