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

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.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/isObject.ts", "../src/allowAdditionalItems.ts", "../src/asNumber.ts", "../src/constants.ts", "../src/getUiOptions.ts", "../src/canExpand.ts", "../src/createErrorHandler.ts", "../src/deepEquals.ts", "../src/schema/findFieldInSchema.ts", "../src/schema/findSelectedOptionInXxxOf.ts", "../src/schema/retrieveSchema.ts", "../src/findSchemaDefinition.ts", "../src/getDiscriminatorFieldFromSchema.ts", "../src/guessType.ts", "../src/mergeSchemas.ts", "../src/getSchemaType.ts", "../src/schema/getFirstMatchingOption.ts", "../src/getOptionMatchingSimpleDiscriminator.ts", "../src/schema/getFromSchema.ts", "../src/schema/getDefaultFormState.ts", "../src/schema/getClosestMatchingOption.ts", "../src/isFixedItems.ts", "../src/mergeDefaultsWithFormData.ts", "../src/mergeObjects.ts", "../src/isConstant.ts", "../src/schema/isSelect.ts", "../src/schema/isMultiSelect.ts", "../src/constIsAjvDataReference.ts", "../src/optionsList.ts", "../src/toConstant.ts", "../src/isCustomWidget.ts", "../src/schema/isFilesArray.ts", "../src/schema/getDisplayLabel.ts", "../src/schema/sanitizeDataForNewSchema.ts", "../src/schema/toIdSchema.ts", "../src/schema/toPathSchema.ts", "../src/createSchemaUtils.ts", "../src/dataURItoBlob.ts", "../src/pad.ts", "../src/dateRangeOptions.ts", "../src/replaceStringParameters.ts", "../src/englishStringTranslator.ts", "../src/enumOptionsValueForIndex.ts", "../src/enumOptionsDeselectValue.ts", "../src/enumOptionsIsSelected.ts", "../src/enumOptionsIndexForValue.ts", "../src/enumOptionsSelectValue.ts", "../src/ErrorSchemaBuilder.ts", "../src/getDateElementProps.ts", "../src/rangeSpec.ts", "../src/getInputProps.ts", "../src/getSubmitButtonOptions.ts", "../src/getTemplate.ts", "../src/getTestIds.ts", "../src/getWidget.tsx", "../src/hashForSchema.ts", "../src/hasWidget.ts", "../src/idGenerators.ts", "../src/labelValue.ts", "../src/localToUTC.ts", "../src/lookupFromFormContext.ts", "../src/orderProperties.ts", "../src/parseDateString.ts", "../src/schemaRequiresTrueValue.ts", "../src/shouldRender.ts", "../src/toDateString.ts", "../src/toErrorList.ts", "../src/toErrorSchema.ts", "../src/unwrapErrorHandler.ts", "../src/utcToLocal.ts", "../src/validationDataMerge.ts", "../src/withIdRefPrefix.ts", "../src/getChangedFields.ts", "../src/enums.ts", "../src/parser/schemaParser.ts", "../src/parser/ParserValidator.ts"],
4
- "sourcesContent": ["import allowAdditionalItems from './allowAdditionalItems';\nimport asNumber from './asNumber';\nimport canExpand from './canExpand';\nimport createErrorHandler from './createErrorHandler';\nimport createSchemaUtils from './createSchemaUtils';\nimport dataURItoBlob from './dataURItoBlob';\nimport dateRangeOptions from './dateRangeOptions';\nimport deepEquals from './deepEquals';\nimport englishStringTranslator from './englishStringTranslator';\nimport enumOptionsDeselectValue from './enumOptionsDeselectValue';\nimport enumOptionsIndexForValue from './enumOptionsIndexForValue';\nimport enumOptionsIsSelected from './enumOptionsIsSelected';\nimport enumOptionsSelectValue from './enumOptionsSelectValue';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport ErrorSchemaBuilder from './ErrorSchemaBuilder';\nimport findSchemaDefinition from './findSchemaDefinition';\nimport getDateElementProps, { type DateElementFormat } from './getDateElementProps';\nimport getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';\nimport getInputProps from './getInputProps';\nimport getSchemaType from './getSchemaType';\nimport getSubmitButtonOptions from './getSubmitButtonOptions';\nimport getTemplate from './getTemplate';\nimport getTestIds from './getTestIds';\nimport getUiOptions from './getUiOptions';\nimport getWidget from './getWidget';\nimport guessType from './guessType';\nimport hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema';\nimport hasWidget from './hasWidget';\nimport {\n ariaDescribedByIds,\n buttonId,\n descriptionId,\n errorId,\n examplesId,\n helpId,\n optionId,\n titleId,\n} from './idGenerators';\nimport isConstant from './isConstant';\nimport isCustomWidget from './isCustomWidget';\nimport isFixedItems from './isFixedItems';\nimport isObject from './isObject';\nimport labelValue from './labelValue';\nimport localToUTC from './localToUTC';\nimport lookupFromFormContext from './lookupFromFormContext';\nimport mergeDefaultsWithFormData from './mergeDefaultsWithFormData';\nimport mergeObjects from './mergeObjects';\nimport mergeSchemas from './mergeSchemas';\nimport optionsList from './optionsList';\nimport orderProperties from './orderProperties';\nimport pad from './pad';\nimport parseDateString from './parseDateString';\nimport rangeSpec from './rangeSpec';\nimport replaceStringParameters from './replaceStringParameters';\nimport schemaRequiresTrueValue from './schemaRequiresTrueValue';\nimport shouldRender from './shouldRender';\nimport toConstant from './toConstant';\nimport toDateString from './toDateString';\nimport toErrorList from './toErrorList';\nimport toErrorSchema from './toErrorSchema';\nimport unwrapErrorHandler from './unwrapErrorHandler';\nimport utcToLocal from './utcToLocal';\nimport validationDataMerge from './validationDataMerge';\nimport withIdRefPrefix from './withIdRefPrefix';\nimport getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';\nimport getChangedFields from './getChangedFields';\n\nexport * from './types';\nexport * from './enums';\n\nexport * from './constants';\nexport * from './parser';\nexport * from './schema';\n\nexport {\n allowAdditionalItems,\n ariaDescribedByIds,\n asNumber,\n buttonId,\n canExpand,\n createErrorHandler,\n createSchemaUtils,\n DateElementFormat,\n dataURItoBlob,\n dateRangeOptions,\n deepEquals,\n descriptionId,\n englishStringTranslator,\n enumOptionsDeselectValue,\n enumOptionsIndexForValue,\n enumOptionsIsSelected,\n enumOptionsSelectValue,\n enumOptionsValueForIndex,\n errorId,\n examplesId,\n ErrorSchemaBuilder,\n findSchemaDefinition,\n getChangedFields,\n getDateElementProps,\n getDiscriminatorFieldFromSchema,\n getInputProps,\n getOptionMatchingSimpleDiscriminator,\n getSchemaType,\n getSubmitButtonOptions,\n getTemplate,\n getTestIds,\n getUiOptions,\n getWidget,\n guessType,\n hasWidget,\n hashForSchema,\n hashObject,\n hashString,\n helpId,\n isConstant,\n isCustomWidget,\n isFixedItems,\n isObject,\n labelValue,\n localToUTC,\n lookupFromFormContext,\n mergeDefaultsWithFormData,\n mergeObjects,\n mergeSchemas,\n optionId,\n optionsList,\n orderProperties,\n pad,\n parseDateString,\n rangeSpec,\n replaceStringParameters,\n schemaRequiresTrueValue,\n shouldRender,\n sortedJSONStringify,\n titleId,\n toConstant,\n toDateString,\n toErrorList,\n toErrorSchema,\n unwrapErrorHandler,\n utcToLocal,\n validationDataMerge,\n withIdRefPrefix,\n};\n", "/** Determines whether a `thing` is an object for the purposes of RJSF. In this case, `thing` is an object if it has\n * the type `object` but is NOT null, an array or a File.\n *\n * @param thing - The thing to check to see whether it is an object\n * @returns - True if it is a non-null, non-array, non-File object\n */\nexport default function isObject(thing: any): thing is object {\n if (typeof thing !== 'object' || thing === null) {\n return false;\n }\n // lastModified is guaranteed to be a number on a File instance\n // as per https://w3c.github.io/FileAPI/#dfn-lastModified\n if (typeof thing.lastModified === 'number' && typeof File !== 'undefined' && thing instanceof File) {\n return false;\n }\n // getMonth is guaranteed to be a method on a Date instance\n // as per https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmonth\n if (typeof thing.getMonth === 'function' && typeof Date !== 'undefined' && thing instanceof Date) {\n return false;\n }\n return !Array.isArray(thing);\n}\n", "import isObject from './isObject';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an\n * object. The user is warned in the console if `schema.additionalItems` has the value `true`.\n *\n * @param schema - The schema object to check\n * @returns - True if additional items is allowed, otherwise false\n */\nexport default function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n if (schema.additionalItems === true) {\n console.warn('additionalItems=true is currently not supported');\n }\n return isObject(schema.additionalItems);\n}\n", "/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a\n * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be\n * in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned\n * because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by\n * `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.\n *\n * @param value - The string or null value to convert to a number\n * @returns - The `value` converted to a number when appropriate, otherwise the `value`\n */\nexport default function asNumber(value: string | null) {\n if (value === '') {\n return undefined;\n }\n if (value === null) {\n return null;\n }\n if (/\\.$/.test(value)) {\n // '3.' can't really be considered a number even if it parses in js. The\n // user is most likely entering a float.\n return value;\n }\n if (/\\.0$/.test(value)) {\n // we need to return this as a string here, to allow for input like 3.07\n return value;\n }\n\n if (/\\.\\d*0$/.test(value)) {\n // It's a number, that's cool - but we need it as a string so it doesn't screw\n // with the user when entering dollar amounts or other values (such as those with\n // specific precision or number of significant digits)\n return value;\n }\n\n const n = Number(value);\n const valid = typeof n === 'number' && !Number.isNaN(n);\n\n return valid ? n : value;\n}\n", "/** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various\n * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and\n * `RJSF_ADDITIONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`\n * utility.\n */\nexport const ADDITIONAL_PROPERTY_FLAG = '__additional_property';\nexport const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';\nexport const ALL_OF_KEY = 'allOf';\nexport const ANY_OF_KEY = 'anyOf';\nexport const CONST_KEY = 'const';\nexport const DEFAULT_KEY = 'default';\nexport const DEFINITIONS_KEY = 'definitions';\nexport const DEPENDENCIES_KEY = 'dependencies';\nexport const ENUM_KEY = 'enum';\nexport const ERRORS_KEY = '__errors';\nexport const ID_KEY = '$id';\nexport const IF_KEY = 'if';\nexport const ITEMS_KEY = 'items';\nexport const JUNK_OPTION_ID = '_$junk_option_schema_id$_';\nexport const NAME_KEY = '$name';\nexport const ONE_OF_KEY = 'oneOf';\nexport const PATTERN_PROPERTIES_KEY = 'patternProperties';\nexport const PROPERTIES_KEY = 'properties';\nexport const READONLY_KEY = 'readonly';\nexport const REQUIRED_KEY = 'required';\nexport const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';\nexport const REF_KEY = '$ref';\nexport const SCHEMA_KEY = '$schema';\n/** The path of the discriminator value returned by the schema endpoint.\n * The discriminator is the value in a `oneOf` that determines which option is selected.\n */\nexport const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];\n/** The name of the `formContext` attribute in the React JSON Schema Form Registry\n */\nexport const FORM_CONTEXT_NAME = 'formContext';\n\n/** The name of the `layoutGridLookupMap` attribute in the form context\n */\nexport const LOOKUP_MAP_NAME = 'layoutGridLookupMap';\nexport const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';\nexport const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';\nexport const UI_FIELD_KEY = 'ui:field';\nexport const UI_WIDGET_KEY = 'ui:widget';\nexport const UI_OPTIONS_KEY = 'ui:options';\nexport const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';\n\n/** The JSON Schema version strings\n */\nexport const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';\n", "import { UI_OPTIONS_KEY, UI_WIDGET_KEY } from './constants';\nimport isObject from './isObject';\nimport { FormContextType, GlobalUISchemaOptions, RJSFSchema, StrictRJSFSchema, UIOptionsType, UiSchema } from './types';\n\n/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`\n * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.\n *\n * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`\n */\nexport default function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n uiSchema: UiSchema<T, S, F> = {},\n globalOptions: GlobalUISchemaOptions = {},\n): UIOptionsType<T, S, F> {\n return Object.keys(uiSchema)\n .filter((key) => key.indexOf('ui:') === 0)\n .reduce(\n (options, key) => {\n const value = uiSchema[key];\n if (key === UI_WIDGET_KEY && isObject(value)) {\n console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');\n return options;\n }\n if (key === UI_OPTIONS_KEY && isObject(value)) {\n return { ...options, ...value };\n }\n return { ...options, [key.substring(3)]: value };\n },\n { ...globalOptions },\n );\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';\nimport getUiOptions from './getUiOptions';\n\n/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for\n * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the\n * `formData` object doesn't already have `schema.maxProperties` elements.\n *\n * @param schema - The schema for the field that is being checked\n * @param [uiSchema={}] - The uiSchema for the field\n * @param [formData] - The formData for the field\n * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit\n */\nexport default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n uiSchema: UiSchema<T, S, F> = {},\n formData?: T,\n) {\n if (!(schema.additionalProperties || schema.patternProperties)) {\n return false;\n }\n const { expandable = true } = getUiOptions<T, S, F>(uiSchema);\n if (expandable === false) {\n return expandable;\n }\n // if ui:options.expandable was not explicitly set to false, we can add\n // another property if we have not exceeded maxProperties yet\n if (schema.maxProperties !== undefined && formData) {\n return Object.keys(formData).length < schema.maxProperties;\n }\n return true;\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ERRORS_KEY } from './constants';\nimport { FieldValidation, FormValidation, GenericObjectType } from './types';\n\n/** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it\n *\n * @param formData - The form data around which the error handler is created\n * @returns - A `FormValidation` object based on the `formData` structure\n */\nexport default function createErrorHandler<T = any>(formData: T): FormValidation<T> {\n const handler: FieldValidation = {\n // We store the list of errors for this node in a property named __errors\n // to avoid name collision with a possible sub schema field named\n // 'errors' (see `utils.toErrorSchema`).\n [ERRORS_KEY]: [],\n addError(message: string) {\n this[ERRORS_KEY]!.push(message);\n },\n };\n if (Array.isArray(formData)) {\n return formData.reduce((acc, value, key) => {\n return { ...acc, [key]: createErrorHandler(value) };\n }, handler);\n }\n if (isPlainObject(formData)) {\n const formObject: GenericObjectType = formData as GenericObjectType;\n return Object.keys(formObject).reduce((acc, key) => {\n return { ...acc, [key]: createErrorHandler(formObject[key]) };\n }, handler as FormValidation<T>);\n }\n return handler as FormValidation<T>;\n}\n", "import isEqualWith from 'lodash/isEqualWith';\n\n/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that\n * assumes all functions are equivalent.\n *\n * @param a - The first element to compare\n * @param b - The second element to compare\n * @returns - True if the `a` and `b` are deeply equal, false otherwise\n */\nexport default function deepEquals(a: any, b: any): boolean {\n return isEqualWith(a, b, (obj: any, other: any) => {\n if (typeof obj === 'function' && typeof other === 'function') {\n // Assume all functions are equivalent\n // see https://github.com/rjsf-team/react-jsonschema-form/issues/255\n return true;\n }\n return undefined; // fallback to default isEquals behavior\n });\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport findSelectedOptionInXxxOf from './findSelectedOptionInXxxOf';\nimport getFromSchema from './getFromSchema';\nimport { ANY_OF_KEY, ONE_OF_KEY, PROPERTIES_KEY, REQUIRED_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n FoundFieldType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\n\n/** Unique schema that represents no schema was found, exported for testing purposes */\nexport const NOT_FOUND_SCHEMA = { title: '!@#$_UNKNOWN_$#@!' };\n\n/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified\n * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf\n * field is in the `required` list for its parent and if so, it is marked as required on return.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The node within the JSON schema in which to search\n * @param path - The keys in the path to the desired field\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - An object that contains the field and its required state. If no field can be found then\n * `{ field: undefined, isRequired: undefined }` is returned.\n */\nexport default function findFieldInSchema<\n T = undefined,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): FoundFieldType<S> {\n const pathList = Array.isArray(path) ? [...path] : path.split('.');\n let parentField = schema;\n\n // store the desired field into a variable and removing it from the `pathList`\n const fieldName = pathList.pop()!;\n\n if (pathList.length) {\n // drilling into the schema for each sub-path and taking into account of the any/oneOfs\n pathList.forEach((subPath) => {\n parentField = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, subPath],\n {} as S,\n experimental_customMergeAllOf,\n );\n if (has(parentField, ONE_OF_KEY)) {\n // if this sub-path has a `oneOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // if this sub-path has a `anyOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n }\n });\n }\n\n if (has(parentField, ONE_OF_KEY)) {\n // When oneOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // When anyOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n }\n\n // taking the most updated `parentField`, get our desired field\n let field: S | undefined = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, fieldName],\n NOT_FOUND_SCHEMA as S,\n experimental_customMergeAllOf,\n );\n if (field === NOT_FOUND_SCHEMA) {\n field = undefined;\n }\n // check to see if our desired field is in the `required` list for its parent\n const requiredArray = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n REQUIRED_KEY,\n [] as T,\n experimental_customMergeAllOf,\n );\n let isRequired: boolean | undefined;\n if (field && Array.isArray(requiredArray)) {\n isRequired = requiredArray.includes(fieldName);\n }\n\n return { field, isRequired };\n}\n", "import get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\n\nimport { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from '../constants';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport retrieveSchema from './retrieveSchema';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\n\n/** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or\n * `properties[selectorField].const` that matches the `formData[selectorField]` value. For the purposes of this\n * function, `selectorField` is either `schema.discriminator.propertyName` or `fallbackField`. The `LayoutGridField`\n * works directly with schemas in a recursive manner, making this faster than `getFirstMatchingOption()`.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The schema element in which to search for the selected anyOf/oneOf option\n * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field\n * @param xxx - Either `anyOf` or `oneOf`, defines which value is being sought\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected\n */\nexport default function findSelectedOptionInXxxOf<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n fallbackField: string,\n xxx: 'anyOf' | 'oneOf',\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S | undefined {\n if (Array.isArray(schema[xxx])) {\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const selectorField = discriminator || fallbackField;\n const xxxOfs = schema[xxx]!.map((xxxOf) =>\n retrieveSchema<T, S, F>(validator, xxxOf as S, rootSchema, formData, experimental_customMergeAllOf),\n );\n const data = get(formData, selectorField);\n if (data !== undefined) {\n return xxxOfs.find((xxx) => {\n return isEqual(\n get(xxx, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get(xxx, [PROPERTIES_KEY, selectorField, CONST_KEY])),\n data,\n );\n });\n }\n }\n return undefined;\n}\n", "import get from 'lodash/get';\nimport set from 'lodash/set';\nimport times from 'lodash/times';\nimport transform from 'lodash/transform';\nimport merge from 'lodash/merge';\nimport flattenDeep from 'lodash/flattenDeep';\nimport uniq from 'lodash/uniq';\nimport mergeAllOf, { Options } from 'json-schema-merge-allof';\n\nimport {\n ADDITIONAL_PROPERTIES_KEY,\n ADDITIONAL_PROPERTY_FLAG,\n ALL_OF_KEY,\n ANY_OF_KEY,\n DEPENDENCIES_KEY,\n ID_KEY,\n IF_KEY,\n ITEMS_KEY,\n ONE_OF_KEY,\n PATTERN_PROPERTIES_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n} from '../constants';\nimport findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport guessType from '../guessType';\nimport isObject from '../isObject';\nimport mergeSchemas from '../mergeSchemas';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport getFirstMatchingOption from './getFirstMatchingOption';\nimport deepEquals from '../deepEquals';\nimport isEmpty from 'lodash/isEmpty';\n\n/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies\n * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the\n * potentially recursive resolution.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema having its conditions, additional properties, references and dependencies resolved\n */\nexport default function retrieveSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S = {} as S,\n rawFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n schema,\n rootSchema,\n rawFormData,\n undefined,\n undefined,\n experimental_customMergeAllOf,\n )[0];\n}\n\n/** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch\n * with the rest of the schema. If `expandAllBranches` is true, then the `retrieveSchemaInteral()` results for both\n * conditions will be returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions\n * @param schema - The schema for which resolving a condition is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and\n * dependencies as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded\n */\nexport function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;\n\n const conditionValue = validator.isValid(expression as S, formData || ({} as T), rootSchema);\n let resolvedSchemas = [resolvedSchemaLessConditional as S];\n let schemas: S[] = [];\n if (expandAllBranches) {\n if (then && typeof then !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n then as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n if (otherwise && typeof otherwise !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n otherwise as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n } else {\n const conditionalSchema = conditionValue ? then : otherwise;\n if (conditionalSchema && typeof conditionalSchema !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n conditionalSchema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n }\n if (schemas.length) {\n resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s) as S);\n }\n return resolvedSchemas.flatMap((s) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n}\n\n/** Given a list of lists of allOf, anyOf or oneOf values, create a list of lists of all permutations of the values. The\n * `listOfLists` is expected to be all resolved values of the 1st...nth schemas within an `allOf`, `anyOf` or `oneOf`.\n * From those lists, build a matrix for each `xxxOf` where there is more than one schema for a row in the list of lists.\n *\n * For example:\n * - If there are three xxxOf rows (A, B, C) and they have been resolved such that there is only one A, two B and three\n * C schemas then:\n * - The permutation for the first row is `[[A]]`\n * - The permutations for the second row are `[[A,B1], [A,B2]]`\n * - The permutations for the third row are `[[A,B1,C1], [A,B1,C2], [A,B1,C3], [A,B2,C1], [A,B2,C2], [A,B2,C3]]`\n *\n * @param listOfLists - The list of lists of elements that represent the allOf, anyOf or oneOf resolved values in order\n * @returns - The list of all permutations of schemas for a set of `xxxOf`s\n */\nexport function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchema>(listOfLists: S[][]) {\n const allPermutations: S[][] = listOfLists.reduce<S[][]>(\n (permutations, list) => {\n // When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values\n if (list.length > 1) {\n return list.flatMap((element) => times(permutations.length, (i) => [...permutations[i]].concat(element)));\n }\n // Otherwise just push in the single value into the current set of permutations\n permutations.forEach((permutation) => permutation.push(list[0]));\n return permutations;\n },\n [[]] as S[][], // Start with an empty list\n );\n\n return allPermutations;\n}\n\n/** Returns the subset of 'patternProperties' specifications that match the given 'key'\n *\n * @param schema - The schema whose 'patternProperties' are to be filtered\n * @param key - The key to match against the 'patternProperties' specifications\n * @returns - The subset of 'patternProperties' specifications that match the given 'key'\n */\nexport function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n key: string,\n): Required<S['patternProperties']> {\n return Object.keys(schema.patternProperties!)\n .filter((pattern: string) => RegExp(pattern).test(key))\n .reduce(\n (obj, pattern) => {\n // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path\n set(obj, [pattern], schema.patternProperties![pattern]);\n return obj;\n },\n {} as Required<S['patternProperties']>,\n );\n}\n\n/** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag\n * down to the `retrieveSchemaInternal()`, `resolveReference()` and `resolveDependencies()` helper calls. If\n * `expandAllBranches` is true, then all possible dependencies and/or allOf branches are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas having its references, dependencies and allOf schemas resolved\n */\nexport function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const updatedSchemas = resolveReference<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n );\n if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {\n // return the updatedSchemas array if it has either multiple schemas within it\n // OR the first schema is not the same as the original schema\n return updatedSchemas;\n }\n if (DEPENDENCIES_KEY in schema) {\n const resolvedSchemas = resolveDependencies<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n );\n return resolvedSchemas.flatMap((s) => {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n });\n }\n if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {\n const allOfSchemaElements: S[][] = schema.allOf.map((allOfSubschema) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n allOfSubschema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n const allPermutations = getAllPermutationsOfXxxOf<S>(allOfSchemaElements);\n return allPermutations.map((permutation) => ({\n ...schema,\n allOf: permutation,\n }));\n }\n // No $ref or dependencies or allOf attribute was found, returning the original schema.\n return [schema];\n}\n\n/** Resolves all references within a schema and then returns the `retrieveSchemaInternal()` if the resolved schema is\n * actually different than the original. Passes the `expandAllBranches` flag down to the `retrieveSchemaInternal()`\n * helper call.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a reference is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list schemas retrieved after having all references resolved\n */\nexport function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const updatedSchema = resolveAllReferences<S>(schema, rootSchema, recurseList);\n if (updatedSchema !== schema) {\n // Only call this if the schema was actually changed by the `resolveAllReferences()` function\n return retrieveSchemaInternal<T, S, F>(\n validator,\n updatedSchema,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n }\n return [schema];\n}\n\n/** Resolves all references within the schema itself as well as any of its properties and array items.\n *\n * @param schema - The schema for which resolving all references is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param recurseList - List of $refs already resolved to prevent recursion\n * @param baseURI - The base URI to be used for resolving relative references\n * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved\n */\nexport function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n rootSchema: S,\n recurseList: string[],\n baseURI?: string,\n): S {\n if (!isObject(schema)) {\n return schema;\n }\n let resolvedSchema: S = schema;\n // resolve top level ref\n if (REF_KEY in resolvedSchema) {\n const { $ref, ...localSchema } = resolvedSchema;\n // Check for a recursive reference and stop the loop\n if (recurseList.includes($ref!)) {\n return resolvedSchema;\n }\n recurseList.push($ref!);\n // Retrieve the referenced schema definition.\n const refSchema = findSchemaDefinition<S>($ref, rootSchema, baseURI);\n resolvedSchema = { ...refSchema, ...localSchema };\n if (ID_KEY in resolvedSchema) {\n baseURI = resolvedSchema[ID_KEY];\n }\n }\n\n if (PROPERTIES_KEY in resolvedSchema) {\n const childrenLists: string[][] = [];\n const updatedProps = transform(\n resolvedSchema[PROPERTIES_KEY]!,\n (result, value, key: string) => {\n const childList: string[] = [...recurseList];\n result[key] = resolveAllReferences(value as S, rootSchema, childList, baseURI);\n childrenLists.push(childList);\n },\n {} as RJSFSchema,\n );\n merge(recurseList, uniq(flattenDeep(childrenLists)));\n resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };\n }\n\n if (\n ITEMS_KEY in resolvedSchema &&\n !Array.isArray(resolvedSchema.items) &&\n typeof resolvedSchema.items !== 'boolean'\n ) {\n resolvedSchema = {\n ...resolvedSchema,\n items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList, baseURI),\n };\n }\n\n return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;\n}\n\n/** Creates new 'properties' items for each key in the `formData`\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which the existing additional properties is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator\n * @param [aFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The updated schema with additional properties stubbed\n */\nexport function stubExistingAdditionalProperties<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n rootSchema?: S,\n aFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S {\n // Clone the schema so that we don't ruin the consumer's original\n const schema = {\n ...theSchema,\n properties: { ...theSchema.properties },\n };\n\n // make sure formData is an object\n const formData: GenericObjectType = aFormData && isObject(aFormData) ? aFormData : {};\n Object.keys(formData).forEach((key) => {\n if (key in schema.properties) {\n // No need to stub, our schema already has the property\n return;\n }\n if (PATTERN_PROPERTIES_KEY in schema) {\n const matchingProperties = getMatchingPatternProperties(schema, key);\n if (!isEmpty(matchingProperties)) {\n schema.properties[key] = retrieveSchema<T, S, F>(\n validator,\n { allOf: Object.values(matchingProperties) } as S,\n rootSchema,\n formData as T,\n experimental_customMergeAllOf,\n );\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n return;\n }\n }\n if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {\n let additionalProperties: S['additionalProperties'] = {};\n if (typeof schema.additionalProperties !== 'boolean') {\n if (REF_KEY in schema.additionalProperties!) {\n additionalProperties = retrieveSchema<T, S, F>(\n validator,\n { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,\n rootSchema,\n formData as T,\n experimental_customMergeAllOf,\n );\n } else if ('type' in schema.additionalProperties!) {\n additionalProperties = { ...schema.additionalProperties };\n } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {\n additionalProperties = {\n type: 'object',\n ...schema.additionalProperties,\n };\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n\n // The type of our new key should match the additionalProperties value;\n schema.properties[key] = additionalProperties;\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n } else {\n // Invalid property\n schema.properties[key] = { type: 'null' };\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n }\n });\n\n return schema;\n}\n\n/** Internal handler that retrieves an expanded schema that has had all of its conditions, additional properties,\n * references and dependencies resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData`\n * that is used to do the potentially recursive resolution. If `expandAllBranches` is true, then all possible branches\n * of the schema and its references, conditions and dependencies are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @param [expandAllBranches=false] - Flag, if true, will return all possible branches of conditions, any/oneOf and\n * dependencies as a list of schemas\n * @param [recurseList=[]] - The optional, list of recursive references already processed\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema(s) resulting from having its conditions, additional properties, references and dependencies\n * resolved. Multiple schemas may be returned if `expandAllBranches` is true.\n */\nexport function retrieveSchemaInternal<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n rawFormData?: T,\n expandAllBranches = false,\n recurseList: string[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n if (!isObject(schema)) {\n return [{} as S];\n }\n const resolvedSchemas = resolveSchema<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n rawFormData,\n experimental_customMergeAllOf,\n );\n return resolvedSchemas.flatMap((s: S) => {\n let resolvedSchema = s;\n if (IF_KEY in resolvedSchema) {\n return resolveCondition<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n expandAllBranches,\n recurseList,\n rawFormData as T,\n experimental_customMergeAllOf,\n );\n }\n if (ALL_OF_KEY in resolvedSchema) {\n // resolve allOf schemas\n if (expandAllBranches) {\n const { allOf, ...restOfSchema } = resolvedSchema;\n return [...(allOf as S[]), restOfSchema as S];\n }\n try {\n const withContainsSchemas = [] as S[];\n const withoutContainsSchemas = [] as S[];\n resolvedSchema.allOf?.forEach((s) => {\n if (typeof s === 'object' && s.contains) {\n withContainsSchemas.push(s as S);\n } else {\n withoutContainsSchemas.push(s as S);\n }\n });\n if (withContainsSchemas.length) {\n resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };\n }\n resolvedSchema = experimental_customMergeAllOf\n ? experimental_customMergeAllOf(resolvedSchema)\n : (mergeAllOf(resolvedSchema, {\n deep: false,\n resolvers: {\n $defs: mergeAllOf.options.resolvers.definitions,\n },\n } as Options) as S);\n if (withContainsSchemas.length) {\n resolvedSchema.allOf = withContainsSchemas;\n }\n } catch (e) {\n console.warn('could not merge subschemas in allOf:\\n', e);\n const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;\n return resolvedSchemaWithoutAllOf as S;\n }\n }\n if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {\n resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(\n (schema, key) => {\n const matchingProperties = getMatchingPatternProperties(schema, key);\n if (!isEmpty(matchingProperties)) {\n schema.properties[key] = retrieveSchema<T, S, F>(\n validator,\n { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,\n rootSchema,\n rawFormData as T,\n experimental_customMergeAllOf,\n );\n }\n return schema;\n },\n {\n ...resolvedSchema,\n properties: { ...resolvedSchema.properties },\n },\n );\n }\n const hasAdditionalProperties =\n PATTERN_PROPERTIES_KEY in resolvedSchema ||\n (ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false);\n if (hasAdditionalProperties) {\n return stubExistingAdditionalProperties<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n rawFormData as T,\n experimental_customMergeAllOf,\n );\n }\n\n return resolvedSchema;\n });\n}\n\n/** Resolves an `anyOf` or `oneOf` within a schema (if present) to the list of schemas returned from\n * `retrieveSchemaInternal()` for the best matching option. If `expandAllBranches` is true, then a list of schemas for ALL\n * options are retrieved and returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema, defaults to an empty object\n * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true\n */\nexport function resolveAnyOrOneOfSchemas<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(validator: ValidatorType<T, S, F>, schema: S, rootSchema: S, expandAllBranches: boolean, rawFormData?: T) {\n let anyOrOneOf: S[] | undefined;\n const { oneOf, anyOf, ...remaining } = schema;\n if (Array.isArray(oneOf)) {\n anyOrOneOf = oneOf as S[];\n } else if (Array.isArray(anyOf)) {\n anyOrOneOf = anyOf as S[];\n }\n if (anyOrOneOf) {\n // Ensure that during expand all branches we pass an object rather than undefined so that all options are interrogated\n const formData = rawFormData === undefined && expandAllBranches ? ({} as T) : rawFormData;\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n anyOrOneOf = anyOrOneOf.map((s) => {\n // Due to anyOf/oneOf possibly using the same $ref we always pass a fresh recurse list array so that each option\n // can resolve recursive references independently\n return resolveAllReferences(s, rootSchema, []);\n });\n // Call this to trigger the set of isValid() calls that the schema parser will need\n const option = getFirstMatchingOption<T, S, F>(validator, formData, anyOrOneOf, rootSchema, discriminator);\n if (expandAllBranches) {\n return anyOrOneOf.map((item) => mergeSchemas(remaining, item) as S);\n }\n schema = mergeSchemas(remaining, anyOrOneOf[option]) as S;\n }\n return [schema];\n}\n\n/** Resolves dependencies within a schema and its 'anyOf/oneOf' children. Passes the `expandAllBranches` flag down to\n * the `resolveAnyOrOneOfSchema()` and `processDependencies()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a dependency is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas with their dependencies resolved\n */\nexport function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n // Drop the dependencies from the source schema.\n const { dependencies, ...remainingSchema } = schema;\n const resolvedSchemas = resolveAnyOrOneOfSchemas<T, S, F>(\n validator,\n remainingSchema as S,\n rootSchema,\n expandAllBranches,\n formData,\n );\n return resolvedSchemas.flatMap((resolvedSchema) =>\n processDependencies<T, S, F>(\n validator,\n dependencies,\n resolvedSchema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n}\n\n/** Processes all the `dependencies` recursively into the list of `resolvedSchema`s as needed. Passes the\n * `expandAllBranches` flag down to the `withDependentSchema()` and the recursive `processDependencies()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param dependencies - The set of dependencies that needs to be processed\n * @param resolvedSchema - The schema for which processing dependencies is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema with the `dependencies` resolved into it\n */\nexport function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n dependencies: S['dependencies'],\n resolvedSchema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n let schemas = [resolvedSchema];\n // Process dependencies updating the local schema properties as appropriate.\n for (const dependencyKey in dependencies) {\n // Skip this dependency if its trigger property is not present.\n if (!expandAllBranches && get(formData, [dependencyKey]) === undefined) {\n continue;\n }\n // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)\n if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {\n continue;\n }\n const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(\n dependencyKey,\n dependencies as GenericObjectType,\n );\n if (Array.isArray(dependencyValue)) {\n schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);\n } else if (isObject(dependencyValue)) {\n schemas = withDependentSchema<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n dependencyKey,\n dependencyValue as S,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n );\n }\n return schemas.flatMap((schema) =>\n processDependencies<T, S, F>(\n validator,\n remainingDependencies,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n }\n return schemas;\n}\n\n/** Updates a schema with additionally required properties added\n *\n * @param schema - The schema for which resolving a dependent properties is desired\n * @param [additionallyRequired] - An optional array of additionally required names\n * @returns - The schema with the additional required values merged in\n */\nexport function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n additionallyRequired?: string[],\n) {\n if (!additionallyRequired) {\n return schema;\n }\n const required = Array.isArray(schema.required)\n ? Array.from(new Set([...schema.required, ...additionallyRequired]))\n : additionallyRequired;\n return { ...schema, required: required };\n}\n\n/** Merges a dependent schema into the `schema` dealing with oneOfs and references. Passes the `expandAllBranches` flag\n * down to the `retrieveSchemaInternal()`, `resolveReference()` and `withExactlyOneSubschema()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a dependent schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param dependencyKey - The key name of the dependency\n * @param dependencyValue - The potentially dependent schema\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData]- The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas with the dependent schema resolved into them\n */\nexport function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n dependencyKey: string,\n dependencyValue: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const dependentSchemas = retrieveSchemaInternal<T, S, F>(\n validator,\n dependencyValue,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n return dependentSchemas.flatMap((dependent) => {\n const { oneOf, ...dependentSchema } = dependent;\n schema = mergeSchemas(schema, dependentSchema) as S;\n // Since it does not contain oneOf, we return the original schema.\n if (oneOf === undefined) {\n return schema;\n }\n // Resolve $refs inside oneOf.\n const resolvedOneOfs = oneOf.map((subschema) => {\n if (typeof subschema === 'boolean' || !(REF_KEY in subschema)) {\n return [subschema as S];\n }\n return resolveReference<T, S, F>(validator, subschema as S, rootSchema, expandAllBranches, recurseList, formData);\n });\n const allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);\n return allPermutations.flatMap((resolvedOneOf) =>\n withExactlyOneSubschema<T, S, F>(\n validator,\n schema,\n rootSchema,\n dependencyKey,\n resolvedOneOf,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n });\n}\n\n/** Returns a list of `schema`s with the best choice from the `oneOf` options merged into it. If `expandAllBranches` is\n * true, then a list of schemas for ALL options are retrieved and returned. Passes the `expandAllBranches` flag down to\n * the `retrieveSchemaInternal()` helper call.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used to validate oneOf options\n * @param schema - The schema for which resolving a oneOf subschema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param dependencyKey - The key name of the oneOf dependency\n * @param oneOf - The list of schemas representing the oneOf options\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true\n */\nexport function withExactlyOneSubschema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n dependencyKey: string,\n oneOf: S['oneOf'],\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const validSubschemas = oneOf!.filter((subschema) => {\n if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {\n return false;\n }\n const { [dependencyKey]: conditionPropertySchema } = subschema.properties;\n if (conditionPropertySchema) {\n const conditionSchema: S = {\n type: 'object',\n properties: {\n [dependencyKey]: conditionPropertySchema,\n },\n } as S;\n return validator.isValid(conditionSchema, formData, rootSchema) || expandAllBranches;\n }\n return false;\n });\n\n if (!expandAllBranches && validSubschemas!.length !== 1) {\n console.warn(\"ignoring oneOf in dependencies because there isn't exactly one subschema that is valid\");\n return [schema];\n }\n return validSubschemas.flatMap((s) => {\n const subschema: S = s as S;\n const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties as GenericObjectType);\n const dependentSchema = { ...subschema, properties: dependentSubschema };\n const schemas = retrieveSchemaInternal<T, S, F>(\n validator,\n dependentSchema,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n return schemas.map((s) => mergeSchemas(schema, s) as S);\n });\n}\n", "import jsonpointer from 'jsonpointer';\nimport omit from 'lodash/omit';\n\nimport { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY } from './constants';\nimport { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';\nimport isObject from 'lodash/isObject';\nimport isEmpty from 'lodash/isEmpty';\nimport UriResolver from 'fast-uri';\n\n/** Looks for the `$id` pointed by `ref` in the schema definitions embedded in\n * a JSON Schema bundle\n *\n * @param schema - The schema wherein `ref` should be searched\n * @param ref - The `$id` of the reference to search for\n * @returns - The schema matching the reference, or `undefined` if no match is found\n */\nfunction findEmbeddedSchemaRecursive<S extends StrictRJSFSchema = RJSFSchema>(schema: S, ref: string): S | undefined {\n if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY] as string, ref)) {\n return schema;\n }\n for (const subSchema of Object.values(schema)) {\n if (isObject(subSchema)) {\n const result = findEmbeddedSchemaRecursive<S>(subSchema as S, ref);\n if (result !== undefined) {\n return result as S;\n }\n }\n }\n return undefined;\n}\n\n/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first\n * location, the `object` minus the `key: value` and in the second location the `value`.\n *\n * @param key - The key from the object to extract\n * @param object - The object from which to extract the element\n * @returns - An array with the first value being the object minus the `key` element and the second element being the\n * value from `object[key]`\n */\nexport function splitKeyElementFromObject(key: string, object: GenericObjectType) {\n const value = object[key];\n const remaining = omit(object, [key]);\n return [remaining, value];\n}\n\n/** Given the name of a `$ref` from within a schema, using the `rootSchema`, recursively look up and return the\n * sub-schema using the path provided by that reference. If `#` is not the first character of the reference, the path\n * does not exist in the schema, or the reference resolves circularly back to itself, then throw an Error.\n * Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.\n *\n * @param $ref - The ref string for which the schema definition is desired\n * @param [rootSchema={}] - The root schema in which to search for the definition\n * @param recurseList - List of $refs already resolved to prevent recursion\n * @param baseURI - The base URI to be used for resolving relative references\n * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists\n * @throws - Error indicating that no schema for that reference could be resolved\n */\nexport function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFSchema>(\n $ref?: string,\n rootSchema: S = {} as S,\n recurseList: string[] = [],\n baseURI: string | undefined = ID_KEY in rootSchema ? rootSchema[ID_KEY] : undefined,\n): S {\n const ref = $ref || '';\n let current: S | undefined = undefined;\n if (ref.startsWith('#')) {\n // Decode URI fragment representation.\n const decodedRef = decodeURIComponent(ref.substring(1));\n if (baseURI === undefined || (ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI)) {\n current = jsonpointer.get(rootSchema, decodedRef);\n } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {\n current = findEmbeddedSchemaRecursive<S>(rootSchema, baseURI.replace(/\\/$/, ''));\n if (current !== undefined) {\n current = jsonpointer.get(current, decodedRef);\n }\n }\n } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {\n const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;\n const [refId, ...refAnchor] = resolvedRef.replace(/#\\/?$/, '').split('#');\n current = findEmbeddedSchemaRecursive<S>(rootSchema, refId.replace(/\\/$/, ''));\n if (current !== undefined) {\n baseURI = current[ID_KEY];\n if (!isEmpty(refAnchor)) {\n current = jsonpointer.get(current, decodeURIComponent(refAnchor.join('#')));\n }\n }\n }\n if (current === undefined) {\n throw new Error(`Could not find a definition for ${$ref}.`);\n }\n const nextRef = current[REF_KEY];\n if (nextRef) {\n // Check for circular references.\n if (recurseList.includes(nextRef)) {\n if (recurseList.length === 1) {\n throw new Error(`Definition for ${$ref} is a circular reference`);\n }\n const [firstRef, ...restRefs] = recurseList;\n const circularPath = [...restRefs, ref, firstRef].join(' -> ');\n throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);\n }\n const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);\n const subSchema = findSchemaDefinitionRecursive<S>(theRef, rootSchema, [...recurseList, ref], baseURI);\n if (Object.keys(remaining).length > 0) {\n return { ...remaining, ...subSchema };\n }\n return subSchema;\n }\n return current;\n}\n\n/** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the\n * path provided by that reference. If `#` is not the first character of the reference, the path does not exist in\n * the schema, or the reference resolves circularly back to itself, then throw an Error. Otherwise return the\n * sub-schema. Also deals with nested `$ref`s in the sub-schema.\n *\n * @param $ref - The ref string for which the schema definition is desired\n * @param [rootSchema={}] - The root schema in which to search for the definition\n * @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references\n * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists\n * @throws - Error indicating that no schema for that reference could be resolved\n */\nexport default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>(\n $ref?: string,\n rootSchema: S = {} as S,\n baseURI: string | undefined = ID_KEY in rootSchema ? rootSchema[ID_KEY] : undefined,\n): S {\n const recurseList: string[] = [];\n return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);\n}\n", "import get from 'lodash/get';\nimport isString from 'lodash/isString';\n\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport { DISCRIMINATOR_PATH } from './constants';\n\n/** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when\n * it is not a string. Returns `undefined` when a valid discriminator is not present.\n *\n * @param schema - The schema from which the discriminator is potentially obtained\n * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`\n */\nexport default function getDiscriminatorFieldFromSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n let discriminator: string | undefined;\n const maybeString = get(schema, DISCRIMINATOR_PATH);\n if (isString(maybeString)) {\n discriminator = maybeString;\n } else if (maybeString !== undefined) {\n console.warn(`Expecting discriminator to be a string, got \"${typeof maybeString}\" instead`);\n }\n return discriminator;\n}\n", "/** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly\n * create a schema, it is useful to know what type to use based on the data we are defining.\n *\n * @param value - The value from which to guess the type\n * @returns - The best guess for the object type\n */\nexport default function guessType(value: any) {\n if (Array.isArray(value)) {\n return 'array';\n }\n if (typeof value === 'string') {\n return 'string';\n }\n if (value == null) {\n return 'null';\n }\n if (typeof value === 'boolean') {\n return 'boolean';\n }\n if (!isNaN(value)) {\n return 'number';\n }\n if (typeof value === 'object') {\n return 'object';\n }\n // Default to string if we can't figure it out\n return 'string';\n}\n", "import union from 'lodash/union';\n\nimport { REQUIRED_KEY } from './constants';\nimport getSchemaType from './getSchemaType';\nimport isObject from './isObject';\nimport { GenericObjectType } from './types';\n\n/** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that\n * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include\n * duplicate values.\n *\n * @param obj1 - The first schema object to merge\n * @param obj2 - The second schema object to merge\n * @returns - The merged schema object\n */\nexport default function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType) {\n const acc = Object.assign({}, obj1); // Prevent mutation of source object.\n return Object.keys(obj2).reduce((acc, key) => {\n const left = obj1 ? obj1[key] : {},\n right = obj2[key];\n if (obj1 && key in obj1 && isObject(right)) {\n acc[key] = mergeSchemas(left, right);\n } else if (\n obj1 &&\n obj2 &&\n (getSchemaType(obj1) === 'object' || getSchemaType(obj2) === 'object') &&\n key === REQUIRED_KEY &&\n Array.isArray(left) &&\n Array.isArray(right)\n ) {\n // Don't include duplicate values when merging 'required' fields.\n acc[key] = union(left, right);\n } else {\n acc[key] = right;\n }\n return acc;\n }, acc);\n}\n", "import guessType from './guessType';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from\n * other elements of the schema as follows:\n * - schema.const: Returns the `guessType()` of that value\n * - schema.enum: Returns `string`\n * - schema.properties: Returns `object`\n * - schema.additionalProperties: Returns `object`\n * - schema.patternProperties: Returns `object`\n * - type is an array with a length of 2 and one type is 'null': Returns the other type\n *\n * @param schema - The schema for which to get the type\n * @returns - The type of the schema\n */\nexport default function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n): string | string[] | undefined {\n let { type } = schema;\n\n if (!type && schema.const) {\n return guessType(schema.const);\n }\n\n if (!type && schema.enum) {\n return 'string';\n }\n\n if (!type && (schema.properties || schema.additionalProperties || schema.patternProperties)) {\n return 'object';\n }\n\n if (Array.isArray(type)) {\n if (type.length === 2 && type.includes('null')) {\n type = type.find((type) => type !== 'null');\n } else {\n type = type[0];\n }\n }\n\n return type;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isNumber from 'lodash/isNumber';\n\nimport { PROPERTIES_KEY } from '../constants';\nimport getOptionMatchingSimpleDiscriminator from '../getOptionMatchingSimpleDiscriminator';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\n\n/** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.\n * Always returns the first option if there is nothing that matches.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param rootSchema - The root schema, used to primarily to look up `$ref`s\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the first matched option or 0 if none is available\n */\nexport default function getFirstMatchingOption<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n formData: T | undefined,\n options: S[],\n rootSchema: S,\n discriminatorField?: string,\n): number {\n // For performance, skip validating subschemas if formData is undefined. We just\n // want to get the first option in that case.\n if (formData === undefined) {\n return 0;\n }\n\n const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);\n if (isNumber(simpleDiscriminatorMatch)) {\n return simpleDiscriminatorMatch;\n }\n\n for (let i = 0; i < options.length; i++) {\n const option = options[i];\n\n // If we have a discriminator field, then we will use this to make the determination\n if (discriminatorField && has(option, [PROPERTIES_KEY, discriminatorField])) {\n const value = get(formData, discriminatorField);\n const discriminator: S = get(option, [PROPERTIES_KEY, discriminatorField], {}) as S;\n if (validator.isValid(discriminator, value, rootSchema)) {\n return i;\n }\n } else if (option[PROPERTIES_KEY]) {\n // If the schema describes an object then we need to add slightly more\n // strict matching to the schema, because unless the schema uses the\n // \"requires\" keyword, an object will match the schema as long as it\n // doesn't have matching keys with a conflicting type. To do this we use an\n // \"anyOf\" with an array of requires. This augmentation expresses that the\n // schema should match if any of the keys in the schema are present on the\n // object and pass validation.\n //\n // Create an \"anyOf\" schema that requires at least one of the keys in the\n // \"properties\" object\n const requiresAnyOf = {\n anyOf: Object.keys(option[PROPERTIES_KEY]).map((key) => ({\n required: [key],\n })),\n };\n\n let augmentedSchema;\n\n // If the \"anyOf\" keyword already exists, wrap the augmentation in an \"allOf\"\n if (option.anyOf) {\n // Create a shallow clone of the option\n const { ...shallowClone } = option;\n\n if (!shallowClone.allOf) {\n shallowClone.allOf = [];\n } else {\n // If \"allOf\" already exists, shallow clone the array\n shallowClone.allOf = shallowClone.allOf.slice();\n }\n\n shallowClone.allOf.push(requiresAnyOf);\n\n augmentedSchema = shallowClone;\n } else {\n augmentedSchema = Object.assign({}, option, requiresAnyOf);\n }\n\n // Remove the \"required\" field as it's likely that not all fields have\n // been filled in yet, which will mean that the schema is not valid\n delete augmentedSchema.required;\n\n if (validator.isValid(augmentedSchema, formData, rootSchema)) {\n return i;\n }\n } else if (validator.isValid(option, formData, rootSchema)) {\n return i;\n }\n }\n return 0;\n}\n", "import get from 'lodash/get';\nimport { PROPERTIES_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Compares the value of `discriminatorField` within `formData` against the value of `discriminatorField` within schema for each `option`.\n * Returns index of first `option` whose discriminator matches formData. Returns `undefined` if there is no match.\n * This function does not work with discriminators of `\"type\": \"object\"` and `\"type\": \"array\"`\n *\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the matched option or undefined if there is no match\n */\nexport default function getOptionMatchingSimpleDiscriminator<T = any, S extends StrictRJSFSchema = RJSFSchema>(\n formData: T | undefined,\n options: S[],\n discriminatorField?: string,\n): number | undefined {\n if (formData && discriminatorField) {\n const value = get(formData, discriminatorField);\n\n if (value === undefined) {\n return;\n }\n\n for (let i = 0; i < options.length; i++) {\n const option = options[i];\n const discriminator: S = get(option, [PROPERTIES_KEY, discriminatorField], {}) as S;\n\n if (discriminator.type === 'object' || discriminator.type === 'array') {\n continue;\n }\n\n if (discriminator.const === value) {\n return i;\n }\n\n if (discriminator.enum?.includes(value)) {\n return i;\n }\n }\n }\n\n return;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isEmpty from 'lodash/isEmpty';\n\nimport retrieveSchema from './retrieveSchema';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport { REF_KEY } from '../constants';\n\n/** Internal helper function that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path\n * for schemas containing potentially nested `$ref`s.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The current node within the JSON schema recursion\n * @param path - The remaining keys in the path to the desired property\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The internal schema from the `schema` for the given `path` or undefined if not found\n */\nfunction getFromSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | S | undefined {\n let fieldSchema = schema;\n if (has(schema, REF_KEY)) {\n fieldSchema = retrieveSchema<T, S, F>(validator, schema, rootSchema, undefined, experimental_customMergeAllOf);\n }\n if (isEmpty(path)) {\n return fieldSchema;\n }\n const pathList = Array.isArray(path) ? path : path.split('.');\n const [part, ...nestedPath] = pathList;\n if (part && has(fieldSchema, part)) {\n fieldSchema = get(fieldSchema, part) as S;\n return getFromSchemaInternal<T, S, F>(\n validator,\n rootSchema,\n fieldSchema,\n nestedPath,\n experimental_customMergeAllOf,\n );\n }\n return undefined;\n}\n\n/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas\n * containing potentially nested `$ref`s.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The current node within the JSON schema recursion\n * @param path - The keys in the path to the desired field\n * @param defaultValue - The value to return if a value is not found for the `pathList` path\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The inner schema from the `schema` for the given `path` or the `defaultValue` if not found\n */\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T;\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S;\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: T | S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | S {\n const result = getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf);\n if (result === undefined) {\n return defaultValue;\n }\n return result;\n}\n", "import get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport { JSONSchema7Object } from 'json-schema';\n\nimport {\n ALL_OF_KEY,\n ANY_OF_KEY,\n CONST_KEY,\n DEFAULT_KEY,\n DEPENDENCIES_KEY,\n ONE_OF_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n} from '../constants';\nimport findSchemaDefinition from '../findSchemaDefinition';\nimport getClosestMatchingOption from './getClosestMatchingOption';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport getSchemaType from '../getSchemaType';\nimport isObject from '../isObject';\nimport isFixedItems from '../isFixedItems';\nimport mergeDefaultsWithFormData from '../mergeDefaultsWithFormData';\nimport mergeObjects from '../mergeObjects';\nimport mergeSchemas from '../mergeSchemas';\nimport {\n Experimental_CustomMergeAllOf,\n Experimental_DefaultFormStateBehavior,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport isMultiSelect from './isMultiSelect';\nimport isSelect from './isSelect';\nimport retrieveSchema, { resolveDependencies } from './retrieveSchema';\nimport isConstant from '../isConstant';\nimport constIsAjvDataReference from '../constIsAjvDataReference';\nimport optionsList from '../optionsList';\nimport deepEquals from '../deepEquals';\n\nconst PRIMITIVE_TYPES = ['string', 'number', 'integer', 'boolean', 'null'];\n\n/** Enum that indicates how `schema.additionalItems` should be handled by the `getInnerSchemaForArrayItem()` function.\n */\nexport enum AdditionalItemsHandling {\n Ignore,\n Invert,\n Fallback,\n}\n\n/** Given a `schema` will return an inner schema that for an array item. This is computed differently based on the\n * `additionalItems` enum and the value of `idx`. There are four possible returns:\n * 1. If `idx` is >= 0, then if `schema.items` is an array the `idx`th element of the array is returned if it is a valid\n * index and not a boolean, otherwise it falls through to 3.\n * 2. If `schema.items` is not an array AND truthy and not a boolean, then `schema.items` is returned since it actually\n * is a schema, otherwise it falls through to 3.\n * 3. If `additionalItems` is not `AdditionalItemsHandling.Ignore` and `schema.additionalItems` is an object, then\n * `schema.additionalItems` is returned since it actually is a schema, otherwise it falls through to 4.\n * 4. {} is returned representing an empty schema\n *\n * @param schema - The schema from which to get the particular item\n * @param [additionalItems=AdditionalItemsHandling.Ignore] - How do we want to handle additional items?\n * @param [idx=-1] - Index, if non-negative, will be used to return the idx-th element in a `schema.items` array\n * @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers\n */\nexport function getInnerSchemaForArrayItem<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n additionalItems: AdditionalItemsHandling = AdditionalItemsHandling.Ignore,\n idx = -1,\n): S {\n if (idx >= 0) {\n if (Array.isArray(schema.items) && idx < schema.items.length) {\n const item = schema.items[idx];\n if (typeof item !== 'boolean') {\n return item as S;\n }\n }\n } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {\n return schema.items as S;\n }\n if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {\n return schema.additionalItems as S;\n }\n return {} as S;\n}\n\n/** Either add `computedDefault` at `key` into `obj` or not add it based on its value, the value of\n * `includeUndefinedValues`, the value of `emptyObjectFields` and if its parent field is required. Generally undefined\n * `computedDefault` values are added only when `includeUndefinedValues` is either true/\"excludeObjectChildren\". If `\n * includeUndefinedValues` is false and `emptyObjectFields` is not \"skipDefaults\", then non-undefined and non-empty-object\n * values will be added based on certain conditions.\n *\n * @param obj - The object into which the computed default may be added\n * @param key - The key into the object at which the computed default may be added\n * @param computedDefault - The computed default value that maybe should be added to the obj\n * @param includeUndefinedValues - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties. If \"allowEmptyObject\", prevents undefined\n * values in this object while allow the object itself to be empty and passing `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n * @param isParentRequired - The optional boolean that indicates whether the parent field is required\n * @param requiredFields - The list of fields that are required\n * @param experimental_defaultFormStateBehavior - Optional configuration object, if provided, allows users to override\n * default form state behavior\n * @param isConst - Optional flag, if true, indicates that the schema has a const property defined, thus we should always return the computedDefault since it's coming from the const.\n */\nfunction maybeAddDefaultToObject<T = any>(\n obj: GenericObjectType,\n key: string,\n computedDefault: T | T[] | undefined,\n includeUndefinedValues: boolean | 'excludeObjectChildren',\n isParentRequired?: boolean,\n requiredFields: string[] = [],\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior = {},\n isConst = false,\n) {\n const { emptyObjectFields = 'populateAllDefaults' } = experimental_defaultFormStateBehavior;\n if (includeUndefinedValues || isConst) {\n // If includeUndefinedValues\n // Or if the schema has a const property defined, then we should always return the computedDefault since it's coming from the const.\n obj[key] = computedDefault;\n } else if (emptyObjectFields !== 'skipDefaults') {\n // If isParentRequired is undefined, then we are at the root level of the schema so defer to the requiredness of\n // the field key itself in the `requiredField` list\n const isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;\n\n if (isObject(computedDefault)) {\n // If emptyObjectFields 'skipEmptyDefaults' store computedDefault if it's a non-empty object(e.g. not {})\n if (emptyObjectFields === 'skipEmptyDefaults') {\n if (!isEmpty(computedDefault)) {\n obj[key] = computedDefault;\n }\n } // Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions\n // Condition 1: If computedDefault is not empty or if the key is a required field\n // Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'\n else if (\n (!isEmpty(computedDefault) || requiredFields.includes(key)) &&\n (isSelfOrParentRequired || emptyObjectFields !== 'populateRequiredDefaults')\n ) {\n obj[key] = computedDefault;\n }\n } else if (\n // Store computedDefault if it's a defined primitive (e.g., true) and satisfies certain conditions\n // Condition 1: computedDefault is not undefined\n // Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults)\n // Or if isSelfOrParentRequired is 'true' and the key is a required field\n computedDefault !== undefined &&\n (emptyObjectFields === 'populateAllDefaults' ||\n emptyObjectFields === 'skipEmptyDefaults' ||\n (isSelfOrParentRequired && requiredFields.includes(key)))\n ) {\n obj[key] = computedDefault;\n }\n }\n}\n\ninterface ComputeDefaultsProps<T = any, S extends StrictRJSFSchema = RJSFSchema> {\n /** Any defaults provided by the parent field in the schema */\n parentDefaults?: T;\n /** The options root schema, used to primarily to look up `$ref`s */\n rootSchema?: S;\n /** The current formData, if any, onto which to provide any missing defaults */\n rawFormData?: T;\n /** Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n */\n includeUndefinedValues?: boolean | 'excludeObjectChildren';\n /** The list of ref names currently being recursed, used to prevent infinite recursion */\n _recurseList?: string[];\n /** Optional configuration object, if provided, allows users to override default form state behavior */\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;\n /** Optional function that allows for custom merging of `allOf` schemas */\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;\n /** Optional flag, if true, indicates this schema was required in the parent schema. */\n required?: boolean;\n /** Optional flag, if true, It will merge defaults into formData.\n * The formData should take precedence unless it's not valid. This is useful when for example the value from formData does not exist in the schema 'enum' property, in such cases we take the value from the defaults because the value from the formData is not valid.\n */\n shouldMergeDefaultsIntoFormData?: boolean;\n}\n\n/** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into\n * each level of the schema, recursively, to fill out every level of defaults provided by the schema.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @returns - The resulting `formData` with all the defaults provided\n */\nexport function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n computeDefaultsProps: ComputeDefaultsProps<T, S> = {},\n): T | T[] | undefined {\n const {\n parentDefaults,\n rawFormData,\n rootSchema = {} as S,\n includeUndefinedValues = false,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData = false,\n } = computeDefaultsProps;\n const formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;\n const schema: S = isObject(rawSchema) ? rawSchema : ({} as S);\n // Compute the defaults recursively: give highest priority to deepest nodes.\n let defaults: T | T[] | undefined = parentDefaults;\n // If we get a new schema, then we need to recompute defaults again for the new schema found.\n let schemaToCompute: S | null = null;\n let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;\n let updatedRecurseList = _recurseList;\n\n if (\n schema[CONST_KEY] &&\n experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&\n !constIsAjvDataReference(schema)\n ) {\n defaults = schema[CONST_KEY] as unknown as T;\n } else if (isObject(defaults) && isObject(schema.default)) {\n // For object defaults, only override parent defaults that are defined in\n // schema.default.\n defaults = mergeObjects(defaults!, schema.default as GenericObjectType) as T;\n } else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {\n // If the schema has a default value, then we should use it as the default.\n // And if the schema does not have anyOf or oneOf, this is done because we need to merge the defaults with the formData.\n defaults = schema.default as unknown as T;\n } else if (REF_KEY in schema) {\n const refName = schema[REF_KEY];\n // Use referenced schema defaults for this node.\n if (!_recurseList.includes(refName!)) {\n updatedRecurseList = _recurseList.concat(refName!);\n schemaToCompute = findSchemaDefinition<S>(refName, rootSchema);\n }\n\n // If the referenced schema exists and parentDefaults is not set\n // Then set the defaults from the current schema for the referenced schema\n if (schemaToCompute && !defaults) {\n defaults = schema.default as T | undefined;\n }\n } else if (DEPENDENCIES_KEY in schema) {\n // Get the default if set from properties to ensure the dependencies conditions are resolved based on it\n const defaultFormData: T = {\n ...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults),\n ...formData,\n };\n const resolvedSchema = resolveDependencies<T, S, F>(\n validator,\n schema,\n rootSchema,\n false,\n [],\n defaultFormData,\n experimental_customMergeAllOf,\n );\n schemaToCompute = resolvedSchema[0]; // pick the first element from resolve dependencies\n } else if (isFixedItems(schema)) {\n defaults = (schema.items! as S[]).map((itemSchema: S, idx: number) =>\n computeDefaults<T, S>(validator, itemSchema, {\n rootSchema,\n includeUndefinedValues,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined,\n rawFormData: formData as T,\n required,\n shouldMergeDefaultsIntoFormData,\n }),\n ) as T[];\n } else if (ONE_OF_KEY in schema) {\n const { oneOf, ...remaining } = schema;\n if (oneOf!.length === 0) {\n return undefined;\n }\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const { type = 'null' } = remaining;\n if (\n !Array.isArray(type) &&\n PRIMITIVE_TYPES.includes(type) &&\n experimental_dfsb_to_compute?.constAsDefaults === 'skipOneOf'\n ) {\n // If we are in a oneOf of a primitive type, then we want to pass constAsDefaults as 'never' for the recursion\n experimental_dfsb_to_compute = {\n ...experimental_dfsb_to_compute,\n constAsDefaults: 'never',\n };\n }\n schemaToCompute = oneOf![\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n rawFormData ?? (schema.default as T),\n oneOf as S[],\n 0,\n discriminator,\n experimental_customMergeAllOf,\n )\n ] as S;\n schemaToCompute = mergeSchemas(remaining, schemaToCompute) as S;\n } else if (ANY_OF_KEY in schema) {\n const { anyOf, ...remaining } = schema;\n if (anyOf!.length === 0) {\n return undefined;\n }\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n schemaToCompute = anyOf![\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n rawFormData ?? (schema.default as T),\n anyOf as S[],\n 0,\n discriminator,\n experimental_customMergeAllOf,\n )\n ] as S;\n schemaToCompute = mergeSchemas(remaining, schemaToCompute) as S;\n }\n\n if (schemaToCompute) {\n return computeDefaults<T, S, F>(validator, schemaToCompute, {\n rootSchema,\n includeUndefinedValues,\n _recurseList: updatedRecurseList,\n experimental_defaultFormStateBehavior: experimental_dfsb_to_compute,\n experimental_customMergeAllOf,\n parentDefaults: defaults as T | undefined,\n rawFormData: formData as T,\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }\n\n // No defaults defined for this node, fallback to generic typed ones.\n if (defaults === undefined) {\n defaults = schema.default as unknown as T;\n }\n\n const defaultBasedOnSchemaType = getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults);\n\n let defaultsWithFormData = defaultBasedOnSchemaType ?? defaults;\n // if shouldMergeDefaultsIntoFormData is true, then merge the defaults into the formData.\n if (shouldMergeDefaultsIntoFormData) {\n const { arrayMinItems = {} } = experimental_defaultFormStateBehavior || {};\n const { mergeExtraDefaults } = arrayMinItems;\n\n const matchingFormData = ensureFormDataMatchingSchema(\n validator,\n schema,\n rootSchema,\n rawFormData,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n );\n if (!isObject(rawFormData) || ALL_OF_KEY in schema) {\n // If the formData is not an object which means it's a primitive field, then we need to merge the defaults into the formData.\n // Or if the schema has allOf, we need to merge the defaults into the formData because we don't compute the defaults for allOf.\n defaultsWithFormData = mergeDefaultsWithFormData<T>(\n defaultsWithFormData as T,\n matchingFormData as T,\n mergeExtraDefaults,\n true,\n ) as T;\n }\n }\n\n return defaultsWithFormData;\n}\n\n/**\n * Ensure that the formData matches the given schema. If it's not matching in the case of a selectField, we change it to match the schema.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the formData state is desired\n * @param rootSchema - The root schema, used to primarily to look up `$ref`s\n * @param formData - The current formData\n * @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - valid formData that matches schema\n */\nexport function ensureFormDataMatchingSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n formData: T | undefined,\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | T[] | undefined {\n const isSelectField =\n !isConstant<S>(schema) && isSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf);\n let validFormData: T | T[] | undefined = formData;\n if (isSelectField) {\n const getOptionsList = optionsList<T, S, F>(schema);\n const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));\n validFormData = isValid ? formData : undefined;\n }\n\n // Override the formData with the const if the constAsDefaults is set to always\n const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === 'always';\n if (constTakesPrecedence) {\n validFormData = schema.const as T;\n }\n\n return validFormData;\n}\n\n/** Computes the default value for objects.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getObjectDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n {\n rawFormData,\n rootSchema = {} as S,\n includeUndefinedValues = false,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData,\n }: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T {\n {\n const formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;\n const schema: S = rawSchema;\n // This is a custom addition that fixes this issue:\n // https://github.com/rjsf-team/react-jsonschema-form/issues/3832\n const retrievedSchema =\n experimental_defaultFormStateBehavior?.allOf === 'populateDefaults' && ALL_OF_KEY in schema\n ? retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf)\n : schema;\n const parentConst = retrievedSchema[CONST_KEY];\n const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(\n (acc: GenericObjectType, key: string) => {\n const propertySchema: S = get(retrievedSchema, [PROPERTIES_KEY, key], {}) as S;\n // Check if the parent schema has a const property defined AND we are supporting const as defaults, then we\n // should always return the computedDefault since it's coming from the const.\n const hasParentConst = isObject(parentConst) && (parentConst as JSONSchema7Object)[key] !== undefined;\n const hasConst =\n ((isObject(propertySchema) && CONST_KEY in propertySchema) || hasParentConst) &&\n experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&\n !constIsAjvDataReference(propertySchema);\n // Compute the defaults for this node, with the parent defaults we might\n // have from a previous run: defaults[key].\n const computedDefault = computeDefaults<T, S, F>(validator, propertySchema, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n includeUndefinedValues: includeUndefinedValues === true,\n parentDefaults: get(defaults, [key]),\n rawFormData: get(formData, [key]),\n required: retrievedSchema.required?.includes(key),\n shouldMergeDefaultsIntoFormData,\n });\n maybeAddDefaultToObject<T>(\n acc,\n key,\n computedDefault,\n includeUndefinedValues,\n required,\n retrievedSchema.required,\n experimental_defaultFormStateBehavior,\n hasConst,\n );\n return acc;\n },\n {},\n ) as T;\n if (retrievedSchema.additionalProperties) {\n // as per spec additionalProperties may be either schema or boolean\n const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties)\n ? retrievedSchema.additionalProperties\n : {};\n\n const keys = new Set<string>();\n if (isObject(defaults)) {\n Object.keys(defaults as GenericObjectType)\n .filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])\n .forEach((key) => keys.add(key));\n }\n const formDataRequired: string[] = [];\n Object.keys(formData as GenericObjectType)\n .filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])\n .forEach((key) => {\n keys.add(key);\n formDataRequired.push(key);\n });\n keys.forEach((key) => {\n const computedDefault = computeDefaults(validator, additionalPropertiesSchema as S, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n includeUndefinedValues: includeUndefinedValues === true,\n parentDefaults: get(defaults, [key]),\n rawFormData: get(formData, [key]),\n required: retrievedSchema.required?.includes(key),\n shouldMergeDefaultsIntoFormData,\n });\n // Since these are additional properties we don't need to add the `experimental_defaultFormStateBehavior` prop\n maybeAddDefaultToObject<T>(\n objectDefaults as GenericObjectType,\n key,\n computedDefault,\n includeUndefinedValues,\n required,\n formDataRequired,\n );\n });\n }\n return objectDefaults;\n }\n}\n\n/** Computes the default value for arrays.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getArrayDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n {\n rawFormData,\n rootSchema = {} as S,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData,\n }: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T | T[] | undefined {\n const schema: S = rawSchema;\n\n const arrayMinItemsStateBehavior = experimental_defaultFormStateBehavior?.arrayMinItems ?? {};\n const { populate: arrayMinItemsPopulate, mergeExtraDefaults: arrayMergeExtraDefaults } = arrayMinItemsStateBehavior;\n\n const neverPopulate = arrayMinItemsPopulate === 'never';\n const ignoreMinItemsFlagSet = arrayMinItemsPopulate === 'requiredOnly';\n const isPopulateAll = arrayMinItemsPopulate === 'all' || (!neverPopulate && !ignoreMinItemsFlagSet);\n const computeSkipPopulate = arrayMinItemsStateBehavior?.computeSkipPopulate ?? (() => false);\n const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === 'skipEmptyDefaults';\n\n const emptyDefault = isSkipEmptyDefaults ? undefined : [];\n\n // Inject defaults into existing array defaults\n if (Array.isArray(defaults)) {\n defaults = defaults.map((item, idx) => {\n const schemaItem: S = getInnerSchemaForArrayItem<S>(schema, AdditionalItemsHandling.Fallback, idx);\n return computeDefaults<T, S, F>(validator, schemaItem, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n parentDefaults: item,\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }) as T[];\n }\n\n // Deeply inject defaults into already existing form data\n if (Array.isArray(rawFormData)) {\n const schemaItem: S = getInnerSchemaForArrayItem<S>(schema);\n if (neverPopulate) {\n defaults = rawFormData;\n } else {\n const itemDefaults = rawFormData.map((item: T, idx: number) => {\n return computeDefaults<T, S, F>(validator, schemaItem, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n rawFormData: item,\n parentDefaults: get(defaults, [idx]),\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }) as T[];\n\n // If the populate 'requiredOnly' flag is set then we only merge and include extra defaults if they are required.\n // Or if populate 'all' is set we merge and include extra defaults.\n const mergeExtraDefaults = ((ignoreMinItemsFlagSet && required) || isPopulateAll) && arrayMergeExtraDefaults;\n defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);\n }\n }\n\n // Check if the schema has a const property defined AND we are supporting const as defaults, then we should always\n // return the computedDefault since it's coming from the const.\n const hasConst =\n isObject(schema) && CONST_KEY in schema && experimental_defaultFormStateBehavior?.constAsDefaults !== 'never';\n if (hasConst === false) {\n if (neverPopulate) {\n return defaults ?? emptyDefault;\n }\n if (ignoreMinItemsFlagSet && !required) {\n // If no form data exists or defaults are set leave the field empty/non-existent, otherwise\n // return form data/defaults\n return defaults ? defaults : undefined;\n }\n }\n\n const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;\n if (\n !schema.minItems ||\n isMultiSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf) ||\n computeSkipPopulate<T, S, F>(validator, schema, rootSchema) ||\n schema.minItems <= defaultsLength\n ) {\n return defaults ? defaults : emptyDefault;\n }\n\n const defaultEntries: T[] = (defaults || []) as T[];\n const fillerSchema: S = getInnerSchemaForArrayItem<S>(schema, AdditionalItemsHandling.Invert);\n const fillerDefault = fillerSchema.default;\n\n // Calculate filler entries for remaining items (minItems - existing raw data/defaults)\n const fillerEntries: T[] = new Array(schema.minItems - defaultsLength).fill(\n computeDefaults<any, S, F>(validator, fillerSchema, {\n parentDefaults: fillerDefault,\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n required,\n shouldMergeDefaultsIntoFormData,\n }),\n ) as T[];\n // then fill up the rest with either the item default or empty, up to minItems\n return defaultEntries.concat(fillerEntries);\n}\n\n/** Computes the default value based on the schema type.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getDefaultBasedOnSchemaType<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n computeDefaultsProps: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T | T[] | void {\n switch (getSchemaType<S>(rawSchema)) {\n // We need to recurse for object schema inner default values.\n case 'object': {\n return getObjectDefaults(validator, rawSchema, computeDefaultsProps, defaults);\n }\n case 'array': {\n return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);\n }\n }\n}\n\n/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have\n * computed to have defaults provided in the `schema`.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which the default state is desired\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The resulting `formData` with all the defaults provided\n */\nexport default function getDefaultFormState<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n formData?: T,\n rootSchema?: S,\n includeUndefinedValues: boolean | 'excludeObjectChildren' = false,\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (!isObject(theSchema)) {\n throw new Error('Invalid schema: ' + theSchema);\n }\n const schema = retrieveSchema<T, S, F>(validator, theSchema, rootSchema, formData, experimental_customMergeAllOf);\n\n // Get the computed defaults with 'shouldMergeDefaultsIntoFormData' set to true to merge defaults into formData.\n // This is done when for example the value from formData does not exist in the schema 'enum' property, in such\n // cases we take the value from the defaults because the value from the formData is not valid.\n const defaults = computeDefaults<T, S, F>(validator, schema, {\n rootSchema,\n includeUndefinedValues,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n rawFormData: formData,\n shouldMergeDefaultsIntoFormData: true,\n });\n\n // If the formData is an object or an array, add additional properties from formData and override formData with\n // defaults since the defaults are already merged with formData.\n if (isObject(formData) || Array.isArray(formData)) {\n const { mergeDefaultsIntoFormData } = experimental_defaultFormStateBehavior || {};\n const defaultSupercedesUndefined = mergeDefaultsIntoFormData === 'useDefaultIfFormDataUndefined';\n const result = mergeDefaultsWithFormData<T | T[]>(\n defaults,\n formData,\n true, // set to true to add any additional default array entries.\n defaultSupercedesUndefined,\n true, // set to true to override formData with defaults if they exist.\n );\n return result;\n }\n\n return defaults;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isNumber from 'lodash/isNumber';\nimport isObject from 'lodash/isObject';\nimport isString from 'lodash/isString';\nimport reduce from 'lodash/reduce';\nimport times from 'lodash/times';\n\nimport getFirstMatchingOption from './getFirstMatchingOption';\nimport retrieveSchema, { resolveAllReferences } from './retrieveSchema';\nimport { ONE_OF_KEY, REF_KEY, JUNK_OPTION_ID, ANY_OF_KEY } from '../constants';\nimport guessType from '../guessType';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport getOptionMatchingSimpleDiscriminator from '../getOptionMatchingSimpleDiscriminator';\n\n/** A junk option used to determine when the getFirstMatchingOption call really matches an option rather than returning\n * the first item\n */\nexport const JUNK_OPTION: StrictRJSFSchema = {\n type: 'object',\n $id: JUNK_OPTION_ID,\n properties: {\n __not_really_there__: {\n type: 'number',\n },\n },\n};\n\n/** Recursive function that calculates the score of a `formData` against the given `schema`. The computation is fairly\n * simple. Initially the total score is 0. When `schema.properties` object exists, then all the `key/value` pairs within\n * the object are processed as follows after obtaining the formValue from `formData` using the `key`:\n * - If the `value` contains a `$ref`, `calculateIndexScore()` is called recursively with the formValue and the new\n * schema that is the result of the ref in the schema being resolved and that sub-schema's resulting score is added to\n * the total.\n * - If the `value` contains a `oneOf` and there is a formValue, then score based on the index returned from calling\n * `getClosestMatchingOption()` of that oneOf.\n * - If the type of the `value` is 'object', `calculateIndexScore()` is called recursively with the formValue and the\n * `value` itself as the sub-schema, and the score is added to the total.\n * - If the type of the `value` matches the guessed-type of the `formValue`, the score is incremented by 1, UNLESS the\n * value has a `default` or `const`. In those case, if the `default` or `const` and the `formValue` match, the score\n * is incremented by another 1 otherwise it is decremented by 1.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param schema - The schema for which the score is being calculated\n * @param formData - The form data associated with the schema, used to calculate the score\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The score a schema against the formData\n */\nexport function calculateIndexScore<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema?: S,\n formData?: any,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): number {\n let totalScore = 0;\n if (schema) {\n if (isObject(schema.properties)) {\n totalScore += reduce(\n schema.properties,\n (score, value, key) => {\n const formValue = get(formData, key);\n if (typeof value === 'boolean') {\n return score;\n }\n if (has(value, REF_KEY)) {\n const newSchema = retrieveSchema<T, S, F>(\n validator,\n value as S,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n return (\n score +\n calculateIndexScore<T, S, F>(\n validator,\n rootSchema,\n newSchema,\n formValue || {},\n experimental_customMergeAllOf,\n )\n );\n }\n if ((has(value, ONE_OF_KEY) || has(value, ANY_OF_KEY)) && formValue) {\n const key = has(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;\n const discriminator = getDiscriminatorFieldFromSchema<S>(value as S);\n return (\n score +\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n formValue,\n get(value, key) as S[],\n -1,\n discriminator,\n experimental_customMergeAllOf,\n )\n );\n }\n if (value.type === 'object') {\n if (isObject(formValue)) {\n // If the structure is matching then give it a little boost in score\n score += 1;\n }\n return (\n score +\n calculateIndexScore<T, S, F>(validator, rootSchema, value as S, formValue, experimental_customMergeAllOf)\n );\n }\n if (value.type === guessType(formValue)) {\n // If the types match, then we bump the score by one\n let newScore = score + 1;\n if (value.default) {\n // If the schema contains a readonly default value score the value that matches the default higher and\n // any non-matching value lower\n newScore += formValue === value.default ? 1 : -1;\n } else if (value.const) {\n // If the schema contains a const value score the value that matches the default higher and\n // any non-matching value lower\n newScore += formValue === value.const ? 1 : -1;\n }\n // TODO eventually, deal with enums/arrays\n return newScore;\n }\n return score;\n },\n 0,\n );\n } else if (isString(schema.type) && schema.type === guessType(formData)) {\n totalScore += 1;\n }\n }\n return totalScore;\n}\n\n/** Determines which of the given `options` provided most closely matches the `formData`. Using\n * `getFirstMatchingOption()` to match two schemas that differ only by the readOnly, default or const value of a field\n * based on the `formData` and returns 0 when there is no match. Rather than passing in all the `options` at once to\n * this utility, instead an array of valid option indexes is created by iterating over the list of options, call\n * `getFirstMatchingOptions` with a list of one junk option and one good option, seeing if the good option is considered\n * matched.\n *\n * Once the list of valid indexes is created, if there is only one valid index, just return it. Otherwise, if there are\n * no valid indexes, then fill the valid indexes array with the indexes of all the options. Next, the index of the\n * option with the highest score is determined by iterating over the list of valid options, calling\n * `calculateIndexScore()` on each, comparing it against the current best score, and returning the index of the one that\n * eventually has the best score.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param formData - The form data associated with the schema\n * @param options - The list of options that can be selected from\n * @param [selectedOption=-1] - The index of the currently selected option, defaulted to -1 if not specified\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match\n */\nexport default function getClosestMatchingOption<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n formData: T | undefined,\n options: S[],\n selectedOption = -1,\n discriminatorField?: string,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): number {\n // First resolve any refs in the options\n const resolvedOptions = options.map((option) => {\n return resolveAllReferences<S>(option, rootSchema, []);\n });\n\n const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);\n if (isNumber(simpleDiscriminatorMatch)) {\n return simpleDiscriminatorMatch;\n }\n\n // Reduce the array of options down to a list of the indexes that are considered matching options\n const allValidIndexes = resolvedOptions.reduce((validList: number[], option, index: number) => {\n const testOptions: S[] = [JUNK_OPTION as S, option];\n const match = getFirstMatchingOption<T, S, F>(validator, formData, testOptions, rootSchema, discriminatorField);\n // The match is the real option, so add its index to list of valid indexes\n if (match === 1) {\n validList.push(index);\n }\n return validList;\n }, []);\n\n // There is only one valid index, so return it!\n if (allValidIndexes.length === 1) {\n return allValidIndexes[0];\n }\n if (!allValidIndexes.length) {\n // No indexes were valid, so we'll score all the options, add all the indexes\n times(resolvedOptions.length, (i) => allValidIndexes.push(i));\n }\n type BestType = { bestIndex: number; bestScore: number };\n const scoreCount = new Set<number>();\n // Score all the options in the list of valid indexes and return the index with the best score\n const { bestIndex }: BestType = allValidIndexes.reduce(\n (scoreData: BestType, index: number) => {\n const { bestScore } = scoreData;\n const option = resolvedOptions[index];\n const score = calculateIndexScore(validator, rootSchema, option, formData, experimental_customMergeAllOf);\n scoreCount.add(score);\n if (score > bestScore) {\n return { bestIndex: index, bestScore: score };\n }\n return scoreData;\n },\n { bestIndex: selectedOption, bestScore: 0 },\n );\n // if all scores are the same go with selectedOption\n if (scoreCount.size === 1 && selectedOption >= 0) {\n return selectedOption;\n }\n\n return bestIndex;\n}\n", "import isObject from './isObject';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array\n * that only contains objects.\n *\n * @param schema - The schema in which to check for fixed items\n * @returns - True if there are fixed items in the schema, false otherwise\n */\nexport default function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));\n}\n", "import get from 'lodash/get';\n\nimport isObject from './isObject';\nimport { GenericObjectType } from '../src';\nimport isNil from 'lodash/isNil';\n\n/** Merges the `defaults` object of type `T` into the `formData` of type `T`\n *\n * When merging defaults and form data, we want to merge in this specific way:\n * - objects are deeply merged\n * - arrays are merged in such a way that:\n * - when the array is set in form data, only array entries set in form data\n * are deeply merged; additional entries from the defaults are ignored unless `mergeExtraArrayDefaults` is true, in\n * which case the extras are appended onto the end of the form data\n * - when the array is not set in form data, the default is copied over\n * - scalars are overwritten/set by form data unless undefined and there is a default AND `defaultSupercedesUndefined`\n * is true\n *\n * @param [defaults] - The defaults to merge\n * @param [formData] - The form data into which the defaults will be merged\n * @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData\n * @param [defaultSupercedesUndefined=false] - If true, an explicit undefined value will be overwritten by the default value\n * @param [overrideFormDataWithDefaults=false] - If true, the default value will overwrite the form data value. If the value\n * doesn't exist in the default, we take it from formData and in the case where the value is set to undefined in formData.\n * This is useful when we have already merged formData with defaults and want to add an additional field from formData\n * that does not exist in defaults.\n * @returns - The resulting merged form data with defaults\n */\nexport default function mergeDefaultsWithFormData<T = any>(\n defaults?: T,\n formData?: T,\n mergeExtraArrayDefaults = false,\n defaultSupercedesUndefined = false,\n overrideFormDataWithDefaults = false,\n): T | undefined {\n if (Array.isArray(formData)) {\n const defaultsArray = Array.isArray(defaults) ? defaults : [];\n\n // If overrideFormDataWithDefaults is true, we want to override the formData with the defaults\n const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;\n const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;\n\n const mapped = overrideArray.map((value, idx) => {\n // We want to explicitly make sure that the value is NOT undefined since null, 0 and empty space are valid values\n if (overrideOppositeArray[idx] !== undefined) {\n return mergeDefaultsWithFormData<any>(\n defaultsArray[idx],\n formData[idx],\n mergeExtraArrayDefaults,\n defaultSupercedesUndefined,\n overrideFormDataWithDefaults,\n );\n }\n return value;\n });\n\n // Merge any extra defaults when mergeExtraArrayDefaults is true\n // Or when overrideFormDataWithDefaults is true and the default array is shorter than the formData array\n if ((mergeExtraArrayDefaults || overrideFormDataWithDefaults) && mapped.length < overrideOppositeArray.length) {\n mapped.push(...overrideOppositeArray.slice(mapped.length));\n }\n return mapped as unknown as T;\n }\n if (isObject(formData)) {\n const acc: { [key in keyof T]: any } = Object.assign({}, defaults); // Prevent mutation of source object.\n return Object.keys(formData as GenericObjectType).reduce((acc, key) => {\n const keyValue = get(formData, key);\n const keyExistsInDefaults = isObject(defaults) && key in (defaults as GenericObjectType);\n const keyExistsInFormData = key in (formData as GenericObjectType);\n acc[key as keyof T] = mergeDefaultsWithFormData<T>(\n defaults ? get(defaults, key) : {},\n keyValue,\n mergeExtraArrayDefaults,\n defaultSupercedesUndefined,\n // overrideFormDataWithDefaults can be true only when the key value exists in defaults\n // Or if the key value doesn't exist in formData\n overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData),\n );\n return acc;\n }, acc);\n }\n\n /**\n * If the defaultSupercedesUndefined flag is true\n * And formData is set to undefined or null and defaults are defined\n * Or if formData is a number and is NaN return defaults\n * Or if overrideFormDataWithDefaults flag is true and formData is set to not undefined/null return defaults\n */\n if (\n (defaultSupercedesUndefined &&\n ((!isNil(defaults) && isNil(formData)) || (typeof formData === 'number' && isNaN(formData)))) ||\n (overrideFormDataWithDefaults && !isNil(formData))\n ) {\n return defaults;\n }\n\n return formData;\n}\n", "import isObject from './isObject';\nimport { GenericObjectType } from './types';\n\n/** Recursively merge deeply nested objects.\n *\n * @param obj1 - The first object to merge\n * @param obj2 - The second object to merge\n * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use\n * \"preventDuplicates\" to merge arrays in a manner that prevents any duplicate entries from being merged.\n * NOTE: Uses shallow comparison for the duplicate checking.\n * @returns - A new object that is the merge of the two given objects\n */\nexport default function mergeObjects(\n obj1: GenericObjectType,\n obj2: GenericObjectType,\n concatArrays: boolean | 'preventDuplicates' = false,\n) {\n return Object.keys(obj2).reduce(\n (acc, key) => {\n const left = obj1 ? obj1[key] : {},\n right = obj2[key];\n if (obj1 && key in obj1 && isObject(right)) {\n acc[key] = mergeObjects(left, right, concatArrays);\n } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {\n let toMerge = right;\n if (concatArrays === 'preventDuplicates') {\n toMerge = right.reduce((result, value) => {\n if (!left.includes(value)) {\n result.push(value);\n }\n return result;\n }, []);\n }\n acc[key] = left.concat(toMerge);\n } else {\n acc[key] = right;\n }\n return acc;\n },\n Object.assign({}, obj1),\n ); // Prevent mutation of source object.\n}\n", "import { CONST_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has\n * an `enum` array with a single value or there is a `const` defined.\n *\n * @param schema - The schema for a field\n * @returns - True if the `schema` has a single constant value, false otherwise\n */\nexport default function isConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return (Array.isArray(schema.enum) && schema.enum.length === 1) || CONST_KEY in schema;\n}\n", "import isConstant from '../isConstant';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType, Experimental_CustomMergeAllOf } from '../types';\nimport retrieveSchema from './retrieveSchema';\n\n/** Checks to see if the `schema` combination represents a select\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which check for a select flag is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema contains a select, otherwise false\n */\nexport default function isSelect<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n rootSchema: S = {} as S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n const schema = retrieveSchema<T, S, F>(validator, theSchema, rootSchema, undefined, experimental_customMergeAllOf);\n const altSchemas = schema.oneOf || schema.anyOf;\n if (Array.isArray(schema.enum)) {\n return true;\n }\n if (Array.isArray(altSchemas)) {\n return altSchemas.every((altSchemas) => typeof altSchemas !== 'boolean' && isConstant(altSchemas));\n }\n return false;\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType, Experimental_CustomMergeAllOf } from '../types';\n\nimport isSelect from './isSelect';\n\n/** Checks to see if the `schema` combination represents a multi-select\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which check for a multi-select flag is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema contains a multi-select, otherwise false\n */\nexport default function isMultiSelect<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema?: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (!schema.uniqueItems || !schema.items || typeof schema.items === 'boolean') {\n return false;\n }\n return isSelect<T, S, F>(validator, schema.items as S, rootSchema, experimental_customMergeAllOf);\n}\n", "import { CONST_KEY, getSchemaType, isObject } from './';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport { JSONSchema7Type } from 'json-schema';\nimport isString from 'lodash/isString';\n\n/**\n * Checks if the schema const property value is an AJV $data reference\n * and the current schema is not an object or array\n *\n * @param schema - The schema to check if the const is an AJV $data reference\n * @returns - true if the schema const property value is an AJV $data reference otherwise false.\n */\nexport default function constIsAjvDataReference<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {\n const schemaConst = schema[CONST_KEY] as JSONSchema7Type & { $data: string };\n const schemaType = getSchemaType<S>(schema);\n return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== 'object' && schemaType !== 'array';\n}\n", "import get from 'lodash/get';\n\nimport { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from './constants';\nimport getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';\nimport getUiOptions from './getUiOptions';\nimport toConstant from './toConstant';\nimport { RJSFSchema, EnumOptionsType, StrictRJSFSchema, FormContextType, UiSchema } from './types';\n\n/** Gets the list of options from the `schema`. If the schema has an enum list, then those enum values are returned. The\n * label will be the same as the `value`.\n *\n * If the schema has a `oneOf` or `anyOf`, then the value is the list of either:\n * - The `const` values from the schema if present\n * - If the schema has a discriminator and the label using either the `schema.title` or the value. If a `uiSchema` is\n * provided, and it has the `ui:enumNames` matched with `enum` or it has an associated `oneOf` or `anyOf` with a list of\n * objects containing `ui:title` then the UI schema values will replace the values from the schema.\n *\n * @param schema - The schema from which to extract the options list\n * @param [uiSchema] - The optional uiSchema from which to get alternate labels for the options\n * @returns - The list of options from the schema\n */\nexport default function optionsList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: S,\n uiSchema?: UiSchema<T, S, F>,\n): EnumOptionsType<S>[] | undefined {\n if (schema.enum) {\n let enumNames: string[] | undefined;\n if (uiSchema) {\n const { enumNames: uiEnumNames } = getUiOptions<T, S, F>(uiSchema);\n enumNames = uiEnumNames;\n }\n return schema.enum.map((value, i) => {\n const label = enumNames?.[i] || String(value);\n return { label, value };\n });\n }\n let altSchemas: S['anyOf'] | S['oneOf'] = undefined;\n let altUiSchemas: UiSchema<T, S, F> | undefined = undefined;\n if (schema.anyOf) {\n altSchemas = schema.anyOf;\n altUiSchemas = uiSchema?.anyOf;\n } else if (schema.oneOf) {\n altSchemas = schema.oneOf;\n altUiSchemas = uiSchema?.oneOf;\n }\n // See if there is a discriminator path specified in the schema, and if so, use it as the selectorField, otherwise\n // pull one from the uiSchema\n let selectorField = getDiscriminatorFieldFromSchema<S>(schema);\n if (uiSchema) {\n const { optionsSchemaSelector = selectorField } = getUiOptions<T, S, F>(uiSchema);\n selectorField = optionsSchemaSelector;\n }\n return (\n altSchemas &&\n altSchemas.map((aSchemaDef, index) => {\n const { title } = getUiOptions<T, S, F>(altUiSchemas?.[index]);\n const aSchema = aSchemaDef as S;\n let value: EnumOptionsType<S>['value'];\n let label = title;\n if (selectorField) {\n const innerSchema: S = get(aSchema, [PROPERTIES_KEY, selectorField], {}) as S;\n value = get(innerSchema, DEFAULT_KEY, get(innerSchema, CONST_KEY));\n label = label || innerSchema?.title || aSchema.title || String(value);\n } else {\n value = toConstant(aSchema);\n label = label || aSchema.title || String(value);\n }\n return {\n schema: aSchema,\n label,\n value,\n };\n })\n );\n}\n", "import { CONST_KEY, ENUM_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise\n * throws an error.\n *\n * @param schema - The schema from which to obtain the constant value\n * @returns - The constant value for the schema\n * @throws - Error when the schema does not have a constant value\n */\nexport default function toConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {\n return schema.enum[0];\n }\n if (CONST_KEY in schema) {\n return schema.const;\n }\n throw new Error('schema cannot be inferred as a constant');\n}\n", "import getUiOptions from './getUiOptions';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';\n\n/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`\n *\n * @param uiSchema - The UI Schema from which to detect if it is customized\n * @returns - True if the `uiSchema` describes a custom widget, false otherwise\n */\nexport default function isCustomWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(uiSchema: UiSchema<T, S, F> = {}) {\n return (\n // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.\n // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets\n 'widget' in getUiOptions<T, S, F>(uiSchema) && getUiOptions<T, S, F>(uiSchema)['widget'] !== 'hidden'\n );\n}\n", "import { UI_WIDGET_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n} from '../types';\nimport retrieveSchema from './retrieveSchema';\n\n/** Checks to see if the `schema` and `uiSchema` combination represents an array of files\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which check for array of files flag is desired\n * @param [uiSchema={}] - The UI schema from which to check the widget\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema/uiSchema contains an array of files, otherwise false\n */\nexport default function isFilesArray<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n uiSchema: UiSchema<T, S, F> = {},\n rootSchema?: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (uiSchema[UI_WIDGET_KEY] === 'files') {\n return true;\n }\n if (schema.items) {\n const itemsSchema = retrieveSchema<T, S, F>(\n validator,\n schema.items as S,\n rootSchema,\n undefined,\n experimental_customMergeAllOf,\n );\n return itemsSchema.type === 'string' && itemsSchema.format === 'data-url';\n }\n return false;\n}\n", "import { UI_FIELD_KEY, UI_WIDGET_KEY } from '../constants';\nimport getSchemaType from '../getSchemaType';\nimport getUiOptions from '../getUiOptions';\nimport isCustomWidget from '../isCustomWidget';\nimport {\n FormContextType,\n GlobalUISchemaOptions,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n Experimental_CustomMergeAllOf,\n} from '../types';\nimport isFilesArray from './isFilesArray';\nimport isMultiSelect from './isMultiSelect';\n\n/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`\n * should be displayed in a UI.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the display label flag is desired\n * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if the label should be displayed or false if it should not\n */\nexport default function getDisplayLabel<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n uiSchema: UiSchema<T, S, F> = {},\n rootSchema?: S,\n globalOptions?: GlobalUISchemaOptions,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): boolean {\n const uiOptions = getUiOptions<T, S, F>(uiSchema, globalOptions);\n const { label = true } = uiOptions;\n let displayLabel = !!label;\n const schemaType = getSchemaType<S>(schema);\n\n if (schemaType === 'array') {\n displayLabel =\n isMultiSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf) ||\n isFilesArray<T, S, F>(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) ||\n isCustomWidget(uiSchema);\n }\n\n if (schemaType === 'object') {\n displayLabel = false;\n }\n if (schemaType === 'boolean' && !uiSchema[UI_WIDGET_KEY]) {\n displayLabel = false;\n }\n if (uiSchema[UI_FIELD_KEY]) {\n displayLabel = false;\n }\n return displayLabel;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport { PROPERTIES_KEY, REF_KEY } from '../constants';\nimport retrieveSchema from './retrieveSchema';\n\nconst NO_VALUE = Symbol('no Value');\n\n/** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new\n * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature\n * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema\n * that are non-existent in the new schema are set to `undefined`. The data sanitization process has the following flow:\n *\n * - If the new schema is an object that contains a `properties` object then:\n * - Create a `removeOldSchemaData` object, setting each key in the `oldSchema.properties` having `data` to undefined\n * - Create an empty `nestedData` object for use in the key filtering below:\n * - Iterate over each key in the `newSchema.properties` as follows:\n * - Get the `formValue` of the key from the `data`\n * - Get the `oldKeySchema` and `newKeyedSchema` for the key, defaulting to `{}` when it doesn't exist\n * - Retrieve the schema for any refs within each `oldKeySchema` and/or `newKeySchema`\n * - Get the types of the old and new keyed schemas and if the old doesn't exist or the old & new are the same then:\n * - If `removeOldSchemaData` has an entry for the key, delete it since the new schema has the same property\n * - If type of the key in the new schema is `object`:\n * - Store the value from the recursive `sanitizeDataForNewSchema` call in `nestedData[key]`\n * - Otherwise, check for default or const values:\n * - Get the old and new `default` values from the schema and check:\n * - If the new `default` value does not match the form value:\n * - If the old `default` value DOES match the form value, then:\n * - Replace `removeOldSchemaData[key]` with the new `default`\n * - Otherwise, if the new schema is `readOnly` then replace `removeOldSchemaData[key]` with undefined\n * - Get the old and new `const` values from the schema and check:\n * - If the new `const` value does not match the form value:\n * - If the old `const` value DOES match the form value, then:\n * - Replace `removeOldSchemaData[key]` with the new `const`\n * - Otherwise, replace `removeOldSchemaData[key]` with undefined\n * - Once all keys have been processed, return an object built as follows:\n * - `{ ...removeOldSchemaData, ...nestedData, ...pick(data, keysToKeep) }`\n * - If the new and old schema types are array and the `data` is an array then:\n * - If the type of the old and new schema `items` are a non-array objects:\n * - Retrieve the schema for any refs within each `oldKeySchema.items` and/or `newKeySchema.items`\n * - If the `type`s of both items are the same (or the old does not have a type):\n * - If the type is \"object\", then:\n * - For each element in the `data` recursively sanitize the data, stopping at `maxItems` if specified\n * - Otherwise, just return the `data` removing any values after `maxItems` if it is set\n * - If the type of the old and new schema `items` are booleans of the same value, return `data` as is\n * - Otherwise return `undefined`\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param [newSchema] - The new schema for which the data is being sanitized\n * @param [oldSchema] - The old schema from which the data originated\n * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The new form data, with all the fields uniquely associated with the old schema set\n * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.\n */\nexport default function sanitizeDataForNewSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n newSchema?: S,\n oldSchema?: S,\n data: any = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T {\n // By default, we will clear the form data\n let newFormData;\n // If the new schema is of type object and that object contains a list of properties\n if (has(newSchema, PROPERTIES_KEY)) {\n // Create an object containing root-level keys in the old schema, setting each key to undefined to remove the data\n const removeOldSchemaData: GenericObjectType = {};\n if (has(oldSchema, PROPERTIES_KEY)) {\n const properties = get(oldSchema, PROPERTIES_KEY, {});\n Object.keys(properties).forEach((key) => {\n if (has(data, key)) {\n removeOldSchemaData[key] = undefined;\n }\n });\n }\n const keys: string[] = Object.keys(get(newSchema, PROPERTIES_KEY, {}));\n // Create a place to store nested data that will be a side-effect of the filter\n const nestedData: GenericObjectType = {};\n keys.forEach((key) => {\n const formValue = get(data, key);\n let oldKeyedSchema: S = get(oldSchema, [PROPERTIES_KEY, key], {}) as S;\n let newKeyedSchema: S = get(newSchema, [PROPERTIES_KEY, key], {}) as S;\n // Resolve the refs if they exist\n if (has(oldKeyedSchema, REF_KEY)) {\n oldKeyedSchema = retrieveSchema<T, S, F>(\n validator,\n oldKeyedSchema,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n }\n if (has(newKeyedSchema, REF_KEY)) {\n newKeyedSchema = retrieveSchema<T, S, F>(\n validator,\n newKeyedSchema,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n }\n // Now get types and see if they are the same\n const oldSchemaTypeForKey = get(oldKeyedSchema, 'type');\n const newSchemaTypeForKey = get(newKeyedSchema, 'type');\n // Check if the old option has the same key with the same type\n if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {\n if (has(removeOldSchemaData, key)) {\n // SIDE-EFFECT: remove the undefined value for a key that has the same type between the old and new schemas\n delete removeOldSchemaData[key];\n }\n // If it is an object, we'll recurse and store the resulting sanitized data for the key\n if (newSchemaTypeForKey === 'object' || (newSchemaTypeForKey === 'array' && Array.isArray(formValue))) {\n // SIDE-EFFECT: process the new schema type of object recursively to save iterations\n const itemData = sanitizeDataForNewSchema<T, S, F>(\n validator,\n rootSchema,\n newKeyedSchema,\n oldKeyedSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n if (itemData !== undefined || newSchemaTypeForKey === 'array') {\n // only put undefined values for the array type and not the object type\n nestedData[key] = itemData;\n }\n } else {\n // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced\n // with the new default or const. This allows the case where two schemas differ that only by the default/const\n // value to be properly selected\n const newOptionDefault = get(newKeyedSchema, 'default', NO_VALUE);\n const oldOptionDefault = get(oldKeyedSchema, 'default', NO_VALUE);\n if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {\n if (oldOptionDefault === formValue) {\n // If the old default matches the formValue, we'll update the new value to match the new default\n removeOldSchemaData[key] = newOptionDefault;\n } else if (get(newKeyedSchema, 'readOnly') === true) {\n // If the new schema has the default set to read-only, treat it like a const and remove the value\n removeOldSchemaData[key] = undefined;\n }\n }\n\n const newOptionConst = get(newKeyedSchema, 'const', NO_VALUE);\n const oldOptionConst = get(oldKeyedSchema, 'const', NO_VALUE);\n if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {\n // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it\n removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;\n }\n }\n }\n });\n\n newFormData = {\n ...(typeof data == 'string' || Array.isArray(data) ? undefined : data),\n ...removeOldSchemaData,\n ...nestedData,\n };\n // First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep\n } else if (get(oldSchema, 'type') === 'array' && get(newSchema, 'type') === 'array' && Array.isArray(data)) {\n let oldSchemaItems = get(oldSchema, 'items');\n let newSchemaItems = get(newSchema, 'items');\n // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data\n // Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations\n if (\n typeof oldSchemaItems === 'object' &&\n typeof newSchemaItems === 'object' &&\n !Array.isArray(oldSchemaItems) &&\n !Array.isArray(newSchemaItems)\n ) {\n if (has(oldSchemaItems, REF_KEY)) {\n oldSchemaItems = retrieveSchema<T, S, F>(\n validator,\n oldSchemaItems as S,\n rootSchema,\n data as T,\n experimental_customMergeAllOf,\n );\n }\n if (has(newSchemaItems, REF_KEY)) {\n newSchemaItems = retrieveSchema<T, S, F>(\n validator,\n newSchemaItems as S,\n rootSchema,\n data as T,\n experimental_customMergeAllOf,\n );\n }\n // Now get types and see if they are the same\n const oldSchemaType = get(oldSchemaItems, 'type');\n const newSchemaType = get(newSchemaItems, 'type');\n // Check if the old option has the same key with the same type\n if (!oldSchemaType || oldSchemaType === newSchemaType) {\n const maxItems = get(newSchema, 'maxItems', -1);\n if (newSchemaType === 'object') {\n newFormData = data.reduce((newValue, aValue) => {\n const itemValue = sanitizeDataForNewSchema<T, S, F>(\n validator,\n rootSchema,\n newSchemaItems as S,\n oldSchemaItems as S,\n aValue,\n experimental_customMergeAllOf,\n );\n if (itemValue !== undefined && (maxItems < 0 || newValue.length < maxItems)) {\n newValue.push(itemValue);\n }\n return newValue;\n }, []);\n } else {\n newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;\n }\n }\n } else if (\n typeof oldSchemaItems === 'boolean' &&\n typeof newSchemaItems === 'boolean' &&\n oldSchemaItems === newSchemaItems\n ) {\n // If they are both booleans and have the same value just return the data as is otherwise fall-thru to undefined\n newFormData = data;\n }\n // Also probably want to deal with `prefixItems` as tuples with the latest 2020 draft\n }\n return newFormData as T;\n}\n", "import get from 'lodash/get';\n\nimport { ALL_OF_KEY, DEPENDENCIES_KEY, ID_KEY, ITEMS_KEY, PROPERTIES_KEY, REF_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n IdSchema,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport retrieveSchema from './retrieveSchema';\nimport getSchemaType from '../getSchemaType';\nimport deepEquals from '../deepEquals';\n\n/** An internal helper that generates an `IdSchema` object for the `schema`, recursively with protection against\n * infinite recursion\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `IdSchema` is desired\n * @param idPrefix - The prefix to use for the id\n * @param idSeparator - The separator to use for the path segments in the id\n * @param [id] - The base id for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `IdSchema` object for the `schema`\n */\nfunction toIdSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n idPrefix: string,\n idSeparator: string,\n id?: string | null,\n rootSchema?: S,\n formData?: T,\n _recurseList: S[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): IdSchema<T> {\n const $id = id || idPrefix;\n const idSchema: IdSchema<T> = { $id } as IdSchema<T>;\n if (typeof schema === 'object') {\n if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {\n const _schema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);\n const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));\n if (sameSchemaIndex === -1) {\n return toIdSchemaInternal<T, S, F>(\n validator,\n _schema,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n _recurseList.concat(_schema),\n experimental_customMergeAllOf,\n );\n }\n }\n if (ITEMS_KEY in schema && !get(schema, [ITEMS_KEY, REF_KEY])) {\n return toIdSchemaInternal<T, S, F>(\n validator,\n get(schema, ITEMS_KEY) as S,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n if (getSchemaType<S>(schema) === 'object' && PROPERTIES_KEY in schema) {\n for (const name in schema.properties) {\n const field: S = schema[PROPERTIES_KEY][name] as S;\n const fieldId = idSchema[ID_KEY] + idSeparator + name;\n (idSchema as IdSchema<GenericObjectType>)[name] = toIdSchemaInternal<T, S, F>(\n validator,\n field,\n idPrefix,\n idSeparator,\n fieldId,\n rootSchema,\n // It's possible that formData is not an object -- this can happen if an\n // array item has just been added, but not populated with data yet\n get(formData, [name]),\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n }\n }\n return idSchema;\n}\n\n/** Generates an `IdSchema` object for the `schema`, recursively\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `IdSchema` is desired\n * @param [id] - The base id for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [idPrefix='root'] - The prefix to use for the id\n * @param [idSeparator='_'] - The separator to use for the path segments in the id\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `IdSchema` object for the `schema`\n */\nexport default function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n id?: string | null,\n rootSchema?: S,\n formData?: T,\n idPrefix = 'root',\n idSeparator = '_',\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): IdSchema<T> {\n return toIdSchemaInternal<T, S, F>(\n validator,\n schema,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n undefined,\n experimental_customMergeAllOf,\n );\n}\n", "import get from 'lodash/get';\nimport set from 'lodash/set';\n\nimport {\n ADDITIONAL_PROPERTIES_KEY,\n ALL_OF_KEY,\n ANY_OF_KEY,\n DEPENDENCIES_KEY,\n ITEMS_KEY,\n NAME_KEY,\n ONE_OF_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n RJSF_ADDITIONAL_PROPERTIES_FLAG,\n} from '../constants';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n PathSchema,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport getClosestMatchingOption from './getClosestMatchingOption';\nimport retrieveSchema from './retrieveSchema';\nimport deepEquals from '../deepEquals';\n\n/** An internal helper that generates an `PathSchema` object for the `schema`, recursively with protection against\n * infinite recursion\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `PathSchema` is desired\n * @param [name=''] - The base name for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `PathSchema` object for the `schema`\n */\nfunction toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n name: string,\n rootSchema?: S,\n formData?: T,\n _recurseList: S[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): PathSchema<T> {\n if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {\n const _schema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);\n const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));\n if (sameSchemaIndex === -1) {\n return toPathSchemaInternal<T, S, F>(\n validator,\n _schema,\n name,\n rootSchema,\n formData,\n _recurseList.concat(_schema),\n experimental_customMergeAllOf,\n );\n }\n }\n\n let pathSchema: PathSchema<T> = {\n [NAME_KEY]: name.replace(/^\\./, ''),\n } as PathSchema<T>;\n\n if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {\n const xxxOf: S[] = ONE_OF_KEY in schema ? (schema.oneOf as S[]) : (schema.anyOf as S[]);\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const index = getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema!,\n formData,\n xxxOf,\n 0,\n discriminator,\n experimental_customMergeAllOf,\n );\n const _schema: S = xxxOf![index] as S;\n pathSchema = {\n ...pathSchema,\n ...toPathSchemaInternal<T, S, F>(\n validator,\n _schema,\n name,\n rootSchema,\n formData,\n _recurseList,\n experimental_customMergeAllOf,\n ),\n };\n }\n\n if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {\n set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);\n }\n\n if (ITEMS_KEY in schema && Array.isArray(formData)) {\n const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;\n\n if (Array.isArray(schemaItems)) {\n formData.forEach((element, i: number) => {\n if (schemaItems[i]) {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaItems[i] as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n } else if (schemaAdditionalItems) {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaAdditionalItems as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n } else {\n console.warn(`Unable to generate path schema for \"${name}.${i}\". No schema defined for it`);\n }\n });\n } else {\n formData.forEach((element, i: number) => {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaItems as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n });\n }\n } else if (PROPERTIES_KEY in schema) {\n for (const property in schema.properties) {\n const field: S = get(schema, [PROPERTIES_KEY, property], {}) as S;\n (pathSchema as PathSchema<GenericObjectType>)[property] = toPathSchemaInternal<T, S, F>(\n validator,\n field,\n `${name}.${property}`,\n rootSchema,\n // It's possible that formData is not an object -- this can happen if an\n // array item has just been added, but not populated with data yet\n get(formData, [property]),\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n }\n return pathSchema;\n}\n\n/** Generates an `PathSchema` object for the `schema`, recursively\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `PathSchema` is desired\n * @param [name=''] - The base name for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `PathSchema` object for the `schema`\n */\nexport default function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n name = '',\n rootSchema?: S,\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): PathSchema<T> {\n return toPathSchemaInternal(validator, schema, name, rootSchema, formData, undefined, experimental_customMergeAllOf);\n}\n", "import deepEquals from './deepEquals';\nimport {\n Experimental_CustomMergeAllOf,\n Experimental_DefaultFormStateBehavior,\n FormContextType,\n FoundFieldType,\n GlobalUISchemaOptions,\n IdSchema,\n PathSchema,\n RJSFSchema,\n SchemaUtilsType,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n} from './types';\nimport {\n findFieldInSchema,\n findSelectedOptionInXxxOf,\n getDefaultFormState,\n getDisplayLabel,\n getClosestMatchingOption,\n getFirstMatchingOption,\n getFromSchema,\n isFilesArray,\n isMultiSelect,\n isSelect,\n retrieveSchema,\n sanitizeDataForNewSchema,\n toIdSchema,\n toPathSchema,\n} from './schema';\n\n/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such\n * that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or\n * `experimental_customMergeAllOf` to each method. Since these generally do not change across a `Form`, this allows for\n * providing a simplified set of APIs to the `@rjsf/core` components and the various themes as well. This class\n * implements the `SchemaUtilsType` interface.\n */\nclass SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements SchemaUtilsType<T, S, F>\n{\n rootSchema: S;\n validator: ValidatorType<T, S, F>;\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior;\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;\n\n /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n */\n constructor(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n ) {\n this.rootSchema = rootSchema;\n this.validator = validator;\n this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;\n this.experimental_customMergeAllOf = experimental_customMergeAllOf;\n }\n\n /** Returns the `ValidatorType` in the `SchemaUtilsType`\n *\n * @returns - The `ValidatorType`\n */\n getValidator() {\n return this.validator;\n }\n\n /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of\n * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation\n * of a new `SchemaUtilsType` with incomplete properties.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one\n * @param rootSchema - The root schema that will be compared against the current one\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`\n */\n doesSchemaUtilsDiffer(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n ): boolean {\n if (!validator || !rootSchema) {\n return false;\n }\n return (\n this.validator !== validator ||\n !deepEquals(this.rootSchema, rootSchema) ||\n !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) ||\n this.experimental_customMergeAllOf !== experimental_customMergeAllOf\n );\n }\n\n /** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified\n * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf\n * field is in the `required` list for its parent and if so, it is marked as required on return.\n *\n * @param schema - The current node within the JSON schema\n * @param path - The remaining keys in the path to the desired field\n * @param [formData] - The form data that is used to determine which oneOf option\n * @returns - An object that contains the field and its required state. If no field can be found then\n * `{ field: undefined, isRequired: undefined }` is returned.\n */\n findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S> {\n return findFieldInSchema(\n this.validator,\n this.rootSchema,\n schema,\n path,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that\n * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either\n * `schema.discriminator.propertyName` or `fallbackField`.\n *\n * @param schema - The schema element in which to search for the selected oneOf option\n * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field\n * @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought\n * @param [formData={}] - The form data that is used to determine which oneOf option\n * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected\n */\n findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData: T): S | undefined {\n return findSelectedOptionInXxxOf(\n this.validator,\n this.rootSchema,\n schema,\n fallbackField,\n xxx,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have\n * computed to have defaults provided in the `schema`.\n *\n * @param schema - The schema for which the default state is desired\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", pass `includeUndefinedValues` as false when computing defaults for any nested\n * object properties.\n * @returns - The resulting `formData` with all the defaults provided\n */\n getDefaultFormState(\n schema: S,\n formData?: T,\n includeUndefinedValues: boolean | 'excludeObjectChildren' = false,\n ): T | T[] | undefined {\n return getDefaultFormState<T, S, F>(\n this.validator,\n schema,\n formData,\n this.rootSchema,\n includeUndefinedValues,\n this.experimental_defaultFormStateBehavior,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`\n * should be displayed in a UI.\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [uiSchema] - The UI schema from which to derive potentially displayable information\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @returns - True if the label should be displayed or false if it should not\n */\n getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions) {\n return getDisplayLabel<T, S, F>(\n this.validator,\n schema,\n uiSchema,\n this.rootSchema,\n globalOptions,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Determines which of the given `options` provided most closely matches the `formData`.\n * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.\n *\n * The closest match is determined using the number of matching properties, and more heavily favors options with\n * matching readOnly, default, or const values.\n *\n * @param formData - The form data associated with the schema\n * @param options - The list of options that can be selected from\n * @param [selectedOption] - The index of the currently selected option, defaulted to -1 if not specified\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match\n */\n getClosestMatchingOption(\n formData: T | undefined,\n options: S[],\n selectedOption?: number,\n discriminatorField?: string,\n ): number {\n return getClosestMatchingOption<T, S, F>(\n this.validator,\n this.rootSchema,\n formData,\n options,\n selectedOption,\n discriminatorField,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.\n * Always returns the first option if there is nothing that matches.\n *\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The firstindex of the matched option or 0 if none is available\n */\n getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number {\n return getFirstMatchingOption<T, S, F>(this.validator, formData, options, this.rootSchema, discriminatorField);\n }\n\n /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas\n * containing potentially nested `$ref`s.\n *\n * @param schema - The current node within the JSON schema recursion\n * @param path - The remaining keys in the path to the desired property\n * @param defaultValue - The value to return if a value is not found for the `pathList` path\n * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found\n */\n getFromSchema(schema: S, path: string | string[], defaultValue: T): T;\n getFromSchema(schema: S, path: string | string[], defaultValue: S): S;\n getFromSchema(schema: S, path: string | string[], defaultValue: T | S): T | S {\n return getFromSchema<T, S, F>(\n this.validator,\n this.rootSchema,\n schema,\n path,\n // @ts-expect-error TS2769: No overload matches this call\n defaultValue,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Checks to see if the `schema` and `uiSchema` combination represents an array of files\n *\n * @param schema - The schema for which check for array of files flag is desired\n * @param [uiSchema] - The UI schema from which to check the widget\n * @returns - True if schema/uiSchema contains an array of files, otherwise false\n */\n isFilesArray(schema: S, uiSchema?: UiSchema<T, S, F>) {\n return isFilesArray<T, S, F>(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Checks to see if the `schema` combination represents a multi-select\n *\n * @param schema - The schema for which check for a multi-select flag is desired\n * @returns - True if schema contains a multi-select, otherwise false\n */\n isMultiSelect(schema: S) {\n return isMultiSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Checks to see if the `schema` combination represents a select\n *\n * @param schema - The schema for which check for a select flag is desired\n * @returns - True if schema contains a select, otherwise false\n */\n isSelect(schema: S) {\n return isSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and\n * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially\n * recursive resolution.\n *\n * @param schema - The schema for which retrieving a schema is desired\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @returns - The schema having its conditions, additional properties, references and dependencies resolved\n */\n retrieveSchema(schema: S, rawFormData?: T) {\n return retrieveSchema<T, S, F>(\n this.validator,\n schema,\n this.rootSchema,\n rawFormData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the\n * new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the\n * nature of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the\n * old schemas that are non-existent in the new schema are set to `undefined`.\n *\n * @param [newSchema] - The new schema for which the data is being sanitized\n * @param [oldSchema] - The old schema from which the data originated\n * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined\n * @returns - The new form data, with all the fields uniquely associated with the old schema set\n * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.\n */\n sanitizeDataForNewSchema(newSchema?: S, oldSchema?: S, data?: any): T {\n return sanitizeDataForNewSchema(\n this.validator,\n this.rootSchema,\n newSchema,\n oldSchema,\n data,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Generates an `IdSchema` object for the `schema`, recursively\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [id] - The base id for the schema\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [idPrefix='root'] - The prefix to use for the id\n * @param [idSeparator='_'] - The separator to use for the path segments in the id\n * @returns - The `IdSchema` object for the `schema`\n */\n toIdSchema(schema: S, id?: string | null, formData?: T, idPrefix = 'root', idSeparator = '_'): IdSchema<T> {\n return toIdSchema<T, S, F>(\n this.validator,\n schema,\n id,\n this.rootSchema,\n formData,\n idPrefix,\n idSeparator,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Generates an `PathSchema` object for the `schema`, recursively\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [name] - The base name for the schema\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @returns - The `PathSchema` object for the `schema`\n */\n toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T> {\n return toPathSchema<T, S, F>(\n this.validator,\n schema,\n name,\n this.rootSchema,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n}\n\n/** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The\n * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - An implementation of a `SchemaUtilsType` interface\n */\nexport default function createSchemaUtils<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): SchemaUtilsType<T, S, F> {\n return new SchemaUtils<T, S, F>(\n validator,\n rootSchema,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n );\n}\n", "/** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name\n * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.\n *\n * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob\n * @returns - an object containing a Blob and its name, extracted from the URI\n */\nexport default function dataURItoBlob(dataURILike: string) {\n // check if is dataURI\n if (dataURILike.indexOf('data:') === -1) {\n throw new Error('File is invalid: URI must be a dataURI');\n }\n const dataURI = dataURILike.slice(5);\n // split the dataURI into media and base64, with the base64 signature\n const splitted = dataURI.split(';base64,');\n // if the base64 signature is not present, the latter part will become empty\n if (splitted.length !== 2) {\n throw new Error('File is invalid: dataURI must be base64');\n }\n // extract the mime type, media parameters including the name, and the base64 string\n const [media, base64] = splitted;\n const [mime, ...mediaparams] = media.split(';');\n const type = mime || '';\n\n // extract the name from the parameters\n const name = decodeURI(\n // parse the parameters into key-value pairs, find a key, and extract a value\n // if no key is found, then the name is unknown\n mediaparams.map((param) => param.split('=')).find(([key]) => key === 'name')?.[1] || 'unknown',\n );\n\n // Built the Uint8Array Blob parameter from the base64 string.\n try {\n const binary = atob(base64);\n const array = new Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n array[i] = binary.charCodeAt(i);\n }\n // Create the blob object\n const blob = new window.Blob([new Uint8Array(array)], { type });\n\n return { blob, name };\n } catch (error) {\n throw new Error('File is invalid: ' + (error as Error).message);\n }\n}\n", "/** Returns a string representation of the `num` that is padded with leading \"0\"s if necessary\n *\n * @param num - The number to pad\n * @param width - The width of the string at which no lead padding is necessary\n * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`\n */\nexport default function pad(num: number, width: number) {\n let s = String(num);\n while (s.length < width) {\n s = '0' + s;\n }\n return s;\n}\n", "import pad from './pad';\nimport { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns a list of options for a date range between `start` and `stop`. If the start date is greater than the end\n * date, then the date range is reversed. If `start` and `stop` are negative numbers (or zero), then they will be\n * treated as relative to the current year.\n *\n * @param start - The starting point of the date range\n * @param stop - The ending point of the date range\n * @returns - The list of EnumOptionsType for the date range between `start` and `stop`\n * @throws - Error when `start` and `stop` aren't both <= 0 or > 0\n */\nexport default function dateRangeOptions<S extends StrictRJSFSchema = RJSFSchema>(\n start: number,\n stop: number,\n): EnumOptionsType<S>[] {\n if (start <= 0 && stop <= 0) {\n start = new Date().getFullYear() + start;\n stop = new Date().getFullYear() + stop;\n } else if (start < 0 || stop < 0) {\n throw new Error(`Both start (${start}) and stop (${stop}) must both be <= 0 or > 0, got one of each`);\n }\n if (start > stop) {\n return dateRangeOptions<S>(stop, start).reverse();\n }\n const options: EnumOptionsType<S>[] = [];\n for (let i = start; i <= stop; i++) {\n options.push({ value: i, label: pad(i, 2) });\n }\n return options;\n}\n", "/** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When\n * a `params` array is provided, each value in the array is used to replace any of the replaceable parameters in the\n * `inputString` using the `%1`, `%2`, etc. replacement specifiers.\n *\n * @param inputString - The string which will be potentially updated with replacement parameters\n * @param params - The optional list of replaceable parameter values to substitute into the english string\n * @returns - The updated string with any replacement specifiers replaced\n */\nexport default function replaceStringParameters(inputString: string, params?: string[]) {\n let output = inputString;\n if (Array.isArray(params)) {\n const parts = output.split(/(%\\d)/);\n params.forEach((param, index) => {\n const partIndex = parts.findIndex((part) => part === `%${index + 1}`);\n if (partIndex >= 0) {\n parts[partIndex] = param;\n }\n });\n output = parts.join('');\n }\n return output;\n}\n", "import { TranslatableString } from './enums';\nimport replaceStringParameters from './replaceStringParameters';\n\n/** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each\n * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,\n * `%2`, etc. replacement specifiers.\n *\n * @param stringToTranslate - The `TranslatableString` value to convert to english\n * @param params - The optional list of replaceable parameter values to substitute into the english string\n * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted\n */\nexport default function englishStringTranslator(stringToTranslate: TranslatableString, params?: string[]): string {\n return replaceStringParameters(stringToTranslate, params);\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an\n * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it\n * contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only\n * valid values or in the worst case, an empty array.\n *\n * @param valueIndex - The index(es) of the value(s) that should be returned\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @param [emptyValue] - The value to return when the non-array `valueIndex` does not refer to a real option\n * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,\n * `emptyValue` or an empty list.\n */\nexport default function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number | Array<string | number>,\n allEnumOptions: EnumOptionsType<S>[] = [],\n emptyValue?: EnumOptionsType<S>['value'],\n): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined {\n if (Array.isArray(valueIndex)) {\n return (\n valueIndex\n .map((index) => enumOptionsValueForIndex(index, allEnumOptions))\n // Since the recursive call returns `emptyValue` when we get a bad option, only filter those out\n .filter((val) => val !== emptyValue)\n );\n }\n // So Number(null) and Number('') both return 0, so use emptyValue for those two values\n const index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);\n const option = allEnumOptions[index];\n return option ? option.value : emptyValue;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport deepEquals from './deepEquals';\n\n/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is\n * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is\n * a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined\n * is returned, otherwise the `selected` value is returned.\n *\n * @param valueIndex - The index of the value to be removed from the selected list or single value\n * @param selected - The current (list of) selected value(s)\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @returns - The updated `selected` with the enum option value at `valueIndex` in `allEnumOptions` removed from it,\n * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns\n * undefined, otherwise `selected`.\n */\nexport default function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number,\n selected?: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined {\n const value = enumOptionsValueForIndex<S>(valueIndex, allEnumOptions);\n if (Array.isArray(selected)) {\n return selected.filter((v) => !deepEquals(v, value));\n }\n return deepEquals(value, selected) ? undefined : selected;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport deepEquals from './deepEquals';\n\n/** Determines whether the given `value` is (one of) the `selected` value(s).\n *\n * @param value - The value being checked to see if it is selected\n * @param selected - The current selected value or list of values\n * @returns - true if the `value` is one of the `selected` ones, false otherwise\n */\nexport default function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(\n value: EnumOptionsType<S>['value'],\n selected: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n) {\n if (Array.isArray(selected)) {\n return selected.some((sel) => deepEquals(sel, value));\n }\n return deepEquals(selected, value);\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsIsSelected from './enumOptionsIsSelected';\n\n/** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the\n * `enumOptions` are filtered based on whether they are a \"selected\" `value` and the index of each selected one is then\n * stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is\n * returned.\n *\n * @param value - The single value or list of values for which indexes are desired\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @param [multiple=false] - Optional flag, if true will return a list of index, otherwise a single one\n * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list\n * of indexes for (each of) the value(s) in `value`.\n */\nexport default function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(\n value: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n multiple = false,\n): string | string[] | undefined {\n const selectedIndexes: string[] = allEnumOptions\n .map((opt, index) => (enumOptionsIsSelected(opt.value, value) ? String(index) : undefined))\n .filter((opt) => typeof opt !== 'undefined') as string[];\n if (!multiple) {\n return selectedIndexes[0];\n }\n return selectedIndexes;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport isNil from 'lodash/isNil';\n\n/** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by\n * `allEnumOptions`\n *\n * @param valueIndex - The index of the value that should be selected\n * @param selected - The current list of selected values\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it\n */\nexport default function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number,\n selected: EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n) {\n const value = enumOptionsValueForIndex<S>(valueIndex, allEnumOptions);\n if (!isNil(value)) {\n const index = allEnumOptions.findIndex((opt) => value === opt.value);\n const all = allEnumOptions.map(({ value: val }) => val);\n const updated = selected.slice(0, index).concat(value, selected.slice(index));\n // As inserting values at predefined index positions doesn't work with empty\n // arrays, we need to reorder the updated selection to match the initial order\n return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));\n }\n return selected;\n}\n", "import cloneDeep from 'lodash/cloneDeep';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport setWith from 'lodash/setWith';\n\nimport { ErrorSchema } from './types';\nimport { ERRORS_KEY } from './constants';\n\n/** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where\n * numbers represent array indexes/\n */\nexport type PathType = string | (string | number)[];\n\n/** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is\n * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error\n * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can\n * get the result and/or reset all the errors back to an initial set and start again.\n */\nexport default class ErrorSchemaBuilder<T = any> {\n /** The error schema being built\n *\n * @private\n */\n private errorSchema: ErrorSchema<T> = {};\n\n /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.\n *\n * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class\n */\n constructor(initialSchema?: ErrorSchema<T>) {\n this.resetAllErrors(initialSchema);\n }\n\n /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`\n */\n get ErrorSchema() {\n return this.errorSchema;\n }\n\n /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.\n *\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)\n * @returns - The error block for the given `pathOfError` or the root if not provided\n * @private\n */\n private getOrCreateErrorBlock(pathOfError?: PathType) {\n const hasPath = (Array.isArray(pathOfError) && pathOfError.length > 0) || typeof pathOfError === 'string';\n // @ts-expect-error TS2590 to avoid \"Expression produces a union type that is too complex to represent\" error\n let errorBlock: ErrorSchema = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;\n if (!errorBlock && pathOfError) {\n errorBlock = {};\n setWith(this.errorSchema, pathOfError, errorBlock, Object);\n }\n return errorBlock;\n }\n\n /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.\n *\n * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n resetAllErrors(initialSchema?: ErrorSchema<T>) {\n this.errorSchema = initialSchema ? cloneDeep(initialSchema) : {};\n return this;\n }\n\n /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within\n * the schema described by the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param errorOrList - The error or list of errors to add into the `ErrorSchema`\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n addErrors(errorOrList: string | string[], pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n let errorsList = get(errorBlock, ERRORS_KEY);\n if (!Array.isArray(errorsList)) {\n errorsList = [];\n errorBlock[ERRORS_KEY] = errorsList;\n }\n\n if (Array.isArray(errorOrList)) {\n set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, ...errorOrList])]);\n } else {\n set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, errorOrList])]);\n }\n return this;\n }\n\n /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location\n * within the schema described by the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param errorOrList - The error or list of errors to set into the `ErrorSchema`\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n setErrors(errorOrList: string | string[], pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n // Effectively clone the array being given to prevent accidental outside manipulation of the given list\n const listToAdd = Array.isArray(errorOrList) ? [...new Set([...errorOrList])] : [errorOrList];\n set(errorBlock, ERRORS_KEY, listToAdd);\n return this;\n }\n\n /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by\n * the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n clearErrors(pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n set(errorBlock, ERRORS_KEY, []);\n return this;\n }\n}\n", "import { type DateObject } from './types';\n\n/** Available options for re-ordering date input element */\nexport type DateElementFormat = 'DMY' | 'MDY' | 'YMD';\n\n/** Type describing format of DateElement prop */\ntype DateElementProp = {\n type: string;\n range: [number, number];\n value: number | undefined;\n};\n\n/** Given date & time information with optional yearRange & format, returns props for DateElement\n *\n * @param date - Object containing date with optional time information\n * @param time - Determines whether to include time or not\n * @param [yearRange=[1900, new Date().getFullYear() + 2]] - Controls the list of years to be displayed\n * @param [format='YMD'] - Controls the order in which day, month and year input element will be displayed\n * @returns Array of props for DateElement\n */\n\nexport default function getDateElementProps(\n date: DateObject,\n time: boolean,\n yearRange: [number, number] = [1900, new Date().getFullYear() + 2],\n format: DateElementFormat = 'YMD',\n) {\n const { day, month, year, hour, minute, second } = date;\n\n const dayObj: DateElementProp = { type: 'day', range: [1, 31], value: day };\n const monthObj: DateElementProp = { type: 'month', range: [1, 12], value: month };\n const yearObj: DateElementProp = { type: 'year', range: yearRange, value: year };\n\n const dateElementProp: DateElementProp[] = [];\n switch (format) {\n case 'MDY':\n dateElementProp.push(monthObj, dayObj, yearObj);\n break;\n case 'DMY':\n dateElementProp.push(dayObj, monthObj, yearObj);\n break;\n case 'YMD':\n default:\n dateElementProp.push(yearObj, monthObj, dayObj);\n }\n\n if (time) {\n dateElementProp.push(\n { type: 'hour', range: [0, 23], value: hour },\n { type: 'minute', range: [0, 59], value: minute },\n { type: 'second', range: [0, 59], value: second },\n );\n }\n\n return dateElementProp;\n}\n", "import { RangeSpecType, StrictRJSFSchema } from './types';\nimport { RJSFSchema } from './types';\n\n/** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML\n * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.\n *\n * @param schema - The schema from which to extract the range spec\n * @returns - A range specification from the schema\n */\nexport default function rangeSpec<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n const spec: RangeSpecType = {};\n if (schema.multipleOf) {\n spec.step = schema.multipleOf;\n }\n if (schema.minimum || schema.minimum === 0) {\n spec.min = schema.minimum;\n }\n if (schema.maximum || schema.maximum === 0) {\n spec.max = schema.maximum;\n }\n return spec;\n}\n", "import rangeSpec from './rangeSpec';\nimport { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';\n\n/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.\n *\n * @param schema - The schema for the field provided by the widget\n * @param [defaultType] - The default type, if any, for the field provided by the widget\n * @param [options={}] - The UI Options for the field provided by the widget\n * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step\n * @returns - The extracted `InputPropsType` object\n */\nexport default function getInputProps<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n schema: RJSFSchema,\n defaultType?: string,\n options: UIOptionsType<T, S, F> = {},\n autoDefaultStepAny = true,\n): InputPropsType {\n const inputProps: InputPropsType = {\n type: defaultType || 'text',\n ...rangeSpec(schema),\n };\n\n // If options.inputType is set use that as the input type\n if (options.inputType) {\n inputProps.type = options.inputType;\n } else if (!defaultType) {\n // If the schema is of type number or integer, set the input type to number\n if (schema.type === 'number') {\n inputProps.type = 'number';\n // Only add step if one isn't already defined and we are auto-defaulting the \"any\" step\n if (autoDefaultStepAny && inputProps.step === undefined) {\n // Setting step to 'any' fixes a bug in Safari where decimals are not\n // allowed in number inputs\n inputProps.step = 'any';\n }\n } else if (schema.type === 'integer') {\n inputProps.type = 'number';\n // Only add step if one isn't already defined\n if (inputProps.step === undefined) {\n // Since this is integer, you always want to step up or down in multiples of 1\n inputProps.step = 1;\n }\n }\n }\n\n if (options.autocomplete) {\n inputProps.autoComplete = options.autocomplete;\n }\n\n if (options.accept) {\n inputProps.accept = options.accept as string;\n }\n\n return inputProps;\n}\n", "import { SUBMIT_BTN_OPTIONS_KEY } from './constants';\nimport getUiOptions from './getUiOptions';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema, UISchemaSubmitButtonOptions } from './types';\n\n/** The default submit button options, exported for testing purposes\n */\nexport const DEFAULT_OPTIONS: UISchemaSubmitButtonOptions = {\n props: {\n disabled: false,\n },\n submitText: 'Submit',\n norender: false,\n};\n\n/** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`\n *\n * @param [uiSchema={}] - the UI Schema from which to extract submit button props\n * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones\n */\nexport default function getSubmitButtonOptions<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(uiSchema: UiSchema<T, S, F> = {}): UISchemaSubmitButtonOptions {\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {\n const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY] as UISchemaSubmitButtonOptions;\n return { ...DEFAULT_OPTIONS, ...options };\n }\n\n return DEFAULT_OPTIONS;\n}\n", "import { FormContextType, TemplatesType, Registry, UIOptionsType, StrictRJSFSchema, RJSFSchema } from './types';\n\n/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`\n * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.\n *\n * @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`\n * @param registry - The `Registry` from which to read the template\n * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template\n * @returns - The template from either the `uiSchema` or `registry` for the `name`\n */\nexport default function getTemplate<\n Name extends keyof TemplatesType<T, S, F>,\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(name: Name, registry: Registry<T, S, F>, uiOptions: UIOptionsType<T, S, F> = {}): TemplatesType<T, S, F>[Name] {\n const { templates } = registry;\n if (name === 'ButtonTemplates') {\n return templates[name];\n }\n // Allow templates to be customized per-field by using string keys from the registry\n if (\n Object.hasOwn(uiOptions, name) &&\n typeof uiOptions[name] === 'string' &&\n Object.hasOwn(templates, uiOptions[name] as string)\n ) {\n const key = uiOptions[name];\n // Evaluating templates[key] results in TS2590: Expression produces a union type that is too complex to represent\n // To avoid that, we cast templates to `any` before accessing the key field\n return (templates as any)[key];\n }\n return (\n // Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent\n // To avoid that, we cast uiOptions to `any` before accessing the name field\n ((uiOptions as any)[name] as TemplatesType<T, S, F>[Name]) || templates[name]\n );\n}\n", "import { nanoid } from 'nanoid';\nimport get from 'lodash/get';\n\nimport { TestIdShape } from './types';\n\n/** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment\n * (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned\n * object is accessed, if the value already exists the object will return that value, otherwise it will create that key\n * with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the\n * function will return an empty object, therefore returning `undefined` for any property within the object and\n * excluding the prop from the rendered output of the component in which it is used.\n * This implementation was adapted from the following blog post: https://www.matthewsessions.com/blog/react-test-id/\n * To use this helper, you will want to generate a separate object for each component to avoid potential overlapping of\n * ID names. You will also want to export the object for use in tests, because the keys will be generated in the\n * component file, and used in the test file. Within the component file, add:\n * `export const TEST_IDS = getTestIds();`\n * Then pass `TEST_IDS.examplePropertyName` as the value of the test ID attribute of the intended component. This will\n * allow you to use `TEST_IDS.examplePropertyName` within your tests, while keeping the test IDs out of your rendered\n * output.\n */\nexport default function getTestIds(): TestIdShape {\n // For some reason, even though process.env contains the value of `test` for NODE_ENV, accessing it directly returns\n // 'development'. Using `get()` does, in fact, return test so sticking with it\n if (typeof process === 'undefined' || get(process, 'env.NODE_ENV') !== 'test') {\n return {};\n }\n\n const ids = new Map();\n return new Proxy(\n {},\n {\n get(_obj, prop) {\n if (!ids.has(prop)) {\n ids.set(prop, nanoid());\n }\n return ids.get(prop);\n },\n },\n );\n}\n", "import { createElement } from 'react';\nimport ReactIs from 'react-is';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\nimport { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types';\nimport getSchemaType from './getSchemaType';\n\n/** The map of schema types to widget type to widget name\n */\nconst widgetMap: { [k: string]: { [j: string]: string } } = {\n boolean: {\n checkbox: 'CheckboxWidget',\n radio: 'RadioWidget',\n select: 'SelectWidget',\n hidden: 'HiddenWidget',\n },\n string: {\n text: 'TextWidget',\n password: 'PasswordWidget',\n email: 'EmailWidget',\n hostname: 'TextWidget',\n ipv4: 'TextWidget',\n ipv6: 'TextWidget',\n uri: 'URLWidget',\n 'data-url': 'FileWidget',\n radio: 'RadioWidget',\n select: 'SelectWidget',\n textarea: 'TextareaWidget',\n hidden: 'HiddenWidget',\n date: 'DateWidget',\n datetime: 'DateTimeWidget',\n 'date-time': 'DateTimeWidget',\n 'alt-date': 'AltDateWidget',\n 'alt-datetime': 'AltDateTimeWidget',\n time: 'TimeWidget',\n color: 'ColorWidget',\n file: 'FileWidget',\n },\n number: {\n text: 'TextWidget',\n select: 'SelectWidget',\n updown: 'UpDownWidget',\n range: 'RangeWidget',\n radio: 'RadioWidget',\n hidden: 'HiddenWidget',\n },\n integer: {\n text: 'TextWidget',\n select: 'SelectWidget',\n updown: 'UpDownWidget',\n range: 'RangeWidget',\n radio: 'RadioWidget',\n hidden: 'HiddenWidget',\n },\n array: {\n select: 'SelectWidget',\n checkboxes: 'CheckboxesWidget',\n files: 'FileWidget',\n hidden: 'HiddenWidget',\n },\n};\n\n/** Wraps the given widget with stateless functional component that will merge any `defaultProps.options` with the\n * `options` that are provided in the props. It will add the wrapper component as a `MergedWidget` property onto the\n * `Widget` so that future attempts to wrap `AWidget` will return the already existing wrapper.\n *\n * @param AWidget - A widget that will be wrapped or one that is already wrapped\n * @returns - The wrapper widget\n */\nfunction mergeWidgetOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n AWidget: Widget<T, S, F>,\n) {\n let MergedWidget: Widget<T, S, F> | undefined = get(AWidget, 'MergedWidget');\n // cache return value as property of widget for proper react reconciliation\n if (!MergedWidget) {\n const defaultOptions = (AWidget.defaultProps && AWidget.defaultProps.options) || {};\n MergedWidget = ({ options, ...props }) => {\n return <AWidget options={{ ...defaultOptions, ...options }} {...props} />;\n };\n set(AWidget, 'MergedWidget', MergedWidget);\n }\n return MergedWidget;\n}\n\n/** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the\n * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped\n * with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based\n * on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.\n *\n * @param schema - The schema for the field\n * @param [widget] - Either the name of the widget OR a `Widget` implementation to use\n * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation\n * @returns - The `Widget` component to use\n * @throws - An error if there is no `Widget` component that can be returned\n */\nexport default function getWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n widget?: Widget<T, S, F> | string,\n registeredWidgets: RegistryWidgetsType<T, S, F> = {},\n): Widget<T, S, F> {\n const type = getSchemaType(schema);\n\n if (\n typeof widget === 'function' ||\n (widget && ReactIs.isForwardRef(createElement(widget))) ||\n ReactIs.isMemo(widget)\n ) {\n return mergeWidgetOptions<T, S, F>(widget as Widget<T, S, F>);\n }\n\n if (typeof widget !== 'string') {\n throw new Error(`Unsupported widget definition: ${typeof widget}`);\n }\n\n if (widget in registeredWidgets) {\n const registeredWidget = registeredWidgets[widget];\n return getWidget<T, S, F>(schema, registeredWidget, registeredWidgets);\n }\n\n if (typeof type === 'string') {\n if (!(type in widgetMap)) {\n throw new Error(`No widget for type '${type}'`);\n }\n\n if (widget in widgetMap[type]) {\n const registeredWidget = registeredWidgets[widgetMap[type][widget]];\n return getWidget<T, S, F>(schema, registeredWidget, registeredWidgets);\n }\n }\n\n throw new Error(`No widget '${widget}' for type '${type}'`);\n}\n", "import { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Hashes a string using the algorithm based on Java's hashing function.\n * JS has no built-in hashing function, so rolling our own\n * based on Java's hashing fn:\n * http://www.java2s.com/example/nodejs-utility-method/string-hash/hashcode-4dc2b.html\n *\n * @param string - The string for which to get the hash\n * @returns - The resulting hash of the string in hex format\n */\nexport function hashString(string: string): string {\n let hash = 0;\n for (let i = 0; i < string.length; i += 1) {\n const chr = string.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash.toString(16);\n}\n\n/** Stringifies an `object`, sorts object fields in consistent order before stringifying it.\n *\n * @param object - The object for which the sorted stringify is desired\n * @returns - The stringified object with keys sorted in a consistent order\n */\nexport function sortedJSONStringify(object: unknown): string {\n const allKeys = new Set<string>();\n // solution source: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/53593328#53593328\n JSON.stringify(object, (key, value) => (allKeys.add(key), value));\n return JSON.stringify(object, Array.from(allKeys).sort());\n}\n\n/** Stringifies an `object` and returns the hash of the resulting string. Sorts object fields\n * in consistent order before stringify to prevent different hash ids for the same object.\n *\n * @param object - The object for which the hash is desired\n * @returns - The string obtained from the hash of the stringified object\n */\nexport function hashObject(object: unknown): string {\n return hashString(sortedJSONStringify(object));\n}\n\n/** Stringifies the schema and returns the hash of the resulting string. Sorts schema fields\n * in consistent order before stringify to prevent different hash ids for the same schema.\n *\n * @param schema - The schema for which the hash is desired\n * @returns - The string obtained from the hash of the stringified schema\n */\nexport default function hashForSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return hashObject(schema);\n}\n", "import getWidget from './getWidget';\nimport { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema, Widget } from './types';\n\n/** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it\n * does, or false if it doesn't.\n *\n * @param schema - The schema for the field\n * @param widget - Either the name of the widget OR a `Widget` implementation to use\n * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation\n * @returns - True if the widget exists, false otherwise\n */\nexport default function hasWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n widget: Widget<T, S, F> | string,\n registeredWidgets: RegistryWidgetsType<T, S, F> = {},\n) {\n try {\n getWidget(schema, widget, registeredWidgets);\n return true;\n } catch (e) {\n const err: Error = e as Error;\n if (err.message && (err.message.startsWith('No widget') || err.message.startsWith('Unsupported widget'))) {\n return false;\n }\n throw e;\n }\n}\n", "import isString from 'lodash/isString';\n\nimport { IdSchema } from './types';\nimport { ID_KEY } from './constants';\n\n/** Generates a consistent `id` pattern for a given `id` and a `suffix`\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param suffix - The suffix to append to the id\n */\nfunction idGenerator<T = any>(id: IdSchema<T> | string, suffix: string) {\n const theId = isString(id) ? id : id[ID_KEY];\n return `${theId}__${suffix}`;\n}\n/** Return a consistent `id` for the field description element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field description element from the given `id`\n */\nexport function descriptionId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'description');\n}\n\n/** Return a consistent `id` for the field error element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field error element from the given `id`\n */\nexport function errorId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'error');\n}\n\n/** Return a consistent `id` for the field examples element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field examples element from the given `id`\n */\nexport function examplesId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'examples');\n}\n\n/** Return a consistent `id` for the field help element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field help element from the given `id`\n */\nexport function helpId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'help');\n}\n\n/** Return a consistent `id` for the field title element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field title element from the given `id`\n */\nexport function titleId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'title');\n}\n\n/** Return a list of element ids that contain additional information about the field that can be used to as the aria\n * description of the field. This is correctly omitting `titleId` which would be \"labeling\" rather than \"describing\" the\n * element.\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list\n * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute\n */\nexport function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, includeExamples = false) {\n const examples = includeExamples ? ` ${examplesId<T>(id)}` : '';\n return `${errorId<T>(id)} ${descriptionId<T>(id)} ${helpId<T>(id)}${examples}`;\n}\n\n/** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget\n *\n * @param id - The id of the parent component for the option\n * @param optionIndex - The index of the option for which the id is desired\n * @returns - An id for the option index based on the parent `id`\n */\nexport function optionId(id: string, optionIndex: number) {\n return `${id}-${optionIndex}`;\n}\n\n/** Return a consistent `id` for the `btn` button element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param btn - The button type for which to generate the id\n * @returns - The consistent id for the button from the given `id` and `btn` type\n */\nexport function buttonId<T = any>(id: IdSchema<T> | string, btn: 'add' | 'copy' | 'moveDown' | 'moveUp' | 'remove') {\n return idGenerator<T>(id, btn);\n}\n", "import { ReactElement } from 'react';\n\n/** Helper function that will return the value to use for a widget `label` based on `hideLabel`. The `fallback` is used\n * as the return value from the function when `hideLabel` is true. Due to the implementation of theme components, it\n * may be necessary to return something other than `undefined` to cause the theme component to not render a label. Some\n * themes require may `false` and others may require an empty string.\n *\n * @param [label] - The label string or component to render when not hidden\n * @param [hideLabel] - Flag, if true, will cause the label to be hidden\n * @param [fallback] - One of 3 values, `undefined` (the default), `false` or an empty string\n * @returns - `fallback` if `hideLabel` is true, otherwise `label`\n */\n\nexport default function labelValue(label?: string, hideLabel?: boolean, fallback?: ''): undefined | string;\nexport default function labelValue(label?: string, hideLabel?: boolean, fallback?: false): undefined | false | string;\nexport default function labelValue(label?: ReactElement, hideLabel?: boolean, fallback?: ''): undefined | ReactElement;\nexport default function labelValue(\n label?: ReactElement,\n hideLabel?: boolean,\n fallback?: false,\n): undefined | false | ReactElement;\nexport default function labelValue(\n label?: string | ReactElement,\n hideLabel?: boolean,\n fallback?: false | '',\n): undefined | false | string | ReactElement {\n return hideLabel ? fallback : label;\n}\n", "/** Converts a local Date string into a UTC date string\n *\n * @param dateString - The string representation of a date as accepted by the `Date()` constructor\n * @returns - A UTC date string if `dateString` is truthy, otherwise undefined\n */\nexport default function localToUTC(dateString: string) {\n return dateString ? new Date(dateString).toJSON() : undefined;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport { FORM_CONTEXT_NAME, LOOKUP_MAP_NAME } from './constants';\nimport { FormContextType, RJSFSchema, Registry, StrictRJSFSchema } from './types';\n\n/** Given a React JSON Schema Form registry or formContext object, return the value associated with `toLookup`. This\n * might be contained within the lookup map in the formContext. If no such value exists, return the `fallback`\n * value.\n *\n * @param regOrFc - The @rjsf registry or form context in which the lookup will occur\n * @param toLookup - The name of the field in the lookup map in the form context to get the value for\n * @param [fallback] - The fallback value to use if the form context does not contain a value for `toLookup`\n * @returns - The value associated with `toLookup` in the form context or `fallback`\n */\nexport default function lookupFromFormContext<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(regOrFc: Registry<T, S, F> | Registry<T, S, F>['formContext'], toLookup: string, fallback?: unknown) {\n const lookupPath = [LOOKUP_MAP_NAME];\n if (has(regOrFc, FORM_CONTEXT_NAME)) {\n lookupPath.unshift(FORM_CONTEXT_NAME);\n }\n return get(regOrFc, [...lookupPath, toLookup], fallback);\n}\n", "import { GenericObjectType } from './types';\n\n/** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.\n * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per\n * the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be\n * places in the location of the `*`.\n *\n * @param properties - The list of property keys to be ordered\n * @param order - An array of property keys to be ordered first, with an optional '*' property\n * @returns - A list with the `properties` ordered\n * @throws - Error when the properties cannot be ordered correctly\n */\nexport default function orderProperties(properties: string[], order?: string[]): string[] {\n if (!Array.isArray(order)) {\n return properties;\n }\n\n const arrayToHash = (arr: string[]) =>\n arr.reduce((prev: GenericObjectType, curr) => {\n prev[curr] = true;\n return prev;\n }, {});\n const errorPropList = (arr: string[]) =>\n arr.length > 1 ? `properties '${arr.join(\"', '\")}'` : `property '${arr[0]}'`;\n const propertyHash = arrayToHash(properties);\n const orderFiltered = order.filter((prop) => prop === '*' || propertyHash[prop]);\n const orderHash = arrayToHash(orderFiltered);\n\n const rest = properties.filter((prop: string) => !orderHash[prop]);\n const restIndex = orderFiltered.indexOf('*');\n if (restIndex === -1) {\n if (rest.length) {\n throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);\n }\n return orderFiltered;\n }\n if (restIndex !== orderFiltered.lastIndexOf('*')) {\n throw new Error('uiSchema order list contains more than one wildcard item');\n }\n\n const complete = [...orderFiltered];\n complete.splice(restIndex, 1, ...rest);\n return complete;\n}\n", "import { DateObject } from './types';\n\n/** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true\n *\n * @param dateString - The date string to parse into a DateObject\n * @param [includeTime=true] - Optional flag, if false, will not include the time data into the object\n * @returns - The date string converted to a `DateObject`\n * @throws - Error when the date cannot be parsed from the string\n */\nexport default function parseDateString(dateString?: string, includeTime = true): DateObject {\n if (!dateString) {\n return {\n year: -1,\n month: -1,\n day: -1,\n hour: includeTime ? -1 : 0,\n minute: includeTime ? -1 : 0,\n second: includeTime ? -1 : 0,\n };\n }\n const date = new Date(dateString);\n if (Number.isNaN(date.getTime())) {\n throw new Error('Unable to parse date ' + dateString);\n }\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1, // oh you, javascript.\n day: date.getUTCDate(),\n hour: includeTime ? date.getUTCHours() : 0,\n minute: includeTime ? date.getUTCMinutes() : 0,\n second: includeTime ? date.getUTCSeconds() : 0,\n };\n}\n", "import { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Check to see if a `schema` specifies that a value must be true. This happens when:\n * - `schema.const` is truthy\n * - `schema.enum` == `[true]`\n * - `schema.anyOf` or `schema.oneOf` has a single value which recursively returns true\n * - `schema.allOf` has at least one value which recursively returns true\n *\n * @param schema - The schema to check\n * @returns - True if the schema specifies a value that must be true, false otherwise\n */\nexport default function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {\n // Check if const is a truthy value\n if (schema.const) {\n return true;\n }\n\n // Check if an enum has a single value of true\n if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {\n return true;\n }\n\n // If anyOf has a single value, evaluate the subschema\n if (schema.anyOf && schema.anyOf.length === 1) {\n return schemaRequiresTrueValue(schema.anyOf[0] as S);\n }\n\n // If oneOf has a single value, evaluate the subschema\n if (schema.oneOf && schema.oneOf.length === 1) {\n return schemaRequiresTrueValue(schema.oneOf[0] as S);\n }\n\n // Evaluate each subschema in allOf, to see if one of them requires a true value\n if (schema.allOf) {\n const schemaSome = (subSchema: S['additionalProperties']) => schemaRequiresTrueValue(subSchema as S);\n return schema.allOf.some(schemaSome);\n }\n\n return false;\n}\n", "import React from 'react';\n\nimport deepEquals from './deepEquals';\n\n/** Determines whether the given `component` should be rerendered by comparing its current set of props and state\n * against the next set. If either of those two sets are not the same, then the component should be rerendered.\n *\n * @param component - A React component being checked\n * @param nextProps - The next set of props against which to check\n * @param nextState - The next set of state against which to check\n * @returns - True if the component should be re-rendered, false otherwise\n */\nexport default function shouldRender(component: React.Component, nextProps: any, nextState: any) {\n const { props, state } = component;\n return !deepEquals(props, nextProps) || !deepEquals(state, nextState);\n}\n", "import { DateObject } from './types';\n\n/** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is\n * removed.\n *\n * @param dateObject - The `DateObject` to convert to a date string\n * @param [time=true] - Optional flag used to remove the time portion of the date string if false\n * @returns - The UTC date string\n */\nexport default function toDateString(dateObject: DateObject, time = true) {\n const { year, month, day, hour = 0, minute = 0, second = 0 } = dateObject;\n const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);\n const datetime = new Date(utcTime).toJSON();\n return time ? datetime : datetime.slice(0, 10);\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ERRORS_KEY } from './constants';\nimport { ErrorSchema, GenericObjectType, RJSFValidationError } from './types';\n\n/** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`\n */\nexport default function toErrorList<T = any>(\n errorSchema?: ErrorSchema<T>,\n fieldPath: string[] = [],\n): RJSFValidationError[] {\n if (!errorSchema) {\n return [];\n }\n let errorList: RJSFValidationError[] = [];\n if (ERRORS_KEY in errorSchema) {\n errorList = errorList.concat(\n errorSchema[ERRORS_KEY]!.map((message: string) => {\n const property = `.${fieldPath.join('.')}`;\n return {\n property,\n message,\n stack: `${property} ${message}`,\n };\n }),\n );\n }\n return Object.keys(errorSchema).reduce((acc, key) => {\n if (key !== ERRORS_KEY) {\n const childSchema = (errorSchema as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));\n }\n }\n return acc;\n }, errorList);\n}\n", "import toPath from 'lodash/toPath';\n\nimport { ErrorSchema, RJSFValidationError } from './types';\nimport ErrorSchemaBuilder from './ErrorSchemaBuilder';\n\n/** Transforms a rjsf validation errors list:\n * [\n * {property: '.level1.level2[2].level3', message: 'err a'},\n * {property: '.level1.level2[2].level3', message: 'err b'},\n * {property: '.level1.level2[4].level3', message: 'err b'},\n * ]\n * Into an error tree:\n * {\n * level1: {\n * level2: {\n * 2: {level3: {errors: ['err a', 'err b']}},\n * 4: {level3: {errors: ['err b']}},\n * }\n * }\n * };\n *\n * @param errors - The list of RJSFValidationError objects\n * @returns - The `ErrorSchema` built from the list of `RJSFValidationErrors`\n */\nexport default function toErrorSchema<T = any>(errors: RJSFValidationError[]): ErrorSchema<T> {\n const builder = new ErrorSchemaBuilder<T>();\n if (errors.length) {\n errors.forEach((error) => {\n const { property, message } = error;\n // When the property is the root element, just use an empty array for the path\n const path = property === '.' ? [] : toPath(property);\n // If the property is at the root (.level1) then toPath creates\n // an empty array element at the first index. Remove it.\n if (path.length > 0 && path[0] === '') {\n path.splice(0, 1);\n }\n if (message) {\n builder.addErrors(message, path);\n }\n });\n }\n return builder.ErrorSchema;\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ErrorSchema, FormValidation, GenericObjectType } from './types';\n\n/** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it\n *\n * @param errorHandler - The `FormValidation` error handling structure\n * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function\n */\nexport default function unwrapErrorHandler<T = any>(errorHandler: FormValidation<T>): ErrorSchema<T> {\n return Object.keys(errorHandler).reduce((acc, key) => {\n if (key === 'addError') {\n return acc;\n } else {\n const childSchema = (errorHandler as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n return {\n ...acc,\n [key]: unwrapErrorHandler(childSchema),\n };\n }\n return { ...acc, [key]: childSchema };\n }\n }, {} as ErrorSchema<T>);\n}\n", "import pad from './pad';\n\n/** Converts a UTC date string into a local Date format\n *\n * @param jsonDate - A UTC date string\n * @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format\n */\nexport default function utcToLocal(jsonDate: string) {\n if (!jsonDate) {\n return '';\n }\n\n // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'\n // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)\n // > should be a _valid local date and time string_ (not GMT)\n\n // Note - date constructor passed local ISO-8601 does not correctly\n // change time to UTC in node pre-8\n const date = new Date(jsonDate);\n\n const yyyy = pad(date.getFullYear(), 4);\n const MM = pad(date.getMonth() + 1, 2);\n const dd = pad(date.getDate(), 2);\n const hh = pad(date.getHours(), 2);\n const mm = pad(date.getMinutes(), 2);\n const ss = pad(date.getSeconds(), 2);\n const SSS = pad(date.getMilliseconds(), 3);\n\n return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;\n}\n", "import isEmpty from 'lodash/isEmpty';\n\nimport mergeObjects from './mergeObjects';\nimport toErrorList from './toErrorList';\nimport { ErrorSchema, ValidationData } from './types';\n\n/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the\n * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling\n * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then\n * `validationData` is returned.\n *\n * @param validationData - The current `ValidationData` into which to merge the additional errors\n * @param [additionalErrorSchema] - The optional additional set of errors in an `ErrorSchema`\n * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.\n */\nexport default function validationDataMerge<T = any>(\n validationData: ValidationData<T>,\n additionalErrorSchema?: ErrorSchema<T>,\n): ValidationData<T> {\n if (!additionalErrorSchema) {\n return validationData;\n }\n const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;\n let errors = toErrorList(additionalErrorSchema);\n let errorSchema = additionalErrorSchema;\n if (!isEmpty(oldErrorSchema)) {\n errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true) as ErrorSchema<T>;\n errors = [...oldErrors].concat(errors);\n }\n return { errorSchema, errors };\n}\n", "import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport isObject from 'lodash/isObject';\n\n/** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n */\nfunction withIdRefPrefixObject<S extends StrictRJSFSchema = RJSFSchema>(node: S): S {\n for (const key in node) {\n const realObj: { [k: string]: any } = node;\n const value = realObj[key];\n if (key === REF_KEY && typeof value === 'string' && value.startsWith('#')) {\n realObj[key] = ROOT_SCHEMA_PREFIX + value;\n } else {\n realObj[key] = withIdRefPrefix<S>(value);\n }\n }\n return node;\n}\n\n/** Takes a `node` object list and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n */\nfunction withIdRefPrefixArray<S extends StrictRJSFSchema = RJSFSchema>(node: S[]): S[] {\n for (let i = 0; i < node.length; i++) {\n node[i] = withIdRefPrefix<S>(node[i]) as S;\n }\n return node;\n}\n\n/** Recursively prefixes all `$ref`s in a schema with the value of the `ROOT_SCHEMA_PREFIX` constant.\n * This is used in isValid to make references to the rootSchema\n *\n * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @returns - A copy of the `schemaNode` with updated `$ref`s\n */\nexport default function withIdRefPrefix<S extends StrictRJSFSchema = RJSFSchema>(\n schemaNode: S | S[] | S[keyof S],\n): S | S[] | S[keyof S] {\n if (Array.isArray(schemaNode)) {\n return withIdRefPrefixArray<S>([...schemaNode]);\n }\n if (isObject(schemaNode)) {\n return withIdRefPrefixObject<S>({ ...schemaNode });\n }\n return schemaNode;\n}\n", "import keys from 'lodash/keys';\nimport pickBy from 'lodash/pickBy';\nimport isPlainObject from 'lodash/isPlainObject';\nimport get from 'lodash/get';\nimport difference from 'lodash/difference';\nimport deepEquals from './deepEquals';\n\n/**\n * Compares two objects and returns the names of the fields that have changed.\n * This function iterates over each field of object `a`, using `_.isEqual` to compare the field value\n * with the corresponding field value in object `b`. If the values are different, the field name will\n * be included in the returned array.\n *\n * @param a - The first object, representing the original data to compare.\n * @param b - The second object, representing the updated data to compare.\n * @returns - An array of field names that have changed.\n *\n * @example\n * const a = { name: 'John', age: 30 };\n * const b = { name: 'John', age: 31 };\n * const changedFields = getChangedFields(a, b);\n * console.log(changedFields); // Output: ['age']\n */\nexport default function getChangedFields(a: unknown, b: unknown): string[] {\n const aIsPlainObject = isPlainObject(a);\n const bIsPlainObject = isPlainObject(b);\n // If strictly equal or neither of them is a plainObject returns an empty array\n if (a === b || (!aIsPlainObject && !bIsPlainObject)) {\n return [];\n }\n if (aIsPlainObject && !bIsPlainObject) {\n return keys(a);\n } else if (!aIsPlainObject && bIsPlainObject) {\n return keys(b);\n } else {\n const unequalFields = keys(pickBy(a as object, (value, key) => !deepEquals(value, get(b, key))));\n const diffFields = difference(keys(b), keys(a));\n return [...unequalFields, ...diffFields];\n }\n}\n", "/** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the\n * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values\n * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of\n * parameters is important because some languages may choose to put the second parameter before the first in its\n * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.\n */\nexport enum TranslatableString {\n /** Fallback title of an array item, used by ArrayField */\n ArrayItemTitle = 'Item',\n /** Missing items reason, used by ArrayField */\n MissingItems = 'Missing items definition',\n /** Empty array message, used by ArrayField */\n EmptyArray = 'No items yet. Use the button below to add some.',\n /** Yes label, used by BooleanField */\n YesLabel = 'Yes',\n /** No label, used by BooleanField */\n NoLabel = 'No',\n /** Close label, used by ErrorList */\n CloseLabel = 'Close',\n /** Errors label, used by ErrorList */\n ErrorsLabel = 'Errors',\n /** New additionalProperties string default value, used by ObjectField */\n NewStringDefault = 'New Value',\n /** Add button title, used by AddButton */\n AddButton = 'Add',\n /** Add button title, used by AddButton */\n AddItemButton = 'Add Item',\n /** Copy button title, used by IconButton */\n CopyButton = 'Copy',\n /** Move down button title, used by IconButton */\n MoveDownButton = 'Move down',\n /** Move up button title, used by IconButton */\n MoveUpButton = 'Move up',\n /** Remove button title, used by IconButton */\n RemoveButton = 'Remove',\n /** Now label, used by AltDateWidget */\n NowLabel = 'Now',\n /** Clear label, used by AltDateWidget */\n ClearLabel = 'Clear',\n /** Aria date label, used by DateWidget */\n AriaDateLabel = 'Select a date',\n /** File preview label, used by FileWidget */\n PreviewLabel = 'Preview',\n /** Decrement button aria label, used by UpDownWidget */\n DecrementAriaLabel = 'Decrease value by 1',\n /** Increment button aria label, used by UpDownWidget */\n IncrementAriaLabel = 'Increase value by 1',\n // Strings with replaceable parameters\n /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */\n UnknownFieldType = 'Unknown field type %1',\n /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */\n OptionPrefix = 'Option %1',\n /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by\n * MultiSchemaField\n */\n TitleOptionPrefix = '%1 option %2',\n /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */\n KeyLabel = '%1 Key',\n // Strings with replaceable parameters AND/OR that support markdown and html\n /** Invalid object field configuration as provided by the ObjectField.\n * NOTE: Use markdown notation rather than html tags.\n */\n InvalidObjectField = 'Invalid \"%1\" object field configuration: _%2_.',\n /** Unsupported field schema, used by UnsupportedField */\n UnsupportedField = 'Unsupported field schema.',\n /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithId = 'Unsupported field schema for field `%1`.',\n /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithReason = 'Unsupported field schema: _%1_.',\n /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,\n * as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithIdAndReason = 'Unsupported field schema for field `%1`: _%2_.',\n /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as\n * provided by FileWidget\n */\n FilesInfo = '**%1** (%2, %3 bytes)',\n}\n", "import forEach from 'lodash/forEach';\n\nimport { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types';\nimport { ITEMS_KEY, PROPERTIES_KEY } from '../constants';\nimport ParserValidator, { SchemaMap } from './ParserValidator';\nimport { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema';\nimport deepEquals from '../deepEquals';\n\n/** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to\n * capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the\n * `retrieveSchemaInternal()`, the `resolveAnyOrOneOfSchemas()` function is called. For each of the schemas returned\n * from THAT call have `properties`, then each of the sub-schema property objects are then recursively parsed.\n *\n * @param validator - The `ParserValidator` implementation used to capture `isValid()` calls during parsing\n * @param recurseList - The list of schemas returned from the `retrieveSchemaInternal`, preventing infinite recursion\n * @param rootSchema - The root schema from which the schema parsing began\n * @param schema - The current schema element being parsed\n */\nfunction parseSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ParserValidator<T, S, F>,\n recurseList: S[],\n rootSchema: S,\n schema: S,\n) {\n const schemas = retrieveSchemaInternal<T, S, F>(validator, schema, rootSchema, undefined, true);\n schemas.forEach((schema) => {\n const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema));\n if (sameSchemaIndex === -1) {\n recurseList.push(schema);\n const allOptions = resolveAnyOrOneOfSchemas<T, S, F>(validator, schema, rootSchema, true);\n allOptions.forEach((s) => {\n if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {\n forEach(schema[PROPERTIES_KEY], (value) => {\n parseSchema<T, S, F>(validator, recurseList, rootSchema, value as S);\n });\n }\n });\n if (ITEMS_KEY in schema && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {\n parseSchema<T, S, F>(validator, recurseList, rootSchema, schema.items as S);\n }\n }\n });\n}\n\n/** Parses the given `rootSchema` to extract out all the sub-schemas that maybe contained within it. Returns a map of\n * the hash of the schema to schema/sub-schema.\n *\n * @param rootSchema - The root schema to parse for sub-schemas used by `isValid()` calls\n * @returns - The `SchemaMap` of all schemas that were parsed\n */\nexport default function schemaParser<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n rootSchema: S,\n): SchemaMap<S> {\n const validator = new ParserValidator<T, S, F>(rootSchema);\n const recurseList: S[] = [];\n\n parseSchema(validator, recurseList, rootSchema, rootSchema);\n\n return validator.getSchemaMap();\n}\n", "import get from 'lodash/get';\n\nimport { ID_KEY } from '../constants';\nimport hashForSchema from '../hashForSchema';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '../types';\nimport deepEquals from '../deepEquals';\n\n/** The type of the map of schema hash to schema\n */\nexport type SchemaMap<S extends StrictRJSFSchema = RJSFSchema> = {\n [hash: string]: S;\n};\n\n/** An implementation of the `ValidatorType` interface that is designed for use in capturing schemas used by the\n * `isValid()` function. The rest of the implementation of the interface throws errors when it is attempted to be used.\n * An instance of the object allows the caller to capture the schemas used in calls to the `isValid()` function. These\n * captured schema, along with the root schema used to construct the object are stored in the map of schemas keyed by\n * the hashed value of the schema. NOTE: After hashing the schema, an $id with the hash value is added to the\n * schema IF that schema doesn't already have an $id, prior to putting the schema into the map.\n */\nexport default class ParserValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The rootSchema provided during construction of the class */\n readonly rootSchema: S;\n\n /** The map of schemas encountered by the ParserValidator */\n schemaMap: SchemaMap<S> = {};\n\n /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`\n * first.\n *\n * @param rootSchema - The root schema against which this validator will be executed\n */\n constructor(rootSchema: S) {\n this.rootSchema = rootSchema;\n this.addSchema(rootSchema, hashForSchema<S>(rootSchema));\n }\n\n /** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.\n */\n reset() {\n this.schemaMap = {};\n }\n\n /** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the\n * schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be\n * associated with it's `hash` for future use (by a schema compiler).\n *\n * @param schema - The schema which is to be added to the map\n * @param hash - The hash value at which to map the schema\n */\n addSchema(schema: S, hash: string) {\n const key = get(schema, ID_KEY, hash);\n const identifiedSchema = { ...schema, [ID_KEY]: key };\n const existing = this.schemaMap[key];\n if (!existing) {\n this.schemaMap[key] = identifiedSchema;\n } else if (!deepEquals(existing, identifiedSchema)) {\n console.error('existing schema:', JSON.stringify(existing, null, 2));\n console.error('new schema:', JSON.stringify(identifiedSchema, null, 2));\n throw new Error(\n `Two different schemas exist with the same key ${key}! What a bad coincidence. If possible, try adding an $id to one of the schemas`,\n );\n }\n }\n\n /** Returns the current `schemaMap` to the caller\n */\n getSchemaMap() {\n return this.schemaMap;\n }\n\n /** Implements the `ValidatorType` `isValid()` method to capture the `schema` in the `schemaMap`. Throws an error when\n * the `rootSchema` is not the same as the root schema provided during construction.\n *\n * @param schema - The schema to record in the `schemaMap`\n * @param _formData - The formData parameter that is ignored\n * @param rootSchema - The root schema associated with the schema\n * @throws - Error when the given `rootSchema` differs from the root schema provided during construction\n */\n isValid(schema: S, _formData: T, rootSchema: S): boolean {\n if (!deepEquals(rootSchema, this.rootSchema)) {\n throw new Error('Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema');\n }\n this.addSchema(schema, hashForSchema<S>(schema));\n\n return false;\n }\n\n /** Implements the `ValidatorType` `rawValidation()` method to throw an error since it is never supposed to be called\n *\n * @param _schema - The schema parameter that is ignored\n * @param _formData - The formData parameter that is ignored\n */\n rawValidation<Result = any>(_schema: S, _formData?: T): { errors?: Result[]; validationError?: Error } {\n throw new Error('Unexpectedly calling the `rawValidation()` method during schema parsing');\n }\n\n /** Implements the `ValidatorType` `toErrorList()` method to throw an error since it is never supposed to be called\n *\n * @param _errorSchema - The error schema parameter that is ignored\n * @param _fieldPath - The field path parameter that is ignored\n */\n toErrorList(_errorSchema?: ErrorSchema<T>, _fieldPath?: string[]): RJSFValidationError[] {\n throw new Error('Unexpectedly calling the `toErrorList()` method during schema parsing');\n }\n\n /** Implements the `ValidatorType` `validateFormData()` method to throw an error since it is never supposed to be\n * called\n *\n * @param _formData - The formData parameter that is ignored\n * @param _schema - The schema parameter that is ignored\n * @param _customValidate - The customValidate parameter that is ignored\n * @param _transformErrors - The transformErrors parameter that is ignored\n * @param _uiSchema - The uiSchema parameter that is ignored\n */\n validateFormData(\n _formData: T,\n _schema: S,\n _customValidate?: CustomValidator<T, S, F>,\n _transformErrors?: ErrorTransformer<T, S, F>,\n _uiSchema?: UiSchema<T, S, F>,\n ): ValidationData<T> {\n throw new Error('Unexpectedly calling the `validateFormData()` method during schema parsing');\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAY,KAAU;AAAA,UACrE,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AACD,UAAI,aAAaA,WAAU,CAAC,MAAM,QAAQA,QAAO,KAAK,KAAK,OAAOA,QAAO,UAAU,WAAW;AAC5F,oBAAqB,WAAW,aAAa,YAAYA,QAAO,KAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAQe,SAAR,aACL,YACc;AACd,QAAM,YAAY,IAAI,gBAAyB,UAAU;AACzD,QAAM,cAAmB,CAAC;AAE1B,cAAY,WAAW,aAAa,YAAY,UAAU;AAE1D,SAAO,UAAU,aAAa;AAChC;",
6
- "names": ["isPlainObject", "isEqualWith", "import_get", "import_has", "import_get", "import_get", "import_isObject", "UriResolver", "isObject", "omit", "jsonpointer", "isEmpty", "get", "isString", "type", "acc", "union", "import_get", "import_get", "get", "isNumber", "has", "get", "import_isEmpty", "times", "set", "transform", "merge", "uniq", "flattenDeep", "isEmpty", "get", "s", "mergeAllOf", "schema", "get", "xxx", "isEqual", "import_get", "import_has", "import_isEmpty", "has", "isEmpty", "get", "has", "get", "import_get", "import_isEmpty", "import_get", "import_has", "import_isNumber", "import_isObject", "import_isString", "import_times", "isObject", "reduce", "get", "has", "key", "isString", "isNumber", "times", "import_get", "acc", "get", "isNil", "altSchemas", "import_isString", "isString", "import_get", "get", "isEmpty", "get", "keys", "import_get", "import_has", "has", "get", "keys", "import_get", "get", "import_get", "import_set", "set", "get", "index", "import_isNil", "isNil", "import_get", "import_set", "get", "setWith", "cloneDeep", "set", "import_get", "get", "import_get", "import_set", "get", "set", "ReactIs", "import_isString", "isString", "import_get", "import_has", "has", "get", "import_isPlainObject", "isPlainObject", "toPath", "import_isPlainObject", "isPlainObject", "import_isEmpty", "isEmpty", "import_isObject", "isObject", "import_isPlainObject", "import_get", "isPlainObject", "keys", "pickBy", "get", "difference", "TranslatableString", "import_get", "get", "schema", "forEach"]
4
+ "sourcesContent": ["import allowAdditionalItems from './allowAdditionalItems';\nimport asNumber from './asNumber';\nimport canExpand from './canExpand';\nimport createErrorHandler from './createErrorHandler';\nimport createSchemaUtils from './createSchemaUtils';\nimport dataURItoBlob from './dataURItoBlob';\nimport dateRangeOptions from './dateRangeOptions';\nimport deepEquals from './deepEquals';\nimport englishStringTranslator from './englishStringTranslator';\nimport enumOptionsDeselectValue from './enumOptionsDeselectValue';\nimport enumOptionsIndexForValue from './enumOptionsIndexForValue';\nimport enumOptionsIsSelected from './enumOptionsIsSelected';\nimport enumOptionsSelectValue from './enumOptionsSelectValue';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport ErrorSchemaBuilder from './ErrorSchemaBuilder';\nimport findSchemaDefinition from './findSchemaDefinition';\nimport getDateElementProps, { type DateElementFormat } from './getDateElementProps';\nimport getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';\nimport getInputProps from './getInputProps';\nimport getSchemaType from './getSchemaType';\nimport getSubmitButtonOptions from './getSubmitButtonOptions';\nimport getTemplate from './getTemplate';\nimport getTestIds from './getTestIds';\nimport getUiOptions from './getUiOptions';\nimport getWidget from './getWidget';\nimport guessType from './guessType';\nimport hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema';\nimport hasWidget from './hasWidget';\nimport {\n ariaDescribedByIds,\n buttonId,\n descriptionId,\n errorId,\n examplesId,\n helpId,\n optionId,\n titleId,\n} from './idGenerators';\nimport isConstant from './isConstant';\nimport isCustomWidget from './isCustomWidget';\nimport isFixedItems from './isFixedItems';\nimport isObject from './isObject';\nimport labelValue from './labelValue';\nimport localToUTC from './localToUTC';\nimport lookupFromFormContext from './lookupFromFormContext';\nimport mergeDefaultsWithFormData from './mergeDefaultsWithFormData';\nimport mergeObjects from './mergeObjects';\nimport mergeSchemas from './mergeSchemas';\nimport optionsList from './optionsList';\nimport orderProperties from './orderProperties';\nimport pad from './pad';\nimport parseDateString from './parseDateString';\nimport rangeSpec from './rangeSpec';\nimport replaceStringParameters from './replaceStringParameters';\nimport schemaRequiresTrueValue from './schemaRequiresTrueValue';\nimport shouldRender from './shouldRender';\nimport toConstant from './toConstant';\nimport toDateString from './toDateString';\nimport toErrorList from './toErrorList';\nimport toErrorSchema from './toErrorSchema';\nimport unwrapErrorHandler from './unwrapErrorHandler';\nimport utcToLocal from './utcToLocal';\nimport validationDataMerge from './validationDataMerge';\nimport withIdRefPrefix from './withIdRefPrefix';\nimport getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';\nimport getChangedFields from './getChangedFields';\n\nexport * from './types';\nexport * from './enums';\n\nexport * from './constants';\nexport * from './parser';\nexport * from './schema';\n\nexport {\n allowAdditionalItems,\n ariaDescribedByIds,\n asNumber,\n buttonId,\n canExpand,\n createErrorHandler,\n createSchemaUtils,\n DateElementFormat,\n dataURItoBlob,\n dateRangeOptions,\n deepEquals,\n descriptionId,\n englishStringTranslator,\n enumOptionsDeselectValue,\n enumOptionsIndexForValue,\n enumOptionsIsSelected,\n enumOptionsSelectValue,\n enumOptionsValueForIndex,\n errorId,\n examplesId,\n ErrorSchemaBuilder,\n findSchemaDefinition,\n getChangedFields,\n getDateElementProps,\n getDiscriminatorFieldFromSchema,\n getInputProps,\n getOptionMatchingSimpleDiscriminator,\n getSchemaType,\n getSubmitButtonOptions,\n getTemplate,\n getTestIds,\n getUiOptions,\n getWidget,\n guessType,\n hasWidget,\n hashForSchema,\n hashObject,\n hashString,\n helpId,\n isConstant,\n isCustomWidget,\n isFixedItems,\n isObject,\n labelValue,\n localToUTC,\n lookupFromFormContext,\n mergeDefaultsWithFormData,\n mergeObjects,\n mergeSchemas,\n optionId,\n optionsList,\n orderProperties,\n pad,\n parseDateString,\n rangeSpec,\n replaceStringParameters,\n schemaRequiresTrueValue,\n shouldRender,\n sortedJSONStringify,\n titleId,\n toConstant,\n toDateString,\n toErrorList,\n toErrorSchema,\n unwrapErrorHandler,\n utcToLocal,\n validationDataMerge,\n withIdRefPrefix,\n};\n", "/** Determines whether a `thing` is an object for the purposes of RJSF. In this case, `thing` is an object if it has\n * the type `object` but is NOT null, an array or a File.\n *\n * @param thing - The thing to check to see whether it is an object\n * @returns - True if it is a non-null, non-array, non-File object\n */\nexport default function isObject(thing: any): thing is object {\n if (typeof thing !== 'object' || thing === null) {\n return false;\n }\n // lastModified is guaranteed to be a number on a File instance\n // as per https://w3c.github.io/FileAPI/#dfn-lastModified\n if (typeof thing.lastModified === 'number' && typeof File !== 'undefined' && thing instanceof File) {\n return false;\n }\n // getMonth is guaranteed to be a method on a Date instance\n // as per https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmonth\n if (typeof thing.getMonth === 'function' && typeof Date !== 'undefined' && thing instanceof Date) {\n return false;\n }\n return !Array.isArray(thing);\n}\n", "import isObject from './isObject';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an\n * object. The user is warned in the console if `schema.additionalItems` has the value `true`.\n *\n * @param schema - The schema object to check\n * @returns - True if additional items is allowed, otherwise false\n */\nexport default function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n if (schema.additionalItems === true) {\n console.warn('additionalItems=true is currently not supported');\n }\n return isObject(schema.additionalItems);\n}\n", "/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a\n * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be\n * in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned\n * because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by\n * `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.\n *\n * @param value - The string or null value to convert to a number\n * @returns - The `value` converted to a number when appropriate, otherwise the `value`\n */\nexport default function asNumber(value: string | null) {\n if (value === '') {\n return undefined;\n }\n if (value === null) {\n return null;\n }\n if (/\\.$/.test(value)) {\n // '3.' can't really be considered a number even if it parses in js. The\n // user is most likely entering a float.\n return value;\n }\n if (/\\.0$/.test(value)) {\n // we need to return this as a string here, to allow for input like 3.07\n return value;\n }\n\n if (/\\.\\d*0$/.test(value)) {\n // It's a number, that's cool - but we need it as a string so it doesn't screw\n // with the user when entering dollar amounts or other values (such as those with\n // specific precision or number of significant digits)\n return value;\n }\n\n const n = Number(value);\n const valid = typeof n === 'number' && !Number.isNaN(n);\n\n return valid ? n : value;\n}\n", "/** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various\n * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and\n * `RJSF_ADDITIONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`\n * utility.\n */\nexport const ADDITIONAL_PROPERTY_FLAG = '__additional_property';\nexport const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';\nexport const ALL_OF_KEY = 'allOf';\nexport const ANY_OF_KEY = 'anyOf';\nexport const CONST_KEY = 'const';\nexport const DEFAULT_KEY = 'default';\nexport const DEFINITIONS_KEY = 'definitions';\nexport const DEPENDENCIES_KEY = 'dependencies';\nexport const ENUM_KEY = 'enum';\nexport const ERRORS_KEY = '__errors';\nexport const ID_KEY = '$id';\nexport const IF_KEY = 'if';\nexport const ITEMS_KEY = 'items';\nexport const JUNK_OPTION_ID = '_$junk_option_schema_id$_';\nexport const NAME_KEY = '$name';\nexport const ONE_OF_KEY = 'oneOf';\nexport const PATTERN_PROPERTIES_KEY = 'patternProperties';\nexport const PROPERTIES_KEY = 'properties';\nexport const READONLY_KEY = 'readonly';\nexport const REQUIRED_KEY = 'required';\nexport const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';\nexport const REF_KEY = '$ref';\nexport const SCHEMA_KEY = '$schema';\n/** The path of the discriminator value returned by the schema endpoint.\n * The discriminator is the value in a `oneOf` that determines which option is selected.\n */\nexport const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];\n/** The name of the `formContext` attribute in the React JSON Schema Form Registry\n */\nexport const FORM_CONTEXT_NAME = 'formContext';\n\n/** The name of the `layoutGridLookupMap` attribute in the form context\n */\nexport const LOOKUP_MAP_NAME = 'layoutGridLookupMap';\nexport const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';\nexport const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';\nexport const UI_FIELD_KEY = 'ui:field';\nexport const UI_WIDGET_KEY = 'ui:widget';\nexport const UI_OPTIONS_KEY = 'ui:options';\nexport const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';\n\n/** The JSON Schema version strings\n */\nexport const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';\n", "import { UI_OPTIONS_KEY, UI_WIDGET_KEY } from './constants';\nimport isObject from './isObject';\nimport { FormContextType, GlobalUISchemaOptions, RJSFSchema, StrictRJSFSchema, UIOptionsType, UiSchema } from './types';\n\n/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`\n * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.\n *\n * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`\n */\nexport default function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n uiSchema: UiSchema<T, S, F> = {},\n globalOptions: GlobalUISchemaOptions = {},\n): UIOptionsType<T, S, F> {\n return Object.keys(uiSchema)\n .filter((key) => key.indexOf('ui:') === 0)\n .reduce(\n (options, key) => {\n const value = uiSchema[key];\n if (key === UI_WIDGET_KEY && isObject(value)) {\n console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');\n return options;\n }\n if (key === UI_OPTIONS_KEY && isObject(value)) {\n return { ...options, ...value };\n }\n return { ...options, [key.substring(3)]: value };\n },\n { ...globalOptions },\n );\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';\nimport getUiOptions from './getUiOptions';\n\n/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for\n * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the\n * `formData` object doesn't already have `schema.maxProperties` elements.\n *\n * @param schema - The schema for the field that is being checked\n * @param [uiSchema={}] - The uiSchema for the field\n * @param [formData] - The formData for the field\n * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit\n */\nexport default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n uiSchema: UiSchema<T, S, F> = {},\n formData?: T,\n) {\n if (!(schema.additionalProperties || schema.patternProperties)) {\n return false;\n }\n const { expandable = true } = getUiOptions<T, S, F>(uiSchema);\n if (expandable === false) {\n return expandable;\n }\n // if ui:options.expandable was not explicitly set to false, we can add\n // another property if we have not exceeded maxProperties yet\n if (schema.maxProperties !== undefined && formData) {\n return Object.keys(formData).length < schema.maxProperties;\n }\n return true;\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ERRORS_KEY } from './constants';\nimport { FieldValidation, FormValidation, GenericObjectType } from './types';\n\n/** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it\n *\n * @param formData - The form data around which the error handler is created\n * @returns - A `FormValidation` object based on the `formData` structure\n */\nexport default function createErrorHandler<T = any>(formData: T): FormValidation<T> {\n const handler: FieldValidation = {\n // We store the list of errors for this node in a property named __errors\n // to avoid name collision with a possible sub schema field named\n // 'errors' (see `utils.toErrorSchema`).\n [ERRORS_KEY]: [],\n addError(message: string) {\n this[ERRORS_KEY]!.push(message);\n },\n };\n if (Array.isArray(formData)) {\n return formData.reduce((acc, value, key) => {\n return { ...acc, [key]: createErrorHandler(value) };\n }, handler);\n }\n if (isPlainObject(formData)) {\n const formObject: GenericObjectType = formData as GenericObjectType;\n return Object.keys(formObject).reduce((acc, key) => {\n return { ...acc, [key]: createErrorHandler(formObject[key]) };\n }, handler as FormValidation<T>);\n }\n return handler as FormValidation<T>;\n}\n", "import isEqualWith from 'lodash/isEqualWith';\n\n/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that\n * assumes all functions are equivalent.\n *\n * @param a - The first element to compare\n * @param b - The second element to compare\n * @returns - True if the `a` and `b` are deeply equal, false otherwise\n */\nexport default function deepEquals(a: any, b: any): boolean {\n return isEqualWith(a, b, (obj: any, other: any) => {\n if (typeof obj === 'function' && typeof other === 'function') {\n // Assume all functions are equivalent\n // see https://github.com/rjsf-team/react-jsonschema-form/issues/255\n return true;\n }\n return undefined; // fallback to default isEquals behavior\n });\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport findSelectedOptionInXxxOf from './findSelectedOptionInXxxOf';\nimport getFromSchema from './getFromSchema';\nimport { ANY_OF_KEY, ONE_OF_KEY, PROPERTIES_KEY, REQUIRED_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n FoundFieldType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\n\n/** Unique schema that represents no schema was found, exported for testing purposes */\nexport const NOT_FOUND_SCHEMA = { title: '!@#$_UNKNOWN_$#@!' };\n\n/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified\n * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf\n * field is in the `required` list for its parent and if so, it is marked as required on return.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The node within the JSON schema in which to search\n * @param path - The keys in the path to the desired field\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - An object that contains the field and its required state. If no field can be found then\n * `{ field: undefined, isRequired: undefined }` is returned.\n */\nexport default function findFieldInSchema<\n T = undefined,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): FoundFieldType<S> {\n const pathList = Array.isArray(path) ? [...path] : path.split('.');\n let parentField = schema;\n\n // store the desired field into a variable and removing it from the `pathList`\n const fieldName = pathList.pop()!;\n\n if (pathList.length) {\n // drilling into the schema for each sub-path and taking into account of the any/oneOfs\n pathList.forEach((subPath) => {\n parentField = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, subPath],\n {} as S,\n experimental_customMergeAllOf,\n );\n if (has(parentField, ONE_OF_KEY)) {\n // if this sub-path has a `oneOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // if this sub-path has a `anyOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n }\n });\n }\n\n if (has(parentField, ONE_OF_KEY)) {\n // When oneOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // When anyOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n }\n\n // taking the most updated `parentField`, get our desired field\n let field: S | undefined = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, fieldName],\n NOT_FOUND_SCHEMA as S,\n experimental_customMergeAllOf,\n );\n if (field === NOT_FOUND_SCHEMA) {\n field = undefined;\n }\n // check to see if our desired field is in the `required` list for its parent\n const requiredArray = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n REQUIRED_KEY,\n [] as T,\n experimental_customMergeAllOf,\n );\n let isRequired: boolean | undefined;\n if (field && Array.isArray(requiredArray)) {\n isRequired = requiredArray.includes(fieldName);\n }\n\n return { field, isRequired };\n}\n", "import get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\n\nimport { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from '../constants';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport retrieveSchema from './retrieveSchema';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\n\n/** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or\n * `properties[selectorField].const` that matches the `formData[selectorField]` value. For the purposes of this\n * function, `selectorField` is either `schema.discriminator.propertyName` or `fallbackField`. The `LayoutGridField`\n * works directly with schemas in a recursive manner, making this faster than `getFirstMatchingOption()`.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The schema element in which to search for the selected anyOf/oneOf option\n * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field\n * @param xxx - Either `anyOf` or `oneOf`, defines which value is being sought\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected\n */\nexport default function findSelectedOptionInXxxOf<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n fallbackField: string,\n xxx: 'anyOf' | 'oneOf',\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S | undefined {\n if (Array.isArray(schema[xxx])) {\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const selectorField = discriminator || fallbackField;\n const xxxOfs = schema[xxx]!.map((xxxOf) =>\n retrieveSchema<T, S, F>(validator, xxxOf as S, rootSchema, formData, experimental_customMergeAllOf),\n );\n const data = get(formData, selectorField);\n if (data !== undefined) {\n return xxxOfs.find((xxx) => {\n return isEqual(\n get(xxx, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get(xxx, [PROPERTIES_KEY, selectorField, CONST_KEY])),\n data,\n );\n });\n }\n }\n return undefined;\n}\n", "import get from 'lodash/get';\nimport set from 'lodash/set';\nimport times from 'lodash/times';\nimport transform from 'lodash/transform';\nimport merge from 'lodash/merge';\nimport flattenDeep from 'lodash/flattenDeep';\nimport uniq from 'lodash/uniq';\nimport mergeAllOf, { Options } from 'json-schema-merge-allof';\n\nimport {\n ADDITIONAL_PROPERTIES_KEY,\n ADDITIONAL_PROPERTY_FLAG,\n ALL_OF_KEY,\n ANY_OF_KEY,\n DEPENDENCIES_KEY,\n ID_KEY,\n IF_KEY,\n ITEMS_KEY,\n ONE_OF_KEY,\n PATTERN_PROPERTIES_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n} from '../constants';\nimport findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport guessType from '../guessType';\nimport isObject from '../isObject';\nimport mergeSchemas from '../mergeSchemas';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport getFirstMatchingOption from './getFirstMatchingOption';\nimport deepEquals from '../deepEquals';\nimport isEmpty from 'lodash/isEmpty';\n\n/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies\n * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the\n * potentially recursive resolution.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema having its conditions, additional properties, references and dependencies resolved\n */\nexport default function retrieveSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S = {} as S,\n rawFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n schema,\n rootSchema,\n rawFormData,\n undefined,\n undefined,\n experimental_customMergeAllOf,\n )[0];\n}\n\n/** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch\n * with the rest of the schema. If `expandAllBranches` is true, then the `retrieveSchemaInteral()` results for both\n * conditions will be returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions\n * @param schema - The schema for which resolving a condition is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and\n * dependencies as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded\n */\nexport function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;\n\n const conditionValue = validator.isValid(expression as S, formData || ({} as T), rootSchema);\n let resolvedSchemas = [resolvedSchemaLessConditional as S];\n let schemas: S[] = [];\n if (expandAllBranches) {\n if (then && typeof then !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n then as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n if (otherwise && typeof otherwise !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n otherwise as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n } else {\n const conditionalSchema = conditionValue ? then : otherwise;\n if (conditionalSchema && typeof conditionalSchema !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n conditionalSchema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n }\n if (schemas.length) {\n resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s) as S);\n }\n return resolvedSchemas.flatMap((s) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n}\n\n/** Given a list of lists of allOf, anyOf or oneOf values, create a list of lists of all permutations of the values. The\n * `listOfLists` is expected to be all resolved values of the 1st...nth schemas within an `allOf`, `anyOf` or `oneOf`.\n * From those lists, build a matrix for each `xxxOf` where there is more than one schema for a row in the list of lists.\n *\n * For example:\n * - If there are three xxxOf rows (A, B, C) and they have been resolved such that there is only one A, two B and three\n * C schemas then:\n * - The permutation for the first row is `[[A]]`\n * - The permutations for the second row are `[[A,B1], [A,B2]]`\n * - The permutations for the third row are `[[A,B1,C1], [A,B1,C2], [A,B1,C3], [A,B2,C1], [A,B2,C2], [A,B2,C3]]`\n *\n * @param listOfLists - The list of lists of elements that represent the allOf, anyOf or oneOf resolved values in order\n * @returns - The list of all permutations of schemas for a set of `xxxOf`s\n */\nexport function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchema>(listOfLists: S[][]) {\n const allPermutations: S[][] = listOfLists.reduce<S[][]>(\n (permutations, list) => {\n // When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values\n if (list.length > 1) {\n return list.flatMap((element) => times(permutations.length, (i) => [...permutations[i]].concat(element)));\n }\n // Otherwise just push in the single value into the current set of permutations\n permutations.forEach((permutation) => permutation.push(list[0]));\n return permutations;\n },\n [[]] as S[][], // Start with an empty list\n );\n\n return allPermutations;\n}\n\n/** Returns the subset of 'patternProperties' specifications that match the given 'key'\n *\n * @param schema - The schema whose 'patternProperties' are to be filtered\n * @param key - The key to match against the 'patternProperties' specifications\n * @returns - The subset of 'patternProperties' specifications that match the given 'key'\n */\nexport function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n key: string,\n): Required<S['patternProperties']> {\n return Object.keys(schema.patternProperties!)\n .filter((pattern: string) => RegExp(pattern).test(key))\n .reduce(\n (obj, pattern) => {\n // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path\n set(obj, [pattern], schema.patternProperties![pattern]);\n return obj;\n },\n {} as Required<S['patternProperties']>,\n );\n}\n\n/** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag\n * down to the `retrieveSchemaInternal()`, `resolveReference()` and `resolveDependencies()` helper calls. If\n * `expandAllBranches` is true, then all possible dependencies and/or allOf branches are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas having its references, dependencies and allOf schemas resolved\n */\nexport function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const updatedSchemas = resolveReference<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n );\n if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {\n // return the updatedSchemas array if it has either multiple schemas within it\n // OR the first schema is not the same as the original schema\n return updatedSchemas;\n }\n if (DEPENDENCIES_KEY in schema) {\n const resolvedSchemas = resolveDependencies<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n );\n return resolvedSchemas.flatMap((s) => {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n });\n }\n if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {\n const allOfSchemaElements: S[][] = schema.allOf.map((allOfSubschema) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n allOfSubschema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n const allPermutations = getAllPermutationsOfXxxOf<S>(allOfSchemaElements);\n return allPermutations.map((permutation) => ({\n ...schema,\n allOf: permutation,\n }));\n }\n // No $ref or dependencies or allOf attribute was found, returning the original schema.\n return [schema];\n}\n\n/** Resolves all references within a schema and then returns the `retrieveSchemaInternal()` if the resolved schema is\n * actually different than the original. Passes the `expandAllBranches` flag down to the `retrieveSchemaInternal()`\n * helper call.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a reference is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list schemas retrieved after having all references resolved\n */\nexport function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const updatedSchema = resolveAllReferences<S>(schema, rootSchema, recurseList);\n if (updatedSchema !== schema) {\n // Only call this if the schema was actually changed by the `resolveAllReferences()` function\n return retrieveSchemaInternal<T, S, F>(\n validator,\n updatedSchema,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n }\n return [schema];\n}\n\n/** Resolves all references within the schema itself as well as any of its properties and array items.\n *\n * @param schema - The schema for which resolving all references is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param recurseList - List of $refs already resolved to prevent recursion\n * @param [baseURI] - The base URI to be used for resolving relative references\n * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved\n */\nexport function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n rootSchema: S,\n recurseList: string[],\n baseURI?: string,\n): S {\n if (!isObject(schema)) {\n return schema;\n }\n let resolvedSchema: S = schema;\n // resolve top level ref\n if (REF_KEY in resolvedSchema) {\n const { $ref, ...localSchema } = resolvedSchema;\n // Check for a recursive reference and stop the loop\n if (recurseList.includes($ref!)) {\n return resolvedSchema;\n }\n recurseList.push($ref!);\n // Retrieve the referenced schema definition.\n const refSchema = findSchemaDefinition<S>($ref, rootSchema, baseURI);\n resolvedSchema = { ...refSchema, ...localSchema };\n if (ID_KEY in resolvedSchema) {\n baseURI = resolvedSchema[ID_KEY];\n }\n }\n\n if (PROPERTIES_KEY in resolvedSchema) {\n const childrenLists: string[][] = [];\n const updatedProps = transform(\n resolvedSchema[PROPERTIES_KEY]!,\n (result, value, key: string) => {\n const childList: string[] = [...recurseList];\n result[key] = resolveAllReferences(value as S, rootSchema, childList, baseURI);\n childrenLists.push(childList);\n },\n {} as RJSFSchema,\n );\n merge(recurseList, uniq(flattenDeep(childrenLists)));\n resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };\n }\n\n if (\n ITEMS_KEY in resolvedSchema &&\n !Array.isArray(resolvedSchema.items) &&\n typeof resolvedSchema.items !== 'boolean'\n ) {\n resolvedSchema = {\n ...resolvedSchema,\n items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList, baseURI),\n };\n }\n\n return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;\n}\n\n/** Creates new 'properties' items for each key in the `formData`\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which the existing additional properties is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator\n * @param [aFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The updated schema with additional properties stubbed\n */\nexport function stubExistingAdditionalProperties<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n rootSchema?: S,\n aFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S {\n // Clone the schema so that we don't ruin the consumer's original\n const schema = {\n ...theSchema,\n properties: { ...theSchema.properties },\n };\n\n // make sure formData is an object\n const formData: GenericObjectType = aFormData && isObject(aFormData) ? aFormData : {};\n Object.keys(formData).forEach((key) => {\n if (key in schema.properties) {\n // No need to stub, our schema already has the property\n return;\n }\n if (PATTERN_PROPERTIES_KEY in schema) {\n const matchingProperties = getMatchingPatternProperties(schema, key);\n if (!isEmpty(matchingProperties)) {\n schema.properties[key] = retrieveSchema<T, S, F>(\n validator,\n { allOf: Object.values(matchingProperties) } as S,\n rootSchema,\n get(formData, [key]) as T,\n experimental_customMergeAllOf,\n );\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n return;\n }\n }\n if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {\n let additionalProperties: S['additionalProperties'] = {};\n if (typeof schema.additionalProperties !== 'boolean') {\n if (REF_KEY in schema.additionalProperties!) {\n additionalProperties = retrieveSchema<T, S, F>(\n validator,\n { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,\n rootSchema,\n formData as T,\n experimental_customMergeAllOf,\n );\n } else if ('type' in schema.additionalProperties!) {\n additionalProperties = { ...schema.additionalProperties };\n } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {\n additionalProperties = {\n type: 'object',\n ...schema.additionalProperties,\n };\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n\n // The type of our new key should match the additionalProperties value;\n schema.properties[key] = additionalProperties;\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n } else {\n // Invalid property\n schema.properties[key] = { type: 'null' };\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n }\n });\n\n return schema;\n}\n\n/** Internal handler that retrieves an expanded schema that has had all of its conditions, additional properties,\n * references and dependencies resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData`\n * that is used to do the potentially recursive resolution. If `expandAllBranches` is true, then all possible branches\n * of the schema and its references, conditions and dependencies are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @param [expandAllBranches=false] - Flag, if true, will return all possible branches of conditions, any/oneOf and\n * dependencies as a list of schemas\n * @param [recurseList=[]] - The optional, list of recursive references already processed\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema(s) resulting from having its conditions, additional properties, references and dependencies\n * resolved. Multiple schemas may be returned if `expandAllBranches` is true.\n */\nexport function retrieveSchemaInternal<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n rawFormData?: T,\n expandAllBranches = false,\n recurseList: string[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n if (!isObject(schema)) {\n return [{} as S];\n }\n const resolvedSchemas = resolveSchema<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n rawFormData,\n experimental_customMergeAllOf,\n );\n return resolvedSchemas.flatMap((s: S) => {\n let resolvedSchema = s;\n if (IF_KEY in resolvedSchema) {\n return resolveCondition<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n expandAllBranches,\n recurseList,\n rawFormData as T,\n experimental_customMergeAllOf,\n );\n }\n if (ALL_OF_KEY in resolvedSchema) {\n // resolve allOf schemas\n if (expandAllBranches) {\n const { allOf, ...restOfSchema } = resolvedSchema;\n return [...(allOf as S[]), restOfSchema as S];\n }\n try {\n const withContainsSchemas = [] as S[];\n const withoutContainsSchemas = [] as S[];\n resolvedSchema.allOf?.forEach((s) => {\n if (typeof s === 'object' && s.contains) {\n withContainsSchemas.push(s as S);\n } else {\n withoutContainsSchemas.push(s as S);\n }\n });\n if (withContainsSchemas.length) {\n resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };\n }\n resolvedSchema = experimental_customMergeAllOf\n ? experimental_customMergeAllOf(resolvedSchema)\n : (mergeAllOf(resolvedSchema, {\n deep: false,\n resolvers: {\n $defs: mergeAllOf.options.resolvers.definitions,\n },\n } as Options) as S);\n if (withContainsSchemas.length) {\n resolvedSchema.allOf = withContainsSchemas;\n }\n } catch (e) {\n console.warn('could not merge subschemas in allOf:\\n', e);\n const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;\n return resolvedSchemaWithoutAllOf as S;\n }\n }\n if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {\n resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(\n (schema, key) => {\n const matchingProperties = getMatchingPatternProperties(schema, key);\n if (!isEmpty(matchingProperties)) {\n schema.properties[key] = retrieveSchema<T, S, F>(\n validator,\n { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,\n rootSchema,\n get(rawFormData, [key]) as T,\n experimental_customMergeAllOf,\n );\n }\n return schema;\n },\n {\n ...resolvedSchema,\n properties: { ...resolvedSchema.properties },\n },\n );\n }\n const hasAdditionalProperties =\n PATTERN_PROPERTIES_KEY in resolvedSchema ||\n (ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false);\n if (hasAdditionalProperties) {\n return stubExistingAdditionalProperties<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n rawFormData as T,\n experimental_customMergeAllOf,\n );\n }\n\n return resolvedSchema;\n });\n}\n\n/** Resolves an `anyOf` or `oneOf` within a schema (if present) to the list of schemas returned from\n * `retrieveSchemaInternal()` for the best matching option. If `expandAllBranches` is true, then a list of schemas for ALL\n * options are retrieved and returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema, defaults to an empty object\n * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true\n */\nexport function resolveAnyOrOneOfSchemas<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(validator: ValidatorType<T, S, F>, schema: S, rootSchema: S, expandAllBranches: boolean, rawFormData?: T) {\n let anyOrOneOf: S[] | undefined;\n const { oneOf, anyOf, ...remaining } = schema;\n if (Array.isArray(oneOf)) {\n anyOrOneOf = oneOf as S[];\n } else if (Array.isArray(anyOf)) {\n anyOrOneOf = anyOf as S[];\n }\n if (anyOrOneOf) {\n // Ensure that during expand all branches we pass an object rather than undefined so that all options are interrogated\n const formData = rawFormData === undefined && expandAllBranches ? ({} as T) : rawFormData;\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n anyOrOneOf = anyOrOneOf.map((s) => {\n // Due to anyOf/oneOf possibly using the same $ref we always pass a fresh recurse list array so that each option\n // can resolve recursive references independently\n return resolveAllReferences(s, rootSchema, []);\n });\n // Call this to trigger the set of isValid() calls that the schema parser will need\n const option = getFirstMatchingOption<T, S, F>(validator, formData, anyOrOneOf, rootSchema, discriminator);\n if (expandAllBranches) {\n return anyOrOneOf.map((item) => mergeSchemas(remaining, item) as S);\n }\n schema = mergeSchemas(remaining, anyOrOneOf[option]) as S;\n }\n return [schema];\n}\n\n/** Resolves dependencies within a schema and its 'anyOf/oneOf' children. Passes the `expandAllBranches` flag down to\n * the `resolveAnyOrOneOfSchema()` and `processDependencies()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a dependency is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas with their dependencies resolved\n */\nexport function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n // Drop the dependencies from the source schema.\n const { dependencies, ...remainingSchema } = schema;\n const resolvedSchemas = resolveAnyOrOneOfSchemas<T, S, F>(\n validator,\n remainingSchema as S,\n rootSchema,\n expandAllBranches,\n formData,\n );\n return resolvedSchemas.flatMap((resolvedSchema) =>\n processDependencies<T, S, F>(\n validator,\n dependencies,\n resolvedSchema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n}\n\n/** Processes all the `dependencies` recursively into the list of `resolvedSchema`s as needed. Passes the\n * `expandAllBranches` flag down to the `withDependentSchema()` and the recursive `processDependencies()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param dependencies - The set of dependencies that needs to be processed\n * @param resolvedSchema - The schema for which processing dependencies is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The schema with the `dependencies` resolved into it\n */\nexport function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n dependencies: S['dependencies'],\n resolvedSchema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n let schemas = [resolvedSchema];\n // Process dependencies updating the local schema properties as appropriate.\n for (const dependencyKey in dependencies) {\n // Skip this dependency if its trigger property is not present.\n if (!expandAllBranches && get(formData, [dependencyKey]) === undefined) {\n continue;\n }\n // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)\n if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {\n continue;\n }\n const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(\n dependencyKey,\n dependencies as GenericObjectType,\n );\n if (Array.isArray(dependencyValue)) {\n schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);\n } else if (isObject(dependencyValue)) {\n schemas = withDependentSchema<T, S, F>(\n validator,\n resolvedSchema,\n rootSchema,\n dependencyKey,\n dependencyValue as S,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n );\n }\n return schemas.flatMap((schema) =>\n processDependencies<T, S, F>(\n validator,\n remainingDependencies,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n }\n return schemas;\n}\n\n/** Updates a schema with additionally required properties added\n *\n * @param schema - The schema for which resolving a dependent properties is desired\n * @param [additionallyRequired] - An optional array of additionally required names\n * @returns - The schema with the additional required values merged in\n */\nexport function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n additionallyRequired?: string[],\n) {\n if (!additionallyRequired) {\n return schema;\n }\n const required = Array.isArray(schema.required)\n ? Array.from(new Set([...schema.required, ...additionallyRequired]))\n : additionallyRequired;\n return { ...schema, required: required };\n}\n\n/** Merges a dependent schema into the `schema` dealing with oneOfs and references. Passes the `expandAllBranches` flag\n * down to the `retrieveSchemaInternal()`, `resolveReference()` and `withExactlyOneSubschema()` helper calls.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a dependent schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param dependencyKey - The key name of the dependency\n * @param dependencyValue - The potentially dependent schema\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData]- The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The list of schemas with the dependent schema resolved into them\n */\nexport function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n dependencyKey: string,\n dependencyValue: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const dependentSchemas = retrieveSchemaInternal<T, S, F>(\n validator,\n dependencyValue,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n return dependentSchemas.flatMap((dependent) => {\n const { oneOf, ...dependentSchema } = dependent;\n schema = mergeSchemas(schema, dependentSchema) as S;\n // Since it does not contain oneOf, we return the original schema.\n if (oneOf === undefined) {\n return schema;\n }\n // Resolve $refs inside oneOf.\n const resolvedOneOfs = oneOf.map((subschema) => {\n if (typeof subschema === 'boolean' || !(REF_KEY in subschema)) {\n return [subschema as S];\n }\n return resolveReference<T, S, F>(validator, subschema as S, rootSchema, expandAllBranches, recurseList, formData);\n });\n const allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);\n return allPermutations.flatMap((resolvedOneOf) =>\n withExactlyOneSubschema<T, S, F>(\n validator,\n schema,\n rootSchema,\n dependencyKey,\n resolvedOneOf,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n ),\n );\n });\n}\n\n/** Returns a list of `schema`s with the best choice from the `oneOf` options merged into it. If `expandAllBranches` is\n * true, then a list of schemas for ALL options are retrieved and returned. Passes the `expandAllBranches` flag down to\n * the `retrieveSchemaInternal()` helper call.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used to validate oneOf options\n * @param schema - The schema for which resolving a oneOf subschema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param dependencyKey - The key name of the oneOf dependency\n * @param oneOf - The list of schemas representing the oneOf options\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true\n */\nexport function withExactlyOneSubschema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n dependencyKey: string,\n oneOf: S['oneOf'],\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const validSubschemas = oneOf!.filter((subschema) => {\n if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {\n return false;\n }\n const { [dependencyKey]: conditionPropertySchema } = subschema.properties;\n if (conditionPropertySchema) {\n const conditionSchema: S = {\n type: 'object',\n properties: {\n [dependencyKey]: conditionPropertySchema,\n },\n } as S;\n return validator.isValid(conditionSchema, formData, rootSchema) || expandAllBranches;\n }\n return false;\n });\n\n if (!expandAllBranches && validSubschemas!.length !== 1) {\n console.warn(\"ignoring oneOf in dependencies because there isn't exactly one subschema that is valid\");\n return [schema];\n }\n return validSubschemas.flatMap((s) => {\n const subschema: S = s as S;\n const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties as GenericObjectType);\n const dependentSchema = { ...subschema, properties: dependentSubschema };\n const schemas = retrieveSchemaInternal<T, S, F>(\n validator,\n dependentSchema,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n return schemas.map((s) => mergeSchemas(schema, s) as S);\n });\n}\n", "import jsonpointer from 'jsonpointer';\nimport omit from 'lodash/omit';\n\nimport { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY } from './constants';\nimport { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';\nimport isObject from 'lodash/isObject';\nimport isEmpty from 'lodash/isEmpty';\nimport UriResolver from 'fast-uri';\nimport get from 'lodash/get';\n\n/** Looks for the `$id` pointed by `ref` in the schema definitions embedded in\n * a JSON Schema bundle\n *\n * @param schema - The schema wherein `ref` should be searched\n * @param ref - The `$id` of the reference to search for\n * @returns - The schema matching the reference, or `undefined` if no match is found\n */\nfunction findEmbeddedSchemaRecursive<S extends StrictRJSFSchema = RJSFSchema>(schema: S, ref: string): S | undefined {\n if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY] as string, ref)) {\n return schema;\n }\n for (const subSchema of Object.values(schema)) {\n if (isObject(subSchema)) {\n const result = findEmbeddedSchemaRecursive<S>(subSchema as S, ref);\n if (result !== undefined) {\n return result as S;\n }\n }\n }\n return undefined;\n}\n\n/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first\n * location, the `object` minus the `key: value` and in the second location the `value`.\n *\n * @param key - The key from the object to extract\n * @param object - The object from which to extract the element\n * @returns - An array with the first value being the object minus the `key` element and the second element being the\n * value from `object[key]`\n */\nexport function splitKeyElementFromObject(key: string, object: GenericObjectType) {\n const value = object[key];\n const remaining = omit(object, [key]);\n return [remaining, value];\n}\n\n/** Given the name of a `$ref` from within a schema, using the `rootSchema`, recursively look up and return the\n * sub-schema using the path provided by that reference. If `#` is not the first character of the reference, the path\n * does not exist in the schema, or the reference resolves circularly back to itself, then throw an Error.\n * Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.\n *\n * @param $ref - The ref string for which the schema definition is desired\n * @param [rootSchema={}] - The root schema in which to search for the definition\n * @param recurseList - List of $refs already resolved to prevent recursion\n * @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references\n * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists\n * @throws - Error indicating that no schema for that reference could be resolved\n */\nexport function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFSchema>(\n $ref?: string,\n rootSchema: S = {} as S,\n recurseList: string[] = [],\n baseURI: string | undefined = get(rootSchema, [ID_KEY]),\n): S {\n const ref = $ref || '';\n let current: S | undefined = undefined;\n if (ref.startsWith('#')) {\n // Decode URI fragment representation.\n const decodedRef = decodeURIComponent(ref.substring(1));\n if (baseURI === undefined || (ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI)) {\n current = jsonpointer.get(rootSchema, decodedRef);\n } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {\n current = findEmbeddedSchemaRecursive<S>(rootSchema, baseURI.replace(/\\/$/, ''));\n if (current !== undefined) {\n current = jsonpointer.get(current, decodedRef);\n }\n }\n } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {\n const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;\n const [refId, ...refAnchor] = resolvedRef.replace(/#\\/?$/, '').split('#');\n current = findEmbeddedSchemaRecursive<S>(rootSchema, refId.replace(/\\/$/, ''));\n if (current !== undefined) {\n baseURI = current[ID_KEY];\n if (!isEmpty(refAnchor)) {\n current = jsonpointer.get(current, decodeURIComponent(refAnchor.join('#')));\n }\n }\n }\n if (current === undefined) {\n throw new Error(`Could not find a definition for ${$ref}.`);\n }\n const nextRef = current[REF_KEY];\n if (nextRef) {\n // Check for circular references.\n if (recurseList.includes(nextRef)) {\n if (recurseList.length === 1) {\n throw new Error(`Definition for ${$ref} is a circular reference`);\n }\n const [firstRef, ...restRefs] = recurseList;\n const circularPath = [...restRefs, ref, firstRef].join(' -> ');\n throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);\n }\n const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);\n const subSchema = findSchemaDefinitionRecursive<S>(theRef, rootSchema, [...recurseList, ref], baseURI);\n if (Object.keys(remaining).length > 0) {\n return { ...remaining, ...subSchema };\n }\n return subSchema;\n }\n return current;\n}\n\n/** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the\n * path provided by that reference. If `#` is not the first character of the reference, the path does not exist in\n * the schema, or the reference resolves circularly back to itself, then throw an Error. Otherwise return the\n * sub-schema. Also deals with nested `$ref`s in the sub-schema.\n *\n * @param $ref - The ref string for which the schema definition is desired\n * @param [rootSchema={}] - The root schema in which to search for the definition\n * @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references\n * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists\n * @throws - Error indicating that no schema for that reference could be resolved\n */\nexport default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>(\n $ref?: string,\n rootSchema: S = {} as S,\n baseURI: string | undefined = get(rootSchema, [ID_KEY]),\n): S {\n const recurseList: string[] = [];\n return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);\n}\n", "import get from 'lodash/get';\nimport isString from 'lodash/isString';\n\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport { DISCRIMINATOR_PATH } from './constants';\n\n/** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when\n * it is not a string. Returns `undefined` when a valid discriminator is not present.\n *\n * @param schema - The schema from which the discriminator is potentially obtained\n * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`\n */\nexport default function getDiscriminatorFieldFromSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n let discriminator: string | undefined;\n const maybeString = get(schema, DISCRIMINATOR_PATH);\n if (isString(maybeString)) {\n discriminator = maybeString;\n } else if (maybeString !== undefined) {\n console.warn(`Expecting discriminator to be a string, got \"${typeof maybeString}\" instead`);\n }\n return discriminator;\n}\n", "/** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly\n * create a schema, it is useful to know what type to use based on the data we are defining.\n *\n * @param value - The value from which to guess the type\n * @returns - The best guess for the object type\n */\nexport default function guessType(value: any) {\n if (Array.isArray(value)) {\n return 'array';\n }\n if (typeof value === 'string') {\n return 'string';\n }\n if (value == null) {\n return 'null';\n }\n if (typeof value === 'boolean') {\n return 'boolean';\n }\n if (!isNaN(value)) {\n return 'number';\n }\n if (typeof value === 'object') {\n return 'object';\n }\n // Default to string if we can't figure it out\n return 'string';\n}\n", "import union from 'lodash/union';\n\nimport { REQUIRED_KEY } from './constants';\nimport getSchemaType from './getSchemaType';\nimport isObject from './isObject';\nimport { GenericObjectType } from './types';\n\n/** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that\n * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include\n * duplicate values.\n *\n * @param obj1 - The first schema object to merge\n * @param obj2 - The second schema object to merge\n * @returns - The merged schema object\n */\nexport default function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType) {\n const acc = Object.assign({}, obj1); // Prevent mutation of source object.\n return Object.keys(obj2).reduce((acc, key) => {\n const left = obj1 ? obj1[key] : {},\n right = obj2[key];\n if (obj1 && key in obj1 && isObject(right)) {\n acc[key] = mergeSchemas(left, right);\n } else if (\n obj1 &&\n obj2 &&\n (getSchemaType(obj1) === 'object' || getSchemaType(obj2) === 'object') &&\n key === REQUIRED_KEY &&\n Array.isArray(left) &&\n Array.isArray(right)\n ) {\n // Don't include duplicate values when merging 'required' fields.\n acc[key] = union(left, right);\n } else {\n acc[key] = right;\n }\n return acc;\n }, acc);\n}\n", "import guessType from './guessType';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from\n * other elements of the schema as follows:\n * - schema.const: Returns the `guessType()` of that value\n * - schema.enum: Returns `string`\n * - schema.properties: Returns `object`\n * - schema.additionalProperties: Returns `object`\n * - schema.patternProperties: Returns `object`\n * - type is an array with a length of 2 and one type is 'null': Returns the other type\n *\n * @param schema - The schema for which to get the type\n * @returns - The type of the schema\n */\nexport default function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n): string | string[] | undefined {\n let { type } = schema;\n\n if (!type && schema.const) {\n return guessType(schema.const);\n }\n\n if (!type && schema.enum) {\n return 'string';\n }\n\n if (!type && (schema.properties || schema.additionalProperties || schema.patternProperties)) {\n return 'object';\n }\n\n if (Array.isArray(type)) {\n if (type.length === 2 && type.includes('null')) {\n type = type.find((type) => type !== 'null');\n } else {\n type = type[0];\n }\n }\n\n return type;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isNumber from 'lodash/isNumber';\n\nimport { PROPERTIES_KEY } from '../constants';\nimport getOptionMatchingSimpleDiscriminator from '../getOptionMatchingSimpleDiscriminator';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\n\n/** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.\n * Always returns the first option if there is nothing that matches.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param rootSchema - The root schema, used to primarily to look up `$ref`s\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the first matched option or 0 if none is available\n */\nexport default function getFirstMatchingOption<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n formData: T | undefined,\n options: S[],\n rootSchema: S,\n discriminatorField?: string,\n): number {\n // For performance, skip validating subschemas if formData is undefined. We just\n // want to get the first option in that case.\n if (formData === undefined) {\n return 0;\n }\n\n const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);\n if (isNumber(simpleDiscriminatorMatch)) {\n return simpleDiscriminatorMatch;\n }\n\n for (let i = 0; i < options.length; i++) {\n const option = options[i];\n\n // If we have a discriminator field, then we will use this to make the determination\n if (discriminatorField && has(option, [PROPERTIES_KEY, discriminatorField])) {\n const value = get(formData, discriminatorField);\n const discriminator: S = get(option, [PROPERTIES_KEY, discriminatorField], {}) as S;\n if (validator.isValid(discriminator, value, rootSchema)) {\n return i;\n }\n } else if (option[PROPERTIES_KEY]) {\n // If the schema describes an object then we need to add slightly more\n // strict matching to the schema, because unless the schema uses the\n // \"requires\" keyword, an object will match the schema as long as it\n // doesn't have matching keys with a conflicting type. To do this we use an\n // \"anyOf\" with an array of requires. This augmentation expresses that the\n // schema should match if any of the keys in the schema are present on the\n // object and pass validation.\n //\n // Create an \"anyOf\" schema that requires at least one of the keys in the\n // \"properties\" object\n const requiresAnyOf = {\n anyOf: Object.keys(option[PROPERTIES_KEY]).map((key) => ({\n required: [key],\n })),\n };\n\n let augmentedSchema;\n\n // If the \"anyOf\" keyword already exists, wrap the augmentation in an \"allOf\"\n if (option.anyOf) {\n // Create a shallow clone of the option\n const { ...shallowClone } = option;\n\n if (!shallowClone.allOf) {\n shallowClone.allOf = [];\n } else {\n // If \"allOf\" already exists, shallow clone the array\n shallowClone.allOf = shallowClone.allOf.slice();\n }\n\n shallowClone.allOf.push(requiresAnyOf);\n\n augmentedSchema = shallowClone;\n } else {\n augmentedSchema = Object.assign({}, option, requiresAnyOf);\n }\n\n // Remove the \"required\" field as it's likely that not all fields have\n // been filled in yet, which will mean that the schema is not valid\n delete augmentedSchema.required;\n\n if (validator.isValid(augmentedSchema, formData, rootSchema)) {\n return i;\n }\n } else if (validator.isValid(option, formData, rootSchema)) {\n return i;\n }\n }\n return 0;\n}\n", "import get from 'lodash/get';\nimport { PROPERTIES_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Compares the value of `discriminatorField` within `formData` against the value of `discriminatorField` within schema for each `option`.\n * Returns index of first `option` whose discriminator matches formData. Returns `undefined` if there is no match.\n * This function does not work with discriminators of `\"type\": \"object\"` and `\"type\": \"array\"`\n *\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the matched option or undefined if there is no match\n */\nexport default function getOptionMatchingSimpleDiscriminator<T = any, S extends StrictRJSFSchema = RJSFSchema>(\n formData: T | undefined,\n options: S[],\n discriminatorField?: string,\n): number | undefined {\n if (formData && discriminatorField) {\n const value = get(formData, discriminatorField);\n\n if (value === undefined) {\n return;\n }\n\n for (let i = 0; i < options.length; i++) {\n const option = options[i];\n const discriminator: S = get(option, [PROPERTIES_KEY, discriminatorField], {}) as S;\n\n if (discriminator.type === 'object' || discriminator.type === 'array') {\n continue;\n }\n\n if (discriminator.const === value) {\n return i;\n }\n\n if (discriminator.enum?.includes(value)) {\n return i;\n }\n }\n }\n\n return;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isEmpty from 'lodash/isEmpty';\n\nimport retrieveSchema from './retrieveSchema';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport { REF_KEY } from '../constants';\n\n/** Internal helper function that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path\n * for schemas containing potentially nested `$ref`s.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The current node within the JSON schema recursion\n * @param path - The remaining keys in the path to the desired property\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The internal schema from the `schema` for the given `path` or undefined if not found\n */\nfunction getFromSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | S | undefined {\n let fieldSchema = schema;\n if (has(schema, REF_KEY)) {\n fieldSchema = retrieveSchema<T, S, F>(validator, schema, rootSchema, undefined, experimental_customMergeAllOf);\n }\n if (isEmpty(path)) {\n return fieldSchema;\n }\n const pathList = Array.isArray(path) ? path : path.split('.');\n const [part, ...nestedPath] = pathList;\n if (part && has(fieldSchema, part)) {\n fieldSchema = get(fieldSchema, part) as S;\n return getFromSchemaInternal<T, S, F>(\n validator,\n rootSchema,\n fieldSchema,\n nestedPath,\n experimental_customMergeAllOf,\n );\n }\n return undefined;\n}\n\n/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas\n * containing potentially nested `$ref`s.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The current node within the JSON schema recursion\n * @param path - The keys in the path to the desired field\n * @param defaultValue - The value to return if a value is not found for the `pathList` path\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The inner schema from the `schema` for the given `path` or the `defaultValue` if not found\n */\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T;\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S;\nexport default function getFromSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n defaultValue: T | S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | S {\n const result = getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf);\n if (result === undefined) {\n return defaultValue;\n }\n return result;\n}\n", "import get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport { JSONSchema7Object } from 'json-schema';\n\nimport {\n ALL_OF_KEY,\n ANY_OF_KEY,\n CONST_KEY,\n DEFAULT_KEY,\n DEPENDENCIES_KEY,\n ONE_OF_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n} from '../constants';\nimport findSchemaDefinition from '../findSchemaDefinition';\nimport getClosestMatchingOption from './getClosestMatchingOption';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport getSchemaType from '../getSchemaType';\nimport isObject from '../isObject';\nimport isFixedItems from '../isFixedItems';\nimport mergeDefaultsWithFormData from '../mergeDefaultsWithFormData';\nimport mergeObjects from '../mergeObjects';\nimport mergeSchemas from '../mergeSchemas';\nimport {\n Experimental_CustomMergeAllOf,\n Experimental_DefaultFormStateBehavior,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport isMultiSelect from './isMultiSelect';\nimport isSelect from './isSelect';\nimport retrieveSchema, { resolveDependencies } from './retrieveSchema';\nimport isConstant from '../isConstant';\nimport constIsAjvDataReference from '../constIsAjvDataReference';\nimport optionsList from '../optionsList';\nimport deepEquals from '../deepEquals';\n\nconst PRIMITIVE_TYPES = ['string', 'number', 'integer', 'boolean', 'null'];\n\n/** Enum that indicates how `schema.additionalItems` should be handled by the `getInnerSchemaForArrayItem()` function.\n */\nexport enum AdditionalItemsHandling {\n Ignore,\n Invert,\n Fallback,\n}\n\n/** Given a `schema` will return an inner schema that for an array item. This is computed differently based on the\n * `additionalItems` enum and the value of `idx`. There are four possible returns:\n * 1. If `idx` is >= 0, then if `schema.items` is an array the `idx`th element of the array is returned if it is a valid\n * index and not a boolean, otherwise it falls through to 3.\n * 2. If `schema.items` is not an array AND truthy and not a boolean, then `schema.items` is returned since it actually\n * is a schema, otherwise it falls through to 3.\n * 3. If `additionalItems` is not `AdditionalItemsHandling.Ignore` and `schema.additionalItems` is an object, then\n * `schema.additionalItems` is returned since it actually is a schema, otherwise it falls through to 4.\n * 4. {} is returned representing an empty schema\n *\n * @param schema - The schema from which to get the particular item\n * @param [additionalItems=AdditionalItemsHandling.Ignore] - How do we want to handle additional items?\n * @param [idx=-1] - Index, if non-negative, will be used to return the idx-th element in a `schema.items` array\n * @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers\n */\nexport function getInnerSchemaForArrayItem<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n additionalItems: AdditionalItemsHandling = AdditionalItemsHandling.Ignore,\n idx = -1,\n): S {\n if (idx >= 0) {\n if (Array.isArray(schema.items) && idx < schema.items.length) {\n const item = schema.items[idx];\n if (typeof item !== 'boolean') {\n return item as S;\n }\n }\n } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {\n return schema.items as S;\n }\n if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {\n return schema.additionalItems as S;\n }\n return {} as S;\n}\n\n/** Either add `computedDefault` at `key` into `obj` or not add it based on its value, the value of\n * `includeUndefinedValues`, the value of `emptyObjectFields` and if its parent field is required. Generally undefined\n * `computedDefault` values are added only when `includeUndefinedValues` is either true/\"excludeObjectChildren\". If `\n * includeUndefinedValues` is false and `emptyObjectFields` is not \"skipDefaults\", then non-undefined and non-empty-object\n * values will be added based on certain conditions.\n *\n * @param obj - The object into which the computed default may be added\n * @param key - The key into the object at which the computed default may be added\n * @param computedDefault - The computed default value that maybe should be added to the obj\n * @param includeUndefinedValues - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties. If \"allowEmptyObject\", prevents undefined\n * values in this object while allow the object itself to be empty and passing `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n * @param isParentRequired - The optional boolean that indicates whether the parent field is required\n * @param requiredFields - The list of fields that are required\n * @param experimental_defaultFormStateBehavior - Optional configuration object, if provided, allows users to override\n * default form state behavior\n * @param isConst - Optional flag, if true, indicates that the schema has a const property defined, thus we should always return the computedDefault since it's coming from the const.\n */\nfunction maybeAddDefaultToObject<T = any>(\n obj: GenericObjectType,\n key: string,\n computedDefault: T | T[] | undefined,\n includeUndefinedValues: boolean | 'excludeObjectChildren',\n isParentRequired?: boolean,\n requiredFields: string[] = [],\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior = {},\n isConst = false,\n) {\n const { emptyObjectFields = 'populateAllDefaults' } = experimental_defaultFormStateBehavior;\n if (includeUndefinedValues || isConst) {\n // If includeUndefinedValues\n // Or if the schema has a const property defined, then we should always return the computedDefault since it's coming from the const.\n obj[key] = computedDefault;\n } else if (emptyObjectFields !== 'skipDefaults') {\n // If isParentRequired is undefined, then we are at the root level of the schema so defer to the requiredness of\n // the field key itself in the `requiredField` list\n const isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;\n\n if (isObject(computedDefault)) {\n // If emptyObjectFields 'skipEmptyDefaults' store computedDefault if it's a non-empty object(e.g. not {})\n if (emptyObjectFields === 'skipEmptyDefaults') {\n if (!isEmpty(computedDefault)) {\n obj[key] = computedDefault;\n }\n } // Else store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions\n // Condition 1: If computedDefault is not empty or if the key is a required field\n // Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'\n else if (\n (!isEmpty(computedDefault) || requiredFields.includes(key)) &&\n (isSelfOrParentRequired || emptyObjectFields !== 'populateRequiredDefaults')\n ) {\n obj[key] = computedDefault;\n }\n } else if (\n // Store computedDefault if it's a defined primitive (e.g., true) and satisfies certain conditions\n // Condition 1: computedDefault is not undefined\n // Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults)\n // Or if isSelfOrParentRequired is 'true' and the key is a required field\n computedDefault !== undefined &&\n (emptyObjectFields === 'populateAllDefaults' ||\n emptyObjectFields === 'skipEmptyDefaults' ||\n (isSelfOrParentRequired && requiredFields.includes(key)))\n ) {\n obj[key] = computedDefault;\n }\n }\n}\n\ninterface ComputeDefaultsProps<T = any, S extends StrictRJSFSchema = RJSFSchema> {\n /** Any defaults provided by the parent field in the schema */\n parentDefaults?: T;\n /** The options root schema, used to primarily to look up `$ref`s */\n rootSchema?: S;\n /** The current formData, if any, onto which to provide any missing defaults */\n rawFormData?: T;\n /** Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n */\n includeUndefinedValues?: boolean | 'excludeObjectChildren';\n /** The list of ref names currently being recursed, used to prevent infinite recursion */\n _recurseList?: string[];\n /** Optional configuration object, if provided, allows users to override default form state behavior */\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;\n /** Optional function that allows for custom merging of `allOf` schemas */\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;\n /** Optional flag, if true, indicates this schema was required in the parent schema. */\n required?: boolean;\n /** Optional flag, if true, It will merge defaults into formData.\n * The formData should take precedence unless it's not valid. This is useful when for example the value from formData does not exist in the schema 'enum' property, in such cases we take the value from the defaults because the value from the formData is not valid.\n */\n shouldMergeDefaultsIntoFormData?: boolean;\n}\n\n/** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into\n * each level of the schema, recursively, to fill out every level of defaults provided by the schema.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @returns - The resulting `formData` with all the defaults provided\n */\nexport function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n computeDefaultsProps: ComputeDefaultsProps<T, S> = {},\n): T | T[] | undefined {\n const {\n parentDefaults,\n rawFormData,\n rootSchema = {} as S,\n includeUndefinedValues = false,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData = false,\n } = computeDefaultsProps;\n let formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;\n const schema: S = isObject(rawSchema) ? rawSchema : ({} as S);\n // Compute the defaults recursively: give highest priority to deepest nodes.\n let defaults: T | T[] | undefined = parentDefaults;\n // If we get a new schema, then we need to recompute defaults again for the new schema found.\n let schemaToCompute: S | null = null;\n let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;\n let updatedRecurseList = _recurseList;\n if (\n schema[CONST_KEY] &&\n experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&\n !constIsAjvDataReference(schema)\n ) {\n defaults = schema[CONST_KEY] as unknown as T;\n } else if (isObject(defaults) && isObject(schema.default)) {\n // For object defaults, only override parent defaults that are defined in\n // schema.default.\n defaults = mergeObjects(defaults!, schema.default as GenericObjectType) as T;\n } else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {\n // If the schema has a default value, then we should use it as the default.\n // And if the schema does not have anyOf or oneOf, this is done because we need to merge the defaults with the formData.\n defaults = schema.default as unknown as T;\n } else if (REF_KEY in schema) {\n const refName = schema[REF_KEY];\n // Use referenced schema defaults for this node.\n if (!_recurseList.includes(refName!)) {\n updatedRecurseList = _recurseList.concat(refName!);\n schemaToCompute = findSchemaDefinition<S>(refName, rootSchema);\n }\n\n // If the referenced schema exists and parentDefaults is not set\n // Then set the defaults from the current schema for the referenced schema\n if (schemaToCompute && !defaults) {\n defaults = schema.default as T | undefined;\n }\n\n // If shouldMergeDefaultsIntoFormData is true\n // And the schemaToCompute is set and the rawFormData is not an object\n // Then set the formData to the rawFormData\n if (shouldMergeDefaultsIntoFormData && schemaToCompute && !isObject(rawFormData)) {\n formData = rawFormData as T;\n }\n } else if (DEPENDENCIES_KEY in schema) {\n // Get the default if set from properties to ensure the dependencies conditions are resolved based on it\n const defaultFormData: T = {\n ...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults),\n ...formData,\n };\n const resolvedSchema = resolveDependencies<T, S, F>(\n validator,\n schema,\n rootSchema,\n false,\n [],\n defaultFormData,\n experimental_customMergeAllOf,\n );\n schemaToCompute = resolvedSchema[0]; // pick the first element from resolve dependencies\n } else if (isFixedItems(schema)) {\n defaults = (schema.items! as S[]).map((itemSchema: S, idx: number) =>\n computeDefaults<T, S>(validator, itemSchema, {\n rootSchema,\n includeUndefinedValues,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined,\n rawFormData: formData as T,\n required,\n shouldMergeDefaultsIntoFormData,\n }),\n ) as T[];\n } else if (ONE_OF_KEY in schema) {\n const { oneOf, ...remaining } = schema;\n if (oneOf!.length === 0) {\n return undefined;\n }\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const { type = 'null' } = remaining;\n if (\n !Array.isArray(type) &&\n PRIMITIVE_TYPES.includes(type) &&\n experimental_dfsb_to_compute?.constAsDefaults === 'skipOneOf'\n ) {\n // If we are in a oneOf of a primitive type, then we want to pass constAsDefaults as 'never' for the recursion\n experimental_dfsb_to_compute = {\n ...experimental_dfsb_to_compute,\n constAsDefaults: 'never',\n };\n }\n schemaToCompute = oneOf![\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n rawFormData ?? (schema.default as T),\n oneOf as S[],\n 0,\n discriminator,\n experimental_customMergeAllOf,\n )\n ] as S;\n schemaToCompute = mergeSchemas(remaining, schemaToCompute) as S;\n } else if (ANY_OF_KEY in schema) {\n const { anyOf, ...remaining } = schema;\n if (anyOf!.length === 0) {\n return undefined;\n }\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n schemaToCompute = anyOf![\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n rawFormData ?? (schema.default as T),\n anyOf as S[],\n 0,\n discriminator,\n experimental_customMergeAllOf,\n )\n ] as S;\n schemaToCompute = mergeSchemas(remaining, schemaToCompute) as S;\n }\n\n if (schemaToCompute) {\n return computeDefaults<T, S, F>(validator, schemaToCompute, {\n rootSchema,\n includeUndefinedValues,\n _recurseList: updatedRecurseList,\n experimental_defaultFormStateBehavior: experimental_dfsb_to_compute,\n experimental_customMergeAllOf,\n parentDefaults: defaults as T | undefined,\n rawFormData: formData as T,\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }\n\n // No defaults defined for this node, fallback to generic typed ones.\n if (defaults === undefined) {\n defaults = schema.default as unknown as T;\n }\n\n const defaultBasedOnSchemaType = getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults);\n\n let defaultsWithFormData = defaultBasedOnSchemaType ?? defaults;\n // if shouldMergeDefaultsIntoFormData is true, then merge the defaults into the formData.\n if (shouldMergeDefaultsIntoFormData) {\n const { arrayMinItems = {} } = experimental_defaultFormStateBehavior || {};\n const { mergeExtraDefaults } = arrayMinItems;\n\n const matchingFormData = ensureFormDataMatchingSchema(\n validator,\n schema,\n rootSchema,\n rawFormData,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n );\n if (!isObject(rawFormData) || ALL_OF_KEY in schema) {\n // If the formData is not an object which means it's a primitive field, then we need to merge the defaults into the formData.\n // Or if the schema has allOf, we need to merge the defaults into the formData because we don't compute the defaults for allOf.\n defaultsWithFormData = mergeDefaultsWithFormData<T>(\n defaultsWithFormData as T,\n matchingFormData as T,\n mergeExtraDefaults,\n true,\n ) as T;\n }\n }\n\n return defaultsWithFormData;\n}\n\n/**\n * Ensure that the formData matches the given schema. If it's not matching in the case of a selectField, we change it to match the schema.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the formData state is desired\n * @param rootSchema - The root schema, used to primarily to look up `$ref`s\n * @param formData - The current formData\n * @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - valid formData that matches schema\n */\nexport function ensureFormDataMatchingSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n formData: T | undefined,\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T | T[] | undefined {\n const isSelectField =\n !isConstant<S>(schema) && isSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf);\n let validFormData: T | T[] | undefined = formData;\n if (isSelectField) {\n const getOptionsList = optionsList<T, S, F>(schema);\n const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));\n validFormData = isValid ? formData : undefined;\n }\n\n // Override the formData with the const if the constAsDefaults is set to always\n const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === 'always';\n if (constTakesPrecedence) {\n validFormData = schema.const as T;\n }\n\n return validFormData;\n}\n\n/** Computes the default value for objects.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getObjectDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n {\n rawFormData,\n rootSchema = {} as S,\n includeUndefinedValues = false,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData,\n }: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T {\n {\n const formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;\n const schema: S = rawSchema;\n // This is a custom addition that fixes this issue:\n // https://github.com/rjsf-team/react-jsonschema-form/issues/3832\n const retrievedSchema =\n experimental_defaultFormStateBehavior?.allOf === 'populateDefaults' && ALL_OF_KEY in schema\n ? retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf)\n : schema;\n const parentConst = retrievedSchema[CONST_KEY];\n const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(\n (acc: GenericObjectType, key: string) => {\n const propertySchema: S = get(retrievedSchema, [PROPERTIES_KEY, key], {}) as S;\n // Check if the parent schema has a const property defined AND we are supporting const as defaults, then we\n // should always return the computedDefault since it's coming from the const.\n const hasParentConst = isObject(parentConst) && (parentConst as JSONSchema7Object)[key] !== undefined;\n const hasConst =\n ((isObject(propertySchema) && CONST_KEY in propertySchema) || hasParentConst) &&\n experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&\n !constIsAjvDataReference(propertySchema);\n // Compute the defaults for this node, with the parent defaults we might\n // have from a previous run: defaults[key].\n const computedDefault = computeDefaults<T, S, F>(validator, propertySchema, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n includeUndefinedValues: includeUndefinedValues === true,\n parentDefaults: get(defaults, [key]),\n rawFormData: get(formData, [key]),\n required: retrievedSchema.required?.includes(key),\n shouldMergeDefaultsIntoFormData,\n });\n maybeAddDefaultToObject<T>(\n acc,\n key,\n computedDefault,\n includeUndefinedValues,\n required,\n retrievedSchema.required,\n experimental_defaultFormStateBehavior,\n hasConst,\n );\n return acc;\n },\n {},\n ) as T;\n if (retrievedSchema.additionalProperties) {\n // as per spec additionalProperties may be either schema or boolean\n const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties)\n ? retrievedSchema.additionalProperties\n : {};\n\n const keys = new Set<string>();\n if (isObject(defaults)) {\n Object.keys(defaults as GenericObjectType)\n .filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])\n .forEach((key) => keys.add(key));\n }\n const formDataRequired: string[] = [];\n Object.keys(formData as GenericObjectType)\n .filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])\n .forEach((key) => {\n keys.add(key);\n formDataRequired.push(key);\n });\n keys.forEach((key) => {\n const computedDefault = computeDefaults(validator, additionalPropertiesSchema as S, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n includeUndefinedValues: includeUndefinedValues === true,\n parentDefaults: get(defaults, [key]),\n rawFormData: get(formData, [key]),\n required: retrievedSchema.required?.includes(key),\n shouldMergeDefaultsIntoFormData,\n });\n // Since these are additional properties we don't need to add the `experimental_defaultFormStateBehavior` prop\n maybeAddDefaultToObject<T>(\n objectDefaults as GenericObjectType,\n key,\n computedDefault,\n includeUndefinedValues,\n required,\n formDataRequired,\n );\n });\n }\n return objectDefaults;\n }\n}\n\n/** Computes the default value for arrays.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getArrayDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n {\n rawFormData,\n rootSchema = {} as S,\n _recurseList = [],\n experimental_defaultFormStateBehavior = undefined,\n experimental_customMergeAllOf = undefined,\n required,\n shouldMergeDefaultsIntoFormData,\n }: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T | T[] | undefined {\n const schema: S = rawSchema;\n\n const arrayMinItemsStateBehavior = experimental_defaultFormStateBehavior?.arrayMinItems ?? {};\n const { populate: arrayMinItemsPopulate, mergeExtraDefaults: arrayMergeExtraDefaults } = arrayMinItemsStateBehavior;\n\n const neverPopulate = arrayMinItemsPopulate === 'never';\n const ignoreMinItemsFlagSet = arrayMinItemsPopulate === 'requiredOnly';\n const isPopulateAll = arrayMinItemsPopulate === 'all' || (!neverPopulate && !ignoreMinItemsFlagSet);\n const computeSkipPopulate = arrayMinItemsStateBehavior?.computeSkipPopulate ?? (() => false);\n const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === 'skipEmptyDefaults';\n\n const emptyDefault = isSkipEmptyDefaults ? undefined : [];\n\n // Inject defaults into existing array defaults\n if (Array.isArray(defaults)) {\n defaults = defaults.map((item, idx) => {\n const schemaItem: S = getInnerSchemaForArrayItem<S>(schema, AdditionalItemsHandling.Fallback, idx);\n return computeDefaults<T, S, F>(validator, schemaItem, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n parentDefaults: item,\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }) as T[];\n }\n\n // Deeply inject defaults into already existing form data\n if (Array.isArray(rawFormData)) {\n const schemaItem: S = getInnerSchemaForArrayItem<S>(schema);\n if (neverPopulate) {\n defaults = rawFormData;\n } else {\n const itemDefaults = rawFormData.map((item: T, idx: number) => {\n return computeDefaults<T, S, F>(validator, schemaItem, {\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n rawFormData: item,\n parentDefaults: get(defaults, [idx]),\n required,\n shouldMergeDefaultsIntoFormData,\n });\n }) as T[];\n\n // If the populate 'requiredOnly' flag is set then we only merge and include extra defaults if they are required.\n // Or if populate 'all' is set we merge and include extra defaults.\n const mergeExtraDefaults = ((ignoreMinItemsFlagSet && required) || isPopulateAll) && arrayMergeExtraDefaults;\n defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);\n }\n }\n\n // Check if the schema has a const property defined AND we are supporting const as defaults, then we should always\n // return the computedDefault since it's coming from the const.\n const hasConst =\n isObject(schema) && CONST_KEY in schema && experimental_defaultFormStateBehavior?.constAsDefaults !== 'never';\n if (hasConst === false) {\n if (neverPopulate) {\n return defaults ?? emptyDefault;\n }\n if (ignoreMinItemsFlagSet && !required) {\n // If no form data exists or defaults are set leave the field empty/non-existent, otherwise\n // return form data/defaults\n return defaults ? defaults : undefined;\n }\n }\n\n const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;\n if (\n !schema.minItems ||\n isMultiSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf) ||\n computeSkipPopulate<T, S, F>(validator, schema, rootSchema) ||\n schema.minItems <= defaultsLength\n ) {\n return defaults ? defaults : emptyDefault;\n }\n\n const defaultEntries: T[] = (defaults || []) as T[];\n const fillerSchema: S = getInnerSchemaForArrayItem<S>(schema, AdditionalItemsHandling.Invert);\n const fillerDefault = fillerSchema.default;\n\n // Calculate filler entries for remaining items (minItems - existing raw data/defaults)\n const fillerEntries: T[] = new Array(schema.minItems - defaultsLength).fill(\n computeDefaults<any, S, F>(validator, fillerSchema, {\n parentDefaults: fillerDefault,\n rootSchema,\n _recurseList,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n required,\n shouldMergeDefaultsIntoFormData,\n }),\n ) as T[];\n // then fill up the rest with either the item default or empty, up to minItems\n return defaultEntries.concat(fillerEntries);\n}\n\n/** Computes the default value based on the schema type.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary\n * @param rawSchema - The schema for which the default state is desired\n * @param {ComputeDefaultsProps} computeDefaultsProps - Optional props for this function\n * @param defaults - Optional props for this function\n * @returns - The default value based on the schema type if they are defined for object or array schemas.\n */\nexport function getDefaultBasedOnSchemaType<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rawSchema: S,\n computeDefaultsProps: ComputeDefaultsProps<T, S> = {},\n defaults?: T | T[] | undefined,\n): T | T[] | void {\n switch (getSchemaType<S>(rawSchema)) {\n // We need to recurse for object schema inner default values.\n case 'object': {\n return getObjectDefaults(validator, rawSchema, computeDefaultsProps, defaults);\n }\n case 'array': {\n return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);\n }\n }\n}\n\n/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have\n * computed to have defaults provided in the `schema`.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which the default state is desired\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", cause undefined values for this object and pass `includeUndefinedValues` as\n * false when computing defaults for any nested object properties.\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The resulting `formData` with all the defaults provided\n */\nexport default function getDefaultFormState<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n formData?: T,\n rootSchema?: S,\n includeUndefinedValues: boolean | 'excludeObjectChildren' = false,\n experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (!isObject(theSchema)) {\n throw new Error('Invalid schema: ' + theSchema);\n }\n const schema = retrieveSchema<T, S, F>(validator, theSchema, rootSchema, formData, experimental_customMergeAllOf);\n\n // Get the computed defaults with 'shouldMergeDefaultsIntoFormData' set to true to merge defaults into formData.\n // This is done when for example the value from formData does not exist in the schema 'enum' property, in such\n // cases we take the value from the defaults because the value from the formData is not valid.\n const defaults = computeDefaults<T, S, F>(validator, schema, {\n rootSchema,\n includeUndefinedValues,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n rawFormData: formData,\n shouldMergeDefaultsIntoFormData: true,\n });\n\n // If the formData is an object or an array, add additional properties from formData and override formData with\n // defaults since the defaults are already merged with formData.\n if (isObject(formData) || Array.isArray(formData)) {\n const { mergeDefaultsIntoFormData } = experimental_defaultFormStateBehavior || {};\n const defaultSupercedesUndefined = mergeDefaultsIntoFormData === 'useDefaultIfFormDataUndefined';\n const result = mergeDefaultsWithFormData<T | T[]>(\n defaults,\n formData,\n true, // set to true to add any additional default array entries.\n defaultSupercedesUndefined,\n true, // set to true to override formData with defaults if they exist.\n );\n return result;\n }\n\n return defaults;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\nimport isNumber from 'lodash/isNumber';\nimport isObject from 'lodash/isObject';\nimport isString from 'lodash/isString';\nimport reduce from 'lodash/reduce';\nimport times from 'lodash/times';\n\nimport getFirstMatchingOption from './getFirstMatchingOption';\nimport retrieveSchema, { resolveAllReferences } from './retrieveSchema';\nimport { ONE_OF_KEY, REF_KEY, JUNK_OPTION_ID, ANY_OF_KEY } from '../constants';\nimport guessType from '../guessType';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport getOptionMatchingSimpleDiscriminator from '../getOptionMatchingSimpleDiscriminator';\n\n/** A junk option used to determine when the getFirstMatchingOption call really matches an option rather than returning\n * the first item\n */\nexport const JUNK_OPTION: StrictRJSFSchema = {\n type: 'object',\n $id: JUNK_OPTION_ID,\n properties: {\n __not_really_there__: {\n type: 'number',\n },\n },\n};\n\n/** Recursive function that calculates the score of a `formData` against the given `schema`. The computation is fairly\n * simple. Initially the total score is 0. When `schema.properties` object exists, then all the `key/value` pairs within\n * the object are processed as follows after obtaining the formValue from `formData` using the `key`:\n * - If the `value` contains a `$ref`, `calculateIndexScore()` is called recursively with the formValue and the new\n * schema that is the result of the ref in the schema being resolved and that sub-schema's resulting score is added to\n * the total.\n * - If the `value` contains a `oneOf` and there is a formValue, then score based on the index returned from calling\n * `getClosestMatchingOption()` of that oneOf.\n * - If the type of the `value` is 'object', `calculateIndexScore()` is called recursively with the formValue and the\n * `value` itself as the sub-schema, and the score is added to the total.\n * - If the type of the `value` matches the guessed-type of the `formValue`, the score is incremented by 1, UNLESS the\n * value has a `default` or `const`. In those case, if the `default` or `const` and the `formValue` match, the score\n * is incremented by another 1 otherwise it is decremented by 1.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param schema - The schema for which the score is being calculated\n * @param formData - The form data associated with the schema, used to calculate the score\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The score a schema against the formData\n */\nexport function calculateIndexScore<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema?: S,\n formData?: any,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): number {\n let totalScore = 0;\n if (schema) {\n if (isObject(schema.properties)) {\n totalScore += reduce(\n schema.properties,\n (score, value, key) => {\n const formValue = get(formData, key);\n if (typeof value === 'boolean') {\n return score;\n }\n if (has(value, REF_KEY)) {\n const newSchema = retrieveSchema<T, S, F>(\n validator,\n value as S,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n return (\n score +\n calculateIndexScore<T, S, F>(\n validator,\n rootSchema,\n newSchema,\n formValue || {},\n experimental_customMergeAllOf,\n )\n );\n }\n if ((has(value, ONE_OF_KEY) || has(value, ANY_OF_KEY)) && formValue) {\n const key = has(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;\n const discriminator = getDiscriminatorFieldFromSchema<S>(value as S);\n return (\n score +\n getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema,\n formValue,\n get(value, key) as S[],\n -1,\n discriminator,\n experimental_customMergeAllOf,\n )\n );\n }\n if (value.type === 'object') {\n if (isObject(formValue)) {\n // If the structure is matching then give it a little boost in score\n score += 1;\n }\n return (\n score +\n calculateIndexScore<T, S, F>(validator, rootSchema, value as S, formValue, experimental_customMergeAllOf)\n );\n }\n if (value.type === guessType(formValue)) {\n // If the types match, then we bump the score by one\n let newScore = score + 1;\n if (value.default) {\n // If the schema contains a readonly default value score the value that matches the default higher and\n // any non-matching value lower\n newScore += formValue === value.default ? 1 : -1;\n } else if (value.const) {\n // If the schema contains a const value score the value that matches the default higher and\n // any non-matching value lower\n newScore += formValue === value.const ? 1 : -1;\n }\n // TODO eventually, deal with enums/arrays\n return newScore;\n }\n return score;\n },\n 0,\n );\n } else if (isString(schema.type) && schema.type === guessType(formData)) {\n totalScore += 1;\n }\n }\n return totalScore;\n}\n\n/** Determines which of the given `options` provided most closely matches the `formData`. Using\n * `getFirstMatchingOption()` to match two schemas that differ only by the readOnly, default or const value of a field\n * based on the `formData` and returns 0 when there is no match. Rather than passing in all the `options` at once to\n * this utility, instead an array of valid option indexes is created by iterating over the list of options, call\n * `getFirstMatchingOptions` with a list of one junk option and one good option, seeing if the good option is considered\n * matched.\n *\n * Once the list of valid indexes is created, if there is only one valid index, just return it. Otherwise, if there are\n * no valid indexes, then fill the valid indexes array with the indexes of all the options. Next, the index of the\n * option with the highest score is determined by iterating over the list of valid options, calling\n * `calculateIndexScore()` on each, comparing it against the current best score, and returning the index of the one that\n * eventually has the best score.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param formData - The form data associated with the schema\n * @param options - The list of options that can be selected from\n * @param [selectedOption=-1] - The index of the currently selected option, defaulted to -1 if not specified\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match\n */\nexport default function getClosestMatchingOption<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n formData: T | undefined,\n options: S[],\n selectedOption = -1,\n discriminatorField?: string,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): number {\n // First resolve any refs in the options\n const resolvedOptions = options.map((option) => {\n return resolveAllReferences<S>(option, rootSchema, []);\n });\n\n const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);\n if (isNumber(simpleDiscriminatorMatch)) {\n return simpleDiscriminatorMatch;\n }\n\n // Reduce the array of options down to a list of the indexes that are considered matching options\n const allValidIndexes = resolvedOptions.reduce((validList: number[], option, index: number) => {\n const testOptions: S[] = [JUNK_OPTION as S, option];\n const match = getFirstMatchingOption<T, S, F>(validator, formData, testOptions, rootSchema, discriminatorField);\n // The match is the real option, so add its index to list of valid indexes\n if (match === 1) {\n validList.push(index);\n }\n return validList;\n }, []);\n\n // There is only one valid index, so return it!\n if (allValidIndexes.length === 1) {\n return allValidIndexes[0];\n }\n if (!allValidIndexes.length) {\n // No indexes were valid, so we'll score all the options, add all the indexes\n times(resolvedOptions.length, (i) => allValidIndexes.push(i));\n }\n type BestType = { bestIndex: number; bestScore: number };\n const scoreCount = new Set<number>();\n // Score all the options in the list of valid indexes and return the index with the best score\n const { bestIndex }: BestType = allValidIndexes.reduce(\n (scoreData: BestType, index: number) => {\n const { bestScore } = scoreData;\n const option = resolvedOptions[index];\n const score = calculateIndexScore(validator, rootSchema, option, formData, experimental_customMergeAllOf);\n scoreCount.add(score);\n if (score > bestScore) {\n return { bestIndex: index, bestScore: score };\n }\n return scoreData;\n },\n { bestIndex: selectedOption, bestScore: 0 },\n );\n // if all scores are the same go with selectedOption\n if (scoreCount.size === 1 && selectedOption >= 0) {\n return selectedOption;\n }\n\n return bestIndex;\n}\n", "import isObject from './isObject';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array\n * that only contains objects.\n *\n * @param schema - The schema in which to check for fixed items\n * @returns - True if there are fixed items in the schema, false otherwise\n */\nexport default function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));\n}\n", "import get from 'lodash/get';\n\nimport isObject from './isObject';\nimport { GenericObjectType } from '../src';\nimport isNil from 'lodash/isNil';\n\n/** Merges the `defaults` object of type `T` into the `formData` of type `T`\n *\n * When merging defaults and form data, we want to merge in this specific way:\n * - objects are deeply merged\n * - arrays are merged in such a way that:\n * - when the array is set in form data, only array entries set in form data\n * are deeply merged; additional entries from the defaults are ignored unless `mergeExtraArrayDefaults` is true, in\n * which case the extras are appended onto the end of the form data\n * - when the array is not set in form data, the default is copied over\n * - scalars are overwritten/set by form data unless undefined and there is a default AND `defaultSupercedesUndefined`\n * is true\n *\n * @param [defaults] - The defaults to merge\n * @param [formData] - The form data into which the defaults will be merged\n * @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData\n * @param [defaultSupercedesUndefined=false] - If true, an explicit undefined value will be overwritten by the default value\n * @param [overrideFormDataWithDefaults=false] - If true, the default value will overwrite the form data value. If the value\n * doesn't exist in the default, we take it from formData and in the case where the value is set to undefined in formData.\n * This is useful when we have already merged formData with defaults and want to add an additional field from formData\n * that does not exist in defaults.\n * @returns - The resulting merged form data with defaults\n */\nexport default function mergeDefaultsWithFormData<T = any>(\n defaults?: T,\n formData?: T,\n mergeExtraArrayDefaults = false,\n defaultSupercedesUndefined = false,\n overrideFormDataWithDefaults = false,\n): T | undefined {\n if (Array.isArray(formData)) {\n const defaultsArray = Array.isArray(defaults) ? defaults : [];\n\n // If overrideFormDataWithDefaults is true, we want to override the formData with the defaults\n const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;\n const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;\n\n const mapped = overrideArray.map((value, idx) => {\n // We want to explicitly make sure that the value is NOT undefined since null, 0 and empty space are valid values\n if (overrideOppositeArray[idx] !== undefined) {\n return mergeDefaultsWithFormData<any>(\n defaultsArray[idx],\n formData[idx],\n mergeExtraArrayDefaults,\n defaultSupercedesUndefined,\n overrideFormDataWithDefaults,\n );\n }\n return value;\n });\n\n // Merge any extra defaults when mergeExtraArrayDefaults is true\n // Or when overrideFormDataWithDefaults is true and the default array is shorter than the formData array\n if ((mergeExtraArrayDefaults || overrideFormDataWithDefaults) && mapped.length < overrideOppositeArray.length) {\n mapped.push(...overrideOppositeArray.slice(mapped.length));\n }\n return mapped as unknown as T;\n }\n if (isObject(formData)) {\n const acc: { [key in keyof T]: any } = Object.assign({}, defaults); // Prevent mutation of source object.\n return Object.keys(formData as GenericObjectType).reduce((acc, key) => {\n const keyValue = get(formData, key);\n const keyExistsInDefaults = isObject(defaults) && key in (defaults as GenericObjectType);\n const keyExistsInFormData = key in (formData as GenericObjectType);\n acc[key as keyof T] = mergeDefaultsWithFormData<T>(\n defaults ? get(defaults, key) : {},\n keyValue,\n mergeExtraArrayDefaults,\n defaultSupercedesUndefined,\n // overrideFormDataWithDefaults can be true only when the key value exists in defaults\n // Or if the key value doesn't exist in formData\n overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData),\n );\n return acc;\n }, acc);\n }\n\n /**\n * If the defaultSupercedesUndefined flag is true\n * And formData is set to undefined or null and defaults are defined\n * Or if formData is a number and is NaN return defaults\n * Or if overrideFormDataWithDefaults flag is true and formData is set to not undefined/null return defaults\n */\n if (\n (defaultSupercedesUndefined &&\n ((!isNil(defaults) && isNil(formData)) || (typeof formData === 'number' && isNaN(formData)))) ||\n (overrideFormDataWithDefaults && !isNil(formData))\n ) {\n return defaults;\n }\n\n return formData;\n}\n", "import isObject from './isObject';\nimport { GenericObjectType } from './types';\n\n/** Recursively merge deeply nested objects.\n *\n * @param obj1 - The first object to merge\n * @param obj2 - The second object to merge\n * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use\n * \"preventDuplicates\" to merge arrays in a manner that prevents any duplicate entries from being merged.\n * NOTE: Uses shallow comparison for the duplicate checking.\n * @returns - A new object that is the merge of the two given objects\n */\nexport default function mergeObjects(\n obj1: GenericObjectType,\n obj2: GenericObjectType,\n concatArrays: boolean | 'preventDuplicates' = false,\n) {\n return Object.keys(obj2).reduce(\n (acc, key) => {\n const left = obj1 ? obj1[key] : {},\n right = obj2[key];\n if (obj1 && key in obj1 && isObject(right)) {\n acc[key] = mergeObjects(left, right, concatArrays);\n } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {\n let toMerge = right;\n if (concatArrays === 'preventDuplicates') {\n toMerge = right.reduce((result, value) => {\n if (!left.includes(value)) {\n result.push(value);\n }\n return result;\n }, []);\n }\n acc[key] = left.concat(toMerge);\n } else {\n acc[key] = right;\n }\n return acc;\n },\n Object.assign({}, obj1),\n ); // Prevent mutation of source object.\n}\n", "import { CONST_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has\n * an `enum` array with a single value or there is a `const` defined.\n *\n * @param schema - The schema for a field\n * @returns - True if the `schema` has a single constant value, false otherwise\n */\nexport default function isConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return (Array.isArray(schema.enum) && schema.enum.length === 1) || CONST_KEY in schema;\n}\n", "import isConstant from '../isConstant';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType, Experimental_CustomMergeAllOf } from '../types';\nimport retrieveSchema from './retrieveSchema';\n\n/** Checks to see if the `schema` combination represents a select\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which check for a select flag is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema contains a select, otherwise false\n */\nexport default function isSelect<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n rootSchema: S = {} as S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n const schema = retrieveSchema<T, S, F>(validator, theSchema, rootSchema, undefined, experimental_customMergeAllOf);\n const altSchemas = schema.oneOf || schema.anyOf;\n if (Array.isArray(schema.enum)) {\n return true;\n }\n if (Array.isArray(altSchemas)) {\n return altSchemas.every((altSchemas) => typeof altSchemas !== 'boolean' && isConstant(altSchemas));\n }\n return false;\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType, Experimental_CustomMergeAllOf } from '../types';\n\nimport isSelect from './isSelect';\n\n/** Checks to see if the `schema` combination represents a multi-select\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which check for a multi-select flag is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema contains a multi-select, otherwise false\n */\nexport default function isMultiSelect<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema?: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (!schema.uniqueItems || !schema.items || typeof schema.items === 'boolean') {\n return false;\n }\n return isSelect<T, S, F>(validator, schema.items as S, rootSchema, experimental_customMergeAllOf);\n}\n", "import { CONST_KEY, getSchemaType, isObject } from './';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport { JSONSchema7Type } from 'json-schema';\nimport isString from 'lodash/isString';\n\n/**\n * Checks if the schema const property value is an AJV $data reference\n * and the current schema is not an object or array\n *\n * @param schema - The schema to check if the const is an AJV $data reference\n * @returns - true if the schema const property value is an AJV $data reference otherwise false.\n */\nexport default function constIsAjvDataReference<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {\n const schemaConst = schema[CONST_KEY] as JSONSchema7Type & { $data: string };\n const schemaType = getSchemaType<S>(schema);\n return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== 'object' && schemaType !== 'array';\n}\n", "import get from 'lodash/get';\n\nimport { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from './constants';\nimport getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';\nimport getUiOptions from './getUiOptions';\nimport toConstant from './toConstant';\nimport { RJSFSchema, EnumOptionsType, StrictRJSFSchema, FormContextType, UiSchema } from './types';\n\n/** Gets the list of options from the `schema`. If the schema has an enum list, then those enum values are returned. The\n * label will be the same as the `value`.\n *\n * If the schema has a `oneOf` or `anyOf`, then the value is the list of either:\n * - The `const` values from the schema if present\n * - If the schema has a discriminator and the label using either the `schema.title` or the value. If a `uiSchema` is\n * provided, and it has the `ui:enumNames` matched with `enum` or it has an associated `oneOf` or `anyOf` with a list of\n * objects containing `ui:title` then the UI schema values will replace the values from the schema.\n *\n * @param schema - The schema from which to extract the options list\n * @param [uiSchema] - The optional uiSchema from which to get alternate labels for the options\n * @returns - The list of options from the schema\n */\nexport default function optionsList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: S,\n uiSchema?: UiSchema<T, S, F>,\n): EnumOptionsType<S>[] | undefined {\n if (schema.enum) {\n let enumNames: string[] | undefined;\n if (uiSchema) {\n const { enumNames: uiEnumNames } = getUiOptions<T, S, F>(uiSchema);\n enumNames = uiEnumNames;\n }\n return schema.enum.map((value, i) => {\n const label = enumNames?.[i] || String(value);\n return { label, value };\n });\n }\n let altSchemas: S['anyOf'] | S['oneOf'] = undefined;\n let altUiSchemas: UiSchema<T, S, F> | undefined = undefined;\n if (schema.anyOf) {\n altSchemas = schema.anyOf;\n altUiSchemas = uiSchema?.anyOf;\n } else if (schema.oneOf) {\n altSchemas = schema.oneOf;\n altUiSchemas = uiSchema?.oneOf;\n }\n // See if there is a discriminator path specified in the schema, and if so, use it as the selectorField, otherwise\n // pull one from the uiSchema\n let selectorField = getDiscriminatorFieldFromSchema<S>(schema);\n if (uiSchema) {\n const { optionsSchemaSelector = selectorField } = getUiOptions<T, S, F>(uiSchema);\n selectorField = optionsSchemaSelector;\n }\n return (\n altSchemas &&\n altSchemas.map((aSchemaDef, index) => {\n const { title } = getUiOptions<T, S, F>(altUiSchemas?.[index]);\n const aSchema = aSchemaDef as S;\n let value: EnumOptionsType<S>['value'];\n let label = title;\n if (selectorField) {\n const innerSchema: S = get(aSchema, [PROPERTIES_KEY, selectorField], {}) as S;\n value = get(innerSchema, DEFAULT_KEY, get(innerSchema, CONST_KEY));\n label = label || innerSchema?.title || aSchema.title || String(value);\n } else {\n value = toConstant(aSchema);\n label = label || aSchema.title || String(value);\n }\n return {\n schema: aSchema,\n label,\n value,\n };\n })\n );\n}\n", "import { CONST_KEY, ENUM_KEY } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise\n * throws an error.\n *\n * @param schema - The schema from which to obtain the constant value\n * @returns - The constant value for the schema\n * @throws - Error when the schema does not have a constant value\n */\nexport default function toConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {\n return schema.enum[0];\n }\n if (CONST_KEY in schema) {\n return schema.const;\n }\n throw new Error('schema cannot be inferred as a constant');\n}\n", "import getUiOptions from './getUiOptions';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';\n\n/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`\n *\n * @param uiSchema - The UI Schema from which to detect if it is customized\n * @returns - True if the `uiSchema` describes a custom widget, false otherwise\n */\nexport default function isCustomWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(uiSchema: UiSchema<T, S, F> = {}) {\n return (\n // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.\n // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets\n 'widget' in getUiOptions<T, S, F>(uiSchema) && getUiOptions<T, S, F>(uiSchema)['widget'] !== 'hidden'\n );\n}\n", "import { UI_WIDGET_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n} from '../types';\nimport retrieveSchema from './retrieveSchema';\n\n/** Checks to see if the `schema` and `uiSchema` combination represents an array of files\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which check for array of files flag is desired\n * @param [uiSchema={}] - The UI schema from which to check the widget\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if schema/uiSchema contains an array of files, otherwise false\n */\nexport default function isFilesArray<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n uiSchema: UiSchema<T, S, F> = {},\n rootSchema?: S,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n) {\n if (uiSchema[UI_WIDGET_KEY] === 'files') {\n return true;\n }\n if (schema.items) {\n const itemsSchema = retrieveSchema<T, S, F>(\n validator,\n schema.items as S,\n rootSchema,\n undefined,\n experimental_customMergeAllOf,\n );\n return itemsSchema.type === 'string' && itemsSchema.format === 'data-url';\n }\n return false;\n}\n", "import { UI_FIELD_KEY, UI_WIDGET_KEY } from '../constants';\nimport getSchemaType from '../getSchemaType';\nimport getUiOptions from '../getUiOptions';\nimport isCustomWidget from '../isCustomWidget';\nimport {\n FormContextType,\n GlobalUISchemaOptions,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n Experimental_CustomMergeAllOf,\n} from '../types';\nimport isFilesArray from './isFilesArray';\nimport isMultiSelect from './isMultiSelect';\n\n/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`\n * should be displayed in a UI.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the display label flag is desired\n * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if the label should be displayed or false if it should not\n */\nexport default function getDisplayLabel<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n uiSchema: UiSchema<T, S, F> = {},\n rootSchema?: S,\n globalOptions?: GlobalUISchemaOptions,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): boolean {\n const uiOptions = getUiOptions<T, S, F>(uiSchema, globalOptions);\n const { label = true } = uiOptions;\n let displayLabel = !!label;\n const schemaType = getSchemaType<S>(schema);\n\n if (schemaType === 'array') {\n displayLabel =\n isMultiSelect<T, S, F>(validator, schema, rootSchema, experimental_customMergeAllOf) ||\n isFilesArray<T, S, F>(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) ||\n isCustomWidget(uiSchema);\n }\n\n if (schemaType === 'object') {\n displayLabel = false;\n }\n if (schemaType === 'boolean' && !uiSchema[UI_WIDGET_KEY]) {\n displayLabel = false;\n }\n if (uiSchema[UI_FIELD_KEY]) {\n displayLabel = false;\n }\n return displayLabel;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport { PROPERTIES_KEY, REF_KEY } from '../constants';\nimport retrieveSchema from './retrieveSchema';\n\nconst NO_VALUE = Symbol('no Value');\n\n/** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new\n * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature\n * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema\n * that are non-existent in the new schema are set to `undefined`. The data sanitization process has the following flow:\n *\n * - If the new schema is an object that contains a `properties` object then:\n * - Create a `removeOldSchemaData` object, setting each key in the `oldSchema.properties` having `data` to undefined\n * - Create an empty `nestedData` object for use in the key filtering below:\n * - Iterate over each key in the `newSchema.properties` as follows:\n * - Get the `formValue` of the key from the `data`\n * - Get the `oldKeySchema` and `newKeyedSchema` for the key, defaulting to `{}` when it doesn't exist\n * - Retrieve the schema for any refs within each `oldKeySchema` and/or `newKeySchema`\n * - Get the types of the old and new keyed schemas and if the old doesn't exist or the old & new are the same then:\n * - If `removeOldSchemaData` has an entry for the key, delete it since the new schema has the same property\n * - If type of the key in the new schema is `object`:\n * - Store the value from the recursive `sanitizeDataForNewSchema` call in `nestedData[key]`\n * - Otherwise, check for default or const values:\n * - Get the old and new `default` values from the schema and check:\n * - If the new `default` value does not match the form value:\n * - If the old `default` value DOES match the form value, then:\n * - Replace `removeOldSchemaData[key]` with the new `default`\n * - Otherwise, if the new schema is `readOnly` then replace `removeOldSchemaData[key]` with undefined\n * - Get the old and new `const` values from the schema and check:\n * - If the new `const` value does not match the form value:\n * - If the old `const` value DOES match the form value, then:\n * - Replace `removeOldSchemaData[key]` with the new `const`\n * - Otherwise, replace `removeOldSchemaData[key]` with undefined\n * - Once all keys have been processed, return an object built as follows:\n * - `{ ...removeOldSchemaData, ...nestedData, ...pick(data, keysToKeep) }`\n * - If the new and old schema types are array and the `data` is an array then:\n * - If the type of the old and new schema `items` are a non-array objects:\n * - Retrieve the schema for any refs within each `oldKeySchema.items` and/or `newKeySchema.items`\n * - If the `type`s of both items are the same (or the old does not have a type):\n * - If the type is \"object\", then:\n * - For each element in the `data` recursively sanitize the data, stopping at `maxItems` if specified\n * - Otherwise, just return the `data` removing any values after `maxItems` if it is set\n * - If the type of the old and new schema `items` are booleans of the same value, return `data` as is\n * - Otherwise return `undefined`\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param rootSchema - The root JSON schema of the entire form\n * @param [newSchema] - The new schema for which the data is being sanitized\n * @param [oldSchema] - The old schema from which the data originated\n * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The new form data, with all the fields uniquely associated with the old schema set\n * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.\n */\nexport default function sanitizeDataForNewSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n newSchema?: S,\n oldSchema?: S,\n data: any = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): T {\n // By default, we will clear the form data\n let newFormData;\n // If the new schema is of type object and that object contains a list of properties\n if (has(newSchema, PROPERTIES_KEY)) {\n // Create an object containing root-level keys in the old schema, setting each key to undefined to remove the data\n const removeOldSchemaData: GenericObjectType = {};\n if (has(oldSchema, PROPERTIES_KEY)) {\n const properties = get(oldSchema, PROPERTIES_KEY, {});\n Object.keys(properties).forEach((key) => {\n if (has(data, key)) {\n removeOldSchemaData[key] = undefined;\n }\n });\n }\n const keys: string[] = Object.keys(get(newSchema, PROPERTIES_KEY, {}));\n // Create a place to store nested data that will be a side-effect of the filter\n const nestedData: GenericObjectType = {};\n keys.forEach((key) => {\n const formValue = get(data, key);\n let oldKeyedSchema: S = get(oldSchema, [PROPERTIES_KEY, key], {}) as S;\n let newKeyedSchema: S = get(newSchema, [PROPERTIES_KEY, key], {}) as S;\n // Resolve the refs if they exist\n if (has(oldKeyedSchema, REF_KEY)) {\n oldKeyedSchema = retrieveSchema<T, S, F>(\n validator,\n oldKeyedSchema,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n }\n if (has(newKeyedSchema, REF_KEY)) {\n newKeyedSchema = retrieveSchema<T, S, F>(\n validator,\n newKeyedSchema,\n rootSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n }\n // Now get types and see if they are the same\n const oldSchemaTypeForKey = get(oldKeyedSchema, 'type');\n const newSchemaTypeForKey = get(newKeyedSchema, 'type');\n // Check if the old option has the same key with the same type\n if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {\n if (has(removeOldSchemaData, key)) {\n // SIDE-EFFECT: remove the undefined value for a key that has the same type between the old and new schemas\n delete removeOldSchemaData[key];\n }\n // If it is an object, we'll recurse and store the resulting sanitized data for the key\n if (newSchemaTypeForKey === 'object' || (newSchemaTypeForKey === 'array' && Array.isArray(formValue))) {\n // SIDE-EFFECT: process the new schema type of object recursively to save iterations\n const itemData = sanitizeDataForNewSchema<T, S, F>(\n validator,\n rootSchema,\n newKeyedSchema,\n oldKeyedSchema,\n formValue,\n experimental_customMergeAllOf,\n );\n if (itemData !== undefined || newSchemaTypeForKey === 'array') {\n // only put undefined values for the array type and not the object type\n nestedData[key] = itemData;\n }\n } else {\n // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced\n // with the new default or const. This allows the case where two schemas differ that only by the default/const\n // value to be properly selected\n const newOptionDefault = get(newKeyedSchema, 'default', NO_VALUE);\n const oldOptionDefault = get(oldKeyedSchema, 'default', NO_VALUE);\n if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {\n if (oldOptionDefault === formValue) {\n // If the old default matches the formValue, we'll update the new value to match the new default\n removeOldSchemaData[key] = newOptionDefault;\n } else if (get(newKeyedSchema, 'readOnly') === true) {\n // If the new schema has the default set to read-only, treat it like a const and remove the value\n removeOldSchemaData[key] = undefined;\n }\n }\n\n const newOptionConst = get(newKeyedSchema, 'const', NO_VALUE);\n const oldOptionConst = get(oldKeyedSchema, 'const', NO_VALUE);\n if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {\n // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it\n removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;\n }\n }\n }\n });\n\n newFormData = {\n ...(typeof data == 'string' || Array.isArray(data) ? undefined : data),\n ...removeOldSchemaData,\n ...nestedData,\n };\n // First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep\n } else if (get(oldSchema, 'type') === 'array' && get(newSchema, 'type') === 'array' && Array.isArray(data)) {\n let oldSchemaItems = get(oldSchema, 'items');\n let newSchemaItems = get(newSchema, 'items');\n // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data\n // Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations\n if (\n typeof oldSchemaItems === 'object' &&\n typeof newSchemaItems === 'object' &&\n !Array.isArray(oldSchemaItems) &&\n !Array.isArray(newSchemaItems)\n ) {\n if (has(oldSchemaItems, REF_KEY)) {\n oldSchemaItems = retrieveSchema<T, S, F>(\n validator,\n oldSchemaItems as S,\n rootSchema,\n data as T,\n experimental_customMergeAllOf,\n );\n }\n if (has(newSchemaItems, REF_KEY)) {\n newSchemaItems = retrieveSchema<T, S, F>(\n validator,\n newSchemaItems as S,\n rootSchema,\n data as T,\n experimental_customMergeAllOf,\n );\n }\n // Now get types and see if they are the same\n const oldSchemaType = get(oldSchemaItems, 'type');\n const newSchemaType = get(newSchemaItems, 'type');\n // Check if the old option has the same key with the same type\n if (!oldSchemaType || oldSchemaType === newSchemaType) {\n const maxItems = get(newSchema, 'maxItems', -1);\n if (newSchemaType === 'object') {\n newFormData = data.reduce((newValue, aValue) => {\n const itemValue = sanitizeDataForNewSchema<T, S, F>(\n validator,\n rootSchema,\n newSchemaItems as S,\n oldSchemaItems as S,\n aValue,\n experimental_customMergeAllOf,\n );\n if (itemValue !== undefined && (maxItems < 0 || newValue.length < maxItems)) {\n newValue.push(itemValue);\n }\n return newValue;\n }, []);\n } else {\n newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;\n }\n }\n } else if (\n typeof oldSchemaItems === 'boolean' &&\n typeof newSchemaItems === 'boolean' &&\n oldSchemaItems === newSchemaItems\n ) {\n // If they are both booleans and have the same value just return the data as is otherwise fall-thru to undefined\n newFormData = data;\n }\n // Also probably want to deal with `prefixItems` as tuples with the latest 2020 draft\n }\n return newFormData as T;\n}\n", "import get from 'lodash/get';\n\nimport { ALL_OF_KEY, DEPENDENCIES_KEY, ID_KEY, ITEMS_KEY, PROPERTIES_KEY, REF_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n IdSchema,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport retrieveSchema from './retrieveSchema';\nimport getSchemaType from '../getSchemaType';\nimport deepEquals from '../deepEquals';\n\n/** An internal helper that generates an `IdSchema` object for the `schema`, recursively with protection against\n * infinite recursion\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `IdSchema` is desired\n * @param idPrefix - The prefix to use for the id\n * @param idSeparator - The separator to use for the path segments in the id\n * @param [id] - The base id for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `IdSchema` object for the `schema`\n */\nfunction toIdSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n idPrefix: string,\n idSeparator: string,\n id?: string | null,\n rootSchema?: S,\n formData?: T,\n _recurseList: S[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): IdSchema<T> {\n const $id = id || idPrefix;\n const idSchema: IdSchema<T> = { $id } as IdSchema<T>;\n if (typeof schema === 'object') {\n if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {\n const _schema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);\n const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));\n if (sameSchemaIndex === -1) {\n return toIdSchemaInternal<T, S, F>(\n validator,\n _schema,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n _recurseList.concat(_schema),\n experimental_customMergeAllOf,\n );\n }\n }\n if (ITEMS_KEY in schema && !get(schema, [ITEMS_KEY, REF_KEY])) {\n return toIdSchemaInternal<T, S, F>(\n validator,\n get(schema, ITEMS_KEY) as S,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n if (getSchemaType<S>(schema) === 'object' && PROPERTIES_KEY in schema) {\n for (const name in schema.properties) {\n const field: S = schema[PROPERTIES_KEY][name] as S;\n const fieldId = idSchema[ID_KEY] + idSeparator + name;\n (idSchema as IdSchema<GenericObjectType>)[name] = toIdSchemaInternal<T, S, F>(\n validator,\n field,\n idPrefix,\n idSeparator,\n fieldId,\n rootSchema,\n // It's possible that formData is not an object -- this can happen if an\n // array item has just been added, but not populated with data yet\n get(formData, [name]),\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n }\n }\n return idSchema;\n}\n\n/** Generates an `IdSchema` object for the `schema`, recursively\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `IdSchema` is desired\n * @param [id] - The base id for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [idPrefix='root'] - The prefix to use for the id\n * @param [idSeparator='_'] - The separator to use for the path segments in the id\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `IdSchema` object for the `schema`\n */\nexport default function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n id?: string | null,\n rootSchema?: S,\n formData?: T,\n idPrefix = 'root',\n idSeparator = '_',\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): IdSchema<T> {\n return toIdSchemaInternal<T, S, F>(\n validator,\n schema,\n idPrefix,\n idSeparator,\n id,\n rootSchema,\n formData,\n undefined,\n experimental_customMergeAllOf,\n );\n}\n", "import get from 'lodash/get';\nimport set from 'lodash/set';\n\nimport {\n ADDITIONAL_PROPERTIES_KEY,\n ALL_OF_KEY,\n ANY_OF_KEY,\n DEPENDENCIES_KEY,\n ITEMS_KEY,\n NAME_KEY,\n ONE_OF_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n RJSF_ADDITIONAL_PROPERTIES_FLAG,\n} from '../constants';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n PathSchema,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport getClosestMatchingOption from './getClosestMatchingOption';\nimport retrieveSchema from './retrieveSchema';\nimport deepEquals from '../deepEquals';\n\n/** An internal helper that generates an `PathSchema` object for the `schema`, recursively with protection against\n * infinite recursion\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `PathSchema` is desired\n * @param [name=''] - The base name for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `PathSchema` object for the `schema`\n */\nfunction toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n name: string,\n rootSchema?: S,\n formData?: T,\n _recurseList: S[] = [],\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): PathSchema<T> {\n if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {\n const _schema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);\n const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));\n if (sameSchemaIndex === -1) {\n return toPathSchemaInternal<T, S, F>(\n validator,\n _schema,\n name,\n rootSchema,\n formData,\n _recurseList.concat(_schema),\n experimental_customMergeAllOf,\n );\n }\n }\n\n let pathSchema: PathSchema<T> = {\n [NAME_KEY]: name.replace(/^\\./, ''),\n } as PathSchema<T>;\n\n if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {\n const xxxOf: S[] = ONE_OF_KEY in schema ? (schema.oneOf as S[]) : (schema.anyOf as S[]);\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const index = getClosestMatchingOption<T, S, F>(\n validator,\n rootSchema!,\n formData,\n xxxOf,\n 0,\n discriminator,\n experimental_customMergeAllOf,\n );\n const _schema: S = xxxOf![index] as S;\n pathSchema = {\n ...pathSchema,\n ...toPathSchemaInternal<T, S, F>(\n validator,\n _schema,\n name,\n rootSchema,\n formData,\n _recurseList,\n experimental_customMergeAllOf,\n ),\n };\n }\n\n if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {\n set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);\n }\n\n if (ITEMS_KEY in schema && Array.isArray(formData)) {\n const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;\n\n if (Array.isArray(schemaItems)) {\n formData.forEach((element, i: number) => {\n if (schemaItems[i]) {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaItems[i] as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n } else if (schemaAdditionalItems) {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaAdditionalItems as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n } else {\n console.warn(`Unable to generate path schema for \"${name}.${i}\". No schema defined for it`);\n }\n });\n } else {\n formData.forEach((element, i: number) => {\n (pathSchema as PathSchema<T[]>)[i] = toPathSchemaInternal<T, S, F>(\n validator,\n schemaItems as S,\n `${name}.${i}`,\n rootSchema,\n element,\n _recurseList,\n experimental_customMergeAllOf,\n );\n });\n }\n } else if (PROPERTIES_KEY in schema) {\n for (const property in schema.properties) {\n const field: S = get(schema, [PROPERTIES_KEY, property], {}) as S;\n (pathSchema as PathSchema<GenericObjectType>)[property] = toPathSchemaInternal<T, S, F>(\n validator,\n field,\n `${name}.${property}`,\n rootSchema,\n // It's possible that formData is not an object -- this can happen if an\n // array item has just been added, but not populated with data yet\n get(formData, [property]),\n _recurseList,\n experimental_customMergeAllOf,\n );\n }\n }\n return pathSchema;\n}\n\n/** Generates an `PathSchema` object for the `schema`, recursively\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param schema - The schema for which the `PathSchema` is desired\n * @param [name=''] - The base name for the schema\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The `PathSchema` object for the `schema`\n */\nexport default function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n name = '',\n rootSchema?: S,\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): PathSchema<T> {\n return toPathSchemaInternal(validator, schema, name, rootSchema, formData, undefined, experimental_customMergeAllOf);\n}\n", "import deepEquals from './deepEquals';\nimport {\n Experimental_CustomMergeAllOf,\n Experimental_DefaultFormStateBehavior,\n FormContextType,\n FoundFieldType,\n GlobalUISchemaOptions,\n IdSchema,\n PathSchema,\n RJSFSchema,\n SchemaUtilsType,\n StrictRJSFSchema,\n UiSchema,\n ValidatorType,\n} from './types';\nimport {\n findFieldInSchema,\n findSelectedOptionInXxxOf,\n getDefaultFormState,\n getDisplayLabel,\n getClosestMatchingOption,\n getFirstMatchingOption,\n getFromSchema,\n isFilesArray,\n isMultiSelect,\n isSelect,\n retrieveSchema,\n sanitizeDataForNewSchema,\n toIdSchema,\n toPathSchema,\n} from './schema';\n\n/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such\n * that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or\n * `experimental_customMergeAllOf` to each method. Since these generally do not change across a `Form`, this allows for\n * providing a simplified set of APIs to the `@rjsf/core` components and the various themes as well. This class\n * implements the `SchemaUtilsType` interface.\n */\nclass SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements SchemaUtilsType<T, S, F>\n{\n rootSchema: S;\n validator: ValidatorType<T, S, F>;\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior;\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;\n\n /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n */\n constructor(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n ) {\n this.rootSchema = rootSchema;\n this.validator = validator;\n this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;\n this.experimental_customMergeAllOf = experimental_customMergeAllOf;\n }\n\n /** Returns the `ValidatorType` in the `SchemaUtilsType`\n *\n * @returns - The `ValidatorType`\n */\n getValidator() {\n return this.validator;\n }\n\n /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of\n * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation\n * of a new `SchemaUtilsType` with incomplete properties.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one\n * @param rootSchema - The root schema that will be compared against the current one\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`\n */\n doesSchemaUtilsDiffer(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n ): boolean {\n if (!validator || !rootSchema) {\n return false;\n }\n return (\n this.validator !== validator ||\n !deepEquals(this.rootSchema, rootSchema) ||\n !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) ||\n this.experimental_customMergeAllOf !== experimental_customMergeAllOf\n );\n }\n\n /** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified\n * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf\n * field is in the `required` list for its parent and if so, it is marked as required on return.\n *\n * @param schema - The current node within the JSON schema\n * @param path - The remaining keys in the path to the desired field\n * @param [formData] - The form data that is used to determine which oneOf option\n * @returns - An object that contains the field and its required state. If no field can be found then\n * `{ field: undefined, isRequired: undefined }` is returned.\n */\n findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S> {\n return findFieldInSchema(\n this.validator,\n this.rootSchema,\n schema,\n path,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that\n * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either\n * `schema.discriminator.propertyName` or `fallbackField`.\n *\n * @param schema - The schema element in which to search for the selected oneOf option\n * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field\n * @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought\n * @param [formData={}] - The form data that is used to determine which oneOf option\n * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected\n */\n findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData: T): S | undefined {\n return findSelectedOptionInXxxOf(\n this.validator,\n this.rootSchema,\n schema,\n fallbackField,\n xxx,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have\n * computed to have defaults provided in the `schema`.\n *\n * @param schema - The schema for which the default state is desired\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.\n * If \"excludeObjectChildren\", pass `includeUndefinedValues` as false when computing defaults for any nested\n * object properties.\n * @returns - The resulting `formData` with all the defaults provided\n */\n getDefaultFormState(\n schema: S,\n formData?: T,\n includeUndefinedValues: boolean | 'excludeObjectChildren' = false,\n ): T | T[] | undefined {\n return getDefaultFormState<T, S, F>(\n this.validator,\n schema,\n formData,\n this.rootSchema,\n includeUndefinedValues,\n this.experimental_defaultFormStateBehavior,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`\n * should be displayed in a UI.\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [uiSchema] - The UI schema from which to derive potentially displayable information\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @returns - True if the label should be displayed or false if it should not\n */\n getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions) {\n return getDisplayLabel<T, S, F>(\n this.validator,\n schema,\n uiSchema,\n this.rootSchema,\n globalOptions,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Determines which of the given `options` provided most closely matches the `formData`.\n * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.\n *\n * The closest match is determined using the number of matching properties, and more heavily favors options with\n * matching readOnly, default, or const values.\n *\n * @param formData - The form data associated with the schema\n * @param options - The list of options that can be selected from\n * @param [selectedOption] - The index of the currently selected option, defaulted to -1 if not specified\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match\n */\n getClosestMatchingOption(\n formData: T | undefined,\n options: S[],\n selectedOption?: number,\n discriminatorField?: string,\n ): number {\n return getClosestMatchingOption<T, S, F>(\n this.validator,\n this.rootSchema,\n formData,\n options,\n selectedOption,\n discriminatorField,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.\n * Always returns the first option if there is nothing that matches.\n *\n * @param formData - The current formData, if any, used to figure out a match\n * @param options - The list of options to find a matching options from\n * @param [discriminatorField] - The optional name of the field within the options object whose value is used to\n * determine which option is selected\n * @returns - The firstindex of the matched option or 0 if none is available\n */\n getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number {\n return getFirstMatchingOption<T, S, F>(this.validator, formData, options, this.rootSchema, discriminatorField);\n }\n\n /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas\n * containing potentially nested `$ref`s.\n *\n * @param schema - The current node within the JSON schema recursion\n * @param path - The remaining keys in the path to the desired property\n * @param defaultValue - The value to return if a value is not found for the `pathList` path\n * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found\n */\n getFromSchema(schema: S, path: string | string[], defaultValue: T): T;\n getFromSchema(schema: S, path: string | string[], defaultValue: S): S;\n getFromSchema(schema: S, path: string | string[], defaultValue: T | S): T | S {\n return getFromSchema<T, S, F>(\n this.validator,\n this.rootSchema,\n schema,\n path,\n // @ts-expect-error TS2769: No overload matches this call\n defaultValue,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Checks to see if the `schema` and `uiSchema` combination represents an array of files\n *\n * @param schema - The schema for which check for array of files flag is desired\n * @param [uiSchema] - The UI schema from which to check the widget\n * @returns - True if schema/uiSchema contains an array of files, otherwise false\n */\n isFilesArray(schema: S, uiSchema?: UiSchema<T, S, F>) {\n return isFilesArray<T, S, F>(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Checks to see if the `schema` combination represents a multi-select\n *\n * @param schema - The schema for which check for a multi-select flag is desired\n * @returns - True if schema contains a multi-select, otherwise false\n */\n isMultiSelect(schema: S) {\n return isMultiSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Checks to see if the `schema` combination represents a select\n *\n * @param schema - The schema for which check for a select flag is desired\n * @returns - True if schema contains a select, otherwise false\n */\n isSelect(schema: S) {\n return isSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);\n }\n\n /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and\n * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially\n * recursive resolution.\n *\n * @param schema - The schema for which retrieving a schema is desired\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @returns - The schema having its conditions, additional properties, references and dependencies resolved\n */\n retrieveSchema(schema: S, rawFormData?: T) {\n return retrieveSchema<T, S, F>(\n this.validator,\n schema,\n this.rootSchema,\n rawFormData,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the\n * new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the\n * nature of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the\n * old schemas that are non-existent in the new schema are set to `undefined`.\n *\n * @param [newSchema] - The new schema for which the data is being sanitized\n * @param [oldSchema] - The old schema from which the data originated\n * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined\n * @returns - The new form data, with all the fields uniquely associated with the old schema set\n * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.\n */\n sanitizeDataForNewSchema(newSchema?: S, oldSchema?: S, data?: any): T {\n return sanitizeDataForNewSchema(\n this.validator,\n this.rootSchema,\n newSchema,\n oldSchema,\n data,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Generates an `IdSchema` object for the `schema`, recursively\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [id] - The base id for the schema\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @param [idPrefix='root'] - The prefix to use for the id\n * @param [idSeparator='_'] - The separator to use for the path segments in the id\n * @returns - The `IdSchema` object for the `schema`\n */\n toIdSchema(schema: S, id?: string | null, formData?: T, idPrefix = 'root', idSeparator = '_'): IdSchema<T> {\n return toIdSchema<T, S, F>(\n this.validator,\n schema,\n id,\n this.rootSchema,\n formData,\n idPrefix,\n idSeparator,\n this.experimental_customMergeAllOf,\n );\n }\n\n /** Generates an `PathSchema` object for the `schema`, recursively\n *\n * @param schema - The schema for which the display label flag is desired\n * @param [name] - The base name for the schema\n * @param [formData] - The current formData, if any, onto which to provide any missing defaults\n * @returns - The `PathSchema` object for the `schema`\n */\n toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T> {\n return toPathSchema<T, S, F>(\n this.validator,\n schema,\n name,\n this.rootSchema,\n formData,\n this.experimental_customMergeAllOf,\n );\n }\n}\n\n/** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The\n * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.\n *\n * @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - An implementation of a `SchemaUtilsType` interface\n */\nexport default function createSchemaUtils<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n experimental_defaultFormStateBehavior = {},\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): SchemaUtilsType<T, S, F> {\n return new SchemaUtils<T, S, F>(\n validator,\n rootSchema,\n experimental_defaultFormStateBehavior,\n experimental_customMergeAllOf,\n );\n}\n", "/** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name\n * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.\n *\n * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob\n * @returns - an object containing a Blob and its name, extracted from the URI\n */\nexport default function dataURItoBlob(dataURILike: string) {\n // check if is dataURI\n if (dataURILike.indexOf('data:') === -1) {\n throw new Error('File is invalid: URI must be a dataURI');\n }\n const dataURI = dataURILike.slice(5);\n // split the dataURI into media and base64, with the base64 signature\n const splitted = dataURI.split(';base64,');\n // if the base64 signature is not present, the latter part will become empty\n if (splitted.length !== 2) {\n throw new Error('File is invalid: dataURI must be base64');\n }\n // extract the mime type, media parameters including the name, and the base64 string\n const [media, base64] = splitted;\n const [mime, ...mediaparams] = media.split(';');\n const type = mime || '';\n\n // extract the name from the parameters\n const name = decodeURI(\n // parse the parameters into key-value pairs, find a key, and extract a value\n // if no key is found, then the name is unknown\n mediaparams.map((param) => param.split('=')).find(([key]) => key === 'name')?.[1] || 'unknown',\n );\n\n // Built the Uint8Array Blob parameter from the base64 string.\n try {\n const binary = atob(base64);\n const array = new Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n array[i] = binary.charCodeAt(i);\n }\n // Create the blob object\n const blob = new window.Blob([new Uint8Array(array)], { type });\n\n return { blob, name };\n } catch (error) {\n throw new Error('File is invalid: ' + (error as Error).message);\n }\n}\n", "/** Returns a string representation of the `num` that is padded with leading \"0\"s if necessary\n *\n * @param num - The number to pad\n * @param width - The width of the string at which no lead padding is necessary\n * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`\n */\nexport default function pad(num: number, width: number) {\n let s = String(num);\n while (s.length < width) {\n s = '0' + s;\n }\n return s;\n}\n", "import pad from './pad';\nimport { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns a list of options for a date range between `start` and `stop`. If the start date is greater than the end\n * date, then the date range is reversed. If `start` and `stop` are negative numbers (or zero), then they will be\n * treated as relative to the current year.\n *\n * @param start - The starting point of the date range\n * @param stop - The ending point of the date range\n * @returns - The list of EnumOptionsType for the date range between `start` and `stop`\n * @throws - Error when `start` and `stop` aren't both <= 0 or > 0\n */\nexport default function dateRangeOptions<S extends StrictRJSFSchema = RJSFSchema>(\n start: number,\n stop: number,\n): EnumOptionsType<S>[] {\n if (start <= 0 && stop <= 0) {\n start = new Date().getFullYear() + start;\n stop = new Date().getFullYear() + stop;\n } else if (start < 0 || stop < 0) {\n throw new Error(`Both start (${start}) and stop (${stop}) must both be <= 0 or > 0, got one of each`);\n }\n if (start > stop) {\n return dateRangeOptions<S>(stop, start).reverse();\n }\n const options: EnumOptionsType<S>[] = [];\n for (let i = start; i <= stop; i++) {\n options.push({ value: i, label: pad(i, 2) });\n }\n return options;\n}\n", "/** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When\n * a `params` array is provided, each value in the array is used to replace any of the replaceable parameters in the\n * `inputString` using the `%1`, `%2`, etc. replacement specifiers.\n *\n * @param inputString - The string which will be potentially updated with replacement parameters\n * @param params - The optional list of replaceable parameter values to substitute into the english string\n * @returns - The updated string with any replacement specifiers replaced\n */\nexport default function replaceStringParameters(inputString: string, params?: string[]) {\n let output = inputString;\n if (Array.isArray(params)) {\n const parts = output.split(/(%\\d)/);\n params.forEach((param, index) => {\n const partIndex = parts.findIndex((part) => part === `%${index + 1}`);\n if (partIndex >= 0) {\n parts[partIndex] = param;\n }\n });\n output = parts.join('');\n }\n return output;\n}\n", "import { TranslatableString } from './enums';\nimport replaceStringParameters from './replaceStringParameters';\n\n/** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each\n * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,\n * `%2`, etc. replacement specifiers.\n *\n * @param stringToTranslate - The `TranslatableString` value to convert to english\n * @param params - The optional list of replaceable parameter values to substitute into the english string\n * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted\n */\nexport default function englishStringTranslator(stringToTranslate: TranslatableString, params?: string[]): string {\n return replaceStringParameters(stringToTranslate, params);\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an\n * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it\n * contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only\n * valid values or in the worst case, an empty array.\n *\n * @param valueIndex - The index(es) of the value(s) that should be returned\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @param [emptyValue] - The value to return when the non-array `valueIndex` does not refer to a real option\n * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,\n * `emptyValue` or an empty list.\n */\nexport default function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number | Array<string | number>,\n allEnumOptions: EnumOptionsType<S>[] = [],\n emptyValue?: EnumOptionsType<S>['value'],\n): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined {\n if (Array.isArray(valueIndex)) {\n return (\n valueIndex\n .map((index) => enumOptionsValueForIndex(index, allEnumOptions))\n // Since the recursive call returns `emptyValue` when we get a bad option, only filter those out\n .filter((val) => val !== emptyValue)\n );\n }\n // So Number(null) and Number('') both return 0, so use emptyValue for those two values\n const index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);\n const option = allEnumOptions[index];\n return option ? option.value : emptyValue;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport deepEquals from './deepEquals';\n\n/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is\n * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is\n * a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined\n * is returned, otherwise the `selected` value is returned.\n *\n * @param valueIndex - The index of the value to be removed from the selected list or single value\n * @param selected - The current (list of) selected value(s)\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @returns - The updated `selected` with the enum option value at `valueIndex` in `allEnumOptions` removed from it,\n * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns\n * undefined, otherwise `selected`.\n */\nexport default function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number,\n selected?: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined {\n const value = enumOptionsValueForIndex<S>(valueIndex, allEnumOptions);\n if (Array.isArray(selected)) {\n return selected.filter((v) => !deepEquals(v, value));\n }\n return deepEquals(value, selected) ? undefined : selected;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport deepEquals from './deepEquals';\n\n/** Determines whether the given `value` is (one of) the `selected` value(s).\n *\n * @param value - The value being checked to see if it is selected\n * @param selected - The current selected value or list of values\n * @returns - true if the `value` is one of the `selected` ones, false otherwise\n */\nexport default function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(\n value: EnumOptionsType<S>['value'],\n selected: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n) {\n if (Array.isArray(selected)) {\n return selected.some((sel) => deepEquals(sel, value));\n }\n return deepEquals(selected, value);\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsIsSelected from './enumOptionsIsSelected';\n\n/** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the\n * `enumOptions` are filtered based on whether they are a \"selected\" `value` and the index of each selected one is then\n * stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is\n * returned.\n *\n * @param value - The single value or list of values for which indexes are desired\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @param [multiple=false] - Optional flag, if true will return a list of index, otherwise a single one\n * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list\n * of indexes for (each of) the value(s) in `value`.\n */\nexport default function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(\n value: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n multiple = false,\n): string | string[] | undefined {\n const selectedIndexes: string[] = allEnumOptions\n .map((opt, index) => (enumOptionsIsSelected(opt.value, value) ? String(index) : undefined))\n .filter((opt) => typeof opt !== 'undefined') as string[];\n if (!multiple) {\n return selectedIndexes[0];\n }\n return selectedIndexes;\n}\n", "import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport isNil from 'lodash/isNil';\n\n/** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by\n * `allEnumOptions`\n *\n * @param valueIndex - The index of the value that should be selected\n * @param selected - The current list of selected values\n * @param [allEnumOptions=[]] - The list of all the known enumOptions\n * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it\n */\nexport default function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(\n valueIndex: string | number,\n selected: EnumOptionsType<S>['value'][],\n allEnumOptions: EnumOptionsType<S>[] = [],\n) {\n const value = enumOptionsValueForIndex<S>(valueIndex, allEnumOptions);\n if (!isNil(value)) {\n const index = allEnumOptions.findIndex((opt) => value === opt.value);\n const all = allEnumOptions.map(({ value: val }) => val);\n const updated = selected.slice(0, index).concat(value, selected.slice(index));\n // As inserting values at predefined index positions doesn't work with empty\n // arrays, we need to reorder the updated selection to match the initial order\n return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));\n }\n return selected;\n}\n", "import cloneDeep from 'lodash/cloneDeep';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport setWith from 'lodash/setWith';\n\nimport { ErrorSchema } from './types';\nimport { ERRORS_KEY } from './constants';\n\n/** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where\n * numbers represent array indexes/\n */\nexport type PathType = string | (string | number)[];\n\n/** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is\n * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error\n * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can\n * get the result and/or reset all the errors back to an initial set and start again.\n */\nexport default class ErrorSchemaBuilder<T = any> {\n /** The error schema being built\n *\n * @private\n */\n private errorSchema: ErrorSchema<T> = {};\n\n /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.\n *\n * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class\n */\n constructor(initialSchema?: ErrorSchema<T>) {\n this.resetAllErrors(initialSchema);\n }\n\n /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`\n */\n get ErrorSchema() {\n return this.errorSchema;\n }\n\n /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.\n *\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)\n * @returns - The error block for the given `pathOfError` or the root if not provided\n * @private\n */\n private getOrCreateErrorBlock(pathOfError?: PathType) {\n const hasPath = (Array.isArray(pathOfError) && pathOfError.length > 0) || typeof pathOfError === 'string';\n // @ts-expect-error TS2590 to avoid \"Expression produces a union type that is too complex to represent\" error\n let errorBlock: ErrorSchema = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;\n if (!errorBlock && pathOfError) {\n errorBlock = {};\n setWith(this.errorSchema, pathOfError, errorBlock, Object);\n }\n return errorBlock;\n }\n\n /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.\n *\n * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n resetAllErrors(initialSchema?: ErrorSchema<T>) {\n this.errorSchema = initialSchema ? cloneDeep(initialSchema) : {};\n return this;\n }\n\n /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within\n * the schema described by the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param errorOrList - The error or list of errors to add into the `ErrorSchema`\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n addErrors(errorOrList: string | string[], pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n let errorsList = get(errorBlock, ERRORS_KEY);\n if (!Array.isArray(errorsList)) {\n errorsList = [];\n errorBlock[ERRORS_KEY] = errorsList;\n }\n\n if (Array.isArray(errorOrList)) {\n set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, ...errorOrList])]);\n } else {\n set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, errorOrList])]);\n }\n return this;\n }\n\n /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location\n * within the schema described by the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param errorOrList - The error or list of errors to set into the `ErrorSchema`\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n setErrors(errorOrList: string | string[], pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n // Effectively clone the array being given to prevent accidental outside manipulation of the given list\n const listToAdd = Array.isArray(errorOrList) ? [...new Set([...errorOrList])] : [errorOrList];\n set(errorBlock, ERRORS_KEY, listToAdd);\n return this;\n }\n\n /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by\n * the `pathOfError`. For more information about how to specify the path see the\n * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).\n *\n * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)\n * @returns - The `ErrorSchemaBuilder` object for chaining purposes\n */\n clearErrors(pathOfError?: PathType) {\n const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);\n set(errorBlock, ERRORS_KEY, []);\n return this;\n }\n}\n", "import { type DateObject } from './types';\n\n/** Available options for re-ordering date input element */\nexport type DateElementFormat = 'DMY' | 'MDY' | 'YMD';\n\n/** Type describing format of DateElement prop */\ntype DateElementProp = {\n type: string;\n range: [number, number];\n value: number | undefined;\n};\n\n/** Given date & time information with optional yearRange & format, returns props for DateElement\n *\n * @param date - Object containing date with optional time information\n * @param time - Determines whether to include time or not\n * @param [yearRange=[1900, new Date().getFullYear() + 2]] - Controls the list of years to be displayed\n * @param [format='YMD'] - Controls the order in which day, month and year input element will be displayed\n * @returns Array of props for DateElement\n */\n\nexport default function getDateElementProps(\n date: DateObject,\n time: boolean,\n yearRange: [number, number] = [1900, new Date().getFullYear() + 2],\n format: DateElementFormat = 'YMD',\n) {\n const { day, month, year, hour, minute, second } = date;\n\n const dayObj: DateElementProp = { type: 'day', range: [1, 31], value: day };\n const monthObj: DateElementProp = { type: 'month', range: [1, 12], value: month };\n const yearObj: DateElementProp = { type: 'year', range: yearRange, value: year };\n\n const dateElementProp: DateElementProp[] = [];\n switch (format) {\n case 'MDY':\n dateElementProp.push(monthObj, dayObj, yearObj);\n break;\n case 'DMY':\n dateElementProp.push(dayObj, monthObj, yearObj);\n break;\n case 'YMD':\n default:\n dateElementProp.push(yearObj, monthObj, dayObj);\n }\n\n if (time) {\n dateElementProp.push(\n { type: 'hour', range: [0, 23], value: hour },\n { type: 'minute', range: [0, 59], value: minute },\n { type: 'second', range: [0, 59], value: second },\n );\n }\n\n return dateElementProp;\n}\n", "import { RangeSpecType, StrictRJSFSchema } from './types';\nimport { RJSFSchema } from './types';\n\n/** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML\n * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.\n *\n * @param schema - The schema from which to extract the range spec\n * @returns - A range specification from the schema\n */\nexport default function rangeSpec<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n const spec: RangeSpecType = {};\n if (schema.multipleOf) {\n spec.step = schema.multipleOf;\n }\n if (schema.minimum || schema.minimum === 0) {\n spec.min = schema.minimum;\n }\n if (schema.maximum || schema.maximum === 0) {\n spec.max = schema.maximum;\n }\n return spec;\n}\n", "import rangeSpec from './rangeSpec';\nimport { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';\n\n/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.\n *\n * @param schema - The schema for the field provided by the widget\n * @param [defaultType] - The default type, if any, for the field provided by the widget\n * @param [options={}] - The UI Options for the field provided by the widget\n * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step\n * @returns - The extracted `InputPropsType` object\n */\nexport default function getInputProps<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n schema: RJSFSchema,\n defaultType?: string,\n options: UIOptionsType<T, S, F> = {},\n autoDefaultStepAny = true,\n): InputPropsType {\n const inputProps: InputPropsType = {\n type: defaultType || 'text',\n ...rangeSpec(schema),\n };\n\n // If options.inputType is set use that as the input type\n if (options.inputType) {\n inputProps.type = options.inputType;\n } else if (!defaultType) {\n // If the schema is of type number or integer, set the input type to number\n if (schema.type === 'number') {\n inputProps.type = 'number';\n // Only add step if one isn't already defined and we are auto-defaulting the \"any\" step\n if (autoDefaultStepAny && inputProps.step === undefined) {\n // Setting step to 'any' fixes a bug in Safari where decimals are not\n // allowed in number inputs\n inputProps.step = 'any';\n }\n } else if (schema.type === 'integer') {\n inputProps.type = 'number';\n // Only add step if one isn't already defined\n if (inputProps.step === undefined) {\n // Since this is integer, you always want to step up or down in multiples of 1\n inputProps.step = 1;\n }\n }\n }\n\n if (options.autocomplete) {\n inputProps.autoComplete = options.autocomplete;\n }\n\n if (options.accept) {\n inputProps.accept = options.accept as string;\n }\n\n return inputProps;\n}\n", "import { SUBMIT_BTN_OPTIONS_KEY } from './constants';\nimport getUiOptions from './getUiOptions';\nimport { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema, UISchemaSubmitButtonOptions } from './types';\n\n/** The default submit button options, exported for testing purposes\n */\nexport const DEFAULT_OPTIONS: UISchemaSubmitButtonOptions = {\n props: {\n disabled: false,\n },\n submitText: 'Submit',\n norender: false,\n};\n\n/** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`\n *\n * @param [uiSchema={}] - the UI Schema from which to extract submit button props\n * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones\n */\nexport default function getSubmitButtonOptions<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(uiSchema: UiSchema<T, S, F> = {}): UISchemaSubmitButtonOptions {\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {\n const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY] as UISchemaSubmitButtonOptions;\n return { ...DEFAULT_OPTIONS, ...options };\n }\n\n return DEFAULT_OPTIONS;\n}\n", "import { FormContextType, TemplatesType, Registry, UIOptionsType, StrictRJSFSchema, RJSFSchema } from './types';\n\n/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`\n * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.\n *\n * @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`\n * @param registry - The `Registry` from which to read the template\n * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template\n * @returns - The template from either the `uiSchema` or `registry` for the `name`\n */\nexport default function getTemplate<\n Name extends keyof TemplatesType<T, S, F>,\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(name: Name, registry: Registry<T, S, F>, uiOptions: UIOptionsType<T, S, F> = {}): TemplatesType<T, S, F>[Name] {\n const { templates } = registry;\n if (name === 'ButtonTemplates') {\n return templates[name];\n }\n // Allow templates to be customized per-field by using string keys from the registry\n if (\n Object.hasOwn(uiOptions, name) &&\n typeof uiOptions[name] === 'string' &&\n Object.hasOwn(templates, uiOptions[name] as string)\n ) {\n const key = uiOptions[name];\n // Evaluating templates[key] results in TS2590: Expression produces a union type that is too complex to represent\n // To avoid that, we cast templates to `any` before accessing the key field\n return (templates as any)[key];\n }\n return (\n // Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent\n // To avoid that, we cast uiOptions to `any` before accessing the name field\n ((uiOptions as any)[name] as TemplatesType<T, S, F>[Name]) || templates[name]\n );\n}\n", "import { nanoid } from 'nanoid';\nimport get from 'lodash/get';\n\nimport { TestIdShape } from './types';\n\n/** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment\n * (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned\n * object is accessed, if the value already exists the object will return that value, otherwise it will create that key\n * with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the\n * function will return an empty object, therefore returning `undefined` for any property within the object and\n * excluding the prop from the rendered output of the component in which it is used.\n * This implementation was adapted from the following blog post: https://www.matthewsessions.com/blog/react-test-id/\n * To use this helper, you will want to generate a separate object for each component to avoid potential overlapping of\n * ID names. You will also want to export the object for use in tests, because the keys will be generated in the\n * component file, and used in the test file. Within the component file, add:\n * `export const TEST_IDS = getTestIds();`\n * Then pass `TEST_IDS.examplePropertyName` as the value of the test ID attribute of the intended component. This will\n * allow you to use `TEST_IDS.examplePropertyName` within your tests, while keeping the test IDs out of your rendered\n * output.\n */\nexport default function getTestIds(): TestIdShape {\n // For some reason, even though process.env contains the value of `test` for NODE_ENV, accessing it directly returns\n // 'development'. Using `get()` does, in fact, return test so sticking with it\n if (typeof process === 'undefined' || get(process, 'env.NODE_ENV') !== 'test') {\n return {};\n }\n\n const ids = new Map();\n return new Proxy(\n {},\n {\n get(_obj, prop) {\n if (!ids.has(prop)) {\n ids.set(prop, nanoid());\n }\n return ids.get(prop);\n },\n },\n );\n}\n", "import { createElement } from 'react';\nimport ReactIs from 'react-is';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\nimport { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types';\nimport getSchemaType from './getSchemaType';\n\n/** The map of schema types to widget type to widget name\n */\nconst widgetMap: { [k: string]: { [j: string]: string } } = {\n boolean: {\n checkbox: 'CheckboxWidget',\n radio: 'RadioWidget',\n select: 'SelectWidget',\n hidden: 'HiddenWidget',\n },\n string: {\n text: 'TextWidget',\n password: 'PasswordWidget',\n email: 'EmailWidget',\n hostname: 'TextWidget',\n ipv4: 'TextWidget',\n ipv6: 'TextWidget',\n uri: 'URLWidget',\n 'data-url': 'FileWidget',\n radio: 'RadioWidget',\n select: 'SelectWidget',\n textarea: 'TextareaWidget',\n hidden: 'HiddenWidget',\n date: 'DateWidget',\n datetime: 'DateTimeWidget',\n 'date-time': 'DateTimeWidget',\n 'alt-date': 'AltDateWidget',\n 'alt-datetime': 'AltDateTimeWidget',\n time: 'TimeWidget',\n color: 'ColorWidget',\n file: 'FileWidget',\n },\n number: {\n text: 'TextWidget',\n select: 'SelectWidget',\n updown: 'UpDownWidget',\n range: 'RangeWidget',\n radio: 'RadioWidget',\n hidden: 'HiddenWidget',\n },\n integer: {\n text: 'TextWidget',\n select: 'SelectWidget',\n updown: 'UpDownWidget',\n range: 'RangeWidget',\n radio: 'RadioWidget',\n hidden: 'HiddenWidget',\n },\n array: {\n select: 'SelectWidget',\n checkboxes: 'CheckboxesWidget',\n files: 'FileWidget',\n hidden: 'HiddenWidget',\n },\n};\n\n/** Wraps the given widget with stateless functional component that will merge any `defaultProps.options` with the\n * `options` that are provided in the props. It will add the wrapper component as a `MergedWidget` property onto the\n * `Widget` so that future attempts to wrap `AWidget` will return the already existing wrapper.\n *\n * @param AWidget - A widget that will be wrapped or one that is already wrapped\n * @returns - The wrapper widget\n */\nfunction mergeWidgetOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n AWidget: Widget<T, S, F>,\n) {\n let MergedWidget: Widget<T, S, F> | undefined = get(AWidget, 'MergedWidget');\n // cache return value as property of widget for proper react reconciliation\n if (!MergedWidget) {\n const defaultOptions = (AWidget.defaultProps && AWidget.defaultProps.options) || {};\n MergedWidget = ({ options, ...props }) => {\n return <AWidget options={{ ...defaultOptions, ...options }} {...props} />;\n };\n set(AWidget, 'MergedWidget', MergedWidget);\n }\n return MergedWidget;\n}\n\n/** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the\n * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped\n * with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based\n * on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.\n *\n * @param schema - The schema for the field\n * @param [widget] - Either the name of the widget OR a `Widget` implementation to use\n * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation\n * @returns - The `Widget` component to use\n * @throws - An error if there is no `Widget` component that can be returned\n */\nexport default function getWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n widget?: Widget<T, S, F> | string,\n registeredWidgets: RegistryWidgetsType<T, S, F> = {},\n): Widget<T, S, F> {\n const type = getSchemaType(schema);\n\n if (\n typeof widget === 'function' ||\n (widget && ReactIs.isForwardRef(createElement(widget))) ||\n ReactIs.isMemo(widget)\n ) {\n return mergeWidgetOptions<T, S, F>(widget as Widget<T, S, F>);\n }\n\n if (typeof widget !== 'string') {\n throw new Error(`Unsupported widget definition: ${typeof widget}`);\n }\n\n if (widget in registeredWidgets) {\n const registeredWidget = registeredWidgets[widget];\n return getWidget<T, S, F>(schema, registeredWidget, registeredWidgets);\n }\n\n if (typeof type === 'string') {\n if (!(type in widgetMap)) {\n throw new Error(`No widget for type '${type}'`);\n }\n\n if (widget in widgetMap[type]) {\n const registeredWidget = registeredWidgets[widgetMap[type][widget]];\n return getWidget<T, S, F>(schema, registeredWidget, registeredWidgets);\n }\n }\n\n throw new Error(`No widget '${widget}' for type '${type}'`);\n}\n", "import { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Hashes a string using the algorithm based on Java's hashing function.\n * JS has no built-in hashing function, so rolling our own\n * based on Java's hashing fn:\n * http://www.java2s.com/example/nodejs-utility-method/string-hash/hashcode-4dc2b.html\n *\n * @param string - The string for which to get the hash\n * @returns - The resulting hash of the string in hex format\n */\nexport function hashString(string: string): string {\n let hash = 0;\n for (let i = 0; i < string.length; i += 1) {\n const chr = string.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash.toString(16);\n}\n\n/** Stringifies an `object`, sorts object fields in consistent order before stringifying it.\n *\n * @param object - The object for which the sorted stringify is desired\n * @returns - The stringified object with keys sorted in a consistent order\n */\nexport function sortedJSONStringify(object: unknown): string {\n const allKeys = new Set<string>();\n // solution source: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/53593328#53593328\n JSON.stringify(object, (key, value) => (allKeys.add(key), value));\n return JSON.stringify(object, Array.from(allKeys).sort());\n}\n\n/** Stringifies an `object` and returns the hash of the resulting string. Sorts object fields\n * in consistent order before stringify to prevent different hash ids for the same object.\n *\n * @param object - The object for which the hash is desired\n * @returns - The string obtained from the hash of the stringified object\n */\nexport function hashObject(object: unknown): string {\n return hashString(sortedJSONStringify(object));\n}\n\n/** Stringifies the schema and returns the hash of the resulting string. Sorts schema fields\n * in consistent order before stringify to prevent different hash ids for the same schema.\n *\n * @param schema - The schema for which the hash is desired\n * @returns - The string obtained from the hash of the stringified schema\n */\nexport default function hashForSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n return hashObject(schema);\n}\n", "import getWidget from './getWidget';\nimport { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema, Widget } from './types';\n\n/** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it\n * does, or false if it doesn't.\n *\n * @param schema - The schema for the field\n * @param widget - Either the name of the widget OR a `Widget` implementation to use\n * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation\n * @returns - True if the widget exists, false otherwise\n */\nexport default function hasWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n widget: Widget<T, S, F> | string,\n registeredWidgets: RegistryWidgetsType<T, S, F> = {},\n) {\n try {\n getWidget(schema, widget, registeredWidgets);\n return true;\n } catch (e) {\n const err: Error = e as Error;\n if (err.message && (err.message.startsWith('No widget') || err.message.startsWith('Unsupported widget'))) {\n return false;\n }\n throw e;\n }\n}\n", "import isString from 'lodash/isString';\n\nimport { IdSchema } from './types';\nimport { ID_KEY } from './constants';\n\n/** Generates a consistent `id` pattern for a given `id` and a `suffix`\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param suffix - The suffix to append to the id\n */\nfunction idGenerator<T = any>(id: IdSchema<T> | string, suffix: string) {\n const theId = isString(id) ? id : id[ID_KEY];\n return `${theId}__${suffix}`;\n}\n/** Return a consistent `id` for the field description element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field description element from the given `id`\n */\nexport function descriptionId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'description');\n}\n\n/** Return a consistent `id` for the field error element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field error element from the given `id`\n */\nexport function errorId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'error');\n}\n\n/** Return a consistent `id` for the field examples element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field examples element from the given `id`\n */\nexport function examplesId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'examples');\n}\n\n/** Return a consistent `id` for the field help element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field help element from the given `id`\n */\nexport function helpId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'help');\n}\n\n/** Return a consistent `id` for the field title element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @returns - The consistent id for the field title element from the given `id`\n */\nexport function titleId<T = any>(id: IdSchema<T> | string) {\n return idGenerator<T>(id, 'title');\n}\n\n/** Return a list of element ids that contain additional information about the field that can be used to as the aria\n * description of the field. This is correctly omitting `titleId` which would be \"labeling\" rather than \"describing\" the\n * element.\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list\n * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute\n */\nexport function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, includeExamples = false) {\n const examples = includeExamples ? ` ${examplesId<T>(id)}` : '';\n return `${errorId<T>(id)} ${descriptionId<T>(id)} ${helpId<T>(id)}${examples}`;\n}\n\n/** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget\n *\n * @param id - The id of the parent component for the option\n * @param optionIndex - The index of the option for which the id is desired\n * @returns - An id for the option index based on the parent `id`\n */\nexport function optionId(id: string, optionIndex: number) {\n return `${id}-${optionIndex}`;\n}\n\n/** Return a consistent `id` for the `btn` button element\n *\n * @param id - Either simple string id or an IdSchema from which to extract it\n * @param btn - The button type for which to generate the id\n * @returns - The consistent id for the button from the given `id` and `btn` type\n */\nexport function buttonId<T = any>(id: IdSchema<T> | string, btn: 'add' | 'copy' | 'moveDown' | 'moveUp' | 'remove') {\n return idGenerator<T>(id, btn);\n}\n", "import { ReactElement } from 'react';\n\n/** Helper function that will return the value to use for a widget `label` based on `hideLabel`. The `fallback` is used\n * as the return value from the function when `hideLabel` is true. Due to the implementation of theme components, it\n * may be necessary to return something other than `undefined` to cause the theme component to not render a label. Some\n * themes require may `false` and others may require an empty string.\n *\n * @param [label] - The label string or component to render when not hidden\n * @param [hideLabel] - Flag, if true, will cause the label to be hidden\n * @param [fallback] - One of 3 values, `undefined` (the default), `false` or an empty string\n * @returns - `fallback` if `hideLabel` is true, otherwise `label`\n */\n\nexport default function labelValue(label?: string, hideLabel?: boolean, fallback?: ''): undefined | string;\nexport default function labelValue(label?: string, hideLabel?: boolean, fallback?: false): undefined | false | string;\nexport default function labelValue(label?: ReactElement, hideLabel?: boolean, fallback?: ''): undefined | ReactElement;\nexport default function labelValue(\n label?: ReactElement,\n hideLabel?: boolean,\n fallback?: false,\n): undefined | false | ReactElement;\nexport default function labelValue(\n label?: string | ReactElement,\n hideLabel?: boolean,\n fallback?: false | '',\n): undefined | false | string | ReactElement {\n return hideLabel ? fallback : label;\n}\n", "/** Converts a local Date string into a UTC date string\n *\n * @param dateString - The string representation of a date as accepted by the `Date()` constructor\n * @returns - A UTC date string if `dateString` is truthy, otherwise undefined\n */\nexport default function localToUTC(dateString: string) {\n return dateString ? new Date(dateString).toJSON() : undefined;\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport { FORM_CONTEXT_NAME, LOOKUP_MAP_NAME } from './constants';\nimport { FormContextType, RJSFSchema, Registry, StrictRJSFSchema } from './types';\n\n/** Given a React JSON Schema Form registry or formContext object, return the value associated with `toLookup`. This\n * might be contained within the lookup map in the formContext. If no such value exists, return the `fallback`\n * value.\n *\n * @param regOrFc - The @rjsf registry or form context in which the lookup will occur\n * @param toLookup - The name of the field in the lookup map in the form context to get the value for\n * @param [fallback] - The fallback value to use if the form context does not contain a value for `toLookup`\n * @returns - The value associated with `toLookup` in the form context or `fallback`\n */\nexport default function lookupFromFormContext<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(regOrFc: Registry<T, S, F> | Registry<T, S, F>['formContext'], toLookup: string, fallback?: unknown) {\n const lookupPath = [LOOKUP_MAP_NAME];\n if (has(regOrFc, FORM_CONTEXT_NAME)) {\n lookupPath.unshift(FORM_CONTEXT_NAME);\n }\n return get(regOrFc, [...lookupPath, toLookup], fallback);\n}\n", "import { GenericObjectType } from './types';\n\n/** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.\n * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per\n * the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be\n * places in the location of the `*`.\n *\n * @param properties - The list of property keys to be ordered\n * @param order - An array of property keys to be ordered first, with an optional '*' property\n * @returns - A list with the `properties` ordered\n * @throws - Error when the properties cannot be ordered correctly\n */\nexport default function orderProperties(properties: string[], order?: string[]): string[] {\n if (!Array.isArray(order)) {\n return properties;\n }\n\n const arrayToHash = (arr: string[]) =>\n arr.reduce((prev: GenericObjectType, curr) => {\n prev[curr] = true;\n return prev;\n }, {});\n const errorPropList = (arr: string[]) =>\n arr.length > 1 ? `properties '${arr.join(\"', '\")}'` : `property '${arr[0]}'`;\n const propertyHash = arrayToHash(properties);\n const orderFiltered = order.filter((prop) => prop === '*' || propertyHash[prop]);\n const orderHash = arrayToHash(orderFiltered);\n\n const rest = properties.filter((prop: string) => !orderHash[prop]);\n const restIndex = orderFiltered.indexOf('*');\n if (restIndex === -1) {\n if (rest.length) {\n throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);\n }\n return orderFiltered;\n }\n if (restIndex !== orderFiltered.lastIndexOf('*')) {\n throw new Error('uiSchema order list contains more than one wildcard item');\n }\n\n const complete = [...orderFiltered];\n complete.splice(restIndex, 1, ...rest);\n return complete;\n}\n", "import { DateObject } from './types';\n\n/** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true\n *\n * @param dateString - The date string to parse into a DateObject\n * @param [includeTime=true] - Optional flag, if false, will not include the time data into the object\n * @returns - The date string converted to a `DateObject`\n * @throws - Error when the date cannot be parsed from the string\n */\nexport default function parseDateString(dateString?: string, includeTime = true): DateObject {\n if (!dateString) {\n return {\n year: -1,\n month: -1,\n day: -1,\n hour: includeTime ? -1 : 0,\n minute: includeTime ? -1 : 0,\n second: includeTime ? -1 : 0,\n };\n }\n const date = new Date(dateString);\n if (Number.isNaN(date.getTime())) {\n throw new Error('Unable to parse date ' + dateString);\n }\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1, // oh you, javascript.\n day: date.getUTCDate(),\n hour: includeTime ? date.getUTCHours() : 0,\n minute: includeTime ? date.getUTCMinutes() : 0,\n second: includeTime ? date.getUTCSeconds() : 0,\n };\n}\n", "import { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Check to see if a `schema` specifies that a value must be true. This happens when:\n * - `schema.const` is truthy\n * - `schema.enum` == `[true]`\n * - `schema.anyOf` or `schema.oneOf` has a single value which recursively returns true\n * - `schema.allOf` has at least one value which recursively returns true\n *\n * @param schema - The schema to check\n * @returns - True if the schema specifies a value that must be true, false otherwise\n */\nexport default function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {\n // Check if const is a truthy value\n if (schema.const) {\n return true;\n }\n\n // Check if an enum has a single value of true\n if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {\n return true;\n }\n\n // If anyOf has a single value, evaluate the subschema\n if (schema.anyOf && schema.anyOf.length === 1) {\n return schemaRequiresTrueValue(schema.anyOf[0] as S);\n }\n\n // If oneOf has a single value, evaluate the subschema\n if (schema.oneOf && schema.oneOf.length === 1) {\n return schemaRequiresTrueValue(schema.oneOf[0] as S);\n }\n\n // Evaluate each subschema in allOf, to see if one of them requires a true value\n if (schema.allOf) {\n const schemaSome = (subSchema: S['additionalProperties']) => schemaRequiresTrueValue(subSchema as S);\n return schema.allOf.some(schemaSome);\n }\n\n return false;\n}\n", "import React from 'react';\n\nimport deepEquals from './deepEquals';\n\n/** Determines whether the given `component` should be rerendered by comparing its current set of props and state\n * against the next set. If either of those two sets are not the same, then the component should be rerendered.\n *\n * @param component - A React component being checked\n * @param nextProps - The next set of props against which to check\n * @param nextState - The next set of state against which to check\n * @returns - True if the component should be re-rendered, false otherwise\n */\nexport default function shouldRender(component: React.Component, nextProps: any, nextState: any) {\n const { props, state } = component;\n return !deepEquals(props, nextProps) || !deepEquals(state, nextState);\n}\n", "import { DateObject } from './types';\n\n/** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is\n * removed.\n *\n * @param dateObject - The `DateObject` to convert to a date string\n * @param [time=true] - Optional flag used to remove the time portion of the date string if false\n * @returns - The UTC date string\n */\nexport default function toDateString(dateObject: DateObject, time = true) {\n const { year, month, day, hour = 0, minute = 0, second = 0 } = dateObject;\n const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);\n const datetime = new Date(utcTime).toJSON();\n return time ? datetime : datetime.slice(0, 10);\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ERRORS_KEY } from './constants';\nimport { ErrorSchema, GenericObjectType, RJSFValidationError } from './types';\n\n/** Converts an `errorSchema` into a list of `RJSFValidationErrors`\n *\n * @param errorSchema - The `ErrorSchema` instance to convert\n * @param [fieldPath=[]] - The current field path, defaults to [] if not specified\n * @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`\n */\nexport default function toErrorList<T = any>(\n errorSchema?: ErrorSchema<T>,\n fieldPath: string[] = [],\n): RJSFValidationError[] {\n if (!errorSchema) {\n return [];\n }\n let errorList: RJSFValidationError[] = [];\n if (ERRORS_KEY in errorSchema) {\n errorList = errorList.concat(\n errorSchema[ERRORS_KEY]!.map((message: string) => {\n const property = `.${fieldPath.join('.')}`;\n return {\n property,\n message,\n stack: `${property} ${message}`,\n };\n }),\n );\n }\n return Object.keys(errorSchema).reduce((acc, key) => {\n if (key !== ERRORS_KEY) {\n const childSchema = (errorSchema as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));\n }\n }\n return acc;\n }, errorList);\n}\n", "import toPath from 'lodash/toPath';\n\nimport { ErrorSchema, RJSFValidationError } from './types';\nimport ErrorSchemaBuilder from './ErrorSchemaBuilder';\n\n/** Transforms a rjsf validation errors list:\n * [\n * {property: '.level1.level2[2].level3', message: 'err a'},\n * {property: '.level1.level2[2].level3', message: 'err b'},\n * {property: '.level1.level2[4].level3', message: 'err b'},\n * ]\n * Into an error tree:\n * {\n * level1: {\n * level2: {\n * 2: {level3: {errors: ['err a', 'err b']}},\n * 4: {level3: {errors: ['err b']}},\n * }\n * }\n * };\n *\n * @param errors - The list of RJSFValidationError objects\n * @returns - The `ErrorSchema` built from the list of `RJSFValidationErrors`\n */\nexport default function toErrorSchema<T = any>(errors: RJSFValidationError[]): ErrorSchema<T> {\n const builder = new ErrorSchemaBuilder<T>();\n if (errors.length) {\n errors.forEach((error) => {\n const { property, message } = error;\n // When the property is the root element, just use an empty array for the path\n const path = property === '.' ? [] : toPath(property);\n // If the property is at the root (.level1) then toPath creates\n // an empty array element at the first index. Remove it.\n if (path.length > 0 && path[0] === '') {\n path.splice(0, 1);\n }\n if (message) {\n builder.addErrors(message, path);\n }\n });\n }\n return builder.ErrorSchema;\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ErrorSchema, FormValidation, GenericObjectType } from './types';\n\n/** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it\n *\n * @param errorHandler - The `FormValidation` error handling structure\n * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function\n */\nexport default function unwrapErrorHandler<T = any>(errorHandler: FormValidation<T>): ErrorSchema<T> {\n return Object.keys(errorHandler).reduce((acc, key) => {\n if (key === 'addError') {\n return acc;\n } else {\n const childSchema = (errorHandler as GenericObjectType)[key];\n if (isPlainObject(childSchema)) {\n return {\n ...acc,\n [key]: unwrapErrorHandler(childSchema),\n };\n }\n return { ...acc, [key]: childSchema };\n }\n }, {} as ErrorSchema<T>);\n}\n", "import pad from './pad';\n\n/** Converts a UTC date string into a local Date format\n *\n * @param jsonDate - A UTC date string\n * @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format\n */\nexport default function utcToLocal(jsonDate: string) {\n if (!jsonDate) {\n return '';\n }\n\n // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'\n // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)\n // > should be a _valid local date and time string_ (not GMT)\n\n // Note - date constructor passed local ISO-8601 does not correctly\n // change time to UTC in node pre-8\n const date = new Date(jsonDate);\n\n const yyyy = pad(date.getFullYear(), 4);\n const MM = pad(date.getMonth() + 1, 2);\n const dd = pad(date.getDate(), 2);\n const hh = pad(date.getHours(), 2);\n const mm = pad(date.getMinutes(), 2);\n const ss = pad(date.getSeconds(), 2);\n const SSS = pad(date.getMilliseconds(), 3);\n\n return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;\n}\n", "import isEmpty from 'lodash/isEmpty';\n\nimport mergeObjects from './mergeObjects';\nimport toErrorList from './toErrorList';\nimport { ErrorSchema, ValidationData } from './types';\n\n/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the\n * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling\n * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then\n * `validationData` is returned.\n *\n * @param validationData - The current `ValidationData` into which to merge the additional errors\n * @param [additionalErrorSchema] - The optional additional set of errors in an `ErrorSchema`\n * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.\n */\nexport default function validationDataMerge<T = any>(\n validationData: ValidationData<T>,\n additionalErrorSchema?: ErrorSchema<T>,\n): ValidationData<T> {\n if (!additionalErrorSchema) {\n return validationData;\n }\n const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;\n let errors = toErrorList(additionalErrorSchema);\n let errorSchema = additionalErrorSchema;\n if (!isEmpty(oldErrorSchema)) {\n errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true) as ErrorSchema<T>;\n errors = [...oldErrors].concat(errors);\n }\n return { errorSchema, errors };\n}\n", "import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\nimport isObject from 'lodash/isObject';\n\n/** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n */\nfunction withIdRefPrefixObject<S extends StrictRJSFSchema = RJSFSchema>(node: S): S {\n for (const key in node) {\n const realObj: { [k: string]: any } = node;\n const value = realObj[key];\n if (key === REF_KEY && typeof value === 'string' && value.startsWith('#')) {\n realObj[key] = ROOT_SCHEMA_PREFIX + value;\n } else {\n realObj[key] = withIdRefPrefix<S>(value);\n }\n }\n return node;\n}\n\n/** Takes a `node` object list and transforms any contained `$ref` node variables with a prefix, recursively calling\n * `withIdRefPrefix` for any other elements.\n *\n * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n */\nfunction withIdRefPrefixArray<S extends StrictRJSFSchema = RJSFSchema>(node: S[]): S[] {\n for (let i = 0; i < node.length; i++) {\n node[i] = withIdRefPrefix<S>(node[i]) as S;\n }\n return node;\n}\n\n/** Recursively prefixes all `$ref`s in a schema with the value of the `ROOT_SCHEMA_PREFIX` constant.\n * This is used in isValid to make references to the rootSchema\n *\n * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it\n * @returns - A copy of the `schemaNode` with updated `$ref`s\n */\nexport default function withIdRefPrefix<S extends StrictRJSFSchema = RJSFSchema>(\n schemaNode: S | S[] | S[keyof S],\n): S | S[] | S[keyof S] {\n if (Array.isArray(schemaNode)) {\n return withIdRefPrefixArray<S>([...schemaNode]);\n }\n if (isObject(schemaNode)) {\n return withIdRefPrefixObject<S>({ ...schemaNode });\n }\n return schemaNode;\n}\n", "import keys from 'lodash/keys';\nimport pickBy from 'lodash/pickBy';\nimport isPlainObject from 'lodash/isPlainObject';\nimport get from 'lodash/get';\nimport difference from 'lodash/difference';\nimport deepEquals from './deepEquals';\n\n/**\n * Compares two objects and returns the names of the fields that have changed.\n * This function iterates over each field of object `a`, using `_.isEqual` to compare the field value\n * with the corresponding field value in object `b`. If the values are different, the field name will\n * be included in the returned array.\n *\n * @param a - The first object, representing the original data to compare.\n * @param b - The second object, representing the updated data to compare.\n * @returns - An array of field names that have changed.\n *\n * @example\n * const a = { name: 'John', age: 30 };\n * const b = { name: 'John', age: 31 };\n * const changedFields = getChangedFields(a, b);\n * console.log(changedFields); // Output: ['age']\n */\nexport default function getChangedFields(a: unknown, b: unknown): string[] {\n const aIsPlainObject = isPlainObject(a);\n const bIsPlainObject = isPlainObject(b);\n // If strictly equal or neither of them is a plainObject returns an empty array\n if (a === b || (!aIsPlainObject && !bIsPlainObject)) {\n return [];\n }\n if (aIsPlainObject && !bIsPlainObject) {\n return keys(a);\n } else if (!aIsPlainObject && bIsPlainObject) {\n return keys(b);\n } else {\n const unequalFields = keys(pickBy(a as object, (value, key) => !deepEquals(value, get(b, key))));\n const diffFields = difference(keys(b), keys(a));\n return [...unequalFields, ...diffFields];\n }\n}\n", "/** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the\n * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values\n * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of\n * parameters is important because some languages may choose to put the second parameter before the first in its\n * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.\n */\nexport enum TranslatableString {\n /** Fallback title of an array item, used by ArrayField */\n ArrayItemTitle = 'Item',\n /** Missing items reason, used by ArrayField */\n MissingItems = 'Missing items definition',\n /** Empty array message, used by ArrayField */\n EmptyArray = 'No items yet. Use the button below to add some.',\n /** Yes label, used by BooleanField */\n YesLabel = 'Yes',\n /** No label, used by BooleanField */\n NoLabel = 'No',\n /** Close label, used by ErrorList */\n CloseLabel = 'Close',\n /** Errors label, used by ErrorList */\n ErrorsLabel = 'Errors',\n /** New additionalProperties string default value, used by ObjectField */\n NewStringDefault = 'New Value',\n /** Add button title, used by AddButton */\n AddButton = 'Add',\n /** Add button title, used by AddButton */\n AddItemButton = 'Add Item',\n /** Copy button title, used by IconButton */\n CopyButton = 'Copy',\n /** Move down button title, used by IconButton */\n MoveDownButton = 'Move down',\n /** Move up button title, used by IconButton */\n MoveUpButton = 'Move up',\n /** Remove button title, used by IconButton */\n RemoveButton = 'Remove',\n /** Now label, used by AltDateWidget */\n NowLabel = 'Now',\n /** Clear label, used by AltDateWidget */\n ClearLabel = 'Clear',\n /** Aria date label, used by DateWidget */\n AriaDateLabel = 'Select a date',\n /** File preview label, used by FileWidget */\n PreviewLabel = 'Preview',\n /** Decrement button aria label, used by UpDownWidget */\n DecrementAriaLabel = 'Decrease value by 1',\n /** Increment button aria label, used by UpDownWidget */\n IncrementAriaLabel = 'Increase value by 1',\n // Strings with replaceable parameters\n /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */\n UnknownFieldType = 'Unknown field type %1',\n /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */\n OptionPrefix = 'Option %1',\n /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by\n * MultiSchemaField\n */\n TitleOptionPrefix = '%1 option %2',\n /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */\n KeyLabel = '%1 Key',\n // Strings with replaceable parameters AND/OR that support markdown and html\n /** Invalid object field configuration as provided by the ObjectField.\n * NOTE: Use markdown notation rather than html tags.\n */\n InvalidObjectField = 'Invalid \"%1\" object field configuration: _%2_.',\n /** Unsupported field schema, used by UnsupportedField */\n UnsupportedField = 'Unsupported field schema.',\n /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithId = 'Unsupported field schema for field `%1`.',\n /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithReason = 'Unsupported field schema: _%1_.',\n /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,\n * as provided by UnsupportedField.\n * NOTE: Use markdown notation rather than html tags.\n */\n UnsupportedFieldWithIdAndReason = 'Unsupported field schema for field `%1`: _%2_.',\n /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as\n * provided by FileWidget\n */\n FilesInfo = '**%1** (%2, %3 bytes)',\n}\n", "import forEach from 'lodash/forEach';\n\nimport { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types';\nimport { ITEMS_KEY, PROPERTIES_KEY } from '../constants';\nimport ParserValidator, { SchemaMap } from './ParserValidator';\nimport { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema';\nimport deepEquals from '../deepEquals';\n\n/** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to\n * capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the\n * `retrieveSchemaInternal()`, the `resolveAnyOrOneOfSchemas()` function is called. For each of the schemas returned\n * from THAT call have `properties`, then each of the sub-schema property objects are then recursively parsed.\n *\n * @param validator - The `ParserValidator` implementation used to capture `isValid()` calls during parsing\n * @param recurseList - The list of schemas returned from the `retrieveSchemaInternal`, preventing infinite recursion\n * @param rootSchema - The root schema from which the schema parsing began\n * @param schema - The current schema element being parsed\n */\nfunction parseSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ParserValidator<T, S, F>,\n recurseList: S[],\n rootSchema: S,\n schema: S,\n) {\n const schemas = retrieveSchemaInternal<T, S, F>(validator, schema, rootSchema, undefined, true);\n schemas.forEach((schema) => {\n const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema));\n if (sameSchemaIndex === -1) {\n recurseList.push(schema);\n const allOptions = resolveAnyOrOneOfSchemas<T, S, F>(validator, schema, rootSchema, true);\n allOptions.forEach((s) => {\n if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {\n forEach(schema[PROPERTIES_KEY], (value) => {\n parseSchema<T, S, F>(validator, recurseList, rootSchema, value as S);\n });\n }\n });\n if (ITEMS_KEY in schema && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {\n parseSchema<T, S, F>(validator, recurseList, rootSchema, schema.items as S);\n }\n }\n });\n}\n\n/** Parses the given `rootSchema` to extract out all the sub-schemas that maybe contained within it. Returns a map of\n * the hash of the schema to schema/sub-schema.\n *\n * @param rootSchema - The root schema to parse for sub-schemas used by `isValid()` calls\n * @returns - The `SchemaMap` of all schemas that were parsed\n */\nexport default function schemaParser<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n rootSchema: S,\n): SchemaMap<S> {\n const validator = new ParserValidator<T, S, F>(rootSchema);\n const recurseList: S[] = [];\n\n parseSchema(validator, recurseList, rootSchema, rootSchema);\n\n return validator.getSchemaMap();\n}\n", "import get from 'lodash/get';\n\nimport { ID_KEY } from '../constants';\nimport hashForSchema from '../hashForSchema';\nimport {\n CustomValidator,\n ErrorSchema,\n ErrorTransformer,\n FormContextType,\n RJSFSchema,\n RJSFValidationError,\n StrictRJSFSchema,\n UiSchema,\n ValidationData,\n ValidatorType,\n} from '../types';\nimport deepEquals from '../deepEquals';\n\n/** The type of the map of schema hash to schema\n */\nexport type SchemaMap<S extends StrictRJSFSchema = RJSFSchema> = {\n [hash: string]: S;\n};\n\n/** An implementation of the `ValidatorType` interface that is designed for use in capturing schemas used by the\n * `isValid()` function. The rest of the implementation of the interface throws errors when it is attempted to be used.\n * An instance of the object allows the caller to capture the schemas used in calls to the `isValid()` function. These\n * captured schema, along with the root schema used to construct the object are stored in the map of schemas keyed by\n * the hashed value of the schema. NOTE: After hashing the schema, an $id with the hash value is added to the\n * schema IF that schema doesn't already have an $id, prior to putting the schema into the map.\n */\nexport default class ParserValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>\n implements ValidatorType<T, S, F>\n{\n /** The rootSchema provided during construction of the class */\n readonly rootSchema: S;\n\n /** The map of schemas encountered by the ParserValidator */\n schemaMap: SchemaMap<S> = {};\n\n /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`\n * first.\n *\n * @param rootSchema - The root schema against which this validator will be executed\n */\n constructor(rootSchema: S) {\n this.rootSchema = rootSchema;\n this.addSchema(rootSchema, hashForSchema<S>(rootSchema));\n }\n\n /** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.\n */\n reset() {\n this.schemaMap = {};\n }\n\n /** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the\n * schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be\n * associated with it's `hash` for future use (by a schema compiler).\n *\n * @param schema - The schema which is to be added to the map\n * @param hash - The hash value at which to map the schema\n */\n addSchema(schema: S, hash: string) {\n const key = get(schema, ID_KEY, hash);\n const identifiedSchema = { ...schema, [ID_KEY]: key };\n const existing = this.schemaMap[key];\n if (!existing) {\n this.schemaMap[key] = identifiedSchema;\n } else if (!deepEquals(existing, identifiedSchema)) {\n console.error('existing schema:', JSON.stringify(existing, null, 2));\n console.error('new schema:', JSON.stringify(identifiedSchema, null, 2));\n throw new Error(\n `Two different schemas exist with the same key ${key}! What a bad coincidence. If possible, try adding an $id to one of the schemas`,\n );\n }\n }\n\n /** Returns the current `schemaMap` to the caller\n */\n getSchemaMap() {\n return this.schemaMap;\n }\n\n /** Implements the `ValidatorType` `isValid()` method to capture the `schema` in the `schemaMap`. Throws an error when\n * the `rootSchema` is not the same as the root schema provided during construction.\n *\n * @param schema - The schema to record in the `schemaMap`\n * @param _formData - The formData parameter that is ignored\n * @param rootSchema - The root schema associated with the schema\n * @throws - Error when the given `rootSchema` differs from the root schema provided during construction\n */\n isValid(schema: S, _formData: T, rootSchema: S): boolean {\n if (!deepEquals(rootSchema, this.rootSchema)) {\n throw new Error('Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema');\n }\n this.addSchema(schema, hashForSchema<S>(schema));\n\n return false;\n }\n\n /** Implements the `ValidatorType` `rawValidation()` method to throw an error since it is never supposed to be called\n *\n * @param _schema - The schema parameter that is ignored\n * @param _formData - The formData parameter that is ignored\n */\n rawValidation<Result = any>(_schema: S, _formData?: T): { errors?: Result[]; validationError?: Error } {\n throw new Error('Unexpectedly calling the `rawValidation()` method during schema parsing');\n }\n\n /** Implements the `ValidatorType` `toErrorList()` method to throw an error since it is never supposed to be called\n *\n * @param _errorSchema - The error schema parameter that is ignored\n * @param _fieldPath - The field path parameter that is ignored\n */\n toErrorList(_errorSchema?: ErrorSchema<T>, _fieldPath?: string[]): RJSFValidationError[] {\n throw new Error('Unexpectedly calling the `toErrorList()` method during schema parsing');\n }\n\n /** Implements the `ValidatorType` `validateFormData()` method to throw an error since it is never supposed to be\n * called\n *\n * @param _formData - The formData parameter that is ignored\n * @param _schema - The schema parameter that is ignored\n * @param _customValidate - The customValidate parameter that is ignored\n * @param _transformErrors - The transformErrors parameter that is ignored\n * @param _uiSchema - The uiSchema parameter that is ignored\n */\n validateFormData(\n _formData: T,\n _schema: S,\n _customValidate?: CustomValidator<T, S, F>,\n _transformErrors?: ErrorTransformer<T, S, F>,\n _uiSchema?: UiSchema<T, S, F>,\n ): ValidationData<T> {\n throw new Error('Unexpectedly calling the `validateFormData()` method during schema parsing');\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMe,SAAR,SAA0B,O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AO,UAAU,WAAW;AAC5F,oBAAqB,WAAW,aAAa,YAAYA,QAAO,KAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAQe,SAAR,aACL,YACc;AACd,QAAM,YAAY,IAAI,gBAAyB,UAAU;AACzD,QAAM,cAAmB,CAAC;AAE1B,cAAY,WAAW,aAAa,YAAY,UAAU;AAE1D,SAAO,UAAU,aAAa;AAChC;",
6
+ "names": ["isPlainObject", "isEqualWith", "import_get", "import_has", "import_get", "import_get", "import_isObject", "UriResolver", "isObject", "omit", "get", "jsonpointer", "isEmpty", "import_get", "get", "isString", "type", "acc", "union", "import_get", "import_get", "get", "isNumber", "has", "get", "import_isEmpty", "times", "set", "transform", "merge", "uniq", "flattenDeep", "isEmpty", "get", "s", "mergeAllOf", "schema", "get", "xxx", "isEqual", "import_get", "import_has", "import_isEmpty", "has", "isEmpty", "get", "has", "get", "import_get", "import_isEmpty", "import_get", "import_has", "import_isNumber", "import_isObject", "import_isString", "import_times", "isObject", "reduce", "get", "has", "key", "isString", "isNumber", "times", "import_get", "acc", "get", "isNil", "altSchemas", "import_isString", "isString", "import_get", "get", "isEmpty", "get", "keys", "import_get", "import_has", "has", "get", "keys", "import_get", "get", "import_get", "import_set", "set", "get", "index", "import_isNil", "isNil", "import_get", "import_set", "get", "setWith", "cloneDeep", "set", "import_get", "get", "import_get", "import_set", "get", "set", "ReactIs", "import_isString", "isString", "import_get", "import_has", "has", "get", "import_isPlainObject", "isPlainObject", "toPath", "import_isPlainObject", "isPlainObject", "import_isEmpty", "isEmpty", "import_isObject", "isObject", "import_isPlainObject", "import_get", "isPlainObject", "keys", "pickBy", "get", "difference", "TranslatableString", "import_get", "get", "schema", "forEach"]
7
7
  }