@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.
Files changed (146) hide show
  1. package/dist/index.cjs +628 -441
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +624 -437
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +632 -445
  6. package/lib/ErrorSchemaBuilder.js.map +1 -1
  7. package/lib/canExpand.js.map +1 -1
  8. package/lib/constIsAjvDataReference.js +1 -1
  9. package/lib/constIsAjvDataReference.js.map +1 -1
  10. package/lib/createSchemaUtils.js +3 -3
  11. package/lib/createSchemaUtils.js.map +1 -1
  12. package/lib/enumOptionSelectedValue.js.map +1 -1
  13. package/lib/enumOptionValueDecoder.js.map +1 -1
  14. package/lib/enumOptionsDeselectValue.js +1 -1
  15. package/lib/enumOptionsDeselectValue.js.map +1 -1
  16. package/lib/enumOptionsIndexForValue.js.map +1 -1
  17. package/lib/enumOptionsIsSelected.js.map +1 -1
  18. package/lib/enumOptionsSelectValue.js +1 -1
  19. package/lib/enumOptionsSelectValue.js.map +1 -1
  20. package/lib/enumOptionsValueForIndex.js +2 -2
  21. package/lib/enumOptionsValueForIndex.js.map +1 -1
  22. package/lib/enums.d.ts +2 -0
  23. package/lib/enums.js +2 -0
  24. package/lib/enums.js.map +1 -1
  25. package/lib/findSchemaDefinition.js +4 -4
  26. package/lib/findSchemaDefinition.js.map +1 -1
  27. package/lib/getChangedFields.js +3 -3
  28. package/lib/getChangedFields.js.map +1 -1
  29. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  30. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  31. package/lib/getTestIds.d.ts +1 -1
  32. package/lib/getTestIds.js +4 -3
  33. package/lib/getTestIds.js.map +1 -1
  34. package/lib/getWidget.js +1 -1
  35. package/lib/getWidget.js.map +1 -1
  36. package/lib/idGenerators.js.map +1 -1
  37. package/lib/index.d.ts +6 -6
  38. package/lib/index.js +6 -6
  39. package/lib/index.js.map +1 -1
  40. package/lib/isFormDataAvailable.js +1 -1
  41. package/lib/isFormDataAvailable.js.map +1 -1
  42. package/lib/isRootSchema.js +1 -1
  43. package/lib/isRootSchema.js.map +1 -1
  44. package/lib/jsonSchemaAugmentation.d.ts +19 -0
  45. package/lib/jsonSchemaAugmentation.js +2 -0
  46. package/lib/jsonSchemaAugmentation.js.map +1 -0
  47. package/lib/mergeDefaultsWithFormData.js +2 -2
  48. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  49. package/lib/parser/ParserValidator.js +1 -1
  50. package/lib/parser/ParserValidator.js.map +1 -1
  51. package/lib/parser/index.d.ts +1 -1
  52. package/lib/parser/index.js.map +1 -1
  53. package/lib/parser/schemaParser.js +2 -2
  54. package/lib/parser/schemaParser.js.map +1 -1
  55. package/lib/removeOptionalEmptyObjects.d.ts +2 -0
  56. package/lib/removeOptionalEmptyObjects.js +8 -29
  57. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  58. package/lib/schema/findFieldInSchema.d.ts +2 -2
  59. package/lib/schema/findFieldInSchema.js +7 -6
  60. package/lib/schema/findFieldInSchema.js.map +1 -1
  61. package/lib/schema/findSelectedOptionInXxxOf.js +1 -1
  62. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  63. package/lib/schema/getClosestMatchingOption.js +3 -3
  64. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  65. package/lib/schema/getDefaultFormState.d.ts +4 -4
  66. package/lib/schema/getDefaultFormState.js +17 -22
  67. package/lib/schema/getDefaultFormState.js.map +1 -1
  68. package/lib/schema/getFromSchema.d.ts +3 -3
  69. package/lib/schema/getFromSchema.js +3 -3
  70. package/lib/schema/getFromSchema.js.map +1 -1
  71. package/lib/schema/index.d.ts +4 -4
  72. package/lib/schema/index.js +4 -4
  73. package/lib/schema/index.js.map +1 -1
  74. package/lib/schema/isMultiSelect.js.map +1 -1
  75. package/lib/schema/omitExtraData.d.ts +18 -8
  76. package/lib/schema/omitExtraData.js +352 -16
  77. package/lib/schema/omitExtraData.js.map +1 -1
  78. package/lib/schema/retrieveSchema.d.ts +15 -0
  79. package/lib/schema/retrieveSchema.js +36 -13
  80. package/lib/schema/retrieveSchema.js.map +1 -1
  81. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  82. package/lib/schema/shallowAllOfMerge.d.ts +11 -0
  83. package/lib/schema/shallowAllOfMerge.js +18 -0
  84. package/lib/schema/shallowAllOfMerge.js.map +1 -0
  85. package/lib/schema/toPathSchema.d.ts +1 -0
  86. package/lib/schema/toPathSchema.js +2 -1
  87. package/lib/schema/toPathSchema.js.map +1 -1
  88. package/lib/shouldRenderOptionalField.js +1 -1
  89. package/lib/shouldRenderOptionalField.js.map +1 -1
  90. package/lib/toErrorSchema.js.map +1 -1
  91. package/lib/tsconfig.tsbuildinfo +1 -1
  92. package/lib/types.d.ts +17 -5
  93. package/lib/types.js +1 -1
  94. package/lib/types.js.map +1 -1
  95. package/lib/useFileWidgetProps.d.ts +1 -1
  96. package/lib/useFileWidgetProps.js +9 -10
  97. package/lib/useFileWidgetProps.js.map +1 -1
  98. package/lib/withIdRefPrefix.js +1 -1
  99. package/lib/withIdRefPrefix.js.map +1 -1
  100. package/package.json +11 -11
  101. package/src/ErrorSchemaBuilder.ts +1 -1
  102. package/src/canExpand.ts +1 -1
  103. package/src/constIsAjvDataReference.ts +3 -2
  104. package/src/createSchemaUtils.ts +22 -20
  105. package/src/enumOptionSelectedValue.ts +1 -1
  106. package/src/enumOptionValueDecoder.ts +1 -1
  107. package/src/enumOptionsDeselectValue.ts +2 -2
  108. package/src/enumOptionsIndexForValue.ts +1 -1
  109. package/src/enumOptionsIsSelected.ts +1 -1
  110. package/src/enumOptionsSelectValue.ts +3 -2
  111. package/src/enumOptionsValueForIndex.ts +2 -2
  112. package/src/enums.ts +2 -0
  113. package/src/findSchemaDefinition.ts +4 -4
  114. package/src/getChangedFields.ts +4 -3
  115. package/src/getDiscriminatorFieldFromSchema.ts +1 -1
  116. package/src/getOptionMatchingSimpleDiscriminator.ts +1 -0
  117. package/src/getTestIds.ts +4 -3
  118. package/src/getWidget.tsx +2 -2
  119. package/src/idGenerators.ts +1 -1
  120. package/src/index.ts +6 -6
  121. package/src/isFormDataAvailable.ts +1 -1
  122. package/src/isRootSchema.ts +1 -1
  123. package/src/jsonSchemaAugmentation.ts +21 -0
  124. package/src/mergeDefaultsWithFormData.ts +4 -3
  125. package/src/parser/ParserValidator.ts +1 -1
  126. package/src/parser/index.ts +1 -1
  127. package/src/parser/schemaParser.ts +3 -3
  128. package/src/removeOptionalEmptyObjects.ts +8 -30
  129. package/src/schema/findFieldInSchema.ts +10 -8
  130. package/src/schema/findSelectedOptionInXxxOf.ts +1 -1
  131. package/src/schema/getClosestMatchingOption.ts +4 -4
  132. package/src/schema/getDefaultFormState.ts +18 -24
  133. package/src/schema/getFromSchema.ts +15 -8
  134. package/src/schema/index.ts +5 -3
  135. package/src/schema/isMultiSelect.ts +0 -1
  136. package/src/schema/omitExtraData.ts +398 -19
  137. package/src/schema/retrieveSchema.ts +41 -15
  138. package/src/schema/sanitizeDataForNewSchema.ts +1 -1
  139. package/src/schema/shallowAllOfMerge.ts +19 -0
  140. package/src/schema/toPathSchema.ts +2 -1
  141. package/src/shouldRenderOptionalField.ts +2 -2
  142. package/src/toErrorSchema.ts +1 -1
  143. package/src/tsconfig.json +0 -1
  144. package/src/types.ts +18 -5
  145. package/src/useFileWidgetProps.ts +9 -10
  146. package/src/withIdRefPrefix.ts +2 -1
