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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/dist/index.js +1281 -625
  2. package/dist/index.js.map +4 -4
  3. package/dist/utils.esm.js +1254 -598
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +1201 -570
  6. package/lib/ErrorSchemaBuilder.d.ts +8 -4
  7. package/lib/ErrorSchemaBuilder.js +10 -8
  8. package/lib/ErrorSchemaBuilder.js.map +1 -1
  9. package/lib/allowAdditionalItems.d.ts +1 -1
  10. package/lib/allowAdditionalItems.js +1 -1
  11. package/lib/allowAdditionalItems.js.map +1 -1
  12. package/lib/asNumber.js.map +1 -1
  13. package/lib/canExpand.d.ts +1 -1
  14. package/lib/canExpand.js +2 -2
  15. package/lib/canExpand.js.map +1 -1
  16. package/lib/constIsAjvDataReference.d.ts +9 -0
  17. package/lib/constIsAjvDataReference.js +15 -0
  18. package/lib/constIsAjvDataReference.js.map +1 -0
  19. package/lib/constants.d.ts +11 -3
  20. package/lib/constants.js +11 -3
  21. package/lib/constants.js.map +1 -1
  22. package/lib/createErrorHandler.d.ts +1 -1
  23. package/lib/createErrorHandler.js +2 -2
  24. package/lib/createErrorHandler.js.map +1 -1
  25. package/lib/createSchemaUtils.d.ts +3 -2
  26. package/lib/createSchemaUtils.js +56 -46
  27. package/lib/createSchemaUtils.js.map +1 -1
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +1 -1
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/deepEquals.js +1 -1
  33. package/lib/deepEquals.js.map +1 -1
  34. package/lib/englishStringTranslator.d.ts +1 -1
  35. package/lib/englishStringTranslator.js +1 -1
  36. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  37. package/lib/enumOptionsDeselectValue.js +4 -4
  38. package/lib/enumOptionsDeselectValue.js.map +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js +1 -1
  41. package/lib/enumOptionsIndexForValue.js.map +1 -1
  42. package/lib/enumOptionsIsSelected.d.ts +1 -1
  43. package/lib/enumOptionsIsSelected.js +3 -3
  44. package/lib/enumOptionsIsSelected.js.map +1 -1
  45. package/lib/enumOptionsSelectValue.d.ts +1 -1
  46. package/lib/enumOptionsSelectValue.js +2 -2
  47. package/lib/enumOptionsSelectValue.js.map +1 -1
  48. package/lib/enumOptionsValueForIndex.d.ts +1 -1
  49. package/lib/enumOptionsValueForIndex.js.map +1 -1
  50. package/lib/enums.d.ts +2 -0
  51. package/lib/enums.js +2 -0
  52. package/lib/enums.js.map +1 -1
  53. package/lib/findSchemaDefinition.d.ts +1 -1
  54. package/lib/findSchemaDefinition.js +2 -2
  55. package/lib/findSchemaDefinition.js.map +1 -1
  56. package/lib/getChangedFields.d.ts +17 -0
  57. package/lib/getChangedFields.js +42 -0
  58. package/lib/getChangedFields.js.map +1 -0
  59. package/lib/getDateElementProps.d.ts +1 -1
  60. package/lib/getDateElementProps.js.map +1 -1
  61. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  62. package/lib/getDiscriminatorFieldFromSchema.js +4 -3
  63. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  64. package/lib/getInputProps.d.ts +1 -1
  65. package/lib/getInputProps.js +4 -1
  66. package/lib/getInputProps.js.map +1 -1
  67. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  68. package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
  69. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  70. package/lib/getSchemaType.d.ts +2 -1
  71. package/lib/getSchemaType.js +3 -2
  72. package/lib/getSchemaType.js.map +1 -1
  73. package/lib/getSubmitButtonOptions.d.ts +1 -1
  74. package/lib/getSubmitButtonOptions.js +2 -2
  75. package/lib/getSubmitButtonOptions.js.map +1 -1
  76. package/lib/getTemplate.d.ts +1 -1
  77. package/lib/getTemplate.js +9 -0
  78. package/lib/getTemplate.js.map +1 -1
  79. package/lib/getTestIds.d.ts +17 -0
  80. package/lib/getTestIds.js +34 -0
  81. package/lib/getTestIds.js.map +1 -0
  82. package/lib/getUiOptions.d.ts +1 -1
  83. package/lib/getUiOptions.js +2 -2
  84. package/lib/getUiOptions.js.map +1 -1
  85. package/lib/getWidget.d.ts +1 -1
  86. package/lib/getWidget.js +3 -3
  87. package/lib/getWidget.js.map +1 -1
  88. package/lib/guessType.d.ts +1 -1
  89. package/lib/guessType.js.map +1 -1
  90. package/lib/hasWidget.d.ts +1 -1
  91. package/lib/hasWidget.js +1 -1
  92. package/lib/hasWidget.js.map +1 -1
  93. package/lib/hashForSchema.d.ts +23 -1
  94. package/lib/hashForSchema.js +24 -6
  95. package/lib/hashForSchema.js.map +1 -1
  96. package/lib/idGenerators.d.ts +8 -1
  97. package/lib/idGenerators.js +11 -2
  98. package/lib/idGenerators.js.map +1 -1
  99. package/lib/index.d.ts +63 -60
  100. package/lib/index.js +63 -60
  101. package/lib/index.js.map +1 -1
  102. package/lib/isConstant.d.ts +1 -1
  103. package/lib/isConstant.js +1 -1
  104. package/lib/isCustomWidget.d.ts +1 -1
  105. package/lib/isCustomWidget.js +1 -1
  106. package/lib/isFixedItems.d.ts +1 -1
  107. package/lib/isFixedItems.js +1 -1
  108. package/lib/isObject.d.ts +2 -2
  109. package/lib/isObject.js +11 -4
  110. package/lib/isObject.js.map +1 -1
  111. package/lib/lookupFromFormContext.d.ts +11 -0
  112. package/lib/lookupFromFormContext.js +20 -0
  113. package/lib/lookupFromFormContext.js.map +1 -0
  114. package/lib/mergeDefaultsWithFormData.d.ts +8 -2
  115. package/lib/mergeDefaultsWithFormData.js +39 -10
  116. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  117. package/lib/mergeObjects.d.ts +1 -1
  118. package/lib/mergeObjects.js +1 -1
  119. package/lib/mergeObjects.js.map +1 -1
  120. package/lib/mergeSchemas.d.ts +1 -1
  121. package/lib/mergeSchemas.js +4 -4
  122. package/lib/mergeSchemas.js.map +1 -1
  123. package/lib/optionsList.d.ts +9 -7
  124. package/lib/optionsList.js +30 -19
  125. package/lib/optionsList.js.map +1 -1
  126. package/lib/orderProperties.js.map +1 -1
  127. package/lib/pad.js.map +1 -1
  128. package/lib/parseDateString.d.ts +1 -1
  129. package/lib/parseDateString.js +1 -1
  130. package/lib/parseDateString.js.map +1 -1
  131. package/lib/parser/ParserValidator.d.ts +1 -1
  132. package/lib/parser/ParserValidator.js +6 -6
  133. package/lib/parser/ParserValidator.js.map +1 -1
  134. package/lib/parser/index.d.ts +2 -2
  135. package/lib/parser/index.js +1 -1
  136. package/lib/parser/schemaParser.d.ts +2 -2
  137. package/lib/parser/schemaParser.js +6 -6
  138. package/lib/parser/schemaParser.js.map +1 -1
  139. package/lib/rangeSpec.d.ts +2 -2
  140. package/lib/rangeSpec.js.map +1 -1
  141. package/lib/replaceStringParameters.js.map +1 -1
  142. package/lib/schema/findFieldInSchema.d.ts +19 -0
  143. package/lib/schema/findFieldInSchema.js +61 -0
  144. package/lib/schema/findFieldInSchema.js.map +1 -0
  145. package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
  146. package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
  147. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
  148. package/lib/schema/getClosestMatchingOption.d.ts +5 -3
  149. package/lib/schema/getClosestMatchingOption.js +28 -20
  150. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  151. package/lib/schema/getDefaultFormState.d.ts +60 -13
  152. package/lib/schema/getDefaultFormState.js +304 -166
  153. package/lib/schema/getDefaultFormState.js.map +1 -1
  154. package/lib/schema/getDisplayLabel.d.ts +3 -2
  155. package/lib/schema/getDisplayLabel.js +10 -9
  156. package/lib/schema/getDisplayLabel.js.map +1 -1
  157. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  158. package/lib/schema/getFirstMatchingOption.js +70 -2
  159. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  160. package/lib/schema/getFromSchema.d.ts +14 -0
  161. package/lib/schema/getFromSchema.js +39 -0
  162. package/lib/schema/getFromSchema.js.map +1 -0
  163. package/lib/schema/index.d.ts +15 -14
  164. package/lib/schema/index.js +15 -14
  165. package/lib/schema/index.js.map +1 -1
  166. package/lib/schema/isFilesArray.d.ts +3 -2
  167. package/lib/schema/isFilesArray.js +5 -4
  168. package/lib/schema/isFilesArray.js.map +1 -1
  169. package/lib/schema/isMultiSelect.d.ts +3 -2
  170. package/lib/schema/isMultiSelect.js +4 -3
  171. package/lib/schema/isMultiSelect.js.map +1 -1
  172. package/lib/schema/isSelect.d.ts +3 -2
  173. package/lib/schema/isSelect.js +5 -4
  174. package/lib/schema/isSelect.js.map +1 -1
  175. package/lib/schema/retrieveSchema.d.ts +28 -11
  176. package/lib/schema/retrieveSchema.js +142 -66
  177. package/lib/schema/retrieveSchema.js.map +1 -1
  178. package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
  179. package/lib/schema/sanitizeDataForNewSchema.js +12 -11
  180. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  181. package/lib/schema/toIdSchema.d.ts +3 -2
  182. package/lib/schema/toIdSchema.js +30 -27
  183. package/lib/schema/toIdSchema.js.map +1 -1
  184. package/lib/schema/toPathSchema.d.ts +3 -2
  185. package/lib/schema/toPathSchema.js +22 -20
  186. package/lib/schema/toPathSchema.js.map +1 -1
  187. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  188. package/lib/schemaRequiresTrueValue.js.map +1 -1
  189. package/lib/shouldRender.js +1 -1
  190. package/lib/toConstant.d.ts +1 -1
  191. package/lib/toConstant.js +1 -1
  192. package/lib/toConstant.js.map +1 -1
  193. package/lib/toDateString.d.ts +1 -1
  194. package/lib/toErrorList.d.ts +1 -1
  195. package/lib/toErrorList.js +2 -2
  196. package/lib/toErrorList.js.map +1 -1
  197. package/lib/toErrorSchema.d.ts +1 -1
  198. package/lib/toErrorSchema.js +2 -2
  199. package/lib/toErrorSchema.js.map +1 -1
  200. package/lib/tsconfig.tsbuildinfo +1 -1
  201. package/lib/types.d.ts +160 -131
  202. package/lib/unwrapErrorHandler.d.ts +1 -1
  203. package/lib/unwrapErrorHandler.js +1 -1
  204. package/lib/unwrapErrorHandler.js.map +1 -1
  205. package/lib/utcToLocal.js +1 -1
  206. package/lib/utcToLocal.js.map +1 -1
  207. package/lib/validationDataMerge.d.ts +1 -1
  208. package/lib/validationDataMerge.js +3 -3
  209. package/lib/validationDataMerge.js.map +1 -1
  210. package/lib/withIdRefPrefix.d.ts +1 -1
  211. package/lib/withIdRefPrefix.js +2 -2
  212. package/lib/withIdRefPrefix.js.map +1 -1
  213. package/package.json +36 -26
  214. package/src/ErrorSchemaBuilder.ts +15 -8
  215. package/src/canExpand.ts +2 -2
  216. package/src/constIsAjvDataReference.ts +17 -0
  217. package/src/constants.ts +12 -3
  218. package/src/createSchemaUtils.ts +140 -50
  219. package/src/dataURItoBlob.ts +1 -1
  220. package/src/dateRangeOptions.ts +1 -1
  221. package/src/enumOptionsDeselectValue.ts +4 -5
  222. package/src/enumOptionsIndexForValue.ts +1 -1
  223. package/src/enumOptionsIsSelected.ts +4 -5
  224. package/src/enumOptionsSelectValue.ts +1 -1
  225. package/src/enumOptionsValueForIndex.ts +1 -1
  226. package/src/enums.ts +2 -0
  227. package/src/findSchemaDefinition.ts +2 -2
  228. package/src/getChangedFields.ts +40 -0
  229. package/src/getDateElementProps.ts +2 -2
  230. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  231. package/src/getInputProps.ts +6 -2
  232. package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
  233. package/src/getSchemaType.ts +3 -2
  234. package/src/getSubmitButtonOptions.ts +1 -1
  235. package/src/getTemplate.ts +12 -1
  236. package/src/getTestIds.ts +40 -0
  237. package/src/getUiOptions.ts +2 -2
  238. package/src/getWidget.tsx +2 -2
  239. package/src/hasWidget.ts +1 -1
  240. package/src/hashForSchema.ts +26 -6
  241. package/src/idGenerators.ts +10 -0
  242. package/src/index.ts +21 -2
  243. package/src/isCustomWidget.ts +1 -1
  244. package/src/isObject.ts +12 -5
  245. package/src/labelValue.ts +2 -2
  246. package/src/lookupFromFormContext.ts +26 -0
  247. package/src/mergeDefaultsWithFormData.ts +54 -9
  248. package/src/mergeObjects.ts +24 -21
  249. package/src/optionsList.ts +31 -22
  250. package/src/parser/ParserValidator.ts +5 -5
  251. package/src/parser/schemaParser.ts +6 -6
  252. package/src/schema/findFieldInSchema.ts +138 -0
  253. package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
  254. package/src/schema/getClosestMatchingOption.ts +38 -11
  255. package/src/schema/getDefaultFormState.ts +447 -191
  256. package/src/schema/getDisplayLabel.ts +7 -4
  257. package/src/schema/getFirstMatchingOption.ts +79 -4
  258. package/src/schema/getFromSchema.ts +100 -0
  259. package/src/schema/index.ts +6 -4
  260. package/src/schema/isFilesArray.ts +18 -3
  261. package/src/schema/isMultiSelect.ts +10 -4
  262. package/src/schema/isSelect.ts +5 -3
  263. package/src/schema/retrieveSchema.ts +256 -75
  264. package/src/schema/sanitizeDataForNewSchema.ts +52 -11
  265. package/src/schema/toIdSchema.ts +69 -43
  266. package/src/schema/toPathSchema.ts +49 -16
  267. package/src/toErrorList.ts +2 -2
  268. package/src/types.ts +266 -174
  269. package/src/validationDataMerge.ts +1 -1
  270. package/src/withIdRefPrefix.ts +1 -1
  271. package/LICENSE.md +0 -201
  272. package/lib/schema/getMatchingOption.d.ts +0 -14
  273. package/lib/schema/getMatchingOption.js +0 -85
  274. package/lib/schema/getMatchingOption.js.map +0 -1
  275. package/lib/schema/mergeValidationData.d.ts +0 -14
  276. package/lib/schema/mergeValidationData.js +0 -28
  277. package/lib/schema/mergeValidationData.js.map +0 -1
  278. package/src/schema/getMatchingOption.ts +0 -103
  279. package/src/schema/mergeValidationData.ts +0 -38
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 description field */
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,7 +299,12 @@ 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
309
  * widget level when no field-level value of the option is provided.
