@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.1

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 (279) hide show
  1. package/dist/index.js +1281 -625
  2. package/dist/index.js.map +4 -4
  3. package/dist/utils.esm.js +1254 -598
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +1201 -570
  6. package/lib/ErrorSchemaBuilder.d.ts +8 -4
  7. package/lib/ErrorSchemaBuilder.js +10 -8
  8. package/lib/ErrorSchemaBuilder.js.map +1 -1
  9. package/lib/allowAdditionalItems.d.ts +1 -1
  10. package/lib/allowAdditionalItems.js +1 -1
  11. package/lib/allowAdditionalItems.js.map +1 -1
  12. package/lib/asNumber.js.map +1 -1
  13. package/lib/canExpand.d.ts +1 -1
  14. package/lib/canExpand.js +2 -2
  15. package/lib/canExpand.js.map +1 -1
  16. package/lib/constIsAjvDataReference.d.ts +9 -0
  17. package/lib/constIsAjvDataReference.js +15 -0
  18. package/lib/constIsAjvDataReference.js.map +1 -0
  19. package/lib/constants.d.ts +11 -3
  20. package/lib/constants.js +11 -3
  21. package/lib/constants.js.map +1 -1
  22. package/lib/createErrorHandler.d.ts +1 -1
  23. package/lib/createErrorHandler.js +2 -2
  24. package/lib/createErrorHandler.js.map +1 -1
  25. package/lib/createSchemaUtils.d.ts +3 -2
  26. package/lib/createSchemaUtils.js +56 -46
  27. package/lib/createSchemaUtils.js.map +1 -1
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +1 -1
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/deepEquals.js +1 -1
  33. package/lib/deepEquals.js.map +1 -1
  34. package/lib/englishStringTranslator.d.ts +1 -1
  35. package/lib/englishStringTranslator.js +1 -1
  36. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  37. package/lib/enumOptionsDeselectValue.js +4 -4
  38. package/lib/enumOptionsDeselectValue.js.map +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js +1 -1
  41. package/lib/enumOptionsIndexForValue.js.map +1 -1
  42. package/lib/enumOptionsIsSelected.d.ts +1 -1
  43. package/lib/enumOptionsIsSelected.js +3 -3
  44. package/lib/enumOptionsIsSelected.js.map +1 -1
  45. package/lib/enumOptionsSelectValue.d.ts +1 -1
  46. package/lib/enumOptionsSelectValue.js +2 -2
  47. package/lib/enumOptionsSelectValue.js.map +1 -1
  48. package/lib/enumOptionsValueForIndex.d.ts +1 -1
  49. package/lib/enumOptionsValueForIndex.js.map +1 -1
  50. package/lib/enums.d.ts +2 -0
  51. package/lib/enums.js +2 -0
  52. package/lib/enums.js.map +1 -1
  53. package/lib/findSchemaDefinition.d.ts +1 -1
  54. package/lib/findSchemaDefinition.js +2 -2
  55. package/lib/findSchemaDefinition.js.map +1 -1
  56. package/lib/getChangedFields.d.ts +17 -0
  57. package/lib/getChangedFields.js +42 -0
  58. package/lib/getChangedFields.js.map +1 -0
  59. package/lib/getDateElementProps.d.ts +1 -1
  60. package/lib/getDateElementProps.js.map +1 -1
  61. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  62. package/lib/getDiscriminatorFieldFromSchema.js +4 -3
  63. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  64. package/lib/getInputProps.d.ts +1 -1
  65. package/lib/getInputProps.js +4 -1
  66. package/lib/getInputProps.js.map +1 -1
  67. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  68. package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
  69. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  70. package/lib/getSchemaType.d.ts +2 -1
  71. package/lib/getSchemaType.js +3 -2
  72. package/lib/getSchemaType.js.map +1 -1
  73. package/lib/getSubmitButtonOptions.d.ts +1 -1
  74. package/lib/getSubmitButtonOptions.js +2 -2
  75. package/lib/getSubmitButtonOptions.js.map +1 -1
  76. package/lib/getTemplate.d.ts +1 -1
  77. package/lib/getTemplate.js +9 -0
  78. package/lib/getTemplate.js.map +1 -1
  79. package/lib/getTestIds.d.ts +17 -0
  80. package/lib/getTestIds.js +34 -0
  81. package/lib/getTestIds.js.map +1 -0
  82. package/lib/getUiOptions.d.ts +1 -1
  83. package/lib/getUiOptions.js +2 -2
  84. package/lib/getUiOptions.js.map +1 -1
  85. package/lib/getWidget.d.ts +1 -1
  86. package/lib/getWidget.js +3 -3
  87. package/lib/getWidget.js.map +1 -1
  88. package/lib/guessType.d.ts +1 -1
  89. package/lib/guessType.js.map +1 -1
  90. package/lib/hasWidget.d.ts +1 -1
  91. package/lib/hasWidget.js +1 -1
  92. package/lib/hasWidget.js.map +1 -1
  93. package/lib/hashForSchema.d.ts +23 -1
  94. package/lib/hashForSchema.js +24 -6
  95. package/lib/hashForSchema.js.map +1 -1
  96. package/lib/idGenerators.d.ts +8 -1
  97. package/lib/idGenerators.js +11 -2
  98. package/lib/idGenerators.js.map +1 -1
  99. package/lib/index.d.ts +63 -60
  100. package/lib/index.js +63 -60
  101. package/lib/index.js.map +1 -1
  102. package/lib/isConstant.d.ts +1 -1
  103. package/lib/isConstant.js +1 -1
  104. package/lib/isCustomWidget.d.ts +1 -1
  105. package/lib/isCustomWidget.js +1 -1
  106. package/lib/isFixedItems.d.ts +1 -1
  107. package/lib/isFixedItems.js +1 -1
  108. package/lib/isObject.d.ts +2 -2
  109. package/lib/isObject.js +11 -4
  110. package/lib/isObject.js.map +1 -1
  111. package/lib/lookupFromFormContext.d.ts +11 -0
  112. package/lib/lookupFromFormContext.js +20 -0
  113. package/lib/lookupFromFormContext.js.map +1 -0
  114. package/lib/mergeDefaultsWithFormData.d.ts +8 -2
  115. package/lib/mergeDefaultsWithFormData.js +39 -10
  116. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  117. package/lib/mergeObjects.d.ts +1 -1
  118. package/lib/mergeObjects.js +1 -1
  119. package/lib/mergeObjects.js.map +1 -1
  120. package/lib/mergeSchemas.d.ts +1 -1
  121. package/lib/mergeSchemas.js +4 -4
  122. package/lib/mergeSchemas.js.map +1 -1
  123. package/lib/optionsList.d.ts +9 -7
  124. package/lib/optionsList.js +30 -19
  125. package/lib/optionsList.js.map +1 -1
  126. package/lib/orderProperties.js.map +1 -1
  127. package/lib/pad.js.map +1 -1
  128. package/lib/parseDateString.d.ts +1 -1
  129. package/lib/parseDateString.js +1 -1
  130. package/lib/parseDateString.js.map +1 -1
  131. package/lib/parser/ParserValidator.d.ts +1 -1
  132. package/lib/parser/ParserValidator.js +6 -6
  133. package/lib/parser/ParserValidator.js.map +1 -1
  134. package/lib/parser/index.d.ts +2 -2
  135. package/lib/parser/index.js +1 -1
  136. package/lib/parser/schemaParser.d.ts +2 -2
  137. package/lib/parser/schemaParser.js +6 -6
  138. package/lib/parser/schemaParser.js.map +1 -1
  139. package/lib/rangeSpec.d.ts +2 -2
  140. package/lib/rangeSpec.js.map +1 -1
  141. package/lib/replaceStringParameters.js.map +1 -1
  142. package/lib/schema/findFieldInSchema.d.ts +19 -0
  143. package/lib/schema/findFieldInSchema.js +61 -0
  144. package/lib/schema/findFieldInSchema.js.map +1 -0
  145. package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
  146. package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
  147. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
  148. package/lib/schema/getClosestMatchingOption.d.ts +5 -3
  149. package/lib/schema/getClosestMatchingOption.js +28 -20
  150. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  151. package/lib/schema/getDefaultFormState.d.ts +60 -13
  152. package/lib/schema/getDefaultFormState.js +304 -166
  153. package/lib/schema/getDefaultFormState.js.map +1 -1
  154. package/lib/schema/getDisplayLabel.d.ts +3 -2
  155. package/lib/schema/getDisplayLabel.js +10 -9
  156. package/lib/schema/getDisplayLabel.js.map +1 -1
  157. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  158. package/lib/schema/getFirstMatchingOption.js +70 -2
  159. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  160. package/lib/schema/getFromSchema.d.ts +14 -0
  161. package/lib/schema/getFromSchema.js +39 -0
  162. package/lib/schema/getFromSchema.js.map +1 -0
  163. package/lib/schema/index.d.ts +15 -14
  164. package/lib/schema/index.js +15 -14
  165. package/lib/schema/index.js.map +1 -1
  166. package/lib/schema/isFilesArray.d.ts +3 -2
  167. package/lib/schema/isFilesArray.js +5 -4
  168. package/lib/schema/isFilesArray.js.map +1 -1
  169. package/lib/schema/isMultiSelect.d.ts +3 -2
  170. package/lib/schema/isMultiSelect.js +4 -3
  171. package/lib/schema/isMultiSelect.js.map +1 -1
  172. package/lib/schema/isSelect.d.ts +3 -2
  173. package/lib/schema/isSelect.js +5 -4
  174. package/lib/schema/isSelect.js.map +1 -1
  175. package/lib/schema/retrieveSchema.d.ts +28 -11
  176. package/lib/schema/retrieveSchema.js +142 -66
  177. package/lib/schema/retrieveSchema.js.map +1 -1
  178. package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
  179. package/lib/schema/sanitizeDataForNewSchema.js +12 -11
  180. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  181. package/lib/schema/toIdSchema.d.ts +3 -2
  182. package/lib/schema/toIdSchema.js +30 -27
  183. package/lib/schema/toIdSchema.js.map +1 -1
  184. package/lib/schema/toPathSchema.d.ts +3 -2
  185. package/lib/schema/toPathSchema.js +22 -20
  186. package/lib/schema/toPathSchema.js.map +1 -1
  187. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  188. package/lib/schemaRequiresTrueValue.js.map +1 -1
  189. package/lib/shouldRender.js +1 -1
  190. package/lib/toConstant.d.ts +1 -1
  191. package/lib/toConstant.js +1 -1
  192. package/lib/toConstant.js.map +1 -1
  193. package/lib/toDateString.d.ts +1 -1
  194. package/lib/toErrorList.d.ts +1 -1
  195. package/lib/toErrorList.js +2 -2
  196. package/lib/toErrorList.js.map +1 -1
  197. package/lib/toErrorSchema.d.ts +1 -1
  198. package/lib/toErrorSchema.js +2 -2
  199. package/lib/toErrorSchema.js.map +1 -1
  200. package/lib/tsconfig.tsbuildinfo +1 -1
  201. package/lib/types.d.ts +160 -131
  202. package/lib/unwrapErrorHandler.d.ts +1 -1
  203. package/lib/unwrapErrorHandler.js +1 -1
  204. package/lib/unwrapErrorHandler.js.map +1 -1
  205. package/lib/utcToLocal.js +1 -1
  206. package/lib/utcToLocal.js.map +1 -1
  207. package/lib/validationDataMerge.d.ts +1 -1
  208. package/lib/validationDataMerge.js +3 -3
  209. package/lib/validationDataMerge.js.map +1 -1
  210. package/lib/withIdRefPrefix.d.ts +1 -1
  211. package/lib/withIdRefPrefix.js +2 -2
  212. package/lib/withIdRefPrefix.js.map +1 -1
  213. package/package.json +36 -26
  214. package/src/ErrorSchemaBuilder.ts +15 -8
  215. package/src/canExpand.ts +2 -2
  216. package/src/constIsAjvDataReference.ts +17 -0
  217. package/src/constants.ts +12 -3
  218. package/src/createSchemaUtils.ts +140 -50
  219. package/src/dataURItoBlob.ts +1 -1
  220. package/src/dateRangeOptions.ts +1 -1
  221. package/src/enumOptionsDeselectValue.ts +4 -5
  222. package/src/enumOptionsIndexForValue.ts +1 -1
  223. package/src/enumOptionsIsSelected.ts +4 -5
  224. package/src/enumOptionsSelectValue.ts +1 -1
  225. package/src/enumOptionsValueForIndex.ts +1 -1
  226. package/src/enums.ts +2 -0
  227. package/src/findSchemaDefinition.ts +2 -2
  228. package/src/getChangedFields.ts +40 -0
  229. package/src/getDateElementProps.ts +2 -2
  230. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  231. package/src/getInputProps.ts +6 -2
  232. package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
  233. package/src/getSchemaType.ts +3 -2
  234. package/src/getSubmitButtonOptions.ts +1 -1
  235. package/src/getTemplate.ts +12 -1
  236. package/src/getTestIds.ts +40 -0
  237. package/src/getUiOptions.ts +2 -2
  238. package/src/getWidget.tsx +2 -2
  239. package/src/hasWidget.ts +1 -1
  240. package/src/hashForSchema.ts +26 -6
  241. package/src/idGenerators.ts +10 -0
  242. package/src/index.ts +21 -2
  243. package/src/isCustomWidget.ts +1 -1
  244. package/src/isObject.ts +12 -5
  245. package/src/labelValue.ts +2 -2
  246. package/src/lookupFromFormContext.ts +26 -0
  247. package/src/mergeDefaultsWithFormData.ts +54 -9
  248. package/src/mergeObjects.ts +24 -21
  249. package/src/optionsList.ts +31 -22
  250. package/src/parser/ParserValidator.ts +5 -5
  251. package/src/parser/schemaParser.ts +6 -6
  252. package/src/schema/findFieldInSchema.ts +138 -0
  253. package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
  254. package/src/schema/getClosestMatchingOption.ts +38 -11
  255. package/src/schema/getDefaultFormState.ts +447 -191
  256. package/src/schema/getDisplayLabel.ts +7 -4
  257. package/src/schema/getFirstMatchingOption.ts +79 -4
  258. package/src/schema/getFromSchema.ts +100 -0
  259. package/src/schema/index.ts +6 -4
  260. package/src/schema/isFilesArray.ts +18 -3
  261. package/src/schema/isMultiSelect.ts +10 -4
  262. package/src/schema/isSelect.ts +5 -3
  263. package/src/schema/retrieveSchema.ts +256 -75
  264. package/src/schema/sanitizeDataForNewSchema.ts +52 -11
  265. package/src/schema/toIdSchema.ts +69 -43
  266. package/src/schema/toPathSchema.ts +49 -16
  267. package/src/toErrorList.ts +2 -2
  268. package/src/types.ts +266 -174
  269. package/src/validationDataMerge.ts +1 -1
  270. package/src/withIdRefPrefix.ts +1 -1
  271. package/LICENSE.md +0 -201
  272. package/lib/schema/getMatchingOption.d.ts +0 -14
  273. package/lib/schema/getMatchingOption.js +0 -85
  274. package/lib/schema/getMatchingOption.js.map +0 -1
  275. package/lib/schema/mergeValidationData.d.ts +0 -14
  276. package/lib/schema/mergeValidationData.js +0 -28
  277. package/lib/schema/mergeValidationData.js.map +0 -1
  278. package/src/schema/getMatchingOption.ts +0 -103
  279. package/src/schema/mergeValidationData.ts +0 -38