package/lib/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ButtonHTMLAttributes, ChangeEvent, ComponentType, FocusEvent, HTMLAttributes, ReactElement, ReactNode, StyleHTMLAttributes } from 'react';
2
2
  import { JSONSchema7 } from 'json-schema';
3
3
  import { TranslatableString } from './enums.js';
4
+ import './jsonSchemaAugmentation.js';
4
5
  /** The representation of any generic object type, usually used as an intersection on other types to make them more
5
6
  * flexible in the properties they support (i.e. anything else)
6
7
  */
@@ -156,6 +157,8 @@ export type InputPropsType = {
156
157
  * `['baz', 1]` represents the second element in the list `baz` of the schema
157
158
  */
158
159
  export type FieldPathList = (string | number)[];
160
+ /** Dot string or segment list for `getFromSchema` / `findFieldInSchema` (same segment rules as {@link FieldPathList}). */
161
+ export type SchemaFieldPath = string | FieldPathList;
159
162
  /** Type describing an id and path used for a field */
160
163
  export type FieldPathId = {
161
164
  /** The id for a field */
@@ -170,7 +173,9 @@ export type FieldPath = {
170
173
  /** The name of a field */
171
174
  $name: string;
172
175
  };
173
- /** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
176
+ /** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys
177
+ * @deprecated - To be removed as an exported `@rjsf/utils` type in a future release
178
+ */
174
179
  export type PathSchema<T = any> = T extends Array<infer U> ? FieldPath & {
175
180
  [i: number]: PathSchema<U>;
176
181
  } : T extends GenericObjectType ? FieldPath & {
@@ -383,6 +388,12 @@ export type GlobalUISchemaOptions = GenericObjectType & {
383
388
  * only affects the DOM-level encoding.
384
389
  */
385
390
  optionValueFormat?: OptionValueFormat;
391
+ /** Controls how a deprecated property is rendered.
392
+ * - `hide`: The field is completely hidden (via the `hidden` prop passed to FieldTemplate).
393
+ * - `disable`: The field is rendered but disabled.
394
+ * - `label` (default): The field is rendered with "(deprecated)" appended to its label.
395
+ */
396
+ deprecatedHandling?: 'hide' | 'disable' | 'label';
386
397
  };
387
398
  /** The set of options from the `Form` that will be available on the `Registry` for use in everywhere the `registry` is
388
399
  * available.
@@ -1073,7 +1084,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
1073
1084
  * @returns - An object that contains the field and its required state. If no field can be found then
1074
1085
  * `{ field: undefined, isRequired: undefined }` is returned.
1075
1086
  */
1076
- findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
1087
+ findFieldInSchema(schema: S, path: SchemaFieldPath, formData?: T): FoundFieldType<S>;
1077
1088
  /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
1078
1089
  * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
1079
1090
  * `schema.discriminator.propertyName` or `fallbackField`.
@@ -1138,9 +1149,9 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
1138
1149
  * @param defaultValue - The value to return if a value is not found for the `pathList` path
1139
1150
  * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
1140
1151
  */
1141
- getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
1142
- getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
1143
- getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
1152
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T): T;
1153
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: S): S;
1154
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T | S): S | T;
1144
1155
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1145
1156
  *
