3156 lines · 119.8 KB · JavaScript
RawDownload
/** @license React v16.8.6 * react.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; (function (global, factory) {    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :        typeof define === 'function' && define.amd ? define(factory) :            (global.React = factory());}(this, (function () {    'use strict';     // TODO: this is special because it gets imported during build.     var ReactVersion = '16.8.6';     // The Symbol used to tag the ReactElement-like types. If there is no native Symbol    // nor polyfill, then a plain number is used for performance.    var hasSymbol = typeof Symbol === 'function' && Symbol.for;     var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;    var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;    var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;    var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;    var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;    var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;    var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;     var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;    var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;    var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;    var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;    var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;     var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;    var FAUX_ITERATOR_SYMBOL = '@@iterator';     function getIteratorFn(maybeIterable) {        if (maybeIterable === null || typeof maybeIterable !== 'object') {            return null;        }        var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];        if (typeof maybeIterator === 'function') {            return maybeIterator;        }        return null;    }     /*    object-assign    (c) Sindre Sorhus    @license MIT    */      /* eslint-disable no-unused-vars */    var getOwnPropertySymbols = Object.getOwnPropertySymbols;    var hasOwnProperty = Object.prototype.hasOwnProperty;    var propIsEnumerable = Object.prototype.propertyIsEnumerable;     function toObject(val) {        if (val === null || val === undefined) {            throw new TypeError('Object.assign cannot be called with null or undefined');        }         return Object(val);    }     function shouldUseNative() {        try {            if (!Object.assign) {                return false;            }             // Detect buggy property enumeration order in older V8 versions.             // https://bugs.chromium.org/p/v8/issues/detail?id=4118            var test1 = new String('abc');  // eslint-disable-line no-new-wrappers            test1[5] = 'de';            if (Object.getOwnPropertyNames(test1)[0] === '5') {                return false;            }             // https://bugs.chromium.org/p/v8/issues/detail?id=3056            var test2 = {};            for (var i = 0; i < 10; i++) {                test2['_' + String.fromCharCode(i)] = i;            }            var order2 = Object.getOwnPropertyNames(test2).map(function (n) {                return test2[n];            });            if (order2.join('') !== '0123456789') {                return false;            }             // https://bugs.chromium.org/p/v8/issues/detail?id=3056            var test3 = {};            'abcdefghijklmnopqrst'.split('').forEach(function (letter) {                test3[letter] = letter;            });            if (Object.keys(Object.assign({}, test3)).join('') !==                'abcdefghijklmnopqrst') {                return false;            }             return true;        } catch (err) {            // We don't expect any of the above to throw, but better to be safe.            return false;        }    }     var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {        var from;        var to = toObject(target);        var symbols;         for (var s = 1; s < arguments.length; s++) {            from = Object(arguments[s]);             for (var key in from) {                if (hasOwnProperty.call(from, key)) {                    to[key] = from[key];                }            }             if (getOwnPropertySymbols) {                symbols = getOwnPropertySymbols(from);                for (var i = 0; i < symbols.length; i++) {                    if (propIsEnumerable.call(from, symbols[i])) {                        to[symbols[i]] = from[symbols[i]];                    }                }            }        }         return to;    };     /**     * Use invariant() to assert state which your program assumes to be true.     *     * Provide sprintf-style format (only %s is supported) and arguments     * to provide information about what broke and what you were     * expecting.     *     * The invariant message will be stripped in production, but the invariant     * will remain to ensure logic does not differ in production.     */     var validateFormat = function () { };     {        validateFormat = function (format) {            if (format === undefined) {                throw new Error('invariant requires an error message argument');            }        };    }     function invariant(condition, format, a, b, c, d, e, f) {        validateFormat(format);         if (!condition) {            var error = void 0;            if (format === undefined) {                error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');            } else {                var args = [a, b, c, d, e, f];                var argIndex = 0;                error = new Error(format.replace(/%s/g, function () {                    return args[argIndex++];                }));                error.name = 'Invariant Violation';            }             error.framesToPop = 1; // we don't care about invariant's own frame            throw error;        }    }     // Relying on the `invariant()` implementation lets us    // preserve the format and params in the www builds.     /**     * Forked from fbjs/warning:     * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js     *     * Only change is we use console.warn instead of console.error,     * and do nothing when 'console' is not supported.     * This really simplifies the code.     * ---     * Similar to invariant but only logs a warning if the condition is not met.     * This can be used to log issues in development environments in critical     * paths. Removing the logging code for production environments will keep the     * same logic and follow the same code paths.     */     var lowPriorityWarning = function () { };     {        var printWarning = function (format) {            for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {                args[_key - 1] = arguments[_key];            }             var argIndex = 0;            var message = 'Warning: ' + format.replace(/%s/g, function () {                return args[argIndex++];            });            if (typeof console !== 'undefined') {                console.warn(message);            }            try {                // --- Welcome to debugging React ---                // This error was thrown as a convenience so that you can use this stack                // to find the callsite that caused this warning to fire.                throw new Error(message);            } catch (x) { }        };         lowPriorityWarning = function (condition, format) {            if (format === undefined) {                throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');            }            if (!condition) {                for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {                    args[_key2 - 2] = arguments[_key2];                }                 printWarning.apply(undefined, [format].concat(args));            }        };    }     var lowPriorityWarning$1 = lowPriorityWarning;     /**     * Similar to invariant but only logs a warning if the condition is not met.     * This can be used to log issues in development environments in critical     * paths. Removing the logging code for production environments will keep the     * same logic and follow the same code paths.     */     var warningWithoutStack = function () { };     {        warningWithoutStack = function (condition, format) {            for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {                args[_key - 2] = arguments[_key];            }             if (format === undefined) {                throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');            }            if (args.length > 8) {                // Check before the condition to catch violations early.                throw new Error('warningWithoutStack() currently supports at most 8 arguments.');            }            if (condition) {                return;            }            if (typeof console !== 'undefined') {                var argsWithFormat = args.map(function (item) {                    return '' + item;                });                argsWithFormat.unshift('Warning: ' + format);                 // We intentionally don't use spread (or .apply) directly because it                // breaks IE9: https://github.com/facebook/react/issues/13610                Function.prototype.apply.call(console.error, console, argsWithFormat);            }            try {                // --- Welcome to debugging React ---                // This error was thrown as a convenience so that you can use this stack                // to find the callsite that caused this warning to fire.                var argIndex = 0;                var message = 'Warning: ' + format.replace(/%s/g, function () {                    return args[argIndex++];                });                throw new Error(message);            } catch (x) { }        };    }     var warningWithoutStack$1 = warningWithoutStack;     var didWarnStateUpdateForUnmountedComponent = {};     function warnNoop(publicInstance, callerName) {        {            var _constructor = publicInstance.constructor;            var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';            var warningKey = componentName + '.' + callerName;            if (didWarnStateUpdateForUnmountedComponent[warningKey]) {                return;            }            warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);            didWarnStateUpdateForUnmountedComponent[warningKey] = true;        }    }     /**     * This is the abstract API for an update queue.     */    var ReactNoopUpdateQueue = {        /**         * Checks whether or not this composite component is mounted.         * @param {ReactClass} publicInstance The instance we want to test.         * @return {boolean} True if mounted, false otherwise.         * @protected         * @final         */        isMounted: function (publicInstance) {            return false;        },         /**         * Forces an update. This should only be invoked when it is known with         * certainty that we are **not** in a DOM transaction.         *         * You may want to call this when you know that some deeper aspect of the         * component's state has changed but `setState` was not called.         *         * This will not invoke `shouldComponentUpdate`, but it will invoke         * `componentWillUpdate` and `componentDidUpdate`.         *         * @param {ReactClass} publicInstance The instance that should rerender.         * @param {?function} callback Called after component is updated.         * @param {?string} callerName name of the calling function in the public API.         * @internal         */        enqueueForceUpdate: function (publicInstance, callback, callerName) {            warnNoop(publicInstance, 'forceUpdate');        },         /**         * Replaces all of the state. Always use this or `setState` to mutate state.         * You should treat `this.state` as immutable.         *         * There is no guarantee that `this.state` will be immediately updated, so         * accessing `this.state` after calling this method may return the old value.         *         * @param {ReactClass} publicInstance The instance that should rerender.         * @param {object} completeState Next state.         * @param {?function} callback Called after component is updated.         * @param {?string} callerName name of the calling function in the public API.         * @internal         */        enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {            warnNoop(publicInstance, 'replaceState');        },         /**         * Sets a subset of the state. This only exists because _pendingState is         * internal. This provides a merging strategy that is not available to deep         * properties which is confusing. TODO: Expose pendingState or don't use it         * during the merge.         *         * @param {ReactClass} publicInstance The instance that should rerender.         * @param {object} partialState Next partial state to be merged with state.         * @param {?function} callback Called after component is updated.         * @param {?string} Name of the calling function in the public API.         * @internal         */        enqueueSetState: function (publicInstance, partialState, callback, callerName) {            warnNoop(publicInstance, 'setState');        }    };     var emptyObject = {};    {        Object.freeze(emptyObject);    }     /**     * Base class helpers for the updating state of a component.     */    function Component(props, context, updater) {        this.props = props;        this.context = context;        // If a component has string refs, we will assign a different object later.        this.refs = emptyObject;        // We initialize the default updater but the real one gets injected by the        // renderer.        this.updater = updater || ReactNoopUpdateQueue;    }     Component.prototype.isReactComponent = {};     /**     * Sets a subset of the state. Always use this to mutate     * state. You should treat `this.state` as immutable.     *     * There is no guarantee that `this.state` will be immediately updated, so     * accessing `this.state` after calling this method may return the old value.     *     * There is no guarantee that calls to `setState` will run synchronously,     * as they may eventually be batched together.  You can provide an optional     * callback that will be executed when the call to setState is actually     * completed.     *     * When a function is provided to setState, it will be called at some point in     * the future (not synchronously). It will be called with the up to date     * component arguments (state, props, context). These values can be different     * from this.* because your function may be called after receiveProps but before     * shouldComponentUpdate, and this new state, props, and context will not yet be     * assigned to this.     *     * @param {object|function} partialState Next partial state or function to     *        produce next partial state to be merged with current state.     * @param {?function} callback Called after state is updated.     * @final     * @protected     */    Component.prototype.setState = function (partialState, callback) {        !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;        this.updater.enqueueSetState(this, partialState, callback, 'setState');    };     /**     * Forces an update. This should only be invoked when it is known with     * certainty that we are **not** in a DOM transaction.     *     * You may want to call this when you know that some deeper aspect of the     * component's state has changed but `setState` was not called.     *     * This will not invoke `shouldComponentUpdate`, but it will invoke     * `componentWillUpdate` and `componentDidUpdate`.     *     * @param {?function} callback Called after update is complete.     * @final     * @protected     */    Component.prototype.forceUpdate = function (callback) {        this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');    };     /**     * Deprecated APIs. These APIs used to exist on classic React classes but since     * we would like to deprecate them, we're not going to move them over to this     * modern base class. Instead, we define a getter that warns if it's accessed.     */    {        var deprecatedAPIs = {            isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],            replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']        };        var defineDeprecationWarning = function (methodName, info) {            Object.defineProperty(Component.prototype, methodName, {                get: function () {                    lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);                    return undefined;                }            });        };        for (var fnName in deprecatedAPIs) {            if (deprecatedAPIs.hasOwnProperty(fnName)) {                defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);            }        }    }     function ComponentDummy() { }    ComponentDummy.prototype = Component.prototype;     /**     * Convenience component with default shallow equality check for sCU.     */    function PureComponent(props, context, updater) {        this.props = props;        this.context = context;        // If a component has string refs, we will assign a different object later.        this.refs = emptyObject;        this.updater = updater || ReactNoopUpdateQueue;    }     var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();    pureComponentPrototype.constructor = PureComponent;    // Avoid an extra prototype jump for these methods.    objectAssign(pureComponentPrototype, Component.prototype);    pureComponentPrototype.isPureReactComponent = true;     // an immutable object with a single mutable value    function createRef() {        var refObject = {            current: null        };        {            Object.seal(refObject);        }        return refObject;    } 

Lines 1–500 of 3156.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t