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

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 +1347 -642
  2. package/dist/index.js.map +4 -4
  3. package/dist/utils.esm.js +1324 -619
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +1266 -590
  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 +2 -2
  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 +15 -3
  20. package/lib/constants.js +15 -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 +5 -3
  54. package/lib/findSchemaDefinition.js +54 -11
  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 +316 -167
  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 +30 -12
  176. package/lib/schema/retrieveSchema.js +153 -70
  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 +172 -142
  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 +37 -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 +17 -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 +55 -10
  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 +461 -193
  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 +268 -78
  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 +278 -184
  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';
@@ -14,19 +13,30 @@ import {
14
13
  ALL_OF_KEY,
15
14
  ANY_OF_KEY,
16
15
  DEPENDENCIES_KEY,
16
+ ID_KEY,
17
17
  IF_KEY,
18
+ ITEMS_KEY,
18
19
  ONE_OF_KEY,
19
- REF_KEY,
20
+ PATTERN_PROPERTIES_KEY,
20
21
  PROPERTIES_KEY,
21
- ITEMS_KEY,
22
+ REF_KEY,
22
23
  } from '../constants';
23
24
  import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';
24
25
  import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
25
26
  import guessType from '../guessType';
26
27
  import isObject from '../isObject';
27
28
  import mergeSchemas from '../mergeSchemas';
28
- import { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';
29
+ import {
30
+ Experimental_CustomMergeAllOf,
31
+ FormContextType,
32
+ GenericObjectType,
33
+ RJSFSchema,
34
+ StrictRJSFSchema,
35
+ ValidatorType,
36
+ } from '../types';
29
37
  import getFirstMatchingOption from './getFirstMatchingOption';
38
+ import deepEquals from '../deepEquals';
39
+ import isEmpty from 'lodash/isEmpty';
30
40
 
31
41
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
32
42
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
@@ -36,14 +46,29 @@ import getFirstMatchingOption from './getFirstMatchingOption';
36
46
  * @param schema - The schema for which retrieving a schema is desired
37
47
  * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
38
48
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
49
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
39
50
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
40
51
  */
41
52
  export default function retrieveSchema<
42
53
  T = any,
43
54
  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];
55
+ F extends FormContextType = any,
56
+ >(
57
+ validator: ValidatorType<T, S, F>,
58
+ schema: S,
59
+ rootSchema: S = {} as S,
60
+ rawFormData?: T,
61
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
62
+ ): S {
63
+ return retrieveSchemaInternal<T, S, F>(
64
+ validator,
65
+ schema,
66
+ rootSchema,
67
+ rawFormData,
68
+ undefined,
69
+ undefined,
70
+ experimental_customMergeAllOf,
71
+ )[0];
47
72
  }
48
73
 
49
74
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
@@ -57,6 +82,7 @@ export default function retrieveSchema<
57
82
  * dependencies as a list of schemas
58
83
  * @param recurseList - The list of recursive references already processed
59
84
  * @param [formData] - The current formData to assist retrieving a schema
85
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
60
86
  * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded
61
87
  */
62
88
  export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -65,7 +91,8 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
65
91
  rootSchema: S,
66
92
  expandAllBranches: boolean,
67
93
  recurseList: string[],
