@rjsf/utils 6.6.1 → 6.7.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 (289) hide show
  1. package/LICENSE.md +201 -0
  2. package/dist/index.cjs +534 -376
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/utils.esm.js +534 -376
  5. package/dist/utils.esm.js.map +4 -4
  6. package/dist/utils.umd.js +561 -400
  7. package/lib/ErrorSchemaBuilder.d.ts +1 -1
  8. package/lib/SelectedOptionDescription.d.ts +4 -0
  9. package/lib/SelectedOptionDescription.js +24 -0
  10. package/lib/SelectedOptionDescription.js.map +1 -0
  11. package/lib/allowAdditionalItems.d.ts +1 -1
  12. package/lib/allowAdditionalItems.js +1 -0
  13. package/lib/allowAdditionalItems.js.map +1 -1
  14. package/lib/asNumber.js +2 -0
  15. package/lib/asNumber.js.map +1 -1
  16. package/lib/canExpand.d.ts +1 -1
  17. package/lib/constIsAjvDataReference.d.ts +1 -1
  18. package/lib/constants.d.ts +8 -5
  19. package/lib/constants.js +10 -7
  20. package/lib/constants.js.map +1 -1
  21. package/lib/createErrorHandler.d.ts +1 -1
  22. package/lib/createErrorHandler.js +2 -6
  23. package/lib/createErrorHandler.js.map +1 -1
  24. package/lib/createSchemaUtils.d.ts +1 -1
  25. package/lib/createSchemaUtils.js +3 -1
  26. package/lib/createSchemaUtils.js.map +1 -1
  27. package/lib/dataURItoBlob.js +3 -3
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +8 -7
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/englishStringTranslator.d.ts +1 -1
  33. package/lib/enumOptionSelectedValue.d.ts +1 -1
  34. package/lib/enumOptionValueDecoder.d.ts +1 -1
  35. package/lib/enumOptionValueDecoder.js +1 -1
  36. package/lib/enumOptionValueDecoder.js.map +1 -1
  37. package/lib/enumOptionValueEncoder.d.ts +1 -1
  38. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js.map +1 -1
  41. package/lib/enumOptionsIsSelected.d.ts +1 -1
  42. package/lib/enumOptionsSelectValue.d.ts +1 -1
  43. package/lib/enumOptionsValueForIndex.d.ts +2 -2
  44. package/lib/enumOptionsValueForIndex.js.map +1 -1
  45. package/lib/enums.d.ts +4 -0
  46. package/lib/enums.js +4 -0
  47. package/lib/enums.js.map +1 -1
  48. package/lib/findSchemaDefinition.d.ts +1 -1
  49. package/lib/findSchemaDefinition.js +15 -15
  50. package/lib/findSchemaDefinition.js.map +1 -1
  51. package/lib/getChangedFields.js +4 -6
  52. package/lib/getChangedFields.js.map +1 -1
  53. package/lib/getDateElementProps.d.ts +3 -3
  54. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  55. package/lib/getDiscriminatorFieldFromSchema.js +1 -0
  56. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  57. package/lib/getInputProps.d.ts +1 -1
  58. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  59. package/lib/getOptionMatchingSimpleDiscriminator.js +10 -11
  60. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  61. package/lib/getOptionValueFormat.d.ts +1 -1
  62. package/lib/getSchemaType.d.ts +1 -1
  63. package/lib/getSchemaType.js +2 -1
  64. package/lib/getSchemaType.js.map +1 -1
  65. package/lib/getSubmitButtonOptions.d.ts +1 -1
  66. package/lib/getSubmitButtonOptions.js +1 -1
  67. package/lib/getSubmitButtonOptions.js.map +1 -1
  68. package/lib/getTemplate.d.ts +1 -1
  69. package/lib/getTestIds.d.ts +1 -1
  70. package/lib/getUiOptions.d.ts +1 -1
  71. package/lib/getUiOptions.js +2 -1
  72. package/lib/getUiOptions.js.map +1 -1
  73. package/lib/getWidget.d.ts +1 -1
  74. package/lib/getWidget.js +4 -4
  75. package/lib/getWidget.js.map +1 -1
  76. package/lib/guessType.js +1 -1
  77. package/lib/guessType.js.map +1 -1
  78. package/lib/hasWidget.d.ts +1 -1
  79. package/lib/hashForSchema.d.ts +3 -1
  80. package/lib/hashForSchema.js +11 -4
  81. package/lib/hashForSchema.js.map +1 -1
  82. package/lib/idGenerators.d.ts +1 -1
  83. package/lib/index.d.ts +14 -7
  84. package/lib/index.js +5 -2
  85. package/lib/index.js.map +1 -1
  86. package/lib/isConstant.d.ts +1 -1
  87. package/lib/isCustomWidget.d.ts +1 -1
  88. package/lib/isCustomWidget.js +1 -1
  89. package/lib/isCustomWidget.js.map +1 -1
  90. package/lib/isFixedItems.d.ts +3 -3
  91. package/lib/isFixedItems.js +3 -3
  92. package/lib/isFixedItems.js.map +1 -1
  93. package/lib/isRootSchema.d.ts +1 -1
  94. package/lib/isRootSchema.js +2 -3
  95. package/lib/isRootSchema.js.map +1 -1
  96. package/lib/labelValue.d.ts +1 -1
  97. package/lib/logUnsupportedDefaultForEnum.d.ts +9 -0
  98. package/lib/logUnsupportedDefaultForEnum.js +18 -0
  99. package/lib/logUnsupportedDefaultForEnum.js.map +1 -0
  100. package/lib/lookupFromFormContext.d.ts +1 -1
  101. package/lib/mergeDefaultsWithFormData.js +6 -5
  102. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  103. package/lib/mergeObjects.d.ts +4 -2
  104. package/lib/mergeObjects.js +1 -1
  105. package/lib/mergeObjects.js.map +1 -1
  106. package/lib/mergeSchemas.d.ts +4 -2
  107. package/lib/mergeSchemas.js +13 -6
  108. package/lib/mergeSchemas.js.map +1 -1
  109. package/lib/nameGenerators.d.ts +1 -1
  110. package/lib/optionsList.d.ts +1 -1
  111. package/lib/optionsList.js +22 -21
  112. package/lib/optionsList.js.map +1 -1
  113. package/lib/orderProperties.js +3 -3
  114. package/lib/orderProperties.js.map +1 -1
  115. package/lib/pad.js +1 -1
  116. package/lib/pad.js.map +1 -1
  117. package/lib/parseDateString.d.ts +1 -1
  118. package/lib/parseDateString.js +1 -1
  119. package/lib/parseDateString.js.map +1 -1
  120. package/lib/parser/ParserValidator.d.ts +2 -4
  121. package/lib/parser/ParserValidator.js +2 -0
  122. package/lib/parser/ParserValidator.js.map +1 -1
  123. package/lib/parser/index.d.ts +1 -1
  124. package/lib/parser/schemaParser.d.ts +2 -2
  125. package/lib/parser/schemaParser.js +7 -7
  126. package/lib/parser/schemaParser.js.map +1 -1
  127. package/lib/rangeSpec.d.ts +1 -2
  128. package/lib/rangeSpec.js.map +1 -1
  129. package/lib/removeOptionalEmptyObjects.d.ts +1 -1
  130. package/lib/removeOptionalEmptyObjects.js +6 -8
  131. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  132. package/lib/resolveUiSchema.d.ts +1 -1
  133. package/lib/resolveUiSchema.js +16 -16
  134. package/lib/resolveUiSchema.js.map +1 -1
  135. package/lib/schema/findFieldInSchema.d.ts +1 -1
  136. package/lib/schema/findSelectedOptionInXxxOf.d.ts +1 -1
  137. package/lib/schema/findSelectedOptionInXxxOf.js +1 -3
  138. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  139. package/lib/schema/getClosestMatchingOption.d.ts +1 -1
  140. package/lib/schema/getClosestMatchingOption.js +6 -9
  141. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  142. package/lib/schema/getDefaultFormState.d.ts +4 -4
  143. package/lib/schema/getDefaultFormState.js +81 -43
  144. package/lib/schema/getDefaultFormState.js.map +1 -1
  145. package/lib/schema/getDisplayLabel.d.ts +1 -1
  146. package/lib/schema/getDisplayLabel.js +2 -3
  147. package/lib/schema/getDisplayLabel.js.map +1 -1
  148. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  149. package/lib/schema/getFirstMatchingOption.js +2 -2
  150. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  151. package/lib/schema/getFromSchema.d.ts +1 -1
  152. package/lib/schema/index.js +9 -3
  153. package/lib/schema/index.js.map +1 -1
  154. package/lib/schema/isFilesArray.d.ts +1 -1
  155. package/lib/schema/isMultiSelect.d.ts +1 -1
  156. package/lib/schema/isMultiSelect.js.map +1 -1
  157. package/lib/schema/isSelect.d.ts +1 -1
  158. package/lib/schema/isSelect.js +1 -1
  159. package/lib/schema/isSelect.js.map +1 -1
  160. package/lib/schema/omitExtraData.d.ts +1 -1
  161. package/lib/schema/omitExtraData.js +66 -52
  162. package/lib/schema/omitExtraData.js.map +1 -1
  163. package/lib/schema/retrieveSchema.d.ts +7 -3
  164. package/lib/schema/retrieveSchema.js +83 -56
  165. package/lib/schema/retrieveSchema.js.map +1 -1
  166. package/lib/schema/sanitizeDataForNewSchema.d.ts +1 -1
  167. package/lib/schema/sanitizeDataForNewSchema.js +48 -7
  168. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  169. package/lib/schema/toPathSchema.d.ts +1 -1
  170. package/lib/schema/toPathSchema.js +9 -5
  171. package/lib/schema/toPathSchema.js.map +1 -1
  172. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  173. package/lib/schemaRequiresTrueValue.js +4 -3
  174. package/lib/schemaRequiresTrueValue.js.map +1 -1
  175. package/lib/shallowEquals.js +2 -2
  176. package/lib/shallowEquals.js.map +1 -1
  177. package/lib/shouldRenderOptionalField.d.ts +1 -1
  178. package/lib/toConstant.d.ts +1 -1
  179. package/lib/toDateString.d.ts +1 -1
  180. package/lib/toErrorList.d.ts +1 -1
  181. package/lib/toErrorList.js +3 -3
  182. package/lib/toErrorList.js.map +1 -1
  183. package/lib/toErrorSchema.d.ts +1 -1
  184. package/lib/toFieldPathId.d.ts +1 -1
  185. package/lib/tsconfig.tsbuildinfo +1 -1
  186. package/lib/types.d.ts +63 -57
  187. package/lib/unwrapErrorHandler.d.ts +1 -1
  188. package/lib/unwrapErrorHandler.js +7 -9
  189. package/lib/unwrapErrorHandler.js.map +1 -1
  190. package/lib/useAltDateWidgetProps.d.ts +6 -6
  191. package/lib/useAltDateWidgetProps.js +3 -3
  192. package/lib/useAltDateWidgetProps.js.map +1 -1
  193. package/lib/useFileWidgetProps.d.ts +2 -2
  194. package/lib/useFileWidgetProps.js +3 -3
  195. package/lib/useFileWidgetProps.js.map +1 -1
  196. package/lib/validationDataMerge.d.ts +1 -1
  197. package/lib/withIdRefPrefix.d.ts +1 -1
  198. package/lib/withIdRefPrefix.js +12 -12
  199. package/lib/withIdRefPrefix.js.map +1 -1
  200. package/package.json +19 -19
  201. package/src/ErrorSchemaBuilder.ts +1 -1
  202. package/src/SelectedOptionDescription.tsx +48 -0
  203. package/src/allowAdditionalItems.ts +2 -1
  204. package/src/asNumber.ts +2 -0
  205. package/src/canExpand.ts +1 -1
  206. package/src/constIsAjvDataReference.ts +2 -2
  207. package/src/constants.ts +10 -7
  208. package/src/createErrorHandler.ts +6 -7
  209. package/src/createSchemaUtils.ts +4 -2
  210. package/src/dataURItoBlob.ts +3 -3
  211. package/src/dateRangeOptions.ts +9 -7
  212. package/src/englishStringTranslator.ts +1 -1
  213. package/src/enumOptionSelectedValue.ts +1 -1
  214. package/src/enumOptionValueDecoder.ts +2 -2
  215. package/src/enumOptionValueEncoder.ts +1 -1
  216. package/src/enumOptionsDeselectValue.ts +1 -1
  217. package/src/enumOptionsIndexForValue.ts +2 -2
  218. package/src/enumOptionsIsSelected.ts +1 -1
  219. package/src/enumOptionsSelectValue.ts +1 -1
  220. package/src/enumOptionsValueForIndex.ts +2 -2
  221. package/src/enums.ts +4 -0
  222. package/src/findSchemaDefinition.ts +18 -17
  223. package/src/getChangedFields.ts +5 -5
  224. package/src/getDateElementProps.ts +3 -3
  225. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  226. package/src/getInputProps.ts +1 -1
  227. package/src/getOptionMatchingSimpleDiscriminator.ts +11 -15
  228. package/src/getOptionValueFormat.ts +1 -1
  229. package/src/getSchemaType.ts +3 -2
  230. package/src/getSubmitButtonOptions.ts +3 -3
  231. package/src/getTemplate.ts +1 -1
  232. package/src/getTestIds.ts +1 -1
  233. package/src/getUiOptions.ts +10 -2
  234. package/src/getWidget.tsx +5 -6
  235. package/src/guessType.ts +1 -1
  236. package/src/hasWidget.ts +1 -1
  237. package/src/hashForSchema.ts +12 -5
  238. package/src/idGenerators.ts +1 -1
  239. package/src/index.ts +16 -5
  240. package/src/isConstant.ts +1 -1
  241. package/src/isCustomWidget.ts +2 -2
  242. package/src/isFixedItems.ts +4 -4
  243. package/src/isRootSchema.ts +3 -5
  244. package/src/labelValue.ts +1 -1
  245. package/src/logUnsupportedDefaultForEnum.ts +28 -0
  246. package/src/lookupFromFormContext.ts +1 -1
  247. package/src/mergeDefaultsWithFormData.ts +8 -7
  248. package/src/mergeObjects.ts +2 -2
  249. package/src/mergeSchemas.ts +14 -7
  250. package/src/nameGenerators.ts +1 -1
  251. package/src/optionsList.ts +21 -23
  252. package/src/orderProperties.ts +4 -4
  253. package/src/pad.ts +1 -1
  254. package/src/parseDateString.ts +2 -2
  255. package/src/parser/ParserValidator.ts +4 -4
  256. package/src/parser/index.ts +1 -1
  257. package/src/parser/schemaParser.ts +10 -9
  258. package/src/rangeSpec.ts +1 -2
  259. package/src/removeOptionalEmptyObjects.ts +8 -11
  260. package/src/resolveUiSchema.ts +32 -25
  261. package/src/schema/findFieldInSchema.ts +1 -1
  262. package/src/schema/findSelectedOptionInXxxOf.ts +17 -7
  263. package/src/schema/getClosestMatchingOption.ts +17 -11
  264. package/src/schema/getDefaultFormState.ts +104 -43
  265. package/src/schema/getDisplayLabel.ts +4 -5
  266. package/src/schema/getFirstMatchingOption.ts +3 -3
  267. package/src/schema/getFromSchema.ts +1 -1
  268. package/src/schema/index.ts +3 -0
  269. package/src/schema/isFilesArray.ts +1 -1
  270. package/src/schema/isMultiSelect.ts +7 -1
  271. package/src/schema/isSelect.ts +8 -2
  272. package/src/schema/omitExtraData.ts +73 -60
  273. package/src/schema/retrieveSchema.ts +131 -83
  274. package/src/schema/sanitizeDataForNewSchema.ts +57 -8
  275. package/src/schema/toPathSchema.ts +11 -7
  276. package/src/schemaRequiresTrueValue.ts +4 -4
  277. package/src/shallowEquals.ts +2 -2
  278. package/src/shouldRenderOptionalField.ts +1 -1
  279. package/src/toConstant.ts +1 -1
  280. package/src/toDateString.ts +1 -1
  281. package/src/toErrorList.ts +4 -4
  282. package/src/toErrorSchema.ts +1 -1
  283. package/src/toFieldPathId.ts +1 -1
  284. package/src/types.ts +92 -63
  285. package/src/unwrapErrorHandler.ts +11 -12
  286. package/src/useAltDateWidgetProps.tsx +10 -8
  287. package/src/useFileWidgetProps.ts +7 -7
  288. package/src/validationDataMerge.ts +1 -1
  289. package/src/withIdRefPrefix.ts +12 -12
