@rjsf/utils 6.5.3 → 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 (134) hide show
  1. package/dist/index.cjs +618 -433
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +614 -429
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +623 -438
  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/findSchemaDefinition.js +4 -4
  23. package/lib/findSchemaDefinition.js.map +1 -1
  24. package/lib/getChangedFields.js +3 -3
  25. package/lib/getChangedFields.js.map +1 -1
  26. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  27. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  28. package/lib/getTestIds.d.ts +1 -1
  29. package/lib/getTestIds.js +4 -3
  30. package/lib/getTestIds.js.map +1 -1
  31. package/lib/getWidget.js +1 -1
  32. package/lib/getWidget.js.map +1 -1
  33. package/lib/idGenerators.js.map +1 -1
  34. package/lib/index.d.ts +6 -6
  35. package/lib/index.js +6 -6
  36. package/lib/index.js.map +1 -1
  37. package/lib/isFormDataAvailable.js +1 -1
  38. package/lib/isFormDataAvailable.js.map +1 -1
  39. package/lib/isRootSchema.js +1 -1
  40. package/lib/isRootSchema.js.map +1 -1
  41. package/lib/mergeDefaultsWithFormData.js +1 -1
  42. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  43. package/lib/parser/ParserValidator.js +1 -1
  44. package/lib/parser/ParserValidator.js.map +1 -1
  45. package/lib/parser/index.d.ts +1 -1
  46. package/lib/parser/index.js.map +1 -1
  47. package/lib/parser/schemaParser.js +2 -2
  48. package/lib/parser/schemaParser.js.map +1 -1
  49. package/lib/removeOptionalEmptyObjects.d.ts +2 -0
  50. package/lib/removeOptionalEmptyObjects.js +8 -29
  51. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  52. package/lib/schema/findFieldInSchema.js +1 -1
  53. package/lib/schema/findFieldInSchema.js.map +1 -1
  54. package/lib/schema/findSelectedOptionInXxxOf.js +1 -1
  55. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  56. package/lib/schema/getClosestMatchingOption.js +3 -3
  57. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  58. package/lib/schema/getDefaultFormState.d.ts +4 -4
  59. package/lib/schema/getDefaultFormState.js +17 -22
  60. package/lib/schema/getDefaultFormState.js.map +1 -1
  61. package/lib/schema/getFromSchema.js +1 -1
  62. package/lib/schema/getFromSchema.js.map +1 -1
  63. package/lib/schema/index.d.ts +4 -4
  64. package/lib/schema/index.js +4 -4
  65. package/lib/schema/index.js.map +1 -1
  66. package/lib/schema/isMultiSelect.js.map +1 -1
  67. package/lib/schema/omitExtraData.d.ts +18 -8
  68. package/lib/schema/omitExtraData.js +352 -16
  69. package/lib/schema/omitExtraData.js.map +1 -1
  70. package/lib/schema/retrieveSchema.d.ts +15 -0
  71. package/lib/schema/retrieveSchema.js +36 -13
  72. package/lib/schema/retrieveSchema.js.map +1 -1
  73. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  74. package/lib/schema/shallowAllOfMerge.d.ts +11 -0
  75. package/lib/schema/shallowAllOfMerge.js +18 -0
  76. package/lib/schema/shallowAllOfMerge.js.map +1 -0
  77. package/lib/schema/toPathSchema.d.ts +1 -0
  78. package/lib/schema/toPathSchema.js +2 -1
  79. package/lib/schema/toPathSchema.js.map +1 -1
  80. package/lib/shouldRenderOptionalField.js +1 -1
  81. package/lib/shouldRenderOptionalField.js.map +1 -1
  82. package/lib/toErrorSchema.js.map +1 -1
  83. package/lib/tsconfig.tsbuildinfo +1 -1
  84. package/lib/types.d.ts +4 -1
  85. package/lib/useFileWidgetProps.d.ts +1 -1
  86. package/lib/useFileWidgetProps.js +9 -10
  87. package/lib/useFileWidgetProps.js.map +1 -1
  88. package/lib/withIdRefPrefix.js +1 -1
  89. package/lib/withIdRefPrefix.js.map +1 -1
  90. package/package.json +10 -10
  91. package/src/ErrorSchemaBuilder.ts +1 -1
  92. package/src/canExpand.ts +1 -1
  93. package/src/constIsAjvDataReference.ts +3 -2
  94. package/src/createSchemaUtils.ts +18 -17
  95. package/src/enumOptionSelectedValue.ts +1 -1
  96. package/src/enumOptionValueDecoder.ts +1 -1
  97. package/src/enumOptionsDeselectValue.ts +2 -2
  98. package/src/enumOptionsIndexForValue.ts +1 -1
  99. package/src/enumOptionsIsSelected.ts +1 -1
  100. package/src/enumOptionsSelectValue.ts +3 -2
  101. package/src/enumOptionsValueForIndex.ts +2 -2
  102. package/src/findSchemaDefinition.ts +4 -4
  103. package/src/getChangedFields.ts +4 -3
  104. package/src/getDiscriminatorFieldFromSchema.ts +1 -1
  105. package/src/getOptionMatchingSimpleDiscriminator.ts +1 -0
  106. package/src/getTestIds.ts +4 -3
  107. package/src/getWidget.tsx +2 -2
  108. package/src/idGenerators.ts +1 -1
  109. package/src/index.ts +6 -6
  110. package/src/isFormDataAvailable.ts +1 -1
  111. package/src/isRootSchema.ts +1 -1
  112. package/src/mergeDefaultsWithFormData.ts +2 -2
  113. package/src/parser/ParserValidator.ts +1 -1
  114. package/src/parser/index.ts +1 -1
  115. package/src/parser/schemaParser.ts +3 -3
  116. package/src/removeOptionalEmptyObjects.ts +8 -30
  117. package/src/schema/findFieldInSchema.ts +2 -2
  118. package/src/schema/findSelectedOptionInXxxOf.ts +1 -1
  119. package/src/schema/getClosestMatchingOption.ts +4 -4
  120. package/src/schema/getDefaultFormState.ts +18 -24
  121. package/src/schema/getFromSchema.ts +2 -2
  122. package/src/schema/index.ts +5 -3
  123. package/src/schema/isMultiSelect.ts +0 -1
  124. package/src/schema/omitExtraData.ts +398 -19
  125. package/src/schema/retrieveSchema.ts +41 -15
  126. package/src/schema/sanitizeDataForNewSchema.ts +1 -1
  127. package/src/schema/shallowAllOfMerge.ts +19 -0
  128. package/src/schema/toPathSchema.ts +2 -1
  129. package/src/shouldRenderOptionalField.ts +2 -2
  130. package/src/toErrorSchema.ts +1 -1
  131. package/src/tsconfig.json +0 -1
  132. package/src/types.ts +4 -1
  133. package/src/useFileWidgetProps.ts +9 -10
  134. package/src/withIdRefPrefix.ts +2 -1