68
- formData?: T
94
+ formData?: T,
95
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
69
96
  ): S[] {
70
97
  const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
71
98
 
@@ -75,12 +102,28 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
75
102
  if (expandAllBranches) {
76
103
  if (then && typeof then !== 'boolean') {
77
104
  schemas = schemas.concat(
78
- retrieveSchemaInternal<T, S, F>(validator, then as S, rootSchema, formData, expandAllBranches, recurseList)
105
+ retrieveSchemaInternal<T, S, F>(
106
+ validator,
107
+ then as S,
108
+ rootSchema,
109
+ formData,
110
+ expandAllBranches,
111
+ recurseList,
112
+ experimental_customMergeAllOf,
113
+ ),
79
114
  );
80
115
  }
81
116
  if (otherwise && typeof otherwise !== 'boolean') {
82
117
  schemas = schemas.concat(
83
- retrieveSchemaInternal<T, S, F>(validator, otherwise as S, rootSchema, formData, expandAllBranches, recurseList)
118
+ retrieveSchemaInternal<T, S, F>(
119
+ validator,
120
+ otherwise as S,
121
+ rootSchema,
122
+ formData,
123
+ expandAllBranches,
124
+ recurseList,
125
+ experimental_customMergeAllOf,
126
+ ),
84
127
  );
85
128
  }
86
129
  } else {
@@ -93,8 +136,9 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
93
136
  rootSchema,
94
137
  formData,
95
138
  expandAllBranches,
96
- recurseList
97
- )
139
+ recurseList,
140
+ experimental_customMergeAllOf,
141
+ ),
98
142
  );
99
143
  }
100
144
  }
@@ -102,7 +146,15 @@ export function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchem
102
146
  resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s) as S);
103
147
  }
104
148
  return resolvedSchemas.flatMap((s) =>
105
- retrieveSchemaInternal<T, S, F>(validator, s, rootSchema, formData, expandAllBranches, recurseList)
149
+ retrieveSchemaInternal<T, S, F>(
150
+ validator,
151
+ s,
152
+ rootSchema,
153
+ formData,
154
+ expandAllBranches,
155
+ recurseList,
156
+ experimental_customMergeAllOf,
157
+ ),
106
158
  );
107
159
  }
108
160
 
@@ -131,12 +183,34 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
131
183
  permutations.forEach((permutation) => permutation.push(list[0]));
132
184
  return permutations;
133
185
  },
134
- [[]] as S[][] // Start with an empty list
186
+ [[]] as S[][], // Start with an empty list
135
187
  );
136
188
 
137
189
  return allPermutations;
138
190
  }
139
191
 
192
+ /** Returns the subset of 'patternProperties' specifications that match the given 'key'
193
+ *
194
+ * @param schema - The schema whose 'patternProperties' are to be filtered
195
+ * @param key - The key to match against the 'patternProperties' specifications
196
+ * @returns - The subset of 'patternProperties' specifications that match the given 'key'
197
+ */
198
+ export function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSchema>(
199
+ schema: S,
200
+ key: string,
201
+ ): Required<S['patternProperties']> {
202
+ return Object.keys(schema.patternProperties!)
203
+ .filter((pattern: string) => RegExp(pattern).test(key))
204
+ .reduce(
205
+ (obj, pattern) => {
206
+ // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path
207
+ set(obj, [pattern], schema.patternProperties![pattern]);
208
+ return obj;
209
+ },
210
+ {} as Required<S['patternProperties']>,
211
+ );
212
+ }
213
+
140
214
  /** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag
141
215
  * down to the `retrieveSchemaInternal()`, `resolveReference()` and `resolveDependencies()` helper calls. If
142
216
  * `expandAllBranches` is true, then all possible dependencies and/or allOf branches are returned.
@@ -148,6 +222,7 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
148
222
  * as a list of schemas
149
223
  * @param recurseList - The list of recursive references already processed
150
224
  * @param [formData] - The current formData, if any, to assist retrieving a schema
225
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
151
226
  * @returns - The list of schemas having its references, dependencies and allOf schemas resolved
152
227
  */
153
228
  export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -156,7 +231,8 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
156
231
  rootSchema: S,
157
232
  expandAllBranches: boolean,
158
233
  recurseList: string[],
