@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
package/lib/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ButtonHTMLAttributes, ChangeEvent, ComponentType, HTMLAttributes, ReactElement, ReactNode, StyleHTMLAttributes } from 'react';
2
2
  import { JSONSchema7 } from 'json-schema';
3
- import { TranslatableString } from './enums';
3
+ import { TranslatableString } from './enums.js';
4
4
  /** The representation of any generic object type, usually used as an intersection on other types to make them more
5
5
  * flexible in the properties they support (i.e. anything else)
6
6
  */
@@ -17,6 +17,9 @@ export type RJSFSchema = StrictRJSFSchema & GenericObjectType;
17
17
  /** Alias GenericObjectType as FormContextType to allow us to remap this at some future date
18
18
  */
19
19
  export type FormContextType = GenericObjectType;
20
+ /** The interface for the test ID proxy objects that are returned by the `getTestId` utility function.
21
+ */
22
+ export type TestIdShape = Record<string, string>;
20
23
  /** Experimental feature that specifies the Array `minItems` default form state behavior
21
24
  */
22
25
  export type Experimental_ArrayMinItems = {
@@ -47,7 +50,8 @@ export type Experimental_ArrayMinItems = {
47
50
  };
48
51
  /** Experimental features to specify different default form state behaviors. Currently, this affects the
49
52
  * handling of optional array fields where `minItems` is set and handling of setting defaults based on the
50
- * value of `emptyObjectFields`.
53
+ * value of `emptyObjectFields`. It also affects how `allOf` fields are handled and how to handle merging defaults into
54
+ * the formData in relation to explicit `undefined` values via `mergeDefaultsIntoFormData`.
51
55
  */
52
56
  export type Experimental_DefaultFormStateBehavior = {
53
57
  /** Optional object, that controls how the default form state for arrays with `minItems` is handled. When not provided
@@ -67,7 +71,33 @@ export type Experimental_DefaultFormStateBehavior = {
67
71
  * Optional flag to compute the default form state using allOf and if/then/else schemas. Defaults to `skipDefaults'.
68
72
  */
69
73
  allOf?: 'populateDefaults' | 'skipDefaults';
74
+ /** Optional enumerated flag controlling how the defaults are merged into the form data when dealing with undefined
75
+ * values, defaulting to `useFormDataIfPresent`.
76
+ * NOTE: If there is a default for a field and the `formData` is unspecified, the default ALWAYS merges.
77
+ * - `useFormDataIfPresent`: Legacy behavior - Do not merge defaults if there is a value for a field in `formData`,
78
+ * even if that value is explicitly set to `undefined`
79
+ * - `useDefaultIfFormDataUndefined`: - If the value of a field within the `formData` is `undefined`, then use the
80
+ * default value instead
81
+ */
82
+ mergeDefaultsIntoFormData?: 'useFormDataIfPresent' | 'useDefaultIfFormDataUndefined';
83
+ /** Optional enumerated flag controlling how const values are merged into the form data as defaults when dealing with
84
+ * undefined values, defaulting to `always`. The defaulting behavior for this flag will always be controlled by the
85
+ * `emptyObjectField` flag value. For instance, if `populateRequiredDefaults` is set and the const value is not
86
+ * required, it will not be set.
87
+ * - `always`: A const value will always be merged into the form as a default. If there is are const values in a
88
+ * `oneOf` (for instance to create an enumeration with title different from the values), the first const value
89
+ * will be defaulted
90
+ * - `skipOneOf`: If const is in a `oneOf` it will NOT pick the first value as a default
91
+ * - `never`: A const value will never be used as a default
92
+ *
93
+ */
94
+ constAsDefaults?: 'always' | 'skipOneOf' | 'never';
70
95
  };
96
+ /** Optional function that allows for custom merging of `allOf` schemas
97
+ * @param schema - Schema with `allOf` that needs to be merged
98
+ * @returns The merged schema
99
+ */
100
+ export type Experimental_CustomMergeAllOf<S extends StrictRJSFSchema = RJSFSchema> = (schema: S) => S;
71
101
  /** The interface representing a Date object that contains an optional time */
72
102
  export interface DateObject {
73
103
  /** The year of the Date */
@@ -100,6 +130,8 @@ export type InputPropsType = Omit<RangeSpecType, 'step'> & {
100
130
  step?: number | 'any';
101
131
  /** Specifies the `autoComplete` value for an <input> element */
102
132
  autoComplete?: HTMLInputElement['autocomplete'];
133
+ /** Specifies a filter for what file types the user can upload. */
134
+ accept?: HTMLInputElement['accept'];
103
135
  };
104
136
  /** Type describing an id used for a field in the `IdSchema` */
105
137
  export type FieldId = {
@@ -163,51 +195,51 @@ export type FieldValidation = FieldErrors & {
163
195
  export type FormValidation<T = any> = FieldValidation & {
164
196
  [key in keyof T]?: FormValidation<T[key]>;
165
197
  };
198
+ /** The base properties passed to various RJSF components. */
199
+ export type RJSFBaseProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
200
+ /** The schema object for the field being described */
201
+ schema: S;
202
+ /** The uiSchema object for this base component */
203
+ uiSchema?: UiSchema<T, S, F>;
204
+ /** The `registry` object */
205
+ registry: Registry<T, S, F>;
206
+ };
166
207
  /** The properties that are passed to an `ErrorListTemplate` implementation */
167
- export type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
208
+ export type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
168
209
  /** The errorSchema constructed by `Form` */
169
210
  errorSchema: ErrorSchema<T>;
170
211
  /** An array of the errors */
171
212
  errors: RJSFValidationError[];
172
213
  /** The `formContext` object that was passed to `Form` */
173
214
  formContext?: F;
174
- /** The schema that was passed to `Form` */
175
- schema: S;
176
- /** The uiSchema that was passed to `Form` */
177
- uiSchema?: UiSchema<T, S, F>;
178
- /** The `registry` object */
179
- registry: Registry<T, S, F>;
180
215
  };
181
216
  /** The properties that are passed to an `FieldErrorTemplate` implementation */
182
- export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
217
+ export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
183
218
  /** The errorSchema constructed by `Form` */
184
219
  errorSchema?: ErrorSchema<T>;
185
220
  /** An array of the errors */
186
221
  errors?: Array<string | ReactElement>;
187
222
  /** The tree of unique ids for every child field */
188
223
  idSchema: IdSchema<T>;
189
- /** The schema that was passed to field */
190
- schema: S;
191
- /** The uiSchema that was passed to field */
192
- uiSchema?: UiSchema<T, S, F>;
193
- /** The `registry` object */
194
- registry: Registry<T, S, F>;
195
224
  };
196
225
  /** The properties that are passed to an `FieldHelpTemplate` implementation */
197
- export type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
226
+ export type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
198
227
  /** The help information to be rendered */
199
228
  help?: string | ReactElement;
200
229
  /** The tree of unique ids for every child field */
201
230
  idSchema: IdSchema<T>;
202
- /** The schema that was passed to field */
203
- schema: S;
204
- /** The uiSchema that was passed to field */
205
- uiSchema?: UiSchema<T, S, F>;
206
231
  /** Flag indicating whether there are errors associated with this field */
207
232
  hasErrors?: boolean;
208
- /** The `registry` object */
209
- registry: Registry<T, S, F>;
210
233
  };