@@ -20,6 +20,7 @@ import {
20
20
  PATTERN_PROPERTIES_KEY,
21
21
  PROPERTIES_KEY,
22
22
  REF_KEY,
23
+ RJSF_REF_CYCLE_KEY,
23
24
  RJSF_REF_KEY,
24
25
  } from '../constants';
25
26
  import deepEquals from '../deepEquals';
@@ -28,10 +29,11 @@ import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema'
28
29
  import guessType from '../guessType';
29
30
  import isObject from '../isObject';
30
31
  import mergeSchemas from '../mergeSchemas';
31
- import {
32
+ import type {
32
33
  Experimental_CustomMergeAllOf,
33
34
  FormContextType,
34
35
  GenericObjectType,
36
+ RJSFMarkedSchema,
35
37
  RJSFSchema,
36
38
  StrictRJSFSchema,
37
39
  ValidatorType,
@@ -75,6 +77,18 @@ export default function retrieveSchema<
75
77
  )[0];
76
78
  }
77
79
 
80
+ /** Converts boolean schemas to equivalent object schemas for APIs that operate on `StrictRJSFSchema` objects.
81
+ *
82
+ * @param schema - The schema or boolean schema to normalize
83
+ * @returns - The original schema or an equivalent object schema
84
+ */
85
+ function normalizeBooleanSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S | boolean): S {
86
+ if (typeof schema !== 'boolean') {
87
+ return schema;
88
+ }
89
+ return (schema ? {} : { not: {} }) as S;
90
+ }
91
+
78
92
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
79
93
  * with the rest of the schema. If `expandAllBranches` is true, then the `retrieveSchemaInteral()` results for both
