@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1347 -642
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1324 -619
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1266 -590
- package/lib/ErrorSchemaBuilder.d.ts +8 -4
- package/lib/ErrorSchemaBuilder.js +10 -8
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/allowAdditionalItems.d.ts +1 -1
- package/lib/allowAdditionalItems.js +1 -1
- package/lib/allowAdditionalItems.js.map +1 -1
- package/lib/asNumber.js.map +1 -1
- package/lib/canExpand.d.ts +2 -2
- package/lib/canExpand.js +2 -2
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.d.ts +9 -0
- package/lib/constIsAjvDataReference.js +15 -0
- package/lib/constIsAjvDataReference.js.map +1 -0
- package/lib/constants.d.ts +15 -3
- package/lib/constants.js +15 -3
- package/lib/constants.js.map +1 -1
- package/lib/createErrorHandler.d.ts +1 -1
- package/lib/createErrorHandler.js +2 -2
- package/lib/createErrorHandler.js.map +1 -1
- package/lib/createSchemaUtils.d.ts +3 -2
- package/lib/createSchemaUtils.js +56 -46
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/dateRangeOptions.d.ts +1 -1
- package/lib/dateRangeOptions.js +1 -1
- package/lib/dateRangeOptions.js.map +1 -1
- package/lib/deepEquals.js +1 -1
- package/lib/deepEquals.js.map +1 -1
- package/lib/englishStringTranslator.d.ts +1 -1
- package/lib/englishStringTranslator.js +1 -1
- package/lib/enumOptionsDeselectValue.d.ts +1 -1
- package/lib/enumOptionsDeselectValue.js +4 -4
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.d.ts +1 -1
- package/lib/enumOptionsIndexForValue.js +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.d.ts +1 -1
- package/lib/enumOptionsIsSelected.js +3 -3
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.d.ts +1 -1
- package/lib/enumOptionsSelectValue.js +2 -2
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.d.ts +1 -1
- package/lib/enumOptionsValueForIndex.js.map +1 -1
- package/lib/enums.d.ts +2 -0
- package/lib/enums.js +2 -0
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +5 -3
- package/lib/findSchemaDefinition.js +54 -11
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.d.ts +17 -0
- package/lib/getChangedFields.js +42 -0
- package/lib/getChangedFields.js.map +1 -0
- package/lib/getDateElementProps.d.ts +1 -1
- package/lib/getDateElementProps.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js +4 -3
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getInputProps.d.ts +1 -1
- package/lib/getInputProps.js +4 -1
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getSchemaType.d.ts +2 -1
- package/lib/getSchemaType.js +3 -2
- package/lib/getSchemaType.js.map +1 -1
- package/lib/getSubmitButtonOptions.d.ts +1 -1
- package/lib/getSubmitButtonOptions.js +2 -2
- package/lib/getSubmitButtonOptions.js.map +1 -1
- package/lib/getTemplate.d.ts +1 -1
- package/lib/getTemplate.js +9 -0
- package/lib/getTemplate.js.map +1 -1
- package/lib/getTestIds.d.ts +17 -0
- package/lib/getTestIds.js +34 -0
- package/lib/getTestIds.js.map +1 -0
- package/lib/getUiOptions.d.ts +1 -1
- package/lib/getUiOptions.js +2 -2
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.d.ts +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/guessType.js.map +1 -1
- package/lib/hasWidget.d.ts +1 -1
- package/lib/hasWidget.js +1 -1
- package/lib/hasWidget.js.map +1 -1
- package/lib/hashForSchema.d.ts +23 -1
- package/lib/hashForSchema.js +24 -6
- package/lib/hashForSchema.js.map +1 -1
- package/lib/idGenerators.d.ts +8 -1
- package/lib/idGenerators.js +11 -2
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +63 -60
- package/lib/index.js +63 -60
- package/lib/index.js.map +1 -1
- package/lib/isConstant.d.ts +1 -1
- package/lib/isConstant.js +1 -1
- package/lib/isCustomWidget.d.ts +1 -1
- package/lib/isCustomWidget.js +1 -1
- package/lib/isFixedItems.d.ts +1 -1
- package/lib/isFixedItems.js +1 -1
- package/lib/isObject.d.ts +2 -2
- package/lib/isObject.js +11 -4
- package/lib/isObject.js.map +1 -1
- package/lib/lookupFromFormContext.d.ts +11 -0
- package/lib/lookupFromFormContext.js +20 -0
- package/lib/lookupFromFormContext.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts +8 -2
- package/lib/mergeDefaultsWithFormData.js +39 -10
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/mergeObjects.d.ts +1 -1
- package/lib/mergeObjects.js +1 -1
- package/lib/mergeObjects.js.map +1 -1
- package/lib/mergeSchemas.d.ts +1 -1
- package/lib/mergeSchemas.js +4 -4
- package/lib/mergeSchemas.js.map +1 -1
- package/lib/optionsList.d.ts +9 -7
- package/lib/optionsList.js +30 -19
- package/lib/optionsList.js.map +1 -1
- package/lib/orderProperties.js.map +1 -1
- package/lib/pad.js.map +1 -1
- package/lib/parseDateString.d.ts +1 -1
- package/lib/parseDateString.js +1 -1
- package/lib/parseDateString.js.map +1 -1
- package/lib/parser/ParserValidator.d.ts +1 -1
- package/lib/parser/ParserValidator.js +6 -6
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +2 -2
- package/lib/parser/index.js +1 -1
- package/lib/parser/schemaParser.d.ts +2 -2
- package/lib/parser/schemaParser.js +6 -6
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/rangeSpec.d.ts +2 -2
- package/lib/rangeSpec.js.map +1 -1
- package/lib/replaceStringParameters.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +19 -0
- package/lib/schema/findFieldInSchema.js +61 -0
- package/lib/schema/findFieldInSchema.js.map +1 -0
- package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
- package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
- package/lib/schema/getClosestMatchingOption.d.ts +5 -3
- package/lib/schema/getClosestMatchingOption.js +28 -20
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +60 -13
- package/lib/schema/getDefaultFormState.js +316 -167
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.d.ts +3 -2
- package/lib/schema/getDisplayLabel.js +10 -9
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/getFirstMatchingOption.d.ts +1 -1
- package/lib/schema/getFirstMatchingOption.js +70 -2
- package/lib/schema/getFirstMatchingOption.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +14 -0
- package/lib/schema/getFromSchema.js +39 -0
- package/lib/schema/getFromSchema.js.map +1 -0
- package/lib/schema/index.d.ts +15 -14
- package/lib/schema/index.js +15 -14
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isFilesArray.d.ts +3 -2
- package/lib/schema/isFilesArray.js +5 -4
- package/lib/schema/isFilesArray.js.map +1 -1
- package/lib/schema/isMultiSelect.d.ts +3 -2
- package/lib/schema/isMultiSelect.js +4 -3
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/isSelect.d.ts +3 -2
- package/lib/schema/isSelect.js +5 -4
- package/lib/schema/isSelect.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +30 -12
- package/lib/schema/retrieveSchema.js +153 -70
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
- package/lib/schema/sanitizeDataForNewSchema.js +12 -11
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/toIdSchema.d.ts +3 -2
- package/lib/schema/toIdSchema.js +30 -27
- package/lib/schema/toIdSchema.js.map +1 -1
- package/lib/schema/toPathSchema.d.ts +3 -2
- package/lib/schema/toPathSchema.js +22 -20
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/schemaRequiresTrueValue.d.ts +1 -1
- package/lib/schemaRequiresTrueValue.js.map +1 -1
- package/lib/shouldRender.js +1 -1
- package/lib/toConstant.d.ts +1 -1
- package/lib/toConstant.js +1 -1
- package/lib/toConstant.js.map +1 -1
- package/lib/toDateString.d.ts +1 -1
- package/lib/toErrorList.d.ts +1 -1
- package/lib/toErrorList.js +2 -2
- package/lib/toErrorList.js.map +1 -1
- package/lib/toErrorSchema.d.ts +1 -1
- package/lib/toErrorSchema.js +2 -2
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +172 -142
- package/lib/unwrapErrorHandler.d.ts +1 -1
- package/lib/unwrapErrorHandler.js +1 -1
- package/lib/unwrapErrorHandler.js.map +1 -1
- package/lib/utcToLocal.js +1 -1
- package/lib/utcToLocal.js.map +1 -1
- package/lib/validationDataMerge.d.ts +1 -1
- package/lib/validationDataMerge.js +3 -3
- package/lib/validationDataMerge.js.map +1 -1
- package/lib/withIdRefPrefix.d.ts +1 -1
- package/lib/withIdRefPrefix.js +2 -2
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +37 -26
- package/src/ErrorSchemaBuilder.ts +15 -8
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +17 -0
- package/src/constants.ts +17 -3
- package/src/createSchemaUtils.ts +140 -50
- package/src/dataURItoBlob.ts +1 -1
- package/src/dateRangeOptions.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +4 -5
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +4 -5
- package/src/enumOptionsSelectValue.ts +1 -1
- package/src/enumOptionsValueForIndex.ts +1 -1
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +55 -10
- package/src/getChangedFields.ts +40 -0
- package/src/getDateElementProps.ts +2 -2
- package/src/getDiscriminatorFieldFromSchema.ts +2 -1
- package/src/getInputProps.ts +6 -2
- package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
- package/src/getSchemaType.ts +3 -2
- package/src/getSubmitButtonOptions.ts +1 -1
- package/src/getTemplate.ts +12 -1
- package/src/getTestIds.ts +40 -0
- package/src/getUiOptions.ts +2 -2
- package/src/getWidget.tsx +2 -2
- package/src/hasWidget.ts +1 -1
- package/src/hashForSchema.ts +26 -6
- package/src/idGenerators.ts +10 -0
- package/src/index.ts +21 -2
- package/src/isCustomWidget.ts +1 -1
- package/src/isObject.ts +12 -5
- package/src/labelValue.ts +2 -2
- package/src/lookupFromFormContext.ts +26 -0
- package/src/mergeDefaultsWithFormData.ts +54 -9
- package/src/mergeObjects.ts +24 -21
- package/src/optionsList.ts +31 -22
- package/src/parser/ParserValidator.ts +5 -5
- package/src/parser/schemaParser.ts +6 -6
- package/src/schema/findFieldInSchema.ts +138 -0
- package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
- package/src/schema/getClosestMatchingOption.ts +38 -11
- package/src/schema/getDefaultFormState.ts +461 -193
- package/src/schema/getDisplayLabel.ts +7 -4
- package/src/schema/getFirstMatchingOption.ts +79 -4
- package/src/schema/getFromSchema.ts +100 -0
- package/src/schema/index.ts +6 -4
- package/src/schema/isFilesArray.ts +18 -3
- package/src/schema/isMultiSelect.ts +10 -4
- package/src/schema/isSelect.ts +5 -3
- package/src/schema/retrieveSchema.ts +268 -78
- package/src/schema/sanitizeDataForNewSchema.ts +52 -11
- package/src/schema/toIdSchema.ts +69 -43
- package/src/schema/toPathSchema.ts +49 -16
- package/src/toErrorList.ts +2 -2
- package/src/types.ts +278 -184
- package/src/validationDataMerge.ts +1 -1
- package/src/withIdRefPrefix.ts +1 -1
- package/LICENSE.md +0 -201
- package/lib/schema/getMatchingOption.d.ts +0 -14
- package/lib/schema/getMatchingOption.js +0 -85
- package/lib/schema/getMatchingOption.js.map +0 -1
- package/lib/schema/mergeValidationData.d.ts +0 -14
- package/lib/schema/mergeValidationData.js +0 -28
- package/lib/schema/mergeValidationData.js.map +0 -1
- package/src/schema/getMatchingOption.ts +0 -103
- package/src/schema/mergeValidationData.ts +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;QACxC,CAAC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
|
package/lib/utcToLocal.js
CHANGED
package/lib/utcToLocal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utcToLocal.js","sourceRoot":"","sources":["../src/utcToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAgB;IACjD,IAAI,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"utcToLocal.js","sourceRoot":"","sources":["../src/utcToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAgB;IACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iFAAiF;IACjF,sGAAsG;IACtG,6DAA6D;IAE7D,mEAAmE;IACnE,mCAAmC;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;IAE3C,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema, ValidationData } from './types';
|
|
1
|
+
import { ErrorSchema, ValidationData } from './types.js';
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
|
-
import mergeObjects from './mergeObjects';
|
|
3
|
-
import toErrorList from './toErrorList';
|
|
1
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
2
|
+
import mergeObjects from './mergeObjects.js';
|
|
3
|
+
import toErrorList from './toErrorList.js';
|
|
4
4
|
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
5
5
|
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
6
6
|
* `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC;IAEtC,IAAI,CAAC,qBAAqB,EAAE;
|
|
1
|
+
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC;IAEtC,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,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7B,WAAW,GAAG,YAAY,CAAC,cAAc,EAAE,qBAAqB,EAAE,IAAI,CAAmB,CAAC;QAC1F,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 { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
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
|
*
|
package/lib/withIdRefPrefix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';
|
|
2
|
-
import isObject from 'lodash/isObject';
|
|
1
|
+
import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.js';
|
|
2
|
+
import isObject from 'lodash-es/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,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;;;GAIG;AACH,SAAS,qBAAqB,CAA0C,IAAO;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"withIdRefPrefix.js","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;;;GAIG;AACH,SAAS,qBAAqB,CAA0C,IAAO;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAyB,IAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,GAAG,KAAK,OAAO,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,KAAK,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAI,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAA0C,IAAS;IAC9E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,CAAC,GAAG,eAAe,CAAI,IAAI,CAAC,CAAC,CAAC,CAAM,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,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,10 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/utils",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-beta.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"description": "Utility functions for @rjsf/core",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"import": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./lib": {
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"import": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./lib/*.js": {
|
|
21
|
+
"types": "./lib/*.d.ts",
|
|
22
|
+
"require": "./dist/*.js",
|
|
23
|
+
"import": "./lib/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./dist": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"require": "./dist/index.js",
|
|
28
|
+
"import": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./dist/*.js": {
|
|
31
|
+
"types": "./lib/*.d.ts",
|
|
32
|
+
"require": "./dist/*.js",
|
|
33
|
+
"import": "./lib/*.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
8
36
|
"files": [
|
|
9
37
|
"dist",
|
|
10
38
|
"lib",
|
|
@@ -12,10 +40,11 @@
|
|
|
12
40
|
],
|
|
13
41
|
"engineStrict": false,
|
|
14
42
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
43
|
+
"node": ">=20"
|
|
16
44
|
},
|
|
17
45
|
"scripts": {
|
|
18
|
-
"
|
|
46
|
+
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
|
|
47
|
+
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
19
48
|
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
|
|
20
49
|
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
|
|
21
50
|
"build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
|
|
@@ -33,40 +62,23 @@
|
|
|
33
62
|
]
|
|
34
63
|
},
|
|
35
64
|
"peerDependencies": {
|
|
36
|
-
"react": "
|
|
65
|
+
"react": ">=18"
|
|
37
66
|
},
|
|
38
67
|
"dependencies": {
|
|
68
|
+
"fast-uri": "^3.0.6",
|
|
39
69
|
"json-schema-merge-allof": "^0.8.1",
|
|
40
70
|
"jsonpointer": "^5.0.1",
|
|
41
71
|
"lodash": "^4.17.21",
|
|
42
72
|
"lodash-es": "^4.17.21",
|
|
73
|
+
"nanoid": "^5.1.5",
|
|
43
74
|
"react-is": "^18.2.0"
|
|
44
75
|
},
|
|
45
76
|
"devDependencies": {
|
|
46
|
-
"@babel/core": "^7.23.9",
|
|
47
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
48
|
-
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
49
|
-
"@babel/preset-env": "^7.23.9",
|
|
50
|
-
"@babel/preset-react": "^7.23.3",
|
|
51
|
-
"@babel/preset-typescript": "^7.23.3",
|
|
52
|
-
"@types/jest": "^29.5.12",
|
|
53
77
|
"@types/json-schema": "^7.0.15",
|
|
54
78
|
"@types/json-schema-merge-allof": "^0.6.5",
|
|
55
|
-
"@types/lodash": "^4.14.202",
|
|
56
|
-
"@types/react": "^18.2.58",
|
|
57
79
|
"@types/react-is": "^18.2.4",
|
|
58
|
-
"@types/react-test-renderer": "^18.0.7",
|
|
59
|
-
"babel-jest": "^29.7.0",
|
|
60
80
|
"deep-freeze-es6": "^1.4.1",
|
|
61
|
-
"
|
|
62
|
-
"eslint": "^8.56.0",
|
|
63
|
-
"jest": "^29.7.0",
|
|
64
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
65
|
-
"react": "^18.2.0",
|
|
66
|
-
"react-test-renderer": "^18.2.0",
|
|
67
|
-
"rimraf": "^5.0.5",
|
|
68
|
-
"rollup": "^3.29.4",
|
|
69
|
-
"typescript": "^4.9.5"
|
|
81
|
+
"eslint": "^8.56.0"
|
|
70
82
|
},
|
|
71
83
|
"publishConfig": {
|
|
72
84
|
"access": "public"
|
|
@@ -85,6 +97,5 @@
|
|
|
85
97
|
"type": "git",
|
|
86
98
|
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
87
99
|
},
|
|
88
|
-
"license": "Apache-2.0"
|
|
89
|
-
"gitHead": "f4229bf6e067d31b24de3ef9d3ca754ee52529ac"
|
|
100
|
+
"license": "Apache-2.0"
|
|
90
101
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import cloneDeep from 'lodash/cloneDeep';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import set from 'lodash/set';
|
|
4
|
+
import setWith from 'lodash/setWith';
|
|
4
5
|
|
|
5
6
|
import { ErrorSchema } from './types';
|
|
6
7
|
import { ERRORS_KEY } from './constants';
|
|
7
8
|
|
|
9
|
+
/** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where
|
|
10
|
+
* numbers represent array indexes/
|
|
11
|
+
*/
|
|
12
|
+
export type PathType = string | (string | number)[];
|
|
13
|
+
|
|
8
14
|
/** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
|
|
9
15
|
* designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
|
|
10
16
|
* schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
|
|
@@ -37,12 +43,13 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
37
43
|
* @returns - The error block for the given `pathOfError` or the root if not provided
|
|
38
44
|
* @private
|
|
39
45
|
*/
|
|
40
|
-
private getOrCreateErrorBlock(pathOfError?:
|
|
46
|
+
private getOrCreateErrorBlock(pathOfError?: PathType) {
|
|
41
47
|
const hasPath = (Array.isArray(pathOfError) && pathOfError.length > 0) || typeof pathOfError === 'string';
|
|
48
|
+
// @ts-expect-error TS2590 to avoid "Expression produces a union type that is too complex to represent" error
|
|
42
49
|
let errorBlock: ErrorSchema = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;
|
|
43
50
|
if (!errorBlock && pathOfError) {
|
|
44
51
|
errorBlock = {};
|
|
45
|
-
|
|
52
|
+
setWith(this.errorSchema, pathOfError, errorBlock, Object);
|
|
46
53
|
}
|
|
47
54
|
return errorBlock;
|
|
48
55
|
}
|
|
@@ -65,7 +72,7 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
65
72
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
|
|
66
73
|
* @returns - The `ErrorSchemaBuilder` object for chaining purposes
|
|
67
74
|
*/
|
|
68
|
-
addErrors(errorOrList: string | string[], pathOfError?:
|
|
75
|
+
addErrors(errorOrList: string | string[], pathOfError?: PathType) {
|
|
69
76
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
70
77
|
let errorsList = get(errorBlock, ERRORS_KEY);
|
|
71
78
|
if (!Array.isArray(errorsList)) {
|
|
@@ -74,9 +81,9 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
if (Array.isArray(errorOrList)) {
|
|
77
|
-
|
|
84
|
+
set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, ...errorOrList])]);
|
|
78
85
|
} else {
|
|
79
|
-
errorsList
|
|
86
|
+
set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, errorOrList])]);
|
|
80
87
|
}
|
|
81
88
|
return this;
|
|
82
89
|
}
|
|
@@ -89,10 +96,10 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
89
96
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
|
|
90
97
|
* @returns - The `ErrorSchemaBuilder` object for chaining purposes
|
|
91
98
|
*/
|
|
92
|
-
setErrors(errorOrList: string | string[], pathOfError?:
|
|
99
|
+
setErrors(errorOrList: string | string[], pathOfError?: PathType) {
|
|
93
100
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
94
101
|
// Effectively clone the array being given to prevent accidental outside manipulation of the given list
|
|
95
|
-
const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
|
|
102
|
+
const listToAdd = Array.isArray(errorOrList) ? [...new Set([...errorOrList])] : [errorOrList];
|
|
96
103
|
set(errorBlock, ERRORS_KEY, listToAdd);
|
|
97
104
|
return this;
|
|
98
105
|
}
|
|
@@ -104,7 +111,7 @@ export default class ErrorSchemaBuilder<T = any> {
|
|
|
104
111
|
* @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
|
|
105
112
|
* @returns - The `ErrorSchemaBuilder` object for chaining purposes
|
|
106
113
|
*/
|
|
107
|
-
clearErrors(pathOfError?:
|
|
114
|
+
clearErrors(pathOfError?: PathType) {
|
|
108
115
|
const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
|
|
109
116
|
set(errorBlock, ERRORS_KEY, []);
|
|
110
117
|
return this;
|
package/src/canExpand.ts
CHANGED
|
@@ -13,9 +13,9 @@ import getUiOptions from './getUiOptions';
|
|
|
13
13
|
export default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
14
14
|
schema: RJSFSchema,
|
|
15
15
|
uiSchema: UiSchema<T, S, F> = {},
|
|
16
|
-
formData?: T
|
|
16
|
+
formData?: T,
|
|
17
17
|
) {
|
|
18
|
-
if (!schema.additionalProperties) {
|
|
18
|
+
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
const { expandable = true } = getUiOptions<T, S, F>(uiSchema);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CONST_KEY, getSchemaType, isObject } from './';
|
|
2
|
+
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
3
|
+
import { JSONSchema7Type } from 'json-schema';
|
|
4
|
+
import isString from 'lodash/isString';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the schema const property value is an AJV $data reference
|
|
8
|
+
* and the current schema is not an object or array
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema to check if the const is an AJV $data reference
|
|
11
|
+
* @returns - true if the schema const property value is an AJV $data reference otherwise false.
|
|
12
|
+
*/
|
|
13
|
+
export default function constIsAjvDataReference<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {
|
|
14
|
+
const schemaConst = schema[CONST_KEY] as JSONSchema7Type & { $data: string };
|
|
15
|
+
const schemaType = getSchemaType<S>(schema);
|
|
16
|
+
return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== 'object' && schemaType !== 'array';
|
|
17
|
+
}
|
package/src/constants.ts
CHANGED
|
@@ -19,17 +19,31 @@ export const ITEMS_KEY = 'items';
|
|
|
19
19
|
export const JUNK_OPTION_ID = '_$junk_option_schema_id$_';
|
|
20
20
|
export const NAME_KEY = '$name';
|
|
21
21
|
export const ONE_OF_KEY = 'oneOf';
|
|
22
|
+
export const PATTERN_PROPERTIES_KEY = 'patternProperties';
|
|
22
23
|
export const PROPERTIES_KEY = 'properties';
|
|
24
|
+
export const READONLY_KEY = 'readonly';
|
|
23
25
|
export const REQUIRED_KEY = 'required';
|
|
24
26
|
export const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
|
|
25
27
|
export const REF_KEY = '$ref';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
export const SCHEMA_KEY = '$schema';
|
|
29
|
+
/** The path of the discriminator value returned by the schema endpoint.
|
|
30
|
+
* The discriminator is the value in a `oneOf` that determines which option is selected.
|
|
28
31
|
*/
|
|
29
|
-
export const
|
|
32
|
+
export const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];
|
|
33
|
+
/** The name of the `formContext` attribute in the React JSON Schema Form Registry
|
|
34
|
+
*/
|
|
35
|
+
export const FORM_CONTEXT_NAME = 'formContext';
|
|
36
|
+
|
|
37
|
+
/** The name of the `layoutGridLookupMap` attribute in the form context
|
|
38
|
+
*/
|
|
39
|
+
export const LOOKUP_MAP_NAME = 'layoutGridLookupMap';
|
|
30
40
|
export const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
|
|
31
41
|
export const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
|
|
32
42
|
export const UI_FIELD_KEY = 'ui:field';
|
|
33
43
|
export const UI_WIDGET_KEY = 'ui:widget';
|
|
34
44
|
export const UI_OPTIONS_KEY = 'ui:options';
|
|
35
45
|
export const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
46
|
+
|
|
47
|
+
/** The JSON Schema version strings
|
|
48
|
+
*/
|
|
49
|
+
export const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
|