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