@handsontable/react 14.3.0 → 14.4.0-next-0a79a1f-20240521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commonjs/react-handsontable.js +927 -885
- package/dist/react-handsontable.js +140 -356
- package/dist/react-handsontable.js.map +1 -1
- package/dist/react-handsontable.min.js +2 -2
- package/dist/react-handsontable.min.js.map +1 -1
- package/es/react-handsontable.mjs +927 -885
- package/hotTableClass.d.ts +11 -2
- package/package.json +13 -13
- package/settingsMapper.d.ts +8 -1
|
@@ -40,11 +40,11 @@ function _toPrimitive(t, r) {
|
|
|
40
40
|
if ("object" != typeof t || !t) return t;
|
|
41
41
|
var e = t[Symbol.toPrimitive];
|
|
42
42
|
if (void 0 !== e) {
|
|
43
|
-
var i = e.call(t, r
|
|
43
|
+
var i = e.call(t, r );
|
|
44
44
|
if ("object" != typeof i) return i;
|
|
45
45
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
46
46
|
}
|
|
47
|
-
return (
|
|
47
|
+
return (String )(t);
|
|
48
48
|
}
|
|
49
49
|
function _toPropertyKey(t) {
|
|
50
50
|
var i = _toPrimitive(t, "string");
|
|
@@ -127,12 +127,11 @@ function _setPrototypeOf(o, p) {
|
|
|
127
127
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
128
128
|
if (source == null) return {};
|
|
129
129
|
var target = {};
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
target[key] = source[key];
|
|
130
|
+
for (var key in source) {
|
|
131
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
132
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
133
|
+
target[key] = source[key];
|
|
134
|
+
}
|
|
136
135
|
}
|
|
137
136
|
return target;
|
|
138
137
|
}
|
|
@@ -363,20 +362,37 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
363
362
|
* Parse component settings into Handosntable-compatible settings.
|
|
364
363
|
*
|
|
365
364
|
* @param {Object} properties Object containing properties from the HotTable object.
|
|
365
|
+
* @param {Object} additionalSettings Additional settings.
|
|
366
|
+
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
367
|
+
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
366
368
|
* @returns {Object} Handsontable-compatible settings object.
|
|
367
369
|
*/
|
|
368
370
|
function getSettings(properties) {
|
|
371
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
372
|
+
_ref$prevProps = _ref.prevProps,
|
|
373
|
+
prevProps = _ref$prevProps === void 0 ? {} : _ref$prevProps,
|
|
374
|
+
_ref$isInit = _ref.isInit,
|
|
375
|
+
isInit = _ref$isInit === void 0 ? false : _ref$isInit,
|
|
376
|
+
_ref$initOnlySettingK = _ref.initOnlySettingKeys,
|
|
377
|
+
initOnlySettingKeys = _ref$initOnlySettingK === void 0 ? [] : _ref$initOnlySettingK;
|
|
378
|
+
var shouldSkipProp = function shouldSkipProp(key) {
|
|
379
|
+
// Omit settings that can be set only during initialization and are intentionally modified.
|
|
380
|
+
if (!isInit && initOnlySettingKeys.includes(key)) {
|
|
381
|
+
return prevProps[key] === properties[key];
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
};
|
|
369
385
|
var newSettings = {};
|
|
370
386
|
if (properties.settings) {
|
|
371
387
|
var settings = properties.settings;
|
|
372
388
|
for (var key in settings) {
|
|
373
|
-
if (settings.hasOwnProperty(key)) {
|
|
389
|
+
if (settings.hasOwnProperty(key) && !shouldSkipProp(key)) {
|
|
374
390
|
newSettings[key] = settings[key];
|
|
375
391
|
}
|
|
376
392
|
}
|
|
377
393
|
}
|
|
378
394
|
for (var _key in properties) {
|
|
379
|
-
if (_key !== 'settings' && _key !== 'children' && properties.hasOwnProperty(_key)) {
|
|
395
|
+
if (_key !== 'settings' && _key !== 'children' && !shouldSkipProp(_key) && properties.hasOwnProperty(_key)) {
|
|
380
396
|
newSettings[_key] = properties[_key];
|
|
381
397
|
}
|
|
382
398
|
}
|
|
@@ -504,160 +520,137 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
|
504
520
|
}]);
|
|
505
521
|
}(React.Component);
|
|
506
522
|
|
|
507
|
-
var version="14.
|
|
523
|
+
var version="14.4.0-next-0a79a1f-20240521";
|
|
508
524
|
|
|
509
|
-
function
|
|
510
|
-
return
|
|
525
|
+
function getDefaultExportFromCjs (x) {
|
|
526
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
511
527
|
}
|
|
512
528
|
|
|
513
|
-
|
|
514
|
-
* react-is.production.min.js
|
|
515
|
-
*
|
|
516
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
517
|
-
*
|
|
518
|
-
* This source code is licensed under the MIT license found in the
|
|
519
|
-
* LICENSE file in the root directory of this source tree.
|
|
520
|
-
*/
|
|
529
|
+
var propTypes = {exports: {}};
|
|
521
530
|
|
|
522
|
-
var
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
531
|
+
var reactIs = {exports: {}};
|
|
532
|
+
|
|
533
|
+
var reactIs_production_min = {};
|
|
534
|
+
|
|
535
|
+
var hasRequiredReactIs_production_min;
|
|
536
|
+
function requireReactIs_production_min() {
|
|
537
|
+
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
538
|
+
hasRequiredReactIs_production_min = 1;
|
|
539
|
+
var b = "function" === typeof Symbol && Symbol["for"],
|
|
540
|
+
c = b ? Symbol["for"]("react.element") : 60103,
|
|
541
|
+
d = b ? Symbol["for"]("react.portal") : 60106,
|
|
542
|
+
e = b ? Symbol["for"]("react.fragment") : 60107,
|
|
543
|
+
f = b ? Symbol["for"]("react.strict_mode") : 60108,
|
|
544
|
+
g = b ? Symbol["for"]("react.profiler") : 60114,
|
|
545
|
+
h = b ? Symbol["for"]("react.provider") : 60109,
|
|
546
|
+
k = b ? Symbol["for"]("react.context") : 60110,
|
|
547
|
+
l = b ? Symbol["for"]("react.async_mode") : 60111,
|
|
548
|
+
m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
|
|
549
|
+
n = b ? Symbol["for"]("react.forward_ref") : 60112,
|
|
550
|
+
p = b ? Symbol["for"]("react.suspense") : 60113,
|
|
551
|
+
q = b ? Symbol["for"]("react.suspense_list") : 60120,
|
|
552
|
+
r = b ? Symbol["for"]("react.memo") : 60115,
|
|
553
|
+
t = b ? Symbol["for"]("react.lazy") : 60116,
|
|
554
|
+
v = b ? Symbol["for"]("react.block") : 60121,
|
|
555
|
+
w = b ? Symbol["for"]("react.fundamental") : 60117,
|
|
556
|
+
x = b ? Symbol["for"]("react.responder") : 60118,
|
|
557
|
+
y = b ? Symbol["for"]("react.scope") : 60119;
|
|
558
|
+
function z(a) {
|
|
559
|
+
if ("object" === _typeof(a) && null !== a) {
|
|
560
|
+
var u = a.$$typeof;
|
|
561
|
+
switch (u) {
|
|
562
|
+
case c:
|
|
563
|
+
switch (a = a.type, a) {
|
|
564
|
+
case l:
|
|
565
|
+
case m:
|
|
566
|
+
case e:
|
|
567
|
+
case g:
|
|
568
|
+
case f:
|
|
569
|
+
case p:
|
|
570
|
+
return a;
|
|
571
|
+
default:
|
|
572
|
+
switch (a = a && a.$$typeof, a) {
|
|
573
|
+
case k:
|
|
574
|
+
case n:
|
|
575
|
+
case t:
|
|
576
|
+
case r:
|
|
577
|
+
case h:
|
|
578
|
+
return a;
|
|
579
|
+
default:
|
|
580
|
+
return u;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
case d:
|
|
584
|
+
return u;
|
|
585
|
+
}
|
|
568
586
|
}
|
|
569
587
|
}
|
|
588
|
+
function A(a) {
|
|
589
|
+
return z(a) === m;
|
|
590
|
+
}
|
|
591
|
+
reactIs_production_min.AsyncMode = l;
|
|
592
|
+
reactIs_production_min.ConcurrentMode = m;
|
|
593
|
+
reactIs_production_min.ContextConsumer = k;
|
|
594
|
+
reactIs_production_min.ContextProvider = h;
|
|
595
|
+
reactIs_production_min.Element = c;
|
|
596
|
+
reactIs_production_min.ForwardRef = n;
|
|
597
|
+
reactIs_production_min.Fragment = e;
|
|
598
|
+
reactIs_production_min.Lazy = t;
|
|
599
|
+
reactIs_production_min.Memo = r;
|
|
600
|
+
reactIs_production_min.Portal = d;
|
|
601
|
+
reactIs_production_min.Profiler = g;
|
|
602
|
+
reactIs_production_min.StrictMode = f;
|
|
603
|
+
reactIs_production_min.Suspense = p;
|
|
604
|
+
reactIs_production_min.isAsyncMode = function (a) {
|
|
605
|
+
return A(a) || z(a) === l;
|
|
606
|
+
};
|
|
607
|
+
reactIs_production_min.isConcurrentMode = A;
|
|
608
|
+
reactIs_production_min.isContextConsumer = function (a) {
|
|
609
|
+
return z(a) === k;
|
|
610
|
+
};
|
|
611
|
+
reactIs_production_min.isContextProvider = function (a) {
|
|
612
|
+
return z(a) === h;
|
|
613
|
+
};
|
|
614
|
+
reactIs_production_min.isElement = function (a) {
|
|
615
|
+
return "object" === _typeof(a) && null !== a && a.$$typeof === c;
|
|
616
|
+
};
|
|
617
|
+
reactIs_production_min.isForwardRef = function (a) {
|
|
618
|
+
return z(a) === n;
|
|
619
|
+
};
|
|
620
|
+
reactIs_production_min.isFragment = function (a) {
|
|
621
|
+
return z(a) === e;
|
|
622
|
+
};
|
|
623
|
+
reactIs_production_min.isLazy = function (a) {
|
|
624
|
+
return z(a) === t;
|
|
625
|
+
};
|
|
626
|
+
reactIs_production_min.isMemo = function (a) {
|
|
627
|
+
return z(a) === r;
|
|
628
|
+
};
|
|
629
|
+
reactIs_production_min.isPortal = function (a) {
|
|
630
|
+
return z(a) === d;
|
|
631
|
+
};
|
|
632
|
+
reactIs_production_min.isProfiler = function (a) {
|
|
633
|
+
return z(a) === g;
|
|
634
|
+
};
|
|
635
|
+
reactIs_production_min.isStrictMode = function (a) {
|
|
636
|
+
return z(a) === f;
|
|
637
|
+
};
|
|
638
|
+
reactIs_production_min.isSuspense = function (a) {
|
|
639
|
+
return z(a) === p;
|
|
640
|
+
};
|
|
641
|
+
reactIs_production_min.isValidElementType = function (a) {
|
|
642
|
+
return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
|
|
643
|
+
};
|
|
644
|
+
reactIs_production_min.typeOf = z;
|
|
645
|
+
return reactIs_production_min;
|
|
570
646
|
}
|
|
571
|
-
function A(a) {
|
|
572
|
-
return z(a) === m;
|
|
573
|
-
}
|
|
574
|
-
var AsyncMode = l;
|
|
575
|
-
var ConcurrentMode = m;
|
|
576
|
-
var ContextConsumer = k;
|
|
577
|
-
var ContextProvider = h;
|
|
578
|
-
var Element = c;
|
|
579
|
-
var ForwardRef = n;
|
|
580
|
-
var Fragment = e;
|
|
581
|
-
var Lazy = t;
|
|
582
|
-
var Memo = r;
|
|
583
|
-
var Portal = d;
|
|
584
|
-
var Profiler = g;
|
|
585
|
-
var StrictMode = f;
|
|
586
|
-
var Suspense = p;
|
|
587
|
-
var isAsyncMode = function isAsyncMode(a) {
|
|
588
|
-
return A(a) || z(a) === l;
|
|
589
|
-
};
|
|
590
|
-
var isConcurrentMode = A;
|
|
591
|
-
var isContextConsumer = function isContextConsumer(a) {
|
|
592
|
-
return z(a) === k;
|
|
593
|
-
};
|
|
594
|
-
var isContextProvider = function isContextProvider(a) {
|
|
595
|
-
return z(a) === h;
|
|
596
|
-
};
|
|
597
|
-
var isElement = function isElement(a) {
|
|
598
|
-
return "object" === _typeof(a) && null !== a && a.$$typeof === c;
|
|
599
|
-
};
|
|
600
|
-
var isForwardRef = function isForwardRef(a) {
|
|
601
|
-
return z(a) === n;
|
|
602
|
-
};
|
|
603
|
-
var isFragment = function isFragment(a) {
|
|
604
|
-
return z(a) === e;
|
|
605
|
-
};
|
|
606
|
-
var isLazy = function isLazy(a) {
|
|
607
|
-
return z(a) === t;
|
|
608
|
-
};
|
|
609
|
-
var isMemo = function isMemo(a) {
|
|
610
|
-
return z(a) === r;
|
|
611
|
-
};
|
|
612
|
-
var isPortal = function isPortal(a) {
|
|
613
|
-
return z(a) === d;
|
|
614
|
-
};
|
|
615
|
-
var isProfiler = function isProfiler(a) {
|
|
616
|
-
return z(a) === g;
|
|
617
|
-
};
|
|
618
|
-
var isStrictMode = function isStrictMode(a) {
|
|
619
|
-
return z(a) === f;
|
|
620
|
-
};
|
|
621
|
-
var isSuspense = function isSuspense(a) {
|
|
622
|
-
return z(a) === p;
|
|
623
|
-
};
|
|
624
|
-
var isValidElementType = function isValidElementType(a) {
|
|
625
|
-
return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
|
|
626
|
-
};
|
|
627
|
-
var typeOf = z;
|
|
628
|
-
var reactIs_production_min = {
|
|
629
|
-
AsyncMode: AsyncMode,
|
|
630
|
-
ConcurrentMode: ConcurrentMode,
|
|
631
|
-
ContextConsumer: ContextConsumer,
|
|
632
|
-
ContextProvider: ContextProvider,
|
|
633
|
-
Element: Element,
|
|
634
|
-
ForwardRef: ForwardRef,
|
|
635
|
-
Fragment: Fragment,
|
|
636
|
-
Lazy: Lazy,
|
|
637
|
-
Memo: Memo,
|
|
638
|
-
Portal: Portal,
|
|
639
|
-
Profiler: Profiler,
|
|
640
|
-
StrictMode: StrictMode,
|
|
641
|
-
Suspense: Suspense,
|
|
642
|
-
isAsyncMode: isAsyncMode,
|
|
643
|
-
isConcurrentMode: isConcurrentMode,
|
|
644
|
-
isContextConsumer: isContextConsumer,
|
|
645
|
-
isContextProvider: isContextProvider,
|
|
646
|
-
isElement: isElement,
|
|
647
|
-
isForwardRef: isForwardRef,
|
|
648
|
-
isFragment: isFragment,
|
|
649
|
-
isLazy: isLazy,
|
|
650
|
-
isMemo: isMemo,
|
|
651
|
-
isPortal: isPortal,
|
|
652
|
-
isProfiler: isProfiler,
|
|
653
|
-
isStrictMode: isStrictMode,
|
|
654
|
-
isSuspense: isSuspense,
|
|
655
|
-
isValidElementType: isValidElementType,
|
|
656
|
-
typeOf: typeOf
|
|
657
|
-
};
|
|
658
647
|
|
|
659
|
-
var reactIs_development =
|
|
648
|
+
var reactIs_development = {};
|
|
660
649
|
|
|
650
|
+
var hasRequiredReactIs_development;
|
|
651
|
+
function requireReactIs_development() {
|
|
652
|
+
if (hasRequiredReactIs_development) return reactIs_development;
|
|
653
|
+
hasRequiredReactIs_development = 1;
|
|
661
654
|
if (process.env.NODE_ENV !== "production") {
|
|
662
655
|
(function () {
|
|
663
656
|
|
|
@@ -784,155 +777,136 @@ var reactIs_development = createCommonjsModule(function (module, exports) {
|
|
|
784
777
|
function isSuspense(object) {
|
|
785
778
|
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
786
779
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
780
|
+
reactIs_development.AsyncMode = AsyncMode;
|
|
781
|
+
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
782
|
+
reactIs_development.ContextConsumer = ContextConsumer;
|
|
783
|
+
reactIs_development.ContextProvider = ContextProvider;
|
|
784
|
+
reactIs_development.Element = Element;
|
|
785
|
+
reactIs_development.ForwardRef = ForwardRef;
|
|
786
|
+
reactIs_development.Fragment = Fragment;
|
|
787
|
+
reactIs_development.Lazy = Lazy;
|
|
788
|
+
reactIs_development.Memo = Memo;
|
|
789
|
+
reactIs_development.Portal = Portal;
|
|
790
|
+
reactIs_development.Profiler = Profiler;
|
|
791
|
+
reactIs_development.StrictMode = StrictMode;
|
|
792
|
+
reactIs_development.Suspense = Suspense;
|
|
793
|
+
reactIs_development.isAsyncMode = isAsyncMode;
|
|
794
|
+
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
795
|
+
reactIs_development.isContextConsumer = isContextConsumer;
|
|
796
|
+
reactIs_development.isContextProvider = isContextProvider;
|
|
797
|
+
reactIs_development.isElement = isElement;
|
|
798
|
+
reactIs_development.isForwardRef = isForwardRef;
|
|
799
|
+
reactIs_development.isFragment = isFragment;
|
|
800
|
+
reactIs_development.isLazy = isLazy;
|
|
801
|
+
reactIs_development.isMemo = isMemo;
|
|
802
|
+
reactIs_development.isPortal = isPortal;
|
|
803
|
+
reactIs_development.isProfiler = isProfiler;
|
|
804
|
+
reactIs_development.isStrictMode = isStrictMode;
|
|
805
|
+
reactIs_development.isSuspense = isSuspense;
|
|
806
|
+
reactIs_development.isValidElementType = isValidElementType;
|
|
807
|
+
reactIs_development.typeOf = typeOf;
|
|
815
808
|
})();
|
|
816
809
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
reactIs_development.ConcurrentMode;
|
|
820
|
-
reactIs_development.ContextConsumer;
|
|
821
|
-
reactIs_development.ContextProvider;
|
|
822
|
-
reactIs_development.Element;
|
|
823
|
-
reactIs_development.ForwardRef;
|
|
824
|
-
reactIs_development.Fragment;
|
|
825
|
-
reactIs_development.Lazy;
|
|
826
|
-
reactIs_development.Memo;
|
|
827
|
-
reactIs_development.Portal;
|
|
828
|
-
reactIs_development.Profiler;
|
|
829
|
-
reactIs_development.StrictMode;
|
|
830
|
-
reactIs_development.Suspense;
|
|
831
|
-
reactIs_development.isAsyncMode;
|
|
832
|
-
reactIs_development.isConcurrentMode;
|
|
833
|
-
reactIs_development.isContextConsumer;
|
|
834
|
-
reactIs_development.isContextProvider;
|
|
835
|
-
reactIs_development.isElement;
|
|
836
|
-
reactIs_development.isForwardRef;
|
|
837
|
-
reactIs_development.isFragment;
|
|
838
|
-
reactIs_development.isLazy;
|
|
839
|
-
reactIs_development.isMemo;
|
|
840
|
-
reactIs_development.isPortal;
|
|
841
|
-
reactIs_development.isProfiler;
|
|
842
|
-
reactIs_development.isStrictMode;
|
|
843
|
-
reactIs_development.isSuspense;
|
|
844
|
-
reactIs_development.isValidElementType;
|
|
845
|
-
reactIs_development.typeOf;
|
|
846
|
-
|
|
847
|
-
var reactIs = createCommonjsModule(function (module) {
|
|
810
|
+
return reactIs_development;
|
|
811
|
+
}
|
|
848
812
|
|
|
813
|
+
var hasRequiredReactIs;
|
|
814
|
+
function requireReactIs() {
|
|
815
|
+
if (hasRequiredReactIs) return reactIs.exports;
|
|
816
|
+
hasRequiredReactIs = 1;
|
|
849
817
|
if (process.env.NODE_ENV === 'production') {
|
|
850
|
-
|
|
818
|
+
reactIs.exports = requireReactIs_production_min();
|
|
851
819
|
} else {
|
|
852
|
-
|
|
820
|
+
reactIs.exports = requireReactIs_development();
|
|
853
821
|
}
|
|
854
|
-
|
|
822
|
+
return reactIs.exports;
|
|
823
|
+
}
|
|
855
824
|
|
|
856
825
|
/*
|
|
857
826
|
object-assign
|
|
858
827
|
(c) Sindre Sorhus
|
|
859
828
|
@license MIT
|
|
860
829
|
*/
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
830
|
+
var objectAssign;
|
|
831
|
+
var hasRequiredObjectAssign;
|
|
832
|
+
function requireObjectAssign() {
|
|
833
|
+
if (hasRequiredObjectAssign) return objectAssign;
|
|
834
|
+
hasRequiredObjectAssign = 1;
|
|
835
|
+
/* eslint-disable no-unused-vars */
|
|
836
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
837
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
838
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
839
|
+
function toObject(val) {
|
|
840
|
+
if (val === null || val === undefined) {
|
|
841
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
842
|
+
}
|
|
843
|
+
return Object(val);
|
|
870
844
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
return false;
|
|
877
|
-
}
|
|
845
|
+
function shouldUseNative() {
|
|
846
|
+
try {
|
|
847
|
+
if (!Object.assign) {
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
878
850
|
|
|
879
|
-
|
|
851
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
880
852
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
853
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
854
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
855
|
+
test1[5] = 'de';
|
|
856
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
887
859
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
860
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
861
|
+
var test2 = {};
|
|
862
|
+
for (var i = 0; i < 10; i++) {
|
|
863
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
864
|
+
}
|
|
865
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
866
|
+
return test2[n];
|
|
867
|
+
});
|
|
868
|
+
if (order2.join('') !== '0123456789') {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
899
871
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
872
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
873
|
+
var test3 = {};
|
|
874
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
875
|
+
test3[letter] = letter;
|
|
876
|
+
});
|
|
877
|
+
if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
return true;
|
|
881
|
+
} catch (err) {
|
|
882
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
906
883
|
return false;
|
|
907
884
|
}
|
|
908
|
-
return true;
|
|
909
|
-
} catch (err) {
|
|
910
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
911
|
-
return false;
|
|
912
885
|
}
|
|
913
|
-
|
|
914
|
-
var
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
886
|
+
objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
887
|
+
var from;
|
|
888
|
+
var to = toObject(target);
|
|
889
|
+
var symbols;
|
|
890
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
891
|
+
from = Object(arguments[s]);
|
|
892
|
+
for (var key in from) {
|
|
893
|
+
if (hasOwnProperty.call(from, key)) {
|
|
894
|
+
to[key] = from[key];
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (getOwnPropertySymbols) {
|
|
898
|
+
symbols = getOwnPropertySymbols(from);
|
|
899
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
900
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
901
|
+
to[symbols[i]] = from[symbols[i]];
|
|
902
|
+
}
|
|
930
903
|
}
|
|
931
904
|
}
|
|
932
905
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
906
|
+
return to;
|
|
907
|
+
};
|
|
908
|
+
return objectAssign;
|
|
909
|
+
}
|
|
936
910
|
|
|
937
911
|
/**
|
|
938
912
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -940,692 +914,736 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
|
|
|
940
914
|
* This source code is licensed under the MIT license found in the
|
|
941
915
|
* LICENSE file in the root directory of this source tree.
|
|
942
916
|
*/
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
var
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
952
|
-
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
953
|
-
var loggedTypeFailures = {};
|
|
954
|
-
var has = has$1;
|
|
955
|
-
printWarning$1 = function printWarning(text) {
|
|
956
|
-
var message = 'Warning: ' + text;
|
|
957
|
-
if (typeof console !== 'undefined') {
|
|
958
|
-
console.error(message);
|
|
959
|
-
}
|
|
960
|
-
try {
|
|
961
|
-
// --- Welcome to debugging React ---
|
|
962
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
963
|
-
// to find the callsite that caused this warning to fire.
|
|
964
|
-
throw new Error(message);
|
|
965
|
-
} catch (x) {/**/}
|
|
966
|
-
};
|
|
917
|
+
var ReactPropTypesSecret_1;
|
|
918
|
+
var hasRequiredReactPropTypesSecret;
|
|
919
|
+
function requireReactPropTypesSecret() {
|
|
920
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
921
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
922
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
923
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
924
|
+
return ReactPropTypesSecret_1;
|
|
967
925
|
}
|
|
968
926
|
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
* @param {string} componentName Name of the component for error messages.
|
|
977
|
-
* @param {?Function} getStack Returns the component stack.
|
|
978
|
-
* @private
|
|
979
|
-
*/
|
|
980
|
-
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
981
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
982
|
-
for (var typeSpecName in typeSpecs) {
|
|
983
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
984
|
-
var error;
|
|
985
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
986
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
987
|
-
// After these have been cleaned up, we'll let them throw.
|
|
988
|
-
try {
|
|
989
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
990
|
-
// behavior as without this statement except with a better message.
|
|
991
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
992
|
-
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + _typeof(typeSpecs[typeSpecName]) + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
993
|
-
err.name = 'Invariant Violation';
|
|
994
|
-
throw err;
|
|
995
|
-
}
|
|
996
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
997
|
-
} catch (ex) {
|
|
998
|
-
error = ex;
|
|
999
|
-
}
|
|
1000
|
-
if (error && !(error instanceof Error)) {
|
|
1001
|
-
printWarning$1((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + _typeof(error) + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
|
|
1002
|
-
}
|
|
1003
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
1004
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
1005
|
-
// same error.
|
|
1006
|
-
loggedTypeFailures[error.message] = true;
|
|
1007
|
-
var stack = getStack ? getStack() : '';
|
|
1008
|
-
printWarning$1('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
927
|
+
var has;
|
|
928
|
+
var hasRequiredHas;
|
|
929
|
+
function requireHas() {
|
|
930
|
+
if (hasRequiredHas) return has;
|
|
931
|
+
hasRequiredHas = 1;
|
|
932
|
+
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
933
|
+
return has;
|
|
1013
934
|
}
|
|
1014
935
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
936
|
+
var checkPropTypes_1;
|
|
937
|
+
var hasRequiredCheckPropTypes;
|
|
938
|
+
function requireCheckPropTypes() {
|
|
939
|
+
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
940
|
+
hasRequiredCheckPropTypes = 1;
|
|
941
|
+
var printWarning = function printWarning() {};
|
|
1021
942
|
if (process.env.NODE_ENV !== 'production') {
|
|
1022
|
-
|
|
943
|
+
var ReactPropTypesSecret = requireReactPropTypesSecret();
|
|
944
|
+
var loggedTypeFailures = {};
|
|
945
|
+
var has = requireHas();
|
|
946
|
+
printWarning = function printWarning(text) {
|
|
947
|
+
var message = 'Warning: ' + text;
|
|
948
|
+
if (typeof console !== 'undefined') {
|
|
949
|
+
console.error(message);
|
|
950
|
+
}
|
|
951
|
+
try {
|
|
952
|
+
// --- Welcome to debugging React ---
|
|
953
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
954
|
+
// to find the callsite that caused this warning to fire.
|
|
955
|
+
throw new Error(message);
|
|
956
|
+
} catch (x) {/**/}
|
|
957
|
+
};
|
|
1023
958
|
}
|
|
1024
|
-
};
|
|
1025
|
-
var checkPropTypes_1 = checkPropTypes;
|
|
1026
|
-
|
|
1027
|
-
var printWarning = function printWarning() {};
|
|
1028
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1029
|
-
printWarning = function printWarning(text) {
|
|
1030
|
-
var message = 'Warning: ' + text;
|
|
1031
|
-
if (typeof console !== 'undefined') {
|
|
1032
|
-
console.error(message);
|
|
1033
|
-
}
|
|
1034
|
-
try {
|
|
1035
|
-
// --- Welcome to debugging React ---
|
|
1036
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
1037
|
-
// to find the callsite that caused this warning to fire.
|
|
1038
|
-
throw new Error(message);
|
|
1039
|
-
} catch (x) {}
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
function emptyFunctionThatReturnsNull() {
|
|
1043
|
-
return null;
|
|
1044
|
-
}
|
|
1045
|
-
var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, throwOnDirectAccess) {
|
|
1046
|
-
/* global Symbol */
|
|
1047
|
-
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
1048
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
1049
959
|
|
|
1050
960
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
* Be sure to invoke the function with the iterable as context:
|
|
1054
|
-
*
|
|
1055
|
-
* var iteratorFn = getIteratorFn(myIterable);
|
|
1056
|
-
* if (iteratorFn) {
|
|
1057
|
-
* var iterator = iteratorFn.call(myIterable);
|
|
1058
|
-
* ...
|
|
1059
|
-
* }
|
|
961
|
+
* Assert that the values match with the type specs.
|
|
962
|
+
* Error messages are memorized and will only be shown once.
|
|
1060
963
|
*
|
|
1061
|
-
* @param {
|
|
1062
|
-
* @
|
|
964
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
965
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
966
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
967
|
+
* @param {string} componentName Name of the component for error messages.
|
|
968
|
+
* @param {?Function} getStack Returns the component stack.
|
|
969
|
+
* @private
|
|
1063
970
|
*/
|
|
1064
|
-
function
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
971
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
972
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
973
|
+
for (var typeSpecName in typeSpecs) {
|
|
974
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
975
|
+
var error;
|
|
976
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
977
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
978
|
+
// After these have been cleaned up, we'll let them throw.
|
|
979
|
+
try {
|
|
980
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
981
|
+
// behavior as without this statement except with a better message.
|
|
982
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
983
|
+
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + _typeof(typeSpecs[typeSpecName]) + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
984
|
+
err.name = 'Invariant Violation';
|
|
985
|
+
throw err;
|
|
986
|
+
}
|
|
987
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
988
|
+
} catch (ex) {
|
|
989
|
+
error = ex;
|
|
990
|
+
}
|
|
991
|
+
if (error && !(error instanceof Error)) {
|
|
992
|
+
printWarning((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + _typeof(error) + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
|
|
993
|
+
}
|
|
994
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
995
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
996
|
+
// same error.
|
|
997
|
+
loggedTypeFailures[error.message] = true;
|
|
998
|
+
var stack = getStack ? getStack() : '';
|
|
999
|
+
printWarning('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1068
1003
|
}
|
|
1069
1004
|
}
|
|
1070
1005
|
|
|
1071
1006
|
/**
|
|
1072
|
-
*
|
|
1073
|
-
* supplied to React components. Example usage:
|
|
1074
|
-
*
|
|
1075
|
-
* var Props = require('ReactPropTypes');
|
|
1076
|
-
* var MyArticle = React.createClass({
|
|
1077
|
-
* propTypes: {
|
|
1078
|
-
* // An optional string prop named "description".
|
|
1079
|
-
* description: Props.string,
|
|
1080
|
-
*
|
|
1081
|
-
* // A required enum prop named "category".
|
|
1082
|
-
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
1083
|
-
*
|
|
1084
|
-
* // A prop named "dialog" that requires an instance of Dialog.
|
|
1085
|
-
* dialog: Props.instanceOf(Dialog).isRequired
|
|
1086
|
-
* },
|
|
1087
|
-
* render: function() { ... }
|
|
1088
|
-
* });
|
|
1089
|
-
*
|
|
1090
|
-
* A more formal specification of how these methods are used:
|
|
1007
|
+
* Resets warning cache when testing.
|
|
1091
1008
|
*
|
|
1092
|
-
*
|
|
1093
|
-
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
1094
|
-
*
|
|
1095
|
-
* Each and every declaration produces a function with the same signature. This
|
|
1096
|
-
* allows the creation of custom validation functions. For example:
|
|
1097
|
-
*
|
|
1098
|
-
* var MyLink = React.createClass({
|
|
1099
|
-
* propTypes: {
|
|
1100
|
-
* // An optional string or URI prop named "href".
|
|
1101
|
-
* href: function(props, propName, componentName) {
|
|
1102
|
-
* var propValue = props[propName];
|
|
1103
|
-
* if (propValue != null && typeof propValue !== 'string' &&
|
|
1104
|
-
* !(propValue instanceof URI)) {
|
|
1105
|
-
* return new Error(
|
|
1106
|
-
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
1107
|
-
* componentName
|
|
1108
|
-
* );
|
|
1109
|
-
* }
|
|
1110
|
-
* }
|
|
1111
|
-
* },
|
|
1112
|
-
* render: function() {...}
|
|
1113
|
-
* });
|
|
1114
|
-
*
|
|
1115
|
-
* @internal
|
|
1009
|
+
* @private
|
|
1116
1010
|
*/
|
|
1011
|
+
checkPropTypes.resetWarningCache = function () {
|
|
1012
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1013
|
+
loggedTypeFailures = {};
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
checkPropTypes_1 = checkPropTypes;
|
|
1017
|
+
return checkPropTypes_1;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
var factoryWithTypeCheckers;
|
|
1021
|
+
var hasRequiredFactoryWithTypeCheckers;
|
|
1022
|
+
function requireFactoryWithTypeCheckers() {
|
|
1023
|
+
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
1024
|
+
hasRequiredFactoryWithTypeCheckers = 1;
|
|
1025
|
+
var ReactIs = requireReactIs();
|
|
1026
|
+
var assign = requireObjectAssign();
|
|
1027
|
+
var ReactPropTypesSecret = requireReactPropTypesSecret();
|
|
1028
|
+
var has = requireHas();
|
|
1029
|
+
var checkPropTypes = requireCheckPropTypes();
|
|
1030
|
+
var printWarning = function printWarning() {};
|
|
1031
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1032
|
+
printWarning = function printWarning(text) {
|
|
1033
|
+
var message = 'Warning: ' + text;
|
|
1034
|
+
if (typeof console !== 'undefined') {
|
|
1035
|
+
console.error(message);
|
|
1036
|
+
}
|
|
1037
|
+
try {
|
|
1038
|
+
// --- Welcome to debugging React ---
|
|
1039
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
1040
|
+
// to find the callsite that caused this warning to fire.
|
|
1041
|
+
throw new Error(message);
|
|
1042
|
+
} catch (x) {}
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
function emptyFunctionThatReturnsNull() {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, throwOnDirectAccess) {
|
|
1049
|
+
/* global Symbol */
|
|
1050
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
1051
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
1117
1052
|
|
|
1118
|
-
|
|
1053
|
+
/**
|
|
1054
|
+
* Returns the iterator method function contained on the iterable object.
|
|
1055
|
+
*
|
|
1056
|
+
* Be sure to invoke the function with the iterable as context:
|
|
1057
|
+
*
|
|
1058
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
1059
|
+
* if (iteratorFn) {
|
|
1060
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
1061
|
+
* ...
|
|
1062
|
+
* }
|
|
1063
|
+
*
|
|
1064
|
+
* @param {?object} maybeIterable
|
|
1065
|
+
* @return {?function}
|
|
1066
|
+
*/
|
|
1067
|
+
function getIteratorFn(maybeIterable) {
|
|
1068
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
1069
|
+
if (typeof iteratorFn === 'function') {
|
|
1070
|
+
return iteratorFn;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1119
1073
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1074
|
+
/**
|
|
1075
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
1076
|
+
* supplied to React components. Example usage:
|
|
1077
|
+
*
|
|
1078
|
+
* var Props = require('ReactPropTypes');
|
|
1079
|
+
* var MyArticle = React.createClass({
|
|
1080
|
+
* propTypes: {
|
|
1081
|
+
* // An optional string prop named "description".
|
|
1082
|
+
* description: Props.string,
|
|
1083
|
+
*
|
|
1084
|
+
* // A required enum prop named "category".
|
|
1085
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
1086
|
+
*
|
|
1087
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
1088
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
1089
|
+
* },
|
|
1090
|
+
* render: function() { ... }
|
|
1091
|
+
* });
|
|
1092
|
+
*
|
|
1093
|
+
* A more formal specification of how these methods are used:
|
|
1094
|
+
*
|
|
1095
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
1096
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
1097
|
+
*
|
|
1098
|
+
* Each and every declaration produces a function with the same signature. This
|
|
1099
|
+
* allows the creation of custom validation functions. For example:
|
|
1100
|
+
*
|
|
1101
|
+
* var MyLink = React.createClass({
|
|
1102
|
+
* propTypes: {
|
|
1103
|
+
* // An optional string or URI prop named "href".
|
|
1104
|
+
* href: function(props, propName, componentName) {
|
|
1105
|
+
* var propValue = props[propName];
|
|
1106
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
1107
|
+
* !(propValue instanceof URI)) {
|
|
1108
|
+
* return new Error(
|
|
1109
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
1110
|
+
* componentName
|
|
1111
|
+
* );
|
|
1112
|
+
* }
|
|
1113
|
+
* }
|
|
1114
|
+
* },
|
|
1115
|
+
* render: function() {...}
|
|
1116
|
+
* });
|
|
1117
|
+
*
|
|
1118
|
+
* @internal
|
|
1119
|
+
*/
|
|
1143
1120
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1121
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
1122
|
+
|
|
1123
|
+
// Important!
|
|
1124
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
1125
|
+
var ReactPropTypes = {
|
|
1126
|
+
array: createPrimitiveTypeChecker('array'),
|
|
1127
|
+
bigint: createPrimitiveTypeChecker('bigint'),
|
|
1128
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
1129
|
+
func: createPrimitiveTypeChecker('function'),
|
|
1130
|
+
number: createPrimitiveTypeChecker('number'),
|
|
1131
|
+
object: createPrimitiveTypeChecker('object'),
|
|
1132
|
+
string: createPrimitiveTypeChecker('string'),
|
|
1133
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
1134
|
+
any: createAnyTypeChecker(),
|
|
1135
|
+
arrayOf: createArrayOfTypeChecker,
|
|
1136
|
+
element: createElementTypeChecker(),
|
|
1137
|
+
elementType: createElementTypeTypeChecker(),
|
|
1138
|
+
instanceOf: createInstanceTypeChecker,
|
|
1139
|
+
node: createNodeChecker(),
|
|
1140
|
+
objectOf: createObjectOfTypeChecker,
|
|
1141
|
+
oneOf: createEnumTypeChecker,
|
|
1142
|
+
oneOfType: createUnionTypeChecker,
|
|
1143
|
+
shape: createShapeTypeChecker,
|
|
1144
|
+
exact: createStrictShapeTypeChecker
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
1149
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
1150
|
+
*/
|
|
1151
|
+
/*eslint-disable no-self-compare*/
|
|
1152
|
+
function is(x, y) {
|
|
1153
|
+
// SameValue algorithm
|
|
1154
|
+
if (x === y) {
|
|
1155
|
+
// Steps 1-5, 7-10
|
|
1156
|
+
// Steps 6.b-6.e: +0 != -0
|
|
1157
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
1158
|
+
} else {
|
|
1159
|
+
// Step 6.a: NaN == NaN
|
|
1160
|
+
return x !== x && y !== y;
|
|
1161
|
+
}
|
|
1158
1162
|
}
|
|
1159
|
-
|
|
1160
|
-
/*eslint-enable no-self-compare*/
|
|
1163
|
+
/*eslint-enable no-self-compare*/
|
|
1161
1164
|
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1165
|
+
/**
|
|
1166
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
1167
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
1168
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
1169
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
1170
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
1171
|
+
*/
|
|
1172
|
+
function PropTypeError(message, data) {
|
|
1173
|
+
this.message = message;
|
|
1174
|
+
this.data = data && _typeof(data) === 'object' ? data : {};
|
|
1175
|
+
this.stack = '';
|
|
1176
|
+
}
|
|
1177
|
+
// Make `instanceof Error` still work for returned errors.
|
|
1178
|
+
PropTypeError.prototype = Error.prototype;
|
|
1179
|
+
function createChainableTypeChecker(validate) {
|
|
1180
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1181
|
+
var manualPropTypeCallCache = {};
|
|
1182
|
+
var manualPropTypeWarningCount = 0;
|
|
1183
|
+
}
|
|
1184
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
1185
|
+
componentName = componentName || ANONYMOUS;
|
|
1186
|
+
propFullName = propFullName || propName;
|
|
1187
|
+
if (secret !== ReactPropTypesSecret) {
|
|
1188
|
+
if (throwOnDirectAccess) {
|
|
1189
|
+
// New behavior only for users of `prop-types` package
|
|
1190
|
+
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
|
1191
|
+
err.name = 'Invariant Violation';
|
|
1192
|
+
throw err;
|
|
1193
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
1194
|
+
// Old behavior for people using React.PropTypes
|
|
1195
|
+
var cacheKey = componentName + ':' + propName;
|
|
1196
|
+
if (!manualPropTypeCallCache[cacheKey] &&
|
|
1197
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
1198
|
+
manualPropTypeWarningCount < 3) {
|
|
1199
|
+
printWarning('You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.');
|
|
1200
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
1201
|
+
manualPropTypeWarningCount++;
|
|
1202
|
+
}
|
|
1199
1203
|
}
|
|
1200
1204
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1205
|
+
if (props[propName] == null) {
|
|
1206
|
+
if (isRequired) {
|
|
1207
|
+
if (props[propName] === null) {
|
|
1208
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
1209
|
+
}
|
|
1210
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
1206
1211
|
}
|
|
1207
|
-
return
|
|
1212
|
+
return null;
|
|
1213
|
+
} else {
|
|
1214
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
1208
1215
|
}
|
|
1209
|
-
return null;
|
|
1210
|
-
} else {
|
|
1211
|
-
return validate(props, propName, componentName, location, propFullName);
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
var chainedCheckType = checkType.bind(null, false);
|
|
1215
|
-
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
1216
|
-
return chainedCheckType;
|
|
1217
|
-
}
|
|
1218
|
-
function createPrimitiveTypeChecker(expectedType) {
|
|
1219
|
-
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
1220
|
-
var propValue = props[propName];
|
|
1221
|
-
var propType = getPropType(propValue);
|
|
1222
|
-
if (propType !== expectedType) {
|
|
1223
|
-
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
1224
|
-
// check, but we can offer a more precise error message here rather than
|
|
1225
|
-
// 'of type `object`'.
|
|
1226
|
-
var preciseType = getPreciseType(propValue);
|
|
1227
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), {
|
|
1228
|
-
expectedType: expectedType
|
|
1229
|
-
});
|
|
1230
1216
|
}
|
|
1231
|
-
|
|
1217
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
1218
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
1219
|
+
return chainedCheckType;
|
|
1232
1220
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
1237
|
-
}
|
|
1238
|
-
function createArrayOfTypeChecker(typeChecker) {
|
|
1239
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1240
|
-
if (typeof typeChecker !== 'function') {
|
|
1241
|
-
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
1242
|
-
}
|
|
1243
|
-
var propValue = props[propName];
|
|
1244
|
-
if (!Array.isArray(propValue)) {
|
|
1221
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
1222
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
1223
|
+
var propValue = props[propName];
|
|
1245
1224
|
var propType = getPropType(propValue);
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return
|
|
1225
|
+
if (propType !== expectedType) {
|
|
1226
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
1227
|
+
// check, but we can offer a more precise error message here rather than
|
|
1228
|
+
// 'of type `object`'.
|
|
1229
|
+
var preciseType = getPreciseType(propValue);
|
|
1230
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), {
|
|
1231
|
+
expectedType: expectedType
|
|
1232
|
+
});
|
|
1252
1233
|
}
|
|
1234
|
+
return null;
|
|
1253
1235
|
}
|
|
1254
|
-
return
|
|
1236
|
+
return createChainableTypeChecker(validate);
|
|
1255
1237
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
function createElementTypeChecker() {
|
|
1259
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1260
|
-
var propValue = props[propName];
|
|
1261
|
-
if (!isValidElement(propValue)) {
|
|
1262
|
-
var propType = getPropType(propValue);
|
|
1263
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
1264
|
-
}
|
|
1265
|
-
return null;
|
|
1238
|
+
function createAnyTypeChecker() {
|
|
1239
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
1266
1240
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1241
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
1242
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1243
|
+
if (typeof typeChecker !== 'function') {
|
|
1244
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
1245
|
+
}
|
|
1246
|
+
var propValue = props[propName];
|
|
1247
|
+
if (!Array.isArray(propValue)) {
|
|
1248
|
+
var propType = getPropType(propValue);
|
|
1249
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
1250
|
+
}
|
|
1251
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
1252
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
1253
|
+
if (error instanceof Error) {
|
|
1254
|
+
return error;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return null;
|
|
1275
1258
|
}
|
|
1276
|
-
return
|
|
1259
|
+
return createChainableTypeChecker(validate);
|
|
1277
1260
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
return
|
|
1261
|
+
function createElementTypeChecker() {
|
|
1262
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1263
|
+
var propValue = props[propName];
|
|
1264
|
+
if (!isValidElement(propValue)) {
|
|
1265
|
+
var propType = getPropType(propValue);
|
|
1266
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
1267
|
+
}
|
|
1268
|
+
return null;
|
|
1286
1269
|
}
|
|
1287
|
-
return
|
|
1270
|
+
return createChainableTypeChecker(validate);
|
|
1288
1271
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
|
|
1296
|
-
} else {
|
|
1297
|
-
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
1272
|
+
function createElementTypeTypeChecker() {
|
|
1273
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1274
|
+
var propValue = props[propName];
|
|
1275
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
1276
|
+
var propType = getPropType(propValue);
|
|
1277
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
1298
1278
|
}
|
|
1279
|
+
return null;
|
|
1299
1280
|
}
|
|
1300
|
-
return
|
|
1281
|
+
return createChainableTypeChecker(validate);
|
|
1301
1282
|
}
|
|
1302
|
-
function
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1283
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
1284
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1285
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
1286
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
1287
|
+
var actualClassName = getClassName(props[propName]);
|
|
1288
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
1307
1289
|
}
|
|
1290
|
+
return null;
|
|
1308
1291
|
}
|
|
1309
|
-
|
|
1310
|
-
var type = getPreciseType(value);
|
|
1311
|
-
if (type === 'symbol') {
|
|
1312
|
-
return String(value);
|
|
1313
|
-
}
|
|
1314
|
-
return value;
|
|
1315
|
-
});
|
|
1316
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
1292
|
+
return createChainableTypeChecker(validate);
|
|
1317
1293
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1294
|
+
function createEnumTypeChecker(expectedValues) {
|
|
1295
|
+
if (!Array.isArray(expectedValues)) {
|
|
1296
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1297
|
+
if (arguments.length > 1) {
|
|
1298
|
+
printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
|
|
1299
|
+
} else {
|
|
1300
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return emptyFunctionThatReturnsNull;
|
|
1324
1304
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1305
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1306
|
+
var propValue = props[propName];
|
|
1307
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
1308
|
+
if (is(propValue, expectedValues[i])) {
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
1313
|
+
var type = getPreciseType(value);
|
|
1314
|
+
if (type === 'symbol') {
|
|
1315
|
+
return String(value);
|
|
1316
|
+
}
|
|
1317
|
+
return value;
|
|
1318
|
+
});
|
|
1319
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
1329
1320
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1321
|
+
return createChainableTypeChecker(validate);
|
|
1322
|
+
}
|
|
1323
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
1324
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1325
|
+
if (typeof typeChecker !== 'function') {
|
|
1326
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
1327
|
+
}
|
|
1328
|
+
var propValue = props[propName];
|
|
1329
|
+
var propType = getPropType(propValue);
|
|
1330
|
+
if (propType !== 'object') {
|
|
1331
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
1332
|
+
}
|
|
1333
|
+
for (var key in propValue) {
|
|
1334
|
+
if (has(propValue, key)) {
|
|
1335
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
1336
|
+
if (error instanceof Error) {
|
|
1337
|
+
return error;
|
|
1338
|
+
}
|
|
1335
1339
|
}
|
|
1336
1340
|
}
|
|
1341
|
+
return null;
|
|
1337
1342
|
}
|
|
1338
|
-
return
|
|
1343
|
+
return createChainableTypeChecker(validate);
|
|
1339
1344
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
1344
|
-
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
1345
|
-
return emptyFunctionThatReturnsNull;
|
|
1346
|
-
}
|
|
1347
|
-
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
1348
|
-
var checker = arrayOfTypeCheckers[i];
|
|
1349
|
-
if (typeof checker !== 'function') {
|
|
1350
|
-
printWarning('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
|
|
1345
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
1346
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
1347
|
+
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
1351
1348
|
return emptyFunctionThatReturnsNull;
|
|
1352
1349
|
}
|
|
1353
|
-
}
|
|
1354
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
1355
|
-
var expectedTypes = [];
|
|
1356
1350
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
1357
1351
|
var checker = arrayOfTypeCheckers[i];
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
return
|
|
1352
|
+
if (typeof checker !== 'function') {
|
|
1353
|
+
printWarning('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
|
|
1354
|
+
return emptyFunctionThatReturnsNull;
|
|
1361
1355
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1356
|
+
}
|
|
1357
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1358
|
+
var expectedTypes = [];
|
|
1359
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
1360
|
+
var checker = arrayOfTypeCheckers[i];
|
|
1361
|
+
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
1362
|
+
if (checkerResult == null) {
|
|
1363
|
+
return null;
|
|
1364
|
+
}
|
|
1365
|
+
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
1366
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
1367
|
+
}
|
|
1364
1368
|
}
|
|
1369
|
+
var expectedTypesMessage = expectedTypes.length > 0 ? ', expected one of type [' + expectedTypes.join(', ') + ']' : '';
|
|
1370
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
1365
1371
|
}
|
|
1366
|
-
|
|
1367
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
1372
|
+
return createChainableTypeChecker(validate);
|
|
1368
1373
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return
|
|
1374
|
+
function createNodeChecker() {
|
|
1375
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1376
|
+
if (!isNode(props[propName])) {
|
|
1377
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
1378
|
+
}
|
|
1379
|
+
return null;
|
|
1375
1380
|
}
|
|
1376
|
-
return
|
|
1381
|
+
return createChainableTypeChecker(validate);
|
|
1377
1382
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if (propType !== 'object') {
|
|
1388
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
1389
|
-
}
|
|
1390
|
-
for (var key in shapeTypes) {
|
|
1391
|
-
var checker = shapeTypes[key];
|
|
1392
|
-
if (typeof checker !== 'function') {
|
|
1393
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1383
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
1384
|
+
return new PropTypeError((componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.');
|
|
1385
|
+
}
|
|
1386
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
1387
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1388
|
+
var propValue = props[propName];
|
|
1389
|
+
var propType = getPropType(propValue);
|
|
1390
|
+
if (propType !== 'object') {
|
|
1391
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
1394
1392
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1393
|
+
for (var key in shapeTypes) {
|
|
1394
|
+
var checker = shapeTypes[key];
|
|
1395
|
+
if (typeof checker !== 'function') {
|
|
1396
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1397
|
+
}
|
|
1398
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
1399
|
+
if (error) {
|
|
1400
|
+
return error;
|
|
1401
|
+
}
|
|
1398
1402
|
}
|
|
1403
|
+
return null;
|
|
1399
1404
|
}
|
|
1400
|
-
return
|
|
1405
|
+
return createChainableTypeChecker(validate);
|
|
1401
1406
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
if (propType !== 'object') {
|
|
1409
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
1410
|
-
}
|
|
1411
|
-
// We need to check all keys in case some are required but missing from props.
|
|
1412
|
-
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
1413
|
-
for (var key in allKeys) {
|
|
1414
|
-
var checker = shapeTypes[key];
|
|
1415
|
-
if (has$1(shapeTypes, key) && typeof checker !== 'function') {
|
|
1416
|
-
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1417
|
-
}
|
|
1418
|
-
if (!checker) {
|
|
1419
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
|
|
1407
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
1408
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
1409
|
+
var propValue = props[propName];
|
|
1410
|
+
var propType = getPropType(propValue);
|
|
1411
|
+
if (propType !== 'object') {
|
|
1412
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
1420
1413
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1414
|
+
// We need to check all keys in case some are required but missing from props.
|
|
1415
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
1416
|
+
for (var key in allKeys) {
|
|
1417
|
+
var checker = shapeTypes[key];
|
|
1418
|
+
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
1419
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
1420
|
+
}
|
|
1421
|
+
if (!checker) {
|
|
1422
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
|
|
1423
|
+
}
|
|
1424
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
1425
|
+
if (error) {
|
|
1426
|
+
return error;
|
|
1427
|
+
}
|
|
1424
1428
|
}
|
|
1429
|
+
return null;
|
|
1425
1430
|
}
|
|
1426
|
-
return
|
|
1431
|
+
return createChainableTypeChecker(validate);
|
|
1427
1432
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
case 'string':
|
|
1434
|
-
case 'undefined':
|
|
1435
|
-
return true;
|
|
1436
|
-
case 'boolean':
|
|
1437
|
-
return !propValue;
|
|
1438
|
-
case 'object':
|
|
1439
|
-
if (Array.isArray(propValue)) {
|
|
1440
|
-
return propValue.every(isNode);
|
|
1441
|
-
}
|
|
1442
|
-
if (propValue === null || isValidElement(propValue)) {
|
|
1433
|
+
function isNode(propValue) {
|
|
1434
|
+
switch (_typeof(propValue)) {
|
|
1435
|
+
case 'number':
|
|
1436
|
+
case 'string':
|
|
1437
|
+
case 'undefined':
|
|
1443
1438
|
return true;
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
if (!isNode(entry[1])) {
|
|
1439
|
+
case 'boolean':
|
|
1440
|
+
return !propValue;
|
|
1441
|
+
case 'object':
|
|
1442
|
+
if (Array.isArray(propValue)) {
|
|
1443
|
+
return propValue.every(isNode);
|
|
1444
|
+
}
|
|
1445
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
1446
|
+
return true;
|
|
1447
|
+
}
|
|
1448
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
1449
|
+
if (iteratorFn) {
|
|
1450
|
+
var iterator = iteratorFn.call(propValue);
|
|
1451
|
+
var step;
|
|
1452
|
+
if (iteratorFn !== propValue.entries) {
|
|
1453
|
+
while (!(step = iterator.next()).done) {
|
|
1454
|
+
if (!isNode(step.value)) {
|
|
1461
1455
|
return false;
|
|
1462
1456
|
}
|
|
1463
1457
|
}
|
|
1458
|
+
} else {
|
|
1459
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
1460
|
+
while (!(step = iterator.next()).done) {
|
|
1461
|
+
var entry = step.value;
|
|
1462
|
+
if (entry) {
|
|
1463
|
+
if (!isNode(entry[1])) {
|
|
1464
|
+
return false;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1464
1468
|
}
|
|
1469
|
+
} else {
|
|
1470
|
+
return false;
|
|
1465
1471
|
}
|
|
1466
|
-
|
|
1472
|
+
return true;
|
|
1473
|
+
default:
|
|
1467
1474
|
return false;
|
|
1468
|
-
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function isSymbol(propType, propValue) {
|
|
1478
|
+
// Native Symbol.
|
|
1479
|
+
if (propType === 'symbol') {
|
|
1469
1480
|
return true;
|
|
1470
|
-
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// falsy value can't be a Symbol
|
|
1484
|
+
if (!propValue) {
|
|
1471
1485
|
return false;
|
|
1472
|
-
|
|
1473
|
-
}
|
|
1474
|
-
function isSymbol(propType, propValue) {
|
|
1475
|
-
// Native Symbol.
|
|
1476
|
-
if (propType === 'symbol') {
|
|
1477
|
-
return true;
|
|
1478
|
-
}
|
|
1486
|
+
}
|
|
1479
1487
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1488
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
1489
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
1490
|
+
return true;
|
|
1491
|
+
}
|
|
1484
1492
|
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1493
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
1494
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
1495
|
+
return true;
|
|
1496
|
+
}
|
|
1497
|
+
return false;
|
|
1488
1498
|
}
|
|
1489
1499
|
|
|
1490
|
-
//
|
|
1491
|
-
|
|
1492
|
-
|
|
1500
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
1501
|
+
function getPropType(propValue) {
|
|
1502
|
+
var propType = _typeof(propValue);
|
|
1503
|
+
if (Array.isArray(propValue)) {
|
|
1504
|
+
return 'array';
|
|
1505
|
+
}
|
|
1506
|
+
if (propValue instanceof RegExp) {
|
|
1507
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
1508
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
1509
|
+
// passes PropTypes.object.
|
|
1510
|
+
return 'object';
|
|
1511
|
+
}
|
|
1512
|
+
if (isSymbol(propType, propValue)) {
|
|
1513
|
+
return 'symbol';
|
|
1514
|
+
}
|
|
1515
|
+
return propType;
|
|
1493
1516
|
}
|
|
1494
|
-
return false;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
1498
|
-
function getPropType(propValue) {
|
|
1499
|
-
var propType = _typeof(propValue);
|
|
1500
|
-
if (Array.isArray(propValue)) {
|
|
1501
|
-
return 'array';
|
|
1502
|
-
}
|
|
1503
|
-
if (propValue instanceof RegExp) {
|
|
1504
|
-
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
1505
|
-
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
1506
|
-
// passes PropTypes.object.
|
|
1507
|
-
return 'object';
|
|
1508
|
-
}
|
|
1509
|
-
if (isSymbol(propType, propValue)) {
|
|
1510
|
-
return 'symbol';
|
|
1511
|
-
}
|
|
1512
|
-
return propType;
|
|
1513
|
-
}
|
|
1514
1517
|
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
var propType = getPropType(propValue);
|
|
1522
|
-
if (propType === 'object') {
|
|
1523
|
-
if (propValue instanceof Date) {
|
|
1524
|
-
return 'date';
|
|
1525
|
-
} else if (propValue instanceof RegExp) {
|
|
1526
|
-
return 'regexp';
|
|
1518
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
1519
|
+
// See `createPrimitiveTypeChecker`.
|
|
1520
|
+
function getPreciseType(propValue) {
|
|
1521
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
1522
|
+
return '' + propValue;
|
|
1527
1523
|
}
|
|
1524
|
+
var propType = getPropType(propValue);
|
|
1525
|
+
if (propType === 'object') {
|
|
1526
|
+
if (propValue instanceof Date) {
|
|
1527
|
+
return 'date';
|
|
1528
|
+
} else if (propValue instanceof RegExp) {
|
|
1529
|
+
return 'regexp';
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return propType;
|
|
1528
1533
|
}
|
|
1529
|
-
return propType;
|
|
1530
|
-
}
|
|
1531
1534
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1535
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
1536
|
+
// For example, "undefined" or "of type array"
|
|
1537
|
+
function getPostfixForTypeWarning(value) {
|
|
1538
|
+
var type = getPreciseType(value);
|
|
1539
|
+
switch (type) {
|
|
1540
|
+
case 'array':
|
|
1541
|
+
case 'object':
|
|
1542
|
+
return 'an ' + type;
|
|
1543
|
+
case 'boolean':
|
|
1544
|
+
case 'date':
|
|
1545
|
+
case 'regexp':
|
|
1546
|
+
return 'a ' + type;
|
|
1547
|
+
default:
|
|
1548
|
+
return type;
|
|
1549
|
+
}
|
|
1546
1550
|
}
|
|
1547
|
-
}
|
|
1548
1551
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1552
|
+
// Returns class name of the object, if any.
|
|
1553
|
+
function getClassName(propValue) {
|
|
1554
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
1555
|
+
return ANONYMOUS;
|
|
1556
|
+
}
|
|
1557
|
+
return propValue.constructor.name;
|
|
1553
1558
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1559
|
-
return ReactPropTypes;
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
|
-
function emptyFunction() {}
|
|
1563
|
-
function emptyFunctionWithReset() {}
|
|
1564
|
-
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1565
|
-
var factoryWithThrowingShims = function factoryWithThrowingShims() {
|
|
1566
|
-
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1567
|
-
if (secret === ReactPropTypesSecret_1) {
|
|
1568
|
-
// It is still safe when called from React.
|
|
1569
|
-
return;
|
|
1570
|
-
}
|
|
1571
|
-
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
|
1572
|
-
err.name = 'Invariant Violation';
|
|
1573
|
-
throw err;
|
|
1574
|
-
}
|
|
1575
|
-
shim.isRequired = shim;
|
|
1576
|
-
function getShim() {
|
|
1577
|
-
return shim;
|
|
1578
|
-
}
|
|
1579
|
-
// Important!
|
|
1580
|
-
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1581
|
-
var ReactPropTypes = {
|
|
1582
|
-
array: shim,
|
|
1583
|
-
bigint: shim,
|
|
1584
|
-
bool: shim,
|
|
1585
|
-
func: shim,
|
|
1586
|
-
number: shim,
|
|
1587
|
-
object: shim,
|
|
1588
|
-
string: shim,
|
|
1589
|
-
symbol: shim,
|
|
1590
|
-
any: shim,
|
|
1591
|
-
arrayOf: getShim,
|
|
1592
|
-
element: shim,
|
|
1593
|
-
elementType: shim,
|
|
1594
|
-
instanceOf: getShim,
|
|
1595
|
-
node: shim,
|
|
1596
|
-
objectOf: getShim,
|
|
1597
|
-
oneOf: getShim,
|
|
1598
|
-
oneOfType: getShim,
|
|
1599
|
-
shape: getShim,
|
|
1600
|
-
exact: getShim,
|
|
1601
|
-
checkPropTypes: emptyFunctionWithReset,
|
|
1602
|
-
resetWarningCache: emptyFunction
|
|
1559
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
1560
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
1561
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1562
|
+
return ReactPropTypes;
|
|
1603
1563
|
};
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
};
|
|
1564
|
+
return factoryWithTypeCheckers;
|
|
1565
|
+
}
|
|
1607
1566
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1567
|
+
/**
|
|
1568
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1569
|
+
*
|
|
1570
|
+
* This source code is licensed under the MIT license found in the
|
|
1571
|
+
* LICENSE file in the root directory of this source tree.
|
|
1572
|
+
*/
|
|
1573
|
+
var factoryWithThrowingShims;
|
|
1574
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
1575
|
+
function requireFactoryWithThrowingShims() {
|
|
1576
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
1577
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
1578
|
+
var ReactPropTypesSecret = requireReactPropTypesSecret();
|
|
1579
|
+
function emptyFunction() {}
|
|
1580
|
+
function emptyFunctionWithReset() {}
|
|
1581
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1582
|
+
factoryWithThrowingShims = function factoryWithThrowingShims() {
|
|
1583
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1584
|
+
if (secret === ReactPropTypesSecret) {
|
|
1585
|
+
// It is still safe when called from React.
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
|
1589
|
+
err.name = 'Invariant Violation';
|
|
1590
|
+
throw err;
|
|
1591
|
+
}
|
|
1592
|
+
shim.isRequired = shim;
|
|
1593
|
+
function getShim() {
|
|
1594
|
+
return shim;
|
|
1595
|
+
}
|
|
1596
|
+
// Important!
|
|
1597
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1598
|
+
var ReactPropTypes = {
|
|
1599
|
+
array: shim,
|
|
1600
|
+
bigint: shim,
|
|
1601
|
+
bool: shim,
|
|
1602
|
+
func: shim,
|
|
1603
|
+
number: shim,
|
|
1604
|
+
object: shim,
|
|
1605
|
+
string: shim,
|
|
1606
|
+
symbol: shim,
|
|
1607
|
+
any: shim,
|
|
1608
|
+
arrayOf: getShim,
|
|
1609
|
+
element: shim,
|
|
1610
|
+
elementType: shim,
|
|
1611
|
+
instanceOf: getShim,
|
|
1612
|
+
node: shim,
|
|
1613
|
+
objectOf: getShim,
|
|
1614
|
+
oneOf: getShim,
|
|
1615
|
+
oneOfType: getShim,
|
|
1616
|
+
shape: getShim,
|
|
1617
|
+
exact: getShim,
|
|
1618
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
1619
|
+
resetWarningCache: emptyFunction
|
|
1620
|
+
};
|
|
1621
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1622
|
+
return ReactPropTypes;
|
|
1623
|
+
};
|
|
1624
|
+
return factoryWithThrowingShims;
|
|
1625
|
+
}
|
|
1615
1626
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1627
|
+
/**
|
|
1628
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1629
|
+
*
|
|
1630
|
+
* This source code is licensed under the MIT license found in the
|
|
1631
|
+
* LICENSE file in the root directory of this source tree.
|
|
1632
|
+
*/
|
|
1633
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1634
|
+
var ReactIs = requireReactIs();
|
|
1618
1635
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1636
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1637
|
+
// http://fb.me/prop-types-in-prod
|
|
1638
|
+
var throwOnDirectAccess = true;
|
|
1639
|
+
propTypes.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
1640
|
+
} else {
|
|
1641
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1642
|
+
// http://fb.me/prop-types-in-prod
|
|
1643
|
+
propTypes.exports = requireFactoryWithThrowingShims()();
|
|
1644
|
+
}
|
|
1645
|
+
var propTypesExports = propTypes.exports;
|
|
1646
|
+
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
1629
1647
|
|
|
1630
1648
|
/**
|
|
1631
1649
|
* A Handsontable-ReactJS wrapper.
|
|
@@ -1742,11 +1760,18 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1742
1760
|
return null;
|
|
1743
1761
|
}
|
|
1744
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Returns `true` if the `hotInstance` exists, but was destroyed.
|
|
1765
|
+
*
|
|
1766
|
+
* @private
|
|
1767
|
+
* @returns {boolean}
|
|
1768
|
+
*/,
|
|
1769
|
+
set:
|
|
1745
1770
|
/**
|
|
1746
1771
|
* Setter for the property storing the Handsontable instance.
|
|
1747
1772
|
* @param {Handsontable} hotInstance The Handsontable instance.
|
|
1748
|
-
|
|
1749
|
-
|
|
1773
|
+
*/
|
|
1774
|
+
function set(hotInstance) {
|
|
1750
1775
|
this.__hotInstance = hotInstance;
|
|
1751
1776
|
}
|
|
1752
1777
|
/**
|
|
@@ -1754,6 +1779,11 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1754
1779
|
*
|
|
1755
1780
|
* @returns {Map}
|
|
1756
1781
|
*/
|
|
1782
|
+
}, {
|
|
1783
|
+
key: "_isHotInstanceDestroyed",
|
|
1784
|
+
value: function _isHotInstanceDestroyed() {
|
|
1785
|
+
return this.__hotInstance && this.__hotInstance.isDestroyed;
|
|
1786
|
+
}
|
|
1757
1787
|
}, {
|
|
1758
1788
|
key: "getPortalContainerCache",
|
|
1759
1789
|
value: function getPortalContainerCache() {
|
|
@@ -1954,12 +1984,24 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
1954
1984
|
/**
|
|
1955
1985
|
* Create a new settings object containing the column settings and global editors and renderers.
|
|
1956
1986
|
*
|
|
1987
|
+
* @param {boolean} [init=false] `true` if called on Handsontable initialization.
|
|
1988
|
+
* @param {HotTableProps} [prevProps] The previous properties object.
|
|
1957
1989
|
* @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
|
|
1958
1990
|
*/
|
|
1959
1991
|
}, {
|
|
1960
1992
|
key: "createNewGlobalSettings",
|
|
1961
1993
|
value: function createNewGlobalSettings() {
|
|
1962
|
-
var
|
|
1994
|
+
var _this$hotInstance;
|
|
1995
|
+
var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1996
|
+
var prevProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1997
|
+
var initOnlySettingKeys = !this._isHotInstanceDestroyed() ?
|
|
1998
|
+
// Needed for React's double-rendering.
|
|
1999
|
+
((_this$hotInstance = this.hotInstance) === null || _this$hotInstance === void 0 || (_this$hotInstance = _this$hotInstance.getSettings()) === null || _this$hotInstance === void 0 ? void 0 : _this$hotInstance._initOnlySettings) || [] : [];
|
|
2000
|
+
var newSettings = SettingsMapper.getSettings(this.props, {
|
|
2001
|
+
prevProps: prevProps,
|
|
2002
|
+
isInit: init,
|
|
2003
|
+
initOnlySettingKeys: initOnlySettingKeys
|
|
2004
|
+
});
|
|
1963
2005
|
var globalRendererNode = this.getGlobalRendererElement();
|
|
1964
2006
|
var globalEditorNode = this.getGlobalEditorElement();
|
|
1965
2007
|
newSettings.columns = this.columnSettings.length ? this.columnSettings : newSettings.columns;
|
|
@@ -2065,7 +2107,7 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2065
2107
|
key: "componentDidMount",
|
|
2066
2108
|
value: function componentDidMount() {
|
|
2067
2109
|
var _this3 = this;
|
|
2068
|
-
var newGlobalSettings = this.createNewGlobalSettings();
|
|
2110
|
+
var newGlobalSettings = this.createNewGlobalSettings(true);
|
|
2069
2111
|
this.hotInstance = new Handsontable.Core(this.hotElementRef, newGlobalSettings);
|
|
2070
2112
|
this.hotInstance.addHook('beforeViewRender', function () {
|
|
2071
2113
|
return _this3.handsontableBeforeViewRender();
|
|
@@ -2082,9 +2124,9 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2082
2124
|
*/
|
|
2083
2125
|
}, {
|
|
2084
2126
|
key: "componentDidUpdate",
|
|
2085
|
-
value: function componentDidUpdate() {
|
|
2127
|
+
value: function componentDidUpdate(prevProps) {
|
|
2086
2128
|
this.clearCache();
|
|
2087
|
-
var newGlobalSettings = this.createNewGlobalSettings();
|
|
2129
|
+
var newGlobalSettings = this.createNewGlobalSettings(false, prevProps);
|
|
2088
2130
|
this.updateHot(newGlobalSettings);
|
|
2089
2131
|
this.displayAutoSizeWarning(newGlobalSettings);
|
|
2090
2132
|
}
|
|
@@ -2145,9 +2187,9 @@ var HotTableClass = /*#__PURE__*/function (_React$Component) {
|
|
|
2145
2187
|
* Prop types to be checked at runtime.
|
|
2146
2188
|
*/
|
|
2147
2189
|
HotTableClass.propTypes = {
|
|
2148
|
-
style:
|
|
2149
|
-
id:
|
|
2150
|
-
className:
|
|
2190
|
+
style: PropTypes.object,
|
|
2191
|
+
id: PropTypes.string,
|
|
2192
|
+
className: PropTypes.string
|
|
2151
2193
|
};
|
|
2152
2194
|
|
|
2153
2195
|
var _excluded = ["children"];
|