234
+ /** The properties that are passed to a `GridTemplate` */
235
+ export interface GridTemplateProps extends GenericObjectType {
236
+ /** The contents of the grid template */
237
+ children?: ReactNode;
238
+ /** Optional flag indicating whether the grid element represents a column, necessary for themes which have components
239
+ * for Rows vs Columns. NOTE: This is falsy by default when not specified
240
+ */
241
+ column?: boolean;
242
+ }
211
243
  /** The set of `Fields` stored in the `Registry` */
212
244
  export type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
213
245
  /** A `Field` indexed by `name` */
@@ -219,13 +251,15 @@ export type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema
219
251
  [name: string]: Widget<T, S, F>;
220
252
  };
221
253
  /** The set of RJSF templates that can be overridden by themes or users */
222
- export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
254
+ export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
223
255
  /** The template to use while rendering normal or fixed array fields */
224
256
  ArrayFieldTemplate: ComponentType<ArrayFieldTemplateProps<T, S, F>>;
225
257
  /** The template to use while rendering the description for an array field */
226
258
  ArrayFieldDescriptionTemplate: ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
259
+ /** The template to use while rendering the buttons for an item in an array field */
260
+ ArrayFieldItemButtonsTemplate: ComponentType<ArrayFieldItemButtonsTemplateType<T, S, F>>;
227
261
  /** The template to use while rendering an item in an array field */