269
310
  */
@@ -360,7 +401,7 @@ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
360
401
  /** The definition of a React-based Field component */
361
402
  export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>>;
362
403
  /** The properties that are passed to a FieldTemplate implementation */
363
- export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
404
+ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
364
405
  /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
365
406
  id: string;
366
407
  /** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
@@ -401,10 +442,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
401
442
  * you don't want to clutter the UI
402
443
  */
403
444
  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
445
  /** The `formContext` object that was passed to `Form` */
409
446
  formContext?: F;
410
447
  /** The formData for this field */
@@ -415,47 +452,29 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
415
452
  onKeyChange: (value: string) => () => void;
416
453
  /** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
417
454
  onDropPropertyClick: (value: string) => () => void;
418
- /** The `registry` object */
419
- registry: Registry<T, S, F>;
420
455
  };
421
456
  /** 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;
457
+ export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
425
458
  /** The tree of unique ids for every child field */
426
459
  idSchema?: IdSchema<T>;
427
460
  /** The reason why the schema field has an unsupported type */
428
461
  reason: string;
429
- /** The `registry` object */
430
- registry: Registry<T, S, F>;
431
462
  };
432
463
  /** The properties that are passed to a `TitleFieldTemplate` implementation */
433
- export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
464
+ export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
434
465
  /** The id of the field title in the hierarchy */
