graphiql-rails-fork 1.4.11
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.
- checksums.yaml +7 -0
- data/app/assets/javascripts/graphiql/rails/application.js +4 -0
- data/app/assets/javascripts/graphiql/rails/fetch-0.10.1.js +381 -0
- data/app/assets/javascripts/graphiql/rails/graphiql-0.11.11.js +46455 -0
- data/app/assets/javascripts/graphiql/rails/react-16.2.0.js +1684 -0
- data/app/assets/javascripts/graphiql/rails/react-dom-16.2.0.js +16068 -0
- data/app/assets/stylesheets/graphiql/rails/application.css +10 -0
- data/app/assets/stylesheets/graphiql/rails/graphiql-0.11.11.css +1741 -0
- data/app/controllers/graphiql/rails/editors_controller.rb +14 -0
- data/app/views/graphiql/rails/editors/show.html.erb +103 -0
- data/config/routes.rb +3 -0
- data/lib/graphiql/rails.rb +26 -0
- data/lib/graphiql/rails/config.rb +43 -0
- data/lib/graphiql/rails/engine.rb +7 -0
- data/lib/graphiql/rails/version.rb +5 -0
- data/test/controllers/editors_controller_test.rb +77 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +3 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/graphiql/rails/config_test.rb +24 -0
- data/test/graphiql/rails/engine_test.rb +7 -0
- data/test/graphiql/rails_test.rb +12 -0
- data/test/test_helper.rb +12 -0
- metadata +227 -0
@@ -0,0 +1,1684 @@
|
|
1
|
+
/** @license React v16.2.0
|
2
|
+
* react.development.js
|
3
|
+
*
|
4
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* This source code is licensed under the MIT license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
(function (global, factory) {
|
13
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
14
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
15
|
+
(global.React = factory());
|
16
|
+
}(this, (function () { 'use strict';
|
17
|
+
|
18
|
+
/*
|
19
|
+
object-assign
|
20
|
+
(c) Sindre Sorhus
|
21
|
+
@license MIT
|
22
|
+
*/
|
23
|
+
|
24
|
+
|
25
|
+
/* eslint-disable no-unused-vars */
|
26
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
27
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
28
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
29
|
+
|
30
|
+
function toObject(val) {
|
31
|
+
if (val === null || val === undefined) {
|
32
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
33
|
+
}
|
34
|
+
|
35
|
+
return Object(val);
|
36
|
+
}
|
37
|
+
|
38
|
+
function shouldUseNative() {
|
39
|
+
try {
|
40
|
+
if (!Object.assign) {
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Detect buggy property enumeration order in older V8 versions.
|
45
|
+
|
46
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
47
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
48
|
+
test1[5] = 'de';
|
49
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
|
53
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
54
|
+
var test2 = {};
|
55
|
+
for (var i = 0; i < 10; i++) {
|
56
|
+
test2['_' + String.fromCharCode(i)] = i;
|
57
|
+
}
|
58
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
59
|
+
return test2[n];
|
60
|
+
});
|
61
|
+
if (order2.join('') !== '0123456789') {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
|
65
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
66
|
+
var test3 = {};
|
67
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
68
|
+
test3[letter] = letter;
|
69
|
+
});
|
70
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
71
|
+
'abcdefghijklmnopqrst') {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
return true;
|
76
|
+
} catch (err) {
|
77
|
+
// We don't expect any of the above to throw, but better to be safe.
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
83
|
+
var from;
|
84
|
+
var to = toObject(target);
|
85
|
+
var symbols;
|
86
|
+
|
87
|
+
for (var s = 1; s < arguments.length; s++) {
|
88
|
+
from = Object(arguments[s]);
|
89
|
+
|
90
|
+
for (var key in from) {
|
91
|
+
if (hasOwnProperty.call(from, key)) {
|
92
|
+
to[key] = from[key];
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
if (getOwnPropertySymbols) {
|
97
|
+
symbols = getOwnPropertySymbols(from);
|
98
|
+
for (var i = 0; i < symbols.length; i++) {
|
99
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
100
|
+
to[symbols[i]] = from[symbols[i]];
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
return to;
|
107
|
+
};
|
108
|
+
|
109
|
+
// TODO: this is special because it gets imported during build.
|
110
|
+
|
111
|
+
var ReactVersion = '16.2.0';
|
112
|
+
|
113
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
114
|
+
// nor polyfill, then a plain number is used for performance.
|
115
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
|
116
|
+
|
117
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
|
118
|
+
var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
|
119
|
+
var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
|
120
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
|
121
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
|
122
|
+
|
123
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
124
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
125
|
+
|
126
|
+
function getIteratorFn(maybeIterable) {
|
127
|
+
if (maybeIterable === null || typeof maybeIterable === 'undefined') {
|
128
|
+
return null;
|
129
|
+
}
|
130
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
131
|
+
if (typeof maybeIterator === 'function') {
|
132
|
+
return maybeIterator;
|
133
|
+
}
|
134
|
+
return null;
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* WARNING: DO NOT manually require this module.
|
139
|
+
* This is a replacement for `invariant(...)` used by the error code system
|
140
|
+
* and will _only_ be required by the corresponding babel pass.
|
141
|
+
* It always throws.
|
142
|
+
*/
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
146
|
+
*
|
147
|
+
* This source code is licensed under the MIT license found in the
|
148
|
+
* LICENSE file in the root directory of this source tree.
|
149
|
+
*
|
150
|
+
*/
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
var emptyObject = {};
|
155
|
+
|
156
|
+
{
|
157
|
+
Object.freeze(emptyObject);
|
158
|
+
}
|
159
|
+
|
160
|
+
var emptyObject_1 = emptyObject;
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
164
|
+
*
|
165
|
+
* This source code is licensed under the MIT license found in the
|
166
|
+
* LICENSE file in the root directory of this source tree.
|
167
|
+
*
|
168
|
+
*/
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Use invariant() to assert state which your program assumes to be true.
|
174
|
+
*
|
175
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
176
|
+
* to provide information about what broke and what you were
|
177
|
+
* expecting.
|
178
|
+
*
|
179
|
+
* The invariant message will be stripped in production, but the invariant
|
180
|
+
* will remain to ensure logic does not differ in production.
|
181
|
+
*/
|
182
|
+
|
183
|
+
var validateFormat = function validateFormat(format) {};
|
184
|
+
|
185
|
+
{
|
186
|
+
validateFormat = function validateFormat(format) {
|
187
|
+
if (format === undefined) {
|
188
|
+
throw new Error('invariant requires an error message argument');
|
189
|
+
}
|
190
|
+
};
|
191
|
+
}
|
192
|
+
|
193
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
194
|
+
validateFormat(format);
|
195
|
+
|
196
|
+
if (!condition) {
|
197
|
+
var error;
|
198
|
+
if (format === undefined) {
|
199
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
200
|
+
} else {
|
201
|
+
var args = [a, b, c, d, e, f];
|
202
|
+
var argIndex = 0;
|
203
|
+
error = new Error(format.replace(/%s/g, function () {
|
204
|
+
return args[argIndex++];
|
205
|
+
}));
|
206
|
+
error.name = 'Invariant Violation';
|
207
|
+
}
|
208
|
+
|
209
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
210
|
+
throw error;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
var invariant_1 = invariant;
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Forked from fbjs/warning:
|
218
|
+
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
219
|
+
*
|
220
|
+
* Only change is we use console.warn instead of console.error,
|
221
|
+
* and do nothing when 'console' is not supported.
|
222
|
+
* This really simplifies the code.
|
223
|
+
* ---
|
224
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
225
|
+
* This can be used to log issues in development environments in critical
|
226
|
+
* paths. Removing the logging code for production environments will keep the
|
227
|
+
* same logic and follow the same code paths.
|
228
|
+
*/
|
229
|
+
|
230
|
+
var lowPriorityWarning = function () {};
|
231
|
+
|
232
|
+
{
|
233
|
+
var printWarning = function (format) {
|
234
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
235
|
+
args[_key - 1] = arguments[_key];
|
236
|
+
}
|
237
|
+
|
238
|
+
var argIndex = 0;
|
239
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
240
|
+
return args[argIndex++];
|
241
|
+
});
|
242
|
+
if (typeof console !== 'undefined') {
|
243
|
+
console.warn(message);
|
244
|
+
}
|
245
|
+
try {
|
246
|
+
// --- Welcome to debugging React ---
|
247
|
+
// This error was thrown as a convenience so that you can use this stack
|
248
|
+
// to find the callsite that caused this warning to fire.
|
249
|
+
throw new Error(message);
|
250
|
+
} catch (x) {}
|
251
|
+
};
|
252
|
+
|
253
|
+
lowPriorityWarning = function (condition, format) {
|
254
|
+
if (format === undefined) {
|
255
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
256
|
+
}
|
257
|
+
if (!condition) {
|
258
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
259
|
+
args[_key2 - 2] = arguments[_key2];
|
260
|
+
}
|
261
|
+
|
262
|
+
printWarning.apply(undefined, [format].concat(args));
|
263
|
+
}
|
264
|
+
};
|
265
|
+
}
|
266
|
+
|
267
|
+
var lowPriorityWarning$1 = lowPriorityWarning;
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
271
|
+
*
|
272
|
+
* This source code is licensed under the MIT license found in the
|
273
|
+
* LICENSE file in the root directory of this source tree.
|
274
|
+
*
|
275
|
+
*
|
276
|
+
*/
|
277
|
+
|
278
|
+
function makeEmptyFunction(arg) {
|
279
|
+
return function () {
|
280
|
+
return arg;
|
281
|
+
};
|
282
|
+
}
|
283
|
+
|
284
|
+
/**
|
285
|
+
* This function accepts and discards inputs; it has no side effects. This is
|
286
|
+
* primarily useful idiomatically for overridable function endpoints which
|
287
|
+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
288
|
+
*/
|
289
|
+
var emptyFunction = function emptyFunction() {};
|
290
|
+
|
291
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
292
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
293
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
294
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
295
|
+
emptyFunction.thatReturnsThis = function () {
|
296
|
+
return this;
|
297
|
+
};
|
298
|
+
emptyFunction.thatReturnsArgument = function (arg) {
|
299
|
+
return arg;
|
300
|
+
};
|
301
|
+
|
302
|
+
var emptyFunction_1 = emptyFunction;
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
306
|
+
*
|
307
|
+
* This source code is licensed under the MIT license found in the
|
308
|
+
* LICENSE file in the root directory of this source tree.
|
309
|
+
*
|
310
|
+
*/
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
318
|
+
* This can be used to log issues in development environments in critical
|
319
|
+
* paths. Removing the logging code for production environments will keep the
|
320
|
+
* same logic and follow the same code paths.
|
321
|
+
*/
|
322
|
+
|
323
|
+
var warning = emptyFunction_1;
|
324
|
+
|
325
|
+
{
|
326
|
+
var printWarning$1 = function printWarning(format) {
|
327
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
328
|
+
args[_key - 1] = arguments[_key];
|
329
|
+
}
|
330
|
+
|
331
|
+
var argIndex = 0;
|
332
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
333
|
+
return args[argIndex++];
|
334
|
+
});
|
335
|
+
if (typeof console !== 'undefined') {
|
336
|
+
console.error(message);
|
337
|
+
}
|
338
|
+
try {
|
339
|
+
// --- Welcome to debugging React ---
|
340
|
+
// This error was thrown as a convenience so that you can use this stack
|
341
|
+
// to find the callsite that caused this warning to fire.
|
342
|
+
throw new Error(message);
|
343
|
+
} catch (x) {}
|
344
|
+
};
|
345
|
+
|
346
|
+
warning = function warning(condition, format) {
|
347
|
+
if (format === undefined) {
|
348
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
349
|
+
}
|
350
|
+
|
351
|
+
if (format.indexOf('Failed Composite propType: ') === 0) {
|
352
|
+
return; // Ignore CompositeComponent proptype check.
|
353
|
+
}
|
354
|
+
|
355
|
+
if (!condition) {
|
356
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
357
|
+
args[_key2 - 2] = arguments[_key2];
|
358
|
+
}
|
359
|
+
|
360
|
+
printWarning$1.apply(undefined, [format].concat(args));
|
361
|
+
}
|
362
|
+
};
|
363
|
+
}
|
364
|
+
|
365
|
+
var warning_1 = warning;
|
366
|
+
|
367
|
+
var didWarnStateUpdateForUnmountedComponent = {};
|
368
|
+
|
369
|
+
function warnNoop(publicInstance, callerName) {
|
370
|
+
{
|
371
|
+
var constructor = publicInstance.constructor;
|
372
|
+
var componentName = constructor && (constructor.displayName || constructor.name) || 'ReactClass';
|
373
|
+
var warningKey = componentName + '.' + callerName;
|
374
|
+
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
375
|
+
return;
|
376
|
+
}
|
377
|
+
warning_1(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
|
378
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
/**
|
383
|
+
* This is the abstract API for an update queue.
|
384
|
+
*/
|
385
|
+
var ReactNoopUpdateQueue = {
|
386
|
+
/**
|
387
|
+
* Checks whether or not this composite component is mounted.
|
388
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
389
|
+
* @return {boolean} True if mounted, false otherwise.
|
390
|
+
* @protected
|
391
|
+
* @final
|
392
|
+
*/
|
393
|
+
isMounted: function (publicInstance) {
|
394
|
+
return false;
|
395
|
+
},
|
396
|
+
|
397
|
+
/**
|
398
|
+
* Forces an update. This should only be invoked when it is known with
|
399
|
+
* certainty that we are **not** in a DOM transaction.
|
400
|
+
*
|
401
|
+
* You may want to call this when you know that some deeper aspect of the
|
402
|
+
* component's state has changed but `setState` was not called.
|
403
|
+
*
|
404
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
405
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
406
|
+
*
|
407
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
408
|
+
* @param {?function} callback Called after component is updated.
|
409
|
+
* @param {?string} callerName name of the calling function in the public API.
|
410
|
+
* @internal
|
411
|
+
*/
|
412
|
+
enqueueForceUpdate: function (publicInstance, callback, callerName) {
|
413
|
+
warnNoop(publicInstance, 'forceUpdate');
|
414
|
+
},
|
415
|
+
|
416
|
+
/**
|
417
|
+
* Replaces all of the state. Always use this or `setState` to mutate state.
|
418
|
+
* You should treat `this.state` as immutable.
|
419
|
+
*
|
420
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
421
|
+
* accessing `this.state` after calling this method may return the old value.
|
422
|
+
*
|
423
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
424
|
+
* @param {object} completeState Next state.
|
425
|
+
* @param {?function} callback Called after component is updated.
|
426
|
+
* @param {?string} callerName name of the calling function in the public API.
|
427
|
+
* @internal
|
428
|
+
*/
|
429
|
+
enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
|
430
|
+
warnNoop(publicInstance, 'replaceState');
|
431
|
+
},
|
432
|
+
|
433
|
+
/**
|
434
|
+
* Sets a subset of the state. This only exists because _pendingState is
|
435
|
+
* internal. This provides a merging strategy that is not available to deep
|
436
|
+
* properties which is confusing. TODO: Expose pendingState or don't use it
|
437
|
+
* during the merge.
|
438
|
+
*
|
439
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
440
|
+
* @param {object} partialState Next partial state to be merged with state.
|
441
|
+
* @param {?function} callback Called after component is updated.
|
442
|
+
* @param {?string} Name of the calling function in the public API.
|
443
|
+
* @internal
|
444
|
+
*/
|
445
|
+
enqueueSetState: function (publicInstance, partialState, callback, callerName) {
|
446
|
+
warnNoop(publicInstance, 'setState');
|
447
|
+
}
|
448
|
+
};
|
449
|
+
|
450
|
+
/**
|
451
|
+
* Base class helpers for the updating state of a component.
|
452
|
+
*/
|
453
|
+
function Component(props, context, updater) {
|
454
|
+
this.props = props;
|
455
|
+
this.context = context;
|
456
|
+
this.refs = emptyObject_1;
|
457
|
+
// We initialize the default updater but the real one gets injected by the
|
458
|
+
// renderer.
|
459
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
460
|
+
}
|
461
|
+
|
462
|
+
Component.prototype.isReactComponent = {};
|
463
|
+
|
464
|
+
/**
|
465
|
+
* Sets a subset of the state. Always use this to mutate
|
466
|
+
* state. You should treat `this.state` as immutable.
|
467
|
+
*
|
468
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
469
|
+
* accessing `this.state` after calling this method may return the old value.
|
470
|
+
*
|
471
|
+
* There is no guarantee that calls to `setState` will run synchronously,
|
472
|
+
* as they may eventually be batched together. You can provide an optional
|
473
|
+
* callback that will be executed when the call to setState is actually
|
474
|
+
* completed.
|
475
|
+
*
|
476
|
+
* When a function is provided to setState, it will be called at some point in
|
477
|
+
* the future (not synchronously). It will be called with the up to date
|
478
|
+
* component arguments (state, props, context). These values can be different
|
479
|
+
* from this.* because your function may be called after receiveProps but before
|
480
|
+
* shouldComponentUpdate, and this new state, props, and context will not yet be
|
481
|
+
* assigned to this.
|
482
|
+
*
|
483
|
+
* @param {object|function} partialState Next partial state or function to
|
484
|
+
* produce next partial state to be merged with current state.
|
485
|
+
* @param {?function} callback Called after state is updated.
|
486
|
+
* @final
|
487
|
+
* @protected
|
488
|
+
*/
|
489
|
+
Component.prototype.setState = function (partialState, callback) {
|
490
|
+
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant_1(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
|
491
|
+
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
492
|
+
};
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Forces an update. This should only be invoked when it is known with
|
496
|
+
* certainty that we are **not** in a DOM transaction.
|
497
|
+
*
|
498
|
+
* You may want to call this when you know that some deeper aspect of the
|
499
|
+
* component's state has changed but `setState` was not called.
|
500
|
+
*
|
501
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
502
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
503
|
+
*
|
504
|
+
* @param {?function} callback Called after update is complete.
|
505
|
+
* @final
|
506
|
+
* @protected
|
507
|
+
*/
|
508
|
+
Component.prototype.forceUpdate = function (callback) {
|
509
|
+
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
510
|
+
};
|
511
|
+
|
512
|
+
/**
|
513
|
+
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
514
|
+
* we would like to deprecate them, we're not going to move them over to this
|
515
|
+
* modern base class. Instead, we define a getter that warns if it's accessed.
|
516
|
+
*/
|
517
|
+
{
|
518
|
+
var deprecatedAPIs = {
|
519
|
+
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
520
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
521
|
+
};
|
522
|
+
var defineDeprecationWarning = function (methodName, info) {
|
523
|
+
Object.defineProperty(Component.prototype, methodName, {
|
524
|
+
get: function () {
|
525
|
+
lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
526
|
+
return undefined;
|
527
|
+
}
|
528
|
+
});
|
529
|
+
};
|
530
|
+
for (var fnName in deprecatedAPIs) {
|
531
|
+
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
532
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
533
|
+
}
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Base class helpers for the updating state of a component.
|
539
|
+
*/
|
540
|
+
function PureComponent(props, context, updater) {
|
541
|
+
// Duplicated from Component.
|
542
|
+
this.props = props;
|
543
|
+
this.context = context;
|
544
|
+
this.refs = emptyObject_1;
|
545
|
+
// We initialize the default updater but the real one gets injected by the
|
546
|
+
// renderer.
|
547
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
548
|
+
}
|
549
|
+
|
550
|
+
function ComponentDummy() {}
|
551
|
+
ComponentDummy.prototype = Component.prototype;
|
552
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
553
|
+
pureComponentPrototype.constructor = PureComponent;
|
554
|
+
// Avoid an extra prototype jump for these methods.
|
555
|
+
objectAssign(pureComponentPrototype, Component.prototype);
|
556
|
+
pureComponentPrototype.isPureReactComponent = true;
|
557
|
+
|
558
|
+
function AsyncComponent(props, context, updater) {
|
559
|
+
// Duplicated from Component.
|
560
|
+
this.props = props;
|
561
|
+
this.context = context;
|
562
|
+
this.refs = emptyObject_1;
|
563
|
+
// We initialize the default updater but the real one gets injected by the
|
564
|
+
// renderer.
|
565
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
566
|
+
}
|
567
|
+
|
568
|
+
var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy();
|
569
|
+
asyncComponentPrototype.constructor = AsyncComponent;
|
570
|
+
// Avoid an extra prototype jump for these methods.
|
571
|
+
objectAssign(asyncComponentPrototype, Component.prototype);
|
572
|
+
asyncComponentPrototype.unstable_isAsyncReactComponent = true;
|
573
|
+
asyncComponentPrototype.render = function () {
|
574
|
+
return this.props.children;
|
575
|
+
};
|
576
|
+
|
577
|
+
/**
|
578
|
+
* Keeps track of the current owner.
|
579
|
+
*
|
580
|
+
* The current owner is the component who should own any components that are
|
581
|
+
* currently being constructed.
|
582
|
+
*/
|
583
|
+
var ReactCurrentOwner = {
|
584
|
+
/**
|
585
|
+
* @internal
|
586
|
+
* @type {ReactComponent}
|
587
|
+
*/
|
588
|
+
current: null
|
589
|
+
};
|
590
|
+
|
591
|
+
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
592
|
+
|
593
|
+
var RESERVED_PROPS = {
|
594
|
+
key: true,
|
595
|
+
ref: true,
|
596
|
+
__self: true,
|
597
|
+
__source: true
|
598
|
+
};
|
599
|
+
|
600
|
+
var specialPropKeyWarningShown;
|
601
|
+
var specialPropRefWarningShown;
|
602
|
+
|
603
|
+
function hasValidRef(config) {
|
604
|
+
{
|
605
|
+
if (hasOwnProperty$1.call(config, 'ref')) {
|
606
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
607
|
+
if (getter && getter.isReactWarning) {
|
608
|
+
return false;
|
609
|
+
}
|
610
|
+
}
|
611
|
+
}
|
612
|
+
return config.ref !== undefined;
|
613
|
+
}
|
614
|
+
|
615
|
+
function hasValidKey(config) {
|
616
|
+
{
|
617
|
+
if (hasOwnProperty$1.call(config, 'key')) {
|
618
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
619
|
+
if (getter && getter.isReactWarning) {
|
620
|
+
return false;
|
621
|
+
}
|
622
|
+
}
|
623
|
+
}
|
624
|
+
return config.key !== undefined;
|
625
|
+
}
|
626
|
+
|
627
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
628
|
+
var warnAboutAccessingKey = function () {
|
629
|
+
if (!specialPropKeyWarningShown) {
|
630
|
+
specialPropKeyWarningShown = true;
|
631
|
+
warning_1(false, '%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://fb.me/react-special-props)', displayName);
|
632
|
+
}
|
633
|
+
};
|
634
|
+
warnAboutAccessingKey.isReactWarning = true;
|
635
|
+
Object.defineProperty(props, 'key', {
|
636
|
+
get: warnAboutAccessingKey,
|
637
|
+
configurable: true
|
638
|
+
});
|
639
|
+
}
|
640
|
+
|
641
|
+
function defineRefPropWarningGetter(props, displayName) {
|
642
|
+
var warnAboutAccessingRef = function () {
|
643
|
+
if (!specialPropRefWarningShown) {
|
644
|
+
specialPropRefWarningShown = true;
|
645
|
+
warning_1(false, '%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://fb.me/react-special-props)', displayName);
|
646
|
+
}
|
647
|
+
};
|
648
|
+
warnAboutAccessingRef.isReactWarning = true;
|
649
|
+
Object.defineProperty(props, 'ref', {
|
650
|
+
get: warnAboutAccessingRef,
|
651
|
+
configurable: true
|
652
|
+
});
|
653
|
+
}
|
654
|
+
|
655
|
+
/**
|
656
|
+
* Factory method to create a new React element. This no longer adheres to
|
657
|
+
* the class pattern, so do not use new to call it. Also, no instanceof check
|
658
|
+
* will work. Instead test $$typeof field against Symbol.for('react.element') to check
|
659
|
+
* if something is a React Element.
|
660
|
+
*
|
661
|
+
* @param {*} type
|
662
|
+
* @param {*} key
|
663
|
+
* @param {string|object} ref
|
664
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
665
|
+
* different from the `owner` when React.createElement is called, so that we
|
666
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
667
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
668
|
+
* change in behavior.
|
669
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
670
|
+
* indicating filename, line number, and/or other information.
|
671
|
+
* @param {*} owner
|
672
|
+
* @param {*} props
|
673
|
+
* @internal
|
674
|
+
*/
|
675
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
676
|
+
var element = {
|
677
|
+
// This tag allow us to uniquely identify this as a React Element
|
678
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
679
|
+
|
680
|
+
// Built-in properties that belong on the element
|
681
|
+
type: type,
|
682
|
+
key: key,
|
683
|
+
ref: ref,
|
684
|
+
props: props,
|
685
|
+
|
686
|
+
// Record the component responsible for creating this element.
|
687
|
+
_owner: owner
|
688
|
+
};
|
689
|
+
|
690
|
+
{
|
691
|
+
// The validation flag is currently mutative. We put it on
|
692
|
+
// an external backing store so that we can freeze the whole object.
|
693
|
+
// This can be replaced with a WeakMap once they are implemented in
|
694
|
+
// commonly used development environments.
|
695
|
+
element._store = {};
|
696
|
+
|
697
|
+
// To make comparing ReactElements easier for testing purposes, we make
|
698
|
+
// the validation flag non-enumerable (where possible, which should
|
699
|
+
// include every environment we run tests in), so the test framework
|
700
|
+
// ignores it.
|
701
|
+
Object.defineProperty(element._store, 'validated', {
|
702
|
+
configurable: false,
|
703
|
+
enumerable: false,
|
704
|
+
writable: true,
|
705
|
+
value: false
|
706
|
+
});
|
707
|
+
// self and source are DEV only properties.
|
708
|
+
Object.defineProperty(element, '_self', {
|
709
|
+
configurable: false,
|
710
|
+
enumerable: false,
|
711
|
+
writable: false,
|
712
|
+
value: self
|
713
|
+
});
|
714
|
+
// Two elements created in two different places should be considered
|
715
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
716
|
+
Object.defineProperty(element, '_source', {
|
717
|
+
configurable: false,
|
718
|
+
enumerable: false,
|
719
|
+
writable: false,
|
720
|
+
value: source
|
721
|
+
});
|
722
|
+
if (Object.freeze) {
|
723
|
+
Object.freeze(element.props);
|
724
|
+
Object.freeze(element);
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
return element;
|
729
|
+
};
|
730
|
+
|
731
|
+
/**
|
732
|
+
* Create and return a new ReactElement of the given type.
|
733
|
+
* See https://reactjs.org/docs/react-api.html#createelement
|
734
|
+
*/
|
735
|
+
function createElement(type, config, children) {
|
736
|
+
var propName;
|
737
|
+
|
738
|
+
// Reserved names are extracted
|
739
|
+
var props = {};
|
740
|
+
|
741
|
+
var key = null;
|
742
|
+
var ref = null;
|
743
|
+
var self = null;
|
744
|
+
var source = null;
|
745
|
+
|
746
|
+
if (config != null) {
|
747
|
+
if (hasValidRef(config)) {
|
748
|
+
ref = config.ref;
|
749
|
+
}
|
750
|
+
if (hasValidKey(config)) {
|
751
|
+
key = '' + config.key;
|
752
|
+
}
|
753
|
+
|
754
|
+
self = config.__self === undefined ? null : config.__self;
|
755
|
+
source = config.__source === undefined ? null : config.__source;
|
756
|
+
// Remaining properties are added to a new props object
|
757
|
+
for (propName in config) {
|
758
|
+
if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
759
|
+
props[propName] = config[propName];
|
760
|
+
}
|
761
|
+
}
|
762
|
+
}
|
763
|
+
|
764
|
+
// Children can be more than one argument, and those are transferred onto
|
765
|
+
// the newly allocated props object.
|
766
|
+
var childrenLength = arguments.length - 2;
|
767
|
+
if (childrenLength === 1) {
|
768
|
+
props.children = children;
|
769
|
+
} else if (childrenLength > 1) {
|
770
|
+
var childArray = Array(childrenLength);
|
771
|
+
for (var i = 0; i < childrenLength; i++) {
|
772
|
+
childArray[i] = arguments[i + 2];
|
773
|
+
}
|
774
|
+
{
|
775
|
+
if (Object.freeze) {
|
776
|
+
Object.freeze(childArray);
|
777
|
+
}
|
778
|
+
}
|
779
|
+
props.children = childArray;
|
780
|
+
}
|
781
|
+
|
782
|
+
// Resolve default props
|
783
|
+
if (type && type.defaultProps) {
|
784
|
+
var defaultProps = type.defaultProps;
|
785
|
+
for (propName in defaultProps) {
|
786
|
+
if (props[propName] === undefined) {
|
787
|
+
props[propName] = defaultProps[propName];
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}
|
791
|
+
{
|
792
|
+
if (key || ref) {
|
793
|
+
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
794
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
795
|
+
if (key) {
|
796
|
+
defineKeyPropWarningGetter(props, displayName);
|
797
|
+
}
|
798
|
+
if (ref) {
|
799
|
+
defineRefPropWarningGetter(props, displayName);
|
800
|
+
}
|
801
|
+
}
|
802
|
+
}
|
803
|
+
}
|
804
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
805
|
+
}
|
806
|
+
|
807
|
+
/**
|
808
|
+
* Return a function that produces ReactElements of a given type.
|
809
|
+
* See https://reactjs.org/docs/react-api.html#createfactory
|
810
|
+
*/
|
811
|
+
|
812
|
+
|
813
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
814
|
+
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
815
|
+
|
816
|
+
return newElement;
|
817
|
+
}
|
818
|
+
|
819
|
+
/**
|
820
|
+
* Clone and return a new ReactElement using element as the starting point.
|
821
|
+
* See https://reactjs.org/docs/react-api.html#cloneelement
|
822
|
+
*/
|
823
|
+
function cloneElement(element, config, children) {
|
824
|
+
var propName;
|
825
|
+
|
826
|
+
// Original props are copied
|
827
|
+
var props = objectAssign({}, element.props);
|
828
|
+
|
829
|
+
// Reserved names are extracted
|
830
|
+
var key = element.key;
|
831
|
+
var ref = element.ref;
|
832
|
+
// Self is preserved since the owner is preserved.
|
833
|
+
var self = element._self;
|
834
|
+
// Source is preserved since cloneElement is unlikely to be targeted by a
|
835
|
+
// transpiler, and the original source is probably a better indicator of the
|
836
|
+
// true owner.
|
837
|
+
var source = element._source;
|
838
|
+
|
839
|
+
// Owner will be preserved, unless ref is overridden
|
840
|
+
var owner = element._owner;
|
841
|
+
|
842
|
+
if (config != null) {
|
843
|
+
if (hasValidRef(config)) {
|
844
|
+
// Silently steal the ref from the parent.
|
845
|
+
ref = config.ref;
|
846
|
+
owner = ReactCurrentOwner.current;
|
847
|
+
}
|
848
|
+
if (hasValidKey(config)) {
|
849
|
+
key = '' + config.key;
|
850
|
+
}
|
851
|
+
|
852
|
+
// Remaining properties override existing props
|
853
|
+
var defaultProps;
|
854
|
+
if (element.type && element.type.defaultProps) {
|
855
|
+
defaultProps = element.type.defaultProps;
|
856
|
+
}
|
857
|
+
for (propName in config) {
|
858
|
+
if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
859
|
+
if (config[propName] === undefined && defaultProps !== undefined) {
|
860
|
+
// Resolve default props
|
861
|
+
props[propName] = defaultProps[propName];
|
862
|
+
} else {
|
863
|
+
props[propName] = config[propName];
|
864
|
+
}
|
865
|
+
}
|
866
|
+
}
|
867
|
+
}
|
868
|
+
|
869
|
+
// Children can be more than one argument, and those are transferred onto
|
870
|
+
// the newly allocated props object.
|
871
|
+
var childrenLength = arguments.length - 2;
|
872
|
+
if (childrenLength === 1) {
|
873
|
+
props.children = children;
|
874
|
+
} else if (childrenLength > 1) {
|
875
|
+
var childArray = Array(childrenLength);
|
876
|
+
for (var i = 0; i < childrenLength; i++) {
|
877
|
+
childArray[i] = arguments[i + 2];
|
878
|
+
}
|
879
|
+
props.children = childArray;
|
880
|
+
}
|
881
|
+
|
882
|
+
return ReactElement(element.type, key, ref, self, source, owner, props);
|
883
|
+
}
|
884
|
+
|
885
|
+
/**
|
886
|
+
* Verifies the object is a ReactElement.
|
887
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
888
|
+
* @param {?object} object
|
889
|
+
* @return {boolean} True if `object` is a valid component.
|
890
|
+
* @final
|
891
|
+
*/
|
892
|
+
function isValidElement(object) {
|
893
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
894
|
+
}
|
895
|
+
|
896
|
+
var ReactDebugCurrentFrame = {};
|
897
|
+
|
898
|
+
{
|
899
|
+
// Component that is being worked on
|
900
|
+
ReactDebugCurrentFrame.getCurrentStack = null;
|
901
|
+
|
902
|
+
ReactDebugCurrentFrame.getStackAddendum = function () {
|
903
|
+
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
904
|
+
if (impl) {
|
905
|
+
return impl();
|
906
|
+
}
|
907
|
+
return null;
|
908
|
+
};
|
909
|
+
}
|
910
|
+
|
911
|
+
var SEPARATOR = '.';
|
912
|
+
var SUBSEPARATOR = ':';
|
913
|
+
|
914
|
+
/**
|
915
|
+
* Escape and wrap key so it is safe to use as a reactid
|
916
|
+
*
|
917
|
+
* @param {string} key to be escaped.
|
918
|
+
* @return {string} the escaped key.
|
919
|
+
*/
|
920
|
+
function escape(key) {
|
921
|
+
var escapeRegex = /[=:]/g;
|
922
|
+
var escaperLookup = {
|
923
|
+
'=': '=0',
|
924
|
+
':': '=2'
|
925
|
+
};
|
926
|
+
var escapedString = ('' + key).replace(escapeRegex, function (match) {
|
927
|
+
return escaperLookup[match];
|
928
|
+
});
|
929
|
+
|
930
|
+
return '$' + escapedString;
|
931
|
+
}
|
932
|
+
|
933
|
+
/**
|
934
|
+
* TODO: Test that a single child and an array with one item have the same key
|
935
|
+
* pattern.
|
936
|
+
*/
|
937
|
+
|
938
|
+
var didWarnAboutMaps = false;
|
939
|
+
|
940
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
941
|
+
function escapeUserProvidedKey(text) {
|
942
|
+
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
943
|
+
}
|
944
|
+
|
945
|
+
var POOL_SIZE = 10;
|
946
|
+
var traverseContextPool = [];
|
947
|
+
function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
|
948
|
+
if (traverseContextPool.length) {
|
949
|
+
var traverseContext = traverseContextPool.pop();
|
950
|
+
traverseContext.result = mapResult;
|
951
|
+
traverseContext.keyPrefix = keyPrefix;
|
952
|
+
traverseContext.func = mapFunction;
|
953
|
+
traverseContext.context = mapContext;
|
954
|
+
traverseContext.count = 0;
|
955
|
+
return traverseContext;
|
956
|
+
} else {
|
957
|
+
return {
|
958
|
+
result: mapResult,
|
959
|
+
keyPrefix: keyPrefix,
|
960
|
+
func: mapFunction,
|
961
|
+
context: mapContext,
|
962
|
+
count: 0
|
963
|
+
};
|
964
|
+
}
|
965
|
+
}
|
966
|
+
|
967
|
+
function releaseTraverseContext(traverseContext) {
|
968
|
+
traverseContext.result = null;
|
969
|
+
traverseContext.keyPrefix = null;
|
970
|
+
traverseContext.func = null;
|
971
|
+
traverseContext.context = null;
|
972
|
+
traverseContext.count = 0;
|
973
|
+
if (traverseContextPool.length < POOL_SIZE) {
|
974
|
+
traverseContextPool.push(traverseContext);
|
975
|
+
}
|
976
|
+
}
|
977
|
+
|
978
|
+
/**
|
979
|
+
* @param {?*} children Children tree container.
|
980
|
+
* @param {!string} nameSoFar Name of the key path so far.
|
981
|
+
* @param {!function} callback Callback to invoke with each child found.
|
982
|
+
* @param {?*} traverseContext Used to pass information throughout the traversal
|
983
|
+
* process.
|
984
|
+
* @return {!number} The number of children in this subtree.
|
985
|
+
*/
|
986
|
+
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
987
|
+
var type = typeof children;
|
988
|
+
|
989
|
+
if (type === 'undefined' || type === 'boolean') {
|
990
|
+
// All of the above are perceived as null.
|
991
|
+
children = null;
|
992
|
+
}
|
993
|
+
|
994
|
+
var invokeCallback = false;
|
995
|
+
|
996
|
+
if (children === null) {
|
997
|
+
invokeCallback = true;
|
998
|
+
} else {
|
999
|
+
switch (type) {
|
1000
|
+
case 'string':
|
1001
|
+
case 'number':
|
1002
|
+
invokeCallback = true;
|
1003
|
+
break;
|
1004
|
+
case 'object':
|
1005
|
+
switch (children.$$typeof) {
|
1006
|
+
case REACT_ELEMENT_TYPE:
|
1007
|
+
case REACT_CALL_TYPE:
|
1008
|
+
case REACT_RETURN_TYPE:
|
1009
|
+
case REACT_PORTAL_TYPE:
|
1010
|
+
invokeCallback = true;
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
if (invokeCallback) {
|
1016
|
+
callback(traverseContext, children,
|
1017
|
+
// If it's the only child, treat the name as if it was wrapped in an array
|
1018
|
+
// so that it's consistent if the number of children grows.
|
1019
|
+
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
1020
|
+
return 1;
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
var child;
|
1024
|
+
var nextName;
|
1025
|
+
var subtreeCount = 0; // Count of children found in the current subtree.
|
1026
|
+
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
1027
|
+
|
1028
|
+
if (Array.isArray(children)) {
|
1029
|
+
for (var i = 0; i < children.length; i++) {
|
1030
|
+
child = children[i];
|
1031
|
+
nextName = nextNamePrefix + getComponentKey(child, i);
|
1032
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
1033
|
+
}
|
1034
|
+
} else {
|
1035
|
+
var iteratorFn = getIteratorFn(children);
|
1036
|
+
if (typeof iteratorFn === 'function') {
|
1037
|
+
{
|
1038
|
+
// Warn about using Maps as children
|
1039
|
+
if (iteratorFn === children.entries) {
|
1040
|
+
warning_1(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum());
|
1041
|
+
didWarnAboutMaps = true;
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
var iterator = iteratorFn.call(children);
|
1046
|
+
var step;
|
1047
|
+
var ii = 0;
|
1048
|
+
while (!(step = iterator.next()).done) {
|
1049
|
+
child = step.value;
|
1050
|
+
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
1051
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
1052
|
+
}
|
1053
|
+
} else if (type === 'object') {
|
1054
|
+
var addendum = '';
|
1055
|
+
{
|
1056
|
+
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
|
1057
|
+
}
|
1058
|
+
var childrenString = '' + children;
|
1059
|
+
invariant_1(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
|
1063
|
+
return subtreeCount;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* Traverses children that are typically specified as `props.children`, but
|
1068
|
+
* might also be specified through attributes:
|
1069
|
+
*
|
1070
|
+
* - `traverseAllChildren(this.props.children, ...)`
|
1071
|
+
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
|
1072
|
+
*
|
1073
|
+
* The `traverseContext` is an optional argument that is passed through the
|
1074
|
+
* entire traversal. It can be used to store accumulations or anything else that
|
1075
|
+
* the callback might find relevant.
|
1076
|
+
*
|
1077
|
+
* @param {?*} children Children tree object.
|
1078
|
+
* @param {!function} callback To invoke upon traversing each child.
|
1079
|
+
* @param {?*} traverseContext Context for traversal.
|
1080
|
+
* @return {!number} The number of children in this subtree.
|
1081
|
+
*/
|
1082
|
+
function traverseAllChildren(children, callback, traverseContext) {
|
1083
|
+
if (children == null) {
|
1084
|
+
return 0;
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
/**
|
1091
|
+
* Generate a key string that identifies a component within a set.
|
1092
|
+
*
|
1093
|
+
* @param {*} component A component that could contain a manual key.
|
1094
|
+
* @param {number} index Index that is used if a manual key is not provided.
|
1095
|
+
* @return {string}
|
1096
|
+
*/
|
1097
|
+
function getComponentKey(component, index) {
|
1098
|
+
// Do some typechecking here since we call this blindly. We want to ensure
|
1099
|
+
// that we don't block potential future ES APIs.
|
1100
|
+
if (typeof component === 'object' && component !== null && component.key != null) {
|
1101
|
+
// Explicit key
|
1102
|
+
return escape(component.key);
|
1103
|
+
}
|
1104
|
+
// Implicit key determined by the index in the set
|
1105
|
+
return index.toString(36);
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
function forEachSingleChild(bookKeeping, child, name) {
|
1109
|
+
var func = bookKeeping.func,
|
1110
|
+
context = bookKeeping.context;
|
1111
|
+
|
1112
|
+
func.call(context, child, bookKeeping.count++);
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
/**
|
1116
|
+
* Iterates through children that are typically specified as `props.children`.
|
1117
|
+
*
|
1118
|
+
* See https://reactjs.org/docs/react-api.html#react.children.foreach
|
1119
|
+
*
|
1120
|
+
* The provided forEachFunc(child, index) will be called for each
|
1121
|
+
* leaf child.
|
1122
|
+
*
|
1123
|
+
* @param {?*} children Children tree container.
|
1124
|
+
* @param {function(*, int)} forEachFunc
|
1125
|
+
* @param {*} forEachContext Context for forEachContext.
|
1126
|
+
*/
|
1127
|
+
function forEachChildren(children, forEachFunc, forEachContext) {
|
1128
|
+
if (children == null) {
|
1129
|
+
return children;
|
1130
|
+
}
|
1131
|
+
var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
|
1132
|
+
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
1133
|
+
releaseTraverseContext(traverseContext);
|
1134
|
+
}
|
1135
|
+
|
1136
|
+
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
1137
|
+
var result = bookKeeping.result,
|
1138
|
+
keyPrefix = bookKeeping.keyPrefix,
|
1139
|
+
func = bookKeeping.func,
|
1140
|
+
context = bookKeeping.context;
|
1141
|
+
|
1142
|
+
|
1143
|
+
var mappedChild = func.call(context, child, bookKeeping.count++);
|
1144
|
+
if (Array.isArray(mappedChild)) {
|
1145
|
+
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction_1.thatReturnsArgument);
|
1146
|
+
} else if (mappedChild != null) {
|
1147
|
+
if (isValidElement(mappedChild)) {
|
1148
|
+
mappedChild = cloneAndReplaceKey(mappedChild,
|
1149
|
+
// Keep both the (mapped) and old keys if they differ, just as
|
1150
|
+
// traverseAllChildren used to do for objects as children
|
1151
|
+
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
1152
|
+
}
|
1153
|
+
result.push(mappedChild);
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
1158
|
+
var escapedPrefix = '';
|
1159
|
+
if (prefix != null) {
|
1160
|
+
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
1161
|
+
}
|
1162
|
+
var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
|
1163
|
+
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
1164
|
+
releaseTraverseContext(traverseContext);
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
/**
|
1168
|
+
* Maps children that are typically specified as `props.children`.
|
1169
|
+
*
|
1170
|
+
* See https://reactjs.org/docs/react-api.html#react.children.map
|
1171
|
+
*
|
1172
|
+
* The provided mapFunction(child, key, index) will be called for each
|
1173
|
+
* leaf child.
|
1174
|
+
*
|
1175
|
+
* @param {?*} children Children tree container.
|
1176
|
+
* @param {function(*, int)} func The map function.
|
1177
|
+
* @param {*} context Context for mapFunction.
|
1178
|
+
* @return {object} Object containing the ordered map of results.
|
1179
|
+
*/
|
1180
|
+
function mapChildren(children, func, context) {
|
1181
|
+
if (children == null) {
|
1182
|
+
return children;
|
1183
|
+
}
|
1184
|
+
var result = [];
|
1185
|
+
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
1186
|
+
return result;
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
/**
|
1190
|
+
* Count the number of children that are typically specified as
|
1191
|
+
* `props.children`.
|
1192
|
+
*
|
1193
|
+
* See https://reactjs.org/docs/react-api.html#react.children.count
|
1194
|
+
*
|
1195
|
+
* @param {?*} children Children tree container.
|
1196
|
+
* @return {number} The number of children.
|
1197
|
+
*/
|
1198
|
+
function countChildren(children, context) {
|
1199
|
+
return traverseAllChildren(children, emptyFunction_1.thatReturnsNull, null);
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
/**
|
1203
|
+
* Flatten a children object (typically specified as `props.children`) and
|
1204
|
+
* return an array with appropriately re-keyed children.
|
1205
|
+
*
|
1206
|
+
* See https://reactjs.org/docs/react-api.html#react.children.toarray
|
1207
|
+
*/
|
1208
|
+
function toArray(children) {
|
1209
|
+
var result = [];
|
1210
|
+
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction_1.thatReturnsArgument);
|
1211
|
+
return result;
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
/**
|
1215
|
+
* Returns the first child in a collection of children and verifies that there
|
1216
|
+
* is only one child in the collection.
|
1217
|
+
*
|
1218
|
+
* See https://reactjs.org/docs/react-api.html#react.children.only
|
1219
|
+
*
|
1220
|
+
* The current implementation of this function assumes that a single child gets
|
1221
|
+
* passed without a wrapper, but the purpose of this helper function is to
|
1222
|
+
* abstract away the particular structure of children.
|
1223
|
+
*
|
1224
|
+
* @param {?object} children Child collection structure.
|
1225
|
+
* @return {ReactElement} The first and only `ReactElement` contained in the
|
1226
|
+
* structure.
|
1227
|
+
*/
|
1228
|
+
function onlyChild(children) {
|
1229
|
+
!isValidElement(children) ? invariant_1(false, 'React.Children.only expected to receive a single React element child.') : void 0;
|
1230
|
+
return children;
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
var describeComponentFrame = function (name, source, ownerName) {
|
1234
|
+
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
1235
|
+
};
|
1236
|
+
|
1237
|
+
function getComponentName(fiber) {
|
1238
|
+
var type = fiber.type;
|
1239
|
+
|
1240
|
+
if (typeof type === 'string') {
|
1241
|
+
return type;
|
1242
|
+
}
|
1243
|
+
if (typeof type === 'function') {
|
1244
|
+
return type.displayName || type.name;
|
1245
|
+
}
|
1246
|
+
return null;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
/**
|
1250
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
1251
|
+
*
|
1252
|
+
* This source code is licensed under the MIT license found in the
|
1253
|
+
* LICENSE file in the root directory of this source tree.
|
1254
|
+
*/
|
1255
|
+
|
1256
|
+
|
1257
|
+
|
1258
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
1259
|
+
|
1260
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
1261
|
+
|
1262
|
+
/**
|
1263
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
1264
|
+
*
|
1265
|
+
* This source code is licensed under the MIT license found in the
|
1266
|
+
* LICENSE file in the root directory of this source tree.
|
1267
|
+
*/
|
1268
|
+
|
1269
|
+
|
1270
|
+
|
1271
|
+
{
|
1272
|
+
var invariant$2 = invariant_1;
|
1273
|
+
var warning$2 = warning_1;
|
1274
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
1275
|
+
var loggedTypeFailures = {};
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
/**
|
1279
|
+
* Assert that the values match with the type specs.
|
1280
|
+
* Error messages are memorized and will only be shown once.
|
1281
|
+
*
|
1282
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
1283
|
+
* @param {object} values Runtime values that need to be type-checked
|
1284
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
1285
|
+
* @param {string} componentName Name of the component for error messages.
|
1286
|
+
* @param {?Function} getStack Returns the component stack.
|
1287
|
+
* @private
|
1288
|
+
*/
|
1289
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
1290
|
+
{
|
1291
|
+
for (var typeSpecName in typeSpecs) {
|
1292
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
1293
|
+
var error;
|
1294
|
+
// Prop type validation may throw. In case they do, we don't want to
|
1295
|
+
// fail the render phase where it didn't fail before. So we log it.
|
1296
|
+
// After these have been cleaned up, we'll let them throw.
|
1297
|
+
try {
|
1298
|
+
// This is intentionally an invariant that gets caught. It's the same
|
1299
|
+
// behavior as without this statement except with a better message.
|
1300
|
+
invariant$2(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
1301
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
1302
|
+
} catch (ex) {
|
1303
|
+
error = ex;
|
1304
|
+
}
|
1305
|
+
warning$2(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
1306
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
1307
|
+
// Only monitor this failure once because there tends to be a lot of the
|
1308
|
+
// same error.
|
1309
|
+
loggedTypeFailures[error.message] = true;
|
1310
|
+
|
1311
|
+
var stack = getStack ? getStack() : '';
|
1312
|
+
|
1313
|
+
warning$2(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
1314
|
+
}
|
1315
|
+
}
|
1316
|
+
}
|
1317
|
+
}
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
var checkPropTypes_1 = checkPropTypes;
|
1321
|
+
|
1322
|
+
/**
|
1323
|
+
* ReactElementValidator provides a wrapper around a element factory
|
1324
|
+
* which validates the props passed to the element. This is intended to be
|
1325
|
+
* used only in DEV and could be replaced by a static type checker for languages
|
1326
|
+
* that support it.
|
1327
|
+
*/
|
1328
|
+
|
1329
|
+
{
|
1330
|
+
var currentlyValidatingElement = null;
|
1331
|
+
|
1332
|
+
var propTypesMisspellWarningShown = false;
|
1333
|
+
|
1334
|
+
var getDisplayName = function (element) {
|
1335
|
+
if (element == null) {
|
1336
|
+
return '#empty';
|
1337
|
+
} else if (typeof element === 'string' || typeof element === 'number') {
|
1338
|
+
return '#text';
|
1339
|
+
} else if (typeof element.type === 'string') {
|
1340
|
+
return element.type;
|
1341
|
+
} else if (element.type === REACT_FRAGMENT_TYPE) {
|
1342
|
+
return 'React.Fragment';
|
1343
|
+
} else {
|
1344
|
+
return element.type.displayName || element.type.name || 'Unknown';
|
1345
|
+
}
|
1346
|
+
};
|
1347
|
+
|
1348
|
+
var getStackAddendum = function () {
|
1349
|
+
var stack = '';
|
1350
|
+
if (currentlyValidatingElement) {
|
1351
|
+
var name = getDisplayName(currentlyValidatingElement);
|
1352
|
+
var owner = currentlyValidatingElement._owner;
|
1353
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
1354
|
+
}
|
1355
|
+
stack += ReactDebugCurrentFrame.getStackAddendum() || '';
|
1356
|
+
return stack;
|
1357
|
+
};
|
1358
|
+
|
1359
|
+
var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
function getDeclarationErrorAddendum() {
|
1363
|
+
if (ReactCurrentOwner.current) {
|
1364
|
+
var name = getComponentName(ReactCurrentOwner.current);
|
1365
|
+
if (name) {
|
1366
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
return '';
|
1370
|
+
}
|
1371
|
+
|
1372
|
+
function getSourceInfoErrorAddendum(elementProps) {
|
1373
|
+
if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
|
1374
|
+
var source = elementProps.__source;
|
1375
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
1376
|
+
var lineNumber = source.lineNumber;
|
1377
|
+
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
1378
|
+
}
|
1379
|
+
return '';
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
1384
|
+
* object keys are not valid. This allows us to keep track of children between
|
1385
|
+
* updates.
|
1386
|
+
*/
|
1387
|
+
var ownerHasKeyUseWarning = {};
|
1388
|
+
|
1389
|
+
function getCurrentComponentErrorInfo(parentType) {
|
1390
|
+
var info = getDeclarationErrorAddendum();
|
1391
|
+
|
1392
|
+
if (!info) {
|
1393
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
1394
|
+
if (parentName) {
|
1395
|
+
info = '\n\nCheck the top-level render call using <' + parentName + '>.';
|
1396
|
+
}
|
1397
|
+
}
|
1398
|
+
return info;
|
1399
|
+
}
|
1400
|
+
|
1401
|
+
/**
|
1402
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
1403
|
+
* This element is in an array. The array could grow and shrink or be
|
1404
|
+
* reordered. All children that haven't already been validated are required to
|
1405
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
1406
|
+
* will only be shown once.
|
1407
|
+
*
|
1408
|
+
* @internal
|
1409
|
+
* @param {ReactElement} element Element that requires a key.
|
1410
|
+
* @param {*} parentType element's parent's type.
|
1411
|
+
*/
|
1412
|
+
function validateExplicitKey(element, parentType) {
|
1413
|
+
if (!element._store || element._store.validated || element.key != null) {
|
1414
|
+
return;
|
1415
|
+
}
|
1416
|
+
element._store.validated = true;
|
1417
|
+
|
1418
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
1419
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
1420
|
+
return;
|
1421
|
+
}
|
1422
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
1423
|
+
|
1424
|
+
// Usually the current owner is the offender, but if it accepts children as a
|
1425
|
+
// property, it may be the creator of the child that's responsible for
|
1426
|
+
// assigning it a key.
|
1427
|
+
var childOwner = '';
|
1428
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
1429
|
+
// Give the component that originally created this child.
|
1430
|
+
childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
|
1431
|
+
}
|
1432
|
+
|
1433
|
+
currentlyValidatingElement = element;
|
1434
|
+
{
|
1435
|
+
warning_1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum());
|
1436
|
+
}
|
1437
|
+
currentlyValidatingElement = null;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
/**
|
1441
|
+
* Ensure that every element either is passed in a static location, in an
|
1442
|
+
* array with an explicit keys property defined, or in an object literal
|
1443
|
+
* with valid key property.
|
1444
|
+
*
|
1445
|
+
* @internal
|
1446
|
+
* @param {ReactNode} node Statically passed child of any type.
|
1447
|
+
* @param {*} parentType node's parent's type.
|
1448
|
+
*/
|
1449
|
+
function validateChildKeys(node, parentType) {
|
1450
|
+
if (typeof node !== 'object') {
|
1451
|
+
return;
|
1452
|
+
}
|
1453
|
+
if (Array.isArray(node)) {
|
1454
|
+
for (var i = 0; i < node.length; i++) {
|
1455
|
+
var child = node[i];
|
1456
|
+
if (isValidElement(child)) {
|
1457
|
+
validateExplicitKey(child, parentType);
|
1458
|
+
}
|
1459
|
+
}
|
1460
|
+
} else if (isValidElement(node)) {
|
1461
|
+
// This element was passed in a valid location.
|
1462
|
+
if (node._store) {
|
1463
|
+
node._store.validated = true;
|
1464
|
+
}
|
1465
|
+
} else if (node) {
|
1466
|
+
var iteratorFn = getIteratorFn(node);
|
1467
|
+
if (typeof iteratorFn === 'function') {
|
1468
|
+
// Entry iterators used to provide implicit keys,
|
1469
|
+
// but now we print a separate warning for them later.
|
1470
|
+
if (iteratorFn !== node.entries) {
|
1471
|
+
var iterator = iteratorFn.call(node);
|
1472
|
+
var step;
|
1473
|
+
while (!(step = iterator.next()).done) {
|
1474
|
+
if (isValidElement(step.value)) {
|
1475
|
+
validateExplicitKey(step.value, parentType);
|
1476
|
+
}
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
}
|
1480
|
+
}
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
/**
|
1484
|
+
* Given an element, validate that its props follow the propTypes definition,
|
1485
|
+
* provided by the type.
|
1486
|
+
*
|
1487
|
+
* @param {ReactElement} element
|
1488
|
+
*/
|
1489
|
+
function validatePropTypes(element) {
|
1490
|
+
var componentClass = element.type;
|
1491
|
+
if (typeof componentClass !== 'function') {
|
1492
|
+
return;
|
1493
|
+
}
|
1494
|
+
var name = componentClass.displayName || componentClass.name;
|
1495
|
+
var propTypes = componentClass.propTypes;
|
1496
|
+
if (propTypes) {
|
1497
|
+
currentlyValidatingElement = element;
|
1498
|
+
checkPropTypes_1(propTypes, element.props, 'prop', name, getStackAddendum);
|
1499
|
+
currentlyValidatingElement = null;
|
1500
|
+
} else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
1501
|
+
propTypesMisspellWarningShown = true;
|
1502
|
+
warning_1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
1503
|
+
}
|
1504
|
+
if (typeof componentClass.getDefaultProps === 'function') {
|
1505
|
+
warning_1(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
/**
|
1510
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
1511
|
+
* @param {ReactElement} fragment
|
1512
|
+
*/
|
1513
|
+
function validateFragmentProps(fragment) {
|
1514
|
+
currentlyValidatingElement = fragment;
|
1515
|
+
|
1516
|
+
var _iteratorNormalCompletion = true;
|
1517
|
+
var _didIteratorError = false;
|
1518
|
+
var _iteratorError = undefined;
|
1519
|
+
|
1520
|
+
try {
|
1521
|
+
for (var _iterator = Object.keys(fragment.props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
1522
|
+
var key = _step.value;
|
1523
|
+
|
1524
|
+
if (!VALID_FRAGMENT_PROPS.has(key)) {
|
1525
|
+
warning_1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
1526
|
+
break;
|
1527
|
+
}
|
1528
|
+
}
|
1529
|
+
} catch (err) {
|
1530
|
+
_didIteratorError = true;
|
1531
|
+
_iteratorError = err;
|
1532
|
+
} finally {
|
1533
|
+
try {
|
1534
|
+
if (!_iteratorNormalCompletion && _iterator['return']) {
|
1535
|
+
_iterator['return']();
|
1536
|
+
}
|
1537
|
+
} finally {
|
1538
|
+
if (_didIteratorError) {
|
1539
|
+
throw _iteratorError;
|
1540
|
+
}
|
1541
|
+
}
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
if (fragment.ref !== null) {
|
1545
|
+
warning_1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
currentlyValidatingElement = null;
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
function createElementWithValidation(type, props, children) {
|
1552
|
+
var validType = typeof type === 'string' || typeof type === 'function' || typeof type === 'symbol' || typeof type === 'number';
|
1553
|
+
// We warn in this case but don't throw. We expect the element creation to
|
1554
|
+
// succeed and there will likely be errors in render.
|
1555
|
+
if (!validType) {
|
1556
|
+
var info = '';
|
1557
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
1558
|
+
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.";
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
var sourceInfo = getSourceInfoErrorAddendum(props);
|
1562
|
+
if (sourceInfo) {
|
1563
|
+
info += sourceInfo;
|
1564
|
+
} else {
|
1565
|
+
info += getDeclarationErrorAddendum();
|
1566
|
+
}
|
1567
|
+
|
1568
|
+
info += getStackAddendum() || '';
|
1569
|
+
|
1570
|
+
warning_1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info);
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
var element = createElement.apply(this, arguments);
|
1574
|
+
|
1575
|
+
// The result can be nullish if a mock or a custom function is used.
|
1576
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
1577
|
+
if (element == null) {
|
1578
|
+
return element;
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
// Skip key warning if the type isn't valid since our key validation logic
|
1582
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
1583
|
+
// We don't want exception behavior to differ between dev and prod.
|
1584
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
1585
|
+
// fixed, the key warnings will appear.)
|
1586
|
+
if (validType) {
|
1587
|
+
for (var i = 2; i < arguments.length; i++) {
|
1588
|
+
validateChildKeys(arguments[i], type);
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
if (typeof type === 'symbol' && type === REACT_FRAGMENT_TYPE) {
|
1593
|
+
validateFragmentProps(element);
|
1594
|
+
} else {
|
1595
|
+
validatePropTypes(element);
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
return element;
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
function createFactoryWithValidation(type) {
|
1602
|
+
var validatedFactory = createElementWithValidation.bind(null, type);
|
1603
|
+
// Legacy hook TODO: Warn if this is accessed
|
1604
|
+
validatedFactory.type = type;
|
1605
|
+
|
1606
|
+
{
|
1607
|
+
Object.defineProperty(validatedFactory, 'type', {
|
1608
|
+
enumerable: false,
|
1609
|
+
get: function () {
|
1610
|
+
lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
|
1611
|
+
Object.defineProperty(this, 'type', {
|
1612
|
+
value: type
|
1613
|
+
});
|
1614
|
+
return type;
|
1615
|
+
}
|
1616
|
+
});
|
1617
|
+
}
|
1618
|
+
|
1619
|
+
return validatedFactory;
|
1620
|
+
}
|
1621
|
+
|
1622
|
+
function cloneElementWithValidation(element, props, children) {
|
1623
|
+
var newElement = cloneElement.apply(this, arguments);
|
1624
|
+
for (var i = 2; i < arguments.length; i++) {
|
1625
|
+
validateChildKeys(arguments[i], newElement.type);
|
1626
|
+
}
|
1627
|
+
validatePropTypes(newElement);
|
1628
|
+
return newElement;
|
1629
|
+
}
|
1630
|
+
|
1631
|
+
var React = {
|
1632
|
+
Children: {
|
1633
|
+
map: mapChildren,
|
1634
|
+
forEach: forEachChildren,
|
1635
|
+
count: countChildren,
|
1636
|
+
toArray: toArray,
|
1637
|
+
only: onlyChild
|
1638
|
+
},
|
1639
|
+
|
1640
|
+
Component: Component,
|
1641
|
+
PureComponent: PureComponent,
|
1642
|
+
unstable_AsyncComponent: AsyncComponent,
|
1643
|
+
|
1644
|
+
Fragment: REACT_FRAGMENT_TYPE,
|
1645
|
+
|
1646
|
+
createElement: createElementWithValidation,
|
1647
|
+
cloneElement: cloneElementWithValidation,
|
1648
|
+
createFactory: createFactoryWithValidation,
|
1649
|
+
isValidElement: isValidElement,
|
1650
|
+
|
1651
|
+
version: ReactVersion,
|
1652
|
+
|
1653
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
1654
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
1655
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
1656
|
+
assign: objectAssign
|
1657
|
+
}
|
1658
|
+
};
|
1659
|
+
|
1660
|
+
{
|
1661
|
+
objectAssign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
1662
|
+
// These should not be included in production.
|
1663
|
+
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
1664
|
+
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
1665
|
+
// TODO: remove in React 17.0.
|
1666
|
+
ReactComponentTreeHook: {}
|
1667
|
+
});
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
|
1671
|
+
|
1672
|
+
var React$2 = Object.freeze({
|
1673
|
+
default: React
|
1674
|
+
});
|
1675
|
+
|
1676
|
+
var React$3 = ( React$2 && React ) || React$2;
|
1677
|
+
|
1678
|
+
// TODO: decide on the top-level export form.
|
1679
|
+
// This is hacky but makes it work with both Rollup and Jest.
|
1680
|
+
var react = React$3['default'] ? React$3['default'] : React$3;
|
1681
|
+
|
1682
|
+
return react;
|
1683
|
+
|
1684
|
+
})));
|