Comparing version 0.12.0 to 0.12.1
{ | ||
"name": "radium", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"homepage": "https://github.com/FormidableLabs/radium", | ||
@@ -5,0 +5,0 @@ "description": "A set of tools to manage inline styles on React elements", |
@@ -11,4 +11,9 @@ Thanks for contributing! | ||
## Flow | ||
1. [Install flow](http://flowtype.org/docs/getting-started.html#installing-flow) | ||
2. Run `flow` to check for missing annotations and static type check failures | ||
## Dist | ||
Please do not commit changes to files in `dist`. These files are only committed when we tag releases. |
@@ -1,2 +0,1 @@ | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("React")):"function"==typeof define&&define.amd?define(["React"],r):"object"==typeof exports?exports.Radium=r(require("React")):t.Radium=r(t.React)}(this,function(t){return function(t){function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,r,e){"use strict";r.Enhancer=e(54),r.Style=e(2),r.getState=e(3),r.keyframes=e(4),r.wrap=e(5)},function(t,r,e){"use strict";function n(t){return t}t.exports=n},function(t,r,e){"use strict";var n=e(6),o=e(17),u=e(18),i=function(t,r){return t&&r?t+"{"+o.createMarkupForStyles(r)+"}":void 0},c=n.createClass({displayName:"Style",propTypes:{scopeSelector:n.PropTypes.string,rules:n.PropTypes.arrayOf(n.PropTypes.object)},getDefaultProps:function(){return{scopeSelector:""}},_buildStyles:function(t){var r=u(t,function(t,r){var e=Object.keys(r)[0],n=r[e];if("mediaQueries"===e)t+=this._buildMediaQueryString(n);else{var o=(this.props.scopeSelector?this.props.scopeSelector+" ":"")+e;t+=i(o,n)}return t},"",this);return r},_buildMediaQueryString:function(t){var r=this._getContextMediaQueries(),e="";return Object.keys(t).forEach(function(n){var o=r[n]?r[n]:n;e+="@media "+o+"{"+this._buildStyles(t[n])+"}"}.bind(this)),e},_getContextMediaQueries:function(){var t={};return this.context&&this.context.mediaQueries&&Object.keys(this.context.mediaQueries).forEach(function(r){t[r]=this.context.mediaQueries[r].media}.bind(this)),t},render:function(){if(!this.props.rules)return null;var t=this._buildStyles(this.props.rules);return n.createElement("style",{dangerouslySetInnerHTML:{__html:t}})}});t.exports=c},function(t,r,e){"use strict";var n=[":active",":focus",":hover"],o=function(t,r,e){if(r=r||"main",-1===n.indexOf(e))throw new Error("Radium.getState invalid value param: `"+e+"`");return t&&t._radiumStyleState&&t._radiumStyleState[r]&&t._radiumStyleState[r][e]||!1};t.exports=o},function(t,r,e){"use strict";var n=e(9),o=e(10),u=e(11),i=/^ms-/,c=1,s=null,a=null;o.canUseDOM&&(s=document.createElement("style"),document.head.appendChild(s),a="keyframes",s.textContent="@keyframes {}",s.sheet.cssRules.length||(a=n.css+"keyframes"));var f=function(t){return Object.keys(t).map(function(r){return u(r).replace(i,"-ms-")+": "+t[r]+";"}).join("\n")},l=function(t){var r="Animation"+c;if(c+=1,!o.canUseDOM)return r;var e="@"+a+" "+r+" {\n"+Object.keys(t).map(function(r){var e=t[r],o=n(e,"css"),u=f(o);return" "+r+" {\n "+u+"\n }"}).join("\n")+"\n}\n";return s.sheet.insertRule(e,s.sheet.cssRules.length),r};t.exports=l},function(t,r,e){"use strict";var n=e(7),o=e(8),u=e(12),i=function(t){var r={getInitialState:function(){var r=t.getInitialState?t.getInitialState.call(this):{},e=o.getInitialState();return u({},r,e)},componentWillUnmount:function(){t.componentWillUnmount&&t.componentWillUnmount.call(this),o.componentWillUnmount(this)},render:function(){var r=t.render.call(this);return n(this,r)}};return u({},t,r)};t.exports=i},function(r,e,n){r.exports=t},function(t,r,e){"use strict";var n=e(13),o=e(3),u=e(9),i=e(10),c=e(6),s=e(14),a=e(15),f=e(12),l=e(16),p={},v=function(t){return":"===t[0]||"@"===t[0]},y=function(t,r,e){return o(t.state,r,e)},d=function(t,r,e){var n=t.state&&t.state._radiumStyleState||{},o={_radiumStyleState:s(n)};o._radiumStyleState[r]=o._radiumStyleState[r]||{},f(o._radiumStyleState[r],e),t.setState(o)},h=function(t){var r=t.filter(function(t){return t&&"object"==typeof t&&!a(t)});return f.apply(null,[{}].concat(r))},b=function(t){Object.keys(t.state._radiumStyleState).forEach(function(r){y(t,r,":active")&&d(t,r,{":active":!1})})},x=function(t,r,e){var n={};n[r]=e.matches,d(t,"_all",n)},m=function(t,r){return i.canUseDOM&&window&&window.matchMedia?(Object.keys(r).filter(function(t){return"@"===t[0]}).map(function(e){var n=r[e];e=e.replace("@media ","");var o=p[e];if(o||(p[e]=o=window.matchMedia(e)),t._radiumMediaQueryListenersByQuery||(t._radiumMediaQueryListenersByQuery={}),!t._radiumMediaQueryListenersByQuery[e]){var u=x.bind(null,t,e);o.addListener(u),t._radiumMediaQueryListenersByQuery[e]={remove:function(){o.removeListener(u)}}}o.matches&&(r=h([r,n]))}),r):r},g=function j(t,r,e){if(e=e||{},!r)return r;var o=null,s=r.props.children;if(s)if(1===c.Children.count(s)&&s.type){var p=c.Children.only(s);o=j(t,p,e)}else o=c.Children.map(s,function(r){return c.isValidElement(r)?j(t,r,e):r});var x=r.props,g=x.style,w={};if(a(g)&&(g=h(g)),!g||!Object.keys(g).some(v))return g?(w.style=u(g),c.cloneElement(r,w,o)):o?c.cloneElement(r,{},o):r;var O=r.ref||r.key,S=O||"main";if(e[S])throw new Error("Radium requires each element with interactive styles to have a unique key, set using either the ref or key prop. "+(O?'Key "'+O+'" is a duplicate.':"Multiple elements have no key specified."));e[S]=!0,g=m(t,g);var A=l(g,function(t,r){return v(r)});if(g[":hover"]||g[":active"]){var E=x.onMouseEnter;w.onMouseEnter=function(r){E&&E(r),d(t,S,{":hover":!0})};var U=x.onMouseLeave;w.onMouseLeave=function(r){U&&U(r),d(t,S,{":hover":!1})}}if(g[":active"]){var M=x.onMouseDown;w.onMouseDown=function(r){M&&M(r),t._lastMouseDown=Date.now(),d(t,S,{":active":!0})}}if(g[":focus"]){var k=x.onFocus;w.onFocus=function(r){k&&k(r),d(t,S,{":focus":!0})};var _=x.onBlur;w.onBlur=function(r){_&&_(r),d(t,S,{":focus":!1})}}return Object.keys(g).forEach(function(r){(":active"===r&&y(t,S,":active")||":hover"===r&&y(t,S,":hover")||":focus"===r&&y(t,S,":focus"))&&f(A,g[r])}),g[":active"]&&!t._radiumMouseUpListener&&i.canUseEventListeners&&(t._radiumMouseUpListener=n.subscribe(b.bind(null,t))),w.style=u(A),c.cloneElement(r,w,o)};g.__clearStateForTests=function(){p={}},t.exports=g},function(t,r,e){"use strict";t.exports={getInitialState:function(){return{_radiumStyleState:{}}},componentWillUnmount:function(t){t._radiumMouseUpListener&&t._radiumMouseUpListener.remove(),t._radiumMediaQueryListenersByQuery&&Object.keys(t._radiumMediaQueryListenersByQuery).forEach(function(r){t._radiumMediaQueryListenersByQuery[r].remove()},t)}}},function(t,r,e){"use strict";var n=e(10),o=e(11),u={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-",O:"-o-"},i="Transform",c={},s={},a={},f="",l="";if(n.canUseDOM){c=document.createElement("p").style;for(var p in u)if(p+i in c){f=p,l=u[p];break}}var v=function(t){if(s.hasOwnProperty(t))return s[t];if(!n.canUseDOM||t in c)return s[t]={css:o(t),js:t},s[t];var r=f+t[0].toUpperCase()+t.slice(1);return r in c?(s[t]={css:l+o(t),js:r},s[t]):s[t]=!1},y=function(t,r){if("string"!=typeof r||!isNaN(parseInt(r,10)))return r;var e=t+r;return a.hasOwnProperty(e)?a[e]:(c[t]="",c[t]=r,c[t]?(a[e]=r,r):(r=l+r,c[t]=r,c[t]?(a[e]=r,r):a[e]=!1))},d=function(t,r){r=r||"js";var e={};return Object.keys(t).forEach(function(n){var o=t[n],u=v(n);if(u===!1)return void(console&&console.warn&&console.warn("Unsupported CSS property "+n));var i=y(u.js,o);i===!1&&console&&console.warn&&console.warn("Unsupported CSS value "+o+" for property "+n),e[u[r]]=i}),e};d.css=l,d.js=f,t.exports=d},function(t,r,e){"use strict";var n=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:n,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:n&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:n&&!!window.screen};t.exports=o},function(t,r,e){"use strict";var n=e(19),o=n(function(t,r,e){return t+(e?"-":"")+r.toLowerCase()});t.exports=o},function(t,r,e){"use strict";var n=e(20),o=e(21),u=o(n);t.exports=u},function(t,r,e){"use strict";var n=[],o=!1,u=function(t){n.forEach(function(r){r(t)})},i=function(t){return-1===n.indexOf(t)&&n.push(t),o||(window.addEventListener("mouseup",u),o=!0),{remove:function(){var r=n.indexOf(t);n.splice(r,1),0===n.length&&o&&(window.removeEventListener("mouseup",u),o=!1)}}};t.exports={subscribe:i}},function(t,r,e){"use strict";function n(t,r,e,n){return r&&"boolean"!=typeof r&&i(t,r,e)?r=!1:"function"==typeof r&&(n=e,e=r,r=!1),e="function"==typeof e&&u(e,n,1),o(t,r,e)}var o=e(30),u=e(22),i=e(31);t.exports=n},function(t,r,e){"use strict";var n=e(32),o=e(33),u=e(34),i="[object Array]",c=Object.prototype,s=c.toString,a=o(a=Array.isArray)&&a,f=a||function(t){return u(t)&&n(t.length)&&s.call(t)==i};t.exports=f},function(t,r,e){"use strict";var n=e(24),o=e(25),u=e(26),i=e(22),c=e(23),s=e(27),a=e(28),f=e(29),l=f(function(t,r){if(null==t)return{};if("function"!=typeof r[0]){var r=n(u(r),String);return s(t,o(c(t),r))}var e=i(r[0],r[1],3);return a(t,function(t,r,n){return!e(t,r,n)})});t.exports=l},function(t,r,e){"use strict";var n=e(39),o=e(40),u=(e(41),e(42)),i=e(38),c=e(43),s=(e(44),c(function(t){return i(t)})),a="cssFloat";o.canUseDOM&&void 0===document.documentElement.style.cssFloat&&(a="styleFloat");var f={createMarkupForStyles:function(t){var r="";for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];null!=n&&(r+=s(e)+":",r+=u(e,n)+";")}return r||null},setValueForStyles:function(t,r){var e=t.style;for(var o in r)if(r.hasOwnProperty(o)){var i=u(o,r[o]);if("float"===o&&(o=a),i)e[o]=i;else{var c=n.shorthandPropertyExpansions[o];if(c)for(var s in c)e[s]="";else e[o]=""}}}};t.exports=f},function(t,r,e){"use strict";var n=e(35),o=e(36),u=e(37),i=u(n,o);t.exports=i},function(t,r,e){"use strict";function n(t){return function(r){for(var e=-1,n=u(o(r)),i=n.length,c="";++e<i;)c=t(c,n[e],e);return c}}var o=e(45),u=e(46);t.exports=n},function(t,r,e){"use strict";function n(t,r,e,v,d){if(!a(t))return t;var h=s(r)&&(c(r)||l(r));if(!h){var b=p(r);y.apply(b,i(r))}return o(b||r,function(o,i){if(b&&(i=o,o=r[i]),f(o))v||(v=[]),d||(d=[]),u(t,r,i,n,e,v,d);else{var c=t[i],s=e?e(c,o,i,t,r):void 0,a=void 0===s;a&&(s=o),!h&&void 0===s||!a&&(s===s?s===c:c!==c)||(t[i]=s)}}),t}var o=e(47),u=e(48),i=e(49),c=e(15),s=e(50),a=e(51),f=e(34),l=e(52),p=e(53),v=Array.prototype,y=v.push;t.exports=n},function(t,r,e){"use strict";function n(t){return i(function(r,e){var n=-1,i=null==r?0:e.length,c=i>2&&e[i-2],s=i>2&&e[2],a=i>1&&e[i-1];for("function"==typeof c?(c=o(c,a,5),i-=2):(c="function"==typeof a?a:null,i-=c?1:0),s&&u(e[0],e[1],s)&&(c=3>i?null:c,i=1);++n<i;){var f=e[n];f&&t(r,f,c)}return r})}var o=e(22),u=e(31),i=e(29);t.exports=n},function(t,r,e){"use strict";function n(t,r,e){if("function"!=typeof t)return o;if(void 0===r)return t;switch(e){case 1:return function(e){return t.call(r,e)};case 3:return function(e,n,o){return t.call(r,e,n,o)};case 4:return function(e,n,o,u){return t.call(r,e,n,o,u)};case 5:return function(e,n,o,u,i){return t.call(r,e,n,o,u,i)}}return function(){return t.apply(r,arguments)}}var o=e(1);t.exports=n},function(t,r,e){"use strict";function n(t){if(null==t)return[];s(t)||(t=Object(t));var r=t.length;r=r&&c(r)&&(u(t)||a.nonEnumArgs&&o(t))&&r||0;for(var e=t.constructor,n=-1,f="function"==typeof e&&e.prototype===t,p=Array(r),v=r>0;++n<r;)p[n]=n+"";for(var y in t)v&&i(y,r)||"constructor"==y&&(f||!l.call(t,y))||p.push(y);return p}var o=e(55),u=e(15),i=e(56),c=e(32),s=e(51),a=e(57),f=Object.prototype,l=f.hasOwnProperty;t.exports=n},function(t,r,e){"use strict";function n(t,r){for(var e=-1,n=t.length,o=Array(n);++e<n;)o[e]=r(t[e],e,t);return o}t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=t?t.length:0,n=[];if(!e)return n;var c=-1,s=o,a=!0,f=a&&r.length>=200?i(r):null,l=r.length;f&&(s=u,a=!1,r=f);t:for(;++c<e;){var p=t[c];if(a&&p===p){for(var v=l;v--;)if(r[v]===p)continue t;n.push(p)}else s(r,p,0)<0&&n.push(p)}return n}var o=e(58),u=e(59),i=e(60);t.exports=n},function(t,r,e){"use strict";function n(t,r,e){for(var s=-1,a=t.length,f=-1,l=[];++s<a;){var p=t[s];if(c(p)&&i(p)&&(e||u(p)||o(p))){r&&(p=n(p,r,e));for(var v=-1,y=p.length;++v<y;)l[++f]=p[v]}else e||(l[++f]=p)}return l}var o=e(55),u=e(15),i=e(50),c=e(34);t.exports=n},function(t,r,e){"use strict";function n(t,r){t=o(t);for(var e=-1,n=r.length,u={};++e<n;){var i=r[e];i in t&&(u[i]=t[i])}return u}var o=e(61);t.exports=n},function(t,r,e){"use strict";function n(t,r){var e={};return o(t,function(t,n,o){r(t,n,o)&&(e[n]=t)}),e}var o=e(62);t.exports=n},function(t,r,e){"use strict";function n(t,r){if("function"!=typeof t)throw new TypeError(o);return r=u(void 0===r?t.length-1:+r||0,0),function(){for(var e=arguments,n=-1,o=u(e.length-r,0),i=Array(o);++n<o;)i[n]=e[r+n];switch(r){case 0:return t.call(this,i);case 1:return t.call(this,e[0],i);case 2:return t.call(this,e[0],e[1],i)}var c=Array(r+1);for(n=-1;++n<r;)c[n]=e[n];return c[r]=i,t.apply(this,c)}}var o="Expected a function",u=Math.max;t.exports=n},function(t,r,e){"use strict";function n(t,r,e,y,d,h,b){var m;if(e&&(m=d?e(t,y,d):e(t)),void 0!==m)return m;if(!p(t))return t;var g=l(t);if(g){if(m=s(t),!r)return o(t,m)}else{var w=B.call(t),O=w==x;if(w!=j&&w!=v&&(!O||d))return W[w]?a(t,w,r):d?t:{};if(m=f(O?{}:t),!r)return i(m,t)}h||(h=[]),b||(b=[]);for(var S=h.length;S--;)if(h[S]==t)return b[S];return h.push(t),b.push(m),(g?u:c)(t,function(o,u){m[u]=n(o,r,e,u,t,h,b)}),m}var o=e(63),u=e(47),i=e(64),c=e(65),s=e(66),a=e(67),f=e(68),l=e(15),p=e(51),v="[object Arguments]",y="[object Array]",d="[object Boolean]",h="[object Date]",b="[object Error]",x="[object Function]",m="[object Map]",g="[object Number]",j="[object Object]",w="[object RegExp]",O="[object Set]",S="[object String]",A="[object WeakMap]",E="[object ArrayBuffer]",U="[object Float32Array]",M="[object Float64Array]",k="[object Int8Array]",_="[object Int16Array]",L="[object Int32Array]",R="[object Uint8Array]",C="[object Uint8ClampedArray]",I="[object Uint16Array]",F="[object Uint32Array]",W={};W[v]=W[y]=W[E]=W[d]=W[h]=W[U]=W[M]=W[k]=W[_]=W[L]=W[g]=W[j]=W[w]=W[S]=W[R]=W[C]=W[I]=W[F]=!0,W[b]=W[x]=W[m]=W[O]=W[A]=!1;var P=Object.prototype,B=P.toString;t.exports=n},function(t,r,e){"use strict";function n(t,r,e){if(!i(e))return!1;var n=typeof r;if("number"==n?o(e)&&u(r,e.length):"string"==n&&r in e){var c=e[r];return t===t?t===c:c!==c}return!1}var o=e(50),u=e(56),i=e(51);t.exports=n},function(t,r,e){"use strict";function n(t){return"number"==typeof t&&t>-1&&t%1==0&&o>=t}var o=Math.pow(2,53)-1;t.exports=n},function(t,r,e){"use strict";function n(t){return null==t?!1:f.call(t)==i?l.test(a.call(t)):u(t)&&c.test(t)}var o=e(69),u=e(34),i="[object Function]",c=/^\[object .+?Constructor\]$/,s=Object.prototype,a=Function.prototype.toString,f=s.toString,l=RegExp("^"+o(f).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=n},function(t,r,e){"use strict";function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n){var o=-1,u=t.length;for(n&&u&&(e=t[++o]);++o<u;)e=r(e,t[o],o,t);return e}t.exports=n},function(t,r,e){"use strict";var n=e(65),o=e(70),u=o(n);t.exports=u},function(t,r,e){"use strict";function n(t,r){return function(e,n,c,s){var a=arguments.length<3;return"function"==typeof n&&void 0===s&&i(e)?t(e,n,c,a):u(e,o(n,s,4),c,a,r)}}var o=e(71),u=e(72),i=e(15);t.exports=n},function(t,r,e){"use strict";function n(t){return o(t).replace(u,"-ms-")}var o=e(73),u=/^ms-/;t.exports=n},function(t,r,e){"use strict";function n(t,r){return t+r.charAt(0).toUpperCase()+r.substring(1)}var o={boxFlex:!0,boxFlexGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0},u=["Webkit","ms","Moz","O"];Object.keys(o).forEach(function(t){u.forEach(function(r){o[n(r,t)]=o[t]})});var i={background:{backgroundImage:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundColor:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0}},c={isUnitlessNumber:o,shorthandPropertyExpansions:i};t.exports=c},function(t,r,e){"use strict";var n=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:n,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:n&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n};t.exports=o},function(t,r,e){"use strict";function n(t){return o(t.replace(u,"ms-"))}var o=e(74),u=/^-ms-/;t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=null==r||"boolean"==typeof r||""===r;if(e)return"";var n=isNaN(r);return n||0===r||u.hasOwnProperty(t)&&u[t]?""+r:("string"==typeof r&&(r=r.trim()),r+"px")}var o=e(39),u=o.isUnitlessNumber;t.exports=n},function(t,r,e){"use strict";function n(t){var r={};return function(e){return r.hasOwnProperty(e)||(r[e]=t.call(this,e)),r[e]}}t.exports=n},function(t,r,e){"use strict";var n=e(75),o=n;t.exports=o},function(t,r,e){"use strict";function n(t){return t=o(t),t&&t.replace(c,u).replace(i,"")}var o=e(76),u=e(77),i=/[\u0300-\u036f\ufe20-\ufe23]/g,c=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;t.exports=n},function(t,r,e){"use strict";function n(t,r,e){return e&&u(t,r,e)&&(r=null),t=o(t),t.match(r||i)||[]}var o=e(76),u=e(31),i=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",r="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+r+")|"+t+"?"+r+"|"+t+"+|[0-9]+","g")}();t.exports=n},function(t,r,e){"use strict";function n(t,r){for(var e=-1,n=t.length;++e<n&&r(t[e],e,t)!==!1;);return t}t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,l,p,v){for(var y=p.length,d=r[e];y--;)if(p[y]==d)return void(t[e]=v[y]);var h=t[e],b=l?l(h,d,e,t,r):void 0,x=void 0===b;x&&(b=d,c(d)&&(i(d)||a(d))?b=i(h)?h:c(h)?o(h):[]:s(d)||u(d)?b=u(h)?f(h):s(h)?h:{}:x=!1),p.push(d),v.push(b),x?t[e]=n(b,d,l,p,v):(b===b?b!==h:h===h)&&(t[e]=b)}var o=e(63),u=e(55),i=e(15),c=e(50),s=e(78),a=e(52),f=e(79);t.exports=n},function(t,r,e){"use strict";var n=e(80),o=e(33),u=e(61),i=o(i=Object.getOwnPropertySymbols)&&i,c=i?function(t){return i(u(t))}:n([]);t.exports=c},function(t,r,e){"use strict";function n(t){return null!=t&&u(o(t))}var o=e(81),u=e(32);t.exports=n},function(t,r,e){"use strict";function n(t){var r=typeof t;return"function"==r||!!t&&"object"==r}t.exports=n},function(t,r,e){"use strict";function n(t){return u(t)&&o(t.length)&&!!k[L.call(t)]}var o=e(32),u=e(34),i="[object Arguments]",c="[object Array]",s="[object Boolean]",a="[object Date]",f="[object Error]",l="[object Function]",p="[object Map]",v="[object Number]",y="[object Object]",d="[object RegExp]",h="[object Set]",b="[object String]",x="[object WeakMap]",m="[object ArrayBuffer]",g="[object Float32Array]",j="[object Float64Array]",w="[object Int8Array]",O="[object Int16Array]",S="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",U="[object Uint16Array]",M="[object Uint32Array]",k={};k[g]=k[j]=k[w]=k[O]=k[S]=k[A]=k[E]=k[U]=k[M]=!0,k[i]=k[c]=k[m]=k[s]=k[a]=k[f]=k[l]=k[p]=k[v]=k[y]=k[d]=k[h]=k[b]=k[x]=!1;var _=Object.prototype,L=_.toString;t.exports=n},function(t,r,e){"use strict";var n=e(50),o=e(33),u=e(51),i=e(82),c=o(c=Object.keys)&&c,s=c?function(t){var r=null!=t&&t.constructor;return"function"==typeof r&&r.prototype===t||"function"!=typeof t&&n(t)?i(t):u(t)?c(t):[]}:i;t.exports=s},function(t,r,e){"use strict";var n=e(7),o=e(8),u=function(t){var r=function(){t.prototype.constructor.call(this),this.state||(this.state={});var r=o.getInitialState();Object.keys(r).forEach(function(t){this.state[t]=r[t]},this)};return r.prototype=new t,r.prototype.constructor=r,r.prototype.render=function(){var r=t.prototype.render.call(this);return n(this,r)},r.prototype.componentWillUnmount=function(){t.prototype.componentWillUnmount&&t.prototype.componentWillUnmount.call(this),o.componentWillUnmount(this)},r.defaultProps=t.defaultProps,r.propTypes=t.propTypes,r.contextTypes=t.contextTypes,r};t.exports=u},function(t,r,e){"use strict";function n(t){return u(t)&&o(t)&&s.call(t)==i}var o=e(50),u=e(34),i="[object Arguments]",c=Object.prototype,s=c.toString;t.exports=n},function(t,r,e){"use strict";function n(t,r){return t=+t,r=null==r?o:r,t>-1&&t%1==0&&r>t}var o=Math.pow(2,53)-1;t.exports=n},function(t,r,e){(function(r){"use strict";var e=Object.prototype,n=(n=r.window)&&n.document,o=e.propertyIsEnumerable,u={};!function(t){var r=function(){this.x=t},e=arguments,i=[];r.prototype={valueOf:t,y:t};for(var c in new r)i.push(c);u.funcDecomp=/\bthis\b/.test(function(){return this}),u.funcNames="string"==typeof Function.name;try{u.dom=11===n.createDocumentFragment().nodeType}catch(s){u.dom=!1}try{u.nonEnumArgs=!o.call(e,1)}catch(s){u.nonEnumArgs=!0}}(1,0),t.exports=u}).call(r,function(){return this}())},function(t,r,e){"use strict";function n(t,r,e){if(r!==r)return o(t,e);for(var n=e-1,u=t.length;++n<u;)if(t[n]===r)return n;return-1}var o=e(83);t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=t.data,n="string"==typeof r||o(r)?e.set.has(r):e.hash[r];return n?0:-1}var o=e(51);t.exports=n},function(t,r,e){(function(r){"use strict";var n=e(84),o=e(80),u=e(33),i=u(i=r.Set)&&i,c=u(c=Object.create)&&c,s=c&&i?function(t){return new n(t)}:o(null);t.exports=s}).call(r,function(){return this}())},function(t,r,e){"use strict";function n(t){return o(t)?t:Object(t)}var o=e(51);t.exports=n},function(t,r,e){"use strict";function n(t,r){return o(t,r,u)}var o=e(85),u=e(23);t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=-1,n=t.length;for(r||(r=Array(n));++e<n;)r[e]=t[e];return r}t.exports=n},function(t,r,e){"use strict";var n=e(86),o=e(49),u=e(33),i=e(53),c=u(c=Object.preventExtensions)&&c,s=function(){var t=c&&u(t=Object.assign)&&t;try{if(t){var r=c({1:0});r[0]=1}}catch(e){try{t(r,"xo")}catch(e){}return!r[1]&&t}return!1}(),a=s||function(t,r){return null==r?t:n(r,o(r),n(r,i(r),t))};t.exports=a},function(t,r,e){"use strict";function n(t,r){return o(t,r,u)}var o=e(85),u=e(53);t.exports=n},function(t,r,e){"use strict";function n(t){var r=t.length,e=new t.constructor(r);return r&&"string"==typeof t[0]&&u.call(t,"index")&&(e.index=t.index,e.input=t.input),e}var o=Object.prototype,u=o.hasOwnProperty;t.exports=n},function(t,r,e){"use strict";function n(t,r,e){var n=t.constructor;switch(r){case f:return o(t);case u:case i:return new n(+t);case l:case p:case v:case y:case d:case h:case b:case x:case m:var j=t.buffer;return new n(e?o(j):j,t.byteOffset,t.length);case c:case a:return new n(t);case s:var w=new n(t.source,g.exec(t));w.lastIndex=t.lastIndex}return w}var o=e(87),u="[object Boolean]",i="[object Date]",c="[object Number]",s="[object RegExp]",a="[object String]",f="[object ArrayBuffer]",l="[object Float32Array]",p="[object Float64Array]",v="[object Int8Array]",y="[object Int16Array]",d="[object Int32Array]",h="[object Uint8Array]",b="[object Uint8ClampedArray]",x="[object Uint16Array]",m="[object Uint32Array]",g=/\w*$/;t.exports=n},function(t,r,e){"use strict";function n(t){var r=t.constructor;return"function"==typeof r&&r instanceof r||(r=Object),new r}t.exports=n},function(t,r,e){"use strict";function n(t){return t=o(t),t&&i.test(t)?t.replace(u,"\\$&"):t}var o=e(76),u=/[.*+?^${}()|[\]\/\\]/g,i=RegExp(u.source);t.exports=n},function(t,r,e){"use strict";function n(t,r){return function(e,n){var c=e?o(e):0;if(!u(c))return t(e,n);for(var s=r?c:-1,a=i(e);(r?s--:++s<c)&&n(a[s],s,a)!==!1;);return e}}var o=e(81),u=e(32),i=e(61);t.exports=n},function(t,r,e){"use strict";function n(t,r,e){var n=typeof t;return"function"==n?void 0===r?t:i(t,r,e):null==t?c:"object"==n?o(t):void 0===r?s(t):u(t,r)}var o=e(88),u=e(89),i=e(22),c=e(1),s=e(90);t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,o){return o(t,function(t,o,u){e=n?(n=!1,t):r(e,t,o,u)}),e}t.exports=n},function(t,r,e){"use strict";function n(t){return t.replace(o,"-$1").toLowerCase()}var o=/([A-Z])/g;t.exports=n},function(t,r,e){"use strict";function n(t){return t.replace(o,function(t,r){return r.toUpperCase()})}var o=/-(.)/g;t.exports=n},function(t,r,e){"use strict";function n(t){return function(){return t}}function o(){}o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(t){return t},t.exports=o},function(t,r,e){"use strict";function n(t){return"string"==typeof t?t:null==t?"":t+""}t.exports=n},function(t,r,e){"use strict";function n(t){return o[t]}var o={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"};t.exports=n},function(t,r,e){"use strict";var n=e(33),o=e(91),u="[object Object]",i=Object.prototype,c=i.toString,s=n(s=Object.getPrototypeOf)&&s,a=s?function(t){if(!t||c.call(t)!=u)return!1;var r=t.valueOf,e=n(r)&&(e=s(r))&&s(e);return e?t==e||s(t)==e:o(t)}:o;t.exports=a},function(t,r,e){"use strict";function n(t){return o(t,u(t))}var o=e(86),u=e(23);t.exports=n},function(t,r,e){"use strict";function n(t){return function(){return t}}t.exports=n},function(t,r,e){"use strict";var n=e(92),o=n("length");t.exports=o},function(t,r,e){"use strict";function n(t){for(var r=s(t),e=r.length,n=e&&t.length,f=n&&c(n)&&(u(t)||a.nonEnumArgs&&o(t)),p=-1,v=[];++p<e;){var y=r[p];(f&&i(y,n)||l.call(t,y))&&v.push(y)}return v}var o=e(55),u=e(15),i=e(56),c=e(32),s=e(23),a=e(57),f=Object.prototype,l=f.hasOwnProperty;t.exports=n},function(t,r,e){"use strict";function n(t,r,e){for(var n=t.length,o=r+(e?0:-1);e?o--:++o<n;){var u=t[o];if(u!==u)return o}return-1}t.exports=n},function(t,r,e){(function(r){"use strict";function n(t){var r=t?t.length:0;for(this.data={hash:c(null),set:new i};r--;)this.push(t[r])}var o=e(93),u=e(33),i=u(i=r.Set)&&i,c=u(c=Object.create)&&c;n.prototype.push=o,t.exports=n}).call(r,function(){return this}())},function(t,r,e){"use strict";var n=e(94),o=n();t.exports=o},function(t,r,e){"use strict";function n(t,r,e){e||(e={});for(var n=-1,o=r.length;++n<o;){var u=r[n];e[u]=t[u]}return e}t.exports=n},function(t,r,e){(function(r){"use strict";function n(t){return c.call(t,0)}var o=e(80),u=e(33),i=u(i=r.ArrayBuffer)&&i,c=u(c=i&&new i(0).slice)&&c,s=Math.floor,a=u(a=r.Uint8Array)&&a,f=function(){try{var t=u(t=r.Float64Array)&&t,e=new t(new i(10),0,1)&&t}catch(n){}return e}(),l=f?f.BYTES_PER_ELEMENT:0;c||(n=i&&a?function(t){var r=t.byteLength,e=f?s(r/l):0,n=e*l,o=new i(r);if(e){var u=new f(o,0,e);u.set(new f(t,0,e))}return r!=n&&(u=new a(o,n),u.set(new a(t,n))),o}:o(null)),t.exports=n}).call(r,function(){return this}())},function(t,r,e){"use strict";function n(t){var r=c(t),e=r.length;if(!e)return u(!0);if(1==e){var n=r[0],a=t[n];if(i(a))return function(t){return null==t?!1:t[n]===a&&(void 0!==a||n in s(t))}}for(var f=Array(e),l=Array(e);e--;)a=t[r[e]],f[e]=a,l[e]=i(a);return function(t){return null!=t&&o(s(t),r,f,l)}}var o=e(95),u=e(80),i=e(96),c=e(53),s=e(61);t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=c(t),n=s(t)&&a(r),v=t+"";return t=p(t),function(c){if(null==c)return!1;var s=v;if(c=l(c),!(!e&&n||s in c)){if(c=1==t.length?c:o(c,i(t,0,-1)),null==c)return!1;s=f(t),c=l(c)}return c[s]===r?void 0!==r||s in c:u(r,c[s],null,!0)}}var o=e(97),u=e(98),i=e(99),c=e(15),s=e(100),a=e(96),f=e(101),l=e(61),p=e(102);t.exports=n},function(t,r,e){"use strict";function n(t){return i(t)?o(t):u(t)}var o=e(92),u=e(103),i=e(100);t.exports=n},function(t,r,e){"use strict";function n(t){var r;if(!u(t)||a.call(t)!=i||!s.call(t,"constructor")&&(r=t.constructor,"function"==typeof r&&!(r instanceof r)))return!1;var e;return o(t,function(t,r){e=r}),void 0===e||s.call(t,e)}var o=e(62),u=e(34),i="[object Object]",c=Object.prototype,s=c.hasOwnProperty,a=c.toString;t.exports=n},function(t,r,e){"use strict";function n(t){return function(r){return null==r?void 0:r[t]}}t.exports=n},function(t,r,e){"use strict";function n(t){var r=this.data;"string"==typeof t||o(t)?r.set.add(t):r.hash[t]=!0}var o=e(51);t.exports=n},function(t,r,e){"use strict";function n(t){return function(r,e,n){for(var u=o(r),i=n(r),c=i.length,s=t?c:-1;t?s--:++s<c;){var a=i[s];if(e(u[a],a,u)===!1)break}return r}}var o=e(61);t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,u){for(var i=-1,c=r.length,s=!u;++i<c;)if(s&&n[i]?e[i]!==t[r[i]]:!(r[i]in t))return!1;for(i=-1;++i<c;){var a=r[i],f=t[a],l=e[i];if(s&&n[i])var p=void 0!==f||a in t;else p=u?u(f,l,a):void 0,void 0===p&&(p=o(l,f,u,!0));if(!p)return!1}return!0}var o=e(98);t.exports=n},function(t,r,e){"use strict";function n(t){return t===t&&!o(t)}var o=e(51);t.exports=n},function(t,r,e){"use strict";function n(t,r,e){if(null!=t){void 0!==e&&e in o(t)&&(r=[e]);for(var n=-1,u=r.length;null!=t&&++n<u;)t=t[r[n]];return n&&n==u?t:void 0}}var o=e(61);t.exports=n},function(t,r,e){"use strict";function n(t,r,e,u,i,c){if(t===r)return!0;var s=typeof t,a=typeof r;return"function"!=s&&"object"!=s&&"function"!=a&&"object"!=a||null==t||null==r?t!==t&&r!==r:o(t,r,n,e,u,i,c)}var o=e(104);t.exports=n},function(t,r,e){"use strict";function n(t,r,e){var n=-1,o=t.length;r=null==r?0:+r||0,0>r&&(r=-r>o?0:o+r),e=void 0===e||e>o?o:+e||0,0>e&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n<o;)u[n]=t[n+r];return u}t.exports=n},function(t,r,e){"use strict";function n(t,r){var e=typeof t;if("string"==e&&c.test(t)||"number"==e)return!0;if(o(t))return!1;var n=!i.test(t);return n||null!=r&&t in u(r)}var o=e(15),u=e(61),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,c=/^\w*$/;t.exports=n},function(t,r,e){"use strict";function n(t){var r=t?t.length:0;return r?t[r-1]:void 0}t.exports=n},function(t,r,e){"use strict";function n(t){if(u(t))return t;var r=[];return o(t).replace(i,function(t,e,n,o){r.push(n?o.replace(c,"$1"):e||t)}),r}var o=e(76),u=e(15),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,c=/\\(\\)?/g;t.exports=n},function(t,r,e){"use strict";function n(t){var r=t+"";return t=u(t),function(e){return o(e,t,r)}}var o=e(97),u=e(102);t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,p,d,h){var b=c(t),x=c(r),m=f,g=f;b||(m=y.call(t),m==a?m=l:m!=l&&(b=s(t))),x||(g=y.call(r),g==a?g=l:g!=l&&(x=s(r)));var j=m==l,w=g==l,O=m==g;if(O&&!b&&!j)return u(t,r,m);if(!p){var S=j&&v.call(t,"__wrapped__"),A=w&&v.call(r,"__wrapped__");if(S||A)return e(S?t.value():t,A?r.value():r,n,p,d,h)}if(!O)return!1;d||(d=[]),h||(h=[]);for(var E=d.length;E--;)if(d[E]==t)return h[E]==r;d.push(t),h.push(r);var U=(b?o:i)(t,r,e,n,p,d,h);return d.pop(),h.pop(),U}var o=e(105),u=e(106),i=e(107),c=e(15),s=e(52),a="[object Arguments]",f="[object Array]",l="[object Object]",p=Object.prototype,v=p.hasOwnProperty,y=p.toString;t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,o,u,i){var c=-1,s=t.length,a=r.length,f=!0;if(s!=a&&!(o&&a>s))return!1;for(;f&&++c<s;){var l=t[c],p=r[c];if(f=void 0,n&&(f=o?n(p,l,c):n(l,p,c)),void 0===f)if(o)for(var v=a;v--&&(p=r[v],!(f=l&&l===p||e(l,p,n,o,u,i))););else f=l&&l===p||e(l,p,n,o,u,i)}return!!f}t.exports=n},function(t,r,e){"use strict";function n(t,r,e){switch(e){case o:case u:return+t==+r;case i:return t.name==r.name&&t.message==r.message;case c:return t!=+t?r!=+r:t==+r;case s:case a:return t==r+""}return!1}var o="[object Boolean]",u="[object Date]",i="[object Error]",c="[object Number]",s="[object RegExp]",a="[object String]";t.exports=n},function(t,r,e){"use strict";function n(t,r,e,n,u,c,s){var a=o(t),f=a.length,l=o(r),p=l.length;if(f!=p&&!u)return!1;for(var v=u,y=-1;++y<f;){var d=a[y],h=u?d in r:i.call(r,d);if(h){var b=t[d],x=r[d];h=void 0,n&&(h=u?n(x,b,d):n(b,x,d)),void 0===h&&(h=b&&b===x||e(b,x,n,u,c,s))}if(!h)return!1;v||(v="constructor"==d)}if(!v){var m=t.constructor,g=r.constructor; | ||
if(m!=g&&"constructor"in t&&"constructor"in r&&!("function"==typeof m&&m instanceof m&&"function"==typeof g&&g instanceof g))return!1}return!0}var o=e(53),u=Object.prototype,i=u.hasOwnProperty;t.exports=n}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Radium=t(require("React")):e.Radium=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";t.Enhancer=r(12),t.Style=r(2),t.getState=r(3),t.keyframes=r(4),t.wrap=r(5)},function(e,t,r){"use strict";var n=[],o=!1,i=function(e){n.forEach(function(t){t(e)})},s=function(e){return-1===n.indexOf(e)&&n.push(e),o||(window.addEventListener("mouseup",i),o=!0),{remove:function(){var t=n.indexOf(e);n.splice(t,1),0===n.length&&o&&(window.removeEventListener("mouseup",i),o=!1)}}};e.exports={subscribe:s}},function(e,t,r){"use strict";var n=r(6),o=r(13),i=function(e,t){return e&&t?e+"{"+o.createMarkupForStyles(t)+"}":void 0},s=n.createClass({displayName:"Style",propTypes:{scopeSelector:n.PropTypes.string,rules:n.PropTypes.arrayOf(n.PropTypes.object)},getDefaultProps:function(){return{scopeSelector:""}},_buildStyles:function(e){var t=this,r=e.reduce(function(e,r){var n=Object.keys(r)[0],o=r[n];if("mediaQueries"===n)e+=t._buildMediaQueryString(o);else{var s=(t.props.scopeSelector?t.props.scopeSelector+" ":"")+n;e+=i(s,o)}return e},"");return r},_buildMediaQueryString:function(e){var t=this._getContextMediaQueries(),r="";return Object.keys(e).forEach(function(n){var o=t[n]?t[n]:n;r+="@media "+o+"{"+this._buildStyles(e[n])+"}"}.bind(this)),r},_getContextMediaQueries:function(){var e={};return this.context&&this.context.mediaQueries&&Object.keys(this.context.mediaQueries).forEach(function(t){e[t]=this.context.mediaQueries[t].media}.bind(this)),e},render:function(){if(!this.props.rules)return null;var e=this._buildStyles(this.props.rules);return n.createElement("style",{dangerouslySetInnerHTML:{__html:e}})}});e.exports=s},function(e,t,r){"use strict";var n=[":active",":focus",":hover"],o=function(e,t,r){if(t=t||"main",-1===n.indexOf(r))throw new Error("Radium.getState invalid value param: `"+r+"`");return e&&e._radiumStyleState&&e._radiumStyleState[t]&&e._radiumStyleState[t][r]||!1};e.exports=o},function(e,t,r){"use strict";var n=r(9),o=r(11),i=1,s=null,u=null;o.canUseDOM&&(s=document.createElement("style"),document.head.appendChild(s),u="keyframes",s.textContent="@keyframes {}",s.sheet.cssRules.length||(u=n.css+"keyframes"));var a=function(e){return Object.keys(e).map(function(t){return t+": "+e[t]+";"}).join("\n")},c=function(e){var t="Animation"+i;if(i+=1,!o.canUseDOM)return t;var r="@"+u+" "+t+" {\n"+Object.keys(e).map(function(t){var r=e[t],o=n(r,"css"),i=a(o);return" "+t+" {\n "+i+"\n }"}).join("\n")+"\n}\n";if(!s)throw new Error("keyframes not initialized properly");return s.sheet.insertRule(r,s.sheet.cssRules.length),t};e.exports=c},function(e,t,r){"use strict";var n=r(7),o=r(8),i=r(10),s=function(e){var t={getInitialState:function(){var t=e.getInitialState?e.getInitialState.call(this):{},r=o.getInitialState();return i({},t,r)},componentWillUnmount:function(){e.componentWillUnmount&&e.componentWillUnmount.call(this),o.componentWillUnmount(this)},render:function(){var t=e.render.call(this);return n(this,t)}};return i({},e,t)};e.exports=s},function(t,r,n){t.exports=e},function(e,t,r){"use strict";var n=r(1),o=r(3),i=r(9),s=r(11),u=r(6),a=r(10),c={},f=function(e){return":"===e[0]||"@"===e[0]},l=function(e,t,r){return o(e.state,t,r)},p=function(e,t,r){var n=e.state&&e.state._radiumStyleState||{},o={_radiumStyleState:a({},n)};o._radiumStyleState[t]=o._radiumStyleState[t]||{},a(o._radiumStyleState[t],r),e.setState(o)},d=function b(e){var t={};return e.forEach(function(e){e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(function(r){f(r)&&t[r]?t[r]=b([t[r],e[r]]):t[r]=e[r]})}),t},y=function(e){Object.keys(e.state._radiumStyleState).forEach(function(t){l(e,t,":active")&&p(e,t,{":active":!1})})},m=function(e,t,r){var n={};n[t]=r.matches,p(e,"_all",n)},v=function(e,t){return s.canUseDOM&&window&&window.matchMedia?(Object.keys(t).filter(function(e){return"@"===e[0]}).map(function(r){var n=t[r];r=r.replace("@media ","");var o=c[r];if(o||(c[r]=o=window.matchMedia(r)),e._radiumMediaQueryListenersByQuery||(e._radiumMediaQueryListenersByQuery={}),!e._radiumMediaQueryListenersByQuery[r]){var i=m.bind(null,e,r);o.addListener(i),e._radiumMediaQueryListenersByQuery[r]={remove:function(){o.removeListener(i)}}}o.matches&&(t=d([t,n]))}),t):t},h=function w(e,t,r){if(r=r||{},!t)return t;var o=null,a=t.props.children;if(a)if(1===u.Children.count(a)&&a.type){var c=u.Children.only(a);o=w(e,c,r)}else o=u.Children.map(a,function(t){return u.isValidElement(t)?w(e,t,r):t});var m=t.props,h=m.style,b={};if(Array.isArray(h)&&(h=d(h)),!h||!Object.keys(h).some(f))return h?(b.style=i(h),u.cloneElement(t,b,o)):o?u.cloneElement(t,{},o):t;var x=t.ref||t.key,g=x||"main";if(r[g])throw new Error("Radium requires each element with interactive styles to have a unique key, set using either the ref or key prop. "+(x?'Key "'+x+'" is a duplicate.':"Multiple elements have no key specified."));r[g]=!0,h=v(e,h);var S={};if(Object.keys(h).forEach(function(e){f(e)||(S[e]=h[e])}),h[":hover"]||h[":active"]){var O=m.onMouseEnter;b.onMouseEnter=function(t){O&&O(t),p(e,g,{":hover":!0})};var k=m.onMouseLeave;b.onMouseLeave=function(t){k&&k(t),p(e,g,{":hover":!1})}}if(h[":active"]){var j=m.onMouseDown;b.onMouseDown=function(t){j&&j(t),e._lastMouseDown=Date.now(),p(e,g,{":active":!0})}}if(h[":focus"]){var E=m.onFocus;b.onFocus=function(t){E&&E(t),p(e,g,{":focus":!0})};var M=m.onBlur;b.onBlur=function(t){M&&M(t),p(e,g,{":focus":!1})}}var _=Object.keys(h).filter(function(t){return":active"===t&&l(e,g,":active")||":hover"===t&&l(e,g,":hover")||":focus"===t&&l(e,g,":focus")}).map(function(e){return h[e]});return _.length&&(S=d([S].concat(_))),h[":active"]&&!e._radiumMouseUpListener&&s.canUseEventListeners&&(e._radiumMouseUpListener=n.subscribe(y.bind(null,e))),b.style=i(S),u.cloneElement(t,b,o)};h.__clearStateForTests=function(){c={}},e.exports=h},function(e,t,r){"use strict";e.exports={getInitialState:function(){return{_radiumStyleState:{}}},componentWillUnmount:function(e){e._radiumMouseUpListener&&e._radiumMouseUpListener.remove(),e._radiumMediaQueryListenersByQuery&&Object.keys(e._radiumMediaQueryListenersByQuery).forEach(function(t){e._radiumMediaQueryListenersByQuery[t].remove()},e)}}},function(e,t,r){"use strict";var n=r(11),o={"-moz-":{cssPrefix:"-moz-",jsPrefix:"Moz"},"-ms-":{cssPrefix:"-ms-",jsPrefix:"ms"},"-o-":{cssPrefix:"-o-",jsPrefix:"O"},"-webkit-":{cssPrefix:"-webkit-",jsPrefix:"Webkit"}},i={},s={},u={},a={cssPrefix:"",jsPrefix:""};if(n.canUseDOM){i=document.createElement("p").style;var c=window.getComputedStyle(document.documentElement,""),f=Array.prototype.slice.call(c).join("").match(/-(moz|webkit|ms|o)-/),l=f&&f[0];a=o[l]||a}var p=/([a-z])?([A-Z])/g,d=function(e,t,r){return t+"-"+r.toLowerCase()},y=function(e){return e.replace(p,d)},m=function(e){if(s.hasOwnProperty(e))return s[e];var t=a.jsPrefix+e[0].toUpperCase()+e.slice(1);return n.canUseDOM&&t in i?(s[e]={css:a.cssPrefix+y(e),js:t},s[e]):!n.canUseDOM||e in i?(s[e]={css:y(e),js:e},s[e]):s[e]=!1},v=function(e,t){if("string"!=typeof t||!isNaN(parseInt(t,10)))return t;var r=e+t;if(u.hasOwnProperty(r))return u[r];if(i[e]="",i[e]=t,u[r]=t,i[e])return u[r];var n=a.cssPrefix+t;return i[e]=n,i[e]?(u[r]=n,n):(console&&console.warn&&console.warn('Unsupported CSS value "'+t+'" for property "'+e+'"'),u[r])},h=function(e,t){t=t||"js";var r={};return Object.keys(e).forEach(function(n){var o=e[n],i=m(n);if(i===!1)return void(console&&console.warn&&console.warn('Unsupported CSS property "'+n+'"'));var s=v(i.js,o);r[i[t]]=s}),r};h.css=a.cssPrefix,h.js=a.jsPrefix,e.exports=h},function(e,t,r){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=Object.assign||function(e,t){for(var r,o,i=n(e),s=1;s<arguments.length;s++){r=arguments[s],o=Object.keys(Object(r));for(var u=0;u<o.length;u++)i[o[u]]=r[o[u]]}return i}},function(e,t,r){"use strict";var n=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:n,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:n&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:n&&!!window.screen};e.exports=o},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}var i=function(){function e(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)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=function(e,t,r){for(var n=!0;n;){var o=e,i=t,s=r;u=c=a=void 0,n=!1;var u=Object.getOwnPropertyDescriptor(o,i);if(void 0!==u){if("value"in u)return u.value;var a=u.get;return void 0===a?void 0:a.call(s)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;e=c,t=i,r=s,n=!0}},u=r(7),a=r(8),c=r(10),f=function(e){var t=e.displayName||e.name||"Component",r=function(e){function r(){n(this,r),s(Object.getPrototypeOf(r.prototype),"constructor",this).apply(this,arguments);var e=a.getInitialState();this.state=c(this.state||{},e)}return o(r,e),i(r,[{key:"render",value:function(){var e=s(Object.getPrototypeOf(r.prototype),"render",this).call(this);return u(this,e)}},{key:"componentWillUnmount",value:function(){s(Object.getPrototypeOf(r.prototype),"componentWillUnmount",this)&&s(Object.getPrototypeOf(r.prototype),"componentWillUnmount",this).call(this),a.componentWillUnmount(this)}}],[{key:"displayName",value:"Radium("+t+")",enumerable:!0}]),r}(e);return r};e.exports=f},function(e,t,r){"use strict";var n=r(15),o=r(16),i=(r(17),r(18)),s=r(14),u=r(19),a=(r(20),u(function(e){return s(e)})),c="cssFloat";o.canUseDOM&&void 0===document.documentElement.style.cssFloat&&(c="styleFloat");var f={createMarkupForStyles:function(e){var t="";for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];null!=n&&(t+=a(r)+":",t+=i(r,n)+";")}return t||null},setValueForStyles:function(e,t){var r=e.style;for(var o in t)if(t.hasOwnProperty(o)){var s=i(o,t[o]);if("float"===o&&(o=c),s)r[o]=s;else{var u=n.shorthandPropertyExpansions[o];if(u)for(var a in u)r[a]="";else r[o]=""}}}};e.exports=f},function(e,t,r){"use strict";function n(e){return o(e).replace(i,"-ms-")}var o=r(21),i=/^ms-/;e.exports=n},function(e,t,r){"use strict";function n(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var o={boxFlex:!0,boxFlexGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0},i=["Webkit","ms","Moz","O"];Object.keys(o).forEach(function(e){i.forEach(function(t){o[n(t,e)]=o[e]})});var s={background:{backgroundImage:!0,backgroundPosition:!0,backgroundRepeat:!0,backgroundColor:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0}},u={isUnitlessNumber:o,shorthandPropertyExpansions:s};e.exports=u},function(e,t,r){"use strict";var n=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:n,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:n&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n};e.exports=o},function(e,t,r){"use strict";function n(e){return o(e.replace(i,"ms-"))}var o=r(22),i=/^-ms-/;e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=null==t||"boolean"==typeof t||""===t;if(r)return"";var n=isNaN(t);return n||0===t||i.hasOwnProperty(e)&&i[e]?""+t:("string"==typeof t&&(t=t.trim()),t+"px")}var o=r(15),i=o.isUnitlessNumber;e.exports=n},function(e,t,r){"use strict";function n(e){var t={};return function(r){return t.hasOwnProperty(r)||(t[r]=e.call(this,r)),t[r]}}e.exports=n},function(e,t,r){"use strict";var n=r(23),o=n;e.exports=o},function(e,t,r){"use strict";function n(e){return e.replace(o,"-$1").toLowerCase()}var o=/([A-Z])/g;e.exports=n},function(e,t,r){"use strict";function n(e){return e.replace(o,function(e,t){return t.toUpperCase()})}var o=/-(.)/g;e.exports=n},function(e,t,r){"use strict";function n(e){return function(){return e}}function o(){}o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o}])}); |
@@ -13,4 +13,4 @@ var babel = require('babel'); | ||
return babel.transform(src).code; | ||
return babel.transform(src, {stage: 0}).code; | ||
} | ||
}; |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var CSSPropertyOperations = require('react/lib/CSSPropertyOperations'); | ||
var reduce = require('lodash/collection/reduce'); | ||
@@ -31,3 +30,5 @@ var buildCssString = function buildCssString(selector, rules) { | ||
_buildStyles: function _buildStyles(stylesArr) { | ||
var styles = reduce(stylesArr, function (accumulator, item) { | ||
var _this = this; | ||
var styles = stylesArr.reduce(function (accumulator, item) { | ||
var selector = Object.keys(item)[0]; | ||
@@ -37,5 +38,5 @@ var rules = item[selector]; | ||
if (selector === 'mediaQueries') { | ||
accumulator += this._buildMediaQueryString(rules); | ||
accumulator += _this._buildMediaQueryString(rules); | ||
} else { | ||
var completeSelector = (this.props.scopeSelector ? this.props.scopeSelector + ' ' : '') + selector; | ||
var completeSelector = (_this.props.scopeSelector ? _this.props.scopeSelector + ' ' : '') + selector; | ||
accumulator += buildCssString(completeSelector, rules); | ||
@@ -45,3 +46,3 @@ } | ||
return accumulator; | ||
}, '', this); | ||
}, ''); | ||
@@ -48,0 +49,0 @@ return styles; |
@@ -0,39 +1,55 @@ | ||
/* @flow */ | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
var resolveStyles = require('./resolve-styles.js'); | ||
var wrapUtils = require('./wrap-utils.js'); | ||
var objectAssign = require('object-assign'); | ||
var enhanceWithRadium = function enhanceWithRadium(ComposedComponent) { | ||
var RadiumEnhancer = function RadiumEnhancer() { | ||
ComposedComponent.prototype.constructor.call(this); | ||
var displayName = ComposedComponent.displayName || ComposedComponent.name || 'Component'; | ||
if (!this.state) { | ||
this.state = {}; | ||
} | ||
var RadiumEnhancer = (function (_ComposedComponent) { | ||
function RadiumEnhancer() { | ||
_classCallCheck(this, RadiumEnhancer); | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
Object.keys(radiumInitialState).forEach(function (key) { | ||
this.state[key] = radiumInitialState[key]; | ||
}, this); | ||
}; | ||
_get(Object.getPrototypeOf(RadiumEnhancer.prototype), 'constructor', this).apply(this, arguments); | ||
RadiumEnhancer.prototype = new ComposedComponent(); | ||
RadiumEnhancer.prototype.constructor = RadiumEnhancer; | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
this.state = objectAssign(this.state || {}, radiumInitialState); | ||
} | ||
RadiumEnhancer.prototype.render = function () { | ||
var renderedElement = ComposedComponent.prototype.render.call(this); | ||
return resolveStyles(this, renderedElement); | ||
}; | ||
_inherits(RadiumEnhancer, _ComposedComponent); | ||
RadiumEnhancer.prototype.componentWillUnmount = function () { | ||
if (ComposedComponent.prototype.componentWillUnmount) { | ||
ComposedComponent.prototype.componentWillUnmount.call(this); | ||
} | ||
_createClass(RadiumEnhancer, [{ | ||
key: 'render', | ||
value: function render() { | ||
var renderedElement = _get(Object.getPrototypeOf(RadiumEnhancer.prototype), 'render', this).call(this); | ||
return resolveStyles(this, renderedElement); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (_get(Object.getPrototypeOf(RadiumEnhancer.prototype), 'componentWillUnmount', this)) { | ||
_get(Object.getPrototypeOf(RadiumEnhancer.prototype), 'componentWillUnmount', this).call(this); | ||
} | ||
wrapUtils.componentWillUnmount(this); | ||
}; | ||
wrapUtils.componentWillUnmount(this); | ||
} | ||
}], [{ | ||
key: 'displayName', | ||
value: 'Radium(' + displayName + ')', | ||
enumerable: true | ||
}]); | ||
RadiumEnhancer.defaultProps = ComposedComponent.defaultProps; | ||
RadiumEnhancer.propTypes = ComposedComponent.propTypes; | ||
RadiumEnhancer.contextTypes = ComposedComponent.contextTypes; | ||
return RadiumEnhancer; | ||
})(ComposedComponent); | ||
@@ -40,0 +56,0 @@ return RadiumEnhancer; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -6,5 +8,3 @@ | ||
var ExecutionEnvironment = require('exenv'); | ||
var kebabCase = require('lodash/string/kebabCase'); | ||
var msPrefix = /^ms-/; | ||
var animationIndex = 1; | ||
@@ -28,3 +28,3 @@ var animationStyleSheet = null; | ||
return Object.keys(style).map(function (property) { | ||
return kebabCase(property).replace(msPrefix, '-ms-') + ': ' + style[property] + ';'; | ||
return property + ': ' + style[property] + ';'; | ||
}).join('\n'); | ||
@@ -50,2 +50,8 @@ }; | ||
// for flow | ||
/* istanbul ignore next */ | ||
if (!animationStyleSheet) { | ||
throw new Error('keyframes not initialized properly'); | ||
} | ||
animationStyleSheet.sheet.insertRule(rule, animationStyleSheet.sheet.cssRules.length); | ||
@@ -52,0 +58,0 @@ return name; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -2,0 +4,0 @@ |
/** | ||
* Based on https://github.com/jsstyles/css-vendor, but without any dash-case | ||
* shenanigans. | ||
* Based on https://github.com/jsstyles/css-vendor, but without having to | ||
* convert between different cases all the time. | ||
*/ | ||
@@ -9,12 +9,21 @@ | ||
var ExecutionEnvironment = require('exenv'); | ||
var kebabCase = require('lodash/string/kebabCase'); | ||
var jsCssMap = { | ||
Webkit: '-webkit-', | ||
Moz: '-moz-', | ||
// IE did it wrong again ... | ||
ms: '-ms-', | ||
O: '-o-' | ||
var infoByCssPrefix = { | ||
'-moz-': { | ||
cssPrefix: '-moz-', | ||
jsPrefix: 'Moz' | ||
}, | ||
'-ms-': { | ||
cssPrefix: '-ms-', | ||
jsPrefix: 'ms' | ||
}, | ||
'-o-': { | ||
cssPrefix: '-o-', | ||
jsPrefix: 'O' | ||
}, | ||
'-webkit-': { | ||
cssPrefix: '-webkit-', | ||
jsPrefix: 'Webkit' | ||
} | ||
}; | ||
var testProp = 'Transform'; | ||
@@ -24,4 +33,6 @@ var domStyle = {}; | ||
var prefixedValueCache = {}; | ||
var jsVendorPrefix = ''; | ||
var cssVendorPrefix = ''; | ||
var prefixInfo = { | ||
cssPrefix: '', | ||
jsPrefix: '' | ||
}; | ||
@@ -31,11 +42,18 @@ if (ExecutionEnvironment.canUseDOM) { | ||
for (var jsPrefix in jsCssMap) { | ||
if (jsPrefix + testProp in domStyle) { | ||
jsVendorPrefix = jsPrefix; | ||
cssVendorPrefix = jsCssMap[jsPrefix]; | ||
break; | ||
} | ||
} | ||
// Based on http://davidwalsh.name/vendor-prefix | ||
var windowStyles = window.getComputedStyle(document.documentElement, ''); | ||
var prefixMatch = Array.prototype.slice.call(windowStyles).join('').match(/-(moz|webkit|ms|o)-/); | ||
var cssVendorPrefix = prefixMatch && prefixMatch[0]; | ||
prefixInfo = infoByCssPrefix[cssVendorPrefix] || prefixInfo; | ||
} | ||
var _camelCaseRegex = /([a-z])?([A-Z])/g; | ||
var _camelCaseReplacer = function _camelCaseReplacer(match, p1, p2) { | ||
return p1 + '-' + p2.toLowerCase(); | ||
}; | ||
var _camelCaseToDashCase = function _camelCaseToDashCase(s) { | ||
return s.replace(_camelCaseRegex, _camelCaseReplacer); | ||
}; | ||
var _getPrefixedProperty = function _getPrefixedProperty(property) { | ||
@@ -46,7 +64,11 @@ if (prefixedPropertyCache.hasOwnProperty(property)) { | ||
if (!ExecutionEnvironment.canUseDOM || property in domStyle) { | ||
// unprefixed | ||
// Try the prefixed version first. Chrome in particular has the `filter` and | ||
// `webkitFilter` properties availalbe on the style object, but only the | ||
// prefixed version actually works. | ||
var prefixedProperty = prefixInfo.jsPrefix + property[0].toUpperCase() + property.slice(1); | ||
if (ExecutionEnvironment.canUseDOM && prefixedProperty in domStyle) { | ||
// prefixed | ||
prefixedPropertyCache[property] = { | ||
css: kebabCase(property), | ||
js: property | ||
css: prefixInfo.cssPrefix + _camelCaseToDashCase(property), | ||
js: prefixedProperty | ||
}; | ||
@@ -56,8 +78,7 @@ return prefixedPropertyCache[property]; | ||
var newProperty = jsVendorPrefix + property[0].toUpperCase() + property.slice(1); | ||
if (newProperty in domStyle) { | ||
// prefixed | ||
if (!ExecutionEnvironment.canUseDOM || property in domStyle) { | ||
// unprefixed | ||
prefixedPropertyCache[property] = { | ||
css: cssVendorPrefix + kebabCase(property), | ||
js: newProperty | ||
css: _camelCaseToDashCase(property), | ||
js: property | ||
}; | ||
@@ -89,2 +110,5 @@ return prefixedPropertyCache[property]; | ||
// Assume unprefixed | ||
prefixedValueCache[cacheKey] = value; | ||
// Value is supported as it is. Note that we just make sure it is not an empty | ||
@@ -96,17 +120,22 @@ // string. Browsers will sometimes rewrite values, but still accept them. They | ||
if (domStyle[property]) { | ||
prefixedValueCache[cacheKey] = value; | ||
return value; | ||
return prefixedValueCache[cacheKey]; | ||
} | ||
// Test value with vendor prefix. | ||
value = cssVendorPrefix + value; | ||
domStyle[property] = value; | ||
var prefixedValue = prefixInfo.cssPrefix + value; | ||
domStyle[property] = prefixedValue; | ||
// Value is supported with vendor prefix. | ||
if (domStyle[property]) { | ||
prefixedValueCache[cacheKey] = value; | ||
return value; | ||
prefixedValueCache[cacheKey] = prefixedValue; | ||
return prefixedValue; | ||
} | ||
return prefixedValueCache[cacheKey] = false; | ||
// Unsupported, assume unprefixed but warn | ||
/*eslint-disable no-console */ | ||
if (console && console.warn) { | ||
console.warn('Unsupported CSS value "' + value + '" for property "' + property + '"'); | ||
} | ||
/*eslint-enable no-console */ | ||
return prefixedValueCache[cacheKey]; | ||
}; | ||
@@ -116,3 +145,2 @@ | ||
// and values. | ||
/*eslint-disable no-console */ | ||
var prefix = function prefix(style, mode /* 'css' or 'js' */) { | ||
@@ -127,5 +155,7 @@ mode = mode || 'js'; | ||
// Ignore unsupported properties | ||
/*eslint-disable no-console */ | ||
if (console && console.warn) { | ||
console.warn('Unsupported CSS property ' + property); | ||
console.warn('Unsupported CSS property "' + property + '"'); | ||
} | ||
/*eslint-enable no-console */ | ||
return; | ||
@@ -135,8 +165,2 @@ } | ||
var newValue = _getPrefixedValue(newProperty.js, value); | ||
if (newValue === false) { | ||
// Ignore unsupported values | ||
if (console && console.warn) { | ||
console.warn('Unsupported CSS value ' + value + ' for property ' + property); | ||
} | ||
} | ||
@@ -147,7 +171,6 @@ newStyle[newProperty[mode]] = newValue; | ||
}; | ||
/*eslint-enable no-console */ | ||
prefix.css = cssVendorPrefix; | ||
prefix.js = jsVendorPrefix; | ||
prefix.css = prefixInfo.cssPrefix; | ||
prefix.js = prefixInfo.jsPrefix; | ||
module.exports = prefix; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -9,6 +11,3 @@ | ||
var React = require('react'); | ||
var clone = require('lodash/lang/clone'); | ||
var isArray = require('lodash/lang/isArray'); | ||
var merge = require('lodash/object/merge'); | ||
var omit = require('lodash/object/omit'); | ||
var objectAssign = require('object-assign'); | ||
@@ -27,5 +26,5 @@ var mediaQueryListByQueryString = {}; | ||
var existing = component.state && component.state._radiumStyleState || {}; | ||
var state = { _radiumStyleState: clone(existing) }; | ||
var state = { _radiumStyleState: objectAssign({}, existing) }; | ||
state._radiumStyleState[key] = state._radiumStyleState[key] || {}; | ||
merge(state._radiumStyleState[key], newState); | ||
objectAssign(state._radiumStyleState[key], newState); | ||
component.setState(state); | ||
@@ -38,9 +37,19 @@ }; | ||
var _mergeStyles = function _mergeStyles(styles) { | ||
var validStyles = styles.filter(function (style) { | ||
return style && typeof style === 'object' && !isArray(style); | ||
var result = {}; | ||
styles.forEach(function (style) { | ||
if (!style || typeof style !== 'object' || Array.isArray(style)) { | ||
return; | ||
} | ||
Object.keys(style).forEach(function (key) { | ||
if (_isSpecialKey(key) && result[key]) { | ||
result[key] = _mergeStyles([result[key], style[key]]); | ||
} else { | ||
result[key] = style[key]; | ||
} | ||
}); | ||
}); | ||
// lodash merge is recursive, which handles :hover styles and even :hover | ||
// within media queries. | ||
return merge.apply(null, [{}].concat(validStyles)); | ||
return result; | ||
}; | ||
@@ -147,3 +156,3 @@ | ||
// Ignores non-objects, so you can do `this.state.isCool && styles.cool`. | ||
if (isArray(style)) { | ||
if (Array.isArray(style)) { | ||
style = _mergeStyles(style); | ||
@@ -180,4 +189,7 @@ } | ||
var newStyle = omit(style, function (value, styleKey) { | ||
return _isSpecialKey(styleKey); | ||
var newStyle = {}; | ||
Object.keys(style).forEach(function (styleKey) { | ||
if (!_isSpecialKey(styleKey)) { | ||
newStyle[styleKey] = style[styleKey]; | ||
} | ||
}); | ||
@@ -227,8 +239,12 @@ | ||
// Merge the styles in the order they were defined | ||
Object.keys(style).forEach(function (name) { | ||
if (name === ':active' && _getStyleState(component, key, ':active') || name === ':hover' && _getStyleState(component, key, ':hover') || name === ':focus' && _getStyleState(component, key, ':focus')) { | ||
merge(newStyle, style[name]); | ||
} | ||
var interactionStyles = Object.keys(style).filter(function (name) { | ||
return name === ':active' && _getStyleState(component, key, ':active') || name === ':hover' && _getStyleState(component, key, ':hover') || name === ':focus' && _getStyleState(component, key, ':focus'); | ||
}).map(function (name) { | ||
return style[name]; | ||
}); | ||
if (interactionStyles.length) { | ||
newStyle = _mergeStyles([newStyle].concat(interactionStyles)); | ||
} | ||
if (style[':active'] && !component._radiumMouseUpListener && ExecutionEnvironment.canUseEventListeners) { | ||
@@ -235,0 +251,0 @@ component._radiumMouseUpListener = MouseUpListener.subscribe(_mouseUp.bind(null, component)); |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -6,3 +8,3 @@ | ||
var merge = require('lodash/object/merge'); | ||
var objectAssign = require('object-assign'); | ||
@@ -14,3 +16,3 @@ var wrap = function wrap(config) { | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
return merge({}, existingInitialState, radiumInitialState); | ||
return objectAssign({}, existingInitialState, radiumInitialState); | ||
}, | ||
@@ -29,5 +31,5 @@ | ||
return merge({}, config, newConfig); | ||
return objectAssign({}, config, newConfig); | ||
}; | ||
module.exports = wrap; |
@@ -41,2 +41,15 @@ /* eslint-env jasmine */ | ||
it('receives the given props', () => { | ||
class Composed extends Component { | ||
constructor (props) { | ||
super(props); | ||
} | ||
} | ||
var Enhanced = Enhancer(Composed); | ||
var instance = new Enhanced({foo: 'bar'}); | ||
expect(instance.props).toEqual({foo: 'bar'}); | ||
}); | ||
it('calls existing render function, then resolveStyles', () => { | ||
@@ -59,2 +72,26 @@ var renderMock = jest.genMockFunction(); | ||
it('calls existing constructor only once', () => { | ||
var constructorMock = jest.genMockFunction(); | ||
class Composed extends Component { | ||
constructor () { | ||
super(); | ||
constructorMock(); | ||
} | ||
} | ||
var Enhanced = Enhancer(Composed); | ||
new Enhanced(); // eslint-disable-line no-new | ||
expect(constructorMock.mock.calls.length).toBe(1); | ||
}); | ||
it('refers to the existing displayName', () => { | ||
class Composed extends Component {} | ||
Composed.displayName = 'Composed'; | ||
var Enhanced = Enhancer(Composed); | ||
expect(Enhanced.displayName).toContain(Composed.displayName); | ||
}); | ||
it('calls existing componentWillUnmount function', () => { | ||
@@ -61,0 +98,0 @@ var existingComponentWillUnmount = jest.genMockFunction(); |
@@ -11,3 +11,3 @@ /* eslint-env jasmine */ | ||
var MouseUpListener = require('../mouse-up-listener.js'); | ||
var merge = require('lodash/object/merge'); | ||
var objectAssign = require('object-assign'); | ||
var resolveStyles = require('../resolve-styles.js'); | ||
@@ -18,3 +18,3 @@ | ||
setState: jest.genMockFunction().mockImplementation(function (newState) { | ||
this.state = merge(this.state, newState); | ||
objectAssign(this.state, newState); | ||
}), | ||
@@ -21,0 +21,0 @@ state: {} |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var CSSPropertyOperations = require('react/lib/CSSPropertyOperations'); | ||
var reduce = require('lodash/collection/reduce'); | ||
@@ -32,3 +31,3 @@ var buildCssString = function (selector, rules) { | ||
_buildStyles: function (stylesArr) { | ||
var styles = reduce(stylesArr, function (accumulator, item) { | ||
var styles = stylesArr.reduce((accumulator, item) => { | ||
var selector = Object.keys(item)[0]; | ||
@@ -48,3 +47,3 @@ var rules = item[selector]; | ||
return accumulator; | ||
}, '', this); | ||
}, ''); | ||
@@ -51,0 +50,0 @@ return styles; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -5,36 +7,33 @@ | ||
var wrapUtils = require('./wrap-utils.js'); | ||
var objectAssign = require('object-assign'); | ||
var enhanceWithRadium = function (ComposedComponent) { | ||
var RadiumEnhancer = function () { | ||
ComposedComponent.prototype.constructor.call(this); | ||
var enhanceWithRadium = function (ComposedComponent: constructor) { | ||
const displayName = | ||
ComposedComponent.displayName || | ||
ComposedComponent.name || | ||
'Component'; | ||
if (!this.state) { | ||
this.state = {}; | ||
} | ||
class RadiumEnhancer extends ComposedComponent { | ||
static displayName = `Radium(${displayName})`; | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
Object.keys(radiumInitialState).forEach(function (key) { | ||
this.state[key] = radiumInitialState[key]; | ||
}, this); | ||
}; | ||
constructor () { | ||
super(...arguments); | ||
RadiumEnhancer.prototype = new ComposedComponent(); | ||
RadiumEnhancer.prototype.constructor = RadiumEnhancer; | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
this.state = objectAssign(this.state || {}, radiumInitialState); | ||
} | ||
RadiumEnhancer.prototype.render = function () { | ||
var renderedElement = ComposedComponent.prototype.render.call(this); | ||
return resolveStyles(this, renderedElement); | ||
}; | ||
RadiumEnhancer.prototype.componentWillUnmount = function () { | ||
if (ComposedComponent.prototype.componentWillUnmount) { | ||
ComposedComponent.prototype.componentWillUnmount.call(this); | ||
render () { | ||
var renderedElement = super.render(); | ||
return resolveStyles(this, renderedElement); | ||
} | ||
wrapUtils.componentWillUnmount(this); | ||
}; | ||
componentWillUnmount () { | ||
if (super.componentWillUnmount) { | ||
super.componentWillUnmount(); | ||
} | ||
RadiumEnhancer.defaultProps = ComposedComponent.defaultProps; | ||
RadiumEnhancer.propTypes = ComposedComponent.propTypes; | ||
RadiumEnhancer.contextTypes = ComposedComponent.contextTypes; | ||
wrapUtils.componentWillUnmount(this); | ||
} | ||
} | ||
@@ -41,0 +40,0 @@ return RadiumEnhancer; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -5,3 +7,7 @@ | ||
var getState = function (state, elementKey, value) { | ||
var getState = function ( | ||
state: {_radiumStyleState: Object<string, Object<string, boolean>>}, | ||
elementKey: string, | ||
value: string, | ||
): boolean { | ||
elementKey = elementKey || 'main'; | ||
@@ -8,0 +14,0 @@ |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -6,5 +8,3 @@ | ||
var ExecutionEnvironment = require('exenv'); | ||
var kebabCase = require('lodash/string/kebabCase'); | ||
var msPrefix = /^ms-/; | ||
var animationIndex = 1; | ||
@@ -15,3 +15,3 @@ var animationStyleSheet = null; | ||
if (ExecutionEnvironment.canUseDOM) { | ||
animationStyleSheet = document.createElement('style'); | ||
animationStyleSheet = (document.createElement('style'): any); | ||
document.head.appendChild(animationStyleSheet); | ||
@@ -29,4 +29,3 @@ | ||
return Object.keys(style).map(function (property) { | ||
return kebabCase(property).replace(msPrefix, '-ms-') + ': ' + | ||
style[property] + ';'; | ||
return property + ': ' + style[property] + ';'; | ||
}).join('\n'); | ||
@@ -37,3 +36,5 @@ }; | ||
// keyframes, and returns a string with the generated animation name. | ||
var keyframes = function (keyframeRules) { | ||
var keyframes = function ( | ||
keyframeRules: Object<string, Object<string, string|number>>, | ||
): string { | ||
var name = 'Animation' + animationIndex; | ||
@@ -55,2 +56,8 @@ animationIndex += 1; | ||
// for flow | ||
/* istanbul ignore next */ | ||
if (!animationStyleSheet) { | ||
throw new Error('keyframes not initialized properly'); | ||
} | ||
animationStyleSheet.sheet.insertRule( | ||
@@ -57,0 +64,0 @@ rule, |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -12,3 +14,3 @@ | ||
var subscribe = function (callback) { | ||
var subscribe = function (callback: () => void): {remove: () => void} { | ||
if (_callbacks.indexOf(callback) === -1) { | ||
@@ -15,0 +17,0 @@ _callbacks.push(callback); |
/** | ||
* Based on https://github.com/jsstyles/css-vendor, but without any dash-case | ||
* shenanigans. | ||
* Based on https://github.com/jsstyles/css-vendor, but without having to | ||
* convert between different cases all the time. | ||
*/ | ||
@@ -9,12 +9,21 @@ | ||
var ExecutionEnvironment = require('exenv'); | ||
var kebabCase = require('lodash/string/kebabCase'); | ||
var jsCssMap = { | ||
Webkit: '-webkit-', | ||
Moz: '-moz-', | ||
// IE did it wrong again ... | ||
ms: '-ms-', | ||
O: '-o-' | ||
var infoByCssPrefix = { | ||
'-moz-': { | ||
cssPrefix: '-moz-', | ||
jsPrefix: 'Moz' | ||
}, | ||
'-ms-': { | ||
cssPrefix: '-ms-', | ||
jsPrefix: 'ms' | ||
}, | ||
'-o-': { | ||
cssPrefix: '-o-', | ||
jsPrefix: 'O' | ||
}, | ||
'-webkit-': { | ||
cssPrefix: '-webkit-', | ||
jsPrefix: 'Webkit' | ||
} | ||
}; | ||
var testProp = 'Transform'; | ||
@@ -24,4 +33,6 @@ var domStyle = {}; | ||
var prefixedValueCache = {}; | ||
var jsVendorPrefix = ''; | ||
var cssVendorPrefix = ''; | ||
var prefixInfo = { | ||
cssPrefix: '', | ||
jsPrefix: '' | ||
}; | ||
@@ -31,11 +42,20 @@ if (ExecutionEnvironment.canUseDOM) { | ||
for (var jsPrefix in jsCssMap) { | ||
if ((jsPrefix + testProp) in domStyle) { | ||
jsVendorPrefix = jsPrefix; | ||
cssVendorPrefix = jsCssMap[jsPrefix]; | ||
break; | ||
} | ||
} | ||
// Based on http://davidwalsh.name/vendor-prefix | ||
var windowStyles = window.getComputedStyle(document.documentElement, ''); | ||
var prefixMatch = Array.prototype.slice.call(windowStyles) | ||
.join('') | ||
.match(/-(moz|webkit|ms|o)-/); | ||
var cssVendorPrefix = prefixMatch && prefixMatch[0]; | ||
prefixInfo = infoByCssPrefix[cssVendorPrefix] || prefixInfo; | ||
} | ||
var _camelCaseRegex = /([a-z])?([A-Z])/g; | ||
var _camelCaseReplacer = function (match, p1, p2) { | ||
return p1 + '-' + p2.toLowerCase(); | ||
}; | ||
var _camelCaseToDashCase = function (s) { | ||
return s.replace(_camelCaseRegex, _camelCaseReplacer); | ||
}; | ||
var _getPrefixedProperty = function (property) { | ||
@@ -46,10 +66,15 @@ if (prefixedPropertyCache.hasOwnProperty(property)) { | ||
// Try the prefixed version first. Chrome in particular has the `filter` and | ||
// `webkitFilter` properties availalbe on the style object, but only the | ||
// prefixed version actually works. | ||
var prefixedProperty = | ||
prefixInfo.jsPrefix + property[0].toUpperCase() + property.slice(1); | ||
if ( | ||
!ExecutionEnvironment.canUseDOM || | ||
property in domStyle | ||
ExecutionEnvironment.canUseDOM && | ||
prefixedProperty in domStyle | ||
) { | ||
// unprefixed | ||
// prefixed | ||
prefixedPropertyCache[property] = { | ||
css: kebabCase(property), | ||
js: property | ||
css: prefixInfo.cssPrefix + _camelCaseToDashCase(property), | ||
js: prefixedProperty | ||
}; | ||
@@ -59,9 +84,10 @@ return prefixedPropertyCache[property]; | ||
var newProperty = | ||
jsVendorPrefix + property[0].toUpperCase() + property.slice(1); | ||
if (newProperty in domStyle) { | ||
// prefixed | ||
if ( | ||
!ExecutionEnvironment.canUseDOM || | ||
property in domStyle | ||
) { | ||
// unprefixed | ||
prefixedPropertyCache[property] = { | ||
css: cssVendorPrefix + kebabCase(property), | ||
js: newProperty | ||
css: _camelCaseToDashCase(property), | ||
js: property | ||
}; | ||
@@ -93,2 +119,5 @@ return prefixedPropertyCache[property]; | ||
// Assume unprefixed | ||
prefixedValueCache[cacheKey] = value; | ||
// Value is supported as it is. Note that we just make sure it is not an empty | ||
@@ -100,17 +129,24 @@ // string. Browsers will sometimes rewrite values, but still accept them. They | ||
if (domStyle[property]) { | ||
prefixedValueCache[cacheKey] = value; | ||
return value; | ||
return prefixedValueCache[cacheKey]; | ||
} | ||
// Test value with vendor prefix. | ||
value = cssVendorPrefix + value; | ||
domStyle[property] = value; | ||
var prefixedValue = prefixInfo.cssPrefix + value; | ||
domStyle[property] = prefixedValue; | ||
// Value is supported with vendor prefix. | ||
if (domStyle[property]) { | ||
prefixedValueCache[cacheKey] = value; | ||
return value; | ||
prefixedValueCache[cacheKey] = prefixedValue; | ||
return prefixedValue; | ||
} | ||
return prefixedValueCache[cacheKey] = false; | ||
// Unsupported, assume unprefixed but warn | ||
/*eslint-disable no-console */ | ||
if (console && console.warn) { | ||
console.warn( | ||
'Unsupported CSS value "' + value + '" for property "' + property + '"' | ||
); | ||
} | ||
/*eslint-enable no-console */ | ||
return prefixedValueCache[cacheKey]; | ||
}; | ||
@@ -120,3 +156,2 @@ | ||
// and values. | ||
/*eslint-disable no-console */ | ||
var prefix = function (style, mode /* 'css' or 'js' */) { | ||
@@ -131,5 +166,7 @@ mode = mode || 'js'; | ||
// Ignore unsupported properties | ||
/*eslint-disable no-console */ | ||
if (console && console.warn) { | ||
console.warn('Unsupported CSS property ' + property); | ||
console.warn('Unsupported CSS property "' + property + '"'); | ||
} | ||
/*eslint-enable no-console */ | ||
return; | ||
@@ -139,10 +176,2 @@ } | ||
var newValue = _getPrefixedValue(newProperty.js, value); | ||
if (newValue === false) { | ||
// Ignore unsupported values | ||
if (console && console.warn) { | ||
console.warn( | ||
'Unsupported CSS value ' + value + ' for property ' + property | ||
); | ||
} | ||
} | ||
@@ -153,7 +182,6 @@ newStyle[newProperty[mode]] = newValue; | ||
}; | ||
/*eslint-enable no-console */ | ||
prefix.css = cssVendorPrefix; | ||
prefix.js = jsVendorPrefix; | ||
prefix.css = prefixInfo.cssPrefix; | ||
prefix.js = prefixInfo.jsPrefix; | ||
module.exports = prefix; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -9,7 +11,10 @@ | ||
var React = require('react'); | ||
var clone = require('lodash/lang/clone'); | ||
var isArray = require('lodash/lang/isArray'); | ||
var merge = require('lodash/object/merge'); | ||
var omit = require('lodash/object/omit'); | ||
var objectAssign = require('object-assign'); | ||
declare class RadiumComponent extends ReactComponent { | ||
_lastMouseDown: number, | ||
_radiumMediaQueryListenersByQuery: Object<string, {remove: () => void}>, | ||
_radiumMouseUpListener: {remove: () => void}, | ||
} | ||
var mediaQueryListByQueryString = {}; | ||
@@ -27,5 +32,5 @@ | ||
var existing = component.state && component.state._radiumStyleState || {}; | ||
var state = { _radiumStyleState: clone(existing) }; | ||
var state = { _radiumStyleState: objectAssign({}, existing) }; | ||
state._radiumStyleState[key] = state._radiumStyleState[key] || {}; | ||
merge(state._radiumStyleState[key], newState); | ||
objectAssign(state._radiumStyleState[key], newState); | ||
component.setState(state); | ||
@@ -38,9 +43,19 @@ }; | ||
var _mergeStyles = function (styles) { | ||
var validStyles = styles.filter(function (style) { | ||
return style && typeof style === 'object' && !isArray(style); | ||
var result = {}; | ||
styles.forEach(function (style) { | ||
if (!style || typeof style !== 'object' || Array.isArray(style)) { | ||
return; | ||
} | ||
Object.keys(style).forEach(function (key) { | ||
if (_isSpecialKey(key) && result[key]) { | ||
result[key] = _mergeStyles([result[key], style[key]]); | ||
} else { | ||
result[key] = style[key]; | ||
} | ||
}); | ||
}); | ||
// lodash merge is recursive, which handles :hover styles and even :hover | ||
// within media queries. | ||
return merge.apply(null, [{}].concat(validStyles)); | ||
return result; | ||
}; | ||
@@ -112,3 +127,7 @@ | ||
// | ||
var resolveStyles = function (component, renderedElement, existingKeyMap) { | ||
var resolveStyles = function ( | ||
component: RadiumComponent, | ||
renderedElement: ReactElement, | ||
existingKeyMap?: Object<string, string> | ||
): ReactElement { | ||
existingKeyMap = existingKeyMap || {}; | ||
@@ -153,3 +172,3 @@ | ||
// Ignores non-objects, so you can do `this.state.isCool && styles.cool`. | ||
if (isArray(style)) { | ||
if (Array.isArray(style)) { | ||
style = _mergeStyles(style); | ||
@@ -195,6 +214,8 @@ } | ||
var newStyle = omit( | ||
style, | ||
function (value, styleKey) { return _isSpecialKey(styleKey); } | ||
); | ||
var newStyle = {}; | ||
Object.keys(style).forEach(function (styleKey) { | ||
if (!_isSpecialKey(styleKey)) { | ||
newStyle[styleKey] = style[styleKey]; | ||
} | ||
}); | ||
@@ -243,12 +264,16 @@ // Only add handlers if necessary | ||
// Merge the styles in the order they were defined | ||
Object.keys(style).forEach(function (name) { | ||
if ( | ||
(name === ':active' && _getStyleState(component, key, ':active')) || | ||
(name === ':hover' && _getStyleState(component, key, ':hover')) || | ||
(name === ':focus' && _getStyleState(component, key, ':focus')) | ||
) { | ||
merge(newStyle, style[name]); | ||
} | ||
}); | ||
var interactionStyles = Object.keys(style) | ||
.filter(function (name) { | ||
return ( | ||
(name === ':active' && _getStyleState(component, key, ':active')) || | ||
(name === ':hover' && _getStyleState(component, key, ':hover')) || | ||
(name === ':focus' && _getStyleState(component, key, ':focus')) | ||
); | ||
}) | ||
.map(function (name) { return style[name]; }); | ||
if (interactionStyles.length) { | ||
newStyle = _mergeStyles([newStyle].concat(interactionStyles)); | ||
} | ||
if ( | ||
@@ -255,0 +280,0 @@ style[':active'] && |
@@ -0,9 +1,16 @@ | ||
/* @flow */ | ||
'use strict'; | ||
declare class RadiumComponent extends ReactComponent { | ||
_radiumMediaQueryListenersByQuery: Object<string, {remove: () => void}>, | ||
_radiumMouseUpListener: {remove: () => void}, | ||
} | ||
module.exports = { | ||
getInitialState: function () { | ||
getInitialState (): {_radiumStyleState: Object} { | ||
return {_radiumStyleState: {}}; | ||
}, | ||
componentWillUnmount: function (component) { | ||
componentWillUnmount (component: RadiumComponent) { | ||
if (component._radiumMouseUpListener) { | ||
@@ -10,0 +17,0 @@ component._radiumMouseUpListener.remove(); |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
'use strict'; | ||
@@ -6,5 +8,11 @@ | ||
var merge = require('lodash/object/merge'); | ||
var objectAssign = require('object-assign'); | ||
var wrap = function (config) { | ||
declare class ReactComponentConfig { | ||
getInitialState?: () => Object; | ||
componentWillUnmount?: () => void; | ||
render: () => ReactElement; | ||
} | ||
var wrap = function (config: ReactComponentConfig) { | ||
var newConfig = { | ||
@@ -16,3 +24,3 @@ getInitialState: function () { | ||
var radiumInitialState = wrapUtils.getInitialState(); | ||
return merge({}, existingInitialState, radiumInitialState); | ||
return objectAssign({}, existingInitialState, radiumInitialState); | ||
}, | ||
@@ -31,5 +39,5 @@ | ||
return merge({}, config, newConfig); | ||
return objectAssign({}, config, newConfig); | ||
}; | ||
module.exports = wrap; |
{ | ||
"name": "radium", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "A set of tools to manage inline styles on React elements", | ||
@@ -16,9 +16,11 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"babel": "rimraf lib && babel --stage 0 modules/ -d lib/", | ||
"dist": "webpack && webpack --config=webpack.config.minified.js", | ||
"examples": "webpack-dev-server --config examples/webpack.config.js --no-info --content-base examples/", | ||
"lib": "rimraf lib && babel modules/ -d lib/ && rimraf lib/__tests__ lib/__mocks__", | ||
"lib": "npm run babel && rimraf lib/__tests__ lib/__mocks__", | ||
"lint": "eslint modules", | ||
"postinstall": "node -e \"require('fs').readdir('lib',function(e){e&&require('child_process').spawn('npm', ['run', 'prepublish'], {stdio: 'inherit'})})\"", | ||
"prepublish": "npm run lib", | ||
"test": "jest" | ||
"test": "jest", | ||
"test-coverage": "npm run babel && jest --config jest/coverage-config.json" | ||
}, | ||
@@ -31,8 +33,9 @@ "license": "MIT", | ||
"exenv": "^1.1.0", | ||
"lodash": "^3.2.0" | ||
"object-assign": "^2.0.0", | ||
"babel": "^5.3.3", | ||
"babel-core": "^5.3.3", | ||
"rimraf": "^2.3.3" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.3.3", | ||
"babel-core": "^5.3.3", | ||
"babel-eslint": "^3.1.1", | ||
"babel-eslint": "^3.1.7", | ||
"babel-loader": "^5.0.0", | ||
@@ -42,4 +45,4 @@ "coveralls": "^2.11.2", | ||
"jest-cli": "^0.4.0", | ||
"lodash": "^3.2.0", | ||
"react": ">=0.12.0 <0.14.0", | ||
"rimraf": "^2.3.3", | ||
"webpack": "^1.5.3", | ||
@@ -53,13 +56,6 @@ "webpack-dev-server": "^1.7.0" | ||
], | ||
"collectCoverage": true, | ||
"collectCoverageOnlyFrom": { | ||
"modules/get-state.js": true, | ||
"modules/resolve-styles.js": true, | ||
"modules/wrap.js": true, | ||
"modules/wrap-utils.js": true, | ||
"modules/enhancer.js": true | ||
}, | ||
"unmockedModulePathPatterns": [ | ||
"exenv", | ||
"lodash", | ||
"object-assign", | ||
"react" | ||
@@ -66,0 +62,0 @@ ] |
@@ -31,2 +31,4 @@ [![Travis Status][trav_img]][trav_site] | ||
For a short technical explanation, see [How does Radium work?](#how-does-radium-work). | ||
## Features | ||
@@ -152,2 +154,13 @@ | ||
## How does Radium work? | ||
Following is a short technical explanation of Radium's inner workings: | ||
- Wrap the `render` function | ||
- Recurse into the result of the original `render` | ||
- For each element: | ||
- Add handlers to props if interactive styles are specified, e.g. `onMouseEnter` for `:hover`, wrapping existing handlers if necessary | ||
- If any of the handlers are triggered, e.g. by hovering, Radium calls `setState` to update a Radium-specific field on the components state object | ||
- On re-render, resolve any interactive styles that apply, e.g. `:hover`, by looking up the element's key or ref in the Radium-specific state | ||
## Contributing | ||
@@ -154,0 +167,0 @@ |
@@ -20,3 +20,3 @@ var path = require('path'); | ||
test: /\.js(x|)?$/, | ||
loader: 'babel-loader' | ||
loader: 'babel-loader?stage=0' | ||
} | ||
@@ -23,0 +23,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9
50
176
0
192483
6
3977
+ Addedbabel@^5.3.3
+ Addedbabel-core@^5.3.3
+ Addedobject-assign@^2.0.0
+ Addedrimraf@^2.3.3
+ Addedalign-text@0.1.4(transitive)
+ Addedalter@0.2.0(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedanymatch@1.3.2(transitive)
+ Addedarr-diff@2.0.04.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.2.10.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedast-traverse@0.1.1(transitive)
+ Addedast-types@0.8.120.8.15(transitive)
+ Addedasync-each@1.0.6(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbabel@5.8.38(transitive)
+ Addedbabel-core@5.8.38(transitive)
+ Addedbabel-plugin-constant-folding@1.0.1(transitive)
+ Addedbabel-plugin-dead-code-elimination@1.0.2(transitive)
+ Addedbabel-plugin-eval@1.0.1(transitive)
+ Addedbabel-plugin-inline-environment-variables@1.0.1(transitive)
+ Addedbabel-plugin-jscript@1.0.4(transitive)
+ Addedbabel-plugin-member-expression-literals@1.0.1(transitive)
+ Addedbabel-plugin-property-literals@1.0.1(transitive)
+ Addedbabel-plugin-proto-to-assign@1.0.4(transitive)
+ Addedbabel-plugin-react-constant-elements@1.0.3(transitive)
+ Addedbabel-plugin-react-display-name@1.0.3(transitive)
+ Addedbabel-plugin-remove-console@1.0.1(transitive)
+ Addedbabel-plugin-remove-debugger@1.0.1(transitive)
+ Addedbabel-plugin-runtime@1.0.7(transitive)
+ Addedbabel-plugin-undeclared-variables-check@1.0.2(transitive)
+ Addedbabel-plugin-undefined-to-void@1.1.6(transitive)
+ Addedbabylon@5.8.38(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addedbraces@1.8.52.3.2(transitive)
+ Addedbreakable@1.0.0(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedchokidar@1.7.0(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddefs@1.1.1(transitive)
+ Addeddetect-indent@3.0.1(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesprima@2.7.3(transitive)
+ Addedesprima-fb@15001.1001.0-dev-harmony-fb(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedexpand-brackets@0.1.52.1.4(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@0.3.22.0.4(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.44.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfs-readdir-recursive@0.1.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@1.2.13(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-stdin@4.0.1(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedglobals@6.4.1(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhome-or-tmp@1.0.0(transitive)
+ Addedinvert-kv@1.0.0(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-finite@1.1.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-integer@1.0.7(transitive)
+ Addedis-number@2.1.03.0.04.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedjs-tokens@1.0.1(transitive)
+ Addedjsesc@0.5.0(transitive)
+ Addedjson5@0.4.0(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlcid@1.0.0(transitive)
+ Addedleven@1.0.2(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.113.1.10(transitive)
+ Addedminimatch@2.0.10(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednan@2.22.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedos-locale@1.4.0(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedoutput-file-sync@1.1.2(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-exists@1.0.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreaddirp@2.2.1(transitive)
+ Addedrecast@0.10.330.10.43(transitive)
+ Addedregenerate@1.4.2(transitive)
+ Addedregenerator@0.8.40(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedregexpu@1.3.0(transitive)
+ Addedregjsgen@0.2.0(transitive)
+ Addedregjsparser@0.1.5(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedrepeating@1.1.3(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsimple-fmt@0.1.0(transitive)
+ Addedsimple-is@0.2.0(transitive)
+ Addedslash@1.0.0(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.1.32(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-support@0.2.10(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstable@0.1.8(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstringmap@0.2.2(transitive)
+ Addedstringset@0.2.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedto-fast-properties@1.0.3(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedtrim-right@1.0.1(transitive)
+ Addedtry-resolve@1.0.1(transitive)
+ Addedtryor@0.1.2(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addeduser-home@1.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwindow-size@0.1.4(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedy18n@3.2.2(transitive)
+ Addedyargs@3.27.0(transitive)
- Removedlodash@^3.2.0