228
- ArrayFieldItemTemplate: ComponentType<ArrayFieldTemplateItemType<T, S, F>>;
262
+ ArrayFieldItemTemplate: ComponentType<ArrayFieldItemTemplateType<T, S, F>>;
229
263
  /** The template to use while rendering the title for an array field */
230
264
  ArrayFieldTitleTemplate: ComponentType<ArrayFieldTitleProps<T, S, F>>;
231
265
  /** The template to use while rendering the standard html input */
@@ -240,6 +274,8 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
240
274
  FieldHelpTemplate: ComponentType<FieldHelpProps<T, S, F>>;
241
275
  /** The template to use while rendering a field */
242
276
  FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
277
+ /** The template to use to render a Grid element */
278
+ GridTemplate: ComponentType<GridTemplateProps>;
243
279
  /** The template to use while rendering an object */
244
280
  ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
245
281
  /** The template to use for rendering the title of a field */
@@ -263,11 +299,17 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
263
299
  /** The template to use for the Remove button used for AdditionalProperties and Array items */
264
300
  RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
265
301
  };
266
- }
302
+ } & {
303
+ /** Allow this to support any named `ComponentType` or an object of named `ComponentType`s */
304
+ [key: string]: ComponentType<any> | {
305
+ [key: string]: ComponentType<any>;
306
+ } | undefined;
307
+ };
267
308
  /** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
268
- * widget level when no field-level value of the option is provided.
309
+ * widget level when no field-level value of the option is provided. Extends GenericObjectType to support allowing users
310
+ * to provide any value they need for their customizations.
269
311
  */
270
- export type GlobalUISchemaOptions = {
312
+ export type GlobalUISchemaOptions = GenericObjectType & {
271
313
  /** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
272
314
  addable?: boolean;
273
315
  /** Flag, if set to `true`, array items can be copied (defaults to false) */
@@ -282,6 +324,9 @@ export type GlobalUISchemaOptions = {
282
324
  * This option allows you to change the separator between the original key name and the integer. Default is "-"
283
325
  */
284
326
  duplicateKeySuffixSeparator?: string;
327
+ /** Enables the displaying of description text that contains markdown
328
+ */
329
+ enableMarkdownInDescription?: boolean;
285
330
  };
286
331
  /** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
287
332
  * context, schema utils and templates.
@@ -313,11 +358,7 @@ export interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
313
358
  globalUiOptions?: GlobalUISchemaOptions;
314
359
  }
315
360
  /** The properties that are passed to a Field implementation */
316
- export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
317
- /** The JSON subschema object for this field */
318
- schema: S;
319
- /** The uiSchema for this field */
320
- uiSchema?: UiSchema<T, S, F>;
361
+ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
321
362
  /** The tree of unique ids for every child field */
322
363
  idSchema: IdSchema<T>;
323
364
  /** The data for this field */
@@ -354,13 +395,14 @@ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
354
395
  idSeparator?: string;
355
396
  /** An array of strings listing all generated error messages from encountered errors for this field */
356
397
  rawErrors?: string[];
357
- /** The `registry` object */
358
- registry: Registry<T, S, F>;
359
398
  }
360
399
  /** The definition of a React-based Field component */
361
- export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>>;
400
+ export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>> & {
401
+ /** The optional TEST_IDS block that some fields contain, exported for testing purposes */
402
+ TEST_IDS?: TestIdShape;
403
+ };
362
404
  /** The properties that are passed to a FieldTemplate implementation */
363
- export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
405
+ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
364
406
  /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
365
407
  id: string;
366
408
  /** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
@@ -401,10 +443,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
401
443
  * you don't want to clutter the UI
402
444
  */
403
445
  displayLabel?: boolean;
404
- /** The schema object for this field */
405
- schema: S;
406
- /** The uiSchema object for this field */
407
- uiSchema?: UiSchema<T, S, F>;
408
446
  /** The `formContext` object that was passed to `Form` */
409
447
  formContext?: F;
410
448
  /** The formData for this field */
@@ -415,47 +453,29 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
415
453
  onKeyChange: (value: string) => () => void;
416
454
  /** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
417
455
  onDropPropertyClick: (value: string) => () => void;
418
- /** The `registry` object */
419
- registry: Registry<T, S, F>;
420
456
  };
