@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,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import deepEquals from '../deepEquals';
|
|
1
|
+
import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY, REF_KEY } from '../constants.ts';
|
|
2
|
+
import deepEquals from '../deepEquals.ts';
|
|
3
|
+
import getPropertySchema from '../getPropertySchema.ts';
|
|
4
|
+
import { getByPath, hasByPath } from '../pathUtils.ts';
|
|
6
5
|
import type {
|
|
7
6
|
Experimental_CustomMergeAllOf,
|
|
8
7
|
FormContextType,
|
|
@@ -10,8 +9,8 @@ import type {
|
|
|
10
9
|
RJSFSchema,
|
|
11
10
|
StrictRJSFSchema,
|
|
12
11
|
ValidatorType,
|
|
13
|
-
} from '../types';
|
|
14
|
-
import retrieveSchema from './retrieveSchema';
|
|
12
|
+
} from '../types.ts';
|
|
13
|
+
import retrieveSchema from './retrieveSchema.ts';
|
|
15
14
|
|
|
16
15
|
const NO_VALUE = Symbol('no Value');
|
|
17
16
|
|
|
@@ -43,7 +42,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
|
|
|
43
42
|
return NO_VALUE;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
const defaultValue =
|
|
45
|
+
const defaultValue = getByPath(schema, DEFAULT_KEY, NO_VALUE);
|
|
47
46
|
if (defaultValue !== NO_VALUE && enumValues.some((value) => deepEquals(value, defaultValue))) {
|
|
48
47
|
return defaultValue;
|
|
49
48
|
}
|
|
@@ -70,7 +69,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
|
|
|
70
69
|
* - Otherwise, check for default or const values:
|
|
71
70
|
* - Get the old and new `default` values from the schema and check:
|
|
72
71
|
* - If the new `default` value does not match the form value:
|
|
73
|
-
* - If the old `default`
|
|
72
|
+
* - If the key is new and its form value is undefined, or the old `default` matches the form value, then:
|
|
74
73
|
* - Replace `removeOldSchemaData[key]` with the new `default`
|
|
75
74
|
* - Otherwise, if the new schema is `readOnly` then replace `removeOldSchemaData[key]` with undefined
|
|
76
75
|
* - Get the old and new `const` values from the schema and check:
|
|
@@ -79,7 +78,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
|
|
|
79
78
|
* - Replace `removeOldSchemaData[key]` with the new `const`
|
|
80
79
|
* - Otherwise, replace `removeOldSchemaData[key]` with undefined
|
|
81
80
|
* - Once all keys have been processed, return an object built as follows:
|
|
82
|
-
* - `{ ...
|
|
81
|
+
* - `{ ...data, ...removeOldSchemaData, ...nestedData }`
|
|
83
82
|
* - If the new and old schema types are array and the `data` is an array then:
|
|
84
83
|
* - If the type of the old and new schema `items` are a non-array objects:
|
|
85
84
|
* - Retrieve the schema for any refs within each `oldKeySchema.items` and/or `newKeySchema.items`
|
|
@@ -113,27 +112,29 @@ export default function sanitizeDataForNewSchema<
|
|
|
113
112
|
): T {
|
|
114
113
|
// By default, we will clear the form data
|
|
115
114
|
let newFormData;
|
|
115
|
+
const newProperties = newSchema?.[PROPERTIES_KEY];
|
|
116
116
|
// If the new schema is of type object and that object contains a list of properties
|
|
117
|
-
if (
|
|
117
|
+
if (newProperties) {
|
|
118
118
|
// Create an object containing root-level keys in the old schema, setting each key to undefined to remove the data
|
|
119
119
|
const removeOldSchemaData: GenericObjectType = {};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Object.keys(
|
|
123
|
-
if (
|
|
120
|
+
const oldProperties = oldSchema?.[PROPERTIES_KEY];
|
|
121
|
+
if (oldProperties) {
|
|
122
|
+
Object.keys(oldProperties).forEach((key) => {
|
|
123
|
+
if (hasByPath(data, key)) {
|
|
124
124
|
removeOldSchemaData[key] = undefined;
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
const keys: string[] = Object.keys(
|
|
128
|
+
const keys: string[] = Object.keys(newProperties);
|
|
129
129
|
// Create a place to store nested data that will be a side-effect of the filter
|
|
130
130
|
const nestedData: GenericObjectType = {};
|
|
131
131
|
keys.forEach((key) => {
|
|
132
|
-
const formValue =
|
|
133
|
-
|
|
134
|
-
let
|
|
132
|
+
const formValue = data?.[key];
|
|
133
|
+
const isNewProperty = !hasByPath(oldSchema, [PROPERTIES_KEY, key]);
|
|
134
|
+
let oldKeyedSchema = getPropertySchema<S>(oldSchema, key);
|
|
135
|
+
let newKeyedSchema = getPropertySchema<S>(newSchema, key);
|
|
135
136
|
// Resolve the refs if they exist
|
|
136
|
-
if (
|
|
137
|
+
if (hasByPath(oldKeyedSchema, REF_KEY)) {
|
|
137
138
|
oldKeyedSchema = retrieveSchema<T, S, F>(
|
|
138
139
|
validator,
|
|
139
140
|
oldKeyedSchema,
|
|
@@ -142,7 +143,7 @@ export default function sanitizeDataForNewSchema<
|
|
|
142
143
|
experimental_customMergeAllOf,
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
|
-
if (
|
|
146
|
+
if (hasByPath(newKeyedSchema, REF_KEY)) {
|
|
146
147
|
newKeyedSchema = retrieveSchema<T, S, F>(
|
|
147
148
|
validator,
|
|
148
149
|
newKeyedSchema,
|
|
@@ -152,11 +153,11 @@ export default function sanitizeDataForNewSchema<
|
|
|
152
153
|
);
|
|
153
154
|
}
|
|
154
155
|
// Now get types and see if they are the same
|
|
155
|
-
const oldSchemaTypeForKey =
|
|
156
|
-
const newSchemaTypeForKey =
|
|
156
|
+
const oldSchemaTypeForKey = oldKeyedSchema.type;
|
|
157
|
+
const newSchemaTypeForKey = newKeyedSchema.type;
|
|
157
158
|
// Check if the old option has the same key with the same type
|
|
158
159
|
if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
|
|
159
|
-
if (
|
|
160
|
+
if (key in removeOldSchemaData) {
|
|
160
161
|
// SIDE-EFFECT: remove the undefined value for a key that has the same type between the old and new schemas
|
|
161
162
|
delete removeOldSchemaData[key];
|
|
162
163
|
}
|
|
@@ -167,7 +168,7 @@ export default function sanitizeDataForNewSchema<
|
|
|
167
168
|
validator,
|
|
168
169
|
rootSchema,
|
|
169
170
|
newKeyedSchema,
|
|
170
|
-
oldKeyedSchema,
|
|
171
|
+
isNewProperty && newSchemaTypeForKey === 'array' ? newKeyedSchema : oldKeyedSchema,
|
|
171
172
|
formValue,
|
|
172
173
|
experimental_customMergeAllOf,
|
|
173
174
|
);
|
|
@@ -179,26 +180,26 @@ export default function sanitizeDataForNewSchema<
|
|
|
179
180
|
// Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
|
|
180
181
|
// with the new default or const. This allows the case where two schemas differ that only by the default/const
|
|
181
182
|
// value to be properly selected
|
|
182
|
-
const newOptionDefault =
|
|
183
|
-
const oldOptionDefault =
|
|
183
|
+
const newOptionDefault = getByPath(newKeyedSchema, DEFAULT_KEY, NO_VALUE);
|
|
184
|
+
const oldOptionDefault = getByPath(oldKeyedSchema, DEFAULT_KEY, NO_VALUE);
|
|
184
185
|
if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
|
|
185
|
-
if (oldOptionDefault === formValue) {
|
|
186
|
-
//
|
|
186
|
+
if ((isNewProperty && formValue === undefined) || oldOptionDefault === formValue) {
|
|
187
|
+
// Initialize a newly entered property or replace an old default with the new default.
|
|
187
188
|
removeOldSchemaData[key] = newOptionDefault;
|
|
188
|
-
} else if (
|
|
189
|
+
} else if (newKeyedSchema.readOnly === true) {
|
|
189
190
|
// If the new schema has the default set to read-only, treat it like a const and remove the value
|
|
190
191
|
removeOldSchemaData[key] = undefined;
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
const newOptionConst =
|
|
195
|
-
const oldOptionConst =
|
|
195
|
+
const newOptionConst = getByPath(newKeyedSchema, CONST_KEY, NO_VALUE);
|
|
196
|
+
const oldOptionConst = getByPath(oldKeyedSchema, CONST_KEY, NO_VALUE);
|
|
196
197
|
if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
|
|
197
198
|
// Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
|
|
198
199
|
removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
|
|
199
200
|
}
|
|
200
201
|
|
|
201
|
-
if (
|
|
202
|
+
if (hasByPath(data, key)) {
|
|
202
203
|
const enumReplacement = replacementForInvalidEnumValue(newKeyedSchema, formValue);
|
|
203
204
|
if (enumReplacement !== NO_VALUE) {
|
|
204
205
|
removeOldSchemaData[key] = enumReplacement;
|
|
@@ -214,9 +215,9 @@ export default function sanitizeDataForNewSchema<
|
|
|
214
215
|
...nestedData,
|
|
215
216
|
};
|
|
216
217
|
// First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep
|
|
217
|
-
} else if (
|
|
218
|
-
let oldSchemaItems =
|
|
219
|
-
let newSchemaItems =
|
|
218
|
+
} else if (oldSchema?.type === 'array' && newSchema?.type === 'array' && Array.isArray(data)) {
|
|
219
|
+
let oldSchemaItems = oldSchema.items;
|
|
220
|
+
let newSchemaItems = newSchema.items;
|
|
220
221
|
// If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data
|
|
221
222
|
// Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations
|
|
222
223
|
if (
|
|
@@ -225,7 +226,7 @@ export default function sanitizeDataForNewSchema<
|
|
|
225
226
|
!Array.isArray(oldSchemaItems) &&
|
|
226
227
|
!Array.isArray(newSchemaItems)
|
|
227
228
|
) {
|
|
228
|
-
if (
|
|
229
|
+
if (hasByPath(oldSchemaItems, REF_KEY)) {
|
|
229
230
|
oldSchemaItems = retrieveSchema<T, S, F>(
|
|
230
231
|
validator,
|
|
231
232
|
oldSchemaItems as S,
|
|
@@ -234,7 +235,7 @@ export default function sanitizeDataForNewSchema<
|
|
|
234
235
|
experimental_customMergeAllOf,
|
|
235
236
|
);
|
|
236
237
|
}
|
|
237
|
-
if (
|
|
238
|
+
if (hasByPath(newSchemaItems, REF_KEY)) {
|
|
238
239
|
newSchemaItems = retrieveSchema<T, S, F>(
|
|
239
240
|
validator,
|
|
240
241
|
newSchemaItems as S,
|
|
@@ -244,11 +245,11 @@ export default function sanitizeDataForNewSchema<
|
|
|
244
245
|
);
|
|
245
246
|
}
|
|
246
247
|
// Now get types and see if they are the same
|
|
247
|
-
const oldSchemaType =
|
|
248
|
-
const newSchemaType =
|
|
248
|
+
const oldSchemaType = getByPath(oldSchemaItems, 'type');
|
|
249
|
+
const newSchemaType = getByPath(newSchemaItems, 'type');
|
|
249
250
|
// Check if the old option has the same key with the same type
|
|
250
251
|
if (!oldSchemaType || oldSchemaType === newSchemaType) {
|
|
251
|
-
const maxItems =
|
|
252
|
+
const maxItems = newSchema.maxItems ?? -1;
|
|
252
253
|
if (newSchemaType === 'object') {
|
|
253
254
|
newFormData = data.reduce((newValue, aValue) => {
|
|
254
255
|
const itemValue = sanitizeDataForNewSchema<T, S, F>(
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// oxlint-disable typescript/no-deprecated
|
|
2
|
-
import get from 'lodash/get';
|
|
3
|
-
import isObject from 'lodash/isObject';
|
|
4
|
-
import set from 'lodash/set';
|
|
5
2
|
|
|
6
3
|
import {
|
|
7
4
|
ADDITIONAL_PROPERTIES_KEY,
|
|
@@ -15,9 +12,12 @@ import {
|
|
|
15
12
|
PROPERTIES_KEY,
|
|
16
13
|
REF_KEY,
|
|
17
14
|
RJSF_ADDITIONAL_PROPERTIES_FLAG,
|
|
18
|
-
} from '../constants';
|
|
19
|
-
import deepEquals from '../deepEquals';
|
|
20
|
-
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
|
|
15
|
+
} from '../constants.ts';
|
|
16
|
+
import deepEquals from '../deepEquals.ts';
|
|
17
|
+
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
|
|
18
|
+
import getPropertySchema from '../getPropertySchema.ts';
|
|
19
|
+
import isObject from '../isObject.ts';
|
|
20
|
+
import { getByPath, setByPath } from '../pathUtils.ts';
|
|
21
21
|
import type {
|
|
22
22
|
Experimental_CustomMergeAllOf,
|
|
23
23
|
FormContextType,
|
|
@@ -26,9 +26,9 @@ import type {
|
|
|
26
26
|
RJSFSchema,
|
|
27
27
|
StrictRJSFSchema,
|
|
28
28
|
ValidatorType,
|
|
29
|
-
} from '../types';
|
|
30
|
-
import getClosestMatchingOption from './getClosestMatchingOption';
|
|
31
|
-
import retrieveSchema from './retrieveSchema';
|
|
29
|
+
} from '../types.ts';
|
|
30
|
+
import getClosestMatchingOption from './getClosestMatchingOption.ts';
|
|
31
|
+
import retrieveSchema from './retrieveSchema.ts';
|
|
32
32
|
|
|
33
33
|
/** An internal helper that generates an `PathSchema` object for the `schema`, recursively with protection against
|
|
34
34
|
* infinite recursion
|
|
@@ -99,11 +99,11 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
|
|
102
|
-
|
|
102
|
+
setByPath(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
|
|
103
103
|
const additionalSchema = (
|
|
104
104
|
isObject(schema[ADDITIONAL_PROPERTIES_KEY]) ? schema[ADDITIONAL_PROPERTIES_KEY] : {}
|
|
105
105
|
) as S;
|
|
106
|
-
const definedProperties =
|
|
106
|
+
const definedProperties = schema[PROPERTIES_KEY] ?? {};
|
|
107
107
|
for (const key of Object.keys((formData ?? {}) as GenericObjectType)) {
|
|
108
108
|
if (!(key in definedProperties)) {
|
|
109
109
|
(pathSchema as PathSchema<GenericObjectType>)[key] = toPathSchemaInternal<T, S, F>(
|
|
@@ -111,7 +111,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
111
111
|
additionalSchema,
|
|
112
112
|
`${name}.${key}`,
|
|
113
113
|
rootSchema,
|
|
114
|
-
|
|
114
|
+
getByPath<T>(formData, key),
|
|
115
115
|
_recurseList,
|
|
116
116
|
experimental_customMergeAllOf,
|
|
117
117
|
);
|
|
@@ -166,7 +166,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
166
166
|
// This is a deprecated function that is no longer used by RJSF
|
|
167
167
|
// oxlint-disable-next-line guard-for-in
|
|
168
168
|
for (const property in schema.properties) {
|
|
169
|
-
const field
|
|
169
|
+
const field = getPropertySchema<S>(schema, property);
|
|
170
170
|
(pathSchema as PathSchema<GenericObjectType>)[property] = toPathSchemaInternal<T, S, F>(
|
|
171
171
|
validator,
|
|
172
172
|
field,
|
|
@@ -174,7 +174,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
174
174
|
rootSchema,
|
|
175
175
|
// It's possible that formData is not an object -- this can happen if an
|
|
176
176
|
// array item has just been added, but not populated with data yet
|
|
177
|
-
|
|
177
|
+
getByPath<T>(formData, property),
|
|
178
178
|
_recurseList,
|
|
179
179
|
experimental_customMergeAllOf,
|
|
180
180
|
);
|
package/src/shouldRender.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import type React from 'react';
|
|
2
2
|
|
|
3
|
-
import deepEquals from './deepEquals';
|
|
4
|
-
import shallowEquals from './shallowEquals';
|
|
3
|
+
import deepEquals from './deepEquals.ts';
|
|
4
|
+
import shallowEquals from './shallowEquals.ts';
|
|
5
5
|
|
|
6
6
|
/** The supported component update strategies */
|
|
7
7
|
export type ComponentUpdateStrategy = 'customDeep' | 'shallow' | 'always';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import isRootSchema from './isRootSchema';
|
|
8
|
-
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
|
|
1
|
+
import { ANY_OF_KEY, ONE_OF_KEY } from './constants.ts';
|
|
2
|
+
import getSchemaType from './getSchemaType.ts';
|
|
3
|
+
import getUiOptions from './getUiOptions.ts';
|
|
4
|
+
import isObject from './isObject.ts';
|
|
5
|
+
import isRootSchema from './isRootSchema.ts';
|
|
6
|
+
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.ts';
|
|
9
7
|
|
|
10
8
|
/** Returns the unique list of schema types for all of the options in a anyOf/oneOf
|
|
11
9
|
*
|
|
@@ -13,12 +11,14 @@ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema
|
|
|
13
11
|
* @returns - All of the unique types contained within the oneOf list
|
|
14
12
|
*/
|
|
15
13
|
export function getSchemaTypesForXxxOf<S extends StrictRJSFSchema = RJSFSchema>(schemas: S[]): string | string[] {
|
|
16
|
-
const allTypes: string[] =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const allTypes: string[] = [
|
|
15
|
+
...new Set(
|
|
16
|
+
schemas
|
|
17
|
+
.map((s) => (isObject(s) ? getSchemaType(s) : undefined))
|
|
18
|
+
.flat()
|
|
19
|
+
.filter((t) => t !== undefined),
|
|
20
|
+
),
|
|
21
|
+
];
|
|
22
22
|
return allTypes.length === 1 ? allTypes[0] : allTypes;
|
|
23
23
|
}
|
|
24
24
|
|
package/src/toConstant.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CONST_KEY, ENUM_KEY } from './constants';
|
|
2
|
-
import type { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { CONST_KEY, ENUM_KEY } from './constants.ts';
|
|
2
|
+
import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
|
|
5
5
|
* throws an error.
|
package/src/toDateString.ts
CHANGED
package/src/toErrorList.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import type { ErrorSchema, GenericObjectType, RJSFValidationError } from './types';
|
|
1
|
+
import { ERRORS_KEY } from './constants.ts';
|
|
2
|
+
import isPlainObject from './isPlainObject.ts';
|
|
3
|
+
import type { ErrorSchema, RJSFValidationError } from './types.ts';
|
|
5
4
|
|
|
6
5
|
/** Converts an `errorSchema` into a list of `RJSFValidationErrors`
|
|
7
6
|
*
|
|
@@ -13,28 +12,26 @@ export default function toErrorList<T = any>(
|
|
|
13
12
|
errorSchema?: ErrorSchema<T>,
|
|
14
13
|
fieldPath: string[] = [],
|
|
15
14
|
): RJSFValidationError[] {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
15
|
+
return errorSchema ? errorsFrom(errorSchema, fieldPath) : [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Does the actual conversion, working on the plain-object shape of an `ErrorSchema` so that the recursive call for a
|
|
19
|
+
* nested error schema does not need an assertion back to `ErrorSchema`.
|
|
20
|
+
*
|
|
21
|
+
* @param errorSchema - The error schema, viewed as the plain object it is at runtime
|
|
22
|
+
* @param fieldPath - The current field path
|
|
23
|
+
* @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`
|
|
24
|
+
*/
|
|
25
|
+
function errorsFrom(errorSchema: Record<string, unknown>, fieldPath: string[]): RJSFValidationError[] {
|
|
26
|
+
const errors = errorSchema[ERRORS_KEY];
|
|
27
|
+
const property = `.${fieldPath.join('.')}`;
|
|
28
|
+
const errorList: RJSFValidationError[] = Array.isArray(errors)
|
|
29
|
+
? errors.map((message: string) => ({ property, message, stack: `${property} ${message}` }))
|
|
30
|
+
: [];
|
|
32
31
|
return Object.keys(errorSchema).reduce((currentList, key) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return currentList.concat(toErrorList(childSchema, [...fieldPath, key]));
|
|
37
|
-
}
|
|
32
|
+
const childSchema = errorSchema[key];
|
|
33
|
+
if (key !== ERRORS_KEY && isPlainObject(childSchema)) {
|
|
34
|
+
return currentList.concat(errorsFrom(childSchema, [...fieldPath, key]));
|
|
38
35
|
}
|
|
39
36
|
return currentList;
|
|
40
37
|
}, errorList);
|
package/src/toErrorSchema.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import type { ErrorSchema, RJSFValidationError } from './types';
|
|
1
|
+
import ErrorSchemaBuilder from './ErrorSchemaBuilder.ts';
|
|
2
|
+
import { toPath } from './pathUtils.ts';
|
|
3
|
+
import type { ErrorSchema, RJSFValidationError } from './types.ts';
|
|
5
4
|
|
|
6
5
|
/** Transforms a rjsf validation errors list:
|
|
7
6
|
* [
|
|
@@ -27,13 +26,8 @@ export default function toErrorSchema<T = any>(errors: RJSFValidationError[]): E
|
|
|
27
26
|
if (errors.length) {
|
|
28
27
|
errors.forEach((error) => {
|
|
29
28
|
const { property, message } = error;
|
|
30
|
-
// When the property is the root element,
|
|
31
|
-
const path = property
|
|
32
|
-
// If the property is at the root (.level1) then toPath creates
|
|
33
|
-
// an empty array element at the first index. Remove it.
|
|
34
|
-
if (path.length > 0 && path[0] === '') {
|
|
35
|
-
path.splice(0, 1);
|
|
36
|
-
}
|
|
29
|
+
// When the property is missing or the root element ('.'), toPath produces an empty path
|
|
30
|
+
const path = property ? toPath(property) : [];
|
|
37
31
|
if (message) {
|
|
38
32
|
builder.addErrors(message, path);
|
|
39
33
|
}
|
package/src/toFieldPathId.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ID_KEY } from './constants';
|
|
2
|
-
import type { FieldPathId, FieldPathList, GlobalFormOptions } from './types';
|
|
1
|
+
import { ID_KEY } from './constants.ts';
|
|
2
|
+
import type { FieldPathId, FieldPathList, GlobalFormOptions } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Constructs the `FieldPathId` for `fieldPath`. If `parentPathId` is provided, the `fieldPath` is appended to the end
|
|
5
5
|
* of the parent path. Then the `ID_KEY` of the resulting `FieldPathId` is constructed from the `idPrefix` and
|
package/src/types.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type {
|
|
|
10
10
|
} from 'react';
|
|
11
11
|
import type { JSONSchema7 } from 'json-schema';
|
|
12
12
|
|
|
13
|
-
import type { TranslatableString } from './enums';
|
|
14
|
-
import './jsonSchemaAugmentation';
|
|
13
|
+
import type { TranslatableString } from './enums.ts';
|
|
14
|
+
import './jsonSchemaAugmentation.ts';
|
|
15
15
|
|
|
16
16
|
/** The representation of any generic object type, usually used as an intersection on other types to make them more
|
|
17
17
|
* flexible in the properties they support (i.e. anything else)
|
|
@@ -185,6 +185,8 @@ export interface InputPropsType {
|
|
|
185
185
|
max?: number | string;
|
|
186
186
|
/** Specifies the `autoComplete` value for an <input> element */
|
|
187
187
|
autoComplete?: HTMLInputElement['autocomplete'];
|
|
188
|
+
/** Specifies the `autoCapitalize` value for an <input> element */
|
|
189
|
+
autoCapitalize?: HTMLInputElement['autocapitalize'];
|
|
188
190
|
/** Specifies a filter for what file types the user can upload. */
|
|
189
191
|
accept?: HTMLInputElement['accept'];
|
|
190
192
|
}
|
|
@@ -1025,7 +1027,12 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
1025
1027
|
/** The definition of a React-based Widget component */
|
|
1026
1028
|
export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<
|
|
1027
1029
|
WidgetProps<T, S, F>
|
|
1028
|
-
|
|
1030
|
+
> & {
|
|
1031
|
+
/** A cached wrapper component that merges the widget's `defaultProps.options` into its props, stamped onto the
|
|
1032
|
+
* widget by `getWidget()` so that repeated lookups return the same component for proper React reconciliation
|
|
1033
|
+
*/
|
|
1034
|
+
MergedWidget?: Widget<T, S, F>;
|
|
1035
|
+
};
|
|
1029
1036
|
|
|
1030
1037
|
/** The properties that are passed to the BaseInputTemplate */
|
|
1031
1038
|
export interface BaseInputTemplateProps<
|
|
@@ -1137,6 +1144,8 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
1137
1144
|
autofocus?: boolean;
|
|
1138
1145
|
/** Use to mark the field as supporting auto complete on a text input or textarea input */
|
|
1139
1146
|
autocomplete?: HTMLInputElement['autocomplete'];
|
|
1147
|
+
/** Controls automatic capitalization for text entered on supporting virtual keyboards */
|
|
1148
|
+
autocapitalize?: HTMLInputElement['autocapitalize'];
|
|
1140
1149
|
/** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
|
|
1141
1150
|
disabled?: boolean;
|
|
1142
1151
|
/** The default value to use when an input for a field is empty */
|
|
@@ -1435,8 +1444,8 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1435
1444
|
* @returns - The firstindex of the matched option or 0 if none is available
|
|
1436
1445
|
*/
|
|
1437
1446
|
getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
|
|
1438
|
-
/**
|
|
1439
|
-
* containing potentially nested `$ref`s.
|
|
1447
|
+
/** Reads the value at `path` within a schema, additionally retrieving `$ref`s as needed to resolve
|
|
1448
|
+
* schemas containing potentially nested `$ref`s.
|
|
1440
1449
|
*
|
|
1441
1450
|
* @param schema - The current node within the JSON schema recursion
|
|
1442
1451
|
* @param path - The remaining keys in the path to the desired property
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import isPlainObject from '
|
|
2
|
-
|
|
3
|
-
import type { ErrorSchema, FormValidation, GenericObjectType } from './types';
|
|
1
|
+
import isPlainObject from './isPlainObject.ts';
|
|
2
|
+
import type { ErrorSchema, FormValidation } from './types.ts';
|
|
4
3
|
|
|
5
4
|
/** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
|
|
6
5
|
*
|
|
@@ -8,15 +7,25 @@ import type { ErrorSchema, FormValidation, GenericObjectType } from './types';
|
|
|
8
7
|
* @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
|
|
9
8
|
*/
|
|
10
9
|
export default function unwrapErrorHandler<T = any>(errorHandler: FormValidation<T>): ErrorSchema<T> {
|
|
11
|
-
return
|
|
10
|
+
return unwrapErrors<T>(errorHandler);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Does the actual unwrapping, working on the plain-object shape of a `FormValidation` so that the recursive call for
|
|
14
|
+
* a nested error handler does not need an assertion back to `FormValidation`.
|
|
15
|
+
*
|
|
16
|
+
* @param errors - The error handling structure, viewed as the plain object it is at runtime
|
|
17
|
+
* @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
|
|
18
|
+
*/
|
|
19
|
+
function unwrapErrors<T>(errors: Record<string, unknown>): ErrorSchema<T> {
|
|
20
|
+
return Object.keys(errors).reduce<ErrorSchema<T>>((acc, key) => {
|
|
12
21
|
if (key === 'addError') {
|
|
13
22
|
return acc;
|
|
14
23
|
}
|
|
15
|
-
const childSchema =
|
|
24
|
+
const childSchema = errors[key];
|
|
16
25
|
if (isPlainObject(childSchema)) {
|
|
17
26
|
return {
|
|
18
27
|
...acc,
|
|
19
|
-
[key]:
|
|
28
|
+
[key]: unwrapErrors<T>(childSchema),
|
|
20
29
|
};
|
|
21
30
|
}
|
|
22
31
|
return { ...acc, [key]: childSchema };
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import type { MouseEvent } from 'react';
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
|
|
6
|
-
import dateRangeOptions from './dateRangeOptions';
|
|
7
|
-
import type { DateElementFormat, DateElementProp } from './getDateElementProps';
|
|
8
|
-
import getDateElementProps from './getDateElementProps';
|
|
9
|
-
import { ariaDescribedByIds } from './idGenerators';
|
|
10
|
-
import parseDateString from './parseDateString';
|
|
11
|
-
import toDateString from './toDateString';
|
|
12
|
-
import type { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types';
|
|
6
|
+
import dateRangeOptions from './dateRangeOptions.ts';
|
|
7
|
+
import type { DateElementFormat, DateElementProp } from './getDateElementProps.ts';
|
|
8
|
+
import getDateElementProps from './getDateElementProps.ts';
|
|
9
|
+
import { ariaDescribedByIds } from './idGenerators.ts';
|
|
10
|
+
import parseDateString from './parseDateString.ts';
|
|
11
|
+
import toDateString from './toDateString.ts';
|
|
12
|
+
import type { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types.ts';
|
|
13
13
|
|
|
14
14
|
/** Function that checks to see if a `DateObject` is ready for the onChange callback to be triggered
|
|
15
15
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
|
|
5
|
-
import deepEquals from './deepEquals';
|
|
5
|
+
import deepEquals from './deepEquals.ts';
|
|
6
6
|
|
|
7
7
|
/** Hook that stores and returns a `T` value. If `newValue` is the same as the stored one, then the stored one is
|
|
8
8
|
* returned to avoid having a component rerender due it being a different object. Otherwise, the `newValue` is stored
|
package/src/utcToLocal.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import toErrorList from './toErrorList';
|
|
5
|
-
import type { ErrorSchema, ValidationData } from './types';
|
|
1
|
+
import mergeObjects from './mergeObjects.ts';
|
|
2
|
+
import toErrorList from './toErrorList.ts';
|
|
3
|
+
import type { ErrorSchema, ValidationData } from './types.ts';
|
|
6
4
|
|
|
7
5
|
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
8
6
|
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
@@ -25,7 +23,7 @@ export default function validationDataMerge<T = any>(
|
|
|
25
23
|
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
26
24
|
let errors = toErrorList(additionalErrorSchema);
|
|
27
25
|
let errorSchema = additionalErrorSchema;
|
|
28
|
-
if (
|
|
26
|
+
if (oldErrorSchema && Object.keys(oldErrorSchema).length > 0) {
|
|
29
27
|
errorSchema = mergeObjects(
|
|
30
28
|
oldErrorSchema,
|
|
31
29
|
additionalErrorSchema,
|
package/src/withIdRefPrefix.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import type { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.ts';
|
|
2
|
+
import isObject from './isObject.ts';
|
|
3
|
+
import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
5
4
|
|
|
6
5
|
/** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
|
|
7
6
|
* `withIdRefPrefix` for any other elements.
|