159
- formData?: T
234
+ formData?: T,
235
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
160
236
  ): S[] {
161
237
  const updatedSchemas = resolveReference<T, S, F>(
162
238
  validator,
@@ -164,7 +240,7 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
164
240
  rootSchema,
165
241
  expandAllBranches,
166
242
  recurseList,
167
- formData
243
+ formData,
168
244
  );
169
245
  if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {
170
246
  // return the updatedSchemas array if it has either multiple schemas within it
@@ -178,10 +254,18 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
178
254
  rootSchema,
179
255
  expandAllBranches,
180
256
  recurseList,
181
- formData
257
+ formData,
182
258
  );
183
259
  return resolvedSchemas.flatMap((s) => {
184
- return retrieveSchemaInternal<T, S, F>(validator, s, rootSchema, formData, expandAllBranches, recurseList);
260
+ return retrieveSchemaInternal<T, S, F>(
261
+ validator,
262
+ s,
263
+ rootSchema,
264
+ formData,
265
+ expandAllBranches,
266
+ recurseList,
267
+ experimental_customMergeAllOf,
268
+ );
185
269
  });
186
270
  }
187
271
  if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
@@ -192,11 +276,15 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
192
276
  rootSchema,
193
277
  formData,
194
278
  expandAllBranches,
195
- recurseList
196
- )
279
+ recurseList,
280
+ experimental_customMergeAllOf,
281
+ ),
197
282
  );
198
283
  const allPermutations = getAllPermutationsOfXxxOf<S>(allOfSchemaElements);
199
- return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
284
+ return allPermutations.map((permutation) => ({
285
+ ...schema,
286
+ allOf: permutation,
287
+ }));
200
288
  }
201
289
  // No $ref or dependencies or allOf attribute was found, returning the original schema.
202
290
  return [schema];
@@ -213,6 +301,7 @@ export function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema,
213
301
  * as a list of schemas
214
302
  * @param recurseList - The list of recursive references already processed
215
303
  * @param [formData] - The current formData, if any, to assist retrieving a schema
304
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
216
305
  * @returns - The list schemas retrieved after having all references resolved
217
306
  */
218
307
  export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -221,7 +310,8 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
221
310
  rootSchema: S,
222
311
  expandAllBranches: boolean,
223
312
  recurseList: string[],
224
- formData?: T
313
+ formData?: T,
314
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
225
315
  ): S[] {
226
316
  const updatedSchema = resolveAllReferences<S>(schema, rootSchema, recurseList);
227
317
  if (updatedSchema !== schema) {
@@ -232,7 +322,8 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
232
322
  rootSchema,
233
323
  formData,
234
324
  expandAllBranches,
235
- recurseList
325
+ recurseList,
326
+ experimental_customMergeAllOf,
236
327
  );
237
328
  }
238
329
  return [schema];
@@ -243,12 +334,14 @@ export function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchem
243
334
  * @param schema - The schema for which resolving all references is desired
244
335
  * @param rootSchema - The root schema that will be forwarded to all the APIs
245
336
  * @param recurseList - List of $refs already resolved to prevent recursion
337
+ * @param [baseURI] - The base URI to be used for resolving relative references
246
338
  * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved
247
339
  */
248
340
  export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
249
341
  schema: S,
250
342
  rootSchema: S,
251
- recurseList: string[]
343
+ recurseList: string[],
344
+ baseURI?: string,
252
345
  ): S {
253
346
  if (!isObject(schema)) {
254
347
  return schema;
@@ -263,8 +356,11 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
263
356
  }
264
357
  recurseList.push($ref!);
265
358
  // Retrieve the referenced schema definition.
266
- const refSchema = findSchemaDefinition<S>($ref, rootSchema);
359
+ const refSchema = findSchemaDefinition<S>($ref, rootSchema, baseURI);
267
360
  resolvedSchema = { ...refSchema, ...localSchema };
361
+ if (ID_KEY in resolvedSchema) {
362
+ baseURI = resolvedSchema[ID_KEY];
363
+ }
268
364
  }
269
365
 
270
366
  if (PROPERTIES_KEY in resolvedSchema) {
@@ -273,10 +369,10 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
273
369
  resolvedSchema[PROPERTIES_KEY]!,
274
370
  (result, value, key: string) => {
275
371
  const childList: string[] = [...recurseList];
276
- result[key] = resolveAllReferences(value as S, rootSchema, childList);
372
+ result[key] = resolveAllReferences(value as S, rootSchema, childList, baseURI);
277
373
  childrenLists.push(childList);
278
374
  },
279
- {} as RJSFSchema
375
+ {} as RJSFSchema,
280
376
  );