435
466
  id: string;
436
467
  /** The title for the field being rendered */
437
468
  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
469
  /** A boolean value stating if the field is required */
443
470
  required?: boolean;
444
- /** The `registry` object */
445
- registry: Registry<T, S, F>;
446
471
  };
447
472
  /** The properties that are passed to a `DescriptionFieldTemplate` implementation */
448
- export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
473
+ export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
449
474
  /** The id of the field description in the hierarchy */
450
475
  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
476
  /** The description of the field being rendered */
456
477
  description: string | ReactElement;
457
- /** The `registry` object */
458
- registry: Registry<T, S, F>;
459
478
  };
460
479
  /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
461
480
  export type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
@@ -471,12 +490,14 @@ export type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJS
471
490
  /** The idSchema of the field in the hierarchy */
472
491
  idSchema: IdSchema<T>;
473
492
  };
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;
493
+ /** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
494
+ export type ArrayFieldItemButtonsTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
495
+ /** The idSchema of the item for which buttons are being rendered */
496
+ idSchema: IdSchema<T>;
478
497
  /** The className string */
479
- className: string;
498
+ className?: string;
499
+ /** Any optional style attributes */
500
+ style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];
480
501
  /** A boolean value stating if the array item is disabled */
481
502
  disabled?: boolean;
