UNPKG

52.8 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var React = require('react');
8var React__default = _interopDefault(React);
9
10function unwrapExports (x) {
11 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12}
13
14function createCommonjsModule(fn, module) {
15 return module = { exports: {} }, fn(module, module.exports), module.exports;
16}
17
18/**
19 * Copyright (c) 2013-present, Facebook, Inc.
20 *
21 * This source code is licensed under the MIT license found in the
22 * LICENSE file in the root directory of this source tree.
23 *
24 *
25 */
26
27function makeEmptyFunction(arg) {
28 return function () {
29 return arg;
30 };
31}
32
33/**
34 * This function accepts and discards inputs; it has no side effects. This is
35 * primarily useful idiomatically for overridable function endpoints which
36 * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
37 */
38var emptyFunction = function emptyFunction() {};
39
40emptyFunction.thatReturns = makeEmptyFunction;
41emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
42emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
43emptyFunction.thatReturnsNull = makeEmptyFunction(null);
44emptyFunction.thatReturnsThis = function () {
45 return this;
46};
47emptyFunction.thatReturnsArgument = function (arg) {
48 return arg;
49};
50
51var emptyFunction_1 = emptyFunction;
52
53/**
54 * Copyright (c) 2013-present, Facebook, Inc.
55 *
56 * This source code is licensed under the MIT license found in the
57 * LICENSE file in the root directory of this source tree.
58 *
59 */
60
61/**
62 * Use invariant() to assert state which your program assumes to be true.
63 *
64 * Provide sprintf-style format (only %s is supported) and arguments
65 * to provide information about what broke and what you were
66 * expecting.
67 *
68 * The invariant message will be stripped in production, but the invariant
69 * will remain to ensure logic does not differ in production.
70 */
71
72var validateFormat = function validateFormat(format) {};
73
74if (process.env.NODE_ENV !== 'production') {
75 validateFormat = function validateFormat(format) {
76 if (format === undefined) {
77 throw new Error('invariant requires an error message argument');
78 }
79 };
80}
81
82function invariant(condition, format, a, b, c, d, e, f) {
83 validateFormat(format);
84
85 if (!condition) {
86 var error;
87 if (format === undefined) {
88 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
89 } else {
90 var args = [a, b, c, d, e, f];
91 var argIndex = 0;
92 error = new Error(format.replace(/%s/g, function () {
93 return args[argIndex++];
94 }));
95 error.name = 'Invariant Violation';
96 }
97
98 error.framesToPop = 1; // we don't care about invariant's own frame
99 throw error;
100 }
101}
102
103var invariant_1 = invariant;
104
105/**
106 * Similar to invariant but only logs a warning if the condition is not met.
107 * This can be used to log issues in development environments in critical
108 * paths. Removing the logging code for production environments will keep the
109 * same logic and follow the same code paths.
110 */
111
112var warning = emptyFunction_1;
113
114if (process.env.NODE_ENV !== 'production') {
115 var printWarning = function printWarning(format) {
116 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
117 args[_key - 1] = arguments[_key];
118 }
119
120 var argIndex = 0;
121 var message = 'Warning: ' + format.replace(/%s/g, function () {
122 return args[argIndex++];
123 });
124 if (typeof console !== 'undefined') {
125 console.error(message);
126 }
127 try {
128 // --- Welcome to debugging React ---
129 // This error was thrown as a convenience so that you can use this stack
130 // to find the callsite that caused this warning to fire.
131 throw new Error(message);
132 } catch (x) {}
133 };
134
135 warning = function warning(condition, format) {
136 if (format === undefined) {
137 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
138 }
139
140 if (format.indexOf('Failed Composite propType: ') === 0) {
141 return; // Ignore CompositeComponent proptype check.
142 }
143
144 if (!condition) {
145 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
146 args[_key2 - 2] = arguments[_key2];
147 }
148
149 printWarning.apply(undefined, [format].concat(args));
150 }
151 };
152}
153
154var warning_1 = warning;
155
156/*
157object-assign
158(c) Sindre Sorhus
159@license MIT
160*/
161/* eslint-disable no-unused-vars */
162var getOwnPropertySymbols = Object.getOwnPropertySymbols;
163var hasOwnProperty = Object.prototype.hasOwnProperty;
164var propIsEnumerable = Object.prototype.propertyIsEnumerable;
165
166function toObject(val) {
167 if (val === null || val === undefined) {
168 throw new TypeError('Object.assign cannot be called with null or undefined');
169 }
170
171 return Object(val);
172}
173
174function shouldUseNative() {
175 try {
176 if (!Object.assign) {
177 return false;
178 }
179
180 // Detect buggy property enumeration order in older V8 versions.
181
182 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
183 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
184 test1[5] = 'de';
185 if (Object.getOwnPropertyNames(test1)[0] === '5') {
186 return false;
187 }
188
189 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
190 var test2 = {};
191 for (var i = 0; i < 10; i++) {
192 test2['_' + String.fromCharCode(i)] = i;
193 }
194 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
195 return test2[n];
196 });
197 if (order2.join('') !== '0123456789') {
198 return false;
199 }
200
201 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
202 var test3 = {};
203 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
204 test3[letter] = letter;
205 });
206 if (Object.keys(Object.assign({}, test3)).join('') !==
207 'abcdefghijklmnopqrst') {
208 return false;
209 }
210
211 return true;
212 } catch (err) {
213 // We don't expect any of the above to throw, but better to be safe.
214 return false;
215 }
216}
217
218var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
219 var from;
220 var to = toObject(target);
221 var symbols;
222
223 for (var s = 1; s < arguments.length; s++) {
224 from = Object(arguments[s]);
225
226 for (var key in from) {
227 if (hasOwnProperty.call(from, key)) {
228 to[key] = from[key];
229 }
230 }
231
232 if (getOwnPropertySymbols) {
233 symbols = getOwnPropertySymbols(from);
234 for (var i = 0; i < symbols.length; i++) {
235 if (propIsEnumerable.call(from, symbols[i])) {
236 to[symbols[i]] = from[symbols[i]];
237 }
238 }
239 }
240 }
241
242 return to;
243};
244
245/**
246 * Copyright (c) 2013-present, Facebook, Inc.
247 *
248 * This source code is licensed under the MIT license found in the
249 * LICENSE file in the root directory of this source tree.
250 */
251
252var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
253
254var ReactPropTypesSecret_1 = ReactPropTypesSecret;
255
256if (process.env.NODE_ENV !== 'production') {
257 var invariant$1 = invariant_1;
258 var warning$1 = warning_1;
259 var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
260 var loggedTypeFailures = {};
261}
262
263/**
264 * Assert that the values match with the type specs.
265 * Error messages are memorized and will only be shown once.
266 *
267 * @param {object} typeSpecs Map of name to a ReactPropType
268 * @param {object} values Runtime values that need to be type-checked
269 * @param {string} location e.g. "prop", "context", "child context"
270 * @param {string} componentName Name of the component for error messages.
271 * @param {?Function} getStack Returns the component stack.
272 * @private
273 */
274function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
275 if (process.env.NODE_ENV !== 'production') {
276 for (var typeSpecName in typeSpecs) {
277 if (typeSpecs.hasOwnProperty(typeSpecName)) {
278 var error;
279 // Prop type validation may throw. In case they do, we don't want to
280 // fail the render phase where it didn't fail before. So we log it.
281 // After these have been cleaned up, we'll let them throw.
282 try {
283 // This is intentionally an invariant that gets caught. It's the same
284 // behavior as without this statement except with a better message.
285 invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
286 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
287 } catch (ex) {
288 error = ex;
289 }
290 warning$1(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
291 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
292 // Only monitor this failure once because there tends to be a lot of the
293 // same error.
294 loggedTypeFailures[error.message] = true;
295
296 var stack = getStack ? getStack() : '';
297
298 warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
299 }
300 }
301 }
302 }
303}
304
305var checkPropTypes_1 = checkPropTypes;
306
307var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
308 /* global Symbol */
309 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
310 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
311
312 /**
313 * Returns the iterator method function contained on the iterable object.
314 *
315 * Be sure to invoke the function with the iterable as context:
316 *
317 * var iteratorFn = getIteratorFn(myIterable);
318 * if (iteratorFn) {
319 * var iterator = iteratorFn.call(myIterable);
320 * ...
321 * }
322 *
323 * @param {?object} maybeIterable
324 * @return {?function}
325 */
326 function getIteratorFn(maybeIterable) {
327 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
328 if (typeof iteratorFn === 'function') {
329 return iteratorFn;
330 }
331 }
332
333 /**
334 * Collection of methods that allow declaration and validation of props that are
335 * supplied to React components. Example usage:
336 *
337 * var Props = require('ReactPropTypes');
338 * var MyArticle = React.createClass({
339 * propTypes: {
340 * // An optional string prop named "description".
341 * description: Props.string,
342 *
343 * // A required enum prop named "category".
344 * category: Props.oneOf(['News','Photos']).isRequired,
345 *
346 * // A prop named "dialog" that requires an instance of Dialog.
347 * dialog: Props.instanceOf(Dialog).isRequired
348 * },
349 * render: function() { ... }
350 * });
351 *
352 * A more formal specification of how these methods are used:
353 *
354 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
355 * decl := ReactPropTypes.{type}(.isRequired)?
356 *
357 * Each and every declaration produces a function with the same signature. This
358 * allows the creation of custom validation functions. For example:
359 *
360 * var MyLink = React.createClass({
361 * propTypes: {
362 * // An optional string or URI prop named "href".
363 * href: function(props, propName, componentName) {
364 * var propValue = props[propName];
365 * if (propValue != null && typeof propValue !== 'string' &&
366 * !(propValue instanceof URI)) {
367 * return new Error(
368 * 'Expected a string or an URI for ' + propName + ' in ' +
369 * componentName
370 * );
371 * }
372 * }
373 * },
374 * render: function() {...}
375 * });
376 *
377 * @internal
378 */
379
380 var ANONYMOUS = '<<anonymous>>';
381
382 // Important!
383 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
384 var ReactPropTypes = {
385 array: createPrimitiveTypeChecker('array'),
386 bool: createPrimitiveTypeChecker('boolean'),
387 func: createPrimitiveTypeChecker('function'),
388 number: createPrimitiveTypeChecker('number'),
389 object: createPrimitiveTypeChecker('object'),
390 string: createPrimitiveTypeChecker('string'),
391 symbol: createPrimitiveTypeChecker('symbol'),
392
393 any: createAnyTypeChecker(),
394 arrayOf: createArrayOfTypeChecker,
395 element: createElementTypeChecker(),
396 instanceOf: createInstanceTypeChecker,
397 node: createNodeChecker(),
398 objectOf: createObjectOfTypeChecker,
399 oneOf: createEnumTypeChecker,
400 oneOfType: createUnionTypeChecker,
401 shape: createShapeTypeChecker,
402 exact: createStrictShapeTypeChecker,
403 };
404
405 /**
406 * inlined Object.is polyfill to avoid requiring consumers ship their own
407 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
408 */
409 /*eslint-disable no-self-compare*/
410 function is(x, y) {
411 // SameValue algorithm
412 if (x === y) {
413 // Steps 1-5, 7-10
414 // Steps 6.b-6.e: +0 != -0
415 return x !== 0 || 1 / x === 1 / y;
416 } else {
417 // Step 6.a: NaN == NaN
418 return x !== x && y !== y;
419 }
420 }
421 /*eslint-enable no-self-compare*/
422
423 /**
424 * We use an Error-like object for backward compatibility as people may call
425 * PropTypes directly and inspect their output. However, we don't use real
426 * Errors anymore. We don't inspect their stack anyway, and creating them
427 * is prohibitively expensive if they are created too often, such as what
428 * happens in oneOfType() for any type before the one that matched.
429 */
430 function PropTypeError(message) {
431 this.message = message;
432 this.stack = '';
433 }
434 // Make `instanceof Error` still work for returned errors.
435 PropTypeError.prototype = Error.prototype;
436
437 function createChainableTypeChecker(validate) {
438 if (process.env.NODE_ENV !== 'production') {
439 var manualPropTypeCallCache = {};
440 var manualPropTypeWarningCount = 0;
441 }
442 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
443 componentName = componentName || ANONYMOUS;
444 propFullName = propFullName || propName;
445
446 if (secret !== ReactPropTypesSecret_1) {
447 if (throwOnDirectAccess) {
448 // New behavior only for users of `prop-types` package
449 invariant_1(
450 false,
451 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
452 'Use `PropTypes.checkPropTypes()` to call them. ' +
453 'Read more at http://fb.me/use-check-prop-types'
454 );
455 } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
456 // Old behavior for people using React.PropTypes
457 var cacheKey = componentName + ':' + propName;
458 if (
459 !manualPropTypeCallCache[cacheKey] &&
460 // Avoid spamming the console because they are often not actionable except for lib authors
461 manualPropTypeWarningCount < 3
462 ) {
463 warning_1(
464 false,
465 'You are manually calling a React.PropTypes validation ' +
466 'function for the `%s` prop on `%s`. This is deprecated ' +
467 'and will throw in the standalone `prop-types` package. ' +
468 'You may be seeing this warning due to a third-party PropTypes ' +
469 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
470 propFullName,
471 componentName
472 );
473 manualPropTypeCallCache[cacheKey] = true;
474 manualPropTypeWarningCount++;
475 }
476 }
477 }
478 if (props[propName] == null) {
479 if (isRequired) {
480 if (props[propName] === null) {
481 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
482 }
483 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
484 }
485 return null;
486 } else {
487 return validate(props, propName, componentName, location, propFullName);
488 }
489 }
490
491 var chainedCheckType = checkType.bind(null, false);
492 chainedCheckType.isRequired = checkType.bind(null, true);
493
494 return chainedCheckType;
495 }
496
497 function createPrimitiveTypeChecker(expectedType) {
498 function validate(props, propName, componentName, location, propFullName, secret) {
499 var propValue = props[propName];
500 var propType = getPropType(propValue);
501 if (propType !== expectedType) {
502 // `propValue` being instance of, say, date/regexp, pass the 'object'
503 // check, but we can offer a more precise error message here rather than
504 // 'of type `object`'.
505 var preciseType = getPreciseType(propValue);
506
507 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
508 }
509 return null;
510 }
511 return createChainableTypeChecker(validate);
512 }
513
514 function createAnyTypeChecker() {
515 return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
516 }
517
518 function createArrayOfTypeChecker(typeChecker) {
519 function validate(props, propName, componentName, location, propFullName) {
520 if (typeof typeChecker !== 'function') {
521 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
522 }
523 var propValue = props[propName];
524 if (!Array.isArray(propValue)) {
525 var propType = getPropType(propValue);
526 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
527 }
528 for (var i = 0; i < propValue.length; i++) {
529 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
530 if (error instanceof Error) {
531 return error;
532 }
533 }
534 return null;
535 }
536 return createChainableTypeChecker(validate);
537 }
538
539 function createElementTypeChecker() {
540 function validate(props, propName, componentName, location, propFullName) {
541 var propValue = props[propName];
542 if (!isValidElement(propValue)) {
543 var propType = getPropType(propValue);
544 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
545 }
546 return null;
547 }
548 return createChainableTypeChecker(validate);
549 }
550
551 function createInstanceTypeChecker(expectedClass) {
552 function validate(props, propName, componentName, location, propFullName) {
553 if (!(props[propName] instanceof expectedClass)) {
554 var expectedClassName = expectedClass.name || ANONYMOUS;
555 var actualClassName = getClassName(props[propName]);
556 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
557 }
558 return null;
559 }
560 return createChainableTypeChecker(validate);
561 }
562
563 function createEnumTypeChecker(expectedValues) {
564 if (!Array.isArray(expectedValues)) {
565 process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
566 return emptyFunction_1.thatReturnsNull;
567 }
568
569 function validate(props, propName, componentName, location, propFullName) {
570 var propValue = props[propName];
571 for (var i = 0; i < expectedValues.length; i++) {
572 if (is(propValue, expectedValues[i])) {
573 return null;
574 }
575 }
576
577 var valuesString = JSON.stringify(expectedValues);
578 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
579 }
580 return createChainableTypeChecker(validate);
581 }
582
583 function createObjectOfTypeChecker(typeChecker) {
584 function validate(props, propName, componentName, location, propFullName) {
585 if (typeof typeChecker !== 'function') {
586 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
587 }
588 var propValue = props[propName];
589 var propType = getPropType(propValue);
590 if (propType !== 'object') {
591 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
592 }
593 for (var key in propValue) {
594 if (propValue.hasOwnProperty(key)) {
595 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
596 if (error instanceof Error) {
597 return error;
598 }
599 }
600 }
601 return null;
602 }
603 return createChainableTypeChecker(validate);
604 }
605
606 function createUnionTypeChecker(arrayOfTypeCheckers) {
607 if (!Array.isArray(arrayOfTypeCheckers)) {
608 process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
609 return emptyFunction_1.thatReturnsNull;
610 }
611
612 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
613 var checker = arrayOfTypeCheckers[i];
614 if (typeof checker !== 'function') {
615 warning_1(
616 false,
617 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
618 'received %s at index %s.',
619 getPostfixForTypeWarning(checker),
620 i
621 );
622 return emptyFunction_1.thatReturnsNull;
623 }
624 }
625
626 function validate(props, propName, componentName, location, propFullName) {
627 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
628 var checker = arrayOfTypeCheckers[i];
629 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
630 return null;
631 }
632 }
633
634 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
635 }
636 return createChainableTypeChecker(validate);
637 }
638
639 function createNodeChecker() {
640 function validate(props, propName, componentName, location, propFullName) {
641 if (!isNode(props[propName])) {
642 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
643 }
644 return null;
645 }
646 return createChainableTypeChecker(validate);
647 }
648
649 function createShapeTypeChecker(shapeTypes) {
650 function validate(props, propName, componentName, location, propFullName) {
651 var propValue = props[propName];
652 var propType = getPropType(propValue);
653 if (propType !== 'object') {
654 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
655 }
656 for (var key in shapeTypes) {
657 var checker = shapeTypes[key];
658 if (!checker) {
659 continue;
660 }
661 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
662 if (error) {
663 return error;
664 }
665 }
666 return null;
667 }
668 return createChainableTypeChecker(validate);
669 }
670
671 function createStrictShapeTypeChecker(shapeTypes) {
672 function validate(props, propName, componentName, location, propFullName) {
673 var propValue = props[propName];
674 var propType = getPropType(propValue);
675 if (propType !== 'object') {
676 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
677 }
678 // We need to check all keys in case some are required but missing from
679 // props.
680 var allKeys = objectAssign({}, props[propName], shapeTypes);
681 for (var key in allKeys) {
682 var checker = shapeTypes[key];
683 if (!checker) {
684 return new PropTypeError(
685 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
686 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
687 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
688 );
689 }
690 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
691 if (error) {
692 return error;
693 }
694 }
695 return null;
696 }
697
698 return createChainableTypeChecker(validate);
699 }
700
701 function isNode(propValue) {
702 switch (typeof propValue) {
703 case 'number':
704 case 'string':
705 case 'undefined':
706 return true;
707 case 'boolean':
708 return !propValue;
709 case 'object':
710 if (Array.isArray(propValue)) {
711 return propValue.every(isNode);
712 }
713 if (propValue === null || isValidElement(propValue)) {
714 return true;
715 }
716
717 var iteratorFn = getIteratorFn(propValue);
718 if (iteratorFn) {
719 var iterator = iteratorFn.call(propValue);
720 var step;
721 if (iteratorFn !== propValue.entries) {
722 while (!(step = iterator.next()).done) {
723 if (!isNode(step.value)) {
724 return false;
725 }
726 }
727 } else {
728 // Iterator will provide entry [k,v] tuples rather than values.
729 while (!(step = iterator.next()).done) {
730 var entry = step.value;
731 if (entry) {
732 if (!isNode(entry[1])) {
733 return false;
734 }
735 }
736 }
737 }
738 } else {
739 return false;
740 }
741
742 return true;
743 default:
744 return false;
745 }
746 }
747
748 function isSymbol(propType, propValue) {
749 // Native Symbol.
750 if (propType === 'symbol') {
751 return true;
752 }
753
754 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
755 if (propValue['@@toStringTag'] === 'Symbol') {
756 return true;
757 }
758
759 // Fallback for non-spec compliant Symbols which are polyfilled.
760 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
761 return true;
762 }
763
764 return false;
765 }
766
767 // Equivalent of `typeof` but with special handling for array and regexp.
768 function getPropType(propValue) {
769 var propType = typeof propValue;
770 if (Array.isArray(propValue)) {
771 return 'array';
772 }
773 if (propValue instanceof RegExp) {
774 // Old webkits (at least until Android 4.0) return 'function' rather than
775 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
776 // passes PropTypes.object.
777 return 'object';
778 }
779 if (isSymbol(propType, propValue)) {
780 return 'symbol';
781 }
782 return propType;
783 }
784
785 // This handles more types than `getPropType`. Only used for error messages.
786 // See `createPrimitiveTypeChecker`.
787 function getPreciseType(propValue) {
788 if (typeof propValue === 'undefined' || propValue === null) {
789 return '' + propValue;
790 }
791 var propType = getPropType(propValue);
792 if (propType === 'object') {
793 if (propValue instanceof Date) {
794 return 'date';
795 } else if (propValue instanceof RegExp) {
796 return 'regexp';
797 }
798 }
799 return propType;
800 }
801
802 // Returns a string that is postfixed to a warning about an invalid type.
803 // For example, "undefined" or "of type array"
804 function getPostfixForTypeWarning(value) {
805 var type = getPreciseType(value);
806 switch (type) {
807 case 'array':
808 case 'object':
809 return 'an ' + type;
810 case 'boolean':
811 case 'date':
812 case 'regexp':
813 return 'a ' + type;
814 default:
815 return type;
816 }
817 }
818
819 // Returns class name of the object, if any.
820 function getClassName(propValue) {
821 if (!propValue.constructor || !propValue.constructor.name) {
822 return ANONYMOUS;
823 }
824 return propValue.constructor.name;
825 }
826
827 ReactPropTypes.checkPropTypes = checkPropTypes_1;
828 ReactPropTypes.PropTypes = ReactPropTypes;
829
830 return ReactPropTypes;
831};
832
833var factoryWithThrowingShims = function() {
834 function shim(props, propName, componentName, location, propFullName, secret) {
835 if (secret === ReactPropTypesSecret_1) {
836 // It is still safe when called from React.
837 return;
838 }
839 invariant_1(
840 false,
841 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
842 'Use PropTypes.checkPropTypes() to call them. ' +
843 'Read more at http://fb.me/use-check-prop-types'
844 );
845 } shim.isRequired = shim;
846 function getShim() {
847 return shim;
848 } // Important!
849 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
850 var ReactPropTypes = {
851 array: shim,
852 bool: shim,
853 func: shim,
854 number: shim,
855 object: shim,
856 string: shim,
857 symbol: shim,
858
859 any: shim,
860 arrayOf: getShim,
861 element: shim,
862 instanceOf: getShim,
863 node: shim,
864 objectOf: getShim,
865 oneOf: getShim,
866 oneOfType: getShim,
867 shape: getShim,
868 exact: getShim
869 };
870
871 ReactPropTypes.checkPropTypes = emptyFunction_1;
872 ReactPropTypes.PropTypes = ReactPropTypes;
873
874 return ReactPropTypes;
875};
876
877var propTypes = createCommonjsModule(function (module) {
878/**
879 * Copyright (c) 2013-present, Facebook, Inc.
880 *
881 * This source code is licensed under the MIT license found in the
882 * LICENSE file in the root directory of this source tree.
883 */
884
885if (process.env.NODE_ENV !== 'production') {
886 var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
887 Symbol.for &&
888 Symbol.for('react.element')) ||
889 0xeac7;
890
891 var isValidElement = function(object) {
892 return typeof object === 'object' &&
893 object !== null &&
894 object.$$typeof === REACT_ELEMENT_TYPE;
895 };
896
897 // By explicitly using `prop-types` you are opting into new development behavior.
898 // http://fb.me/prop-types-in-prod
899 var throwOnDirectAccess = true;
900 module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
901} else {
902 // By explicitly using `prop-types` you are opting into new production behavior.
903 // http://fb.me/prop-types-in-prod
904 module.exports = factoryWithThrowingShims();
905}
906});
907
908var key = '__global_unique_id__';
909
910var gud = function() {
911 return global[key] = (global[key] || 0) + 1;
912};
913
914var implementation = createCommonjsModule(function (module, exports) {
915
916exports.__esModule = true;
917
918
919
920var _react2 = _interopRequireDefault(React__default);
921
922
923
924var _propTypes2 = _interopRequireDefault(propTypes);
925
926
927
928var _gud2 = _interopRequireDefault(gud);
929
930
931
932var _warning2 = _interopRequireDefault(warning_1);
933
934function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
935
936function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
937
938function _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; }
939
940function _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; }
941
942var MAX_SIGNED_31_BIT_INT = 1073741823;
943
944// Inlined Object.is polyfill.
945// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
946function objectIs(x, y) {
947 if (x === y) {
948 return x !== 0 || 1 / x === 1 / y;
949 } else {
950 return x !== x && y !== y;
951 }
952}
953
954function createEventEmitter(value) {
955 var handlers = [];
956 return {
957 on: function on(handler) {
958 handlers.push(handler);
959 },
960 off: function off(handler) {
961 handlers = handlers.filter(function (h) {
962 return h !== handler;
963 });
964 },
965 get: function get() {
966 return value;
967 },
968 set: function set(newValue, changedBits) {
969 value = newValue;
970 handlers.forEach(function (handler) {
971 return handler(value, changedBits);
972 });
973 }
974 };
975}
976
977function onlyChild(children) {
978 return Array.isArray(children) ? children[0] : children;
979}
980
981function createReactContext(defaultValue, calculateChangedBits) {
982 var _Provider$childContex, _Consumer$contextType;
983
984 var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__';
985
986 var Provider = function (_Component) {
987 _inherits(Provider, _Component);
988
989 function Provider() {
990 var _temp, _this, _ret;
991
992 _classCallCheck(this, Provider);
993
994 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
995 args[_key] = arguments[_key];
996 }
997
998 return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret);
999 }
1000
1001 Provider.prototype.getChildContext = function getChildContext() {
1002 var _ref;
1003
1004 return _ref = {}, _ref[contextProp] = this.emitter, _ref;
1005 };
1006
1007 Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1008 if (this.props.value !== nextProps.value) {
1009 var oldValue = this.props.value;
1010 var newValue = nextProps.value;
1011 var changedBits = void 0;
1012
1013 if (objectIs(oldValue, newValue)) {
1014 changedBits = 0; // No change
1015 } else {
1016 changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
1017 if (process.env.NODE_ENV !== 'production') {
1018 (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);
1019 }
1020
1021 changedBits |= 0;
1022
1023 if (changedBits !== 0) {
1024 this.emitter.set(nextProps.value, changedBits);
1025 }
1026 }
1027 }
1028 };
1029
1030 Provider.prototype.render = function render() {
1031 return this.props.children;
1032 };
1033
1034 return Provider;
1035 }(React__default.Component);
1036
1037 Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex);
1038
1039 var Consumer = function (_Component2) {
1040 _inherits(Consumer, _Component2);
1041
1042 function Consumer() {
1043 var _temp2, _this2, _ret2;
1044
1045 _classCallCheck(this, Consumer);
1046
1047 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1048 args[_key2] = arguments[_key2];
1049 }
1050
1051 return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.state = {
1052 value: _this2.getValue()
1053 }, _this2.onUpdate = function (newValue, changedBits) {
1054 var observedBits = _this2.observedBits | 0;
1055 if ((observedBits & changedBits) !== 0) {
1056 _this2.setState({ value: _this2.getValue() });
1057 }
1058 }, _temp2), _possibleConstructorReturn(_this2, _ret2);
1059 }
1060
1061 Consumer.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1062 var observedBits = nextProps.observedBits;
1063
1064 this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1065 : observedBits;
1066 };
1067
1068 Consumer.prototype.componentDidMount = function componentDidMount() {
1069 if (this.context[contextProp]) {
1070 this.context[contextProp].on(this.onUpdate);
1071 }
1072 var observedBits = this.props.observedBits;
1073
1074 this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1075 : observedBits;
1076 };
1077
1078 Consumer.prototype.componentWillUnmount = function componentWillUnmount() {
1079 if (this.context[contextProp]) {
1080 this.context[contextProp].off(this.onUpdate);
1081 }
1082 };
1083
1084 Consumer.prototype.getValue = function getValue() {
1085 if (this.context[contextProp]) {
1086 return this.context[contextProp].get();
1087 } else {
1088 return defaultValue;
1089 }
1090 };
1091
1092 Consumer.prototype.render = function render() {
1093 return onlyChild(this.props.children)(this.state.value);
1094 };
1095
1096 return Consumer;
1097 }(React__default.Component);
1098
1099 Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = _propTypes2.default.object, _Consumer$contextType);
1100
1101
1102 return {
1103 Provider: Provider,
1104 Consumer: Consumer
1105 };
1106}
1107
1108exports.default = _react2.default.createContext || createReactContext;
1109module.exports = exports['default'];
1110});
1111
1112unwrapExports(implementation);
1113
1114var lib = createCommonjsModule(function (module, exports) {
1115
1116exports.__esModule = true;
1117
1118
1119
1120var _react2 = _interopRequireDefault(React__default);
1121
1122
1123
1124var _implementation2 = _interopRequireDefault(implementation);
1125
1126function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1127
1128exports.default = _react2.default.createContext || _implementation2.default;
1129module.exports = exports['default'];
1130});
1131
1132var createReactContext = unwrapExports(lib);
1133
1134var classCallCheck = function (instance, Constructor) {
1135 if (!(instance instanceof Constructor)) {
1136 throw new TypeError("Cannot call a class as a function");
1137 }
1138};
1139
1140var createClass = function () {
1141 function defineProperties(target, props) {
1142 for (var i = 0; i < props.length; i++) {
1143 var descriptor = props[i];
1144 descriptor.enumerable = descriptor.enumerable || false;
1145 descriptor.configurable = true;
1146 if ("value" in descriptor) descriptor.writable = true;
1147 Object.defineProperty(target, descriptor.key, descriptor);
1148 }
1149 }
1150
1151 return function (Constructor, protoProps, staticProps) {
1152 if (protoProps) defineProperties(Constructor.prototype, protoProps);
1153 if (staticProps) defineProperties(Constructor, staticProps);
1154 return Constructor;
1155 };
1156}();
1157
1158var _extends = Object.assign || function (target) {
1159 for (var i = 1; i < arguments.length; i++) {
1160 var source = arguments[i];
1161
1162 for (var key in source) {
1163 if (Object.prototype.hasOwnProperty.call(source, key)) {
1164 target[key] = source[key];
1165 }
1166 }
1167 }
1168
1169 return target;
1170};
1171
1172var inherits = function (subClass, superClass) {
1173 if (typeof superClass !== "function" && superClass !== null) {
1174 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
1175 }
1176
1177 subClass.prototype = Object.create(superClass && superClass.prototype, {
1178 constructor: {
1179 value: subClass,
1180 enumerable: false,
1181 writable: true,
1182 configurable: true
1183 }
1184 });
1185 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
1186};
1187
1188var objectWithoutProperties = function (obj, keys) {
1189 var target = {};
1190
1191 for (var i in obj) {
1192 if (keys.indexOf(i) >= 0) continue;
1193 if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
1194 target[i] = obj[i];
1195 }
1196
1197 return target;
1198};
1199
1200var possibleConstructorReturn = function (self, call) {
1201 if (!self) {
1202 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1203 }
1204
1205 return call && (typeof call === "object" || typeof call === "function") ? call : self;
1206};
1207
1208function createThemeProvider(defaultTheme, ThemeContext) {
1209 var _class, _temp;
1210
1211 return _temp = _class = function (_React$PureComponent) {
1212 inherits(ThemeProvider, _React$PureComponent);
1213
1214 function ThemeProvider() {
1215 classCallCheck(this, ThemeProvider);
1216 return possibleConstructorReturn(this, (ThemeProvider.__proto__ || Object.getPrototypeOf(ThemeProvider)).apply(this, arguments));
1217 }
1218
1219 createClass(ThemeProvider, [{
1220 key: 'render',
1221 value: function render() {
1222 return React.createElement(
1223 ThemeContext.Provider,
1224 { value: this.props.theme },
1225 this.props.children
1226 );
1227 }
1228 }]);
1229 return ThemeProvider;
1230 }(React.PureComponent), _class.defaultProps = {
1231 theme: defaultTheme
1232 }, _temp;
1233}
1234
1235var isMergeableObject = function isMergeableObject(value) {
1236 return isNonNullObject(value)
1237 && !isSpecial(value)
1238};
1239
1240function isNonNullObject(value) {
1241 return !!value && typeof value === 'object'
1242}
1243
1244function isSpecial(value) {
1245 var stringValue = Object.prototype.toString.call(value);
1246
1247 return stringValue === '[object RegExp]'
1248 || stringValue === '[object Date]'
1249 || isReactElement(value)
1250}
1251
1252// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
1253var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
1254var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
1255
1256function isReactElement(value) {
1257 return value.$$typeof === REACT_ELEMENT_TYPE
1258}
1259
1260function emptyTarget(val) {
1261 return Array.isArray(val) ? [] : {}
1262}
1263
1264function cloneUnlessOtherwiseSpecified(value, options) {
1265 return (options.clone !== false && options.isMergeableObject(value))
1266 ? deepmerge(emptyTarget(value), value, options)
1267 : value
1268}
1269
1270function defaultArrayMerge(target, source, options) {
1271 return target.concat(source).map(function(element) {
1272 return cloneUnlessOtherwiseSpecified(element, options)
1273 })
1274}
1275
1276function mergeObject(target, source, options) {
1277 var destination = {};
1278 if (options.isMergeableObject(target)) {
1279 Object.keys(target).forEach(function(key) {
1280 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
1281 });
1282 }
1283 Object.keys(source).forEach(function(key) {
1284 if (!options.isMergeableObject(source[key]) || !target[key]) {
1285 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
1286 } else {
1287 destination[key] = deepmerge(target[key], source[key], options);
1288 }
1289 });
1290 return destination
1291}
1292
1293function deepmerge(target, source, options) {
1294 options = options || {};
1295 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
1296 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
1297
1298 var sourceIsArray = Array.isArray(source);
1299 var targetIsArray = Array.isArray(target);
1300 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
1301
1302 if (!sourceAndTargetTypesMatch) {
1303 return cloneUnlessOtherwiseSpecified(source, options)
1304 } else if (sourceIsArray) {
1305 return options.arrayMerge(target, source, options)
1306 } else {
1307 return mergeObject(target, source, options)
1308 }
1309}
1310
1311deepmerge.all = function deepmergeAll(array, options) {
1312 if (!Array.isArray(array)) {
1313 throw new Error('first argument should be an array')
1314 }
1315
1316 return array.reduce(function(prev, next) {
1317 return deepmerge(prev, next, options)
1318 }, {})
1319};
1320
1321var deepmerge_1 = deepmerge;
1322
1323var hoistNonReactStatics = createCommonjsModule(function (module, exports) {
1324/**
1325 * Copyright 2015, Yahoo! Inc.
1326 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
1327 */
1328(function (global, factory) {
1329 module.exports = factory();
1330}(this, (function () {
1331
1332 var REACT_STATICS = {
1333 childContextTypes: true,
1334 contextTypes: true,
1335 defaultProps: true,
1336 displayName: true,
1337 getDefaultProps: true,
1338 getDerivedStateFromProps: true,
1339 mixins: true,
1340 propTypes: true,
1341 type: true
1342 };
1343
1344 var KNOWN_STATICS = {
1345 name: true,
1346 length: true,
1347 prototype: true,
1348 caller: true,
1349 callee: true,
1350 arguments: true,
1351 arity: true
1352 };
1353
1354 var defineProperty = Object.defineProperty;
1355 var getOwnPropertyNames = Object.getOwnPropertyNames;
1356 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1357 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1358 var getPrototypeOf = Object.getPrototypeOf;
1359 var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
1360
1361 return function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
1362 if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
1363
1364 if (objectPrototype) {
1365 var inheritedComponent = getPrototypeOf(sourceComponent);
1366 if (inheritedComponent && inheritedComponent !== objectPrototype) {
1367 hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
1368 }
1369 }
1370
1371 var keys = getOwnPropertyNames(sourceComponent);
1372
1373 if (getOwnPropertySymbols) {
1374 keys = keys.concat(getOwnPropertySymbols(sourceComponent));
1375 }
1376
1377 for (var i = 0; i < keys.length; ++i) {
1378 var key = keys[i];
1379 if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) {
1380 var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
1381 try { // Avoid failures from read-only properties
1382 defineProperty(targetComponent, key, descriptor);
1383 } catch (e) {}
1384 }
1385 }
1386
1387 return targetComponent;
1388 }
1389
1390 return targetComponent;
1391 };
1392})));
1393});
1394
1395var REACT_METHODS = ['autobind', 'childContextTypes', 'componentDidMount', 'componentDidUpdate', 'componentWillMount', 'componentWillReceiveProps', 'componentWillUnmount', 'componentWillUpdate', 'contextTypes', 'displayName', 'getChildContext', 'getDefaultProps', 'getDOMNode', 'getInitialState', 'mixins', 'propTypes', 'render', 'replaceProps', 'setProps', 'shouldComponentUpdate', 'statics', 'updateComponent'];
1396
1397function copyRefs(TargetComponent, SourceComponent) {
1398 if (!SourceComponent.prototype) {
1399 return TargetComponent;
1400 }
1401
1402 // $FlowFixMe
1403 Object.getOwnPropertyNames(SourceComponent.prototype).filter(function (prop) {
1404 return !(REACT_METHODS.includes(prop) || // React specific methods and properties
1405 prop in React.Component.prototype || // Properties from React's prototype such as `setState`
1406 // $FlowFixMe
1407 prop in TargetComponent.prototype || // Properties from enhanced component's prototype
1408 // Private methods
1409 prop.startsWith('_'));
1410 }).forEach(function (prop) {
1411 // $FlowFixMe
1412 if (typeof SourceComponent.prototype[prop] === 'function') {
1413 /* eslint-disable func-names, no-param-reassign */
1414 // $FlowFixMe
1415 TargetComponent.prototype[prop] = function () {
1416 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1417 args[_key] = arguments[_key];
1418 }
1419
1420 // Make sure the function is called with correct context
1421 // $FlowFixMe
1422 return SourceComponent.prototype[prop].apply(this.getWrappedInstance(), args);
1423 };
1424 } else {
1425 // Copy properties as getters and setters
1426 // This make sure dynamic properties always stay up-to-date
1427 // $FlowFixMe
1428 Object.defineProperty(TargetComponent.prototype, prop, {
1429 get: function get() {
1430 return this.getWrappedInstance()[prop];
1431 },
1432 set: function set(value) {
1433 this.getWrappedInstance()[prop] = value;
1434 }
1435 });
1436 }
1437 });
1438
1439 return TargetComponent;
1440}
1441
1442var isClassComponent = function isClassComponent(Component) {
1443 return Boolean(Component.prototype && Component.prototype.isReactComponent);
1444};
1445
1446var createWithTheme = function createWithTheme(ThemeProvider, ThemeContext) {
1447 return function withTheme(Comp) {
1448 var ThemedComponent = function (_React$Component) {
1449 inherits(ThemedComponent, _React$Component);
1450
1451 function ThemedComponent() {
1452 var _ref;
1453
1454 var _temp, _this, _ret;
1455
1456 classCallCheck(this, ThemedComponent);
1457
1458 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1459 args[_key] = arguments[_key];
1460 }
1461
1462 return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = ThemedComponent.__proto__ || Object.getPrototypeOf(ThemedComponent)).call.apply(_ref, [this].concat(args))), _this), _this._merge = function (a, b) {
1463 var previous = _this._previous;
1464
1465 if (previous && previous.a === a && previous.b === b) {
1466 return previous.result;
1467 }
1468
1469 var result = a && b ? deepmerge_1(a, b) : a || b;
1470
1471 _this._previous = { a: a, b: b, result: result };
1472
1473 return result;
1474 }, _temp), possibleConstructorReturn(_this, _ret);
1475 }
1476 /* $FlowFixMe */
1477
1478
1479 createClass(ThemedComponent, [{
1480 key: 'render',
1481 value: function render() {
1482 var _this2 = this;
1483
1484 var _props = this.props,
1485 forwardedRef = _props.forwardedRef,
1486 rest = objectWithoutProperties(_props, ['forwardedRef']);
1487
1488 return React.createElement(
1489 ThemeContext.Consumer,
1490 null,
1491 function (theme) {
1492 var merged = _this2._merge(theme, _this2.props.theme);
1493
1494 var element = void 0;
1495 if (isClassComponent(Comp)) {
1496 // Only add refs for class components as function components don't support them
1497 // It's needed to support use cases which need access to the underlying node
1498 element = React.createElement(Comp, _extends({}, rest, {
1499 ref: function ref(c) {
1500 _this2._root = c;
1501 },
1502 theme: merged
1503 }));
1504 } else {
1505 element = React.createElement(Comp, _extends({}, rest, { theme: merged }));
1506 }
1507
1508 if (merged !== _this2.props.theme) {
1509 // If a theme prop was passed, expose it to the children
1510 return React.createElement(
1511 ThemeProvider,
1512 { theme: merged },
1513 element
1514 );
1515 }
1516
1517 return element;
1518 }
1519 );
1520 }
1521 }]);
1522 return ThemedComponent;
1523 }(React.Component);
1524
1525 ThemedComponent.displayName = 'withTheme(' + (Comp.displayName || Comp.name) + ')';
1526
1527
1528 var ComponentWithMethods = ThemedComponent;
1529 if (isClassComponent(Comp)) {
1530 // getWrappedInstance is exposed by some HOCs like react-redux's connect
1531 // Use it to get the ref to the underlying element
1532 // Also expose it to access the underlying element after wrapping
1533 // $FlowFixMe
1534 ComponentWithMethods.prototype.getWrappedInstance = function getWrappedInstance() {
1535 return this._root.getWrappedInstance ? this._root.getWrappedInstance() : this._root;
1536 };
1537
1538 ComponentWithMethods = copyRefs(ComponentWithMethods, Comp);
1539 }
1540
1541 hoistNonReactStatics(ComponentWithMethods, Comp);
1542
1543 return ComponentWithMethods;
1544 };
1545};
1546
1547function createTheming(defaultTheme) {
1548 var ThemeContext = createReactContext(defaultTheme);
1549
1550 var ThemeProvider = createThemeProvider(defaultTheme, ThemeContext);
1551 var withTheme = createWithTheme(ThemeProvider, ThemeContext);
1552
1553 return {
1554 ThemeProvider: ThemeProvider,
1555 withTheme: withTheme
1556 };
1557}
1558
1559var _createTheming = createTheming({}),
1560 ThemeProvider = _createTheming.ThemeProvider,
1561 withTheme = _createTheming.withTheme;
1562
1563exports.ThemeProvider = ThemeProvider;
1564exports.withTheme = withTheme;
1565exports.createTheming = createTheming;