@@ -1,5 +1,4 @@
1
1
  import get from 'lodash/get';
2
- import isEqual from 'lodash/isEqual';
3
2
  import set from 'lodash/set';
4
3
  import times from 'lodash/times';
5
4
  import transform from 'lodash/transform';
@@ -15,18 +14,28 @@ import {
15
14
  ANY_OF_KEY,
16
15
  DEPENDENCIES_KEY,
17
16
  IF_KEY,
17
+ ITEMS_KEY,
18
18
  ONE_OF_KEY,
19
- REF_KEY,
19
+ PATTERN_PROPERTIES_KEY,
20
20
  PROPERTIES_KEY,
21
- ITEMS_KEY,
21
+ REF_KEY,
22
22
  } from '../constants';
23
23
  import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';
24
24
  import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
25
25
  import guessType from '../guessType';
26
26
  import isObject from '../isObject';
27
27
  import mergeSchemas from '../mergeSchemas';
28
- import { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';
28
+ import {
29
+ Experimental_CustomMergeAllOf,
30
+ FormContextType,
31
+ GenericObjectType,
32
+ RJSFSchema,
33
+ StrictRJSFSchema,
34
+ ValidatorType,
35
+ } from '../types';
29
36
  import getFirstMatchingOption from './getFirstMatchingOption';
37
+ import deepEquals from '../deepEquals';
38
+ import isEmpty from 'lodash/isEmpty';
30
39
 
31
40
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
32
41
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
@@ -36,14 +45,29 @@ import getFirstMatchingOption from './getFirstMatchingOption';
36
45
  * @param schema - The schema for which retrieving a schema is desired
37
46
  * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
38
47
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
48
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
39
49
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
40
50
  */
41
51
  export default function retrieveSchema<
42
52
  T = any,
43
53
  S extends StrictRJSFSchema = RJSFSchema,
44
- F extends FormContextType = any
45
- >(validator: ValidatorType<T, S, F>, schema: S, rootSchema: S = {} as S, rawFormData?: T): S {
46
- return retrieveSchemaInternal<T, S, F>(validator, schema, rootSchema, rawFormData)[0];
54
+ F extends FormContextType = any,
55
+ >(
56
+ validator: ValidatorType<T, S, F>,
57
+ schema: S,
58
+ rootSchema: S = {} as S,
59
+ rawFormData?: T,
60
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
61
+ ): S {
62
+ return retrieveSchemaInternal<T, S, F>(
63
+ validator,
64
+ schema,
65
+ rootSchema,
66
+ rawFormData,
67
+ undefined,
68
+ undefined,
69
+ experimental_customMergeAllOf,
70
+ )[0];
47
71
  }
48
72
 
49
73
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
@@ -57,6 +81,7 @@ export default function retrieveSchema<
57
81
  * dependencies as a list of schemas
58
82
  * @param recurseList - The list of recursive references already processed
59
83
  * @param [formData] - The current formData to assist retrieving a schema
84
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
60
85
  * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded
61
86
  */
62
87
  export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -65,7 +90,8 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
65
90
  rootSchema: S,
66
91
  expandAllBranches: boolean,
67
92
  recurseList: string[],
68
- formData?: T
93
+ formData?: T,
94
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
69
95
  ): S[] {
70
96
  const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
71
97
 
@@ -75,12 +101,28 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
75
101
  if (expandAllBranches) {
76
102
  if (then && typeof then !== 'boolean') {
77
103
  schemas = schemas.concat(
78
- retrieveSchemaInternal<T, S, F>(validator, then as S, rootSchema, formData, expandAllBranches, recurseList)
104
+ retrieveSchemaInternal<T, S, F>(
105
+ validator,
106
+ then as S,
107
+ rootSchema,
108
+ formData,
109
+ expandAllBranches,
110
+ recurseList,
111
+ experimental_customMergeAllOf,
112
+ ),
79
113
  );
80
114
  }
81
115
  if (otherwise && typeof otherwise !== 'boolean') {
82
116
  schemas = schemas.concat(
83
- retrieveSchemaInternal<T, S, F>(validator, otherwise as S, rootSchema, formData, expandAllBranches, recurseList)
117
+ retrieveSchemaInternal<T, S, F>(
118
+ validator,
119
+ otherwise as S,
120
+ rootSchema,
121
+ formData,
122
+ expandAllBranches,
123
+ recurseList,
124
+ experimental_customMergeAllOf,
125
+ ),
84
126
  );
85
127
  }
86
128
  } else {
@@ -93,8 +135,9 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
93
135
  rootSchema,
94
136
  formData,
95
137
  expandAllBranches,
96
- recurseList
97
- )
138
+ recurseList,
139
+ experimental_customMergeAllOf,
140
+ ),
98
141
  );
