index.min.js
2.16 KB
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=require("react"),n=t(e),r=t(require("@babel/runtime/helpers/inheritsLoose")),o=t(require("prop-types")),i=t(require("tiny-warning")),u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function s(t){var e=[];return{on:function(t){e.push(t)},off:function(t){e=e.filter((function(e){return e!==t}))},get:function(){return t},set:function(n,r){t=n,e.forEach((function(e){return e(t,r)}))}}}var a=n.createContext||function(t,n){var a,c,l,p="__create-react-context-"+(u[l="__global_unique_id__"]=(u[l]||0)+1)+"__",f=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).emitter=s(e.props.value),e}r(e,t);var o=e.prototype;return o.getChildContext=function(){var t;return(t={})[p]=this.emitter,t},o.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var e,r=this.props.value,o=t.value;((u=r)===(s=o)?0!==u||1/u==1/s:u!=u&&s!=s)?e=0:(e="function"==typeof n?n(r,o):1073741823,"production"!==process.env.NODE_ENV&&i((1073741823&e)===e,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+e),0!==(e|=0)&&this.emitter.set(t.value,e))}var u,s},o.render=function(){return this.props.children},e}(e.Component);f.childContextTypes=((a={})[p]=o.object.isRequired,a);var v=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).state={value:t.getValue()},t.onUpdate=function(e,n){0!=((0|t.observedBits)&n)&&t.setState({value:t.getValue()})},t}r(n,e);var o=n.prototype;return o.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=null==e?1073741823:e},o.componentDidMount=function(){this.context[p]&&this.context[p].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=null==t?1073741823:t},o.componentWillUnmount=function(){this.context[p]&&this.context[p].off(this.onUpdate)},o.getValue=function(){return this.context[p]?this.context[p].get():t},o.render=function(){return(t=this.props.children,Array.isArray(t)?t[0]:t)(this.state.value);var t},n}(e.Component);return v.contextTypes=((c={})[p]=o.object,c),{Provider:f,Consumer:v}};module.exports=a;