@rjsf/utils 5.11.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/dist/index.js +2544 -5
  2. package/dist/index.js.map +7 -0
  3. package/dist/utils.esm.js +1228 -2105
  4. package/dist/utils.esm.js.map +7 -1
  5. package/dist/utils.umd.js +2414 -0
  6. package/lib/ErrorSchemaBuilder.d.ts +60 -0
  7. package/lib/ErrorSchemaBuilder.js +103 -0
  8. package/lib/ErrorSchemaBuilder.js.map +1 -0
  9. package/lib/allowAdditionalItems.d.ts +8 -0
  10. package/lib/allowAdditionalItems.js +14 -0
  11. package/lib/allowAdditionalItems.js.map +1 -0
  12. package/lib/asNumber.d.ts +10 -0
  13. package/lib/asNumber.js +36 -0
  14. package/lib/asNumber.js.map +1 -0
  15. package/lib/canExpand.d.ts +11 -0
  16. package/lib/canExpand.js +26 -0
  17. package/lib/canExpand.js.map +1 -0
  18. package/lib/constants.d.ts +31 -0
  19. package/lib/constants.js +32 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/createErrorHandler.d.ts +7 -0
  22. package/lib/createErrorHandler.js +31 -0
  23. package/lib/createErrorHandler.js.map +1 -0
  24. package/lib/createSchemaUtils.d.ts +10 -0
  25. package/lib/createSchemaUtils.js +207 -0
  26. package/lib/createSchemaUtils.js.map +1 -0
  27. package/lib/dataURItoBlob.d.ts +16 -0
  28. package/lib/dataURItoBlob.js +43 -0
  29. package/lib/dataURItoBlob.js.map +1 -0
  30. package/lib/deepEquals.d.ts +8 -0
  31. package/lib/deepEquals.js +19 -0
  32. package/lib/deepEquals.js.map +1 -0
  33. package/lib/englishStringTranslator.d.ts +10 -0
  34. package/lib/englishStringTranslator.js +13 -0
  35. package/lib/englishStringTranslator.js.map +1 -0
  36. package/lib/enumOptionsDeselectValue.d.ts +14 -0
  37. package/lib/enumOptionsDeselectValue.js +22 -0
  38. package/lib/enumOptionsDeselectValue.js.map +1 -0
  39. package/lib/enumOptionsIndexForValue.d.ts +13 -0
  40. package/lib/enumOptionsIndexForValue.js +22 -0
  41. package/lib/enumOptionsIndexForValue.js.map +1 -0
  42. package/lib/enumOptionsIsSelected.d.ts +8 -0
  43. package/lib/enumOptionsIsSelected.js +14 -0
  44. package/lib/enumOptionsIsSelected.js.map +1 -0
  45. package/lib/enumOptionsSelectValue.d.ts +10 -0
  46. package/lib/enumOptionsSelectValue.js +23 -0
  47. package/lib/enumOptionsSelectValue.js.map +1 -0
  48. package/lib/enumOptionsValueForIndex.d.ts +13 -0
  49. package/lib/enumOptionsValueForIndex.js +21 -0
  50. package/lib/enumOptionsValueForIndex.js.map +1 -0
  51. package/lib/enums.d.ts +72 -0
  52. package/lib/enums.js +76 -0
  53. package/lib/enums.js.map +1 -0
  54. package/lib/findSchemaDefinition.d.ts +20 -0
  55. package/lib/findSchemaDefinition.js +49 -0
  56. package/lib/findSchemaDefinition.js.map +1 -0
  57. package/lib/getDiscriminatorFieldFromSchema.d.ts +8 -0
  58. package/lib/getDiscriminatorFieldFromSchema.js +20 -0
  59. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -0
  60. package/lib/getInputProps.d.ts +10 -0
  61. package/lib/getInputProps.js +41 -0
  62. package/lib/getInputProps.js.map +1 -0
  63. package/lib/getSchemaType.d.ts +13 -0
  64. package/lib/getSchemaType.js +29 -0
  65. package/lib/getSchemaType.js.map +1 -0
  66. package/lib/getSubmitButtonOptions.d.ts +10 -0
  67. package/lib/getSubmitButtonOptions.js +25 -0
  68. package/lib/getSubmitButtonOptions.js.map +1 -0
  69. package/lib/getTemplate.d.ts +10 -0
  70. package/lib/getTemplate.js +19 -0
  71. package/lib/getTemplate.js.map +1 -0
  72. package/lib/getUiOptions.d.ts +9 -0
  73. package/lib/getUiOptions.js +25 -0
  74. package/lib/getUiOptions.js.map +1 -0
  75. package/lib/getWidget.d.ts +13 -0
  76. package/lib/getWidget.js +118 -0
  77. package/lib/getWidget.js.map +1 -0
  78. package/lib/guessType.d.ts +7 -0
  79. package/lib/guessType.js +29 -0
  80. package/lib/guessType.js.map +1 -0
  81. package/lib/hasWidget.d.ts +10 -0
  82. package/lib/hasWidget.js +23 -0
  83. package/lib/hasWidget.js.map +1 -0
  84. package/lib/hashForSchema.d.ts +8 -0
  85. package/lib/hashForSchema.js +29 -0
  86. package/lib/hashForSchema.js.map +1 -0
  87. package/lib/idGenerators.d.ts +47 -0
  88. package/lib/idGenerators.js +73 -0
  89. package/lib/idGenerators.js.map +1 -0
  90. package/lib/index.d.ts +57 -0
  91. package/lib/index.js +58 -0
  92. package/lib/index.js.map +1 -0
  93. package/lib/isConstant.d.ts +8 -0
  94. package/lib/isConstant.js +11 -0
  95. package/lib/isConstant.js.map +1 -0
  96. package/lib/isCustomWidget.d.ts +7 -0
  97. package/lib/isCustomWidget.js +13 -0
  98. package/lib/isCustomWidget.js.map +1 -0
  99. package/lib/isFixedItems.d.ts +8 -0
  100. package/lib/isFixedItems.js +11 -0
  101. package/lib/isFixedItems.js.map +1 -0
  102. package/lib/isObject.d.ts +7 -0
  103. package/lib/isObject.js +16 -0
  104. package/lib/isObject.js.map +1 -0
  105. package/lib/labelValue.d.ts +13 -0
  106. package/lib/labelValue.js +4 -0
  107. package/lib/labelValue.js.map +1 -0
  108. package/lib/localToUTC.d.ts +6 -0
  109. package/lib/localToUTC.js +9 -0
  110. package/lib/localToUTC.js.map +1 -0
  111. package/lib/mergeDefaultsWithFormData.d.ts +17 -0
  112. package/lib/mergeDefaultsWithFormData.js +43 -0
  113. package/lib/mergeDefaultsWithFormData.js.map +1 -0
  114. package/lib/mergeObjects.d.ts +11 -0
  115. package/lib/mergeObjects.js +35 -0
  116. package/lib/mergeObjects.js.map +1 -0
  117. package/lib/mergeSchemas.d.ts +10 -0
  118. package/lib/mergeSchemas.js +35 -0
  119. package/lib/mergeSchemas.js.map +1 -0
  120. package/lib/optionsList.d.ts +10 -0
  121. package/lib/optionsList.js +36 -0
  122. package/lib/optionsList.js.map +1 -0
  123. package/lib/orderProperties.d.ts +11 -0
  124. package/lib/orderProperties.js +38 -0
  125. package/lib/orderProperties.js.map +1 -0
  126. package/lib/pad.d.ts +7 -0
  127. package/lib/pad.js +14 -0
  128. package/lib/pad.js.map +1 -0
  129. package/lib/parseDateString.d.ts +9 -0
  130. package/lib/parseDateString.js +32 -0
  131. package/lib/parseDateString.js.map +1 -0
  132. package/lib/parser/ParserValidator.d.ts +70 -0
  133. package/lib/parser/ParserValidator.js +93 -0
  134. package/lib/parser/ParserValidator.js.map +1 -0
  135. package/lib/parser/index.d.ts +4 -0
  136. package/lib/parser/index.js +3 -0
  137. package/lib/parser/index.js.map +1 -0
  138. package/lib/parser/schemaParser.d.ts +9 -0
  139. package/lib/parser/schemaParser.js +48 -0
  140. package/lib/parser/schemaParser.js.map +1 -0
  141. package/lib/rangeSpec.d.ts +9 -0
  142. package/lib/rangeSpec.js +20 -0
  143. package/lib/rangeSpec.js.map +1 -0
  144. package/lib/replaceStringParameters.d.ts +9 -0
  145. package/lib/replaceStringParameters.js +23 -0
  146. package/lib/replaceStringParameters.js.map +1 -0
  147. package/lib/schema/getClosestMatchingOption.d.ts +49 -0
  148. package/lib/schema/getClosestMatchingOption.js +154 -0
  149. package/lib/schema/getClosestMatchingOption.js.map +1 -0
  150. package/lib/schema/getDefaultFormState.d.ts +66 -0
  151. package/lib/schema/getDefaultFormState.js +351 -0
  152. package/lib/schema/getDefaultFormState.js.map +1 -0
  153. package/lib/schema/getDisplayLabel.d.ts +12 -0
  154. package/lib/schema/getDisplayLabel.js +39 -0
  155. package/lib/schema/getDisplayLabel.js.map +1 -0
  156. package/lib/schema/getFirstMatchingOption.d.ts +13 -0
  157. package/lib/schema/getFirstMatchingOption.js +16 -0
  158. package/lib/schema/getFirstMatchingOption.js.map +1 -0
  159. package/lib/schema/getMatchingOption.d.ts +14 -0
  160. package/lib/schema/getMatchingOption.js +80 -0
  161. package/lib/schema/getMatchingOption.js.map +1 -0
  162. package/lib/schema/index.d.ts +14 -0
  163. package/lib/schema/index.js +15 -0
  164. package/lib/schema/index.js.map +1 -0
  165. package/lib/schema/isFilesArray.d.ts +10 -0
  166. package/lib/schema/isFilesArray.js +21 -0
  167. package/lib/schema/isFilesArray.js.map +1 -0
  168. package/lib/schema/isMultiSelect.d.ts +9 -0
  169. package/lib/schema/isMultiSelect.js +15 -0
  170. package/lib/schema/isMultiSelect.js.map +1 -0
  171. package/lib/schema/isSelect.d.ts +9 -0
  172. package/lib/schema/isSelect.js +21 -0
  173. package/lib/schema/isSelect.js.map +1 -0
  174. package/lib/schema/mergeValidationData.d.ts +14 -0
  175. package/lib/schema/mergeValidationData.js +28 -0
  176. package/lib/schema/mergeValidationData.js.map +1 -0
  177. package/lib/schema/retrieveSchema.d.ts +170 -0
  178. package/lib/schema/retrieveSchema.js +437 -0
  179. package/lib/schema/retrieveSchema.js.map +1 -0
  180. package/lib/schema/sanitizeDataForNewSchema.d.ts +49 -0
  181. package/lib/schema/sanitizeDataForNewSchema.js +173 -0
  182. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -0
  183. package/lib/schema/toIdSchema.d.ts +13 -0
  184. package/lib/schema/toIdSchema.js +59 -0
  185. package/lib/schema/toIdSchema.js.map +1 -0
  186. package/lib/schema/toPathSchema.d.ts +11 -0
  187. package/lib/schema/toPathSchema.js +68 -0
  188. package/lib/schema/toPathSchema.js.map +1 -0
  189. package/lib/schemaRequiresTrueValue.d.ts +11 -0
  190. package/lib/schemaRequiresTrueValue.js +34 -0
  191. package/lib/schemaRequiresTrueValue.js.map +1 -0
  192. package/lib/shouldRender.d.ts +10 -0
  193. package/lib/shouldRender.js +14 -0
  194. package/lib/shouldRender.js.map +1 -0
  195. package/lib/toConstant.d.ts +9 -0
  196. package/lib/toConstant.js +18 -0
  197. package/lib/toConstant.js.map +1 -0
  198. package/lib/toDateString.d.ts +9 -0
  199. package/lib/toDateString.js +14 -0
  200. package/lib/toDateString.js.map +1 -0
  201. package/lib/toErrorList.d.ts +8 -0
  202. package/lib/toErrorList.js +34 -0
  203. package/lib/toErrorList.js.map +1 -0
  204. package/lib/toErrorSchema.d.ts +21 -0
  205. package/lib/toErrorSchema.js +41 -0
  206. package/lib/toErrorSchema.js.map +1 -0
  207. package/lib/types.d.ts +982 -0
  208. package/lib/types.js +2 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib/unwrapErrorHandler.d.ts +7 -0
  211. package/lib/unwrapErrorHandler.js +21 -0
  212. package/lib/unwrapErrorHandler.js.map +1 -0
  213. package/lib/utcToLocal.d.ts +6 -0
  214. package/lib/utcToLocal.js +26 -0
  215. package/lib/utcToLocal.js.map +1 -0
  216. package/lib/validationDataMerge.d.ts +11 -0
  217. package/lib/validationDataMerge.js +26 -0
  218. package/lib/validationDataMerge.js.map +1 -0
  219. package/lib/withIdRefPrefix.d.ts +8 -0
  220. package/lib/withIdRefPrefix.js +47 -0
  221. package/lib/withIdRefPrefix.js.map +1 -0
  222. package/package.json +21 -13
  223. package/src/ErrorSchemaBuilder.ts +112 -0
  224. package/src/allowAdditionalItems.ts +15 -0
  225. package/src/asNumber.ts +38 -0
  226. package/src/canExpand.ts +31 -0
  227. package/src/constants.ts +31 -0
  228. package/src/createErrorHandler.ts +33 -0
  229. package/src/createSchemaUtils.ts +298 -0
  230. package/src/dataURItoBlob.ts +42 -0
  231. package/src/deepEquals.ts +19 -0
  232. package/src/englishStringTranslator.ts +14 -0
  233. package/src/enumOptionsDeselectValue.ts +28 -0
  234. package/src/enumOptionsIndexForValue.ts +27 -0
  235. package/src/enumOptionsIsSelected.ts +19 -0
  236. package/src/enumOptionsSelectValue.ts +28 -0
  237. package/src/enumOptionsValueForIndex.ts +26 -0
  238. package/src/enums.ts +74 -0
  239. package/src/findSchemaDefinition.ts +54 -0
  240. package/src/getDiscriminatorFieldFromSchema.ts +21 -0
  241. package/src/getInputProps.ts +55 -0
  242. package/src/getSchemaType.ts +37 -0
  243. package/src/getSubmitButtonOptions.ts +32 -0
  244. package/src/getTemplate.ts +26 -0
  245. package/src/getUiOptions.ts +32 -0
  246. package/src/getWidget.tsx +133 -0
  247. package/src/guessType.ts +28 -0
  248. package/src/hasWidget.ts +27 -0
  249. package/src/hashForSchema.ts +31 -0
  250. package/src/idGenerators.ts +81 -0
  251. package/src/index.ts +118 -0
  252. package/src/isConstant.ts +12 -0
  253. package/src/isCustomWidget.ts +19 -0
  254. package/src/isFixedItems.ts +12 -0
  255. package/src/isObject.ts +15 -0
  256. package/src/labelValue.ts +16 -0
  257. package/src/localToUTC.ts +8 -0
  258. package/src/mergeDefaultsWithFormData.ts +53 -0
  259. package/src/mergeObjects.ts +39 -0
  260. package/src/mergeSchemas.ts +38 -0
  261. package/src/optionsList.ts +41 -0
  262. package/src/orderProperties.ts +44 -0
  263. package/src/pad.ts +13 -0
  264. package/src/parseDateString.ts +33 -0
  265. package/src/parser/ParserValidator.ts +132 -0
  266. package/src/parser/index.ts +6 -0
  267. package/src/parser/schemaParser.ts +60 -0
  268. package/src/rangeSpec.ts +22 -0
  269. package/src/replaceStringParameters.ts +22 -0
  270. package/src/schema/getClosestMatchingOption.ts +191 -0
  271. package/src/schema/getDefaultFormState.ts +447 -0
  272. package/src/schema/getDisplayLabel.ts +59 -0
  273. package/src/schema/getFirstMatchingOption.ts +27 -0
  274. package/src/schema/getMatchingOption.ts +95 -0
  275. package/src/schema/index.ts +29 -0
  276. package/src/schema/isFilesArray.ts +27 -0
  277. package/src/schema/isMultiSelect.ts +21 -0
  278. package/src/schema/isSelect.ts +26 -0
  279. package/src/schema/mergeValidationData.ts +38 -0
  280. package/src/schema/retrieveSchema.ts +614 -0
  281. package/src/schema/sanitizeDataForNewSchema.ts +197 -0
  282. package/src/schema/toIdSchema.ts +105 -0
  283. package/src/schema/toPathSchema.ts +121 -0
  284. package/src/schemaRequiresTrueValue.ts +40 -0
  285. package/src/shouldRender.ts +16 -0
  286. package/src/toConstant.ts +19 -0
  287. package/src/toDateString.ts +15 -0
  288. package/src/toErrorList.ts +41 -0
  289. package/src/toErrorSchema.ts +43 -0
  290. package/src/types.ts +1139 -0
  291. package/src/unwrapErrorHandler.ts +25 -0
  292. package/src/utcToLocal.ts +30 -0
  293. package/src/validationDataMerge.ts +31 -0
  294. package/src/withIdRefPrefix.ts +49 -0
  295. package/dist/index.d.ts +0 -1912
  296. package/dist/utils.cjs.development.js +0 -3513
  297. package/dist/utils.cjs.development.js.map +0 -1
  298. package/dist/utils.cjs.production.min.js +0 -2
  299. package/dist/utils.cjs.production.min.js.map +0 -1
  300. package/dist/utils.umd.development.js +0 -3496
  301. package/dist/utils.umd.development.js.map +0 -1
  302. package/dist/utils.umd.production.min.js +0 -2
  303. package/dist/utils.umd.production.min.js.map +0 -1
