UNPKG

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