Comparing version 2.2.0 to 3.0.0
@@ -6,2 +6,12 @@ # Changelog | ||
### 3.0 (2018-12-20) | ||
- Upgrade to React 16.3 and cache the calculation of the theme object ([#74](https://github.com/cssinjs/theming/pull/74)) | ||
- Add support for the new forward ref API and deprecate the `innerRef` prop ([#75](https://github.com/cssinjs/theming/pull/75)) | ||
### 2.2.0 (2018-11-16) | ||
- Make the default theme undefined so when a ThemeProvider is not nested, it will not merge the themes ([#70](https://github.com/cssinjs/theming/pull/70)) | ||
- Save the context on the theming object ([#69](https://github.com/cssinjs/theming/pull/69)) | ||
### 2.1.2 (2018-11-2) | ||
@@ -8,0 +18,0 @@ |
@@ -7,3 +7,4 @@ 'use strict'; | ||
var React = _interopDefault(require('react')); | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var warning = _interopDefault(require('warning')); | ||
@@ -13,3 +14,2 @@ var PropTypes = _interopDefault(require('prop-types')); | ||
var getDisplayName = _interopDefault(require('react-display-name')); | ||
var createReactContext = _interopDefault(require('create-react-context')); | ||
@@ -55,15 +55,8 @@ function _defineProperty(obj, key, value) { | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return target; | ||
return self; | ||
} | ||
@@ -84,3 +77,24 @@ | ||
function ThemeProvider() { | ||
return _React$Component.apply(this, arguments) || this; | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "cachedTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastOuterTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderProvider", function (outerTheme) { | ||
var children = _this.props.children; | ||
return React__default.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
return _this; | ||
} | ||
@@ -94,15 +108,19 @@ | ||
if (typeof theme === 'function') { | ||
var mergedTheme = theme(outerTheme); | ||
warning(isObject(mergedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
return mergedTheme; | ||
if (theme !== this.lastTheme || outerTheme !== this.lastOuterTheme || !this.cachedTheme) { | ||
this.lastOuterTheme = outerTheme; | ||
this.lastTheme = theme; | ||
if (typeof theme === 'function') { | ||
this.cachedTheme = theme(outerTheme); | ||
warning(isObject(this.cachedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
} else { | ||
warning(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
this.cachedTheme = outerTheme ? _extends({}, outerTheme, theme) : theme; | ||
} | ||
} | ||
warning(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
return !outerTheme ? theme : _extends({}, outerTheme, theme); | ||
return this.cachedTheme; | ||
}; | ||
_proto.render = function render() { | ||
var _this = this; | ||
var children = this.props.children; | ||
@@ -114,11 +132,7 @@ | ||
return React.createElement(context.Consumer, null, function (outerTheme) { | ||
return React.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
return React__default.createElement(context.Consumer, null, this.renderProvider); | ||
}; | ||
return ThemeProvider; | ||
}(React.Component), _defineProperty(_class, "propTypes", { | ||
}(React__default.Component), _defineProperty(_class, "propTypes", { | ||
children: PropTypes.node, | ||
@@ -133,15 +147,12 @@ theme: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.func]).isRequired | ||
return function hoc(Component) { | ||
function withTheme(props) { | ||
var innerRef = props.innerRef, | ||
otherProps = _objectWithoutPropertiesLoose(props, ["innerRef"]); | ||
return React.createElement(context.Consumer, null, function (theme) { | ||
// $FlowFixMe | ||
var withTheme = React__default.forwardRef(function (props, ref) { | ||
return React__default.createElement(context.Consumer, null, function (theme) { | ||
warning(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
return React.createElement(Component, _extends({ | ||
return React__default.createElement(Component, _extends({ | ||
theme: theme, | ||
ref: innerRef | ||
}, otherProps)); | ||
ref: ref | ||
}, props)); | ||
}); | ||
} | ||
}); | ||
withTheme.displayName = "WithTheme(" + getDisplayName(Component) + ")"; | ||
@@ -153,3 +164,3 @@ hoist(withTheme, Component); | ||
var ThemeContext = createReactContext(); | ||
var ThemeContext = React.createContext(); | ||
@@ -156,0 +167,0 @@ function createTheming(context) { |
@@ -1,2 +0,2 @@ | ||
import React from 'react'; | ||
import React, { createContext } from 'react'; | ||
import warning from 'warning'; | ||
@@ -6,3 +6,2 @@ import PropTypes from 'prop-types'; | ||
import getDisplayName from 'react-display-name'; | ||
import createReactContext from 'create-react-context'; | ||
@@ -48,15 +47,8 @@ function _defineProperty(obj, key, value) { | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return target; | ||
return self; | ||
} | ||
@@ -77,3 +69,24 @@ | ||
function ThemeProvider() { | ||
return _React$Component.apply(this, arguments) || this; | ||
var _this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "cachedTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastOuterTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderProvider", function (outerTheme) { | ||
var children = _this.props.children; | ||
return React.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
return _this; | ||
} | ||
@@ -87,15 +100,19 @@ | ||
if (typeof theme === 'function') { | ||
var mergedTheme = theme(outerTheme); | ||
warning(isObject(mergedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
return mergedTheme; | ||
if (theme !== this.lastTheme || outerTheme !== this.lastOuterTheme || !this.cachedTheme) { | ||
this.lastOuterTheme = outerTheme; | ||
this.lastTheme = theme; | ||
if (typeof theme === 'function') { | ||
this.cachedTheme = theme(outerTheme); | ||
warning(isObject(this.cachedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
} else { | ||
warning(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
this.cachedTheme = outerTheme ? _extends({}, outerTheme, theme) : theme; | ||
} | ||
} | ||
warning(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
return !outerTheme ? theme : _extends({}, outerTheme, theme); | ||
return this.cachedTheme; | ||
}; | ||
_proto.render = function render() { | ||
var _this = this; | ||
var children = this.props.children; | ||
@@ -107,7 +124,3 @@ | ||
return React.createElement(context.Consumer, null, function (outerTheme) { | ||
return React.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
return React.createElement(context.Consumer, null, this.renderProvider); | ||
}; | ||
@@ -126,6 +139,4 @@ | ||
return function hoc(Component) { | ||
function withTheme(props) { | ||
var innerRef = props.innerRef, | ||
otherProps = _objectWithoutPropertiesLoose(props, ["innerRef"]); | ||
// $FlowFixMe | ||
var withTheme = React.forwardRef(function (props, ref) { | ||
return React.createElement(context.Consumer, null, function (theme) { | ||
@@ -135,7 +146,6 @@ warning(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
theme: theme, | ||
ref: innerRef | ||
}, otherProps)); | ||
ref: ref | ||
}, props)); | ||
}); | ||
} | ||
}); | ||
withTheme.displayName = "WithTheme(" + getDisplayName(Component) + ")"; | ||
@@ -147,3 +157,3 @@ hoist(withTheme, Component); | ||
var ThemeContext = createReactContext(); | ||
var ThemeContext = createContext(); | ||
@@ -150,0 +160,0 @@ function createTheming(context) { |
2647
dist/theming.js
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : | ||
(factory((global.theming = {}),global.react)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : | ||
(factory((global.theming = {}),global.react)); | ||
}(this, (function (exports,React) { 'use strict'; | ||
React = React && React.hasOwnProperty('default') ? React['default'] : React; | ||
var React__default = 'default' in React ? React['default'] : React; | ||
function unwrapExports (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
return obj; | ||
} | ||
/* | ||
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 _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
function toObject(val) { | ||
if (val === null || val === undefined) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return Object(val); | ||
} | ||
return target; | ||
}; | ||
function shouldUseNative() { | ||
try { | ||
if (!Object.assign) { | ||
return false; | ||
} | ||
return _extends.apply(this, arguments); | ||
} | ||
// Detect buggy property enumeration order in older V8 versions. | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
// 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; | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
// 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; | ||
} | ||
return self; | ||
} | ||
// 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; | ||
} | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
return true; | ||
} catch (err) { | ||
// We don't expect any of the above to throw, but better to be safe. | ||
return false; | ||
} | ||
} | ||
var warning = function() {}; | ||
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { | ||
var from; | ||
var to = toObject(target); | ||
var symbols; | ||
{ | ||
var printWarning = function printWarning(format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
} | ||
var argIndex = 0; | ||
var message = 'Warning: ' + | ||
format.replace(/%s/g, function() { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = Object(arguments[s]); | ||
warning = function(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
} | ||
if (format === undefined) { | ||
throw new Error( | ||
'`warning(condition, format, ...args)` requires a warning ' + | ||
'message argument' | ||
); | ||
} | ||
if (!condition) { | ||
printWarning.apply(null, [format].concat(args)); | ||
} | ||
}; | ||
} | ||
for (var key in from) { | ||
if (hasOwnProperty.call(from, key)) { | ||
to[key] = from[key]; | ||
} | ||
} | ||
var warning_1 = warning; | ||
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]]; | ||
} | ||
} | ||
} | ||
} | ||
function unwrapExports (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x; | ||
} | ||
return to; | ||
}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
/* | ||
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; | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
function toObject(val) { | ||
if (val === null || val === undefined) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
var ReactPropTypesSecret_1 = ReactPropTypesSecret; | ||
return Object(val); | ||
} | ||
var printWarning = function() {}; | ||
function shouldUseNative() { | ||
try { | ||
if (!Object.assign) { | ||
return false; | ||
} | ||
{ | ||
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1; | ||
var loggedTypeFailures = {}; | ||
// Detect buggy property enumeration order in older V8 versions. | ||
printWarning = function(text) { | ||
var message = 'Warning: ' + text; | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
} | ||
// 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; | ||
} | ||
/** | ||
* Assert that the values match with the type specs. | ||
* Error messages are memorized and will only be shown once. | ||
* | ||
* @param {object} typeSpecs Map of name to a ReactPropType | ||
* @param {object} values Runtime values that need to be type-checked | ||
* @param {string} location e.g. "prop", "context", "child context" | ||
* @param {string} componentName Name of the component for error messages. | ||
* @param {?Function} getStack Returns the component stack. | ||
* @private | ||
*/ | ||
function checkPropTypes(typeSpecs, values, location, componentName, getStack) { | ||
{ | ||
for (var typeSpecName in typeSpecs) { | ||
if (typeSpecs.hasOwnProperty(typeSpecName)) { | ||
var error; | ||
// Prop type validation may throw. In case they do, we don't want to | ||
// fail the render phase where it didn't fail before. So we log it. | ||
// After these have been cleaned up, we'll let them throw. | ||
try { | ||
// This is intentionally an invariant that gets caught. It's the same | ||
// behavior as without this statement except with a better message. | ||
if (typeof typeSpecs[typeSpecName] !== 'function') { | ||
var err = Error( | ||
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + | ||
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' | ||
); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} | ||
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1); | ||
} catch (ex) { | ||
error = ex; | ||
} | ||
if (error && !(error instanceof Error)) { | ||
printWarning( | ||
(componentName || 'React class') + ': type specification of ' + | ||
location + ' `' + typeSpecName + '` is invalid; the type checker ' + | ||
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + | ||
'You may have forgotten to pass an argument to the type checker ' + | ||
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + | ||
'shape all require an argument).' | ||
); | ||
// 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; | ||
} | ||
} | ||
if (error instanceof Error && !(error.message in loggedTypeFailures)) { | ||
// Only monitor this failure once because there tends to be a lot of the | ||
// same error. | ||
loggedTypeFailures[error.message] = true; | ||
// 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; | ||
} | ||
var stack = getStack ? getStack() : ''; | ||
return true; | ||
} catch (err) { | ||
// We don't expect any of the above to throw, but better to be safe. | ||
return false; | ||
} | ||
} | ||
printWarning( | ||
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { | ||
var from; | ||
var to = toObject(target); | ||
var symbols; | ||
var checkPropTypes_1 = checkPropTypes; | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = Object(arguments[s]); | ||
var printWarning$1 = function() {}; | ||
for (var key in from) { | ||
if (hasOwnProperty.call(from, key)) { | ||
to[key] = from[key]; | ||
} | ||
} | ||
{ | ||
printWarning$1 = function(text) { | ||
var message = 'Warning: ' + text; | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
} | ||
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]]; | ||
} | ||
} | ||
} | ||
} | ||
function emptyFunctionThatReturnsNull() { | ||
return null; | ||
} | ||
return to; | ||
}; | ||
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) { | ||
/* global Symbol */ | ||
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | ||
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
/** | ||
* Returns the iterator method function contained on the iterable object. | ||
* | ||
* Be sure to invoke the function with the iterable as context: | ||
* | ||
* var iteratorFn = getIteratorFn(myIterable); | ||
* if (iteratorFn) { | ||
* var iterator = iteratorFn.call(myIterable); | ||
* ... | ||
* } | ||
* | ||
* @param {?object} maybeIterable | ||
* @return {?function} | ||
*/ | ||
function getIteratorFn(maybeIterable) { | ||
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | ||
if (typeof iteratorFn === 'function') { | ||
return iteratorFn; | ||
} | ||
} | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
/** | ||
* Collection of methods that allow declaration and validation of props that are | ||
* supplied to React components. Example usage: | ||
* | ||
* var Props = require('ReactPropTypes'); | ||
* var MyArticle = React.createClass({ | ||
* propTypes: { | ||
* // An optional string prop named "description". | ||
* description: Props.string, | ||
* | ||
* // A required enum prop named "category". | ||
* category: Props.oneOf(['News','Photos']).isRequired, | ||
* | ||
* // A prop named "dialog" that requires an instance of Dialog. | ||
* dialog: Props.instanceOf(Dialog).isRequired | ||
* }, | ||
* render: function() { ... } | ||
* }); | ||
* | ||
* A more formal specification of how these methods are used: | ||
* | ||
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) | ||
* decl := ReactPropTypes.{type}(.isRequired)? | ||
* | ||
* Each and every declaration produces a function with the same signature. This | ||
* allows the creation of custom validation functions. For example: | ||
* | ||
* var MyLink = React.createClass({ | ||
* propTypes: { | ||
* // An optional string or URI prop named "href". | ||
* href: function(props, propName, componentName) { | ||
* var propValue = props[propName]; | ||
* if (propValue != null && typeof propValue !== 'string' && | ||
* !(propValue instanceof URI)) { | ||
* return new Error( | ||
* 'Expected a string or an URI for ' + propName + ' in ' + | ||
* componentName | ||
* ); | ||
* } | ||
* } | ||
* }, | ||
* render: function() {...} | ||
* }); | ||
* | ||
* @internal | ||
*/ | ||
var ReactPropTypesSecret_1 = ReactPropTypesSecret; | ||
var ANONYMOUS = '<<anonymous>>'; | ||
var printWarning$1 = function() {}; | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`. | ||
var ReactPropTypes = { | ||
array: createPrimitiveTypeChecker('array'), | ||
bool: createPrimitiveTypeChecker('boolean'), | ||
func: createPrimitiveTypeChecker('function'), | ||
number: createPrimitiveTypeChecker('number'), | ||
object: createPrimitiveTypeChecker('object'), | ||
string: createPrimitiveTypeChecker('string'), | ||
symbol: createPrimitiveTypeChecker('symbol'), | ||
{ | ||
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1; | ||
var loggedTypeFailures = {}; | ||
any: createAnyTypeChecker(), | ||
arrayOf: createArrayOfTypeChecker, | ||
element: createElementTypeChecker(), | ||
instanceOf: createInstanceTypeChecker, | ||
node: createNodeChecker(), | ||
objectOf: createObjectOfTypeChecker, | ||
oneOf: createEnumTypeChecker, | ||
oneOfType: createUnionTypeChecker, | ||
shape: createShapeTypeChecker, | ||
exact: createStrictShapeTypeChecker, | ||
}; | ||
printWarning$1 = function(text) { | ||
var message = 'Warning: ' + text; | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
} | ||
/** | ||
* inlined Object.is polyfill to avoid requiring consumers ship their own | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | ||
*/ | ||
/*eslint-disable no-self-compare*/ | ||
function is(x, y) { | ||
// SameValue algorithm | ||
if (x === y) { | ||
// Steps 1-5, 7-10 | ||
// Steps 6.b-6.e: +0 != -0 | ||
return x !== 0 || 1 / x === 1 / y; | ||
} else { | ||
// Step 6.a: NaN == NaN | ||
return x !== x && y !== y; | ||
} | ||
} | ||
/*eslint-enable no-self-compare*/ | ||
/** | ||
* Assert that the values match with the type specs. | ||
* Error messages are memorized and will only be shown once. | ||
* | ||
* @param {object} typeSpecs Map of name to a ReactPropType | ||
* @param {object} values Runtime values that need to be type-checked | ||
* @param {string} location e.g. "prop", "context", "child context" | ||
* @param {string} componentName Name of the component for error messages. | ||
* @param {?Function} getStack Returns the component stack. | ||
* @private | ||
*/ | ||
function checkPropTypes(typeSpecs, values, location, componentName, getStack) { | ||
{ | ||
for (var typeSpecName in typeSpecs) { | ||
if (typeSpecs.hasOwnProperty(typeSpecName)) { | ||
var error; | ||
// Prop type validation may throw. In case they do, we don't want to | ||
// fail the render phase where it didn't fail before. So we log it. | ||
// After these have been cleaned up, we'll let them throw. | ||
try { | ||
// This is intentionally an invariant that gets caught. It's the same | ||
// behavior as without this statement except with a better message. | ||
if (typeof typeSpecs[typeSpecName] !== 'function') { | ||
var err = Error( | ||
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + | ||
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' | ||
); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} | ||
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1); | ||
} catch (ex) { | ||
error = ex; | ||
} | ||
if (error && !(error instanceof Error)) { | ||
printWarning$1( | ||
(componentName || 'React class') + ': type specification of ' + | ||
location + ' `' + typeSpecName + '` is invalid; the type checker ' + | ||
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + | ||
'You may have forgotten to pass an argument to the type checker ' + | ||
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + | ||
'shape all require an argument).' | ||
); | ||
/** | ||
* We use an Error-like object for backward compatibility as people may call | ||
* PropTypes directly and inspect their output. However, we don't use real | ||
* Errors anymore. We don't inspect their stack anyway, and creating them | ||
* is prohibitively expensive if they are created too often, such as what | ||
* happens in oneOfType() for any type before the one that matched. | ||
*/ | ||
function PropTypeError(message) { | ||
this.message = message; | ||
this.stack = ''; | ||
} | ||
// Make `instanceof Error` still work for returned errors. | ||
PropTypeError.prototype = Error.prototype; | ||
} | ||
if (error instanceof Error && !(error.message in loggedTypeFailures)) { | ||
// Only monitor this failure once because there tends to be a lot of the | ||
// same error. | ||
loggedTypeFailures[error.message] = true; | ||
function createChainableTypeChecker(validate) { | ||
{ | ||
var manualPropTypeCallCache = {}; | ||
var manualPropTypeWarningCount = 0; | ||
} | ||
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { | ||
componentName = componentName || ANONYMOUS; | ||
propFullName = propFullName || propName; | ||
var stack = getStack ? getStack() : ''; | ||
if (secret !== ReactPropTypesSecret_1) { | ||
if (throwOnDirectAccess) { | ||
// New behavior only for users of `prop-types` package | ||
var err = new Error( | ||
'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' | ||
); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} else if (typeof console !== 'undefined') { | ||
// Old behavior for people using React.PropTypes | ||
var cacheKey = componentName + ':' + propName; | ||
if ( | ||
!manualPropTypeCallCache[cacheKey] && | ||
// Avoid spamming the console because they are often not actionable except for lib authors | ||
manualPropTypeWarningCount < 3 | ||
) { | ||
printWarning$1( | ||
'You are manually calling a React.PropTypes validation ' + | ||
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + | ||
'and will throw in the standalone `prop-types` package. ' + | ||
'You may be seeing this warning due to a third-party PropTypes ' + | ||
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' | ||
); | ||
manualPropTypeCallCache[cacheKey] = true; | ||
manualPropTypeWarningCount++; | ||
} | ||
} | ||
} | ||
if (props[propName] == null) { | ||
if (isRequired) { | ||
if (props[propName] === null) { | ||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); | ||
} | ||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); | ||
} | ||
return null; | ||
} else { | ||
return validate(props, propName, componentName, location, propFullName); | ||
} | ||
} | ||
printWarning$1( | ||
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
var chainedCheckType = checkType.bind(null, false); | ||
chainedCheckType.isRequired = checkType.bind(null, true); | ||
var checkPropTypes_1 = checkPropTypes; | ||
return chainedCheckType; | ||
} | ||
var printWarning$2 = function() {}; | ||
function createPrimitiveTypeChecker(expectedType) { | ||
function validate(props, propName, componentName, location, propFullName, secret) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== expectedType) { | ||
// `propValue` being instance of, say, date/regexp, pass the 'object' | ||
// check, but we can offer a more precise error message here rather than | ||
// 'of type `object`'. | ||
var preciseType = getPreciseType(propValue); | ||
{ | ||
printWarning$2 = function(text) { | ||
var message = 'Warning: ' + text; | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
} | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function emptyFunctionThatReturnsNull() { | ||
return null; | ||
} | ||
function createAnyTypeChecker() { | ||
return createChainableTypeChecker(emptyFunctionThatReturnsNull); | ||
} | ||
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) { | ||
/* global Symbol */ | ||
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | ||
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | ||
function createArrayOfTypeChecker(typeChecker) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (typeof typeChecker !== 'function') { | ||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); | ||
} | ||
var propValue = props[propName]; | ||
if (!Array.isArray(propValue)) { | ||
var propType = getPropType(propValue); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); | ||
} | ||
for (var i = 0; i < propValue.length; i++) { | ||
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1); | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
/** | ||
* Returns the iterator method function contained on the iterable object. | ||
* | ||
* Be sure to invoke the function with the iterable as context: | ||
* | ||
* var iteratorFn = getIteratorFn(myIterable); | ||
* if (iteratorFn) { | ||
* var iterator = iteratorFn.call(myIterable); | ||
* ... | ||
* } | ||
* | ||
* @param {?object} maybeIterable | ||
* @return {?function} | ||
*/ | ||
function getIteratorFn(maybeIterable) { | ||
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | ||
if (typeof iteratorFn === 'function') { | ||
return iteratorFn; | ||
} | ||
} | ||
function createElementTypeChecker() { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
if (!isValidElement(propValue)) { | ||
var propType = getPropType(propValue); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
/** | ||
* Collection of methods that allow declaration and validation of props that are | ||
* supplied to React components. Example usage: | ||
* | ||
* var Props = require('ReactPropTypes'); | ||
* var MyArticle = React.createClass({ | ||
* propTypes: { | ||
* // An optional string prop named "description". | ||
* description: Props.string, | ||
* | ||
* // A required enum prop named "category". | ||
* category: Props.oneOf(['News','Photos']).isRequired, | ||
* | ||
* // A prop named "dialog" that requires an instance of Dialog. | ||
* dialog: Props.instanceOf(Dialog).isRequired | ||
* }, | ||
* render: function() { ... } | ||
* }); | ||
* | ||
* A more formal specification of how these methods are used: | ||
* | ||
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) | ||
* decl := ReactPropTypes.{type}(.isRequired)? | ||
* | ||
* Each and every declaration produces a function with the same signature. This | ||
* allows the creation of custom validation functions. For example: | ||
* | ||
* var MyLink = React.createClass({ | ||
* propTypes: { | ||
* // An optional string or URI prop named "href". | ||
* href: function(props, propName, componentName) { | ||
* var propValue = props[propName]; | ||
* if (propValue != null && typeof propValue !== 'string' && | ||
* !(propValue instanceof URI)) { | ||
* return new Error( | ||
* 'Expected a string or an URI for ' + propName + ' in ' + | ||
* componentName | ||
* ); | ||
* } | ||
* } | ||
* }, | ||
* render: function() {...} | ||
* }); | ||
* | ||
* @internal | ||
*/ | ||
function createInstanceTypeChecker(expectedClass) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (!(props[propName] instanceof expectedClass)) { | ||
var expectedClassName = expectedClass.name || ANONYMOUS; | ||
var actualClassName = getClassName(props[propName]); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
var ANONYMOUS = '<<anonymous>>'; | ||
function createEnumTypeChecker(expectedValues) { | ||
if (!Array.isArray(expectedValues)) { | ||
printWarning$1('Invalid argument supplied to oneOf, expected an instance of array.'); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
// Important! | ||
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`. | ||
var ReactPropTypes = { | ||
array: createPrimitiveTypeChecker('array'), | ||
bool: createPrimitiveTypeChecker('boolean'), | ||
func: createPrimitiveTypeChecker('function'), | ||
number: createPrimitiveTypeChecker('number'), | ||
object: createPrimitiveTypeChecker('object'), | ||
string: createPrimitiveTypeChecker('string'), | ||
symbol: createPrimitiveTypeChecker('symbol'), | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
for (var i = 0; i < expectedValues.length; i++) { | ||
if (is(propValue, expectedValues[i])) { | ||
return null; | ||
} | ||
} | ||
any: createAnyTypeChecker(), | ||
arrayOf: createArrayOfTypeChecker, | ||
element: createElementTypeChecker(), | ||
instanceOf: createInstanceTypeChecker, | ||
node: createNodeChecker(), | ||
objectOf: createObjectOfTypeChecker, | ||
oneOf: createEnumTypeChecker, | ||
oneOfType: createUnionTypeChecker, | ||
shape: createShapeTypeChecker, | ||
exact: createStrictShapeTypeChecker, | ||
}; | ||
var valuesString = JSON.stringify(expectedValues); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
/** | ||
* inlined Object.is polyfill to avoid requiring consumers ship their own | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | ||
*/ | ||
/*eslint-disable no-self-compare*/ | ||
function is(x, y) { | ||
// SameValue algorithm | ||
if (x === y) { | ||
// Steps 1-5, 7-10 | ||
// Steps 6.b-6.e: +0 != -0 | ||
return x !== 0 || 1 / x === 1 / y; | ||
} else { | ||
// Step 6.a: NaN == NaN | ||
return x !== x && y !== y; | ||
} | ||
} | ||
/*eslint-enable no-self-compare*/ | ||
function createObjectOfTypeChecker(typeChecker) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (typeof typeChecker !== 'function') { | ||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); | ||
} | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); | ||
} | ||
for (var key in propValue) { | ||
if (propValue.hasOwnProperty(key)) { | ||
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
/** | ||
* We use an Error-like object for backward compatibility as people may call | ||
* PropTypes directly and inspect their output. However, we don't use real | ||
* Errors anymore. We don't inspect their stack anyway, and creating them | ||
* is prohibitively expensive if they are created too often, such as what | ||
* happens in oneOfType() for any type before the one that matched. | ||
*/ | ||
function PropTypeError(message) { | ||
this.message = message; | ||
this.stack = ''; | ||
} | ||
// Make `instanceof Error` still work for returned errors. | ||
PropTypeError.prototype = Error.prototype; | ||
function createUnionTypeChecker(arrayOfTypeCheckers) { | ||
if (!Array.isArray(arrayOfTypeCheckers)) { | ||
printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.'); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
function createChainableTypeChecker(validate) { | ||
{ | ||
var manualPropTypeCallCache = {}; | ||
var manualPropTypeWarningCount = 0; | ||
} | ||
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { | ||
componentName = componentName || ANONYMOUS; | ||
propFullName = propFullName || propName; | ||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
var checker = arrayOfTypeCheckers[i]; | ||
if (typeof checker !== 'function') { | ||
printWarning$1( | ||
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + | ||
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' | ||
); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
} | ||
if (secret !== ReactPropTypesSecret_1) { | ||
if (throwOnDirectAccess) { | ||
// New behavior only for users of `prop-types` package | ||
var err = new Error( | ||
'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' | ||
); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} else if (typeof console !== 'undefined') { | ||
// Old behavior for people using React.PropTypes | ||
var cacheKey = componentName + ':' + propName; | ||
if ( | ||
!manualPropTypeCallCache[cacheKey] && | ||
// Avoid spamming the console because they are often not actionable except for lib authors | ||
manualPropTypeWarningCount < 3 | ||
) { | ||
printWarning$2( | ||
'You are manually calling a React.PropTypes validation ' + | ||
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + | ||
'and will throw in the standalone `prop-types` package. ' + | ||
'You may be seeing this warning due to a third-party PropTypes ' + | ||
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' | ||
); | ||
manualPropTypeCallCache[cacheKey] = true; | ||
manualPropTypeWarningCount++; | ||
} | ||
} | ||
} | ||
if (props[propName] == null) { | ||
if (isRequired) { | ||
if (props[propName] === null) { | ||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); | ||
} | ||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); | ||
} | ||
return null; | ||
} else { | ||
return validate(props, propName, componentName, location, propFullName); | ||
} | ||
} | ||
function validate(props, propName, componentName, location, propFullName) { | ||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
var checker = arrayOfTypeCheckers[i]; | ||
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) { | ||
return null; | ||
} | ||
} | ||
var chainedCheckType = checkType.bind(null, false); | ||
chainedCheckType.isRequired = checkType.bind(null, true); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
return chainedCheckType; | ||
} | ||
function createNodeChecker() { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (!isNode(props[propName])) { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function createPrimitiveTypeChecker(expectedType) { | ||
function validate(props, propName, componentName, location, propFullName, secret) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== expectedType) { | ||
// `propValue` being instance of, say, date/regexp, pass the 'object' | ||
// check, but we can offer a more precise error message here rather than | ||
// 'of type `object`'. | ||
var preciseType = getPreciseType(propValue); | ||
function createShapeTypeChecker(shapeTypes) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
} | ||
for (var key in shapeTypes) { | ||
var checker = shapeTypes[key]; | ||
if (!checker) { | ||
continue; | ||
} | ||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function createStrictShapeTypeChecker(shapeTypes) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
} | ||
// We need to check all keys in case some are required but missing from | ||
// props. | ||
var allKeys = objectAssign({}, props[propName], shapeTypes); | ||
for (var key in allKeys) { | ||
var checker = shapeTypes[key]; | ||
if (!checker) { | ||
return new PropTypeError( | ||
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + | ||
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') + | ||
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') | ||
); | ||
} | ||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
function createAnyTypeChecker() { | ||
return createChainableTypeChecker(emptyFunctionThatReturnsNull); | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function createArrayOfTypeChecker(typeChecker) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (typeof typeChecker !== 'function') { | ||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); | ||
} | ||
var propValue = props[propName]; | ||
if (!Array.isArray(propValue)) { | ||
var propType = getPropType(propValue); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); | ||
} | ||
for (var i = 0; i < propValue.length; i++) { | ||
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1); | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
function isNode(propValue) { | ||
switch (typeof propValue) { | ||
case 'number': | ||
case 'string': | ||
case 'undefined': | ||
return true; | ||
case 'boolean': | ||
return !propValue; | ||
case 'object': | ||
if (Array.isArray(propValue)) { | ||
return propValue.every(isNode); | ||
} | ||
if (propValue === null || isValidElement(propValue)) { | ||
return true; | ||
} | ||
function createElementTypeChecker() { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
if (!isValidElement(propValue)) { | ||
var propType = getPropType(propValue); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
var iteratorFn = getIteratorFn(propValue); | ||
if (iteratorFn) { | ||
var iterator = iteratorFn.call(propValue); | ||
var step; | ||
if (iteratorFn !== propValue.entries) { | ||
while (!(step = iterator.next()).done) { | ||
if (!isNode(step.value)) { | ||
return false; | ||
} | ||
} | ||
} else { | ||
// Iterator will provide entry [k,v] tuples rather than values. | ||
while (!(step = iterator.next()).done) { | ||
var entry = step.value; | ||
if (entry) { | ||
if (!isNode(entry[1])) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
return false; | ||
} | ||
function createInstanceTypeChecker(expectedClass) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (!(props[propName] instanceof expectedClass)) { | ||
var expectedClassName = expectedClass.name || ANONYMOUS; | ||
var actualClassName = getClassName(props[propName]); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
function createEnumTypeChecker(expectedValues) { | ||
if (!Array.isArray(expectedValues)) { | ||
printWarning$2('Invalid argument supplied to oneOf, expected an instance of array.'); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
function isSymbol(propType, propValue) { | ||
// Native Symbol. | ||
if (propType === 'symbol') { | ||
return true; | ||
} | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
for (var i = 0; i < expectedValues.length; i++) { | ||
if (is(propValue, expectedValues[i])) { | ||
return null; | ||
} | ||
} | ||
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' | ||
if (propValue['@@toStringTag'] === 'Symbol') { | ||
return true; | ||
} | ||
var valuesString = JSON.stringify(expectedValues); | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
// Fallback for non-spec compliant Symbols which are polyfilled. | ||
if (typeof Symbol === 'function' && propValue instanceof Symbol) { | ||
return true; | ||
} | ||
function createObjectOfTypeChecker(typeChecker) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (typeof typeChecker !== 'function') { | ||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); | ||
} | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); | ||
} | ||
for (var key in propValue) { | ||
if (propValue.hasOwnProperty(key)) { | ||
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
return false; | ||
} | ||
function createUnionTypeChecker(arrayOfTypeCheckers) { | ||
if (!Array.isArray(arrayOfTypeCheckers)) { | ||
printWarning$2('Invalid argument supplied to oneOfType, expected an instance of array.'); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
// Equivalent of `typeof` but with special handling for array and regexp. | ||
function getPropType(propValue) { | ||
var propType = typeof propValue; | ||
if (Array.isArray(propValue)) { | ||
return 'array'; | ||
} | ||
if (propValue instanceof RegExp) { | ||
// Old webkits (at least until Android 4.0) return 'function' rather than | ||
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/ | ||
// passes PropTypes.object. | ||
return 'object'; | ||
} | ||
if (isSymbol(propType, propValue)) { | ||
return 'symbol'; | ||
} | ||
return propType; | ||
} | ||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
var checker = arrayOfTypeCheckers[i]; | ||
if (typeof checker !== 'function') { | ||
printWarning$2( | ||
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + | ||
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' | ||
); | ||
return emptyFunctionThatReturnsNull; | ||
} | ||
} | ||
// This handles more types than `getPropType`. Only used for error messages. | ||
// See `createPrimitiveTypeChecker`. | ||
function getPreciseType(propValue) { | ||
if (typeof propValue === 'undefined' || propValue === null) { | ||
return '' + propValue; | ||
} | ||
var propType = getPropType(propValue); | ||
if (propType === 'object') { | ||
if (propValue instanceof Date) { | ||
return 'date'; | ||
} else if (propValue instanceof RegExp) { | ||
return 'regexp'; | ||
} | ||
} | ||
return propType; | ||
} | ||
function validate(props, propName, componentName, location, propFullName) { | ||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
var checker = arrayOfTypeCheckers[i]; | ||
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) { | ||
return null; | ||
} | ||
} | ||
// Returns a string that is postfixed to a warning about an invalid type. | ||
// For example, "undefined" or "of type array" | ||
function getPostfixForTypeWarning(value) { | ||
var type = getPreciseType(value); | ||
switch (type) { | ||
case 'array': | ||
case 'object': | ||
return 'an ' + type; | ||
case 'boolean': | ||
case 'date': | ||
case 'regexp': | ||
return 'a ' + type; | ||
default: | ||
return type; | ||
} | ||
} | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
// Returns class name of the object, if any. | ||
function getClassName(propValue) { | ||
if (!propValue.constructor || !propValue.constructor.name) { | ||
return ANONYMOUS; | ||
} | ||
return propValue.constructor.name; | ||
} | ||
function createNodeChecker() { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
if (!isNode(props[propName])) { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
ReactPropTypes.checkPropTypes = checkPropTypes_1; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
function createShapeTypeChecker(shapeTypes) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
} | ||
for (var key in shapeTypes) { | ||
var checker = shapeTypes[key]; | ||
if (!checker) { | ||
continue; | ||
} | ||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
return createChainableTypeChecker(validate); | ||
} | ||
return ReactPropTypes; | ||
}; | ||
function createStrictShapeTypeChecker(shapeTypes) { | ||
function validate(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var propType = getPropType(propValue); | ||
if (propType !== 'object') { | ||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
} | ||
// We need to check all keys in case some are required but missing from | ||
// props. | ||
var allKeys = objectAssign({}, props[propName], shapeTypes); | ||
for (var key in allKeys) { | ||
var checker = shapeTypes[key]; | ||
if (!checker) { | ||
return new PropTypeError( | ||
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + | ||
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') + | ||
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') | ||
); | ||
} | ||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1); | ||
if (error) { | ||
return error; | ||
} | ||
} | ||
return null; | ||
} | ||
var propTypes = createCommonjsModule(function (module) { | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
return createChainableTypeChecker(validate); | ||
} | ||
{ | ||
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && | ||
Symbol.for && | ||
Symbol.for('react.element')) || | ||
0xeac7; | ||
function isNode(propValue) { | ||
switch (typeof propValue) { | ||
case 'number': | ||
case 'string': | ||
case 'undefined': | ||
return true; | ||
case 'boolean': | ||
return !propValue; | ||
case 'object': | ||
if (Array.isArray(propValue)) { | ||
return propValue.every(isNode); | ||
} | ||
if (propValue === null || isValidElement(propValue)) { | ||
return true; | ||
} | ||
var isValidElement = function(object) { | ||
return typeof object === 'object' && | ||
object !== null && | ||
object.$$typeof === REACT_ELEMENT_TYPE; | ||
}; | ||
var iteratorFn = getIteratorFn(propValue); | ||
if (iteratorFn) { | ||
var iterator = iteratorFn.call(propValue); | ||
var step; | ||
if (iteratorFn !== propValue.entries) { | ||
while (!(step = iterator.next()).done) { | ||
if (!isNode(step.value)) { | ||
return false; | ||
} | ||
} | ||
} else { | ||
// Iterator will provide entry [k,v] tuples rather than values. | ||
while (!(step = iterator.next()).done) { | ||
var entry = step.value; | ||
if (entry) { | ||
if (!isNode(entry[1])) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
return false; | ||
} | ||
// By explicitly using `prop-types` you are opting into new development behavior. | ||
// http://fb.me/prop-types-in-prod | ||
var throwOnDirectAccess = true; | ||
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess); | ||
} | ||
}); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
var global$1 = (typeof global !== "undefined" ? global : | ||
typeof self !== "undefined" ? self : | ||
typeof window !== "undefined" ? window : {}); | ||
function isSymbol(propType, propValue) { | ||
// Native Symbol. | ||
if (propType === 'symbol') { | ||
return true; | ||
} | ||
var key = '__global_unique_id__'; | ||
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' | ||
if (propValue['@@toStringTag'] === 'Symbol') { | ||
return true; | ||
} | ||
var gud = function() { | ||
return global$1[key] = (global$1[key] || 0) + 1; | ||
}; | ||
// Fallback for non-spec compliant Symbols which are polyfilled. | ||
if (typeof Symbol === 'function' && propValue instanceof Symbol) { | ||
return true; | ||
} | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
*/ | ||
return false; | ||
} | ||
function makeEmptyFunction(arg) { | ||
return function () { | ||
return arg; | ||
}; | ||
} | ||
// Equivalent of `typeof` but with special handling for array and regexp. | ||
function getPropType(propValue) { | ||
var propType = typeof propValue; | ||
if (Array.isArray(propValue)) { | ||
return 'array'; | ||
} | ||
if (propValue instanceof RegExp) { | ||
// Old webkits (at least until Android 4.0) return 'function' rather than | ||
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/ | ||
// passes PropTypes.object. | ||
return 'object'; | ||
} | ||
if (isSymbol(propType, propValue)) { | ||
return 'symbol'; | ||
} | ||
return propType; | ||
} | ||
/** | ||
* This function accepts and discards inputs; it has no side effects. This is | ||
* primarily useful idiomatically for overridable function endpoints which | ||
* always need to be callable, since JS lacks a null-call idiom ala Cocoa. | ||
*/ | ||
var emptyFunction$1 = function emptyFunction() {}; | ||
// This handles more types than `getPropType`. Only used for error messages. | ||
// See `createPrimitiveTypeChecker`. | ||
function getPreciseType(propValue) { | ||
if (typeof propValue === 'undefined' || propValue === null) { | ||
return '' + propValue; | ||
} | ||
var propType = getPropType(propValue); | ||
if (propType === 'object') { | ||
if (propValue instanceof Date) { | ||
return 'date'; | ||
} else if (propValue instanceof RegExp) { | ||
return 'regexp'; | ||
} | ||
} | ||
return propType; | ||
} | ||
emptyFunction$1.thatReturns = makeEmptyFunction; | ||
emptyFunction$1.thatReturnsFalse = makeEmptyFunction(false); | ||
emptyFunction$1.thatReturnsTrue = makeEmptyFunction(true); | ||
emptyFunction$1.thatReturnsNull = makeEmptyFunction(null); | ||
emptyFunction$1.thatReturnsThis = function () { | ||
return this; | ||
}; | ||
emptyFunction$1.thatReturnsArgument = function (arg) { | ||
return arg; | ||
}; | ||
// Returns a string that is postfixed to a warning about an invalid type. | ||
// For example, "undefined" or "of type array" | ||
function getPostfixForTypeWarning(value) { | ||
var type = getPreciseType(value); | ||
switch (type) { | ||
case 'array': | ||
case 'object': | ||
return 'an ' + type; | ||
case 'boolean': | ||
case 'date': | ||
case 'regexp': | ||
return 'a ' + type; | ||
default: | ||
return type; | ||
} | ||
} | ||
var emptyFunction_1 = emptyFunction$1; | ||
// Returns class name of the object, if any. | ||
function getClassName(propValue) { | ||
if (!propValue.constructor || !propValue.constructor.name) { | ||
return ANONYMOUS; | ||
} | ||
return propValue.constructor.name; | ||
} | ||
/** | ||
* 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. | ||
*/ | ||
ReactPropTypes.checkPropTypes = checkPropTypes_1; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
var warning = emptyFunction_1; | ||
return ReactPropTypes; | ||
}; | ||
{ | ||
var printWarning$2 = function printWarning(format) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
var propTypes = createCommonjsModule(function (module) { | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
{ | ||
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && | ||
Symbol.for && | ||
Symbol.for('react.element')) || | ||
0xeac7; | ||
warning = function warning(condition, format) { | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
var isValidElement = function(object) { | ||
return typeof object === 'object' && | ||
object !== null && | ||
object.$$typeof === REACT_ELEMENT_TYPE; | ||
}; | ||
if (format.indexOf('Failed Composite propType: ') === 0) { | ||
return; // Ignore CompositeComponent proptype check. | ||
} | ||
// By explicitly using `prop-types` you are opting into new development behavior. | ||
// http://fb.me/prop-types-in-prod | ||
var throwOnDirectAccess = true; | ||
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess); | ||
} | ||
}); | ||
if (!condition) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
function isObject(obj) { | ||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj); | ||
} | ||
printWarning$2.apply(undefined, [format].concat(args)); | ||
} | ||
}; | ||
} | ||
function createThemeProvider(context) { | ||
var _class, _temp; | ||
var warning_1 = warning; | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inheritsLoose(ThemeProvider, _React$Component); | ||
var implementation = createCommonjsModule(function (module, exports) { | ||
function ThemeProvider() { | ||
var _this; | ||
exports.__esModule = true; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "cachedTheme", void 0); | ||
var _react2 = _interopRequireDefault(React); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastOuterTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lastTheme", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderProvider", function (outerTheme) { | ||
var children = _this.props.children; | ||
return React__default.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
var _propTypes2 = _interopRequireDefault(propTypes); | ||
return _this; | ||
} | ||
var _proto = ThemeProvider.prototype; | ||
// Get the theme from the props, supporting both (outerTheme) => {} as well as object notation | ||
_proto.getTheme = function getTheme(outerTheme) { | ||
var theme = this.props.theme; | ||
var _gud2 = _interopRequireDefault(gud); | ||
if (theme !== this.lastTheme || outerTheme !== this.lastOuterTheme || !this.cachedTheme) { | ||
this.lastOuterTheme = outerTheme; | ||
this.lastTheme = theme; | ||
if (typeof theme === 'function') { | ||
this.cachedTheme = theme(outerTheme); | ||
warning_1(isObject(this.cachedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
} else { | ||
warning_1(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
this.cachedTheme = outerTheme ? _extends({}, outerTheme, theme) : theme; | ||
} | ||
} | ||
return this.cachedTheme; | ||
}; | ||
var _warning2 = _interopRequireDefault(warning_1); | ||
_proto.render = function render() { | ||
var children = this.props.children; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
if (!children) { | ||
return null; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
return React__default.createElement(context.Consumer, null, this.renderProvider); | ||
}; | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
return ThemeProvider; | ||
}(React__default.Component), _defineProperty(_class, "propTypes", { | ||
children: propTypes.node, | ||
theme: propTypes.oneOfType([propTypes.shape({}), propTypes.func]).isRequired | ||
}), _defineProperty(_class, "defaultProps", { | ||
children: null | ||
}), _temp; | ||
} | ||
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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var reactIs_production_min = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports,"__esModule",{value:!0}); | ||
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.concurrent_mode"):60111,m=b?Symbol.for("react.forward_ref"):60112,n=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):60115,r=b?Symbol.for("react.lazy"): | ||
60116;function t(a){if("object"===typeof a&&null!==a){var p=a.$$typeof;switch(p){case c:switch(a=a.type,a){case l:case e:case g:case f:return a;default:switch(a=a&&a.$$typeof,a){case k:case m:case h:return a;default:return p}}case d:return p}}}function u(a){return t(a)===l}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=l;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=m;exports.Fragment=e;exports.Profiler=g;exports.Portal=d; | ||
exports.StrictMode=f;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===l||a===g||a===f||a===n||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===m)};exports.isAsyncMode=function(a){return u(a)};exports.isConcurrentMode=u;exports.isContextConsumer=function(a){return t(a)===k};exports.isContextProvider=function(a){return t(a)===h}; | ||
exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===m};exports.isFragment=function(a){return t(a)===e};exports.isProfiler=function(a){return t(a)===g};exports.isPortal=function(a){return t(a)===d};exports.isStrictMode=function(a){return t(a)===f}; | ||
}); | ||
var MAX_SIGNED_31_BIT_INT = 1073741823; | ||
unwrapExports(reactIs_production_min); | ||
var reactIs_production_min_1 = reactIs_production_min.typeOf; | ||
var reactIs_production_min_2 = reactIs_production_min.AsyncMode; | ||
var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode; | ||
var reactIs_production_min_4 = reactIs_production_min.ContextConsumer; | ||
var reactIs_production_min_5 = reactIs_production_min.ContextProvider; | ||
var reactIs_production_min_6 = reactIs_production_min.Element; | ||
var reactIs_production_min_7 = reactIs_production_min.ForwardRef; | ||
var reactIs_production_min_8 = reactIs_production_min.Fragment; | ||
var reactIs_production_min_9 = reactIs_production_min.Profiler; | ||
var reactIs_production_min_10 = reactIs_production_min.Portal; | ||
var reactIs_production_min_11 = reactIs_production_min.StrictMode; | ||
var reactIs_production_min_12 = reactIs_production_min.isValidElementType; | ||
var reactIs_production_min_13 = reactIs_production_min.isAsyncMode; | ||
var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode; | ||
var reactIs_production_min_15 = reactIs_production_min.isContextConsumer; | ||
var reactIs_production_min_16 = reactIs_production_min.isContextProvider; | ||
var reactIs_production_min_17 = reactIs_production_min.isElement; | ||
var reactIs_production_min_18 = reactIs_production_min.isForwardRef; | ||
var reactIs_production_min_19 = reactIs_production_min.isFragment; | ||
var reactIs_production_min_20 = reactIs_production_min.isProfiler; | ||
var reactIs_production_min_21 = reactIs_production_min.isPortal; | ||
var reactIs_production_min_22 = reactIs_production_min.isStrictMode; | ||
// Inlined Object.is polyfill. | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | ||
function objectIs(x, y) { | ||
if (x === y) { | ||
return x !== 0 || 1 / x === 1 / y; | ||
} else { | ||
return x !== x && y !== y; | ||
} | ||
} | ||
var reactIs_development = createCommonjsModule(function (module, exports) { | ||
function createEventEmitter(value) { | ||
var handlers = []; | ||
return { | ||
on: function on(handler) { | ||
handlers.push(handler); | ||
}, | ||
off: function off(handler) { | ||
handlers = handlers.filter(function (h) { | ||
return h !== handler; | ||
}); | ||
}, | ||
get: function get() { | ||
return value; | ||
}, | ||
set: function set(newValue, changedBits) { | ||
value = newValue; | ||
handlers.forEach(function (handler) { | ||
return handler(value, changedBits); | ||
}); | ||
} | ||
}; | ||
} | ||
function onlyChild(children) { | ||
return Array.isArray(children) ? children[0] : children; | ||
} | ||
function createReactContext(defaultValue, calculateChangedBits) { | ||
var _Provider$childContex, _Consumer$contextType; | ||
{ | ||
(function() { | ||
var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var Provider = function (_Component) { | ||
_inherits(Provider, _Component); | ||
// 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; | ||
function Provider() { | ||
var _temp, _this, _ret; | ||
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; | ||
_classCallCheck(this, Provider); | ||
function isValidElementType(type) { | ||
return typeof type === 'string' || typeof type === 'function' || | ||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. | ||
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); | ||
} | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
/** | ||
* 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. | ||
*/ | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
var lowPriorityWarning = function () {}; | ||
Provider.prototype.getChildContext = function getChildContext() { | ||
var _ref; | ||
{ | ||
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]; | ||
} | ||
return _ref = {}, _ref[contextProp] = this.emitter, _ref; | ||
}; | ||
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) {} | ||
}; | ||
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
if (this.props.value !== nextProps.value) { | ||
var oldValue = this.props.value; | ||
var newValue = nextProps.value; | ||
var changedBits = void 0; | ||
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]; | ||
} | ||
if (objectIs(oldValue, newValue)) { | ||
changedBits = 0; // No change | ||
} else { | ||
changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; | ||
{ | ||
(0, _warning2.default)((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); | ||
} | ||
printWarning.apply(undefined, [format].concat(args)); | ||
} | ||
}; | ||
} | ||
changedBits |= 0; | ||
var lowPriorityWarning$1 = lowPriorityWarning; | ||
if (changedBits !== 0) { | ||
this.emitter.set(nextProps.value, changedBits); | ||
} | ||
} | ||
} | ||
}; | ||
function typeOf(object) { | ||
if (typeof object === 'object' && object !== null) { | ||
var $$typeof = object.$$typeof; | ||
Provider.prototype.render = function render() { | ||
return this.props.children; | ||
}; | ||
switch ($$typeof) { | ||
case REACT_ELEMENT_TYPE: | ||
var type = object.type; | ||
return Provider; | ||
}(React.Component); | ||
switch (type) { | ||
case REACT_CONCURRENT_MODE_TYPE: | ||
case REACT_FRAGMENT_TYPE: | ||
case REACT_PROFILER_TYPE: | ||
case REACT_STRICT_MODE_TYPE: | ||
return type; | ||
default: | ||
var $$typeofType = type && type.$$typeof; | ||
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex); | ||
switch ($$typeofType) { | ||
case REACT_CONTEXT_TYPE: | ||
case REACT_FORWARD_REF_TYPE: | ||
case REACT_PROVIDER_TYPE: | ||
return $$typeofType; | ||
default: | ||
return $$typeof; | ||
} | ||
} | ||
case REACT_PORTAL_TYPE: | ||
return $$typeof; | ||
} | ||
} | ||
var Consumer = function (_Component2) { | ||
_inherits(Consumer, _Component2); | ||
return undefined; | ||
} | ||
function Consumer() { | ||
var _temp2, _this2, _ret2; | ||
// AsyncMode alias is deprecated along with isAsyncMode | ||
var AsyncMode = REACT_CONCURRENT_MODE_TYPE; | ||
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; | ||
var ContextConsumer = REACT_CONTEXT_TYPE; | ||
var ContextProvider = REACT_PROVIDER_TYPE; | ||
var Element = REACT_ELEMENT_TYPE; | ||
var ForwardRef = REACT_FORWARD_REF_TYPE; | ||
var Fragment = REACT_FRAGMENT_TYPE; | ||
var Profiler = REACT_PROFILER_TYPE; | ||
var Portal = REACT_PORTAL_TYPE; | ||
var StrictMode = REACT_STRICT_MODE_TYPE; | ||
_classCallCheck(this, Consumer); | ||
var hasWarnedAboutDeprecatedIsAsyncMode = false; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
// AsyncMode should be deprecated | ||
function isAsyncMode(object) { | ||
{ | ||
if (!hasWarnedAboutDeprecatedIsAsyncMode) { | ||
hasWarnedAboutDeprecatedIsAsyncMode = true; | ||
lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); | ||
} | ||
} | ||
return isConcurrentMode(object); | ||
} | ||
function isConcurrentMode(object) { | ||
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; | ||
} | ||
function isContextConsumer(object) { | ||
return typeOf(object) === REACT_CONTEXT_TYPE; | ||
} | ||
function isContextProvider(object) { | ||
return typeOf(object) === REACT_PROVIDER_TYPE; | ||
} | ||
function isElement(object) { | ||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; | ||
} | ||
function isForwardRef(object) { | ||
return typeOf(object) === REACT_FORWARD_REF_TYPE; | ||
} | ||
function isFragment(object) { | ||
return typeOf(object) === REACT_FRAGMENT_TYPE; | ||
} | ||
function isProfiler(object) { | ||
return typeOf(object) === REACT_PROFILER_TYPE; | ||
} | ||
function isPortal(object) { | ||
return typeOf(object) === REACT_PORTAL_TYPE; | ||
} | ||
function isStrictMode(object) { | ||
return typeOf(object) === REACT_STRICT_MODE_TYPE; | ||
} | ||
return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.state = { | ||
value: _this2.getValue() | ||
}, _this2.onUpdate = function (newValue, changedBits) { | ||
var observedBits = _this2.observedBits | 0; | ||
if ((observedBits & changedBits) !== 0) { | ||
_this2.setState({ value: _this2.getValue() }); | ||
} | ||
}, _temp2), _possibleConstructorReturn(_this2, _ret2); | ||
} | ||
exports.typeOf = typeOf; | ||
exports.AsyncMode = AsyncMode; | ||
exports.ConcurrentMode = ConcurrentMode; | ||
exports.ContextConsumer = ContextConsumer; | ||
exports.ContextProvider = ContextProvider; | ||
exports.Element = Element; | ||
exports.ForwardRef = ForwardRef; | ||
exports.Fragment = Fragment; | ||
exports.Profiler = Profiler; | ||
exports.Portal = Portal; | ||
exports.StrictMode = StrictMode; | ||
exports.isValidElementType = isValidElementType; | ||
exports.isAsyncMode = isAsyncMode; | ||
exports.isConcurrentMode = isConcurrentMode; | ||
exports.isContextConsumer = isContextConsumer; | ||
exports.isContextProvider = isContextProvider; | ||
exports.isElement = isElement; | ||
exports.isForwardRef = isForwardRef; | ||
exports.isFragment = isFragment; | ||
exports.isProfiler = isProfiler; | ||
exports.isPortal = isPortal; | ||
exports.isStrictMode = isStrictMode; | ||
})(); | ||
} | ||
}); | ||
Consumer.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var observedBits = nextProps.observedBits; | ||
unwrapExports(reactIs_development); | ||
var reactIs_development_1 = reactIs_development.typeOf; | ||
var reactIs_development_2 = reactIs_development.AsyncMode; | ||
var reactIs_development_3 = reactIs_development.ConcurrentMode; | ||
var reactIs_development_4 = reactIs_development.ContextConsumer; | ||
var reactIs_development_5 = reactIs_development.ContextProvider; | ||
var reactIs_development_6 = reactIs_development.Element; | ||
var reactIs_development_7 = reactIs_development.ForwardRef; | ||
var reactIs_development_8 = reactIs_development.Fragment; | ||
var reactIs_development_9 = reactIs_development.Profiler; | ||
var reactIs_development_10 = reactIs_development.Portal; | ||
var reactIs_development_11 = reactIs_development.StrictMode; | ||
var reactIs_development_12 = reactIs_development.isValidElementType; | ||
var reactIs_development_13 = reactIs_development.isAsyncMode; | ||
var reactIs_development_14 = reactIs_development.isConcurrentMode; | ||
var reactIs_development_15 = reactIs_development.isContextConsumer; | ||
var reactIs_development_16 = reactIs_development.isContextProvider; | ||
var reactIs_development_17 = reactIs_development.isElement; | ||
var reactIs_development_18 = reactIs_development.isForwardRef; | ||
var reactIs_development_19 = reactIs_development.isFragment; | ||
var reactIs_development_20 = reactIs_development.isProfiler; | ||
var reactIs_development_21 = reactIs_development.isPortal; | ||
var reactIs_development_22 = reactIs_development.isStrictMode; | ||
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default | ||
: observedBits; | ||
}; | ||
var reactIs = createCommonjsModule(function (module) { | ||
Consumer.prototype.componentDidMount = function componentDidMount() { | ||
if (this.context[contextProp]) { | ||
this.context[contextProp].on(this.onUpdate); | ||
} | ||
var observedBits = this.props.observedBits; | ||
{ | ||
module.exports = reactIs_development; | ||
} | ||
}); | ||
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default | ||
: observedBits; | ||
}; | ||
/** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
Consumer.prototype.componentWillUnmount = function componentWillUnmount() { | ||
if (this.context[contextProp]) { | ||
this.context[contextProp].off(this.onUpdate); | ||
} | ||
}; | ||
Consumer.prototype.getValue = function getValue() { | ||
if (this.context[contextProp]) { | ||
return this.context[contextProp].get(); | ||
} else { | ||
return defaultValue; | ||
} | ||
}; | ||
var REACT_STATICS = { | ||
childContextTypes: true, | ||
contextType: true, | ||
contextTypes: true, | ||
defaultProps: true, | ||
displayName: true, | ||
getDefaultProps: true, | ||
getDerivedStateFromProps: true, | ||
mixins: true, | ||
propTypes: true, | ||
type: true | ||
}; | ||
Consumer.prototype.render = function render() { | ||
return onlyChild(this.props.children)(this.state.value); | ||
}; | ||
var KNOWN_STATICS = { | ||
name: true, | ||
length: true, | ||
prototype: true, | ||
caller: true, | ||
callee: true, | ||
arguments: true, | ||
arity: true | ||
}; | ||
return Consumer; | ||
}(React.Component); | ||
var FORWARD_REF_STATICS = { | ||
'$$typeof': true, | ||
render: true | ||
}; | ||
Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = _propTypes2.default.object, _Consumer$contextType); | ||
var TYPE_STATICS = {}; | ||
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS; | ||
var defineProperty = Object.defineProperty; | ||
var getOwnPropertyNames = Object.getOwnPropertyNames; | ||
var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols; | ||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
var getPrototypeOf = Object.getPrototypeOf; | ||
var objectPrototype = Object.prototype; | ||
return { | ||
Provider: Provider, | ||
Consumer: Consumer | ||
}; | ||
} | ||
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { | ||
if (typeof sourceComponent !== 'string') { | ||
// don't hoist over string (html) components | ||
exports.default = createReactContext; | ||
module.exports = exports['default']; | ||
}); | ||
if (objectPrototype) { | ||
var inheritedComponent = getPrototypeOf(sourceComponent); | ||
if (inheritedComponent && inheritedComponent !== objectPrototype) { | ||
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); | ||
} | ||
} | ||
unwrapExports(implementation); | ||
var keys = getOwnPropertyNames(sourceComponent); | ||
var lib = createCommonjsModule(function (module, exports) { | ||
if (getOwnPropertySymbols$1) { | ||
keys = keys.concat(getOwnPropertySymbols$1(sourceComponent)); | ||
} | ||
exports.__esModule = true; | ||
var targetStatics = TYPE_STATICS[targetComponent['$$typeof']] || REACT_STATICS; | ||
var sourceStatics = TYPE_STATICS[sourceComponent['$$typeof']] || REACT_STATICS; | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { | ||
var descriptor = getOwnPropertyDescriptor(sourceComponent, key); | ||
try { | ||
// Avoid failures from read-only properties | ||
defineProperty(targetComponent, key, descriptor); | ||
} catch (e) {} | ||
} | ||
} | ||
return targetComponent; | ||
} | ||
var _react2 = _interopRequireDefault(React); | ||
return targetComponent; | ||
} | ||
var hoistNonReactStatics_cjs = hoistNonReactStatics; | ||
var getDisplayName_1 = createCommonjsModule(function (module, exports) { | ||
var _implementation2 = _interopRequireDefault(implementation); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = getDisplayName; | ||
function getDisplayName(Component) { | ||
return Component.displayName || Component.name || (typeof Component === 'string' && Component.length > 0 ? Component : 'Unknown'); | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var getDisplayName = unwrapExports(getDisplayName_1); | ||
exports.default = _react2.default.createContext || _implementation2.default; | ||
module.exports = exports['default']; | ||
}); | ||
function createWithTheme(context) { | ||
return function hoc(Component) { | ||
// $FlowFixMe | ||
var withTheme = React__default.forwardRef(function (props, ref) { | ||
return React__default.createElement(context.Consumer, null, function (theme) { | ||
warning_1(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
return React__default.createElement(Component, _extends({ | ||
theme: theme, | ||
ref: ref | ||
}, props)); | ||
}); | ||
}); | ||
withTheme.displayName = "WithTheme(" + getDisplayName(Component) + ")"; | ||
hoistNonReactStatics_cjs(withTheme, Component); | ||
return withTheme; | ||
}; | ||
} | ||
var createReactContext = unwrapExports(lib); | ||
var ThemeContext = React.createContext(); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
function createTheming(context) { | ||
return { | ||
context: context, | ||
withTheme: createWithTheme(context), | ||
ThemeProvider: createThemeProvider(context) | ||
}; | ||
} | ||
return obj; | ||
} | ||
var _createTheming = createTheming(ThemeContext), | ||
withTheme = _createTheming.withTheme, | ||
ThemeProvider = _createTheming.ThemeProvider; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
exports.ThemeContext = ThemeContext; | ||
exports.withTheme = withTheme; | ||
exports.createTheming = createTheming; | ||
exports.ThemeProvider = ThemeProvider; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var warning$1 = function() {}; | ||
{ | ||
var printWarning$3 = function printWarning(format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
} | ||
var argIndex = 0; | ||
var message = 'Warning: ' + | ||
format.replace(/%s/g, function() { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(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) {} | ||
}; | ||
warning$1 = function(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
} | ||
if (format === undefined) { | ||
throw new Error( | ||
'`warning(condition, format, ...args)` requires a warning ' + | ||
'message argument' | ||
); | ||
} | ||
if (!condition) { | ||
printWarning$3.apply(null, [format].concat(args)); | ||
} | ||
}; | ||
} | ||
var warning_1$1 = warning$1; | ||
function isObject(obj) { | ||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj); | ||
} | ||
function createThemeProvider(context) { | ||
var _class, _temp; | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inheritsLoose(ThemeProvider, _React$Component); | ||
function ThemeProvider() { | ||
return _React$Component.apply(this, arguments) || this; | ||
} | ||
var _proto = ThemeProvider.prototype; | ||
// Get the theme from the props, supporting both (outerTheme) => {} as well as object notation | ||
_proto.getTheme = function getTheme(outerTheme) { | ||
var theme = this.props.theme; | ||
if (typeof theme === 'function') { | ||
var mergedTheme = theme(outerTheme); | ||
warning_1$1(isObject(mergedTheme), '[ThemeProvider] Please return an object from your theme function'); | ||
return mergedTheme; | ||
} | ||
warning_1$1(isObject(theme), '[ThemeProvider] Please make your theme prop a plain object'); | ||
return !outerTheme ? theme : _extends({}, outerTheme, theme); | ||
}; | ||
_proto.render = function render() { | ||
var _this = this; | ||
var children = this.props.children; | ||
if (!children) { | ||
return null; | ||
} | ||
return React.createElement(context.Consumer, null, function (outerTheme) { | ||
return React.createElement(context.Provider, { | ||
value: _this.getTheme(outerTheme) | ||
}, children); | ||
}); | ||
}; | ||
return ThemeProvider; | ||
}(React.Component), _defineProperty(_class, "propTypes", { | ||
children: propTypes.node, | ||
theme: propTypes.oneOfType([propTypes.shape({}), propTypes.func]).isRequired | ||
}), _defineProperty(_class, "defaultProps", { | ||
children: null | ||
}), _temp; | ||
} | ||
var reactIs_production_min = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports,"__esModule",{value:!0}); | ||
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.concurrent_mode"):60111,m=b?Symbol.for("react.forward_ref"):60112,n=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):60115,r=b?Symbol.for("react.lazy"): | ||
60116;function t(a){if("object"===typeof a&&null!==a){var p=a.$$typeof;switch(p){case c:switch(a=a.type,a){case l:case e:case g:case f:return a;default:switch(a=a&&a.$$typeof,a){case k:case m:case h:return a;default:return p}}case d:return p}}}function u(a){return t(a)===l}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=l;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=m;exports.Fragment=e;exports.Profiler=g;exports.Portal=d; | ||
exports.StrictMode=f;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===l||a===g||a===f||a===n||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===m)};exports.isAsyncMode=function(a){return u(a)};exports.isConcurrentMode=u;exports.isContextConsumer=function(a){return t(a)===k};exports.isContextProvider=function(a){return t(a)===h}; | ||
exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===m};exports.isFragment=function(a){return t(a)===e};exports.isProfiler=function(a){return t(a)===g};exports.isPortal=function(a){return t(a)===d};exports.isStrictMode=function(a){return t(a)===f}; | ||
}); | ||
unwrapExports(reactIs_production_min); | ||
var reactIs_production_min_1 = reactIs_production_min.typeOf; | ||
var reactIs_production_min_2 = reactIs_production_min.AsyncMode; | ||
var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode; | ||
var reactIs_production_min_4 = reactIs_production_min.ContextConsumer; | ||
var reactIs_production_min_5 = reactIs_production_min.ContextProvider; | ||
var reactIs_production_min_6 = reactIs_production_min.Element; | ||
var reactIs_production_min_7 = reactIs_production_min.ForwardRef; | ||
var reactIs_production_min_8 = reactIs_production_min.Fragment; | ||
var reactIs_production_min_9 = reactIs_production_min.Profiler; | ||
var reactIs_production_min_10 = reactIs_production_min.Portal; | ||
var reactIs_production_min_11 = reactIs_production_min.StrictMode; | ||
var reactIs_production_min_12 = reactIs_production_min.isValidElementType; | ||
var reactIs_production_min_13 = reactIs_production_min.isAsyncMode; | ||
var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode; | ||
var reactIs_production_min_15 = reactIs_production_min.isContextConsumer; | ||
var reactIs_production_min_16 = reactIs_production_min.isContextProvider; | ||
var reactIs_production_min_17 = reactIs_production_min.isElement; | ||
var reactIs_production_min_18 = reactIs_production_min.isForwardRef; | ||
var reactIs_production_min_19 = reactIs_production_min.isFragment; | ||
var reactIs_production_min_20 = reactIs_production_min.isProfiler; | ||
var reactIs_production_min_21 = reactIs_production_min.isPortal; | ||
var reactIs_production_min_22 = reactIs_production_min.isStrictMode; | ||
var reactIs_development = createCommonjsModule(function (module, exports) { | ||
{ | ||
(function() { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
// 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; | ||
function isValidElementType(type) { | ||
return typeof type === 'string' || typeof type === 'function' || | ||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. | ||
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); | ||
} | ||
/** | ||
* 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; | ||
function typeOf(object) { | ||
if (typeof object === 'object' && object !== null) { | ||
var $$typeof = object.$$typeof; | ||
switch ($$typeof) { | ||
case REACT_ELEMENT_TYPE: | ||
var type = object.type; | ||
switch (type) { | ||
case REACT_CONCURRENT_MODE_TYPE: | ||
case REACT_FRAGMENT_TYPE: | ||
case REACT_PROFILER_TYPE: | ||
case REACT_STRICT_MODE_TYPE: | ||
return type; | ||
default: | ||
var $$typeofType = type && type.$$typeof; | ||
switch ($$typeofType) { | ||
case REACT_CONTEXT_TYPE: | ||
case REACT_FORWARD_REF_TYPE: | ||
case REACT_PROVIDER_TYPE: | ||
return $$typeofType; | ||
default: | ||
return $$typeof; | ||
} | ||
} | ||
case REACT_PORTAL_TYPE: | ||
return $$typeof; | ||
} | ||
} | ||
return undefined; | ||
} | ||
// AsyncMode alias is deprecated along with isAsyncMode | ||
var AsyncMode = REACT_CONCURRENT_MODE_TYPE; | ||
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; | ||
var ContextConsumer = REACT_CONTEXT_TYPE; | ||
var ContextProvider = REACT_PROVIDER_TYPE; | ||
var Element = REACT_ELEMENT_TYPE; | ||
var ForwardRef = REACT_FORWARD_REF_TYPE; | ||
var Fragment = REACT_FRAGMENT_TYPE; | ||
var Profiler = REACT_PROFILER_TYPE; | ||
var Portal = REACT_PORTAL_TYPE; | ||
var StrictMode = REACT_STRICT_MODE_TYPE; | ||
var hasWarnedAboutDeprecatedIsAsyncMode = false; | ||
// AsyncMode should be deprecated | ||
function isAsyncMode(object) { | ||
{ | ||
if (!hasWarnedAboutDeprecatedIsAsyncMode) { | ||
hasWarnedAboutDeprecatedIsAsyncMode = true; | ||
lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); | ||
} | ||
} | ||
return isConcurrentMode(object); | ||
} | ||
function isConcurrentMode(object) { | ||
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; | ||
} | ||
function isContextConsumer(object) { | ||
return typeOf(object) === REACT_CONTEXT_TYPE; | ||
} | ||
function isContextProvider(object) { | ||
return typeOf(object) === REACT_PROVIDER_TYPE; | ||
} | ||
function isElement(object) { | ||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; | ||
} | ||
function isForwardRef(object) { | ||
return typeOf(object) === REACT_FORWARD_REF_TYPE; | ||
} | ||
function isFragment(object) { | ||
return typeOf(object) === REACT_FRAGMENT_TYPE; | ||
} | ||
function isProfiler(object) { | ||
return typeOf(object) === REACT_PROFILER_TYPE; | ||
} | ||
function isPortal(object) { | ||
return typeOf(object) === REACT_PORTAL_TYPE; | ||
} | ||
function isStrictMode(object) { | ||
return typeOf(object) === REACT_STRICT_MODE_TYPE; | ||
} | ||
exports.typeOf = typeOf; | ||
exports.AsyncMode = AsyncMode; | ||
exports.ConcurrentMode = ConcurrentMode; | ||
exports.ContextConsumer = ContextConsumer; | ||
exports.ContextProvider = ContextProvider; | ||
exports.Element = Element; | ||
exports.ForwardRef = ForwardRef; | ||
exports.Fragment = Fragment; | ||
exports.Profiler = Profiler; | ||
exports.Portal = Portal; | ||
exports.StrictMode = StrictMode; | ||
exports.isValidElementType = isValidElementType; | ||
exports.isAsyncMode = isAsyncMode; | ||
exports.isConcurrentMode = isConcurrentMode; | ||
exports.isContextConsumer = isContextConsumer; | ||
exports.isContextProvider = isContextProvider; | ||
exports.isElement = isElement; | ||
exports.isForwardRef = isForwardRef; | ||
exports.isFragment = isFragment; | ||
exports.isProfiler = isProfiler; | ||
exports.isPortal = isPortal; | ||
exports.isStrictMode = isStrictMode; | ||
})(); | ||
} | ||
}); | ||
unwrapExports(reactIs_development); | ||
var reactIs_development_1 = reactIs_development.typeOf; | ||
var reactIs_development_2 = reactIs_development.AsyncMode; | ||
var reactIs_development_3 = reactIs_development.ConcurrentMode; | ||
var reactIs_development_4 = reactIs_development.ContextConsumer; | ||
var reactIs_development_5 = reactIs_development.ContextProvider; | ||
var reactIs_development_6 = reactIs_development.Element; | ||
var reactIs_development_7 = reactIs_development.ForwardRef; | ||
var reactIs_development_8 = reactIs_development.Fragment; | ||
var reactIs_development_9 = reactIs_development.Profiler; | ||
var reactIs_development_10 = reactIs_development.Portal; | ||
var reactIs_development_11 = reactIs_development.StrictMode; | ||
var reactIs_development_12 = reactIs_development.isValidElementType; | ||
var reactIs_development_13 = reactIs_development.isAsyncMode; | ||
var reactIs_development_14 = reactIs_development.isConcurrentMode; | ||
var reactIs_development_15 = reactIs_development.isContextConsumer; | ||
var reactIs_development_16 = reactIs_development.isContextProvider; | ||
var reactIs_development_17 = reactIs_development.isElement; | ||
var reactIs_development_18 = reactIs_development.isForwardRef; | ||
var reactIs_development_19 = reactIs_development.isFragment; | ||
var reactIs_development_20 = reactIs_development.isProfiler; | ||
var reactIs_development_21 = reactIs_development.isPortal; | ||
var reactIs_development_22 = reactIs_development.isStrictMode; | ||
var reactIs = createCommonjsModule(function (module) { | ||
{ | ||
module.exports = reactIs_development; | ||
} | ||
}); | ||
/** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
var REACT_STATICS = { | ||
childContextTypes: true, | ||
contextType: true, | ||
contextTypes: true, | ||
defaultProps: true, | ||
displayName: true, | ||
getDefaultProps: true, | ||
getDerivedStateFromProps: true, | ||
mixins: true, | ||
propTypes: true, | ||
type: true | ||
}; | ||
var KNOWN_STATICS = { | ||
name: true, | ||
length: true, | ||
prototype: true, | ||
caller: true, | ||
callee: true, | ||
arguments: true, | ||
arity: true | ||
}; | ||
var FORWARD_REF_STATICS = { | ||
'$$typeof': true, | ||
render: true | ||
}; | ||
var TYPE_STATICS = {}; | ||
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS; | ||
var defineProperty = Object.defineProperty; | ||
var getOwnPropertyNames = Object.getOwnPropertyNames; | ||
var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols; | ||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
var getPrototypeOf = Object.getPrototypeOf; | ||
var objectPrototype = Object.prototype; | ||
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { | ||
if (typeof sourceComponent !== 'string') { | ||
// don't hoist over string (html) components | ||
if (objectPrototype) { | ||
var inheritedComponent = getPrototypeOf(sourceComponent); | ||
if (inheritedComponent && inheritedComponent !== objectPrototype) { | ||
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); | ||
} | ||
} | ||
var keys = getOwnPropertyNames(sourceComponent); | ||
if (getOwnPropertySymbols$1) { | ||
keys = keys.concat(getOwnPropertySymbols$1(sourceComponent)); | ||
} | ||
var targetStatics = TYPE_STATICS[targetComponent['$$typeof']] || REACT_STATICS; | ||
var sourceStatics = TYPE_STATICS[sourceComponent['$$typeof']] || REACT_STATICS; | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { | ||
var descriptor = getOwnPropertyDescriptor(sourceComponent, key); | ||
try { | ||
// Avoid failures from read-only properties | ||
defineProperty(targetComponent, key, descriptor); | ||
} catch (e) {} | ||
} | ||
} | ||
return targetComponent; | ||
} | ||
return targetComponent; | ||
} | ||
var hoistNonReactStatics_cjs = hoistNonReactStatics; | ||
var getDisplayName_1 = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = getDisplayName; | ||
function getDisplayName(Component) { | ||
return Component.displayName || Component.name || (typeof Component === 'string' && Component.length > 0 ? Component : 'Unknown'); | ||
} | ||
}); | ||
var getDisplayName = unwrapExports(getDisplayName_1); | ||
function createWithTheme(context) { | ||
return function hoc(Component) { | ||
function withTheme(props) { | ||
var innerRef = props.innerRef, | ||
otherProps = _objectWithoutPropertiesLoose(props, ["innerRef"]); | ||
return React.createElement(context.Consumer, null, function (theme) { | ||
warning_1$1(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
return React.createElement(Component, _extends({ | ||
theme: theme, | ||
ref: innerRef | ||
}, otherProps)); | ||
}); | ||
} | ||
withTheme.displayName = "WithTheme(" + getDisplayName(Component) + ")"; | ||
hoistNonReactStatics_cjs(withTheme, Component); | ||
return withTheme; | ||
}; | ||
} | ||
var ThemeContext = createReactContext(); | ||
function createTheming(context) { | ||
return { | ||
context: context, | ||
withTheme: createWithTheme(context), | ||
ThemeProvider: createThemeProvider(context) | ||
}; | ||
} | ||
var _createTheming = createTheming(ThemeContext), | ||
withTheme = _createTheming.withTheme, | ||
ThemeProvider = _createTheming.ThemeProvider; | ||
exports.ThemeContext = ThemeContext; | ||
exports.withTheme = withTheme; | ||
exports.createTheming = createTheming; | ||
exports.ThemeProvider = ThemeProvider; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=theming.js.map |
@@ -1,1 +0,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.theming={},e.react)}(this,function(e,y){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e,t){return e(t={exports:{}},t.exports),t.exports}y=y&&y.hasOwnProperty("default")?y.default:y;var n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}})()&&Object.assign;function u(){}var d=r(function(e){e.exports=function(){function e(e,t,r,n,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var u=new Error("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");throw u.name="Invariant Violation",u}}function t(){return e}var r={array:e.isRequired=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}()}),a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},c="__global_unique_id__",h=function(){return a[c]=(a[c]||0)+1};function f(e){return function(){return e}}var s=function(){};s.thatReturns=f,s.thatReturnsFalse=f(!1),s.thatReturnsTrue=f(!0),s.thatReturnsNull=f(null),s.thatReturnsThis=function(){return this},s.thatReturnsArgument=function(e){return e};var m=s,p=r(function(e,t){t.__esModule=!0;r(y);var a=r(d),c=r(h);r(m);function r(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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 l=1073741823;t.default=function(e,u){var t,r,n="__create-react-context-"+(0,c.default)()+"__",o=function(a){function c(){var e,t,r,n;f(this,c);for(var o=arguments.length,i=Array(o),u=0;u<o;u++)i[u]=arguments[u];return(e=t=s(this,a.call.apply(a,[this].concat(i)))).emitter=(r=t.props.value,n=[],{on:function(e){n.push(e)},off:function(t){n=n.filter(function(e){return e!==t})},get:function(){return r},set:function(e,t){r=e,n.forEach(function(e){return e(r,t)})}}),s(t,e)}return p(c,a),c.prototype.getChildContext=function(){var e;return(e={})[n]=this.emitter,e},c.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var t=this.props.value,r=e.value,n=void 0;((o=t)===(i=r)?0!==o||1/o==1/i:o!=o&&i!=i)?n=0:(n="function"==typeof u?u(t,r):l,0!=(n|=0)&&this.emitter.set(e.value,n))}var o,i},c.prototype.render=function(){return this.props.children},c}(y.Component);o.childContextTypes=((t={})[n]=a.default.object.isRequired,t);var i=function(i){function u(){var e,r;f(this,u);for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=r=s(this,i.call.apply(i,[this].concat(n)))).state={value:r.getValue()},r.onUpdate=function(e,t){0!=((0|r.observedBits)&t)&&r.setState({value:r.getValue()})},s(r,e)}return p(u,i),u.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?l:t},u.prototype.componentDidMount=function(){this.context[n]&&this.context[n].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?l:e},u.prototype.componentWillUnmount=function(){this.context[n]&&this.context[n].off(this.onUpdate)},u.prototype.getValue=function(){return this.context[n]?this.context[n].get():e},u.prototype.render=function(){return e=this.props.children,(Array.isArray(e)?e[0]:e)(this.state.value);var e},u}(y.Component);return i.contextTypes=((r={})[n]=a.default.object,r),{Provider:o,Consumer:i}},e.exports=t.default});t(p);var l=t(r(function(e,t){t.__esModule=!0;var r=o(y),n=o(p);function o(e){return e&&e.__esModule?e:{default:e}}t.default=r.default.createContext||n.default,e.exports=t.default}));function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){return(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}).apply(this,arguments)}var P=function(){};function g(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function O(i){var e,t;return t=e=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),(t.prototype.constructor=t).__proto__=r;var o=n.prototype;return o.getTheme=function(e){var t=this.props.theme;if("function"!=typeof t)return P(g(t),"[ThemeProvider] Please make your theme prop a plain object"),e?b({},e,t):t;var r=t(e);return P(g(r),"[ThemeProvider] Please return an object from your theme function"),r},o.render=function(){var t=this,r=this.props.children;return r?y.createElement(i.Consumer,null,function(e){return y.createElement(i.Provider,{value:t.getTheme(e)},r)}):null},n}(y.Component),v(e,"propTypes",{children:d.node,theme:d.oneOfType([d.shape({}),d.func]).isRequired}),v(e,"defaultProps",{children:null}),t}var _=r(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&Symbol.for,n=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,u=r?Symbol.for("react.strict_mode"):60108,a=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,f=r?Symbol.for("react.context"):60110,s=r?Symbol.for("react.concurrent_mode"):60111,p=r?Symbol.for("react.forward_ref"):60112,l=r?Symbol.for("react.suspense"):60113,y=r?Symbol.for("react.memo"):60115,d=r?Symbol.for("react.lazy"):60116;function h(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case s:case i:case a:case u:return e;default:switch(e=e&&e.$$typeof){case f:case p:case c:return e;default:return t}}case o:return t}}}function m(e){return h(e)===s}t.typeOf=h,t.AsyncMode=s,t.ConcurrentMode=s,t.ContextConsumer=f,t.ContextProvider=c,t.Element=n,t.ForwardRef=p,t.Fragment=i,t.Profiler=a,t.Portal=o,t.StrictMode=u,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===s||e===a||e===u||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===y||e.$$typeof===c||e.$$typeof===f||e.$$typeof===p)},t.isAsyncMode=function(e){return m(e)},t.isConcurrentMode=m,t.isContextConsumer=function(e){return h(e)===f},t.isContextProvider=function(e){return h(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return h(e)===p},t.isFragment=function(e){return h(e)===i},t.isProfiler=function(e){return h(e)===a},t.isPortal=function(e){return h(e)===o},t.isStrictMode=function(e){return h(e)===u}});t(_);_.typeOf,_.AsyncMode,_.ConcurrentMode,_.ContextConsumer,_.ContextProvider,_.Element,_.ForwardRef,_.Fragment,_.Profiler,_.Portal,_.StrictMode,_.isValidElementType,_.isAsyncMode,_.isConcurrentMode,_.isContextConsumer,_.isContextProvider,_.isElement,_.isForwardRef,_.isFragment,_.isProfiler,_.isPortal,_.isStrictMode;var j=r(function(e,t){});t(j);j.typeOf,j.AsyncMode,j.ConcurrentMode,j.ContextConsumer,j.ContextProvider,j.Element,j.ForwardRef,j.Fragment,j.Profiler,j.Portal,j.StrictMode,j.isValidElementType,j.isAsyncMode,j.isConcurrentMode,j.isContextConsumer,j.isContextProvider,j.isElement,j.isForwardRef,j.isFragment,j.isProfiler,j.isPortal,j.isStrictMode;var x=r(function(e){e.exports=_}),w={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},C={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},T={};T[x.ForwardRef]={$$typeof:!0,render:!0};var S=Object.defineProperty,M=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,E=Object.getOwnPropertyDescriptor,$=Object.getPrototypeOf,F=Object.prototype;var A=function e(t,r,n){if("string"==typeof r)return t;if(F){var o=$(r);o&&o!==F&&e(t,o,n)}var i=M(r);R&&(i=i.concat(R(r)));for(var u=T[t.$$typeof]||w,a=T[r.$$typeof]||w,c=0;c<i.length;++c){var f=i[c];if(!(C[f]||n&&n[f]||a&&a[f]||u&&u[f])){var s=E(r,f);try{S(t,f,s)}catch(e){}}}return t},k=t(r(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return e.displayName||e.name||("string"==typeof e&&0<e.length?e:"Unknown")}}));function N(o){return function(n){function e(e){var t=e.innerRef,r=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],0<=t.indexOf(r)||(o[r]=e[r]);return o}(e,["innerRef"]);return y.createElement(o.Consumer,null,function(e){return P(g(e),"[theming] Please use withTheme only with the ThemeProvider"),y.createElement(n,b({theme:e,ref:t},r))})}return e.displayName="WithTheme("+k(n)+")",A(e,n),e}}var q=l();function U(e){return{context:e,withTheme:N(e),ThemeProvider:O(e)}}var V=U(q),B=V.withTheme,D=V.ThemeProvider;e.ThemeContext=q,e.withTheme=B,e.createTheming=U,e.ThemeProvider=D,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t(e.theming={},e.react)}(this,function(e,t){"use strict";var a="default"in t?t.default:t;function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var u=function(){};function r(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}var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}})()&&Object.assign;function l(){}var y=o(function(e){e.exports=function(){function e(e,t,r,o,n,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var a=new Error("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");throw a.name="Invariant Violation",a}}function t(){return e}var r={array:e.isRequired=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=l,r.PropTypes=r}()});function m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function d(i){var e,t;return t=e=function(n){var e,t;function r(){for(var r,e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return c(f(f(r=n.call.apply(n,[this].concat(t))||this)),"cachedTheme",void 0),c(f(f(r)),"lastOuterTheme",void 0),c(f(f(r)),"lastTheme",void 0),c(f(f(r)),"renderProvider",function(e){var t=r.props.children;return a.createElement(i.Provider,{value:r.getTheme(e)},t)}),r}t=n,(e=r).prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t;var o=r.prototype;return o.getTheme=function(e){var t=this.props.theme;return t===this.lastTheme&&e===this.lastOuterTheme&&this.cachedTheme||(this.lastOuterTheme=e,"function"==typeof(this.lastTheme=t)?(this.cachedTheme=t(e),u(m(this.cachedTheme),"[ThemeProvider] Please return an object from your theme function")):(u(m(t),"[ThemeProvider] Please make your theme prop a plain object"),this.cachedTheme=e?s({},e,t):t)),this.cachedTheme},o.render=function(){return this.props.children?a.createElement(i.Consumer,null,this.renderProvider):null},r}(a.Component),c(e,"propTypes",{children:y.node,theme:y.oneOfType([y.shape({}),y.func]).isRequired}),c(e,"defaultProps",{children:null}),t}var h=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,n=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,a=r?Symbol.for("react.strict_mode"):60108,c=r?Symbol.for("react.profiler"):60114,s=r?Symbol.for("react.provider"):60109,f=r?Symbol.for("react.context"):60110,u=r?Symbol.for("react.concurrent_mode"):60111,p=r?Symbol.for("react.forward_ref"):60112,l=r?Symbol.for("react.suspense"):60113,y=r?Symbol.for("react.memo"):60115,m=r?Symbol.for("react.lazy"):60116;function d(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case u:case i:case c:case a:return e;default:switch(e=e&&e.$$typeof){case f:case p:case s:return e;default:return t}}case n:return t}}}function h(e){return d(e)===u}t.typeOf=d,t.AsyncMode=u,t.ConcurrentMode=u,t.ContextConsumer=f,t.ContextProvider=s,t.Element=o,t.ForwardRef=p,t.Fragment=i,t.Profiler=c,t.Portal=n,t.StrictMode=a,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===u||e===c||e===a||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===y||e.$$typeof===s||e.$$typeof===f||e.$$typeof===p)},t.isAsyncMode=function(e){return h(e)},t.isConcurrentMode=h,t.isContextConsumer=function(e){return d(e)===f},t.isContextProvider=function(e){return d(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return d(e)===p},t.isFragment=function(e){return d(e)===i},t.isProfiler=function(e){return d(e)===c},t.isPortal=function(e){return d(e)===n},t.isStrictMode=function(e){return d(e)===a}});r(h);h.typeOf,h.AsyncMode,h.ConcurrentMode,h.ContextConsumer,h.ContextProvider,h.Element,h.ForwardRef,h.Fragment,h.Profiler,h.Portal,h.StrictMode,h.isValidElementType,h.isAsyncMode,h.isConcurrentMode,h.isContextConsumer,h.isContextProvider,h.isElement,h.isForwardRef,h.isFragment,h.isProfiler,h.isPortal,h.isStrictMode;var b=o(function(e,t){});r(b);b.typeOf,b.AsyncMode,b.ConcurrentMode,b.ContextConsumer,b.ContextProvider,b.Element,b.ForwardRef,b.Fragment,b.Profiler,b.Portal,b.StrictMode,b.isValidElementType,b.isAsyncMode,b.isConcurrentMode,b.isContextConsumer,b.isContextProvider,b.isElement,b.isForwardRef,b.isFragment,b.isProfiler,b.isPortal,b.isStrictMode;var v=o(function(e){e.exports=h}),P={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},O={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},T={};T[v.ForwardRef]={$$typeof:!0,render:!0};var g=Object.defineProperty,j=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,C=Object.getOwnPropertyDescriptor,x=Object.getPrototypeOf,S=Object.prototype;var _=function e(t,r,o){if("string"==typeof r)return t;if(S){var n=x(r);n&&n!==S&&e(t,n,o)}var i=j(r);w&&(i=i.concat(w(r)));for(var a=T[t.$$typeof]||P,c=T[r.$$typeof]||P,s=0;s<i.length;++s){var f=i[s];if(!(O[f]||o&&o[f]||c&&c[f]||a&&a[f])){var u=C(r,f);try{g(t,f,u)}catch(e){}}}return t},M=r(o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return e.displayName||e.name||("string"==typeof e&&0<e.length?e:"Unknown")}}));var $=t.createContext();function E(e){return{context:e,withTheme:(n=e,function(o){var e=a.forwardRef(function(t,r){return a.createElement(n.Consumer,null,function(e){return u(m(e),"[theming] Please use withTheme only with the ThemeProvider"),a.createElement(o,s({theme:e,ref:r},t))})});return e.displayName="WithTheme("+M(o)+")",_(e,o),e}),ThemeProvider:d(e)};var n}var F=E($),R=F.withTheme,A=F.ThemeProvider;e.ThemeContext=$,e.withTheme=R,e.createTheming=E,e.ThemeProvider=A,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "theming", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Unified CSSinJS theming solution for React", | ||
@@ -73,3 +73,3 @@ "main": "dist/theming.cjs.js", | ||
"eslint-config-jss": "^5.0.1", | ||
"flow-bin": "^0.85.0", | ||
"flow-bin": "^0.88.0", | ||
"nyc": "^13.1.0", | ||
@@ -92,3 +92,2 @@ "react": "^16.6.0", | ||
"@types/react": "^16.4.18", | ||
"create-react-context": "^0.2.3", | ||
"hoist-non-react-statics": "^3.1.0", | ||
@@ -100,4 +99,4 @@ "prop-types": "^15.5.8", | ||
"peerDependencies": { | ||
"react": ">=15" | ||
"react": ">=16.3" | ||
} | ||
} |
@@ -90,3 +90,3 @@ # Theming | ||
> | ||
> If you insist on using context despite these warnings, try to isolate your use of context to a small area and avoid using the context API directly when possible so that it's easier to upgrade when the API changes. | ||
> If you insist on using context despite these warnings, try to isolate your use of context to a small area and avoid using the context API directly when possible so that it's easier to upgrade when the API changes. | ||
> — [Context, React documentation](https://facebook.github.io/react/docs/context.html) | ||
@@ -96,4 +96,4 @@ | ||
> Should I use React unstable “context” feature? | ||
> <img src="https://pbs.twimg.com/media/CmeGPNcVYAAM7TR.jpg" alt="![context application areas]" height="300" /> | ||
> Should I use React unstable “context” feature? | ||
> <img src="https://pbs.twimg.com/media/CmeGPNcVYAAM7TR.jpg" alt="![context application areas]" height="300" /> | ||
> — [Dan Abramov @dan_abramov on Twitter](https://twitter.com/dan_abramov/status/749715530454622208?lang=en) | ||
@@ -126,3 +126,3 @@ | ||
*Required* | ||
*Required* | ||
Type: `Object`, `Function` | ||
@@ -169,3 +169,3 @@ | ||
*Required* | ||
*Required* | ||
Type: `PropTypes.element` | ||
@@ -179,4 +179,4 @@ | ||
*Required* | ||
Type: `PropTypes.element` | ||
*Required* | ||
Type: `ComponentType` | ||
@@ -222,2 +222,6 @@ You need to have `ThemeProvider` with a theme somewhere upper the react tree, after that wrap your component in `withTheme` and your component will get theme as a prop. `withTheme` will handle initial theme object as well as theme updates. | ||
#### Access inner component instance | ||
The `withTheme` HOC supports the new React forwardRef API so you can just use the normal ref prop. | ||
### createTheming(context) | ||
@@ -230,3 +234,3 @@ | ||
Type: `Object` | ||
Type: `Object` | ||
Result: `Object { withTheme, ThemeProvider }` | ||
@@ -233,0 +237,0 @@ |
// @flow | ||
import { type Context } from 'create-react-context'; | ||
import React, { type Node } from 'react'; | ||
import React, { type Node, type Context } from 'react'; | ||
import warning from 'warning'; | ||
@@ -27,21 +26,42 @@ import PropTypes from 'prop-types'; | ||
if (typeof theme === 'function') { | ||
const mergedTheme = theme(outerTheme); | ||
if (theme !== this.lastTheme || outerTheme !== this.lastOuterTheme || !this.cachedTheme) { | ||
this.lastOuterTheme = outerTheme; | ||
this.lastTheme = theme; | ||
warning( | ||
isObject(mergedTheme), | ||
'[ThemeProvider] Please return an object from your theme function', | ||
); | ||
if (typeof theme === 'function') { | ||
this.cachedTheme = theme(outerTheme); | ||
return mergedTheme; | ||
warning( | ||
isObject(this.cachedTheme), | ||
'[ThemeProvider] Please return an object from your theme function', | ||
); | ||
} else { | ||
warning( | ||
isObject(theme), | ||
'[ThemeProvider] Please make your theme prop a plain object', | ||
); | ||
this.cachedTheme = outerTheme ? { ...outerTheme, ...theme } : theme; | ||
} | ||
} | ||
warning( | ||
isObject(theme), | ||
'[ThemeProvider] Please make your theme prop a plain object', | ||
return this.cachedTheme; | ||
} | ||
cachedTheme: Theme; | ||
lastOuterTheme: Theme; | ||
lastTheme: $NonMaybeType<Theme>; | ||
renderProvider = (outerTheme: Theme) => { | ||
const { children } = this.props; | ||
return ( | ||
<context.Provider value={this.getTheme(outerTheme)}> | ||
{children} | ||
</context.Provider> | ||
); | ||
}; | ||
return !outerTheme ? theme : { ...outerTheme, ...theme }; | ||
} | ||
render() { | ||
@@ -56,7 +76,3 @@ const { children } = this.props; | ||
<context.Consumer> | ||
{outerTheme => ( | ||
<context.Provider value={this.getTheme(outerTheme)}> | ||
{children} | ||
</context.Provider> | ||
)} | ||
{this.renderProvider} | ||
</context.Consumer> | ||
@@ -63,0 +79,0 @@ ); |
// @flow | ||
import test from 'ava'; | ||
import createReactContext from 'create-react-context'; | ||
import React from 'react'; | ||
@@ -20,3 +19,3 @@ import sinon from 'sinon'; | ||
const themeFn = sinon.spy(outerTheme => outerTheme); | ||
const context = createReactContext(defaultTheme); | ||
const context = React.createContext(defaultTheme); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -36,3 +35,3 @@ | ||
const themeFn = sinon.spy(theme => theme); | ||
const context = createReactContext({}); | ||
const context = React.createContext({}); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -52,3 +51,3 @@ | ||
test('should merge nested themes', (t) => { | ||
const context = createReactContext({}); | ||
const context = React.createContext({}); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -78,3 +77,3 @@ const themeA = { themeA: 'a' }; | ||
test('should not render any Consumer and Provider if no children were passed', (t) => { | ||
const context = createReactContext({}); | ||
const context = React.createContext({}); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -90,3 +89,3 @@ | ||
test('should return not modify the theme when the ThemeProvider isn\'t nested', (t) => { | ||
const context = createReactContext(); | ||
const context = React.createContext(); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -111,3 +110,3 @@ const themeA = {}; | ||
test('should create new theme object when 2 ThemeProvider\'s are nested', (t) => { | ||
const context = createReactContext(); | ||
const context = React.createContext(); | ||
const ThemeProvider = createThemeProvider(context); | ||
@@ -114,0 +113,0 @@ const themeA = {}; |
// @flow | ||
import React, { type ComponentType, type Ref } from 'react'; | ||
import { type Context } from 'create-react-context'; | ||
import React, { type ComponentType, type Context } from 'react'; | ||
import hoist from 'hoist-non-react-statics'; | ||
@@ -12,26 +11,23 @@ import getDisplayName from 'react-display-name'; | ||
return function hoc< | ||
InnerProps: {}, | ||
InnerProps, | ||
InnerComponent: ComponentType<InnerProps>, | ||
OuterProps: $Diff<InnerProps, { theme: Theme }> & { innerRef?: Ref<InnerComponent> }, | ||
OuterProps: { ...InnerProps, theme?: $NonMaybeType<Theme> }, | ||
>(Component: InnerComponent): ComponentType<OuterProps> { | ||
function withTheme(props: OuterProps) { | ||
const { innerRef, ...otherProps } = props; | ||
// $FlowFixMe | ||
const withTheme = React.forwardRef((props, ref) => ( | ||
<context.Consumer> | ||
{(theme) => { | ||
warning(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
return ( | ||
<context.Consumer> | ||
{(theme) => { | ||
warning(isObject(theme), '[theming] Please use withTheme only with the ThemeProvider'); | ||
return ( | ||
<Component | ||
theme={theme} | ||
ref={ref} | ||
{...props} | ||
/> | ||
); | ||
}} | ||
</context.Consumer> | ||
)); | ||
return ( | ||
<Component | ||
theme={theme} | ||
ref={innerRef} | ||
{...otherProps} | ||
/> | ||
); | ||
}} | ||
</context.Consumer> | ||
); | ||
} | ||
withTheme.displayName = `WithTheme(${getDisplayName(Component)})`; | ||
@@ -38,0 +34,0 @@ |
// @flow | ||
import test from 'ava'; | ||
import createReactContext from 'create-react-context'; | ||
import React from 'react'; | ||
@@ -32,3 +31,3 @@ import TestRenderer from 'react-test-renderer'; | ||
test('createWithTheme\'s result is function on its own', (t) => { | ||
const context = createReactContext({}); | ||
const context = React.createContext({}); | ||
const withTheme = createWithTheme(context); | ||
@@ -41,3 +40,3 @@ | ||
const theme = {}; | ||
const context = createReactContext(theme); | ||
const context = React.createContext(theme); | ||
const WithTheme = createWithTheme(context)(FunctionalComponent); | ||
@@ -52,3 +51,3 @@ const { root } = TestRenderer.create(<WithTheme />); | ||
const theme = { test: 'test' }; | ||
const context = createReactContext(theme); | ||
const context = React.createContext(theme); | ||
const WithTheme = createWithTheme(context)(FunctionalComponent); | ||
@@ -65,6 +64,5 @@ const { root } = TestRenderer.create(( | ||
test('should allow overriding the prop from the outer props', (t) => { | ||
const theme = {}; | ||
const otherTheme = {}; | ||
const context = createReactContext(theme); | ||
const WithTheme = createWithTheme(context)(FunctionalComponent); | ||
const context = React.createContext<{}>({}); | ||
const WithTheme = createWithTheme<{}>(context)(FunctionalComponent); | ||
const { root } = TestRenderer.create(( | ||
@@ -77,6 +75,5 @@ <WithTheme theme={otherTheme} /> | ||
test('innerRef should set the ref prop on the wrapped component', (t) => { | ||
const theme = {}; | ||
const context = createReactContext<{}>(theme); | ||
const withTheme = createWithTheme(context); | ||
test('normal refs should just work and correctly be forwarded', (t) => { | ||
const context = React.createContext({}); | ||
const WithTheme = createWithTheme(context)(ClassComponent); | ||
let refComp = null; | ||
@@ -86,6 +83,5 @@ const innerRef = (comp) => { | ||
}; | ||
const WithTheme = withTheme(ClassComponent); | ||
TestRenderer.create(( | ||
<WithTheme innerRef={innerRef} /> | ||
<WithTheme ref={innerRef} /> | ||
)); | ||
@@ -97,3 +93,3 @@ | ||
test('withTheme(Comp) hoists non-react static class properties', (t) => { | ||
const context = createReactContext({}); | ||
const context = React.createContext({}); | ||
const withTheme = createWithTheme(context); | ||
@@ -118,3 +114,3 @@ const WithTheme = withTheme(ClassComponent); | ||
const context = createReactContext(null); | ||
const context = React.createContext<{} | void>(); | ||
const withTheme = createWithTheme(context); | ||
@@ -121,0 +117,0 @@ const WithTheme = withTheme(ClassComponent); |
import * as React from 'react'; | ||
import { Context } from 'create-react-context'; | ||
type DefaultTheme = object | null; | ||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
type WithThemeFactory<Theme> = < | ||
InnerProps extends { theme: NonNullable<Theme> }, | ||
InnerComponent extends React.ComponentType<InnerProps>, | ||
OuterProps extends Omit<InnerProps, { theme: NonNullable<Theme> }> & { innerRef?: React.Ref<InnerComponent> }, | ||
OuterProps extends InnerProps & { theme?: NonNullable<Theme> }, | ||
>(comp: InnerComponent) => React.ComponentType<OuterProps>; | ||
@@ -22,3 +19,3 @@ | ||
interface Theming<Theme> { | ||
context: Context<Theme>, | ||
context: React.Context<Theme>, | ||
withTheme: WithThemeFactory<Theme>, | ||
@@ -28,7 +25,7 @@ ThemeProvider: ThemeProviderFactory<Theme>, | ||
declare function createTheming<Theme>(context: Context<Theme>): Theming<Theme>; | ||
declare function createTheming<Theme>(context: React.Context<Theme>): Theming<Theme>; | ||
declare const withTheme: WithThemeFactory<DefaultTheme>; | ||
declare const ThemeProvider: ThemeProviderFactory<DefaultTheme>; | ||
declare const ThemeContext: Context<DefaultTheme>; | ||
declare const ThemeContext: React.Context<DefaultTheme>; | ||
@@ -35,0 +32,0 @@ export { |
// @flow | ||
import createReactContext, { type Context } from 'create-react-context'; | ||
import { createContext, type Context } from 'react'; | ||
@@ -18,3 +18,3 @@ import createThemeProvider, { type ThemeProviderProps } from './create-theme-provider'; | ||
const ThemeContext = createReactContext<{} | void>(); | ||
const ThemeContext = createContext<{} | void>(); | ||
@@ -21,0 +21,0 @@ function createTheming<Theme>(context: Context<Theme>): Theming<Theme> { |
// @flow | ||
import test from 'ava'; | ||
import createReactContext from 'create-react-context'; | ||
import { createContext } from 'react'; | ||
@@ -13,3 +13,3 @@ import isObject from './is-object'; | ||
test('createTheming()\'s type', (t) => { | ||
const context = createReactContext({}); | ||
const context = createContext({}); | ||
const theming = createTheming(context); | ||
@@ -21,3 +21,3 @@ const actual = isObject(theming); | ||
test('createTheming()\'s key names', (t) => { | ||
const context = createReactContext({}); | ||
const context = createContext({}); | ||
const theming = createTheming(context); | ||
@@ -24,0 +24,0 @@ const actual = Object.keys(theming); |
Sorry, the diff of this file is not supported yet
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
6
295
174229
1855
- Removedcreate-react-context@^0.2.3
- Removedasap@2.0.6(transitive)
- Removedcore-js@1.2.7(transitive)
- Removedcreate-react-context@0.2.3(transitive)
- Removedencoding@0.1.13(transitive)
- Removedfbjs@0.8.18(transitive)
- Removedgud@1.0.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedpromise@7.3.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedua-parser-js@0.7.39(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)