99
142
  }
100
143
  }
@@ -102,7 +145,15 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
102
145
  resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s) as S);
103
146
  }
104
147
  return resolvedSchemas.flatMap((s) =>
105
- retrieveSchemaInternal<T, S, F>(validator, s, rootSchema, formData, expandAllBranches, recurseList)
148
+ retrieveSchemaInternal<T, S, F>(
149
+ validator,
150
+ s,
151
+ rootSchema,
152
+ formData,
153
+ expandAllBranches,
154
+ recurseList,
155
+ experimental_customMergeAllOf,
156
+ ),
106
157
  );
107
158
  }
108
159
 
@@ -131,12 +182,34 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
131
182
  permutations.forEach((permutation) => permutation.push(list[0]));
132
183
  return permutations;
133
184
  },
134
- [[]] as S[][] // Start with an empty list
185
+ [[]] as S[][], // Start with an empty list
135
186
  );
136
187
 
137
188
  return allPermutations;
138
189
  }
139
190
 
191
+ /** Returns the subset of 'patternProperties' specifications that match the given 'key'
192
+ *
193
+ * @param schema - The schema whose 'patternProperties' are to be filtered
194
+ * @param key - The key to match against the 'patternProperties' specifications
195
+ * @returns - The subset of 'patternProperties' specifications that match the given 'key'
196
+ */
197
+ export function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSchema>(
198
+ schema: S,
199
+ key: string,
200
+ ): Required<S['patternProperties']> {
201
+ return Object.keys(schema.patternProperties!)
202
+ .filter((pattern: string) => RegExp(pattern).test(key))
203
+ .reduce(
204
+ (obj, pattern) => {
205
+ // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path
206
+ set(obj, [pattern], schema.patternProperties![pattern]);
207
+ return obj;
208
+ },
209
+ {} as Required<S['patternProperties']>,
210
+ );
211
+ }
212
+
140
213
  /** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag
141
214
  * down to the `retrieveSchemaInternal()`, `resolveReference()` and `resolveDependencies()` helper calls. If
142
215
  * `expandAllBranches` is true, then all possible dependencies and/or allOf branches are returned.
@@ -148,6 +221,7 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
148
221
  * as a list of schemas
149
222
  * @param recurseList - The list of recursive references already processed
150
223
  * @param [formData] - The current formData, if any, to assist retrieving a schema
224
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
151
225
  * @returns - The list of schemas having its references, dependencies and allOf schemas resolved
152
226
  */
