RAHHH
This commit is contained in:
46
backend/frontend/node_modules/uncontrollable/lib/esm/utils.js
generated
vendored
Normal file
46
backend/frontend/node_modules/uncontrollable/lib/esm/utils.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import invariant from 'invariant';
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
function readOnlyPropType(handler, name) {
|
||||
return function (props, propName) {
|
||||
if (props[propName] !== undefined) {
|
||||
if (!props[handler]) {
|
||||
return new Error("You have provided a `" + propName + "` prop to `" + name + "` " + ("without an `" + handler + "` handler prop. This will render a read-only field. ") + ("If the field should be mutable use `" + defaultKey(propName) + "`. ") + ("Otherwise, set `" + handler + "`."));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function uncontrolledPropTypes(controlledValues, displayName) {
|
||||
var propTypes = {};
|
||||
Object.keys(controlledValues).forEach(function (prop) {
|
||||
// add default propTypes for folks that use runtime checks
|
||||
propTypes[defaultKey(prop)] = noop;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var handler = controlledValues[prop];
|
||||
!(typeof handler === 'string' && handler.trim().length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop) : invariant(false) : void 0;
|
||||
propTypes[prop] = readOnlyPropType(handler, displayName);
|
||||
}
|
||||
});
|
||||
return propTypes;
|
||||
}
|
||||
export function isProp(props, prop) {
|
||||
return props[prop] !== undefined;
|
||||
}
|
||||
export function defaultKey(key) {
|
||||
return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
export function canAcceptRef(component) {
|
||||
return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent);
|
||||
}
|
||||
Reference in New Issue
Block a user