281
377
  merge(recurseList, uniq(flattenDeep(childrenLists)));
282
378
  resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
@@ -289,11 +385,11 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
289
385
  ) {
290
386
  resolvedSchema = {
291
387
  ...resolvedSchema,
292
- items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList),
388
+ items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList, baseURI),
293
389
  };
294
390
  }
295
391
 
296
- return isEqual(schema, resolvedSchema) ? schema : resolvedSchema;
392
+ return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
297
393
  }
298
394
 
299
395
  /** Creates new 'properties' items for each key in the `formData`
@@ -302,13 +398,20 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
302
398
  * @param theSchema - The schema for which the existing additional properties is desired
303
399
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator
304
400
  * @param [aFormData] - The current formData, if any, to assist retrieving a schema
401
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
305
402
  * @returns - The updated schema with additional properties stubbed
306
403
  */
307
404
  export function stubExistingAdditionalProperties<
308
405
  T = any,
309
406
  S extends StrictRJSFSchema = RJSFSchema,
310
- F extends FormContextType = any
311
- >(validator: ValidatorType<T, S, F>, theSchema: S, rootSchema?: S, aFormData?: T): S {
407
+ F extends FormContextType = any,
408
+ >(
409
+ validator: ValidatorType<T, S, F>,
410
+ theSchema: S,
411
+ rootSchema?: S,
412
+ aFormData?: T,
413
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
414
+ ): S {
312
415
  // Clone the schema so that we don't ruin the consumer's original
313
416
  const schema = {
314
417
  ...theSchema,
@@ -322,34 +425,55 @@ export function stubExistingAdditionalProperties<
322
425
  // No need to stub, our schema already has the property
323
426
  return;
324
427
  }
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>(
428
+ if (PATTERN_PROPERTIES_KEY in schema) {
429
+ const matchingProperties = getMatchingPatternProperties(schema, key);
430
+ if (!isEmpty(matchingProperties)) {
431
+ schema.properties[key] = retrieveSchema<T, S, F>(
330
432
  validator,
331
- { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,
433
+ { allOf: Object.values(matchingProperties) } as S,
332
434
  rootSchema,
333
- formData as T
435
+ get(formData, [key]) as T,
436
+ experimental_customMergeAllOf,
334
437
  );
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
- };
438
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
439
+ return;
440
+ }
441
+ }
442
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {
443
+ let additionalProperties: S['additionalProperties'] = {};
444
+ if (typeof schema.additionalProperties !== 'boolean') {
445
+ if (REF_KEY in schema.additionalProperties!) {
446
+ additionalProperties = retrieveSchema<T, S, F>(
447
+ validator,
448
+ { $ref: get(schema.additionalProperties, [REF_KEY]) } as S,
449
+ rootSchema,
450
+ formData as T,
451
+ experimental_customMergeAllOf,
452
+ );
453
+ } else if ('type' in schema.additionalProperties!) {
454
+ additionalProperties = { ...schema.additionalProperties };
455
+ } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {
456
+ additionalProperties = {
457
+ type: 'object',
458
+ ...schema.additionalProperties,
459
+ };
460
+ } else {
461
+ additionalProperties = { type: guessType(get(formData, [key])) };
462
+ }
342
463
  } else {
343
464
  additionalProperties = { type: guessType(get(formData, [key])) };
344
465
  }
466
+
467
+ // The type of our new key should match the additionalProperties value;
468
+ schema.properties[key] = additionalProperties;
469
+ // Set our additional property flag so we know it was dynamically added
470
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
345
471
  } else {
346
- additionalProperties = { type: guessType(get(formData, [key])) };
472
+ // Invalid property
473
+ schema.properties[key] = { type: 'null' };
474
+ // Set our additional property flag so we know it was dynamically added
475
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
347
476
  }
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
477
  });
354
478
 
355
479
  return schema;
@@ -367,20 +491,22 @@ export function stubExistingAdditionalProperties<
367
491
  * @param [expandAllBranches=false] - Flag, if true, will return all possible branches of conditions, any/oneOf and
368
492
  * dependencies as a list of schemas
369
493
  * @param [recurseList=[]] - The optional, list of recursive references already processed
494
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
370
495
  * @returns - The schema(s) resulting from having its conditions, additional properties, references and dependencies
371
496
  * resolved. Multiple schemas may be returned if `expandAllBranches` is true.
372
497
  */
373
498
  export function retrieveSchemaInternal<
374
499
  T = any,
375
500
  S extends StrictRJSFSchema = RJSFSchema,
376
- F extends FormContextType = any
501
+ F extends FormContextType = any,
377
502
  >(
378
503
  validator: ValidatorType<T, S, F>,
379
504
  schema: S,
380
505
  rootSchema: S,
381
506
  rawFormData?: T,
382
507
  expandAllBranches = false,
383
- recurseList: string[] = []
508
+ recurseList: string[] = [],
509
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
384
510
  ): S[] {
385
511
  if (!isObject(schema)) {
386
512
  return [{} as S];
@@ -391,7 +517,8 @@ export function retrieveSchemaInternal<
391
517
  rootSchema,
392
518
  expandAllBranches,
393
519
  recurseList,
394
- rawFormData
520
+ rawFormData,
521
+ experimental_customMergeAllOf,
395
522
  );
396
523
  return resolvedSchemas.flatMap((s: S) => {
397
524
  let resolvedSchema = s;
@@ -402,7 +529,8 @@ export function retrieveSchemaInternal<
402
529
  rootSchema,
403
530
  expandAllBranches,
404
531
  recurseList,
405
- rawFormData as T
532
+ rawFormData as T,
533
+ experimental_customMergeAllOf,
406
534
  );
407
535
  }
408
536
  if (ALL_OF_KEY in resolvedSchema) {
@@ -412,19 +540,67 @@ export function retrieveSchemaInternal<
412
540
  return [...(allOf as S[]), restOfSchema as S];
413
541
  }
414
542
  try {
415
- resolvedSchema = mergeAllOf(resolvedSchema, {
416
- deep: false,
417
- } as Options) as S;
543
+ const withContainsSchemas = [] as S[];
544
+ const withoutContainsSchemas = [] as S[];
545
+ resolvedSchema.allOf?.forEach((s) => {
546
+ if (typeof s === 'object' && s.contains) {
547
+ withContainsSchemas.push(s as S);
548
+ } else {
549
+ withoutContainsSchemas.push(s as S);
550
+ }
551
+ });
552
+ if (withContainsSchemas.length) {
553
+ resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };
554
+ }
555
+ resolvedSchema = experimental_customMergeAllOf
556
+ ? experimental_customMergeAllOf(resolvedSchema)
557
+ : (mergeAllOf(resolvedSchema, {
558
+ deep: false,
559
+ resolvers: {
560
+ $defs: mergeAllOf.options.resolvers.definitions,
561
+ },
562
+ } as Options) as S);
563
+ if (withContainsSchemas.length) {
564
+ resolvedSchema.allOf = withContainsSchemas;
565
+ }
418
566
  } catch (e) {
419
567
  console.warn('could not merge subschemas in allOf:\n', e);
420
568
  const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;
421
569
  return resolvedSchemaWithoutAllOf as S;
422
570
  }
423
571
  }
