@rjsf/utils 6.7.1 → 6.10.0
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.cjs +521 -425
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +520 -424
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +579 -333
- package/lib/ErrorSchemaBuilder.d.ts +8 -7
- package/lib/ErrorSchemaBuilder.d.ts.map +1 -0
- package/lib/ErrorSchemaBuilder.js +29 -27
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/SelectedOptionDescription.d.ts +2 -1
- package/lib/SelectedOptionDescription.d.ts.map +1 -0
- package/lib/SelectedOptionDescription.js +6 -7
- package/lib/SelectedOptionDescription.js.map +1 -1
- package/lib/allowAdditionalItems.d.ts +2 -1
- package/lib/allowAdditionalItems.d.ts.map +1 -0
- package/lib/allowAdditionalItems.js +1 -1
- package/lib/allowAdditionalItems.js.map +1 -1
- package/lib/asNumber.d.ts +1 -0
- package/lib/asNumber.d.ts.map +1 -0
- package/lib/asNumber.js +1 -1
- package/lib/asNumber.js.map +1 -1
- package/lib/canExpand.d.ts +2 -1
- package/lib/canExpand.d.ts.map +1 -0
- package/lib/canExpand.js +1 -1
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.d.ts +2 -1
- package/lib/constIsAjvDataReference.d.ts.map +1 -0
- package/lib/constIsAjvDataReference.js +2 -3
- package/lib/constIsAjvDataReference.js.map +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/createErrorHandler.d.ts +2 -1
- package/lib/createErrorHandler.d.ts.map +1 -0
- package/lib/createErrorHandler.js +3 -4
- package/lib/createErrorHandler.js.map +1 -1
- package/lib/createSchemaUtils.d.ts +2 -1
- package/lib/createSchemaUtils.d.ts.map +1 -0
- package/lib/createSchemaUtils.js +10 -7
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/dataURItoBlob.d.ts +1 -0
- package/lib/dataURItoBlob.d.ts.map +1 -0
- package/lib/dataURItoBlob.js +1 -2
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/dateRangeOptions.d.ts +2 -1
- package/lib/dateRangeOptions.d.ts.map +1 -0
- package/lib/dateRangeOptions.js +1 -1
- package/lib/dateRangeOptions.js.map +1 -1
- package/lib/deepEquals.d.ts +1 -0
- package/lib/deepEquals.d.ts.map +1 -0
- package/lib/englishStringTranslator.d.ts +2 -1
- package/lib/englishStringTranslator.d.ts.map +1 -0
- package/lib/englishStringTranslator.js +1 -1
- package/lib/englishStringTranslator.js.map +1 -1
- package/lib/enumOptionSelectedValue.d.ts +2 -1
- package/lib/enumOptionSelectedValue.d.ts.map +1 -0
- package/lib/enumOptionSelectedValue.js +1 -1
- package/lib/enumOptionSelectedValue.js.map +1 -1
- package/lib/enumOptionValueDecoder.d.ts +2 -1
- package/lib/enumOptionValueDecoder.d.ts.map +1 -0
- package/lib/enumOptionValueDecoder.js +1 -1
- package/lib/enumOptionValueDecoder.js.map +1 -1
- package/lib/enumOptionValueEncoder.d.ts +2 -1
- package/lib/enumOptionValueEncoder.d.ts.map +1 -0
- package/lib/enumOptionValueEncoder.js +1 -2
- package/lib/enumOptionValueEncoder.js.map +1 -1
- package/lib/enumOptionsDeselectValue.d.ts +2 -1
- package/lib/enumOptionsDeselectValue.d.ts.map +1 -0
- package/lib/enumOptionsDeselectValue.js +2 -2
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.d.ts +2 -1
- package/lib/enumOptionsIndexForValue.d.ts.map +1 -0
- package/lib/enumOptionsIndexForValue.js +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.d.ts +2 -1
- package/lib/enumOptionsIsSelected.d.ts.map +1 -0
- package/lib/enumOptionsIsSelected.js +1 -1
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.d.ts +2 -1
- package/lib/enumOptionsSelectValue.d.ts.map +1 -0
- package/lib/enumOptionsSelectValue.js +2 -3
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.d.ts +2 -1
- package/lib/enumOptionsValueForIndex.d.ts.map +1 -0
- package/lib/enums.d.ts +1 -0
- package/lib/enums.d.ts.map +1 -0
- package/lib/findSchemaDefinition.d.ts +2 -1
- package/lib/findSchemaDefinition.d.ts.map +1 -0
- package/lib/findSchemaDefinition.js +7 -11
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.d.ts +11 -2
- package/lib/getChangedFields.d.ts.map +1 -0
- package/lib/getChangedFields.js +57 -18
- package/lib/getChangedFields.js.map +1 -1
- package/lib/getDateElementProps.d.ts +2 -1
- package/lib/getDateElementProps.d.ts.map +1 -0
- package/lib/getDecimalSeparator.d.ts +1 -0
- package/lib/getDecimalSeparator.d.ts.map +1 -0
- package/lib/getDecimalSeparator.js +1 -2
- package/lib/getDecimalSeparator.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts +2 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts.map +1 -0
- package/lib/getDiscriminatorFieldFromSchema.js +4 -5
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getInputProps.d.ts +2 -1
- package/lib/getInputProps.d.ts.map +1 -0
- package/lib/getInputProps.js +4 -1
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts +2 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts.map +1 -0
- package/lib/getOptionMatchingSimpleDiscriminator.js +6 -6
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getOptionValueFormat.d.ts +2 -1
- package/lib/getOptionValueFormat.d.ts.map +1 -0
- package/lib/getOptionValueFormat.js +1 -2
- package/lib/getOptionValueFormat.js.map +1 -1
- package/lib/getPropertySchema.d.ts +12 -0
- package/lib/getPropertySchema.d.ts.map +1 -0
- package/lib/getPropertySchema.js +14 -0
- package/lib/getPropertySchema.js.map +1 -0
- package/lib/getSchemaType.d.ts +2 -1
- package/lib/getSchemaType.d.ts.map +1 -0
- package/lib/getSchemaType.js +1 -1
- package/lib/getSchemaType.js.map +1 -1
- package/lib/getSubmitButtonOptions.d.ts +2 -1
- package/lib/getSubmitButtonOptions.d.ts.map +1 -0
- package/lib/getSubmitButtonOptions.js +3 -3
- package/lib/getSubmitButtonOptions.js.map +1 -1
- package/lib/getTemplate.d.ts +2 -1
- package/lib/getTemplate.d.ts.map +1 -0
- package/lib/getTestIds.d.ts +2 -1
- package/lib/getTestIds.d.ts.map +1 -0
- package/lib/getTestIds.js +6 -5
- package/lib/getTestIds.js.map +1 -1
- package/lib/getUiOptions.d.ts +2 -1
- package/lib/getUiOptions.d.ts.map +1 -0
- package/lib/getUiOptions.js +2 -2
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.d.ts +2 -1
- package/lib/getWidget.d.ts.map +1 -0
- package/lib/getWidget.js +6 -7
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +2 -1
- package/lib/guessType.d.ts.map +1 -0
- package/lib/hasWidget.d.ts +2 -1
- package/lib/hasWidget.d.ts.map +1 -0
- package/lib/hasWidget.js +1 -1
- package/lib/hasWidget.js.map +1 -1
- package/lib/hashForSchema.d.ts +4 -2
- package/lib/hashForSchema.d.ts.map +1 -0
- package/lib/hashForSchema.js +17 -8
- package/lib/hashForSchema.js.map +1 -1
- package/lib/idGenerators.d.ts +2 -1
- package/lib/idGenerators.d.ts.map +1 -0
- package/lib/idGenerators.js +2 -3
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +93 -87
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +85 -81
- package/lib/index.js.map +1 -1
- package/lib/isConstant.d.ts +2 -1
- package/lib/isConstant.d.ts.map +1 -0
- package/lib/isConstant.js +1 -1
- package/lib/isConstant.js.map +1 -1
- package/lib/isCustomWidget.d.ts +2 -1
- package/lib/isCustomWidget.d.ts.map +1 -0
- package/lib/isCustomWidget.js +1 -1
- package/lib/isCustomWidget.js.map +1 -1
- package/lib/isFixedItems.d.ts +2 -1
- package/lib/isFixedItems.d.ts.map +1 -0
- package/lib/isFixedItems.js +1 -1
- package/lib/isFixedItems.js.map +1 -1
- package/lib/isFormDataAvailable.d.ts +1 -0
- package/lib/isFormDataAvailable.d.ts.map +1 -0
- package/lib/isFormDataAvailable.js +7 -4
- package/lib/isFormDataAvailable.js.map +1 -1
- package/lib/isObject.d.ts +3 -1
- package/lib/isObject.d.ts.map +1 -0
- package/lib/isObject.js +8 -2
- package/lib/isObject.js.map +1 -1
- package/lib/isPlainObject.d.ts +9 -0
- package/lib/isPlainObject.d.ts.map +1 -0
- package/lib/isPlainObject.js +15 -0
- package/lib/isPlainObject.js.map +1 -0
- package/lib/isRootSchema.d.ts +2 -1
- package/lib/isRootSchema.d.ts.map +1 -0
- package/lib/isRootSchema.js +2 -2
- package/lib/isRootSchema.js.map +1 -1
- package/lib/jsonSchemaAugmentation.d.ts +1 -0
- package/lib/jsonSchemaAugmentation.d.ts.map +1 -0
- package/lib/labelValue.d.ts +1 -0
- package/lib/labelValue.d.ts.map +1 -0
- package/lib/localToUTC.d.ts +1 -0
- package/lib/localToUTC.d.ts.map +1 -0
- package/lib/logUnsupportedDefaultForEnum.d.ts +2 -1
- package/lib/logUnsupportedDefaultForEnum.d.ts.map +1 -0
- package/lib/logUnsupportedDefaultForEnum.js +1 -1
- package/lib/logUnsupportedDefaultForEnum.js.map +1 -1
- package/lib/lookupFromFormContext.d.ts +3 -2
- package/lib/lookupFromFormContext.d.ts.map +1 -0
- package/lib/lookupFromFormContext.js +4 -5
- package/lib/lookupFromFormContext.js.map +1 -1
- package/lib/mergeDefaultsWithFormData.d.ts +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +20 -16
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/mergeObjects.d.ts +2 -1
- package/lib/mergeObjects.d.ts.map +1 -0
- package/lib/mergeObjects.js +1 -1
- package/lib/mergeObjects.js.map +1 -1
- package/lib/mergeSchemas.d.ts +2 -1
- package/lib/mergeSchemas.d.ts.map +1 -0
- package/lib/mergeSchemas.js +4 -5
- package/lib/mergeSchemas.js.map +1 -1
- package/lib/nameGenerators.d.ts +2 -1
- package/lib/nameGenerators.d.ts.map +1 -0
- package/lib/noop.d.ts +5 -0
- package/lib/noop.d.ts.map +1 -0
- package/lib/noop.js +5 -0
- package/lib/noop.js.map +1 -0
- package/lib/optionsList.d.ts +2 -1
- package/lib/optionsList.d.ts.map +1 -0
- package/lib/optionsList.js +15 -15
- package/lib/optionsList.js.map +1 -1
- package/lib/orderProperties.d.ts +1 -0
- package/lib/orderProperties.d.ts.map +1 -0
- package/lib/pad.d.ts +1 -0
- package/lib/pad.d.ts.map +1 -0
- package/lib/parseDateString.d.ts +2 -1
- package/lib/parseDateString.d.ts.map +1 -0
- package/lib/parser/ParserValidator.d.ts +2 -1
- package/lib/parser/ParserValidator.d.ts.map +1 -0
- package/lib/parser/ParserValidator.js +8 -7
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +3 -2
- package/lib/parser/index.d.ts.map +1 -0
- package/lib/parser/index.js +1 -1
- package/lib/parser/index.js.map +1 -1
- package/lib/parser/schemaParser.d.ts +3 -2
- package/lib/parser/schemaParser.d.ts.map +1 -0
- package/lib/parser/schemaParser.js +6 -7
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/pathUtils.d.ts +77 -0
- package/lib/pathUtils.d.ts.map +1 -0
- package/lib/pathUtils.js +192 -0
- package/lib/pathUtils.js.map +1 -0
- package/lib/rangeSpec.d.ts +2 -1
- package/lib/rangeSpec.d.ts.map +1 -0
- package/lib/removeOptionalEmptyObjects.d.ts +2 -1
- package/lib/removeOptionalEmptyObjects.d.ts.map +1 -0
- package/lib/removeOptionalEmptyObjects.js +2 -2
- package/lib/removeOptionalEmptyObjects.js.map +1 -1
- package/lib/replaceStringParameters.d.ts +1 -0
- package/lib/replaceStringParameters.d.ts.map +1 -0
- package/lib/resolveUiSchema.d.ts +2 -1
- package/lib/resolveUiSchema.d.ts.map +1 -0
- package/lib/resolveUiSchema.js +6 -8
- package/lib/resolveUiSchema.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +2 -1
- package/lib/schema/findFieldInSchema.d.ts.map +1 -0
- package/lib/schema/findFieldInSchema.js +10 -11
- package/lib/schema/findFieldInSchema.js.map +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.d.ts +2 -1
- package/lib/schema/findSelectedOptionInXxxOf.d.ts.map +1 -0
- package/lib/schema/findSelectedOptionInXxxOf.js +7 -7
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
- package/lib/schema/getClosestMatchingOption.d.ts +2 -1
- package/lib/schema/getClosestMatchingOption.d.ts.map +1 -0
- package/lib/schema/getClosestMatchingOption.js +18 -23
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +2 -1
- package/lib/schema/getDefaultFormState.d.ts.map +1 -0
- package/lib/schema/getDefaultFormState.js +78 -56
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.d.ts +2 -1
- package/lib/schema/getDisplayLabel.d.ts.map +1 -0
- package/lib/schema/getDisplayLabel.js +7 -7
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/getFirstMatchingOption.d.ts +2 -1
- package/lib/schema/getFirstMatchingOption.d.ts.map +1 -0
- package/lib/schema/getFirstMatchingOption.js +9 -9
- package/lib/schema/getFirstMatchingOption.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +3 -2
- package/lib/schema/getFromSchema.d.ts.map +1 -0
- package/lib/schema/getFromSchema.js +10 -11
- package/lib/schema/getFromSchema.js.map +1 -1
- package/lib/schema/index.d.ts +15 -14
- package/lib/schema/index.d.ts.map +1 -0
- package/lib/schema/index.js +14 -14
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isFilesArray.d.ts +2 -1
- package/lib/schema/isFilesArray.d.ts.map +1 -0
- package/lib/schema/isFilesArray.js +2 -2
- package/lib/schema/isFilesArray.js.map +1 -1
- package/lib/schema/isMultiSelect.d.ts +2 -1
- package/lib/schema/isMultiSelect.d.ts.map +1 -0
- package/lib/schema/isMultiSelect.js +1 -1
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/isSelect.d.ts +2 -1
- package/lib/schema/isSelect.d.ts.map +1 -0
- package/lib/schema/isSelect.js +2 -2
- package/lib/schema/isSelect.js.map +1 -1
- package/lib/schema/omitExtraData.d.ts +2 -1
- package/lib/schema/omitExtraData.d.ts.map +1 -0
- package/lib/schema/omitExtraData.js +100 -64
- package/lib/schema/omitExtraData.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +2 -1
- package/lib/schema/retrieveSchema.d.ts.map +1 -0
- package/lib/schema/retrieveSchema.js +32 -40
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.d.ts +4 -3
- package/lib/schema/sanitizeDataForNewSchema.d.ts.map +1 -0
- package/lib/schema/sanitizeDataForNewSchema.js +41 -39
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/shallowAllOfMerge.d.ts +1 -0
- package/lib/schema/shallowAllOfMerge.d.ts.map +1 -0
- package/lib/schema/toPathSchema.d.ts +2 -1
- package/lib/schema/toPathSchema.d.ts.map +1 -0
- package/lib/schema/toPathSchema.js +14 -14
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/schemaRequiresTrueValue.d.ts +2 -1
- package/lib/schemaRequiresTrueValue.d.ts.map +1 -0
- package/lib/schemaRequiresTrueValue.js +3 -4
- package/lib/schemaRequiresTrueValue.js.map +1 -1
- package/lib/shallowEquals.d.ts +1 -0
- package/lib/shallowEquals.d.ts.map +1 -0
- package/lib/shouldRender.d.ts +2 -1
- package/lib/shouldRender.d.ts.map +1 -0
- package/lib/shouldRender.js +2 -2
- package/lib/shouldRender.js.map +1 -1
- package/lib/shouldRenderOptionalField.d.ts +2 -1
- package/lib/shouldRenderOptionalField.d.ts.map +1 -0
- package/lib/shouldRenderOptionalField.js +11 -10
- package/lib/shouldRenderOptionalField.js.map +1 -1
- package/lib/toConstant.d.ts +2 -1
- package/lib/toConstant.d.ts.map +1 -0
- package/lib/toConstant.js +1 -1
- package/lib/toConstant.js.map +1 -1
- package/lib/toDateString.d.ts +2 -1
- package/lib/toDateString.d.ts.map +1 -0
- package/lib/toErrorList.d.ts +2 -1
- package/lib/toErrorList.d.ts.map +1 -0
- package/lib/toErrorList.js +20 -21
- package/lib/toErrorList.js.map +1 -1
- package/lib/toErrorSchema.d.ts +2 -1
- package/lib/toErrorSchema.d.ts.map +1 -0
- package/lib/toErrorSchema.js +4 -9
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/toFieldPathId.d.ts +2 -1
- package/lib/toFieldPathId.d.ts.map +1 -0
- package/lib/toFieldPathId.js +2 -2
- package/lib/toFieldPathId.js.map +1 -1
- package/lib/types.d.ts +15 -5
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/unwrapErrorHandler.d.ts +2 -1
- package/lib/unwrapErrorHandler.d.ts.map +1 -0
- package/lib/unwrapErrorHandler.js +13 -4
- package/lib/unwrapErrorHandler.js.map +1 -1
- package/lib/useAltDateWidgetProps.d.ts +3 -2
- package/lib/useAltDateWidgetProps.d.ts.map +1 -0
- package/lib/useAltDateWidgetProps.js +5 -5
- package/lib/useAltDateWidgetProps.js.map +1 -1
- package/lib/useDeepCompareMemo.d.ts +1 -0
- package/lib/useDeepCompareMemo.d.ts.map +1 -0
- package/lib/useDeepCompareMemo.js +1 -1
- package/lib/useDeepCompareMemo.js.map +1 -1
- package/lib/useFileWidgetProps.d.ts +1 -0
- package/lib/useFileWidgetProps.d.ts.map +1 -0
- package/lib/useFileWidgetProps.js +3 -4
- package/lib/useFileWidgetProps.js.map +1 -1
- package/lib/utcToLocal.d.ts +1 -0
- package/lib/utcToLocal.d.ts.map +1 -0
- package/lib/utcToLocal.js +1 -1
- package/lib/utcToLocal.js.map +1 -1
- package/lib/validationDataMerge.d.ts +2 -1
- package/lib/validationDataMerge.d.ts.map +1 -0
- package/lib/validationDataMerge.js +3 -4
- package/lib/validationDataMerge.js.map +1 -1
- package/lib/withIdRefPrefix.d.ts +2 -1
- package/lib/withIdRefPrefix.d.ts.map +1 -0
- package/lib/withIdRefPrefix.js +2 -2
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +5 -6
- package/src/ErrorSchemaBuilder.ts +25 -24
- package/src/SelectedOptionDescription.tsx +5 -5
- package/src/allowAdditionalItems.ts +2 -2
- package/src/asNumber.ts +1 -1
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +5 -4
- package/src/createErrorHandler.ts +5 -7
- package/src/createSchemaUtils.ts +8 -10
- package/src/dateRangeOptions.ts +2 -2
- package/src/englishStringTranslator.ts +2 -2
- package/src/enumOptionSelectedValue.ts +2 -2
- package/src/enumOptionValueDecoder.ts +2 -2
- package/src/enumOptionValueEncoder.ts +2 -4
- package/src/enumOptionsDeselectValue.ts +3 -3
- package/src/enumOptionsIndexForValue.ts +2 -2
- package/src/enumOptionsIsSelected.ts +2 -2
- package/src/enumOptionsSelectValue.ts +3 -5
- package/src/enumOptionsValueForIndex.ts +1 -1
- package/src/findSchemaDefinition.ts +8 -12
- package/src/getChangedFields.ts +57 -18
- package/src/getDateElementProps.ts +1 -1
- package/src/getDiscriminatorFieldFromSchema.ts +5 -7
- package/src/getInputProps.ts +6 -2
- package/src/getOptionMatchingSimpleDiscriminator.ts +7 -7
- package/src/getOptionValueFormat.ts +1 -1
- package/src/getPropertySchema.ts +18 -0
- package/src/getSchemaType.ts +2 -2
- package/src/getSubmitButtonOptions.ts +3 -3
- package/src/getTemplate.ts +1 -1
- package/src/getTestIds.ts +7 -6
- package/src/getUiOptions.ts +3 -3
- package/src/getWidget.tsx +6 -6
- package/src/hasWidget.ts +2 -2
- package/src/hashForSchema.ts +20 -9
- package/src/idGenerators.ts +3 -5
- package/src/index.ts +99 -85
- package/src/isConstant.ts +2 -2
- package/src/isCustomWidget.ts +2 -2
- package/src/isFixedItems.ts +2 -2
- package/src/isFormDataAvailable.ts +7 -5
- package/src/isObject.ts +15 -3
- package/src/isPlainObject.ts +14 -0
- package/src/isRootSchema.ts +3 -3
- package/src/logUnsupportedDefaultForEnum.ts +2 -2
- package/src/lookupFromFormContext.ts +7 -8
- package/src/mergeDefaultsWithFormData.ts +22 -18
- package/src/mergeObjects.ts +2 -2
- package/src/mergeSchemas.ts +5 -7
- package/src/nameGenerators.ts +1 -1
- package/src/noop.ts +4 -0
- package/src/optionsList.ts +9 -9
- package/src/orderProperties.ts +1 -1
- package/src/parseDateString.ts +1 -1
- package/src/parser/ParserValidator.ts +5 -7
- package/src/parser/index.ts +2 -2
- package/src/parser/schemaParser.ts +8 -10
- package/src/pathUtils.ts +203 -0
- package/src/rangeSpec.ts +1 -1
- package/src/removeOptionalEmptyObjects.ts +3 -3
- package/src/resolveUiSchema.ts +5 -7
- package/src/schema/findFieldInSchema.ts +11 -13
- package/src/schema/findSelectedOptionInXxxOf.ts +9 -10
- package/src/schema/getClosestMatchingOption.ts +73 -83
- package/src/schema/getDefaultFormState.ts +62 -34
- package/src/schema/getDisplayLabel.ts +7 -7
- package/src/schema/getFirstMatchingOption.ts +10 -11
- package/src/schema/getFromSchema.ts +12 -14
- package/src/schema/index.ts +14 -14
- package/src/schema/isFilesArray.ts +3 -3
- package/src/schema/isMultiSelect.ts +2 -2
- package/src/schema/isSelect.ts +3 -3
- package/src/schema/omitExtraData.ts +104 -68
- package/src/schema/retrieveSchema.ts +47 -60
- package/src/schema/sanitizeDataForNewSchema.ts +42 -41
- package/src/schema/toPathSchema.ts +14 -14
- package/src/schemaRequiresTrueValue.ts +1 -1
- package/src/shouldRender.ts +3 -3
- package/src/shouldRenderOptionalField.ts +14 -14
- package/src/toConstant.ts +2 -2
- package/src/toDateString.ts +1 -1
- package/src/toErrorList.ts +22 -25
- package/src/toErrorSchema.ts +5 -11
- package/src/toFieldPathId.ts +2 -2
- package/src/types.ts +14 -5
- package/src/unwrapErrorHandler.ts +15 -6
- package/src/useAltDateWidgetProps.tsx +7 -7
- package/src/useDeepCompareMemo.ts +1 -1
- package/src/useFileWidgetProps.ts +1 -1
- package/src/utcToLocal.ts +1 -1
- package/src/validationDataMerge.ts +4 -6
- package/src/withIdRefPrefix.ts +3 -4
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/tsconfig.json +0 -9
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import findSchemaDefinition from '../findSchemaDefinition';
|
|
8
|
-
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
|
|
9
|
-
import getSchemaType from '../getSchemaType';
|
|
10
|
-
import isObject from '../isObject';
|
|
1
|
+
import { NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG } from '../constants.ts';
|
|
2
|
+
import findSchemaDefinition from '../findSchemaDefinition.ts';
|
|
3
|
+
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
|
|
4
|
+
import getSchemaType from '../getSchemaType.ts';
|
|
5
|
+
import isObject from '../isObject.ts';
|
|
6
|
+
import { getByPath, hasByPath, setByPath, toPath } from '../pathUtils.ts';
|
|
11
7
|
import type {
|
|
12
8
|
Experimental_CustomMergeAllOf,
|
|
13
9
|
FormContextType,
|
|
@@ -16,11 +12,11 @@ import type {
|
|
|
16
12
|
RJSFSchema,
|
|
17
13
|
StrictRJSFSchema,
|
|
18
14
|
ValidatorType,
|
|
19
|
-
} from '../types';
|
|
20
|
-
import getClosestMatchingOption from './getClosestMatchingOption';
|
|
21
|
-
import isSelect from './isSelect';
|
|
22
|
-
import { relaxOptionsForScoring, resolveAllReferences } from './retrieveSchema';
|
|
23
|
-
import shallowAllOfMerge from './shallowAllOfMerge';
|
|
15
|
+
} from '../types.ts';
|
|
16
|
+
import getClosestMatchingOption from './getClosestMatchingOption.ts';
|
|
17
|
+
import isSelect from './isSelect.ts';
|
|
18
|
+
import { relaxOptionsForScoring, resolveAllReferences } from './retrieveSchema.ts';
|
|
19
|
+
import shallowAllOfMerge from './shallowAllOfMerge.ts';
|
|
24
20
|
|
|
25
21
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
26
22
|
*
|
|
@@ -34,7 +30,15 @@ export function getUsedFormData<T = any>(formData: T | undefined, fields: string
|
|
|
34
30
|
return formData;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
// Keep only the values at the given field paths; `fields` contains either dotted strings or the
|
|
34
|
+
// deep path lists produced by `getFieldNames()`
|
|
35
|
+
const data: GenericObjectType = {};
|
|
36
|
+
fields.forEach((field) => {
|
|
37
|
+
const path = Array.isArray(field) ? field : toPath(field);
|
|
38
|
+
if (hasByPath(formData, path)) {
|
|
39
|
+
setByPath(data, path, getByPath(formData, path));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
38
42
|
if (Array.isArray(formData)) {
|
|
39
43
|
return Object.keys(data).map((key: string) => data[key]) as unknown as T;
|
|
40
44
|
}
|
|
@@ -50,8 +54,13 @@ export function getUsedFormData<T = any>(formData: T | undefined, fields: string
|
|
|
50
54
|
*/
|
|
51
55
|
// oxlint-disable-next-line typescript/no-deprecated
|
|
52
56
|
export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T): string[][] {
|
|
53
|
-
const formValueHasData = (value:
|
|
54
|
-
typeof value !== 'object' ||
|
|
57
|
+
const formValueHasData = (value: unknown, isLeaf: boolean) => {
|
|
58
|
+
if (typeof value !== 'object' || value === null) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const isEmptyValue = Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0;
|
|
62
|
+
return isEmptyValue || isLeaf;
|
|
63
|
+
};
|
|
55
64
|
const getAllPaths = (_obj: GenericObjectType, acc: string[][] = [], paths: string[][] = [[]]) => {
|
|
56
65
|
const objKeys = Object.keys(_obj);
|
|
57
66
|
objKeys.forEach((key: string) => {
|
|
@@ -66,12 +75,12 @@ export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T):
|
|
|
66
75
|
}
|
|
67
76
|
} else if (key === NAME_KEY && data !== '') {
|
|
68
77
|
paths.forEach((path) => {
|
|
69
|
-
const formValue =
|
|
78
|
+
const formValue = getByPath(formData, path);
|
|
70
79
|
const isLeaf = objKeys.length === 1;
|
|
71
80
|
// adds path to fieldNames if it points to a value or an empty object/array which is not a leaf
|
|
72
81
|
if (
|
|
73
82
|
formValueHasData(formValue, isLeaf) ||
|
|
74
|
-
(Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf)))
|
|
83
|
+
(Array.isArray(formValue) && formValue.every((val: unknown) => formValueHasData(val, isLeaf)))
|
|
75
84
|
) {
|
|
76
85
|
acc.push(path);
|
|
77
86
|
}
|
|
@@ -91,14 +100,14 @@ export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T):
|
|
|
91
100
|
* @returns - True if the value is considered empty, false otherwise
|
|
92
101
|
*/
|
|
93
102
|
export function isValueEmpty(value: unknown): boolean {
|
|
94
|
-
if (
|
|
103
|
+
if (value == null || value === '') {
|
|
95
104
|
return true;
|
|
96
105
|
}
|
|
97
106
|
if (Array.isArray(value)) {
|
|
98
107
|
return value.length === 0;
|
|
99
108
|
}
|
|
100
109
|
if (isObject(value)) {
|
|
101
|
-
return Object.values(value
|
|
110
|
+
return Object.values(value).every(isValueEmpty);
|
|
102
111
|
}
|
|
103
112
|
return false;
|
|
104
113
|
}
|
|
@@ -163,7 +172,7 @@ export default function omitExtraData<
|
|
|
163
172
|
}
|
|
164
173
|
|
|
165
174
|
/** Copies schema-defined properties from `source` into `target`, applying `omit` recursively for
|
|
166
|
-
* each value. Handles `properties`, `patternProperties`,
|
|
175
|
+
* each value. Handles `properties`, `patternProperties`, and `additionalProperties`.
|
|
167
176
|
* Optional object-valued properties are pruned when every key in the filtered result is both
|
|
168
177
|
* optional (per the inner schema's `required`) and empty (per `isValueEmpty`). This preserves
|
|
169
178
|
* optional objects whose required children have empty values, while still dropping objects whose
|
|
@@ -177,7 +186,7 @@ export default function omitExtraData<
|
|
|
177
186
|
* @returns - `target` after all schema-defined properties have been processed
|
|
178
187
|
*/
|
|
179
188
|
function handleObject(childSchema: S, source: GenericObjectType, target: GenericObjectType): GenericObjectType {
|
|
180
|
-
const { properties, additionalProperties, patternProperties
|
|
189
|
+
const { properties, additionalProperties, patternProperties } = childSchema;
|
|
181
190
|
const requiredSet = new Set(childSchema.required ?? []);
|
|
182
191
|
|
|
183
192
|
/** Recursively omits extra data from `value` via `omit`, then conditionally writes the result to
|
|
@@ -204,9 +213,7 @@ export default function omitExtraData<
|
|
|
204
213
|
const innerRequired = new Set(sd.required ?? []);
|
|
205
214
|
// Drop this optional object when every key in v is both optional in the inner schema
|
|
206
215
|
// and has an empty value. Vacuously true for {} so empty objects are always dropped.
|
|
207
|
-
const shouldDrop = Object.entries(v
|
|
208
|
-
([k, val]) => !innerRequired.has(k) && isValueEmpty(val),
|
|
209
|
-
);
|
|
216
|
+
const shouldDrop = Object.entries(v).every(([k, val]) => !innerRequired.has(k) && isValueEmpty(val));
|
|
210
217
|
if (shouldDrop) {
|
|
211
218
|
return;
|
|
212
219
|
}
|
|
@@ -262,46 +269,51 @@ export default function omitExtraData<
|
|
|
262
269
|
}
|
|
263
270
|
}
|
|
264
271
|
|
|
265
|
-
// When propertyNames is present, the schema only constrains key names — all source keys are valid.
|
|
266
|
-
if (propertyNames !== undefined) {
|
|
267
|
-
for (const [key, value] of Object.entries(source)) {
|
|
268
|
-
// oxlint-disable-next-line no-param-reassign
|
|
269
|
-
target[key] = value;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
272
|
return target;
|
|
274
273
|
}
|
|
275
274
|
|
|
276
275
|
/** Filters array elements from `source` into `target` according to `schema.items` and
|
|
277
|
-
* `schema.additionalItems`.
|
|
278
|
-
*
|
|
279
|
-
* For
|
|
276
|
+
* `schema.additionalItems`. Only called when `items` is defined (guarded in `omit`). Uses index
|
|
277
|
+
* assignment (not push) so a pre-populated `target` from a prior branch is overwritten rather than
|
|
278
|
+
* appended to, preventing item duplication. For tuple schemas (`items` is an array) elements up to
|
|
279
|
+
* `min(items.length, source.length)` are filtered by their per-index schema; elements beyond the
|
|
280
|
+
* tuple are covered by `additionalItems` when present, or the target is truncated when absent.
|
|
281
|
+
* For list schemas (`items` is a single schema) every source element is filtered and `target.length`
|
|
282
|
+
* is set to `source.length`.
|
|
280
283
|
*
|
|
281
284
|
* @param childSchema - The array schema describing `items` and optionally `additionalItems`
|
|
282
285
|
* @param source - The source array to read elements from
|
|
283
|
-
* @param target - The accumulator array to
|
|
284
|
-
* @returns - `target` after all applicable source elements have been
|
|
286
|
+
* @param target - The accumulator array to write filtered elements into
|
|
287
|
+
* @returns - `target` after all applicable source elements have been written
|
|
285
288
|
*/
|
|
286
289
|
function handleArray(childSchema: S, source: unknown[], target: unknown[]): unknown[] {
|
|
287
290
|
const { items, additionalItems } = childSchema;
|
|
288
|
-
if (items
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
for (let i = 0; i < source.length; i += 1) {
|
|
295
|
-
target.push(omit(items as S | boolean, source[i]));
|
|
296
|
-
}
|
|
291
|
+
if (Array.isArray(items)) {
|
|
292
|
+
const tupleLength = Math.min(items.length, source.length);
|
|
293
|
+
let i = 0;
|
|
294
|
+
for (; i < tupleLength; i += 1) {
|
|
295
|
+
// oxlint-disable-next-line no-param-reassign
|
|
296
|
+
target[i] = omit(items[i] as S | boolean, source[i]);
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
target
|
|
298
|
+
// Without additionalItems, truncate at the tuple boundary to drop any pre-existing items.
|
|
299
|
+
if (!additionalItems) {
|
|
300
|
+
// oxlint-disable-next-line no-param-reassign
|
|
301
|
+
target.length = tupleLength;
|
|
302
|
+
return target;
|
|
303
|
+
}
|
|
304
|
+
for (; i < source.length; i += 1) {
|
|
305
|
+
// oxlint-disable-next-line no-param-reassign
|
|
306
|
+
target[i] = omit(additionalItems as S | boolean, source[i]);
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
310
|
+
// oxlint-disable-next-line no-param-reassign
|
|
311
|
+
target[i] = omit(items as S | boolean, source[i]);
|
|
303
312
|
}
|
|
304
313
|
}
|
|
314
|
+
// Truncate any pre-existing items beyond the source length.
|
|
315
|
+
// oxlint-disable-next-line no-param-reassign
|
|
316
|
+
target.length = source.length;
|
|
305
317
|
return target;
|
|
306
318
|
}
|
|
307
319
|
|
|
@@ -326,7 +338,7 @@ export default function omitExtraData<
|
|
|
326
338
|
? validator.isValid(condition as S, source as T, rootSchema)
|
|
327
339
|
: condition;
|
|
328
340
|
const branch = isThenBranch ? then : otherwise;
|
|
329
|
-
return branch === undefined ? target : omit(branch as S | boolean, source, target);
|
|
341
|
+
return branch === undefined ? target : omit(branch as S | boolean, source, target, false);
|
|
330
342
|
}
|
|
331
343
|
|
|
332
344
|
/** Applies the best-matching `oneOf` option to `source`, merging the result into `target`. When
|
|
@@ -364,7 +376,7 @@ export default function omitExtraData<
|
|
|
364
376
|
const resolved: S = isObject(winning)
|
|
365
377
|
? resolveAllReferences<S>(winning, rootSchema, [])
|
|
366
378
|
: scoringOptions[bestIndex];
|
|
367
|
-
return omit(resolved, source, target);
|
|
379
|
+
return omit(resolved, source, target, false);
|
|
368
380
|
}
|
|
369
381
|
|
|
370
382
|
/** Applies `anyOf` branches from `schema` to `source`, merging results into `target`. When `anyOf`
|
|
@@ -390,7 +402,7 @@ export default function omitExtraData<
|
|
|
390
402
|
) {
|
|
391
403
|
let result = target;
|
|
392
404
|
for (const branch of anyOf as (S | boolean)[]) {
|
|
393
|
-
result = omit(branch, source, result);
|
|
405
|
+
result = omit(branch, source, result, false);
|
|
394
406
|
}
|
|
395
407
|
return result;
|
|
396
408
|
}
|
|
@@ -416,7 +428,7 @@ export default function omitExtraData<
|
|
|
416
428
|
for (const [key, deps] of Object.entries(dependencies)) {
|
|
417
429
|
// Skip property dependencies (string arrays); only process schema dependencies.
|
|
418
430
|
if (key in source && !Array.isArray(deps)) {
|
|
419
|
-
result = omit(deps as S | boolean, source, result);
|
|
431
|
+
result = omit(deps as S | boolean, source, result, false);
|
|
420
432
|
}
|
|
421
433
|
}
|
|
422
434
|
return result;
|
|
@@ -425,26 +437,30 @@ export default function omitExtraData<
|
|
|
425
437
|
/** Core recursive filter. Resolves `$ref`s, merges `allOf`, then delegates to the type-specific
|
|
426
438
|
* handlers (`handleObject`, `handleArray`) and keyword handlers (`handleAnyOf`, `handleOneOf`,
|
|
427
439
|
* `handleConditions`, `handleDependencies`). Returns `undefined` when `source` is undefined or
|
|
428
|
-
* `schemaDef` is `false`;
|
|
440
|
+
* `schemaDef` is `false`; when `schemaDef` is `true` or empty returns `target ?? source` (when
|
|
441
|
+
* `useSourceAsFallback` is true) or `target` (when false) to avoid aliasing `source` as the
|
|
442
|
+
* accumulator across multiple compositional branches.
|
|
429
443
|
*
|
|
430
444
|
* @param schemaDef - The schema (or boolean shorthand) to filter `source` against
|
|
431
445
|
* @param source - The raw form data value to filter
|
|
432
446
|
* @param [target] - An optional accumulator carrying results from prior oneOf/anyOf processing
|
|
447
|
+
* @param [useSourceAsFallback=true] - When false a permissive schema (`true`/`{}`) returns `target`
|
|
448
|
+
* rather than `source`, preventing compositional branches from aliasing the accumulator to `source`
|
|
433
449
|
* @returns - The filtered value, or `undefined` when the schema rejects the value
|
|
434
450
|
*/
|
|
435
|
-
function omit(schemaDef: S | boolean, source: unknown, target?: unknown): unknown {
|
|
451
|
+
function omit(schemaDef: S | boolean, source: unknown, target?: unknown, useSourceAsFallback = true): unknown {
|
|
436
452
|
if (source === undefined || schemaDef === false) {
|
|
437
453
|
return undefined;
|
|
438
454
|
}
|
|
439
|
-
if (schemaDef === true ||
|
|
440
|
-
return source;
|
|
455
|
+
if (schemaDef === true || !schemaDef || Object.keys(schemaDef).length === 0) {
|
|
456
|
+
return target ?? (useSourceAsFallback ? source : undefined);
|
|
441
457
|
}
|
|
442
458
|
|
|
443
459
|
let localSchema = schemaDef;
|
|
444
460
|
const { $ref: ref, allOf } = localSchema;
|
|
445
461
|
|
|
446
462
|
if (ref !== undefined) {
|
|
447
|
-
return omit(findSchemaDefinition<S>(ref, rootSchema), source, target);
|
|
463
|
+
return omit(findSchemaDefinition<S>(ref, rootSchema), source, target, useSourceAsFallback);
|
|
448
464
|
}
|
|
449
465
|
if (allOf) {
|
|
450
466
|
localSchema = doMergeAllOf<S>(localSchema, experimental_customMergeAllOf);
|
|
@@ -456,7 +472,7 @@ export default function omitExtraData<
|
|
|
456
472
|
if (remainingAllOf) {
|
|
457
473
|
for (let i = 0; i < remainingAllOf.length; i++) {
|
|
458
474
|
// oxlint-disable-next-line no-param-reassign
|
|
459
|
-
target = omit(remainingAllOf[i] as S | boolean, source, target);
|
|
475
|
+
target = omit(remainingAllOf[i] as S | boolean, source, target, false);
|
|
460
476
|
}
|
|
461
477
|
}
|
|
462
478
|
}
|
|
@@ -473,12 +489,32 @@ export default function omitExtraData<
|
|
|
473
489
|
if (!Array.isArray(source)) {
|
|
474
490
|
return undefined;
|
|
475
491
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
492
|
+
if (localSchema.items !== undefined) {
|
|
493
|
+
filtered = handleArray(localSchema, source, Array.isArray(filtered) ? filtered : []);
|
|
494
|
+
}
|
|
479
495
|
}
|
|
480
496
|
|
|
481
|
-
|
|
497
|
+
// Post-prune after conditions (oneOf/anyOf/if-then) but BEFORE dependencies: keys added by
|
|
498
|
+
// dependency sub-schemas are legitimate extensions of the allowed property set and must not be
|
|
499
|
+
// pruned. Keys added only by winning conditional branches are still removed here so the result
|
|
500
|
+
// honours additionalProperties:false.
|
|
501
|
+
const afterConditions = handleConditions(localSchema, source, filtered);
|
|
502
|
+
if (localSchema.additionalProperties === false && isObjectValue(afterConditions)) {
|
|
503
|
+
const knownKeys = new Set(Object.keys(localSchema.properties ?? {}));
|
|
504
|
+
const patterns = localSchema.patternProperties
|
|
505
|
+
? Object.keys(localSchema.patternProperties).map((p) => new RegExp(p))
|
|
506
|
+
: [];
|
|
507
|
+
for (const key of Object.keys(afterConditions)) {
|
|
508
|
+
if (!knownKeys.has(key) && !patterns.some((re) => re.test(key))) {
|
|
509
|
+
// oxlint-disable-next-line no-param-reassign
|
|
510
|
+
delete afterConditions[key];
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const result = handleDependencies(localSchema, source, afterConditions);
|
|
516
|
+
|
|
517
|
+
return result ?? (useSourceAsFallback ? source : undefined);
|
|
482
518
|
}
|
|
483
519
|
|
|
484
520
|
return omit(schema, formData) as T | undefined;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import flattenDeep from 'lodash/flattenDeep';
|
|
2
|
-
import get from 'lodash/get';
|
|
3
|
-
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import merge from 'lodash/merge';
|
|
5
|
-
import set from 'lodash/set';
|
|
6
|
-
import times from 'lodash/times';
|
|
7
|
-
import transform from 'lodash/transform';
|
|
8
|
-
import uniq from 'lodash/uniq';
|
|
9
|
-
|
|
10
1
|
import {
|
|
11
2
|
ADDITIONAL_PROPERTIES_KEY,
|
|
12
3
|
ADDITIONAL_PROPERTY_FLAG,
|
|
@@ -22,13 +13,14 @@ import {
|
|
|
22
13
|
REF_KEY,
|
|
23
14
|
RJSF_REF_CYCLE_KEY,
|
|
24
15
|
RJSF_REF_KEY,
|
|
25
|
-
} from '../constants';
|
|
26
|
-
import deepEquals from '../deepEquals';
|
|
27
|
-
import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';
|
|
28
|
-
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
|
|
29
|
-
import guessType from '../guessType';
|
|
30
|
-
import isObject from '../isObject';
|
|
31
|
-
import mergeSchemas from '../mergeSchemas';
|
|
16
|
+
} from '../constants.ts';
|
|
17
|
+
import deepEquals from '../deepEquals.ts';
|
|
18
|
+
import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition.ts';
|
|
19
|
+
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
|
|
20
|
+
import guessType from '../guessType.ts';
|
|
21
|
+
import isObject from '../isObject.ts';
|
|
22
|
+
import mergeSchemas from '../mergeSchemas.ts';
|
|
23
|
+
import { getByPath } from '../pathUtils.ts';
|
|
32
24
|
import type {
|
|
33
25
|
Experimental_CustomMergeAllOf,
|
|
34
26
|
FormContextType,
|
|
@@ -37,9 +29,9 @@ import type {
|
|
|
37
29
|
RJSFSchema,
|
|
38
30
|
StrictRJSFSchema,
|
|
39
31
|
ValidatorType,
|
|
40
|
-
} from '../types';
|
|
41
|
-
import getFirstMatchingOption from './getFirstMatchingOption';
|
|
42
|
-
import shallowAllOfMerge from './shallowAllOfMerge';
|
|
32
|
+
} from '../types.ts';
|
|
33
|
+
import getFirstMatchingOption from './getFirstMatchingOption.ts';
|
|
34
|
+
import shallowAllOfMerge from './shallowAllOfMerge.ts';
|
|
43
35
|
|
|
44
36
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
|
|
45
37
|
* resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
|
|
@@ -198,7 +190,7 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
|
|
|
198
190
|
(permutations, list) => {
|
|
199
191
|
// When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values
|
|
200
192
|
if (list.length > 1) {
|
|
201
|
-
return list.flatMap((element) =>
|
|
193
|
+
return list.flatMap((element) => permutations.map((permutation) => [...permutation, element]));
|
|
202
194
|
}
|
|
203
195
|
// Otherwise just push in the single value into the current set of permutations
|
|
204
196
|
permutations.forEach((permutation) => permutation.push(list[0]));
|
|
@@ -220,16 +212,10 @@ export function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSc
|
|
|
220
212
|
schema: S,
|
|
221
213
|
key: string,
|
|
222
214
|
): Required<S['patternProperties']> {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
// Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path
|
|
228
|
-
set(obj, [pattern], schema.patternProperties![pattern]);
|
|
229
|
-
return obj;
|
|
230
|
-
},
|
|
231
|
-
{} as Required<S['patternProperties']>,
|
|
232
|
-
);
|
|
215
|
+
const patternProperties = schema.patternProperties ?? {};
|
|
216
|
+
return Object.fromEntries(
|
|
217
|
+
Object.entries(patternProperties).filter(([pattern]) => RegExp(pattern).test(key)),
|
|
218
|
+
) as Required<S['patternProperties']>;
|
|
233
219
|
}
|
|
234
220
|
|
|
235
221
|
/** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag
|
|
@@ -402,27 +388,28 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
|
|
|
402
388
|
|
|
403
389
|
if (PROPERTIES_KEY in resolvedSchema) {
|
|
404
390
|
const childrenLists: string[][] = [];
|
|
405
|
-
const updatedProps =
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
391
|
+
const updatedProps: RJSFSchema = {};
|
|
392
|
+
for (const [key, value] of Object.entries(resolvedSchema[PROPERTIES_KEY] ?? {})) {
|
|
393
|
+
const childList: string[] = [...recurseList];
|
|
394
|
+
// Mark cycles only when NOT in resolveAnyOfOrOneOfRefs mode. When resolveAnyOfOrOneOfRefs=true
|
|
395
|
+
// (e.g. from ObjectField), options are resolved against a shared recurseList that accumulates
|
|
396
|
+
// refs across branches, causing false positives. In simple (non-anyOf) resolution, a $ref cycle
|
|
397
|
+
// in an object property always causes an infinite render loop and must be caught.
|
|
398
|
+
updatedProps[key] = resolveAllReferences(
|
|
399
|
+
value as S,
|
|
400
|
+
rootSchema,
|
|
401
|
+
childList,
|
|
402
|
+
currentBaseURI,
|
|
403
|
+
resolveAnyOfOrOneOfRefs,
|
|
404
|
+
!resolveAnyOfOrOneOfRefs,
|
|
405
|
+
);
|
|
406
|
+
childrenLists.push(childList);
|
|
407
|
+
}
|
|
408
|
+
for (const ref of new Set(childrenLists.flat())) {
|
|
409
|
+
if (!recurseList.includes(ref)) {
|
|
410
|
+
recurseList.push(ref);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
426
413
|
resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
|
|
427
414
|
}
|
|
428
415
|
|
|
@@ -502,12 +489,12 @@ export function stubExistingAdditionalProperties<
|
|
|
502
489
|
}
|
|
503
490
|
if (PATTERN_PROPERTIES_KEY in schema) {
|
|
504
491
|
const matchingProperties = getMatchingPatternProperties(schema, key);
|
|
505
|
-
if (
|
|
492
|
+
if (Object.keys(matchingProperties).length > 0) {
|
|
506
493
|
schema.properties[key] = retrieveSchema<T, S, F>(
|
|
507
494
|
validator,
|
|
508
495
|
{ [ALL_OF_KEY]: Object.values(matchingProperties) } as S,
|
|
509
496
|
rootSchema,
|
|
510
|
-
|
|
497
|
+
formData[key],
|
|
511
498
|
experimental_customMergeAllOf,
|
|
512
499
|
);
|
|
513
500
|
(schema.properties[key] as RJSFMarkedSchema)[ADDITIONAL_PROPERTY_FLAG] = true;
|
|
@@ -520,9 +507,9 @@ export function stubExistingAdditionalProperties<
|
|
|
520
507
|
if (REF_KEY in schema.additionalProperties!) {
|
|
521
508
|
additionalProperties = retrieveSchema<T, S, F>(
|
|
522
509
|
validator,
|
|
523
|
-
{ [REF_KEY]:
|
|
510
|
+
{ [REF_KEY]: (schema.additionalProperties as S)[REF_KEY] } as S,
|
|
524
511
|
rootSchema,
|
|
525
|
-
|
|
512
|
+
formData[key],
|
|
526
513
|
experimental_customMergeAllOf,
|
|
527
514
|
);
|
|
528
515
|
} else if ('type' in schema.additionalProperties!) {
|
|
@@ -533,10 +520,10 @@ export function stubExistingAdditionalProperties<
|
|
|
533
520
|
...schema.additionalProperties,
|
|
534
521
|
};
|
|
535
522
|
} else {
|
|
536
|
-
additionalProperties = { type: guessType(
|
|
523
|
+
additionalProperties = { type: guessType(formData[key]) };
|
|
537
524
|
}
|
|
538
525
|
} else {
|
|
539
|
-
additionalProperties = { type: guessType(
|
|
526
|
+
additionalProperties = { type: guessType(formData[key]) };
|
|
540
527
|
}
|
|
541
528
|
|
|
542
529
|
// The type of our new key should match the additionalProperties value;
|
|
@@ -668,12 +655,12 @@ export function retrieveSchemaInternal<
|
|
|
668
655
|
resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(
|
|
669
656
|
(acc, key) => {
|
|
670
657
|
const matchingProperties = getMatchingPatternProperties(acc, key);
|
|
671
|
-
if (
|
|
658
|
+
if (Object.keys(matchingProperties).length > 0) {
|
|
672
659
|
acc.properties[key] = retrieveSchema<T, S, F>(
|
|
673
660
|
validator,
|
|
674
661
|
{ allOf: [acc.properties[key], ...Object.values(matchingProperties)] } as S,
|
|
675
662
|
rootSchema,
|
|
676
|
-
|
|
663
|
+
getByPath<T>(rawFormData, key),
|
|
677
664
|
experimental_customMergeAllOf,
|
|
678
665
|
);
|
|
679
666
|
}
|
|
@@ -850,7 +837,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
850
837
|
// Process dependencies updating the local schema properties as appropriate.
|
|
851
838
|
for (const dependencyKey in dependencies) {
|
|
852
839
|
if (
|
|
853
|
-
(expandAllBranches ||
|
|
840
|
+
(expandAllBranches || getByPath(formData, dependencyKey) !== undefined) &&
|
|
854
841
|
(!resolvedSchema.properties || dependencyKey in resolvedSchema.properties)
|
|
855
842
|
) {
|
|
856
843
|
const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
|