421
457
  /** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
422
- export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
423
- /** The schema object for this field */
424
- schema: S;
458
+ export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
425
459
  /** The tree of unique ids for every child field */
426
460
  idSchema?: IdSchema<T>;
427
461
  /** The reason why the schema field has an unsupported type */
428
462
  reason: string;
429
- /** The `registry` object */
430
- registry: Registry<T, S, F>;
431
463
  };
432
464
  /** The properties that are passed to a `TitleFieldTemplate` implementation */
433
- export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
465
+ export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
434
466
  /** The id of the field title in the hierarchy */
435
467
  id: string;
436
468
  /** The title for the field being rendered */
437
469
  title: string;
438
- /** The schema object for the field being titled */
439
- schema: S;
440
- /** The uiSchema object for this title field */
441
- uiSchema?: UiSchema<T, S, F>;
442
470
  /** A boolean value stating if the field is required */
443
471
  required?: boolean;
444
- /** The `registry` object */
445
- registry: Registry<T, S, F>;
446
472
  };
447
473
  /** The properties that are passed to a `DescriptionFieldTemplate` implementation */
448
- export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
474
+ export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
449
475
  /** The id of the field description in the hierarchy */
450
476
  id: string;
451
- /** The schema object for the field being described */
452
- schema: S;
453
- /** The uiSchema object for this description field */
454
- uiSchema?: UiSchema<T, S, F>;
455
477
  /** The description of the field being rendered */
456
478
  description: string | ReactElement;
457
- /** The `registry` object */
458
- registry: Registry<T, S, F>;
459
479
  };
460
480
  /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
461
481
  export type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
@@ -471,12 +491,14 @@ export type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJS
471
491
  /** The idSchema of the field in the hierarchy */
472
492
  idSchema: IdSchema<T>;
473
493
  };
474
- /** The properties of each element in the ArrayFieldTemplateProps.items array */
475
- export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
476
- /** The html for the item's content */
477
- children: ReactElement;
494
+ /** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
495
+ export type ArrayFieldItemButtonsTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
496
+ /** The idSchema of the item for which buttons are being rendered */
497
+ idSchema: IdSchema<T>;
478
498
  /** The className string */
479
- className: string;
499
+ className?: string;
500
+ /** Any optional style attributes */
501
+ style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];
480
502
  /** A boolean value stating if the array item is disabled */
481
503
  disabled?: boolean;
482
504
  /** A boolean value stating whether new items can be added to the array */
@@ -489,8 +511,6 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
489
511
  hasMoveUp: boolean;
490
512
  /** A boolean value stating whether the array item can be removed */
491
513
  hasRemove: boolean;
492
- /** A boolean value stating whether the array item has a toolbar */
493
- hasToolbar: boolean;
494
514
  /** A number stating the index the array item occurs in `items` */
495
515
  index: number;
496
516
  /** A number stating the total number `items` in the array */
@@ -505,17 +525,34 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
505
525
  onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
506
526
  /** A boolean value stating if the array item is read-only */
507
527
  readonly?: boolean;
528
+ };
529
+ /** The properties of each element in the ArrayFieldTemplateProps.items array */
530
+ export type ArrayFieldItemTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
531
+ /** The html for the item's content */
532
+ children: ReactNode;
533
+ /** The props to pass to the `ArrayFieldItemButtonTemplate` */
534
+ buttonsProps: ArrayFieldItemButtonsTemplateType<T, S, F>;
535
+ /** The className string */
536
+ className: string;
537
+ /** A boolean value stating if the array item is disabled */
538
+ disabled?: boolean;
539
+ /** A boolean value stating whether the array item has a toolbar */
540
+ hasToolbar: boolean;
541
+ /** A number stating the index the array item occurs in `items` */
542
+ index: number;
543
+ /** A number stating the total number `items` in the array */
544
+ totalItems: number;
545
+ /** A boolean value stating if the array item is read-only */
546
+ readonly?: boolean;
508
547
  /** A stable, unique key for the array item */
