UNPKG

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