153
227
  export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -156,7 +230,8 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
156
230
  rootSchema: S,
157
231
  expandAllBranches: boolean,
158
232
  recurseList: string[],
159
- formData?: T
233
+ formData?: T,
234
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
160
235
  ): S[] {
161
236
  const updatedSchemas = resolveReference<T, S, F>(
162
237
  validator,
@@ -164,7 +239,7 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
164
239
  rootSchema,
165
240
  expandAllBranches,
166
241
  recurseList,
167
- formData
242
+ formData,
168
243
  );
169
244
  if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {
170
245
  // return the updatedSchemas array if it has either multiple schemas within it
@@ -178,10 +253,18 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
178
253
  rootSchema,
179
254
  expandAllBranches,
180
255
  recurseList,
181
- formData
256
+ formData,
182
257
  );
183
258
  return resolvedSchemas.flatMap((s) => {
184
- return retrieveSchemaInternal<T, S, F>(validator, s, rootSchema, formData, expandAllBranches, recurseList);
259
+ return retrieveSchemaInternal<T, S, F>(
260
+ validator,
261
+ s,
262
+ rootSchema,
263
+ formData,
264
+ expandAllBranches,
265
+ recurseList,
266
+ experimental_customMergeAllOf,
267
+ );
185
268
  });
186
269
  }
