@rjsf/utils 6.5.2 → 6.6.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 +628 -441
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +624 -437
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +632 -445
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.js +1 -1
- package/lib/constIsAjvDataReference.js.map +1 -1
- package/lib/createSchemaUtils.js +3 -3
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enumOptionSelectedValue.js.map +1 -1
- package/lib/enumOptionValueDecoder.js.map +1 -1
- package/lib/enumOptionsDeselectValue.js +1 -1
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.js +1 -1
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.js +2 -2
- 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.js +4 -4
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.js +3 -3
- package/lib/getChangedFields.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getTestIds.d.ts +1 -1
- package/lib/getTestIds.js +4 -3
- package/lib/getTestIds.js.map +1 -1
- package/lib/getWidget.js +1 -1
- package/lib/getWidget.js.map +1 -1
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/isFormDataAvailable.js +1 -1
- package/lib/isFormDataAvailable.js.map +1 -1
- package/lib/isRootSchema.js +1 -1
- package/lib/isRootSchema.js.map +1 -1
- package/lib/jsonSchemaAugmentation.d.ts +19 -0
- package/lib/jsonSchemaAugmentation.js +2 -0
- package/lib/jsonSchemaAugmentation.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +2 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/parser/ParserValidator.js +1 -1
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.js.map +1 -1
- package/lib/parser/schemaParser.js +2 -2
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/removeOptionalEmptyObjects.d.ts +2 -0
- package/lib/removeOptionalEmptyObjects.js +8 -29
- package/lib/removeOptionalEmptyObjects.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +2 -2
- package/lib/schema/findFieldInSchema.js +7 -6
- package/lib/schema/findFieldInSchema.js.map +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
- package/lib/schema/getClosestMatchingOption.js +3 -3
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +4 -4
- package/lib/schema/getDefaultFormState.js +17 -22
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +3 -3
- package/lib/schema/getFromSchema.js +3 -3
- package/lib/schema/getFromSchema.js.map +1 -1
- package/lib/schema/index.d.ts +4 -4
- package/lib/schema/index.js +4 -4
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/omitExtraData.d.ts +18 -8
- package/lib/schema/omitExtraData.js +352 -16
- package/lib/schema/omitExtraData.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +15 -0
- package/lib/schema/retrieveSchema.js +36 -13
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/shallowAllOfMerge.d.ts +11 -0
- package/lib/schema/shallowAllOfMerge.js +18 -0
- package/lib/schema/shallowAllOfMerge.js.map +1 -0
- package/lib/schema/toPathSchema.d.ts +1 -0
- package/lib/schema/toPathSchema.js +2 -1
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/shouldRenderOptionalField.js +1 -1
- package/lib/shouldRenderOptionalField.js.map +1 -1
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +17 -5
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/useFileWidgetProps.d.ts +1 -1
- package/lib/useFileWidgetProps.js +9 -10
- package/lib/useFileWidgetProps.js.map +1 -1
- package/lib/withIdRefPrefix.js +1 -1
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +11 -11
- package/src/ErrorSchemaBuilder.ts +1 -1
- package/src/canExpand.ts +1 -1
- package/src/constIsAjvDataReference.ts +3 -2
- package/src/createSchemaUtils.ts +22 -20
- package/src/enumOptionSelectedValue.ts +1 -1
- package/src/enumOptionValueDecoder.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +2 -2
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +1 -1
- package/src/enumOptionsSelectValue.ts +3 -2
- package/src/enumOptionsValueForIndex.ts +2 -2
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +4 -4
- package/src/getChangedFields.ts +4 -3
- package/src/getDiscriminatorFieldFromSchema.ts +1 -1
- package/src/getOptionMatchingSimpleDiscriminator.ts +1 -0
- package/src/getTestIds.ts +4 -3
- package/src/getWidget.tsx +2 -2
- package/src/idGenerators.ts +1 -1
- package/src/index.ts +6 -6
- package/src/isFormDataAvailable.ts +1 -1
- package/src/isRootSchema.ts +1 -1
- package/src/jsonSchemaAugmentation.ts +21 -0
- package/src/mergeDefaultsWithFormData.ts +4 -3
- package/src/parser/ParserValidator.ts +1 -1
- package/src/parser/index.ts +1 -1
- package/src/parser/schemaParser.ts +3 -3
- package/src/removeOptionalEmptyObjects.ts +8 -30
- package/src/schema/findFieldInSchema.ts +10 -8
- package/src/schema/findSelectedOptionInXxxOf.ts +1 -1
- package/src/schema/getClosestMatchingOption.ts +4 -4
- package/src/schema/getDefaultFormState.ts +18 -24
- package/src/schema/getFromSchema.ts +15 -8
- package/src/schema/index.ts +5 -3
- package/src/schema/isMultiSelect.ts +0 -1
- package/src/schema/omitExtraData.ts +398 -19
- package/src/schema/retrieveSchema.ts +41 -15
- package/src/schema/sanitizeDataForNewSchema.ts +1 -1
- package/src/schema/shallowAllOfMerge.ts +19 -0
- package/src/schema/toPathSchema.ts +2 -1
- package/src/shouldRenderOptionalField.ts +2 -2
- package/src/toErrorSchema.ts +1 -1
- package/src/tsconfig.json +0 -1
- package/src/types.ts +18 -5
- package/src/useFileWidgetProps.ts +9 -10
- package/src/withIdRefPrefix.ts +2 -1
package/src/types.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import { JSONSchema7 } from 'json-schema';
|
|
12
12
|
|
|
13
13
|
import { TranslatableString } from './enums';
|
|
14
|
+
import './jsonSchemaAugmentation';
|
|
14
15
|
|
|
15
16
|
/** The representation of any generic object type, usually used as an intersection on other types to make them more
|
|
16
17
|
* flexible in the properties they support (i.e. anything else)
|
|
@@ -185,6 +186,9 @@ export type InputPropsType = {
|
|
|
185
186
|
*/
|
|
186
187
|
export type FieldPathList = (string | number)[];
|
|
187
188
|
|
|
189
|
+
/** Dot string or segment list for `getFromSchema` / `findFieldInSchema` (same segment rules as {@link FieldPathList}). */
|
|
190
|
+
export type SchemaFieldPath = string | FieldPathList;
|
|
191
|
+
|
|
188
192
|
/** Type describing an id and path used for a field */
|
|
189
193
|
export type FieldPathId = {
|
|
190
194
|
/** The id for a field */
|
|
@@ -201,7 +205,9 @@ export type FieldPath = {
|
|
|
201
205
|
$name: string;
|
|
202
206
|
};
|
|
203
207
|
|
|
204
|
-
/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys
|
|
208
|
+
/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys
|
|
209
|
+
* @deprecated - To be removed as an exported `@rjsf/utils` type in a future release
|
|
210
|
+
*/
|
|
205
211
|
export type PathSchema<T = any> =
|
|
206
212
|
T extends Array<infer U>
|
|
207
213
|
? FieldPath & {
|
|
@@ -447,6 +453,12 @@ export type GlobalUISchemaOptions = GenericObjectType & {
|
|
|
447
453
|
* only affects the DOM-level encoding.
|
|
448
454
|
*/
|
|
449
455
|
optionValueFormat?: OptionValueFormat;
|
|
456
|
+
/** Controls how a deprecated property is rendered.
|
|
457
|
+
* - `hide`: The field is completely hidden (via the `hidden` prop passed to FieldTemplate).
|
|
458
|
+
* - `disable`: The field is rendered but disabled.
|
|
459
|
+
* - `label` (default): The field is rendered with "(deprecated)" appended to its label.
|
|
460
|
+
*/
|
|
461
|
+
deprecatedHandling?: 'hide' | 'disable' | 'label';
|
|
450
462
|
};
|
|
451
463
|
|
|
452
464
|
/** The set of options from the `Form` that will be available on the `Registry` for use in everywhere the `registry` is
|
|
@@ -1328,7 +1340,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1328
1340
|
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
1329
1341
|
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
1330
1342
|
*/
|
|
1331
|
-
findFieldInSchema(schema: S, path:
|
|
1343
|
+
findFieldInSchema(schema: S, path: SchemaFieldPath, formData?: T): FoundFieldType<S>;
|
|
1332
1344
|
/** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
|
|
1333
1345
|
* matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
|
|
1334
1346
|
* `schema.discriminator.propertyName` or `fallbackField`.
|
|
@@ -1403,9 +1415,9 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1403
1415
|
* @param defaultValue - The value to return if a value is not found for the `pathList` path
|
|
1404
1416
|
* @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
|
|
1405
1417
|
*/
|
|
1406
|
-
getFromSchema(schema: S, path:
|
|
1407
|
-
getFromSchema(schema: S, path:
|
|
1408
|
-
getFromSchema(schema: S, path:
|
|
1418
|
+
getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T): T;
|
|
1419
|
+
getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: S): S;
|
|
1420
|
+
getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T | S): S | T;
|
|
1409
1421
|
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
1410
1422
|
*
|
|
1411
1423
|
* @param schema - The schema for which check for array of files flag is desired
|
|
@@ -1463,6 +1475,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1463
1475
|
* @param [name] - The base name for the schema
|
|
1464
1476
|
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
1465
1477
|
* @returns - The `PathSchema` object for the `schema`
|
|
1478
|
+
* @deprecated - To be removed as an exported `@rjsf/utils` function in a future release
|
|
1466
1479
|
*/
|
|
1467
1480
|
toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T>;
|
|
1468
1481
|
}
|
|
@@ -20,7 +20,7 @@ export interface UseFileWidgetPropsResult {
|
|
|
20
20
|
/** The list of FileInfoType contained within the FileWidget */
|
|
21
21
|
filesInfo: FileInfoType[];
|
|
22
22
|
/** The callback handler to pass to the onChange of the input */
|
|
23
|
-
handleChange: (files: FileList) => void
|
|
23
|
+
handleChange: (files: FileList) => void | Promise<void>;
|
|
24
24
|
/** The callback handler to pass in order to delete a file */
|
|
25
25
|
handleRemove: (index: number) => void;
|
|
26
26
|
}
|
|
@@ -129,15 +129,14 @@ export default function useFileWidgetProps(
|
|
|
129
129
|
);
|
|
130
130
|
|
|
131
131
|
const handleChange = useCallback(
|
|
132
|
-
(files: FileList) => {
|
|
133
|
-
processFiles(files)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
132
|
+
async (files: FileList) => {
|
|
133
|
+
const filesInfoEvent = await processFiles(files);
|
|
134
|
+
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL || null);
|
|
135
|
+
if (multiple) {
|
|
136
|
+
onChange(values.concat(...newValue));
|
|
137
|
+
} else {
|
|
138
|
+
onChange(newValue[0]);
|
|
139
|
+
}
|
|
141
140
|
},
|
|
142
141
|
[values, multiple, onChange],
|
|
143
142
|
);
|
package/src/withIdRefPrefix.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import isObject from 'lodash/isObject';
|
|
2
|
+
|
|
1
3
|
import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';
|
|
2
4
|
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
3
|
-
import isObject from 'lodash/isObject';
|
|
4
5
|
|
|
5
6
|
/** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
|
|
6
7
|
* `withIdRefPrefix` for any other elements.
|