@rjsf/utils
Advanced tools
Comparing version 5.24.1 to 5.24.2
@@ -1,3 +0,2 @@ | ||
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that | ||
* assumes all functions are equivalent. | ||
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent. | ||
* | ||
@@ -8,2 +7,3 @@ * @param a - The first element to compare | ||
*/ | ||
export default function deepEquals(a: any, b: any): boolean; | ||
declare const deepEquals: <A, B>(a: A, b: B) => boolean; | ||
export default deepEquals; |
@@ -1,4 +0,3 @@ | ||
import isEqualWith from 'lodash/isEqualWith'; | ||
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that | ||
* assumes all functions are equivalent. | ||
import { createCustomEqual } from 'fast-equals'; | ||
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent. | ||
* | ||
@@ -9,12 +8,15 @@ * @param a - The first element to compare | ||
*/ | ||
export default function deepEquals(a, b) { | ||
return isEqualWith(a, b, (obj, other) => { | ||
if (typeof obj === 'function' && typeof other === 'function') { | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
return true; | ||
} | ||
return undefined; // fallback to default isEquals behavior | ||
}); | ||
} | ||
const deepEquals = createCustomEqual({ | ||
createCustomConfig: () => ({ | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
// | ||
// Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function. | ||
// https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99 | ||
areFunctionsEqual(_a, b) { | ||
return typeof b === 'function'; | ||
}, | ||
}), | ||
}); | ||
export default deepEquals; | ||
//# sourceMappingURL=deepEquals.js.map |
@@ -7,5 +7,5 @@ /** | ||
* | ||
* @param {unknown} a - The first object, representing the original data to compare. | ||
* @param {unknown} b - The second object, representing the updated data to compare. | ||
* @returns {string[]} - An array of field names that have changed. | ||
* @param a - The first object, representing the original data to compare. | ||
* @param b - The second object, representing the updated data to compare. | ||
* @returns - An array of field names that have changed. | ||
* | ||
@@ -12,0 +12,0 @@ * @example |
@@ -13,5 +13,5 @@ import keys from 'lodash/keys'; | ||
* | ||
* @param {unknown} a - The first object, representing the original data to compare. | ||
* @param {unknown} b - The second object, representing the updated data to compare. | ||
* @returns {string[]} - An array of field names that have changed. | ||
* @param a - The first object, representing the original data to compare. | ||
* @param b - The second object, representing the updated data to compare. | ||
* @returns - An array of field names that have changed. | ||
* | ||
@@ -18,0 +18,0 @@ * @example |
@@ -42,4 +42,7 @@ import rangeSpec from './rangeSpec'; | ||
} | ||
if (options.accept) { | ||
inputProps.accept = options.accept; | ||
} | ||
return inputProps; | ||
} | ||
//# sourceMappingURL=getInputProps.js.map |
@@ -33,3 +33,4 @@ import get from 'lodash/get'; | ||
const mapped = overrideArray.map((value, idx) => { | ||
if (overrideOppositeArray[idx]) { | ||
// We want to explicitly make sure that the value is NOT undefined since null, 0 and empty space are valid values | ||
if (overrideOppositeArray[idx] !== undefined) { | ||
return mergeDefaultsWithFormData(defaultsArray[idx], formData[idx], mergeExtraArrayDefaults, defaultSupercedesUndefined, overrideFormDataWithDefaults); | ||
@@ -36,0 +37,0 @@ } |
@@ -130,2 +130,4 @@ import type { ButtonHTMLAttributes, ChangeEvent, ComponentType, HTMLAttributes, ReactElement, ReactNode, StyleHTMLAttributes } from 'react'; | ||
autoComplete?: HTMLInputElement['autocomplete']; | ||
/** Specifies a filter for what file types the user can upload. */ | ||
accept?: HTMLInputElement['accept']; | ||
}; | ||
@@ -132,0 +134,0 @@ /** Type describing an id used for a field in the `IdSchema` */ |
{ | ||
"name": "@rjsf/utils", | ||
"version": "5.24.1", | ||
"version": "5.24.2", | ||
"main": "dist/index.js", | ||
@@ -39,2 +39,3 @@ "module": "lib/index.js", | ||
"dependencies": { | ||
"fast-equals": "^5.2.2", | ||
"json-schema-merge-allof": "^0.8.1", | ||
@@ -89,3 +90,3 @@ "jsonpointer": "^5.0.1", | ||
"license": "Apache-2.0", | ||
"gitHead": "8ef623853bfa929342147416e814630d9bb40d43" | ||
"gitHead": "3965cb9d654e59890dd2b5c0c92b8d18d2b8b3b0" | ||
} |
@@ -1,5 +0,4 @@ | ||
import isEqualWith from 'lodash/isEqualWith'; | ||
import { createCustomEqual } from 'fast-equals'; | ||
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that | ||
* assumes all functions are equivalent. | ||
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent. | ||
* | ||
@@ -10,11 +9,15 @@ * @param a - The first element to compare | ||
*/ | ||
export default function deepEquals(a: any, b: any): boolean { | ||
return isEqualWith(a, b, (obj: any, other: any) => { | ||
if (typeof obj === 'function' && typeof other === 'function') { | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
return true; | ||
} | ||
return undefined; // fallback to default isEquals behavior | ||
}); | ||
} | ||
const deepEquals = createCustomEqual({ | ||
createCustomConfig: () => ({ | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
// | ||
// Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function. | ||
// https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99 | ||
areFunctionsEqual(_a, b) { | ||
return typeof b === 'function'; | ||
}, | ||
}), | ||
}); | ||
export default deepEquals; |
@@ -14,5 +14,5 @@ import keys from 'lodash/keys'; | ||
* | ||
* @param {unknown} a - The first object, representing the original data to compare. | ||
* @param {unknown} b - The second object, representing the updated data to compare. | ||
* @returns {string[]} - An array of field names that have changed. | ||
* @param a - The first object, representing the original data to compare. | ||
* @param b - The second object, representing the updated data to compare. | ||
* @returns - An array of field names that have changed. | ||
* | ||
@@ -19,0 +19,0 @@ * @example |
@@ -54,3 +54,7 @@ import rangeSpec from './rangeSpec'; | ||
if (options.accept) { | ||
inputProps.accept = options.accept as string; | ||
} | ||
return inputProps; | ||
} |
@@ -44,3 +44,4 @@ import get from 'lodash/get'; | ||
const mapped = overrideArray.map((value, idx) => { | ||
if (overrideOppositeArray[idx]) { | ||
// We want to explicitly make sure that the value is NOT undefined since null, 0 and empty space are valid values | ||
if (overrideOppositeArray[idx] !== undefined) { | ||
return mergeDefaultsWithFormData<any>( | ||
@@ -47,0 +48,0 @@ defaultsArray[idx], |
@@ -153,2 +153,4 @@ import type { | ||
autoComplete?: HTMLInputElement['autocomplete']; | ||
/** Specifies a filter for what file types the user can upload. */ | ||
accept?: HTMLInputElement['accept']; | ||
}; | ||
@@ -155,0 +157,0 @@ |
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
Sorry, the diff of this file is not supported yet
1824410
22072
7
+ Addedfast-equals@^5.2.2
+ Addedfast-equals@5.2.2(transitive)