482
503
  /** A boolean value stating whether new items can be added to the array */
@@ -489,8 +510,6 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
489
510
  hasMoveUp: boolean;
490
511
  /** A boolean value stating whether the array item can be removed */
491
512
  hasRemove: boolean;
492
- /** A boolean value stating whether the array item has a toolbar */
493
- hasToolbar: boolean;
494
513
  /** A number stating the index the array item occurs in `items` */
495
514
  index: number;
496
515
  /** A number stating the total number `items` in the array */
@@ -505,17 +524,34 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
505
524
  onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
506
525
  /** A boolean value stating if the array item is read-only */
507
526
  readonly?: boolean;
527
+ };
528
+ /** The properties of each element in the ArrayFieldTemplateProps.items array */
529
+ export type ArrayFieldItemTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
530
+ /** The html for the item's content */
531
+ children: ReactNode;
532
+ /** The props to pass to the `ArrayFieldItemButtonTemplate` */
533
+ buttonsProps: ArrayFieldItemButtonsTemplateType<T, S, F>;
534
+ /** The className string */
535
+ className: string;
536
+ /** A boolean value stating if the array item is disabled */
537
+ disabled?: boolean;
538
+ /** A boolean value stating whether the array item has a toolbar */
539
+ hasToolbar: boolean;
540
+ /** A number stating the index the array item occurs in `items` */
541
+ index: number;
542
+ /** A number stating the total number `items` in the array */
543
+ totalItems: number;
544
+ /** A boolean value stating if the array item is read-only */
545
+ readonly?: boolean;
508
546
  /** A stable, unique key for the array item */
