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