package/lib/types.d.ts CHANGED
@@ -173,7 +173,9 @@ export type FieldPath = {
173
173
  /** The name of a field */
174
174
  $name: string;
175
175
  };
176
- /** 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
+ */
177
179
  export type PathSchema<T = any> = T extends Array<infer U> ? FieldPath & {
178
180
  [i: number]: PathSchema<U>;
179
181
  } : T extends GenericObjectType ? FieldPath & {
@@ -1207,6 +1209,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
1207
1209
  * @param [name] - The base name for the schema
1208
1210
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1209
1211
  * @returns - The `PathSchema` object for the `schema`
1212
+ * @deprecated - To be removed as an exported `@rjsf/utils` function in a future release
1210
1213
  */
1211
1214
  toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T>;
1212
1215
  }
@@ -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,CAAC;AAChF,CAAC;AAED;;;;GAIG;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AM,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,CAAC;QACvB,MAAM,OAAO,GAAyB,IAA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+ "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": {
@@ -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,18 +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
- SchemaFieldPath,
11
- SchemaUtilsType,
12
- StrictRJSFSchema,
13
- UiSchema,
14
- ValidatorType,
15
- } from './types';
5
+ import { makeAllReferencesAbsolute } from './findSchemaDefinition';
16
6
  import {
17
7
  findFieldInSchema,
18
8
  findSelectedOptionInXxxOf,
@@ -29,9 +19,20 @@ import {
29
19
  sanitizeDataForNewSchema,
30
20
  toPathSchema,
31
21
  } from './schema';
32
- import { makeAllReferencesAbsolute } from './findSchemaDefinition';
33
- import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants';
34
- 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';
35
36
 
36
37
  /** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
37
38
  * that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
@@ -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
@@ -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
@@ -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
  *
@@ -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
@@ -1,31 +1,6 @@
1
- import isNil from 'lodash/isNil';
2
-
3
1
  import isObject from './isObject';
2
+ import { isValueEmpty, retrieveSchema } from './schema';
4
3
  import { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, ValidatorType } from './types';
5
- import retrieveSchema from './schema/retrieveSchema';
6
-
7
- /** Determines whether a value is considered "empty" for the purposes of optional object pruning.
8
- * A value is empty if it is `undefined`, `null`, an empty string, or an object where all own
9
- * properties are themselves empty.
10
- *
11
- * @param value - The value to check
12
- * @returns True if the value is considered empty
13
- */
14
- function isValueEmpty(value: unknown): boolean {
15
- if (isNil(value) || value === '') {
16
- return true;
17
- }
18
- if (Array.isArray(value)) {
19
- // An empty array is considered empty; a non-empty array is not
20
- return value.length === 0;
21
- }
22
- if (isObject(value)) {
23
- const obj = value as GenericObjectType;
24
- const keys = Object.keys(obj);
25
- return keys.every((key) => isValueEmpty(obj[key]));
26
- }
27
- return false;
28
- }
29
4
 
30
5
  /** Recursively removes optional objects from the `formData` that are empty (i.e., all their fields
31
6
  * are undefined, null, empty strings, or themselves empty optional objects). This solves the problem
@@ -41,7 +16,10 @@ function isValueEmpty(value: unknown): boolean {
41
16
  * @param [formData] - The current form data to prune
42
17
  * @returns - A new copy of `formData` with empty optional objects removed, or `undefined` if the
43
18
  * entire formData was pruned
19
+ * @deprecated - This function will be removed in a future release. The equivalent pruning behavior
20
+ * is now built into `omitExtraData` — use that instead.
44
21
  */
22
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
45
23
  export default function removeOptionalEmptyObjects<
46
24
  T = any,
47
25
  S extends StrictRJSFSchema = RJSFSchema,
@@ -65,6 +43,7 @@ export default function removeOptionalEmptyObjects<
65
43
  if (Array.isArray(itemsSchema)) {
66
44
  itemSchema = itemsSchema[index] || (resolvedSchema.additionalItems as S) || ({} as S);
67
45
  }
46
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
68
47
  const cleaned = removeOptionalEmptyObjects<T, S, F>(validator, itemSchema, rootSchema, item);
69
48
  if (cleaned !== item) {
70
49
  hasChanges = true;
@@ -97,6 +76,7 @@ export default function removeOptionalEmptyObjects<
97
76
 
98
77
  if ((isObj || isArr) && properties[key]) {
99
78
  // Recursively process nested objects and arrays
79
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
100
80
  const cleaned = removeOptionalEmptyObjects<T, S, F>(validator, propertySchema, rootSchema, value as T);
101
81
 
102
82
  if (!isRequired && isValueEmpty(cleaned)) {
@@ -106,10 +86,8 @@ export default function removeOptionalEmptyObjects<
106
86
 
107
87
  result[key] = cleaned;
108
88
  hasAnyValue = true;
109
- } else if (!isRequired && isValueEmpty(value) && properties[key]) {
110
- // Optional scalar property that is empty omit it
111
- continue;
112
- } else {
89
+ } else if (isRequired || !isValueEmpty(value) || !properties[key]) {
90
+ // Keep: required, non-empty, or not schema-defined; skip optional empty scalars silently
113
91
  result[key] = value;
114
92
  if (!isValueEmpty(value)) {
115
93
  hasAnyValue = true;
@@ -1,8 +1,6 @@
1
1
  import get from 'lodash/get';
2
2
  import has from 'lodash/has';
3
3
 
4
- import findSelectedOptionInXxxOf from './findSelectedOptionInXxxOf';
5
- import getFromSchema from './getFromSchema';
6
4
  import { ANY_OF_KEY, ONE_OF_KEY, PROPERTIES_KEY, REQUIRED_KEY } from '../constants';
7
5
  import {
8
6
  Experimental_CustomMergeAllOf,
@@ -13,6 +11,8 @@ import {
13
11
  StrictRJSFSchema,
14
12
  ValidatorType,
15
13
  } from '../types';
14
+ import findSelectedOptionInXxxOf from './findSelectedOptionInXxxOf';
15
+ import getFromSchema from './getFromSchema';
16
16
 
17
17
  /** Unique schema that represents no schema was found, exported for testing purposes */
18
18
  export const NOT_FOUND_SCHEMA = { title: '!@#$_UNKNOWN_$#@!' };
@@ -2,9 +2,9 @@ import get from 'lodash/get';
2
2
 
3
3
  import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from '../constants';
4
4
  import deepEquals from '../deepEquals';
5
+ import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
5
6
  import { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';
6
7
  import retrieveSchema from './retrieveSchema';
7
- import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
8
8
 
9
9
  /** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or
10
10
  * `properties[selectorField].const` that matches the `formData[selectorField]` value. For the purposes of this
@@ -6,13 +6,13 @@ import isString from 'lodash/isString';
6
6
  import reduce from 'lodash/reduce';
7
7
  import times from 'lodash/times';
8
8
 
9
- import getFirstMatchingOption from './getFirstMatchingOption';
10
- import retrieveSchema, { resolveAllReferences } from './retrieveSchema';
11
9
  import { ONE_OF_KEY, REF_KEY, JUNK_OPTION_ID, ANY_OF_KEY } from '../constants';
12
- import guessType from '../guessType';
13
- import { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';
14
10
  import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
15
11
  import getOptionMatchingSimpleDiscriminator from '../getOptionMatchingSimpleDiscriminator';
12
+ import guessType from '../guessType';
13
+ import { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';
14
+ import getFirstMatchingOption from './getFirstMatchingOption';
15
+ import retrieveSchema, { resolveAllReferences } from './retrieveSchema';
16
16
 
17
17
  /** A junk option used to determine when the getFirstMatchingOption call really matches an option rather than returning
18
18
  * the first item