509
547
  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
548
  };
549
+ /**
550
+ * @deprecated - Use `ArrayFieldItemTemplateType` instead
551
+ */
552
+ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ArrayFieldItemTemplateType<T, S, F>;
517
553
  /** The properties that are passed to an ArrayFieldTemplate implementation */
518
- export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
554
+ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
519
555
  /** A boolean value stating whether new elements can be added to the array */
520
556
  canAdd?: boolean;
521
557
  /** The className string */
@@ -525,7 +561,7 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
525
561
  /** An object containing the id for this object & ids for its properties */
526
562
  idSchema: IdSchema<T>;
527
563
  /** An array of objects representing the items in the array */
528
- items: ArrayFieldTemplateItemType<T, S, F>[];
564
+ items: ArrayFieldItemTemplateType<T, S, F>[];
529
565
  /** A function that adds a new item to the array */
530
566
  onAddClick: (event?: any) => void;
531
567
  /** A boolean value stating if the array is read-only */
@@ -534,10 +570,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
534
570
  required?: boolean;
535
571
  /** A boolean value stating if the field is hiding its errors */
536
572
  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
573
  /** A string value containing the title for the array */
542
574
  title: string;
543
575
  /** The `formContext` object that was passed to Form */
@@ -548,8 +580,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
548
580
  errorSchema?: ErrorSchema<T>;
549
581
  /** An array of strings listing all generated error messages from encountered errors for this widget */
