0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,18 @@
export default function HTMLElementType(props, propName, componentName, location, propFullName) {
if (process.env.NODE_ENV === 'production') {
return null;
}
const propValue = props[propName];
const safePropName = propFullName || propName;
if (propValue == null) {
return null;
}
if (propValue && propValue.nodeType !== 1) {
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`);
}
return null;
}

View file

@ -0,0 +1,9 @@
export default function chainPropTypes(propType1, propType2) {
if (process.env.NODE_ENV === 'production') {
return () => null;
}
return function validate(...args) {
return propType1(...args) || propType2(...args);
};
}

26
web/node_modules/@material-ui/utils/es/deepmerge.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
import _extends from "@babel/runtime/helpers/esm/extends";
export function isPlainObject(item) {
return item && typeof item === 'object' && item.constructor === Object;
}
export default function deepmerge(target, source, options = {
clone: true
}) {
const output = options.clone ? _extends({}, target) : target;
if (isPlainObject(target) && isPlainObject(source)) {
Object.keys(source).forEach(key => {
// Avoid prototype pollution
if (key === '__proto__') {
return;
}
if (isPlainObject(source[key]) && key in target) {
output[key] = deepmerge(target[key], source[key], options);
} else {
output[key] = source[key];
}
});
}
return output;
}

View file

@ -0,0 +1,45 @@
import PropTypes from 'prop-types';
import chainPropTypes from './chainPropTypes';
function isClassComponent(elementType) {
// elementType.prototype?.isReactComponent
const {
prototype = {}
} = elementType;
return Boolean(prototype.isReactComponent);
}
function acceptingRef(props, propName, componentName, location, propFullName) {
const element = props[propName];
const safePropName = propFullName || propName;
if (element == null) {
return null;
}
let warningHint;
const elementType = element.type;
/**
* Blacklisting instead of whitelisting
*
* Blacklisting will miss some components, such as React.Fragment. Those will at least
* trigger a warning in React.
* We can't whitelist because there is no safe way to detect React.forwardRef
* or class components. "Safe" means there's no public API.
*
*/
if (typeof elementType === 'function' && !isClassComponent(elementType)) {
warningHint = 'Did you accidentally use a plain function component for an element instead?';
}
if (warningHint !== undefined) {
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element that can hold a ref. ${warningHint} ` + 'For more information see https://material-ui.com/r/caveat-with-refs-guide');
}
return null;
}
const elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef);
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef);
export default elementAcceptingRef;

View file

@ -0,0 +1,42 @@
import * as PropTypes from 'prop-types';
import chainPropTypes from './chainPropTypes';
function isClassComponent(elementType) {
// elementType.prototype?.isReactComponent
const {
prototype = {}
} = elementType;
return Boolean(prototype.isReactComponent);
}
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) {
const propValue = props[propName];
const safePropName = propFullName || propName;
if (propValue == null) {
return null;
}
let warningHint;
/**
* Blacklisting instead of whitelisting
*
* Blacklisting will miss some components, such as React.Fragment. Those will at least
* trigger a warning in React.
* We can't whitelist because there is no safe way to detect React.forwardRef
* or class components. "Safe" means there's no public API.
*
*/
if (typeof propValue === 'function' && !isClassComponent(propValue)) {
warningHint = 'Did you accidentally provide a plain function component instead?';
}
if (warningHint !== undefined) {
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://material-ui.com/r/caveat-with-refs-guide');
}
return null;
}
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef);

23
web/node_modules/@material-ui/utils/es/exactProp.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
import _extends from "@babel/runtime/helpers/esm/extends";
// This module is based on https://github.com/airbnb/prop-types-exact repository.
// However, in order to reduce the number of dependencies and to remove some extra safe checks
// the module was forked.
// Only exported for test purposes.
export const specialProperty = 'exact-prop: \u200b';
export default function exactProp(propTypes) {
if (process.env.NODE_ENV === 'production') {
return propTypes;
}
return _extends({}, propTypes, {
[specialProperty]: props => {
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
if (unsupportedProps.length > 0) {
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`);
}
return null;
}
});
}

View file

@ -0,0 +1,22 @@
/**
* WARNING: Don't import this directly.
* Use `MuiError` from `@material-ui/utils/macros/MuiError.macro` instead.
* @param {number} code
*/
export default function formatMuiErrorMessage(code) {
// Apply babel-plugin-transform-template-literals in loose mode
// loose mode is safe iff we're concatenating primitives
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose
/* eslint-disable prefer-template */
let url = 'https://material-ui.com/production-error/?code=' + code;
for (let i = 1; i < arguments.length; i += 1) {
// rest params over-transpile for this case
// eslint-disable-next-line prefer-rest-params
url += '&args[]=' + encodeURIComponent(arguments[i]);
}
return 'Minified Material-UI error #' + code + '; visit ' + url + ' for the full message.';
/* eslint-enable prefer-template */
}

View file

@ -0,0 +1,61 @@
import { ForwardRef, Memo } from 'react-is'; // Simplified polyfill for IE 11 support
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
export function getFunctionName(fn) {
const match = `${fn}`.match(fnNameMatchRegex);
const name = match && match[1];
return name || '';
}
/**
* @param {function} Component
* @param {string} fallback
* @returns {string | undefined}
*/
function getFunctionComponentName(Component, fallback = '') {
return Component.displayName || Component.name || getFunctionName(Component) || fallback;
}
function getWrappedName(outerType, innerType, wrapperName) {
const functionName = getFunctionComponentName(innerType);
return outerType.displayName || (functionName !== '' ? `${wrapperName}(${functionName})` : wrapperName);
}
/**
* cherry-pick from
* https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
* originally forked from recompose/getDisplayName with added IE 11 support
*
* @param {React.ReactType} Component
* @returns {string | undefined}
*/
export default function getDisplayName(Component) {
if (Component == null) {
return undefined;
}
if (typeof Component === 'string') {
return Component;
}
if (typeof Component === 'function') {
return getFunctionComponentName(Component, 'Component');
}
if (typeof Component === 'object') {
switch (Component.$$typeof) {
case ForwardRef:
return getWrappedName(Component, Component.render, 'ForwardRef');
case Memo:
return getWrappedName(Component, Component.type, 'memo');
default:
return undefined;
}
}
return undefined;
}

10
web/node_modules/@material-ui/utils/es/index.js generated vendored Normal file
View file

@ -0,0 +1,10 @@
export { default as chainPropTypes } from './chainPropTypes';
export { default as deepmerge } from './deepmerge';
export { default as elementAcceptingRef } from './elementAcceptingRef';
export { default as elementTypeAcceptingRef } from './elementTypeAcceptingRef';
export { default as exactProp } from './exactProp';
export { default as formatMuiErrorMessage } from './formatMuiErrorMessage';
export { default as getDisplayName } from './getDisplayName';
export { default as HTMLElementType } from './HTMLElementType';
export { default as ponyfillGlobal } from './ponyfillGlobal';
export { default as refType } from './refType';

View file

@ -0,0 +1,3 @@
/* eslint-disable */
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
export default typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();

3
web/node_modules/@material-ui/utils/es/refType.js generated vendored Normal file
View file

@ -0,0 +1,3 @@
import PropTypes from 'prop-types';
const refType = PropTypes.oneOfType([PropTypes.func, PropTypes.object]);
export default refType;