@rjsf/utils 6.0.0-beta.9 → 6.0.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.js → index.cjs} +563 -200
- package/dist/index.cjs.map +7 -0
- package/dist/utils.esm.js +562 -199
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +533 -193
- package/lib/ErrorSchemaBuilder.d.ts +2 -2
- package/lib/constants.d.ts +3 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -1
- package/lib/createSchemaUtils.js +25 -18
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enums.d.ts +13 -3
- package/lib/enums.js +13 -3
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +6 -0
- package/lib/findSchemaDefinition.js +44 -3
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getDateElementProps.d.ts +1 -2
- package/lib/getTestIds.js +2 -2
- package/lib/getTestIds.js.map +1 -1
- package/lib/getUiOptions.js +4 -0
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/idGenerators.d.ts +22 -15
- package/lib/idGenerators.js +17 -8
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +16 -6
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/lib/isFormDataAvailable.d.ts +7 -0
- package/lib/isFormDataAvailable.js +13 -0
- package/lib/isFormDataAvailable.js.map +1 -0
- package/lib/isRootSchema.d.ts +13 -0
- package/lib/isRootSchema.js +25 -0
- package/lib/isRootSchema.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +14 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/nameGenerators.d.ts +13 -0
- package/lib/nameGenerators.js +30 -0
- package/lib/nameGenerators.js.map +1 -0
- package/lib/schema/getDefaultFormState.d.ts +17 -3
- package/lib/schema/getDefaultFormState.js +66 -26
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.js +2 -2
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/index.d.ts +1 -2
- package/lib/schema/index.js +1 -2
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +10 -5
- package/lib/schema/retrieveSchema.js +40 -17
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/shallowEquals.d.ts +8 -0
- package/lib/shallowEquals.js +36 -0
- package/lib/shallowEquals.js.map +1 -0
- package/lib/shouldRender.d.ts +8 -2
- package/lib/shouldRender.js +17 -2
- package/lib/shouldRender.js.map +1 -1
- package/lib/shouldRenderOptionalField.d.ts +18 -0
- package/lib/shouldRenderOptionalField.js +47 -0
- package/lib/shouldRenderOptionalField.js.map +1 -0
- package/lib/toFieldPathId.d.ts +14 -0
- package/lib/toFieldPathId.js +26 -0
- package/lib/toFieldPathId.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +196 -105
- package/lib/useAltDateWidgetProps.d.ts +39 -0
- package/lib/useAltDateWidgetProps.js +71 -0
- package/lib/useAltDateWidgetProps.js.map +1 -0
- package/lib/useDeepCompareMemo.d.ts +8 -0
- package/lib/useDeepCompareMemo.js +17 -0
- package/lib/useDeepCompareMemo.js.map +1 -0
- package/lib/useFileWidgetProps.d.ts +29 -0
- package/lib/useFileWidgetProps.js +119 -0
- package/lib/useFileWidgetProps.js.map +1 -0
- package/lib/validationDataMerge.d.ts +2 -1
- package/lib/validationDataMerge.js +3 -2
- package/lib/validationDataMerge.js.map +1 -1
- package/package.json +13 -14
- package/src/ErrorSchemaBuilder.ts +2 -2
- package/src/constants.ts +3 -0
- package/src/createSchemaUtils.ts +25 -26
- package/src/enums.ts +13 -3
- package/src/findSchemaDefinition.ts +51 -3
- package/src/getDateElementProps.ts +1 -1
- package/src/getTestIds.ts +2 -2
- package/src/getUiOptions.ts +4 -0
- package/src/getWidget.tsx +3 -3
- package/src/idGenerators.ts +35 -25
- package/src/index.ts +36 -5
- package/src/isFormDataAvailable.ts +13 -0
- package/src/isRootSchema.ts +30 -0
- package/src/mergeDefaultsWithFormData.ts +16 -2
- package/src/nameGenerators.ts +43 -0
- package/src/schema/getDefaultFormState.ts +87 -31
- package/src/schema/getDisplayLabel.ts +2 -2
- package/src/schema/index.ts +0 -2
- package/src/schema/retrieveSchema.ts +43 -7
- package/src/shallowEquals.ts +41 -0
- package/src/shouldRender.ts +27 -2
- package/src/shouldRenderOptionalField.ts +56 -0
- package/src/toFieldPathId.ts +34 -0
- package/src/types.ts +229 -113
- package/src/useAltDateWidgetProps.tsx +163 -0
- package/src/useDeepCompareMemo.ts +17 -0
- package/src/useFileWidgetProps.ts +155 -0
- package/src/validationDataMerge.ts +7 -1
- package/dist/index.js.map +0 -7
- package/lib/schema/toIdSchema.d.ts +0 -14
- package/lib/schema/toIdSchema.js +0 -62
- package/lib/schema/toIdSchema.js.map +0 -1
- package/src/schema/toIdSchema.ts +0 -131
package/lib/idGenerators.js
CHANGED
|
@@ -2,7 +2,7 @@ import isString from 'lodash-es/isString.js';
|
|
|
2
2
|
import { ID_KEY } from './constants.js';
|
|
3
3
|
/** Generates a consistent `id` pattern for a given `id` and a `suffix`
|
|
4
4
|
*
|
|
5
|
-
* @param id - Either simple string id or an
|
|
5
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
6
6
|
* @param suffix - The suffix to append to the id
|
|
7
7
|
*/
|
|
8
8
|
function idGenerator(id, suffix) {
|
|
@@ -11,7 +11,7 @@ function idGenerator(id, suffix) {
|
|
|
11
11
|
}
|
|
12
12
|
/** Return a consistent `id` for the field description element
|
|
13
13
|
*
|
|
14
|
-
* @param id - Either simple string id or an
|
|
14
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
15
15
|
* @returns - The consistent id for the field description element from the given `id`
|
|
16
16
|
*/
|
|
17
17
|
export function descriptionId(id) {
|
|
@@ -19,7 +19,7 @@ export function descriptionId(id) {
|
|
|
19
19
|
}
|
|
20
20
|
/** Return a consistent `id` for the field error element
|
|
21
21
|
*
|
|
22
|
-
* @param id - Either simple string id or an
|
|
22
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
23
23
|
* @returns - The consistent id for the field error element from the given `id`
|
|
24
24
|
*/
|
|
25
25
|
export function errorId(id) {
|
|
@@ -27,7 +27,7 @@ export function errorId(id) {
|
|
|
27
27
|
}
|
|
28
28
|
/** Return a consistent `id` for the field examples element
|
|
29
29
|
*
|
|
30
|
-
* @param id - Either simple string id or an
|
|
30
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
31
31
|
* @returns - The consistent id for the field examples element from the given `id`
|
|
32
32
|
*/
|
|
33
33
|
export function examplesId(id) {
|
|
@@ -35,7 +35,7 @@ export function examplesId(id) {
|
|
|
35
35
|
}
|
|
36
36
|
/** Return a consistent `id` for the field help element
|
|
37
37
|
*
|
|
38
|
-
* @param id - Either simple string id or an
|
|
38
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
39
39
|
* @returns - The consistent id for the field help element from the given `id`
|
|
40
40
|
*/
|
|
41
41
|
export function helpId(id) {
|
|
@@ -43,7 +43,7 @@ export function helpId(id) {
|
|
|
43
43
|
}
|
|
44
44
|
/** Return a consistent `id` for the field title element
|
|
45
45
|
*
|
|
46
|
-
* @param id - Either simple string id or an
|
|
46
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
47
47
|
* @returns - The consistent id for the field title element from the given `id`
|
|
48
48
|
*/
|
|
49
49
|
export function titleId(id) {
|
|
@@ -53,7 +53,7 @@ export function titleId(id) {
|
|
|
53
53
|
* description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
|
|
54
54
|
* element.
|
|
55
55
|
*
|
|
56
|
-
* @param id - Either simple string id or an
|
|
56
|
+
* @param id - Either simple string id or an FieldPathId from which to extract it
|
|
57
57
|
* @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
|
|
58
58
|
* @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
|
|
59
59
|
*/
|
|
@@ -72,11 +72,20 @@ export function optionId(id, optionIndex) {
|
|
|
72
72
|
}
|
|
73
73
|
/** Return a consistent `id` for the `btn` button element
|
|
74
74
|
*
|
|
75
|
-
* @param id -
|
|
75
|
+
* @param id - The id of the parent component for the option
|
|
76
76
|
* @param btn - The button type for which to generate the id
|
|
77
77
|
* @returns - The consistent id for the button from the given `id` and `btn` type
|
|
78
78
|
*/
|
|
79
79
|
export function buttonId(id, btn) {
|
|
80
80
|
return idGenerator(id, btn);
|
|
81
81
|
}
|
|
82
|
+
/** Return a consistent `id` for the optional data controls `element`
|
|
83
|
+
*
|
|
84
|
+
* @param id - The id of the parent component for the option
|
|
85
|
+
* @param element - The element type for which to generate the id
|
|
86
|
+
* @returns - The consistent id for the optional data controls element from the given `id` and `element` type
|
|
87
|
+
*/
|
|
88
|
+
export function optionalControlsId(id, element) {
|
|
89
|
+
return idGenerator(id, `optional${element}`);
|
|
90
|
+
}
|
|
82
91
|
//# sourceMappingURL=idGenerators.js.map
|
package/lib/idGenerators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idGenerators.js","sourceRoot":"","sources":["../src/idGenerators.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"idGenerators.js","sourceRoot":"","sources":["../src/idGenerators.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,SAAS,WAAW,CAAC,EAAwB,EAAE,MAAc;IAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,C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wB,EAAE,GAAsD;IACvG,OAAO,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAwB,EAAE,OAAiC;IAC5F,OAAO,WAAW,CAAC,EAAE,EAAE,WAAW,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -14,9 +15,11 @@ import enumOptionsSelectValue from './enumOptionsSelectValue.js';
|
|
|
14
15
|
import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
|
|
15
16
|
import ErrorSchemaBuilder from './ErrorSchemaBuilder.js';
|
|
16
17
|
import findSchemaDefinition from './findSchemaDefinition.js';
|
|
17
|
-
import
|
|
18
|
+
import getChangedFields from './getChangedFields.js';
|
|
19
|
+
import getDateElementProps, { DateElementFormat, DateElementProp } from './getDateElementProps.js';
|
|
18
20
|
import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
|
|
19
21
|
import getInputProps from './getInputProps.js';
|
|
22
|
+
import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
|
|
20
23
|
import getSchemaType from './getSchemaType.js';
|
|
21
24
|
import getSubmitButtonOptions from './getSubmitButtonOptions.js';
|
|
22
25
|
import getTemplate from './getTemplate.js';
|
|
@@ -26,11 +29,13 @@ import getWidget from './getWidget.js';
|
|
|
26
29
|
import guessType from './guessType.js';
|
|
27
30
|
import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema.js';
|
|
28
31
|
import hasWidget from './hasWidget.js';
|
|
29
|
-
import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators.js';
|
|
32
|
+
import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionalControlsId, optionId, titleId } from './idGenerators.js';
|
|
30
33
|
import isConstant from './isConstant.js';
|
|
31
34
|
import isCustomWidget from './isCustomWidget.js';
|
|
32
35
|
import isFixedItems from './isFixedItems.js';
|
|
36
|
+
import isFormDataAvailable from './isFormDataAvailable.js';
|
|
33
37
|
import isObject from './isObject.js';
|
|
38
|
+
import isRootSchema from './isRootSchema.js';
|
|
34
39
|
import labelValue from './labelValue.js';
|
|
35
40
|
import localToUTC from './localToUTC.js';
|
|
36
41
|
import lookupFromFormContext from './lookupFromFormContext.js';
|
|
@@ -44,20 +49,25 @@ import parseDateString from './parseDateString.js';
|
|
|
44
49
|
import rangeSpec from './rangeSpec.js';
|
|
45
50
|
import replaceStringParameters from './replaceStringParameters.js';
|
|
46
51
|
import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
|
|
47
|
-
import shouldRender from './shouldRender.js';
|
|
52
|
+
import shouldRender, { ComponentUpdateStrategy } from './shouldRender.js';
|
|
53
|
+
import shouldRenderOptionalField from './shouldRenderOptionalField.js';
|
|
48
54
|
import toConstant from './toConstant.js';
|
|
49
55
|
import toDateString from './toDateString.js';
|
|
50
56
|
import toErrorList from './toErrorList.js';
|
|
51
57
|
import toErrorSchema from './toErrorSchema.js';
|
|
58
|
+
import toFieldPathId from './toFieldPathId.js';
|
|
52
59
|
import unwrapErrorHandler from './unwrapErrorHandler.js';
|
|
60
|
+
import useAltDateWidgetProps, { DateElement, DateElementProps, UseAltDateWidgetResult } from './useAltDateWidgetProps.js';
|
|
61
|
+
import useDeepCompareMemo from './useDeepCompareMemo.js';
|
|
62
|
+
import useFileWidgetProps, { FileInfoType, UseFileWidgetPropsResult } from './useFileWidgetProps.js';
|
|
53
63
|
import utcToLocal from './utcToLocal.js';
|
|
54
64
|
import validationDataMerge from './validationDataMerge.js';
|
|
55
65
|
import withIdRefPrefix from './withIdRefPrefix.js';
|
|
56
|
-
import
|
|
57
|
-
import getChangedFields from './getChangedFields.js';
|
|
66
|
+
import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators.js';
|
|
58
67
|
export * from './types.js';
|
|
59
68
|
export * from './enums.js';
|
|
60
69
|
export * from './constants.js';
|
|
61
70
|
export * from './parser/index.js';
|
|
62
71
|
export * from './schema/index.js';
|
|
63
|
-
export {
|
|
72
|
+
export type { ComponentUpdateStrategy, DateElementFormat, DateElementProp, DateElementProps, FileInfoType, UseAltDateWidgetResult, UseFileWidgetPropsResult, };
|
|
73
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, shouldRenderOptionalField, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, useAltDateWidgetProps, useDeepCompareMemo, useFileWidgetProps, utcToLocal, validationDataMerge, withIdRefPrefix, bracketNameGenerator, dotNotationNameGenerator, };
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -14,9 +15,11 @@ import enumOptionsSelectValue from './enumOptionsSelectValue.js';
|
|
|
14
15
|
import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
|
|
15
16
|
import ErrorSchemaBuilder from './ErrorSchemaBuilder.js';
|
|
16
17
|
import findSchemaDefinition from './findSchemaDefinition.js';
|
|
18
|
+
import getChangedFields from './getChangedFields.js';
|
|
17
19
|
import getDateElementProps from './getDateElementProps.js';
|
|
18
20
|
import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
|
|
19
21
|
import getInputProps from './getInputProps.js';
|
|
22
|
+
import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
|
|
20
23
|
import getSchemaType from './getSchemaType.js';
|
|
21
24
|
import getSubmitButtonOptions from './getSubmitButtonOptions.js';
|
|
22
25
|
import getTemplate from './getTemplate.js';
|
|
@@ -26,11 +29,13 @@ import getWidget from './getWidget.js';
|
|
|
26
29
|
import guessType from './guessType.js';
|
|
27
30
|
import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema.js';
|
|
28
31
|
import hasWidget from './hasWidget.js';
|
|
29
|
-
import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionId, titleId, } from './idGenerators.js';
|
|
32
|
+
import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionalControlsId, optionId, titleId, } from './idGenerators.js';
|
|
30
33
|
import isConstant from './isConstant.js';
|
|
31
34
|
import isCustomWidget from './isCustomWidget.js';
|
|
32
35
|
import isFixedItems from './isFixedItems.js';
|
|
36
|
+
import isFormDataAvailable from './isFormDataAvailable.js';
|
|
33
37
|
import isObject from './isObject.js';
|
|
38
|
+
import isRootSchema from './isRootSchema.js';
|
|
34
39
|
import labelValue from './labelValue.js';
|
|
35
40
|
import localToUTC from './localToUTC.js';
|
|
36
41
|
import lookupFromFormContext from './lookupFromFormContext.js';
|
|
@@ -45,20 +50,24 @@ import rangeSpec from './rangeSpec.js';
|
|
|
45
50
|
import replaceStringParameters from './replaceStringParameters.js';
|
|
46
51
|
import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
|
|
47
52
|
import shouldRender from './shouldRender.js';
|
|
53
|
+
import shouldRenderOptionalField from './shouldRenderOptionalField.js';
|
|
48
54
|
import toConstant from './toConstant.js';
|
|
49
55
|
import toDateString from './toDateString.js';
|
|
50
56
|
import toErrorList from './toErrorList.js';
|
|
51
57
|
import toErrorSchema from './toErrorSchema.js';
|
|
58
|
+
import toFieldPathId from './toFieldPathId.js';
|
|
52
59
|
import unwrapErrorHandler from './unwrapErrorHandler.js';
|
|
60
|
+
import useAltDateWidgetProps, { DateElement } from './useAltDateWidgetProps.js';
|
|
61
|
+
import useDeepCompareMemo from './useDeepCompareMemo.js';
|
|
62
|
+
import useFileWidgetProps from './useFileWidgetProps.js';
|
|
53
63
|
import utcToLocal from './utcToLocal.js';
|
|
54
64
|
import validationDataMerge from './validationDataMerge.js';
|
|
55
65
|
import withIdRefPrefix from './withIdRefPrefix.js';
|
|
56
|
-
import
|
|
57
|
-
import getChangedFields from './getChangedFields.js';
|
|
66
|
+
import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators.js';
|
|
58
67
|
export * from './types.js';
|
|
59
68
|
export * from './enums.js';
|
|
60
69
|
export * from './constants.js';
|
|
61
70
|
export * from './parser/index.js';
|
|
62
71
|
export * from './schema/index.js';
|
|
63
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
72
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, shouldRenderOptionalField, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, useAltDateWidgetProps, useDeepCompareMemo, useFileWidgetProps, utcToLocal, validationDataMerge, withIdRefPrefix, bracketNameGenerator, dotNotationNameGenerator, };
|
|
64
73
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAA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Aa,EACb,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,GACzB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Determines whether the given `formData` represents valid form data, such as a primitive type, an array, or a
|
|
2
|
+
* non-empty object.
|
|
3
|
+
*
|
|
4
|
+
* @param formData - The data to check
|
|
5
|
+
* @returns - True if `formData` is not undefined, null, a primitive type or an array or an empty object
|
|
6
|
+
*/
|
|
7
|
+
export default function isFormDataAvailable<T = any>(formData?: T): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isNil from 'lodash-es/isNil.js';
|
|
2
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
3
|
+
import isObject from 'lodash-es/isObject.js';
|
|
4
|
+
/** Determines whether the given `formData` represents valid form data, such as a primitive type, an array, or a
|
|
5
|
+
* non-empty object.
|
|
6
|
+
*
|
|
7
|
+
* @param formData - The data to check
|
|
8
|
+
* @returns - True if `formData` is not undefined, null, a primitive type or an array or an empty object
|
|
9
|
+
*/
|
|
10
|
+
export default function isFormDataAvailable(formData) {
|
|
11
|
+
return !isNil(formData) && (!isObject(formData) || Array.isArray(formData) || !isEmpty(formData));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=isFormDataAvailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFormDataAvailable.js","sourceRoot":"","sources":["../src/isFormDataAvailable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAU,QAAY;IAC/D,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
|
+
/** Helper to check whether a JSON schema object is the root schema. The schema is a root schema with root `properties`
|
|
3
|
+
* key or a root `$ref` key. If the `schemaToCompare` has a root `oneOf` property, the function will
|
|
4
|
+
* return false. Else if `schemaToCompare` and `rootSchema` are the same object or equal, the function will return
|
|
5
|
+
* `true`. Else if the `rootSchema` has a $ref, it will be resolved using `schemaUtils.resolveSchema` utility. If the
|
|
6
|
+
* resolved schema matches the `schemaToCompare` the function will return `true`. Otherwise, it will return false.
|
|
7
|
+
*
|
|
8
|
+
* @param registry - The `Registry` used to get the `rootSchema` and `schemaUtils`
|
|
9
|
+
* @param schemaToCompare - The JSON schema object to check. If `schemaToCompare` is an root schema, the
|
|
10
|
+
* function will return true.
|
|
11
|
+
* @returns - Flag indicating whether the `schemaToCompare` is the root schema
|
|
12
|
+
*/
|
|
13
|
+
export default function isRootSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(registry: Registry<T, S, F>, schemaToCompare: S): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import isEqual from 'lodash-es/isEqual.js';
|
|
2
|
+
import { REF_KEY } from './constants.js';
|
|
3
|
+
/** Helper to check whether a JSON schema object is the root schema. The schema is a root schema with root `properties`
|
|
4
|
+
* key or a root `$ref` key. If the `schemaToCompare` has a root `oneOf` property, the function will
|
|
5
|
+
* return false. Else if `schemaToCompare` and `rootSchema` are the same object or equal, the function will return
|
|
6
|
+
* `true`. Else if the `rootSchema` has a $ref, it will be resolved using `schemaUtils.resolveSchema` utility. If the
|
|
7
|
+
* resolved schema matches the `schemaToCompare` the function will return `true`. Otherwise, it will return false.
|
|
8
|
+
*
|
|
9
|
+
* @param registry - The `Registry` used to get the `rootSchema` and `schemaUtils`
|
|
10
|
+
* @param schemaToCompare - The JSON schema object to check. If `schemaToCompare` is an root schema, the
|
|
11
|
+
* function will return true.
|
|
12
|
+
* @returns - Flag indicating whether the `schemaToCompare` is the root schema
|
|
13
|
+
*/
|
|
14
|
+
export default function isRootSchema(registry, schemaToCompare) {
|
|
15
|
+
const { rootSchema, schemaUtils } = registry;
|
|
16
|
+
if (isEqual(schemaToCompare, rootSchema)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (REF_KEY in rootSchema) {
|
|
20
|
+
const resolvedSchema = schemaUtils.retrieveSchema(rootSchema);
|
|
21
|
+
return isEqual(schemaToCompare, resolvedSchema);
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=isRootSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isRootSchema.js","sourceRoot":"","sources":["../src/isRootSchema.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAA2B,EAC3B,eAAkB;IAElB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IAC7C,IAAI,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -46,10 +46,22 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
46
46
|
if (isObject(formData)) {
|
|
47
47
|
const acc = Object.assign({}, defaults); // Prevent mutation of source object.
|
|
48
48
|
return Object.keys(formData).reduce((acc, key) => {
|
|
49
|
+
var _a;
|
|
49
50
|
const keyValue = get(formData, key);
|
|
50
51
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
51
52
|
const keyExistsInFormData = key in formData;
|
|
52
|
-
|
|
53
|
+
const keyDefault = (_a = get(defaults, key)) !== null && _a !== void 0 ? _a : {};
|
|
54
|
+
const defaultValueIsNestedObject = keyExistsInDefaults && Object.entries(keyDefault).some(([, v]) => isObject(v));
|
|
55
|
+
const keyDefaultIsObject = keyExistsInDefaults && isObject(get(defaults, key));
|
|
56
|
+
const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
|
|
57
|
+
if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
|
|
58
|
+
acc[key] = {
|
|
59
|
+
...get(defaults, key),
|
|
60
|
+
...keyValue,
|
|
61
|
+
};
|
|
62
|
+
return acc;
|
|
63
|
+
}
|
|
64
|
+
acc[key] = mergeDefaultsWithFormData(get(defaults, key), keyValue, mergeExtraArrayDefaults, defaultSupercedesUndefined,
|
|
53
65
|
// overrideFormDataWithDefaults can be true only when the key value exists in defaults
|
|
54
66
|
// Or if the key value doesn't exist in formData
|
|
55
67
|
overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData));
|
|
@@ -63,7 +75,7 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
63
75
|
* Or if overrideFormDataWithDefaults flag is true and formData is set to not undefined/null return defaults
|
|
64
76
|
*/
|
|
65
77
|
if ((defaultSupercedesUndefined &&
|
|
66
|
-
((!
|
|
78
|
+
((!(defaults === undefined) && isNil(formData)) || (typeof formData === 'number' && isNaN(formData)))) ||
|
|
67
79
|
(overrideFormDataWithDefaults && !isNil(formData))) {
|
|
68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}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NameGeneratorFunction } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates bracketed names
|
|
4
|
+
* Example: root[tasks][0][title]
|
|
5
|
+
* For multi-value fields (checkboxes, multi-select): root[hobbies][]
|
|
6
|
+
*/
|
|
7
|
+
export declare const bracketNameGenerator: NameGeneratorFunction;
|
|
8
|
+
/**
|
|
9
|
+
* Generates dot-notation names
|
|
10
|
+
* Example: root.tasks.0.title
|
|
11
|
+
* Multi-value fields are handled the same as single-value fields in dot notation
|
|
12
|
+
*/
|
|
13
|
+
export declare const dotNotationNameGenerator: NameGeneratorFunction;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates bracketed names
|
|
3
|
+
* Example: root[tasks][0][title]
|
|
4
|
+
* For multi-value fields (checkboxes, multi-select): root[hobbies][]
|
|
5
|
+
*/
|
|
6
|
+
export const bracketNameGenerator = (path, idPrefix, isMultiValue) => {
|
|
7
|
+
if (!path || path.length === 0) {
|
|
8
|
+
return idPrefix;
|
|
9
|
+
}
|
|
10
|
+
const baseName = path.reduce((acc, pathUnit, index) => {
|
|
11
|
+
if (index === 0) {
|
|
12
|
+
return `${idPrefix}[${String(pathUnit)}]`;
|
|
13
|
+
}
|
|
14
|
+
return `${acc}[${String(pathUnit)}]`;
|
|
15
|
+
}, '');
|
|
16
|
+
// For multi-value fields, append [] to allow multiple values with the same name
|
|
17
|
+
return isMultiValue ? `${baseName}[]` : baseName;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Generates dot-notation names
|
|
21
|
+
* Example: root.tasks.0.title
|
|
22
|
+
* Multi-value fields are handled the same as single-value fields in dot notation
|
|
23
|
+
*/
|
|
24
|
+
export const dotNotationNameGenerator = (path, idPrefix, _isMultiValue) => {
|
|
25
|
+
if (!path || path.length === 0) {
|
|
26
|
+
return idPrefix;
|
|
27
|
+
}
|
|
28
|
+
return `${idPrefix}.${path.map(String).join('.')}`;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=nameGenerators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nameGenerators.js","sourceRoot":"","sources":["../src/nameGenerators.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B,CACzD,IAAmB,EACnB,QAAgB,EAChB,YAAsB,EACd,EAAE;IACV,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QAC5D,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;IACvC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,gFAAgF;IAChF,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AACnD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA0B,CAC7D,IAAmB,EACnB,QAAgB,EAChB,aAAuB,EACf,EAAE;IACV,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -22,6 +22,15 @@ export declare enum AdditionalItemsHandling {
|
|
|
22
22
|
* @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers
|
|
23
23
|
*/
|
|
24
24
|
export declare function getInnerSchemaForArrayItem<S extends StrictRJSFSchema = RJSFSchema>(schema: S, additionalItems?: AdditionalItemsHandling, idx?: number): S;
|
|
25
|
+
/** Checks if the given `schema` contains the `null` type along with another type AND if the `default` contained within
|
|
26
|
+
* the schema is `null` AND the `computedDefault` is empty. If all of those conditions are true, then the `schema`'s
|
|
27
|
+
* default should be `null` rather than `computedDefault`.
|
|
28
|
+
*
|
|
29
|
+
* @param schema - The schema to inspect
|
|
30
|
+
* @param computedDefault - The computed default for the schema
|
|
31
|
+
* @returns - Flag indicating whether a null should be returned instead of the computedDefault
|
|
32
|
+
*/
|
|
33
|
+
export declare function computeDefaultBasedOnSchemaTypeAndDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema>(schema: S, computedDefault: T): T;
|
|
25
34
|
interface ComputeDefaultsProps<T = any, S extends StrictRJSFSchema = RJSFSchema> {
|
|
26
35
|
/** Any defaults provided by the parent field in the schema */
|
|
27
36
|
parentDefaults?: T;
|
|
@@ -42,10 +51,14 @@ interface ComputeDefaultsProps<T = any, S extends StrictRJSFSchema = RJSFSchema>
|
|
|
42
51
|
experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;
|
|
43
52
|
/** Optional flag, if true, indicates this schema was required in the parent schema. */
|
|
44
53
|
required?: boolean;
|
|
54
|
+
/** Optional flag, if true, indicates this schema was required because it is the root. */
|
|
55
|
+
requiredAsRoot?: boolean;
|
|
45
56
|
/** Optional flag, if true, It will merge defaults into formData.
|
|
46
57
|
* The formData should take precedence unless it's not valid. This is useful when for example the value from formData does not exist in the schema 'enum' property, in such cases we take the value from the defaults because the value from the formData is not valid.
|
|
47
58
|
*/
|
|
48
59
|
shouldMergeDefaultsIntoFormData?: boolean;
|
|
60
|
+
/** Indicates whether initial defaults have been generated */
|
|
61
|
+
initialDefaultsGenerated?: boolean;
|
|
49
62
|
}
|
|
50
63
|
/** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into
|
|
51
64
|
* each level of the schema, recursively, to fill out every level of defaults provided by the schema.
|
|
@@ -76,7 +89,7 @@ export declare function ensureFormDataMatchingSchema<T = any, S extends StrictRJ
|
|
|
76
89
|
* @param defaults - Optional props for this function
|
|
77
90
|
* @returns - The default value based on the schema type if they are defined for object or array schemas.
|
|
78
91
|
*/
|
|
79
|
-
export declare function getObjectDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rawSchema: S, { rawFormData, rootSchema, includeUndefinedValues, _recurseList, experimental_defaultFormStateBehavior, experimental_customMergeAllOf, required, shouldMergeDefaultsIntoFormData, }?: ComputeDefaultsProps<T, S>, defaults?: T | T[]
|
|
92
|
+
export declare function getObjectDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rawSchema: S, { rawFormData, rootSchema, includeUndefinedValues, _recurseList, experimental_defaultFormStateBehavior, experimental_customMergeAllOf, required, shouldMergeDefaultsIntoFormData, initialDefaultsGenerated, }?: ComputeDefaultsProps<T, S>, defaults?: T | T[]): T;
|
|
80
93
|
/** Computes the default value for arrays.
|
|
81
94
|
*
|
|
82
95
|
* @param validator - an implementation of the `ValidatorType` interface that will be used when necessary
|
|
@@ -85,7 +98,7 @@ export declare function getObjectDefaults<T = any, S extends StrictRJSFSchema =
|
|
|
85
98
|
* @param defaults - Optional props for this function
|
|
86
99
|
* @returns - The default value based on the schema type if they are defined for object or array schemas.
|
|
87
100
|
*/
|
|
88
|
-
export declare function getArrayDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rawSchema: S, { rawFormData, rootSchema, _recurseList, experimental_defaultFormStateBehavior, experimental_customMergeAllOf, required, shouldMergeDefaultsIntoFormData, }?: ComputeDefaultsProps<T, S>, defaults?: T
|
|
101
|
+
export declare function getArrayDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rawSchema: S, { rawFormData, rootSchema, _recurseList, experimental_defaultFormStateBehavior, experimental_customMergeAllOf, required, requiredAsRoot, shouldMergeDefaultsIntoFormData, initialDefaultsGenerated, }?: ComputeDefaultsProps<T, S>, defaults?: T[]): T[] | undefined;
|
|
89
102
|
/** Computes the default value based on the schema type.
|
|
90
103
|
*
|
|
91
104
|
* @param validator - an implementation of the `ValidatorType` interface that will be used when necessary
|
|
@@ -107,7 +120,8 @@ export declare function getDefaultBasedOnSchemaType<T = any, S extends StrictRJS
|
|
|
107
120
|
* false when computing defaults for any nested object properties.
|
|
108
121
|
* @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
|
|
109
122
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
123
|
+
* @param initialDefaultsGenerated - Optional flag, indicates whether or not initial defaults have been generated
|
|
110
124
|
* @returns - The resulting `formData` with all the defaults provided
|
|
111
125
|
*/
|
|
112
|
-
export default function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean | 'excludeObjectChildren', experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S
|
|
126
|
+
export default function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean | 'excludeObjectChildren', experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>, initialDefaultsGenerated?: boolean): T | T[] | undefined;
|
|
113
127
|
export {};
|