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

@rjsf/utils

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjsf/utils - npm Package Compare versions

Comparing version 5.17.1 to 5.18.0

2

lib/enums.d.ts

@@ -71,3 +71,3 @@ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the

*/
FilesInfo = "<strong>%1</strong> (%2, %3 bytes)"
FilesInfo = "**%1** (%2, %3 bytes)"
}

@@ -74,4 +74,4 @@ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the

*/
TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
TranslatableString["FilesInfo"] = "**%1** (%2, %3 bytes)";
})(TranslatableString || (TranslatableString = {}));
//# sourceMappingURL=enums.js.map

@@ -84,6 +84,12 @@ import get from 'lodash/get';

const isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;
// Store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
// If emptyObjectFields 'skipEmptyDefaults' store computedDefault if it's a non-empty object(e.g. not {})
if (emptyObjectFields === 'skipEmptyDefaults') {
if (!isEmpty(computedDefault)) {
obj[key] = computedDefault;
}
}
// Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
// Condition 1: If computedDefault is not empty or if the key is a required field
// Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'
if ((!isEmpty(computedDefault) || requiredFields.includes(key)) &&
else if ((!isEmpty(computedDefault) || requiredFields.includes(key)) &&
(isSelfOrParentRequired || emptyObjectFields !== 'populateRequiredDefaults')) {

@@ -96,5 +102,7 @@ obj[key] = computedDefault;

// Condition 1: computedDefault is not undefined
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or if the key is a required field
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults) or if the key is a required field
computedDefault !== undefined &&
(emptyObjectFields === 'populateAllDefaults' || requiredFields.includes(key))) {
(emptyObjectFields === 'populateAllDefaults' ||
emptyObjectFields === 'skipEmptyDefaults' ||
requiredFields.includes(key))) {
obj[key] = computedDefault;

@@ -122,3 +130,3 @@ }

export function computeDefaults(validator, rawSchema, { parentDefaults, rawFormData, rootSchema = {}, includeUndefinedValues = false, _recurseList = [], experimental_defaultFormStateBehavior = undefined, required, } = {}) {
var _a, _b;
var _a, _b, _c, _d;
const formData = (isObject(rawFormData) ? rawFormData : {});

@@ -257,2 +265,5 @@ const schema = isObject(rawSchema) ? rawSchema : {};

const ignoreMinItemsFlagSet = ((_b = experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : experimental_defaultFormStateBehavior.arrayMinItems) === null || _b === void 0 ? void 0 : _b.populate) === 'requiredOnly';
const isSkipEmptyDefaults = (experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : experimental_defaultFormStateBehavior.emptyObjectFields) === 'skipEmptyDefaults';
const computeSkipPopulate = (_d = (_c = experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : experimental_defaultFormStateBehavior.arrayMinItems) === null || _c === void 0 ? void 0 : _c.computeSkipPopulate) !== null && _d !== void 0 ? _d : (() => false);
const emptyDefault = isSkipEmptyDefaults ? undefined : [];
// Inject defaults into existing array defaults

@@ -291,3 +302,3 @@ if (Array.isArray(defaults)) {

if (neverPopulate) {
return defaults !== null && defaults !== void 0 ? defaults : [];
return defaults !== null && defaults !== void 0 ? defaults : emptyDefault;
}

@@ -302,4 +313,5 @@ if (ignoreMinItemsFlagSet && !required) {

isMultiSelect(validator, schema, rootSchema) ||
computeSkipPopulate(validator, schema, rootSchema) ||
schema.minItems <= defaultsLength) {
return defaults ? defaults : [];
return defaults ? defaults : emptyDefault;
}

@@ -306,0 +318,0 @@ const defaultEntries = (defaults || []);

@@ -30,2 +30,12 @@ import type { ButtonHTMLAttributes, ChangeEvent, ComponentType, HTMLAttributes, ReactElement, ReactNode, StyleHTMLAttributes } from 'react';

populate?: 'all' | 'requiredOnly' | 'never';
/** A function that determines whether to skip populating the array with default values based on the provided validator,
* schema, and root schema.
* If the function returns true, the array will not be populated with default values.
* If the function returns false, the array will be populated with default values according to the `populate` option.
* @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions
* @param schema - The schema for which resolving a condition is desired
* @param [rootSchema] - The root schema that will be forwarded to all the APIs
* @returns A boolean indicating whether to skip populating the array with default values.
*/
computeSkipPopulate?: <T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, rootSchema?: S) => boolean;
/** When `formData` is provided and does not contain `minItems` worth of data, this flag (`false` by default) controls

@@ -54,4 +64,5 @@ * whether the extra data provided by the defaults is appended onto the existing `formData` items to ensure the

* - `skipDefaults`: Does not set defaults |
* - `skipEmptyDefaults`: Does not set an empty default. It will still apply the default value if a default property is defined in your schema. |
*/
emptyObjectFields?: 'populateAllDefaults' | 'populateRequiredDefaults' | 'skipDefaults';
emptyObjectFields?: 'populateAllDefaults' | 'populateRequiredDefaults' | 'skipDefaults' | 'skipEmptyDefaults';
/**

@@ -58,0 +69,0 @@ * Optional flag to compute the default form state using allOf and if/then/else schemas. Defaults to `skipDefaults'.

{
"name": "@rjsf/utils",
"version": "5.17.1",
"version": "5.18.0",
"main": "dist/index.js",

@@ -89,3 +89,3 @@ "module": "lib/index.js",

"license": "Apache-2.0",
"gitHead": "4d13c51c861fa0d21ec6e40881a21ba16c72d8bd"
"gitHead": "7059e5ec14e0e454fe016aa367d9b65208f3bd8d"
}

@@ -73,3 +73,3 @@ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the

*/
FilesInfo = '<strong>%1</strong> (%2, %3 bytes)',
FilesInfo = '**%1** (%2, %3 bytes)',
}