550
582
  rawErrors?: string[];
551
- /** The `registry` object */
552
- registry: Registry<T, S, F>;
553
583
  };
554
584
  /** The properties of each element in the ObjectFieldTemplateProps.properties array */
555
585
  export type ObjectFieldTemplatePropertyType = {
@@ -565,7 +595,7 @@ export type ObjectFieldTemplatePropertyType = {
565
595
  hidden: boolean;
566
596
  };
567
597
  /** The properties that are passed to an ObjectFieldTemplate implementation */
568
- export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
598
+ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
569
599
  /** A string value containing the title for the object */
570
600
  title: string;
571
601
  /** A string value containing the description for the object */
@@ -582,10 +612,6 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
582
612
  required?: boolean;
583
613
  /** A boolean value stating if the field is hiding its errors */
584
614
  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
615
  /** An object containing the id for this object & ids for its properties */
590
616
  idSchema: IdSchema<T>;
591
617
  /** The optional validation errors in the form of an `ErrorSchema` */
@@ -594,16 +620,14 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
594
620
  formData?: T;
595
621
  /** The `formContext` object that was passed to Form */
596
622
  formContext?: F;
597
- /** The `registry` object */
598
- registry: Registry<T, S, F>;
599
623
  };
600
624
  /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
601
- export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
625
+ export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
602
626
  /** The field or widget component instance for this field row */
603
627
  children: ReactNode;
604
- } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
628
+ } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'hideError' | 'rawErrors' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
605
629
  /** 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'>> {
630
+ 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
631
  /** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
608
632
  * widgets
609
633
  */
@@ -612,10 +636,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
612
636
  * of custom widgets.
613
637
  */
614
638
  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
639
  /** The current value for this widget */
620
640
  value: any;
621
641
  /** The required status of this widget */
@@ -655,8 +675,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
655
675
  multiple?: boolean;
656
676
  /** An array of strings listing all generated error messages from encountered errors for this widget */
657
677
  rawErrors?: string[];
658
- /** The `registry` object */
659
- registry: Registry<T, S, F>;
660
678
  }
661
679
  /** The definition of a React-based Widget component */
662
680
  export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<WidgetProps<T, S, F>>;
@@ -676,15 +694,11 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
676
694
  registry: Registry<T, S, F>;
677
695
  };
678
696
  /** 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> & {
697
+ export type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
680
698
  /** An alternative specification for the type of the icon button */
681
699
  iconType?: string;
682
700
  /** The name representation or actual react element implementation for the icon */
683
701
  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
702
  };
689
703
  /** The type that defines how to change the behavior of the submit button for the form */