509
548
  key: string;
510
- /** The schema object for this array item */
511
- schema: S;
512
- /** The uiSchema object for this array item */
513
- uiSchema?: UiSchema<T, S, F>;
514
- /** The `registry` object */
515
- registry: Registry<T, S, F>;
516
549
  };
550
+ /**
551
+ * @deprecated - Use `ArrayFieldItemTemplateType` instead
552
+ */
553
+ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ArrayFieldItemTemplateType<T, S, F>;
517
554
  /** The properties that are passed to an ArrayFieldTemplate implementation */
518
- export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
555
+ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
519
556
  /** A boolean value stating whether new elements can be added to the array */
520
557
  canAdd?: boolean;
521
558
  /** The className string */
@@ -525,7 +562,7 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
525
562
  /** An object containing the id for this object & ids for its properties */
526
563
  idSchema: IdSchema<T>;
527
564
  /** An array of objects representing the items in the array */
528
- items: ArrayFieldTemplateItemType<T, S, F>[];
565
+ items: ArrayFieldItemTemplateType<T, S, F>[];
529
566
  /** A function that adds a new item to the array */
530
567
  onAddClick: (event?: any) => void;
531
568
  /** A boolean value stating if the array is read-only */
@@ -534,10 +571,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
534
571
  required?: boolean;
535
572
  /** A boolean value stating if the field is hiding its errors */
536
573
  hideError?: boolean;
537
- /** The schema object for this array */
538
- schema: S;
539
- /** The uiSchema object for this array field */
540
- uiSchema?: UiSchema<T, S, F>;
541
574
  /** A string value containing the title for the array */
542
575
  title: string;
543
576
  /** The `formContext` object that was passed to Form */
@@ -548,8 +581,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
548
581
  errorSchema?: ErrorSchema<T>;
549
582
  /** An array of strings listing all generated error messages from encountered errors for this widget */
550
583
  rawErrors?: string[];
551
- /** The `registry` object */
552
- registry: Registry<T, S, F>;
553
584
  };
554
585
  /** The properties of each element in the ObjectFieldTemplateProps.properties array */
555
586
  export type ObjectFieldTemplatePropertyType = {
@@ -565,11 +596,11 @@ export type ObjectFieldTemplatePropertyType = {
565
596
  hidden: boolean;
566
597
  };
567
598
  /** The properties that are passed to an ObjectFieldTemplate implementation */
568
- export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
599
+ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
569
600
  /** A string value containing the title for the object */
570
601
  title: string;
571
602
  /** A string value containing the description for the object */
572
- description?: string;
603
+ description?: string | ReactElement;
573
604
  /** A boolean value stating if the object is disabled */
574
605
  disabled?: boolean;
575
606
  /** An array of objects representing the properties in the object */
@@ -582,10 +613,6 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
582
613
  required?: boolean;
583
614
  /** A boolean value stating if the field is hiding its errors */
584
615
  hideError?: boolean;
585
- /** The schema object for this object */
586
- schema: S;
587
- /** The uiSchema object for this object field */
588
- uiSchema?: UiSchema<T, S, F>;
589
616
  /** An object containing the id for this object & ids for its properties */
590
617
  idSchema: IdSchema<T>;
591
618
  /** The optional validation errors in the form of an `ErrorSchema` */
@@ -594,16 +621,14 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
594
621
  formData?: T;
595
622
  /** The `formContext` object that was passed to Form */
596
623
  formContext?: F;
597
- /** The `registry` object */
598
- registry: Registry<T, S, F>;
599
624
  };
600
625
  /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
601
- export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
626
+ export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
602
627
  /** The field or widget component instance for this field row */
603
628
  children: ReactNode;
604
- } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
629
+ } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'hideError' | 'rawErrors' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
605
630
  /** The properties that are passed to a Widget implementation */
606
- export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
631
+ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
607
632
  /** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
608
633
  * widgets
609
634
  */