@@ -113,6 +113,13 @@ import get from 'lodash/get';

const isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;
// Store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
// If emptyObjectFields 'skipEmptyDefaults' store computedDefault if it's a non-empty object(e.g. not {})
if (emptyObjectFields === 'skipEmptyDefaults') {
if (!isEmpty(computedDefault)) {
obj[key] = computedDefault;
}
}
// Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
// Condition 1: If computedDefault is not empty or if the key is a required field
// Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'
if (
else if (
(!isEmpty(computedDefault) || requiredFields.includes(key)) &&

@@ -126,5 +133,7 @@ (isSelfOrParentRequired || emptyObjectFields !== 'populateRequiredDefaults')

// Condition 1: computedDefault is not undefined
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or if the key is a required field
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults) or if the key is a required field
computedDefault !== undefined &&
(emptyObjectFields === 'populateAllDefaults' || requiredFields.includes(key))
(emptyObjectFields === 'populateAllDefaults' ||
emptyObjectFields === 'skipEmptyDefaults' ||
requiredFields.includes(key))
) {

@@ -345,3 +354,8 @@ obj[key] = computedDefault;

const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === 'requiredOnly';
const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === 'skipEmptyDefaults';
const computeSkipPopulate =
experimental_defaultFormStateBehavior?.arrayMinItems?.computeSkipPopulate ?? (() => false);
const emptyDefault = isSkipEmptyDefaults ? undefined : [];
// Inject defaults into existing array defaults

@@ -381,3 +395,3 @@ if (Array.isArray(defaults)) {

if (neverPopulate) {
return defaults ?? [];
return defaults ?? emptyDefault;
}

@@ -394,5 +408,6 @@ if (ignoreMinItemsFlagSet && !required) {

isMultiSelect<T, S, F>(validator, schema, rootSchema) ||
computeSkipPopulate<T, S, F>(validator, schema, rootSchema) ||
schema.minItems <= defaultsLength
) {
return defaults ? defaults : [];
return defaults ? defaults : emptyDefault;
}

@@ -399,0 +414,0 @@

@@ -44,2 +44,16 @@ import type {

populate?: 'all' | 'requiredOnly' | 'never';
/** A function that determines whether to skip populating the array with default values based on the provided validator,
* schema, and root schema.
* If the function returns true, the array will not be populated with default values.
* If the function returns false, the array will be populated with default values according to the `populate` option.
* @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions
* @param schema - The schema for which resolving a condition is desired
* @param [rootSchema] - The root schema that will be forwarded to all the APIs
* @returns A boolean indicating whether to skip populating the array with default values.
*/
computeSkipPopulate?: <T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
validator: ValidatorType<T, S, F>,
schema: S,
rootSchema?: S
) => boolean;
/** When `formData` is provided and does not contain `minItems` worth of data, this flag (`false` by default) controls

@@ -69,4 +83,5 @@ * whether the extra data provided by the defaults is appended onto the existing `formData` items to ensure the

* - `skipDefaults`: Does not set defaults |
* - `skipEmptyDefaults`: Does not set an empty default. It will still apply the default value if a default property is defined in your schema. |
*/
emptyObjectFields?: 'populateAllDefaults' | 'populateRequiredDefaults' | 'skipDefaults';
emptyObjectFields?: 'populateAllDefaults' | 'populateRequiredDefaults' | 'skipDefaults' | 'skipEmptyDefaults';
/**

@@ -73,0 +88,0 @@ * Optional flag to compute the default form state using allOf and if/then/else schemas. Defaults to `skipDefaults'.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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