572
+ if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {
573
+ resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(
574
+ (schema, key) => {
575
+ const matchingProperties = getMatchingPatternProperties(schema, key);
576
+ if (!isEmpty(matchingProperties)) {
577
+ schema.properties[key] = retrieveSchema<T, S, F>(
578
+ validator,
579
+ { allOf: [schema.properties[key], ...Object.values(matchingProperties)] } as S,
580
+ rootSchema,
581
+ get(rawFormData, [key]) as T,
582
+ experimental_customMergeAllOf,
583
+ );
584
+ }
585
+ return schema;
586
+ },
587
+ {
588
+ ...resolvedSchema,
589
+ properties: { ...resolvedSchema.properties },
590
+ },
591
+ );
592
+ }
424
593
  const hasAdditionalProperties =
425
- ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
594
+ PATTERN_PROPERTIES_KEY in resolvedSchema ||
595
+ (ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false);
426
596
  if (hasAdditionalProperties) {
427
- return stubExistingAdditionalProperties<T, S, F>(validator, resolvedSchema, rootSchema, rawFormData as T);
597
+ return stubExistingAdditionalProperties<T, S, F>(
598
+ validator,
599
+ resolvedSchema,
600
+ rootSchema,
601
+ rawFormData as T,
602
+ experimental_customMergeAllOf,
603
+ );
428
604
  }