187
270
  if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
@@ -192,11 +275,15 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
192
275
  rootSchema,
193
276
  formData,
194
277
  expandAllBranches,
195
- recurseList
196
- )
278
+ recurseList,
279
+ experimental_customMergeAllOf,
280
+ ),
197
281
  );
198
282
  const allPermutations = getAllPermutationsOfXxxOf<S>(allOfSchemaElements);
199
- return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
283
+ return allPermutations.map((permutation) => ({
284
+ ...schema,
285
+ allOf: permutation,
286
+ }));
200
287
  }
201
288
  // No $ref or dependencies or allOf attribute was found, returning the original schema.
202
289
  return [schema];
@@ -213,6 +300,7 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
213
300
  * as a list of schemas
214
301
  * @param recurseList - The list of recursive references already processed
215
302
  * @param [formData] - The current formData, if any, to assist retrieving a schema
303
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
216
304
  * @returns - The list schemas retrieved after having all references resolved
217
305
  */
218
306
  export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -221,7 +309,8 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
221
309
  rootSchema: S,
222
310
  expandAllBranches: boolean,
223
311
  recurseList: string[],
224
- formData?: T
312
+ formData?: T,
313
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
225
314
  ): S[] {
226
315
  const updatedSchema = resolveAllReferences<S>(schema, rootSchema, recurseList);
227
316
  if (updatedSchema !== schema) {
@@ -232,7 +321,8 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
232
321
  rootSchema,
233
322
  formData,
234
323
  expandAllBranches,
235
- recurseList
324
+ recurseList,
325
+ experimental_customMergeAllOf,
236
326
  );
237
327
  }
238
328
  return [schema];
@@ -248,7 +338,7 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
248
338
  export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
249
339
  schema: S,
250
340
  rootSchema: S,
