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