1 | import React__default, { createElement, PureComponent, Component } from 'react';
|
2 |
|
3 | function unwrapExports (x) {
|
4 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
5 | }
|
6 |
|
7 | function createCommonjsModule(fn, module) {
|
8 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function makeEmptyFunction(arg) {
|
21 | return function () {
|
22 | return arg;
|
23 | };
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | var emptyFunction = function emptyFunction() {};
|
32 |
|
33 | emptyFunction.thatReturns = makeEmptyFunction;
|
34 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
35 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
36 | emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
37 | emptyFunction.thatReturnsThis = function () {
|
38 | return this;
|
39 | };
|
40 | emptyFunction.thatReturnsArgument = function (arg) {
|
41 | return arg;
|
42 | };
|
43 |
|
44 | var emptyFunction_1 = emptyFunction;
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | var validateFormat = function validateFormat(format) {};
|
66 |
|
67 | if (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 |
|
75 | function 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;
|
92 | throw error;
|
93 | }
|
94 | }
|
95 |
|
96 | var invariant_1 = invariant;
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | var warning = emptyFunction_1;
|
106 |
|
107 | if (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 |
|
122 |
|
123 |
|
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;
|
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 |
|
147 | var warning_1 = warning;
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
156 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
157 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
158 |
|
159 | function 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 |
|
167 | function shouldUseNative() {
|
168 | try {
|
169 | if (!Object.assign) {
|
170 | return false;
|
171 | }
|
172 |
|
173 |
|
174 |
|
175 |
|
176 | var test1 = new String('abc');
|
177 | test1[5] = 'de';
|
178 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
179 | return false;
|
180 | }
|
181 |
|
182 |
|
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 |
|
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 |
|
207 | return false;
|
208 | }
|
209 | }
|
210 |
|
211 | var 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 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
246 |
|
247 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
248 |
|
249 | if (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 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | function 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 |
|
273 |
|
274 |
|
275 | try {
|
276 |
|
277 |
|
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 |
|
286 |
|
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 |
|
298 | var checkPropTypes_1 = checkPropTypes;
|
299 |
|
300 | var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
301 |
|
302 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
303 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
304 |
|
305 | |
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
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 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 | var ANONYMOUS = '<<anonymous>>';
|
374 |
|
375 |
|
376 |
|
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 |
|
400 |
|
401 |
|
402 |
|
403 | function is(x, y) {
|
404 |
|
405 | if (x === y) {
|
406 |
|
407 |
|
408 | return x !== 0 || 1 / x === 1 / y;
|
409 | } else {
|
410 |
|
411 | return x !== x && y !== y;
|
412 | }
|
413 | }
|
414 |
|
415 |
|
416 | |
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | function PropTypeError(message) {
|
424 | this.message = message;
|
425 | this.stack = '';
|
426 | }
|
427 |
|
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 |
|
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 |
|
450 | var cacheKey = componentName + ':' + propName;
|
451 | if (
|
452 | !manualPropTypeCallCache[cacheKey] &&
|
453 |
|
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 |
|
496 |
|
497 |
|
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 |
|
672 |
|
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 |
|
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 |
|
743 | if (propType === 'symbol') {
|
744 | return true;
|
745 | }
|
746 |
|
747 |
|
748 | if (propValue['@@toStringTag'] === 'Symbol') {
|
749 | return true;
|
750 | }
|
751 |
|
752 |
|
753 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
754 | return true;
|
755 | }
|
756 |
|
757 | return false;
|
758 | }
|
759 |
|
760 |
|
761 | function getPropType(propValue) {
|
762 | var propType = typeof propValue;
|
763 | if (Array.isArray(propValue)) {
|
764 | return 'array';
|
765 | }
|
766 | if (propValue instanceof RegExp) {
|
767 |
|
768 |
|
769 |
|
770 | return 'object';
|
771 | }
|
772 | if (isSymbol(propType, propValue)) {
|
773 | return 'symbol';
|
774 | }
|
775 | return propType;
|
776 | }
|
777 |
|
778 |
|
779 |
|
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 |
|
796 |
|
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 |
|
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 |
|
826 | var factoryWithThrowingShims = function() {
|
827 | function shim(props, propName, componentName, location, propFullName, secret) {
|
828 | if (secret === ReactPropTypesSecret_1) {
|
829 |
|
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 | }
|
842 |
|
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 |
|
870 | var propTypes = createCommonjsModule(function (module) {
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 | if (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 |
|
891 |
|
892 | var throwOnDirectAccess = true;
|
893 | module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
894 | } else {
|
895 |
|
896 |
|
897 | module.exports = factoryWithThrowingShims();
|
898 | }
|
899 | });
|
900 |
|
901 | var key = '__global_unique_id__';
|
902 |
|
903 | var gud = function() {
|
904 | return global[key] = (global[key] || 0) + 1;
|
905 | };
|
906 |
|
907 | var implementation = createCommonjsModule(function (module, exports) {
|
908 |
|
909 | exports.__esModule = true;
|
910 |
|
911 |
|
912 |
|
913 | var _react2 = _interopRequireDefault(React__default);
|
914 |
|
915 |
|
916 |
|
917 | var _propTypes2 = _interopRequireDefault(propTypes);
|
918 |
|
919 |
|
920 |
|
921 | var _gud2 = _interopRequireDefault(gud);
|
922 |
|
923 |
|
924 |
|
925 | var _warning2 = _interopRequireDefault(warning_1);
|
926 |
|
927 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
928 |
|
929 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
930 |
|
931 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
932 |
|
933 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
934 |
|
935 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
936 |
|
937 |
|
938 |
|
939 | function 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 |
|
947 | function 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 |
|
970 | function onlyChild(children) {
|
971 | return Array.isArray(children) ? children[0] : children;
|
972 | }
|
973 |
|
974 | function 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;
|
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
|
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
|
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 |
|
1101 | exports.default = _react2.default.createContext || createReactContext;
|
1102 | module.exports = exports['default'];
|
1103 | });
|
1104 |
|
1105 | unwrapExports(implementation);
|
1106 |
|
1107 | var lib = createCommonjsModule(function (module, exports) {
|
1108 |
|
1109 | exports.__esModule = true;
|
1110 |
|
1111 |
|
1112 |
|
1113 | var _react2 = _interopRequireDefault(React__default);
|
1114 |
|
1115 |
|
1116 |
|
1117 | var _implementation2 = _interopRequireDefault(implementation);
|
1118 |
|
1119 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1120 |
|
1121 | exports.default = _react2.default.createContext || _implementation2.default;
|
1122 | module.exports = exports['default'];
|
1123 | });
|
1124 |
|
1125 | var createReactContext = unwrapExports(lib);
|
1126 |
|
1127 | var classCallCheck = function (instance, Constructor) {
|
1128 | if (!(instance instanceof Constructor)) {
|
1129 | throw new TypeError("Cannot call a class as a function");
|
1130 | }
|
1131 | };
|
1132 |
|
1133 | var 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 |
|
1151 | var _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 |
|
1165 | var 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 |
|
1181 | var 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 |
|
1193 | var 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 |
|
1201 | function 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 |
|
1228 | var isMergeableObject = function isMergeableObject(value) {
|
1229 | return isNonNullObject(value)
|
1230 | && !isSpecial(value)
|
1231 | };
|
1232 |
|
1233 | function isNonNullObject(value) {
|
1234 | return !!value && typeof value === 'object'
|
1235 | }
|
1236 |
|
1237 | function 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 |
|
1246 | var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
1247 | var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
1248 |
|
1249 | function isReactElement(value) {
|
1250 | return value.$$typeof === REACT_ELEMENT_TYPE
|
1251 | }
|
1252 |
|
1253 | function emptyTarget(val) {
|
1254 | return Array.isArray(val) ? [] : {}
|
1255 | }
|
1256 |
|
1257 | function cloneUnlessOtherwiseSpecified(value, options) {
|
1258 | return (options.clone !== false && options.isMergeableObject(value))
|
1259 | ? deepmerge(emptyTarget(value), value, options)
|
1260 | : value
|
1261 | }
|
1262 |
|
1263 | function defaultArrayMerge(target, source, options) {
|
1264 | return target.concat(source).map(function(element) {
|
1265 | return cloneUnlessOtherwiseSpecified(element, options)
|
1266 | })
|
1267 | }
|
1268 |
|
1269 | function 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 |
|
1286 | function 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 |
|
1304 | deepmerge.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 |
|
1314 | var deepmerge_1 = deepmerge;
|
1315 |
|
1316 | var hoistNonReactStatics = createCommonjsModule(function (module, exports) {
|
1317 |
|
1318 |
|
1319 |
|
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') {
|
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 {
|
1375 | defineProperty(targetComponent, key, descriptor);
|
1376 | } catch (e) {}
|
1377 | }
|
1378 | }
|
1379 |
|
1380 | return targetComponent;
|
1381 | }
|
1382 |
|
1383 | return targetComponent;
|
1384 | };
|
1385 | })));
|
1386 | });
|
1387 |
|
1388 | var 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 |
|
1390 | function copyRefs(TargetComponent, SourceComponent) {
|
1391 | if (!SourceComponent.prototype) {
|
1392 | return TargetComponent;
|
1393 | }
|
1394 |
|
1395 |
|
1396 | Object.getOwnPropertyNames(SourceComponent.prototype).filter(function (prop) {
|
1397 | return !(REACT_METHODS.includes(prop) ||
|
1398 | prop in Component.prototype ||
|
1399 |
|
1400 | prop in TargetComponent.prototype ||
|
1401 |
|
1402 | prop.startsWith('_'));
|
1403 | }).forEach(function (prop) {
|
1404 |
|
1405 | if (typeof SourceComponent.prototype[prop] === 'function') {
|
1406 |
|
1407 |
|
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 |
|
1414 |
|
1415 | return SourceComponent.prototype[prop].apply(this.getWrappedInstance(), args);
|
1416 | };
|
1417 | } else {
|
1418 |
|
1419 |
|
1420 |
|
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 |
|
1435 | var isClassComponent = function isClassComponent(Component$$1) {
|
1436 | return Boolean(Component$$1.prototype && Component$$1.prototype.isReactComponent);
|
1437 | };
|
1438 |
|
1439 | var 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 |
|
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 |
|
1490 |
|
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 |
|
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 |
|
1524 |
|
1525 |
|
1526 |
|
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 |
|
1540 | function 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 |
|
1552 | var _createTheming = createTheming({}),
|
1553 | ThemeProvider = _createTheming.ThemeProvider,
|
1554 | withTheme = _createTheming.withTheme;
|
1555 |
|
1556 | export { ThemeProvider, withTheme, createTheming };
|