251
- recurseList: string[]
341
+ recurseList: string[],
252
342
  ): S {
253
343
  if (!isObject(schema)) {
254
344
  return schema;
@@ -276,7 +366,7 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
276
366
  result[key] = resolveAllReferences(value as S, rootSchema, childList);
277
367
  childrenLists.push(childList);
278
368
  },
279
- {} as RJSFSchema
369
+ {} as RJSFSchema,
280
370
  );
281
371
  merge(recurseList, uniq(flattenDeep(childrenLists)));
282
372
  resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
@@ -293,7 +383,7 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
293
383
  };
294
384
  }
295
385
 
296
- return isEqual(schema, resolvedSchema) ? schema : resolvedSchema;
386
+ return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
297
387
  }
298
388
 
299
389
  /** Creates new 'properties' items for each key in the `formData`
@@ -302,13 +392,20 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
302
392
  * @param theSchema - The schema for which the existing additional properties is desired
303
393
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator
304
394
  * @param [aFormData] - The current formData, if any, to assist retrieving a schema
395
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
305
396
  * @returns - The updated schema with additional properties stubbed
306
397
  */
307
398
  export function stubExistingAdditionalProperties<
308
399
  T = any,
309
400
  S extends StrictRJSFSchema = RJSFSchema,
310
- F extends FormContextType = any
311
- >(validator: ValidatorType<T, S, F>, theSchema: S, rootSchema?: S, aFormData?: T): S {
401
+ F extends FormContextType = any,
402
+ >(
403
+ validator: ValidatorType<T, S, F>,
404
+ theSchema: S,
405
+ rootSchema?: S,
406
+ aFormData?: T,
407
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
408
+ ): S {
312
409
  // Clone the schema so that we don't ruin the consumer's original
313
410
  const schema = {
314
411
  ...theSchema,
@@ -322,34 +419,55 @@ export function stubExistingAdditionalProperties<
322
419
  // No need to stub, our schema already has the property
323
420
  return;
324
421
  }
325
-
326
- let additionalProperties: S['additionalProperties'] = {};
327
- if (typeof schema.additionalProperties !== 'boolean') {
328
- if (REF_KEY in schema.additionalProperties!) {
329
- additionalProperties = retrieveSchema<T, S, F>(
422
+ if (PATTERN_PROPERTIES_KEY in schema) {
423
+ const matchingProperties = getMatchingPatternProperties(schema, key);
424
+ if (!isEmpty(matchingProperties)) {
425
+ schema.properties[key] = retrieveSchema<T, S, F>(
330
426
  validator,
331
- { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,
427
+ { allOf: Object.values(matchingProperties) } as S,
332
428
  rootSchema,
333
- formData as T
429
+ formData as T,
430
+ experimental_customMergeAllOf,
334
431
  );
335
- } else if ('type' in schema.additionalProperties!) {
336
- additionalProperties = { ...schema.additionalProperties };
337
- } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {
338
- additionalProperties = {
339
- type: 'object',
340
- ...schema.additionalProperties,
341
- };
432
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
433
+ return;
434
+ }
435
+ }
436
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {
437
+ let additionalProperties: S['additionalProperties'] = {};
438
+ if (typeof schema.additionalProperties !== 'boolean') {
439
+ if (REF_KEY in schema.additionalProperties!) {
440
+ additionalProperties = retrieveSchema<T, S, F>(
441
+ validator,
442
+ { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,
443
+ rootSchema,
444
+ formData as T,
445
+ experimental_customMergeAllOf,
446
+ );
447
+ } else if ('type' in schema.additionalProperties!) {
448
+ additionalProperties = { ...schema.additionalProperties };
449
+ } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {
450
+ additionalProperties = {
451
+ type: 'object',
452
+ ...schema.additionalProperties,
453
+ };
454
+ } else {
455
+ additionalProperties = { type: guessType(get(formData, [key])) };
456
+ }
342
457
  } else {
343
458
  additionalProperties = { type: guessType(get(formData, [key])) };
344
459
  }
460
+
461
+ // The type of our new key should match the additionalProperties value;
462
+ schema.properties[key] = additionalProperties;
463
+ // Set our additional property flag so we know it was dynamically added
464
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
345
465
  } else {
346
- additionalProperties = { type: guessType(get(formData, [key])) };
466
+ // Invalid property
467
+ schema.properties[key] = { type: 'null' };
468
+ // Set our additional property flag so we know it was dynamically added
469
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
347
470
  }
348
-
349
- // The type of our new key should match the additionalProperties value;
350
- schema.properties[key] = additionalProperties;
351
- // Set our additional property flag so we know it was dynamically added
352
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
353
471
  });
354
472
 
355
473
  return schema;
@@ -367,20 +485,22 @@ export function stubExistingAdditionalProperties<
367
485
  * @param [expandAllBranches=false] - Flag, if true, will return all possible branches of conditions, any/oneOf and
368
486
  * dependencies as a list of schemas
369
487
  * @param [recurseList=[]] - The optional, list of recursive references already processed
488
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
370
489
  * @returns - The schema(s) resulting from having its conditions, additional properties, references and dependencies
371
490
  * resolved. Multiple schemas may be returned if `expandAllBranches` is true.
372
491
  */
373
492
  export function retrieveSchemaInternal<
374
493
  T = any,
375
494
  S extends StrictRJSFSchema = RJSFSchema,
376
- F extends FormContextType = any
495
+ F extends FormContextType = any,
377
496
  >(
378
497
  validator: ValidatorType<T, S, F>,
379
498
  schema: S,
380
499
  rootSchema: S,
381
500
  rawFormData?: T,
382
501
  expandAllBranches = false,
383
- recurseList: string[] = []
502
+ recurseList: string[] = [],
503
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
384
504
  ): S[] {
385
505
  if (!isObject(schema)) {
386
506
  return [{} as S];
@@ -391,7 +511,8 @@ export function retrieveSchemaInternal<
391
511
  rootSchema,
392
512
  expandAllBranches,
393
513
  recurseList,
394
- rawFormData
514
+ rawFormData,
515
+ experimental_customMergeAllOf,
395
516
  );
396
517
  return resolvedSchemas.flatMap((s: S) => {
397
518
  let resolvedSchema = s;
@@ -402,7 +523,8 @@ export function retrieveSchemaInternal<
402
523
  rootSchema,
403
524
  expandAllBranches,
404
525
  recurseList,
405
- rawFormData as T
526
+ rawFormData as T,
527
+ experimental_customMergeAllOf,
406
528
  );
407
529
  }
408
530
  if (ALL_OF_KEY in resolvedSchema) {
@@ -412,19 +534,64 @@ export function retrieveSchemaInternal<
412
534
  return [...(allOf as S[]), restOfSchema as S];
413
535
  }
414
536
  try {
415
- resolvedSchema = mergeAllOf(resolvedSchema, {
416
- deep: false,
417
- } as Options) as S;
537
+ const withContainsSchemas = [] as S[];
538
+ const withoutContainsSchemas = [] as S[];
539
+ resolvedSchema.allOf?.forEach((s) => {
540
+ if (typeof s === 'object' && s.contains) {
541
+ withContainsSchemas.push(s as S);
542
+ } else {
543
+ withoutContainsSchemas.push(s as S);
544
+ }
545
+ });
546
+ if (withContainsSchemas.length) {
547
+ resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };
548
+ }
549
+ resolvedSchema = experimental_customMergeAllOf
550
+ ? experimental_customMergeAllOf(resolvedSchema)
551
+ : (mergeAllOf(resolvedSchema, {
552
+ deep: false,
553
+ } as Options) as S);
554
+ if (withContainsSchemas.length) {
555
+ resolvedSchema.allOf = withContainsSchemas;
556
+ }
418
557
  } catch (e) {
419
558
  console.warn('could not merge subschemas in allOf:\n', e);
420
559
  const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;
421
560
  return resolvedSchemaWithoutAllOf as S;
422
561
  }
423
562
  }
563
+ if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {
564
+ resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(
565
+ (schema, key) => {
566
+ const matchingProperties = getMatchingPatternProperties(schema, key);
567
+ if (!isEmpty(matchingProperties)) {
568
+ schema.properties[key] = retrieveSchema<T, S, F>(
569
+ validator,
570
+ { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,
571
+ rootSchema,
572
+ rawFormData as T,
573
+ experimental_customMergeAllOf,
574
+ );
575
+ }
576
+ return schema;
577
+ },
578
+ {
579
+ ...resolvedSchema,
580
+ properties: { ...resolvedSchema.properties },
581
+ },
582
+ );
583
+ }
424
584
  const hasAdditionalProperties =
425
- ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
585
+ PATTERN_PROPERTIES_KEY in resolvedSchema ||
586
+ (ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false);
426
587
  if (hasAdditionalProperties) {
427
- return stubExistingAdditionalProperties<T, S, F>(validator, resolvedSchema, rootSchema, rawFormData as T);
588
+ return stubExistingAdditionalProperties<T, S, F>(
589
+ validator,
590
+ resolvedSchema,
591
+ rootSchema,
592
+ rawFormData as T,
593
+ experimental_customMergeAllOf,
594
+ );
428
595
  }
429
596
 
430
597
  return resolvedSchema;
@@ -446,7 +613,7 @@ export function retrieveSchemaInternal<
446
613
  export function resolveAnyOrOneOfSchemas<
447
614
  T = any,
448
615
  S extends StrictRJSFSchema = RJSFSchema,
449
- F extends FormContextType = any
616
+ F extends FormContextType = any,
450
617
  >(validator: ValidatorType<T, S, F>, schema: S, rootSchema: S, expandAllBranches: boolean, rawFormData?: T) {
451
618
  let anyOrOneOf: S[] | undefined;
452
619
  const { oneOf, anyOf, ...remaining } = schema;
@@ -484,6 +651,7 @@ export function resolveAnyOrOneOfSchemas<
484
651
  * as a list of schemas
485
652
  * @param recurseList - The list of recursive references already processed
486
653
  * @param [formData] - The current formData, if any, to assist retrieving a schema
654
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
487
655
  * @returns - The list of schemas with their dependencies resolved
488
656
  */
489
657
  export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -492,7 +660,8 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
492
660
  rootSchema: S,
493
661
  expandAllBranches: boolean,
494
662
  recurseList: string[],
495
- formData?: T
663
+ formData?: T,
664
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
496
665
  ): S[] {
497
666
  // Drop the dependencies from the source schema.
498
667
  const { dependencies, ...remainingSchema } = schema;
@@ -501,7 +670,7 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
501
670
  remainingSchema as S,
502
671
  rootSchema,
503
672
  expandAllBranches,
504
- formData
673
+ formData,
505
674
  );
506
675
  return resolvedSchemas.flatMap((resolvedSchema) =>
507
676
  processDependencies<T, S, F>(
@@ -511,8 +680,9 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
511
680
  rootSchema,
512
681
  expandAllBranches,
513
682
  recurseList,
514
- formData
515
- )
683
+ formData,
684
+ experimental_customMergeAllOf,
685
+ ),
516
686
  );
517
687
  }
518
688
 
@@ -527,6 +697,7 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
527
697
  * as a list of schemas
528
698
  * @param recurseList - The list of recursive references already processed
529
699
  * @param [formData] - The current formData, if any, to assist retrieving a schema
700
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
530
701
  * @returns - The schema with the `dependencies` resolved into it
531
702
  */
532
703
  export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -536,7 +707,8 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
536
707
  rootSchema: S,
537
708
  expandAllBranches: boolean,
538
709
  recurseList: string[],
539
- formData?: T
710
+ formData?: T,
711
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
540
712
  ): S[] {
541
713
  let schemas = [resolvedSchema];
542
714
  // Process dependencies updating the local schema properties as appropriate.
@@ -551,7 +723,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
551
723
  }
552
724
  const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
553
725
  dependencyKey,
554
- dependencies as GenericObjectType
726
+ dependencies as GenericObjectType,
555
727
  );
556
728
  if (Array.isArray(dependencyValue)) {
557
729
  schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);
@@ -564,7 +736,8 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
564
736
  dependencyValue as S,
565
737
  expandAllBranches,
566
738
  recurseList,
567
- formData
739
+ formData,
740
+ experimental_customMergeAllOf,
568
741
  );