1146
1157
  * @param schema - The schema for which check for array of files flag is desired
@@ -1198,6 +1209,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
1198
1209
  * @param [name] - The base name for the schema
1199
1210
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1200
1211
  * @returns - The `PathSchema` object for the `schema`
1212
+ * @deprecated - To be removed as an exported `@rjsf/utils` function in a future release
1201
1213
  */
1202
1214
  toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T>;
1203
1215
  }
package/lib/types.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ import './jsonSchemaAugmentation.js';
2
2
  //# sourceMappingURL=types.js.map
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAaA,OAAO,0BAA0B,CAAC"}
@@ -13,7 +13,7 @@ export interface UseFileWidgetPropsResult {
13
13
  /** The list of FileInfoType contained within the FileWidget */
14
14
  filesInfo: FileInfoType[];
15
15
  /** The callback handler to pass to the onChange of the input */
16
- handleChange: (files: FileList) => void;
16
+ handleChange: (files: FileList) => void | Promise<void>;
17
17
  /** The callback handler to pass in order to delete a file */
18
18
  handleRemove: (index: number) => void;
19
19
  }
@@ -95,16 +95,15 @@ export default function useFileWidgetProps(value, onChange, multiple = false) {
95
95
  return [];
96
96
  }, [value, multiple]);