690
704
  export type UISchemaSubmitButtonOptions = {
@@ -716,7 +730,11 @@ type MakeUIType<Type> = {
716
730
  /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
717
731
  * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
718
732
  */
719
- type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & GlobalUISchemaOptions & {
733
+ 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 & {
734
+ /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
735
+ * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
736
+ */
737
+ field?: Field<T, S, F> | string;
720
738
  /** Any classnames that the user wants to be applied to a field in the ui */
721
739
  classNames?: string;
722
740
  /** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
@@ -739,6 +757,12 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
739
757
  emptyValue?: any;
740
758
  /** Will disable any of the enum options specified in the array (by value) */
741
759
  enumDisabled?: Array<string | number | boolean>;
760
+ /** Allows a user to provide a list of labels for enum values in the schema */
761
+ enumNames?: string[];
762
+ /** Provides an optional field within a schema to be used as the oneOf/anyOf selector when there isn't a
763
+ * discriminator
764
+ */
765
+ optionsSchemaSelector?: string;
742
766
  /** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
743
767
  * hierarchy
744
768
  */
@@ -761,8 +785,6 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
761
785
  * to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
762
786
  */
763
787
  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
788
  };
767
789
  /** The type that represents the Options potentially provided by `ui:options` */
768
790
  export type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
@@ -779,10 +801,6 @@ export type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
779
801
  'ui:globalOptions'?: GlobalUISchemaOptions;
780
802
  /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
781
803
  '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
804
  /** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
787
805
  * `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
788
806
  * related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
@@ -825,14 +843,6 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
825
843
  * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
826
844
  */
827
845
  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
846
  /** Validates data against a schema, returning true if the data is valid, or
837
847
  * false otherwise. If the schema is invalid, then this function will return
838
848
  * false.
@@ -857,6 +867,14 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
857
867
  */
858
868
  reset?: () => void;
859
869
  }
870
+ /** The interface for the return value of the `findFieldInSchema` function
871
+ */
872
+ export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
873
+ /** The field that was found, or undefined if it wasn't */
874
+ field?: S;
875
+ /** The requiredness of the field found or undefined if it wasn't */
876
+ isRequired?: boolean;
877
+ }
860
878
  /** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
861
879
  * directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
862
880
  * the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
@@ -875,9 +893,32 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
875
893
  * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
876
894
  * @param rootSchema - The root schema that will be compared against the current one
877
895
  * @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
896
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
878
897
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
879
898
  */
880
- doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior): boolean;
899
+ doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): boolean;
900
+ /** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
901
+ * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
902
+ * field is in the `required` list for its parent and if so, it is marked as required on return.
903
+ *
904
+ * @param schema - The current node within the JSON schema
905
+ * @param path - The remaining keys in the path to the desired field
906
+ * @param [formData] - The form data that is used to determine which oneOf option
907
+ * @returns - An object that contains the field and its required state. If no field can be found then
908
+ * `{ field: undefined, isRequired: undefined }` is returned.
909
+ */
910
+ findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
911
+ /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
912
+ * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
913
+ * `schema.discriminator.propertyName` or `fallbackField`.
914
+ *
915
+ * @param schema - The schema element in which to search for the selected oneOf option
916
+ * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
917
+ * @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
918
+ * @param [formData] - The form data that is used to determine which oneOf option
919
+ * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
920
+ */
921
+ findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData?: T): S | undefined;
881
922
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
882
923
  * computed to have defaults provided in the `schema`.
883
924
  *
@@ -922,17 +963,17 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
922
963
  * @returns - The firstindex of the matched option or 0 if none is available
923
964
  */
924
965
  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.
966
+ /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
967
+ * containing potentially nested `$ref`s.
927
968
  *
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
969
+ * @param schema - The current node within the JSON schema recursion
970
+ * @param path - The remaining keys in the path to the desired property
971
+ * @param defaultValue - The value to return if a value is not found for the `pathList` path
972
+ * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
934
973
  */
935
- getMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
974
+ getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
975
+ getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
976
+ getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
936
977
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
937
978
  *
938
979
  * @param schema - The schema for which check for array of files flag is desired
@@ -952,18 +993,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
952
993
  * @returns - True if schema contains a select, otherwise false
953
994
  */
954
995
  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
996
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
968
997
  * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
969
998
  * 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
@@ -1 +1 @@
1
- {"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE;YACtB,OAAO,GAAG,CAAC;SACZ;aAAM;YACL,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;gBAC9B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;aACH;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;SACvC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;QACxC,CAAC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
package/lib/utcToLocal.js CHANGED
@@ -1,4 +1,4 @@
1
- import pad from './pad';
1
+ import pad from './pad.js';
2
2
  /** Converts a UTC date string into a local Date format
3
3
  *
4
4
  * @param jsonDate - A UTC date string
@@ -1 +1 @@
1
- {"version":3,"file":"utcToLocal.js","sourceRoot":"","sources":["../src/utcToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAgB;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,EAAE,CAAC;KACX;IAED,iFAAiF;IACjF,sGAAsG;IACtG,6DAA6D;IAE7D,mEAAmE;IACnE,mCAAmC;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;IAE3C,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;AACxD,CAAC"}
1
+ {"version":3,"file":"utcToLocal.js","sourceRoot":"","sources":["../src/utcToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAgB;IACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iFAAiF;IACjF,sGAAsG;IACtG,6DAA6D;IAE7D,mEAAmE;IACnE,mCAAmC;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;IAE3C,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;AACxD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ErrorSchema, ValidationData } from './types';
1
+ import { ErrorSchema, ValidationData } from './types.js';
2
2
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
3
3
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
4
4
  * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
@@ -1,6 +1,6 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import mergeObjects from './mergeObjects';
3
- import toErrorList from './toErrorList';
1
+ import isEmpty from 'lodash-es/isEmpty.js';
2
+ import mergeObjects from './mergeObjects.js';
3
+ import toErrorList from './toErrorList.js';
4
4
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
5
5
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
6
6
  * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then