@rjsf/utils 6.0.0-beta.7 → 6.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -204,7 +204,7 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
204
204
  required,
205
205
  shouldMergeDefaultsIntoFormData = false,
206
206
  } = computeDefaultsProps;
207
- const formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;
207
+ let formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;
208
208
  const schema: S = isObject(rawSchema) ? rawSchema : ({} as S);
209
209
  // Compute the defaults recursively: give highest priority to deepest nodes.
210
210
  let defaults: T | T[] | undefined = parentDefaults;
@@ -212,7 +212,6 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
212
212
  let schemaToCompute: S | null = null;
213
213
  let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;
214
214
  let updatedRecurseList = _recurseList;
215
-
216
215
  if (
217
216
  schema[CONST_KEY] &&
218
217
  experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&
@@ -240,6 +239,13 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
240
239
  if (schemaToCompute && !defaults) {
241
240
  defaults = schema.default as T | undefined;
242
241
  }
242
+
243
+ // If shouldMergeDefaultsIntoFormData is true
244
+ // And the schemaToCompute is set and the rawFormData is not an object
245
+ // Then set the formData to the rawFormData
246
+ if (shouldMergeDefaultsIntoFormData && schemaToCompute && !isObject(rawFormData)) {
247
+ formData = rawFormData as T;
248
+ }
243
249
  } else if (DEPENDENCIES_KEY in schema) {
244
250
  // Get the default if set from properties to ensure the dependencies conditions are resolved based on it
245
251
  const defaultFormData: T = {
@@ -334,7 +334,7 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
334
334
  * @param schema - The schema for which resolving all references is desired
335
335
  * @param rootSchema - The root schema that will be forwarded to all the APIs
336
336
  * @param recurseList - List of $refs already resolved to prevent recursion
337
- * @param baseURI - The base URI to be used for resolving relative references
337
+ * @param [baseURI] - The base URI to be used for resolving relative references
338
338
  * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved
339
339
  */
340
340
  export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
@@ -432,7 +432,7 @@ export function stubExistingAdditionalProperties<
432
432
  validator,
433
433
  { allOf: Object.values(matchingProperties) } as S,
434
434
  rootSchema,
435
- formData as T,
435
+ get(formData, [key]) as T,
436
436
  experimental_customMergeAllOf,
437
437
  );
438
438
  set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
@@ -578,7 +578,7 @@ export function retrieveSchemaInternal<
578
578
  validator,
579
579
  { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,
580
580
  rootSchema,
581
- rawFormData as T,
581
+ get(rawFormData, [key]) as T,
582
582
  experimental_customMergeAllOf,
583
583
  );
584
584
  }
package/src/types.ts CHANGED
@@ -370,9 +370,10 @@ export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
370
370
  };
371
371
 
372
372
  /** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
373
- * widget level when no field-level value of the option is provided.
373
+ * widget level when no field-level value of the option is provided. Extends GenericObjectType to support allowing users
374
+ * to provide any value they need for their customizations.
374
375
  */
375
- export type GlobalUISchemaOptions = {
376
+ export type GlobalUISchemaOptions = GenericObjectType & {
376
377
  /** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
377
378
  addable?: boolean;
378
379
  /** Flag, if set to `true`, array items can be copied (defaults to false) */