UNPKG

37.8 kBJavaScriptView Raw
1/** @license React v17.0.2
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
12if (process.env.NODE_ENV !== "production") {
13 (function() {
14'use strict';
15
16var React = require('react');
17var _assign = require('object-assign');
18
19// ATTENTION
20// When adding new symbols to this file,
21// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
22// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
23// nor polyfill, then a plain number is used for performance.
24var REACT_ELEMENT_TYPE = 0xeac7;
25var REACT_PORTAL_TYPE = 0xeaca;
26exports.Fragment = 0xeacb;
27var REACT_STRICT_MODE_TYPE = 0xeacc;
28var REACT_PROFILER_TYPE = 0xead2;
29var REACT_PROVIDER_TYPE = 0xeacd;
30var REACT_CONTEXT_TYPE = 0xeace;
31var REACT_FORWARD_REF_TYPE = 0xead0;
32var REACT_SUSPENSE_TYPE = 0xead1;
33var REACT_SUSPENSE_LIST_TYPE = 0xead8;
34var REACT_MEMO_TYPE = 0xead3;
35var REACT_LAZY_TYPE = 0xead4;
36var REACT_BLOCK_TYPE = 0xead9;
37var REACT_SERVER_BLOCK_TYPE = 0xeada;
38var REACT_FUNDAMENTAL_TYPE = 0xead5;
39var REACT_SCOPE_TYPE = 0xead7;
40var REACT_OPAQUE_ID_TYPE = 0xeae0;
41var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
42var REACT_OFFSCREEN_TYPE = 0xeae2;
43var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
44
45if (typeof Symbol === 'function' && Symbol.for) {
46 var symbolFor = Symbol.for;
47 REACT_ELEMENT_TYPE = symbolFor('react.element');
48 REACT_PORTAL_TYPE = symbolFor('react.portal');
49 exports.Fragment = symbolFor('react.fragment');
50 REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
51 REACT_PROFILER_TYPE = symbolFor('react.profiler');
52 REACT_PROVIDER_TYPE = symbolFor('react.provider');
53 REACT_CONTEXT_TYPE = symbolFor('react.context');
54 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
55 REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
56 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
57 REACT_MEMO_TYPE = symbolFor('react.memo');
58 REACT_LAZY_TYPE = symbolFor('react.lazy');
59 REACT_BLOCK_TYPE = symbolFor('react.block');
60 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
61 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
62 REACT_SCOPE_TYPE = symbolFor('react.scope');
63 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
64 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
65 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
66 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
67}
68
69var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
70var FAUX_ITERATOR_SYMBOL = '@@iterator';
71function getIteratorFn(maybeIterable) {
72 if (maybeIterable === null || typeof maybeIterable !== 'object') {
73 return null;
74 }
75
76 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
77
78 if (typeof maybeIterator === 'function') {
79 return maybeIterator;
80 }
81
82 return null;
83}
84
85var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
86
87function error(format) {
88 {
89 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
90 args[_key2 - 1] = arguments[_key2];
91 }
92
93 printWarning('error', format, args);
94 }
95}
96
97function printWarning(level, format, args) {
98 // When changing this logic, you might want to also
99 // update consoleWithStackDev.www.js as well.
100 {
101 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
102 var stack = ReactDebugCurrentFrame.getStackAddendum();
103
104 if (stack !== '') {
105 format += '%s';
106 args = args.concat([stack]);
107 }
108
109 var argsWithFormat = args.map(function (item) {
110 return '' + item;
111 }); // Careful: RN currently depends on this prefix
112
113 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
114 // breaks IE9: https://github.com/facebook/react/issues/13610
115 // eslint-disable-next-line react-internal/no-production-logging
116
117 Function.prototype.apply.call(console[level], console, argsWithFormat);
118 }
119}
120
121// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
122
123var enableScopeAPI = false; // Experimental Create Event Handle API.
124
125function isValidElementType(type) {
126 if (typeof type === 'string' || typeof type === 'function') {
127 return true;
128 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
129
130
131 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 ) {
132 return true;
133 }
134
135 if (typeof type === 'object' && type !== null) {
136 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) {
137 return true;
138 }
139 }
140
141 return false;
142}
143
144function getWrappedName(outerType, innerType, wrapperName) {
145 var functionName = innerType.displayName || innerType.name || '';
146 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
147}
148
149function getContextName(type) {
150 return type.displayName || 'Context';
151}
152
153function getComponentName(type) {
154 if (type == null) {
155 // Host root, text node or just invalid type.
156 return null;
157 }
158
159 {
160 if (typeof type.tag === 'number') {
161 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
162 }
163 }
164
165 if (typeof type === 'function') {
166 return type.displayName || type.name || null;
167 }
168
169 if (typeof type === 'string') {
170 return type;
171 }
172
173 switch (type) {
174 case exports.Fragment:
175 return 'Fragment';
176
177 case REACT_PORTAL_TYPE:
178 return 'Portal';
179
180 case REACT_PROFILER_TYPE:
181 return 'Profiler';
182
183 case REACT_STRICT_MODE_TYPE:
184 return 'StrictMode';
185
186 case REACT_SUSPENSE_TYPE:
187 return 'Suspense';
188
189 case REACT_SUSPENSE_LIST_TYPE:
190 return 'SuspenseList';
191 }
192
193 if (typeof type === 'object') {
194 switch (type.$$typeof) {
195 case REACT_CONTEXT_TYPE:
196 var context = type;
197 return getContextName(context) + '.Consumer';
198
199 case REACT_PROVIDER_TYPE:
200 var provider = type;
201 return getContextName(provider._context) + '.Provider';
202
203 case REACT_FORWARD_REF_TYPE:
204 return getWrappedName(type, type.render, 'ForwardRef');
205
206 case REACT_MEMO_TYPE:
207 return getComponentName(type.type);
208
209 case REACT_BLOCK_TYPE:
210 return getComponentName(type._render);
211
212 case REACT_LAZY_TYPE:
213 {
214 var lazyComponent = type;
215 var payload = lazyComponent._payload;
216 var init = lazyComponent._init;
217
218 try {
219 return getComponentName(init(payload));
220 } catch (x) {
221 return null;
222 }
223 }
224 }
225 }
226
227 return null;
228}
229
230// Helpers to patch console.logs to avoid logging during side-effect free
231// replaying on render function. This currently only patches the object
232// lazily which won't cover if the log function was extracted eagerly.
233// We could also eagerly patch the method.
234var disabledDepth = 0;
235var prevLog;
236var prevInfo;
237var prevWarn;
238var prevError;
239var prevGroup;
240var prevGroupCollapsed;
241var prevGroupEnd;
242
243function disabledLog() {}
244
245disabledLog.__reactDisabledLog = true;
246function disableLogs() {
247 {
248 if (disabledDepth === 0) {
249 /* eslint-disable react-internal/no-production-logging */
250 prevLog = console.log;
251 prevInfo = console.info;
252 prevWarn = console.warn;
253 prevError = console.error;
254 prevGroup = console.group;
255 prevGroupCollapsed = console.groupCollapsed;
256 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
257
258 var props = {
259 configurable: true,
260 enumerable: true,
261 value: disabledLog,
262 writable: true
263 }; // $FlowFixMe Flow thinks console is immutable.
264
265 Object.defineProperties(console, {
266 info: props,
267 log: props,
268 warn: props,
269 error: props,
270 group: props,
271 groupCollapsed: props,
272 groupEnd: props
273 });
274 /* eslint-enable react-internal/no-production-logging */
275 }
276
277 disabledDepth++;
278 }
279}
280function reenableLogs() {
281 {
282 disabledDepth--;
283
284 if (disabledDepth === 0) {
285 /* eslint-disable react-internal/no-production-logging */
286 var props = {
287 configurable: true,
288 enumerable: true,
289 writable: true
290 }; // $FlowFixMe Flow thinks console is immutable.
291
292 Object.defineProperties(console, {
293 log: _assign({}, props, {
294 value: prevLog
295 }),
296 info: _assign({}, props, {
297 value: prevInfo
298 }),
299 warn: _assign({}, props, {
300 value: prevWarn
301 }),
302 error: _assign({}, props, {
303 value: prevError
304 }),
305 group: _assign({}, props, {
306 value: prevGroup
307 }),
308 groupCollapsed: _assign({}, props, {
309 value: prevGroupCollapsed
310 }),
311 groupEnd: _assign({}, props, {
312 value: prevGroupEnd
313 })
314 });
315 /* eslint-enable react-internal/no-production-logging */
316 }
317
318 if (disabledDepth < 0) {
319 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
320 }
321 }
322}
323
324var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
325var prefix;
326function describeBuiltInComponentFrame(name, source, ownerFn) {
327 {
328 if (prefix === undefined) {
329 // Extract the VM specific prefix used by each line.
330 try {
331 throw Error();
332 } catch (x) {
333 var match = x.stack.trim().match(/\n( *(at )?)/);
334 prefix = match && match[1] || '';
335 }
336 } // We use the prefix to ensure our stacks line up with native stack frames.
337
338
339 return '\n' + prefix + name;
340 }
341}
342var reentry = false;
343var componentFrameCache;
344
345{
346 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
347 componentFrameCache = new PossiblyWeakMap();
348}
349
350function describeNativeComponentFrame(fn, construct) {
351 // If something asked for a stack inside a fake render, it should get ignored.
352 if (!fn || reentry) {
353 return '';
354 }
355
356 {
357 var frame = componentFrameCache.get(fn);
358
359 if (frame !== undefined) {
360 return frame;
361 }
362 }
363
364 var control;
365 reentry = true;
366 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
367
368 Error.prepareStackTrace = undefined;
369 var previousDispatcher;
370
371 {
372 previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
373 // for warnings.
374
375 ReactCurrentDispatcher.current = null;
376 disableLogs();
377 }
378
379 try {
380 // This should throw.
381 if (construct) {
382 // Something should be setting the props in the constructor.
383 var Fake = function () {
384 throw Error();
385 }; // $FlowFixMe
386
387
388 Object.defineProperty(Fake.prototype, 'props', {
389 set: function () {
390 // We use a throwing setter instead of frozen or non-writable props
391 // because that won't throw in a non-strict mode function.
392 throw Error();
393 }
394 });
395
396 if (typeof Reflect === 'object' && Reflect.construct) {
397 // We construct a different control for this case to include any extra
398 // frames added by the construct call.
399 try {
400 Reflect.construct(Fake, []);
401 } catch (x) {
402 control = x;
403 }
404
405 Reflect.construct(fn, [], Fake);
406 } else {
407 try {
408 Fake.call();
409 } catch (x) {
410 control = x;
411 }
412
413 fn.call(Fake.prototype);
414 }
415 } else {
416 try {
417 throw Error();
418 } catch (x) {
419 control = x;
420 }
421
422 fn();
423 }
424 } catch (sample) {
425 // This is inlined manually because closure doesn't do it for us.
426 if (sample && control && typeof sample.stack === 'string') {
427 // This extracts the first frame from the sample that isn't also in the control.
428 // Skipping one frame that we assume is the frame that calls the two.
429 var sampleLines = sample.stack.split('\n');
430 var controlLines = control.stack.split('\n');
431 var s = sampleLines.length - 1;
432 var c = controlLines.length - 1;
433
434 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
435 // We expect at least one stack frame to be shared.
436 // Typically this will be the root most one. However, stack frames may be
437 // cut off due to maximum stack limits. In this case, one maybe cut off
438 // earlier than the other. We assume that the sample is longer or the same
439 // and there for cut off earlier. So we should find the root most frame in
440 // the sample somewhere in the control.
441 c--;
442 }
443
444 for (; s >= 1 && c >= 0; s--, c--) {
445 // Next we find the first one that isn't the same which should be the
446 // frame that called our sample function and the control.
447 if (sampleLines[s] !== controlLines[c]) {
448 // In V8, the first line is describing the message but other VMs don't.
449 // If we're about to return the first line, and the control is also on the same
450 // line, that's a pretty good indicator that our sample threw at same line as
451 // the control. I.e. before we entered the sample frame. So we ignore this result.
452 // This can happen if you passed a class to function component, or non-function.
453 if (s !== 1 || c !== 1) {
454 do {
455 s--;
456 c--; // We may still have similar intermediate frames from the construct call.
457 // The next one that isn't the same should be our match though.
458
459 if (c < 0 || sampleLines[s] !== controlLines[c]) {
460 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
461 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
462
463 {
464 if (typeof fn === 'function') {
465 componentFrameCache.set(fn, _frame);
466 }
467 } // Return the line we found.
468
469
470 return _frame;
471 }
472 } while (s >= 1 && c >= 0);
473 }
474
475 break;
476 }
477 }
478 }
479 } finally {
480 reentry = false;
481
482 {
483 ReactCurrentDispatcher.current = previousDispatcher;
484 reenableLogs();
485 }
486
487 Error.prepareStackTrace = previousPrepareStackTrace;
488 } // Fallback to just using the name if we couldn't make it throw.
489
490
491 var name = fn ? fn.displayName || fn.name : '';
492 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
493
494 {
495 if (typeof fn === 'function') {
496 componentFrameCache.set(fn, syntheticFrame);
497 }
498 }
499
500 return syntheticFrame;
501}
502function describeFunctionComponentFrame(fn, source, ownerFn) {
503 {
504 return describeNativeComponentFrame(fn, false);
505 }
506}
507
508function shouldConstruct(Component) {
509 var prototype = Component.prototype;
510 return !!(prototype && prototype.isReactComponent);
511}
512
513function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
514
515 if (type == null) {
516 return '';
517 }
518
519 if (typeof type === 'function') {
520 {
521 return describeNativeComponentFrame(type, shouldConstruct(type));
522 }
523 }
524
525 if (typeof type === 'string') {
526 return describeBuiltInComponentFrame(type);
527 }
528
529 switch (type) {
530 case REACT_SUSPENSE_TYPE:
531 return describeBuiltInComponentFrame('Suspense');
532
533 case REACT_SUSPENSE_LIST_TYPE:
534 return describeBuiltInComponentFrame('SuspenseList');
535 }
536
537 if (typeof type === 'object') {
538 switch (type.$$typeof) {
539 case REACT_FORWARD_REF_TYPE:
540 return describeFunctionComponentFrame(type.render);
541
542 case REACT_MEMO_TYPE:
543 // Memo may contain any component type so we recursively resolve it.
544 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
545
546 case REACT_BLOCK_TYPE:
547 return describeFunctionComponentFrame(type._render);
548
549 case REACT_LAZY_TYPE:
550 {
551 var lazyComponent = type;
552 var payload = lazyComponent._payload;
553 var init = lazyComponent._init;
554
555 try {
556 // Lazy may contain any component type so we recursively resolve it.
557 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
558 } catch (x) {}
559 }
560 }
561 }
562
563 return '';
564}
565
566var loggedTypeFailures = {};
567var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
568
569function setCurrentlyValidatingElement(element) {
570 {
571 if (element) {
572 var owner = element._owner;
573 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
574 ReactDebugCurrentFrame.setExtraStackFrame(stack);
575 } else {
576 ReactDebugCurrentFrame.setExtraStackFrame(null);
577 }
578 }
579}
580
581function checkPropTypes(typeSpecs, values, location, componentName, element) {
582 {
583 // $FlowFixMe This is okay but Flow doesn't know it.
584 var has = Function.call.bind(Object.prototype.hasOwnProperty);
585
586 for (var typeSpecName in typeSpecs) {
587 if (has(typeSpecs, typeSpecName)) {
588 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
589 // fail the render phase where it didn't fail before. So we log it.
590 // After these have been cleaned up, we'll let them throw.
591
592 try {
593 // This is intentionally an invariant that gets caught. It's the same
594 // behavior as without this statement except with a better message.
595 if (typeof typeSpecs[typeSpecName] !== 'function') {
596 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`.');
597 err.name = 'Invariant Violation';
598 throw err;
599 }
600
601 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
602 } catch (ex) {
603 error$1 = ex;
604 }
605
606 if (error$1 && !(error$1 instanceof Error)) {
607 setCurrentlyValidatingElement(element);
608
609 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);
610
611 setCurrentlyValidatingElement(null);
612 }
613
614 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
615 // Only monitor this failure once because there tends to be a lot of the
616 // same error.
617 loggedTypeFailures[error$1.message] = true;
618 setCurrentlyValidatingElement(element);
619
620 error('Failed %s type: %s', location, error$1.message);
621
622 setCurrentlyValidatingElement(null);
623 }
624 }
625 }
626 }
627}
628
629var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
630var hasOwnProperty = Object.prototype.hasOwnProperty;
631var RESERVED_PROPS = {
632 key: true,
633 ref: true,
634 __self: true,
635 __source: true
636};
637var specialPropKeyWarningShown;
638var specialPropRefWarningShown;
639var didWarnAboutStringRefs;
640
641{
642 didWarnAboutStringRefs = {};
643}
644
645function hasValidRef(config) {
646 {
647 if (hasOwnProperty.call(config, 'ref')) {
648 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
649
650 if (getter && getter.isReactWarning) {
651 return false;
652 }
653 }
654 }
655
656 return config.ref !== undefined;
657}
658
659function hasValidKey(config) {
660 {
661 if (hasOwnProperty.call(config, 'key')) {
662 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
663
664 if (getter && getter.isReactWarning) {
665 return false;
666 }
667 }
668 }
669
670 return config.key !== undefined;
671}
672
673function warnIfStringRefCannotBeAutoConverted(config, self) {
674 {
675 if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
676 var componentName = getComponentName(ReactCurrentOwner.current.type);
677
678 if (!didWarnAboutStringRefs[componentName]) {
679 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);
680
681 didWarnAboutStringRefs[componentName] = true;
682 }
683 }
684 }
685}
686
687function defineKeyPropWarningGetter(props, displayName) {
688 {
689 var warnAboutAccessingKey = function () {
690 if (!specialPropKeyWarningShown) {
691 specialPropKeyWarningShown = true;
692
693 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);
694 }
695 };
696
697 warnAboutAccessingKey.isReactWarning = true;
698 Object.defineProperty(props, 'key', {
699 get: warnAboutAccessingKey,
700 configurable: true
701 });
702 }
703}
704
705function defineRefPropWarningGetter(props, displayName) {
706 {
707 var warnAboutAccessingRef = function () {
708 if (!specialPropRefWarningShown) {
709 specialPropRefWarningShown = true;
710
711 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);
712 }
713 };
714
715 warnAboutAccessingRef.isReactWarning = true;
716 Object.defineProperty(props, 'ref', {
717 get: warnAboutAccessingRef,
718 configurable: true
719 });
720 }
721}
722/**
723 * Factory method to create a new React element. This no longer adheres to
724 * the class pattern, so do not use new to call it. Also, instanceof check
725 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
726 * if something is a React Element.
727 *
728 * @param {*} type
729 * @param {*} props
730 * @param {*} key
731 * @param {string|object} ref
732 * @param {*} owner
733 * @param {*} self A *temporary* helper to detect places where `this` is
734 * different from the `owner` when React.createElement is called, so that we
735 * can warn. We want to get rid of owner and replace string `ref`s with arrow
736 * functions, and as long as `this` and owner are the same, there will be no
737 * change in behavior.
738 * @param {*} source An annotation object (added by a transpiler or otherwise)
739 * indicating filename, line number, and/or other information.
740 * @internal
741 */
742
743
744var ReactElement = function (type, key, ref, self, source, owner, props) {
745 var element = {
746 // This tag allows us to uniquely identify this as a React Element
747 $$typeof: REACT_ELEMENT_TYPE,
748 // Built-in properties that belong on the element
749 type: type,
750 key: key,
751 ref: ref,
752 props: props,
753 // Record the component responsible for creating this element.
754 _owner: owner
755 };
756
757 {
758 // The validation flag is currently mutative. We put it on
759 // an external backing store so that we can freeze the whole object.
760 // This can be replaced with a WeakMap once they are implemented in
761 // commonly used development environments.
762 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
763 // the validation flag non-enumerable (where possible, which should
764 // include every environment we run tests in), so the test framework
765 // ignores it.
766
767 Object.defineProperty(element._store, 'validated', {
768 configurable: false,
769 enumerable: false,
770 writable: true,
771 value: false
772 }); // self and source are DEV only properties.
773
774 Object.defineProperty(element, '_self', {
775 configurable: false,
776 enumerable: false,
777 writable: false,
778 value: self
779 }); // Two elements created in two different places should be considered
780 // equal for testing purposes and therefore we hide it from enumeration.
781
782 Object.defineProperty(element, '_source', {
783 configurable: false,
784 enumerable: false,
785 writable: false,
786 value: source
787 });
788
789 if (Object.freeze) {
790 Object.freeze(element.props);
791 Object.freeze(element);
792 }
793 }
794
795 return element;
796};
797/**
798 * https://github.com/reactjs/rfcs/pull/107
799 * @param {*} type
800 * @param {object} props
801 * @param {string} key
802 */
803
804function jsxDEV(type, config, maybeKey, source, self) {
805 {
806 var propName; // Reserved names are extracted
807
808 var props = {};
809 var key = null;
810 var ref = null; // Currently, key can be spread in as a prop. This causes a potential
811 // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
812 // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
813 // but as an intermediary step, we will use jsxDEV for everything except
814 // <div {...props} key="Hi" />, because we aren't currently able to tell if
815 // key is explicitly declared to be undefined or not.
816
817 if (maybeKey !== undefined) {
818 key = '' + maybeKey;
819 }
820
821 if (hasValidKey(config)) {
822 key = '' + config.key;
823 }
824
825 if (hasValidRef(config)) {
826 ref = config.ref;
827 warnIfStringRefCannotBeAutoConverted(config, self);
828 } // Remaining properties are added to a new props object
829
830
831 for (propName in config) {
832 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
833 props[propName] = config[propName];
834 }
835 } // Resolve default props
836
837
838 if (type && type.defaultProps) {
839 var defaultProps = type.defaultProps;
840
841 for (propName in defaultProps) {
842 if (props[propName] === undefined) {
843 props[propName] = defaultProps[propName];
844 }
845 }
846 }
847
848 if (key || ref) {
849 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
850
851 if (key) {
852 defineKeyPropWarningGetter(props, displayName);
853 }
854
855 if (ref) {
856 defineRefPropWarningGetter(props, displayName);
857 }
858 }
859
860 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
861 }
862}
863
864var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
865var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
866
867function setCurrentlyValidatingElement$1(element) {
868 {
869 if (element) {
870 var owner = element._owner;
871 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
872 ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
873 } else {
874 ReactDebugCurrentFrame$1.setExtraStackFrame(null);
875 }
876 }
877}
878
879var propTypesMisspellWarningShown;
880
881{
882 propTypesMisspellWarningShown = false;
883}
884/**
885 * Verifies the object is a ReactElement.
886 * See https://reactjs.org/docs/react-api.html#isvalidelement
887 * @param {?object} object
888 * @return {boolean} True if `object` is a ReactElement.
889 * @final
890 */
891
892function isValidElement(object) {
893 {
894 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
895 }
896}
897
898function getDeclarationErrorAddendum() {
899 {
900 if (ReactCurrentOwner$1.current) {
901 var name = getComponentName(ReactCurrentOwner$1.current.type);
902
903 if (name) {
904 return '\n\nCheck the render method of `' + name + '`.';
905 }
906 }
907
908 return '';
909 }
910}
911
912function getSourceInfoErrorAddendum(source) {
913 {
914 if (source !== undefined) {
915 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
916 var lineNumber = source.lineNumber;
917 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
918 }
919
920 return '';
921 }
922}
923/**
924 * Warn if there's no key explicitly set on dynamic arrays of children or
925 * object keys are not valid. This allows us to keep track of children between
926 * updates.
927 */
928
929
930var ownerHasKeyUseWarning = {};
931
932function getCurrentComponentErrorInfo(parentType) {
933 {
934 var info = getDeclarationErrorAddendum();
935
936 if (!info) {
937 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
938
939 if (parentName) {
940 info = "\n\nCheck the top-level render call using <" + parentName + ">.";
941 }
942 }
943
944 return info;
945 }
946}
947/**
948 * Warn if the element doesn't have an explicit key assigned to it.
949 * This element is in an array. The array could grow and shrink or be
950 * reordered. All children that haven't already been validated are required to
951 * have a "key" property assigned to it. Error statuses are cached so a warning
952 * will only be shown once.
953 *
954 * @internal
955 * @param {ReactElement} element Element that requires a key.
956 * @param {*} parentType element's parent's type.
957 */
958
959
960function validateExplicitKey(element, parentType) {
961 {
962 if (!element._store || element._store.validated || element.key != null) {
963 return;
964 }
965
966 element._store.validated = true;
967 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
968
969 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
970 return;
971 }
972
973 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
974 // property, it may be the creator of the child that's responsible for
975 // assigning it a key.
976
977 var childOwner = '';
978
979 if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
980 // Give the component that originally created this child.
981 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
982 }
983
984 setCurrentlyValidatingElement$1(element);
985
986 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);
987
988 setCurrentlyValidatingElement$1(null);
989 }
990}
991/**
992 * Ensure that every element either is passed in a static location, in an
993 * array with an explicit keys property defined, or in an object literal
994 * with valid key property.
995 *
996 * @internal
997 * @param {ReactNode} node Statically passed child of any type.
998 * @param {*} parentType node's parent's type.
999 */
1000
1001
1002function validateChildKeys(node, parentType) {
1003 {
1004 if (typeof node !== 'object') {
1005 return;
1006 }
1007
1008 if (Array.isArray(node)) {
1009 for (var i = 0; i < node.length; i++) {
1010 var child = node[i];
1011
1012 if (isValidElement(child)) {
1013 validateExplicitKey(child, parentType);
1014 }
1015 }
1016 } else if (isValidElement(node)) {
1017 // This element was passed in a valid location.
1018 if (node._store) {
1019 node._store.validated = true;
1020 }
1021 } else if (node) {
1022 var iteratorFn = getIteratorFn(node);
1023
1024 if (typeof iteratorFn === 'function') {
1025 // Entry iterators used to provide implicit keys,
1026 // but now we print a separate warning for them later.
1027 if (iteratorFn !== node.entries) {
1028 var iterator = iteratorFn.call(node);
1029 var step;
1030
1031 while (!(step = iterator.next()).done) {
1032 if (isValidElement(step.value)) {
1033 validateExplicitKey(step.value, parentType);
1034 }
1035 }
1036 }
1037 }
1038 }
1039 }
1040}
1041/**
1042 * Given an element, validate that its props follow the propTypes definition,
1043 * provided by the type.
1044 *
1045 * @param {ReactElement} element
1046 */
1047
1048
1049function validatePropTypes(element) {
1050 {
1051 var type = element.type;
1052
1053 if (type === null || type === undefined || typeof type === 'string') {
1054 return;
1055 }
1056
1057 var propTypes;
1058
1059 if (typeof type === 'function') {
1060 propTypes = type.propTypes;
1061 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1062 // Inner props are checked in the reconciler.
1063 type.$$typeof === REACT_MEMO_TYPE)) {
1064 propTypes = type.propTypes;
1065 } else {
1066 return;
1067 }
1068
1069 if (propTypes) {
1070 // Intentionally inside to avoid triggering lazy initializers:
1071 var name = getComponentName(type);
1072 checkPropTypes(propTypes, element.props, 'prop', name, element);
1073 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1074 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1075
1076 var _name = getComponentName(type);
1077
1078 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1079 }
1080
1081 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1082 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1083 }
1084 }
1085}
1086/**
1087 * Given a fragment, validate that it can only be provided with fragment props
1088 * @param {ReactElement} fragment
1089 */
1090
1091
1092function validateFragmentProps(fragment) {
1093 {
1094 var keys = Object.keys(fragment.props);
1095
1096 for (var i = 0; i < keys.length; i++) {
1097 var key = keys[i];
1098
1099 if (key !== 'children' && key !== 'key') {
1100 setCurrentlyValidatingElement$1(fragment);
1101
1102 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1103
1104 setCurrentlyValidatingElement$1(null);
1105 break;
1106 }
1107 }
1108
1109 if (fragment.ref !== null) {
1110 setCurrentlyValidatingElement$1(fragment);
1111
1112 error('Invalid attribute `ref` supplied to `React.Fragment`.');
1113
1114 setCurrentlyValidatingElement$1(null);
1115 }
1116 }
1117}
1118
1119function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1120 {
1121 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1122 // succeed and there will likely be errors in render.
1123
1124 if (!validType) {
1125 var info = '';
1126
1127 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1128 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.";
1129 }
1130
1131 var sourceInfo = getSourceInfoErrorAddendum(source);
1132
1133 if (sourceInfo) {
1134 info += sourceInfo;
1135 } else {
1136 info += getDeclarationErrorAddendum();
1137 }
1138
1139 var typeString;
1140
1141 if (type === null) {
1142 typeString = 'null';
1143 } else if (Array.isArray(type)) {
1144 typeString = 'array';
1145 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1146 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
1147 info = ' Did you accidentally export a JSX literal instead of a component?';
1148 } else {
1149 typeString = typeof type;
1150 }
1151
1152 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);
1153 }
1154
1155 var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1156 // TODO: Drop this when these are no longer allowed as the type argument.
1157
1158 if (element == null) {
1159 return element;
1160 } // Skip key warning if the type isn't valid since our key validation logic
1161 // doesn't expect a non-string/function type and can throw confusing errors.
1162 // We don't want exception behavior to differ between dev and prod.
1163 // (Rendering will throw with a helpful message and as soon as the type is
1164 // fixed, the key warnings will appear.)
1165
1166
1167 if (validType) {
1168 var children = props.children;
1169
1170 if (children !== undefined) {
1171 if (isStaticChildren) {
1172 if (Array.isArray(children)) {
1173 for (var i = 0; i < children.length; i++) {
1174 validateChildKeys(children[i], type);
1175 }
1176
1177 if (Object.freeze) {
1178 Object.freeze(children);
1179 }
1180 } else {
1181 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.');
1182 }
1183 } else {
1184 validateChildKeys(children, type);
1185 }
1186 }
1187 }
1188
1189 if (type === exports.Fragment) {
1190 validateFragmentProps(element);
1191 } else {
1192 validatePropTypes(element);
1193 }
1194
1195 return element;
1196 }
1197} // These two functions exist to still get child warnings in dev
1198
1199var jsxDEV$1 = jsxWithValidation ;
1200
1201exports.jsxDEV = jsxDEV$1;
1202 })();
1203}