Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fluentui/react-proptypes

Package Overview
Dependencies
Maintainers
12
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluentui/react-proptypes - npm Package Compare versions

Comparing version 0.66.3 to 0.66.4

238

dist/dts/src/index.js

@@ -125,20 +125,22 @@ "use strict";

*/
var every = function (validators) { return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
if (!Array.isArray(validators)) {
throw new Error([
'Invalid argument supplied to every, expected an instance of array.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
return _.first(_.compact(_.map(validators, function (validator) {
if (typeof validator !== 'function') {
throw new Error("every() argument \"validators\" should contain functions, found: " + typeOf(validator) + ".");
var every = function (validators) {
return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
return validator.apply(void 0, __spreadArray([props, propName, componentName], args));
}))); // we can only return one error at a time
}; };
if (!Array.isArray(validators)) {
throw new Error([
'Invalid argument supplied to every, expected an instance of array.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
return _.first(_.compact(_.map(validators, function (validator) {
if (typeof validator !== 'function') {
throw new Error("every() argument \"validators\" should contain functions, found: " + typeOf(validator) + ".");
}
return validator.apply(void 0, __spreadArray([props, propName, componentName], args));
}))); // we can only return one error at a time
};
};
exports.every = every;

@@ -149,27 +151,29 @@ /**

*/
var some = function (validators) { return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
if (!Array.isArray(validators)) {
throw new Error([
'Invalid argument supplied to some, expected an instance of array.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
var errors = _.compact(_.map(validators, function (validator) {
if (!_.isFunction(validator)) {
throw new Error("some() argument \"validators\" should contain functions, found: " + typeOf(validator) + ".");
var some = function (validators) {
return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
return validator.apply(void 0, __spreadArray([props, propName, componentName], args));
}));
// fail only if all validators failed
if (errors.length === validators.length) {
var error = new Error('One of these validators must pass:');
error.message += "\n" + _.map(errors, function (err) { return "- " + err.message; }).join('\n');
return error;
}
return undefined;
}; };
if (!Array.isArray(validators)) {
throw new Error([
'Invalid argument supplied to some, expected an instance of array.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
var errors = _.compact(_.map(validators, function (validator) {
if (!_.isFunction(validator)) {
throw new Error("some() argument \"validators\" should contain functions, found: " + typeOf(validator) + ".");
}
return validator.apply(void 0, __spreadArray([props, propName, componentName], args));
}));
// fail only if all validators failed
if (errors.length === validators.length) {
var error = new Error('One of these validators must pass:');
error.message += "\n" + _.map(errors, function (err) { return "- " + err.message; }).join('\n');
return error;
}
return undefined;
};
};
exports.some = some;

@@ -181,46 +185,48 @@ /**

*/
var givenProps = function (propsShape, validator) { return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
if (!_.isPlainObject(propsShape)) {
throw new Error([
'Invalid argument supplied to givenProps, expected an object.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
if (typeof validator !== 'function') {
throw new Error([
'Invalid argument supplied to givenProps, expected a function.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
var shouldValidate = _.keys(propsShape).every(function (key) {
var val = propsShape[key];
// require propShape validators to pass or prop values to match
return typeof val === 'function' ? !val.apply(void 0, __spreadArray([props, key, componentName], args)) : val === props[propName];
});
if (!shouldValidate)
return undefined;
var error = validator.apply(void 0, __spreadArray([props, propName, componentName], args));
if (error) {
// poor mans shallow pretty print, prevents JSON circular reference errors
var prettyProps = "{ " + _.keys(_.pick(props, _.keys(propsShape)))
.map(function (key) {
var val = props[key];
var renderedValue = val;
if (typeof val === 'string')
renderedValue = "\"" + val + "\"";
else if (Array.isArray(val))
renderedValue = "[" + val.join(', ') + "]";
else if (_.isObject(val))
renderedValue = '{...}';
return key + ": " + renderedValue;
})
.join(', ') + " }";
error.message = "Given props " + prettyProps + ": " + error.message;
return error;
}
}; };
var givenProps = function (propsShape, validator) {
return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
if (!_.isPlainObject(propsShape)) {
throw new Error([
'Invalid argument supplied to givenProps, expected an object.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
if (typeof validator !== 'function') {
throw new Error([
'Invalid argument supplied to givenProps, expected a function.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
var shouldValidate = _.keys(propsShape).every(function (key) {
var val = propsShape[key];
// require propShape validators to pass or prop values to match
return typeof val === 'function' ? !val.apply(void 0, __spreadArray([props, key, componentName], args)) : val === props[propName];
});
if (!shouldValidate)
return undefined;
var error = validator.apply(void 0, __spreadArray([props, propName, componentName], args));
if (error) {
// poor mans shallow pretty print, prevents JSON circular reference errors
var prettyProps = "{ " + _.keys(_.pick(props, _.keys(propsShape)))
.map(function (key) {
var val = props[key];
var renderedValue = val;
if (typeof val === 'string')
renderedValue = "\"" + val + "\"";
else if (Array.isArray(val))
renderedValue = "[" + val.join(', ') + "]";
else if (_.isObject(val))
renderedValue = '{...}';
return key + ": " + renderedValue;
})
.join(', ') + " }";
error.message = "Given props " + prettyProps + ": " + error.message;
return error;
}
};
};
exports.givenProps = givenProps;

@@ -334,37 +340,39 @@ /**

*/
var deprecate = function (help, validator) { return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
if (typeof help !== 'string') {
throw new Error([
'Invalid `help` argument supplied to deprecate, expected a string.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
// skip if prop is undefined
if (props[propName] === undefined)
return undefined;
// deprecation error and help
var error = new Error("The `" + propName + "` prop in `" + componentName + "` is deprecated.");
if (help)
error.message += " " + help;
// add optional validation error message
if (validator) {
if (typeof validator === 'function') {
var validationError = validator.apply(void 0, __spreadArray([props, propName, componentName], args));
if (validationError) {
error.message = error.message + " " + validationError.message;
}
var deprecate = function (help, validator) {
return function (props, propName, componentName) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
else {
if (typeof help !== 'string') {
throw new Error([
'Invalid argument supplied to deprecate, expected a function.',
'Invalid `help` argument supplied to deprecate, expected a string.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
}
return error;
}; };
// skip if prop is undefined
if (props[propName] === undefined)
return undefined;
// deprecation error and help
var error = new Error("The `" + propName + "` prop in `" + componentName + "` is deprecated.");
if (help)
error.message += " " + help;
// add optional validation error message
if (validator) {
if (typeof validator === 'function') {
var validationError = validator.apply(void 0, __spreadArray([props, propName, componentName], args));
if (validationError) {
error.message = error.message + " " + validationError.message;
}
}
else {
throw new Error([
'Invalid argument supplied to deprecate, expected a function.',
"See `" + propName + "` prop in `" + componentName + "`.",
].join(' '));
}
}
return error;
};
};
exports.deprecate = deprecate;

@@ -371,0 +379,0 @@ exports.accessibility = PropTypes.func;

{
"name": "@fluentui/react-proptypes",
"description": "Set of custom reusable PropTypes for React components, some of them are specific for Fluent UI.",
"version": "0.66.3",
"version": "0.66.4",
"author": "Oleksandr Fediashov <olfedias@microsoft.com>",

@@ -41,3 +41,3 @@ "bugs": "https://github.com/microsoft/fluentui/issues",

"types": "dist/es/index.d.ts",
"gitHead": "8c8cd54560b9a7af71ab1733885cb5ef10707f7d"
"gitHead": "d265bbce2d0d145ea5ed5ac5840138d24aee24ba"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc