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