97
97
  const filesInfo = useMemo(() => (Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value || ''])), [value]);
98
- const handleChange = useCallback((files) => {
99
- processFiles(files).then((filesInfoEvent) => {
100
- const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL || null);
101
- if (multiple) {
102
- onChange(values.concat(...newValue));
103
- }
104
- else {
105
- onChange(newValue[0]);
106
- }
107
- });
98
+ const handleChange = useCallback(async (files) => {
99
+ const filesInfoEvent = await processFiles(files);
100
+ const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL || null);
101
+ if (multiple) {
102
+ onChange(values.concat(...newValue));
103
+ }
104
+ else {
105
+ onChange(newValue[0]);
106
+ }
108
107
  }, [values, multiple, onChange]);
109
108
  const handleRemove = useCallback((index) => {
110
109
  if (multiple) {
@@ -1 +1 @@
1
- {"version":3,"file":"useFileWidgetProps.js","sourceRoot":"","sources":["../src/useFileWidgetProps.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAuB5C;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe,EAAE,IAAY;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,C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ACb,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAC7B,CAAC;IACF,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,KAAa,EAAE,EAAE;QAChB,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;YAC9D,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAC7B,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACnD,CAAC"}
@@ -1,5 +1,5 @@
1
- import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.js';
2
1
  import isObject from 'lodash-es/isObject.js';
2
+ import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.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,CAA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@rjsf/utils",
3
- "version": "6.5.2",
3
+ "version": "6.6.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -49,16 +49,17 @@
49
49
  "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
50
50
  "build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
51
51
  "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
52
- "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"",
53
- "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
54
- "lint": "eslint src test",
52
+ "cs-check": "oxfmt --check \"{src,test}/**/*.{ts,tsx}\"",
53
+ "cs-format": "oxfmt \"{src,test}/**/*.{ts,tsx}\"",
54
+ "lint": "oxlint src test",
55
55
  "precommit": "lint-staged",
56
- "test": "jest",
57
- "test:debug": "node --inspect-brk ../../node_modules/.bin/jest"
56
+ "test": "vitest run",
57
+ "test:debug": "node --inspect-brk ../../node_modules/.bin/vitest --pool=forks"
58
58
  },
59
59
  "lint-staged": {
60
- "{src,test}/**/*.ts?(x)": [
61
- "eslint --fix"
60
+ "{src,test}/**/*.{ts,tsx}": [
61
+ "oxlint --fix",
62
+ "oxfmt"
62
63
  ]
63
64
  },
64
65
  "peerDependencies": {
@@ -67,7 +68,7 @@
67
68
  "dependencies": {
68
69
  "@x0k/json-schema-merge": "^1.0.3",
69
70
  "fast-equals": "^6.0.0",
70
- "fast-uri": "^3.1.0",
71
+ "fast-uri": "^3.1.2",
71
72
  "jsonpointer": "^5.0.1",
72
73
  "lodash": "^4.18.1",
73
74
  "lodash-es": "^4.18.1",
@@ -76,8 +77,7 @@
76
77
  "devDependencies": {
77
78
  "@types/json-schema": "^7.0.15",
78
79
  "@types/react-is": "^18.3.1",
79
- "deep-freeze-es6": "^4.0.1",
80
- "eslint": "^8.57.1"
80
+ "deep-freeze-es6": "^4.0.1"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public"
@@ -3,8 +3,8 @@ import get from 'lodash/get';
3
3
  import set from 'lodash/set';
4
4
  import setWith from 'lodash/setWith';
5
5
 
6
- import { ErrorSchema, FieldPathList } from './types';
7
6
  import { ERRORS_KEY } from './constants';
7
+ import { ErrorSchema, FieldPathList } from './types';
8
8
 
9
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
10
  * numbers represent array indexes/
package/src/canExpand.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
2
1
  import getUiOptions from './getUiOptions';
2
+ import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
3
3
 
4
4
  /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
5
5
  * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
@@ -1,8 +1,9 @@
1
- import { CONST_KEY, getSchemaType, isObject } from './';
2
- import { RJSFSchema, StrictRJSFSchema } from './types';
3
1
  import { JSONSchema7Type } from 'json-schema';
4
2
  import isString from 'lodash/isString';
5
3
 
4
+ import { CONST_KEY, getSchemaType, isObject } from './';
5
+ import { RJSFSchema, StrictRJSFSchema } from './types';
6
+
6
7
  /**
7
8
  * Checks if the schema const property value is an AJV $data reference
8
9
  * and the current schema is not an object or array
@@ -1,17 +1,8 @@
1
+ import get from 'lodash/get';
2
+
3
+ import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants';
1
4
  import deepEquals from './deepEquals';
2
- import {
3
- Experimental_CustomMergeAllOf,
4
- Experimental_DefaultFormStateBehavior,
5
- FormContextType,
6
- FoundFieldType,
7
- GlobalUISchemaOptions,
8
- PathSchema,
9
- RJSFSchema,
10
- SchemaUtilsType,
11
- StrictRJSFSchema,
12
- UiSchema,
13
- ValidatorType,
14
- } from './types';
5
+ import { makeAllReferencesAbsolute } from './findSchemaDefinition';
15
6
  import {
16
7
  findFieldInSchema,
17
8
  findSelectedOptionInXxxOf,
@@ -28,9 +19,20 @@ import {
28
19
  sanitizeDataForNewSchema,
29
20
  toPathSchema,
30
21
  } from './schema';
31
- import { makeAllReferencesAbsolute } from './findSchemaDefinition';
32
- import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants';
33
- import get from 'lodash/get';
22
+ import {
23
+ Experimental_CustomMergeAllOf,
24
+ Experimental_DefaultFormStateBehavior,
25
+ FormContextType,
26
+ FoundFieldType,
27
+ GlobalUISchemaOptions,
28
+ PathSchema,
29
+ RJSFSchema,
30
+ SchemaFieldPath,
31
+ SchemaUtilsType,
32
+ StrictRJSFSchema,
33
+ UiSchema,
34
+ ValidatorType,
35
+ } from './types';
34
36
 
35
37
  /** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
36
38
  * that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
@@ -127,7 +129,7 @@ class SchemaUtils<
127
129
  * @returns - An object that contains the field and its required state. If no field can be found then
128
130
  * `{ field: undefined, isRequired: undefined }` is returned.
129
131
  */
130
- findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S> {
132
+ findFieldInSchema(schema: S, path: SchemaFieldPath, formData?: T): FoundFieldType<S> {
131
133
  return findFieldInSchema(
132
134
  this.validator,
133
135
  this.rootSchema,
@@ -259,9 +261,9 @@ class SchemaUtils<
259
261
  * @param defaultValue - The value to return if a value is not found for the `pathList` path
260
262
  * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
261
263
  */
262
- getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
263
- getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
264
- getFromSchema(schema: S, path: string | string[], defaultValue: T | S): T | S {
264
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T): T;
265
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: S): S;
266
+ getFromSchema(schema: S, path: SchemaFieldPath, defaultValue: T | S): T | S {
265
267
  return getFromSchema<T, S, F>(
266
268
  this.validator,
267
269
  this.rootSchema,
@@ -1,5 +1,5 @@
1
- import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
2
1
  import enumOptionsIndexForValue from './enumOptionsIndexForValue';
2
+ import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
3
3
 
4
4
  /** Computes the value to pass to a select element's `value` attribute.
5
5
  *
@@ -1,5 +1,5 @@
1
- import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
2
1
  import enumOptionsValueForIndex from './enumOptionsValueForIndex';
2
+ import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
3
3
 
4
4
  /** Resolves a single DOM value string back to its typed enum value in `'realValue'` mode.
5
5
  *
@@ -1,6 +1,6 @@
1
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
- import enumOptionsValueForIndex from './enumOptionsValueForIndex';
3
1
  import deepEquals from './deepEquals';
2
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
3
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
4
4
 
5
5
  /** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
6
6
  * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
@@ -1,5 +1,5 @@
1
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
1
  import enumOptionsIsSelected from './enumOptionsIsSelected';
2
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
5
5
  * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
@@ -1,5 +1,5 @@
1
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
1
  import deepEquals from './deepEquals';
2
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Determines whether the given `value` is (one of) the `selected` value(s).
5
5
  *
@@ -1,7 +1,8 @@
1
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
- import enumOptionsValueForIndex from './enumOptionsValueForIndex';
3
1
  import isNil from 'lodash/isNil';
4
2
 
3
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
4
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
5
+
5
6
  /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
6
7
  * `allEnumOptions`
7
8
  *
@@ -20,8 +20,8 @@ export default function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJ
20
20
  return (
21
21
  valueIndex
22
22
  .map((index) => enumOptionsValueForIndex(index, allEnumOptions))
23
- // Since the recursive call returns `emptyValue` when we get a bad option, only filter those out
24
- .filter((val) => val !== emptyValue)
23
+ // The recursive call returns undefined for a bad option, filter those out
24
+ .filter((val) => val !== undefined)
25
25
  );
26
26
  }
27
27
  // So Number(null) and Number('') both return 0, so use emptyValue for those two values
package/src/enums.ts CHANGED
@@ -68,6 +68,8 @@ export enum TranslatableString {
68
68
  TitleOptionPrefix = '%1 option %2',
69
69
  /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
70
70
  KeyLabel = '%1 Key',
71
+ /** Deprecated label, where %1 will be replaced by the label as provided by SchemaField */
72
+ DeprecatedLabel = '%1 (deprecated)',
71
73
  // Strings with replaceable parameters AND/OR that support markdown and html
72
74
  /** Invalid object field configuration as provided by the ObjectField.
73
75
  * NOTE: Use markdown notation rather than html tags.
@@ -1,4 +1,8 @@
1
+ import UriResolver from 'fast-uri';
1
2
  import jsonpointer from 'jsonpointer';
3
+ import get from 'lodash/get';
4
+ import isEmpty from 'lodash/isEmpty';
5
+ import isObject from 'lodash/isObject';
2
6
  import omit from 'lodash/omit';
3
7
 
4
8
  import {
@@ -10,10 +14,6 @@ import {
10
14
  SCHEMA_KEY,
11
15
  } from './constants';
12
16
  import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';
13
- import isObject from 'lodash/isObject';
14
- import isEmpty from 'lodash/isEmpty';
15
- import UriResolver from 'fast-uri';
16
- import get from 'lodash/get';
17
17
 
18
18
  /** Looks for the `$id` pointed by `ref` in the schema definitions embedded in
19
19
  * a JSON Schema bundle
@@ -1,8 +1,9 @@
1
+ import difference from 'lodash/difference';
2
+ import get from 'lodash/get';
3
+ import isPlainObject from 'lodash/isPlainObject';
1
4
  import keys from 'lodash/keys';
2
5
  import pickBy from 'lodash/pickBy';
3
- import isPlainObject from 'lodash/isPlainObject';
4
- import get from 'lodash/get';
5
- import difference from 'lodash/difference';
6
+
6
7
  import deepEquals from './deepEquals';
7
8
 
8
9
  /**
@@ -1,8 +1,8 @@
1
1
  import get from 'lodash/get';
2
2
  import isString from 'lodash/isString';
3
3
 
4
- import { RJSFSchema, StrictRJSFSchema } from './types';
5
4
  import { DISCRIMINATOR_PATH } from './constants';
5
+ import { RJSFSchema, StrictRJSFSchema } from './types';
6
6
 
7
7
  /** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
8
8
  * it is not a string. Returns `undefined` when a valid discriminator is not present.
@@ -1,4 +1,5 @@
1
1
  import get from 'lodash/get';
2
+
2
3
  import { PROPERTIES_KEY } from './constants';
3
4
  import { RJSFSchema, StrictRJSFSchema } from './types';
4
5
 
package/src/getTestIds.ts CHANGED
@@ -4,7 +4,7 @@ import uniqueId from 'lodash/uniqueId';
4
4
  import { TestIdShape } from './types';
5
5
 
6
6
  /** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
7
- * (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
7
+ * (`NODE_ENV === 'test'`, this is set by vitest) then a Proxy object will be returned. If a key within the returned
8
8
  * object is accessed, if the value already exists the object will return that value, otherwise it will create that key
9
9
  * with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the
10
10
  * function will return an empty object, therefore returning `undefined` for any property within the object and
@@ -20,8 +20,9 @@ import { TestIdShape } from './types';
20
20
  */
21
21
  export default function getTestIds(): TestIdShape {
22
22
  // For some reason, even though process.env contains the value of `test` for NODE_ENV, accessing it directly returns
23
- // 'development'. Using `get()` does, in fact, return test so sticking with it
24
- if (typeof process === 'undefined' || get(process, 'env.NODE_ENV') !== 'test') {
23
+ // 'development'. Using `get()` does, in fact, return test so sticking with it.
24
+ // Use globalThis to access process without requiring @types/node (TS6 compatibility).
25
+ if (get(globalThis, 'process.env.NODE_ENV') !== 'test') {
25
26
  return {};
26
27
  }
27
28
 
package/src/getWidget.tsx CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createElement } from 'react';
2
- import ReactIs from 'react-is';
3
2
  import get from 'lodash/get';
4
3
  import set from 'lodash/set';
4
+ import ReactIs from 'react-is';
5
5
 
6
- import { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types';
7
6
  import getSchemaType from './getSchemaType';
7
+ import { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types';
8
8
 
9
9
  /** The map of schema types to widget type to widget name
10
10
  */
@@ -1,7 +1,7 @@
1
1
  import isString from 'lodash/isString';
2
2
 
3
- import { FieldPathId } from './types';
4
3
  import { ID_KEY } from './constants';
4
+ import { FieldPathId } from './types';
5
5
 
6
6
  /** Generates a consistent `id` pattern for a given `id` and a `suffix`
7
7
  *
package/src/index.ts CHANGED
@@ -6,16 +6,15 @@ import createSchemaUtils from './createSchemaUtils';
6
6
  import dataURItoBlob from './dataURItoBlob';
7
7
  import dateRangeOptions from './dateRangeOptions';
8
8
  import deepEquals from './deepEquals';
9
- import shallowEquals from './shallowEquals';
10
9
  import englishStringTranslator from './englishStringTranslator';
11
- import enumOptionSelectedValue from './enumOptionSelectedValue';
12
- import enumOptionValueDecoder from './enumOptionValueDecoder';
13
- import enumOptionValueEncoder from './enumOptionValueEncoder';
14
10
  import enumOptionsDeselectValue from './enumOptionsDeselectValue';
11
+ import enumOptionSelectedValue from './enumOptionSelectedValue';
15
12
  import enumOptionsIndexForValue from './enumOptionsIndexForValue';
16
13
  import enumOptionsIsSelected from './enumOptionsIsSelected';
17
14
  import enumOptionsSelectValue from './enumOptionsSelectValue';
18
15
  import enumOptionsValueForIndex from './enumOptionsValueForIndex';
16
+ import enumOptionValueDecoder from './enumOptionValueDecoder';
17
+ import enumOptionValueEncoder from './enumOptionValueEncoder';
19
18
  import ErrorSchemaBuilder from './ErrorSchemaBuilder';
20
19
  import findSchemaDefinition from './findSchemaDefinition';
21
20
  import getChangedFields from './getChangedFields';
@@ -56,15 +55,17 @@ import lookupFromFormContext from './lookupFromFormContext';
56
55
  import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
57
56
  import mergeObjects from './mergeObjects';
58
57
  import mergeSchemas from './mergeSchemas';
58
+ import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators';
59
59
  import optionsList from './optionsList';
60
- import removeOptionalEmptyObjects from './removeOptionalEmptyObjects';
61
60
  import orderProperties from './orderProperties';
62
61
  import pad from './pad';
63
62
  import parseDateString from './parseDateString';
64
63
  import rangeSpec from './rangeSpec';
64
+ import removeOptionalEmptyObjects from './removeOptionalEmptyObjects';
65
65
  import replaceStringParameters from './replaceStringParameters';
66
66
  import resolveUiSchema from './resolveUiSchema';
67
67
  import schemaRequiresTrueValue from './schemaRequiresTrueValue';
68
+ import shallowEquals from './shallowEquals';
68
69
  import shouldRender, { ComponentUpdateStrategy } from './shouldRender';
69
70
  import shouldRenderOptionalField from './shouldRenderOptionalField';
70
71
  import toConstant from './toConstant';
@@ -79,7 +80,6 @@ import useFileWidgetProps, { FileInfoType, UseFileWidgetPropsResult } from './us
79
80
  import utcToLocal from './utcToLocal';
80
81
  import validationDataMerge from './validationDataMerge';
81
82
  import withIdRefPrefix from './withIdRefPrefix';
82
- import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators';
83
83
 
84
84
  export * from './types';
85
85
  export * from './enums';
@@ -1,5 +1,5 @@
1
- import isNil from 'lodash/isNil';
2
1
  import isEmpty from 'lodash/isEmpty';
2
+ import isNil from 'lodash/isNil';
3
3
  import isObject from 'lodash/isObject';
4
4
 
5
5
  /** Determines whether the given `formData` represents valid form data, such as a primitive type, an array, or a
@@ -1,8 +1,8 @@
1
1
  import omit from 'lodash/omit';
2
2
 
3
+ import { REF_KEY, RJSF_REF_KEY } from './constants';
3
4
  import deepEquals from './deepEquals';
4
5
  import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from './types';
5
- import { REF_KEY, RJSF_REF_KEY } from './constants';
6
6
 
7
7
  /** Helper to check whether a JSON schema object is the root schema. The schema is a root schema with root `properties`
8
8
  * key or a root `$ref` key. If the `schemaToCompare` has a root `oneOf` property, the function will
@@ -0,0 +1,21 @@
1
+ import type { JSONSchema7 } from 'json-schema';
2
+
3
+ /**
4
+ * This file is used to augment the `json-schema` module with the `deprecated` keyword.
5
+ *
6
+ * It is a dedicated file because `json-schema` is a type-only package. Standard augmentation
7
+ * using `import 'json-schema'` in a file with other imports can cause module resolution
8
+ * errors in certain environments (like Jest). Using `import type` in this dedicated file
9
+ * ensures the augmentation is correctly applied by the TypeScript compiler without
10
+ * confusing runtime module resolvers.
11
+ */
12
+ declare module 'json-schema' {
13
+ export interface JSONSchema7 {
14
+ /** The deprecated keyword is a boolean that indicates that the instance value the keyword applies to should not be
15
+ * used and may be removed in the future.
16
+ */
17
+ deprecated?: boolean;
18
+ }
19
+ }
20
+
21
+ export type { JSONSchema7 };
@@ -1,8 +1,8 @@
1
1
  import get from 'lodash/get';
2
+ import isNil from 'lodash/isNil';
2
3
 
3
- import isObject from './isObject';
4
4
  import { GenericObjectType } from '../src';
5
- import isNil from 'lodash/isNil';
5
+ import isObject from './isObject';
6
6
 
7
7
  /** Merges the `defaults` object of type `T` into the `formData` of type `T`
8
8
  *
@@ -68,7 +68,8 @@ export default function mergeDefaultsWithFormData<T = any>(
68
68
  const keyExistsInDefaults = isObject(defaults) && key in (defaults as GenericObjectType);
69
69
  const keyExistsInFormData = key in (formData as GenericObjectType);
70
70
  const keyDefault = get(defaults, key) ?? {};
71
- const defaultValueIsNestedObject = keyExistsInDefaults && Object.entries(keyDefault).some(([, v]) => isObject(v));
71
+ const defaultValueIsNestedObject =
72
+ keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
72
73
 
73
74
  const keyDefaultIsObject = keyExistsInDefaults && isObject(get(defaults, key));
74
75
  const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
@@ -1,6 +1,7 @@
1
1
  import get from 'lodash/get';
2
2
 
3
3
  import { ID_KEY } from '../constants';
4
+ import deepEquals from '../deepEquals';
4
5
  import hashForSchema from '../hashForSchema';
5
6
  import {
6
7
  CustomValidator,
@@ -14,7 +15,6 @@ import {
14
15
  ValidationData,
15
16
  ValidatorType,
16
17
  } from '../types';
17
- import deepEquals from '../deepEquals';
18
18
 
19
19
  /** The type of the map of schema hash to schema
20
20
  */
@@ -1,5 +1,5 @@
1
- import schemaParser from './schemaParser';
2
1
  import { SchemaMap } from './ParserValidator';
2
+ import schemaParser from './schemaParser';
3
3
 
4
4
  export type { SchemaMap };
5
5
 
@@ -1,10 +1,10 @@
1
1
  import forEach from 'lodash/forEach';
2
2
 
3
- import { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types';
4
3
  import { ITEMS_KEY, PROPERTIES_KEY } from '../constants';
5
- import ParserValidator, { SchemaMap } from './ParserValidator';
6
- import { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema';
7
4
  import deepEquals from '../deepEquals';
5
+ import { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema';
6
+ import { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types';
7
+ import ParserValidator, { SchemaMap } from './ParserValidator';
8
8
 
9
9
  /** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to
10
10
  * capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the