569
742
  }
570
743
  return schemas.flatMap((schema) =>
@@ -575,8 +748,9 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
575
748
  rootSchema,
576
749
  expandAllBranches,
577
750
  recurseList,
578
- formData
579
- )
751
+ formData,
752
+ experimental_customMergeAllOf,
753
+ ),
580
754
  );
581
755
  }
582
756
  return schemas;
@@ -590,7 +764,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
590
764
  */
591
765
  export function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>(
592
766
  schema: S,
593
- additionallyRequired?: string[]
767
+ additionallyRequired?: string[],
594
768
  ) {
595
769
  if (!additionallyRequired) {
596
770
  return schema;
@@ -613,6 +787,7 @@ export function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>
613
787
  * as a list of schemas
614
788
  * @param recurseList - The list of recursive references already processed
615
789
  * @param [formData]- The current formData to assist retrieving a schema
790
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
616
791
  * @returns - The list of schemas with the dependent schema resolved into them
617
792
  */
618
793
  export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -623,7 +798,8 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
623
798
  dependencyValue: S,
624
799
  expandAllBranches: boolean,
625
800
  recurseList: string[],
626
- formData?: T
801
+ formData?: T,
802
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
627
803
  ): S[] {
628
804
  const dependentSchemas = retrieveSchemaInternal<T, S, F>(
629
805
  validator,
@@ -631,7 +807,8 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
631
807
  rootSchema,
632
808
  formData,
633
809
  expandAllBranches,
634
- recurseList
810
+ recurseList,
811
+ experimental_customMergeAllOf,
635
812
  );
636
813
  return dependentSchemas.flatMap((dependent) => {
637
814
  const { oneOf, ...dependentSchema } = dependent;
@@ -657,8 +834,9 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
657
834
  resolvedOneOf,
658
835
  expandAllBranches,
659
836
  recurseList,
660
- formData
661
- )
837
+ formData,
838
+ experimental_customMergeAllOf,
839
+ ),
662
840
  );
663
841
  });