80
94
  * conditions will be returned.
@@ -105,10 +119,11 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
105
119
  let schemas: S[] = [];
106
120
  if (expandAllBranches) {
107
121
  if (then && typeof then !== 'boolean') {
122
+ const thenSchema = then as unknown as S;
108
123
  schemas = schemas.concat(
109
124
  retrieveSchemaInternal<T, S, F>(
110
125
  validator,
111
- then as S,
126
+ thenSchema,
112
127
  rootSchema,
113
128
  formData,
114
129
  expandAllBranches,
@@ -118,10 +133,11 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
118
133
  );
119
134
  }
120
135
  if (otherwise && typeof otherwise !== 'boolean') {
136
+ const otherwiseSchema = otherwise as unknown as S;
121
137
  schemas = schemas.concat(
122
138
  retrieveSchemaInternal<T, S, F>(
123
139
  validator,
124
- otherwise as S,
140
+ otherwiseSchema,
125
141
  rootSchema,
126
142
  formData,
127
143
  expandAllBranches,
@@ -131,12 +147,13 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
131
147
  );
132
148
  }
133
149
  } else {
134
- const conditionalSchema = conditionValue ? then : otherwise;
135
- if (conditionalSchema && typeof conditionalSchema !== 'boolean') {
150
+ const conditionalBranch = (conditionValue ? then : otherwise) as S | boolean | undefined;
151
+ if (conditionalBranch !== undefined) {
152
+ const conditionalSchema = normalizeBooleanSchema<S>(conditionalBranch);
136
153
  schemas = schemas.concat(
137
154
  retrieveSchemaInternal<T, S, F>(
138
155
  validator,
139
- conditionalSchema as S,
156
+ conditionalSchema,
140
157
  rootSchema,
141
158
  formData,
142
159
  expandAllBranches,
@@ -187,7 +204,7 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
187
204
  permutations.forEach((permutation) => permutation.push(list[0]));
188
205
  return permutations;
189
206
  },
190
- [[]] as S[][], // Start with an empty list
207
+ [[]], // Start with an empty list
191
208
  );
192
209
 
193
210
  return allPermutations;
@@ -265,8 +282,8 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
265
282
  formData,
266
283
  experimental_customMergeAllOf,
267
284
  );
268
- return resolvedSchemas.flatMap((s) => {
269
- return retrieveSchemaInternal<T, S, F>(
285
+ return resolvedSchemas.flatMap((s) =>
286
+ retrieveSchemaInternal<T, S, F>(
270
287
  validator,
271
288
  s,
272
289
  rootSchema,
@@ -274,8 +291,8 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
274
291
  expandAllBranches,
275
292
  recurseList,
276
293
  experimental_customMergeAllOf,
277
- );
278
- });
294
+ ),
295
+ );
279
296
  }
280
297
  if (ALL_OF_KEY in schema && Array.isArray(schema[ALL_OF_KEY])) {
281
298
  const allOfSchemaElements: S[][] = schema.allOf.map((allOfSubschema) =>
@@ -348,6 +365,10 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
348
365
  * @param recurseList - List of $refs already resolved to prevent recursion
349
366
  * @param [baseURI] - The base URI to be used for resolving relative references
350
367
  * @param [resolveAnyOfOrOneOfRefs] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists
368
+ * @param [markCycleOnDetection=false] - When true and a recursive $ref is detected, the returned schema is tagged
369
+ * with `__rjsf_ref_cycle: true` so that `SchemaField` can render a cycle indicator instead of recursing.
370
+ * Should only be `true` when called from an **object-property** context, because object properties are always
371
+ * rendered (creating an infinite loop), whereas array items and anyOf/oneOf branches are data-driven.
351
372
  * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved
352
373
  */
353
374
  export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
@@ -356,24 +377,26 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
356
377
  recurseList: string[],
357
378
  baseURI?: string,
358
379
  resolveAnyOfOrOneOfRefs?: boolean,
380
+ markCycleOnDetection = false,
359
381
  ): S {
360
382
  if (!isObject(schema)) {
361
383
  return schema;
362
384
  }
363
385
  let resolvedSchema: S = schema;
386
+ let currentBaseURI = baseURI;
364
387
  // resolve top level ref
365
388
  if (REF_KEY in resolvedSchema) {
366
389
  const { $ref, ...localSchema } = resolvedSchema;
367
390
  // Check for a recursive reference and stop the loop
368
391
  if (recurseList.includes($ref!)) {
369
- return resolvedSchema;
392
+ return markCycleOnDetection ? ({ ...resolvedSchema, [RJSF_REF_CYCLE_KEY]: true } as S) : resolvedSchema;
370
393
  }
371
394
  recurseList.push($ref!);
372
395
  // Retrieve the referenced schema definition.
373
- const refSchema = findSchemaDefinition<S>($ref, rootSchema, baseURI);
396
+ const refSchema = findSchemaDefinition<S>($ref, rootSchema, currentBaseURI);
374
397
  resolvedSchema = { ...refSchema, ...localSchema, [RJSF_REF_KEY]: $ref };
375
398
  if (ID_KEY in resolvedSchema) {
376
- baseURI = resolvedSchema[ID_KEY];
399
+ currentBaseURI = resolvedSchema[ID_KEY];
377
400
  }
378
401
  }
379
402
 
@@ -381,9 +404,20 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
381
404
  const childrenLists: string[][] = [];
382
405
  const updatedProps = transform(
383
406
  resolvedSchema[PROPERTIES_KEY]!,
384
- (result, value, key: string) => {
407
+ (acc, value, key: string) => {
385
408
  const childList: string[] = [...recurseList];
386
- result[key] = resolveAllReferences(value as S, rootSchema, childList, baseURI, resolveAnyOfOrOneOfRefs);
409
+ // Mark cycles only when NOT in resolveAnyOfOrOneOfRefs mode. When resolveAnyOfOrOneOfRefs=true
410
+ // (e.g. from ObjectField), options are resolved against a shared recurseList that accumulates
411
+ // refs across branches, causing false positives. In simple (non-anyOf) resolution, a $ref cycle
412
+ // in an object property always causes an infinite render loop and must be caught.
413
+ acc[key] = resolveAllReferences(
414
+ value as S,
415
+ rootSchema,
416
+ childList,
417
+ currentBaseURI,
418
+ resolveAnyOfOrOneOfRefs,
419
+ !resolveAnyOfOrOneOfRefs,
420
+ );
387
421
  childrenLists.push(childList);
388
422
  },
389
423
  {} as RJSFSchema,
@@ -399,7 +433,14 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
399
433
  ) {
400
434
  resolvedSchema = {
401
435
  ...resolvedSchema,
402
- items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs),
436
+ // Array items are only rendered when data exists, so a $ref cycle here does NOT cause an infinite render.
437
+ items: resolveAllReferences(
438
+ resolvedSchema.items as S,
439
+ rootSchema,
440
+ recurseList,
441
+ currentBaseURI,
442
+ resolveAnyOfOrOneOfRefs,
443
+ ),
403
444
  };
404
445
  }
405
446
 
@@ -417,7 +458,7 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
417
458
  resolvedSchema = {
418
459
  ...resolvedSchema,
419
460
  [key]: schemas.map((s: S) =>
420
- resolveAllReferences(s, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs),
461
+ resolveAllReferences(s, rootSchema, recurseList, currentBaseURI, resolveAnyOfOrOneOfRefs),
421
462
  ),
422
463
  };
423
464
  }
@@ -469,7 +510,7 @@ export function stubExistingAdditionalProperties<
469
510
  get(formData, [key]) as T,
470
511
  experimental_customMergeAllOf,
471
512
  );
472
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
513
+ (schema.properties[key] as RJSFMarkedSchema)[ADDITIONAL_PROPERTY_FLAG] = true;
473
514
  return;
474
515
  }
475
516
  }
@@ -481,7 +522,7 @@ export function stubExistingAdditionalProperties<
481
522
  validator,
482
523
  { [REF_KEY]: get(schema.additionalProperties, [REF_KEY]) } as S,
483
524
  rootSchema,
484
- formData as T,
525
+ get(formData, [key]) as T,
485
526
  experimental_customMergeAllOf,
486
527
  );