@@ -612,10 +637,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
612
637
  * of custom widgets.
613
638
  */
614
639
  name: string;
615
- /** The JSONSchema subschema object for this widget */
616
- schema: S;
617
- /** The uiSchema for this widget */
618
- uiSchema?: UiSchema<T, S, F>;
619
640
  /** The current value for this widget */
620
641
  value: any;
621
642
  /** The required status of this widget */
@@ -655,8 +676,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
655
676
  multiple?: boolean;
656
677
  /** An array of strings listing all generated error messages from encountered errors for this widget */
657
678
  rawErrors?: string[];
658
- /** The `registry` object */
659
- registry: Registry<T, S, F>;
660
679
  }
661
680
  /** The definition of a React-based Widget component */
662
681
  export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<WidgetProps<T, S, F>>;
@@ -676,15 +695,11 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
676
695
  registry: Registry<T, S, F>;
677
696
  };
678
697
  /** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
679
- export type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & {
698
+ export type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
680
699
  /** An alternative specification for the type of the icon button */
681
700
  iconType?: string;
682
701
  /** The name representation or actual react element implementation for the icon */
683
702
  icon?: string | ReactElement;
684
- /** The uiSchema for this widget */
685
- uiSchema?: UiSchema<T, S, F>;
686
- /** The `registry` object */
687
- registry: Registry<T, S, F>;
688
703
  };
689
704
  /** The type that defines how to change the behavior of the submit button for the form */
690
705
  export type UISchemaSubmitButtonOptions = {
@@ -716,7 +731,11 @@ type MakeUIType<Type> = {
716
731
  /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
717
732
  * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
718
733
  */
719
- type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & GlobalUISchemaOptions & {
734
+ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Pick<TemplatesType<T, S, F>, 'ArrayFieldDescriptionTemplate' | 'ArrayFieldItemTemplate' | 'ArrayFieldTemplate' | 'ArrayFieldTitleTemplate' | 'BaseInputTemplate' | 'DescriptionFieldTemplate' | 'ErrorListTemplate' | 'FieldErrorTemplate' | 'FieldHelpTemplate' | 'FieldTemplate' | 'ObjectFieldTemplate' | 'TitleFieldTemplate' | 'UnsupportedFieldTemplate' | 'WrapIfAdditionalTemplate'>> & GlobalUISchemaOptions & {
735
+ /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
736
+ * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
737
+ */
738
+ field?: Field<T, S, F> | string;
720
739
  /** Any classnames that the user wants to be applied to a field in the ui */
721
740
  classNames?: string;
722
741
  /** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
@@ -739,6 +758,12 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
739
758
  emptyValue?: any;
740
759
  /** Will disable any of the enum options specified in the array (by value) */
741
760
  enumDisabled?: Array<string | number | boolean>;
761
+ /** Allows a user to provide a list of labels for enum values in the schema */
762
+ enumNames?: string[];
763
+ /** Provides an optional field within a schema to be used as the oneOf/anyOf selector when there isn't a
764
+ * discriminator
765
+ */
766
+ optionsSchemaSelector?: string;
742
767
  /** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
743
768
  * hierarchy
744
769
  */
@@ -761,8 +786,6 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
761
786
  * to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
762
787
  */
763
788
  widget?: Widget<T, S, F> | string;
764
- /** Allows a user to provide a list of labels for enum values in the schema */
765
- enumNames?: string[];
766
789
  };
767
790
  /** The type that represents the Options potentially provided by `ui:options` */
768
791
  export type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
@@ -779,10 +802,6 @@ export type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
779
802
  'ui:globalOptions'?: GlobalUISchemaOptions;
780
803
  /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
781
804
  'ui:rootFieldId'?: string;
782
- /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
783
- * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
784
- */
785
- 'ui:field'?: Field<T, S, F> | string;
786
805
  /** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
787
806
  * `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
788
807
  * related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
@@ -825,14 +844,6 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
825
844
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
826
845
  */
827
846
  validateFormData(formData: T | undefined, schema: S, customValidate?: CustomValidator<T, S, F>, transformErrors?: ErrorTransformer<T, S, F>, uiSchema?: UiSchema<T, S, F>): ValidationData<T>;
828
- /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
829
- *
830
- * @param errorSchema - The `ErrorSchema` instance to convert
831
- * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
832
- * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
833
- * the next major release.
834
- */
835
- toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
836
847
  /** Validates data against a schema, returning true if the data is valid, or
837
848
  * false otherwise. If the schema is invalid, then this function will return
838
849
  * false.
@@ -857,6 +868,14 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
857
868
  */
858
869
  reset?: () => void;
859
870
  }
871
+ /** The interface for the return value of the `findFieldInSchema` function
872
+ */
873
+ export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
874
+ /** The field that was found, or undefined if it wasn't */
875
+ field?: S;
876
+ /** The requiredness of the field found or undefined if it wasn't */
877
+ isRequired?: boolean;
878
+ }
860
879
  /** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
861
880
  * directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
862
881
  * the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
@@ -875,9 +894,32 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
875
894
  * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
876
895
  * @param rootSchema - The root schema that will be compared against the current one
877
896
  * @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
897
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
878
898
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
879
899
  */
880
- doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior): boolean;
900
+ doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): boolean;
901
+ /** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
902
+ * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
903
+ * field is in the `required` list for its parent and if so, it is marked as required on return.
904
+ *
905
+ * @param schema - The current node within the JSON schema
906
+ * @param path - The remaining keys in the path to the desired field
907
+ * @param [formData] - The form data that is used to determine which oneOf option
908
+ * @returns - An object that contains the field and its required state. If no field can be found then
909
+ * `{ field: undefined, isRequired: undefined }` is returned.
910
+ */
911
+ findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
912
+ /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
913
+ * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
914
+ * `schema.discriminator.propertyName` or `fallbackField`.
915
+ *
916
+ * @param schema - The schema element in which to search for the selected oneOf option
917
+ * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
918
+ * @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
919
+ * @param [formData] - The form data that is used to determine which oneOf option
920
+ * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
921
+ */
922
+ findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData?: T): S | undefined;
881
923
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
882
924
  * computed to have defaults provided in the `schema`.
