11import get from 'lodash/get' ;
22import isEmpty from 'lodash/isEmpty' ;
3+ import { JSONSchema7Object } from 'json-schema' ;
34
45import {
6+ ALL_OF_KEY ,
57 ANY_OF_KEY ,
68 CONST_KEY ,
79 DEFAULT_KEY ,
810 DEPENDENCIES_KEY ,
9- PROPERTIES_KEY ,
1011 ONE_OF_KEY ,
12+ PROPERTIES_KEY ,
1113 REF_KEY ,
12- ALL_OF_KEY ,
1314} from '../constants' ;
1415import findSchemaDefinition from '../findSchemaDefinition' ;
1516import getClosestMatchingOption from './getClosestMatchingOption' ;
@@ -33,9 +34,8 @@ import isMultiSelect from './isMultiSelect';
3334import isSelect from './isSelect' ;
3435import retrieveSchema , { resolveDependencies } from './retrieveSchema' ;
3536import isConstant from '../isConstant' ;
36- import { JSONSchema7Object } from 'json-schema' ;
37- import isEqual from 'lodash/isEqual' ;
3837import optionsList from '../optionsList' ;
38+ import deepEquals from '../deepEquals' ;
3939
4040const PRIMITIVE_TYPES = [ 'string' , 'number' , 'integer' , 'boolean' , 'null' ] ;
4141
@@ -129,8 +129,7 @@ function maybeAddDefaultToObject<T = any>(
129129 if ( ! isEmpty ( computedDefault ) ) {
130130 obj [ key ] = computedDefault ;
131131 }
132- }
133- // Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
132+ } // Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
134133 // Condition 1: If computedDefault is not empty or if the key is a required field
135134 // Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'
136135 else if (
@@ -271,7 +270,10 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
271270 experimental_dfsb_to_compute ?. constAsDefaults === 'skipOneOf'
272271 ) {
273272 // If we are in a oneOf of a primitive type, then we want to pass constAsDefaults as 'never' for the recursion
274- experimental_dfsb_to_compute = { ...experimental_dfsb_to_compute , constAsDefaults : 'never' } ;
273+ experimental_dfsb_to_compute = {
274+ ...experimental_dfsb_to_compute ,
275+ constAsDefaults : 'never' ,
276+ } ;
275277 }
276278 schemaToCompute = oneOf ! [
277279 getClosestMatchingOption < T , S , F > (
@@ -377,7 +379,7 @@ export function ensureFormDataMatchingSchema<
377379 let validFormData : T | T [ ] | undefined = formData ;
378380 if ( isSelectField ) {
379381 const getOptionsList = optionsList ( schema ) ;
380- const isValid = getOptionsList ?. some ( ( option ) => isEqual ( option . value , formData ) ) ;
382+ const isValid = getOptionsList ?. some ( ( option ) => deepEquals ( option . value , formData ) ) ;
381383 validFormData = isValid ? formData : undefined ;
382384 }
383385
0 commit comments