664
842
  }
@@ -676,12 +854,13 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
676
854
  * as a list of schemas
677
855
  * @param recurseList - The list of recursive references already processed
678
856
  * @param [formData] - The current formData to assist retrieving a schema
857
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
679
858
  * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true
680
859
  */
681
860
  export function withExactlyOneSubschema<
682
861
  T = any,
683
862
  S extends StrictRJSFSchema = RJSFSchema,
684
- F extends FormContextType = any
863
+ F extends FormContextType = any,
685
864
  >(
686
865
  validator: ValidatorType<T, S, F>,
687
866
  schema: S,
@@ -690,7 +869,8 @@ export function withExactlyOneSubschema<
690
869
  oneOf: S['oneOf'],
691
870
  expandAllBranches: boolean,
692
871
  recurseList: string[],
693
- formData?: T
872
+ formData?: T,
873
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
694
874
  ): S[] {
695
875
  const validSubschemas = oneOf!.filter((subschema) => {
696
876
  if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
@@ -723,7 +903,8 @@ export function withExactlyOneSubschema<
723
903
  rootSchema,
724
904
  formData,
725
905
  expandAllBranches,
726
- recurseList
906
+ recurseList,
907
+ experimental_customMergeAllOf,
727
908
  );
728
909
  return schemas.map((s) => mergeSchemas(schema, s) as S);
729
910
  });