UNPKG

9.77 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.ThemeProvider={},e.React)}(this,function(e,t){"use strict";var r=t.default;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return function(){return e}}var a=function(){};a.thatReturns=i,a.thatReturnsFalse=i(!1),a.thatReturnsTrue=i(!0),a.thatReturnsNull=i(null),a.thatReturnsThis=function(){return this},a.thatReturnsArgument=function(e){return e};var u=a;var c=function(e,t,r,n,o,i,a,u){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[r,n,o,i,a,u],s=0;(c=new Error(t.replace(/%s/g,function(){return p[s++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}},p="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",s=o(function(e){e.exports=function(){function e(e,t,r,n,o,i){i!==p&&c(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=u,r.PropTypes=r,r}()}),f="__global_unique_id__",l=function(){return global[f]=(global[f]||0)+1},y=u,h=o(function(e,t){t.__esModule=!0;var n=a(r),o=a(s),i=a(l);a(y);function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function p(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&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var f=1073741823;t.default=n.default.createContext||function(e,t){var n,a,s="__create-react-context-"+(0,i.default)()+"__",l=function(e){function r(){var t,n,o,i;u(this,r);for(var a=arguments.length,p=Array(a),s=0;s<a;s++)p[s]=arguments[s];return t=n=c(this,e.call.apply(e,[this].concat(p))),n.emitter=(o=n.props.value,i=[],{on:function(e){i.push(e)},off:function(e){i=i.filter(function(t){return t!==e})},get:function(){return o},set:function(e,t){o=e,i.forEach(function(e){return e(o,t)})}}),c(n,t)}return p(r,e),r.prototype.getChildContext=function(){var e;return(e={})[s]=this.emitter,e},r.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var r=this.props.value,n=e.value,o=void 0;((i=r)===(a=n)?0!==i||1/i==1/a:i!=i&&a!=a)?o=0:(o="function"==typeof t?t(r,n):f,0!=(o|=0)&&this.emitter.set(e.value,o))}var i,a},r.prototype.render=function(){return this.props.children},r}(r.Component);l.childContextTypes=((n={})[s]=o.default.object.isRequired,n);var y=function(t){function r(){var e,n;u(this,r);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return e=n=c(this,t.call.apply(t,[this].concat(i))),n.state={value:n.getValue()},n.onUpdate=function(e,t){0!=((0|n.observedBits)&t)&&n.setState({value:n.getValue()})},c(n,e)}return p(r,t),r.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=void 0===t||null===t?f:t},r.prototype.componentDidMount=function(){this.context[s]&&this.context[s].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=void 0===e||null===e?f:e},r.prototype.componentWillUnmount=function(){this.context[s]&&this.context[s].off(this.onUpdate)},r.prototype.getValue=function(){return this.context[s]?this.context[s].get():e},r.prototype.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},r}(r.Component);return y.contextTypes=((a={})[s]=o.default.object,a),{Provider:l,Consumer:y}},e.exports=t.default});n(h);var d=n(o(function(e,t){t.__esModule=!0;var n=i(r),o=i(h);function i(e){return e&&e.__esModule?e:{default:e}}t.default=n.default.createContext||o.default,e.exports=t.default})),v=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},m=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}}(),b=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},g=function(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&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},_=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t};var O=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===P}(e)}(e)};var P="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function j(e,t){return!1!==t.clone&&t.isMergeableObject(e)?w((r=e,Array.isArray(r)?[]:{}),e,t):e;var r}function x(e,t,r){return e.concat(t).map(function(e){return j(e,r)})}function w(e,t,r){(r=r||{}).arrayMerge=r.arrayMerge||x,r.isMergeableObject=r.isMergeableObject||O;var n=Array.isArray(t);return n===Array.isArray(e)?n?r.arrayMerge(e,t,r):function(e,t,r){var n={};return r.isMergeableObject(e)&&Object.keys(e).forEach(function(t){n[t]=j(e[t],r)}),Object.keys(t).forEach(function(o){r.isMergeableObject(t[o])&&e[o]?n[o]=w(e[o],t[o],r):n[o]=j(t[o],r)}),n}(e,t,r):j(t,r)}w.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,r){return w(e,r,t)},{})};var T=w,C=o(function(e,t){var r,n,o,i,a,u,c,p;e.exports=(r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o=Object.defineProperty,i=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,u=Object.getOwnPropertyDescriptor,c=Object.getPrototypeOf,p=c&&c(Object),function e(t,s,f){if("string"!=typeof s){if(p){var l=c(s);l&&l!==p&&e(t,l,f)}var y=i(s);a&&(y=y.concat(a(s)));for(var h=0;h<y.length;++h){var d=y[h];if(!(r[d]||n[d]||f&&f[d])){var v=u(s,d);try{o(t,d,v)}catch(e){}}}return t}return t})}),E=["autobind","childContextTypes","componentDidMount","componentDidUpdate","componentWillMount","componentWillReceiveProps","componentWillUnmount","componentWillUpdate","contextTypes","displayName","getChildContext","getDefaultProps","getDOMNode","getInitialState","mixins","propTypes","render","replaceProps","setProps","shouldComponentUpdate","statics","updateComponent"];var R=function(e){return Boolean(e.prototype&&e.prototype.isReactComponent)},M=function(e,r){return function(n){var o=function(o){function i(){var e,t,r;v(this,i);for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return t=r=_(this,(e=i.__proto__||Object.getPrototypeOf(i)).call.apply(e,[this].concat(o))),r._merge=function(e,t){var n=r._previous;if(n&&n.a===e&&n.b===t)return n.result;var o=e&&t?T(e,t):e||t;return r._previous={a:e,b:t,result:o},o},_(r,t)}return g(i,o),m(i,[{key:"render",value:function(){var o=this,i=this.props,a=(i.forwardedRef,function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}(i,["forwardedRef"]));return t.createElement(r.Consumer,null,function(r){var i=o._merge(r,o.props.theme),u=void 0;return u=R(n)?t.createElement(n,b({},a,{ref:function(e){o._root=e},theme:i})):t.createElement(n,b({},a,{theme:i})),i!==o.props.theme?t.createElement(e,{theme:i},u):u})}}]),i}(t.Component);o.displayName="withTheme("+(n.displayName||n.name)+")";var i,a,u=o;return R(n)&&(u.prototype.getWrappedInstance=function(){return this._root.getWrappedInstance?this._root.getWrappedInstance():this._root},i=u,u=(a=n).prototype?(Object.getOwnPropertyNames(a.prototype).filter(function(e){return!(E.includes(e)||e in t.Component.prototype||e in i.prototype||e.startsWith("_"))}).forEach(function(e){"function"==typeof a.prototype[e]?i.prototype[e]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return a.prototype[e].apply(this.getWrappedInstance(),r)}:Object.defineProperty(i.prototype,e,{get:function(){return this.getWrappedInstance()[e]},set:function(t){this.getWrappedInstance()[e]=t}})}),i):i),C(u,n),u}};function A(e){var r=d(e),n=function(e,r){var n,o;return o=n=function(e){function n(){return v(this,n),_(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return g(n,e),m(n,[{key:"render",value:function(){return t.createElement(r.Provider,{value:this.props.theme},this.props.children)}}]),n}(t.PureComponent),n.defaultProps={theme:e},o}(e,r);return{ThemeProvider:n,withTheme:M(n,r)}}var W=A({}),S=W.ThemeProvider,D=W.withTheme;e.ThemeProvider=S,e.withTheme=D,e.createTheming=A,Object.defineProperty(e,"__esModule",{value:!0})});