429
605
 
430
606
  return resolvedSchema;
@@ -446,7 +622,7 @@ export function retrieveSchemaInternal<
446
622
  export function resolveAnyOrOneOfSchemas<
447
623
  T = any,
448
624
  S extends StrictRJSFSchema = RJSFSchema,
449
- F extends FormContextType = any
625
+ F extends FormContextType = any,
450
626
  >(validator: ValidatorType<T, S, F>, schema: S, rootSchema: S, expandAllBranches: boolean, rawFormData?: T) {
451
627
  let anyOrOneOf: S[] | undefined;
452
628
  const { oneOf, anyOf, ...remaining } = schema;
@@ -484,6 +660,7 @@ export function resolveAnyOrOneOfSchemas<
484
660
  * as a list of schemas
485
661
  * @param recurseList - The list of recursive references already processed
486
662
  * @param [formData] - The current formData, if any, to assist retrieving a schema
663
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
487
664
  * @returns - The list of schemas with their dependencies resolved
488
665
  */
489
666
  export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -492,7 +669,8 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
492
669
  rootSchema: S,
493
670
  expandAllBranches: boolean,
494
671
  recurseList: string[],
495
- formData?: T
672
+ formData?: T,
673
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
496
674
  ): S[] {
497
675
  // Drop the dependencies from the source schema.
498
676
  const { dependencies, ...remainingSchema } = schema;
@@ -501,7 +679,7 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
501
679
  remainingSchema as S,
502
680
  rootSchema,
503
681
  expandAllBranches,
504
- formData
682
+ formData,
505
683
  );
506
684
  return resolvedSchemas.flatMap((resolvedSchema) =>
507
685
  processDependencies<T, S, F>(
@@ -511,8 +689,9 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
511
689
  rootSchema,
512
690
  expandAllBranches,
513
691
  recurseList,
514
- formData
515
- )
692
+ formData,
693
+ experimental_customMergeAllOf,
694
+ ),
516
695
  );
517
696
  }
518
697
 
@@ -527,6 +706,7 @@ export function resolveDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
527
706
  * as a list of schemas
528
707
  * @param recurseList - The list of recursive references already processed
529
708
  * @param [formData] - The current formData, if any, to assist retrieving a schema
709
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
530
710
  * @returns - The schema with the `dependencies` resolved into it
531
711
  */
532
712
  export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -536,7 +716,8 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
536
716
  rootSchema: S,
537
717
  expandAllBranches: boolean,
538
718
  recurseList: string[],
539
- formData?: T
719
+ formData?: T,
720
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
540
721
  ): S[] {
541
722
  let schemas = [resolvedSchema];
542
723
  // Process dependencies updating the local schema properties as appropriate.
@@ -551,7 +732,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
551
732
  }
552
733
  const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
553
734
  dependencyKey,
554
- dependencies as GenericObjectType
735
+ dependencies as GenericObjectType,
555
736
  );