487
528
  } else if ('type' in schema.additionalProperties!) {
@@ -501,12 +542,12 @@ export function stubExistingAdditionalProperties<
501
542
  // The type of our new key should match the additionalProperties value;
502
543
  schema.properties[key] = additionalProperties;
503
544
  // Set our additional property flag so we know it was dynamically added
504
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
545
+ (schema.properties[key] as RJSFMarkedSchema)[ADDITIONAL_PROPERTY_FLAG] = true;
505
546
  } else {
506
547
  // Invalid property
507
548
  schema.properties[key] = { type: 'null' };
508
549
  // Set our additional property flag so we know it was dynamically added
509
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
550
+ (schema.properties[key] as RJSFMarkedSchema)[ADDITIONAL_PROPERTY_FLAG] = true;
510
551
  }
511
552
  });
512
553
 
@@ -588,11 +629,19 @@ export function retrieveSchemaInternal<
588
629
  try {
589
630
  const withContainsSchemas = [] as S[];
590
631
  const withoutContainsSchemas = [] as S[];
591
- resolvedSchema.allOf?.forEach((s) => {
592
- if (typeof s === 'object' && s.contains) {
593
- withContainsSchemas.push(s as S);
632
+ // Collect Symbol-keyed properties from allOf subschemas before merging; shallowAllOfMerge
633
+ // (external library) only operates on string keys and will drop them.
634
+ const allOfSymbols: Record<symbol, unknown> = {};
635
+ resolvedSchema.allOf?.forEach((allOfItem) => {
636
+ if (typeof allOfItem === 'object' && allOfItem.contains) {
637
+ withContainsSchemas.push(allOfItem as S);
594
638
  } else {
595
- withoutContainsSchemas.push(s as S);
639
+ withoutContainsSchemas.push(allOfItem as S);
640
+ for (const sym of Object.getOwnPropertySymbols(allOfItem)) {
641
+ if (!(sym in allOfSymbols)) {
642
+ allOfSymbols[sym] = (allOfItem as any)[sym];
643
+ }
644
+ }
596
645
  }
597
646
  });
598
647
  if (withContainsSchemas.length) {
@@ -601,10 +650,15 @@ export function retrieveSchemaInternal<
601
650
  resolvedSchema = experimental_customMergeAllOf
602
651
  ? experimental_customMergeAllOf(resolvedSchema)
603
652
  : mergeAllOf(resolvedSchema);
653
+ // Re-apply collected Symbol properties that the merge dropped.
654
+ for (const sym of Object.getOwnPropertySymbols(allOfSymbols)) {
655
+ (resolvedSchema as any)[sym] = allOfSymbols[sym];
656
+ }
604
657
  if (withContainsSchemas.length) {
605
658
  resolvedSchema.allOf = withContainsSchemas;
606
659
  }
607
660
  } catch (e) {
661
+ // oxlint-disable-next-line no-console
608
662
  console.warn('could not merge subschemas in allOf:\n', e);
609
663
  const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;
610
664
  return resolvedSchemaWithoutAllOf as S;
@@ -612,18 +666,18 @@ export function retrieveSchemaInternal<
612
666
  }
613
667
  if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {
614
668
  resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(
615
- (schema, key) => {
616
- const matchingProperties = getMatchingPatternProperties(schema, key);
669
+ (acc, key) => {
670
+ const matchingProperties = getMatchingPatternProperties(acc, key);
617
671
  if (!isEmpty(matchingProperties)) {
618
- schema.properties[key] = retrieveSchema<T, S, F>(
672
+ acc.properties[key] = retrieveSchema<T, S, F>(
619
673
  validator,
620
- { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,
674
+ { allOf: [acc.properties[key], ...Object.values(matchingProperties)] } as S,
621
675
  rootSchema,
622
676
  get(rawFormData, [key]) as T,
623
677
  experimental_customMergeAllOf,
624
678
  );
625
679
  }
626
- return schema;
680
+ return acc;
627
681
  },
628
682
  {
629
683
  ...resolvedSchema,
@@ -676,11 +730,7 @@ export function resolveAnyOrOneOfSchemas<
676
730
  // Ensure that during expand all branches we pass an object rather than undefined so that all options are interrogated
677
731
  const formData = rawFormData === undefined && expandAllBranches ? ({} as T) : rawFormData;
678
732
  const discriminator = getDiscriminatorFieldFromSchema<S>(schema);
679
- anyOrOneOf = anyOrOneOf.map((s) => {
680
- // Due to anyOf/oneOf possibly using the same $ref we always pass a fresh recurse list array so that each option
681
- // can resolve recursive references independently
682
- return resolveAllReferences(s, rootSchema, []);
683
- });
733
+ anyOrOneOf = anyOrOneOf.map((s) => resolveAllReferences(s, rootSchema, []));
684
734
  // Call this to trigger the set of isValid() calls that the schema parser will need
685
735
  const option = getFirstMatchingOption<T, S, F>(validator, formData, anyOrOneOf, rootSchema, discriminator);
686
736
  if (expandAllBranches) {
@@ -694,7 +744,7 @@ export function resolveAnyOrOneOfSchemas<
694
744
  getFirstMatchingOption<T, S, F>(validator, formData, relaxed, rootSchema, discriminator);
695
745
  return anyOrOneOf.map((item) => mergeSchemas(remaining, item) as S);
696
746
  }
697
- schema = mergeSchemas(remaining, anyOrOneOf[option]) as S;
747
+ return [mergeSchemas(remaining, anyOrOneOf[option]) as S];
698
748
  }
699
749
  return [schema];
700
750
  }
@@ -714,15 +764,15 @@ export function resolveAnyOrOneOfSchemas<
714
764
  * @returns - A new array of plain schema objects with `additionalProperties` relaxed where needed
715
765
  */
716
766
  export function relaxOptionsForScoring<S extends StrictRJSFSchema = RJSFSchema>(
717
- options: Array<S | boolean>,
767
+ options: (S | boolean)[],
718
768
  resolveRefs = false,
719
769
  rootSchema?: S,
720
770
  ): S[] {
721
771
  return options.map((d) => {
722
772
  if (!isObject(d)) {
723
- return (d ? {} : { not: {} }) as S;
773
+ return normalizeBooleanSchema<S>(d);
724
774
  }
725
- const schema = resolveRefs && rootSchema ? resolveAllReferences<S>(d as S, rootSchema, []) : (d as S);
775
+ const schema = resolveRefs && rootSchema ? resolveAllReferences<S>(d, rootSchema, []) : d;
726
776
  return schema.additionalProperties === false ? { ...schema, additionalProperties: true } : schema;
727
777
  });
728
778
  }
@@ -799,45 +849,42 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
799
849
  let schemas = [resolvedSchema];
800
850
  // Process dependencies updating the local schema properties as appropriate.
801
851
  for (const dependencyKey in dependencies) {
802
- // Skip this dependency if its trigger property is not present.
803
- if (!expandAllBranches && get(formData, [dependencyKey]) === undefined) {
804
- continue;
805
- }
806
- // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)
807
- if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
808
- continue;
809
- }
810
- const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
811
- dependencyKey,
812
- dependencies as GenericObjectType,
813
- );
814
- if (Array.isArray(dependencyValue)) {
815
- schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);
816
- } else if (isObject(dependencyValue)) {
817
- schemas = withDependentSchema<T, S, F>(
818
- validator,
819
- resolvedSchema,
820
- rootSchema,
852
+ if (
853
+ (expandAllBranches || get(formData, [dependencyKey]) !== undefined) &&
854
+ (!resolvedSchema.properties || dependencyKey in resolvedSchema.properties)
855
+ ) {
856
+ const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
821
857
  dependencyKey,
822
- dependencyValue as S,
823
- expandAllBranches,
824
- recurseList,
825
- formData,
826
- experimental_customMergeAllOf,
858
+ dependencies as GenericObjectType,
859
+ );
860
+ if (Array.isArray(dependencyValue)) {
861
+ schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);
862
+ } else if (isObject(dependencyValue)) {
863
+ schemas = withDependentSchema<T, S, F>(
864
+ validator,
865
+ resolvedSchema,
866
+ rootSchema,
867
+ dependencyKey,
868
+ dependencyValue as S,
869
+ expandAllBranches,
870
+ recurseList,
871
+ formData,
872
+ experimental_customMergeAllOf,
873
+ );
874
+ }
875
+ return schemas.flatMap((schema) =>
876
+ processDependencies<T, S, F>(
877
+ validator,
878
+ remainingDependencies,
879
+ schema,
880
+ rootSchema,
881
+ expandAllBranches,
882
+ recurseList,
883
+ formData,
884
+ experimental_customMergeAllOf,
885
+ ),
827
886
  );
828
887
  }
829
- return schemas.flatMap((schema) =>
830
- processDependencies<T, S, F>(
831
- validator,
832
- remainingDependencies,
833
- schema,
834
- rootSchema,
835
- expandAllBranches,
836
- recurseList,
837
- formData,
838
- experimental_customMergeAllOf,
839
- ),
840
- );
841
888
  }
842
889
  return schemas;
843
890
  }
@@ -858,7 +905,7 @@ export function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>
858
905
  const required = Array.isArray(schema.required)
859
906
  ? Array.from(new Set([...schema.required, ...additionallyRequired]))
860
907
  : additionallyRequired;
861
- return { ...schema, required: required };
908
+ return { ...schema, required };
862
909
  }
863
910
 
864
911
  /** Merges a dependent schema into the `schema` dealing with oneOfs and references. Passes the `expandAllBranches` flag
@@ -898,10 +945,10 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
898
945
  );
899
946
  return dependentSchemas.flatMap((dependent) => {
900
947
  const { oneOf, ...dependentSchema } = dependent;
901
- schema = mergeSchemas(schema, dependentSchema) as S;
948
+ const mergedSchema = mergeSchemas(schema, dependentSchema) as S;
902
949
  // Since it does not contain oneOf, we return the original schema.
903
950
  if (oneOf === undefined) {
904
- return schema;
951
+ return mergedSchema;
905
952
  }
906
953
  // Resolve $refs inside oneOf.
907
954
  const resolvedOneOfs = oneOf.map((subschema) => {
@@ -914,7 +961,7 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
914
961
  return allPermutations.flatMap((resolvedOneOf) =>
915
962
  withExactlyOneSubschema<T, S, F>(
916
963
  validator,
917
- schema,
964
+ mergedSchema,
918
965
  rootSchema,
919
966
  dependencyKey,
920
967
  resolvedOneOf,
@@ -959,7 +1006,7 @@ export function withExactlyOneSubschema<
959
1006
  experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
960
1007
  ): S[] {
961
1008
  const validSubschemas = oneOf!.filter((subschema) => {
962
- if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
1009
+ if (typeof subschema === 'boolean' || !subschema?.properties) {
963
1010
  return false;
964
1011
  }
965
1012
  const { [dependencyKey]: conditionPropertySchema } = subschema.properties;
@@ -975,7 +1022,8 @@ export function withExactlyOneSubschema<
975
1022
  return false;
976
1023
  });
977
1024
 
978
- if (!expandAllBranches && validSubschemas!.length !== 1) {
1025
+ if (!expandAllBranches && validSubschemas.length !== 1) {
1026
+ // oxlint-disable-next-line no-console
979
1027
  console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
980
1028
  return [schema];
981
1029
  }
@@ -992,6 +1040,6 @@ export function withExactlyOneSubschema<
992
1040
  recurseList,
993
1041
  experimental_customMergeAllOf,
994
1042
  );
995
- return schemas.map((s) => mergeSchemas(schema, s) as S);
1043
+ return schemas.map((resolvedSubschema) => mergeSchemas(schema, resolvedSubschema) as S);
996
1044
  });
997
1045
  }
@@ -1,8 +1,9 @@
1
1
  import get from 'lodash/get';
2
2
  import has from 'lodash/has';
3
3
 
4
- import { PROPERTIES_KEY, REF_KEY } from '../constants';
5
- import {
4
+ import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY, REF_KEY } from '../constants';
5
+ import deepEquals from '../deepEquals';
6
+ import type {
6
7
  Experimental_CustomMergeAllOf,
7
8
  FormContextType,
8
9
  GenericObjectType,
@@ -14,6 +15,42 @@ import retrieveSchema from './retrieveSchema';
14
15
 
15
16
  const NO_VALUE = Symbol('no Value');
16
17
 
18
+ function enumValuesForSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S): any[] | undefined {
19
+ if (Array.isArray(schema.enum)) {
20
+ return schema.enum;
21
+ }
22
+
23
+ const options = (schema.oneOf || schema.anyOf) as S[] | undefined;
24
+ if (!Array.isArray(options)) {
25
+ return undefined;
26
+ }
27
+
28
+ const values = options
29
+ .map((option) => {
30
+ if (CONST_KEY in option) {
31
+ return option[CONST_KEY];
32
+ }
33
+ return Array.isArray(option.enum) && option.enum.length === 1 ? option.enum[0] : NO_VALUE;
34
+ })
35
+ .filter((value) => value !== NO_VALUE);
36
+
37
+ return values.length > 0 ? values : undefined;
38
+ }
39
+
40
+ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>(schema: S, formValue: any) {
41
+ const enumValues = enumValuesForSchema(schema);
42
+ if (!enumValues || enumValues.some((value) => deepEquals(value, formValue))) {
43
+ return NO_VALUE;
44
+ }
45
+
46
+ const defaultValue = get(schema, DEFAULT_KEY, NO_VALUE);
47
+ if (defaultValue !== NO_VALUE && enumValues.some((value) => deepEquals(value, defaultValue))) {
48
+ return defaultValue;
49
+ }
50
+
51
+ return enumValues.length === 1 ? enumValues[0] : undefined;
52
+ }
53
+
17
54
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new
18
55
  * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature
19
56
  * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema
@@ -142,8 +179,8 @@ export default function sanitizeDataForNewSchema<
142
179
  // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
143
180
  // with the new default or const. This allows the case where two schemas differ that only by the default/const
144
181
  // value to be properly selected
145
- const newOptionDefault = get(newKeyedSchema, 'default', NO_VALUE);
146
- const oldOptionDefault = get(oldKeyedSchema, 'default', NO_VALUE);
182
+ const newOptionDefault = get(newKeyedSchema, DEFAULT_KEY, NO_VALUE);
183
+ const oldOptionDefault = get(oldKeyedSchema, DEFAULT_KEY, NO_VALUE);
147
184
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
148
185
  if (oldOptionDefault === formValue) {
149
186
  // If the old default matches the formValue, we'll update the new value to match the new default
@@ -154,18 +191,25 @@ export default function sanitizeDataForNewSchema<
154
191
  }
155
192
  }
156
193
 
157
- const newOptionConst = get(newKeyedSchema, 'const', NO_VALUE);
158
- const oldOptionConst = get(oldKeyedSchema, 'const', NO_VALUE);
194
+ const newOptionConst = get(newKeyedSchema, CONST_KEY, NO_VALUE);
195
+ const oldOptionConst = get(oldKeyedSchema, CONST_KEY, NO_VALUE);
159
196
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
160
197
  // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
161
198
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
162
199
  }
200
+
201
+ if (has(data, key)) {
202
+ const enumReplacement = replacementForInvalidEnumValue(newKeyedSchema, formValue);
203
+ if (enumReplacement !== NO_VALUE) {
204
+ removeOldSchemaData[key] = enumReplacement;
205
+ }
206
+ }
163
207
  }
164
208
  }
165
209
  });
166
210
 
167
211
  newFormData = {
168
- ...(typeof data == 'string' || Array.isArray(data) ? undefined : data),
212
+ ...(typeof data === 'string' || Array.isArray(data) ? undefined : data),
169
213
  ...removeOldSchemaData,
170
214
  ...nestedData,
171
215
  };
@@ -221,7 +265,12 @@ export default function sanitizeDataForNewSchema<
221
265
  return newValue;
222
266
  }, []);
223
267
  } else {
224
- newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;
268
+ // Filter out items that are no longer valid in the new items schema (e.g., enum values that changed)
269
+ const newItemEnumValues = enumValuesForSchema(newSchemaItems as S);
270
+ const filteredData = newItemEnumValues
271
+ ? data.filter((item: any) => newItemEnumValues.some((v: any) => deepEquals(v, item)))
272
+ : data;
273
+ newFormData = maxItems > 0 && filteredData.length > maxItems ? filteredData.slice(0, maxItems) : filteredData;
225
274
  }
226
275
  }
227
276
  } else if (
@@ -1,3 +1,4 @@
1
+ // oxlint-disable typescript/no-deprecated
1
2
  import get from 'lodash/get';
2
3
  import isObject from 'lodash/isObject';
3
4
  import set from 'lodash/set';
@@ -17,7 +18,7 @@ import {
17
18
  } from '../constants';
18
19
  import deepEquals from '../deepEquals';
19
20
  import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
20
- import {
21
+ import type {
21
22
  Experimental_CustomMergeAllOf,
22
23
  FormContextType,
23
24
  GenericObjectType,
@@ -51,16 +52,16 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
51
52
  experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
52
53
  ): PathSchema<T> {
53
54
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
54
- const _schema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
55
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
55
+ const innerSchema = retrieveSchema<T, S, F>(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
56
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, innerSchema));
56
57
  if (sameSchemaIndex === -1) {
57
58
  return toPathSchemaInternal<T, S, F>(
58
59
  validator,
59
- _schema,
60
+ innerSchema,
60
61
  name,
61
62
  rootSchema,
62
63
  formData,
63
- _recurseList.concat(_schema),
64
+ _recurseList.concat(innerSchema),
64
65
  experimental_customMergeAllOf,
65
66
  );
66
67
  }
@@ -82,12 +83,12 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
82
83
  discriminator,
83
84
  experimental_customMergeAllOf,
84
85
  );
85
- const _schema: S = xxxOf![index] as S;
86
+ const innerSchema: S = xxxOf[index];
86
87
  pathSchema = {
87
88
  ...pathSchema,
88
89
  ...toPathSchemaInternal<T, S, F>(
89
90
  validator,
90
- _schema,
91
+ innerSchema,
91
92
  name,
92
93
  rootSchema,
93
94
  formData,
@@ -144,6 +145,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
144
145
  experimental_customMergeAllOf,
145
146
  );
146
147
  } else {
148
+ // oxlint-disable-next-line no-console
147
149
  console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
148
150
  }
149
151
  });
@@ -161,6 +163,8 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
161
163
  });
162
164
  }
163
165
  } else if (PROPERTIES_KEY in schema) {
166
+ // This is a deprecated function that is no longer used by RJSF
167
+ // oxlint-disable-next-line guard-for-in
164
168
  for (const property in schema.properties) {
165
169
  const field: S = get(schema, [PROPERTIES_KEY, property], {}) as S;
166
170
  (pathSchema as PathSchema<GenericObjectType>)[property] = toPathSchemaInternal<T, S, F>(
@@ -1,4 +1,4 @@
1
- import { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import type { RJSFSchema, StrictRJSFSchema } from './types';
2
2
 
3
3
  /** Check to see if a `schema` specifies that a value must be true. This happens when:
4
4
  * - `schema.const` is truthy
@@ -16,17 +16,17 @@ export default function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJS
16
16
  }
17
17
 
18
18
  // Check if an enum has a single value of true
19
- if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
19
+ if (schema.enum?.length === 1 && schema.enum[0] === true) {
20
20
  return true;
21
21
  }
22
22
 
23
23
  // If anyOf has a single value, evaluate the subschema
24
- if (schema.anyOf && schema.anyOf.length === 1) {
24
+ if (schema.anyOf?.length === 1) {
25
25
  return schemaRequiresTrueValue(schema.anyOf[0] as S);
26
26
  }
27
27
 
28
28
  // If oneOf has a single value, evaluate the subschema
29
- if (schema.oneOf && schema.oneOf.length === 1) {
29
+ if (schema.oneOf?.length === 1) {
30
30
  return schemaRequiresTrueValue(schema.oneOf[0] as S);
31
31
  }
32
32