@rjsf/utils 6.8.0 → 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 +509 -419
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +508 -418
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +567 -327
- 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 +2 -1
- package/lib/hashForSchema.d.ts.map +1 -0
- 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 +1 -1
- 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
package/lib/parser/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { SchemaMap } from './ParserValidator.
|
|
2
|
-
import schemaParser from './schemaParser.
|
|
1
|
+
import type { SchemaMap } from './ParserValidator.ts';
|
|
2
|
+
import schemaParser from './schemaParser.ts';
|
|
3
3
|
export type { SchemaMap };
|
|
4
4
|
export { schemaParser };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/lib/parser/index.js
CHANGED
package/lib/parser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types.
|
|
2
|
-
import type { SchemaMap } from './ParserValidator.
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types.ts';
|
|
2
|
+
import type { SchemaMap } from './ParserValidator.ts';
|
|
3
3
|
/** Parses the given `rootSchema` to extract out all the sub-schemas that maybe contained within it. Returns a map of
|
|
4
4
|
* the hash of the schema to schema/sub-schema.
|
|
5
5
|
*
|
|
@@ -7,3 +7,4 @@ import type { SchemaMap } from './ParserValidator.js';
|
|
|
7
7
|
* @returns - The `SchemaMap` of all schemas that were parsed
|
|
8
8
|
*/
|
|
9
9
|
export default function schemaParser<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(rootSchema: S): SchemaMap<S>;
|
|
10
|
+
//# sourceMappingURL=schemaParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaParser.d.ts","sourceRoot":"","sources":["../../src/parser/schemaParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAuCtD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpH,UAAU,EAAE,CAAC,GACZ,SAAS,CAAC,CAAC,CAAC,CAOd"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import ParserValidator from './ParserValidator.js';
|
|
1
|
+
import { ITEMS_KEY, PROPERTIES_KEY } from "../constants.js";
|
|
2
|
+
import deepEquals from "../deepEquals.js";
|
|
3
|
+
import { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from "../schema/retrieveSchema.js";
|
|
4
|
+
import ParserValidator from "./ParserValidator.js";
|
|
6
5
|
/** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to
|
|
7
6
|
* capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the
|
|
8
7
|
* `retrieveSchemaInternal()`, the `resolveAnyOrOneOfSchemas()` function is called. For each of the schemas returned
|
|
@@ -22,9 +21,9 @@ function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
|
22
21
|
const allOptions = resolveAnyOrOneOfSchemas(validator, localSchema, rootSchema, true);
|
|
23
22
|
allOptions.forEach((s) => {
|
|
24
23
|
if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
|
|
25
|
-
|
|
24
|
+
for (const value of Object.values(localSchema[PROPERTIES_KEY] ?? {})) {
|
|
26
25
|
parseSchema(validator, recurseList, rootSchema, value);
|
|
27
|
-
}
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
29
|
if (ITEMS_KEY in localSchema && !Array.isArray(localSchema.items) && typeof localSchema.items !== 'boolean') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaParser.js","sourceRoot":"","sources":["../../src/parser/schemaParser.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"schemaParser.js","sourceRoot":"","sources":["../../src/parser/schemaParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAG/F,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;GASG;AACH,SAAS,WAAW,CAClB,SAAmC,EACnC,WAAgB,EAChB,UA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AAe,CAAU,UAAU,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAQ,EAAE,CAAC;IAE5B,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAE5D,OAAO,SAAS,CAAC,YAAY,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { FieldPathList } from './types.ts';
|
|
2
|
+
/** A path into an object: either a list of path segments or a single property key (string or number).
|
|
3
|
+
* A bare string is ALWAYS treated as one literal key — `'a.b'` is the key `'a.b'`, not a deep path. To
|
|
4
|
+
* traverse a dotted path string, convert it explicitly with {@link toPath}
|
|
5
|
+
*/
|
|
6
|
+
export type ObjectPath = string | number | FieldPathList;
|
|
7
|
+
/** Converts a dotted path string, such as produced for validation error properties, into its list of
|
|
8
|
+
* path segments. Array indexes may be written bracketed (`'a[0].b'`) or dotted (`'a.0.b'`), and empty
|
|
9
|
+
* segments — from a leading `.`, a trailing `.` or a `..` run — are dropped.
|
|
10
|
+
*
|
|
11
|
+
* Only the grammar RJSF itself produces is supported: dots and brackets are always separators, so
|
|
12
|
+
* quoted keys are not recognized and keys containing dots must be addressed with a segment list
|
|
13
|
+
* instead of a string.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The string path to convert, such as `'.level1.level2[2].level3'`
|
|
16
|
+
* @returns - The list of path segments, such as `['level1', 'level2', '2', 'level3']`
|
|
17
|
+
*/
|
|
18
|
+
export declare function toPath(path: string): string[];
|
|
19
|
+
/** Gets the value at `path` of `obj`, returning `defaultValue` when the resolved value is `undefined`
|
|
20
|
+
*
|
|
21
|
+
* Every segment must be an OWN property, matching {@link hasByPath}, so the two can be used as a
|
|
22
|
+
* guard/read pair. Inherited members are never resolved: `getByPath({}, 'toString')` returns
|
|
23
|
+
* `defaultValue`, not `Function.prototype.toString`. For the plain form data and schemas RJSF navigates,
|
|
24
|
+
* an inherited member is never data, and the own-property rule also makes prototype internals such as
|
|
25
|
+
* `__proto__` unreachable unless they are genuine own data keys
|
|
26
|
+
*
|
|
27
|
+
* An empty segment list resolves to nothing, so `defaultValue` is returned. This matches {@link hasByPath},
|
|
28
|
+
* which is `false` for an empty path, and keeps a computed-but-empty path (`toPath('')` for a root-level
|
|
29
|
+
* validation error, say) from resolving to the whole object
|
|
30
|
+
*
|
|
31
|
+
* The value at a runtime-computed path cannot be known statically, so `R` is the CALLER'S declaration of
|
|
32
|
+
* the expected type (like `Map.get()`); it defaults to `unknown`, which forces narrowing when no type is given
|
|
33
|
+
*
|
|
34
|
+
* @param obj - The object to query
|
|
35
|
+
* @param path - The single key or list of path segments at which to get the value
|
|
36
|
+
* @param [defaultValue] - The value returned when the resolved value is `undefined`
|
|
37
|
+
* @returns - The resolved value, otherwise `defaultValue`
|
|
38
|
+
*/
|
|
39
|
+
export declare function getByPath<R = unknown>(obj: unknown, path: ObjectPath, defaultValue?: R): R;
|
|
40
|
+
/** Sets `value` at `path` of `obj`, mutating and returning `obj`. Missing intermediate containers are
|
|
41
|
+
* created: arrays when the next segment is a valid array index, plain objects otherwise (or always plain
|
|
42
|
+
* objects when `createIntermediateObjects` is true)
|
|
43
|
+
*
|
|
44
|
+
* A `__proto__` segment is refused in any position — assigning to it would mutate the prototype chain rather
|
|
45
|
+
* than create an own property — and the write is silently skipped. Every other key, `constructor` and
|
|
46
|
+
* `prototype` included, is written as an own property
|
|
47
|
+
*
|
|
48
|
+
* @param obj - The object to modify
|
|
49
|
+
* @param path - The single key or list of path segments at which to set the value
|
|
50
|
+
* @param value - The value to set
|
|
51
|
+
* @param [createIntermediateObjects] - When true, always create plain objects for missing intermediate
|
|
52
|
+
* containers, even for numeric path segments
|
|
53
|
+
* @returns - The mutated `obj`
|
|
54
|
+
*/
|
|
55
|
+
export declare function setByPath<O>(obj: O, path: ObjectPath, value: unknown, createIntermediateObjects?: boolean): O;
|
|
56
|
+
/** Determines whether `obj` has an own property at `path`
|
|
57
|
+
*
|
|
58
|
+
* Every segment is checked with `Object.hasOwn()`, so inherited properties report `false` —
|
|
59
|
+
* `hasByPath({}, 'toString')` is `false`. {@link getByPath} applies the same own-property rule, so the
|
|
60
|
+
* two can be used as a guard/read pair
|
|
61
|
+
*
|
|
62
|
+
* @param obj - The object to query
|
|
63
|
+
* @param path - The single key or list of path segments to check for
|
|
64
|
+
* @returns - True if the own property exists at `path`, otherwise false
|
|
65
|
+
*/
|
|
66
|
+
export declare function hasByPath(obj: unknown, path: ObjectPath): boolean;
|
|
67
|
+
/** Removes the own property at `path` of `obj`, mutating `obj`
|
|
68
|
+
*
|
|
69
|
+
* Both the parent lookup and the delete are own-property-only, so no segment can reach the prototype chain and
|
|
70
|
+
* no `UNSAFE_SEGMENTS`-style guard is needed: deleting a `__proto__` that is not an own property is a no-op
|
|
71
|
+
*
|
|
72
|
+
* @param obj - The object to modify
|
|
73
|
+
* @param path - The single key or list of path segments at which to remove the property
|
|
74
|
+
* @returns - True if the property was removed or did not exist, otherwise false
|
|
75
|
+
*/
|
|
76
|
+
export declare function unsetByPath(obj: unknown, path: ObjectPath): boolean;
|
|
77
|
+
//# sourceMappingURL=pathUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;AAKzD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7C;AA2BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAsB1F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,yBAAyB,UAAQ,GAAG,CAAC,CAuC3G;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAajE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAiBnE"}
|
package/lib/pathUtils.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/** Matches unsigned integer strings that represent valid array indexes */
|
|
2
|
+
const reIsIndex = /^(?:0|[1-9]\d*)$/;
|
|
3
|
+
/** Converts a dotted path string, such as produced for validation error properties, into its list of
|
|
4
|
+
* path segments. Array indexes may be written bracketed (`'a[0].b'`) or dotted (`'a.0.b'`), and empty
|
|
5
|
+
* segments — from a leading `.`, a trailing `.` or a `..` run — are dropped.
|
|
6
|
+
*
|
|
7
|
+
* Only the grammar RJSF itself produces is supported: dots and brackets are always separators, so
|
|
8
|
+
* quoted keys are not recognized and keys containing dots must be addressed with a segment list
|
|
9
|
+
* instead of a string.
|
|
10
|
+
*
|
|
11
|
+
* @param path - The string path to convert, such as `'.level1.level2[2].level3'`
|
|
12
|
+
* @returns - The list of path segments, such as `['level1', 'level2', '2', 'level3']`
|
|
13
|
+
*/
|
|
14
|
+
export function toPath(path) {
|
|
15
|
+
return path.split(/[.[\]]+/).filter(Boolean);
|
|
16
|
+
}
|
|
17
|
+
/** Normalizes an `ObjectPath` into a list of path segments, wrapping a single key into a one-element list */
|
|
18
|
+
function normalizePath(path) {
|
|
19
|
+
return Array.isArray(path) ? path : [path];
|
|
20
|
+
}
|
|
21
|
+
/** Determines whether a path segment could mutate the prototype chain. Only `__proto__` can: assigning to it
|
|
22
|
+
* invokes the prototype setter rather than creating an own property. `constructor` and `prototype` are safe
|
|
23
|
+
* here — and are legal JSON Schema property names — because both reads and writes below are own-property-only,
|
|
24
|
+
* so `['constructor', 'prototype', 'polluted']` shadows `constructor` with a fresh object instead of walking
|
|
25
|
+
* into `Object.prototype`. Only writes need this check; reads are already own-property-only
|
|
26
|
+
*/
|
|
27
|
+
function isUnsafeSegment(segment) {
|
|
28
|
+
return segment === '__proto__';
|
|
29
|
+
}
|
|
30
|
+
/** Determines whether a path segment represents a valid array index */
|
|
31
|
+
function isIndex(segment) {
|
|
32
|
+
return typeof segment === 'number' ? Number.isInteger(segment) && segment >= 0 : reIsIndex.test(segment);
|
|
33
|
+
}
|
|
34
|
+
/** Determines whether `value` can hold properties, i.e. is an object (arrays included) or a function */
|
|
35
|
+
function isSettable(value) {
|
|
36
|
+
return value != null && (typeof value === 'object' || typeof value === 'function');
|
|
37
|
+
}
|
|
38
|
+
/** Gets the value at `path` of `obj`, returning `defaultValue` when the resolved value is `undefined`
|
|
39
|
+
*
|
|
40
|
+
* Every segment must be an OWN property, matching {@link hasByPath}, so the two can be used as a
|
|
41
|
+
* guard/read pair. Inherited members are never resolved: `getByPath({}, 'toString')` returns
|
|
42
|
+
* `defaultValue`, not `Function.prototype.toString`. For the plain form data and schemas RJSF navigates,
|
|
43
|
+
* an inherited member is never data, and the own-property rule also makes prototype internals such as
|
|
44
|
+
* `__proto__` unreachable unless they are genuine own data keys
|
|
45
|
+
*
|
|
46
|
+
* An empty segment list resolves to nothing, so `defaultValue` is returned. This matches {@link hasByPath},
|
|
47
|
+
* which is `false` for an empty path, and keeps a computed-but-empty path (`toPath('')` for a root-level
|
|
48
|
+
* validation error, say) from resolving to the whole object
|
|
49
|
+
*
|
|
50
|
+
* The value at a runtime-computed path cannot be known statically, so `R` is the CALLER'S declaration of
|
|
51
|
+
* the expected type (like `Map.get()`); it defaults to `unknown`, which forces narrowing when no type is given
|
|
52
|
+
*
|
|
53
|
+
* @param obj - The object to query
|
|
54
|
+
* @param path - The single key or list of path segments at which to get the value
|
|
55
|
+
* @param [defaultValue] - The value returned when the resolved value is `undefined`
|
|
56
|
+
* @returns - The resolved value, otherwise `defaultValue`
|
|
57
|
+
*/
|
|
58
|
+
export function getByPath(obj, path, defaultValue) {
|
|
59
|
+
let current;
|
|
60
|
+
if (!Array.isArray(path)) {
|
|
61
|
+
// Fast path for the most common call shape, a single constant key, avoiding the segment-list allocation
|
|
62
|
+
current = isSettable(obj) && Object.hasOwn(obj, path) ? obj[path] : undefined;
|
|
63
|
+
}
|
|
64
|
+
else if (path.length === 0) {
|
|
65
|
+
// An empty path resolves to nothing, mirroring `hasByPath()`
|
|
66
|
+
current = undefined;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
current = obj;
|
|
70
|
+
for (let i = 0; i < path.length; i++) {
|
|
71
|
+
const segment = path[i];
|
|
72
|
+
// Only own data keys resolve, so inherited members and prototype internals are never read
|
|
73
|
+
if (!isSettable(current) || !Object.hasOwn(current, segment)) {
|
|
74
|
+
current = undefined;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
current = current[segment];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// The single deliberate cast in these utilities: the resolved value is trusted to be the `R` the caller declared
|
|
81
|
+
return (current === undefined ? defaultValue : current);
|
|
82
|
+
}
|
|
83
|
+
/** Sets `value` at `path` of `obj`, mutating and returning `obj`. Missing intermediate containers are
|
|
84
|
+
* created: arrays when the next segment is a valid array index, plain objects otherwise (or always plain
|
|
85
|
+
* objects when `createIntermediateObjects` is true)
|
|
86
|
+
*
|
|
87
|
+
* A `__proto__` segment is refused in any position — assigning to it would mutate the prototype chain rather
|
|
88
|
+
* than create an own property — and the write is silently skipped. Every other key, `constructor` and
|
|
89
|
+
* `prototype` included, is written as an own property
|
|
90
|
+
*
|
|
91
|
+
* @param obj - The object to modify
|
|
92
|
+
* @param path - The single key or list of path segments at which to set the value
|
|
93
|
+
* @param value - The value to set
|
|
94
|
+
* @param [createIntermediateObjects] - When true, always create plain objects for missing intermediate
|
|
95
|
+
* containers, even for numeric path segments
|
|
96
|
+
* @returns - The mutated `obj`
|
|
97
|
+
*/
|
|
98
|
+
export function setByPath(obj, path, value, createIntermediateObjects = false) {
|
|
99
|
+
if (!isSettable(obj)) {
|
|
100
|
+
return obj;
|
|
101
|
+
}
|
|
102
|
+
// Fast path for a single constant key, avoiding the segment-list allocation
|
|
103
|
+
if (!Array.isArray(path)) {
|
|
104
|
+
// Refuse a segment that could mutate the prototype chain (prototype pollution)
|
|
105
|
+
if (!isUnsafeSegment(path)) {
|
|
106
|
+
const target = obj;
|
|
107
|
+
target[path] = value;
|
|
108
|
+
}
|
|
109
|
+
return obj;
|
|
110
|
+
}
|
|
111
|
+
const segments = path;
|
|
112
|
+
// Refuse paths that could mutate the prototype chain (prototype pollution)
|
|
113
|
+
if (segments.some(isUnsafeSegment)) {
|
|
114
|
+
return obj;
|
|
115
|
+
}
|
|
116
|
+
let current = obj;
|
|
117
|
+
for (let i = 0; i < segments.length; i++) {
|
|
118
|
+
const segment = segments[i];
|
|
119
|
+
if (i === segments.length - 1) {
|
|
120
|
+
current[segment] = value;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// Own properties only, so an inherited member is never traversed into
|
|
124
|
+
const existing = Object.hasOwn(current, segment) ? current[segment] : undefined;
|
|
125
|
+
if (isSettable(existing)) {
|
|
126
|
+
current = existing;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const next = createIntermediateObjects || !isIndex(segments[i + 1]) ? {} : [];
|
|
130
|
+
current[segment] = next;
|
|
131
|
+
/* v8 ignore next -- a fresh {} or [] is always settable; the guard exists only to narrow the type */
|
|
132
|
+
if (isSettable(next)) {
|
|
133
|
+
current = next;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return obj;
|
|
139
|
+
}
|
|
140
|
+
/** Determines whether `obj` has an own property at `path`
|
|
141
|
+
*
|
|
142
|
+
* Every segment is checked with `Object.hasOwn()`, so inherited properties report `false` —
|
|
143
|
+
* `hasByPath({}, 'toString')` is `false`. {@link getByPath} applies the same own-property rule, so the
|
|
144
|
+
* two can be used as a guard/read pair
|
|
145
|
+
*
|
|
146
|
+
* @param obj - The object to query
|
|
147
|
+
* @param path - The single key or list of path segments to check for
|
|
148
|
+
* @returns - True if the own property exists at `path`, otherwise false
|
|
149
|
+
*/
|
|
150
|
+
export function hasByPath(obj, path) {
|
|
151
|
+
// Fast path for a single constant key, avoiding the segment-list allocation
|
|
152
|
+
if (!Array.isArray(path)) {
|
|
153
|
+
return isSettable(obj) && Object.hasOwn(obj, path);
|
|
154
|
+
}
|
|
155
|
+
let current = obj;
|
|
156
|
+
for (let i = 0; i < path.length; i++) {
|
|
157
|
+
if (!isSettable(current) || !Object.hasOwn(current, path[i])) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
current = current[path[i]];
|
|
161
|
+
}
|
|
162
|
+
return path.length > 0;
|
|
163
|
+
}
|
|
164
|
+
/** Removes the own property at `path` of `obj`, mutating `obj`
|
|
165
|
+
*
|
|
166
|
+
* Both the parent lookup and the delete are own-property-only, so no segment can reach the prototype chain and
|
|
167
|
+
* no `UNSAFE_SEGMENTS`-style guard is needed: deleting a `__proto__` that is not an own property is a no-op
|
|
168
|
+
*
|
|
169
|
+
* @param obj - The object to modify
|
|
170
|
+
* @param path - The single key or list of path segments at which to remove the property
|
|
171
|
+
* @returns - True if the property was removed or did not exist, otherwise false
|
|
172
|
+
*/
|
|
173
|
+
export function unsetByPath(obj, path) {
|
|
174
|
+
const segments = normalizePath(path);
|
|
175
|
+
// An empty path names no property, so there is nothing to remove
|
|
176
|
+
if (segments.length === 0) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
const parent = segments.length > 1 ? getByPath(obj, segments.slice(0, -1)) : obj;
|
|
180
|
+
if (parent == null) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
// Returns false for a non-configurable property instead of throwing like `delete` in strict mode
|
|
185
|
+
return Reflect.deleteProperty(parent, segments[segments.length - 1]);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Reflect.deleteProperty throws when the target is a primitive
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=pathUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAQA,0EAA0E;AAC1E,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,6GAA6G;AAC7G,SAAS,aAAa,CAAC,IAAgB;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,OAAwB;IAC/C,OAAO,OAAO,KAAK,WAAW,CAAC;AACjC,CAAC;AAED,uEAAuE;AACvE,SAAS,OAAO,CAAC,OAAwB;IACvC,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3G,CAAC;AAED,wGAAwG;AACxG,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC;AACrF,CAAC;AAED;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,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACjF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,iGAAiG;QACjG,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;QAC/D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/lib/rangeSpec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RangeSpecType, RJSFSchema, StrictRJSFSchema } from './types.
|
|
1
|
+
import type { RangeSpecType, RJSFSchema, StrictRJSFSchema } from './types.ts';
|
|
2
2
|
/** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
|
|
3
3
|
* input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
|
|
4
4
|
*
|
|
@@ -6,3 +6,4 @@ import type { RangeSpecType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
|
6
6
|
* @returns - A range specification from the schema
|
|
7
7
|
*/
|
|
8
8
|
export default function rangeSpec<S extends StrictRJSFSchema = RJSFSchema>(schema: S): RangeSpecType;
|
|
9
|
+
//# sourceMappingURL=rangeSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rangeSpec.d.ts","sourceRoot":"","sources":["../src/rangeSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,MAAM,EAAE,CAAC,iBAYnF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from './types.
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from './types.ts';
|
|
2
2
|
/** Recursively removes optional objects from the `formData` that are empty (i.e., all their fields
|
|
3
3
|
* are undefined, null, empty strings, or themselves empty optional objects). This solves the problem
|
|
4
4
|
* where interacting with fields inside an optional object "activates" it permanently, making the
|
|
@@ -17,3 +17,4 @@ import type { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } fro
|
|
|
17
17
|
* is now built into `omitExtraData` — use that instead.
|
|
18
18
|
*/
|
|
19
19
|
export default function removeOptionalEmptyObjects<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, rootSchema?: S, formData?: T): T | undefined;
|
|
20
|
+
//# sourceMappingURL=removeOptionalEmptyObjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeOptionalEmptyObjects.d.ts","sourceRoot":"","sources":["../src/removeOptionalEmptyObjects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAqB,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElH;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,SAAS,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CA2E3F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import isObject from
|
|
2
|
-
import { isValueEmpty, retrieveSchema } from
|
|
1
|
+
import isObject from "./isObject.js";
|
|
2
|
+
import { isValueEmpty, retrieveSchema } from "./schema/index.js";
|
|
3
3
|
/** Recursively removes optional objects from the `formData` that are empty (i.e., all their fields
|
|
4
4
|
* are undefined, null, empty strings, or themselves empty optional objects). This solves the problem
|
|
5
5
|
* where interacting with fields inside an optional object "activates" it permanently, making the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeOptionalEmptyObjects.js","sourceRoot":"","sources":["../src/removeOptionalEmptyObjects.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"removeOptionalEmptyObjects.js","sourceRoot":"","sources":["../src/removeOptionalEmptyObjects.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGjE;;;;;;;;;;;;;;;;GAgBG;AACH,4DAA4D;AAC5D,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAIhD,SAAiC,EAAE,MAAS,EAAE,UAAc,EAAE,QAAY;IAC1E,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,cAAc,GAAG,cAAc,CAAU,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAExF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,cAAc,CAAC,KAAgB,CAAC;QACpD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,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G,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,gDAAgD;YAChD,4DAA4D;YAC5D,MAAM,OAAO,GAAG,0BAA0B,CAAU,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAU,CAAC,CAAC;YAEvG,IAAI,UAAU,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;gBACtB,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;QACH,CAAC;aAAM,IAAI,UAAU,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAClE,yFAAyF;YACzF,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,kFAAkF;IAClF,sFAAsF;IACtF,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceStringParameters.d.ts","sourceRoot":"","sources":["../src/replaceStringParameters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAarF"}
|
package/lib/resolveUiSchema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.
|
|
1
|
+
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.ts';
|
|
2
2
|
/** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry.
|
|
3
3
|
*
|
|
4
4
|
* Called at runtime for each field. When the schema contains a `$ref`, looks up the corresponding
|
|
@@ -16,3 +16,4 @@ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema
|
|
|
16
16
|
* @returns - The resolved uiSchema with definitions merged in
|
|
17
17
|
*/
|
|
18
18
|
export default function resolveUiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: S, localUiSchema: UiSchema<T, S, F> | undefined, registry: Registry<T, S, F>): UiSchema<T, S, F>;
|
|
19
|
+
//# sourceMappingURL=resolveUiSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveUiSchema.d.ts","sourceRoot":"","sources":["../src/resolveUiSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAEf,QAAQ,EAER,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CA6DzG"}
|
package/lib/resolveUiSchema.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import mergeObjects from './mergeObjects.js';
|
|
1
|
+
import { ANY_OF_KEY, ONE_OF_KEY, REF_KEY, RJSF_REF_KEY } from "./constants.js";
|
|
2
|
+
import findSchemaDefinition from "./findSchemaDefinition.js";
|
|
3
|
+
import mergeObjects from "./mergeObjects.js";
|
|
5
4
|
/** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry.
|
|
6
5
|
*
|
|
7
6
|
* Called at runtime for each field. When the schema contains a `$ref`, looks up the corresponding
|
|
@@ -19,15 +18,14 @@ import mergeObjects from './mergeObjects.js';
|
|
|
19
18
|
* @returns - The resolved uiSchema with definitions merged in
|
|
20
19
|
*/
|
|
21
20
|
export default function resolveUiSchema(schema, localUiSchema, registry) {
|
|
22
|
-
|
|
23
|
-
const ref = ((_a = schema[RJSF_REF_KEY]) !== null && _a !== void 0 ? _a : schema[REF_KEY]);
|
|
21
|
+
const ref = (schema[RJSF_REF_KEY] ?? schema[REF_KEY]);
|
|
24
22
|
const definitions = registry.uiSchemaDefinitions;
|
|
25
23
|
const definitionUiSchema = ref && definitions ? definitions[ref] : undefined;
|
|
26
24
|
let result;
|
|
27
25
|
if (!definitionUiSchema) {
|
|
28
26
|
result = localUiSchema || {};
|
|
29
27
|
}
|
|
30
|
-
else if (!localUiSchema ||
|
|
28
|
+
else if (!localUiSchema || Object.keys(localUiSchema).length === 0) {
|
|
31
29
|
result = { ...definitionUiSchema };
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
@@ -55,7 +53,7 @@ export default function resolveUiSchema(schema, localUiSchema, registry) {
|
|
|
55
53
|
let hasExpanded = false;
|
|
56
54
|
for (let i = 0; i < schemaOptions.length; i++) {
|
|
57
55
|
const option = schemaOptions[i];
|
|
58
|
-
const optionRef = (
|
|
56
|
+
const optionRef = (option?.[RJSF_REF_KEY] ?? option?.[REF_KEY]);
|
|
59
57
|
if (optionRef && optionRef in definitions) {
|
|
60
58
|
const optionUiSchema = (uiSchemaArray[i] || {});
|
|
61
59
|
uiSchemaArray[i] = mergeObjects(definitions[optionRef], optionUiSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveUiSchema.js","sourceRoot":"","sources":["../src/resolveUiSchema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolveUiSchema.js","sourceRoot":"","sources":["../src/resolveUiSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAW7C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAIrC,MAAS,EAAE,aAA4C,EAAE,QAA2B;IACpF,MAAM,GAAG,GAAG,CAAE,MAA2B,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAuB,CAAC;IAClG,MAAM,WAAW,GAAG,QAAQ,CAAC,mBAAmB,CAAC;IACjD,MAAM,kBAAkB,GAAG,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7E,IAAI,MAAyB,CAAC;IAC9B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,GAAG,aAAa,IAAI,EAAE,CAAC;IAC/B,CAAC;SAAM,IAAI,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrE,MAAM,GAAG,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,YAAY,CAAC,kBAAuC,EAAE,aAAkC,CAIhG,CAAC;IAC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IAAI,WAAW,EAAE,CAAC;wBAC1C,MAAM,cAAc,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAsB,CAAC;wBACrE,aAAa,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,SAAS,CAAsB,EAAE,cAAc,CAI1F,CAAC;wBACF,WAAW,GAAG,IAAI,CAAC;oBACrB,CAAC;gBACH,CAAC;gBAED,IAAI,WAAW,EAAE,CAAC;oBACf,MAA4B,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;gBACzD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Experimental_CustomMergeAllOf, FormContextType, FoundFieldType, RJSFSchema, SchemaFieldPath, StrictRJSFSchema, ValidatorType } from '../types.
|
|
1
|
+
import type { Experimental_CustomMergeAllOf, FormContextType, FoundFieldType, RJSFSchema, SchemaFieldPath, StrictRJSFSchema, ValidatorType } from '../types.ts';
|
|
2
2
|
/** Unique schema that represents no schema was found, exported for testing purposes */
|
|
3
3
|
export declare const NOT_FOUND_SCHEMA: {
|
|
4
4
|
title: string;
|
|
@@ -17,3 +17,4 @@ export declare const NOT_FOUND_SCHEMA: {
|
|
|
17
17
|
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
18
18
|
*/
|
|
19
19
|
export default function findFieldInSchema<T = undefined, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path: SchemaFieldPath, formData?: T, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): FoundFieldType<S>;
|
|
20
|
+
//# sourceMappingURL=findFieldInSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findFieldInSchema.d.ts","sourceRoot":"","sources":["../../src/schema/findFieldInSchema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAC7B,eAAe,EACf,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,uFAAuF;AACvF,eAAO,MAAM,gBAAgB;;CAAiC,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,GAAG,SAAS,EACb,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAE/B,SAAS,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACjC,UAAU,EAAE,CAAC,EACb,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,eAAe,EACrB,QAAQ,GAAE,CAAW,EACrB,6BAA6B,CAAC,EAAE,6BAA6B,CAAC,CAAC,CAAC,GAC/D,cAAc,CAAC,CAAC,CAAC,CAgGnB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import getFromSchema from './getFromSchema.js';
|
|
1
|
+
import { ANY_OF_KEY, ONE_OF_KEY, PROPERTIES_KEY, REQUIRED_KEY } from "../constants.js";
|
|
2
|
+
import { getByPath, hasByPath } from "../pathUtils.js";
|
|
3
|
+
import findSelectedOptionInXxxOf from "./findSelectedOptionInXxxOf.js";
|
|
4
|
+
import getFromSchema from "./getFromSchema.js";
|
|
6
5
|
/** Unique schema that represents no schema was found, exported for testing purposes */
|
|
7
6
|
export const NOT_FOUND_SCHEMA = { title: '!@#$_UNKNOWN_$#@!' };
|
|
8
7
|
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
@@ -28,21 +27,21 @@ export default function findFieldInSchema(validator, rootSchema, schema, path, f
|
|
|
28
27
|
// drilling into the schema for each sub-path and taking into account of the any/oneOfs
|
|
29
28
|
pathList.forEach((subPath) => {
|
|
30
29
|
parentField = getFromSchema(validator, rootSchema, parentField, [PROPERTIES_KEY, subPath], {}, experimental_customMergeAllOf);
|
|
31
|
-
if (
|
|
30
|
+
if (hasByPath(parentField, ONE_OF_KEY)) {
|
|
32
31
|
// if this sub-path has a `oneOf` then use the formData to drill into the schema with the selected option
|
|
33
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ONE_OF_KEY,
|
|
32
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ONE_OF_KEY, getByPath(formData, subPath), experimental_customMergeAllOf);
|
|
34
33
|
}
|
|
35
|
-
else if (
|
|
34
|
+
else if (hasByPath(parentField, ANY_OF_KEY)) {
|
|
36
35
|
// if this sub-path has a `anyOf` then use the formData to drill into the schema with the selected option
|
|
37
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ANY_OF_KEY,
|
|
36
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ANY_OF_KEY, getByPath(formData, subPath), experimental_customMergeAllOf);
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
if (
|
|
40
|
+
if (hasByPath(parentField, ONE_OF_KEY)) {
|
|
42
41
|
// When oneOf is in the root schema, use the formData to drill into the schema with the selected option
|
|
43
42
|
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ONE_OF_KEY, formData, experimental_customMergeAllOf);
|
|
44
43
|
}
|
|
45
|
-
else if (
|
|
44
|
+
else if (hasByPath(parentField, ANY_OF_KEY)) {
|
|
46
45
|
// When anyOf is in the root schema, use the formData to drill into the schema with the selected option
|
|
47
46
|
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ANY_OF_KEY, formData, experimental_customMergeAllOf);
|
|
48
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findFieldInSchema.js","sourceRoot":"","sources":["../../src/schema/findFieldInSchema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AAC;IACF,IAAI,UAA+B,CAAC;IACpC,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QAC1C,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.
|
|
1
|
+
import type { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.ts';
|
|
2
2
|
/** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or
|
|
3
3
|
* `properties[selectorField].const` that matches the `formData[selectorField]` value. For the purposes of this
|
|
4
4
|
* function, `selectorField` is either `schema.discriminator.propertyName` or `fallbackField`. The `LayoutGridField`
|
|
@@ -14,3 +14,4 @@ import type { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, Strict
|
|
|
14
14
|
* @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
|
|
15
15
|
*/
|
|
16
16
|
export default function findSelectedOptionInXxxOf<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, fallbackField: string, xxx: 'anyOf' | 'oneOf', formData?: T, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): S | undefined;
|
|
17
|
+
//# sourceMappingURL=findSelectedOptionInXxxOf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findSelectedOptionInXxxOf.d.ts","sourceRoot":"","sources":["../../src/schema/findSelectedOptionInXxxOf.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,6BAA6B,EAC7B,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAE/B,SAAS,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACjC,UAAU,EAAE,CAAC,EACb,MAAM,EAAE,CAAC,EACT,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,OAAO,GAAG,OAAO,EACtB,QAAQ,GAAE,CAAW,EACrB,6BAA6B,CAAC,EAAE,6BAA6B,CAAC,CAAC,CAAC,GAC/D,CAAC,GAAG,SAAS,CAsBf"}
|