@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,4 +1,4 @@
|
|
|
1
|
-
import type { ErrorSchema, ValidationData } from './types.
|
|
1
|
+
import type { ErrorSchema, ValidationData } from './types.ts';
|
|
2
2
|
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
3
3
|
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
4
4
|
* `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
@@ -10,3 +10,4 @@ import type { ErrorSchema, ValidationData } from './types.js';
|
|
|
10
10
|
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
11
11
|
*/
|
|
12
12
|
export default function validationDataMerge<T = any>(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>, preventDuplicates?: boolean): ValidationData<T>;
|
|
13
|
+
//# sourceMappingURL=validationDataMerge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationDataMerge.d.ts","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACjD,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,EACjC,qBAAqB,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EACtC,iBAAiB,UAAQ,GACxB,cAAc,CAAC,CAAC,CAAC,CAgBnB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import toErrorList from './toErrorList.js';
|
|
1
|
+
import mergeObjects from "./mergeObjects.js";
|
|
2
|
+
import toErrorList from "./toErrorList.js";
|
|
4
3
|
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
5
4
|
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
6
5
|
* `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
@@ -18,7 +17,7 @@ export default function validationDataMerge(validationData, additionalErrorSchem
|
|
|
18
17
|
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
19
18
|
let errors = toErrorList(additionalErrorSchema);
|
|
20
19
|
let errorSchema = additionalErrorSchema;
|
|
21
|
-
if (
|
|
20
|
+
if (oldErrorSchema && Object.keys(oldErrorSchema).length > 0) {
|
|
22
21
|
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, preventDuplicates ? 'preventDuplicates' : true);
|
|
23
22
|
errors = [...oldErrors].concat(errors);
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAG3C;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC,EACtC,iBAAiB,GAAG,KAAK;IAEzB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC1E,IAAI,MAAM,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,qBAAqB,CAAC;IACxC,IAAI,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,WAAW,GAAG,YAAY,CACxB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAC7B,CAAC;QACpB,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
package/lib/withIdRefPrefix.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RJSFSchema, StrictRJSFSchema } from './types.
|
|
1
|
+
import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
2
2
|
/** Recursively prefixes all `$ref`s in a schema with the value of the `ROOT_SCHEMA_PREFIX` constant.
|
|
3
3
|
* This is used in isValid to make references to the rootSchema
|
|
4
4
|
*
|
|
@@ -6,3 +6,4 @@ import type { RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
|
6
6
|
* @returns - A copy of the `schemaNode` with updated `$ref`s
|
|
7
7
|
*/
|
|
8
8
|
export default function withIdRefPrefix<S extends StrictRJSFSchema = RJSFSchema>(schemaNode: S | S[] | S[keyof S]): S | S[] | S[keyof S];
|
|
9
|
+
//# sourceMappingURL=withIdRefPrefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withIdRefPrefix.d.ts","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgC/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAC7E,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAC/B,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAQtB"}
|
package/lib/withIdRefPrefix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { REF_KEY, ROOT_SCHEMA_PREFIX } from "./constants.js";
|
|
2
|
+
import isObject from "./isObject.js";
|
|
3
3
|
/** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
|
|
4
4
|
* `withIdRefPrefix` for any other elements.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIdRefPrefix.js","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"withIdRefPrefix.js","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,QAAQ,MAAM,eAAe,CAAC;AAGrC;;;;GAIG;AACH,SAAS,qBAAqB,CAA0C,IAAO;IAC7E,MAAM,OAAO,GAAwB,IAAI,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,uFAAuF;QACvF,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,GAAG,KAAK,OAAO,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1E,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,KAAK,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAI,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAA0C,IAAS;IAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAI,IAAI,CAAM,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAgC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,oBAAoB,CAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACzB,OAAO,qBAAqB,CAAI,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"description": "Utility functions for @rjsf/core",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
12
|
+
"@rjsf/source": "./src/index.ts",
|
|
11
13
|
"types": "./lib/index.d.ts",
|
|
12
14
|
"require": "./dist/index.cjs",
|
|
13
15
|
"import": "./lib/index.js"
|
|
@@ -54,10 +56,8 @@
|
|
|
54
56
|
"dependencies": {
|
|
55
57
|
"@x0k/json-schema-merge": "^1.0.3",
|
|
56
58
|
"fast-equals": "^6.0.0",
|
|
57
|
-
"fast-uri": "^4.1.
|
|
59
|
+
"fast-uri": "^4.1.4",
|
|
58
60
|
"jsonpointer": "^5.0.1",
|
|
59
|
-
"lodash": "^4.18.1",
|
|
60
|
-
"lodash-es": "^4.18.1",
|
|
61
61
|
"react-is": "^18.3.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
@@ -84,8 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"license": "Apache-2.0",
|
|
86
86
|
"scripts": {
|
|
87
|
-
"
|
|
88
|
-
"build:ts": "pnpm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
87
|
+
"build:ts": "tsc -b",
|
|
89
88
|
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
|
|
90
89
|
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
|
|
91
90
|
"build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import setWith from 'lodash/setWith';
|
|
5
|
-
|
|
6
|
-
import { ERRORS_KEY } from './constants';
|
|
7
|
-
import type { ErrorSchema, FieldPathList } from './types';
|
|
1
|
+
import { ERRORS_KEY } from './constants.ts';
|
|
2
|
+
import { getByPath, setByPath, toPath } from './pathUtils.ts';
|
|
3
|
+
import type { ErrorSchema, FieldPathList } from './types.ts';
|
|
8
4
|
|
|
9
5
|
/** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where
|
|
10
6
|
* numbers represent array indexes/
|
|
@@ -44,12 +40,17 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
44
40
|
* @private
|
|
45
41
|
*/
|
|
46
42
|
private getOrCreateErrorBlock(pathOfError?: PathType) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
// A string path is dotted-path notation, so parse it into its segments
|
|
44
|
+
const path = typeof pathOfError === 'string' ? toPath(pathOfError) : (pathOfError ?? []);
|
|
45
|
+
if (path.length === 0) {
|
|
46
|
+
return this.errorSchema;
|
|
47
|
+
}
|
|
48
|
+
// An `ErrorSchema` only ever nests `ErrorSchema` blocks, so create any missing block along the path,
|
|
49
|
+
// always as a plain object since an `ErrorSchema` is never an array
|
|
50
|
+
let errorBlock = getByPath<ErrorSchema | undefined>(this.errorSchema, path);
|
|
51
|
+
if (!errorBlock) {
|
|
51
52
|
errorBlock = {};
|
|
52
|
-
|
|
53
|
+
setByPath(this.errorSchema, path, errorBlock, true);
|
|
53
54
|
}
|
|
54
55
|
return errorBlock;
|
|
55
56
|
}
|
|
@@ -60,13 +61,13 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
60
61
|
* @returns - The `ErrorSchemaBuilder` object for chaining purposes
|
|
61
62
|
*/
|
|
62
63
|
resetAllErrors(initialSchema?: ErrorSchema<T>) {
|
|
63
|
-
this.errorSchema = initialSchema ?
|
|
64
|
+
this.errorSchema = initialSchema ? structuredClone(initialSchema) : {};
|
|
64
65
|
return this;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within
|
|
68
|
-
* the schema described by the `pathOfError`.
|
|
69
|
-
* [
|
|
69
|
+
* the schema described by the `pathOfError`. The path is either a dotted string (with optional bracketed array
|
|
70
|
+
* indexes, e.g. `'a.b[0]'`) or a list of path segments; keys containing dots require the list form.
|
|
70
71
|
*
|
|
71
72
|
* @param errorOrList - The error or list of errors to add into the `ErrorSchema`
|
|
72
73
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
|
|
@@ -74,23 +75,23 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
74
75
|
*/
|
|
75
76
|
addErrors(errorOrList: string | string[], pathOfError?: PathType) {
|
|
76
77
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
77
|
-
let errorsList =
|
|
78
|
+
let errorsList = errorBlock[ERRORS_KEY];
|
|
78
79
|
if (!Array.isArray(errorsList)) {
|
|
79
80
|
errorsList = [];
|
|
80
81
|
errorBlock[ERRORS_KEY] = errorsList;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (Array.isArray(errorOrList)) {
|
|
84
|
-
|
|
85
|
+
errorBlock[ERRORS_KEY] = [...new Set([...errorsList, ...errorOrList])];
|
|
85
86
|
} else {
|
|
86
|
-
|
|
87
|
+
errorBlock[ERRORS_KEY] = [...new Set([...errorsList, errorOrList])];
|
|
87
88
|
}
|
|
88
89
|
return this;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location
|
|
92
|
-
* within the schema described by the `pathOfError`.
|
|
93
|
-
* [
|
|
93
|
+
* within the schema described by the `pathOfError`. The path is either a dotted string (with optional bracketed array
|
|
94
|
+
* indexes, e.g. `'a.b[0]'`) or a list of path segments; keys containing dots require the list form.
|
|
94
95
|
*
|
|
95
96
|
* @param errorOrList - The error or list of errors to set into the `ErrorSchema`
|
|
96
97
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
|
|
@@ -100,20 +101,20 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
100
101
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
101
102
|
// Effectively clone the array being given to prevent accidental outside manipulation of the given list
|
|
102
103
|
const listToAdd = Array.isArray(errorOrList) ? [...new Set([...errorOrList])] : [errorOrList];
|
|
103
|
-
|
|
104
|
+
errorBlock[ERRORS_KEY] = listToAdd;
|
|
104
105
|
return this;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
|
|
108
|
-
* the `pathOfError`.
|
|
109
|
-
* [
|
|
109
|
+
* the `pathOfError`. The path is either a dotted string (with optional bracketed array
|
|
110
|
+
* indexes, e.g. `'a.b[0]'`) or a list of path segments; keys containing dots require the list form.
|
|
110
111
|
*
|
|
111
112
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
|
|
112
113
|
* @returns - The `ErrorSchemaBuilder` object for chaining purposes
|
|
113
114
|
*/
|
|
114
115
|
clearErrors(pathOfError?: PathType) {
|
|
115
116
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
116
|
-
|
|
117
|
+
errorBlock[ERRORS_KEY] = [];
|
|
117
118
|
return this;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import enumOptionsIsSelected from './enumOptionsIsSelected';
|
|
2
|
-
import getTemplate from './getTemplate';
|
|
3
|
-
import getUiOptions from './getUiOptions';
|
|
4
|
-
import { descriptionId } from './idGenerators';
|
|
5
|
-
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types';
|
|
1
|
+
import enumOptionsIsSelected from './enumOptionsIsSelected.ts';
|
|
2
|
+
import getTemplate from './getTemplate.ts';
|
|
3
|
+
import getUiOptions from './getUiOptions.ts';
|
|
4
|
+
import { descriptionId } from './idGenerators.ts';
|
|
5
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types.ts';
|
|
6
6
|
|
|
7
7
|
export type SelectedOptionDescriptionProps<
|
|
8
8
|
T = any,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import isObject from './isObject';
|
|
2
|
-
import type { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import isObject from './isObject.ts';
|
|
2
|
+
import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
|
|
5
5
|
* object. The user is warned in the console if `schema.additionalItems` has the value `true`.
|
package/src/asNumber.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import getDecimalSeparator from './getDecimalSeparator';
|
|
1
|
+
import getDecimalSeparator from './getDecimalSeparator.ts';
|
|
2
2
|
|
|
3
3
|
/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned.
|
|
4
4
|
* If a `null` is provided, it is returned. If the string ends in a `.` or the locale-specific separator then the
|
package/src/canExpand.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import getUiOptions from './getUiOptions';
|
|
2
|
-
import type { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
|
|
1
|
+
import getUiOptions from './getUiOptions.ts';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
|
|
5
5
|
* the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { JSONSchema7Type } from 'json-schema';
|
|
2
|
-
import isString from 'lodash/isString';
|
|
3
2
|
|
|
4
|
-
import { CONST_KEY, getSchemaType, isObject } from './';
|
|
5
|
-
import type { RJSFSchema, StrictRJSFSchema } from './types';
|
|
3
|
+
import { CONST_KEY, getSchemaType, isObject } from './index.ts';
|
|
4
|
+
import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Checks if the schema const property value is an AJV $data reference
|
|
@@ -14,5 +13,7 @@ import type { RJSFSchema, StrictRJSFSchema } from './types';
|
|
|
14
13
|
export default function constIsAjvDataReference<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {
|
|
15
14
|
const schemaConst = schema[CONST_KEY] as JSONSchema7Type & { $data: string };
|
|
16
15
|
const schemaType = getSchemaType<S>(schema);
|
|
17
|
-
return
|
|
16
|
+
return (
|
|
17
|
+
isObject(schemaConst) && typeof schemaConst?.$data === 'string' && schemaType !== 'object' && schemaType !== 'array'
|
|
18
|
+
);
|
|
18
19
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import type { FieldValidation, FormValidation, GenericObjectType } from './types';
|
|
1
|
+
import { ERRORS_KEY } from './constants.ts';
|
|
2
|
+
import isPlainObject from './isPlainObject.ts';
|
|
3
|
+
import type { FieldValidation, FormValidation } from './types.ts';
|
|
5
4
|
|
|
6
5
|
/** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it
|
|
7
6
|
*
|
|
@@ -22,9 +21,8 @@ export default function createErrorHandler<T = any>(formData: T): FormValidation
|
|
|
22
21
|
return formData.reduce((acc, value, key) => ({ ...acc, [key]: createErrorHandler(value) }), handler);
|
|
23
22
|
}
|
|
24
23
|
if (isPlainObject(formData)) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(acc, key) => ({ ...acc, [key]: createErrorHandler(formObject[key]) }),
|
|
24
|
+
return Object.keys(formData).reduce(
|
|
25
|
+
(acc, key) => ({ ...acc, [key]: createErrorHandler(formData[key]) }),
|
|
28
26
|
handler as FormValidation<T>,
|
|
29
27
|
);
|
|
30
28
|
}
|
package/src/createSchemaUtils.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import deepEquals from './deepEquals';
|
|
5
|
-
import { makeAllReferencesAbsolute } from './findSchemaDefinition';
|
|
1
|
+
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants.ts';
|
|
2
|
+
import deepEquals from './deepEquals.ts';
|
|
3
|
+
import { makeAllReferencesAbsolute } from './findSchemaDefinition.ts';
|
|
6
4
|
import {
|
|
7
5
|
findFieldInSchema,
|
|
8
6
|
findSelectedOptionInXxxOf,
|
|
@@ -18,7 +16,7 @@ import {
|
|
|
18
16
|
retrieveSchema,
|
|
19
17
|
sanitizeDataForNewSchema,
|
|
20
18
|
toPathSchema,
|
|
21
|
-
} from './schema';
|
|
19
|
+
} from './schema/index.ts';
|
|
22
20
|
import type {
|
|
23
21
|
Experimental_CustomMergeAllOf,
|
|
24
22
|
Experimental_DefaultFormStateBehavior,
|
|
@@ -32,7 +30,7 @@ import type {
|
|
|
32
30
|
StrictRJSFSchema,
|
|
33
31
|
UiSchema,
|
|
34
32
|
ValidatorType,
|
|
35
|
-
} from './types';
|
|
33
|
+
} from './types.ts';
|
|
36
34
|
|
|
37
35
|
/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
|
|
38
36
|
* that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
|
|
@@ -64,7 +62,7 @@ class SchemaUtils<
|
|
|
64
62
|
experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
|
|
65
63
|
) {
|
|
66
64
|
if (rootSchema?.[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
67
|
-
this.rootSchema = makeAllReferencesAbsolute(rootSchema,
|
|
65
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, rootSchema[ID_KEY] ?? '#');
|
|
68
66
|
} else {
|
|
69
67
|
this.rootSchema = rootSchema;
|
|
70
68
|
}
|
|
@@ -253,8 +251,8 @@ class SchemaUtils<
|
|
|
253
251
|
return getFirstMatchingOption<T, S, F>(this.validator, formData, options, this.rootSchema, discriminatorField);
|
|
254
252
|
}
|
|
255
253
|
|
|
256
|
-
/**
|
|
257
|
-
* containing potentially nested `$ref`s.
|
|
254
|
+
/** Reads the value at `path` within a schema, additionally retrieving `$ref`s as needed to resolve
|
|
255
|
+
* schemas containing potentially nested `$ref`s.
|
|
258
256
|
*
|
|
259
257
|
* @param schema - The current node within the JSON schema recursion
|
|
260
258
|
* @param path - The remaining keys in the path to the desired property
|
package/src/dateRangeOptions.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import pad from './pad';
|
|
2
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import pad from './pad.ts';
|
|
2
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Returns a list of options for a date range between `start` and `stop`. If the start date is greater than the end
|
|
5
5
|
* date, then the date range is reversed. If `start` and `stop` are negative numbers (or zero), then they will be
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TranslatableString } from './enums';
|
|
2
|
-
import replaceStringParameters from './replaceStringParameters';
|
|
1
|
+
import type { TranslatableString } from './enums.ts';
|
|
2
|
+
import replaceStringParameters from './replaceStringParameters.ts';
|
|
3
3
|
|
|
4
4
|
/** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
|
|
5
5
|
* value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import enumOptionsIndexForValue from './enumOptionsIndexForValue';
|
|
2
|
-
import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
|
|
1
|
+
import enumOptionsIndexForValue from './enumOptionsIndexForValue.ts';
|
|
2
|
+
import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Computes the value to pass to a select element's `value` attribute.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
2
|
-
import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
|
|
1
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.ts';
|
|
2
|
+
import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Resolves a single DOM value string back to its typed enum value in `'realValue'` mode.
|
|
5
5
|
*
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import type { OptionValueFormat } from './types';
|
|
1
|
+
import type { OptionValueFormat } from './types.ts';
|
|
4
2
|
|
|
5
3
|
/** Encodes an enum option value into a string for a DOM value attribute.
|
|
6
4
|
*
|
|
@@ -23,7 +21,7 @@ export default function enumOptionValueEncoder(
|
|
|
23
21
|
if (format !== 'realValue') {
|
|
24
22
|
return String(index);
|
|
25
23
|
}
|
|
26
|
-
if (
|
|
24
|
+
if (value == null) {
|
|
27
25
|
return '';
|
|
28
26
|
}
|
|
29
27
|
if (typeof value === 'object') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import deepEquals from './deepEquals';
|
|
2
|
-
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
3
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import deepEquals from './deepEquals.ts';
|
|
2
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.ts';
|
|
3
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
4
4
|
|
|
5
5
|
/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
|
|
6
6
|
* a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import enumOptionsIsSelected from './enumOptionsIsSelected';
|
|
2
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import enumOptionsIsSelected from './enumOptionsIsSelected.ts';
|
|
2
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
|
|
5
5
|
* `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import deepEquals from './deepEquals';
|
|
2
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import deepEquals from './deepEquals.ts';
|
|
2
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
3
3
|
|
|
4
4
|
/** Determines whether the given `value` is (one of) the `selected` value(s).
|
|
5
5
|
*
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
4
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.ts';
|
|
2
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
5
3
|
|
|
6
4
|
/** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
|
|
7
5
|
* `allEnumOptions`
|
|
@@ -17,7 +15,7 @@ export default function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSF
|
|
|
17
15
|
allEnumOptions: EnumOptionsType<S>[] = [],
|
|
18
16
|
) {
|
|
19
17
|
const value = enumOptionsValueForIndex<S>(valueIndex, allEnumOptions);
|
|
20
|
-
if (
|
|
18
|
+
if (value != null) {
|
|
21
19
|
const index = allEnumOptions.findIndex((opt) => value === opt.value);
|
|
22
20
|
const all = allEnumOptions.map(({ value: val }) => val);
|
|
23
21
|
const updated = selected.slice(0, index).concat(value, selected.slice(index));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
2
2
|
|
|
3
3
|
/** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
|
|
4
4
|
* array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import UriResolver from 'fast-uri';
|
|
2
2
|
import jsonpointer from 'jsonpointer';
|
|
3
|
-
import get from 'lodash/get';
|
|
4
|
-
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import isObject from 'lodash/isObject';
|
|
6
|
-
import omit from 'lodash/omit';
|
|
7
3
|
|
|
8
4
|
import {
|
|
9
5
|
ALL_OF_KEY,
|
|
@@ -12,8 +8,9 @@ import {
|
|
|
12
8
|
JSON_SCHEMA_DRAFT_2020_12,
|
|
13
9
|
REF_KEY,
|
|
14
10
|
SCHEMA_KEY,
|
|
15
|
-
} from './constants';
|
|
16
|
-
import
|
|
11
|
+
} from './constants.ts';
|
|
12
|
+
import isObject from './isObject.ts';
|
|
13
|
+
import type { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
17
14
|
|
|
18
15
|
/** Looks for the `$id` pointed by `ref` in the schema definitions embedded in
|
|
19
16
|
* a JSON Schema bundle
|
|
@@ -52,7 +49,7 @@ function findEmbeddedSchemaRecursive<S extends StrictRJSFSchema = RJSFSchema>(sc
|
|
|
52
49
|
* @param baseURI - The base URI to be used for resolving relative references
|
|
53
50
|
*/
|
|
54
51
|
export function makeAllReferencesAbsolute<S extends StrictRJSFSchema = RJSFSchema>(schema: S, baseURI: string): S {
|
|
55
|
-
const currentURI =
|
|
52
|
+
const currentURI = schema[ID_KEY] ?? baseURI;
|
|
56
53
|
let result = schema;
|
|
57
54
|
// Make all other references absolute
|
|
58
55
|
if (REF_KEY in result) {
|
|
@@ -81,8 +78,7 @@ export function makeAllReferencesAbsolute<S extends StrictRJSFSchema = RJSFSchem
|
|
|
81
78
|
* value from `object[key]`
|
|
82
79
|
*/
|
|
83
80
|
export function splitKeyElementFromObject(key: string, object: GenericObjectType) {
|
|
84
|
-
const value = object
|
|
85
|
-
const remaining = omit(object, [key]);
|
|
81
|
+
const { [key]: value, ...remaining } = object;
|
|
86
82
|
return [remaining, value];
|
|
87
83
|
}
|
|
88
84
|
|
|
@@ -102,7 +98,7 @@ export function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFS
|
|
|
102
98
|
$ref?: string,
|
|
103
99
|
rootSchema: S = {} as S,
|
|
104
100
|
recurseList: string[] = [],
|
|
105
|
-
baseURI: string | undefined =
|
|
101
|
+
baseURI: string | undefined = rootSchema[ID_KEY],
|
|
106
102
|
): S {
|
|
107
103
|
const ref = $ref || '';
|
|
108
104
|
let current: S | undefined = undefined;
|
|
@@ -124,7 +120,7 @@ export function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFS
|
|
|
124
120
|
current = findEmbeddedSchemaRecursive<S>(rootSchema, refId.replace(/\/$/, ''));
|
|
125
121
|
if (current !== undefined) {
|
|
126
122
|
currentBaseURI = current[ID_KEY];
|
|
127
|
-
if (
|
|
123
|
+
if (refAnchor.length > 0) {
|
|
128
124
|
current = jsonpointer.get(current, decodeURIComponent(refAnchor.join('#')));
|
|
129
125
|
}
|
|
130
126
|
}
|
|
@@ -173,7 +169,7 @@ export function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFS
|
|
|
173
169
|
export default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>(
|
|
174
170
|
$ref?: string,
|
|
175
171
|
rootSchema: S = {} as S,
|
|
176
|
-
baseURI: string | undefined =
|
|
172
|
+
baseURI: string | undefined = rootSchema[ID_KEY],
|
|
177
173
|
): S {
|
|
178
174
|
const recurseList: string[] = [];
|
|
179
175
|
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|