556
737
  if (Array.isArray(dependencyValue)) {
557
738
  schemas[0] = withDependentProperties<S>(resolvedSchema, dependencyValue);
@@ -564,7 +745,8 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
564
745
  dependencyValue as S,
565
746
  expandAllBranches,
566
747
  recurseList,
567
- formData
748
+ formData,
749
+ experimental_customMergeAllOf,
568
750
  );
569
751
  }
570
752
  return schemas.flatMap((schema) =>
@@ -575,8 +757,9 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
575
757
  rootSchema,
576
758
  expandAllBranches,
577
759
  recurseList,
578
- formData
579
- )
760
+ formData,
761
+ experimental_customMergeAllOf,
762
+ ),
580
763
  );
581
764
  }
582
765
  return schemas;
@@ -590,7 +773,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
590
773
  */
591
774
  export function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>(
592
775
  schema: S,
593
- additionallyRequired?: string[]
776
+ additionallyRequired?: string[],
594
777
  ) {
595
778
  if (!additionallyRequired) {
596
779
  return schema;
@@ -613,6 +796,7 @@ export function withDependentProperties<S extends StrictRJSFSchema = RJSFSchema>
613
796
  * as a list of schemas
614
797
  * @param recurseList - The list of recursive references already processed
615
798
  * @param [formData]- The current formData to assist retrieving a schema
799
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
616
800
  * @returns - The list of schemas with the dependent schema resolved into them
617
801
  */
618
802
  export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
@@ -623,7 +807,8 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
623
807
  dependencyValue: S,
624
808
  expandAllBranches: boolean,
625
809
  recurseList: string[],
626
- formData?: T
810
+ formData?: T,
811
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
627
812
  ): S[] {
628
813
  const dependentSchemas = retrieveSchemaInternal<T, S, F>(
629
814
  validator,
@@ -631,7 +816,8 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
631
816
  rootSchema,
632
817
  formData,
633
818
  expandAllBranches,
634
- recurseList
819
+ recurseList,
820
+ experimental_customMergeAllOf,
635
821
  );
636
822
  return dependentSchemas.flatMap((dependent) => {
637
823
  const { oneOf, ...dependentSchema } = dependent;
@@ -657,8 +843,9 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
657
843
  resolvedOneOf,
658
844
  expandAllBranches,
659
845
  recurseList,
660
- formData
661
- )
846
+ formData,
847
+ experimental_customMergeAllOf,
848
+ ),
662
849
  );
663
850
  });
664
851
  }
@@ -676,12 +863,13 @@ export function withDependentSchema<T = any, S extends StrictRJSFSchema = RJSFSc
676
863
  * as a list of schemas
677
864
  * @param recurseList - The list of recursive references already processed
678
865
  * @param [formData] - The current formData to assist retrieving a schema
866
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
679
867
  * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true
680
868
  */
681
869
  export function withExactlyOneSubschema<
682
870
  T = any,
683
871
  S extends StrictRJSFSchema = RJSFSchema,
684
- F extends FormContextType = any
872
+ F extends FormContextType = any,
685
873
  >(
686
874
  validator: ValidatorType<T, S, F>,
687
875
  schema: S,
@@ -690,7 +878,8 @@ export function withExactlyOneSubschema<
690
878
  oneOf: S['oneOf'],
691
879
  expandAllBranches: boolean,
692
880
  recurseList: string[],
693
- formData?: T
881
+ formData?: T,
882
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
694
883
  ): S[] {
695
884
  const validSubschemas = oneOf!.filter((subschema) => {
696
885
  if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
@@ -723,7 +912,8 @@ export function withExactlyOneSubschema<
723
912
  rootSchema,
724
913
  formData,
725
914
  expandAllBranches,
726
- recurseList
915
+ recurseList,
916
+ experimental_customMergeAllOf,
727
917
  );
728
918
  return schemas.map((s) => mergeSchemas(schema, s) as S);
729
919
  });