@innoways/utils 3.0.0
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/CHANGELOG.md +184 -0
- package/README.md +11 -0
- package/__tests__/combine.ts +102 -0
- package/__tests__/common.ts +155 -0
- package/__tests__/flowHandle.ts +16 -0
- package/__tests__/parse.ts +109 -0
- package/__testsdata__/array.schema.ts +97 -0
- package/__testsdata__/controlFlow.ts +166 -0
- package/__testsdata__/datePicker.schema.ts +92 -0
- package/__testsdata__/errMsg.schema.ts +138 -0
- package/__testsdata__/errMsg2.schema.ts +74 -0
- package/__testsdata__/errMsg3.schema.ts +79 -0
- package/__testsdata__/errMsg4.schema.ts +152 -0
- package/__testsdata__/multinest.schema.ts +265 -0
- package/__testsdata__/nest.schema.ts +307 -0
- package/__testsdata__/nestObject.schema.ts +360 -0
- package/__testsdata__/repeatField.schema.ts +88 -0
- package/__testsdata__/root.schema.ts +35 -0
- package/__testsdata__/test$fieldKey.schema.ts +1158 -0
- package/__testsdata__/test.schema.ts +1158 -0
- package/build-info/index.stats.html +2648 -0
- package/dist/cjs/index.js +3949 -0
- package/dist/esm/index.js +3907 -0
- package/package.json +44 -0
- package/rollup.config.js +13 -0
- package/tsconfig.dist.json +7 -0
|
@@ -0,0 +1,3907 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
6
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
7
|
+
import stringify from 'js-stringify';
|
|
8
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
9
|
+
|
|
10
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
11
|
+
return module = {
|
|
12
|
+
path: basedir,
|
|
13
|
+
exports: {},
|
|
14
|
+
require: function (path, base) {
|
|
15
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
16
|
+
}
|
|
17
|
+
}, fn(module, module.exports), module.exports;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function commonjsRequire () {
|
|
21
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
object-assign
|
|
26
|
+
(c) Sindre Sorhus
|
|
27
|
+
@license MIT
|
|
28
|
+
*/
|
|
29
|
+
/* eslint-disable no-unused-vars */
|
|
30
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
31
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
32
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
33
|
+
|
|
34
|
+
function toObject(val) {
|
|
35
|
+
if (val === null || val === undefined) {
|
|
36
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return Object(val);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function shouldUseNative() {
|
|
43
|
+
try {
|
|
44
|
+
if (!Object.assign) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
49
|
+
|
|
50
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
51
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
52
|
+
test1[5] = 'de';
|
|
53
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
58
|
+
var test2 = {};
|
|
59
|
+
for (var i = 0; i < 10; i++) {
|
|
60
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
61
|
+
}
|
|
62
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
63
|
+
return test2[n];
|
|
64
|
+
});
|
|
65
|
+
if (order2.join('') !== '0123456789') {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
70
|
+
var test3 = {};
|
|
71
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
72
|
+
test3[letter] = letter;
|
|
73
|
+
});
|
|
74
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
75
|
+
'abcdefghijklmnopqrst') {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
87
|
+
var from;
|
|
88
|
+
var to = toObject(target);
|
|
89
|
+
var symbols;
|
|
90
|
+
|
|
91
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
92
|
+
from = Object(arguments[s]);
|
|
93
|
+
|
|
94
|
+
for (var key in from) {
|
|
95
|
+
if (hasOwnProperty.call(from, key)) {
|
|
96
|
+
to[key] = from[key];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (getOwnPropertySymbols) {
|
|
101
|
+
symbols = getOwnPropertySymbols(from);
|
|
102
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
103
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
104
|
+
to[symbols[i]] = from[symbols[i]];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return to;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var react_production_min = createCommonjsModule(function (module, exports) {
|
|
114
|
+
var n=60103,p=60106;exports.Fragment=60107;exports.StrictMode=60108;exports.Profiler=60114;var q=60109,r=60110,t=60112;exports.Suspense=60113;var u=60115,v=60116;
|
|
115
|
+
if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;n=w("react.element");p=w("react.portal");exports.Fragment=w("react.fragment");exports.StrictMode=w("react.strict_mode");exports.Profiler=w("react.profiler");q=w("react.provider");r=w("react.context");t=w("react.forward_ref");exports.Suspense=w("react.suspense");u=w("react.memo");v=w("react.lazy");}var x="function"===typeof Symbol&&Symbol.iterator;
|
|
116
|
+
function y(a){if(null===a||"object"!==typeof a)return null;a=x&&a[x]||a["@@iterator"];return "function"===typeof a?a:null}function z(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return "Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
|
|
117
|
+
var A={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},B={};function C(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A;}C.prototype.isReactComponent={};C.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(z(85));this.updater.enqueueSetState(this,a,b,"setState");};C.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate");};
|
|
118
|
+
function D(){}D.prototype=C.prototype;function E(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A;}var F=E.prototype=new D;F.constructor=E;objectAssign(F,C.prototype);F.isPureReactComponent=!0;var G={current:null},H=Object.prototype.hasOwnProperty,I={key:!0,ref:!0,__self:!0,__source:!0};
|
|
119
|
+
function J(a,b,c){var e,d={},k=null,h=null;if(null!=b)for(e in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)H.call(b,e)&&!I.hasOwnProperty(e)&&(d[e]=b[e]);var g=arguments.length-2;if(1===g)d.children=c;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];d.children=f;}if(a&&a.defaultProps)for(e in g=a.defaultProps,g)void 0===d[e]&&(d[e]=g[e]);return {$$typeof:n,type:a,key:k,ref:h,props:d,_owner:G.current}}
|
|
120
|
+
function K(a,b){return {$$typeof:n,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function L(a){return "object"===typeof a&&null!==a&&a.$$typeof===n}function escape(a){var b={"=":"=0",":":"=2"};return "$"+a.replace(/[=:]/g,function(a){return b[a]})}var M=/\/+/g;function N(a,b){return "object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
|
|
121
|
+
function O(a,b,c,e,d){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case n:case p:h=!0;}}if(h)return h=a,d=d(h),a=""===e?"."+N(h,0):e,Array.isArray(d)?(c="",null!=a&&(c=a.replace(M,"$&/")+"/"),O(d,b,c,"",function(a){return a})):null!=d&&(L(d)&&(d=K(d,c+(!d.key||h&&h.key===d.key?"":(""+d.key).replace(M,"$&/")+"/")+a)),b.push(d)),1;h=0;e=""===e?".":e+":";if(Array.isArray(a))for(var g=
|
|
122
|
+
0;g<a.length;g++){k=a[g];var f=e+N(k,g);h+=O(k,b,c,f,d);}else if(f=y(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=e+N(k,g++),h+=O(k,b,c,f,d);else if("object"===k)throw b=""+a,Error(z(31,"[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b));return h}function P(a,b,c){if(null==a)return a;var e=[],d=0;O(a,e,"","",function(a){return b.call(c,a,d++)});return e}
|
|
123
|
+
function Q(a){if(-1===a._status){var b=a._result;b=b();a._status=0;a._result=b;b.then(function(b){0===a._status&&(b=b.default,a._status=1,a._result=b);},function(b){0===a._status&&(a._status=2,a._result=b);});}if(1===a._status)return a._result;throw a._result;}var R={current:null};function S(){var a=R.current;if(null===a)throw Error(z(321));return a}var T={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:G,IsSomeRendererActing:{current:!1},assign:objectAssign};
|
|
124
|
+
exports.Children={map:P,forEach:function(a,b,c){P(a,function(){b.apply(this,arguments);},c);},count:function(a){var b=0;P(a,function(){b++;});return b},toArray:function(a){return P(a,function(a){return a})||[]},only:function(a){if(!L(a))throw Error(z(143));return a}};exports.Component=C;exports.PureComponent=E;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=T;
|
|
125
|
+
exports.cloneElement=function(a,b,c){if(null===a||void 0===a)throw Error(z(267,a));var e=objectAssign({},a.props),d=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=G.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)H.call(b,f)&&!I.hasOwnProperty(f)&&(e[f]=void 0===b[f]&&void 0!==g?g[f]:b[f]);}var f=arguments.length-2;if(1===f)e.children=c;else if(1<f){g=Array(f);for(var m=0;m<f;m++)g[m]=arguments[m+2];e.children=g;}return {$$typeof:n,type:a.type,
|
|
126
|
+
key:d,ref:k,props:e,_owner:h}};exports.createContext=function(a,b){void 0===b&&(b=null);a={$$typeof:r,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:q,_context:a};return a.Consumer=a};exports.createElement=J;exports.createFactory=function(a){var b=J.bind(null,a);b.type=a;return b};exports.createRef=function(){return {current:null}};exports.forwardRef=function(a){return {$$typeof:t,render:a}};exports.isValidElement=L;
|
|
127
|
+
exports.lazy=function(a){return {$$typeof:v,_payload:{_status:-1,_result:a},_init:Q}};exports.memo=function(a,b){return {$$typeof:u,type:a,compare:void 0===b?null:b}};exports.useCallback=function(a,b){return S().useCallback(a,b)};exports.useContext=function(a,b){return S().useContext(a,b)};exports.useDebugValue=function(){};exports.useEffect=function(a,b){return S().useEffect(a,b)};exports.useImperativeHandle=function(a,b,c){return S().useImperativeHandle(a,b,c)};
|
|
128
|
+
exports.useLayoutEffect=function(a,b){return S().useLayoutEffect(a,b)};exports.useMemo=function(a,b){return S().useMemo(a,b)};exports.useReducer=function(a,b,c){return S().useReducer(a,b,c)};exports.useRef=function(a){return S().useRef(a)};exports.useState=function(a){return S().useState(a)};exports.version="17.0.2";
|
|
129
|
+
});
|
|
130
|
+
react_production_min.Fragment;
|
|
131
|
+
react_production_min.StrictMode;
|
|
132
|
+
react_production_min.Profiler;
|
|
133
|
+
react_production_min.Suspense;
|
|
134
|
+
react_production_min.Children;
|
|
135
|
+
react_production_min.Component;
|
|
136
|
+
react_production_min.PureComponent;
|
|
137
|
+
react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
138
|
+
react_production_min.cloneElement;
|
|
139
|
+
react_production_min.createContext;
|
|
140
|
+
react_production_min.createElement;
|
|
141
|
+
react_production_min.createFactory;
|
|
142
|
+
react_production_min.createRef;
|
|
143
|
+
react_production_min.forwardRef;
|
|
144
|
+
react_production_min.isValidElement;
|
|
145
|
+
react_production_min.lazy;
|
|
146
|
+
react_production_min.memo;
|
|
147
|
+
react_production_min.useCallback;
|
|
148
|
+
react_production_min.useContext;
|
|
149
|
+
react_production_min.useDebugValue;
|
|
150
|
+
react_production_min.useEffect;
|
|
151
|
+
react_production_min.useImperativeHandle;
|
|
152
|
+
react_production_min.useLayoutEffect;
|
|
153
|
+
react_production_min.useMemo;
|
|
154
|
+
react_production_min.useReducer;
|
|
155
|
+
react_production_min.useRef;
|
|
156
|
+
react_production_min.useState;
|
|
157
|
+
react_production_min.version;
|
|
158
|
+
|
|
159
|
+
var react_development = createCommonjsModule(function (module, exports) {
|
|
160
|
+
|
|
161
|
+
if (process.env.NODE_ENV !== "production") {
|
|
162
|
+
(function() {
|
|
163
|
+
|
|
164
|
+
var _assign = objectAssign;
|
|
165
|
+
|
|
166
|
+
// TODO: this is special because it gets imported during build.
|
|
167
|
+
var ReactVersion = '17.0.2';
|
|
168
|
+
|
|
169
|
+
// ATTENTION
|
|
170
|
+
// When adding new symbols to this file,
|
|
171
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
172
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
173
|
+
// nor polyfill, then a plain number is used for performance.
|
|
174
|
+
var REACT_ELEMENT_TYPE = 0xeac7;
|
|
175
|
+
var REACT_PORTAL_TYPE = 0xeaca;
|
|
176
|
+
exports.Fragment = 0xeacb;
|
|
177
|
+
exports.StrictMode = 0xeacc;
|
|
178
|
+
exports.Profiler = 0xead2;
|
|
179
|
+
var REACT_PROVIDER_TYPE = 0xeacd;
|
|
180
|
+
var REACT_CONTEXT_TYPE = 0xeace;
|
|
181
|
+
var REACT_FORWARD_REF_TYPE = 0xead0;
|
|
182
|
+
exports.Suspense = 0xead1;
|
|
183
|
+
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
|
184
|
+
var REACT_MEMO_TYPE = 0xead3;
|
|
185
|
+
var REACT_LAZY_TYPE = 0xead4;
|
|
186
|
+
var REACT_BLOCK_TYPE = 0xead9;
|
|
187
|
+
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
|
188
|
+
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
|
189
|
+
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
190
|
+
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
191
|
+
|
|
192
|
+
if (typeof Symbol === 'function' && Symbol.for) {
|
|
193
|
+
var symbolFor = Symbol.for;
|
|
194
|
+
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
195
|
+
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
196
|
+
exports.Fragment = symbolFor('react.fragment');
|
|
197
|
+
exports.StrictMode = symbolFor('react.strict_mode');
|
|
198
|
+
exports.Profiler = symbolFor('react.profiler');
|
|
199
|
+
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
200
|
+
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
201
|
+
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
202
|
+
exports.Suspense = symbolFor('react.suspense');
|
|
203
|
+
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
204
|
+
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
205
|
+
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
206
|
+
REACT_BLOCK_TYPE = symbolFor('react.block');
|
|
207
|
+
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
|
208
|
+
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
|
209
|
+
symbolFor('react.scope');
|
|
210
|
+
symbolFor('react.opaque.id');
|
|
211
|
+
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
212
|
+
symbolFor('react.offscreen');
|
|
213
|
+
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
217
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
218
|
+
function getIteratorFn(maybeIterable) {
|
|
219
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
224
|
+
|
|
225
|
+
if (typeof maybeIterator === 'function') {
|
|
226
|
+
return maybeIterator;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Keeps track of the current dispatcher.
|
|
234
|
+
*/
|
|
235
|
+
var ReactCurrentDispatcher = {
|
|
236
|
+
/**
|
|
237
|
+
* @internal
|
|
238
|
+
* @type {ReactComponent}
|
|
239
|
+
*/
|
|
240
|
+
current: null
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Keeps track of the current batch's configuration such as how long an update
|
|
245
|
+
* should suspend for if it needs to.
|
|
246
|
+
*/
|
|
247
|
+
var ReactCurrentBatchConfig = {
|
|
248
|
+
transition: 0
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Keeps track of the current owner.
|
|
253
|
+
*
|
|
254
|
+
* The current owner is the component who should own any components that are
|
|
255
|
+
* currently being constructed.
|
|
256
|
+
*/
|
|
257
|
+
var ReactCurrentOwner = {
|
|
258
|
+
/**
|
|
259
|
+
* @internal
|
|
260
|
+
* @type {ReactComponent}
|
|
261
|
+
*/
|
|
262
|
+
current: null
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
var ReactDebugCurrentFrame = {};
|
|
266
|
+
var currentExtraStackFrame = null;
|
|
267
|
+
function setExtraStackFrame(stack) {
|
|
268
|
+
{
|
|
269
|
+
currentExtraStackFrame = stack;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
{
|
|
274
|
+
ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {
|
|
275
|
+
{
|
|
276
|
+
currentExtraStackFrame = stack;
|
|
277
|
+
}
|
|
278
|
+
}; // Stack implementation injected by the current renderer.
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
282
|
+
|
|
283
|
+
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
284
|
+
var stack = ''; // Add an extra top frame while an element is being validated
|
|
285
|
+
|
|
286
|
+
if (currentExtraStackFrame) {
|
|
287
|
+
stack += currentExtraStackFrame;
|
|
288
|
+
} // Delegate to the injected renderer-specific implementation
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
292
|
+
|
|
293
|
+
if (impl) {
|
|
294
|
+
stack += impl() || '';
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return stack;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Used by act() to track whether you're inside an act() scope.
|
|
303
|
+
*/
|
|
304
|
+
var IsSomeRendererActing = {
|
|
305
|
+
current: false
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
var ReactSharedInternals = {
|
|
309
|
+
ReactCurrentDispatcher: ReactCurrentDispatcher,
|
|
310
|
+
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
|
|
311
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
|
312
|
+
IsSomeRendererActing: IsSomeRendererActing,
|
|
313
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
314
|
+
assign: _assign
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
{
|
|
318
|
+
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// by calls to these methods by a Babel plugin.
|
|
322
|
+
//
|
|
323
|
+
// In PROD (or in packages without access to React internals),
|
|
324
|
+
// they are left as they are instead.
|
|
325
|
+
|
|
326
|
+
function warn(format) {
|
|
327
|
+
{
|
|
328
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
329
|
+
args[_key - 1] = arguments[_key];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
printWarning('warn', format, args);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function error(format) {
|
|
336
|
+
{
|
|
337
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
338
|
+
args[_key2 - 1] = arguments[_key2];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
printWarning('error', format, args);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function printWarning(level, format, args) {
|
|
346
|
+
// When changing this logic, you might want to also
|
|
347
|
+
// update consoleWithStackDev.www.js as well.
|
|
348
|
+
{
|
|
349
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
350
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
351
|
+
|
|
352
|
+
if (stack !== '') {
|
|
353
|
+
format += '%s';
|
|
354
|
+
args = args.concat([stack]);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
var argsWithFormat = args.map(function (item) {
|
|
358
|
+
return '' + item;
|
|
359
|
+
}); // Careful: RN currently depends on this prefix
|
|
360
|
+
|
|
361
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
362
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
363
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
364
|
+
|
|
365
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
var didWarnStateUpdateForUnmountedComponent = {};
|
|
370
|
+
|
|
371
|
+
function warnNoop(publicInstance, callerName) {
|
|
372
|
+
{
|
|
373
|
+
var _constructor = publicInstance.constructor;
|
|
374
|
+
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
|
375
|
+
var warningKey = componentName + "." + callerName;
|
|
376
|
+
|
|
377
|
+
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
|
|
382
|
+
|
|
383
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* This is the abstract API for an update queue.
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
var ReactNoopUpdateQueue = {
|
|
392
|
+
/**
|
|
393
|
+
* Checks whether or not this composite component is mounted.
|
|
394
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
|
395
|
+
* @return {boolean} True if mounted, false otherwise.
|
|
396
|
+
* @protected
|
|
397
|
+
* @final
|
|
398
|
+
*/
|
|
399
|
+
isMounted: function (publicInstance) {
|
|
400
|
+
return false;
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Forces an update. This should only be invoked when it is known with
|
|
405
|
+
* certainty that we are **not** in a DOM transaction.
|
|
406
|
+
*
|
|
407
|
+
* You may want to call this when you know that some deeper aspect of the
|
|
408
|
+
* component's state has changed but `setState` was not called.
|
|
409
|
+
*
|
|
410
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
411
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
|
412
|
+
*
|
|
413
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
414
|
+
* @param {?function} callback Called after component is updated.
|
|
415
|
+
* @param {?string} callerName name of the calling function in the public API.
|
|
416
|
+
* @internal
|
|
417
|
+
*/
|
|
418
|
+
enqueueForceUpdate: function (publicInstance, callback, callerName) {
|
|
419
|
+
warnNoop(publicInstance, 'forceUpdate');
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Replaces all of the state. Always use this or `setState` to mutate state.
|
|
424
|
+
* You should treat `this.state` as immutable.
|
|
425
|
+
*
|
|
426
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
|
427
|
+
* accessing `this.state` after calling this method may return the old value.
|
|
428
|
+
*
|
|
429
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
430
|
+
* @param {object} completeState Next state.
|
|
431
|
+
* @param {?function} callback Called after component is updated.
|
|
432
|
+
* @param {?string} callerName name of the calling function in the public API.
|
|
433
|
+
* @internal
|
|
434
|
+
*/
|
|
435
|
+
enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
|
|
436
|
+
warnNoop(publicInstance, 'replaceState');
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Sets a subset of the state. This only exists because _pendingState is
|
|
441
|
+
* internal. This provides a merging strategy that is not available to deep
|
|
442
|
+
* properties which is confusing. TODO: Expose pendingState or don't use it
|
|
443
|
+
* during the merge.
|
|
444
|
+
*
|
|
445
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
446
|
+
* @param {object} partialState Next partial state to be merged with state.
|
|
447
|
+
* @param {?function} callback Called after component is updated.
|
|
448
|
+
* @param {?string} Name of the calling function in the public API.
|
|
449
|
+
* @internal
|
|
450
|
+
*/
|
|
451
|
+
enqueueSetState: function (publicInstance, partialState, callback, callerName) {
|
|
452
|
+
warnNoop(publicInstance, 'setState');
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
var emptyObject = {};
|
|
457
|
+
|
|
458
|
+
{
|
|
459
|
+
Object.freeze(emptyObject);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Base class helpers for the updating state of a component.
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
function Component(props, context, updater) {
|
|
467
|
+
this.props = props;
|
|
468
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
469
|
+
|
|
470
|
+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
|
|
471
|
+
// renderer.
|
|
472
|
+
|
|
473
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
Component.prototype.isReactComponent = {};
|
|
477
|
+
/**
|
|
478
|
+
* Sets a subset of the state. Always use this to mutate
|
|
479
|
+
* state. You should treat `this.state` as immutable.
|
|
480
|
+
*
|
|
481
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
|
482
|
+
* accessing `this.state` after calling this method may return the old value.
|
|
483
|
+
*
|
|
484
|
+
* There is no guarantee that calls to `setState` will run synchronously,
|
|
485
|
+
* as they may eventually be batched together. You can provide an optional
|
|
486
|
+
* callback that will be executed when the call to setState is actually
|
|
487
|
+
* completed.
|
|
488
|
+
*
|
|
489
|
+
* When a function is provided to setState, it will be called at some point in
|
|
490
|
+
* the future (not synchronously). It will be called with the up to date
|
|
491
|
+
* component arguments (state, props, context). These values can be different
|
|
492
|
+
* from this.* because your function may be called after receiveProps but before
|
|
493
|
+
* shouldComponentUpdate, and this new state, props, and context will not yet be
|
|
494
|
+
* assigned to this.
|
|
495
|
+
*
|
|
496
|
+
* @param {object|function} partialState Next partial state or function to
|
|
497
|
+
* produce next partial state to be merged with current state.
|
|
498
|
+
* @param {?function} callback Called after state is updated.
|
|
499
|
+
* @final
|
|
500
|
+
* @protected
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
Component.prototype.setState = function (partialState, callback) {
|
|
504
|
+
if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
|
|
505
|
+
{
|
|
506
|
+
throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." );
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Forces an update. This should only be invoked when it is known with
|
|
514
|
+
* certainty that we are **not** in a DOM transaction.
|
|
515
|
+
*
|
|
516
|
+
* You may want to call this when you know that some deeper aspect of the
|
|
517
|
+
* component's state has changed but `setState` was not called.
|
|
518
|
+
*
|
|
519
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
520
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
|
521
|
+
*
|
|
522
|
+
* @param {?function} callback Called after update is complete.
|
|
523
|
+
* @final
|
|
524
|
+
* @protected
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
Component.prototype.forceUpdate = function (callback) {
|
|
529
|
+
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
533
|
+
* we would like to deprecate them, we're not going to move them over to this
|
|
534
|
+
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
535
|
+
*/
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
{
|
|
539
|
+
var deprecatedAPIs = {
|
|
540
|
+
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
541
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
var defineDeprecationWarning = function (methodName, info) {
|
|
545
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
546
|
+
get: function () {
|
|
547
|
+
warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
548
|
+
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
for (var fnName in deprecatedAPIs) {
|
|
555
|
+
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
556
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function ComponentDummy() {}
|
|
562
|
+
|
|
563
|
+
ComponentDummy.prototype = Component.prototype;
|
|
564
|
+
/**
|
|
565
|
+
* Convenience component with default shallow equality check for sCU.
|
|
566
|
+
*/
|
|
567
|
+
|
|
568
|
+
function PureComponent(props, context, updater) {
|
|
569
|
+
this.props = props;
|
|
570
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
571
|
+
|
|
572
|
+
this.refs = emptyObject;
|
|
573
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
577
|
+
pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
|
|
578
|
+
|
|
579
|
+
_assign(pureComponentPrototype, Component.prototype);
|
|
580
|
+
|
|
581
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
582
|
+
|
|
583
|
+
// an immutable object with a single mutable value
|
|
584
|
+
function createRef() {
|
|
585
|
+
var refObject = {
|
|
586
|
+
current: null
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
{
|
|
590
|
+
Object.seal(refObject);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return refObject;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
597
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
598
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function getContextName(type) {
|
|
602
|
+
return type.displayName || 'Context';
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function getComponentName(type) {
|
|
606
|
+
if (type == null) {
|
|
607
|
+
// Host root, text node or just invalid type.
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
{
|
|
612
|
+
if (typeof type.tag === 'number') {
|
|
613
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (typeof type === 'function') {
|
|
618
|
+
return type.displayName || type.name || null;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (typeof type === 'string') {
|
|
622
|
+
return type;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
switch (type) {
|
|
626
|
+
case exports.Fragment:
|
|
627
|
+
return 'Fragment';
|
|
628
|
+
|
|
629
|
+
case REACT_PORTAL_TYPE:
|
|
630
|
+
return 'Portal';
|
|
631
|
+
|
|
632
|
+
case exports.Profiler:
|
|
633
|
+
return 'Profiler';
|
|
634
|
+
|
|
635
|
+
case exports.StrictMode:
|
|
636
|
+
return 'StrictMode';
|
|
637
|
+
|
|
638
|
+
case exports.Suspense:
|
|
639
|
+
return 'Suspense';
|
|
640
|
+
|
|
641
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
642
|
+
return 'SuspenseList';
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (typeof type === 'object') {
|
|
646
|
+
switch (type.$$typeof) {
|
|
647
|
+
case REACT_CONTEXT_TYPE:
|
|
648
|
+
var context = type;
|
|
649
|
+
return getContextName(context) + '.Consumer';
|
|
650
|
+
|
|
651
|
+
case REACT_PROVIDER_TYPE:
|
|
652
|
+
var provider = type;
|
|
653
|
+
return getContextName(provider._context) + '.Provider';
|
|
654
|
+
|
|
655
|
+
case REACT_FORWARD_REF_TYPE:
|
|
656
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
657
|
+
|
|
658
|
+
case REACT_MEMO_TYPE:
|
|
659
|
+
return getComponentName(type.type);
|
|
660
|
+
|
|
661
|
+
case REACT_BLOCK_TYPE:
|
|
662
|
+
return getComponentName(type._render);
|
|
663
|
+
|
|
664
|
+
case REACT_LAZY_TYPE:
|
|
665
|
+
{
|
|
666
|
+
var lazyComponent = type;
|
|
667
|
+
var payload = lazyComponent._payload;
|
|
668
|
+
var init = lazyComponent._init;
|
|
669
|
+
|
|
670
|
+
try {
|
|
671
|
+
return getComponentName(init(payload));
|
|
672
|
+
} catch (x) {
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
683
|
+
var RESERVED_PROPS = {
|
|
684
|
+
key: true,
|
|
685
|
+
ref: true,
|
|
686
|
+
__self: true,
|
|
687
|
+
__source: true
|
|
688
|
+
};
|
|
689
|
+
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
|
|
690
|
+
|
|
691
|
+
{
|
|
692
|
+
didWarnAboutStringRefs = {};
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function hasValidRef(config) {
|
|
696
|
+
{
|
|
697
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
698
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
699
|
+
|
|
700
|
+
if (getter && getter.isReactWarning) {
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return config.ref !== undefined;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function hasValidKey(config) {
|
|
710
|
+
{
|
|
711
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
712
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
713
|
+
|
|
714
|
+
if (getter && getter.isReactWarning) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return config.key !== undefined;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
724
|
+
var warnAboutAccessingKey = function () {
|
|
725
|
+
{
|
|
726
|
+
if (!specialPropKeyWarningShown) {
|
|
727
|
+
specialPropKeyWarningShown = true;
|
|
728
|
+
|
|
729
|
+
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
735
|
+
Object.defineProperty(props, 'key', {
|
|
736
|
+
get: warnAboutAccessingKey,
|
|
737
|
+
configurable: true
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
742
|
+
var warnAboutAccessingRef = function () {
|
|
743
|
+
{
|
|
744
|
+
if (!specialPropRefWarningShown) {
|
|
745
|
+
specialPropRefWarningShown = true;
|
|
746
|
+
|
|
747
|
+
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
753
|
+
Object.defineProperty(props, 'ref', {
|
|
754
|
+
get: warnAboutAccessingRef,
|
|
755
|
+
configurable: true
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function warnIfStringRefCannotBeAutoConverted(config) {
|
|
760
|
+
{
|
|
761
|
+
if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
|
|
762
|
+
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
763
|
+
|
|
764
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
765
|
+
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
|
|
766
|
+
|
|
767
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
774
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
775
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
776
|
+
* if something is a React Element.
|
|
777
|
+
*
|
|
778
|
+
* @param {*} type
|
|
779
|
+
* @param {*} props
|
|
780
|
+
* @param {*} key
|
|
781
|
+
* @param {string|object} ref
|
|
782
|
+
* @param {*} owner
|
|
783
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
784
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
785
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
786
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
787
|
+
* change in behavior.
|
|
788
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
789
|
+
* indicating filename, line number, and/or other information.
|
|
790
|
+
* @internal
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
795
|
+
var element = {
|
|
796
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
797
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
798
|
+
// Built-in properties that belong on the element
|
|
799
|
+
type: type,
|
|
800
|
+
key: key,
|
|
801
|
+
ref: ref,
|
|
802
|
+
props: props,
|
|
803
|
+
// Record the component responsible for creating this element.
|
|
804
|
+
_owner: owner
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
{
|
|
808
|
+
// The validation flag is currently mutative. We put it on
|
|
809
|
+
// an external backing store so that we can freeze the whole object.
|
|
810
|
+
// This can be replaced with a WeakMap once they are implemented in
|
|
811
|
+
// commonly used development environments.
|
|
812
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
813
|
+
// the validation flag non-enumerable (where possible, which should
|
|
814
|
+
// include every environment we run tests in), so the test framework
|
|
815
|
+
// ignores it.
|
|
816
|
+
|
|
817
|
+
Object.defineProperty(element._store, 'validated', {
|
|
818
|
+
configurable: false,
|
|
819
|
+
enumerable: false,
|
|
820
|
+
writable: true,
|
|
821
|
+
value: false
|
|
822
|
+
}); // self and source are DEV only properties.
|
|
823
|
+
|
|
824
|
+
Object.defineProperty(element, '_self', {
|
|
825
|
+
configurable: false,
|
|
826
|
+
enumerable: false,
|
|
827
|
+
writable: false,
|
|
828
|
+
value: self
|
|
829
|
+
}); // Two elements created in two different places should be considered
|
|
830
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
831
|
+
|
|
832
|
+
Object.defineProperty(element, '_source', {
|
|
833
|
+
configurable: false,
|
|
834
|
+
enumerable: false,
|
|
835
|
+
writable: false,
|
|
836
|
+
value: source
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
if (Object.freeze) {
|
|
840
|
+
Object.freeze(element.props);
|
|
841
|
+
Object.freeze(element);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
return element;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* Create and return a new ReactElement of the given type.
|
|
849
|
+
* See https://reactjs.org/docs/react-api.html#createelement
|
|
850
|
+
*/
|
|
851
|
+
|
|
852
|
+
function createElement(type, config, children) {
|
|
853
|
+
var propName; // Reserved names are extracted
|
|
854
|
+
|
|
855
|
+
var props = {};
|
|
856
|
+
var key = null;
|
|
857
|
+
var ref = null;
|
|
858
|
+
var self = null;
|
|
859
|
+
var source = null;
|
|
860
|
+
|
|
861
|
+
if (config != null) {
|
|
862
|
+
if (hasValidRef(config)) {
|
|
863
|
+
ref = config.ref;
|
|
864
|
+
|
|
865
|
+
{
|
|
866
|
+
warnIfStringRefCannotBeAutoConverted(config);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
if (hasValidKey(config)) {
|
|
871
|
+
key = '' + config.key;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
self = config.__self === undefined ? null : config.__self;
|
|
875
|
+
source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
|
|
876
|
+
|
|
877
|
+
for (propName in config) {
|
|
878
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
879
|
+
props[propName] = config[propName];
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
883
|
+
// the newly allocated props object.
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
var childrenLength = arguments.length - 2;
|
|
887
|
+
|
|
888
|
+
if (childrenLength === 1) {
|
|
889
|
+
props.children = children;
|
|
890
|
+
} else if (childrenLength > 1) {
|
|
891
|
+
var childArray = Array(childrenLength);
|
|
892
|
+
|
|
893
|
+
for (var i = 0; i < childrenLength; i++) {
|
|
894
|
+
childArray[i] = arguments[i + 2];
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
{
|
|
898
|
+
if (Object.freeze) {
|
|
899
|
+
Object.freeze(childArray);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
props.children = childArray;
|
|
904
|
+
} // Resolve default props
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
if (type && type.defaultProps) {
|
|
908
|
+
var defaultProps = type.defaultProps;
|
|
909
|
+
|
|
910
|
+
for (propName in defaultProps) {
|
|
911
|
+
if (props[propName] === undefined) {
|
|
912
|
+
props[propName] = defaultProps[propName];
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
{
|
|
918
|
+
if (key || ref) {
|
|
919
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
920
|
+
|
|
921
|
+
if (key) {
|
|
922
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if (ref) {
|
|
926
|
+
defineRefPropWarningGetter(props, displayName);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
932
|
+
}
|
|
933
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
934
|
+
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
935
|
+
return newElement;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Clone and return a new ReactElement using element as the starting point.
|
|
939
|
+
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
940
|
+
*/
|
|
941
|
+
|
|
942
|
+
function cloneElement(element, config, children) {
|
|
943
|
+
if (!!(element === null || element === undefined)) {
|
|
944
|
+
{
|
|
945
|
+
throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." );
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
var propName; // Original props are copied
|
|
950
|
+
|
|
951
|
+
var props = _assign({}, element.props); // Reserved names are extracted
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
var key = element.key;
|
|
955
|
+
var ref = element.ref; // Self is preserved since the owner is preserved.
|
|
956
|
+
|
|
957
|
+
var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
|
|
958
|
+
// transpiler, and the original source is probably a better indicator of the
|
|
959
|
+
// true owner.
|
|
960
|
+
|
|
961
|
+
var source = element._source; // Owner will be preserved, unless ref is overridden
|
|
962
|
+
|
|
963
|
+
var owner = element._owner;
|
|
964
|
+
|
|
965
|
+
if (config != null) {
|
|
966
|
+
if (hasValidRef(config)) {
|
|
967
|
+
// Silently steal the ref from the parent.
|
|
968
|
+
ref = config.ref;
|
|
969
|
+
owner = ReactCurrentOwner.current;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
if (hasValidKey(config)) {
|
|
973
|
+
key = '' + config.key;
|
|
974
|
+
} // Remaining properties override existing props
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
var defaultProps;
|
|
978
|
+
|
|
979
|
+
if (element.type && element.type.defaultProps) {
|
|
980
|
+
defaultProps = element.type.defaultProps;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
for (propName in config) {
|
|
984
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
985
|
+
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
986
|
+
// Resolve default props
|
|
987
|
+
props[propName] = defaultProps[propName];
|
|
988
|
+
} else {
|
|
989
|
+
props[propName] = config[propName];
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
994
|
+
// the newly allocated props object.
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
var childrenLength = arguments.length - 2;
|
|
998
|
+
|
|
999
|
+
if (childrenLength === 1) {
|
|
1000
|
+
props.children = children;
|
|
1001
|
+
} else if (childrenLength > 1) {
|
|
1002
|
+
var childArray = Array(childrenLength);
|
|
1003
|
+
|
|
1004
|
+
for (var i = 0; i < childrenLength; i++) {
|
|
1005
|
+
childArray[i] = arguments[i + 2];
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
props.children = childArray;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
return ReactElement(element.type, key, ref, self, source, owner, props);
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Verifies the object is a ReactElement.
|
|
1015
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
1016
|
+
* @param {?object} object
|
|
1017
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
1018
|
+
* @final
|
|
1019
|
+
*/
|
|
1020
|
+
|
|
1021
|
+
function isValidElement(object) {
|
|
1022
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
var SEPARATOR = '.';
|
|
1026
|
+
var SUBSEPARATOR = ':';
|
|
1027
|
+
/**
|
|
1028
|
+
* Escape and wrap key so it is safe to use as a reactid
|
|
1029
|
+
*
|
|
1030
|
+
* @param {string} key to be escaped.
|
|
1031
|
+
* @return {string} the escaped key.
|
|
1032
|
+
*/
|
|
1033
|
+
|
|
1034
|
+
function escape(key) {
|
|
1035
|
+
var escapeRegex = /[=:]/g;
|
|
1036
|
+
var escaperLookup = {
|
|
1037
|
+
'=': '=0',
|
|
1038
|
+
':': '=2'
|
|
1039
|
+
};
|
|
1040
|
+
var escapedString = key.replace(escapeRegex, function (match) {
|
|
1041
|
+
return escaperLookup[match];
|
|
1042
|
+
});
|
|
1043
|
+
return '$' + escapedString;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* TODO: Test that a single child and an array with one item have the same key
|
|
1047
|
+
* pattern.
|
|
1048
|
+
*/
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
var didWarnAboutMaps = false;
|
|
1052
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
1053
|
+
|
|
1054
|
+
function escapeUserProvidedKey(text) {
|
|
1055
|
+
return text.replace(userProvidedKeyEscapeRegex, '$&/');
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Generate a key string that identifies a element within a set.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {*} element A element that could contain a manual key.
|
|
1061
|
+
* @param {number} index Index that is used if a manual key is not provided.
|
|
1062
|
+
* @return {string}
|
|
1063
|
+
*/
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
function getElementKey(element, index) {
|
|
1067
|
+
// Do some typechecking here since we call this blindly. We want to ensure
|
|
1068
|
+
// that we don't block potential future ES APIs.
|
|
1069
|
+
if (typeof element === 'object' && element !== null && element.key != null) {
|
|
1070
|
+
// Explicit key
|
|
1071
|
+
return escape('' + element.key);
|
|
1072
|
+
} // Implicit key determined by the index in the set
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
return index.toString(36);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
1079
|
+
var type = typeof children;
|
|
1080
|
+
|
|
1081
|
+
if (type === 'undefined' || type === 'boolean') {
|
|
1082
|
+
// All of the above are perceived as null.
|
|
1083
|
+
children = null;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
var invokeCallback = false;
|
|
1087
|
+
|
|
1088
|
+
if (children === null) {
|
|
1089
|
+
invokeCallback = true;
|
|
1090
|
+
} else {
|
|
1091
|
+
switch (type) {
|
|
1092
|
+
case 'string':
|
|
1093
|
+
case 'number':
|
|
1094
|
+
invokeCallback = true;
|
|
1095
|
+
break;
|
|
1096
|
+
|
|
1097
|
+
case 'object':
|
|
1098
|
+
switch (children.$$typeof) {
|
|
1099
|
+
case REACT_ELEMENT_TYPE:
|
|
1100
|
+
case REACT_PORTAL_TYPE:
|
|
1101
|
+
invokeCallback = true;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
if (invokeCallback) {
|
|
1108
|
+
var _child = children;
|
|
1109
|
+
var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
|
|
1110
|
+
// so that it's consistent if the number of children grows:
|
|
1111
|
+
|
|
1112
|
+
var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
|
|
1113
|
+
|
|
1114
|
+
if (Array.isArray(mappedChild)) {
|
|
1115
|
+
var escapedChildKey = '';
|
|
1116
|
+
|
|
1117
|
+
if (childKey != null) {
|
|
1118
|
+
escapedChildKey = escapeUserProvidedKey(childKey) + '/';
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
|
|
1122
|
+
return c;
|
|
1123
|
+
});
|
|
1124
|
+
} else if (mappedChild != null) {
|
|
1125
|
+
if (isValidElement(mappedChild)) {
|
|
1126
|
+
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
|
|
1127
|
+
// traverseAllChildren used to do for objects as children
|
|
1128
|
+
escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
|
|
1129
|
+
mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
|
|
1130
|
+
escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
array.push(mappedChild);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return 1;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
var child;
|
|
1140
|
+
var nextName;
|
|
1141
|
+
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
1142
|
+
|
|
1143
|
+
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
1144
|
+
|
|
1145
|
+
if (Array.isArray(children)) {
|
|
1146
|
+
for (var i = 0; i < children.length; i++) {
|
|
1147
|
+
child = children[i];
|
|
1148
|
+
nextName = nextNamePrefix + getElementKey(child, i);
|
|
1149
|
+
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
|
1150
|
+
}
|
|
1151
|
+
} else {
|
|
1152
|
+
var iteratorFn = getIteratorFn(children);
|
|
1153
|
+
|
|
1154
|
+
if (typeof iteratorFn === 'function') {
|
|
1155
|
+
var iterableChildren = children;
|
|
1156
|
+
|
|
1157
|
+
{
|
|
1158
|
+
// Warn about using Maps as children
|
|
1159
|
+
if (iteratorFn === iterableChildren.entries) {
|
|
1160
|
+
if (!didWarnAboutMaps) {
|
|
1161
|
+
warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
didWarnAboutMaps = true;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
var iterator = iteratorFn.call(iterableChildren);
|
|
1169
|
+
var step;
|
|
1170
|
+
var ii = 0;
|
|
1171
|
+
|
|
1172
|
+
while (!(step = iterator.next()).done) {
|
|
1173
|
+
child = step.value;
|
|
1174
|
+
nextName = nextNamePrefix + getElementKey(child, ii++);
|
|
1175
|
+
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
|
1176
|
+
}
|
|
1177
|
+
} else if (type === 'object') {
|
|
1178
|
+
var childrenString = '' + children;
|
|
1179
|
+
|
|
1180
|
+
{
|
|
1181
|
+
{
|
|
1182
|
+
throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). If you meant to render a collection of children, use an array instead." );
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
return subtreeCount;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Maps children that are typically specified as `props.children`.
|
|
1193
|
+
*
|
|
1194
|
+
* See https://reactjs.org/docs/react-api.html#reactchildrenmap
|
|
1195
|
+
*
|
|
1196
|
+
* The provided mapFunction(child, index) will be called for each
|
|
1197
|
+
* leaf child.
|
|
1198
|
+
*
|
|
1199
|
+
* @param {?*} children Children tree container.
|
|
1200
|
+
* @param {function(*, int)} func The map function.
|
|
1201
|
+
* @param {*} context Context for mapFunction.
|
|
1202
|
+
* @return {object} Object containing the ordered map of results.
|
|
1203
|
+
*/
|
|
1204
|
+
function mapChildren(children, func, context) {
|
|
1205
|
+
if (children == null) {
|
|
1206
|
+
return children;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
var result = [];
|
|
1210
|
+
var count = 0;
|
|
1211
|
+
mapIntoArray(children, result, '', '', function (child) {
|
|
1212
|
+
return func.call(context, child, count++);
|
|
1213
|
+
});
|
|
1214
|
+
return result;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Count the number of children that are typically specified as
|
|
1218
|
+
* `props.children`.
|
|
1219
|
+
*
|
|
1220
|
+
* See https://reactjs.org/docs/react-api.html#reactchildrencount
|
|
1221
|
+
*
|
|
1222
|
+
* @param {?*} children Children tree container.
|
|
1223
|
+
* @return {number} The number of children.
|
|
1224
|
+
*/
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
function countChildren(children) {
|
|
1228
|
+
var n = 0;
|
|
1229
|
+
mapChildren(children, function () {
|
|
1230
|
+
n++; // Don't return anything
|
|
1231
|
+
});
|
|
1232
|
+
return n;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Iterates through children that are typically specified as `props.children`.
|
|
1237
|
+
*
|
|
1238
|
+
* See https://reactjs.org/docs/react-api.html#reactchildrenforeach
|
|
1239
|
+
*
|
|
1240
|
+
* The provided forEachFunc(child, index) will be called for each
|
|
1241
|
+
* leaf child.
|
|
1242
|
+
*
|
|
1243
|
+
* @param {?*} children Children tree container.
|
|
1244
|
+
* @param {function(*, int)} forEachFunc
|
|
1245
|
+
* @param {*} forEachContext Context for forEachContext.
|
|
1246
|
+
*/
|
|
1247
|
+
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
1248
|
+
mapChildren(children, function () {
|
|
1249
|
+
forEachFunc.apply(this, arguments); // Don't return anything.
|
|
1250
|
+
}, forEachContext);
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Flatten a children object (typically specified as `props.children`) and
|
|
1254
|
+
* return an array with appropriately re-keyed children.
|
|
1255
|
+
*
|
|
1256
|
+
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
|
1257
|
+
*/
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
function toArray(children) {
|
|
1261
|
+
return mapChildren(children, function (child) {
|
|
1262
|
+
return child;
|
|
1263
|
+
}) || [];
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Returns the first child in a collection of children and verifies that there
|
|
1267
|
+
* is only one child in the collection.
|
|
1268
|
+
*
|
|
1269
|
+
* See https://reactjs.org/docs/react-api.html#reactchildrenonly
|
|
1270
|
+
*
|
|
1271
|
+
* The current implementation of this function assumes that a single child gets
|
|
1272
|
+
* passed without a wrapper, but the purpose of this helper function is to
|
|
1273
|
+
* abstract away the particular structure of children.
|
|
1274
|
+
*
|
|
1275
|
+
* @param {?object} children Child collection structure.
|
|
1276
|
+
* @return {ReactElement} The first and only `ReactElement` contained in the
|
|
1277
|
+
* structure.
|
|
1278
|
+
*/
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
function onlyChild(children) {
|
|
1282
|
+
if (!isValidElement(children)) {
|
|
1283
|
+
{
|
|
1284
|
+
throw Error( "React.Children.only expected to receive a single React element child." );
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
return children;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
function createContext(defaultValue, calculateChangedBits) {
|
|
1292
|
+
if (calculateChangedBits === undefined) {
|
|
1293
|
+
calculateChangedBits = null;
|
|
1294
|
+
} else {
|
|
1295
|
+
{
|
|
1296
|
+
if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
|
|
1297
|
+
error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
var context = {
|
|
1303
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
1304
|
+
_calculateChangedBits: calculateChangedBits,
|
|
1305
|
+
// As a workaround to support multiple concurrent renderers, we categorize
|
|
1306
|
+
// some renderers as primary and others as secondary. We only expect
|
|
1307
|
+
// there to be two concurrent renderers at most: React Native (primary) and
|
|
1308
|
+
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
|
1309
|
+
// Secondary renderers store their context values on separate fields.
|
|
1310
|
+
_currentValue: defaultValue,
|
|
1311
|
+
_currentValue2: defaultValue,
|
|
1312
|
+
// Used to track how many concurrent renderers this context currently
|
|
1313
|
+
// supports within in a single renderer. Such as parallel server rendering.
|
|
1314
|
+
_threadCount: 0,
|
|
1315
|
+
// These are circular
|
|
1316
|
+
Provider: null,
|
|
1317
|
+
Consumer: null
|
|
1318
|
+
};
|
|
1319
|
+
context.Provider = {
|
|
1320
|
+
$$typeof: REACT_PROVIDER_TYPE,
|
|
1321
|
+
_context: context
|
|
1322
|
+
};
|
|
1323
|
+
var hasWarnedAboutUsingNestedContextConsumers = false;
|
|
1324
|
+
var hasWarnedAboutUsingConsumerProvider = false;
|
|
1325
|
+
var hasWarnedAboutDisplayNameOnConsumer = false;
|
|
1326
|
+
|
|
1327
|
+
{
|
|
1328
|
+
// A separate object, but proxies back to the original context object for
|
|
1329
|
+
// backwards compatibility. It has a different $$typeof, so we can properly
|
|
1330
|
+
// warn for the incorrect usage of Context as a Consumer.
|
|
1331
|
+
var Consumer = {
|
|
1332
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
1333
|
+
_context: context,
|
|
1334
|
+
_calculateChangedBits: context._calculateChangedBits
|
|
1335
|
+
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
|
|
1336
|
+
|
|
1337
|
+
Object.defineProperties(Consumer, {
|
|
1338
|
+
Provider: {
|
|
1339
|
+
get: function () {
|
|
1340
|
+
if (!hasWarnedAboutUsingConsumerProvider) {
|
|
1341
|
+
hasWarnedAboutUsingConsumerProvider = true;
|
|
1342
|
+
|
|
1343
|
+
error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
return context.Provider;
|
|
1347
|
+
},
|
|
1348
|
+
set: function (_Provider) {
|
|
1349
|
+
context.Provider = _Provider;
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
_currentValue: {
|
|
1353
|
+
get: function () {
|
|
1354
|
+
return context._currentValue;
|
|
1355
|
+
},
|
|
1356
|
+
set: function (_currentValue) {
|
|
1357
|
+
context._currentValue = _currentValue;
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
_currentValue2: {
|
|
1361
|
+
get: function () {
|
|
1362
|
+
return context._currentValue2;
|
|
1363
|
+
},
|
|
1364
|
+
set: function (_currentValue2) {
|
|
1365
|
+
context._currentValue2 = _currentValue2;
|
|
1366
|
+
}
|
|
1367
|
+
},
|
|
1368
|
+
_threadCount: {
|
|
1369
|
+
get: function () {
|
|
1370
|
+
return context._threadCount;
|
|
1371
|
+
},
|
|
1372
|
+
set: function (_threadCount) {
|
|
1373
|
+
context._threadCount = _threadCount;
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
Consumer: {
|
|
1377
|
+
get: function () {
|
|
1378
|
+
if (!hasWarnedAboutUsingNestedContextConsumers) {
|
|
1379
|
+
hasWarnedAboutUsingNestedContextConsumers = true;
|
|
1380
|
+
|
|
1381
|
+
error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
return context.Consumer;
|
|
1385
|
+
}
|
|
1386
|
+
},
|
|
1387
|
+
displayName: {
|
|
1388
|
+
get: function () {
|
|
1389
|
+
return context.displayName;
|
|
1390
|
+
},
|
|
1391
|
+
set: function (displayName) {
|
|
1392
|
+
if (!hasWarnedAboutDisplayNameOnConsumer) {
|
|
1393
|
+
warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName);
|
|
1394
|
+
|
|
1395
|
+
hasWarnedAboutDisplayNameOnConsumer = true;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
|
|
1400
|
+
|
|
1401
|
+
context.Consumer = Consumer;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
{
|
|
1405
|
+
context._currentRenderer = null;
|
|
1406
|
+
context._currentRenderer2 = null;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
return context;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
var Uninitialized = -1;
|
|
1413
|
+
var Pending = 0;
|
|
1414
|
+
var Resolved = 1;
|
|
1415
|
+
var Rejected = 2;
|
|
1416
|
+
|
|
1417
|
+
function lazyInitializer(payload) {
|
|
1418
|
+
if (payload._status === Uninitialized) {
|
|
1419
|
+
var ctor = payload._result;
|
|
1420
|
+
var thenable = ctor(); // Transition to the next state.
|
|
1421
|
+
|
|
1422
|
+
var pending = payload;
|
|
1423
|
+
pending._status = Pending;
|
|
1424
|
+
pending._result = thenable;
|
|
1425
|
+
thenable.then(function (moduleObject) {
|
|
1426
|
+
if (payload._status === Pending) {
|
|
1427
|
+
var defaultExport = moduleObject.default;
|
|
1428
|
+
|
|
1429
|
+
{
|
|
1430
|
+
if (defaultExport === undefined) {
|
|
1431
|
+
error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
|
1432
|
+
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
|
|
1433
|
+
}
|
|
1434
|
+
} // Transition to the next state.
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
var resolved = payload;
|
|
1438
|
+
resolved._status = Resolved;
|
|
1439
|
+
resolved._result = defaultExport;
|
|
1440
|
+
}
|
|
1441
|
+
}, function (error) {
|
|
1442
|
+
if (payload._status === Pending) {
|
|
1443
|
+
// Transition to the next state.
|
|
1444
|
+
var rejected = payload;
|
|
1445
|
+
rejected._status = Rejected;
|
|
1446
|
+
rejected._result = error;
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
if (payload._status === Resolved) {
|
|
1452
|
+
return payload._result;
|
|
1453
|
+
} else {
|
|
1454
|
+
throw payload._result;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
function lazy(ctor) {
|
|
1459
|
+
var payload = {
|
|
1460
|
+
// We use these fields to store the result.
|
|
1461
|
+
_status: -1,
|
|
1462
|
+
_result: ctor
|
|
1463
|
+
};
|
|
1464
|
+
var lazyType = {
|
|
1465
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
1466
|
+
_payload: payload,
|
|
1467
|
+
_init: lazyInitializer
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
{
|
|
1471
|
+
// In production, this would just set it on the object.
|
|
1472
|
+
var defaultProps;
|
|
1473
|
+
var propTypes; // $FlowFixMe
|
|
1474
|
+
|
|
1475
|
+
Object.defineProperties(lazyType, {
|
|
1476
|
+
defaultProps: {
|
|
1477
|
+
configurable: true,
|
|
1478
|
+
get: function () {
|
|
1479
|
+
return defaultProps;
|
|
1480
|
+
},
|
|
1481
|
+
set: function (newDefaultProps) {
|
|
1482
|
+
error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
|
1483
|
+
|
|
1484
|
+
defaultProps = newDefaultProps; // Match production behavior more closely:
|
|
1485
|
+
// $FlowFixMe
|
|
1486
|
+
|
|
1487
|
+
Object.defineProperty(lazyType, 'defaultProps', {
|
|
1488
|
+
enumerable: true
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
propTypes: {
|
|
1493
|
+
configurable: true,
|
|
1494
|
+
get: function () {
|
|
1495
|
+
return propTypes;
|
|
1496
|
+
},
|
|
1497
|
+
set: function (newPropTypes) {
|
|
1498
|
+
error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
|
1499
|
+
|
|
1500
|
+
propTypes = newPropTypes; // Match production behavior more closely:
|
|
1501
|
+
// $FlowFixMe
|
|
1502
|
+
|
|
1503
|
+
Object.defineProperty(lazyType, 'propTypes', {
|
|
1504
|
+
enumerable: true
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
return lazyType;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function forwardRef(render) {
|
|
1515
|
+
{
|
|
1516
|
+
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
|
|
1517
|
+
error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
|
|
1518
|
+
} else if (typeof render !== 'function') {
|
|
1519
|
+
error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
1520
|
+
} else {
|
|
1521
|
+
if (render.length !== 0 && render.length !== 2) {
|
|
1522
|
+
error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
if (render != null) {
|
|
1527
|
+
if (render.defaultProps != null || render.propTypes != null) {
|
|
1528
|
+
error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
var elementType = {
|
|
1534
|
+
$$typeof: REACT_FORWARD_REF_TYPE,
|
|
1535
|
+
render: render
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
{
|
|
1539
|
+
var ownName;
|
|
1540
|
+
Object.defineProperty(elementType, 'displayName', {
|
|
1541
|
+
enumerable: false,
|
|
1542
|
+
configurable: true,
|
|
1543
|
+
get: function () {
|
|
1544
|
+
return ownName;
|
|
1545
|
+
},
|
|
1546
|
+
set: function (name) {
|
|
1547
|
+
ownName = name;
|
|
1548
|
+
|
|
1549
|
+
if (render.displayName == null) {
|
|
1550
|
+
render.displayName = name;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
return elementType;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
|
1560
|
+
|
|
1561
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
1562
|
+
|
|
1563
|
+
function isValidElementType(type) {
|
|
1564
|
+
if (typeof type === 'string' || typeof type === 'function') {
|
|
1565
|
+
return true;
|
|
1566
|
+
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
|
1570
|
+
return true;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
if (typeof type === 'object' && type !== null) {
|
|
1574
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
|
1575
|
+
return true;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
return false;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
function memo(type, compare) {
|
|
1583
|
+
{
|
|
1584
|
+
if (!isValidElementType(type)) {
|
|
1585
|
+
error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
var elementType = {
|
|
1590
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
1591
|
+
type: type,
|
|
1592
|
+
compare: compare === undefined ? null : compare
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
{
|
|
1596
|
+
var ownName;
|
|
1597
|
+
Object.defineProperty(elementType, 'displayName', {
|
|
1598
|
+
enumerable: false,
|
|
1599
|
+
configurable: true,
|
|
1600
|
+
get: function () {
|
|
1601
|
+
return ownName;
|
|
1602
|
+
},
|
|
1603
|
+
set: function (name) {
|
|
1604
|
+
ownName = name;
|
|
1605
|
+
|
|
1606
|
+
if (type.displayName == null) {
|
|
1607
|
+
type.displayName = name;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
return elementType;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
function resolveDispatcher() {
|
|
1617
|
+
var dispatcher = ReactCurrentDispatcher.current;
|
|
1618
|
+
|
|
1619
|
+
if (!(dispatcher !== null)) {
|
|
1620
|
+
{
|
|
1621
|
+
throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." );
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
return dispatcher;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
function useContext(Context, unstable_observedBits) {
|
|
1629
|
+
var dispatcher = resolveDispatcher();
|
|
1630
|
+
|
|
1631
|
+
{
|
|
1632
|
+
if (unstable_observedBits !== undefined) {
|
|
1633
|
+
error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://reactjs.org/link/rules-of-hooks' : '');
|
|
1634
|
+
} // TODO: add a more generic warning for invalid values.
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
if (Context._context !== undefined) {
|
|
1638
|
+
var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
|
|
1639
|
+
// and nobody should be using this in existing code.
|
|
1640
|
+
|
|
1641
|
+
if (realContext.Consumer === Context) {
|
|
1642
|
+
error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
|
|
1643
|
+
} else if (realContext.Provider === Context) {
|
|
1644
|
+
error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
return dispatcher.useContext(Context, unstable_observedBits);
|
|
1650
|
+
}
|
|
1651
|
+
function useState(initialState) {
|
|
1652
|
+
var dispatcher = resolveDispatcher();
|
|
1653
|
+
return dispatcher.useState(initialState);
|
|
1654
|
+
}
|
|
1655
|
+
function useReducer(reducer, initialArg, init) {
|
|
1656
|
+
var dispatcher = resolveDispatcher();
|
|
1657
|
+
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1658
|
+
}
|
|
1659
|
+
function useRef(initialValue) {
|
|
1660
|
+
var dispatcher = resolveDispatcher();
|
|
1661
|
+
return dispatcher.useRef(initialValue);
|
|
1662
|
+
}
|
|
1663
|
+
function useEffect(create, deps) {
|
|
1664
|
+
var dispatcher = resolveDispatcher();
|
|
1665
|
+
return dispatcher.useEffect(create, deps);
|
|
1666
|
+
}
|
|
1667
|
+
function useLayoutEffect(create, deps) {
|
|
1668
|
+
var dispatcher = resolveDispatcher();
|
|
1669
|
+
return dispatcher.useLayoutEffect(create, deps);
|
|
1670
|
+
}
|
|
1671
|
+
function useCallback(callback, deps) {
|
|
1672
|
+
var dispatcher = resolveDispatcher();
|
|
1673
|
+
return dispatcher.useCallback(callback, deps);
|
|
1674
|
+
}
|
|
1675
|
+
function useMemo(create, deps) {
|
|
1676
|
+
var dispatcher = resolveDispatcher();
|
|
1677
|
+
return dispatcher.useMemo(create, deps);
|
|
1678
|
+
}
|
|
1679
|
+
function useImperativeHandle(ref, create, deps) {
|
|
1680
|
+
var dispatcher = resolveDispatcher();
|
|
1681
|
+
return dispatcher.useImperativeHandle(ref, create, deps);
|
|
1682
|
+
}
|
|
1683
|
+
function useDebugValue(value, formatterFn) {
|
|
1684
|
+
{
|
|
1685
|
+
var dispatcher = resolveDispatcher();
|
|
1686
|
+
return dispatcher.useDebugValue(value, formatterFn);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
1691
|
+
// replaying on render function. This currently only patches the object
|
|
1692
|
+
// lazily which won't cover if the log function was extracted eagerly.
|
|
1693
|
+
// We could also eagerly patch the method.
|
|
1694
|
+
var disabledDepth = 0;
|
|
1695
|
+
var prevLog;
|
|
1696
|
+
var prevInfo;
|
|
1697
|
+
var prevWarn;
|
|
1698
|
+
var prevError;
|
|
1699
|
+
var prevGroup;
|
|
1700
|
+
var prevGroupCollapsed;
|
|
1701
|
+
var prevGroupEnd;
|
|
1702
|
+
|
|
1703
|
+
function disabledLog() {}
|
|
1704
|
+
|
|
1705
|
+
disabledLog.__reactDisabledLog = true;
|
|
1706
|
+
function disableLogs() {
|
|
1707
|
+
{
|
|
1708
|
+
if (disabledDepth === 0) {
|
|
1709
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
1710
|
+
prevLog = console.log;
|
|
1711
|
+
prevInfo = console.info;
|
|
1712
|
+
prevWarn = console.warn;
|
|
1713
|
+
prevError = console.error;
|
|
1714
|
+
prevGroup = console.group;
|
|
1715
|
+
prevGroupCollapsed = console.groupCollapsed;
|
|
1716
|
+
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
|
1717
|
+
|
|
1718
|
+
var props = {
|
|
1719
|
+
configurable: true,
|
|
1720
|
+
enumerable: true,
|
|
1721
|
+
value: disabledLog,
|
|
1722
|
+
writable: true
|
|
1723
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
1724
|
+
|
|
1725
|
+
Object.defineProperties(console, {
|
|
1726
|
+
info: props,
|
|
1727
|
+
log: props,
|
|
1728
|
+
warn: props,
|
|
1729
|
+
error: props,
|
|
1730
|
+
group: props,
|
|
1731
|
+
groupCollapsed: props,
|
|
1732
|
+
groupEnd: props
|
|
1733
|
+
});
|
|
1734
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
disabledDepth++;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
function reenableLogs() {
|
|
1741
|
+
{
|
|
1742
|
+
disabledDepth--;
|
|
1743
|
+
|
|
1744
|
+
if (disabledDepth === 0) {
|
|
1745
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
1746
|
+
var props = {
|
|
1747
|
+
configurable: true,
|
|
1748
|
+
enumerable: true,
|
|
1749
|
+
writable: true
|
|
1750
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
1751
|
+
|
|
1752
|
+
Object.defineProperties(console, {
|
|
1753
|
+
log: _assign({}, props, {
|
|
1754
|
+
value: prevLog
|
|
1755
|
+
}),
|
|
1756
|
+
info: _assign({}, props, {
|
|
1757
|
+
value: prevInfo
|
|
1758
|
+
}),
|
|
1759
|
+
warn: _assign({}, props, {
|
|
1760
|
+
value: prevWarn
|
|
1761
|
+
}),
|
|
1762
|
+
error: _assign({}, props, {
|
|
1763
|
+
value: prevError
|
|
1764
|
+
}),
|
|
1765
|
+
group: _assign({}, props, {
|
|
1766
|
+
value: prevGroup
|
|
1767
|
+
}),
|
|
1768
|
+
groupCollapsed: _assign({}, props, {
|
|
1769
|
+
value: prevGroupCollapsed
|
|
1770
|
+
}),
|
|
1771
|
+
groupEnd: _assign({}, props, {
|
|
1772
|
+
value: prevGroupEnd
|
|
1773
|
+
})
|
|
1774
|
+
});
|
|
1775
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
if (disabledDepth < 0) {
|
|
1779
|
+
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
|
|
1785
|
+
var prefix;
|
|
1786
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
1787
|
+
{
|
|
1788
|
+
if (prefix === undefined) {
|
|
1789
|
+
// Extract the VM specific prefix used by each line.
|
|
1790
|
+
try {
|
|
1791
|
+
throw Error();
|
|
1792
|
+
} catch (x) {
|
|
1793
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
1794
|
+
prefix = match && match[1] || '';
|
|
1795
|
+
}
|
|
1796
|
+
} // We use the prefix to ensure our stacks line up with native stack frames.
|
|
1797
|
+
|
|
1798
|
+
|
|
1799
|
+
return '\n' + prefix + name;
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
var reentry = false;
|
|
1803
|
+
var componentFrameCache;
|
|
1804
|
+
|
|
1805
|
+
{
|
|
1806
|
+
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
1807
|
+
componentFrameCache = new PossiblyWeakMap();
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
function describeNativeComponentFrame(fn, construct) {
|
|
1811
|
+
// If something asked for a stack inside a fake render, it should get ignored.
|
|
1812
|
+
if (!fn || reentry) {
|
|
1813
|
+
return '';
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
{
|
|
1817
|
+
var frame = componentFrameCache.get(fn);
|
|
1818
|
+
|
|
1819
|
+
if (frame !== undefined) {
|
|
1820
|
+
return frame;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
var control;
|
|
1825
|
+
reentry = true;
|
|
1826
|
+
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
1827
|
+
|
|
1828
|
+
Error.prepareStackTrace = undefined;
|
|
1829
|
+
var previousDispatcher;
|
|
1830
|
+
|
|
1831
|
+
{
|
|
1832
|
+
previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function
|
|
1833
|
+
// for warnings.
|
|
1834
|
+
|
|
1835
|
+
ReactCurrentDispatcher$1.current = null;
|
|
1836
|
+
disableLogs();
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
try {
|
|
1840
|
+
// This should throw.
|
|
1841
|
+
if (construct) {
|
|
1842
|
+
// Something should be setting the props in the constructor.
|
|
1843
|
+
var Fake = function () {
|
|
1844
|
+
throw Error();
|
|
1845
|
+
}; // $FlowFixMe
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
Object.defineProperty(Fake.prototype, 'props', {
|
|
1849
|
+
set: function () {
|
|
1850
|
+
// We use a throwing setter instead of frozen or non-writable props
|
|
1851
|
+
// because that won't throw in a non-strict mode function.
|
|
1852
|
+
throw Error();
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
|
|
1856
|
+
if (typeof Reflect === 'object' && Reflect.construct) {
|
|
1857
|
+
// We construct a different control for this case to include any extra
|
|
1858
|
+
// frames added by the construct call.
|
|
1859
|
+
try {
|
|
1860
|
+
Reflect.construct(Fake, []);
|
|
1861
|
+
} catch (x) {
|
|
1862
|
+
control = x;
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
Reflect.construct(fn, [], Fake);
|
|
1866
|
+
} else {
|
|
1867
|
+
try {
|
|
1868
|
+
Fake.call();
|
|
1869
|
+
} catch (x) {
|
|
1870
|
+
control = x;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
fn.call(Fake.prototype);
|
|
1874
|
+
}
|
|
1875
|
+
} else {
|
|
1876
|
+
try {
|
|
1877
|
+
throw Error();
|
|
1878
|
+
} catch (x) {
|
|
1879
|
+
control = x;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
fn();
|
|
1883
|
+
}
|
|
1884
|
+
} catch (sample) {
|
|
1885
|
+
// This is inlined manually because closure doesn't do it for us.
|
|
1886
|
+
if (sample && control && typeof sample.stack === 'string') {
|
|
1887
|
+
// This extracts the first frame from the sample that isn't also in the control.
|
|
1888
|
+
// Skipping one frame that we assume is the frame that calls the two.
|
|
1889
|
+
var sampleLines = sample.stack.split('\n');
|
|
1890
|
+
var controlLines = control.stack.split('\n');
|
|
1891
|
+
var s = sampleLines.length - 1;
|
|
1892
|
+
var c = controlLines.length - 1;
|
|
1893
|
+
|
|
1894
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
1895
|
+
// We expect at least one stack frame to be shared.
|
|
1896
|
+
// Typically this will be the root most one. However, stack frames may be
|
|
1897
|
+
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
1898
|
+
// earlier than the other. We assume that the sample is longer or the same
|
|
1899
|
+
// and there for cut off earlier. So we should find the root most frame in
|
|
1900
|
+
// the sample somewhere in the control.
|
|
1901
|
+
c--;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
for (; s >= 1 && c >= 0; s--, c--) {
|
|
1905
|
+
// Next we find the first one that isn't the same which should be the
|
|
1906
|
+
// frame that called our sample function and the control.
|
|
1907
|
+
if (sampleLines[s] !== controlLines[c]) {
|
|
1908
|
+
// In V8, the first line is describing the message but other VMs don't.
|
|
1909
|
+
// If we're about to return the first line, and the control is also on the same
|
|
1910
|
+
// line, that's a pretty good indicator that our sample threw at same line as
|
|
1911
|
+
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
|
1912
|
+
// This can happen if you passed a class to function component, or non-function.
|
|
1913
|
+
if (s !== 1 || c !== 1) {
|
|
1914
|
+
do {
|
|
1915
|
+
s--;
|
|
1916
|
+
c--; // We may still have similar intermediate frames from the construct call.
|
|
1917
|
+
// The next one that isn't the same should be our match though.
|
|
1918
|
+
|
|
1919
|
+
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
1920
|
+
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
1921
|
+
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
|
|
1922
|
+
|
|
1923
|
+
{
|
|
1924
|
+
if (typeof fn === 'function') {
|
|
1925
|
+
componentFrameCache.set(fn, _frame);
|
|
1926
|
+
}
|
|
1927
|
+
} // Return the line we found.
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
return _frame;
|
|
1931
|
+
}
|
|
1932
|
+
} while (s >= 1 && c >= 0);
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
break;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
} finally {
|
|
1940
|
+
reentry = false;
|
|
1941
|
+
|
|
1942
|
+
{
|
|
1943
|
+
ReactCurrentDispatcher$1.current = previousDispatcher;
|
|
1944
|
+
reenableLogs();
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
1948
|
+
} // Fallback to just using the name if we couldn't make it throw.
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
var name = fn ? fn.displayName || fn.name : '';
|
|
1952
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
|
1953
|
+
|
|
1954
|
+
{
|
|
1955
|
+
if (typeof fn === 'function') {
|
|
1956
|
+
componentFrameCache.set(fn, syntheticFrame);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
return syntheticFrame;
|
|
1961
|
+
}
|
|
1962
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
1963
|
+
{
|
|
1964
|
+
return describeNativeComponentFrame(fn, false);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
function shouldConstruct(Component) {
|
|
1969
|
+
var prototype = Component.prototype;
|
|
1970
|
+
return !!(prototype && prototype.isReactComponent);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
1974
|
+
|
|
1975
|
+
if (type == null) {
|
|
1976
|
+
return '';
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
if (typeof type === 'function') {
|
|
1980
|
+
{
|
|
1981
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
if (typeof type === 'string') {
|
|
1986
|
+
return describeBuiltInComponentFrame(type);
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
switch (type) {
|
|
1990
|
+
case exports.Suspense:
|
|
1991
|
+
return describeBuiltInComponentFrame('Suspense');
|
|
1992
|
+
|
|
1993
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
1994
|
+
return describeBuiltInComponentFrame('SuspenseList');
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
if (typeof type === 'object') {
|
|
1998
|
+
switch (type.$$typeof) {
|
|
1999
|
+
case REACT_FORWARD_REF_TYPE:
|
|
2000
|
+
return describeFunctionComponentFrame(type.render);
|
|
2001
|
+
|
|
2002
|
+
case REACT_MEMO_TYPE:
|
|
2003
|
+
// Memo may contain any component type so we recursively resolve it.
|
|
2004
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
2005
|
+
|
|
2006
|
+
case REACT_BLOCK_TYPE:
|
|
2007
|
+
return describeFunctionComponentFrame(type._render);
|
|
2008
|
+
|
|
2009
|
+
case REACT_LAZY_TYPE:
|
|
2010
|
+
{
|
|
2011
|
+
var lazyComponent = type;
|
|
2012
|
+
var payload = lazyComponent._payload;
|
|
2013
|
+
var init = lazyComponent._init;
|
|
2014
|
+
|
|
2015
|
+
try {
|
|
2016
|
+
// Lazy may contain any component type so we recursively resolve it.
|
|
2017
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
2018
|
+
} catch (x) {}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
return '';
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
var loggedTypeFailures = {};
|
|
2027
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
2028
|
+
|
|
2029
|
+
function setCurrentlyValidatingElement(element) {
|
|
2030
|
+
{
|
|
2031
|
+
if (element) {
|
|
2032
|
+
var owner = element._owner;
|
|
2033
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
2034
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
2035
|
+
} else {
|
|
2036
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
2042
|
+
{
|
|
2043
|
+
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
2044
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
2045
|
+
|
|
2046
|
+
for (var typeSpecName in typeSpecs) {
|
|
2047
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
2048
|
+
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
2049
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
2050
|
+
// After these have been cleaned up, we'll let them throw.
|
|
2051
|
+
|
|
2052
|
+
try {
|
|
2053
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
2054
|
+
// behavior as without this statement except with a better message.
|
|
2055
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
2056
|
+
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`.');
|
|
2057
|
+
err.name = 'Invariant Violation';
|
|
2058
|
+
throw err;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
2062
|
+
} catch (ex) {
|
|
2063
|
+
error$1 = ex;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
2067
|
+
setCurrentlyValidatingElement(element);
|
|
2068
|
+
|
|
2069
|
+
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
2070
|
+
|
|
2071
|
+
setCurrentlyValidatingElement(null);
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
2075
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
2076
|
+
// same error.
|
|
2077
|
+
loggedTypeFailures[error$1.message] = true;
|
|
2078
|
+
setCurrentlyValidatingElement(element);
|
|
2079
|
+
|
|
2080
|
+
error('Failed %s type: %s', location, error$1.message);
|
|
2081
|
+
|
|
2082
|
+
setCurrentlyValidatingElement(null);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
2090
|
+
{
|
|
2091
|
+
if (element) {
|
|
2092
|
+
var owner = element._owner;
|
|
2093
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
2094
|
+
setExtraStackFrame(stack);
|
|
2095
|
+
} else {
|
|
2096
|
+
setExtraStackFrame(null);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
var propTypesMisspellWarningShown;
|
|
2102
|
+
|
|
2103
|
+
{
|
|
2104
|
+
propTypesMisspellWarningShown = false;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
function getDeclarationErrorAddendum() {
|
|
2108
|
+
if (ReactCurrentOwner.current) {
|
|
2109
|
+
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
2110
|
+
|
|
2111
|
+
if (name) {
|
|
2112
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
return '';
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
function getSourceInfoErrorAddendum(source) {
|
|
2120
|
+
if (source !== undefined) {
|
|
2121
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
2122
|
+
var lineNumber = source.lineNumber;
|
|
2123
|
+
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
return '';
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
function getSourceInfoErrorAddendumForProps(elementProps) {
|
|
2130
|
+
if (elementProps !== null && elementProps !== undefined) {
|
|
2131
|
+
return getSourceInfoErrorAddendum(elementProps.__source);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
return '';
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
2138
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
2139
|
+
* updates.
|
|
2140
|
+
*/
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
var ownerHasKeyUseWarning = {};
|
|
2144
|
+
|
|
2145
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
2146
|
+
var info = getDeclarationErrorAddendum();
|
|
2147
|
+
|
|
2148
|
+
if (!info) {
|
|
2149
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
2150
|
+
|
|
2151
|
+
if (parentName) {
|
|
2152
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
return info;
|
|
2157
|
+
}
|
|
2158
|
+
/**
|
|
2159
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
2160
|
+
* This element is in an array. The array could grow and shrink or be
|
|
2161
|
+
* reordered. All children that haven't already been validated are required to
|
|
2162
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
2163
|
+
* will only be shown once.
|
|
2164
|
+
*
|
|
2165
|
+
* @internal
|
|
2166
|
+
* @param {ReactElement} element Element that requires a key.
|
|
2167
|
+
* @param {*} parentType element's parent's type.
|
|
2168
|
+
*/
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
function validateExplicitKey(element, parentType) {
|
|
2172
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
2173
|
+
return;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
element._store.validated = true;
|
|
2177
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
2178
|
+
|
|
2179
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
2184
|
+
// property, it may be the creator of the child that's responsible for
|
|
2185
|
+
// assigning it a key.
|
|
2186
|
+
|
|
2187
|
+
var childOwner = '';
|
|
2188
|
+
|
|
2189
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
2190
|
+
// Give the component that originally created this child.
|
|
2191
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
{
|
|
2195
|
+
setCurrentlyValidatingElement$1(element);
|
|
2196
|
+
|
|
2197
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
2198
|
+
|
|
2199
|
+
setCurrentlyValidatingElement$1(null);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Ensure that every element either is passed in a static location, in an
|
|
2204
|
+
* array with an explicit keys property defined, or in an object literal
|
|
2205
|
+
* with valid key property.
|
|
2206
|
+
*
|
|
2207
|
+
* @internal
|
|
2208
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
2209
|
+
* @param {*} parentType node's parent's type.
|
|
2210
|
+
*/
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
function validateChildKeys(node, parentType) {
|
|
2214
|
+
if (typeof node !== 'object') {
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
if (Array.isArray(node)) {
|
|
2219
|
+
for (var i = 0; i < node.length; i++) {
|
|
2220
|
+
var child = node[i];
|
|
2221
|
+
|
|
2222
|
+
if (isValidElement(child)) {
|
|
2223
|
+
validateExplicitKey(child, parentType);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
} else if (isValidElement(node)) {
|
|
2227
|
+
// This element was passed in a valid location.
|
|
2228
|
+
if (node._store) {
|
|
2229
|
+
node._store.validated = true;
|
|
2230
|
+
}
|
|
2231
|
+
} else if (node) {
|
|
2232
|
+
var iteratorFn = getIteratorFn(node);
|
|
2233
|
+
|
|
2234
|
+
if (typeof iteratorFn === 'function') {
|
|
2235
|
+
// Entry iterators used to provide implicit keys,
|
|
2236
|
+
// but now we print a separate warning for them later.
|
|
2237
|
+
if (iteratorFn !== node.entries) {
|
|
2238
|
+
var iterator = iteratorFn.call(node);
|
|
2239
|
+
var step;
|
|
2240
|
+
|
|
2241
|
+
while (!(step = iterator.next()).done) {
|
|
2242
|
+
if (isValidElement(step.value)) {
|
|
2243
|
+
validateExplicitKey(step.value, parentType);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
2252
|
+
* provided by the type.
|
|
2253
|
+
*
|
|
2254
|
+
* @param {ReactElement} element
|
|
2255
|
+
*/
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
function validatePropTypes(element) {
|
|
2259
|
+
{
|
|
2260
|
+
var type = element.type;
|
|
2261
|
+
|
|
2262
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
var propTypes;
|
|
2267
|
+
|
|
2268
|
+
if (typeof type === 'function') {
|
|
2269
|
+
propTypes = type.propTypes;
|
|
2270
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
2271
|
+
// Inner props are checked in the reconciler.
|
|
2272
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
2273
|
+
propTypes = type.propTypes;
|
|
2274
|
+
} else {
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
if (propTypes) {
|
|
2279
|
+
// Intentionally inside to avoid triggering lazy initializers:
|
|
2280
|
+
var name = getComponentName(type);
|
|
2281
|
+
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
2282
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
2283
|
+
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
2284
|
+
|
|
2285
|
+
var _name = getComponentName(type);
|
|
2286
|
+
|
|
2287
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
2291
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
2297
|
+
* @param {ReactElement} fragment
|
|
2298
|
+
*/
|
|
2299
|
+
|
|
2300
|
+
|
|
2301
|
+
function validateFragmentProps(fragment) {
|
|
2302
|
+
{
|
|
2303
|
+
var keys = Object.keys(fragment.props);
|
|
2304
|
+
|
|
2305
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2306
|
+
var key = keys[i];
|
|
2307
|
+
|
|
2308
|
+
if (key !== 'children' && key !== 'key') {
|
|
2309
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
2310
|
+
|
|
2311
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
2312
|
+
|
|
2313
|
+
setCurrentlyValidatingElement$1(null);
|
|
2314
|
+
break;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
if (fragment.ref !== null) {
|
|
2319
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
2320
|
+
|
|
2321
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
2322
|
+
|
|
2323
|
+
setCurrentlyValidatingElement$1(null);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
function createElementWithValidation(type, props, children) {
|
|
2328
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
2329
|
+
// succeed and there will likely be errors in render.
|
|
2330
|
+
|
|
2331
|
+
if (!validType) {
|
|
2332
|
+
var info = '';
|
|
2333
|
+
|
|
2334
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
2335
|
+
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
|
|
2339
|
+
|
|
2340
|
+
if (sourceInfo) {
|
|
2341
|
+
info += sourceInfo;
|
|
2342
|
+
} else {
|
|
2343
|
+
info += getDeclarationErrorAddendum();
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
var typeString;
|
|
2347
|
+
|
|
2348
|
+
if (type === null) {
|
|
2349
|
+
typeString = 'null';
|
|
2350
|
+
} else if (Array.isArray(type)) {
|
|
2351
|
+
typeString = 'array';
|
|
2352
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
2353
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
2354
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
2355
|
+
} else {
|
|
2356
|
+
typeString = typeof type;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
{
|
|
2360
|
+
error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
|
|
2365
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
2366
|
+
|
|
2367
|
+
if (element == null) {
|
|
2368
|
+
return element;
|
|
2369
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
2370
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
2371
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
2372
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
2373
|
+
// fixed, the key warnings will appear.)
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
if (validType) {
|
|
2377
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
2378
|
+
validateChildKeys(arguments[i], type);
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
if (type === exports.Fragment) {
|
|
2383
|
+
validateFragmentProps(element);
|
|
2384
|
+
} else {
|
|
2385
|
+
validatePropTypes(element);
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
return element;
|
|
2389
|
+
}
|
|
2390
|
+
var didWarnAboutDeprecatedCreateFactory = false;
|
|
2391
|
+
function createFactoryWithValidation(type) {
|
|
2392
|
+
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
2393
|
+
validatedFactory.type = type;
|
|
2394
|
+
|
|
2395
|
+
{
|
|
2396
|
+
if (!didWarnAboutDeprecatedCreateFactory) {
|
|
2397
|
+
didWarnAboutDeprecatedCreateFactory = true;
|
|
2398
|
+
|
|
2399
|
+
warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
|
|
2400
|
+
} // Legacy hook: remove it
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
Object.defineProperty(validatedFactory, 'type', {
|
|
2404
|
+
enumerable: false,
|
|
2405
|
+
get: function () {
|
|
2406
|
+
warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
|
|
2407
|
+
|
|
2408
|
+
Object.defineProperty(this, 'type', {
|
|
2409
|
+
value: type
|
|
2410
|
+
});
|
|
2411
|
+
return type;
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
return validatedFactory;
|
|
2417
|
+
}
|
|
2418
|
+
function cloneElementWithValidation(element, props, children) {
|
|
2419
|
+
var newElement = cloneElement.apply(this, arguments);
|
|
2420
|
+
|
|
2421
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
2422
|
+
validateChildKeys(arguments[i], newElement.type);
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
validatePropTypes(newElement);
|
|
2426
|
+
return newElement;
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
{
|
|
2430
|
+
|
|
2431
|
+
try {
|
|
2432
|
+
var frozenObject = Object.freeze({});
|
|
2433
|
+
/* eslint-disable no-new */
|
|
2434
|
+
|
|
2435
|
+
new Map([[frozenObject, null]]);
|
|
2436
|
+
new Set([frozenObject]);
|
|
2437
|
+
/* eslint-enable no-new */
|
|
2438
|
+
} catch (e) {
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
var createElement$1 = createElementWithValidation ;
|
|
2443
|
+
var cloneElement$1 = cloneElementWithValidation ;
|
|
2444
|
+
var createFactory = createFactoryWithValidation ;
|
|
2445
|
+
var Children = {
|
|
2446
|
+
map: mapChildren,
|
|
2447
|
+
forEach: forEachChildren,
|
|
2448
|
+
count: countChildren,
|
|
2449
|
+
toArray: toArray,
|
|
2450
|
+
only: onlyChild
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
exports.Children = Children;
|
|
2454
|
+
exports.Component = Component;
|
|
2455
|
+
exports.PureComponent = PureComponent;
|
|
2456
|
+
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
|
|
2457
|
+
exports.cloneElement = cloneElement$1;
|
|
2458
|
+
exports.createContext = createContext;
|
|
2459
|
+
exports.createElement = createElement$1;
|
|
2460
|
+
exports.createFactory = createFactory;
|
|
2461
|
+
exports.createRef = createRef;
|
|
2462
|
+
exports.forwardRef = forwardRef;
|
|
2463
|
+
exports.isValidElement = isValidElement;
|
|
2464
|
+
exports.lazy = lazy;
|
|
2465
|
+
exports.memo = memo;
|
|
2466
|
+
exports.useCallback = useCallback;
|
|
2467
|
+
exports.useContext = useContext;
|
|
2468
|
+
exports.useDebugValue = useDebugValue;
|
|
2469
|
+
exports.useEffect = useEffect;
|
|
2470
|
+
exports.useImperativeHandle = useImperativeHandle;
|
|
2471
|
+
exports.useLayoutEffect = useLayoutEffect;
|
|
2472
|
+
exports.useMemo = useMemo;
|
|
2473
|
+
exports.useReducer = useReducer;
|
|
2474
|
+
exports.useRef = useRef;
|
|
2475
|
+
exports.useState = useState;
|
|
2476
|
+
exports.version = ReactVersion;
|
|
2477
|
+
})();
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
react_development.Fragment;
|
|
2481
|
+
react_development.StrictMode;
|
|
2482
|
+
react_development.Profiler;
|
|
2483
|
+
react_development.Suspense;
|
|
2484
|
+
react_development.Children;
|
|
2485
|
+
react_development.Component;
|
|
2486
|
+
react_development.PureComponent;
|
|
2487
|
+
react_development.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
2488
|
+
react_development.cloneElement;
|
|
2489
|
+
react_development.createContext;
|
|
2490
|
+
react_development.createElement;
|
|
2491
|
+
react_development.createFactory;
|
|
2492
|
+
react_development.createRef;
|
|
2493
|
+
react_development.forwardRef;
|
|
2494
|
+
react_development.isValidElement;
|
|
2495
|
+
react_development.lazy;
|
|
2496
|
+
react_development.memo;
|
|
2497
|
+
react_development.useCallback;
|
|
2498
|
+
react_development.useContext;
|
|
2499
|
+
react_development.useDebugValue;
|
|
2500
|
+
react_development.useEffect;
|
|
2501
|
+
react_development.useImperativeHandle;
|
|
2502
|
+
react_development.useLayoutEffect;
|
|
2503
|
+
react_development.useMemo;
|
|
2504
|
+
react_development.useReducer;
|
|
2505
|
+
react_development.useRef;
|
|
2506
|
+
react_development.useState;
|
|
2507
|
+
react_development.version;
|
|
2508
|
+
|
|
2509
|
+
createCommonjsModule(function (module) {
|
|
2510
|
+
|
|
2511
|
+
if (process.env.NODE_ENV === 'production') {
|
|
2512
|
+
module.exports = react_production_min;
|
|
2513
|
+
} else {
|
|
2514
|
+
module.exports = react_development;
|
|
2515
|
+
}
|
|
2516
|
+
});
|
|
2517
|
+
|
|
2518
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2519
|
+
|
|
2520
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
2521
|
+
|
|
2522
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* 生成fieldkey的正则
|
|
2526
|
+
* 根据a.0.b 返回/a.(\d+|$container).b/正则
|
|
2527
|
+
* @param arr <Array> 需要生成正则的数组
|
|
2528
|
+
* @returns 返回正则
|
|
2529
|
+
*/
|
|
2530
|
+
var generateReg = function generateReg(arr) {
|
|
2531
|
+
var regStr = arr.reduce(function (prev, cur, index, arr) {
|
|
2532
|
+
if (Number.isNaN(parseInt(cur))) {
|
|
2533
|
+
return "".concat(prev).concat(index !== 0 ? '\\.' : '').concat(arr[index].replace(/\$/g, '\\$'));
|
|
2534
|
+
} else {
|
|
2535
|
+
return "".concat(index !== 0 ? "".concat(prev, "\\.") : '', "(").concat(cur, "|\\$container)");
|
|
2536
|
+
}
|
|
2537
|
+
}, '');
|
|
2538
|
+
return new RegExp("^".concat(regStr, "$"), 'ig');
|
|
2539
|
+
};
|
|
2540
|
+
/**
|
|
2541
|
+
* 用于删除、切换数组排序的arraykey
|
|
2542
|
+
* @param arr
|
|
2543
|
+
* @returns
|
|
2544
|
+
*/
|
|
2545
|
+
|
|
2546
|
+
var generateArrayKeyReg = function generateArrayKeyReg(arr) {
|
|
2547
|
+
var regStr = arr.reduce(function (prev, cur, index) {
|
|
2548
|
+
if (index === arr.length - 1) {
|
|
2549
|
+
return "".concat(prev, ")\\.(\\d)+");
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
return "".concat(index !== 0 ? "".concat(prev, "\\.") : '').concat(cur);
|
|
2553
|
+
});
|
|
2554
|
+
return new RegExp("^(".concat(regStr, "(\\..+)+"), 'ig');
|
|
2555
|
+
};
|
|
2556
|
+
/**
|
|
2557
|
+
* 基本数据类型检测
|
|
2558
|
+
* @param {unknown} checkVar 待检测的变量
|
|
2559
|
+
* @returns {string} 基本数据类型:Object | Array | String | Number | Boolean | Null | Undefined
|
|
2560
|
+
*/
|
|
2561
|
+
|
|
2562
|
+
function typeCheck(checkVar) {
|
|
2563
|
+
var typeClass = Object.prototype.toString.call(checkVar);
|
|
2564
|
+
return typeClass.split(' ')[1].split(']')[0];
|
|
2565
|
+
}
|
|
2566
|
+
/**
|
|
2567
|
+
* 判断变量是否为空
|
|
2568
|
+
* @param checkVar
|
|
2569
|
+
*/
|
|
2570
|
+
|
|
2571
|
+
function isEmpty(checkVar) {
|
|
2572
|
+
var empty = false;
|
|
2573
|
+
var varType = typeCheck(checkVar);
|
|
2574
|
+
|
|
2575
|
+
switch (varType) {
|
|
2576
|
+
case 'Number':
|
|
2577
|
+
case 'Boolean':
|
|
2578
|
+
empty = false;
|
|
2579
|
+
break;
|
|
2580
|
+
|
|
2581
|
+
case 'Null':
|
|
2582
|
+
case 'Undefined':
|
|
2583
|
+
empty = true;
|
|
2584
|
+
break;
|
|
2585
|
+
|
|
2586
|
+
case 'Array':
|
|
2587
|
+
case 'String':
|
|
2588
|
+
empty = checkVar.length === 0;
|
|
2589
|
+
break;
|
|
2590
|
+
|
|
2591
|
+
default:
|
|
2592
|
+
{
|
|
2593
|
+
var keys = Object.keys(checkVar);
|
|
2594
|
+
empty = keys.length === 0;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
return empty;
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* 设置data.a.b.c = value
|
|
2602
|
+
* 若data没有a.b 则依次赋值空对象,最后再将a.b.c设为value
|
|
2603
|
+
* @param {string} keys a.b.c
|
|
2604
|
+
* @param {object} data data.a.b.c
|
|
2605
|
+
* @param {unknown} value data.a.b.c = value
|
|
2606
|
+
* @param {object} typeMap 确定a.0.b.1中的0和1的父级应该是对象还是数组形式
|
|
2607
|
+
* @param parentKey
|
|
2608
|
+
*/
|
|
2609
|
+
|
|
2610
|
+
var setDeepProp = function setDeepProp(keys, data, value, typeMap, parentKey) {
|
|
2611
|
+
if (keys.length === 0) {
|
|
2612
|
+
return;
|
|
2613
|
+
} // 取出keys的第一个元素作为当前待填充的key
|
|
2614
|
+
|
|
2615
|
+
|
|
2616
|
+
var curKey = keys.shift(); // data是否有当前key
|
|
2617
|
+
|
|
2618
|
+
if (keys.length > 0) {
|
|
2619
|
+
var hasKey = Object.keys(data).includes(curKey);
|
|
2620
|
+
|
|
2621
|
+
if (!hasKey) {
|
|
2622
|
+
if (typeMap) {
|
|
2623
|
+
var typeKey = Object.keys(typeMap).find(function (item) {
|
|
2624
|
+
return generateReg(parentKey ? parentKey.concat(curKey) : [curKey]).test(item);
|
|
2625
|
+
}); // 根据typeMap判断当前是数组还是对象,兜底逻辑为对象
|
|
2626
|
+
|
|
2627
|
+
if (typeKey) {
|
|
2628
|
+
switch (typeMap[typeKey].type) {
|
|
2629
|
+
case 'array':
|
|
2630
|
+
data[curKey] = [];
|
|
2631
|
+
break;
|
|
2632
|
+
|
|
2633
|
+
case 'object':
|
|
2634
|
+
data[curKey] = {};
|
|
2635
|
+
break;
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
} else {
|
|
2639
|
+
// typeMap未定义当前curKey时,默认认为是对象
|
|
2640
|
+
data[curKey] = {};
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
setDeepProp(keys, data[curKey], value, typeMap, (parentKey || []).concat(curKey));
|
|
2645
|
+
} else {
|
|
2646
|
+
data[curKey] = value;
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
/**
|
|
2650
|
+
* 删除data.a.b.c
|
|
2651
|
+
* 若data没有a.b.c,则不进行任何操作
|
|
2652
|
+
* @param {string} keys [a,b,c]
|
|
2653
|
+
* @param {object} data 需要删除的对象
|
|
2654
|
+
*/
|
|
2655
|
+
|
|
2656
|
+
var deleteDeepProp = function deleteDeepProp(keys, data) {
|
|
2657
|
+
if (keys.length === 0) return; // 当前key
|
|
2658
|
+
|
|
2659
|
+
var curKey = keys.shift(); // data是否有当前key
|
|
2660
|
+
|
|
2661
|
+
var hasKey = Object.keys(data).includes(curKey);
|
|
2662
|
+
|
|
2663
|
+
if (keys.length > 0) {
|
|
2664
|
+
if (!hasKey) {
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
deleteDeepProp(keys, data[curKey]);
|
|
2669
|
+
} else {
|
|
2670
|
+
if (Array.isArray(data) && !Number.isNaN(parseInt(curKey))) {
|
|
2671
|
+
data.splice(parseInt(curKey), 1);
|
|
2672
|
+
} else {
|
|
2673
|
+
delete data[curKey];
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
/**
|
|
2678
|
+
* 判断对象是否有某一属性,如没有,则根据valueType为其创建
|
|
2679
|
+
* 并返回最后一个key的校验生成后的value
|
|
2680
|
+
* @param {Map} source 源对象
|
|
2681
|
+
* @param {'array' | 'object'} valueType 创建的类型
|
|
2682
|
+
* @param {array} keys 对象的key值,支持...以拓展深层对象的创建
|
|
2683
|
+
*/
|
|
2684
|
+
|
|
2685
|
+
var judgeAndRegister = function judgeAndRegister(source, valueType) {
|
|
2686
|
+
var currSource = source;
|
|
2687
|
+
|
|
2688
|
+
for (var _len = arguments.length, keys = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
2689
|
+
keys[_key - 2] = arguments[_key];
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
2693
|
+
var key = _keys[_i];
|
|
2694
|
+
|
|
2695
|
+
if (!Object.hasOwnProperty.call(currSource, key)) {
|
|
2696
|
+
currSource[key] = valueType === 'array' ? [] : {};
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
currSource = currSource[key];
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
return currSource;
|
|
2703
|
+
};
|
|
2704
|
+
/**
|
|
2705
|
+
* 允许循环引用的深拷贝
|
|
2706
|
+
* @param target
|
|
2707
|
+
* @param map
|
|
2708
|
+
*/
|
|
2709
|
+
|
|
2710
|
+
function deepClone(target) {
|
|
2711
|
+
var map = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
|
|
2712
|
+
if (map.get(target) || target === null || target === undefined) return target; // 针对Date和RegExp等特殊引用类型,直接执行构造函数进行克隆
|
|
2713
|
+
|
|
2714
|
+
var constructor = target.constructor;
|
|
2715
|
+
|
|
2716
|
+
if (/^(Date|RegExp)/.test(constructor.name)) {
|
|
2717
|
+
return new constructor(target);
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
if (_typeof(target) === 'object') {
|
|
2721
|
+
// 标记当前target已被处理过,避免递归过程中出现循环引用导致栈溢出的文日
|
|
2722
|
+
map.set(target, true);
|
|
2723
|
+
var res = Array.isArray(target) ? [] : {};
|
|
2724
|
+
|
|
2725
|
+
for (var i in target) {
|
|
2726
|
+
if (Object.hasOwnProperty.call(target, i)) {
|
|
2727
|
+
res[i] = deepClone(target[i], map);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
return res;
|
|
2732
|
+
} else {
|
|
2733
|
+
return target;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* 该方法用于快速向check的shcmea中注入vcontol。方便过滤已经设置的表单
|
|
2738
|
+
* @param obj 待注入vontrol的uiSchema对象
|
|
2739
|
+
*/
|
|
2740
|
+
|
|
2741
|
+
function injectVcontrol(obj) {
|
|
2742
|
+
for (var i in obj) {
|
|
2743
|
+
if (Object.prototype.hasOwnProperty.call(obj, i)) {
|
|
2744
|
+
switch (typeCheck(i)) {
|
|
2745
|
+
case 'Array':
|
|
2746
|
+
// 数组的vcontrol统一设置在顶层
|
|
2747
|
+
break;
|
|
2748
|
+
|
|
2749
|
+
case 'Object':
|
|
2750
|
+
injectVcontrol(obj[i]);
|
|
2751
|
+
break;
|
|
2752
|
+
|
|
2753
|
+
default:
|
|
2754
|
+
{
|
|
2755
|
+
// 只有设置了fieldKey的才需要设置vcontrol和vcontrolDefault
|
|
2756
|
+
var fieldKey = obj.fieldKey;
|
|
2757
|
+
|
|
2758
|
+
if (fieldKey) {
|
|
2759
|
+
setDeepProp(['ui', 'vcontrol'], obj, 'const {fieldKey,formData,get}=props;return formData.viewMode==="configured"?typeof get(fieldKey).data!==\'number\'? get(fieldKey).data:true:true');
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
break;
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* 解析url中?后的参数,返回参数Map
|
|
2770
|
+
* @param url
|
|
2771
|
+
*/
|
|
2772
|
+
|
|
2773
|
+
function parseHrefParam(url) {
|
|
2774
|
+
url = url || window.location.href;
|
|
2775
|
+
var parseUrl = /(.*)\?(.*)/.exec(url);
|
|
2776
|
+
var res = {};
|
|
2777
|
+
|
|
2778
|
+
if (parseUrl && parseUrl[2]) {
|
|
2779
|
+
var paramsList = parseUrl[2].split('&');
|
|
2780
|
+
|
|
2781
|
+
var _iterator = _createForOfIteratorHelper$1(paramsList),
|
|
2782
|
+
_step;
|
|
2783
|
+
|
|
2784
|
+
try {
|
|
2785
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2786
|
+
var str = _step.value;
|
|
2787
|
+
var split = str.split('=');
|
|
2788
|
+
res[split[0]] = split[1] !== undefined ? split[1] : true;
|
|
2789
|
+
}
|
|
2790
|
+
} catch (err) {
|
|
2791
|
+
_iterator.e(err);
|
|
2792
|
+
} finally {
|
|
2793
|
+
_iterator.f();
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
return res;
|
|
2798
|
+
}
|
|
2799
|
+
function randomString(length) {
|
|
2800
|
+
var str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
2801
|
+
var result = '';
|
|
2802
|
+
|
|
2803
|
+
for (var i = length; i > 0; --i) {
|
|
2804
|
+
result += str[Math.floor(Math.random() * str.length)];
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
return result;
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* 将大于等于零的整数number转成中文汉字
|
|
2811
|
+
*/
|
|
2812
|
+
|
|
2813
|
+
var numChar = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
|
|
2814
|
+
var unitChar = ['', '十', '百', '千'];
|
|
2815
|
+
var millionUnitChar = ['', '万', '亿', '万亿', '亿亿']; // 已万为处理段,该方法处理万以内的数字转成中文
|
|
2816
|
+
|
|
2817
|
+
function range2Chinese(range) {
|
|
2818
|
+
var numUnitChar = '';
|
|
2819
|
+
var tempStr = '';
|
|
2820
|
+
var unit = 0;
|
|
2821
|
+
var isNeedZero = true;
|
|
2822
|
+
|
|
2823
|
+
while (range > 0) {
|
|
2824
|
+
var currentNum = range % 10;
|
|
2825
|
+
|
|
2826
|
+
if (currentNum === 0) {
|
|
2827
|
+
if (!isNeedZero) {
|
|
2828
|
+
isNeedZero = true;
|
|
2829
|
+
tempStr = numChar[currentNum] + tempStr;
|
|
2830
|
+
}
|
|
2831
|
+
} else {
|
|
2832
|
+
isNeedZero = false;
|
|
2833
|
+
numUnitChar = numChar[currentNum];
|
|
2834
|
+
numUnitChar += unitChar[unit];
|
|
2835
|
+
tempStr = numUnitChar + tempStr;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
unit++;
|
|
2839
|
+
range = Math.floor(range / 10);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
return tempStr;
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
function number2Chinese(num) {
|
|
2846
|
+
var millionUnit = 0;
|
|
2847
|
+
var tempStr = '';
|
|
2848
|
+
var resStr = '';
|
|
2849
|
+
var isNeedZero = false;
|
|
2850
|
+
|
|
2851
|
+
if (num === 0) {
|
|
2852
|
+
return numChar[0];
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
while (num > 0) {
|
|
2856
|
+
var range = num % 10000;
|
|
2857
|
+
|
|
2858
|
+
if (isNeedZero) {
|
|
2859
|
+
resStr = numChar[0] + resStr;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
tempStr = range2Chinese(range);
|
|
2863
|
+
tempStr += range !== 0 ? millionUnitChar[millionUnit] : millionUnitChar[0];
|
|
2864
|
+
resStr = tempStr + resStr;
|
|
2865
|
+
isNeedZero = range < 1000 && range > 0;
|
|
2866
|
+
num = Math.floor(num / 10000);
|
|
2867
|
+
millionUnit++;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
return resStr;
|
|
2871
|
+
} // TODO 更新Read more文档
|
|
2872
|
+
|
|
2873
|
+
function upgradeTips(oldApiName, newApiName) {
|
|
2874
|
+
console.warn("".concat(oldApiName, ": The current usage is about to discard after the next main version is upgraded, please use ").concat(newApiName, "! "));
|
|
2875
|
+
} // 转换数组
|
|
2876
|
+
|
|
2877
|
+
function toArray(param) {
|
|
2878
|
+
return Array.isArray(param) ? param : [param];
|
|
2879
|
+
} // 处理容器宽度
|
|
2880
|
+
|
|
2881
|
+
var handleMargin = function handleMargin(style) {
|
|
2882
|
+
var margin = style.margin,
|
|
2883
|
+
width = style.width;
|
|
2884
|
+
var marginRight = style.marginRight || '0px';
|
|
2885
|
+
var marginLeft = style.marginLeft || '0px';
|
|
2886
|
+
|
|
2887
|
+
if (width) {
|
|
2888
|
+
if (margin) {
|
|
2889
|
+
if (typeof margin === 'string') {
|
|
2890
|
+
var marginArr = margin.trim().split(' ');
|
|
2891
|
+
|
|
2892
|
+
if (marginArr.length === 1) {
|
|
2893
|
+
marginRight = margin;
|
|
2894
|
+
marginLeft = margin;
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
if (marginArr.length === 2 || marginArr.length === 3) {
|
|
2898
|
+
marginRight = marginArr[1];
|
|
2899
|
+
marginLeft = marginArr[1];
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
if (marginArr.length === 4) {
|
|
2903
|
+
marginRight = marginArr[1];
|
|
2904
|
+
marginLeft = marginArr[3];
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
marginRight = marginRight === '0' ? '0px' : marginRight;
|
|
2910
|
+
marginLeft = marginLeft === '0' ? '0px' : marginLeft;
|
|
2911
|
+
style.width = "calc(".concat(style.width, " - ").concat(marginRight, " - ").concat(marginLeft, ")");
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
/**
|
|
2915
|
+
* 根据uiSchema,获取当前schem相对的主题和组件类型
|
|
2916
|
+
* @param uiSchema
|
|
2917
|
+
* @returns
|
|
2918
|
+
*/
|
|
2919
|
+
|
|
2920
|
+
var getThemeAndType = function getThemeAndType(uiSchema) {
|
|
2921
|
+
var type = uiSchema.type,
|
|
2922
|
+
theme = uiSchema.theme;
|
|
2923
|
+
|
|
2924
|
+
var _type$split = type.split('::'),
|
|
2925
|
+
_type$split2 = _slicedToArray(_type$split, 2),
|
|
2926
|
+
newType = _type$split2[1]; // v0未区分容器和组件概念,需要做判断
|
|
2927
|
+
|
|
2928
|
+
|
|
2929
|
+
if (['root', 'object', 'array'].includes(newType || type)) {
|
|
2930
|
+
return newType || type;
|
|
2931
|
+
} else {
|
|
2932
|
+
return newType ? type : "".concat(theme, "::").concat(type);
|
|
2933
|
+
}
|
|
2934
|
+
};
|
|
2935
|
+
function isValidHttpUrl(string) {
|
|
2936
|
+
var url;
|
|
2937
|
+
|
|
2938
|
+
try {
|
|
2939
|
+
url = new URL(string);
|
|
2940
|
+
} catch (_) {
|
|
2941
|
+
return false;
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
2945
|
+
}
|
|
2946
|
+
function removeSpaceAndmakeStringCamelCase(string) {
|
|
2947
|
+
var regex = /\s+(\w)?/gi;
|
|
2948
|
+
var output = string.toLowerCase().replace(regex, function (match, letter) {
|
|
2949
|
+
return letter ? letter.toUpperCase() : '';
|
|
2950
|
+
});
|
|
2951
|
+
return output;
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
/**
|
|
2955
|
+
* 将二进制流数据转成base64格式的数据
|
|
2956
|
+
*
|
|
2957
|
+
* @param file
|
|
2958
|
+
*/
|
|
2959
|
+
function binaryData2Blob(file) {
|
|
2960
|
+
return new Promise(function (resolve, reject) {
|
|
2961
|
+
var reader = new FileReader();
|
|
2962
|
+
reader.readAsDataURL(file);
|
|
2963
|
+
|
|
2964
|
+
reader.onload = function () {
|
|
2965
|
+
resolve(this.result);
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
reader.onerror = function (err) {
|
|
2969
|
+
reject(err);
|
|
2970
|
+
};
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* 将base64g格式的图片地址转成img图片对象
|
|
2975
|
+
*
|
|
2976
|
+
* @param {string} imgBase64Url
|
|
2977
|
+
*/
|
|
2978
|
+
|
|
2979
|
+
function getImgEl(imgBase64Url) {
|
|
2980
|
+
return new Promise(function (resolve, reject) {
|
|
2981
|
+
var img = new Image();
|
|
2982
|
+
|
|
2983
|
+
img.onload = function () {
|
|
2984
|
+
resolve(img);
|
|
2985
|
+
};
|
|
2986
|
+
|
|
2987
|
+
img.onerror = function (err) {
|
|
2988
|
+
reject(err);
|
|
2989
|
+
};
|
|
2990
|
+
|
|
2991
|
+
img.src = imgBase64Url;
|
|
2992
|
+
});
|
|
2993
|
+
} // 尺寸限制
|
|
2994
|
+
|
|
2995
|
+
var isValidFileUploaded = function isValidFileUploaded(file) {
|
|
2996
|
+
var accept = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2997
|
+
|
|
2998
|
+
if (accept) {
|
|
2999
|
+
var validExtensions = accept.split(',');
|
|
3000
|
+
var fileExtension = file.type.split('/')[1];
|
|
3001
|
+
var fileName = file.name.split('.');
|
|
3002
|
+
var fileNameExtension = '';
|
|
3003
|
+
|
|
3004
|
+
if (fileName.length) {
|
|
3005
|
+
fileNameExtension = fileName[fileName.length - 1];
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
return validExtensions.includes(".".concat(fileExtension)) || validExtensions.includes(".".concat(fileNameExtension));
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
return true;
|
|
3012
|
+
};
|
|
3013
|
+
|
|
3014
|
+
function checkImg(_x) {
|
|
3015
|
+
return _checkImg.apply(this, arguments);
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
function _checkImg() {
|
|
3019
|
+
_checkImg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
3020
|
+
var file, dimension, size, accept, errMsg, isOk, errors, _ref2, width, height, minWidth, minHeight, maxWidth, maxHeight, widthDivisor, heightDivisor, widthHeightEqual, _ref3, max, min, imgBase64Url, _yield$getImgEl, naturalHeight, naturalWidth, count, _size, message;
|
|
3021
|
+
|
|
3022
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3023
|
+
while (1) {
|
|
3024
|
+
switch (_context.prev = _context.next) {
|
|
3025
|
+
case 0:
|
|
3026
|
+
file = _ref.file, dimension = _ref.dimension, size = _ref.size, accept = _ref.accept, errMsg = _ref.errMsg;
|
|
3027
|
+
isOk = true;
|
|
3028
|
+
errors = [];
|
|
3029
|
+
_ref2 = dimension || {}, width = _ref2.width, height = _ref2.height, minWidth = _ref2.minWidth, minHeight = _ref2.minHeight, maxWidth = _ref2.maxWidth, maxHeight = _ref2.maxHeight, widthDivisor = _ref2.widthDivisor, heightDivisor = _ref2.heightDivisor, widthHeightEqual = _ref2.widthHeightEqual;
|
|
3030
|
+
_ref3 = size || {}, max = _ref3.max, min = _ref3.min; // 尺寸校验
|
|
3031
|
+
|
|
3032
|
+
_context.prev = 5;
|
|
3033
|
+
_context.next = 8;
|
|
3034
|
+
return binaryData2Blob(file);
|
|
3035
|
+
|
|
3036
|
+
case 8:
|
|
3037
|
+
imgBase64Url = _context.sent;
|
|
3038
|
+
|
|
3039
|
+
if (!imgBase64Url) {
|
|
3040
|
+
_context.next = 35;
|
|
3041
|
+
break;
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
_context.next = 12;
|
|
3045
|
+
return getImgEl(imgBase64Url);
|
|
3046
|
+
|
|
3047
|
+
case 12:
|
|
3048
|
+
_yield$getImgEl = _context.sent;
|
|
3049
|
+
naturalHeight = _yield$getImgEl.naturalHeight;
|
|
3050
|
+
naturalWidth = _yield$getImgEl.naturalWidth;
|
|
3051
|
+
count = 0;
|
|
3052
|
+
width && count++;
|
|
3053
|
+
minWidth && count++;
|
|
3054
|
+
maxWidth && count++;
|
|
3055
|
+
widthDivisor && count++;
|
|
3056
|
+
height && count++;
|
|
3057
|
+
minHeight && count++;
|
|
3058
|
+
maxHeight && count++;
|
|
3059
|
+
heightDivisor && count++;
|
|
3060
|
+
widthHeightEqual && count++;
|
|
3061
|
+
if (width && width === naturalWidth) count--;
|
|
3062
|
+
if (minWidth && minWidth <= naturalWidth) count--;
|
|
3063
|
+
if (maxWidth && maxWidth >= naturalWidth) count--;
|
|
3064
|
+
if (widthDivisor && naturalWidth % widthDivisor === 0) count--;
|
|
3065
|
+
if (height && height === naturalHeight) count--;
|
|
3066
|
+
if (minHeight && minHeight <= naturalHeight) count--;
|
|
3067
|
+
if (maxHeight && maxHeight >= naturalHeight) count--;
|
|
3068
|
+
if (heightDivisor && naturalHeight % heightDivisor === 0) count--;
|
|
3069
|
+
if (widthHeightEqual === true && naturalHeight === naturalWidth) count--;
|
|
3070
|
+
|
|
3071
|
+
if (count !== 0) {
|
|
3072
|
+
errors.push((errMsg === null || errMsg === void 0 ? void 0 : errMsg.dimension) || '图片尺寸校验未通过');
|
|
3073
|
+
isOk = false;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
case 35:
|
|
3077
|
+
_context.next = 40;
|
|
3078
|
+
break;
|
|
3079
|
+
|
|
3080
|
+
case 37:
|
|
3081
|
+
_context.prev = 37;
|
|
3082
|
+
_context.t0 = _context["catch"](5);
|
|
3083
|
+
console.error(_context.t0);
|
|
3084
|
+
|
|
3085
|
+
case 40:
|
|
3086
|
+
// 大小校验
|
|
3087
|
+
if (min && min >= file.size) {
|
|
3088
|
+
errors.push((errMsg === null || errMsg === void 0 ? void 0 : errMsg.size) || '图片大小校验未通过');
|
|
3089
|
+
isOk = false;
|
|
3090
|
+
} else if (max && max * 1024 <= file.size) {
|
|
3091
|
+
_size = file.size;
|
|
3092
|
+
message = '';
|
|
3093
|
+
|
|
3094
|
+
if (max > 1024) {
|
|
3095
|
+
_size = max / 1024;
|
|
3096
|
+
message = "".concat(_size.toFixed(1), " mb");
|
|
3097
|
+
} else {
|
|
3098
|
+
message = "".concat(max, " kb");
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
errors.push((errMsg === null || errMsg === void 0 ? void 0 : errMsg.size) || "File size exceeds limit, the file must be smaller than ".concat(message));
|
|
3102
|
+
isOk = false;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
if (!isValidFileUploaded(file, accept || '')) {
|
|
3106
|
+
errors.push((errMsg === null || errMsg === void 0 ? void 0 : errMsg.type) || 'File type is not supported');
|
|
3107
|
+
isOk = false;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
return _context.abrupt("return", {
|
|
3111
|
+
isOk: isOk,
|
|
3112
|
+
errors: errors
|
|
3113
|
+
});
|
|
3114
|
+
|
|
3115
|
+
case 43:
|
|
3116
|
+
case "end":
|
|
3117
|
+
return _context.stop();
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
}, _callee, null, [[5, 37]]);
|
|
3121
|
+
}));
|
|
3122
|
+
return _checkImg.apply(this, arguments);
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
/**
|
|
3126
|
+
* 递归解析
|
|
3127
|
+
*/
|
|
3128
|
+
function initParse(_ref) {
|
|
3129
|
+
var unitedSchema = _ref.unitedSchema,
|
|
3130
|
+
parentType = _ref.parentType,
|
|
3131
|
+
idx = _ref.idx,
|
|
3132
|
+
parentUiSchema = _ref.parentUiSchema,
|
|
3133
|
+
parentDataSchema = _ref.parentDataSchema,
|
|
3134
|
+
customProps = _ref.customProps,
|
|
3135
|
+
typePath = _ref.typePath,
|
|
3136
|
+
_ref$parentTypePath = _ref.parentTypePath,
|
|
3137
|
+
parentTypePath = _ref$parentTypePath === void 0 ? '' : _ref$parentTypePath,
|
|
3138
|
+
index = _ref.index;
|
|
3139
|
+
// 当前uiSchema
|
|
3140
|
+
var curUiSchema = parentUiSchema; // 当前dataSchema
|
|
3141
|
+
|
|
3142
|
+
var curDataSchema = parentDataSchema; // 当前的typePath的key
|
|
3143
|
+
|
|
3144
|
+
var curTypePath = parentTypePath; // 非第一次调用initParse
|
|
3145
|
+
|
|
3146
|
+
if (idx) {
|
|
3147
|
+
var _typePath$parentTypeP, _typePath$parentTypeP2;
|
|
3148
|
+
|
|
3149
|
+
// 设置typePath
|
|
3150
|
+
curTypePath = parentTypePath ? "".concat(parentTypePath, ".").concat(idx) : idx;
|
|
3151
|
+
typePath[curTypePath] = {
|
|
3152
|
+
fatherKey: parentTypePath,
|
|
3153
|
+
title: unitedSchema.title || '',
|
|
3154
|
+
type: unitedSchema.type,
|
|
3155
|
+
unitedSchemaKey: "".concat((_typePath$parentTypeP = typePath[parentTypePath]) !== null && _typePath$parentTypeP !== void 0 && _typePath$parentTypeP.unitedSchemaKey ? "".concat((_typePath$parentTypeP2 = typePath[parentTypePath]) === null || _typePath$parentTypeP2 === void 0 ? void 0 : _typePath$parentTypeP2.unitedSchemaKey, ".") : '').concat(parentType == 'object' ? 'schema' : 'items').concat(index !== '$container' ? ".".concat(index) : '')
|
|
3156
|
+
};
|
|
3157
|
+
} else {
|
|
3158
|
+
// 设置根元素的typePath
|
|
3159
|
+
if (unitedSchema.fieldKey) {
|
|
3160
|
+
typePath[unitedSchema.fieldKey] = {
|
|
3161
|
+
type: unitedSchema.type,
|
|
3162
|
+
unitedSchemaKey: '',
|
|
3163
|
+
fatherKey: ''
|
|
3164
|
+
};
|
|
3165
|
+
} // 根元素type默认为object
|
|
3166
|
+
|
|
3167
|
+
|
|
3168
|
+
curDataSchema.type = 'object';
|
|
3169
|
+
} // ui:开头的
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
var uiReg = /^ui:/; // 是否是uiSchema中的属性
|
|
3173
|
+
|
|
3174
|
+
var isUiProp = function isUiProp(key) {
|
|
3175
|
+
// 需要丢到uiSchema中的属性
|
|
3176
|
+
var uiSchemaKeys = ['footer', 'theme', 'containerStyle', 'formMode', 'ui'];
|
|
3177
|
+
return uiSchemaKeys.includes(key) || uiReg.test(key);
|
|
3178
|
+
};
|
|
3179
|
+
|
|
3180
|
+
Object.entries(unitedSchema).map(function (_ref2) {
|
|
3181
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
3182
|
+
key = _ref3[0],
|
|
3183
|
+
value = _ref3[1];
|
|
3184
|
+
|
|
3185
|
+
// 设置uiSchema
|
|
3186
|
+
if (isUiProp(key)) {
|
|
3187
|
+
// 非第一次调用initParse
|
|
3188
|
+
if (idx) {
|
|
3189
|
+
var path = ['properties', idx];
|
|
3190
|
+
setDeepProp(path, parentUiSchema, {});
|
|
3191
|
+
curUiSchema = parentUiSchema.properties[idx]; // 设置order
|
|
3192
|
+
|
|
3193
|
+
var order = _.get(parentUiSchema, 'order', []); // 避免重复fieldKey
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
if (!order.includes(idx)) {
|
|
3197
|
+
order.push(idx);
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
parentUiSchema.order = order;
|
|
3201
|
+
} // 设置ui:开头的ui属性,ui:{}优先级更高
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
if (uiReg.test(key)) {
|
|
3205
|
+
curUiSchema[key.slice(3)] = ((unitedSchema === null || unitedSchema === void 0 ? void 0 : unitedSchema.ui) || {})[key.slice(3)] || value;
|
|
3206
|
+
} else if (key === 'ui') {
|
|
3207
|
+
// 设置ui:{}中的属性
|
|
3208
|
+
Object.entries(value).map(function (_ref4) {
|
|
3209
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
3210
|
+
key = _ref5[0],
|
|
3211
|
+
value = _ref5[1];
|
|
3212
|
+
|
|
3213
|
+
curUiSchema[key] = value;
|
|
3214
|
+
});
|
|
3215
|
+
} else {
|
|
3216
|
+
curUiSchema[key] = value;
|
|
3217
|
+
}
|
|
3218
|
+
} else {
|
|
3219
|
+
// 设置dataSchema
|
|
3220
|
+
// 非第一次调用initParse
|
|
3221
|
+
if (idx) {
|
|
3222
|
+
switch (parentType) {
|
|
3223
|
+
case 'object':
|
|
3224
|
+
{
|
|
3225
|
+
var _path = ['properties', idx];
|
|
3226
|
+
setDeepProp(_path, parentDataSchema, _.get(parentDataSchema, _path, {}));
|
|
3227
|
+
curDataSchema = parentDataSchema.properties[idx];
|
|
3228
|
+
break;
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
case 'array':
|
|
3232
|
+
{
|
|
3233
|
+
var _path2 = ['items'];
|
|
3234
|
+
setDeepProp(['items'], parentDataSchema, _.get(parentDataSchema, _path2, {}));
|
|
3235
|
+
curDataSchema = parentDataSchema.items;
|
|
3236
|
+
break;
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
case 'tuple':
|
|
3240
|
+
{
|
|
3241
|
+
var _path3 = ['items', idx];
|
|
3242
|
+
setDeepProp(_path3, parentDataSchema, _.get(parentDataSchema, _path3, {}), {
|
|
3243
|
+
items: {
|
|
3244
|
+
type: 'array'
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
curDataSchema = parentDataSchema.items[Number(idx)];
|
|
3248
|
+
break;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
switch (key) {
|
|
3254
|
+
case 'requiredMsg':
|
|
3255
|
+
// 设置父级,只有对象才有
|
|
3256
|
+
if (parentType === 'object' && idx) {
|
|
3257
|
+
// 设置order
|
|
3258
|
+
var required = _.get(parentDataSchema, 'required', []); // 避免重复fieldKey
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
if (!required.includes(idx)) {
|
|
3262
|
+
required.push(idx);
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
parentDataSchema.required = required;
|
|
3266
|
+
setDeepProp(['errorMessage', 'required', idx], parentDataSchema, value);
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
break;
|
|
3270
|
+
// 错误信息配置
|
|
3271
|
+
|
|
3272
|
+
case 'errMsg':
|
|
3273
|
+
curDataSchema.errorMessage = value;
|
|
3274
|
+
break;
|
|
3275
|
+
// 以下字段 items、 schema、fieldKey 不设置到dataSchema中
|
|
3276
|
+
|
|
3277
|
+
case 'items':
|
|
3278
|
+
case 'schema':
|
|
3279
|
+
case 'fieldKey':
|
|
3280
|
+
break;
|
|
3281
|
+
|
|
3282
|
+
default:
|
|
3283
|
+
// 设置customProps
|
|
3284
|
+
if (/^\$:/.test(key)) {
|
|
3285
|
+
customProps.push(key);
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
curDataSchema[key] = value;
|
|
3289
|
+
break;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
}); // 当前表单嵌套类型 'schema'为object|'items'为array
|
|
3293
|
+
|
|
3294
|
+
var type = 'object';
|
|
3295
|
+
|
|
3296
|
+
if (unitedSchema.items) {
|
|
3297
|
+
type = 'array';
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
switch (type) {
|
|
3301
|
+
case 'object':
|
|
3302
|
+
{
|
|
3303
|
+
var _unitedSchema$schema;
|
|
3304
|
+
|
|
3305
|
+
// 处理通用逻辑
|
|
3306
|
+
// 对schema处理(子表单处理,递归)
|
|
3307
|
+
(_unitedSchema$schema = unitedSchema.schema) === null || _unitedSchema$schema === void 0 ? void 0 : _unitedSchema$schema.map(function (childUnitedSchema, i) {
|
|
3308
|
+
initParse({
|
|
3309
|
+
unitedSchema: childUnitedSchema,
|
|
3310
|
+
idx: childUnitedSchema.fieldKey,
|
|
3311
|
+
parentType: 'object',
|
|
3312
|
+
parentUiSchema: curUiSchema,
|
|
3313
|
+
parentDataSchema: curDataSchema,
|
|
3314
|
+
parentTypePath: curTypePath,
|
|
3315
|
+
customProps: customProps,
|
|
3316
|
+
typePath: typePath,
|
|
3317
|
+
index: i
|
|
3318
|
+
});
|
|
3319
|
+
});
|
|
3320
|
+
break;
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
case 'array':
|
|
3324
|
+
{
|
|
3325
|
+
// 处理通用逻辑
|
|
3326
|
+
// 对items处理(子表单处理,递归)
|
|
3327
|
+
var item = unitedSchema.items;
|
|
3328
|
+
|
|
3329
|
+
var _type = typeCheck(item); // 普通数组
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
if (_type === 'Object') {
|
|
3333
|
+
initParse({
|
|
3334
|
+
unitedSchema: item,
|
|
3335
|
+
idx: '$container',
|
|
3336
|
+
parentType: 'array',
|
|
3337
|
+
parentUiSchema: curUiSchema,
|
|
3338
|
+
parentDataSchema: curDataSchema,
|
|
3339
|
+
customProps: customProps,
|
|
3340
|
+
typePath: typePath,
|
|
3341
|
+
parentTypePath: curTypePath,
|
|
3342
|
+
index: '$container'
|
|
3343
|
+
});
|
|
3344
|
+
} else if (_type === 'Array') {
|
|
3345
|
+
// 元祖
|
|
3346
|
+
item === null || item === void 0 ? void 0 : item.map(function (childUnitedSchema, i) {
|
|
3347
|
+
initParse({
|
|
3348
|
+
unitedSchema: childUnitedSchema,
|
|
3349
|
+
idx: String(i),
|
|
3350
|
+
parentType: 'tuple',
|
|
3351
|
+
parentUiSchema: curUiSchema,
|
|
3352
|
+
parentDataSchema: curDataSchema,
|
|
3353
|
+
customProps: customProps,
|
|
3354
|
+
typePath: typePath,
|
|
3355
|
+
parentTypePath: curTypePath,
|
|
3356
|
+
index: i
|
|
3357
|
+
});
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
break;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
/**
|
|
3366
|
+
* 解析联合Schema
|
|
3367
|
+
* @param unitedSchema
|
|
3368
|
+
*/
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
var parseUnitedSchema = function parseUnitedSchema(unitedSchema) {
|
|
3372
|
+
var dataSchema = {};
|
|
3373
|
+
var uiSchema = {}; // 用来存储每个表单项对应的type值,如果是嵌套格式,则解析为 { a: 'object', 'a.b': 'object', 'a.b.c': 'array' }
|
|
3374
|
+
|
|
3375
|
+
var typePath = {}; // $:的自定义属性,仅统计dataSchema的
|
|
3376
|
+
|
|
3377
|
+
var customProps = [];
|
|
3378
|
+
initParse({
|
|
3379
|
+
unitedSchema: unitedSchema,
|
|
3380
|
+
parentUiSchema: uiSchema,
|
|
3381
|
+
parentDataSchema: dataSchema,
|
|
3382
|
+
customProps: customProps,
|
|
3383
|
+
typePath: typePath
|
|
3384
|
+
});
|
|
3385
|
+
return {
|
|
3386
|
+
dataSchema: dataSchema,
|
|
3387
|
+
uiSchema: uiSchema,
|
|
3388
|
+
typePath: typePath,
|
|
3389
|
+
customProps: _toConsumableArray(new Set(customProps))
|
|
3390
|
+
};
|
|
3391
|
+
};
|
|
3392
|
+
|
|
3393
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
3394
|
+
|
|
3395
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3396
|
+
|
|
3397
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
3398
|
+
var needToHandledKeywords = ['required', 'errorMessage', 'items', 'schema', 'properties', 'order'];
|
|
3399
|
+
var needToSetToRootUi = ['theme'];
|
|
3400
|
+
/**
|
|
3401
|
+
* 值拷贝
|
|
3402
|
+
* @param targetObj
|
|
3403
|
+
* @param rawObj
|
|
3404
|
+
* @param dataType
|
|
3405
|
+
*/
|
|
3406
|
+
|
|
3407
|
+
function valueClone(_ref) {
|
|
3408
|
+
var targetObj = _ref.targetObj,
|
|
3409
|
+
rawObj = _ref.rawObj,
|
|
3410
|
+
dataType = _ref.dataType,
|
|
3411
|
+
fromRoot = _ref.fromRoot;
|
|
3412
|
+
|
|
3413
|
+
for (var key in rawObj) {
|
|
3414
|
+
if (rawObj[key] === null || _typeof(rawObj[key]) !== 'object') {
|
|
3415
|
+
if (fromRoot && key === 'theme') ; else {
|
|
3416
|
+
targetObj[key] = rawObj[key];
|
|
3417
|
+
}
|
|
3418
|
+
} else if (!needToHandledKeywords.includes(key) && !needToSetToRootUi.includes(key)) {
|
|
3419
|
+
// 非特殊字段可使用深拷贝,比如title, containerStyle
|
|
3420
|
+
targetObj[key] = deepClone(rawObj[key]);
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
|
|
3424
|
+
if (dataType && Object.hasOwnProperty.call(rawObj, 'errorMessage')) {
|
|
3425
|
+
targetObj.errMsg = deepClone(rawObj.errorMessage);
|
|
3426
|
+
|
|
3427
|
+
if (targetObj.errMsg.required) {
|
|
3428
|
+
delete targetObj.errMsg.required;
|
|
3429
|
+
|
|
3430
|
+
if (Object.keys(targetObj.errMsg).length === 0) {
|
|
3431
|
+
delete targetObj.errMsg;
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
/**
|
|
3437
|
+
* 递归合并
|
|
3438
|
+
* @param dataSchema
|
|
3439
|
+
* @param uiSchema
|
|
3440
|
+
* @param schema
|
|
3441
|
+
* @param fromRoot
|
|
3442
|
+
*/
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
function recursionCombine(_ref2) {
|
|
3446
|
+
var dataSchema = _ref2.dataSchema,
|
|
3447
|
+
uiSchema = _ref2.uiSchema,
|
|
3448
|
+
schema = _ref2.schema,
|
|
3449
|
+
fromRoot = _ref2.fromRoot,
|
|
3450
|
+
options = _ref2.options;
|
|
3451
|
+
// 先拷贝ui和data的值类型属性或非特殊对象类型属性,比如title, containerStyle
|
|
3452
|
+
valueClone({
|
|
3453
|
+
targetObj: schema,
|
|
3454
|
+
rawObj: dataSchema,
|
|
3455
|
+
dataType: dataSchema.type
|
|
3456
|
+
}); // uiSchema非空时进行拷贝
|
|
3457
|
+
|
|
3458
|
+
if (!isEmpty(uiSchema)) {
|
|
3459
|
+
// 填充ui属性,用于存放uiSchema
|
|
3460
|
+
if (!Object.hasOwnProperty.call(schema, 'ui')) {
|
|
3461
|
+
schema.ui = {};
|
|
3462
|
+
} // 如果是根路径的,需要处理特殊字段
|
|
3463
|
+
|
|
3464
|
+
|
|
3465
|
+
if (fromRoot) {
|
|
3466
|
+
needToSetToRootUi.forEach(function (key) {
|
|
3467
|
+
if (Object.hasOwnProperty.call(uiSchema, key)) {
|
|
3468
|
+
schema[key] = uiSchema[key];
|
|
3469
|
+
}
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
valueClone({
|
|
3474
|
+
targetObj: schema.ui,
|
|
3475
|
+
rawObj: uiSchema,
|
|
3476
|
+
fromRoot: fromRoot
|
|
3477
|
+
});
|
|
3478
|
+
|
|
3479
|
+
if (isEmpty(schema.ui)) {
|
|
3480
|
+
delete schema.ui;
|
|
3481
|
+
}
|
|
3482
|
+
} // 如果有order,则根据order填充联合schema
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
if (Object.hasOwnProperty.call(uiSchema, 'order')) {
|
|
3486
|
+
// 子项需要填充到联合schema的哪个prop下
|
|
3487
|
+
// 当父节点类型为array时应为items,否则为schema
|
|
3488
|
+
var toSchemaProp = dataSchema.type === 'array' ? 'items' : 'schema'; // 因为子项的错误信息在dataSchema中,此处需要进行处理
|
|
3489
|
+
|
|
3490
|
+
var required = dataSchema.required,
|
|
3491
|
+
errorMessage = dataSchema.errorMessage,
|
|
3492
|
+
msgMap = {};
|
|
3493
|
+
|
|
3494
|
+
if (_typeof(errorMessage) === 'object') {
|
|
3495
|
+
var requireMsg = errorMessage.required;
|
|
3496
|
+
var errMsg = errorMessage[toSchemaProp === 'items' ? 'items' : 'properties']; // 收集必填的错误提示
|
|
3497
|
+
|
|
3498
|
+
if (required) {
|
|
3499
|
+
var _iterator = _createForOfIteratorHelper(required),
|
|
3500
|
+
_step;
|
|
3501
|
+
|
|
3502
|
+
try {
|
|
3503
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3504
|
+
var fk = _step.value;
|
|
3505
|
+
if (!msgMap[fk]) msgMap[fk] = {};
|
|
3506
|
+
msgMap[fk] = {
|
|
3507
|
+
requiredMsg: requireMsg[fk]
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
} catch (err) {
|
|
3511
|
+
_iterator.e(err);
|
|
3512
|
+
} finally {
|
|
3513
|
+
_iterator.f();
|
|
3514
|
+
}
|
|
3515
|
+
} // 收集校验的错误提示
|
|
3516
|
+
|
|
3517
|
+
|
|
3518
|
+
if (errMsg) {
|
|
3519
|
+
for (var _fk in errMsg) {
|
|
3520
|
+
if (Object.hasOwnProperty.call(errMsg, _fk)) {
|
|
3521
|
+
if (!msgMap[_fk]) msgMap[_fk] = {};
|
|
3522
|
+
msgMap[_fk] = {
|
|
3523
|
+
// 注意errMsg[fk]可能为string或对象,因此需要深拷贝
|
|
3524
|
+
errMsg: deepClone(errMsg[_fk])
|
|
3525
|
+
};
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
} // 遍历order的fieldKey
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
var _iterator2 = _createForOfIteratorHelper(uiSchema.order),
|
|
3533
|
+
_step2;
|
|
3534
|
+
|
|
3535
|
+
try {
|
|
3536
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3537
|
+
var fieldKey = _step2.value;
|
|
3538
|
+
// 根据fieldKey获取子项的schema
|
|
3539
|
+
var subUiSchema = uiSchema.properties[fieldKey]; // 初始化子项的dataSchema
|
|
3540
|
+
|
|
3541
|
+
var subDataSchema = dataSchema; // 根据dataSchema(父节点)中的type字段判断在联合schema中,子项以什么形式存在
|
|
3542
|
+
// array需读取dataSchema的items,object需读取properties
|
|
3543
|
+
|
|
3544
|
+
if (fieldKey === '$container') {
|
|
3545
|
+
subDataSchema = subDataSchema.items;
|
|
3546
|
+
} else if (dataSchema.type === 'array') {
|
|
3547
|
+
subDataSchema = subDataSchema.items[fieldKey];
|
|
3548
|
+
} else {
|
|
3549
|
+
subDataSchema = subDataSchema.properties[fieldKey];
|
|
3550
|
+
} // 初始化待填充的表单项
|
|
3551
|
+
|
|
3552
|
+
|
|
3553
|
+
var fieldItem = {}; // 开始递归
|
|
3554
|
+
|
|
3555
|
+
recursionCombine({
|
|
3556
|
+
dataSchema: subDataSchema,
|
|
3557
|
+
uiSchema: subUiSchema,
|
|
3558
|
+
schema: fieldItem,
|
|
3559
|
+
options: options
|
|
3560
|
+
});
|
|
3561
|
+
|
|
3562
|
+
if (msgMap[fieldKey]) {
|
|
3563
|
+
Object.assign(fieldItem, msgMap[fieldKey]);
|
|
3564
|
+
} // 将递归完成的fieldItem填充到父组件的prop中
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
if (toSchemaProp === 'items' && !Array.isArray(dataSchema === null || dataSchema === void 0 ? void 0 : dataSchema.items)) {
|
|
3568
|
+
// 对于元组类型,items应为 {}
|
|
3569
|
+
if (!Object.hasOwnProperty.call(schema, toSchemaProp)) {
|
|
3570
|
+
schema[toSchemaProp] = {};
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
schema[toSchemaProp] = fieldItem;
|
|
3574
|
+
} else {
|
|
3575
|
+
// 其余类型应为数组
|
|
3576
|
+
if (!Object.hasOwnProperty.call(schema, toSchemaProp)) {
|
|
3577
|
+
schema[toSchemaProp] = [];
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
if (toSchemaProp === 'schema') {
|
|
3581
|
+
// 对于容器类型的子项,需要填充fieldKey
|
|
3582
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3583
|
+
// @ts-ignore
|
|
3584
|
+
if (Object.prototype.hasOwnProperty.call(subDataSchema, '$fieldKey') && options && options['$fieldKey']) {
|
|
3585
|
+
fieldKey = subDataSchema['$fieldKey'];
|
|
3586
|
+
delete fieldItem['$fieldKey'];
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
fieldItem.fieldKey = fieldKey;
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
schema[toSchemaProp].push(fieldItem);
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
} catch (err) {
|
|
3596
|
+
_iterator2.e(err);
|
|
3597
|
+
} finally {
|
|
3598
|
+
_iterator2.f();
|
|
3599
|
+
}
|
|
3600
|
+
} else {
|
|
3601
|
+
// 如果没有order,但数据类型为array且dataSchema中有配置items的,将items拷贝至联合schema
|
|
3602
|
+
// fix: 时间选择器combine后属性丢失的问题
|
|
3603
|
+
if (dataSchema.type === 'array' && !isEmpty(dataSchema.items)) {
|
|
3604
|
+
schema.items = dataSchema.items;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
/**
|
|
3609
|
+
* 融合dataSchema和uiSchema为联合Schema
|
|
3610
|
+
*/
|
|
3611
|
+
|
|
3612
|
+
|
|
3613
|
+
function combine(dataSchema, uiSchema, options) {
|
|
3614
|
+
var unitedSchema = {};
|
|
3615
|
+
recursionCombine({
|
|
3616
|
+
dataSchema: dataSchema,
|
|
3617
|
+
uiSchema: uiSchema,
|
|
3618
|
+
schema: unitedSchema,
|
|
3619
|
+
fromRoot: true,
|
|
3620
|
+
options: options
|
|
3621
|
+
});
|
|
3622
|
+
return unitedSchema;
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3625
|
+
var commonStr = 'const {get,set,merge,setDeepProp,changeKey}=props;';
|
|
3626
|
+
|
|
3627
|
+
var getFileKeyToString = function getFileKeyToString(fieldKey) {
|
|
3628
|
+
var _fieldKey$trim$split = fieldKey.trim().split(' '),
|
|
3629
|
+
_fieldKey$trim$split2 = _slicedToArray(_fieldKey$trim$split, 3),
|
|
3630
|
+
newFieldKey = _fieldKey$trim$split2[0],
|
|
3631
|
+
type = _fieldKey$trim$split2[1],
|
|
3632
|
+
property = _fieldKey$trim$split2[2];
|
|
3633
|
+
|
|
3634
|
+
return property ? "get('".concat(newFieldKey, "').").concat(type, "?.").concat(property) : "get('".concat(newFieldKey, "').").concat(type);
|
|
3635
|
+
}; // TODO else实现
|
|
3636
|
+
// TODO effect subAction实现
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
var parseControlFlow = function parseControlFlow(action, flowStr) {
|
|
3640
|
+
// if的条件语句
|
|
3641
|
+
var condintionStr = ''; // if判断成功,执行的语句
|
|
3642
|
+
|
|
3643
|
+
var effectStr = '';
|
|
3644
|
+
action.condintion.map(function (condintion, index, condintions) {
|
|
3645
|
+
if (!condintion.fieldKey1) return; // 是否取反
|
|
3646
|
+
|
|
3647
|
+
var non = condintion.operator.startsWith('-'); // 去掉 - 之后的字符(例子:前 -includes 后:includes)
|
|
3648
|
+
|
|
3649
|
+
var operator = non ? condintion.operator.slice(1) : condintion.operator;
|
|
3650
|
+
|
|
3651
|
+
if (['true', 'false'].includes(operator)) {
|
|
3652
|
+
operator = '===';
|
|
3653
|
+
} // 需要前面加.的操作符
|
|
3654
|
+
|
|
3655
|
+
|
|
3656
|
+
var isdotOperator = ['includes', 'in'].includes(operator); // change是特殊的判断
|
|
3657
|
+
|
|
3658
|
+
var operatorStr = operator === 'change' ? "('".concat(condintion.fieldKey1.trim().split(' ').shift(), "'===changeKey)") : "(".concat(getFileKeyToString(condintion.fieldKey1)).concat(isdotOperator ? '?.' : '').concat(operator).concat(['true', 'false'].includes(condintion.operator) ? condintion.operator : "".concat(stringify(condintion.value2)), ")");
|
|
3659
|
+
condintionStr += "".concat(operatorStr).concat(condintion.logicOperator && index != condintions.length - 1 ? condintion.logicOperator : '');
|
|
3660
|
+
});
|
|
3661
|
+
action.effect.map(function (effect) {
|
|
3662
|
+
// 转换set类型并过滤空的fieldKey
|
|
3663
|
+
if (effect.type === 'set' && effect.fieldKey) {
|
|
3664
|
+
var _effect$fieldKey$trim = effect.fieldKey.trim().split(' '),
|
|
3665
|
+
_effect$fieldKey$trim2 = _slicedToArray(_effect$fieldKey$trim, 3),
|
|
3666
|
+
fieldKey = _effect$fieldKey$trim2[0],
|
|
3667
|
+
subType = _effect$fieldKey$trim2[1],
|
|
3668
|
+
property = _effect$fieldKey$trim2[2];
|
|
3669
|
+
|
|
3670
|
+
effectStr += "set('".concat(fieldKey, "','").concat(subType, "',").concat(property ? "(oldValue)=>{\n ".concat(property == 'queryConfig.refreshId' ? 'let newRefreshId=oldValue?.queryConfig?.refreshId||0;newRefreshId++;' : '', "\n setDeepProp(").concat(stringify(property.split('.')), ",oldValue,").concat(property === 'vcontrol' ? stringify("const {get}=props;return ".concat(effect.value ? condintionStr : "!(".concat(condintionStr, ")"))) : property == 'queryConfig.refreshId' ? 'newRefreshId' : stringify(effect.value), ")\n }") : stringify(effect.value)) + ');';
|
|
3671
|
+
}
|
|
3672
|
+
});
|
|
3673
|
+
|
|
3674
|
+
if (condintionStr) {
|
|
3675
|
+
flowStr += "if(".concat(condintionStr, "){").concat(effectStr, "};");
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
return flowStr;
|
|
3679
|
+
};
|
|
3680
|
+
|
|
3681
|
+
var parseFlow = function parseFlow(flow) {
|
|
3682
|
+
var flowStr = ''; //TODO trigger.event支持其他类型后,需对一期默认的globalChange兼容
|
|
3683
|
+
// 解析flow.actions
|
|
3684
|
+
|
|
3685
|
+
flow.actions.map(function (action) {
|
|
3686
|
+
switch (action.type) {
|
|
3687
|
+
case 'controlFlow':
|
|
3688
|
+
flowStr += parseControlFlow(action, flowStr);
|
|
3689
|
+
break;
|
|
3690
|
+
}
|
|
3691
|
+
});
|
|
3692
|
+
return commonStr + flowStr;
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3696
|
+
|
|
3697
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3698
|
+
|
|
3699
|
+
var request = /*#__PURE__*/function () {
|
|
3700
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, config) {
|
|
3701
|
+
var res, data;
|
|
3702
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3703
|
+
while (1) {
|
|
3704
|
+
switch (_context.prev = _context.next) {
|
|
3705
|
+
case 0:
|
|
3706
|
+
if (window.fetch) {
|
|
3707
|
+
_context.next = 2;
|
|
3708
|
+
break;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
throw '浏览器版本过低';
|
|
3712
|
+
|
|
3713
|
+
case 2:
|
|
3714
|
+
_context.prev = 2;
|
|
3715
|
+
_context.next = 5;
|
|
3716
|
+
return fetch(url, config);
|
|
3717
|
+
|
|
3718
|
+
case 5:
|
|
3719
|
+
res = _context.sent;
|
|
3720
|
+
|
|
3721
|
+
if (!res.ok) {
|
|
3722
|
+
_context.next = 13;
|
|
3723
|
+
break;
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3726
|
+
_context.next = 9;
|
|
3727
|
+
return res.json();
|
|
3728
|
+
|
|
3729
|
+
case 9:
|
|
3730
|
+
data = _context.sent;
|
|
3731
|
+
return _context.abrupt("return", data);
|
|
3732
|
+
|
|
3733
|
+
case 13:
|
|
3734
|
+
console.error('请求失败');
|
|
3735
|
+
|
|
3736
|
+
case 14:
|
|
3737
|
+
_context.next = 19;
|
|
3738
|
+
break;
|
|
3739
|
+
|
|
3740
|
+
case 16:
|
|
3741
|
+
_context.prev = 16;
|
|
3742
|
+
_context.t0 = _context["catch"](2);
|
|
3743
|
+
console.error(_context.t0);
|
|
3744
|
+
|
|
3745
|
+
case 19:
|
|
3746
|
+
case "end":
|
|
3747
|
+
return _context.stop();
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
}, _callee, null, [[2, 16]]);
|
|
3751
|
+
}));
|
|
3752
|
+
|
|
3753
|
+
return function request(_x, _x2) {
|
|
3754
|
+
return _ref.apply(this, arguments);
|
|
3755
|
+
};
|
|
3756
|
+
}();
|
|
3757
|
+
|
|
3758
|
+
var get$1 = function get(_ref2) {
|
|
3759
|
+
var params = _ref2.params,
|
|
3760
|
+
url = _ref2.url;
|
|
3761
|
+
|
|
3762
|
+
var _URL = new URL(url),
|
|
3763
|
+
search = _URL.search,
|
|
3764
|
+
origin = _URL.origin,
|
|
3765
|
+
hash = _URL.hash,
|
|
3766
|
+
pathname = _URL.pathname;
|
|
3767
|
+
|
|
3768
|
+
var searchParams = new URLSearchParams(search);
|
|
3769
|
+
Object.entries(params).map(function (_ref3) {
|
|
3770
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
3771
|
+
key = _ref4[0],
|
|
3772
|
+
value = _ref4[1];
|
|
3773
|
+
|
|
3774
|
+
searchParams.set(key, value);
|
|
3775
|
+
});
|
|
3776
|
+
var newSearchParams = searchParams.toString();
|
|
3777
|
+
return request("".concat(origin).concat(pathname).concat(newSearchParams ? "?".concat(newSearchParams) : '').concat(hash), {
|
|
3778
|
+
method: 'GET'
|
|
3779
|
+
});
|
|
3780
|
+
};
|
|
3781
|
+
|
|
3782
|
+
var post = function post(_ref5) {
|
|
3783
|
+
var params = _ref5.params,
|
|
3784
|
+
url = _ref5.url;
|
|
3785
|
+
return request(url, {
|
|
3786
|
+
method: 'POST',
|
|
3787
|
+
body: JSON.stringify(params)
|
|
3788
|
+
});
|
|
3789
|
+
};
|
|
3790
|
+
|
|
3791
|
+
var fetchFn = function fetchFn(_ref6) {
|
|
3792
|
+
var oldParams = _ref6.params,
|
|
3793
|
+
url = _ref6.url,
|
|
3794
|
+
method = _ref6.method;
|
|
3795
|
+
var params = {};
|
|
3796
|
+
oldParams.map(function (_ref7) {
|
|
3797
|
+
var key = _ref7.key,
|
|
3798
|
+
value = _ref7.value;
|
|
3799
|
+
params[key] = value;
|
|
3800
|
+
});
|
|
3801
|
+
|
|
3802
|
+
switch (method.toUpperCase()) {
|
|
3803
|
+
case 'GET':
|
|
3804
|
+
return get$1({
|
|
3805
|
+
params: params,
|
|
3806
|
+
url: url
|
|
3807
|
+
});
|
|
3808
|
+
|
|
3809
|
+
case 'POST':
|
|
3810
|
+
return post({
|
|
3811
|
+
params: params,
|
|
3812
|
+
url: url
|
|
3813
|
+
});
|
|
3814
|
+
|
|
3815
|
+
default:
|
|
3816
|
+
throw new Error('不支持改请求类型');
|
|
3817
|
+
}
|
|
3818
|
+
};
|
|
3819
|
+
var fetchFnJsonKey = /*#__PURE__*/function () {
|
|
3820
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref8) {
|
|
3821
|
+
var _config$headers;
|
|
3822
|
+
|
|
3823
|
+
var config, _ref8$dataHandler, dataHandler, _ref8$dataSetter, dataSetter, auth, fetchConfig;
|
|
3824
|
+
|
|
3825
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
3826
|
+
while (1) {
|
|
3827
|
+
switch (_context2.prev = _context2.next) {
|
|
3828
|
+
case 0:
|
|
3829
|
+
config = _ref8.config, _ref8$dataHandler = _ref8.dataHandler, dataHandler = _ref8$dataHandler === void 0 ? null : _ref8$dataHandler, _ref8$dataSetter = _ref8.dataSetter, dataSetter = _ref8$dataSetter === void 0 ? null : _ref8$dataSetter;
|
|
3830
|
+
auth = (config === null || config === void 0 ? void 0 : (_config$headers = config.headers) === null || _config$headers === void 0 ? void 0 : _config$headers.Authorization) || '';
|
|
3831
|
+
|
|
3832
|
+
if (localStorage.getItem('jwtToken')) {
|
|
3833
|
+
auth = "Bearer ".concat(localStorage.getItem('jwtToken'));
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3836
|
+
if (config !== null && config !== void 0 && config.token) {
|
|
3837
|
+
auth = "Bearer ".concat(config === null || config === void 0 ? void 0 : config.token);
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
fetchConfig = {
|
|
3841
|
+
method: config.method,
|
|
3842
|
+
headers: _objectSpread(_objectSpread({}, config === null || config === void 0 ? void 0 : config.headers), {}, {
|
|
3843
|
+
Authorization: auth
|
|
3844
|
+
})
|
|
3845
|
+
};
|
|
3846
|
+
|
|
3847
|
+
if (config !== null && config !== void 0 && config.body) {
|
|
3848
|
+
fetchConfig.body = config.body;
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3851
|
+
_context2.next = 8;
|
|
3852
|
+
return request(config.url, fetchConfig).then(function (res) {
|
|
3853
|
+
var data;
|
|
3854
|
+
|
|
3855
|
+
if (config.jsonkey) {
|
|
3856
|
+
var jsonKeyVals = config.jsonkey.split('.');
|
|
3857
|
+
|
|
3858
|
+
if (jsonKeyVals.length === 1) {
|
|
3859
|
+
data = res === null || res === void 0 ? void 0 : res[jsonKeyVals[0]];
|
|
3860
|
+
} else if (jsonKeyVals.length === 2) {
|
|
3861
|
+
var _res$jsonKeyVals$;
|
|
3862
|
+
|
|
3863
|
+
data = res === null || res === void 0 ? void 0 : (_res$jsonKeyVals$ = res[jsonKeyVals[0]]) === null || _res$jsonKeyVals$ === void 0 ? void 0 : _res$jsonKeyVals$[jsonKeyVals[1]];
|
|
3864
|
+
}
|
|
3865
|
+
} else {
|
|
3866
|
+
data = res;
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
if (dataHandler) {
|
|
3870
|
+
dataHandler((data || []).map(function (item) {
|
|
3871
|
+
return {
|
|
3872
|
+
label: item[config.labelKey],
|
|
3873
|
+
value: item[config.valueKey]
|
|
3874
|
+
};
|
|
3875
|
+
}));
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
if (dataSetter) {
|
|
3879
|
+
dataSetter(data);
|
|
3880
|
+
}
|
|
3881
|
+
})["catch"](function (error) {
|
|
3882
|
+
console.error('Error:', error);
|
|
3883
|
+
});
|
|
3884
|
+
|
|
3885
|
+
case 8:
|
|
3886
|
+
case "end":
|
|
3887
|
+
return _context2.stop();
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}, _callee2);
|
|
3891
|
+
}));
|
|
3892
|
+
|
|
3893
|
+
return function fetchFnJsonKey(_x3) {
|
|
3894
|
+
return _ref9.apply(this, arguments);
|
|
3895
|
+
};
|
|
3896
|
+
}();
|
|
3897
|
+
|
|
3898
|
+
/*
|
|
3899
|
+
* @Author: jiangxiaowei
|
|
3900
|
+
* @Date: 2020-05-30 15:05:24
|
|
3901
|
+
* @Last Modified by: jiangxiaowei
|
|
3902
|
+
* @Last Modified time: 2022-11-24 16:33:13
|
|
3903
|
+
*/
|
|
3904
|
+
var isEqual = _.isEqual;
|
|
3905
|
+
var get = _.get;
|
|
3906
|
+
|
|
3907
|
+
export { binaryData2Blob, checkImg, combine, deepClone, deleteDeepProp, fetchFn, fetchFnJsonKey, generateArrayKeyReg, generateReg, get, getImgEl, getThemeAndType, handleMargin, injectVcontrol, isEmpty, isEqual, isValidHttpUrl, judgeAndRegister, number2Chinese, parseFlow, parseHrefParam, parseUnitedSchema, randomString, removeSpaceAndmakeStringCamelCase, setDeepProp, toArray, typeCheck, upgradeTips };
|