package/dist/index.d.ts DELETED
@@ -1,1912 +0,0 @@
1
- /// <reference types="react-addons-linked-state-mixin" />
2
- import * as react from 'react';
3
- import react__default, { ReactElement, ComponentType, HTMLAttributes, StyleHTMLAttributes, ReactNode, ChangeEvent, ButtonHTMLAttributes } from 'react';
4
- import * as json_schema from 'json-schema';
5
- import { JSONSchema7 } from 'json-schema';
6
-
7
- /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the
8
- * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values
9
- * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of
10
- * parameters is important because some languages may choose to put the second parameter before the first in its
11
- * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.
12
- */
13
- declare enum TranslatableString {
14
- /** Fallback title of an array item, used by ArrayField */
15
- ArrayItemTitle = "Item",
16
- /** Missing items reason, used by ArrayField */
17
- MissingItems = "Missing items definition",
18
- /** Yes label, used by BooleanField */
19
- YesLabel = "Yes",
20
- /** No label, used by BooleanField */
21
- NoLabel = "No",
22
- /** Close label, used by ErrorList */
23
- CloseLabel = "Close",
24
- /** Errors label, used by ErrorList */
25
- ErrorsLabel = "Errors",
26
- /** New additionalProperties string default value, used by ObjectField */
27
- NewStringDefault = "New Value",
28
- /** Add button title, used by AddButton */
29
- AddButton = "Add",
30
- /** Add button title, used by AddButton */
31
- AddItemButton = "Add Item",
32
- /** Copy button title, used by IconButton */
33
- CopyButton = "Copy",
34
- /** Move down button title, used by IconButton */
35
- MoveDownButton = "Move down",
36
- /** Move up button title, used by IconButton */
37
- MoveUpButton = "Move up",
38
- /** Remove button title, used by IconButton */
39
- RemoveButton = "Remove",
40
- /** Now label, used by AltDateWidget */
41
- NowLabel = "Now",
42
- /** Clear label, used by AltDateWidget */
43
- ClearLabel = "Clear",
44
- /** Aria date label, used by DateWidget */
45
- AriaDateLabel = "Select a date",
46
- /** File preview label, used by FileWidget */
47
- PreviewLabel = "Preview",
48
- /** Decrement button aria label, used by UpDownWidget */
49
- DecrementAriaLabel = "Decrease value by 1",
50
- /** Increment button aria label, used by UpDownWidget */
51
- IncrementAriaLabel = "Increase value by 1",
52
- /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */
53
- UnknownFieldType = "Unknown field type %1",
54
- /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */
55
- OptionPrefix = "Option %1",
56
- /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by
57
- * MultiSchemaField
58
- */
59
- TitleOptionPrefix = "%1 option %2",
60
- /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
61
- KeyLabel = "%1 Key",
62
- /** Invalid object field configuration as provided by the ObjectField */
63
- InvalidObjectField = "Invalid \"%1\" object field configuration: <em>%2</em>.",
64
- /** Unsupported field schema, used by UnsupportedField */
65
- UnsupportedField = "Unsupported field schema.",
66
- /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
67
- UnsupportedFieldWithId = "Unsupported field schema for field <code>%1</code>.",
68
- /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
69
- UnsupportedFieldWithReason = "Unsupported field schema: <em>%1</em>.",
70
- /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
71
- * as provided by UnsupportedField
72
- */
73
- UnsupportedFieldWithIdAndReason = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.",
74
- /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
75
- * provided by FileWidget
76
- */
77
- FilesInfo = "<strong>%1</strong> (%2, %3 bytes)"
78
- }
79
-
80
- /** The representation of any generic object type, usually used as an intersection on other types to make them more
81
- * flexible in the properties they support (i.e. anything else)
82
- */
83
- type GenericObjectType = {
84
- [name: string]: any;
85
- };
86
- /** Map the JSONSchema7 to our own type so that we can easily bump to a more recent version at some future date and only
87
- * have to update this one type.
88
- */
89
- type StrictRJSFSchema = JSONSchema7;
90
- /** Allow for more flexible schemas (i.e. draft-2019) than the strict JSONSchema7
91
- */
92
- type RJSFSchema = StrictRJSFSchema & GenericObjectType;
93
- /** Alias GenericObjectType as FormContextType to allow us to remap this at some future date
94
- */
95
- type FormContextType = GenericObjectType;
96
- /** Experimental feature that specifies the Array `minItems` default form state behavior
97
- */
98
- type Experimental_ArrayMinItems = {
99
- /** Optional enumerated flag controlling how array minItems are populated, defaulting to `all`:
100
- * - `all`: Legacy behavior, populate minItems entries with default values initially and include an empty array when
101
- * no values have been defined.
102
- * - `requiredOnly`: Ignore `minItems` on a field when calculating defaults unless the field is required.
103
- */
104
- populate?: 'all' | 'requiredOnly';
105
- /** When `formData` is provided and does not contain `minItems` worth of data, this flag (`false` by default) controls
106
- * whether the extra data provided by the defaults is appended onto the existing `formData` items to ensure the
107
- * `minItems` condition is met. When false (legacy behavior), only the `formData` provided is merged into the default
108
- * form state, even if there are fewer than the `minItems`. When true, the defaults are appended onto the end of the
109
- * `formData` until the `minItems` condition is met.
110
- */
111
- mergeExtraDefaults?: boolean;
112
- };
113
- /** Experimental features to specify different default form state behaviors. Currently, this affects the
114
- * handling of optional array fields where `minItems` is set and handling of setting defaults based on the
115
- * value of `emptyObjectFields`.
116
- */
117
- type Experimental_DefaultFormStateBehavior = {
118
- /** Optional object, that controls how the default form state for arrays with `minItems` is handled. When not provided
119
- * it defaults to `{ populate: 'all' }`.
120
- */
121
- arrayMinItems?: Experimental_ArrayMinItems;
122
- /** Optional enumerated flag controlling how empty object fields are populated, defaulting to `populateAllDefaults`:
123
- * - `populateAllDefaults`: Legacy behavior - set default when there is a primitive value, an non-empty object field,
124
- * or the field itself is required |
125
- * - `populateRequiredDefaults`: Only sets default when a value is an object and its parent field is required, or it
126
- * is a primitive value and it is required |
127
- * - `skipDefaults`: Does not set defaults |
128
- */
129
- emptyObjectFields?: 'populateAllDefaults' | 'populateRequiredDefaults' | 'skipDefaults';
130
- };
131
- /** The interface representing a Date object that contains an optional time */
132
- interface DateObject {
133
- /** The year of the Date */
134
- year: number;
135
- /** The month of the Date */
136
- month: number;
137
- /** The day of the Date */
138
- day: number;
139
- /** The optional hours for the time of a Date */
140
- hour?: number;
141
- /** The optional minutes for the time of a Date */
142
- minute?: number;
143
- /** The optional seconds for the time of a Date */
144
- second?: number;
145
- }
146
- /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
147
- type RangeSpecType = {
148
- /** Specifies the interval between legal numbers in an input field */
149
- step?: number;
150
- /** Specifies a minimum value for an <input> element */
151
- min?: number;
152
- /** Specifies the maximum value for an <input> element */
153
- max?: number;
154
- };
155
- /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
156
- type InputPropsType = Omit<RangeSpecType, 'step'> & {
157
- /** Specifies the type of the <input> element */
158
- type: string;
159
- /** Specifies the interval between legal numbers in an input field or "any" */
160
- step?: number | 'any';
161
- /** Specifies the `autoComplete` value for an <input> element */
162
- autoComplete?: HTMLInputElement['autocomplete'];
163
- };
164
- /** Type describing an id used for a field in the `IdSchema` */
165
- type FieldId = {
166
- /** The id for a field */
167
- $id: string;
168
- };
169
- /** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
170
- type IdSchema<T = any> = FieldId & {
171
- [key in keyof T]?: IdSchema<T[key]>;
172
- };
173
- /** Type describing a name used for a field in the `PathSchema` */
174
- type FieldPath = {
175
- /** The name of a field */
176
- $name: string;
177
- };
178
- /** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
179
- type PathSchema<T = any> = FieldPath & {
180
- [key in keyof T]?: PathSchema<T[key]>;
181
- };
182
- /** The type for error produced by RJSF schema validation */
183
- type RJSFValidationError = {
184
- /** Name of the error, for example, "required" or "minLength" */
185
- name?: string;
186
- /** Message, for example, "is a required property" or "should NOT be shorter than 3 characters" */
187
- message?: string;
188
- /** An object with the error params returned by ajv
189
- * ([see doc](https://github.com/ajv-validator/ajv/tree/6a671057ea6aae690b5967ee26a0ddf8452c6297#error-parameters)
190
- * for more info)
191
- */
192
- params?: any;
193
- /** A string in Javascript property accessor notation to the data path of the field with the error. For example,
194
- * `.name` or `['first-name']`
195
- */
196
- property?: string;
197
- /** JSON pointer to the schema of the keyword that failed validation. For example, `#/fields/firstName/required`.
198
- * (Note: this may sometimes be wrong due to a [bug in ajv](https://github.com/ajv-validator/ajv/issues/512))
199
- */
200
- schemaPath?: string;
201
- /** Full error name, for example ".name is a required property" */
202
- stack: string;
203
- };
204
- /** The type that describes an error in a field */
205
- type FieldError = string;
206
- /** The type that describes the list of errors for a field */
207
- type FieldErrors = {
208
- /** The list of errors for the field */
209
- __errors?: FieldError[];
210
- };
211
- /** Type describing a recursive structure of `FieldErrors`s for an object with a non-empty set of keys */
212
- type ErrorSchema<T = any> = FieldErrors & {
213
- [key in keyof T]?: ErrorSchema<T[key]>;
214
- };
215
- /** Type that describes the list of errors for a field being actively validated by a custom validator */
216
- type FieldValidation = FieldErrors & {
217
- /** Function that will add a new `message` to the list of errors */
218
- addError: (message: string) => void;
219
- };
220
- /** Type describing a recursive structure of `FieldValidation`s for an object with a non-empty set of keys */
221
- type FormValidation<T = any> = FieldValidation & {
222
- [key in keyof T]?: FormValidation<T[key]>;
223
- };
224
- /** The properties that are passed to an `ErrorListTemplate` implementation */
225
- type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
226
- /** The errorSchema constructed by `Form` */
227
- errorSchema: ErrorSchema<T>;
228
- /** An array of the errors */
229
- errors: RJSFValidationError[];
230
- /** The `formContext` object that was passed to `Form` */
231
- formContext?: F;
232
- /** The schema that was passed to `Form` */
233
- schema: S;
234
- /** The uiSchema that was passed to `Form` */
235
- uiSchema?: UiSchema<T, S, F>;
236
- /** The `registry` object */
237
- registry: Registry<T, S, F>;
238
- };
239
- /** The properties that are passed to an `FieldErrorTemplate` implementation */
240
- type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
241
- /** The errorSchema constructed by `Form` */
242
- errorSchema?: ErrorSchema<T>;
243
- /** An array of the errors */
244
- errors?: Array<string | ReactElement>;
245
- /** The tree of unique ids for every child field */
246
- idSchema: IdSchema<T>;
247
- /** The schema that was passed to field */
248
- schema: S;
249
- /** The uiSchema that was passed to field */
250
- uiSchema?: UiSchema<T, S, F>;
251
- /** The `registry` object */
252
- registry: Registry<T, S, F>;
253
- };
254
- /** The properties that are passed to an `FieldHelpTemplate` implementation */
255
- type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
256
- /** The help information to be rendered */
257
- help?: string | ReactElement;
258
- /** The tree of unique ids for every child field */
259
- idSchema: IdSchema<T>;
260
- /** The schema that was passed to field */
261
- schema: S;
262
- /** The uiSchema that was passed to field */
263
- uiSchema?: UiSchema<T, S, F>;
264
- /** Flag indicating whether there are errors associated with this field */
265
- hasErrors?: boolean;
266
- /** The `registry` object */
267
- registry: Registry<T, S, F>;
268
- };
269
- /** The set of `Fields` stored in the `Registry` */
270
- type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
271
- /** A `Field` indexed by `name` */
272
- [name: string]: Field<T, S, F>;
273
- };
274
- /** The set of `Widgets` stored in the `Registry` */
275
- type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
276
- /** A `Widget` indexed by `name` */
277
- [name: string]: Widget<T, S, F>;
278
- };
279
- /** The set of RJSF templates that can be overridden by themes or users */
280
- interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
281
- /** The template to use while rendering normal or fixed array fields */
282
- ArrayFieldTemplate: ComponentType<ArrayFieldTemplateProps<T, S, F>>;
283
- /** The template to use while rendering the description for an array field */
284
- ArrayFieldDescriptionTemplate: ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
285
- /** The template to use while rendering an item in an array field */
286
- ArrayFieldItemTemplate: ComponentType<ArrayFieldTemplateItemType<T, S, F>>;
287
- /** The template to use while rendering the title for an array field */
288
- ArrayFieldTitleTemplate: ComponentType<ArrayFieldTitleProps<T, S, F>>;
289
- /** The template to use while rendering the standard html input */
290
- BaseInputTemplate: ComponentType<BaseInputTemplateProps<T, S, F>>;
291
- /** The template to use for rendering the description of a field */
292
- DescriptionFieldTemplate: ComponentType<DescriptionFieldProps<T, S, F>>;
293
- /** The template to use while rendering the errors for the whole form */
294
- ErrorListTemplate: ComponentType<ErrorListProps<T, S, F>>;
295
- /** The template to use while rendering the errors for a single field */
296
- FieldErrorTemplate: ComponentType<FieldErrorProps<T, S, F>>;
297
- /** The template to use while rendering the errors for a single field */
298
- FieldHelpTemplate: ComponentType<FieldHelpProps<T, S, F>>;
299
- /** The template to use while rendering a field */
300
- FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
301
- /** The template to use while rendering an object */
302
- ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
303
- /** The template to use for rendering the title of a field */
304
- TitleFieldTemplate: ComponentType<TitleFieldProps<T, S, F>>;
305
- /** The template to use for rendering information about an unsupported field type in the schema */
306
- UnsupportedFieldTemplate: ComponentType<UnsupportedFieldProps<T, S, F>>;
307
- /** The template to use for rendering a field that allows a user to add additional properties */
308
- WrapIfAdditionalTemplate: ComponentType<WrapIfAdditionalTemplateProps<T, S, F>>;
309
- /** The set of templates associated with buttons in the form */
310
- ButtonTemplates: {
311
- /** The template to use for the main `Submit` button */
312
- SubmitButton: ComponentType<SubmitButtonProps<T, S, F>>;
313
- /** The template to use for the Add button used for AdditionalProperties and Array items */
314
- AddButton: ComponentType<IconButtonProps<T, S, F>>;
315
- /** The template to use for the Copy button used for Array items */
316
- CopyButton: ComponentType<IconButtonProps<T, S, F>>;
317
- /** The template to use for the Move Down button used for Array items */
318
- MoveDownButton: ComponentType<IconButtonProps<T, S, F>>;
319
- /** The template to use for the Move Up button used for Array items */
320
- MoveUpButton: ComponentType<IconButtonProps<T, S, F>>;
321
- /** The template to use for the Remove button used for AdditionalProperties and Array items */
322
- RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
323
- };
324
- }
325
- /** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
326
- * widget level when no field-level value of the option is provided.
327
- */
328
- type GlobalUISchemaOptions = {
329
- /** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
330
- addable?: boolean;
331
- /** Flag, if set to `true`, array items can be copied (defaults to false) */
332
- copyable?: boolean;
333
- /** Flag, if set to `false`, array items cannot be ordered (defaults to true) */
334
- orderable?: boolean;
335
- /** Flag, if set to `false`, array items will not be removable (defaults to true) */
336
- removable?: boolean;
337
- /** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
338
- label?: boolean;
339
- /** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
340
- * This option allows you to change the separator between the original key name and the integer. Default is "-"
341
- */
342
- duplicateKeySuffixSeparator?: string;
343
- };
344
- /** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
345
- * context, schema utils and templates.
346
- */
347
- interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
348
- /** The set of all fields used by the `Form`. Includes fields from `core`, theme-specific fields and any custom
349
- * registered fields
350
- */
351
- fields: RegistryFieldsType<T, S, F>;
352
- /** The set of templates used by the `Form`. Includes templates from `core`, theme-specific fields and any custom
353
- * registered templates
354
- */
355
- templates: TemplatesType<T, S, F>;
356
- /** The set of all widgets used by the `Form`. Includes widgets from `core`, theme-specific widgets and any custom
357
- * registered widgets
358
- */
359
- widgets: RegistryWidgetsType<T, S, F>;
360
- /** The `formContext` object that was passed to `Form` */
361
- formContext: F;
362
- /** The root schema, as passed to the `Form`, which can contain referenced definitions */
363
- rootSchema: S;
364
- /** The current implementation of the `SchemaUtilsType` (from `@rjsf/utils`) in use by the `Form`. Used to call any
365
- * of the validation-schema-based utility functions
366
- */
367
- schemaUtils: SchemaUtilsType<T, S>;
368
- /** The string translation function to use when displaying any of the RJSF strings in templates, fields or widgets */
369
- translateString: (stringKey: TranslatableString, params?: string[]) => string;
370
- /** The optional global UI Options that are available for all templates, fields and widgets to access */
371
- globalUiOptions?: GlobalUISchemaOptions;
372
- }
373
- /** The properties that are passed to a Field implementation */
374
- interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
375
- /** The JSON subschema object for this field */
376
- schema: S;
377
- /** The uiSchema for this field */
378
- uiSchema?: UiSchema<T, S, F>;
379
- /** The tree of unique ids for every child field */
380
- idSchema: IdSchema<T>;
381
- /** The data for this field */
382
- formData?: T;
383
- /** The tree of errors for this field and its children */
384
- errorSchema?: ErrorSchema<T>;
385
- /** The field change event handler; called with the updated form data and an optional `ErrorSchema` */
386
- onChange: (newFormData: T | undefined, es?: ErrorSchema<T>, id?: string) => any;
387
- /** The input blur event handler; call it with the field id and value */
388
- onBlur: (id: string, value: any) => void;
389
- /** The input focus event handler; call it with the field id and value */
390
- onFocus: (id: string, value: any) => void;
391
- /** The `formContext` object that you passed to `Form` */
392
- formContext?: F;
393
- /** A boolean value stating if the field should autofocus */
394
- autofocus?: boolean;
395
- /** A boolean value stating if the field is disabled */
396
- disabled: boolean;
397
- /** A boolean value stating if the field is hiding its errors */
398
- hideError?: boolean;
399
- /** A boolean value stating if the field is read-only */
400
- readonly: boolean;
401
- /** The required status of this field */
402
- required?: boolean;
403
- /** The unique name of the field, usually derived from the name of the property in the JSONSchema */
404
- name: string;
405
- /** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
406
- * Default is `root`
407
- */
408
- idPrefix?: string;
409
- /** To avoid using a path separator that is present in field names, it is possible to change the separator used for
410
- * ids (Default is `_`)
411
- */
412
- idSeparator?: string;
413
- /** An array of strings listing all generated error messages from encountered errors for this field */
414
- rawErrors?: string[];
415
- /** The `registry` object */
416
- registry: Registry<T, S, F>;
417
- }
418
- /** The definition of a React-based Field component */
419
- type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>>;
420
- /** The properties that are passed to a FieldTemplate implementation */
421
- type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
422
- /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
423
- id: string;
424
- /** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
425
- classNames?: string;
426
- /** An object containing the style as defined in the `uiSchema` */
427
- style?: StyleHTMLAttributes<any>;
428
- /** The computed label for this field, as a string */
429
- label: string;
430
- /** A component instance rendering the field description, if one is defined (this will use any custom
431
- * `DescriptionField` defined)
432
- */
433
- description?: ReactElement;
434
- /** A string containing any `ui:description` uiSchema directive defined */
435
- rawDescription?: string;
436
- /** The field or widget component instance for this field row */
437
- children: ReactElement;
438
- /** A component instance listing any encountered errors for this field */
439
- errors?: ReactElement;
440
- /** An array of strings listing all generated error messages from encountered errors for this field */
441
- rawErrors?: string[];
442
- /** A component instance rendering any `ui:help` uiSchema directive defined */
443
- help?: ReactElement;
444
- /** A string containing any `ui:help` uiSchema directive defined. **NOTE:** `rawHelp` will be `undefined` if passed
445
- * `ui:help` is a React component instead of a string
446
- */
447
- rawHelp?: string;
448
- /** A boolean value stating if the field should be hidden */
449
- hidden?: boolean;
450
- /** A boolean value stating if the field is required */
451
- required?: boolean;
452
- /** A boolean value stating if the field is read-only */
453
- readonly: boolean;
454
- /** A boolean value stating if the field is hiding its errors */
455
- hideError?: boolean;
456
- /** A boolean value stating if the field is disabled */
457
- disabled: boolean;
458
- /** A boolean value stating if the label should be rendered or not. This is useful for nested fields in arrays where
459
- * you don't want to clutter the UI
460
- */
461
- displayLabel?: boolean;
462
- /** The schema object for this field */
463
- schema: S;
464
- /** The uiSchema object for this field */
465
- uiSchema?: UiSchema<T, S, F>;
466
- /** The `formContext` object that was passed to `Form` */
467
- formContext?: F;
468
- /** The formData for this field */
469
- formData?: T;
470
- /** The value change event handler; Can be called with a new value to change the value for this field */
471
- onChange: FieldProps['onChange'];
472
- /** The key change event handler; Called when the key associated with a field is changed for an additionalProperty */
473
- onKeyChange: (value: string) => () => void;
474
- /** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
475
- onDropPropertyClick: (value: string) => () => void;
476
- /** The `registry` object */
477
- registry: Registry<T, S, F>;
478
- };
479
- /** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
480
- type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
481
- /** The schema object for this field */
482
- schema: S;
483
- /** The tree of unique ids for every child field */
484
- idSchema?: IdSchema<T>;
485
- /** The reason why the schema field has an unsupported type */
486
- reason: string;
487
- /** The `registry` object */
488
- registry: Registry<T, S, F>;
489
- };
490
- /** The properties that are passed to a `TitleFieldTemplate` implementation */
491
- type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
492
- /** The id of the field title in the hierarchy */
493
- id: string;
494
- /** The title for the field being rendered */
495
- title: string;
496
- /** The schema object for the field being titled */
497
- schema: S;
498
- /** The uiSchema object for this title field */
499
- uiSchema?: UiSchema<T, S, F>;
500
- /** A boolean value stating if the field is required */
501
- required?: boolean;
502
- /** The `registry` object */
503
- registry: Registry<T, S, F>;
504
- };
505
- /** The properties that are passed to a `DescriptionFieldTemplate` implementation */
506
- type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
507
- /** The id of the field description in the hierarchy */
508
- id: string;
509
- /** The schema object for the field being described */
510
- schema: S;
511
- /** The uiSchema object for this description field */
512
- uiSchema?: UiSchema<T, S, F>;
513
- /** The description of the field being rendered */
514
- description: string | ReactElement;
515
- /** The `registry` object */
516
- registry: Registry<T, S, F>;
517
- };
518
- /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
519
- type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
520
- /** The title for the field being rendered */
521
- title?: string;
522
- /** The idSchema of the field in the hierarchy */
523
- idSchema: IdSchema<T>;
524
- };
525
- /** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
526
- type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, 'id' | 'description'> & {
527
- /** The description of the field being rendered */
528
- description?: string | ReactElement;
529
- /** The idSchema of the field in the hierarchy */
530
- idSchema: IdSchema<T>;
531
- };
532
- /** The properties of each element in the ArrayFieldTemplateProps.items array */
533
- type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
534
- /** The html for the item's content */
535
- children: ReactElement;
536
- /** The className string */
537
- className: string;
538
- /** A boolean value stating if the array item is disabled */
539
- disabled: boolean;
540
- /** A boolean value stating whether new items can be added to the array */
541
- canAdd: boolean;
542
- /** A boolean value stating whether the array item can be copied, assumed false if missing */
543
- hasCopy: boolean;
544
- /** A boolean value stating whether the array item can be moved down */
545
- hasMoveDown: boolean;
546
- /** A boolean value stating whether the array item can be moved up */
547
- hasMoveUp: boolean;
548
- /** A boolean value stating whether the array item can be removed */
549
- hasRemove: boolean;
550
- /** A boolean value stating whether the array item has a toolbar */
551
- hasToolbar: boolean;
552
- /** A number stating the index the array item occurs in `items` */
553
- index: number;
554
- /** A number stating the total number `items` in the array */
555
- totalItems: number;
556
- /** Returns a function that adds a new item at `index` */
557
- onAddIndexClick: (index: number) => (event?: any) => void;
558
- /** Returns a function that copies the item at `index` into the position at `index + 1` */
559
- onCopyIndexClick: (index: number) => (event?: any) => void;
560
- /** Returns a function that removes the item at `index` */
561
- onDropIndexClick: (index: number) => (event?: any) => void;
562
- /** Returns a function that swaps the items at `index` with `newIndex` */
563
- onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
564
- /** A boolean value stating if the array item is read-only */
565
- readonly: boolean;
566
- /** A stable, unique key for the array item */
567
- key: string;
568
- /** The schema object for this array item */
569
- schema: S;
570
- /** The uiSchema object for this array item */
571
- uiSchema?: UiSchema<T, S, F>;
572
- /** The `registry` object */
573
- registry: Registry<T, S, F>;
574
- };
575
- /** The properties that are passed to an ArrayFieldTemplate implementation */
576
- type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
577
- /** A boolean value stating whether new elements can be added to the array */
578
- canAdd?: boolean;
579
- /** The className string */
580
- className?: string;
581
- /** A boolean value stating if the array is disabled */
582
- disabled?: boolean;
583
- /** An object containing the id for this object & ids for its properties */
584
- idSchema: IdSchema<T>;
585
- /** An array of objects representing the items in the array */
586
- items: ArrayFieldTemplateItemType<T, S, F>[];
587
- /** A function that adds a new item to the array */
588
- onAddClick: (event?: any) => void;
589
- /** A boolean value stating if the array is read-only */
590
- readonly?: boolean;
591
- /** A boolean value stating if the array is required */
592
- required?: boolean;
593
- /** A boolean value stating if the field is hiding its errors */
594
- hideError?: boolean;
595
- /** The schema object for this array */
596
- schema: S;
597
- /** The uiSchema object for this array field */
598
- uiSchema?: UiSchema<T, S, F>;
599
- /** A string value containing the title for the array */
600
- title: string;
601
- /** The `formContext` object that was passed to Form */
602
- formContext?: F;
603
- /** The formData for this array */
604
- formData?: T;
605
- /** An array of strings listing all generated error messages from encountered errors for this widget */
606
- rawErrors?: string[];
607
- /** The `registry` object */
608
- registry: Registry<T, S, F>;
609
- };
610
- /** The properties of each element in the ObjectFieldTemplateProps.properties array */
611
- type ObjectFieldTemplatePropertyType = {
612
- /** The html for the property's content */
613
- content: ReactElement;
614
- /** A string representing the property name */
615
- name: string;
616
- /** A boolean value stating if the object property is disabled */
617
- disabled: boolean;
618
- /** A boolean value stating if the property is read-only */
619
- readonly: boolean;
620
- /** A boolean value stating if the property should be hidden */
621
- hidden: boolean;
622
- };
623
- /** The properties that are passed to an ObjectFieldTemplate implementation */
624
- type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
625
- /** A string value containing the title for the object */
626
- title: string;
627
- /** A string value containing the description for the object */
628
- description?: string;
629
- /** A boolean value stating if the object is disabled */
630
- disabled?: boolean;
631
- /** An array of objects representing the properties in the object */
632
- properties: ObjectFieldTemplatePropertyType[];
633
- /** Returns a function that adds a new property to the object (to be used with additionalProperties) */
634
- onAddClick: (schema: S) => () => void;
635
- /** A boolean value stating if the object is read-only */
636
- readonly?: boolean;
637
- /** A boolean value stating if the object is required */
638
- required?: boolean;
639
- /** A boolean value stating if the field is hiding its errors */
640
- hideError?: boolean;
641
- /** The schema object for this object */
642
- schema: S;
643
- /** The uiSchema object for this object field */
644
- uiSchema?: UiSchema<T, S, F>;
645
- /** An object containing the id for this object & ids for its properties */
646
- idSchema: IdSchema<T>;
647
- /** The optional validation errors in the form of an `ErrorSchema` */
648
- errorSchema?: ErrorSchema<T>;
649
- /** The form data for the object */
650
- formData?: T;
651
- /** The `formContext` object that was passed to Form */
652
- formContext?: F;
653
- /** The `registry` object */
654
- registry: Registry<T, S, F>;
655
- };
656
- /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
657
- type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
658
- /** The field or widget component instance for this field row */
659
- children: ReactNode;
660
- } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
661
- /** The properties that are passed to a Widget implementation */
662
- interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
663
- /** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
664
- * widgets
665
- */
666
- id: string;
667
- /** The unique name of the field, usually derived from the name of the property in the JSONSchema; Provided in support
668
- * of custom widgets.
669
- */
670
- name: string;
671
- /** The JSONSchema subschema object for this widget */
672
- schema: S;
673
- /** The uiSchema for this widget */
674
- uiSchema?: UiSchema<T, S, F>;
675
- /** The current value for this widget */
676
- value: any;
677
- /** The required status of this widget */
678
- required?: boolean;
679
- /** A boolean value stating if the widget is disabled */
680
- disabled?: boolean;
681
- /** A boolean value stating if the widget is read-only */
682
- readonly?: boolean;
683
- /** A boolean value stating if the widget is hiding its errors */
684
- hideError?: boolean;
685
- /** A boolean value stating if the widget should autofocus */
686
- autofocus?: boolean;
687
- /** The placeholder for the widget, if any */
688
- placeholder?: string;
689
- /** A map of UI Options passed as a prop to the component, including the optional `enumOptions`
690
- * which is a special case on top of `UIOptionsType` needed only by widgets
691
- */
692
- options: NonNullable<UIOptionsType<T, S, F>> & {
693
- /** The enum options list for a type that supports them */
694
- enumOptions?: EnumOptionsType<S>[];
695
- };
696
- /** The `formContext` object that you passed to `Form` */
697
- formContext?: F;
698
- /** The input blur event handler; call it with the widget id and value */
699
- onBlur: (id: string, value: any) => void;
700
- /** The value change event handler; call it with the new value every time it changes */
701
- onChange: (value: any) => void;
702
- /** The input focus event handler; call it with the widget id and value */
703
- onFocus: (id: string, value: any) => void;
704
- /** The computed label for this widget, as a string */
705
- label: string;
706
- /** A boolean value, if true, will cause the label to be hidden. This is useful for nested fields where you don't want
707
- * to clutter the UI. Customized via `label` in the `UiSchema`
708
- */
709
- hideLabel?: boolean;
710
- /** A boolean value stating if the widget can accept multiple values */
711
- multiple?: boolean;
712
- /** An array of strings listing all generated error messages from encountered errors for this widget */
713
- rawErrors?: string[];
714
- /** The `registry` object */
715
- registry: Registry<T, S, F>;
716
- }
717
- /** The definition of a React-based Widget component */
718
- type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<WidgetProps<T, S, F>>;
719
- /** The properties that are passed to the BaseInputTemplate */
720
- interface BaseInputTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends WidgetProps<T, S, F> {
721
- /** A `BaseInputTemplate` implements a default `onChange` handler that it passes to the HTML input component to handle
722
- * the `ChangeEvent`. Sometimes a widget may need to handle the `ChangeEvent` using custom logic. If that is the case,
723
- * that widget should provide its own handler via this prop.
724
- */
725
- onChangeOverride?: (event: ChangeEvent<HTMLInputElement>) => void;
726
- }
727
- /** The type that defines the props used by the Submit button */
728
- type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
729
- /** The uiSchema for this widget */
730
- uiSchema?: UiSchema<T, S, F>;
731
- /** The `registry` object */
732
- registry: Registry<T, S, F>;
733
- };
734
- /** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
735
- type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & {
736
- /** An alternative specification for the type of the icon button */
737
- iconType?: string;
738
- /** The name representation or actual react element implementation for the icon */
739
- icon?: string | ReactElement;
740
- /** The uiSchema for this widget */
741
- uiSchema?: UiSchema<T, S, F>;
742
- /** The `registry` object */
743
- registry: Registry<T, S, F>;
744
- };
745
- /** The type that defines how to change the behavior of the submit button for the form */
746
- type UISchemaSubmitButtonOptions = {
747
- /** The text of the submit button. Set to "Submit" by default */
748
- submitText?: string;
749
- /** Flag, if `true`, removes the submit button completely from the form */
750
- norender?: boolean;
751
- /** Any other props to be passed to the submit button itself */
752
- props?: GenericObjectType & {
753
- /** A boolean value stating if the submit button is disabled */
754
- disabled?: boolean;
755
- /** The class name for the submit button */
756
- className?: string;
757
- };
758
- };
759
- /** This type represents an element used to render an enum option */
760
- type EnumOptionsType<S extends StrictRJSFSchema = RJSFSchema> = {
761
- /** The value for the enum option */
762
- value: any;
763
- /** The label for the enum options */
764
- label: string;
765
- /** The schema associated with the enum option when the option represents a `oneOf` or `anyOf` choice */
766
- schema?: S;
767
- };
768
- /** This type remaps the keys of `Type` to prepend `ui:` onto them. As a result it does not need to be exported */
769
- type MakeUIType<Type> = {
770
- [Property in keyof Type as `ui:${string & Property}`]: Type[Property];
771
- };
772
- /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
773
- * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
774
- */
775
- type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & GlobalUISchemaOptions & {
776
- /** Any classnames that the user wants to be applied to a field in the ui */
777
- classNames?: string;
778
- /** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
779
- style?: StyleHTMLAttributes<any>;
780
- /** We know that for title, it will be a string, if it is provided */
781
- title?: string;
782
- /** We know that for description, it will be a string, if it is provided */
783
- description?: string;
784
- /** We know that for placeholder, it will be a string, if it is provided */
785
- placeholder?: string;
786
- /** Used to add text next to a field to guide the end user in filling it in */
787
- help?: string;
788
- /** Flag, if set to `true`, will mark the field as automatically focused on a text input or textarea input */
789
- autofocus?: boolean;
790
- /** Use to mark the field as supporting auto complete on a text input or textarea input */
791
- autocomplete?: HTMLInputElement['autocomplete'];
792
- /** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
793
- disabled?: boolean;
794
- /** The default value to use when an input for a field is empty */
795
- emptyValue?: any;
796
- /** Will disable any of the enum options specified in the array (by value) */
797
- enumDisabled?: Array<string | number | boolean>;
798
- /** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
799
- * hierarchy
800
- */
801
- hideError?: boolean;
802
- /** Flag, if set to `true`, will mark all child widgets from a given field as read-only */
803
- readonly?: boolean;
804
- /** This property allows you to reorder the properties that are shown for a particular object */
805
- order?: string[];
806
- /** Flag, if set to `true`, will cause the `FileWidget` to show a preview (with download for non-image files) */
807
- filePreview?: boolean;
808
- /** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
809
- inline?: boolean;
810
- /** Used to change the input type (for example, `tel` or `email`) for an <input> */
811
- inputType?: string;
812
- /** Provides a means to set the initial height of a textarea widget */
813
- rows?: number;
814
- /** If submitButtonOptions is provided it should match the `UISchemaSubmitButtonOptions` type */
815
- submitButtonOptions?: UISchemaSubmitButtonOptions;
816
- /** Allows RJSF to override the default widget implementation by specifying either the name of a widget that is used
817
- * to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
818
- */
819
- widget?: Widget<T, S, F> | string;
820
- };
821
- /** The type that represents the Options potentially provided by `ui:options` */
822
- type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
823
- /** Anything else will be one of these types */
824
- [key: string]: boolean | number | string | object | any[] | null | undefined;
825
- };
826
- /** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
827
- * starting with `ui:`.
828
- */
829
- type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
830
- /** The set of Globally relevant UI Schema options that are read from the root-level UiSchema and stored in the
831
- * Registry for use everywhere.
832
- */
833
- 'ui:globalOptions'?: GlobalUISchemaOptions;
834
- /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
835
- 'ui:rootFieldId'?: string;
836
- /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
837
- * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
838
- */
839
- 'ui:field'?: Field<T, S, F> | string;
840
- /** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
841
- * `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
842
- * related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
843
- * By providing a `true` value for this flag in association with a custom `ui:field`, the wrapped components will be
844
- * omitted, so just one instance of the custom field will be rendered. If the flag is omitted or set to `false`,
845
- * your custom field will be wrapped by `AnyOfField`/`OneOfField`.
846
- */
847
- 'ui:fieldReplacesAnyOrOneOf'?: boolean;
848
- /** An object that contains all the potential UI options in a single object */
849
- 'ui:options'?: UIOptionsType<T, S, F>;
850
- };
851
- /** A `CustomValidator` function takes in a `formData`, `errors` and `uiSchema` objects and returns the given `errors`
852
- * object back, while potentially adding additional messages to the `errors`
853
- */
854
- type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (formData: T | undefined, errors: FormValidation<T>, uiSchema?: UiSchema<T, S, F>) => FormValidation<T>;
855
- /** An `ErrorTransformer` function will take in a list of `errors` & a `uiSchema` and potentially return a
856
- * transformation of those errors in what ever way it deems necessary
857
- */
858
- type ErrorTransformer<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (errors: RJSFValidationError[], uiSchema?: UiSchema<T, S, F>) => RJSFValidationError[];
859
- /** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
860
- type ValidationData<T> = {
861
- /** The validation errors as a list of `RJSFValidationError` objects */
862
- errors: RJSFValidationError[];
863
- /** The validation errors in the form of an `ErrorSchema` */
864
- errorSchema: ErrorSchema<T>;
865
- };
866
- /** The interface that describes the validation functions that are provided by a Validator implementation used by the
867
- * schema utilities.
868
- */
869
- interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
870
- /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
871
- * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
872
- * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
873
- * transform them in what ever way it chooses.
874
- *
875
- * @param formData - The form data to validate
876
- * @param schema - The schema against which to validate the form data
877
- * @param [customValidate] - An optional function that is used to perform custom validation
878
- * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
879
- * @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
880
- */
881
- validateFormData(formData: T | undefined, schema: S, customValidate?: CustomValidator<T, S, F>, transformErrors?: ErrorTransformer<T, S, F>, uiSchema?: UiSchema<T, S, F>): ValidationData<T>;
882
- /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
883
- *
884
- * @param errorSchema - The `ErrorSchema` instance to convert
885
- * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
886
- * @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
887
- * the next major release.
888
- */
889
- toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
890
- /** Validates data against a schema, returning true if the data is valid, or
891
- * false otherwise. If the schema is invalid, then this function will return
892
- * false.
893
- *
894
- * @param schema - The schema against which to validate the form data * @param schema
895
- * @param formData - The form data to validate
896
- * @param rootSchema - The root schema used to provide $ref resolutions
897
- */
898
- isValid(schema: S, formData: T | undefined, rootSchema: S): boolean;
899
- /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
900
- * by the playground. Returns the `errors` from the validation
901
- *
902
- * @param schema - The schema against which to validate the form data
903
- * @param formData - The form data to validate
904
- */
905
- rawValidation<Result = any>(schema: S, formData?: T): {
906
- errors?: Result[];
907
- validationError?: Error;
908
- };
909
- }
910
- /** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
911
- * directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
912
- * the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
913
- * set of APIs to the `@rjsf/core` components and the various themes as well.
914
- */
915
- interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
916
- /** Returns the `ValidatorType` in the `SchemaUtilsType`
917
- *
918
- * @returns - The `ValidatorType`
919
- */
920
- getValidator(): ValidatorType<T, S, F>;
921
- /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
922
- * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
923
- * of a new `SchemaUtilsType` with incomplete properties.
924
- *
925
- * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
926
- * @param rootSchema - The root schema that will be compared against the current one
927
- * @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
928
- * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
929
- */
930
- doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior): boolean;
931
- /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
932
- * computed to have defaults provided in the `schema`.
933
- *
934
- * @param schema - The schema for which the default state is desired
935
- * @param [formData] - The current formData, if any, onto which to provide any missing defaults
936
- * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
937
- * If "excludeObjectChildren", cause undefined values for this object and pass `includeUndefinedValues` as
938
- * false when computing defaults for any nested object properties.
939
- * @returns - The resulting `formData` with all the defaults provided
940
- */
941
- getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean | 'excludeObjectChildren'): T | T[] | undefined;
942
- /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
943
- * should be displayed in a UI.
944
- *
945
- * @param schema - The schema for which the display label flag is desired
946
- * @param [uiSchema] - The UI schema from which to derive potentially displayable information
947
- * @param [globalOptions={}] - The Global UI Schema from which to get any fallback `xxx` options
948
- * @returns - True if the label should be displayed or false if it should not
949
- */
950
- getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): boolean;
951
- /** Determines which of the given `options` provided most closely matches the `formData`.
952
- * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
953
- *
954
- * The closest match is determined using the number of matching properties, and more heavily favors options with
955
- * matching readOnly, default, or const values.
956
- *
957
- * @param formData - The form data associated with the schema
958
- * @param options - The list of options that can be selected from
959
- * @param [selectedOption] - The index of the currently selected option, defaulted to -1 if not specified
960
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
961
- * determine which option is selected
962
- * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match
963
- */
964
- getClosestMatchingOption(formData: T | undefined, options: S[], selectedOption?: number, discriminatorField?: string): number;
965
- /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
966
- * Always returns the first option if there is nothing that matches.
967
- *
968
- * @param formData - The current formData, if any, used to figure out a match
969
- * @param options - The list of options to find a matching options from
970
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
971
- * determine which option is selected
972
- * @returns - The firstindex of the matched option or 0 if none is available
973
- */
974
- getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
975
- /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
976
- * Deprecated, use `getFirstMatchingOption()` instead.
977
- *
978
- * @param formData - The current formData, if any, onto which to provide any missing defaults
979
- * @param options - The list of options to find a matching options from
980
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
981
- * determine which option is selected
982
- * @returns - The index of the matched option or 0 if none is available
983
- * @deprecated
984
- */
985
- getMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
986
- /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
987
- *
988
- * @param schema - The schema for which check for array of files flag is desired
989
- * @param [uiSchema] - The UI schema from which to check the widget
990
- * @returns - True if schema/uiSchema contains an array of files, otherwise false
991
- */
992
- isFilesArray(schema: S, uiSchema?: UiSchema<T, S, F>): boolean;
993
- /** Checks to see if the `schema` combination represents a multi-select
994
- *
995
- * @param schema - The schema for which check for a multi-select flag is desired
996
- * @returns - True if schema contains a multi-select, otherwise false
997
- */
998
- isMultiSelect(schema: S): boolean;
999
- /** Checks to see if the `schema` combination represents a select
1000
- *
1001
- * @param schema - The schema for which check for a select flag is desired
1002
- * @returns - True if schema contains a select, otherwise false
1003
- */
1004
- isSelect(schema: S): boolean;
1005
- /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
1006
- * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1007
- * `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
1008
- * `validationData` is returned.
1009
- *
1010
- * @param validationData - The current `ValidationData` into which to merge the additional errors
1011
- * @param [additionalErrorSchema] - The additional set of errors
1012
- * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided
1013
- * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
1014
- * removed in the next major release.
1015
- */
1016
- mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
1017
- /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
1018
- * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
1019
- * recursive resolution.
1020
- *
1021
- * @param schema - The schema for which retrieving a schema is desired
1022
- * @param [formData] - The current formData, if any, to assist retrieving a schema
1023
- * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1024
- */
1025
- retrieveSchema(schema: S, formData?: T): S;
1026
- /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
1027
- * new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the
1028
- * nature of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the
1029
- * old schema that are non-existent in the new schema are set to `undefined`.
1030
- *
1031
- * @param [newSchema] - The new schema for which the data is being sanitized
1032
- * @param [oldSchema] - The old schema from which the data originated
1033
- * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined
1034
- * @returns - The new form data, with all of the fields uniquely associated with the old schema set
1035
- * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1036
- */
1037
- sanitizeDataForNewSchema(newSchema?: S, oldSchema?: S, data?: any): T;
1038
- /** Generates an `IdSchema` object for the `schema`, recursively
1039
- *
1040
- * @param schema - The schema for which the display label flag is desired
1041
- * @param [id] - The base id for the schema
1042
- * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1043
- * @param [idPrefix='root'] - The prefix to use for the id
1044
- * @param [idSeparator='_'] - The separator to use for the path segments in the id
1045
- * @returns - The `IdSchema` object for the `schema`
1046
- */
1047
- toIdSchema(schema: S, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
1048
- /** Generates an `PathSchema` object for the `schema`, recursively
1049
- *
1050
- * @param schema - The schema for which the display label flag is desired
1051
- * @param [name] - The base name for the schema
1052
- * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1053
- * @returns - The `PathSchema` object for the `schema`
1054
- */
1055
- toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T>;
1056
- }
1057
-
1058
- /** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
1059
- * object. The user is warned in the console if `schema.additionalItems` has the value `true`.
1060
- *
1061
- * @param schema - The schema object to check
1062
- * @returns - True if additional items is allowed, otherwise false
1063
- */
1064
- declare function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
1065
-
1066
- /** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a
1067
- * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be
1068
- * in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned
1069
- * because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by
1070
- * `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.
1071
- *
1072
- * @param value - The string or null value to convert to a number
1073
- * @returns - The `value` converted to a number when appropriate, otherwise the `value`
1074
- */
1075
- declare function asNumber(value: string | null): string | number | null | undefined;
1076
-
1077
- /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
1078
- * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
1079
- * `formData` object doesn't already have `schema.maxProperties` elements.
1080
- *
1081
- * @param schema - The schema for the field that is being checked
1082
- * @param [uiSchema={}] - The uiSchema for the field
1083
- * @param [formData] - The formData for the field
1084
- * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
1085
- */
1086
- declare function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, S, F>, formData?: T): boolean;
1087
-
1088
- /** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it
1089
- *
1090
- * @param formData - The form data around which the error handler is created
1091
- * @returns - A `FormValidation` object based on the `formData` structure
1092
- */
1093
- declare function createErrorHandler<T = any>(formData: T): FormValidation<T>;
1094
-
1095
- /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
1096
- * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
1097
- *
1098
- * @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1099
- * @param rootSchema - The root schema that will be forwarded to all the APIs
1100
- * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
1101
- * @returns - An implementation of a `SchemaUtilsType` interface
1102
- */
1103
- declare function createSchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: {}): SchemaUtilsType<T, S, F>;
1104
-
1105
- /** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
1106
- * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
1107
- *
1108
- * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
1109
- * @returns - an object containing a Blob and its name, extracted from the URI
1110
- */
1111
- declare function dataURItoBlob(dataURI: string): {
1112
- blob: Blob;
1113
- name: string;
1114
- } | {
1115
- blob: {
1116
- size: number;
1117
- type: string;
1118
- };
1119
- name: string;
1120
- };
1121
-
1122
- /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
1123
- * assumes all functions are equivalent.
1124
- *
1125
- * @param a - The first element to compare
1126
- * @param b - The second element to compare
1127
- * @returns - True if the `a` and `b` are deeply equal, false otherwise
1128
- */
1129
- declare function deepEquals(a: any, b: any): boolean;
1130
-
1131
- /** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
1132
- * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
1133
- * `%2`, etc. replacement specifiers.
1134
- *
1135
- * @param stringToTranslate - The `TranslatableString` value to convert to english
1136
- * @param params - The optional list of replaceable parameter values to substitute into the english string
1137
- * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted
1138
- */
1139
- declare function englishStringTranslator(stringToTranslate: TranslatableString, params?: string[]): string;
1140
-
1141
- /** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
1142
- * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
1143
- * a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
1144
- * is returned, otherwise the `selected` value is returned.
1145
- *
1146
- * @param valueIndex - The index of the value to be removed from the selected list or single value
1147
- * @param selected - The current (list of) selected value(s)
1148
- * @param [allEnumOptions=[]] - The list of all the known enumOptions
1149
- * @returns - The updated `selected` with the enum option value at `valueIndex` in `allEnumOptions` removed from it,
1150
- * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns
1151
- * undefined, otherwise `selected`.
1152
- */
1153
- declare function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected?: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
1154
-
1155
- /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
1156
- * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
1157
- * stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is
1158
- * returned.
1159
- *
1160
- * @param value - The single value or list of values for which indexes are desired
1161
- * @param [allEnumOptions=[]] - The list of all the known enumOptions
1162
- * @param [multiple=false] - Optional flag, if true will return a list of index, otherwise a single one
1163
- * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list
1164
- * of indexes for (each of) the value(s) in `value`.
1165
- */
1166
- declare function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[], multiple?: boolean): string | string[] | undefined;
1167
-
1168
- /** Determines whether the given `value` is (one of) the `selected` value(s).
1169
- *
1170
- * @param value - The value being checked to see if it is selected
1171
- * @param selected - The current selected value or list of values
1172
- * @returns - true if the `value` is one of the `selected` ones, false otherwise
1173
- */
1174
- declare function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'], selected: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][]): boolean;
1175
-
1176
- /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
1177
- * `allEnumOptions`
1178
- *
1179
- * @param valueIndex - The index of the value that should be selected
1180
- * @param selected - The current list of selected values
1181
- * @param [allEnumOptions=[]] - The list of all the known enumOptions
1182
- * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it
1183
- */
1184
- declare function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected: EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): any[];
1185
-
1186
- /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
1187
- * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
1188
- * contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only
1189
- * valid values or in the worst case, an empty array.
1190
- *
1191
- * @param valueIndex - The index(es) of the value(s) that should be returned
1192
- * @param [allEnumOptions=[]] - The list of all the known enumOptions
1193
- * @param [emptyValue] - The value to return when the non-array `valueIndex` does not refer to a real option
1194
- * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,
1195
- * `emptyValue` or an empty list.
1196
- */
1197
- declare function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number | Array<string | number>, allEnumOptions?: EnumOptionsType<S>[], emptyValue?: EnumOptionsType<S>['value']): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
1198
-
1199
- /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
1200
- * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
1201
- * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
1202
- * get the result and/or reset all the errors back to an initial set and start again.
1203
- */
1204
- declare class ErrorSchemaBuilder<T = any> {
1205
- /** The error schema being built
1206
- *
1207
- * @private
1208
- */
1209
- private errorSchema;
1210
- /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
1211
- *
1212
- * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1213
- */
1214
- constructor(initialSchema?: ErrorSchema<T>);
1215
- /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`
1216
- */
1217
- get ErrorSchema(): ErrorSchema<T>;
1218
- /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.
1219
- *
1220
- * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1221
- * @returns - The error block for the given `pathOfError` or the root if not provided
1222
- * @private
1223
- */
1224
- private getOrCreateErrorBlock;
1225
- /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.
1226
- *
1227
- * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1228
- * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1229
- */
1230
- resetAllErrors(initialSchema?: ErrorSchema<T>): this;
1231
- /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within
1232
- * the schema described by the `pathOfError`. For more information about how to specify the path see the
1233
- * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1234
- *
1235
- * @param errorOrList - The error or list of errors to add into the `ErrorSchema`
1236
- * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1237
- * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1238
- */
1239
- addErrors(errorOrList: string | string[], pathOfError?: string | string[]): this;
1240
- /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location
1241
- * within the schema described by the `pathOfError`. For more information about how to specify the path see the
1242
- * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1243
- *
1244
- * @param errorOrList - The error or list of errors to set into the `ErrorSchema`
1245
- * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
1246
- * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1247
- */
1248
- setErrors(errorOrList: string | string[], pathOfError?: string | string[]): this;
1249
- /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
1250
- * the `pathOfError`. For more information about how to specify the path see the
1251
- * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1252
- *
1253
- * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
1254
- * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1255
- */
1256
- clearErrors(pathOfError?: string | string[]): this;
1257
- }
1258
-
1259
- /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
1260
- * path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
1261
- * the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
1262
- *
1263
- * @param $ref - The ref string for which the schema definition is desired
1264
- * @param [rootSchema={}] - The root schema in which to search for the definition
1265
- * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
1266
- * @throws - Error indicating that no schema for that reference exists
1267
- */
1268
- declare function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S): S;
1269
-
1270
- /** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
1271
- * it is not a string. Returns `undefined` when a valid discriminator is not present.
1272
- *
1273
- * @param schema - The schema from which the discriminator is potentially obtained
1274
- * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`
1275
- */
1276
- declare function getDiscriminatorFieldFromSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string | undefined;
1277
-
1278
- /** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
1279
- *
1280
- * @param schema - The schema for the field provided by the widget
1281
- * @param [defaultType] - The default type, if any, for the field provided by the widget
1282
- * @param [options={}] - The UI Options for the field provided by the widget
1283
- * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
1284
- * @returns - The extracted `InputPropsType` object
1285
- */
1286
- declare function getInputProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, S, F>, autoDefaultStepAny?: boolean): InputPropsType;
1287
-
1288
- /** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
1289
- * other elements of the schema as follows:
1290
- * - schema.const: Returns the `guessType()` of that value
1291
- * - schema.enum: Returns `string`
1292
- * - schema.properties: Returns `object`
1293
- * - schema.additionalProperties: Returns `object`
1294
- * - type is an array with a length of 2 and one type is 'null': Returns the other type
1295
- *
1296
- * @param schema - The schema for which to get the type
1297
- * @returns - The type of the schema
1298
- */
1299
- declare function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string | string[] | undefined;
1300
-
1301
- /** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
1302
- *
1303
- * @param [uiSchema={}] - the UI Schema from which to extract submit button props
1304
- * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
1305
- */
1306
- declare function getSubmitButtonOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): UISchemaSubmitButtonOptions;
1307
-
1308
- /** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
1309
- * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
1310
- *
1311
- * @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`
1312
- * @param registry - The `Registry` from which to read the template
1313
- * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
1314
- * @returns - The template from either the `uiSchema` or `registry` for the `name`
1315
- */
1316
- declare function getTemplate<Name extends keyof TemplatesType<T, S, F>, T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(name: Name, registry: Registry<T, S, F>, uiOptions?: UIOptionsType<T, S, F>): TemplatesType<T, S, F>[Name];
1317
-
1318
- /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
1319
- * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
1320
- *
1321
- * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
1322
- * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1323
- * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
1324
- */
1325
- declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): UIOptionsType<T, S, F>;
1326
-
1327
- /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
1328
- * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
1329
- * with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based
1330
- * on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.
1331
- *
1332
- * @param schema - The schema for the field
1333
- * @param [widget] - Either the name of the widget OR a `Widget` implementation to use
1334
- * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
1335
- * @returns - The `Widget` component to use
1336
- * @throws - An error if there is no `Widget` component that can be returned
1337
- */
1338
- declare function getWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, widget?: Widget<T, S, F> | string, registeredWidgets?: RegistryWidgetsType<T, S, F>): Widget<T, S, F>;
1339
-
1340
- /** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly
1341
- * create a schema, it is useful to know what type to use based on the data we are defining.
1342
- *
1343
- * @param value - The value from which to guess the type
1344
- * @returns - The best guess for the object type
1345
- */
1346
- declare function guessType(value: any): "array" | "string" | "null" | "boolean" | "number" | "object";
1347
-
1348
- /** Stringifies the schema and returns the hash of the resulting string. Sorts schema fields
1349
- * in consistent order before stringify to prevent different hash ids for the same schema.
1350
- *
1351
- * @param schema - The schema for which the hash is desired
1352
- * @returns - The string obtained from the hash of the stringified schema
1353
- */
1354
- declare function hashForSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string;
1355
-
1356
- /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
1357
- * does, or false if it doesn't.
1358
- *
1359
- * @param schema - The schema for the field
1360
- * @param widget - Either the name of the widget OR a `Widget` implementation to use
1361
- * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
1362
- * @returns - True if the widget exists, false otherwise
1363
- */
1364
- declare function hasWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, widget: Widget<T, S, F> | string, registeredWidgets?: RegistryWidgetsType<T, S, F>): boolean;
1365
-
1366
- /** Return a consistent `id` for the field description element
1367
- *
1368
- * @param id - Either simple string id or an IdSchema from which to extract it
1369
- * @returns - The consistent id for the field description element from the given `id`
1370
- */
1371
- declare function descriptionId<T = any>(id: IdSchema<T> | string): string;
1372
- /** Return a consistent `id` for the field error element
1373
- *
1374
- * @param id - Either simple string id or an IdSchema from which to extract it
1375
- * @returns - The consistent id for the field error element from the given `id`
1376
- */
1377
- declare function errorId<T = any>(id: IdSchema<T> | string): string;
1378
- /** Return a consistent `id` for the field examples element
1379
- *
1380
- * @param id - Either simple string id or an IdSchema from which to extract it
1381
- * @returns - The consistent id for the field examples element from the given `id`
1382
- */
1383
- declare function examplesId<T = any>(id: IdSchema<T> | string): string;
1384
- /** Return a consistent `id` for the field help element
1385
- *
1386
- * @param id - Either simple string id or an IdSchema from which to extract it
1387
- * @returns - The consistent id for the field help element from the given `id`
1388
- */
1389
- declare function helpId<T = any>(id: IdSchema<T> | string): string;
1390
- /** Return a consistent `id` for the field title element
1391
- *
1392
- * @param id - Either simple string id or an IdSchema from which to extract it
1393
- * @returns - The consistent id for the field title element from the given `id`
1394
- */
1395
- declare function titleId<T = any>(id: IdSchema<T> | string): string;
1396
- /** Return a list of element ids that contain additional information about the field that can be used to as the aria
1397
- * description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
1398
- * element.
1399
- *
1400
- * @param id - Either simple string id or an IdSchema from which to extract it
1401
- * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
1402
- * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
1403
- */
1404
- declare function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, includeExamples?: boolean): string;
1405
- /** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget
1406
- *
1407
- * @param id - The id of the parent component for the option
1408
- * @param optionIndex - The index of the option for which the id is desired
1409
- * @returns - An id for the option index based on the parent `id`
1410
- */
1411
- declare function optionId(id: string, optionIndex: number): string;
1412
-
1413
- /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
1414
- * an `enum` array with a single value or there is a `const` defined.
1415
- *
1416
- * @param schema - The schema for a field
1417
- * @returns - True if the `schema` has a single constant value, false otherwise
1418
- */
1419
- declare function isConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
1420
-
1421
- /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
1422
- *
1423
- * @param uiSchema - The UI Schema from which to detect if it is customized
1424
- * @returns - True if the `uiSchema` describes a custom widget, false otherwise
1425
- */
1426
- declare function isCustomWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): boolean;
1427
-
1428
- /** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
1429
- * that only contains objects.
1430
- *
1431
- * @param schema - The schema in which to check for fixed items
1432
- * @returns - True if there are fixed items in the schema, false otherwise
1433
- */
1434
- declare function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
1435
-
1436
- /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
1437
- * the type `object` but is NOT null, an array or a File.
1438
- *
1439
- * @param thing - The thing to check to see whether it is an object
1440
- * @returns - True if it is a non-null, non-array, non-File object
1441
- */
1442
- declare function isObject(thing: any): boolean;
1443
-
1444
- /** Helper function that will return the value to use for a widget `label` based on `hideLabel`. The `fallback` is used
1445
- * as the return value from the function when `hideLabel` is true. Due to the implementation of theme components, it
1446
- * may be necessary to return something other than `undefined` to cause the theme component to not render a label. Some
1447
- * themes require may `false` and others may require an empty string.
1448
- *
1449
- * @param [label] - The label string or component to render when not hidden
1450
- * @param [hideLabel] - Flag, if true, will cause the label to be hidden
1451
- * @param [fallback] - One of 3 values, `undefined` (the default), `false` or an empty string
1452
- * @returns - `fallback` if `hideLabel` is true, otherwise `label`
1453
- */
1454
- declare function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: ''): undefined | string;
1455
- declare function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: false | ''): string | false | ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
1456
-
1457
- /** Converts a local Date string into a UTC date string
1458
- *
1459
- * @param dateString - The string representation of a date as accepted by the `Date()` constructor
1460
- * @returns - A UTC date string if `dateString` is truthy, otherwise undefined
1461
- */
1462
- declare function localToUTC(dateString: string): string | undefined;
1463
-
1464
- /** Merges the `defaults` object of type `T` into the `formData` of type `T`
1465
- *
1466
- * When merging defaults and form data, we want to merge in this specific way:
1467
- * - objects are deeply merged
1468
- * - arrays are merged in such a way that:
1469
- * - when the array is set in form data, only array entries set in form data
1470
- * are deeply merged; additional entries from the defaults are ignored unless `mergeExtraArrayDefaults` is true, in
1471
- * which case the extras are appended onto the end of the form data
1472
- * - when the array is not set in form data, the default is copied over
1473
- * - scalars are overwritten/set by form data
1474
- *
1475
- * @param [defaults] - The defaults to merge
1476
- * @param [formData] - The form data into which the defaults will be merged
1477
- * @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData
1478
- * @returns - The resulting merged form data with defaults
1479
- */
1480
- declare function mergeDefaultsWithFormData<T = any>(defaults?: T, formData?: T, mergeExtraArrayDefaults?: boolean): T | undefined;
1481
-
1482
- /** Recursively merge deeply nested objects.
1483
- *
1484
- * @param obj1 - The first object to merge
1485
- * @param obj2 - The second object to merge
1486
- * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use
1487
- * "preventDuplicates" to merge arrays in a manner that prevents any duplicate entries from being merged.
1488
- * NOTE: Uses shallow comparison for the duplicate checking.
1489
- * @returns - A new object that is the merge of the two given objects
1490
- */
1491
- declare function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean | 'preventDuplicates'): GenericObjectType;
1492
-
1493
- /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
1494
- * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
1495
- * duplicate values.
1496
- *
1497
- * @param obj1 - The first schema object to merge
1498
- * @param obj2 - The second schema object to merge
1499
- * @returns - The merged schema object
1500
- */
1501
- declare function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType): GenericObjectType;
1502
-
1503
- /** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
1504
- * labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
1505
- * the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
1506
- * `const` values from the schema and the label is either the `schema.title` or the value.
1507
- *
1508
- * @param schema - The schema from which to extract the options list
1509
- * @returns - The list of options from the schema
1510
- */
1511
- declare function optionsList<S extends StrictRJSFSchema = RJSFSchema>(schema: S): EnumOptionsType<S>[] | undefined;
1512
-
1513
- /** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
1514
- * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
1515
- * the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be
1516
- * places in the location of the `*`.
1517
- *
1518
- * @param properties - The list of property keys to be ordered
1519
- * @param order - An array of property keys to be ordered first, with an optional '*' property
1520
- * @returns - A list with the `properties` ordered
1521
- * @throws - Error when the properties cannot be ordered correctly
1522
- */
1523
- declare function orderProperties(properties: string[], order?: string[]): string[];
1524
-
1525
- /** Returns a string representation of the `num` that is padded with leading "0"s if necessary
1526
- *
1527
- * @param num - The number to pad
1528
- * @param width - The width of the string at which no lead padding is necessary
1529
- * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
1530
- */
1531
- declare function pad(num: number, width: number): string;
1532
-
1533
- /** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true
1534
- *
1535
- * @param dateString - The date string to parse into a DateObject
1536
- * @param [includeTime=true] - Optional flag, if false, will not include the time data into the object
1537
- * @returns - The date string converted to a `DateObject`
1538
- * @throws - Error when the date cannot be parsed from the string
1539
- */
1540
- declare function parseDateString(dateString?: string, includeTime?: boolean): DateObject;
1541
-
1542
- /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
1543
- * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
1544
- *
1545
- * @param schema - The schema from which to extract the range spec
1546
- * @returns - A range specification from the schema
1547
- */
1548
- declare function rangeSpec<S extends StrictRJSFSchema = RJSFSchema>(schema: S): RangeSpecType;
1549
-
1550
- /** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When
1551
- * a `params` array is provided, each value in the array is used to replace any of the replaceable parameters in the
1552
- * `inputString` using the `%1`, `%2`, etc. replacement specifiers.
1553
- *
1554
- * @param inputString - The string which will be potentially updated with replacement parameters
1555
- * @param params - The optional list of replaceable parameter values to substitute into the english string
1556
- * @returns - The updated string with any replacement specifiers replaced
1557
- */
1558
- declare function replaceStringParameters(inputString: string, params?: string[]): string;
1559
-
1560
- /** Check to see if a `schema` specifies that a value must be true. This happens when:
1561
- * - `schema.const` is truthy
1562
- * - `schema.enum` == `[true]`
1563
- * - `schema.anyOf` or `schema.oneOf` has a single value which recursively returns true
1564
- * - `schema.allOf` has at least one value which recursively returns true
1565
- *
1566
- * @param schema - The schema to check
1567
- * @returns - True if the schema specifies a value that must be true, false otherwise
1568
- */
1569
- declare function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
1570
-
1571
- /** Determines whether the given `component` should be rerendered by comparing its current set of props and state
1572
- * against the next set. If either of those two sets are not the same, then the component should be rerendered.
1573
- *
1574
- * @param component - A React component being checked
1575
- * @param nextProps - The next set of props against which to check
1576
- * @param nextState - The next set of state against which to check
1577
- * @returns - True if the component should be re-rendered, false otherwise
1578
- */
1579
- declare function shouldRender(component: react__default.Component, nextProps: any, nextState: any): boolean;
1580
-
1581
- /** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
1582
- * throws an error.
1583
- *
1584
- * @param schema - The schema from which to obtain the constant value
1585
- * @returns - The constant value for the schema
1586
- * @throws - Error when the schema does not have a constant value
1587
- */
1588
- declare function toConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S): json_schema.JSONSchema7Type | undefined;
1589
-
1590
- /** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is
1591
- * removed.
1592
- *
1593
- * @param dateObject - The `DateObject` to convert to a date string
1594
- * @param [time=true] - Optional flag used to remove the time portion of the date string if false
1595
- * @returns - The UTC date string
1596
- */
1597
- declare function toDateString(dateObject: DateObject, time?: boolean): string;
1598
-
1599
- /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
1600
- *
1601
- * @param errorSchema - The `ErrorSchema` instance to convert
1602
- * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
1603
- * @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`
1604
- */
1605
- declare function toErrorList<T = any>(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
1606
-
1607
- /** Transforms a rjsf validation errors list:
1608
- * [
1609
- * {property: '.level1.level2[2].level3', message: 'err a'},
1610
- * {property: '.level1.level2[2].level3', message: 'err b'},
1611
- * {property: '.level1.level2[4].level3', message: 'err b'},
1612
- * ]
1613
- * Into an error tree:
1614
- * {
1615
- * level1: {
1616
- * level2: {
1617
- * 2: {level3: {errors: ['err a', 'err b']}},
1618
- * 4: {level3: {errors: ['err b']}},
1619
- * }
1620
- * }
1621
- * };
1622
- *
1623
- * @param errors - The list of RJSFValidationError objects
1624
- * @returns - The `ErrorSchema` built from the list of `RJSFValidationErrors`
1625
- */
1626
- declare function toErrorSchema<T = any>(errors: RJSFValidationError[]): ErrorSchema<T>;
1627
-
1628
- /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
1629
- *
1630
- * @param errorHandler - The `FormValidation` error handling structure
1631
- * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
1632
- */
1633
- declare function unwrapErrorHandler<T = any>(errorHandler: FormValidation<T>): ErrorSchema<T>;
1634
-
1635
- /** Converts a UTC date string into a local Date format
1636
- *
1637
- * @param jsonDate - A UTC date string
1638
- * @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format
1639
- */
1640
- declare function utcToLocal(jsonDate: string): string;
1641
-
1642
- /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
1643
- * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1644
- * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
1645
- * `validationData` is returned.
1646
- *
1647
- * @param validationData - The current `ValidationData` into which to merge the additional errors
1648
- * @param [additionalErrorSchema] - The optional additional set of errors in an `ErrorSchema`
1649
- * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1650
- */
1651
- declare function validationDataMerge<T = any>(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
1652
-
1653
- /** Recursively prefixes all `$ref`s in a schema with the value of the `ROOT_SCHEMA_PREFIX` constant.
1654
- * This is used in isValid to make references to the rootSchema
1655
- *
1656
- * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
1657
- * @returns - A copy of the `schemaNode` with updated `$ref`s
1658
- */
1659
- declare function withIdRefPrefix<S extends StrictRJSFSchema = RJSFSchema>(schemaNode: S): S | S[];
1660
-
1661
- /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
1662
- * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
1663
- * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
1664
- * utility.
1665
- */
1666
- declare const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
1667
- declare const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
1668
- declare const ALL_OF_KEY = "allOf";
1669
- declare const ANY_OF_KEY = "anyOf";
1670
- declare const CONST_KEY = "const";
1671
- declare const DEFAULT_KEY = "default";
1672
- declare const DEFINITIONS_KEY = "definitions";
1673
- declare const DEPENDENCIES_KEY = "dependencies";
1674
- declare const ENUM_KEY = "enum";
1675
- declare const ERRORS_KEY = "__errors";
1676
- declare const ID_KEY = "$id";
1677
- declare const IF_KEY = "if";
1678
- declare const ITEMS_KEY = "items";
1679
- declare const JUNK_OPTION_ID = "_$junk_option_schema_id$_";
1680
- declare const NAME_KEY = "$name";
1681
- declare const ONE_OF_KEY = "oneOf";
1682
- declare const PROPERTIES_KEY = "properties";
1683
- declare const REQUIRED_KEY = "required";
1684
- declare const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
1685
- declare const REF_KEY = "$ref";
1686
- declare const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
1687
- declare const ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";
1688
- declare const UI_FIELD_KEY = "ui:field";
1689
- declare const UI_WIDGET_KEY = "ui:widget";
1690
- declare const UI_OPTIONS_KEY = "ui:options";
1691
- declare const UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
1692
-
1693
- /** The type of the map of schema hash to schema
1694
- */
1695
- type SchemaMap<S extends StrictRJSFSchema = RJSFSchema> = {
1696
- [hash: string]: S;
1697
- };
1698
-
1699
- /** Parses the given `rootSchema` to extract out all the sub-schemas that maybe contained within it. Returns a map of
1700
- * the hash of the schema to schema/sub-schema.
1701
- *
1702
- * @param rootSchema - The root schema to parse for sub-schemas used by `isValid()` calls
1703
- * @returns - The `SchemaMap` of all schemas that were parsed
1704
- */
1705
- declare function schemaParser<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(rootSchema: S): SchemaMap<S>;
1706
-
1707
- /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1708
- * computed to have defaults provided in the `schema`.
1709
- *
1710
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1711
- * @param theSchema - The schema for which the default state is desired
1712
- * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1713
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1714
- * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
1715
- * If "excludeObjectChildren", cause undefined values for this object and pass `includeUndefinedValues` as
1716
- * false when computing defaults for any nested object properties.
1717
- * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
1718
- * @returns - The resulting `formData` with all the defaults provided
1719
- */
1720
- declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean | 'excludeObjectChildren', experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior): T | T[] | undefined;
1721
-
1722
- /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1723
- * should be displayed in a UI.
1724
- *
1725
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1726
- * @param schema - The schema for which the display label flag is desired
1727
- * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
1728
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1729
- * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1730
- * @returns - True if the label should be displayed or false if it should not
1731
- */
1732
- declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S, globalOptions?: GlobalUISchemaOptions): boolean;
1733
-
1734
- /** Determines which of the given `options` provided most closely matches the `formData`. Using
1735
- * `getFirstMatchingOption()` to match two schemas that differ only by the readOnly, default or const value of a field
1736
- * based on the `formData` and returns 0 when there is no match. Rather than passing in all the `options` at once to
1737
- * this utility, instead an array of valid option indexes is created by iterating over the list of options, call
1738
- * `getFirstMatchingOptions` with a list of one junk option and one good option, seeing if the good option is considered
1739
- * matched.
1740
- *
1741
- * Once the list of valid indexes is created, if there is only one valid index, just return it. Otherwise, if there are
1742
- * no valid indexes, then fill the valid indexes array with the indexes of all the options. Next, the index of the
1743
- * option with the highest score is determined by iterating over the list of valid options, calling
1744
- * `calculateIndexScore()` on each, comparing it against the current best score, and returning the index of the one that
1745
- * eventually has the best score.
1746
- *
1747
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1748
- * @param rootSchema - The root JSON schema of the entire form
1749
- * @param formData - The form data associated with the schema
1750
- * @param options - The list of options that can be selected from
1751
- * @param [selectedOption=-1] - The index of the currently selected option, defaulted to -1 if not specified
1752
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1753
- * determine which option is selected
1754
- * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match
1755
- */
1756
- declare function getClosestMatchingOption<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, formData: T | undefined, options: S[], selectedOption?: number, discriminatorField?: string): number;
1757
-
1758
- /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
1759
- * Always returns the first option if there is nothing that matches.
1760
- *
1761
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1762
- * @param formData - The current formData, if any, used to figure out a match
1763
- * @param options - The list of options to find a matching options from
1764
- * @param rootSchema - The root schema, used to primarily to look up `$ref`s
1765
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1766
- * determine which option is selected
1767
- * @returns - The index of the first matched option or 0 if none is available
1768
- */
1769
- declare function getFirstMatchingOption<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, formData: T | undefined, options: S[], rootSchema: S, discriminatorField?: string): number;
1770
-
1771
- /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
1772
- * Deprecated, use `getFirstMatchingOption()` instead.
1773
- *
1774
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1775
- * @param formData - The current formData, if any, used to figure out a match
1776
- * @param options - The list of options to find a matching options from
1777
- * @param rootSchema - The root schema, used to primarily to look up `$ref`s
1778
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
1779
- * determine which option is selected
1780
- * @returns - The index of the matched option or 0 if none is available
1781
- * @deprecated
1782
- */
1783
- declare function getMatchingOption<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, formData: T | undefined, options: S[], rootSchema: S, discriminatorField?: string): number;
1784
-
1785
- /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1786
- *
1787
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1788
- * @param schema - The schema for which check for array of files flag is desired
1789
- * @param [uiSchema={}] - The UI schema from which to check the widget
1790
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1791
- * @returns - True if schema/uiSchema contains an array of files, otherwise false
1792
- */
1793
- declare function isFilesArray<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S): boolean;
1794
-
1795
- /** Checks to see if the `schema` combination represents a multi-select
1796
- *
1797
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1798
- * @param schema - The schema for which check for a multi-select flag is desired
1799
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1800
- * @returns - True if schema contains a multi-select, otherwise false
1801
- */
1802
- declare function isMultiSelect<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, rootSchema?: S): boolean;
1803
-
1804
- /** Checks to see if the `schema` combination represents a select
1805
- *
1806
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1807
- * @param theSchema - The schema for which check for a select flag is desired
1808
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1809
- * @returns - True if schema contains a select, otherwise false
1810
- */
1811
- declare function isSelect<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, rootSchema?: S): boolean;
1812
-
1813
- /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
1814
- * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1815
- * `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
1816
- * `validationData` is returned.
1817
- *
1818
- * @param validator - The validator used to convert an ErrorSchema to a list of errors
1819
- * @param validationData - The current `ValidationData` into which to merge the additional errors
1820
- * @param [additionalErrorSchema] - The additional set of errors in an `ErrorSchema`
1821
- * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1822
- * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
1823
- * removed in the next major release.
1824
- */
1825
- declare function mergeValidationData<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
1826
-
1827
- /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
1828
- * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
1829
- * potentially recursive resolution.
1830
- *
1831
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1832
- * @param schema - The schema for which retrieving a schema is desired
1833
- * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
1834
- * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1835
- * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1836
- */
1837
- declare function retrieveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, rootSchema?: S, rawFormData?: T): S;
1838
-
1839
- /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new
1840
- * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature
1841
- * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema
1842
- * that are non-existent in the new schema are set to `undefined`. The data sanitization process has the following flow:
1843
- *
1844
- * - If the new schema is an object that contains a `properties` object then:
1845
- * - Create a `removeOldSchemaData` object, setting each key in the `oldSchema.properties` having `data` to undefined
1846
- * - Create an empty `nestedData` object for use in the key filtering below:
1847
- * - Iterate over each key in the `newSchema.properties` as follows:
1848
- * - Get the `formValue` of the key from the `data`
1849
- * - Get the `oldKeySchema` and `newKeyedSchema` for the key, defaulting to `{}` when it doesn't exist
1850
- * - Retrieve the schema for any refs within each `oldKeySchema` and/or `newKeySchema`
1851
- * - Get the types of the old and new keyed schemas and if the old doesn't exist or the old & new are the same then:
1852
- * - If `removeOldSchemaData` has an entry for the key, delete it since the new schema has the same property
1853
- * - If type of the key in the new schema is `object`:
1854
- * - Store the value from the recursive `sanitizeDataForNewSchema` call in `nestedData[key]`
1855
- * - Otherwise, check for default or const values:
1856
- * - Get the old and new `default` values from the schema and check:
1857
- * - If the new `default` value does not match the form value:
1858
- * - If the old `default` value DOES match the form value, then:
1859
- * - Replace `removeOldSchemaData[key]` with the new `default`
1860
- * - Otherwise, if the new schema is `readOnly` then replace `removeOldSchemaData[key]` with undefined
1861
- * - Get the old and new `const` values from the schema and check:
1862
- * - If the new `const` value does not match the form value:
1863
- * - If the old `const` value DOES match the form value, then:
1864
- * - Replace `removeOldSchemaData[key]` with the new `const`
1865
- * - Otherwise, replace `removeOldSchemaData[key]` with undefined
1866
- * - Once all keys have been processed, return an object built as follows:
1867
- * - `{ ...removeOldSchemaData, ...nestedData, ...pick(data, keysToKeep) }`
1868
- * - If the new and old schema types are array and the `data` is an array then:
1869
- * - If the type of the old and new schema `items` are a non-array objects:
1870
- * - Retrieve the schema for any refs within each `oldKeySchema.items` and/or `newKeySchema.items`
1871
- * - If the `type`s of both items are the same (or the old does not have a type):
1872
- * - If the type is "object", then:
1873
- * - For each element in the `data` recursively sanitize the data, stopping at `maxItems` if specified
1874
- * - Otherwise, just return the `data` removing any values after `maxItems` if it is set
1875
- * - If the type of the old and new schema `items` are booleans of the same value, return `data` as is
1876
- * - Otherwise return `undefined`
1877
- *
1878
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1879
- * @param rootSchema - The root JSON schema of the entire form
1880
- * @param [newSchema] - The new schema for which the data is being sanitized
1881
- * @param [oldSchema] - The old schema from which the data originated
1882
- * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined
1883
- * @returns - The new form data, with all the fields uniquely associated with the old schema set
1884
- * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1885
- */
1886
- declare function sanitizeDataForNewSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, newSchema?: S, oldSchema?: S, data?: any): T;
1887
-
1888
- /** Generates an `IdSchema` object for the `schema`, recursively
1889
- *
1890
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1891
- * @param schema - The schema for which the `IdSchema` is desired
1892
- * @param [id] - The base id for the schema
1893
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1894
- * @param [formData] - The current formData, if any, to assist retrieving a schema
1895
- * @param [idPrefix='root'] - The prefix to use for the id
1896
- * @param [idSeparator='_'] - The separator to use for the path segments in the id
1897
- * @returns - The `IdSchema` object for the `schema`
1898
- */
1899
- declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, id?: string | null, rootSchema?: S, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
1900
-
1901
- /** Generates an `PathSchema` object for the `schema`, recursively
1902
- *
1903
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1904
- * @param schema - The schema for which the `PathSchema` is desired
1905
- * @param [name=''] - The base name for the schema
1906
- * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1907
- * @param [formData] - The current formData, if any, to assist retrieving a schema
1908
- * @returns - The `PathSchema` object for the `schema`
1909
- */
1910
- declare function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, name?: string, rootSchema?: S, formData?: T): PathSchema<T>;
1911
-
1912
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, BaseInputTemplateProps, CONST_KEY, CustomValidator, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, DateObject, DescriptionFieldProps, ENUM_KEY, ERRORS_KEY, EnumOptionsType, ErrorListProps, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, Experimental_ArrayMinItems, Experimental_DefaultFormStateBehavior, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormContextType, FormValidation, GenericObjectType, GlobalUISchemaOptions, ID_KEY, IF_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, JUNK_OPTION_ID, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, ROOT_SCHEMA_PREFIX, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaMap, SchemaUtilsType, StrictRJSFSchema, SubmitButtonProps, TemplatesType, TitleFieldProps, TranslatableString, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDiscriminatorFieldFromSchema, getDisplayLabel, getFirstMatchingOption, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaParser, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toIdSchema, toPathSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix };