1 | /** @license React v16.14.0
|
---|
2 | * react-jsx-dev-runtime.development.js
|
---|
3 | *
|
---|
4 | * Copyright (c) Facebook, Inc. and its affiliates.
|
---|
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 | if (process.env.NODE_ENV !== "production") {
|
---|
13 | (function() {
|
---|
14 | 'use strict';
|
---|
15 |
|
---|
16 | var React = require('react');
|
---|
17 |
|
---|
18 | // ATTENTION
|
---|
19 | // When adding new symbols to this file,
|
---|
20 | // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
---|
21 | // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
---|
22 | // nor polyfill, then a plain number is used for performance.
|
---|
23 | var REACT_ELEMENT_TYPE = 0xeac7;
|
---|
24 | var REACT_PORTAL_TYPE = 0xeaca;
|
---|
25 | exports.Fragment = 0xeacb;
|
---|
26 | var REACT_STRICT_MODE_TYPE = 0xeacc;
|
---|
27 | var REACT_PROFILER_TYPE = 0xead2;
|
---|
28 | var REACT_PROVIDER_TYPE = 0xeacd;
|
---|
29 | var REACT_CONTEXT_TYPE = 0xeace;
|
---|
30 | var REACT_FORWARD_REF_TYPE = 0xead0;
|
---|
31 | var REACT_SUSPENSE_TYPE = 0xead1;
|
---|
32 | var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
---|
33 | var REACT_MEMO_TYPE = 0xead3;
|
---|
34 | var REACT_LAZY_TYPE = 0xead4;
|
---|
35 | var REACT_BLOCK_TYPE = 0xead9;
|
---|
36 | var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
---|
37 | var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
---|
38 | var REACT_SCOPE_TYPE = 0xead7;
|
---|
39 | var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
---|
40 | var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
---|
41 | var REACT_OFFSCREEN_TYPE = 0xeae2;
|
---|
42 | var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
---|
43 |
|
---|
44 | if (typeof Symbol === 'function' && Symbol.for) {
|
---|
45 | var symbolFor = Symbol.for;
|
---|
46 | REACT_ELEMENT_TYPE = symbolFor('react.element');
|
---|
47 | REACT_PORTAL_TYPE = symbolFor('react.portal');
|
---|
48 | exports.Fragment = symbolFor('react.fragment');
|
---|
49 | REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
---|
50 | REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
---|
51 | REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
---|
52 | REACT_CONTEXT_TYPE = symbolFor('react.context');
|
---|
53 | REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
---|
54 | REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
---|
55 | REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
---|
56 | REACT_MEMO_TYPE = symbolFor('react.memo');
|
---|
57 | REACT_LAZY_TYPE = symbolFor('react.lazy');
|
---|
58 | REACT_BLOCK_TYPE = symbolFor('react.block');
|
---|
59 | REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
---|
60 | REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
---|
61 | REACT_SCOPE_TYPE = symbolFor('react.scope');
|
---|
62 | REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
---|
63 | REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
---|
64 | REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
---|
65 | REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
---|
66 | }
|
---|
67 |
|
---|
68 | var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
---|
69 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
---|
70 | function getIteratorFn(maybeIterable) {
|
---|
71 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
---|
72 | return null;
|
---|
73 | }
|
---|
74 |
|
---|
75 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
---|
76 |
|
---|
77 | if (typeof maybeIterator === 'function') {
|
---|
78 | return maybeIterator;
|
---|
79 | }
|
---|
80 |
|
---|
81 | return null;
|
---|
82 | }
|
---|
83 |
|
---|
84 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
---|
85 |
|
---|
86 | function error(format) {
|
---|
87 | {
|
---|
88 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
---|
89 | args[_key2 - 1] = arguments[_key2];
|
---|
90 | }
|
---|
91 |
|
---|
92 | printWarning('error', format, args);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | function printWarning(level, format, args) {
|
---|
97 | // When changing this logic, you might want to also
|
---|
98 | // update consoleWithStackDev.www.js as well.
|
---|
99 | {
|
---|
100 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
---|
101 | var stack = '';
|
---|
102 |
|
---|
103 | if (currentlyValidatingElement) {
|
---|
104 | var name = getComponentName(currentlyValidatingElement.type);
|
---|
105 | var owner = currentlyValidatingElement._owner;
|
---|
106 | stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
---|
107 | }
|
---|
108 |
|
---|
109 | stack += ReactDebugCurrentFrame.getStackAddendum();
|
---|
110 |
|
---|
111 |
|
---|
112 | if (stack !== '') {
|
---|
113 | format += '%s';
|
---|
114 | args = args.concat([stack]);
|
---|
115 | }
|
---|
116 |
|
---|
117 | var argsWithFormat = args.map(function (item) {
|
---|
118 | return '' + item;
|
---|
119 | }); // Careful: RN currently depends on this prefix
|
---|
120 |
|
---|
121 | argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
---|
122 | // breaks IE9: https://github.com/facebook/react/issues/13610
|
---|
123 | // eslint-disable-next-line react-internal/no-production-logging
|
---|
124 |
|
---|
125 | Function.prototype.apply.call(console[level], console, argsWithFormat);
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
---|
130 |
|
---|
131 | var enableScopeAPI = false; // Experimental Create Event Handle API.
|
---|
132 |
|
---|
133 | function isValidElementType(type) {
|
---|
134 | if (typeof type === 'string' || typeof type === 'function') {
|
---|
135 | return true;
|
---|
136 | } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
---|
137 |
|
---|
138 |
|
---|
139 | if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
---|
140 | return true;
|
---|
141 | }
|
---|
142 |
|
---|
143 | if (typeof type === 'object' && type !== null) {
|
---|
144 | 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) {
|
---|
145 | return true;
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 | return false;
|
---|
150 | }
|
---|
151 | var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
---|
152 | function describeComponentFrame (name, source, ownerName) {
|
---|
153 | var sourceInfo = '';
|
---|
154 |
|
---|
155 | if (source) {
|
---|
156 | var path = source.fileName;
|
---|
157 | var fileName = path.replace(BEFORE_SLASH_RE, '');
|
---|
158 |
|
---|
159 | {
|
---|
160 | // In DEV, include code for a common special case:
|
---|
161 | // prefer "folder/index.js" instead of just "index.js".
|
---|
162 | if (/^index\./.test(fileName)) {
|
---|
163 | var match = path.match(BEFORE_SLASH_RE);
|
---|
164 |
|
---|
165 | if (match) {
|
---|
166 | var pathBeforeSlash = match[1];
|
---|
167 |
|
---|
168 | if (pathBeforeSlash) {
|
---|
169 | var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
---|
170 | fileName = folderName + '/' + fileName;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 | sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
---|
177 | } else if (ownerName) {
|
---|
178 | sourceInfo = ' (created by ' + ownerName + ')';
|
---|
179 | }
|
---|
180 |
|
---|
181 | return '\n in ' + (name || 'Unknown') + sourceInfo;
|
---|
182 | }
|
---|
183 |
|
---|
184 | var Resolved = 1;
|
---|
185 | function refineResolvedLazyComponent(lazyComponent) {
|
---|
186 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
---|
187 | }
|
---|
188 |
|
---|
189 | function getWrappedName(outerType, innerType, wrapperName) {
|
---|
190 | var functionName = innerType.displayName || innerType.name || '';
|
---|
191 | return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
---|
192 | }
|
---|
193 |
|
---|
194 | function getComponentName(type) {
|
---|
195 | if (type == null) {
|
---|
196 | // Host root, text node or just invalid type.
|
---|
197 | return null;
|
---|
198 | }
|
---|
199 |
|
---|
200 | {
|
---|
201 | if (typeof type.tag === 'number') {
|
---|
202 | error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | if (typeof type === 'function') {
|
---|
207 | return type.displayName || type.name || null;
|
---|
208 | }
|
---|
209 |
|
---|
210 | if (typeof type === 'string') {
|
---|
211 | return type;
|
---|
212 | }
|
---|
213 |
|
---|
214 | switch (type) {
|
---|
215 | case exports.Fragment:
|
---|
216 | return 'Fragment';
|
---|
217 |
|
---|
218 | case REACT_PORTAL_TYPE:
|
---|
219 | return 'Portal';
|
---|
220 |
|
---|
221 | case REACT_PROFILER_TYPE:
|
---|
222 | return "Profiler";
|
---|
223 |
|
---|
224 | case REACT_STRICT_MODE_TYPE:
|
---|
225 | return 'StrictMode';
|
---|
226 |
|
---|
227 | case REACT_SUSPENSE_TYPE:
|
---|
228 | return 'Suspense';
|
---|
229 |
|
---|
230 | case REACT_SUSPENSE_LIST_TYPE:
|
---|
231 | return 'SuspenseList';
|
---|
232 | }
|
---|
233 |
|
---|
234 | if (typeof type === 'object') {
|
---|
235 | switch (type.$$typeof) {
|
---|
236 | case REACT_CONTEXT_TYPE:
|
---|
237 | return 'Context.Consumer';
|
---|
238 |
|
---|
239 | case REACT_PROVIDER_TYPE:
|
---|
240 | return 'Context.Provider';
|
---|
241 |
|
---|
242 | case REACT_FORWARD_REF_TYPE:
|
---|
243 | return getWrappedName(type, type.render, 'ForwardRef');
|
---|
244 |
|
---|
245 | case REACT_MEMO_TYPE:
|
---|
246 | return getComponentName(type.type);
|
---|
247 |
|
---|
248 | case REACT_BLOCK_TYPE:
|
---|
249 | return getComponentName(type.render);
|
---|
250 |
|
---|
251 | case REACT_LAZY_TYPE:
|
---|
252 | {
|
---|
253 | var thenable = type;
|
---|
254 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
---|
255 |
|
---|
256 | if (resolvedThenable) {
|
---|
257 | return getComponentName(resolvedThenable);
|
---|
258 | }
|
---|
259 |
|
---|
260 | break;
|
---|
261 | }
|
---|
262 | }
|
---|
263 | }
|
---|
264 |
|
---|
265 | return null;
|
---|
266 | }
|
---|
267 | var loggedTypeFailures = {};
|
---|
268 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
---|
269 | var currentlyValidatingElement = null;
|
---|
270 |
|
---|
271 | function setCurrentlyValidatingElement(element) {
|
---|
272 | currentlyValidatingElement = element;
|
---|
273 | }
|
---|
274 |
|
---|
275 | function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
---|
276 | {
|
---|
277 | // $FlowFixMe This is okay but Flow doesn't know it.
|
---|
278 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
---|
279 |
|
---|
280 | for (var typeSpecName in typeSpecs) {
|
---|
281 | if (has(typeSpecs, typeSpecName)) {
|
---|
282 | var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
---|
283 | // fail the render phase where it didn't fail before. So we log it.
|
---|
284 | // After these have been cleaned up, we'll let them throw.
|
---|
285 |
|
---|
286 | try {
|
---|
287 | // This is intentionally an invariant that gets caught. It's the same
|
---|
288 | // behavior as without this statement except with a better message.
|
---|
289 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
---|
290 | 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`.');
|
---|
291 | err.name = 'Invariant Violation';
|
---|
292 | throw err;
|
---|
293 | }
|
---|
294 |
|
---|
295 | error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
---|
296 | } catch (ex) {
|
---|
297 | error$1 = ex;
|
---|
298 | }
|
---|
299 |
|
---|
300 | if (error$1 && !(error$1 instanceof Error)) {
|
---|
301 | setCurrentlyValidatingElement(element);
|
---|
302 |
|
---|
303 | 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);
|
---|
304 |
|
---|
305 | setCurrentlyValidatingElement(null);
|
---|
306 | }
|
---|
307 |
|
---|
308 | if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
---|
309 | // Only monitor this failure once because there tends to be a lot of the
|
---|
310 | // same error.
|
---|
311 | loggedTypeFailures[error$1.message] = true;
|
---|
312 | setCurrentlyValidatingElement(element);
|
---|
313 |
|
---|
314 | error('Failed %s type: %s', location, error$1.message);
|
---|
315 |
|
---|
316 | setCurrentlyValidatingElement(null);
|
---|
317 | }
|
---|
318 | }
|
---|
319 | }
|
---|
320 | }
|
---|
321 | }
|
---|
322 |
|
---|
323 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
---|
324 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
---|
325 | var RESERVED_PROPS = {
|
---|
326 | key: true,
|
---|
327 | ref: true,
|
---|
328 | __self: true,
|
---|
329 | __source: true
|
---|
330 | };
|
---|
331 | var specialPropKeyWarningShown;
|
---|
332 | var specialPropRefWarningShown;
|
---|
333 | var didWarnAboutStringRefs;
|
---|
334 |
|
---|
335 | {
|
---|
336 | didWarnAboutStringRefs = {};
|
---|
337 | }
|
---|
338 |
|
---|
339 | function hasValidRef(config) {
|
---|
340 | {
|
---|
341 | if (hasOwnProperty.call(config, 'ref')) {
|
---|
342 | var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
---|
343 |
|
---|
344 | if (getter && getter.isReactWarning) {
|
---|
345 | return false;
|
---|
346 | }
|
---|
347 | }
|
---|
348 | }
|
---|
349 |
|
---|
350 | return config.ref !== undefined;
|
---|
351 | }
|
---|
352 |
|
---|
353 | function hasValidKey(config) {
|
---|
354 | {
|
---|
355 | if (hasOwnProperty.call(config, 'key')) {
|
---|
356 | var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
---|
357 |
|
---|
358 | if (getter && getter.isReactWarning) {
|
---|
359 | return false;
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | return config.key !== undefined;
|
---|
365 | }
|
---|
366 |
|
---|
367 | function warnIfStringRefCannotBeAutoConverted(config, self) {
|
---|
368 | {
|
---|
369 | if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
---|
370 | var componentName = getComponentName(ReactCurrentOwner.current.type);
|
---|
371 |
|
---|
372 | if (!didWarnAboutStringRefs[componentName]) {
|
---|
373 | 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', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
---|
374 |
|
---|
375 | didWarnAboutStringRefs[componentName] = true;
|
---|
376 | }
|
---|
377 | }
|
---|
378 | }
|
---|
379 | }
|
---|
380 |
|
---|
381 | function defineKeyPropWarningGetter(props, displayName) {
|
---|
382 | {
|
---|
383 | var warnAboutAccessingKey = function () {
|
---|
384 | if (!specialPropKeyWarningShown) {
|
---|
385 | specialPropKeyWarningShown = true;
|
---|
386 |
|
---|
387 | 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);
|
---|
388 | }
|
---|
389 | };
|
---|
390 |
|
---|
391 | warnAboutAccessingKey.isReactWarning = true;
|
---|
392 | Object.defineProperty(props, 'key', {
|
---|
393 | get: warnAboutAccessingKey,
|
---|
394 | configurable: true
|
---|
395 | });
|
---|
396 | }
|
---|
397 | }
|
---|
398 |
|
---|
399 | function defineRefPropWarningGetter(props, displayName) {
|
---|
400 | {
|
---|
401 | var warnAboutAccessingRef = function () {
|
---|
402 | if (!specialPropRefWarningShown) {
|
---|
403 | specialPropRefWarningShown = true;
|
---|
404 |
|
---|
405 | 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);
|
---|
406 | }
|
---|
407 | };
|
---|
408 |
|
---|
409 | warnAboutAccessingRef.isReactWarning = true;
|
---|
410 | Object.defineProperty(props, 'ref', {
|
---|
411 | get: warnAboutAccessingRef,
|
---|
412 | configurable: true
|
---|
413 | });
|
---|
414 | }
|
---|
415 | }
|
---|
416 | /**
|
---|
417 | * Factory method to create a new React element. This no longer adheres to
|
---|
418 | * the class pattern, so do not use new to call it. Also, instanceof check
|
---|
419 | * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
---|
420 | * if something is a React Element.
|
---|
421 | *
|
---|
422 | * @param {*} type
|
---|
423 | * @param {*} props
|
---|
424 | * @param {*} key
|
---|
425 | * @param {string|object} ref
|
---|
426 | * @param {*} owner
|
---|
427 | * @param {*} self A *temporary* helper to detect places where `this` is
|
---|
428 | * different from the `owner` when React.createElement is called, so that we
|
---|
429 | * can warn. We want to get rid of owner and replace string `ref`s with arrow
|
---|
430 | * functions, and as long as `this` and owner are the same, there will be no
|
---|
431 | * change in behavior.
|
---|
432 | * @param {*} source An annotation object (added by a transpiler or otherwise)
|
---|
433 | * indicating filename, line number, and/or other information.
|
---|
434 | * @internal
|
---|
435 | */
|
---|
436 |
|
---|
437 |
|
---|
438 | var ReactElement = function (type, key, ref, self, source, owner, props) {
|
---|
439 | var element = {
|
---|
440 | // This tag allows us to uniquely identify this as a React Element
|
---|
441 | $$typeof: REACT_ELEMENT_TYPE,
|
---|
442 | // Built-in properties that belong on the element
|
---|
443 | type: type,
|
---|
444 | key: key,
|
---|
445 | ref: ref,
|
---|
446 | props: props,
|
---|
447 | // Record the component responsible for creating this element.
|
---|
448 | _owner: owner
|
---|
449 | };
|
---|
450 |
|
---|
451 | {
|
---|
452 | // The validation flag is currently mutative. We put it on
|
---|
453 | // an external backing store so that we can freeze the whole object.
|
---|
454 | // This can be replaced with a WeakMap once they are implemented in
|
---|
455 | // commonly used development environments.
|
---|
456 | element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
---|
457 | // the validation flag non-enumerable (where possible, which should
|
---|
458 | // include every environment we run tests in), so the test framework
|
---|
459 | // ignores it.
|
---|
460 |
|
---|
461 | Object.defineProperty(element._store, 'validated', {
|
---|
462 | configurable: false,
|
---|
463 | enumerable: false,
|
---|
464 | writable: true,
|
---|
465 | value: false
|
---|
466 | }); // self and source are DEV only properties.
|
---|
467 |
|
---|
468 | Object.defineProperty(element, '_self', {
|
---|
469 | configurable: false,
|
---|
470 | enumerable: false,
|
---|
471 | writable: false,
|
---|
472 | value: self
|
---|
473 | }); // Two elements created in two different places should be considered
|
---|
474 | // equal for testing purposes and therefore we hide it from enumeration.
|
---|
475 |
|
---|
476 | Object.defineProperty(element, '_source', {
|
---|
477 | configurable: false,
|
---|
478 | enumerable: false,
|
---|
479 | writable: false,
|
---|
480 | value: source
|
---|
481 | });
|
---|
482 |
|
---|
483 | if (Object.freeze) {
|
---|
484 | Object.freeze(element.props);
|
---|
485 | Object.freeze(element);
|
---|
486 | }
|
---|
487 | }
|
---|
488 |
|
---|
489 | return element;
|
---|
490 | };
|
---|
491 | /**
|
---|
492 | * https://github.com/reactjs/rfcs/pull/107
|
---|
493 | * @param {*} type
|
---|
494 | * @param {object} props
|
---|
495 | * @param {string} key
|
---|
496 | */
|
---|
497 |
|
---|
498 | function jsxDEV(type, config, maybeKey, source, self) {
|
---|
499 | {
|
---|
500 | var propName; // Reserved names are extracted
|
---|
501 |
|
---|
502 | var props = {};
|
---|
503 | var key = null;
|
---|
504 | var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
---|
505 | // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
---|
506 | // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
---|
507 | // but as an intermediary step, we will use jsxDEV for everything except
|
---|
508 | // <div {...props} key="Hi" />, because we aren't currently able to tell if
|
---|
509 | // key is explicitly declared to be undefined or not.
|
---|
510 |
|
---|
511 | if (maybeKey !== undefined) {
|
---|
512 | key = '' + maybeKey;
|
---|
513 | }
|
---|
514 |
|
---|
515 | if (hasValidKey(config)) {
|
---|
516 | key = '' + config.key;
|
---|
517 | }
|
---|
518 |
|
---|
519 | if (hasValidRef(config)) {
|
---|
520 | ref = config.ref;
|
---|
521 | warnIfStringRefCannotBeAutoConverted(config, self);
|
---|
522 | } // Remaining properties are added to a new props object
|
---|
523 |
|
---|
524 |
|
---|
525 | for (propName in config) {
|
---|
526 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
---|
527 | props[propName] = config[propName];
|
---|
528 | }
|
---|
529 | } // Resolve default props
|
---|
530 |
|
---|
531 |
|
---|
532 | if (type && type.defaultProps) {
|
---|
533 | var defaultProps = type.defaultProps;
|
---|
534 |
|
---|
535 | for (propName in defaultProps) {
|
---|
536 | if (props[propName] === undefined) {
|
---|
537 | props[propName] = defaultProps[propName];
|
---|
538 | }
|
---|
539 | }
|
---|
540 | }
|
---|
541 |
|
---|
542 | if (key || ref) {
|
---|
543 | var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
---|
544 |
|
---|
545 | if (key) {
|
---|
546 | defineKeyPropWarningGetter(props, displayName);
|
---|
547 | }
|
---|
548 |
|
---|
549 | if (ref) {
|
---|
550 | defineRefPropWarningGetter(props, displayName);
|
---|
551 | }
|
---|
552 | }
|
---|
553 |
|
---|
554 | return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
---|
555 | }
|
---|
556 | }
|
---|
557 |
|
---|
558 | var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
---|
559 | var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
---|
560 |
|
---|
561 | function setCurrentlyValidatingElement$1(element) {
|
---|
562 | currentlyValidatingElement = element;
|
---|
563 | }
|
---|
564 |
|
---|
565 | var propTypesMisspellWarningShown;
|
---|
566 |
|
---|
567 | {
|
---|
568 | propTypesMisspellWarningShown = false;
|
---|
569 | }
|
---|
570 | /**
|
---|
571 | * Verifies the object is a ReactElement.
|
---|
572 | * See https://reactjs.org/docs/react-api.html#isvalidelement
|
---|
573 | * @param {?object} object
|
---|
574 | * @return {boolean} True if `object` is a ReactElement.
|
---|
575 | * @final
|
---|
576 | */
|
---|
577 |
|
---|
578 | function isValidElement(object) {
|
---|
579 | {
|
---|
580 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
---|
581 | }
|
---|
582 | }
|
---|
583 |
|
---|
584 | function getDeclarationErrorAddendum() {
|
---|
585 | {
|
---|
586 | if (ReactCurrentOwner$1.current) {
|
---|
587 | var name = getComponentName(ReactCurrentOwner$1.current.type);
|
---|
588 |
|
---|
589 | if (name) {
|
---|
590 | return '\n\nCheck the render method of `' + name + '`.';
|
---|
591 | }
|
---|
592 | }
|
---|
593 |
|
---|
594 | return '';
|
---|
595 | }
|
---|
596 | }
|
---|
597 |
|
---|
598 | function getSourceInfoErrorAddendum(source) {
|
---|
599 | {
|
---|
600 | if (source !== undefined) {
|
---|
601 | var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
---|
602 | var lineNumber = source.lineNumber;
|
---|
603 | return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
---|
604 | }
|
---|
605 |
|
---|
606 | return '';
|
---|
607 | }
|
---|
608 | }
|
---|
609 | /**
|
---|
610 | * Warn if there's no key explicitly set on dynamic arrays of children or
|
---|
611 | * object keys are not valid. This allows us to keep track of children between
|
---|
612 | * updates.
|
---|
613 | */
|
---|
614 |
|
---|
615 |
|
---|
616 | var ownerHasKeyUseWarning = {};
|
---|
617 |
|
---|
618 | function getCurrentComponentErrorInfo(parentType) {
|
---|
619 | {
|
---|
620 | var info = getDeclarationErrorAddendum();
|
---|
621 |
|
---|
622 | if (!info) {
|
---|
623 | var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
---|
624 |
|
---|
625 | if (parentName) {
|
---|
626 | info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
---|
627 | }
|
---|
628 | }
|
---|
629 |
|
---|
630 | return info;
|
---|
631 | }
|
---|
632 | }
|
---|
633 | /**
|
---|
634 | * Warn if the element doesn't have an explicit key assigned to it.
|
---|
635 | * This element is in an array. The array could grow and shrink or be
|
---|
636 | * reordered. All children that haven't already been validated are required to
|
---|
637 | * have a "key" property assigned to it. Error statuses are cached so a warning
|
---|
638 | * will only be shown once.
|
---|
639 | *
|
---|
640 | * @internal
|
---|
641 | * @param {ReactElement} element Element that requires a key.
|
---|
642 | * @param {*} parentType element's parent's type.
|
---|
643 | */
|
---|
644 |
|
---|
645 |
|
---|
646 | function validateExplicitKey(element, parentType) {
|
---|
647 | {
|
---|
648 | if (!element._store || element._store.validated || element.key != null) {
|
---|
649 | return;
|
---|
650 | }
|
---|
651 |
|
---|
652 | element._store.validated = true;
|
---|
653 | var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
---|
654 |
|
---|
655 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
---|
656 | return;
|
---|
657 | }
|
---|
658 |
|
---|
659 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
---|
660 | // property, it may be the creator of the child that's responsible for
|
---|
661 | // assigning it a key.
|
---|
662 |
|
---|
663 | var childOwner = '';
|
---|
664 |
|
---|
665 | if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
---|
666 | // Give the component that originally created this child.
|
---|
667 | childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
---|
668 | }
|
---|
669 |
|
---|
670 | setCurrentlyValidatingElement$1(element);
|
---|
671 |
|
---|
672 | 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);
|
---|
673 |
|
---|
674 | setCurrentlyValidatingElement$1(null);
|
---|
675 | }
|
---|
676 | }
|
---|
677 | /**
|
---|
678 | * Ensure that every element either is passed in a static location, in an
|
---|
679 | * array with an explicit keys property defined, or in an object literal
|
---|
680 | * with valid key property.
|
---|
681 | *
|
---|
682 | * @internal
|
---|
683 | * @param {ReactNode} node Statically passed child of any type.
|
---|
684 | * @param {*} parentType node's parent's type.
|
---|
685 | */
|
---|
686 |
|
---|
687 |
|
---|
688 | function validateChildKeys(node, parentType) {
|
---|
689 | {
|
---|
690 | if (typeof node !== 'object') {
|
---|
691 | return;
|
---|
692 | }
|
---|
693 |
|
---|
694 | if (Array.isArray(node)) {
|
---|
695 | for (var i = 0; i < node.length; i++) {
|
---|
696 | var child = node[i];
|
---|
697 |
|
---|
698 | if (isValidElement(child)) {
|
---|
699 | validateExplicitKey(child, parentType);
|
---|
700 | }
|
---|
701 | }
|
---|
702 | } else if (isValidElement(node)) {
|
---|
703 | // This element was passed in a valid location.
|
---|
704 | if (node._store) {
|
---|
705 | node._store.validated = true;
|
---|
706 | }
|
---|
707 | } else if (node) {
|
---|
708 | var iteratorFn = getIteratorFn(node);
|
---|
709 |
|
---|
710 | if (typeof iteratorFn === 'function') {
|
---|
711 | // Entry iterators used to provide implicit keys,
|
---|
712 | // but now we print a separate warning for them later.
|
---|
713 | if (iteratorFn !== node.entries) {
|
---|
714 | var iterator = iteratorFn.call(node);
|
---|
715 | var step;
|
---|
716 |
|
---|
717 | while (!(step = iterator.next()).done) {
|
---|
718 | if (isValidElement(step.value)) {
|
---|
719 | validateExplicitKey(step.value, parentType);
|
---|
720 | }
|
---|
721 | }
|
---|
722 | }
|
---|
723 | }
|
---|
724 | }
|
---|
725 | }
|
---|
726 | }
|
---|
727 | /**
|
---|
728 | * Given an element, validate that its props follow the propTypes definition,
|
---|
729 | * provided by the type.
|
---|
730 | *
|
---|
731 | * @param {ReactElement} element
|
---|
732 | */
|
---|
733 |
|
---|
734 |
|
---|
735 | function validatePropTypes(element) {
|
---|
736 | {
|
---|
737 | var type = element.type;
|
---|
738 |
|
---|
739 | if (type === null || type === undefined || typeof type === 'string') {
|
---|
740 | return;
|
---|
741 | }
|
---|
742 |
|
---|
743 | var propTypes;
|
---|
744 |
|
---|
745 | if (typeof type === 'function') {
|
---|
746 | propTypes = type.propTypes;
|
---|
747 | } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
---|
748 | // Inner props are checked in the reconciler.
|
---|
749 | type.$$typeof === REACT_MEMO_TYPE)) {
|
---|
750 | propTypes = type.propTypes;
|
---|
751 | } else {
|
---|
752 | return;
|
---|
753 | }
|
---|
754 |
|
---|
755 | if (propTypes) {
|
---|
756 | // Intentionally inside to avoid triggering lazy initializers:
|
---|
757 | var name = getComponentName(type);
|
---|
758 | checkPropTypes(propTypes, element.props, 'prop', name, element);
|
---|
759 | } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
---|
760 | propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
---|
761 |
|
---|
762 | var _name = getComponentName(type);
|
---|
763 |
|
---|
764 | error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
---|
765 | }
|
---|
766 |
|
---|
767 | if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
---|
768 | error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
---|
769 | }
|
---|
770 | }
|
---|
771 | }
|
---|
772 | /**
|
---|
773 | * Given a fragment, validate that it can only be provided with fragment props
|
---|
774 | * @param {ReactElement} fragment
|
---|
775 | */
|
---|
776 |
|
---|
777 |
|
---|
778 | function validateFragmentProps(fragment) {
|
---|
779 | {
|
---|
780 | var keys = Object.keys(fragment.props);
|
---|
781 |
|
---|
782 | for (var i = 0; i < keys.length; i++) {
|
---|
783 | var key = keys[i];
|
---|
784 |
|
---|
785 | if (key !== 'children' && key !== 'key') {
|
---|
786 | setCurrentlyValidatingElement$1(fragment);
|
---|
787 |
|
---|
788 | error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
---|
789 |
|
---|
790 | setCurrentlyValidatingElement$1(null);
|
---|
791 | break;
|
---|
792 | }
|
---|
793 | }
|
---|
794 |
|
---|
795 | if (fragment.ref !== null) {
|
---|
796 | setCurrentlyValidatingElement$1(fragment);
|
---|
797 |
|
---|
798 | error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
---|
799 |
|
---|
800 | setCurrentlyValidatingElement$1(null);
|
---|
801 | }
|
---|
802 | }
|
---|
803 | }
|
---|
804 |
|
---|
805 | function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
---|
806 | {
|
---|
807 | var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
---|
808 | // succeed and there will likely be errors in render.
|
---|
809 |
|
---|
810 | if (!validType) {
|
---|
811 | var info = '';
|
---|
812 |
|
---|
813 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
---|
814 | 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.";
|
---|
815 | }
|
---|
816 |
|
---|
817 | var sourceInfo = getSourceInfoErrorAddendum(source);
|
---|
818 |
|
---|
819 | if (sourceInfo) {
|
---|
820 | info += sourceInfo;
|
---|
821 | } else {
|
---|
822 | info += getDeclarationErrorAddendum();
|
---|
823 | }
|
---|
824 |
|
---|
825 | var typeString;
|
---|
826 |
|
---|
827 | if (type === null) {
|
---|
828 | typeString = 'null';
|
---|
829 | } else if (Array.isArray(type)) {
|
---|
830 | typeString = 'array';
|
---|
831 | } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
---|
832 | typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
---|
833 | info = ' Did you accidentally export a JSX literal instead of a component?';
|
---|
834 | } else {
|
---|
835 | typeString = typeof type;
|
---|
836 | }
|
---|
837 |
|
---|
838 | error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
---|
839 | }
|
---|
840 |
|
---|
841 | var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
---|
842 | // TODO: Drop this when these are no longer allowed as the type argument.
|
---|
843 |
|
---|
844 | if (element == null) {
|
---|
845 | return element;
|
---|
846 | } // Skip key warning if the type isn't valid since our key validation logic
|
---|
847 | // doesn't expect a non-string/function type and can throw confusing errors.
|
---|
848 | // We don't want exception behavior to differ between dev and prod.
|
---|
849 | // (Rendering will throw with a helpful message and as soon as the type is
|
---|
850 | // fixed, the key warnings will appear.)
|
---|
851 |
|
---|
852 |
|
---|
853 | if (validType) {
|
---|
854 | var children = props.children;
|
---|
855 |
|
---|
856 | if (children !== undefined) {
|
---|
857 | if (isStaticChildren) {
|
---|
858 | if (Array.isArray(children)) {
|
---|
859 | for (var i = 0; i < children.length; i++) {
|
---|
860 | validateChildKeys(children[i], type);
|
---|
861 | }
|
---|
862 |
|
---|
863 | if (Object.freeze) {
|
---|
864 | Object.freeze(children);
|
---|
865 | }
|
---|
866 | } else {
|
---|
867 | error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
---|
868 | }
|
---|
869 | } else {
|
---|
870 | validateChildKeys(children, type);
|
---|
871 | }
|
---|
872 | }
|
---|
873 | }
|
---|
874 |
|
---|
875 | if (type === exports.Fragment) {
|
---|
876 | validateFragmentProps(element);
|
---|
877 | } else {
|
---|
878 | validatePropTypes(element);
|
---|
879 | }
|
---|
880 |
|
---|
881 | return element;
|
---|
882 | }
|
---|
883 | } // These two functions exist to still get child warnings in dev
|
---|
884 |
|
---|
885 | var jsxDEV$1 = jsxWithValidation ;
|
---|
886 |
|
---|
887 | exports.jsxDEV = jsxDEV$1;
|
---|
888 | })();
|
---|
889 | }
|
---|