883
925
  *
@@ -922,17 +964,17 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
922
964
  * @returns - The firstindex of the matched option or 0 if none is available
923
965
  */
924
966
  getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
925
- /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
926
- * Deprecated, use `getFirstMatchingOption()` instead.
967
+ /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
968
+ * containing potentially nested `$ref`s.
927
969
  *
928
- * @param formData - The current formData, if any, onto which to provide any missing defaults
929
- * @param options - The list of options to find a matching options from
930
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
931
- * determine which option is selected
932
- * @returns - The index of the matched option or 0 if none is available
933
- * @deprecated
970
+ * @param schema - The current node within the JSON schema recursion
971
+ * @param path - The remaining keys in the path to the desired property
972
+ * @param defaultValue - The value to return if a value is not found for the `pathList` path
973
+ * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
934
974
  */
935
- getMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
975
+ getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
976
+ getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
977
+ getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
936
978
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
937
979
  *
938
980
  * @param schema - The schema for which check for array of files flag is desired
@@ -952,18 +994,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
952
994
  * @returns - True if schema contains a select, otherwise false
953
995
  */
954
996
  isSelect(schema: S): boolean;
955
- /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
956
- * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
957
- * `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
958
- * `validationData` is returned.
959
- *
960
- * @param validationData - The current `ValidationData` into which to merge the additional errors
961
- * @param [additionalErrorSchema] - The additional set of errors
962
- * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided
963
- * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
964
- * removed in the next major release.
965
- */
966
- mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
967
997
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
968
998
  * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
969
999
  * recursive resolution.
@@ -1,4 +1,4 @@
1
- import { ErrorSchema, FormValidation } from './types';
1
+ import { ErrorSchema, FormValidation } from './types.js';
2
2
  /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
3
3
  *
4
4
  * @param errorHandler - The `FormValidation` error handling structure
@@ -1,4 +1,4 @@
1
- import isPlainObject from 'lodash/isPlainObject';
1
+ import isPlainObject from 'lodash-es/isPlainObject.js';
2
2
  /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
3
3
  *
4
4
  * @param errorHandler - The `FormValidation` error handling structure